summaryrefslogtreecommitdiff
path: root/lib/lib/hexeditor.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lib/hexeditor.tcl')
-rw-r--r--[-rwxr-xr-x]lib/lib/hexeditor.tcl311
1 files changed, 197 insertions, 114 deletions
diff --git a/lib/lib/hexeditor.tcl b/lib/lib/hexeditor.tcl
index ceb9192..fc3c5e6 100755..100644
--- a/lib/lib/hexeditor.tcl
+++ b/lib/lib/hexeditor.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,31 +21,43 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _HEXEDITOR_TCL ] } {
+set _HEXEDITOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# This class provides simple hexeditor with selectable view mode
+# This class provides simple hex editor with selectable view mode
# and optional ascii view. See constructor and section
# "GENERAL PUBLIC INTERFACE" for more details.
# --------------------------------------------------------------------------
class HexEditor {
- common DEBUG 0 ;# Bool: More secure input data checking
# Font for editor text widget(s) - normal size
- common view_font_n [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -15 \
- ]
+ if {!$::MICROSOFT_WINDOWS} {
+ common view_font_n [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-15 * $::font_size_factor)}] \
+ ]
+ } else {
+ common view_font_n [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-15 * $::font_size_factor)}] \
+ -weight bold \
+ ]
+ }
# Font for editor headers - normal size
- common header_font_n [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -15 \
- -weight bold \
+ common header_font_n [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-15 * $::font_size_factor)}] \
+ -weight bold \
]
# Font for editor headers - small size
- common header_font_s [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ common header_font_s [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
common view_font_s $header_font_s ;# Font for editor text widget(s) - small size
common header_bg {#9999FF} ;# Background color for headers
@@ -103,7 +115,7 @@ class HexEditor {
private variable in_cell 0 ;# Bool: mouse pointer in cell (see code below)
private variable motion_binding 0 ;# Bool: Bindings for special mouse events set
private variable view_mode ;# Current view mode (one of {dec hec oct bin})
- private variable ascii_view ;# Bool: Ascii view avaliable
+ private variable ascii_view ;# Bool: Ascii view available
private variable address_length ;# Int: Length of addresses on left address bar
private variable physical_height ;# Int: Height of view in rows
private variable width ;# Int: Number of cells in left view in one row
@@ -162,7 +174,7 @@ class HexEditor {
if {$small} {
set view_font $view_font_s
set header_font $header_font_s
- } {
+ } else {
set view_font $view_font_n
set header_font $header_font_n
}
@@ -189,6 +201,11 @@ class HexEditor {
catch {
destroy $main_frame
}
+
+ # Remove find dialog window if exists
+ if {[winfo exists $find_dialog_win]} {
+ destroy $find_dialog_win
+ }
}
## Create popup menu (for left & right view)
@@ -210,14 +227,17 @@ class HexEditor {
"find_next" {1downarrow} {}}
{command {Find previous} {Shift+F3} 8
"find_prev" {1uparrow} {}}
- } $popup_menu 0 "$this " 0 {}
+ {separator}
+ {command {Fill with pseudo-random values} {} 0
+ "text_random" {} {}}
+ } $popup_menu 0 "$this " 0 {} [namespace current]
# Configure menu entries
$popup_menu entryconfigure [::mc "Find next"] -state disabled
$popup_menu entryconfigure [::mc "Find previous"] -state disabled
}
- ## Create all hexeditor widgets expect popup menu
+ ## Create all hex editor widgets expect popup menu
# @return void
private method create_gui {} {
# Determinate width of left view text widget and cell width
@@ -240,13 +260,16 @@ class HexEditor {
}
# Create button "Select All" in left top corner
- set left_top_button [button $main_frame.left_top_button \
- -bg $header_bg -bd 0 -padx 0 -pady 0 \
- -activebackground white -relief flat \
- -highlightthickness 0 \
- -command "$main_frame.left_view tag add sel 1.0 end" \
- ]
- DynamicHelp::add $main_frame.left_top_button -text [mc "Select all"]
+ if {!$::MICROSOFT_WINDOWS} {
+ set left_top_button [button $main_frame.left_top_button \
+ -bg $header_bg -bd 0 -padx 0 -pady 0 \
+ -activebackground white -relief flat \
+ -highlightthickness 0 \
+ -command "$main_frame.left_view tag add sel 1.0 end" \
+ ]
+ DynamicHelp::add $main_frame.left_top_button -text [mc "Select all"]
+ grid $left_top_button -row 0 -column 0 -sticky nsew
+ }
# Create left address bar
set left_address_bar [text $main_frame.left_address_bar \
-height $physical_height -width $address_length \
@@ -256,7 +279,6 @@ class HexEditor {
-yscrollcommand "$this scrollSet" \
-cursor left_ptr \
]
- grid $left_top_button -row 0 -column 0 -sticky nsew
grid $left_address_bar -row 1 -column 0 -sticky ns
# Create horizontal header for left view
@@ -315,7 +337,7 @@ class HexEditor {
grid rowconfigure $main_frame 1 -weight 1
}
- ## Create event bindings for all hexeditor widgets (except popup menu)
+ ## Create event bindings for all hex editor widgets (except popup menu)
# @return void
private method create_bindings {} {
## LEFT PART
@@ -363,6 +385,8 @@ class HexEditor {
} {
bind $left_view $key "[bind Text $key]; break"
}
+ bind $left_view <Double-Button-1> {break}
+ bind $left_view <Triple-Button-1> {break}
bind $left_view <Button-4> "$this scroll scroll -3 units"
bind $left_view <Button-5> "$this scroll scroll +3 units"
@@ -430,6 +454,8 @@ class HexEditor {
} {
bind $right_view $key "[bind Text $key]; break"
}
+ bind $right_view <Double-Button-1> {break}
+ bind $right_view <Triple-Button-1> {break}
bind $right_view <Button-4> "$this scroll scroll -3 units"
bind $right_view <Button-5> "$this scroll scroll +3 units"
@@ -449,31 +475,35 @@ class HexEditor {
-background $current_full_bg \
-foreground {#000000}
# Cursor position for active view and inactive view
- foreach widget [list $left_header $left_view] {
+ foreach widget [list $left_header $left_view] \
+ font [list $header_font $view_font] \
+ {
$widget tag configure tag_current_full \
- -font $header_font \
+ -font $font \
-background $current_full_bg \
-foreground {#000000}
$widget tag configure tag_current_half \
- -font $header_font \
+ -font $font \
-background $current_half_bg \
-foreground {#000000}
}
# Nth row backrgound
- $left_view tag configure tag_n_row -background $n_row_bg
+ $left_view tag configure tag_n_row \
+ -background $n_row_bg \
+ -font $view_font
# Cell highlight
$left_view tag configure tag_hg \
-foreground $highlight_fg \
- -font $header_font
+ -font $view_font
$left_view tag configure tag_bg_hg \
-background $highlight_bg \
- -font $header_font
+ -font $view_font
$left_view tag configure tag_bg_hg1 \
-background $highlight_bg1 \
- -font $header_font
+ -font $view_font
$left_view tag configure tag_bg_hg2 \
-background $highlight_bg2 \
- -font $header_font
+ -font $view_font
# Other tags
$left_view tag configure normal_font \
-font $view_font
@@ -525,28 +555,30 @@ class HexEditor {
# Cursor position for active view
$right_view tag configure tag_current_full \
- -font $header_font \
+ -font $view_font \
-background $current_full_bg
# Cursor position for inactive view
$right_view tag configure tag_current_half \
- -font $header_font \
+ -font $view_font \
-background $current_half_bg
# Nth row backrgound
- $right_view tag configure tag_n_row -background $n_row_bg
+ $right_view tag configure tag_n_row \
+ -background $n_row_bg \
+ -font $view_font
# Cell highlight
$right_view tag configure tag_hg \
-foreground $highlight_fg \
- -font $header_font
+ -font $view_font
$right_view tag configure tag_bg_hg \
-background $highlight_bg \
- -font $header_font
+ -font $view_font
$right_view tag configure tag_bg_hg1 \
-background $highlight_bg1 \
- -font $header_font
+ -font $view_font
$right_view tag configure tag_bg_hg2 \
-background $highlight_bg2 \
- -font $header_font
+ -font $view_font
# Other tags
$right_view tag configure normal_font \
@@ -638,7 +670,7 @@ class HexEditor {
$left_header delete 1.0 end
if {$view_mode == {hex}} {
set space { }
- } {
+ } else {
$left_header insert end { }
set space { }
}
@@ -704,7 +736,7 @@ class HexEditor {
if {$cell} {
if {$view_mode != {hex}} {
set start_col [expr {$cell * 4}]
- } {
+ } else {
set start_col [expr {$cell * 3}]
}
}
@@ -713,7 +745,7 @@ class HexEditor {
set end_col $start_col
if {$view_mode != {hex}} {
incr end_col 3
- } {
+ } else {
incr end_col 2
}
@@ -730,13 +762,13 @@ class HexEditor {
if {$view == {left}} {
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
scan [$left_view index $index] {%d.%d} row col
set cell [expr {($col / $step)}]
# Right view
- } {
+ } else {
scan [$right_view index $index] {%d.%d} row cell
}
@@ -751,7 +783,7 @@ class HexEditor {
private method col_to_start_end {col} {
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
@@ -835,7 +867,7 @@ class HexEditor {
if {($col % 4) == 3} {
set index [$left_view index "$index+1c"]
}
- } {
+ } else {
if {($col % 3) == 2} {
set index [$left_view index "$index+1c"]
}
@@ -854,7 +886,7 @@ class HexEditor {
scan [$right_view index insert] {%d.%d} row cell
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
set cursor_address_original $cursor_address
@@ -933,6 +965,43 @@ class HexEditor {
}
}
+ ## Fill the selected are with random values
+ # @return void
+ public method text_random {} {
+ #
+ if {$selected_view == {left}} {
+ set view_widget $left_view
+
+ } elseif {$ascii_view && $selected_view == {right}} {
+ set view_widget $right_view
+
+ } else {
+ return
+ }
+
+ #
+ if {![llength [$view_widget tag nextrange sel 0.0]]} {
+ return
+ }
+
+ #
+ set start_address [index_to_address $selected_view [$view_widget index sel.first]]
+ set end_address [index_to_address $selected_view [$view_widget index sel.last]]
+
+ #
+ for {set i $start_address} {$i <= $end_address} {incr i} {
+ if {$i >= $total_capacity} {
+ break
+ }
+
+ set value [expr {int(256 * rand()) & 0x0ff}]
+ setValue $i $value
+ if {$cell_value_changed_cmd_set} {
+ eval "$cell_value_changed_cmd $i $value"
+ }
+ }
+ }
+
## Synchronize selection in right view with left view
# Binding for event <<Selection>>
# @return void
@@ -944,7 +1013,7 @@ class HexEditor {
if {![llength [$right_view tag nextrange sel 0.0]]} {
set selection_sync_in_P 0
set anything_selected 0
- } {
+ } else {
set anything_selected 1
}
@@ -968,7 +1037,7 @@ class HexEditor {
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
@@ -1033,7 +1102,7 @@ class HexEditor {
eval $scroll_action_cmd
}
- update idle
+ update idletasks
set scroll_in_progress 0
}
@@ -1050,7 +1119,7 @@ class HexEditor {
if {![llength [$left_view tag nextrange sel 0.0]]} {
set selection_sync_in_P 0
set anything_selected 0
- } {
+ } else {
set anything_selected 1
}
@@ -1106,7 +1175,7 @@ class HexEditor {
# Get clipboard contents
if {[catch {
set text [clipboard get]
- }]} {
+ }]} then {
set text {}
}
# If clipboard empty then return
@@ -1316,7 +1385,7 @@ class HexEditor {
}
}
- ## Invoke hexeditor popup menu
+ ## Invoke hex editor popup menu
# @parm String side - "left" or "right"
# @parm Int x - Relative mouse pointer position
# @parm Int y - Relative mouse pointer position
@@ -1328,7 +1397,7 @@ class HexEditor {
if {$selected_view == {left}} {
set widget $left_view
left_view_move_insert $x $y
- } {
+ } else {
set widget $right_view
}
@@ -1343,16 +1412,16 @@ class HexEditor {
# Configure popup menu
if {[llength [$widget tag nextrange sel 0.0]]} {
$popup_menu entryconfigure [::mc "Copy"] -state normal
- } {
+ } else {
$popup_menu entryconfigure [::mc "Copy"] -state disabled
}
if {[catch {
if {[string length [clipboard get]]} {
$popup_menu entryconfigure [::mc "Paste"] -state normal
- } {
+ } else {
$popup_menu entryconfigure [::mc "Paste"] -state disabled
}
- }]} {
+ }]} then {
$popup_menu entryconfigure [::mc "Paste"] -state disabled
}
@@ -1449,7 +1518,7 @@ class HexEditor {
if {($val < 127) && [string is print -strict $char]} {
$right_view insert $cell $char
$right_view tag remove tag_np $cell "$cell+1c"
- } {
+ } else {
$right_view insert $cell {.}
$right_view tag add tag_np $cell "$cell+1c"
}
@@ -1459,7 +1528,7 @@ class HexEditor {
# Adjust insertion cursor
if {($row == $height) && ($col >= ($left_view_width - 1))} {
left_view_adjust_cursor
- } {
+ } else {
left_view_movement 0 Right
}
}
@@ -1541,7 +1610,7 @@ class HexEditor {
}
if {$col == $col_s} {
set correction {-2c}
- } {
+ } else {
set correction {-1c}
}
}
@@ -1552,7 +1621,7 @@ class HexEditor {
}
if {$col == $col_e} {
set correction {+2c}
- } {
+ } else {
set correction {+1c}
}
}
@@ -1599,10 +1668,10 @@ class HexEditor {
# Adjust selection
if {!$select} {
set cur_idx [$left_view index insert]
- } {
+ } else {
if {[$left_view compare $cur_idx <= insert]} {
$left_view tag add sel $cur_idx insert
- } {
+ } else {
$left_view tag add sel insert $cur_idx
}
}
@@ -1687,7 +1756,7 @@ class HexEditor {
scan $index {%d.%d} row col
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
@@ -1730,13 +1799,13 @@ class HexEditor {
return $popup_menu
}
- ## Get list of values from hexeditor
+ ## Get list of values from hex editor
# @parm Int start - Start address
# @parm Int end - End address
# @return List - List of decimal values (e.g. {0 226 {} {} 126 {} 6 8})
public method get_values {start end} {
# Check for allowed address range
- if {$DEBUG} {
+ if {${::DEBUG}} {
if {$end >= $total_capacity} {
error "Address out of range"
}
@@ -1764,7 +1833,7 @@ class HexEditor {
if {$view_mode != {hex}} {
set step 4
set len 3
- } {
+ } else {
set step 3
set len 2
}
@@ -1813,7 +1882,7 @@ class HexEditor {
if {$start == $end} {
return [lindex $result 0]
- } {
+ } else {
return $result
}
}
@@ -1837,7 +1906,7 @@ class HexEditor {
$left_view delete $row.$start_col $row.$end_col
if {$view_mode != {hex}} {
$left_view insert $row.$start_col { }
- } {
+ } else {
$left_view insert $row.$start_col { }
}
$left_view mark set insert $index
@@ -1854,7 +1923,7 @@ class HexEditor {
if {$cursor_address == $address} {
if {$selected_view == {left}} {
left_view_adjust_cursor
- } {
+ } else {
right_view_adjust_cursor
}
}
@@ -1867,7 +1936,7 @@ class HexEditor {
}
# Validate input address and value
- if {$DEBUG} {
+ if {${::DEBUG}} {
if {$address >= $total_capacity} {
error "Address out of range"
}
@@ -1926,7 +1995,7 @@ class HexEditor {
if {($original_value < 127) && [string is print -strict $value]} {
$right_view insert $row.$cell $value
$right_view tag remove tag_np $row.$cell "$row.$cell+1c"
- } {
+ } else {
$right_view insert $row.$cell {.}
$right_view tag add tag_np $row.$cell $row.$end_col
}
@@ -1945,7 +2014,7 @@ class HexEditor {
if {$cursor_address == $address} {
if {$selected_view == {left}} {
left_view_adjust_cursor
- } {
+ } else {
right_view_adjust_cursor
}
}
@@ -1962,7 +2031,7 @@ class HexEditor {
}
if {$selected_view == {left}} {
focus $right_view
- } {
+ } else {
focus $left_view
}
}
@@ -1994,7 +2063,7 @@ class HexEditor {
# @return void
public method set_bg_hg {address bool type} {
# Validate input address
- if {$DEBUG} {
+ if {${::DEBUG}} {
if {$address >= $total_capacity} {
error "Address out of range"
}
@@ -2020,7 +2089,7 @@ class HexEditor {
set tag {tag_bg_hg2}
}
}
- if {[subst "\$${arr}($address)"] == $bool} {
+ if {[subst -nocommands "\$${arr}($address)"] == $bool} {
return
}
set ${arr}($address) $bool
@@ -2035,7 +2104,7 @@ class HexEditor {
# Create highlight
if {$bool} {
set bool {add}
- } {
+ } else {
set bool {remove}
}
$left_view tag $bool $tag $row.$start_col $row.$end_col
@@ -2050,7 +2119,7 @@ class HexEditor {
# @return void
public method setHighlighted {address bool} {
# Validate input address
- if {$DEBUG} {
+ if {${::DEBUG}} {
if {$address >= $total_capacity} {
error "Address out of range"
}
@@ -2077,7 +2146,7 @@ class HexEditor {
# Create highlight
if {$bool} {
set bool {add}
- } {
+ } else {
set bool {remove}
}
$left_view tag $bool tag_hg $row.$start_col $row.$end_col
@@ -2152,7 +2221,7 @@ class HexEditor {
$left_view mark set insert $row.$start_col
$left_view see insert
left_view_adjust_cursor
- } {
+ } else {
$right_view mark set insert $row.$cell
$right_view see insert
right_view_adjust_cursor
@@ -2177,7 +2246,7 @@ class HexEditor {
# Adjust cursor
if {$selected_view == {left}} {
$left_view see $row.$start_col
- } {
+ } else {
$right_view see $row.$cell
}
}
@@ -2256,7 +2325,7 @@ class HexEditor {
[index_to_address {left} [$left_view index sel.first+1c]] \
[index_to_address {left} [$left_view index sel.last-1c]] \
]
- } {
+ } else {
return {}
}
}
@@ -2340,13 +2409,13 @@ class HexEditor {
foreach val $values {
if {!$first} {
$left_view insert $lineend { }
- } {
+ } else {
set first 0
}
if {$val == {}} {
$left_view insert $lineend $space
continue
- } {
+ } else {
set val [string trimleft $val 0]
if {$val == {}} {
set val 0
@@ -2358,7 +2427,7 @@ class HexEditor {
set val [expr "0x$val"]
# HEX -> OCT
- } {
+ } else {
set val [expr "0x$val"]
set val [format {%o} $val]
}
@@ -2369,7 +2438,7 @@ class HexEditor {
set val [format %X $val]
# DEC -> OCT
- } {
+ } else {
set val [format %o $val]
}
}
@@ -2380,7 +2449,7 @@ class HexEditor {
set val [format %X $val]
# OCT -> DEC
- } {
+ } else {
set val [expr "0$val"]
}
}
@@ -2418,31 +2487,39 @@ class HexEditor {
}
}
- ## Set hexeditor enabled/disabled state
+ ## Set hex editor enabled/disabled state
# @parm Bool bool - 1 == enabled; 0 == disabled
# @return void
public method setDisabled {bool} {
set disabled $bool
- # Set state for left view
if {$bool} {
- $left_view configure -state disabled
+ set state {disabled}
+ } else {
+ set state {normal}
+ }
+
+ # Set state for the left view
+ $left_view configure -state $state
+ if {$bool} {
$left_view configure -bg {#F8F8F8} -fg {#999999} ;#DDDDDD
- } {
- $left_view configure -state normal
+ } else {
$left_view configure -bg {#FFFFFF} -fg {#000000}
}
- # Set state for right view
+ # Set state for the right view
if {$ascii_view} {
+ $right_view configure -state $state
if {$bool} {
- $right_view configure -state disabled
$right_view configure -bg {#F8F8F8} -fg {#999999} ;#DDDDDD
- } {
- $right_view configure -state normal
+ } else {
$right_view configure -bg {#FFFFFF} -fg {#000000}
}
}
+
+ # Set state for certain menu entries
+ $popup_menu entryconfigure [::mc "Paste"] -state $state
+ $popup_menu entryconfigure [::mc "Fill with pseudo-random values"] -state $state
}
## Get reference of left view text widget
@@ -2481,7 +2558,7 @@ class HexEditor {
}
}
- ## Find next occurence of search string
+ ## Find next occurrence of search string
# @return Bool - 0 == Invalid call; 1 == Valid call
public method find_next {} {
if {$last_find_index == {}} {
@@ -2489,13 +2566,13 @@ class HexEditor {
}
if {$find_opt(bw)} {
set result [find_FIND $last_find_index-[string length $text_to_find]c]
- } {
+ } else {
set result [find_FIND $last_find_index]
}
return $result
}
- ## Find previous occurence of search string
+ ## Find previous occurrence of search string
# @return Bool - 0 == Invalid call; 1 == Valid call
public method find_prev {} {
if {$last_find_index == {}} {
@@ -2507,7 +2584,7 @@ class HexEditor {
if {$find_opt(bw)} {
set result [find_FIND $last_find_index-[string length $text_to_find]c]
- } {
+ } else {
set result [find_FIND $last_find_index]
}
@@ -2518,10 +2595,12 @@ class HexEditor {
## Invoke dialog: Find string
# @return Bool - 1 == string found; 0 == string not found
public method find_dialog {} {
- # Create toplevel find_dialog_window
+ # Remove previous find dialog windows
if {[winfo exists $find_dialog_win]} {
destroy $find_dialog_win
}
+
+ # Create toplevel find_dialog_window
incr find_dialog_count
set find_dialog_win [toplevel .hex_editor_find_dialog_$find_dialog_count]
@@ -2579,13 +2658,13 @@ class HexEditor {
-compound left \
-image ::ICONS::16::ok \
-command "$this find_FIND" \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command "$this find_CANCEL" \
- ] -side left
+ ] -side left -padx 2
# Events binding (Enter == Find; Escape == Cancel)
bind $find_dialog_win <KeyRelease-Return> "$this find_FIND; break"
@@ -2594,7 +2673,7 @@ class HexEditor {
# Pack dialog frames
pack $top_frame -fill both -anchor nw -padx 5 -pady 5
- pack $buttonFrame -side bottom -anchor e -padx 5
+ pack $buttonFrame -side bottom -anchor e -padx 5 -pady 5
# Window manager options -- modal find_dialog_window
wm iconphoto $find_dialog_win ::ICONS::16::find
@@ -2613,7 +2692,7 @@ class HexEditor {
tkwait window $find_dialog_win
if {$last_find_index == {}} {
return 0
- } {
+ } else {
return 1
}
}
@@ -2629,18 +2708,18 @@ class HexEditor {
set start_index [lindex $args 0]
if {$where_to_search == {left}} {
set widget $left_view
- } {
+ } else {
set widget $right_view
}
if {$find_opt(bw)} {
set direction {-backwards}
- } {
+ } else {
set direction {-forwards}
}
if {$start_index == {}} {
if {$find_opt(fc)} {
set start_index [$widget index insert]
- } {
+ } else {
set start_index 1.0
}
}
@@ -2663,13 +2742,13 @@ class HexEditor {
set result 1
# String not found
- } {
+ } else {
$popup_menu entryconfigure [::mc "Find next"] -state disabled
$popup_menu entryconfigure [::mc "Find previous"] -state disabled
if {[winfo exists $find_dialog_win]} {
set parent $find_dialog_win
- } {
+ } else {
set $main_frame
}
tk_messageBox \
@@ -2703,3 +2782,7 @@ array set ::HexEditor::find_opt {
fc 1
bw 0
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard