summaryrefslogtreecommitdiff
path: root/lib/bottompanel/cvarsview.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bottompanel/cvarsview.tcl')
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/cvarsview.tcl142
1 files changed, 80 insertions, 62 deletions
diff --git a/lib/bottompanel/cvarsview.tcl b/lib/bottompanel/cvarsview.tcl
index fbc5dd2..ebebce3 100755..100644
--- a/lib/bottompanel/cvarsview.tcl
+++ b/lib/bottompanel/cvarsview.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 _CVARSVIEW_TCL ] } {
+set _CVARSVIEW_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides GUI interface designed for the bottom panel to show and
@@ -30,25 +35,25 @@
class CVarsView {
## COMMON
# Normal font fot the text widget
- common text_wdg_font_n [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight normal \
- -slant roman \
+ common text_wdg_font_n [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight normal \
+ -slant roman \
]
# Bold font for the text widget
- common text_wdg_font_b [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
- -slant roman \
+ common text_wdg_font_b [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ -slant roman \
]
# Italic font for the text widget
- common text_wdg_font_i [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight normal \
- -slant italic \
+ common text_wdg_font_i [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight normal \
+ -slant italic \
]
# Background color for selected lines
common color_selected_line {#CCCCFF}
@@ -57,7 +62,7 @@ class CVarsView {
# Variables related to object initialization
private variable parent ;# Widget: parent widget
- private variable gui_initialized 0 ;# Bool: GUI initialized
+ private variable cvv_gui_initialized 0 ;# Bool: GUI initialized
private variable panedwindow ;# Widget: Paned window for local and global variables
# Int: Last paned window sash position
@@ -103,7 +108,7 @@ class CVarsView {
# @return void
public method PrepareCVarsView {_parent} {
set parent $_parent
- set gui_initialized 0
+ set cvv_gui_initialized 0
}
## Inform this tab than it has became active
@@ -114,8 +119,12 @@ class CVarsView {
## Create GUI of this tab
# @return void
public method CreateCVarsViewGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$cvv_gui_initialized} {return}
+ set cvv_gui_initialized 1
+
+ if {${::DEBUG}} {
+ puts "CreateCVarsViewGUI \[ENTER\]"
+ }
## Create GUI of main frame
set main_frame [frame $parent.main_frame]
@@ -146,14 +155,14 @@ class CVarsView {
set filename [$this simulator_get_cdb_filename]
if {[catch {
set file [open $filename r]
- }]} {
+ }]} then {
tk_messageBox \
-parent . \
-icon warning \
-type ok \
-title [mc "Permission denied"] \
-message [mc "Unable to read file\n'%s'"] $filename
- } {
+ } else {
cvarsview_load_cdb $file
close $file
}
@@ -163,15 +172,15 @@ class CVarsView {
## Restore paned window sash position
# @return void
public method cvarsview_redraw_pane {} {
- if {!$gui_initialized} {return}
-# update idle
+ if {!$cvv_gui_initialized} {return}
+# update idletasks
# $panedwindow sash place 0 $panel_sash_position 0
}
## Get panel configuration list
# @return List - Panel config
public method cvarsview_get_config {} {
- if {$gui_initialized} {
+ if {$cvv_gui_initialized} {
# set panel_sash_position [lindex [$panedwindow sash coord 0] 0]
}
return [list $panel_sash_position]
@@ -188,12 +197,12 @@ class CVarsView {
# Empty string given
if {![string length $string]} {
- [subst "\$search_entry_$type"] configure -style TEntry
- [subst "\$search_clear_$type"] configure -state disabled
+ [subst -nocommands "\$search_entry_$type"] configure -style TEntry
+ [subst -nocommands "\$search_clear_$type"] configure -state disabled
set search_val_in_progress 0
return 1
}
- [subst "\$search_clear_$type"] configure -state normal
+ [subst -nocommands "\$search_clear_$type"] configure -state normal
## Perform search
set idx 0
@@ -208,17 +217,17 @@ class CVarsView {
incr idx
}
# Local variable
- } {
+ } else {
}
# Variable found
if {$found} {
cvarsview_select_line $type [expr {[lsearch $global_displayed $idx] + 1}] 1
- [subst "\$search_entry_$type"] configure -style StringFound.TEntry
+ [subst -nocommands "\$search_entry_$type"] configure -style StringFound.TEntry
# Variable not found
- } {
- [subst "\$search_entry_$type"] configure -style StringNotFound.TEntry
+ } else {
+ [subst -nocommands "\$search_entry_$type"] configure -style StringNotFound.TEntry
}
@@ -255,7 +264,7 @@ class CVarsView {
}
# Line with a local variable
- } {
+ } else {
}
}
@@ -273,7 +282,7 @@ class CVarsView {
$text_widget_global tag remove tag_current_line 0.0 end
set selected_line_global 0
# View with a local variable
- } {
+ } else {
}
}
@@ -384,7 +393,7 @@ class CVarsView {
# Create the top frame
set top_frame [frame $local_frame.top_frame]
pack [label $top_frame.header \
- -text "$type static scalar variables" \
+ -text [mc "$type static scalar variables"] \
-anchor w -justify left \
] -side left
@@ -415,7 +424,7 @@ class CVarsView {
set text_frame_main [frame $text_frame.main_frame -bd 1 -relief sunken]
if {$type == {Local}} {
set text [mc "Value Level Data type Variable name"]
- } {
+ } else {
set text [mc "Value Data type Variable name"]
}
pack [label $text_frame_main.header \
@@ -449,7 +458,7 @@ class CVarsView {
if {$type == {Local}} {
set text_widget_local $text_widget
- } {
+ } else {
set text_widget_global $text_widget
}
@@ -465,7 +474,7 @@ class CVarsView {
# @parm File cdb_file - Opened CDB file
# @return Bool - True in success
public method cvarsview_load_cdb {cdb_file} {
- if {!$gui_initialized} {CreateCVarsViewGUI}
+ if {!$cvv_gui_initialized} {CreateCVarsViewGUI}
set result 1
set local_variables_nlist {}
@@ -638,7 +647,7 @@ class CVarsView {
$registers 0 \
0 \
]
- } {
+ } else {
lappend local_variables_nlist $name
lappend local_variables_list [list $level $block]
lappend local_variables [list \
@@ -694,7 +703,7 @@ class CVarsView {
if {$subtype == {G}} {
set addresses_lst {global_addresses}
set addresses_list_lst {global_addresses_list}
- } {
+ } else {
set addresses_lst {local_addresses}
set addresses_list_lst {local_addresses_list}
}
@@ -708,13 +717,13 @@ class CVarsView {
# @parm String type - "Local" or "Global"
# @return void
public method cvarsview_clear_view {type} {
- if {!$gui_initialized} {CreateCVarsViewGUI}
+ if {!$cvv_gui_initialized} {CreateCVarsViewGUI}
if {$type == {local}} {
set text_widget $text_widget_local
set current_level {}
set current_block {}
- } {
+ } else {
set text_widget $text_widget_global
}
$text_widget configure -state normal
@@ -740,10 +749,15 @@ class CVarsView {
set pointer { }
if {$isglobal} {
set text_widget $text_widget_global
- } {
+ } else {
set text_widget $text_widget_local
}
+ if {$start_address == {}} {
+ puts "Error: start_address is empty: create_variable_record [list is=$id name=$name level=$level isglobal=$isglobal isvector=$isvector start_address=$start_address end_address=$end_address memory_type=$memory_type signed=$signed datatype=$datatype]"
+ return
+ }
+
foreach dt $datatype {
switch -glob -- $dt {
{DA*} { ;# Array of <n> elements
@@ -785,28 +799,28 @@ class CVarsView {
{SL} { ;# Long integer
if {$signed == {U}} {
set data_type {ulong}
- } {
+ } else {
set data_type {long}
}
}
{SI} { ;# Integer
if {$signed == {U}} {
set data_type {uint}
- } {
+ } else {
set data_type {int}
}
}
{SC} { ;# Char
if {$signed == {U}} {
set data_type {uchar}
- } {
+ } else {
set data_type {char}
}
}
{SS} { ;# Short integer
if {$signed == {U}} {
set data_type {ushort}
- } {
+ } else {
set data_type {short}
}
}
@@ -868,12 +882,12 @@ class CVarsView {
-bd 0 -justify right \
-disabledbackground {#FFFFFF} \
-fg ${::Simulator::normal_color} \
- -validatecommand "$this cvarsview_validate $id $isglobal $start_address %P" \
+ -validatecommand [list $this cvarsview_validate $id $isglobal $start_address %P] \
]
$entry insert insert 0
if {$isglobal} {
set type {Global}
- } {
+ } else {
set type {Local}
}
@@ -962,7 +976,7 @@ class CVarsView {
if {$isglobal} {
set definition [lindex $global_variables $id]
- } {
+ } else {
set validation_ena 1
return 0 ;# <-- DEBUG
}
@@ -976,7 +990,7 @@ class CVarsView {
set signed [lindex $definition 3]
if {$signed == {S}} {
set signed 1
- } {
+ } else {
set signed 0
}
@@ -999,12 +1013,12 @@ class CVarsView {
# Determinate valid value range
if {$mem_type == {J} || $mem_type == {H}} {
set max_value 1
- } {
+ } else {
set max_value [expr {int(pow(2, $len*8))}]
if {$signed} {
set min_value [expr {$max_value / 2}]
set max_value [expr {$max_value / 2 - 1}]
- } {
+ } else {
incr max_value -1
}
}
@@ -1015,7 +1029,7 @@ class CVarsView {
set validation_ena 1
return 0
}
- } {
+ } else {
if {$value > $max_value} {
set validation_ena 1
return 0
@@ -1027,7 +1041,7 @@ class CVarsView {
if {$mem_type == {J} || $mem_type == {H}} {
set value_list $value
# Other values
- } {
+ } else {
set value_list [list]
set value [format %X $string]
set value [string range $value end-[expr {$len * 2}] end]
@@ -1038,7 +1052,7 @@ class CVarsView {
if {$val == {}} {
lappend value_list 0
- } {
+ } else {
lappend value_list [expr "0x$val"]
}
}
@@ -1083,12 +1097,12 @@ class CVarsView {
return 1
}
{I} { ;# SFR space
- set mem_type_for_SE D
+ set mem_type_for_SE S
set command {setSfr_directly}
set synccmd {Simulator_sync_sfr}
}
{J} { ;# SBIT space
- set mem_type_for_SE B
+ set mem_type_for_SE J
if {[$this simulator_address_range $mem_type_for_SE $address]} {
$this setBit $address $value
$this Simulator_sync_sfr [$this getRegOfBit $address]
@@ -1126,11 +1140,11 @@ class CVarsView {
# @parm Bool enabled - 1 == Enable; 0 == Disable
# @return void
public method cvarsview_setEnabled {enabled} {
- if {!$gui_initialized} {return}
+ if {!$cvv_gui_initialized} {return}
if {$enabled} {
set state normal
- } {
+ } else {
set state disabled
}
@@ -1147,7 +1161,7 @@ class CVarsView {
# @parm Int address - Address of changed register
# @return void
public method cvarsview_sync {memtype address} {
- if {!$gui_initialized} {return}
+ if {!$cvv_gui_initialized} {return}
if {!$validation_ena} {return}
if {$memtype == {I} && !($address % 8)} {
set bitaddr $address
@@ -1277,7 +1291,7 @@ class CVarsView {
} elseif {$signed == {S}} {
set max_positive_value [expr {pow(2,($length * 8 - 1)) - 1}]
if {$value > $max_positive_value} {
- set value [expr {pow(2,($length * 8)) - $value}]
+ set value [expr {$value - pow(2,($length * 8))}]
}
set value [expr {int($value)}]
@@ -1301,3 +1315,7 @@ class CVarsView {
set validation_ena 1
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard