summaryrefslogtreecommitdiff
path: root/lib/utilities/hexeditdlg.tcl
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
committerAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
commit47aa8b00b2b11df13a100489e0f904a4947177ef (patch)
treeb35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib/utilities/hexeditdlg.tcl
parent5b8466f7fae0e071c0f4eda13051c93313910028 (diff)
Import Upstream version 1.4.7
Diffstat (limited to 'lib/utilities/hexeditdlg.tcl')
-rw-r--r--[-rwxr-xr-x]lib/utilities/hexeditdlg.tcl257
1 files changed, 145 insertions, 112 deletions
diff --git a/lib/utilities/hexeditdlg.tcl b/lib/utilities/hexeditdlg.tcl
index 42175f1..c18df59 100755..100644
--- a/lib/utilities/hexeditdlg.tcl
+++ b/lib/utilities/hexeditdlg.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 _HEXEDITDLG_TCL ] } {
+set _HEXEDITDLG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Prodides hexadecimal editor for external data and program memory.
@@ -34,16 +39,16 @@ class HexEditDlg {
common cell {0} ;# Current cell (0 - 0xFFFF)
common current_view {left} ;# Focused view {left right}
# Font for mode combobox
- common mode_cb_font [font create \
- -family {Helvetica} \
- -size -17 \
- -weight bold \
+ common mode_cb_font [font create \
+ -family {Helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
]
# General normal size bold font
- common bold_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ common bold_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
# Status bar tips for main menu for XDATA mode
common HELPFILE_XDATA {
@@ -62,8 +67,8 @@ class HexEditDlg {
{}
{}
{Invoke dialog for searching strings in the text}
- {Find next occurence of the search string}
- {Find previous occurence of the search string}
+ {Find next occurrence of the search string}
+ {Find previous occurrence of the search string}
} {
{Switch view mode to hexadecimal}
{Switch view mode to decimal}
@@ -86,8 +91,8 @@ class HexEditDlg {
{}
{}
{Invoke dialog for searching strings in the text}
- {Find next occurence of the search string}
- {Find previous occurence of the search string}
+ {Find next occurrence of the search string}
+ {Find previous occurrence of the search string}
} {
{Switch view mode to hexadecimal}
{Switch view mode to decimal}
@@ -138,7 +143,7 @@ class HexEditDlg {
set project $_project
set type $_type
set obj_idx $count
- set win [toplevel .hexeditdlg${obj_idx} -class {Hex Editor} -bg {#EEEEEE}]
+ set win [toplevel .hexeditdlg${obj_idx} -class {Hex Editor} -bg ${::COMMON_BG_COLOR}]
set loaded_lines [string repeat [string repeat 0 0xFF] 0xFF]
incr count ;# Increment instance counter
@@ -180,7 +185,7 @@ class HexEditDlg {
if {$type == {code}} {
if {[$project is_frozen]} {
set state normal
- } {
+ } else {
set state disabled
}
@@ -199,7 +204,7 @@ class HexEditDlg {
# Fill EntryBoxes
if {$cell >= $capacity} {
set current_cell [expr {$capacity - 1}]
- } {
+ } else {
set current_cell $cell
}
set value [$hexeditor get_values $current_cell $current_cell]
@@ -208,7 +213,7 @@ class HexEditDlg {
set validation_ena 1
# Pack dialog frames
- pack $tool_bar_frame -fill x -anchor w
+ pack $tool_bar_frame -fill x -anchor w -padx 3
pack $middle_frame -anchor nw -after $tool_bar_frame -pady 10
pack $bottom_frame -anchor w -after $middle_frame
pack $statusbar_frame -side bottom -fill x -after $bottom_frame
@@ -235,7 +240,7 @@ class HexEditDlg {
wm resizable $win 0 0
if {$mode == {hex}} {
wm geometry $win ${win_pos}
- } {
+ } else {
wm geometry $win ${win_pos}
}
@@ -243,7 +248,7 @@ class HexEditDlg {
wm iconphoto $win ::ICONS::16::$window_icon
if {$type == {uni}} {
wm protocol $win WM_DELETE_WINDOW "$this quit"
- } {
+ } else {
wm protocol $win WM_DELETE_WINDOW \
[list ::X::close_hexedit $type $project]
}
@@ -289,9 +294,9 @@ class HexEditDlg {
## Create menu widgets
# Main
set mainmenu [menu $win.mainmenu \
- -bd 0 -tearoff 0 -bg {#EEEEEE} \
+ -bd 0 -tearoff 0 -bg ${::COMMON_BG_COLOR} \
-activeforeground {#6666FF} \
- -activebackground {#EEEEEE} \
+ -activebackground ${::COMMON_BG_COLOR} \
]
set file_menu [menu $mainmenu.file_menu -tearoff 0] ;# Main -> File
set edit_menu [menu $mainmenu.edit_menu -tearoff 0] ;# Main -> Edit
@@ -307,71 +312,71 @@ class HexEditDlg {
# Create File menu
if {$type == {code}} {
- $file_menu add command -label "Open ADF" -compound left \
+ $file_menu add command -label [mc "Open ADF"] -compound left \
-command "$this opensim" -underline 0 \
-image ::ICONS::16::fileopen
}
- $file_menu add command -label "Open IHEX8" -compound left \
+ $file_menu add command -label [mc "Open IHEX8"] -compound left \
-accelerator "Ctrl+O" -command "$this openhex" \
-image ::ICONS::16::fileopen -underline 1
$file_menu add separator
- $file_menu add command -label "Save" -compound left \
+ $file_menu add command -label [mc "Save"] -compound left \
-accelerator "Ctrl+S" -command "$this save" \
-image ::ICONS::16::filesave -underline 0
- $file_menu add command -label "Save as" -compound left \
+ $file_menu add command -label [mc "Save as"] -compound left \
-accelerator "Ctrl+Shift+S" -command "$this saveas" \
-image ::ICONS::16::filesaveas -underline 1
$file_menu add separator
if {$type != {code}} {
- $file_menu add command -label "Reload" -compound left \
- -accelerator "F5" -command "$this reload" \
+ $file_menu add command -label [mc "Reload"] -compound left \
+ -accelerator "F5" -command "$this reload" \
-image ::ICONS::16::reload -underline 1
$file_menu add separator
}
- $file_menu add command -label "Exit" -compound left \
- -accelerator "Ctrl+Q" -command "$this quit" \
+ $file_menu add command -label [mc "Exit"] -compound left \
+ -accelerator "Ctrl+Q" -command "$this quit" \
-image ::ICONS::16::exit -underline 1
# Create Edit menu
- $edit_menu add command -label "Copy" -compound left \
+ $edit_menu add command -label [mc "Copy"] -compound left \
-accelerator "Ctrl+C" -command "$this text_copy" \
-image ::ICONS::16::editcopy -underline 0
- $edit_menu add command -label "Paste" -compound left \
+ $edit_menu add command -label [mc "Paste"] -compound left \
-accelerator "Ctrl+V" -command "$this text_paste" \
-image ::ICONS::16::editpaste -underline 0
$edit_menu add separator
- $edit_menu add command -label "Find" -compound left \
- -accelerator "Ctrl+F" -command "$this find_string 0" \
+ $edit_menu add command -label [mc "Find"] -compound left \
+ -accelerator "Ctrl+F" -command "$this find_string 0" \
-image ::ICONS::16::find -underline 0
- $edit_menu add command -label "Find next" -compound left \
- -accelerator "F3" -command "$this find_string 1" \
+ $edit_menu add command -label [mc "Find next"] -compound left \
+ -accelerator "F3" -command "$this find_string 1" \
-image ::ICONS::16::1downarrow -underline 5
- $edit_menu add command -label "Find previous" -compound left \
- -accelerator "Shift+F3" -command "$this find_string 2" \
+ $edit_menu add command -label [mc "Find previous"] -compound left \
+ -accelerator "Shift+F3" -command "$this find_string 2" \
-image ::ICONS::16::1uparrow -underline 8
# Create Mode menu
set ::HexEditDlg::mode_${obj_idx} $mode
- $mode_menu add radiobutton -label "HEX" \
+ $mode_menu add radiobutton -label [mc "HEX"] \
-variable ::HexEditDlg::mode_${obj_idx} \
-indicatoron 0 -compound left -image ::ICONS::raoff \
-selectimage ::ICONS::raon -value {hex} -underline 0 \
-command [list $this adjust_mode]
- $mode_menu add radiobutton -label "DEC" \
+ $mode_menu add radiobutton -label [mc "DEC"] \
-variable ::HexEditDlg::mode_${obj_idx} \
-indicatoron 0 -compound left -image ::ICONS::raoff \
-selectimage ::ICONS::raon -value {dec} -underline 0 \
-command [list $this adjust_mode]
- $mode_menu add radiobutton -label "OCT" \
+ $mode_menu add radiobutton -label [mc "OCT"] \
-variable ::HexEditDlg::mode_${obj_idx} \
-indicatoron 0 -compound left -image ::ICONS::raoff \
-selectimage ::ICONS::raon -value {oct} -underline 0 \
-command [list $this adjust_mode]
# Create Main menu
- $mainmenu add cascade -label "File" -underline 0 -menu $file_menu
- $mainmenu add cascade -label "Edit" -underline 0 -menu $edit_menu
- $mainmenu add cascade -label "Mode" -underline 0 -menu $mode_menu
+ $mainmenu add cascade -label [mc "File"] -underline 0 -menu $file_menu
+ $mainmenu add cascade -label [mc "Edit"] -underline 0 -menu $edit_menu
+ $mainmenu add cascade -label [mc "Mode"] -underline 0 -menu $mode_menu
$win configure -menu $mainmenu
}
@@ -462,8 +467,8 @@ class HexEditDlg {
bind $wdg <Leave> [list $this sbar_show {}]
}
- ## Create hexeditor and entryboxes for address and value
- # @parm Widget middle_frame - Frame for hexeditor
+ ## Create hex editor and entryboxes for address and value
+ # @parm Widget middle_frame - Frame for hex editor
# @parm Widget bottom_frame - Frame for entryboxes
# @return void
private method create_middle_bottom_frame {middle_frame bottom_frame} {
@@ -475,7 +480,7 @@ class HexEditDlg {
set hexeditor [HexEditor editor${obj_idx} $middle_frame 16 $hg 4 $mode 1 0 16 $capacity]
if {$current_view == {left}} {
$hexeditor focus_left_view
- } {
+ } else {
$hexeditor focus_right_view
}
$hexeditor setCurrentCell $cell
@@ -535,7 +540,7 @@ class HexEditDlg {
if {$type == {code}} {
if {[$project is_frozen]} {
set state normal
- } {
+ } else {
set state disabled
}
@@ -624,7 +629,7 @@ class HexEditDlg {
$project rightPanel_watch_sync $hex_addr
# Code memory
- } {
+ } else {
$project setCodeDEC $addr $val
}
}
@@ -639,7 +644,7 @@ class HexEditDlg {
set modified $bool
if {$modified} {
wm title $win "\[modified\] [wm title $win]"
- } {
+ } else {
wm title $win [string range [wm title $win] 11 end]
}
}
@@ -647,7 +652,7 @@ class HexEditDlg {
## Parse given data (IHEX-8 and load it into the editor + sync with external components)
# @parm String hex_data - input data
- # @return void
+ # @return Bool - 1 == success; 0 == failure
private method readHex {hex_data} {
# Any EOL -> LF
regsub -all {\r\n?} $hex_data "\n" hex_data
@@ -657,7 +662,7 @@ class HexEditDlg {
# Local variables
set pointer 0 ;# Current address
set line_number 0 ;# Number of the current line
- set errors_count 0 ;# Number of errors occured while parsing ihex file
+ set errors_count 0 ;# Number of errors occurred while parsing ihex file
set eof 0 ;# Bool: EOF detected
set error_string {} ;# Text of error message
@@ -736,7 +741,7 @@ class HexEditDlg {
set number [string range $data $i $j]
if {$type == {uni}} {
$hexeditor setValue $pointer [expr "0x$number"]
- } {
+ } else {
write_to_simulator $pointer [expr "0x$number"]
}
incr pointer
@@ -752,7 +757,7 @@ class HexEditDlg {
# Invoke error dialog
if {$errors_count} {
# Create dialog window
- set dialog [toplevel .error_message_dialog -bg {#EEEEEE}]
+ set dialog [toplevel $win.error_message_dialog -bg ${::COMMON_BG_COLOR}]
# Create main frame (text widget and scrolbar)
set main_frame [frame $dialog.main_frame]
@@ -785,13 +790,16 @@ class HexEditDlg {
# Set window attributes
wm iconphoto $dialog ::ICONS::16::no
- wm title $dialog [mc "Error(s) occured while parsing IHEX file"]
+ wm title $dialog [mc "Error(s) occurred while parsing IHEX file"]
wm minsize $dialog 500 250
wm protocol $dialog WM_DELETE_WINDOW "grab release $dialog; destroy $dialog"
wm transient $dialog $win
grab $dialog
raise $dialog
tkwait window $dialog
+ return 0
+ } else {
+ return 1
}
}
@@ -806,7 +814,7 @@ class HexEditDlg {
set hexlen 2
set octlen 3
set binlen 8
- } {
+ } else {
set hexlen 4
set octlen 7
set binlen 16
@@ -818,7 +826,7 @@ class HexEditDlg {
set oct {}
set bin {}
# Non empty value -> convert
- } {
+ } else {
# To hexadecimal
set hex [format %X $value]
set len [string length $hex]
@@ -903,7 +911,7 @@ class HexEditDlg {
sbar_show {}
}
- ## This method should be called after value change in hexeditor
+ ## This method should be called after value change in hex editor
# This method writes new value to simulator engine, watchers and EntryBoxes
# @parm Int addr - Address of changed cell
# @parm int val - New value of the entry
@@ -917,7 +925,7 @@ class HexEditDlg {
set validation_ena 1
}
- ## This method should be called after current cell change in hexeditor
+ ## This method should be called after current cell change in hex editor
# Synchronizes EntryBoxes
# @parm Int addr - New cell address
# @return void
@@ -945,7 +953,7 @@ class HexEditDlg {
# Check for valid characters
if {$valtype == {val}} {
set m 1
- } {
+ } else {
set m 2
}
set len [string length $value]
@@ -998,7 +1006,7 @@ class HexEditDlg {
set validation_ena 1
return 0
}
- } {
+ } else {
if {$value >= $capacity} {
set validation_ena 1
return 0
@@ -1010,7 +1018,7 @@ class HexEditDlg {
if {$valtype == {val}} {
$hexeditor setValue $current_cell $value
write_to_simulator $current_cell $value
- } {
+ } else {
set current_cell $value
$hexeditor setCurrentCell $value
}
@@ -1026,11 +1034,11 @@ class HexEditDlg {
# @return void
public method prog_jump {} {
if {$type != {code}} {return}
- $project setPC [subst "\$::HexEditDlg::dec_addr_${obj_idx}"]
+ $project setPC [subst -nocommands "\$::HexEditDlg::dec_addr_${obj_idx}"]
set lineNum [$project simulator_getCurrentLine]
if {$lineNum != {}} {
$project move_simulator_line $lineNum
- } {
+ } else {
$project editor_procedure {} unset_simulator_line {}
}
$project Simulator_sync_PC_etc
@@ -1040,11 +1048,11 @@ class HexEditDlg {
# @return void
public method sub_call {} {
if {$type != {code}} {return}
- $project simulator_subprog_call [subst "\$::HexEditDlg::dec_addr_${obj_idx}"]
+ $project simulator_subprog_call [subst -nocommands "\$::HexEditDlg::dec_addr_${obj_idx}"]
set lineNum [$project simulator_getCurrentLine]
if {$lineNum != {}} {
$project move_simulator_line $lineNum
- } {
+ } else {
$project editor_procedure {} unset_simulator_line {}
}
$project Simulator_sync_PC_etc
@@ -1053,10 +1061,10 @@ class HexEditDlg {
## Adjust view mode to state of mode menu
# @return void
public method adjust_mode {} {
- $mode_combo_box current [lsearch {hex dec oct} [subst "\$::HexEditDlg::mode_${obj_idx}"]]
+ $mode_combo_box current [lsearch {hex dec oct} [subst -nocommands "\$::HexEditDlg::mode_${obj_idx}"]]
sbar_show {Working ...}
update
- $hexeditor switch_mode [subst "\$::HexEditDlg::mode_${obj_idx}"]
+ $hexeditor switch_mode [subst -nocommands "\$::HexEditDlg::mode_${obj_idx}"]
sbar_show {Working}
}
@@ -1078,7 +1086,7 @@ class HexEditDlg {
}
if {$type == {uni}} {
delete object $this
- } {
+ } else {
::X::close_hexedit $type $project
}
}
@@ -1102,7 +1110,7 @@ class HexEditDlg {
if {$type == {code}} {
$left_sbar_label configure -text \
[mc [lindex $HELPFILE_CODE [list $help_file_index $entry_index]]]
- } {
+ } else {
$left_sbar_label configure -text \
[mc [lindex $HELPFILE_XDATA [list $help_file_index $entry_index]]]
}
@@ -1189,6 +1197,19 @@ class HexEditDlg {
# Reload content of HexEditor
# @return void
public method reload {} {
+
+ if {$modified} {
+ set response [tk_messageBox \
+ -parent $win \
+ -type yesno \
+ -icon warning \
+ -title [mc "File modified"] \
+ -message [mc "Content of the hex editor has been changed.\nDo you really want to reload without saving it?"]]
+ if {$response == {no}} {
+ return
+ }
+ }
+
# Store original cursor position
set current_cursor_pos [$hexeditor getCurrentCell]
@@ -1198,7 +1219,7 @@ class HexEditDlg {
if {$ext != {} && $opened_file != {}} {
open_file $opened_file $ext
}
- } {
+ } else {
refresh
}
@@ -1209,21 +1230,21 @@ class HexEditDlg {
}
## Action for Menu/Toolbar - Save as
- # Save current content of hexeditor as IHEX8 file and ask for file name
+ # Save current content of hex editor as IHEX8 file and ask for file name
# @return void
public method saveas {} {
set directory [file dirname $opened_file]
if {$type == {uni}} {
if {${::X::project_menu_locked}} {
set project {}
- } {
+ } else {
set project ${::X::actualProject}
}
}
if {$directory == {.}} {
if {$project == {}} {
set directory ${::X::defaultDirectory}
- } {
+ } else {
set directory [$project cget -projectPath]
}
}
@@ -1232,11 +1253,11 @@ class HexEditDlg {
-title [mc "Save file - MCU 8051 IDE"] \
-master $win \
-directory $directory \
- -initialfile [$middle_sbar_label cget -text] \
- -defaultmask 0 -multiple 0 -filetypes {
- {{IHEX8} {*.{hex,ihx}} }
- {{All files} {*} }
- }
+ -initialfile [$middle_sbar_label cget -text] \
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Intel 8 HEX"] {*.{hex,ihx}} ] \
+ [list [mc "All files"] {*} ] \
+ ]
fsd setokcmd "$this save_file_proc \[::HexEditDlg::fsd get\]"
fsd activate
}
@@ -1259,14 +1280,14 @@ class HexEditDlg {
if {$type == {uni}} {
if {${::X::project_menu_locked}} {
set project {}
- } {
+ } else {
set project ${::X::actualProject}
}
}
if {$directory == {.}} {
if {$project == {}} {
set directory ${::X::defaultDirectory}
- } {
+ } else {
set directory [$project cget -projectPath]
}
}
@@ -1274,10 +1295,10 @@ class HexEditDlg {
KIFSD::FSD fsd \
-title [mc "Open file - MCU 8051 IDE"] \
-master $win -directory $directory \
- -defaultmask 0 -multiple 0 -filetypes {
- {{IHEX8} {*.{hex,ihx}} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Intel 8 HEX"] {*.{hex,ihx}} ] \
+ [list [mc "All files"] {*} ] \
+ ]
fsd setokcmd "$this open_file \[::HexEditDlg::fsd get\] hex"
fsd activate
}
@@ -1294,10 +1315,10 @@ class HexEditDlg {
KIFSD::FSD fsd \
-title [mc "Open file - MCU 8051 IDE"] \
-master $win -directory $directory \
- -defaultmask 0 -multiple 0 -filetypes {
- {{Simulator file} {*.adb} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Simulator file"] {*.adb} ] \
+ [list [mc "All files"] {*} ] \
+ ]
fsd setokcmd "$this open_file \[::HexEditDlg::fsd get\] adf"
fsd activate
}
@@ -1305,7 +1326,7 @@ class HexEditDlg {
## Open the give file and load its contents into editor
# @parm String filename - Relative or absolute filename
# @parm String extension - Fily type {adf hex}
- # @return void
+ # @return Bool - 1 == success; 0 == failure
public method open_file {filename extension} {
# Store original cursor position
set current_cursor_pos [$hexeditor getCurrentCell]
@@ -1316,14 +1337,14 @@ class HexEditDlg {
if {$type == {uni}} {
if {${::X::project_menu_locked}} {
set project {}
- } {
+ } else {
set project ${::X::actualProject}
}
}
if {$directory == {.}} {
if {$project == {}} {
set directory ${::X::defaultDirectory}
- } {
+ } else {
set directory [$project cget -projectPath]
}
}
@@ -1331,8 +1352,8 @@ class HexEditDlg {
if {![regexp "^(~|/)" $filename]} {
set filename "$directory/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
set filename [file join $directory $filename]
}
}
@@ -1347,20 +1368,20 @@ class HexEditDlg {
-icon warning \
-title [mc "Permission denied"] \
-message [mc "Unable to open file:\n%s" $filename]
- return
+ return 0
}
# Clear editor
if {$type == {uni}} {
$hexeditor fill_views
- } {
+ } else {
$project simulator_clear_memory $type
}
# Load contents
if {$extension == {adf}} {
$project load_program_from_adf $filename
- } {
+ } else {
readHex [read $file]
}
@@ -1373,6 +1394,8 @@ class HexEditDlg {
update
$hexeditor setCurrentCell $current_cursor_pos
$hexeditor seeCell $current_cursor_pos
+
+ return 1
}
## Save content of the editor into the given file in format IHEX8
@@ -1386,14 +1409,14 @@ class HexEditDlg {
if {$type == {uni}} {
if {${::X::project_menu_locked}} {
set project {}
- } {
+ } else {
set project ${::X::actualProject}
}
}
if {$directory == {.}} {
if {$project == {}} {
set directory ${::X::defaultDirectory}
- } {
+ } else {
set directory [$project cget -projectPath]
}
}
@@ -1402,7 +1425,7 @@ class HexEditDlg {
set filename "$directory/$filename"
}
} { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
+ if {![regexp {^\w:} $filename]} {
set filename [file join $directory $filename]
}
}
@@ -1411,7 +1434,7 @@ class HexEditDlg {
if {![regexp {\.(hex|ihx)$} $filename]} {
if {$type != {code} && $type != {uni} } {
append filename {.xdata.hex}
- } {
+ } else {
append filename {.hex}
}
}
@@ -1431,7 +1454,7 @@ class HexEditDlg {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $filename]]
] != {yes}
- } {
+ } then {
return
}
# Create a backup file
@@ -1458,8 +1481,8 @@ class HexEditDlg {
# Open file
if {[catch {
- set file [open $filename w 420]
- }]} {
+ set file [open $filename w 0640]
+ }]} then {
tk_messageBox \
-parent $win \
-type ok \
@@ -1560,11 +1583,14 @@ class HexEditDlg {
}
# Save EOF
- puts -nonewline $file {:00000001FF}
+ puts $file {:00000001FF}
# Done ...
close $file
setModified 0
+ if {$::MICROSOFT_WINDOWS} { ;# "/" --> "\"
+ regsub -all {/} $filename "\\" filename
+ }
sbar_show [mc "File %s saved" $filename]
}
@@ -1595,7 +1621,7 @@ class HexEditDlg {
# GENERAL PUBLIC INTERFACE
# -------------------------------------------------------------------
- ## Inform hexeditor about simulator start or shutdown
+ ## Inform hex editor about simulator start or shutdown
# @parm Bool started - 1 == Simulator started; 0 == Simulator stopped
# @return void
public method simulator_stared_stopped {started} {
@@ -1605,7 +1631,7 @@ class HexEditDlg {
if {$started} {
set state {normal}
- } {
+ } else {
set state {disabled}
}
$sub_call_but configure -state $state
@@ -1614,7 +1640,8 @@ class HexEditDlg {
[$hexeditor get_popup_menu] entryconfigure [::mc "LCALL this_address"] -state $state
}
- ## Move program pointer (highlight cells) -- Avaliable only for code memory hexeditor
+ ## Move program pointer (highlight cells)
+ # -- available only for code memory hex editor
# @parm Int new_PC - New program counter
# @parm Int int_length - Instruction length
# @return void
@@ -1647,12 +1674,14 @@ class HexEditDlg {
for {set i 0} {$i < $int_length} {incr i} {
$hexeditor set_bg_hg $new_PC 1 2
+ $hexeditor set_bg_hg $new_PC 0 1
incr new_PC
}
$hexeditor seeCell $new_PC
}
- ## Directly move program pointer (do not affect previous PC pointer) -- Avaliable only for code memory hexeditor
+ ## Directly move program pointer (do not affect previous PC pointer)
+ # -- available only for code memory hex editor
# @parm Int new_PC - New program counter (-1 == unresolved)
# @parm Int int_length - Instruction length
# @return void
@@ -1697,7 +1726,7 @@ class HexEditDlg {
}
## Write value to the editor
- # - avaliable only in modes: XDATA and ERAM
+ # - available only in modes: XDATA and ERAM
# @parm String address - hexadecimal address
# @return void
public method reg_sync {address} {
@@ -1733,7 +1762,7 @@ class HexEditDlg {
set loaded_lines [string repeat [string repeat 0 0xFF] 0xFF]
load_data_to_current_view
- setModified 1
+ setModified 0
}
## Get configuration list
@@ -1752,7 +1781,7 @@ class HexEditDlg {
set cell [lindex $config 2]
set current_view [lindex $config 3]
- # load configuration for hexeditor widget
+ # load configuration for hex editor widget
::HexEditor::load_config_list [lindex $config 4]
# Validate loaded values
@@ -1785,9 +1814,13 @@ class HexEditDlg {
if {$type == {uni}} {
if {$modified} {
wm title $win "\[modified\] $filename - [mc {Hexadecimal editor}] - MCU 8051 IDE"
- } {
+ } else {
wm title $win "$filename - [mc {Hexadecimal editor}] - MCU 8051 IDE"
}
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard