summaryrefslogtreecommitdiff
path: root/lib/simulator/hibernate.tcl
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
committerAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
commit47aa8b00b2b11df13a100489e0f904a4947177ef (patch)
treeb35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib/simulator/hibernate.tcl
parent5b8466f7fae0e071c0f4eda13051c93313910028 (diff)
Import Upstream version 1.4.7
Diffstat (limited to 'lib/simulator/hibernate.tcl')
-rw-r--r--[-rwxr-xr-x]lib/simulator/hibernate.tcl107
1 files changed, 61 insertions, 46 deletions
diff --git a/lib/simulator/hibernate.tcl b/lib/simulator/hibernate.tcl
index c35f4f8..0cd090e 100755..100644
--- a/lib/simulator/hibernate.tcl
+++ b/lib/simulator/hibernate.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 _HIBERNATE_TCL ] } {
+set _HIBERNATE_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides program hibernation capability. It ohter words it can save
@@ -59,16 +64,21 @@ class Hibernate {
common mcu_variable ;# Bool: Checkbox variable for "Different processor"
common xdata_variable ;# Int: RadioButton variable for "Different XDATA size"
common md5_variable ;# Bool: Checkbox variable for "Different MD5 hash"
- # Big font for dialog "Program resumption"
- common big_font [font create \
- -family {helvetica} \
- -weight bold -size -35 \
- ]
- # Normal font for dialog "Program resumption"
- common text_font [font create \
- -family {helvetica} \
- -weight bold -size -14 \
- ]
+
+ if {$::GUI_AVAILABLE} {
+ # Big font for dialog "Program resumption"
+ common big_font [font create \
+ -family {helvetica} \
+ -weight bold \
+ -size [expr {int(-35 * $::font_size_factor)}] \
+ ]
+ # Normal font for dialog "Program resumption"
+ common text_font [font create \
+ -family {helvetica} \
+ -weight bold \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ ]
+ }
## PRIVATE
private variable parser ;# Object: Reference to active XML parser
@@ -102,7 +112,7 @@ class Hibernate {
}
if {$for_what == {data}} {
$mem_prg_bar configure -maximum $value
- } {
+ } else {
$stb_prg_bar configure -maximum $value
}
}
@@ -128,15 +138,16 @@ class Hibernate {
}
# Create dialog window
- set win [toplevel .hibernation_progress_dialog -class {Progress dialog} -bg {#EEEEEE}]
+ set win [toplevel .hibernation_progress_dialog -class {Progress dialog} -bg ${::COMMON_BG_COLOR}]
# Create dialog header
- pack [label $win.header \
- -text $header \
- -font [font create \
- -size -17 -weight {bold} \
- -family {helvetica} \
- ] \
+ pack [label $win.header \
+ -text $header \
+ -font [font create \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight {bold} \
+ -family {helvetica} \
+ ] \
] -fill x
# Create progress bar "Memory"
@@ -167,7 +178,7 @@ class Hibernate {
-compound left \
-image ::ICONS::16::button_cancel \
-command {set ::Hibernate::hib_abort 1} \
- ] -padx 10 -fill x
+ ] -pady 5
# Configure dialog window
wm iconphoto $win ::ICONS::16::bar5
@@ -191,15 +202,15 @@ class Hibernate {
public method hibernate_hibernate {filename sourcefile md5 exclude_stepback} {
# Try to open the destination file
if {[catch {
- set file [open $filename w 420]
- }]} {
+ set file [open $filename w 0640]
+ }]} then {
return 0
}
# Determinate depth of stepback stack and size of XDATA memory
if {$exclude_stepback} {
set stacklength 0
- } {
+ } else {
set stacklength [$this simulator_get_SBS_len]
}
set xdata_size [$this cget -P_option_mcu_xdata]
@@ -217,18 +228,18 @@ class Hibernate {
puts -nonewline $file "\tThis is MCU 8051 IDE hibernation data file.\n"
puts -nonewline $file "\tIt does not contain program code, only data.\n\n"
puts -nonewline $file "\tPLEASE DO NOT EDIT THIS FILE MANUALY, BECAUSE\n"
- puts -nonewline $file "\tBAD FORMATING OF THIS FILE WILL LEAD MCU 8051 IDE TO CRASH !\n"
+ puts -nonewline $file "\tBAD FORMATTING OF THIS FILE WILL LEAD MCU 8051 IDE TO CRASH !\n"
puts -nonewline $file "-->\n"
# Write DTD (Document Type Declaration) to the destination file
- if {[file exists "${::LIB_DIRNAME}/../data/m5ihib.dtd"]} {
+ if {[file exists "${::ROOT_DIRNAME}/data/m5ihib.dtd"]} {
if {[catch {
- set dtd [open "${::LIB_DIRNAME}/../data/m5ihib.dtd" r]
- }]} {
+ set dtd [open "${::ROOT_DIRNAME}/data/m5ihib.dtd" r]
+ }]} then {
puts stderr "Unable to open m5ihib.dtd, please check your installation."
} else {
puts -nonewline $file "<!DOCTYPE m5ihib \[\n\n"
- while 1 {
+ while {1} {
if {[eof $dtd]} {
close $dtd
break
@@ -333,7 +344,7 @@ class Hibernate {
# Special function registers
puts -nonewline $file "\t\t<sfr>\n"
puts -nonewline $file "\t\t\t<addresses>\n\t\t\t\t"
- set sfr [$this simulator_get_avaliable_sfr]
+ set sfr [$this simulator_get_available_sfr]
set j 0
foreach addr $sfr {
if {$j > 6} {
@@ -366,7 +377,7 @@ class Hibernate {
## Write content of list of active interrupts
puts -nonewline $file "\t<subprograms count=\"[$this subprograms_get_count]\">\n"
- foreach sub [$this subprograms_get_formated_content] {
+ foreach sub [$this subprograms_get_formatted_content] {
set source [lindex $sub 0]
set target [lindex $sub 1]
set type [lindex $sub 2]
@@ -414,7 +425,7 @@ class Hibernate {
hibernate_close_progress_dialog
if {[catch {close $file}]} {
return 0
- } {
+ } else {
return 1
}
}
@@ -442,12 +453,12 @@ class Hibernate {
# Open hibernation data file
if {[catch {
set file [open $filename {r}]
- }]} {
+ }]} then {
return 1
}
# Show progress dialog
- show_progress_dialog {Resuming hibernated program} 1 1
+ show_progress_dialog [mc "Resuming hibernated program"] 1 1
# Create XML parser object
if {[catch {
@@ -455,12 +466,12 @@ class Hibernate {
-elementstartcommand [list $this hibernate_xml_parser_element] \
-characterdatacommand [list $this hibernate_xml_parser_data] \
]
- }]} {
+ }]} then {
hibernate_close_progress_dialog
tk_messageBox \
-type ok -icon error -parent . \
-title "::xml::parser error" \
- -message "Unknown error occured in XML parser library,\nplease try to reinstall package \"tdom\"."
+ -message "Unknown error occurred in XML parser library,\nplease try to reinstall package \"tdom\"."
return 2
}
@@ -485,7 +496,7 @@ class Hibernate {
# Close the file and free the parser
if {[catch {
close $file
- }]} {
+ }]} then {
set exit_code 1
}
catch {
@@ -500,13 +511,13 @@ class Hibernate {
set interrupts_in_progress [$this simulator_get_interrupts_in_progress_pb]
if {[llength $interrupts_in_progress]} {
simulator_Sbar [mc "Interrupt at vector 0x%s " [format %X [$this intr2vector [lindex $interrupts_in_progress end]]]] 1 $this
- } {
+ } else {
simulator_Sbar {} 0 $this
}
set lineNum [$this simulator_getCurrentLine]
if {$lineNum != {}} {
$this move_simulator_line $lineNum
- } {
+ } else {
$this editor_procedure {} unset_simulator_line {}
}
::X::stepback_button_set_ena [$this simulator_get_SBS_len]
@@ -663,7 +674,7 @@ class Hibernate {
}
if {$source != {} && $target != {} && $type != {}} {
$this subprograms_call $type $source $target
- } {
+ } else {
error "Invalid argument set in tag <step>"
}
}
@@ -680,7 +691,7 @@ class Hibernate {
$this simulator_set_SBS_len $stacklength
progress_dialog_set_max stepback [expr {$stacklength / 10}]
break
- } {
+ } else {
incr i
}
}
@@ -861,7 +872,7 @@ class Hibernate {
set xdata_variable 1
set md5_variable 1
- set win [toplevel .hibernation_bad_file_dialog -class {Error dialog} -bg {#EEEEEE}]
+ set win [toplevel .hibernation_bad_file_dialog -class {Error dialog} -bg ${::COMMON_BG_COLOR}]
set dlg_result 1
set dlg_bits $differences
@@ -931,13 +942,13 @@ class Hibernate {
-compound left \
-image ::ICONS::16::ok \
]
- pack $dlg_ok_but -side left
+ pack $dlg_ok_but -side left -padx 2
pack [ttk::button $button_frame.button_cancel \
-text [mc "Cancel"] \
-command "$this hibernation_cls_dlg 1" \
-compound left \
-image ::ICONS::16::button_cancel \
- ] -side left
+ ] -side left -padx 2
pack $button_frame -side bottom -anchor e -padx 10 -pady 5
# Configure dialog window
@@ -980,7 +991,7 @@ class Hibernate {
# Create text widget for the given message
set text_wdg [text $right_frame.top_text \
-width 0 -height 3 -wrap word -bd 0 \
- -relief flat -bg {#EEEEEE} \
+ -relief flat -bg ${::COMMON_BG_COLOR} \
-font $text_font -cursor left_ptr \
]
$text_wdg insert end $text
@@ -1004,7 +1015,7 @@ class Hibernate {
public method hibernation_chbut_rabut_command {} {
if {$file_variable && $mcu_variable && $xdata_variable && $md5_variable} {
$dlg_ok_but configure -state normal
- } {
+ } else {
$dlg_ok_but configure -state disabled
}
}
@@ -1027,7 +1038,7 @@ class Hibernate {
$this configure -P_option_mcu_xdata $xdata_size
::X::close_hexedit xdata $this
$this simulator_resize_xdata_memory $xdata_size
- } {
+ } else {
set xdata_size 0
}
@@ -1049,3 +1060,7 @@ class Hibernate {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard