summaryrefslogtreecommitdiff
path: root/lib/editor/commandline.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/editor/commandline.tcl')
-rw-r--r--[-rwxr-xr-x]lib/editor/commandline.tcl119
1 files changed, 64 insertions, 55 deletions
diff --git a/lib/editor/commandline.tcl b/lib/editor/commandline.tcl
index 4fe39c3..4e15e0a 100755..100644
--- a/lib/editor/commandline.tcl
+++ b/lib/editor/commandline.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 _COMMANDLINE_TCL ] } {
+set _COMMANDLINE_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements procedures related to editor command line
@@ -50,7 +55,7 @@ public method cmd_line_key {key} {
{Delete} {
if {[llength [$cmd_line tag nextrange sel 1.0]]} {
$cmd_line delete sel.first sel.last
- } {
+ } else {
if {[$cmd_line index insert] != [$cmd_line index {insert lineend}]} {
$cmd_line delete insert {insert+1c}
}
@@ -59,7 +64,7 @@ public method cmd_line_key {key} {
{BackSpace} {
if {[llength [$cmd_line tag nextrange sel 1.0]]} {
$cmd_line delete sel.first sel.last
- } {
+ } else {
if {[$cmd_line index insert] != [$cmd_line index {insert linestart}]} {
$cmd_line delete {insert-1c} insert
}
@@ -149,7 +154,7 @@ public method cmd_line_enter {} {
}
set command [cmd_line_get_possible_cmds $command]
if {$command == {}} {
- Sbar [mc "EDITOR COMMAND LINE: invalid command, type `help list' to get list of avaliable commands"]
+ Sbar [mc "EDITOR COMMAND LINE: invalid command, type `help list' to get list of available commands"]
return
} elseif {[llength $command] > 1} {
Sbar [mc "Ambiguous command"]
@@ -164,8 +169,8 @@ public method cmd_line_enter {} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "char"]
}
if {![llength $args]} {
- cmd_line_help_window {Help} [mc \
- "This is MCU 8051 IDE command line\n\nusage: <b>command \[argumets\]</b>\n\nEnter <b>help list</b> for list of avaliable commands or\n<b>help <STRING command></b> for help for individual command"]
+ cmd_line_help_window [mc "Help"] [mc \
+ "This is MCU 8051 IDE command line\n\nusage: <b>command \[arguments\]</b>\n\nEnter <b>help list</b> for list of available commands or\n<b>help <STRING command></b> for help for individual command"]
return
}
set command [lindex $args 0]
@@ -179,7 +184,7 @@ public method cmd_line_enter {} {
switch -- $command {
{list} {
- cmd_line_help_window [mc "Avaliable commands"] \
+ cmd_line_help_window [mc "Available commands"] \
"<b>d2h</b> [mc {DEC -> HEX}]
<b>d2o</b> [mc {DEC -> OCT}]
<b>d2b</b> [mc {DEC -> BIN}]
@@ -199,7 +204,7 @@ public method cmd_line_enter {} {
<b>breakpoint</b> [mc {Add/Remove breakpoint}]
<b>capitalize</b> [mc {Capitalize selection}]
<b>clear</b> [mc {Clear history}]
- <b>comment</b> [mc {Comment slected text}]
+ <b>comment</b> [mc {Comment selected text}]
<b>copy</b> [mc {Copy selection}]
<b>custom</b> [mc {Custom command}]
<b>cut</b> [mc {Cut selection}]
@@ -236,11 +241,11 @@ public method cmd_line_enter {} {
}
{hibernate} {
cmd_line_help_window [mc "Command hibernate"] [mc \
- "<b>hibernate</b> \[<STRING target-file>\]\nHibernate running program (avaliliable only when simulator is stated).\n\nThis function saves current state of the simulator engine for future resumption. If no target is not specified it will invoke file selection dialog"]
+ "<b>hibernate</b> \[<STRING target-file>\]\nHibernate running program (available only when simulator is stated).\n\nThis function saves current state of the simulator engine for future resumption. If no target is not specified it will invoke file selection dialog"]
}
{resume} {
cmd_line_help_window [mc "Command resume"] [mc \
- "<b>resume</b> \[<STRING source-file>\]\nResume hibernated program (avaliliable only when simulator is stated).\n\nThis function restores previous state of the simulator engine stored in the given file. If no source is not specified it will invoke file selection dialog"]
+ "<b>resume</b> \[<STRING source-file>\]\nResume hibernated program (available only when simulator is stated).\n\nThis function restores previous state of the simulator engine stored in the given file. If no source is not specified it will invoke file selection dialog"]
}
{switch-mcu} {
cmd_line_help_window [mc "Command switch-mcu"] [mc \
@@ -248,15 +253,15 @@ public method cmd_line_enter {} {
}
{set-xcode} {
cmd_line_help_window [mc "Command set-xcode"] [mc \
- "<b>set-xcode</b> <INT size>\nChange capacity of external program memory.\nNote: this command also close CODE memory hexeditor"]
+ "<b>set-xcode</b> <INT size>\nChange capacity of external program memory.\nNote: this command also close CODE memory hex editor"]
}
{set-xdata} {
cmd_line_help_window [mc "Command set-xdata"] [mc \
- "<b>set-xdata</b> <INT size>\nChange capacity of external data memory.\nNote: this command also close XDATA memory hexeditor"]
+ "<b>set-xdata</b> <INT size>\nChange capacity of external data memory.\nNote: this command also close XDATA memory hex editor"]
}
{run} {
cmd_line_help_window [mc "Command run"] [mc \
- "Run simulation (avaliliable only when simulator is stated)"]
+ "Run simulation (available only when simulator is stated)"]
}
{exit} {
cmd_line_help_window [mc "Command exit"] [mc \
@@ -276,7 +281,7 @@ public method cmd_line_enter {} {
}
{help} {
cmd_line_help_window [mc "Command help"] [mc \
- "<b>help</b> <STRING command>\nShows help for the given command\n\n<b>help list</b>\nShows list of avaliable command"]
+ "<b>help</b> <STRING command>\nShows help for the given command\n\n<b>help list</b>\nShows list of available command"]
}
{open} {
cmd_line_help_window [mc "Command open"] [mc \
@@ -304,7 +309,7 @@ public method cmd_line_enter {} {
}
{date} {
cmd_line_help_window [mc "Command date"] [mc \
- "<b>date</b> <STRING format>\nInserts formated date at the current position in text\n\n<b>Format string:</b>\n%% => %\n%a => Weekday name (Mon, Tue, etc.)\n%A => Weekday name (Monday, Tuesday, etc.)\n%b => Month name (Jan, Feb, etc.)\n%B => Full month name\n%C => Year (19 or 20)\n%d => Day of month (01 - 31)\n%D => %m/%d/%y\n%h => Abbreviated month name.\n%H => Hour (00 - 23)\n%I => Hour (01 - 12)\n%j => Day of year (001 - 366)\n%k => Hour (0 - 23)\n%l => Hour (1 - 12).\n%m => Month (01 - 12)\n%M => Minute (00 - 59)\n%n => Newline\n%p => AM/PM\n%R => %H:%M.\n%s => Unix timestamp\n%S => Seconds (00 - 59)\n%t => Tab\n%T => %H:%M:%S.\n%u => Weekday number (Monday = 1, Sunday = 7)\n%w => Weekday number (Sunday = 0, Saturday = 6)\n%y => Year without century (00 - 99)\n%Y => Year with century (e.g. 1459)"]
+ "<b>date</b> <STRING format>\nInserts formatted date at the current position in text\n\n<b>Format string:</b>\n%% => %\n%a => Weekday name (Mon, Tue, etc.)\n%A => Weekday name (Monday, Tuesday, etc.)\n%b => Month name (Jan, Feb, etc.)\n%B => Full month name\n%C => Year (19 or 20)\n%d => Day of month (01 - 31)\n%D => %m/%d/%y\n%h => Abbreviated month name.\n%H => Hour (00 - 23)\n%I => Hour (01 - 12)\n%j => Day of year (001 - 366)\n%k => Hour (0 - 23)\n%l => Hour (1 - 12).\n%m => Month (01 - 12)\n%M => Minute (00 - 59)\n%n => Newline\n%p => AM/PM\n%R => %H:%M.\n%s => Unix timestamp\n%S => Seconds (00 - 59)\n%t => Tab\n%T => %H:%M:%S.\n%u => Weekday number (Monday = 1, Sunday = 7)\n%w => Weekday number (Sunday = 0, Saturday = 6)\n%y => Year without century (00 - 99)\n%Y => Year with century (e.g. 1459)"]
}
{clear} {
cmd_line_help_window [mc "Command clear"] [mc \
@@ -344,7 +349,7 @@ public method cmd_line_enter {} {
}
{toupper} {
cmd_line_help_window [mc "Command toupper"] [mc \
- "Convert selected text to upppercase"]
+ "Convert selected text to uppercase"]
}
{capitalize} {
cmd_line_help_window [mc "Command capitalize"] [mc \
@@ -392,11 +397,11 @@ public method cmd_line_enter {} {
}
{step} {
cmd_line_help_window [mc "Command step"] [mc \
- "Step program (avaliliable only when simulator is stated)"]
+ "Step program (available only when simulator is stated)"]
}
{animate} {
cmd_line_help_window [mc "Command animate"] [mc \
- "Animate program (avaliliable only when simulator is stated)"]
+ "Animate program (available only when simulator is stated)"]
}
{d2h} {
cmd_line_help_window [mc "Command d2h"] [mc \
@@ -459,7 +464,7 @@ public method cmd_line_enter {} {
if {![llength $args]} {
::X::__hibernate
- } {
+ } else {
::X::__hibernate_to [lindex $args 0] $filename
}
Sbar [mc "Success"]
@@ -472,7 +477,7 @@ public method cmd_line_enter {} {
if {![llength $args]} {
::X::__resume
- } {
+ } else {
::X::__resume_from [lindex $args 0] $filename
}
Sbar [mc "Success"]
@@ -486,15 +491,15 @@ public method cmd_line_enter {} {
set arg [string toupper [lindex $args 0]]
if {$arg == {list}} {
set arg {}
- foreach mcu ${::X::avaliable_processors} {
+ foreach mcu ${::X::available_processors} {
append arg $mcu
append arg "\n"
}
cmd_line_help_window {Supported microcontrollers} $arg
- } {
- if {[lsearch ${::X::avaliable_processors} $arg] == -1} {
+ } else {
+ if {[lsearch ${::X::available_processors} $arg] == -1} {
Sbar [mc "EDITOR COMMAND LINE: Unsupported processor `%s'" "$arg"]
- } {
+ } else {
::X::change_processor $arg
}
}
@@ -525,13 +530,13 @@ public method cmd_line_enter {} {
set icode [expr {[lindex [${::X::actualProject} cget -procData] 2] * 1024}]
if {$arg > (0xFFFF - $icode)} {
- Sbar [mc "EDITOR COMMAND LINE: This MCU has CODE memory limit 0x10000 B (65536) (command: %s)"] "set-xdata"
+ Sbar [mc "EDITOR COMMAND LINE: This MCU has CODE memory limit 0x10000 B (65536) (command: %s)"] "set-xcode"
return
}
if {[lindex [${::X::actualProject} cget -procData] 1] != {yes}} {
Sbar [mc "This MCU cannot have connected external program memory"]
- } {
+ } else {
${::X::actualProject} configure -P_option_mcu_xcode $arg
::X::close_hexedit code ${::X::actualProject}
${::X::actualProject} simulator_resize_code_memory $arg
@@ -568,7 +573,7 @@ public method cmd_line_enter {} {
if {[lindex [${::X::actualProject} cget -procData] 0] != {yes}} {
Sbar [mc "This MCU cannot have connected external data memory"]
- } {
+ } else {
${::X::actualProject} configure -P_option_mcu_xdata $arg
::X::close_hexedit xdata ${::X::actualProject}
${::X::actualProject} simulator_resize_xdata_memory $arg
@@ -601,17 +606,17 @@ public method cmd_line_enter {} {
}
if {$fullFileName != {}} {
set dir [file dirname $fullFileName]
- } {
+ } else {
set dir $projectPath
}
set filename [file join $dir [lindex $args 0]]
if {![file exists $filename] || ![file isfile $filename]} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "unindent"]
}
- if {[${X::actualProject} openfile $filename 1 . def def 0 0 {}] != {}} {
- ${X::actualProject} switch_to_last
- update idle
- ${X::actualProject} editor_procedure {} parseAll {}
+ if {[${::X::actualProject} openfile $filename 1 . def def 0 0 {}] != {}} {
+ ${::X::actualProject} switch_to_last
+ update idletasks
+ ${::X::actualProject} editor_procedure {} parseAll {}
Sbar [mc "Success"]
}
}
@@ -639,7 +644,7 @@ public method cmd_line_enter {} {
{date} {
if {[catch {$editor insert insert [clock format [clock seconds] -format $args]}]} {
Sbar [mc "EDITOR COMMAND LINE: Invalid format string"]
- } {
+ } else {
parse [expr {int([$editor index insert])}]
Sbar [mc "Success"]
}
@@ -647,7 +652,7 @@ public method cmd_line_enter {} {
{char} {
if {[llength $args] > 1} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "char"]
- } {
+ } else {
Sbar [mc "Success"]
}
set char [lindex $args 0]
@@ -661,7 +666,7 @@ public method cmd_line_enter {} {
{goto} {
if {[llength $args] > 1} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "goto"]
- } {
+ } else {
Sbar [mc "Success"]
}
set target_line [lindex $args 0]
@@ -672,7 +677,7 @@ public method cmd_line_enter {} {
}
if {$target_line > [editor_linescount]} {
Sbar [mc "Target line out of range"]
- } {
+ } else {
goto $target_line
Sbar [mc "Success"]
}
@@ -680,7 +685,7 @@ public method cmd_line_enter {} {
{replace} {
if {[llength $args] > 2} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "replace"]
- } {
+ } else {
Sbar [mc "Success"]
}
set pattern [lindex $args 0]
@@ -754,8 +759,8 @@ public method cmd_line_enter {} {
set result [find $fromCursor $Backwards $regExp $noCase $inSelection 1.0 $pattern]
if {[lindex $result 0] == -1} {
Sbar [mc "String not found: %s" [lindex $result 1]]
- } {
- Sbar [mc "Found %s occurences" [lindex $result 2]]
+ } else {
+ Sbar [mc "Found %s occurrence" [lindex $result 2]]
}
}
{cut} {
@@ -850,14 +855,14 @@ public method cmd_line_enter {} {
command_without_args $args
}
default {
- Sbar [mc "EDITOR COMMAND LINE: invalid command, type `help list' to get list of avaliable commands"]
+ Sbar [mc "EDITOR COMMAND LINE: invalid command, type `help list' to get list of available commands"]
}
}
# Manage command line history
if {int([$cmd_line index end-1l]) == int([$cmd_line index insert])} {
$cmd_line insert {insert lineend} "\n"
- } {
+ } else {
set txt [$cmd_line get {insert linestart} {insert lineend}]
$cmd_line mark set insert end
$cmd_line insert insert $txt
@@ -959,9 +964,9 @@ private method command_without_args {args} {
}
## Highlight current contents of editor command line
- # @parm Bool = 0 - Disable popup-based completion
+ # @parm Bool no_completion=0 - Disable popup-based completion
# @return void
-private method cmd_line_highlight args {
+private method cmd_line_highlight {{no_completion 0}} {
# Remove all tags from command line
foreach tag {tag_cmd tag_argument tag_option tag_error} {
$cmd_line tag remove $tag {insert linestart} {insert lineend}
@@ -988,7 +993,7 @@ private method cmd_line_highlight args {
if {[llength $command] == 1} {
$cmd_line tag add tag_cmd $startIdx $lineNumber.$endIdx
} elseif {$endIdx && [llength $command] > 1 && [$cmd_line compare $lineNumber.$endIdx == insert]} {
- if {$cline_completion && $args != 1} {
+ if {$cline_completion && !$no_completion} {
# Automaticaly complete command
set possible_cmd [lindex $command 0]
set insert [$cmd_line index insert]
@@ -1012,7 +1017,7 @@ private method cmd_line_highlight args {
incr endIdx [string length $opt]
if {[lsearch $commands_with_option $command] != -1} {
$cmd_line tag add tag_option $lineNumber.$startIdx $lineNumber.$endIdx
- } {
+ } else {
$cmd_line tag add tag_error $lineNumber.$startIdx $lineNumber.$endIdx
}
}
@@ -1078,7 +1083,7 @@ private method cmd_line_menu_postdown {commands} {
%W selection set"
# Finalize window initialization (global grab)
- update idle
+ update idletasks
catch {
grab -global $win
raise $win
@@ -1100,7 +1105,7 @@ private method cmd_line_menu_postdown {commands} {
public method cmd_line_down {} {
if {![winfo exists $cmd_line_listbox]} {
return 0
- } {
+ } else {
$cmd_line_listbox selection set [$cmd_line_listbox item 0]
focus -force $cmd_line_listbox
return 1
@@ -1167,14 +1172,14 @@ private method cmd_line_help_window {header content} {
}
# Create window
- set win [toplevel .editor_cmd_help_widow -bg {#EEEEEE}]
+ set win [toplevel .editor_cmd_help_widow -bg ${::COMMON_BG_COLOR}]
wm overrideredirect $win 1
bind $win <ButtonPress-1> "$this cmd_line_win_B1 %X %Y"
bind $win <FocusOut> "$this cmd_line_menu_close_now"
# Create header
- set header_frame [frame $win.header]
+ set header_frame [frame $win.header -bg {#AAAAFF}]
pack [label $header_frame.lbl_heder \
-text $header -fg {#FF0000} \
-bg {#AAAAFF} -bd 0 -anchor w \
@@ -1207,7 +1212,7 @@ private method cmd_line_help_window {header content} {
# Create map of bold font tags
regsub -all -line {^\t+} $content {} content
set bold_tag_map {}
- while 1 {
+ while {1} {
set tag_pair {}
set idx [string first {<b>} $content]
@@ -1241,7 +1246,7 @@ private method cmd_line_help_window {header content} {
# Show the window
set x [winfo rootx $cmd_line]
set y [expr {[winfo rooty $cmd_line] + [winfo height $cmd_line]}]
- update idle
+ update idletasks
if {150 > ([winfo height .] - $y)} {
incr y -150
incr y -[winfo height $cmd_line]
@@ -1255,21 +1260,25 @@ private method cmd_line_help_window {header content} {
}
## Focus on editor / editor command line
- # @parm Bool = 0 - Do not call proc. "cmd_line_on"
+ # @parm Bool no_cmd_line_on=0 - Do not call proc. "cmd_line_on"
# @return void
-public method cmd_line_focus args {
+public method cmd_line_focus {{no_cmd_line_on 0}} {
# Show command line
if {![winfo viewable $cmd_line]} {
pack $cmd_line -side top -fill x
- if {$args != 1} {
+ if {!$no_cmd_line_on} {
${::X::actualProject} cmd_line_on
}
}
if {[focus] == $cmd_line} {
focus $editor
- } {
+ } else {
focus $cmd_line
}
update
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard