Debian Codegraph @

lib/rightpanel/regwatches.tcl

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/bin/tclsh
2 # Part of MCU 8051 IDE ( http://http://www.moravia-microsystems.com/mcu8051ide )
3
4 ############################################################################
5 # Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
6 # [email protected] #
7 # #
8 # Copyright (C) 2014 by Moravia Microsystems, s.r.o. #
9 # [email protected] #
10 # #
11 # This program is free software; you can redistribute it and#or modify #
12 # it under the terms of the GNU General Public License as published by #
13 # the Free Software Foundation; either version 2 of the License, or #
14 # (at your option) any later version. #
15 # #
16 # This program is distributed in the hope that it will be useful, #
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
19 # GNU General Public License for more details. #
20 # #
21 # You should have received a copy of the GNU General Public License #
22 # along with this program; if not, write to the #
23 # Free Software Foundation, Inc., #
24 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
25 ############################################################################
26
27 # >>> File inclusion guard
28 if { ! [ info exists _REGWATCHES_TCL ] } {
29 set _REGWATCHES_TCL _
30 # <<< File inclusion guard
31
32 # --------------------------------------------------------------------------
33 # DESCRIPTION
34 # Implements register watches (part of Right Panel)
35 # --------------------------------------------------------------------------
36
37 class RegWatches {
38
39 ## COMMON
40 public common watches_set_shortcuts {} ;# Currently set shortcuts for register watches
41 public common watches_shortcuts_cat {watches} ;# Key shortcut categories related to register watches
42 # Counter of embedded entry widgets in register watches
43 public common watch_entry_count 0
44 # Conter of instances
45 public common regw_count 0
46 ## Highlighting tags for register watches
47 # {
48 # {tag_name foreground_color ?bold_or_italic?}
49 # ...
50 # }
51 public common watch_text_tags {
52 {tag_Baddr #DD0000 1}
53 {tag_Xaddr #AA00FF 1}
54 {tag_Eaddr #00AAFF 1}
55 {tag_addr #0000DD 1}
56 {tag_name #8888DD {}}
57 }
58 public common regfont [font create -family $::DEFAULT_FIXED_FONT -size [expr {int(-14 * $::font_size_factor)}]]
59 # Popup menu for register watches
60 public common WATCHMENU {
61 {command {Move top} {$watches:top} 0 "rightPanel_watch_move_top"
62 {top} "Move this register watch to the top of list"}
63 {command {Move up} {$watches:up} 0 "rightPanel_watch_move_up"
64 {1uparrow} "Move this register watch up"}
65 {command {Move down} {$watches:down} 1 "rightPanel_watch_move_down"
66 {1downarrow} "Move this register watch down"}
67 {command {Move bottom} {$watches:bottom} 2 "rightPanel_watch_move_bottom"
68 {bottom} "Move this register watch to the bottom of list"}
69 {separator}
70 {command {Remove} {$watches:remove} 2 "rightPanel_watch_remove"
71 {button_cancel} "Remove this register watch from the list"}
72 {separator}
73 {command {Remove all} {$watches:remove_all} 0 "rightPanel_watch_clear"
74 {editdelete} "Clear the list of register watches"}
75 {separator}
76 {command {Save} {} 0 "rightPanel_watch_save {} 1" {filesave}
77 "Save this list to a file"}
78 {command {Configure} {} 0 "rightPanel_configure 0" {configure}
79 "Configure this panel"}
80 }
81 # Configuration menu
82 public common CONFMENU {
83 {cascade "Sort by" 0 "" .sort false 1 {
84 {command "Name" {} 0 "rightPanel_watch_sort_by N" {}
85 ""}
86 {command "Address" {} 0 "rightPanel_watch_sort_by A" {}
87 ""}
88 {command "Type" {} 0 "rightPanel_watch_sort_by T" {}
89 ""}
90 {separator}
91 {radiobutton "Incremental" {} ::RegWatches::sorting_order 1
92 {} 0 ""}
93 {radiobutton "Decremental" {} ::RegWatches::sorting_order 0
94 {} 0 ""}
95 }}
96 {command "Remove all" {} 0 "rightPanel_watch_clear" {editdelete}
97 ""}
98 {separator}
99 {checkbutton "Autoload from code listing" {} {::RegWatches::menu_autoload} 1 0 0
100 {rightPanel_watch_toggle_autoload_flag}}
101 {checkbutton "Clear on auto-load" {} {::RegWatches::menu_autoclear} 1 0 0
102 {rightPanel_watch_toggle_autoclear_flag}}
103 }
104
105 ## PRIVATE
106 private variable enabled 0 ;# Bool: enable procedures which are needless while loading project
107 private variable obj_idx ;# Number of this object
108 private variable parent ;# Widget: parent widget
109 private variable regw_gui_initialized 0 ;# Bool: GUI initialized
110
111 private variable conf_button ;# Widget: Configuration button
112 private variable conf_menu {} ;# Configuration menu
113 private variable watch_menu ;# ID of popup menu for "Register watches"
114 private variable watch_text ;# ID of text widget representing list of register watches
115 private variable watch_remove_button ;# ID of button "Remove watch" - Register watches
116 private variable watch_new_button ;# ID of button "New watch" - Register watches
117 private variable watch_add_button ;# ID of button "Add watch" - Register watches
118 private variable watch_addr_entry ;# ID of entry "Address" - Register watches
119 private variable watch_search_entry ;# ID of entry "Search" - Register watches
120 private variable watch_search_clear ;# ID of button "Clear search entry" - Register watches
121
122 # Bool: Autoload from LST file
123 private variable autoload_flag [lindex $::CONFIG(REGWATCHES_CONFIG) 0]
124 private variable autoclear_flag [lindex $::CONFIG(REGWATCHES_CONFIG) 2]
125 private variable watches_modified 0 ;# Bool: Register watches definition modified
126 private variable search_val_in_progress 0 ;# Bool: Search entry validation in porgress
127 private variable watch_file_name {} ;# Name of file currently loaded in register watches
128 private variable watch_curLine 0 ;# Current line in list of register watches
129 private variable watch_AN_valid_ena 1 ;# Bool: Enable validation of address entry in register watches
130 private variable validator_engaged 0 ;# Bool: Address entry validation in progress
131 private variable watches_enabled 0 ;# Bool: Entry widgets in register watches enabled
132
133 private variable watch_addrs {} ;# List - {hex_addr hex_addr ...}
134 ## Array of Lists - info about particular watch
135 # format: $watch_data($hex_addr) -> {regName textVariable}
136 # note: embedded entry path == $watch_text.$textVariable
137 private variable watch_data
138
139
140 ## Object constructor
141 constructor {} {
142 incr regw_count
143 set obj_idx $regw_count
144 }
145
146 ## Object destructor
147 destructor {
148 if {$regw_gui_initialized} {
149 # Remove status bar tips for popup menus
150 menu_Sbar_remove $watch_menu
151
152 # Unallocate GUI related variables
153 unset RightPanel::watch_addr$obj_idx
154 unset RightPanel::watch_name$obj_idx
155 }
156 }
157
158 ## Prepare object for creating its GUI
159 # @parm Widget _parent - GUI parent widget
160 # @parm String watches_file - Definition file for register watches
161 # @return void
162 public method PrepareRegWatches {_parent filename} {
163 set parent $_parent
164 set watch_file_name $filename
165 set regw_gui_initialized 0
166 }
167
168 ## Create GUI of register watches
169 # @return void
170 public method CreateRegWatchesGUI {} {
171 if {$regw_gui_initialized} {return}
172 set regw_gui_initialized 1
173
174 # Top frame
175 set icon_bar [frame $parent.frm_rightPanel_watch_iconBar]
176 # Bottom frame
177 set text_frame [frame $parent.frm_rightPanel_watch_txt]
178 # Toolbar
179 set tool_bar [frame $parent.frm_rightPanel_watch_toolBar]
180
181 # Button "Configure"
182 set button [ttk::button $icon_bar.conf_but \
183 -image ::ICONS::16::configure \
184 -command "$this rightPanel_watch_cfg_menu" \
185 -style Flat.TButton \
186 ]
187 set conf_button $button
188 pack $button -side left -padx 3
189 # Separator
190 pack [ttk::separator $icon_bar.sep_rightPanel_watch_ib_sepm0 \
191 -orient vertical \
192 ] -side left -fill y -padx 3
193 # Button "Save"
194 set button [ttk::button $icon_bar.but_rightPanel_watch_save \
195 -image ::ICONS::16::filesave \
196 -command "$this rightPanel_watch_save {} 1" \
197 -style Flat.TButton \
198 ]
199 pack $button -side left -padx 3
200 DynamicHelp::add $button -text [mc "Save"]
201 setStatusTip -widget $button \
202 -text [mc "Save"]
203 # Button "Save as"
204 set button [ttk::button $icon_bar.but_rightPanel_watch_saveas \
205 -image ::ICONS::16::filesaveas \
206 -command "$this rightPanel_watch_saveas" \
207 -style Flat.TButton \
208 ]
209 pack $button -side left -padx 3
210 DynamicHelp::add $button -text [mc "Save under a different file name"]
211 setStatusTip -widget $button \
212 -text [mc "Save under a different file name"]
213 # Separator
214 pack [ttk::separator $icon_bar.sep_rightPanel_watch_ib_sep0 \
215 -orient vertical \
216 ] -side left -fill y -padx 3
217 # Button "Open"
218 set button [ttk::button $icon_bar.but_rightPanel_watch_open \
219 -image ::ICONS::16::fileopen \
220 -command "$this rightPanel_watch_open" \
221 -style Flat.TButton \
222 ]
223 pack $button -side left -padx 3
224 DynamicHelp::add $button -text [mc "Open *.wtc file"]
225 setStatusTip -widget $button \
226 -text [mc "Open *.wtc file"]
227 # Button "Import"
228 set button [ttk::button $icon_bar.but_rightPanel_watch_imp \
229 -image ::ICONS::16::fileimport \
230 -style Flat.TButton \
231 -command "$this rightPanel_watch_import" \
232 ]
233 pack $button -side left -padx 3
234 DynamicHelp::add $button -text [mc "Import list of registers from code listing or WTC file"]
235 setStatusTip -widget $button \
236 -text [mc "Import list of registers from *.lst or *.wtc file"]
237 # Entry "Search"
238 set watch_search_entry [ttk::entry $icon_bar.search_entry \
239 -validate key \
240 -width 0 \
241 -validatecommand "$this rightPanel_watch_search_validate %P" \
242 ]
243 DynamicHelp::add $watch_search_entry \
244 -text [mc "Enter your search string here"]
245 pack $watch_search_entry -side left -fill x -expand 1
246 setStatusTip -widget $watch_search_entry \
247 -text [mc "Search for a name"]
248 # Button "Clear search string"
249 set watch_search_clear [ttk::button $icon_bar.clear_search \
250 -image ::ICONS::16::clear_left \
251 -command "$watch_search_entry delete 0 end" \
252 -state disabled \
253 -style Flat.TButton \
254 ]
255 DynamicHelp::add $icon_bar.clear_search -text [mc "Clear search string"]
256 pack $watch_search_clear -side right -after $watch_search_entry
257 setStatusTip -widget $icon_bar.clear_search \
258 -text [mc "Clear search string"]
259
260 # Entry "Address"
261 set entry [ttk::entry $tool_bar.ent_rightPanel_watch_addr \
262 -textvariable RightPanel::watch_addr${regw_count} \
263 -validatecommand "$this rightPanel_watch_addr_validate %P" \
264 -validate key \
265 -width 5 \
266 ]
267 DynamicHelp::add $entry \
268 -text [mc "Register address:\n 1 or 2 digits\tinternal RAM (not SFR)\n 3 digits\t\texpanded RAM\n 4 digits\t\texternal RAM\n dot and 2 digits\tBit"]
269 setStatusTip -widget $entry \
270 -text [mc "Register address or bit address"]
271 grid $entry -sticky w -row 2 -column 1
272 bind $entry <Return> "$this rightPanel_watch_add"
273 bind $entry <KP_Enter> "$this rightPanel_watch_add"
274
275 # Entry "Name"
276 set entry [ttk::entry $tool_bar.ent_rightPanel_watch_name \
277 -textvariable RightPanel::watch_name${regw_count} \
278 -validatecommand "$this rightPanel_watch_name_validate %P" \
279 -validate key \
280 -width 20 \
281 ]
282 setStatusTip -widget $entry \
283 -text [mc "Name of the watch. Any string."]
284 grid $entry -sticky w -row 2 -column 2 -padx 3
285 bind $entry <Return> "$this rightPanel_watch_add"
286 bind $entry <KP_Enter> "$this rightPanel_watch_add"
287 # Button "Add"
288 set watch_add_button [ttk::button $tool_bar.but_rightPanel_watch_add \
289 -image ::ICONS::16::add \
290 -command "$this rightPanel_watch_add" \
291 -style Flat.TButton \
292 ]
293 DynamicHelp::add $watch_add_button -text [mc "Add this entry to register watches"]
294 setStatusTip -widget $watch_add_button \
295 -text [mc "Add this entry to register watches"]
296 grid $watch_add_button -sticky w -row 2 -column 3
297 # Button "New"
298 set watch_new_button [ttk::button $tool_bar.but_rightPanel_watch_new \
299 -image ::ICONS::16::filenew \
300 -command "$this rightPanel_watch_new" \
301 -style Flat.TButton \
302 ]
303 DynamicHelp::add $watch_new_button -text [mc "New register watches entry"]
304 setStatusTip -widget $watch_new_button \
305 -text [mc "Create new register watch"]
306 grid $watch_new_button -sticky w -row 2 -column 4
307 # Button "Remove"
308 set watch_remove_button [ttk::button $tool_bar.but_rightPanel_watch_remove \
309 -image ::ICONS::16::button_cancel \
310 -command "$this rightPanel_watch_remove" \
311 -style Flat.TButton \
312 ]
313 DynamicHelp::add $watch_remove_button -text [mc "Remove this entry"]
314 setStatusTip -widget $watch_remove_button \
315 -text [mc "Remove this entry"]
316 grid $watch_remove_button -sticky w -row 2 -column 5
317 # Label "Addr"
318 set watch_addr_entry [label $tool_bar.lbl_rightPanel_watch_addr \
319 -text [mc "Addr"] \
320 -font ${Simulator_GUI::smallfont} \
321 -fg ${Simulator_GUI::small_color} \
322 ]
323 grid $watch_addr_entry -row 1 -column 1
324 # Label "Register name"
325 grid [label $tool_bar.lbl_rightPanel_watch_name \
326 -text [mc "Register name"] \
327 -font ${Simulator_GUI::smallfont} \
328 -fg ${Simulator_GUI::small_color} \
329 ] -row 1 -column 2
330
331 # Create text widget representing list of register watches
332 set watch_text [text $text_frame.txt_rightPanel_watch \
333 -yscrollcommand "$text_frame.src_rightPanel_watch set" \
334 -bg {#FFFFFF} -font $regfont \
335 -cursor left_ptr \
336 -state disabled -exportselection 0 \
337 ]
338 # Create text tags
339 $this right_panel_create_highlighting_tags $watch_text $watch_text_tags -1
340 $watch_text tag configure tag_curLine -background ${::RightPanel::selection_color_dark}
341
342 # Create scrollbar
343 pack [ttk::scrollbar $text_frame.src_rightPanel_watch \
344 -orient vertical \
345 -command "$watch_text yview" \
346 ] -side right -fill y
347 pack $watch_text -side left -fill both -expand 1
348 # Create event bindings
349 bind $watch_text <ButtonRelease-3> "$this rightPanel_watch_popupmenu %X %Y %x %y; break"
350 bind $watch_text <Button-1> "$this rightPanel_watch_click %x %y; break"
351 bind $watch_text <<Selection>> "false_selection $watch_text; break"
352 bind $watch_text <Key-Menu> {break}
353
354 # Pack frames
355 pack $tool_bar -side bottom -anchor w
356 pack $icon_bar -side top -fill x
357 pack $text_frame -side top -fill both -expand 1
358 rightPanel_watch_switch_line 1
359
360 # Create popup menu
361 set watch_menu $parent.menu_rightPanel_watch
362 regwatches_makePopupMenu
363
364 # Refresh highlighting tags
365 rightPanel_refresh_regwatches_highlighting
366
367 # Open definition file
368 if {$watch_file_name != {}} {
369 rightPanel_watch_openfile $watch_file_name . 0
370 }
371 }
372
373 ## Sort register watches
374 # @parm Char sorting_key
375 # N - Sort by name
376 # A - Sort by address
377 # T - Sort by type
378 # @return void
379 public method rightPanel_watch_sort_by {sorting_key} {
380 # Pack all watches into one sigle list
381 set list_to_sort [list]
382 set type {}
383 foreach addr [array names watch_data] {
384
385 switch -- [string length $addr] {
386 4 {
387 set type {X}
388 }
389 3 {
390 if {[string index $addr 0] == {.}} {
391 set type {B}
392 } else {
393 set type {E}
394 }
395 }
396 default {
397 set type {D}
398 }
399 }
400
401 lappend list_to_sort [list $addr [lindex $watch_data($addr) 0] $type]
402 }
403
404 # Incremental sorting order
405 if {$::RegWatches::sorting_order} {
406 set order {-increasing}
407 # Decremental sorting order
408 } else {
409 set order {-decreasing}
410 }
411
412 switch -- $sorting_key {
413 N { ;# Name
414 set index 1
415 }
416 A { ;# Address
417 set index 0
418 }
419 T { ;# Type
420 set index 2
421 }
422 }
423
424 # Sort the list
425 set list_to_sort [lsort -dictionary $order -index $index $list_to_sort]
426
427 # Refill the panel
428 rightPanel_watch_clear 1
429 foreach entry $list_to_sort {
430 set addr [lindex $entry 0]
431 set name [lindex $entry 1]
432
433 rightPanel_watch_add $addr $name
434 }
435 }
436
437 ## Perform autoload on simulator start
438 # @parm String filename - Code listinf file
439 # @return void
440 public method rightPanel_watch_autoload {filename} {
441 if {!$autoload_flag} {return}
442 if {![file exists $filename]} {return}
443
444 if {$autoclear_flag} {
445 rightPanel_watch_clear 1
446 }
447 rightPanel_watch_import_file $filename .
448 }
449
450 ## Autoload flag toggled (this function should be invoked from configuration menu)
451 # @return void
452 public method rightPanel_watch_toggle_autoload_flag {} {
453 set autoload_flag $::RegWatches::menu_autoload
454 }
455
456 ## Autoclear flag toggled (this function should be invoked from configuration menu)
457 # @return void
458 public method rightPanel_watch_toggle_autoclear_flag {} {
459 set autoclear_flag $::RegWatches::menu_autoclear
460 }
461
462 ## Get configuration list
463 # @return void
464 public method rightPanel_watch_get_config {} {
465 return [list \
466 $autoload_flag \
467 $::RegWatches::sorting_order \
468 $autoclear_flag \
469 ]
470 }
471
472 ## Create configuration menu
473 # @return void
474 private method create_conf_menu {} {
475 if {$conf_menu != {}} {
476 return
477 }
478 set conf_menu $parent.conf_menu
479 menuFactory $CONFMENU $conf_menu 0 "$this " 0 {} [namespace current]
480
481 watch_disEna_buttons
482 }
483
484 ## Invoke configuration menu
485 # @return void
486 public method rightPanel_watch_cfg_menu {} {
487 create_conf_menu
488
489 set x [winfo rootx $conf_button]
490 set y [winfo rooty $conf_button]
491 incr y [winfo height $conf_button]
492
493 set ::RegWatches::menu_autoload $autoload_flag
494 set ::RegWatches::menu_autoclear $autoclear_flag
495 tk_popup $conf_menu $x $y
496 }
497
498 ## Refresh highlighting tags
499 # @return void
500 public method rightPanel_refresh_regwatches_highlighting {} {
501 if {!$regw_gui_initialized} {return}
502 $this right_panel_create_highlighting_tags $watch_text $watch_text_tags -1
503 }
504
505 ## Recreate popup menu
506 # @return void
507 public method regwatches_makePopupMenu {} {
508 if {!$regw_gui_initialized} {return}
509 if {[winfo exists $watch_menu]} {destroy $watch_menu}
510 menuFactory $WATCHMENU $watch_menu 0 "$this " 0 {} [namespace current]
511 }
512
513
514 ## Retrun name of file currently loaded in register watches
515 # @return String - filename
516 public method getWatchesFileName {} {
517 # Determinate project root path
518 set prj_path [$this cget -projectPath]
519 append prj_path {/}
520
521 # Return relative directory location
522 if {![string first $prj_path $watch_file_name]} {
523 return [string range $watch_file_name [string length $prj_path] end]
524 # Return absolute directory location
525 } else {
526 return $watch_file_name
527 }
528 }
529
530 ## (Re)set dynamic shortcuts for the given entry widget
531 # @parm Widget entry - Target entry widget
532 # @return void
533 private method watch_entry_shortcuts_reset {entry} {
534 if {!$regw_gui_initialized} {return}
535
536 # Unset previous configuration
537 foreach key $watches_set_shortcuts {
538 bind $entry <$key> {}
539 }
540 set set_shortcuts {}
541
542 # Iterate over shortcuts definition
543 foreach block ${::SHORTCUTS_LIST} {
544 # Determinate category
545 set category [lindex $block 0]
546 if {[lsearch $watches_shortcuts_cat $category] == -1} {continue}
547
548 # Determinate definition list and its length
549 set block [lreplace $block 0 2]
550 set len [llength $block]
551
552 # Iterate over definition list and create bindings
553 for {set i 0; set j 1} {$i < $len} {incr i 2; incr j 2} {
554 # Determinate key sequence
555 set key [lindex $block $i]
556 if {[catch {
557 set key $::SHORTCUTS_DB($category:$key)
558 }]} then {
559 continue
560 }
561 if {$key == {}} {continue}
562
563 # Create and register new binding
564 lappend watches_set_shortcuts $key
565 set cmd [subst [lindex $block [list $j 1]]]
566 append cmd {;break}
567 bind $entry <$key> $cmd
568 }
569 }
570 }
571
572 ## Get adjusted value of address entry (register watches)
573 # @parm String string - input data ("\n" == get value from entry widget)
574 # @return String - result address
575 private method get_watchAddr {string} {
576
577 # Evaluate input string
578 if {$string == {} || $string == {.}} {
579 return { .00}
580 }
581 if {$string == "\n"} {
582 set string [subst -nocommands "\$::RightPanel::watch_addr${obj_idx}"]
583 regsub {^\s+} $string {} string
584 }
585 if {[string index $string 0] == {.}} {
586 set string [string replace $string 0 0]
587 set bit_addr 1
588 } else {
589 set bit_addr 0
590 }
591
592 # Adjust address
593 set len [string length $string]
594 if {$len > 2} {
595 if {$len != 4} {
596 set string " $string"
597 }
598 } else {
599 if {$len == 1} {
600 set string "0$string"
601 }
602 set string " $string"
603 }
604
605 # Resturn result
606 if {$bit_addr} {
607 return [string replace $string 1 1 {.}]
608 } else {
609 return [string toupper $string]
610 }
611 }
612
613 ## Get adjusted value of register name (Register watches)
614 # @parm String string - input data ("\n" == get value from entry widget)
615 # @return String - resulting register name
616 private method get_watchName {string} {
617 # Conditionaly get value from entry widget
618 if {$string == "\n"} {
619 set string [subst -nocommands "\$::RightPanel::watch_name${obj_idx}"]
620 regsub {\t+$} $string {} string
621 }
622
623 # Adjust resulting string
624 set len [string length $string]
625 append string [string repeat { } [expr {23 - $len}]]
626
627 # Return result
628 return $string
629 }
630
631 ## Validate content of address entry - Register watches
632 # @parm String value - input value
633 # @return Bool - result
634 public method rightPanel_watch_addr_validate {value} {
635
636 # Check if validation is enabled
637 if {!$watch_AN_valid_ena} {return 1}
638
639 # Check for allowed length
640 if {[string length $value] > 4} {
641 return 0
642 }
643
644 # Check for allowed characters
645 if {!([regexp {^[A-Fa-f0-9]*$} $value] || [regexp {^\.[A-Fa-f0-9]{0,2}$} $value])} {
646 return 0
647 }
648
649 # Change content of address field in register watches text widget
650 if {$watch_curLine != 0 && $value != {}} {
651
652 # Get address
653 set value [get_watchAddr $value]
654 regsub {^\s+} $value {} real_value
655
656 # Check it the desired address is unique
657 if {[lsearch -ascii -exact $watch_addrs $real_value] != -1} {
658 Sbar [mc "Unable to assign, address is already in use"]
659 return 1
660 }
661
662 # Modify variables related to the current entry
663 set idx [expr {$watch_curLine - 1}]
664 set addr [lindex $watch_addrs $idx]
665 set var [lindex $watch_data($addr) 1]
666 set watch_data($real_value) $watch_data($addr)
667 unset watch_data($addr)
668 lset watch_addrs $idx $real_value
669
670 # Synchronize
671 $watch_text.$var configure -state normal
672 rightPanel_watch_sync $real_value
673 $watch_text.$var configure -fg ${Simulator::normal_color}
674 if {!$watches_enabled || [read_from_simulator $real_value] == {--}} {
675 $watch_text.$var configure -state disabled
676 }
677
678 # Enable entry watches text widget
679 $watch_text configure -state normal
680
681 # Change content of address field
682 $watch_text delete $watch_curLine.0 $watch_curLine.4
683 $watch_text insert $watch_curLine.0 $value
684
685 # Bit -> Byte
686 if {[string index $addr 0] == {.} && [string index $real_value 0] != {.}} {
687 $watch_text.$var configure -width 2
688 help_window_hide
689
690 # Byte -> Bit
691 } elseif {[string index $addr 0] != {.} && [string index $real_value 0] == {.}} {
692 $watch_text.$var configure -width 1
693 help_window_hide
694 }
695
696 # Highlight address field
697 set len [string length $real_value]
698 if {$len == 4} {
699 set addr_tag {tag_Xaddr}
700 } elseif {$len == 3 && ([string index $real_value 0] == {.})} {
701 set addr_tag {tag_Baddr}
702 } elseif {$len == 3} {
703 set addr_tag {tag_Eaddr}
704 } else {
705 set addr_tag {tag_addr}
706 }
707 $watch_text tag add $addr_tag $watch_curLine.0 $watch_curLine.4
708
709 # Change selection
710 $watch_text tag remove tag_curLine 1.0 end
711 $watch_text tag add tag_curLine $watch_curLine.0 "$watch_curLine.0 + 1 line"
712
713 $watch_text configure -state disabled
714
715 # Adjust help window
716 help_window_update_addr $addr $real_value
717 bind $watch_text.[lindex $watch_data($real_value) 1] <Enter> \
718 "$this create_help_window_ram ${real_value}h; help_window_variable_addr"
719
720 # Adjust flag: modified
721 set watches_modified 1
722 }
723
724 # Success
725 return 1
726 }
727
728 ## Validate content of register name entry - Register watches
729 # @parm String value - input value
730 # @return Bool - result
731 public method rightPanel_watch_name_validate {value} {
732 # Check if validation is enabled
733 if {!$watch_AN_valid_ena} {return 1}
734
735 # Check for allowed length
736 if {[string length $value] > 23} {
737 return 0
738 }
739
740 # Change content of register name field in register watches text widget
741 if {$watch_curLine != 0} {
742 # Local variables
743 set name [get_watchName $value] ;# Register name
744
745 # Change reg. name in object variable watch_data
746 lset watch_data([lindex $watch_addrs [expr {$watch_curLine - 1}]]) 0 [string trimright $value]
747
748 # Enable list of watches widget
749 $watch_text configure -state normal
750
751 # Change current register name
752 $watch_text delete $watch_curLine.5 "$watch_curLine.0 lineend - 1 char"
753 $watch_text insert $watch_curLine.5 $name
754
755 # Restore reg. name text tag
756 $watch_text tag add tag_name $watch_curLine.5 $watch_curLine.28
757
758 # Adjust selection
759 $watch_text tag remove tag_curLine 1.0 end
760 $watch_text tag add tag_curLine $watch_curLine.0 "$watch_curLine.0 + 1 line"
761
762 # Disable list of watches widget
763 $watch_text configure -state disabled
764
765 # Adjust status modified
766 set watches_modified 1
767 }
768
769 # Success
770 $watch_search_entry delete 0 end
771 return 1
772 }
773
774 ## Validate content of embedded entries in list of register watches
775 # @parm String addr - hexadecimal representation of register addres
776 # @parm String value - string to validate
777 # @return Bool - result
778 public method rightPanel_watch_value_validate {addr value} {
779 if {$validator_engaged} {return 1}
780 set validator_engaged 1
781
782 # Check for allowed length
783 if {[string length $value] > 2} {
784 set validator_engaged 0
785 return 0
786 }
787
788 # Check for allowed characters
789 if {![regexp {^[A-Fa-f0-9]*$} $value]} {
790 set validator_engaged 0
791 return 0
792 }
793
794 ## Synchronize new content with simulator engine
795 if {[string index $addr 0] == {.}} {
796 set addr [string replace $addr 0 0]
797 set bit_addr 1
798 } else {
799 set bit_addr 0
800 }
801 set dec_addr [expr "0x$addr"]
802 # Bit
803 if {$bit_addr} {
804 if {$value == {}} {
805 set value 0
806 }
807 if {![regexp {^[01]?$} $value]} {
808 set validator_engaged 0
809 return 0
810 }
811 $this setBit $dec_addr $value
812
813 # External RAM
814 } elseif {[string length $addr] == 4} {
815 $this setXdata $dec_addr $value
816 $this Simulator_XDATA_sync $addr
817
818 # Expanded RAM
819 } elseif {[string length $addr] == 3} {
820 $this setEram $dec_addr $value
821 $this Simulator_XDATA_sync $addr
822
823 # Internal RAM
824 } else {
825 $this setData $dec_addr $value
826 $this SimGUI_disable_sync
827 $this Simulator_GUI_sync I $dec_addr
828 $this SimGUI_enable_sync
829 }
830
831 if {$bit_addr} {
832 set addr .$addr
833 }
834 $watch_text.[lindex $watch_data($addr) 1] configure -fg ${Simulator::normal_color}
835
836 # Synchronize with help window
837 help_window_update $addr $value
838
839 # Done ...
840 set validator_engaged 0
841 return 1
842 }
843
844 ## Enable entry widgets in register watches
845 # AFFECT ALL ENTRIES (not only valid ones) !!!
846 # @return void
847 public method rightPanel_watch_force_enable {} {
848 if {!$regw_gui_initialized} {CreateRegWatchesGUI}
849
850 set watches_enabled 1
851 foreach addr $watch_addrs {
852 $watch_text.[lindex $watch_data($addr) 1] configure -state normal
853 }
854 }
855
856 ## Enable entry widgets in register watches
857 # Affect only entries with valid address (implemented on current MCU)
858 # @return void
859 public method rightPanel_watch_enable {} {
860 if {!$regw_gui_initialized} {CreateRegWatchesGUI}
861
862 set watches_enabled 1
863 foreach addr $watch_addrs {
864 if {[string index $addr 0] == {.}} {
865 set addr [string replace $addr 0 0]
866 set bit_addr 1
867 } else {
868 set bit_addr 0
869 }
870 set dec_addr [expr "0x$addr"]
871 set len [string length $addr]
872
873 # Bit
874 if {$bit_addr} {
875 if {$dec_addr > 0x7F} {
876 if {![$this simulator_is_sfr_available [$this getRegOfBit $dec_addr]]} {
877 continue
878 }
879 }
880 set addr ".$addr"
881
882 # Internal RAM
883 } elseif {$len < 3} {
884 if {$dec_addr >= [lindex [$this cget -procData] 3]} {
885 continue
886 }
887
888 # Expanded RAM
889 } elseif {$len == 3} {
890 if {$dec_addr >= [lindex [$this cget -procData] 8]} {
891 continue
892 }
893
894 # External RAM
895 } else {
896 if {$dec_addr >= [$this cget -P_option_mcu_xdata]} {
897 continue
898 }
899 }
900
901 $watch_text.[lindex $watch_data($addr) 1] configure -state normal
902 }
903 }
904
905 ## Disable all entry widgets in register watches
906 # @return void
907 public method rightPanel_watch_disable {} {
908 if {!$regw_gui_initialized} {return}
909
910 set watches_enabled 0
911 foreach addr $watch_addrs {
912 $watch_text.[lindex $watch_data($addr) 1] configure -state disabled
913 }
914 }
915 ## Select line in list of register watches
916 # @parm Int x - relative X coordinate
917 # @parm Int y - relative Y coordinate
918 # @return void
919 public method rightPanel_watch_click {x y} {
920 rightPanel_watch_switch_line [expr {int([$watch_text index @$x,$y])}]
921 $watch_search_entry delete 0 end
922 }
923
924 ## Change current line in register watches
925 # @parm Int row - target line
926 # @return void
927 public method rightPanel_watch_switch_line {row} {
928 if {!$regw_gui_initialized} {return}
929 set watch_AN_valid_ena 0
930
931 # Determinate number of the last row
932 set end [$watch_text index end]
933 set end [expr {int($end) - 1}]
934
935 # Restore previous state of the last selected entry box
936 if {$watch_curLine} {
937 set addr [lindex $watch_addrs [expr {$watch_curLine - 1}]]
938 set var [lindex $watch_data($addr) 1]
939 $watch_text.$var selection clear
940 $watch_text.$var configure \
941 -disabledbackground {#FFFFFF} \
942 -bg {#FFFFFF}
943 }
944
945 # Enable/Disable buttons and Clear/Keep entry widgets at the bottom
946 if {$row == $end} {
947 $watch_remove_button configure -state disabled
948 $watch_new_button configure -state disabled
949 $watch_add_button configure -state normal
950 set watch_curLine 0
951 $watch_text tag remove tag_curLine 1.0 end
952 set ::RightPanel::watch_name${obj_idx} {}
953 set ::RightPanel::watch_addr${obj_idx} {}
954 set watch_AN_valid_ena 1
955 return 0
956 } else {
957 set watch_curLine $row
958 $watch_remove_button configure -state normal
959 $watch_new_button configure -state normal
960 $watch_add_button configure -state disabled
961 }
962
963 # Determinate text indexes
964 set idx0 "$row.0"
965 set idx1 [expr {$row + 1}]
966 append idx1 {.0}
967
968 # Set selection tag
969 $watch_text tag remove tag_curLine 1.0 end
970 $watch_text tag add tag_curLine $idx0 $idx1
971
972 # Adjust content of entry widgets at the bottom
973 set addr [lindex $watch_addrs [expr {$watch_curLine - 1}]]
974 set name [lindex $watch_data($addr) 0]
975 set var [lindex $watch_data($addr) 1]
976
977 set ::RightPanel::watch_name${obj_idx} [string trimright $name]
978 set ::RightPanel::watch_addr${obj_idx} [string trimright $addr]
979
980 # Change foreground color of current value entry
981 $watch_text.$var configure \
982 -fg ${Simulator::normal_color} \
983 -bg ${::RightPanel::selection_color_dark} \
984 -disabledbackground ${::RightPanel::selection_color_dark}
985
986 # Focus on value entry
987 focus $watch_text.$var
988 $watch_text.$var selection range 0 end
989 $watch_text see $row.0
990
991 set watch_AN_valid_ena 1
992 }
993
994 ## Create a new register watch
995 # @parm String - Hex address, {} == Content of address entry
996 # @parm String - Register name, {} == Content of name entry
997 # @return void
998 public method rightPanel_watch_add args {
999 # Local variables
1000 set row [$watch_text index end] ;# Last row in the list
1001 set row [expr {int($row) - 1}]
1002 set addr [lindex $args 0] ;# Register address (Hex String)
1003 set name [lindex $args 1] ;# Watch name
1004 set shortAddr {} ;# Register address (Hex Number)
1005
1006 if {$addr == {} || $name == {}} {
1007 set addr [get_watchAddr "\n"]
1008 set name [get_watchName "\n"]
1009 set no_sbar 0
1010 } else {
1011 set addr [get_watchAddr $addr]
1012 set name [get_watchName $name]
1013 set no_sbar 1
1014 }
1015 set shortAddr [regsub {^\s*} $addr {}]
1016
1017 # Check address validity
1018 if {$shortAddr == {}} {
1019 if {!$no_sbar} {
1020 Sbar [mc "You must specify the register address."]
1021 }
1022 return 0
1023 }
1024 if {[lsearch -ascii -exact $watch_addrs $shortAddr] != -1} {
1025 if {!$no_sbar} {
1026 Sbar [mc "Specified address is already used."]
1027 }
1028 return 0
1029 }
1030
1031 # Enable text widget
1032 $watch_text configure -state normal
1033 # Insert address and watch name
1034 $watch_text insert end "$addr $name"
1035 # Insert text tags
1036 regsub {^ +} $addr {} addr
1037 set entry [watch_create_entry $addr $row $watch_entry_count]
1038 $watch_text window create end -window $entry -pady 0
1039 $watch_text insert end "\n"
1040 set len [string length $addr]
1041 if {$len == 4} {
1042 set addr_tag {tag_Xaddr}
1043 } elseif {$len == 3 && ([string index $addr 0] == {.})} {
1044 set addr_tag {tag_Baddr}
1045 } elseif {$len == 3} {
1046 set addr_tag {tag_Eaddr}
1047 } else {
1048 set addr_tag {tag_addr}
1049 }
1050 $watch_text tag add $addr_tag $row.0 $row.4
1051 $watch_text tag add tag_name $row.5 $row.28
1052 # Disable text widget
1053 $watch_text configure -state disabled
1054
1055 # Register new watch
1056 regsub {\t+$} $name {} name
1057 lappend watch_addrs $addr
1058 set watch_data($addr) [list $name $watch_entry_count]
1059
1060 # Synchronize
1061 rightPanel_watch_sync $addr
1062 $entry configure -fg ${Simulator::normal_color}
1063
1064 # Enable/Disable the entry widget
1065 if {!$watches_enabled} {
1066 $entry configure -state disabled
1067 }
1068
1069 incr watch_entry_count
1070
1071 # Reevaluate button states
1072 watch_disEna_buttons
1073
1074 # Clear search entry
1075 $watch_search_entry delete 0 end
1076
1077 # Adjust status modified
1078 set watches_modified 1
1079 }
1080
1081 ## Create entry widget for embedding in list of watches
1082 # @parm String addr - hexadecimal register address
1083 # @parm Int row - target row in text widget
1084 # @parm Variable var - entry text variable
1085 # @return Widget - resulting entry widget
1086 private method watch_create_entry {addr row var} {
1087 if {[string index $addr 0] == {.}} {
1088 set width 1
1089 } else {
1090 set width 2
1091 }
1092
1093 # Create entry widget
1094 set entry [entry $watch_text.$var \
1095 -width $width \
1096 -font ${::Simulator_GUI::entry_font} \
1097 -bg {#FFFFFF} -validate key \
1098 -takefocus 0 -highlightthickness 0 \
1099 -disabledbackground {#FFFFFF} \
1100 -vcmd "$this rightPanel_watch_value_validate $addr %P" \
1101 -bd 0 -justify right \
1102 ]
1103
1104 # Set event bindings
1105 bind $entry <Button-1> "$this rightPanel_watch_switch_line $row"
1106 bind $entry <Key-Up> "$this rightPanel_watch_up 1"
1107 bind $entry <Key-Down> "$this rightPanel_watch_down 1"
1108 bind $entry <Key-Next> "$this rightPanel_watch_down 4"
1109 bind $entry <Key-Prior> "$this rightPanel_watch_up 4"
1110 bind $entry <Motion> {help_window_show %X %Y}
1111 bind $entry <Leave> {help_window_hide}
1112 bind $entry <Enter> "$this create_help_window_ram ${addr}h; help_window_variable_addr"
1113 bind $entry <Button-4> "$watch_text yview scroll -5 units"
1114 bind $entry <Button-5> "$watch_text yview scroll +5 units"
1115 watch_entry_shortcuts_reset $entry
1116
1117 # Return entry reference
1118 return $entry
1119 }
1120
1121 ## Clear highlight for all registers
1122 # @return void
1123 public method rightPanel_watch_clear_highlight {} {
1124 if {!$regw_gui_initialized} {return}
1125
1126 foreach addr $watch_addrs {
1127 $watch_text.[lindex $watch_data($addr) 1] configure -fg ${Simulator::normal_color}
1128 }
1129 }
1130
1131 ## Clear highlight for the given register
1132 # @return void
1133 public method rightPanel_watch_unhighlight {addr} {
1134 if {!$regw_gui_initialized} {return}
1135
1136 if {[lsearch $watch_addrs $addr] == -1} {
1137 return
1138 }
1139 $watch_text.[lindex $watch_data($addr) 1] configure -fg ${Simulator::normal_color}
1140 }
1141
1142 ## Move current watch to the top
1143 # @return void
1144 public method rightPanel_watch_move_top {} {
1145 rightPanel_watch_move 1
1146 }
1147
1148 ## Move current watch to up
1149 # @return void
1150 public method rightPanel_watch_move_up {} {
1151 # Determinate target line
1152 set target_line [expr {$watch_curLine - 1}]
1153 if {$target_line == 0} {return 0}
1154 # Move watch
1155 rightPanel_watch_move $target_line
1156 }
1157
1158 ## Move current watch to down
1159 # @return void
1160 public method rightPanel_watch_move_down {} {
1161 # Determinate target line
1162 set target_line [expr {$watch_curLine + 1}]
1163 set end [$watch_text index end]
1164 set end [expr {int($end) - 1}]
1165 if {$target_line == $end} {return 0}
1166 # Move watch
1167 rightPanel_watch_move $target_line
1168 }
1169
1170 ## Move current watch to the bottom
1171 # @return void
1172 public method rightPanel_watch_move_bottom {} {
1173 # Determinate target line
1174 set target_line [$watch_text index end]
1175 set target_line [expr {int($target_line) - 2}]
1176 # Move watch
1177 rightPanel_watch_move $target_line
1178 }
1179
1180 ## Move current watch to the given line
1181 # @parm Int target_line - target line
1182 # @return void
1183 private method rightPanel_watch_move {target_line} {
1184 # Validate current line value
1185 if {$watch_curLine == 0} {return}
1186
1187 # Local variables
1188 set cur_idx [expr {$watch_curLine - 1}] ;# index in $watch_addrs -- current line
1189 set trg_idx [expr {$target_line - 1}] ;# index in $watch_addrs -- target line
1190 set addr [lindex $watch_addrs $cur_idx] ;# register address
1191 set name [lindex $watch_data($addr) 0] ;# watch name
1192 set var [lindex $watch_data($addr) 1] ;# textvariable of the value entry
1193
1194 # Modify variables related to the watch
1195 set watch_addrs [lreplace $watch_addrs $cur_idx $cur_idx]
1196 set watch_addrs [linsert $watch_addrs $trg_idx $addr]
1197
1198 # Enable the widget
1199 $watch_text configure -state normal
1200 # Change textual content
1201 $watch_text delete $watch_curLine.0 "$watch_curLine.0 + 1 line linestart"
1202 $watch_text insert $target_line.0 "[get_watchAddr $addr] [get_watchName $name]\n"
1203 # Destroy the current entry widget
1204 destroy $watch_text.$var
1205 # Change embedded entry
1206 set entry [watch_create_entry $addr $target_line $var]
1207 $watch_text window create [list $target_line.0 lineend] -window $entry -pady 0
1208 set len [string length $addr]
1209 if {$len == 4} {
1210 set addr_tag {tag_Xaddr}
1211 } elseif {$len == 3 && ([string index [string trim $addr] 0] == {.})} {
1212 set addr_tag {tag_Baddr}
1213 } elseif {$len == 3} {
1214 set addr_tag {tag_Eaddr}
1215 } else {
1216 set addr_tag {tag_addr}
1217 }
1218 # Restore text tags
1219 $watch_text tag add $addr_tag $target_line.0 $target_line.4
1220 $watch_text tag add tag_name $target_line.5 $target_line.28
1221 # Disable the widget
1222 $watch_text configure -state disabled
1223
1224 # Synchronize entry widget content
1225 rightPanel_watch_sync $addr
1226
1227 # Enable/Disable the entry widget
1228 if {!$watches_enabled} {
1229 $entry configure -state disabled
1230 }
1231
1232 # Set current line
1233 set watch_curLine $target_line
1234 rightPanel_watch_switch_line $target_line
1235
1236 # Clear search entry
1237 $watch_search_entry delete 0 end
1238
1239 # Adjust status modified
1240 set watches_modified 1
1241 }
1242
1243 ## Change current line in list of register watches to the line above the current one
1244 # @parm Int lines - number of lines to skip - 1
1245 # @return void
1246 public method rightPanel_watch_up {lines} {
1247 # Determinate number of last row in the widget
1248 set end [$watch_text index end]
1249 set end [expr {int($end) - 2}]
1250
1251 # Change current line (logicaly)
1252 set line $watch_curLine
1253 incr line -$lines
1254 if {$line < 1} {
1255 set line 1
1256 }
1257
1258 # Change current line (physicaly)
1259 $watch_text see $watch_curLine.0
1260 rightPanel_watch_switch_line $line
1261
1262 # Clear search entry
1263 $watch_search_entry delete 0 end
1264 }
1265
1266 ## Change current line in list of register watches to the line below the current one
1267 # @parm Int lines - number of lines to skip - 1
1268 # @return void
1269 public method rightPanel_watch_down {lines} {
1270 # Determinate number of last row in the widget
1271 set end [$watch_text index end]
1272 set end [expr {int($end) - 2}]
1273
1274 # Change current line (logicaly)
1275 set line $watch_curLine
1276 incr line $lines
1277 if {$line > $end} {
1278 set line $end
1279 }
1280
1281 # Change current line (physicaly)
1282 $watch_text see $watch_curLine.0
1283 rightPanel_watch_switch_line $line
1284
1285 # Clear search entry
1286 $watch_search_entry delete 0 end
1287 }
1288
1289 ## Binding for button "New" (Clears entry widgets at the bottom and unselect current watch)
1290 # @return void
1291 public method rightPanel_watch_new {} {
1292 set end [$watch_text index end]
1293 set end [expr {int($end) - 1}]
1294 rightPanel_watch_switch_line $end
1295
1296 # Clear search entry
1297 $watch_search_entry delete 0 end
1298 }
1299
1300 ## Remove the current register watch
1301 # @return void
1302 public method rightPanel_watch_remove {} {
1303 # Determinate register address
1304 set addr [lindex $watch_addrs [expr {$watch_curLine - 1}]]
1305 if {$addr != {}} {
1306 # Destroy value entry
1307 set var [lindex $watch_data($addr) 1]
1308 destroy $watch_text.$var
1309 # Unregister watch
1310 unset watch_data($addr)
1311 set idx [lsearch $watch_addrs $addr]
1312 set watch_addrs [lreplace $watch_addrs $idx $idx]
1313
1314 # Remove watch from the text widget
1315 $watch_text configure -state normal
1316 $watch_text delete $watch_curLine.0 "$watch_curLine.0 + 1 line"
1317 $watch_text configure -state disabled
1318 }
1319
1320 # Change current line
1321 if {$watch_curLine > [llength $watch_addrs]} {
1322 set watch_curLine [llength $watch_addrs]
1323 }
1324 if {$watch_curLine} {
1325 rightPanel_watch_switch_line $watch_curLine
1326 } else {
1327 rightPanel_watch_switch_line 1
1328 }
1329
1330 # Reevaluate button states
1331 watch_disEna_buttons
1332 # Clear search entry
1333 $watch_search_entry delete 0 end
1334 # Adjust status modified
1335 set watches_modified 1
1336 }
1337
1338 ## Save watches definition to a file
1339 # @parm String filename - Target filename or an empty string
1340 # @parm Bool force=0 - Do not ask for overwrite
1341 # @return void
1342 public method rightPanel_watch_save {filename {force 0}} {
1343 if {!$regw_gui_initialized} {CreateRegWatchesGUI}
1344
1345 if {$filename != {}} {
1346 set watch_file_name $filename
1347 }
1348
1349 # If no filename specified -> invoke dislog "Save as"
1350 if {$watch_file_name == {}} {
1351 rightPanel_watch_saveas
1352
1353 # Save file
1354 } else {
1355 # Set new filename
1356 if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
1357 if {![regexp "^(~|/)" $watch_file_name]} {
1358 set filename "[$this cget -ProjectDir]/$watch_file_name"
1359 }
1360 } else { ;# Microsoft windows way
1361 if {![regexp {^\w:} $watch_file_name]} {
1362 set filename [file join [$this cget -ProjectDir] $watch_file_name]
1363 }
1364 }
1365
1366 set watch_file_name [file normalize $watch_file_name]
1367 # Adjust file extension
1368 if {![regexp {\.wtc$} $watch_file_name]} {
1369 append watch_file_name {.wtc}
1370 }
1371
1372 if {[file exists $watch_file_name] && [file isfile $watch_file_name]} {
1373 # Ask user for overwrite existing file
1374 if {!$force && [tk_messageBox \
1375 -type yesno \
1376 -icon question \
1377 -parent . \
1378 -title [mc "Overwrite file"] \
1379 -message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $watch_file_name]]
1380 ] != {yes}
1381 } then {
1382 return
1383 }
1384 # Create a backup file
1385 catch {
1386 file rename -force $watch_file_name "$watch_file_name~"
1387 }
1388 }
1389 if {[catch {
1390 set file [open $watch_file_name w 0640]
1391 }]} then {
1392 if {[winfo exists .fsd]} {
1393 set parent .fsd
1394 } else {
1395 set parent .
1396 }
1397 tk_messageBox -type ok \
1398 -parent $parent -icon warning \
1399 -title [mc "Error - MCU 8051 IDE"] \
1400 -message [mc "Unable to access file \"%s\", check your permissions." $watch_file_name]
1401 return
1402 }
1403
1404 # Write file header
1405 puts $file "# Watches definition file -- ${::APPNAME}"
1406
1407 # Write watches definition
1408 puts -nonewline $file [regsub -all -line {\s+$} [$watch_text get 1.0 end] {}]
1409
1410 # Finish
1411 close $file
1412 Sbar [mc "Definitions saved to \"%s\"" $watch_file_name]
1413
1414 # Adjust status modified
1415 set watches_modified 0
1416 }
1417 }
1418
1419 ## Invoke dialog "Save as" - Register watches
1420 # @return void
1421 public method rightPanel_watch_saveas {} {
1422
1423 # Abort if there is already opened some file selection dialog
1424 if {[winfo exists .fsd]} {return}
1425
1426 # Invoke the dialog
1427 KIFSD::FSD ::fsd \
1428 -title [mc "Save watches - MCU 8051 IDE"] \
1429 -directory [$this cget -ProjectDir] \
1430 -defaultmask 0 -multiple 0 -filetypes [list \
1431 [list [mc "MCU 8051 IDE watches definition"] {*.wtc}] \
1432 [list [mc "All files"] {*}] \
1433 ]
1434 # Save file after press of OK button
1435 ::fsd setokcmd {
1436 set ::filename [::fsd get]
1437 if {$::filename != {} && ![file isdirectory $::filename]} {
1438 ${::X::actualProject} rightPanel_watch_save $::filename
1439 }
1440 }
1441 # Activate the dialog
1442 ::fsd activate
1443 }
1444
1445 ## Open and process watches definition file
1446 # @parm String filename - name of source file
1447 # @parm Widget parent - GUI parent (for error dialogues)
1448 # @parm Bool clear - Clear watches before loading
1449 # @return Bool - result
1450 public method rightPanel_watch_openfile {filename parent clear} {
1451 if {!$regw_gui_initialized} {CreateRegWatchesGUI}
1452
1453 # Normalize filename
1454 if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
1455 if {![regexp "^(~|/)" $filename]} {
1456 set filename "[$this cget -projectPath]/$filename"
1457 }
1458 } else { ;# Microsoft windows way
1459 if {![regexp {^\w:} $filename]} {
1460 set filename [file join [$this cget -projectPath] $filename]
1461 }
1462 }
1463 set filename [file normalize $filename]
1464
1465 # Set new watches filename
1466 set watch_file_name $filename
1467
1468 # Open file
1469 if {[catch {
1470 set file [open $filename r]
1471 }]} then {
1472 tk_messageBox \
1473 -parent $parent \
1474 -icon warning \
1475 -type ok \
1476 -title [mc "File access error"] \
1477 -message [mc "Unable to read file '%s'" $filename]
1478 set watch_file_name {}
1479 return 0
1480 }
1481
1482 # Verify input data validity
1483 while {![eof $file]} {
1484 set line [gets $file]
1485
1486 # Skip comments and empty lines
1487 if {[regexp {^\s*#} $line]} {continue}
1488 if {[regexp {^\s*$} $line]} {continue}
1489
1490 # Local variables
1491 regexp {^\s*\.?\w+} $line addr ;# Register address
1492 regsub {^\s*\.?\w+\s*} $line {} name ;# Watch name
1493 regsub {\s+$} $name {} name
1494
1495 # Check for address and name validity
1496 if {
1497 ![regexp {^\s*\.?[A-Fa-f0-9]+$} $addr] ||
1498 [string length $addr] > 4 ||
1499 [string length $name] > 23
1500 } then {
1501 tk_messageBox \
1502 -title [mc "Corrupted file"] \
1503 -icon error -type ok -parent $parent \
1504 -message [mc "file: %s is either corrupted or it is not a file in expected format." $filename]
1505 return 0
1506 }
1507 }
1508
1509 # Clear watches
1510 if {$clear} {
1511 rightPanel_watch_clear 1
1512 }
1513
1514 # Parse input data
1515 seek $file 0
1516 while {![eof $file]} {
1517 set line [gets $file]
1518
1519 # Skip comments and empty lines
1520 if {[regexp {^\s*#} $line]} {continue}
1521 if {[regexp {^\s*$} $line]} {continue}
1522
1523 regexp {^\s*\.?\w+} $line addr ;# Register address
1524 regsub {^\s*\.?\w+\s*} $line {} name ;# Watch name
1525 set addr [string trimleft $addr]
1526 set name [string trimright $name]
1527
1528 # Create new register watch
1529 rightPanel_watch_add $addr $name
1530 }
1531
1532 # Deselect all
1533 rightPanel_watch_new
1534
1535 # Reevaluate button states (icon bar)
1536 watch_disEna_buttons
1537
1538 # Adjust status modified
1539 set watches_modified 0
1540
1541 # Success
1542 close $file
1543 return 1
1544 }
1545
1546 ## Invoke dialog "Open file"
1547 # @return void
1548 public method rightPanel_watch_open {} {
1549 # Invoke the dialog
1550 KIFSD::FSD ::fsd \
1551 -title [mc "Load watches from file - MCU 8051 IDE"] \
1552 -directory [$this cget -ProjectDir] -autoclose 0 \
1553 -defaultmask 0 -multiple 0 -filetypes [list \
1554 [list [mc "MCU 8051 IDE watches definition"] {*.wtc}] \
1555 [list [mc "All files"] {*}] \
1556 ]
1557
1558 # Open file after press of OK button
1559 fsd setokcmd {
1560 # Get chosen file name
1561 set filename [::fsd get]
1562 if {[${::X::actualProject} rightPanel_watch_openfile $filename [::fsd get_window_name] 1]} {
1563 ::fsd deactivate
1564 delete object fsd
1565 }
1566 }
1567
1568 # Activate the dialog
1569 fsd activate
1570 }
1571
1572 ## Invoke dialog "Import file"
1573 # @return void
1574 public method rightPanel_watch_import {} {
1575 # Invoke the dialog
1576 KIFSD::FSD ::fsd \
1577 -title [mc "Import file - MCU 8051 IDE"] \
1578 -directory [$this cget -ProjectDir] -autoclose 0 \
1579 -defaultmask 0 -multiple 0 -filetypes [list \
1580 [list [mc "Code listing"] {*.lst}] \
1581 [list [mc "MCU 8051 IDE watches definition"] {*.wtc}] \
1582 [list [mc "All files"] {*}] \
1583 ]
1584
1585 # Open file after press of OK button
1586 fsd setokcmd {
1587 # Get chosen file name
1588 set filename [::fsd get]
1589 if {[${::X::actualProject} rightPanel_watch_import_file $filename [::fsd get_window_name]]} {
1590 ::fsd deactivate
1591 delete object fsd
1592 }
1593 }
1594
1595 # Activate the dialog
1596 fsd activate
1597 }
1598
1599 ## Import file
1600 # @parm String filename - Name of source file (*.lst or *.wtc)
1601 # @parm Widget parent - GUI parent (for error dialogues)
1602 # @return Bool - result
1603 public method rightPanel_watch_import_file {filename parent} {
1604 if {!$regw_gui_initialized} {CreateRegWatchesGUI}
1605
1606 # Determinate file type
1607 set filename [file normalize [file join [$this cget -ProjectDir] $filename]]
1608 set file_type 0
1609 switch -nocase -- [file extension $filename] {
1610 {.wtc} { ;# Watches definition file
1611 set file_type 1
1612 }
1613 {.lst} { ;# Code listing
1614 set file_type 2
1615 }
1616 default { ;# Try to detect file type by file header
1617 catch {
1618 set file [open $filename r]
1619 if {[string first {# Watches definition file} [gets $file]] == 0} {
1620 set file_type 1
1621 }
1622 close $file
1623 }
1624 }
1625 }
1626
1627 # Unknown file type
1628 if {!$file_type} {
1629 tk_messageBox \
1630 -parent . \
1631 -type ok \
1632 -icon warning \
1633 -title [mc "Unknown file"] \
1634 -message [mc "Unable to recognize file format"]
1635 return 0
1636 }
1637
1638 # -----------------------------------------------------------------------
1639 ## WTC file - load and exit procedure
1640 # -----------------------------------------------------------------------
1641 if {$file_type == 1} {
1642 return [rightPanel_watch_openfile $filename $parent 0]
1643 }
1644
1645
1646 # -----------------------------------------------------------------------
1647 # LST file
1648 # -----------------------------------------------------------------------
1649
1650 # Try to open file
1651 if {[catch {
1652 set file [open $filename r]
1653 }]} then {
1654 tk_messageBox \
1655 -parent . \
1656 -type ok \
1657 -icon warning \
1658 -title [mc "File access error"] \
1659 -message [mc "Unable to open file:\n'%s'" $filename]
1660 return 0
1661 }
1662
1663 # Parse file
1664 set read_line 0
1665 set line {}
1666 set name {}
1667 set addr {}
1668 set type {}
1669 set bita 0
1670 while {![eof $file]} {
1671 set bita 0
1672 set line [gets $file]
1673
1674 # Empty line - stop reading
1675 if {![string length [string trimright $line "  \f"]]} {
1676 set read_line 0
1677 continue
1678
1679 # MCU 8051 IDE Assembler symbol table
1680 } elseif {![string first {SYMBOL TABLE:} $line]} {
1681 set read_line 1
1682 continue
1683
1684 # ASEM-51 Assembler symbol table
1685 } elseif {![string first {------------------------------------------------------------} $line]} {
1686 set read_line 2
1687 continue
1688 }
1689
1690
1691 # MCU 8051 IDE Assembler symbol
1692 if {$read_line == 1} {
1693 if {![regexp {^\w+} $line name]} {
1694 continue
1695 }
1696 if {![regexp {[\w\s]+$} $line line]} {
1697 continue
1698 }
1699 set type [lindex $line 0]
1700
1701 # Ignore all types except address
1702 if {[lindex $line 1] != {ADDR}} {
1703 continue
1704 }
1705
1706 # Internal data memory
1707 if {$type == {D} || $type == {I}} {
1708 set addr [string range [lindex $line 2] 2 3]
1709 # External data memory (inluding ERAM, EEPROM, etc.)
1710 } elseif {$type == {X}} {
1711 set addr [string range [lindex $line 2] 0 3]
1712 # Bit addressable area
1713 } elseif {$type == {B}} {
1714 set bita 1
1715 set addr [string range [lindex $line 2] 2 3]
1716 # Another type of memory -> IGNORE
1717 } else {
1718 continue
1719 }
1720
1721 # Ignore unused symbols
1722 if {[lindex $line end-1] == {NOT} || [lindex $line end-2] == {NOT}} {
1723 continue
1724 }
1725
1726 # ASEM-51 Assembler symbol
1727 } elseif {$read_line == 2} {
1728 # Remove dangerous characters
1729 regsub -all {\{\}\"\"} $line {} line
1730
1731 # Ignore unused symbols
1732 if {[llength $line] < 4} {
1733 continue
1734 }
1735
1736 # Determinate address and symbol name
1737 set type [lindex $line 1]
1738 set addr [lindex $line 2]
1739 set name [lindex $line 0]
1740
1741 # Accept only internal and external data memory
1742 if {$type != {IDATA} && $type != {DATA} && $type != {XDATA} && $type != {BIT}} {
1743 continue
1744 }
1745 if {$type == {BIT}} {
1746 set bita 1
1747 }
1748
1749 # This line is not a part of symbol table
1750 } else {
1751 continue
1752 }
1753
1754 # Address must be a valid hexadecimal value
1755 if {![string is xdigit -strict $addr]} {
1756 continue
1757 }
1758
1759 # Exclude SFR's
1760 if {[lsearch -ascii -exact ${::ASMsyntaxHighlight::spec_registers} $name] != -1} {
1761 continue
1762 }
1763
1764 # Create new register watch
1765 if {[string length $name] > 23} {
1766 set name [string range $name 0 16]
1767 append name {..}
1768 }
1769
1770 if {$bita} {
1771 set addr .$addr
1772 }
1773
1774 rightPanel_watch_add $addr $name
1775 set watches_modified 1
1776 }
1777
1778 # Finalize
1779 rightPanel_watch_new
1780 watch_disEna_buttons
1781 close $file
1782 return 1
1783 }
1784
1785 ## Remove all register watches
1786 # Bool force=0 - Don't ask for user comfirmation
1787 # @return void
1788 public method rightPanel_watch_clear {{force 0}} {
1789 if {!$regw_gui_initialized} {CreateRegWatchesGUI}
1790
1791 # Ask user for comfirmation
1792 if {!$force} {
1793 if {[tk_messageBox \
1794 -parent . \
1795 -type yesno \
1796 -icon question \
1797 -title [mc "Are you sure ?"] \
1798 -message [mc "Do you really want to clear the panel ?"]
1799 ] != {yes}} {
1800 return
1801 }
1802 }
1803
1804 # Clear text widget
1805 $watch_text configure -state normal
1806 $watch_text delete 1.0 end
1807 $watch_text configure -state disabled
1808
1809 # Destroy all embedded entry widgets
1810 foreach addr $watch_addrs {
1811 destroy $watch_text.[lindex $watch_data($addr) 1]
1812 }
1813
1814 # Clear entries on the bottom bar
1815 set watch_curLine 0
1816 set ::RightPanel::watch_name${obj_idx} {}
1817 set ::RightPanel::watch_addr${obj_idx} {}
1818
1819 # Unregister all watches
1820 set watch_addrs {}
1821 catch {
1822 array unset watch_data
1823 }
1824
1825 # Reevaluate button states (icon bar)
1826 watch_disEna_buttons
1827
1828 # Adjust status modified
1829 set watches_modified 1
1830 }
1831
1832 ## Search for the given string in the list of register watches -- search entry validator
1833 # @parm String content - String to find/validate
1834 # @return Bool - result
1835 public method rightPanel_watch_search_validate {content} {
1836 if {$search_val_in_progress} {return 0}
1837 set search_val_in_progress 1
1838
1839 # Enable/Disable button "Clear search entry"
1840 if {$content == {}} {
1841 $watch_search_clear configure -state disabled
1842 } else {
1843 $watch_search_clear configure -state normal
1844 }
1845
1846 # Validate search string
1847 if {[regexp {^\s*$} $content]} {
1848 $watch_search_entry configure -style TEntry
1849 set search_val_in_progress 0
1850 return 1
1851 }
1852 if {[string length $content] > 23} {
1853 set search_val_in_progress 0
1854 return 0
1855 }
1856
1857 # Search for the given string
1858 set i 1
1859 set content [string trimright $content]
1860 set content [string tolower $content]
1861 foreach addr $watch_addrs {
1862 if {![string first $content [string tolower [lindex $watch_data($addr) 0]]]} {
1863 $watch_search_entry configure -style StringFound.TEntry
1864 rightPanel_watch_switch_line $i
1865 focus $watch_search_entry
1866 set search_val_in_progress 0
1867 return 1
1868 }
1869 incr i
1870 }
1871
1872 # String not found
1873 $watch_search_entry configure -style StringNotFound.TEntry
1874 set search_val_in_progress 0
1875 return 1
1876 }
1877
1878 ## Syncronize all register watches
1879 # @return void
1880 public method rightPanel_watch_sync_all {} {
1881 if {!$regw_gui_initialized} {CreateRegWatchesGUI}
1882
1883 # Iterate over addresses
1884 foreach addr $watch_addrs {
1885 # Synchronize
1886 rightPanel_watch_sync $addr
1887 # Clear highligh
1888 set var [lindex $watch_data($addr) 1]
1889 $watch_text.$var configure -fg ${Simulator::normal_color}
1890 }
1891 }
1892
1893 ## Read value from simulator engine
1894 # @parm String addr - hexadecimal register address
1895 # @return String - hexadecimal value or {--}
1896 private method read_from_simulator {addr} {
1897 ## Determinate address type (Bit / Internal / Enternal / Expanded)
1898 if {[string index $addr 0] == {.}} {
1899 set addr [string replace $addr 0 0]
1900 if {![string length $addr]} {
1901 return {--}
1902 }
1903 set bit_addr 1
1904 } else {
1905 set bit_addr 0
1906 }
1907 set len [string length $addr]
1908 set val {--}
1909 set addr_dec [expr "0x$addr"]
1910
1911 # Bit
1912 if {$bit_addr} {
1913 if {$addr_dec > 0x7F} {
1914 if {[$this simulator_is_sfr_available [$this getRegOfBit $addr_dec]]} {
1915 set val [$this getBit $addr_dec]
1916 }
1917 } else {
1918 set val [$this getBit $addr_dec]
1919 }
1920
1921 # Internal RAM
1922 } elseif {$len < 3} {
1923 # Normalize address
1924 if {$len == 1} {
1925 set addr "0$addr"
1926 }
1927 # Get register value
1928 if {$addr_dec < [lindex [$this cget -procData] 3]} {
1929 set val [$this getData $addr_dec]
1930 }
1931
1932 # Expanded RAM
1933 } elseif {$len == 3} {
1934 if {$addr_dec < [lindex [$this cget -procData] 8]} {
1935 set val [$this getEram $addr_dec]
1936 }
1937
1938 # External RAM
1939 } elseif {$len == 4} {
1940 if {$addr_dec < [$this cget -P_option_mcu_xdata]} {
1941 set val [$this getXdata $addr_dec]
1942 }
1943 }
1944
1945 return $val
1946 }
1947
1948 ## Synchronize all bits in the specified SFR
1949 # @parm Int dec_addr - SFR register address
1950 # @return void
1951 public method rightPanel_watch_sync_sfr {dec_addr} {
1952
1953 if {$validator_engaged} {
1954 return
1955 }
1956 if {$dec_addr % 8} {
1957 return
1958 }
1959
1960 for {set i 0} {$i < 8} {incr i} {
1961 rightPanel_watch_sync .[format %X $dec_addr]
1962 incr dec_addr
1963 }
1964 }
1965
1966 ## Synchronize one register watch
1967 # @parm String addr - hexadecimal register address
1968 # @return Bool - result
1969 public method rightPanel_watch_sync {addr} {
1970 if {$validator_engaged} {return 1}
1971 if {!$regw_gui_initialized} {CreateRegWatchesGUI}
1972
1973 # Detect bit address
1974 if {[string index $addr 0] == {.}} {
1975 set bit_addr 1
1976 } else {
1977 set bit_addr 0
1978 }
1979
1980 # Get register value
1981 set val [read_from_simulator $addr]
1982
1983 # Synchronize bits in the given register
1984 if {!$validator_engaged && [string length $addr] == 2} {
1985
1986 set dec_addr [expr "0x$addr"]
1987
1988 if {$dec_addr >= 0x20 && $dec_addr <= 0x2F} {
1989 set dec_addr [expr {($dec_addr - 0x20) * 8}]
1990 for {set i 0} {$i < 8} {incr i} {
1991
1992 set hex_addr [format %X $dec_addr]
1993 if {[string length $hex_addr] == 1} {
1994 set hex_addr "0$hex_addr"
1995 }
1996
1997 rightPanel_watch_sync .$hex_addr
1998 incr dec_addr
1999 }
2000 }
2001 }
2002
2003 # Check for watch presence
2004 if {[lsearch -ascii -exact $watch_addrs $addr] == -1} {
2005 return 0
2006 }
2007
2008 # Normalize register value
2009 if {!$bit_addr && [string length $val] == 1} {
2010 set val "0$val"
2011 }
2012
2013 set var [lindex $watch_data($addr) 1]
2014 set path $watch_text.$var ;# Path to watch entry widget
2015
2016 # Determinate original value
2017 set original_val [$watch_text.$var get]
2018
2019 # Highlight value entry
2020 if { "0x$original_val" != "0x$val"} {
2021 $path configure -fg ${Simulator::highlight_color}
2022 }
2023
2024 # Set new entry value
2025 set validator_engaged 1
2026 $watch_text.$var delete 0 end
2027 $watch_text.$var insert 0 $val
2028 set validator_engaged 0
2029
2030 # Synchronize with help window
2031 help_window_update $addr $val
2032
2033 # Done ...
2034 return 1
2035 }
2036
2037 ## Enable/Disable buttons on watches icon bar
2038 # @return void
2039 private method watch_disEna_buttons {} {
2040 if {!$regw_gui_initialized} {return}
2041
2042 if {[$watch_text index end] == {2.0}} {
2043 set state {disabled}
2044 } else {
2045 set state {normal}
2046 }
2047
2048 if {$conf_menu != {}} {
2049 $conf_menu entryconfigure [::mc "Sort by"] -state $state
2050 $conf_menu entryconfigure [::mc "Remove all"] -state $state
2051 }
2052 }
2053
2054 ## Get status modified for register watches
2055 # @return Bool - true if register watches were modified
2056 public method rightPanel_watch_modified {} {
2057 return $watches_modified
2058 }
2059
2060 ## Invoke register watches popup menu
2061 # @parm Int X - absolute X coordinate
2062 # @parm Int Y - absolute Y coordinate
2063 # @parm Int x - relative X coordinate
2064 # @parm Int y - relative Y coordinate
2065 # @return void
2066 public method rightPanel_watch_popupmenu {X Y x y} {
2067 # Change current line
2068 rightPanel_watch_click $x $y
2069
2070 ## Enable/Disable menu items
2071
2072 # If address entry is not empty -> disable all
2073 set addr [subst -nocommands "\$::RightPanel::watch_addr${obj_idx}"]
2074 if {$addr != {}} {
2075 set end [$watch_text index end]
2076 } else {
2077 set end {2.0}
2078 }
2079 # Empty list
2080 if {$end == {2.0}} {
2081 $watch_menu entryconfigure [::mc "Move top"] -state disabled
2082 $watch_menu entryconfigure [::mc "Move up"] -state disabled
2083 $watch_menu entryconfigure [::mc "Move down"] -state disabled
2084 $watch_menu entryconfigure [::mc "Move bottom"] -state disabled
2085 $watch_menu entryconfigure [::mc "Remove"] -state disabled
2086 $watch_menu entryconfigure [::mc "Remove all"] -state disabled
2087 # One item
2088 } elseif {$end == {3.0}} {
2089 $watch_menu entryconfigure [::mc "Move top"] -state disabled
2090 $watch_menu entryconfigure [::mc "Move up"] -state disabled
2091 $watch_menu entryconfigure [::mc "Move down"] -state disabled
2092 $watch_menu entryconfigure [::mc "Move bottom"] -state disabled
2093 $watch_menu entryconfigure [::mc "Remove"] -state normal
2094 $watch_menu entryconfigure [::mc "Remove all"] -state normal
2095 # More items
2096 } else {
2097 # First item
2098 if {$watch_curLine == 1} {
2099 $watch_menu entryconfigure [::mc "Move top"] -state disabled
2100 $watch_menu entryconfigure [::mc "Move up"] -state disabled
2101 $watch_menu entryconfigure [::mc "Move down"] -state normal
2102 $watch_menu entryconfigure [::mc "Move bottom"] -state normal
2103 # Last item
2104 } elseif {$watch_curLine == ($end - 2)} {
2105 $watch_menu entryconfigure [::mc "Move top"] -state normal
2106 $watch_menu entryconfigure [::mc "Move up"] -state normal
2107 $watch_menu entryconfigure [::mc "Move down"] -state disabled
2108 $watch_menu entryconfigure [::mc "Move bottom"] -state disabled
2109 # Any other item
2110 } else {
2111 $watch_menu entryconfigure [::mc "Move top"] -state normal
2112 $watch_menu entryconfigure [::mc "Move up"] -state normal
2113 $watch_menu entryconfigure [::mc "Move down"] -state normal
2114 $watch_menu entryconfigure [::mc "Move bottom"] -state normal
2115 }
2116 $watch_menu entryconfigure [::mc "Remove"] -state normal
2117 $watch_menu entryconfigure [::mc "Remove all"] -state normal
2118 }
2119
2120 # Invoke popup menu
2121 tk_popup $watch_menu $X $Y
2122 }
2123
2124
2125 ## Create bindings for defined key shortcuts -- register watches
2126 # @return void
2127 public method rightPanel_watch_shortcuts_reevaluate {} {
2128 if {!$regw_gui_initialized} {return}
2129 foreach addr $watch_addrs {
2130 watch_entry_shortcuts_reset watch_text.[lindex $watch_data($addr) 1]
2131 }
2132 }
2133
2134 ## Set flag enabled
2135 # @parm Bool bool - New value
2136 # @return void
2137 public method right_panel_watches_set_enabled {bool} {
2138 set enabled $bool
2139 }
2140 }
2141
2142 set ::RegWatches::menu_autoload [lindex $::CONFIG(REGWATCHES_CONFIG) 0]
2143 set ::RegWatches::sorting_order [lindex $::CONFIG(REGWATCHES_CONFIG) 1]
2144 set ::RegWatches::menu_autoclear [lindex $::CONFIG(REGWATCHES_CONFIG) 2]
2145
2146 # >>> File inclusion guard
2147 }
2148 # <<< File inclusion guard