summaryrefslogtreecommitdiff
path: root/lib/editor/editor.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/editor/editor.tcl')
-rw-r--r--[-rwxr-xr-x]lib/editor/editor.tcl652
1 files changed, 380 insertions, 272 deletions
diff --git a/lib/editor/editor.tcl b/lib/editor/editor.tcl
index d4d9bec..e375386 100755..100644
--- a/lib/editor/editor.tcl
+++ b/lib/editor/editor.tcl
@@ -2,7 +2,7 @@
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2007-2009 by Martin Ošmera #
+# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
# This program is free software; you can redistribute it and#or modify #
@@ -21,6 +21,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _EDITOR_TCL ] } {
+set _EDITOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements source code editor with syntax highligh and
@@ -46,23 +51,6 @@ source "${::LIB_DIRNAME}/editor/LSTsyntaxhighlight.tcl"
set ::editor_search_count 0
class Editor {
-
- # Load procedures related to editor command line
- source "${::LIB_DIRNAME}/editor/commandline.tcl"
-
- # Load procedures related to exports to other data formats
- source "${::LIB_DIRNAME}/editor/exports.tcl"
-
- # Load autocompletion related procedures
- source "${::LIB_DIRNAME}/editor/autocompletion.tcl"
-
- # Load general purpose procedures
- source "${::LIB_DIRNAME}/editor/generalproc.tcl"
-
- # Load event handlers
- source "${::LIB_DIRNAME}/editor/eventhandlers.tcl"
-
-
## COMMON
## Editor to use
# 0 - Native editor
@@ -118,32 +106,36 @@ class Editor {
{tag_simulator_curr #AAFFAA}
{tag_error_line #FFDDDD}
{tag_trailing_space #E8FFF0}
+ {tag_breakpoint_INVALID #888888}
}
# Font for command line: Normal help window text
- common cl_hw_nrml_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
+ common cl_hw_nrml_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
]
# Font for command line: Bold help window text
- common cl_hw_bold_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- -weight bold \
+ common cl_hw_bold_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
]
# Font for command line: Subheader in help window text
- common cl_hw_hdr_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- -weight bold \
+ common cl_hw_hdr_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
]
# Font for command line: Main header in help window text
- common cmd_line_win_font [font create \
- -size -17 -weight bold \
- -family {helvetica} \
+ common cmd_line_win_font [font create \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica} \
]
- common cmd_line_fontSize 14 ;# Font size for command line
- common cmd_line_fontFamily $::DEFAULT_FIXED_FONT ;# Font family for command line
+ # Font size for command line
+ common cmd_line_fontSize [expr {int(14 * $::font_size_factor)}]
+ # Font family for command line
+ common cmd_line_fontFamily $::DEFAULT_FIXED_FONT
# Font for editor command line
common cmd_line_font [font create \
-family $cmd_line_fontFamily \
@@ -174,8 +166,13 @@ class Editor {
Unindent Uppercase Lowercase Capitalize
}
- common fontSize 13 ;# Default font size
- common fontFamily $::DEFAULT_FIXED_FONT ;# Default font family
+ # Maximum width of the tab character, measured in number of spaces
+ common tab_width 8
+
+ # Default font size
+ common fontSize [expr {int(13 * $::font_size_factor)}]
+ # Default font family
+ common fontFamily $::DEFAULT_FIXED_FONT
# Default font for editor
common defaultFont \
@@ -193,17 +190,17 @@ class Editor {
common defaultCharWidth 0 ;# Width of one character of the default font
common defaultCharHeight 0 ;# Height of one character of the default font
# Font for status bar (Normal)
- common statusBarFont \
- [font create \
- -size -12 \
- -family $::DEFAULT_FIXED_FONT \
+ common statusBarFont \
+ [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family $::DEFAULT_FIXED_FONT \
]
# Font for status bar (Bold)
- common statusBarBoldFont \
- [font create \
- -size -12 \
- -weight bold \
- -family $::DEFAULT_FIXED_FONT \
+ common statusBarBoldFont \
+ [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ -family $::DEFAULT_FIXED_FONT \
]
# Definition of editor popup menu
common EDITORMENU {
@@ -257,17 +254,17 @@ class Editor {
{checkbutton "Bookmark" {$edit:bookmark} {::Editor::bookmark} 1 0 0
{Bookmark ${::Editor::pmenu_cline}}}
{separator}
- {command "Configure panel" "" 0 {configDialogs_mkDialog Colors}
+ {command "Configure panel" "" 0 {configDialogues_mkDialog Colors}
{configure} "Invoke editor configuration dialog"}
{command "Hide" "" 0 {show_hine_IconB}
{2leftarrow} "Hide this panel"}
}
# Definition of popup menu for line numbers
common LNMENU {
- {checkbutton "Breakpont" {$edit:breakpoint} {::Editor::breakpoint} 1 0 0
+ {checkbutton "Breakpoint" {$edit:breakpoint} {::Editor::breakpoint} 1 0 0
{Breakpoint ${::Editor::pmenu_cline}}}
{separator}
- {command "Configure panel" "" 0 {configDialogs_mkDialog Colors}
+ {command "Configure panel" "" 0 {configDialogues_mkDialog Colors}
{configure} "Invoke editor configuration dialog"}
{command "Hide panel" "" 0 {show_hine_LineN}
{2leftarrow} "Hide this panel"}
@@ -283,7 +280,7 @@ class Editor {
{view_remove} ""}
{separator}
{command "Back" {$edit:prev} 0 {__prev_editor_from_pmenu}
- {left} "Go to prevoius file in the file list"}
+ {left} "Go to previous file in the file list"}
{command "Forward" {$edit:next} 0 {__next_editor_from_pmenu}
{right} "Go to next file in the file list"}
}
@@ -292,11 +289,11 @@ class Editor {
public variable editor ;# text widget identifier
public variable ed_sc_frame ;# frame identifier (need packing)
public variable show_iconBorder 1 ;# on/off indicator for Icon Border (bool)
- public variable show_lineNum 1 ;# on/off indicator for Line NUmbers (bool)
+ public variable show_lineNum 1 ;# on/off indicator for Line Numbers (bool)
public variable iconBorder ;# Identifier of Icon Border text widget
public variable lineNumbers ;# Identifier of Line Numbers text widget
public variable scrollbar ;# Identifier of scrollbar widget
- public variable lastEnd 1 ;# Last end index of Edior text widget (for speed optimalization)
+ public variable lastEnd 2 ;# Last end index of Editor text widget (for speed optimization)
public variable Sbar_lock_file ;# Identifier of image label widget at the left site of status bar
public variable Sbar_sim_mode ;# Identifier of label widget at the left site of status bar
public variable Sbar_ssim_mode
@@ -307,7 +304,7 @@ class Editor {
public variable Sbar_total ;# ID of label showing total number of lines
public variable Sbar_image ;# Identifier of floppy disk icon at the middle site of status bar
public variable Sbar_fileName ;# Identifier of the text of filename at the right site of status bar
- public variable Sbar_prog_lang ;# ID of text specifing file type at the right site of status bar
+ public variable Sbar_prog_lang ;# ID of text specifying file type at the right site of status bar
public variable fullFileName ;# Full file name of the current file ("" == untitled)
public variable filename ;# Name of currently opened file or 'untitled'
public variable modified 0 ;# Boolean value indicating than the text has been modified since last save
@@ -316,6 +313,7 @@ class Editor {
public variable ro_mode 0 ;# Bool: Read only mode
## PRIVATE
+ private variable file_change_notif_flg 0 ;# Bool: The opened file was modified on disk by another program
private variable finishigh_hg_dlg_wdg {} ;# Widget: Finishing highlight dialog
private variable finishigh_hg_dlg_tmr {} ;# Timer: Finishing highlight dialog
private variable object_initialized 0 ;# Bool: Flag "Object initialized"
@@ -335,7 +333,7 @@ class Editor {
private variable left_frame_L ;# ID of frame containing Line Numbers
private variable left_frame_R ;# ID of frame containing Icon Border
private variable LN_menu ;# Identifier of popup menu for line numbers
- private variable frozen 0 ;# True if editor is in simulator mode
+ private variable frozen 0 ;# Bool: True if the editor is in simulator mode
private variable getDataAsXHTML_abort 0 ;# Set this variable to 1 to immediate stop export to XHTML
private variable getDataAsLaTeX_abort 0 ;# Set this variable to 1 to immediate stop export to LaTeX
private variable changeLCase_abort 0 ;# Set this variable to 1 to immediate stop changing letter case
@@ -356,7 +354,7 @@ class Editor {
private variable autosave_timer {} ;# ID of autosave timer (command "after")
private variable key_handler_buffer {} ;# List: Buffer for <Key> event handler
private variable key_handler_in_progress 0 ;# Bool: <Key> event handler in progress
- private variable statusbar_menu_config {} ;# List: Statusbra menu configuration list
+ private variable statusbar_menu_config {} ;# List: Status bar menu configuration list
private variable auto_switching_lock 0 ;# Bool: Automatic file switching enabled
private variable selection_in_progress 0 ;# Bool: Procedure "editor_selection" in progress
private variable selection_mode 0 ;# Bool: Block selection mode flag
@@ -373,49 +371,32 @@ class Editor {
private variable top_frame_idx 0 ;# Int: Unique number of container frame for embedded editor
private variable pid {} ;# Int: Process indentifier of embedded external editor (e.g. Vim)
- ## Array: Strings avaliable for autocompletion
- # Index 0 - Labels in assembly
- # Index 1 - Constants/variables
- # Index 2 - C variables
- # Index 3 - Macros
- # Index 4 - SFR's
- # Index 5 - Expression symbols
- # Index 6 - Doxygen tags
- # Index 7 - C Functions
- common invoke_com_win_in_p 0 ;# Bool: invoke_completion_popup_window in progress
- common completion_win_opened 0 ;# Bool: Editor popup-based completion window opended
- private variable autocompletion_list
- private variable completion_win_str_i 1.0 ;# TextIndex: String to complete - start index
- private variable completion_win_end_i 1.0 ;# TextIndex: String to complete - end index
- private variable completion_win_mode 0 ;# Int: Completion window mode
- private variable comp_win_loading_in_p 0 ;# Bool: Completion window list loading is in progress
- private variable comp_win_loading_max 1 ;# Int: Maximum for progressbar in the completion window
- private variable macl_invocations 0 ;# Int: Number of invocations of "manage_autocompletion_list"
- private variable doxytag_fg {#000000} ;# Color: Highlight color for doxygen tag
- private variable indirect_fg {#000000} ;# Color: Highlight color for indirect address
- private variable symbol_fg {#000000} ;# Color: Highlight color for asm. symbol
- private variable sfr_fg {#000000} ;# Color: Highlight color for SFR
- private variable label_fg {#000000} ;# Color: Highlight color for asm. label
- private variable macro_fg {#000000} ;# Color: Highlight color for asm. macro
- private variable const_fg {#000000} ;# Color: Highlight color for asm. const
- private variable dir_fg {#000000} ;# Color: Highlight color for asm. directive
- private variable cs_fg {#000000} ;# Color: Highlight color for constrol sequence
- private variable ins_fg {#000000} ;# Color: Highlight color for instruction
- private variable doxytag_font $defaultFont ;# Font: Font for doxygen tag
- private variable indirect_font $defaultFont ;# Font: Font for indirect address
- private variable symbol_font $defaultFont ;# Font: Font for asm. symbol
- private variable sfr_font $defaultFont ;# Font: Font for SFR
- private variable label_font $defaultFont ;# Font: Font for asm. label
- private variable macro_font $defaultFont ;# Font: Font for asm. macro
- private variable const_font $defaultFont ;# Font: Font for asm. const
- private variable dir_font $defaultFont ;# Font: Font for asm. directive
- private variable cs_font $defaultFont ;# Font: Font for constrol sequence
- private variable ins_font $defaultFont ;# Font: Font for instruction
+
+
+ # Load procedures related to editor command line
+ source "${::LIB_DIRNAME}/editor/commandline.tcl"
+
+ # Load procedures related to exports to other data formats
+ source "${::LIB_DIRNAME}/editor/exports.tcl"
+
+ # Load autocompletion related procedures
+ source "${::LIB_DIRNAME}/editor/autocompletion.tcl"
+
+ # Load general purpose procedures
+ source "${::LIB_DIRNAME}/editor/generalproc.tcl"
+
+ # Load event handlers
+ source "${::LIB_DIRNAME}/editor/eventhandlers.tcl"
+
+ # Spell checker interface
+ source "${::LIB_DIRNAME}/editor/spell_check.tcl"
+
+
## Object constructor
# @parm Bool create_tags - Create highlighting tags
- # @parm String eol_char - EOL (one of {lf cr crlf})
- # @parm String enc - Character encoding (some iso-8859-x or utf-8)
+ # @parm String eol_char - EOL (one of {lf cr crlf})
+ # @parm String enc - Character encoding (some iso-8859-x or utf-8)
# @parm Bool read_only - Read only flag
# @parm Bool switch_lock - Automatic file switching enabled
# @parm widget parentobject - Reference to parent object
@@ -427,6 +408,14 @@ class Editor {
constructor {create_tags eol_char enc read_only switch_lock parentobject fileName filepath Cmd_prefix data sh} {
close_completion_popup_window_NOW
+ set bold_font [font create -size -$fontSize -family $fontFamily -weight {bold}]
+ set italic_font [font create -size -$fontSize -family $fontFamily -slant {italic}]
+ if {[font metrics $bold_font -displayof . -linespace] < [font metrics $italic_font -displayof . -linespace]} {
+ set defaultFont_bold $italic_font
+ } else {
+ set defaultFont_bold $bold_font
+ }
+
# Configure specific ttk styles
ttk::style configure Editor_DarkBg.TButton \
-background {#DDDDDD} \
@@ -435,7 +424,7 @@ class Editor {
-relief flat
ttk::style map Editor_DarkBg.TButton \
-relief [list active raised !active flat]
-
+
# increment instance counter
incr count
@@ -455,11 +444,11 @@ class Editor {
set parentObject $parentobject ;# Identifier parent GUI component (some frame widget)
set fullFileName $filepath ;# Full file name (including path) of current file
set filename $fileName ;# Name of currently opened file or 'untitled'
- refresh_avaliable_SFR
+ refresh_available_SFR
if {$sh == {}} {
determinate_prog_lang 0
- } {
+ } else {
set prog_language_old $prog_language
set prog_language $sh
}
@@ -472,19 +461,22 @@ class Editor {
}
# Create frames
- set ed_sc_frame [frame .editor_frame$count]
- set top_frame [frame $ed_sc_frame.editor_top_frame -relief sunken -bd 1]
- set left_frame [frame $top_frame.editor_left_frame]
- set left_frame_L [frame $left_frame.left -bg $iconBorder_bg]
- set left_frame_R [frame $left_frame.right -bg $lineNumbers_bg]
- set bottom_frame [frame $ed_sc_frame.bottom_frame]
- set statusbar [frame $bottom_frame.editor_status -bg #DDDDDD]
+ set ed_sc_frame [frame .editor_frame$count]
+ set top_frame [frame $ed_sc_frame.editor_top_frame -relief sunken -bd 1]
+ set left_frame [frame $top_frame.editor_left_frame]
+ set left_frame_L [frame $left_frame.left -bg $iconBorder_bg]
+ set left_frame_R [frame $left_frame.right -bg $lineNumbers_bg]
+ set bottom_frame [frame $ed_sc_frame.bottom_frame]
+ set statusbar [frame $bottom_frame.editor_status -bg #DDDDDD]
# Create command line
- set cmd_line [text $bottom_frame.cmd_line \
- -bd 1 -bg #FFFFFF -highlightcolor #8888FF \
- -highlightthickness 1 -height 1 \
- -font $cmd_line_font \
+ set cmd_line [text $bottom_frame.cmd_line \
+ -bd 1 \
+ -bg {#FFFFFF} \
+ -highlightcolor {#8888FF} \
+ -highlightthickness 1 \
+ -height 1 \
+ -font $cmd_line_font \
]
setStatusTip -widget $cmd_line \
-text [mc "Editor command line, type `help' for more"]
@@ -537,8 +529,9 @@ class Editor {
# Create "Editor"
frame $top_frame.f -bd 0 -bg $normal_text_bg -cursor xterm
+
+ set tab_width_un [expr {$tab_width * [font measure $defaultFont_bold 0]}]
set editor [text $top_frame.f.editor \
- -yscrollcommand "$this scrollSet" \
-bg $normal_text_bg \
-font $defaultFont_bold \
-undo 1 -exportselection 1 \
@@ -547,6 +540,7 @@ class Editor {
-selectborderwidth 1 \
-bd 0 -relief flat \
-tabstyle wordprocessor \
+ -tabs [list $tab_width_un left] \
]
bind $top_frame.f <Button-1> "$this click_under_editor %x %y; break"
bind $top_frame.f <Button-4> "$this scroll scroll -3 units; break"
@@ -581,21 +575,21 @@ class Editor {
pack $top_frame -side top -fill both -expand 1
## Create statusbar
- set stat_menu $statusbar.popup_menu
+ set stat_menu $statusbar.popup_menu
set status_left [frame $statusbar.editor_status_left -bg #DDDDDD]
- set status_middle [frame $statusbar.editor_status_middle -width 16 -bg #DDDDDD -width 20]
+ set status_middle [frame $statusbar.editor_status_middle -width 16 -bg #DDDDDD]
set status_right [frame $statusbar.editor_status_right -bg #DDDDDD]
set ins_mode_lbl [Label $statusbar.ins_mode_lbl \
- -text [mc "INS"] -fg #000000 -pady 0 \
- -bg #DDDDDD -cursor hand2 \
- -helptext [mc "Insertion mode"] \
- -font $statusBarBoldFont \
+ -text [mc "INS"] -fg #000000 -pady 0 \
+ -bg #DDDDDD -cursor hand2 \
+ -helptext [mc "Insertion mode"] \
+ -font $statusBarBoldFont \
]
set sel_mode_lbl [Label $statusbar.sel_mode_lbl \
- -text [mc "NORM"] -fg #000000 -pady 0 \
- -bg #DDDDDD -cursor hand2 \
- -helptext [mc "Selection mode"] \
- -font $statusBarBoldFont -width 7 \
+ -text [mc "NORM"] -fg #000000 -pady 0 \
+ -bg #DDDDDD -cursor hand2 \
+ -helptext [mc "Selection mode"] \
+ -font $statusBarBoldFont -width 7 \
]
setStatusTip -widget $sel_mode_lbl -text [mc "Selection mode -- BLK == block; NORM == normal"]
bind $sel_mode_lbl <Button-1> "$this switch_sel_mode"
@@ -603,7 +597,7 @@ class Editor {
pack $status_left -side left -padx 10
pack $status_middle -side left
pack $ins_mode_lbl -side left -padx 5
- pack $sel_mode_lbl -side left -padx 5
+ pack $sel_mode_lbl -side left -padx 5 -pady 3
pack $status_right -side right -fill x -padx 10
# Frame for "Line: x Col: x Total: x"
@@ -715,6 +709,7 @@ class Editor {
}
# Create text tags
+ $editor tag configure tag_wrong_spelling -underline 1
if {$create_tags} {
create_highlighting_tags
}
@@ -766,6 +761,10 @@ class Editor {
bind $editor <Button-4> "$this scroll scroll -3 units; break"
bind $editor <Button-5> "$this scroll scroll +3 units; break"
+ bind $editor <XF86Back> {::X::__prev_editor}
+ bind $editor <XF86Forward> {::X::__next_editor}
+ bind $editor <XF86Reload> {::X::__reload}
+
# Other
foreach key {
<Double-Shift-Button-1> <Shift-Button-1>
@@ -815,6 +814,8 @@ class Editor {
$this recalc_status_counter {}
}
break"
+ bind $editor <Control-Shift-Up> "$this control_shift_updown 1; break"
+ bind $editor <Control-Shift-Down> "$this control_shift_updown 0; break"
bind $editor <Control-Insert> "$this copy; break"
bind $editor <Shift-Insert> "$this paste; break"
bind $editor <Shift-Delete> "$this cut; break"
@@ -822,6 +823,8 @@ class Editor {
bind $editor <Control-Key-Up> "$this control_up; break"
bind $editor <Key-Down> "$this down; break"
bind $editor <Key-Up> "$this up; break"
+ bind $editor <Control-Key-Home> "$this control_home; break"
+ bind $editor <Control-Key-End> "$this control_end; break"
bind $editor <Key-Home> "$this home_press; break"
bind $editor <Shift-Key-Home> "$this shift_home; break"
bind $editor <Key-Insert> "$this switch_ins_ovr; break"
@@ -842,7 +845,7 @@ class Editor {
bind $editor <Shift-KP_Enter> "$this shift_enter; break"
bind $editor <Return> "$this enter; break"
bind $editor <KP_Enter> "$this enter; break"
- bind $editor <Key> "$this Key %A; break"
+ bind $editor <Key> "$this Key %A %K; break"
bind $editor <KeyRelease> "$this KeyRelease %K; break"
bind $editor <ButtonRelease-3> "$this popupMenu %X %Y %x %y; break"
bind $editor <Key-Menu> "$this Key_Menu; break"
@@ -897,17 +900,20 @@ class Editor {
update
break"
bind $editor <Button-1> "
+ # Check spelling on the line which we are now leaving
+ $this spellcheck_check_all \[expr {int(\[%W index insert\])}\]
+
[bind Text <Button-1>]
$this rightPanel_adjust \[expr {int(\[%W index insert\])}\]
$this resetUpDownIndex
- $this recalc_status_counter {%x %y}
+ $this recalc_status_counter
focus -force $editor
break"
bind $editor <B1-Motion> "
[bind Text <B1-Motion>]
$this rightPanel_adjust \[expr {int(\[%W index @%x,%y\])}\]
$this resetUpDownIndex
- $this recalc_status_counter {%x %y}
+ $this recalc_status_counter
break"
bind $editor <<Selection>> "$this editor_selection; break"
@@ -957,7 +963,6 @@ class Editor {
bind $editor <FocusIn> "$parentObject filelist_editor_selected $this"
bind $cmd_line <FocusIn> "$parentObject filelist_editor_selected $this"
-
# Set event bindings for "Line numbers"
bind $lineNumbers <Button-1> "
$parentObject filelist_editor_selected $this
@@ -989,15 +994,19 @@ class Editor {
bindtags $iconBorder [list $iconBorder . all]
# Finalize initialization
+ $editor configure -yscrollcommand "$this scrollSet"
set object_initialized 1
change_RO_MODE $ro_mode
+
+ # Start watching for changes in the file
+ FSnotifications::watch $fullFileName [list ::Editor::file_change_notif $this]
}
## Object destructor
destructor {
if {$editor_to_use} {
kill_childern
- } {
+ } else {
# Stop autosave timer
catch {
after cancel $autosave_timer
@@ -1051,21 +1060,36 @@ class Editor {
public method refresh_font_settings {} {
if {$editor_to_use} {return}
+ # Set new font specification variables
+ set defaultCharHeight_org $defaultCharHeight
+ set defaultFont [font create -size -$fontSize -family $fontFamily]
+ set bold_font [font create -size -$fontSize -family $fontFamily -weight {bold}]
+ set italic_font [font create -size -$fontSize -family $fontFamily -slant {italic}]
+ if {[font metrics $bold_font -displayof $editor -linespace] < [font metrics $italic_font -displayof $editor -linespace]} {
+ set defaultFont_bold $italic_font
+ } else {
+ set defaultFont_bold $bold_font
+ }
+ set defaultCharWidth [font measure $defaultFont_bold -displayof $editor { }]
+ set defaultCharHeight [font metrics $defaultFont_bold -displayof $editor -linespace]
+
# Remove all text tags
foreach tag [$editor tag names] {
if {[lsearch {
sel tag_current_line tag_bookmark
- tag_breakpoint tag_simulator_curr tag_error_line
+ tag_breakpoint tag_breakpoint_INVALID tag_simulator_curr
+ tag_error_line
} $tag] != -1
} then {
break
}
$editor tag remove $tag 1.0 end
}
- # Change fonts
+ # Change fonts and tab width
+ set tab_width_un [expr {$tab_width * [font measure $defaultFont_bold 0]}]
$iconBorder configure -font $defaultFont_bold
$lineNumbers configure -font $defaultFont_bold
- $editor configure -font $defaultFont_bold
+ $editor configure -font $defaultFont_bold -tabs [list $tab_width_un left]
$lineNumbers tag configure right -justify right
$lineNumbers tag configure center -justify center
@@ -1074,19 +1098,13 @@ class Editor {
# Enable writing to the left border
$iconBorder configure -state normal
- # Set new font
- set defaultCharHeight_org $defaultCharHeight
- set defaultFont [font create -size -$fontSize -family $fontFamily]
- set defaultFont_bold [font create -size -$fontSize -family $fontFamily -weight {bold}]
- set defaultCharWidth [font measure $defaultFont_bold -displayof $editor { }]
- set defaultCharHeight [font metrics $defaultFont_bold -displayof $editor -linespace]
# Adjust bookmark images
if {$defaultCharHeight_org != $defaultCharHeight} {
set indexes {}
if {$defaultCharHeight_org < 9} {
set idx 1.0
set idx_prev $idx
- while 1 {
+ while {1} {
set idx [$iconBorder search -exact -- {*} $idx]
if {$idx == {}} {break}
if {[$iconBorder compare $idx_prev >= $idx]} {break}
@@ -1094,7 +1112,7 @@ class Editor {
set idx_prev $idx
set idx [$iconBorder index "$idx+1c"]
}
- } {
+ } else {
foreach img [$iconBorder image names] {
lappend indexes [$iconBorder index $img]
}
@@ -1104,10 +1122,10 @@ class Editor {
$iconBorder delete $idx "$idx+1c"
$iconBorder insert $idx {*}
}
- } {
+ } else {
if {$defaultCharHeight < 15} {
set image {dot}
- } {
+ } else {
set image {bookmark}
}
foreach idx $indexes {
@@ -1122,7 +1140,7 @@ class Editor {
$iconBorder configure -state disabled
# Reset line wrap settings
set highlighted_lines [string repeat 0 [string bytelength $highlighted_lines]]
- update idle
+ update idletasks
highlight_visible_area
# Adjust editor height
@@ -1135,7 +1153,7 @@ class Editor {
if {$ins_ovr_mode} {
$ins_mode_lbl configure -text [mc "INS"] -fg #000000
$editor configure -blockcursor 0
- } {
+ } else {
$ins_mode_lbl configure -text [mc "OVR"] -fg #FF0000
$editor configure -blockcursor 1
}
@@ -1168,7 +1186,7 @@ class Editor {
## Determinate whether editor text has been modified
# and adjust internal variables
# @parm bool force - 1: "I'm sure it has been modified !"
- # 0: "discover it automaticaly"
+ # 0: "discover it automatically"
# @return bool - a new modified flag or {}
public method recalc_status_modified {force} {
@@ -1189,11 +1207,11 @@ class Editor {
catch {
after cancel $autosave_timer
}
- set autosave_timer [after [expr {$autosave * 60000}] [list $this save]]
+ set autosave_timer [after [expr {$autosave * 60000}] "catch {$this save}"]
}
# Not modifed
- } {
+ } else {
# Adjust editor status bar
pack forget $Sbar_image
@@ -1212,24 +1230,18 @@ class Editor {
return $modified
}
- ## Call ::configDialogs::mkDialog $args
+ ## Call ::configDialogues::mkDialog $args
# @return void
- public method configDialogs_mkDialog args {
- ::configDialogs::editor::mkDialog $args
+ public method configDialogues_mkDialog args {
+ ::configDialogues::editor::mkDialog $args
}
## Recalculate variables related to bookmarks, line numbers and list of highlighted lines
- # @parm Bool force = 1 - perform recalcutaion even if length of text wasn't changed
+ # @parm Bool force=1 - perform recalcutaion even if length of text wasn't changed
# @return bool - 0: failed; 1: successful
- public method recalc_left_frame args {
+ public method recalc_left_frame {{force 0}} {
if {$editor_to_use} {return}
- # Parse arguments
- set force [lindex $args 0]
- if {$force == {}} {
- set force 0
- }
-
# Determinate editor lines count and End index
set End [$editor index end]
set Tlines [expr {int($End)}]
@@ -1245,8 +1257,7 @@ class Editor {
incr Tlines -1
# Determinate iconBorder lines count - 1
- set Ilines [expr {int([$iconBorder index end]) - $number_of_wraps}]
- incr Ilines -1
+ set Ilines [expr {int([$iconBorder index end]) - $number_of_wraps - 1}]
# Remove wrap markers from line numbers
if {$number_of_wraps && ($Ilines != $Tlines)} {
@@ -1315,13 +1326,13 @@ class Editor {
$parentObject rightPanel_shift_symbols $Actline [expr {$Actline - $diff - 1}]
# rewrite breakpoints
- rewrite_breakpoint_tags
+ rewrite_breakpoint_tags 1
## Some lines have been added
} elseif {$Ilines < $Tlines} {
# Determinate how many lines should be added
- set diff $Tlines
- incr diff -$Ilines
+ set diff [expr {$Tlines - $Ilines}]
+
set ins [string repeat "\n" $diff]
set BMStr [string range [string repeat {0 } $diff] 0 end-1]
set insIndex $Actline
@@ -1379,8 +1390,8 @@ class Editor {
$editor tag add tag_bookmark [expr {$insIndex - 1}].0 $insIndex.0
}
- } {
- # Adjust list of highlighted lines
+ } else {
+ # Adjust list of lighted lines
set highlighted_lines [string replace \
$highlighted_lines $insIndex $insIndex \
[string repeat 0 [expr {$diff + 1}]]]
@@ -1409,7 +1420,7 @@ class Editor {
$iconBorder configure -state disabled
# rewrite breakpoints
- rewrite_breakpoint_tags
+ rewrite_breakpoint_tags 1
}
## Recalculate Line Numbers
@@ -1426,7 +1437,7 @@ class Editor {
if {$Llines > $Tlines} { ;# too many lines -> remove some ones
$lineNumbers delete $End end
- } elseif {$Llines < $Tlines} { ;# not enought lines -> add some ones
+ } elseif {$Llines < $Tlines} { ;# not enough lines -> add some ones
# Create string to insert to Line Numbers
set ins {}
for {set i [expr {$Llines + 1}]} {$i <= $Tlines} {incr i} {
@@ -1444,16 +1455,15 @@ class Editor {
# Restore wrap markers
if {$number_of_wraps} {
set remaining $number_of_wraps
- set i 1
- foreach wrap $map_of_wraped_lines {
+ for {set i [expr {[llength $map_of_wraped_lines] - 1}]} {$i > 0} {incr i -1} {
+ set wrap [lindex $map_of_wraped_lines $i]
if {$wrap > 0} {
- $lineNumbers insert $i.0 [string repeat "$wrap_char\n" $wrap]
- $lineNumbers tag add center $i.0 [expr {$i + $wrap}].0
- incr i $wrap
+ set ln [expr {$i + 1}]
+ $lineNumbers insert $ln.0 [string repeat "$wrap_char\n" $wrap]
+ $lineNumbers tag add center $ln.0 [expr {$ln + $wrap}].0
incr remaining -$wrap
}
if {!$remaining} {break}
- incr i
}
}
# Disable Line Numbers
@@ -1481,16 +1491,19 @@ class Editor {
# Adjust list of bookmarks
if {[lindex $bookmarks $lineNumber] == 1} {
$parentObject rightPanel_bm_select $lineNumber
- } {
+ } else {
$parentObject rightPanel_bm_unselect
}
# Adjust list of breakpoints
if {[lindex $breakpoints $lineNumber] == 1} {
$parentObject rightPanel_bp_select $lineNumber
- } {
+ } else {
$parentObject rightPanel_bp_unselect
}
+
+ # Adjust list of symbols
+ $parentObject rightPanel_sm_select $lineNumber
}
## Line wrapping manager - variant 2
@@ -1507,7 +1520,7 @@ class Editor {
set new_wrap [get_count_of_lines $line_number.0 "$line_number.0 lineend"]
incr new_wrap -1
# Empty line
- } {
+ } else {
set new_wrap 0
}
@@ -1519,7 +1532,7 @@ class Editor {
if {$line_number >= [llength $map_of_wraped_lines]} {
Configure
return
- } {
+ } else {
lset map_of_wraped_lines $line_number $new_wrap
}
@@ -1536,10 +1549,9 @@ class Editor {
$iconBorder configure -state normal
if {$new_wrap > $wrap} {
set diff [expr {$new_wrap - $wrap}]
- set ins [string repeat "$wrap_char\n" $diff]
incr number_of_wraps $diff
- $lineNumbers insert $line_number.0 $ins
- $iconBorder insert $line_number.0 $ins
+ $lineNumbers insert $line_number.0 [string repeat "$wrap_char\n" $diff]
+ $iconBorder insert $line_number.0 [string repeat "\n" $diff]
$lineNumbers tag add center $line_number.0 [expr {$line_number + $diff}].0
} elseif {$new_wrap < $wrap} {
set diff [expr {$wrap - $new_wrap}]
@@ -1578,7 +1590,7 @@ class Editor {
if {$line_number >= [llength $map_of_wraped_lines]} {
Configure
return
- } {
+ } else {
lset map_of_wraped_lines $line_number $new_wrap
}
@@ -1595,14 +1607,13 @@ class Editor {
$iconBorder configure -state normal
if {$new_wrap > $wrap} {
set diff [expr {$new_wrap - $wrap}]
- set ins [string repeat "$wrap_char\n" $diff]
incr number_of_wraps $diff
- $lineNumbers insert $line_number.0 $ins
- $iconBorder insert $line_number.0 $ins
+ $lineNumbers insert $line_number.0 [string repeat "$wrap_char\n" $diff]
+ $iconBorder insert $line_number.0 [string repeat "\n" $diff]
$lineNumbers tag add center $line_number.0 [expr {$line_number + $diff}].0
} elseif {$new_wrap < $wrap} {
set diff [expr {$wrap - $new_wrap}]
- incr number_of_wraps $diff
+ set number_of_wraps [expr {$number_of_wraps - $diff}]
$lineNumbers delete $line_number.0 $line_number.0+${diff}l
$iconBorder delete $line_number.0 $line_number.0+${diff}l
}
@@ -1673,7 +1684,7 @@ class Editor {
if {$highlight_status == {}} {
set highlight_status 0
}
- } {
+ } else {
set highlight_status 1
}
@@ -1717,12 +1728,15 @@ class Editor {
set i $lineNumber
set last_visible_line [expr {int([lindex [$editor yview] 1] * int([$editor index end])) + 1}]
- # Highlight all line after the current one until it is nessesary
- while 1 {
+ # Highlight all line after the current one until it is not nessesary
+ while {1} {
autocompletion_maybe_important_change $i.0 $i.0
set highlight_status_org [string index $highlighted_lines $i]
set highlight_status [CsyntaxHighlight::highlight $editor $i $highlight_status]
autocompletion_c_syntax_analyze $i
+ if {$i == $lineNumber} {
+ manage_autocompletion_list $i
+ }
set highlighted_lines \
[string replace $highlighted_lines $i $i $highlight_status]
if {
@@ -1761,9 +1775,10 @@ class Editor {
## Parse given line
# Restore highlight, recalculate counters on status bar, adjust right panel
- # @parm Int lineNumber - number of the target line
+ # @parm Int lineNumber - Number of the target line
+ # @parm Bool force_spell_check - Force spelling check
# @return Bool - result from wrap manager
- public method parse {lineNumber} {
+ public method parse {lineNumber {force_spell_check 0}} {
# Check if the given line number is valid
if {$lineNumber >= int([$editor index end])} {
set lineNumber [expr {int([$editor index end]) - 1}]
@@ -1772,7 +1787,7 @@ class Editor {
# Is the given line number is the current line ?
if {int([$editor index insert]) == $lineNumber} {
set curLine 1
- } {
+ } else {
set curLine 0
}
@@ -1827,6 +1842,11 @@ class Editor {
validate_line $lineNumber 0
}
+ # Check spelling if not current line and if enabled
+ if {!$curLine || $force_spell_check} {
+ spellcheck_check_all $lineNumber 1
+ }
+
# Recalculate counters on status bar
if {$curLine} {
recalc_status_counter {}
@@ -1840,7 +1860,7 @@ class Editor {
if {${::ASMsyntaxHighlight::validation_L0}} {
if {[llength [$editor tag nextrange tag_error $lineNumber.0 [list $lineNumber.0 lineend]]]} {
set add 1
- } {
+ } else {
set remove 1
}
# Remove tag "tag_error_line"
@@ -1859,7 +1879,7 @@ class Editor {
if {[lindex $bookmarks $lineNumber] == 1} {
set image {bm_ex}
- } {
+ } else {
set image {exclamation}
}
@@ -1902,19 +1922,21 @@ class Editor {
}
## Finalize syntax validation on the given line (validates operands only)
- # @parm Int - Number of line in source code
- # @parm Bool = 1 - Affect panel "Instruction details"
+ # @parm Int line - Number of line in source code
+ # @parm Bool ins_det=1 - Affect panel "Instruction details"
# @return void
- private method validate_line args {
- # Parse input arguments
- set line [lindex $args 0]
- set ins_det [lindex $args 1]
- if {$ins_det == {}} {
- set ins_det 1
+ private method validate_line {line {ins_det 1}} {
+ # Check if basic validation is enabled
+ if {!${::ASMsyntaxHighlight::validation_L0}} {
+ return
}
- # Check if basic validation is enabled
- if {!${::ASMsyntaxHighlight::validation_L0}} {return}
+ # Validate breakpoint first
+ if {[is_breakpoint_valid $line]} {
+ mark_breakpoint_as_valid $line
+ } else {
+ mark_breakpoint_as_invalid $line
+ }
# Detereminate range of instruction tag
set ins_range [$editor tag nextrange tag_instruction $line.0 "$line.0 lineend"]
@@ -1927,11 +1949,12 @@ class Editor {
if {[lsearch -ascii -exact ${CompilerConsts::AllInstructions} $instruction] == -1} {
return
}
- } {
+
+ } else {
return
}
- # Inset selection in "Instruction details" tab on the Right Panel
+ # Unset selection in "Instruction details" tab on the Right Panel
if {$ins_det} {
$parentObject rightPanel_ins_unselect
}
@@ -1970,7 +1993,7 @@ class Editor {
if {$opr_set == $operands} {
if {$i} {
lappend matches0 $idx
- } {
+ } else {
lappend matches $idx
}
}
@@ -1998,7 +2021,7 @@ class Editor {
}
}
- # Highlight coresponding operand sets in "Instruction details"
+ # Highlight corresponding operand sets in "Instruction details"
if {[llength $matches] || [llength $matches0]} {
if {$ins_det} {
if {[llength $matches]} {
@@ -2008,7 +2031,7 @@ class Editor {
$parentObject rightPanel_ins_select 0 $matches0
}
}
- } {
+ } else {
$editor tag add tag_error [lindex $ins_range 0] [lindex $ins_range 1]
}
@@ -2016,7 +2039,7 @@ class Editor {
set sfr_range_start $line.0
set sfr_range {}
set sfr_name {}
- while 1 {
+ while {1} {
# Try to find SFR
set sfr_range [$editor tag nextrange tag_sfr $sfr_range_start [list $line.0 lineend]]
if {![llength $sfr_range]} {
@@ -2030,10 +2053,10 @@ class Editor {
if {[string index $sfr_name 0] == {/}} {
set sfr_name [string range $sfr_name 1 end]
}
-
+
if {
[lsearch -ascii -exact \
- [$parentObject cget -avaliable_SFR] \
+ [$parentObject cget -available_SFR] \
[string toupper $sfr_name] \
] == -1
} then {
@@ -2043,8 +2066,8 @@ class Editor {
}
}
- ## Adjust content of the given line in list of bookmakrs and list of breakpoint (in right panel)
- # This function should be called after change content of any line
+ ## Adjust content of the given line in list of bookmarks and list of breakpoint (in right panel)
+ # This function should be called after change in content of a line
# @parm Int lineNumber - line number
# @return void
private method rightPanel_changeLineContent {lineNumber} {
@@ -2054,6 +2077,7 @@ class Editor {
$parentObject rightPanel_add_bookmark $lineNumber
$parentObject rightPanel_bm_select $lineNumber
}
+
# Adjust list of breakpoints
if {[lindex $breakpoints $lineNumber] == 1} {
$parentObject rightPanel_remove_breakpoint $lineNumber
@@ -2090,7 +2114,7 @@ class Editor {
private method wrap_aux_line2idx {line} {
if {$number_of_wraps} {
set i 1
- while 1 {
+ while {1} {
incr line [expr { -1 - [lindex $map_of_wraped_lines $i]}]
if {$line < 1 || $line == {}} {break}
incr i
@@ -2104,7 +2128,7 @@ class Editor {
## Focus on the editor widget
# @return void
public method focus_in {} {
- focus $editor
+ focus -force $editor
}
## Get ranges for all highlighting tags on the given line
@@ -2119,9 +2143,9 @@ class Editor {
# Iterate over defined highlighting tags
foreach tag [concat \
- ${ASMsyntaxHighlight::hightlight_tags} \
- ${CsyntaxHighlight::hightlight_tags} \
- ${LSTsyntaxHighlight::hightlight_tags} \
+ ${ASMsyntaxHighlight::highlight_tags} \
+ ${CsyntaxHighlight::highlight_tags} \
+ ${LSTsyntaxHighlight::highlight_tags} \
{tag_macro_def tag_constant_def} \
] {
@@ -2130,7 +2154,7 @@ class Editor {
# Determinate range of the tag
set range {}
- while 1 {
+ while {1} {
# Determinate start index
set startIdx [lindex $range [expr {[llength $range] - 1}]]
if {$startIdx == {}} {
@@ -2157,9 +2181,63 @@ class Editor {
return $ranges
}
+ ## Make breakpoint on the specified line as VALID (reachable)
+ # @param Int line_number - line number
+ # @return void
+ private method mark_breakpoint_as_valid {line_number} {
+ if {[lindex $breakpoints $line_number] != 1} {
+ return
+ }
+
+ set line_number [wrap_aux_idx2line $line_number]
+
+ $lineNumbers tag remove tag_breakpoint_INVALID $line_number.0 [list $line_number.0+1l]
+ $lineNumbers tag add tag_breakpoint $line_number.0 [list $line_number.0+1l]
+ }
+
+ ## Make breakpoint on the specified line as INVALID (unreachable)
+ # @param Int line_number - line number
+ # @return void
+ private method mark_breakpoint_as_invalid {line_number} {
+ if {[lindex $breakpoints $line_number] != 1} {
+ return
+ }
+
+ set line_number [wrap_aux_idx2line $line_number]
+
+ $lineNumbers tag remove tag_breakpoint $line_number.0 [list $line_number.0+1l]
+ $lineNumbers tag add tag_breakpoint_INVALID $line_number.0 [list $line_number.0+1l]
+ }
+
+ ## Determinate whether breakpoint on the specified line is valid or could be
+ #+ valid in case there is no breakpoint yet
+ # @param Int line_number - line number
+ # @return Bool - 1 == is valid; 0 == is NOT valid
+ private method is_breakpoint_valid {line_number} {
+
+ if {$prog_language == 2 || $prog_language == 3} {
+ return 0
+ }
+
+ if {
+ !$prog_language
+ &&
+ ${::ASMsyntaxHighlight::validation_L0}
+ &&
+ ![llength [$editor tag nextrange tag_instruction $line_number.0 [list $line_number.0 lineend]]]
+ &&
+ ![llength [$editor tag nextrange tag_macro $line_number.0 [list $line_number.0 lineend]]]
+ } then {
+ return 0
+ }
+
+ return 1
+ }
+
## Restore breakpoint tags in "Line numbers"
+ # @parm Bool ignore_wrap=0 - Ignore line wrapping (see recalc_left_frame)
# @return void
- private method rewrite_breakpoint_tags {} {
+ private method rewrite_breakpoint_tags {{ignore_wrap 0}} {
if {$editor_to_use} {return}
# Enable line numbers
@@ -2167,10 +2245,33 @@ class Editor {
# Remove current tags
$lineNumbers tag remove tag_breakpoint 1.0 end
+ $lineNumbers tag remove tag_breakpoint_INVALID 1.0 end
+
# Restore tags
- foreach line [lsearch -ascii -exact -all $breakpoints 1] {
- append line {.0}
- $lineNumbers tag add tag_breakpoint $line "$line+1l"
+ if {!$ignore_wrap && $number_of_wraps} {
+ set i 0
+ set line 0
+ foreach wrap $map_of_wraped_lines {
+ if {[lindex $breakpoints $line] == 1} {
+ if {[is_breakpoint_valid $line]} {
+ $lineNumbers tag add tag_breakpoint $i.0 "$i.0+1l"
+ } else {
+ $lineNumbers tag add tag_breakpoint_INVALID $i.0 "$i.0+1l"
+ }
+ }
+
+ incr wrap
+ incr i $wrap
+ incr line
+ }
+ } else {
+ foreach line [lsearch -ascii -exact -all $breakpoints 1] {
+ if {[is_breakpoint_valid $line]} {
+ $lineNumbers tag add tag_breakpoint $line.0 "$line.0+1l"
+ } else {
+ $lineNumbers tag add tag_breakpoint_INVALID $line.0 "$line.0+1l"
+ }
+ }
}
# Disable line numbers
@@ -2187,7 +2288,7 @@ class Editor {
# Create tag in editor
$editor tag configure [lindex $tag_definition 0] -background [lindex $tag_definition 1]
# Create tag in line numbers
- if {[lindex $tag_definition 0] == {tag_breakpoint}} {
+ if {[lsearch {tag_breakpoint_INVALID tag_breakpoint} [lindex $tag_definition 0]] != -1} {
$lineNumbers tag configure [lindex $tag_definition 0] \
-background [lindex $tag_definition 1] -relief raised -borderwidth 1
}
@@ -2248,16 +2349,16 @@ class Editor {
# @return void
public method makePopupMenu {} {
if {[winfo exists $menu]} {destroy $menu}
- menuFactory $EDITORMENU $menu 0 $cmd_prefix 0 {}
+ menuFactory $EDITORMENU $menu 0 $cmd_prefix 0 {} [namespace current]
if {[winfo exists $stat_menu]} {destroy $stat_menu}
- menuFactory $STATMENU $stat_menu 0 {::X::} 0 {}
+ menuFactory $STATMENU $stat_menu 0 {::X::} 0 {} [namespace current]
if {[winfo exists $IB_menu]} {destroy $IB_menu}
- menuFactory $IBMENU $IB_menu 0 "$this " 0 {}
+ menuFactory $IBMENU $IB_menu 0 "$this " 0 {} [namespace current]
if {[winfo exists $LN_menu]} {destroy $LN_menu}
- menuFactory $LNMENU $LN_menu 0 "$this " 0 {}
+ menuFactory $LNMENU $LN_menu 0 "$this " 0 {} [namespace current]
}
## Configure state of statusbar popup menu entries
@@ -2271,40 +2372,35 @@ class Editor {
set statusbar_menu_config [list 1 1 1 1]
}
if {$split != {}} {
- lset statusbar_menu_config 0 $split
+ lset statusbar_menu_config 0 [expr "$split"]
}
if {$close != {}} {
- lset statusbar_menu_config 1 $close
+ lset statusbar_menu_config 1 [expr "$close"]
}
if {$prev != {}} {
- lset statusbar_menu_config 2 $prev
+ lset statusbar_menu_config 2 [expr "$prev"]
}
if {$next != {}} {
- lset statusbar_menu_config 3 $next
+ lset statusbar_menu_config 3 [expr "$next"]
}
}
## Rewrite left site of editor status bar
- # @parm List - Relative mouse cursor coordinates ({%x,%y})
- # {} == keyboard input (eg. leftArrow pressed)
- # @parm Bool = 1 - Highlight current line and such things
+ # @parm List coord={} - Relative mouse cursor coordinates ({%x,%y})
+ # {} == keyboard input (eg. leftArrow pressed)
+ # @parm Bool perform_highlight=1 - Highlight current line and such things
# @return void
- public method recalc_status_counter args {
+ public method recalc_status_counter {{coord {}} {perform_highlight 1}} {
if {$editor_to_use} {return}
- # Procedure can executed only in editor mode
- if {$frozen} {return}
+# # Procedure can executed only in normal editor mode
+# if {$frozen} {return}
# Parse arguments
- if {[lindex $args 0] == {}} {
+ if {$coord == {}} {
set coord insert
- } {
- set coord "@[lindex $args {0 0}],[lindex $args {0 1}]"
- }
- if {[lindex $args 1] == {}} {
- set perform_highlight 1
- } {
- set perform_highlight [lindex $args 1]
+ } else {
+ set coord "@[lindex $coord 0],[lindex $coord 1]"
}
# Translate text index into number
@@ -2319,7 +2415,7 @@ class Editor {
if {[regexp {\t} $lineText]} {
set idx -1
set cor 0
- while 1 {
+ while {1} {
set idx [string first "\t" $lineText [expr {$idx + 1}]]
if {$idx == -1 || $idx > $Index} {break}
@@ -2337,7 +2433,7 @@ class Editor {
incr tmp
$editor tag add tag_current_line $line.0 $tmp.0
set last_cur_line $line
- } {
+ } else {
$editor tag add tag_current_line $line.0 $tmp.0
}
@@ -2399,15 +2495,15 @@ class Editor {
if {[llength $ins_range]} {
$parentObject rightPanel_ins_change [$editor get [lindex $ins_range 0] [lindex $ins_range 1]]
- } {
+ } else {
set ins_range [$editor tag nextrange tag_directive {insert linestart} {insert lineend}]
if {[llength $ins_range]} {
$parentObject rightPanel_dir_change D [$editor get [lindex $ins_range 0] [lindex $ins_range 1]]
- } {
+ } else {
set ins_range [$editor tag nextrange tag_control {insert linestart} {insert lineend}]
if {[llength $ins_range]} {
$parentObject rightPanel_dir_change C [$editor get [lindex $ins_range 0] [lindex $ins_range 1]]
- } {
+ } else {
$parentObject rightPanel_ins_clear
}
}
@@ -2427,7 +2523,7 @@ class Editor {
} then {
if {$up__down} {
return [$editor index {insert-1l linestart}]
- } {
+ } else {
return [$editor index {insert+1l linestart}]
}
@@ -2439,14 +2535,14 @@ class Editor {
# Determinate target column number
if {!$lastUpDownIndex} {
set lastUpDownIndex $col
- } {
+ } else {
set col $lastUpDownIndex
}
# Traslate column number to text index
if {$up__down} {
incr lineNum -1
- } {
+ } else {
incr lineNum
}
@@ -2464,7 +2560,7 @@ class Editor {
if {[string first "\t" $lineText] != -1} {
set idx -1
set cor 0
- while 1 {
+ while {1} {
set idx [string first "\t" $lineText [expr {$idx + 1}]]
if {$idx == -1} {break}
@@ -2480,6 +2576,9 @@ class Editor {
# @parm Int col - Column number
# @return TextIndex - Resulting insertIndex
private method column_to_text_index {lineNum col} {
+ if {!$col} {
+ return 0
+ }
set lineText [$editor get $lineNum.0 [list $lineNum.0 lineend]]
if {[string first "\t" $lineText] != -1} {
@@ -2564,7 +2663,7 @@ class Editor {
# Determinate width of the selected block
if {abs($col_s1 - $col_s0) < abs($col_e1 - $col_e0)} {
set width [expr {abs($col_s1 - $col_s0)}]
- } {
+ } else {
set width [expr {abs($col_e1 - $col_e0)}]
}
@@ -2572,14 +2671,15 @@ class Editor {
$editor tag remove sel 0.0 end
set col 0
for {set row $row_s0} {$row <= $row_e1} {incr row} {
- set col [column_to_text_index $row $col_s0]
- if {[$editor compare $row.$col >= [list $row.0 lineend]]} {
+ set col0 [column_to_text_index $row $col_s0]
+ set col1 [column_to_text_index $row [expr {$col_s0 + $width}]]
+ if {[$editor compare $row.$col0 >= [list $row.0 lineend]]} {
continue
}
- if {[$editor compare $row.$col+${width}c > [list $row.0 lineend]]} {
- $editor tag add sel $row.$col [list $row.0 lineend]
- } {
- $editor tag add sel $row.$col $row.$col+${width}c
+ if {[$editor compare $row.$col1 > [list $row.0 lineend]]} {
+ $editor tag add sel $row.$col0 [list $row.0 lineend]
+ } else {
+ $editor tag add sel $row.$col0 $row.$col1
}
}
}
@@ -2635,7 +2735,7 @@ class Editor {
if {[catch {
if {$filename == {}} {
cd [$parentObject cget -projectPath]
- } {
+ } else {
cd [file dirname $filename]
}
}]} then {
@@ -2650,7 +2750,7 @@ class Editor {
+sb -bg "$normal_text_bg" -b 0 -w 0 -sl 0 \
-fn "xft:$fontFamily:pixelsize=$fontSize" \
-e $cmd &]
- } {
+ } else {
set pid [exec -- urxvt -embed [expr [winfo id $top_frame]] \
+sb -bg "$normal_text_bg" -b 0 -w 0 -sl 0 \
-fn "xft:$fontFamily:pixelsize=$fontSize" \
@@ -2662,7 +2762,7 @@ class Editor {
+sb -bg "$normal_text_bg" -b 0 -w 0 -sl 0 \
-fn "xft:$fontFamily:pixelsize=$fontSize" \
-e $cmd $opt &]
- } {
+ } else {
set pid [exec -- urxvt -embed [expr [winfo id $top_frame]] \
+sb -bg "$normal_text_bg" -b 0 -w 0 -sl 0 \
-fn "xft:$fontFamily:pixelsize=$fontSize" \
@@ -2676,7 +2776,7 @@ class Editor {
-icon error \
-type ok \
-title [mc "FATAL ERROR"] \
- -message [mc "Unable to start embedded editor due to an unknow error. This error did not occured in MCU 8051 IDE code but somewhere else. Please try to restart MCU 8051 IDE with --reset-user-settings"]
+ -message [mc "Unable to start embedded editor due to an unknown error. This error did not occurred in MCU 8051 IDE code but somewhere else. Please try to restart MCU 8051 IDE with --reset-user-settings"]
}
# Return to previous directory
@@ -2687,7 +2787,7 @@ class Editor {
# @parm String filename - Name of file to open with the external editor
# @return void
public method recreate_terminal {filename} {
- update idle
+ update idletasks
if {![winfo exists $ed_sc_frame]} {return}
set top_frame [frame $ed_sc_frame.top_frame_$top_frame_idx -container 1]
pack $top_frame -expand 1 -fill both
@@ -2697,7 +2797,7 @@ class Editor {
incr top_frame_idx
}
- ## Determinate file type acording to its name externsion
+ ## Determinate file type according to its name extension
# @parm Bool reset - Reset syntax highlight
# @return void
private method determinate_prog_lang {reset} {
@@ -2727,12 +2827,16 @@ class Editor {
private method prog_lang_changed {} {
if {$editor_to_use} {return}
# Clear current highlighting tags
- $editor tag remove tag_error 0.0 end
- $editor tag remove tag_error_line 0.0 end
- foreach tag [concat \
- ${::CsyntaxHighlight::hightlight_tags} \
- ${::ASMsyntaxHighlight::hightlight_tags} \
- ${LSTsyntaxHighlight::hightlight_tags} \
+ $editor tag remove tag_error 0.0 end
+ $editor tag remove tag_error_line 0.0 end
+ $editor tag remove tag_constant_def 0.0 end
+ $editor tag remove tag_macro_def 0.0 end
+ $editor tag remove c_lang_func 0.0 end
+ $editor tag remove c_lang_var 0.0 end
+ foreach tag [concat \
+ ${::CsyntaxHighlight::highlight_tags} \
+ ${::ASMsyntaxHighlight::highlight_tags} \
+ ${::LSTsyntaxHighlight::highlight_tags} \
] {
$editor tag remove [lindex $tag 0] 0.0 end
}
@@ -2760,7 +2864,7 @@ class Editor {
# Adjust main menu and main toolbar
if {$prog_language == 1} {
set uses_c 1
- } {
+ } else {
set uses_c 0
}
::X::adjust_mainmenu_and_toolbar_to_editor {} $uses_c
@@ -2779,8 +2883,12 @@ class Editor {
$Sbar_prog_lang configure -fg {#00DDEE} -text "LST"
} elseif {$prog_language == 3} {
$Sbar_prog_lang configure -fg {#0000DD} -text "ASX"
- } {
+ } else {
$Sbar_prog_lang configure -fg {#00CC00} -text "ASM"
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard