summaryrefslogtreecommitdiff
path: root/lib/editor/eventhandlers.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/editor/eventhandlers.tcl')
-rw-r--r--[-rwxr-xr-x]lib/editor/eventhandlers.tcl166
1 files changed, 144 insertions, 22 deletions
diff --git a/lib/editor/eventhandlers.tcl b/lib/editor/eventhandlers.tcl
index c6d1083..279b2e2 100755..100644
--- a/lib/editor/eventhandlers.tcl
+++ b/lib/editor/eventhandlers.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 _EVENTHANDLERS_TCL ] } {
+set _EVENTHANDLERS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements event handlers
@@ -138,7 +143,7 @@ public method scroll args {
if {$unit != {p}} {
incr line [lindex $args 1]
- } {
+ } else {
incr line [expr {30 * [lindex $args 1]}]
}
incr line -1
@@ -157,7 +162,7 @@ public method scroll args {
}
highlight_visible_area ;# Highlight lines which hasn't been highlighted yet
- update idle
+ update idletasks
set tmp_row $row
if {$number_of_wraps} {
@@ -187,7 +192,7 @@ public method scroll args {
}
# Done ...
- update idle
+ update idletasks
set scroll_in_progress 0
}
@@ -207,12 +212,12 @@ public method popupMenu {X Y x y} {
]
if {$address == {}} {
set state {disabled}
- } {
+ } else {
set state {normal}
}
$menu entryconfigure [::mc "LJMP this line"] -state $state
$menu entryconfigure [::mc "LCALL this line"] -state $state
- } {
+ } else {
$menu entryconfigure [::mc "LJMP this line"] -state disabled
$menu entryconfigure [::mc "LCALL this line"] -state disabled
}
@@ -262,7 +267,7 @@ public method statusbar_popup_menu {editor X Y} {
if {[lindex $statusbar_menu_config 0] != 0} {
set state normal
- } {
+ } else {
set state disabled
}
$stat_menu entryconfigure [::mc "Split vertical"] -state $state
@@ -270,21 +275,21 @@ public method statusbar_popup_menu {editor X Y} {
if {[lindex $statusbar_menu_config 1] != 0} {
set state normal
- } {
+ } else {
set state disabled
}
$stat_menu entryconfigure [::mc "Close current view"] -state $state
if {[lindex $statusbar_menu_config 2] != 0} {
set state normal
- } {
+ } else {
set state disabled
}
$stat_menu entryconfigure [::mc "Back"] -state $state
if {[lindex $statusbar_menu_config 3] != 0} {
set state normal
- } {
+ } else {
set state disabled
}
$stat_menu entryconfigure [::mc "Forward"] -state $state
@@ -322,9 +327,83 @@ public method control_up {} {
$editor yview scroll -1 units
}
+## Handles event: "Control-Shift-Key-Up" and "Control-Shift-Key-Down"
+ # @parm Bool up__down - 1 == Control-Shift-Key-Up; 0 == Control-Shift-Key-Down
+ # @return void
+public method control_shift_updown {up__down} {
+ if {$up__down} {
+ if {int([$editor index insert]) == 1} {
+ return
+ }
+ } else {
+ if {(int([$editor index insert]) + 1) == int([$editor index end])} {
+ return
+ }
+ }
+
+ $editor configure -autoseparators 0
+ if {$up__down} {
+ set target_idx [$editor index {insert-1l}]
+ autocompletion_maybe_important_change [$editor index {insert-1l linestart}] [$editor index {insert lineend}]
+ } else {
+ set target_idx [$editor index {insert+1l}]
+ autocompletion_maybe_important_change [$editor index {insert linestart}] [$editor index {insert+1l lineend}]
+ }
+
+ catch {
+ $editor tag remove sel 1.0 end
+ }
+
+ set line0 [$editor get {insert linestart} {insert lineend}]
+ if {$up__down} {
+ set line1 [$editor get {insert-1l linestart} {insert-1l lineend}]
+ } else {
+ set line1 [$editor get {insert+1l linestart} {insert+1l lineend}]
+ }
+
+ $editor delete {insert linestart} {insert lineend}
+ if {$up__down} {
+ $editor delete {insert-1l linestart} {insert-1l lineend}
+ } else {
+ $editor delete {insert+1l linestart} {insert+1l lineend}
+ }
+
+ $editor insert insert $line1
+ if {$up__down} {
+ $editor insert {insert-1l} $line0
+ } else {
+ $editor insert {insert+1l} $line0
+ }
+
+ set idx [expr {int([$editor index insert])}]
+ parse $idx
+ manage_autocompletion_list $idx
+ if {$up__down} {
+ set idx [expr {int([$editor index insert-1l])}]
+ } else {
+ set idx [expr {int([$editor index insert+1l])}]
+ }
+ parse $idx
+ manage_autocompletion_list $idx
+
+ # Check spelling on the other line
+ update
+ spellcheck_check_all [expr {int([$editor index insert])}] 1
+
+ # Move insertion cursor
+ $editor mark set insert $target_idx
+ $editor see insert
+
+ $editor edit separator
+ $editor configure -autoseparators 1
+}
+
## Handles event: "Shift-Key-Down"
# @return void
public method shift_down {} {
+ # Check spelling on the line which we are noe leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
tk::TextKeySelect $editor [get_up_down_idx 0]
# Adjust selection in list of bookmarks and list of breakpoints
@@ -338,6 +417,9 @@ public method shift_down {} {
## Handles event: "Shift-Key-Up"
# @return void
public method shift_up {} {
+ # Check spelling on the line which we are noe leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
tk::TextKeySelect $editor [get_up_down_idx 1]
# Adjust selection in list of bookmarks and list of breakpoints
@@ -351,6 +433,9 @@ public method shift_up {} {
## Handles event: "Key-Up"
# @return void
public method up {} {
+ # Check spelling on the line which we are now leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
# Move insertion cursor
$editor mark set insert [get_up_down_idx 1]
@@ -370,6 +455,9 @@ public method up {} {
## Handles event: "Key-Down"
# @return void
public method down {} {
+ # Check spelling on the line which we are now leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
# Focus completion popup window
if {$completion_win_opened} {
catch {
@@ -427,7 +515,7 @@ public method shift_home {} {
}
# Nothing selected
- } {
+ } else {
set idx [$editor index insert]
home_press
catch {
@@ -436,12 +524,32 @@ public method shift_home {} {
if {[$editor compare $idx < insert]} {
$editor tag add sel $idx insert
- } {
+ } else {
$editor tag add sel insert $idx
}
}
}
+## Handles event: "Control-Key-Home"
+ # @return void
+public method control_home {} {
+ $editor mark set insert 1.0
+ rightPanel_adjust [expr {int([$editor index insert])}]
+ resetUpDownIndex
+ recalc_status_counter {} 0
+ $editor see insert
+}
+
+## Handles event: "Control-Key-End"
+ # @return void
+public method control_end {} {
+ $editor mark set insert end
+ rightPanel_adjust [expr {int([$editor index insert])}]
+ resetUpDownIndex
+ recalc_status_counter {} 0
+ $editor see insert
+}
+
## Handles event: "Key-Home"
# @return void
public method home_press {} {
@@ -455,10 +563,10 @@ public method home_press {} {
set col [string length $space]
if {$col_original == $col} {
$editor mark set insert $row.0
- } {
+ } else {
$editor mark set insert $row.$col
}
- } {
+ } else {
$editor mark set insert $row.0
}
@@ -468,6 +576,7 @@ public method home_press {} {
}
# Adjust status bar counters
+ resetUpDownIndex
recalc_status_counter {} 0
$editor see insert
}
@@ -477,7 +586,7 @@ public method home_press {} {
public method tab_press {} {
if {$spaces_no_tabs} {
set indent_char [string repeat { } $number_of_spaces]
- } {
+ } else {
set indent_char "\t"
}
@@ -486,7 +595,7 @@ public method tab_press {} {
Key $indent_char
# Something selected -> indent
- } {
+ } else {
# convert selection indexes to line numbers
set start [expr {int([$editor index sel.first])}]
set end_o [$editor index sel.last]
@@ -514,6 +623,9 @@ public method shift_enter {} {
if {$critical_edit_proc} {return}
set critical_edit_proc 1
+ # Check spelling on the line which we are noe leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
deleteselection
$editor insert insert "\n"
@@ -553,10 +665,13 @@ public method enter {} {
set idx [expr {int($idx)}]
incr idx
+ # Check spelling on the line which we are noe leaving
+ spellcheck_check_all $idx
+
# Keep indention of the previous line
if {$intentation_mode == {normal}} {
- # Determinate indetication charactes
+ # Determinate indetication characters
set prev_line [$editor get \
[$editor index {insert-1l linestart}] \
[$editor index {insert-1l lineend}] \
@@ -620,7 +735,7 @@ public method KeyRelease {key} {
if {[lsearch {ISO_Next_Group ISO_Prev_Group Alt_R Alt_L Control Meta Shift_L Shift_R} $key] == -1} {
if {$do_not_hide_comp_win} {
set do_not_hide_comp_win 0
- } {
+ } else {
close_completion_popup_window
}
}
@@ -628,8 +743,8 @@ public method KeyRelease {key} {
## Handles event: 'Key'
# @return void
-public method Key {key} {
- # Skip values with no meaning
+public method Key {key {key_k {}}} {
+ # Skip values with no meaning for us herw
if {![string is print -strict $key] && $key != "\t"} {
return
}
@@ -643,6 +758,7 @@ public method Key {key} {
set key_handler_in_progress 1
set scroll_in_progress 1 ;# Block scrolling
+ spellcheck_change_detected_pre
autocompletion_maybe_important_change insert insert
$editor configure -autoseparators 0
@@ -665,7 +781,7 @@ public method Key {key} {
$editor tag remove sel 1.0 end
# Insert the selected character twice
- } {
+ } else {
set next_char [$editor get insert insert+1c]
$editor insert insert $key
switch -- $key {
@@ -730,6 +846,7 @@ public method Key {key} {
set key_handler_in_progress 0
update
set scroll_in_progress 0 ;# Unblock scrolling
+ spellcheck_change_detected_post
}
## Handles event: 'Key-Delete'
@@ -738,7 +855,7 @@ public method key_delete {} {
if {![$this deleteselection 1]} {
if {[$editor compare {insert linestart} != {insert+1c linestart}]} {
set remove_trailing_space 1
- } {
+ } else {
set remove_trailing_space 0
}
@@ -752,6 +869,7 @@ public method key_delete {} {
$this resetUpDownIndex
$this recalc_left_frame
+ $this parse [expr {int([$editor index insert])}]
update
}
@@ -779,3 +897,7 @@ public method key_backspace {} {
$this parse [expr {int([$editor index insert])}]
update
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard