diff options
Diffstat (limited to 'lib/rightpanel/subprograms.tcl')
-rw-r--r--[-rwxr-xr-x] | lib/rightpanel/subprograms.tcl | 107 |
1 files changed, 59 insertions, 48 deletions
diff --git a/lib/rightpanel/subprograms.tcl b/lib/rightpanel/subprograms.tcl index 6385266..c8380cb 100755..100644 --- a/lib/rightpanel/subprograms.tcl +++ b/lib/rightpanel/subprograms.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 _SUBPROGRAMS_TCL ] } { +set _SUBPROGRAMS_TCL _ +# <<< File inclusion guard + # -------------------------------------------------------------------------- # DESCRIPTION # Provides panel for watching subprogram calls @@ -30,29 +35,31 @@ class SubPrograms { ## COMMON common fsd_filename {} ;# Filename choosen by FSD # Main font for the text widget - common main_font [font create \ - -family {helvetica} \ - -size -14 \ + common main_font [font create \ + -family {helvetica} \ + -size [expr {int(-14 * $::font_size_factor)}] \ ] # Bold font for the text widget - common bold_font [font create \ - -family {helvetica} \ - -size -14 -weight {bold} \ + common bold_font [font create \ + -family {helvetica} \ + -size [expr {int(-14 * $::font_size_factor)}] \ + -weight {bold} \ ] # Font for status bar below the text box - common large_font [font create \ - -family {helvetica} \ - -size -14 \ + common large_font [font create \ + -family {helvetica} \ + -size [expr {int(-14 * $::font_size_factor)}] \ ] # Bold font for status bar below the text box - common large_bold_font [font create \ - -family {helvetica} \ - -size -14 -weight {bold} \ + common large_bold_font [font create \ + -family {helvetica} \ + -size [expr {int(-14 * $::font_size_factor)}] \ + -weight {bold} \ ] ## PRIVATE private variable parent ;# Widget: parent widget - private variable gui_initialized 0 ;# Bool: GUI initialized + private variable subp_gui_initialized 0 ;# Bool: GUI initialized private variable text_widget ;# Widget: Text widget containg almost all the information private variable scrollbar ;# Widget: Scrollbar for the text widget @@ -73,7 +80,7 @@ class SubPrograms { } destructor { - if {$gui_initialized} { + if {$subp_gui_initialized} { menu_Sbar_remove $menu } } @@ -84,7 +91,7 @@ class SubPrograms { # @return void public method PrepareSubPrograms {_parent} { set parent $_parent - set gui_initialized 0 + set subp_gui_initialized 0 load_config $::CONFIG(SUBP_MON_CONFIG) } @@ -117,8 +124,8 @@ class SubPrograms { ## Create all widgets which this panel consist of # @return void private method create_gui {} { - if {$gui_initialized} {return} - set gui_initialized 1 + if {$subp_gui_initialized} {return} + set subp_gui_initialized 1 # Create top frame (checkbuttons) set top_frame [frame $parent.top] @@ -136,12 +143,12 @@ class SubPrograms { # Adjust check buttons if {$enabled} { $enable_chbut select - } { + } else { $enable_chbut deselect } if {$ena_intr} { $intr_chbut select - } { + } else { $intr_chbut deselect } @@ -153,7 +160,7 @@ class SubPrograms { -image ::ICONS::16::button_cancel \ -command "$this subprograms_force_return" \ -state disabled \ - -width 6 \ + -width 7 \ ] set clear_but [ttk::button $button_frame.clear_but \ -text [mc "Clear"] \ @@ -244,7 +251,7 @@ class SubPrograms { {separator} {command {Remove this} {} 0 "subprograms_menu_action 4" {editdelete} "Remove this entry"} - } $menu 0 "$this " 0 {} + } $menu 0 "$this " 0 {} [namespace current] } ## Create highlighting tags for the text widget @@ -365,7 +372,7 @@ class SubPrograms { $this Simulator_sync_PC_etc $this move_simulator_line $line # Simulator is not running - } { + } else { set filename [$this simulator_get_filename [lindex $line 1]] set filename [file tail $filename] if {[$this fucus_specific_editor $filename 0]} { @@ -373,7 +380,7 @@ class SubPrograms { } } # Line unresolved - } { + } else { tk_messageBox \ -parent . \ -title [mc "Line not found"] \ @@ -397,10 +404,10 @@ class SubPrograms { set line [expr {$line / 3}] if {$line >= $count} { set state {disabled} - } { + } else { set state {normal} } - } { + } else { set state {disabled} } @@ -426,7 +433,7 @@ class SubPrograms { # @return void public method subprograms_call {type from to} { if {!$enabled} {return} - if {!$gui_initialized} CreateSubProgramsGUI + if {!$subp_gui_initialized} CreateSubProgramsGUI # Determinate string to print as an instruction switch -- $type { @@ -444,7 +451,7 @@ class SubPrograms { # Convert value of source address to hexadecimal representation if {$from < 0} { set from {-----} - } { + } else { set from [format %X $from] set len [string length $from] if {$len < 4} { @@ -456,7 +463,7 @@ class SubPrograms { # Convert value of target address to hexadecimal representation if {$to < 0} { set to {-----} - } { + } else { set to [format %X $to] set len [string length $to] if {$len < 4} { @@ -504,7 +511,7 @@ class SubPrograms { private method disena_buttonbar {bool} { if {$bool} { set state {normal} - } { + } else { set state {disabled} } $return_but configure -state $state @@ -519,7 +526,7 @@ class SubPrograms { if {!$enabled} {return} if {!$count} {return} if {$intr__sub && !$ena_intr} {return} - if {!$gui_initialized} CreateSubProgramsGUI + if {!$subp_gui_initialized} CreateSubProgramsGUI $text_widget configure -state normal $text_widget delete 1.0 4.0 @@ -536,7 +543,7 @@ class SubPrograms { ## Clear the text widget # @return void public method subprograms_clear {} { - if {!$gui_initialized} {return} + if {!$subp_gui_initialized} {return} set count 0 $total_val_lbl configure -text 0 $text_widget configure -state normal @@ -549,7 +556,7 @@ class SubPrograms { # @parm Bool bool - 1 == Enable; 0 == Disbale # @return void public method subprograms_setEnabled {bool} { - if {!$gui_initialized} {return} + if {!$subp_gui_initialized} {return} if {!$bool} { $return_but configure -state disabled } @@ -565,7 +572,7 @@ class SubPrograms { set word [string trim $word] if {$word == {Interrupt}} { set word 1 - } { + } else { set word 0 } $this simulator_return_from_SP $word @@ -581,10 +588,10 @@ class SubPrograms { KIFSD::FSD fsd \ -title [mc "Save file - MCU 8051 IDE"] \ -directory [$this cget -projectPath] \ - -defaultmask 0 -multiple 0 -filetypes { - {{Plain text} {*.txt} } - {{All files} {*} } - } + -defaultmask 0 -multiple 0 -filetypes [list \ + [list [mc "Plain text"] {*.txt} ] \ + [list [mc "All files"] {*} ] \ + ] # Ok button fsd setokcmd { @@ -593,12 +600,12 @@ class SubPrograms { if {![regexp "^(~|/)" $fsd_filename]} { set filename "[${::X::actualProject} cget -ProjectDir]/$fsd_filename" } - } { ;# Microsoft windows way - if {![regexp "^\w:" $fsd_filename]} { + } else { ;# Microsoft windows way + if {![regexp {^\w:} $fsd_filename]} { set filename [file join [${::X::actualProject} cget -ProjectDir] $fsd_filename] } } - + set ::SubPrograms::fsd_filename [file normalize $fsd_filename] } @@ -627,7 +634,7 @@ class SubPrograms { -title [mc "Overwrite file"] \ -message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $filename]] ] != {yes} - } { + } then { return } # Create a backup file @@ -637,8 +644,8 @@ class SubPrograms { } # Try to open the file if {[catch { - set file [open $filename w 420] - }]} { + set file [open $filename w 0640] + }]} then { tk_messageBox \ -parent . \ -icon warning \ @@ -655,14 +662,14 @@ class SubPrograms { ## Get number of recorder active subprograms # @return Int - Count public method subprograms_get_count {} { - if {!$gui_initialized} {return 0} + if {!$subp_gui_initialized} {return 0} return $count } ## Get content for purpose of program hibernation # @return String - Text - public method subprograms_get_formated_content {} { - if {!$gui_initialized} {return {}} + public method subprograms_get_formatted_content {} { + if {!$subp_gui_initialized} {return {}} set result {} set source {} set target {} @@ -684,7 +691,7 @@ class SubPrograms { regexp {\w+\s*$} $line source set source [string range $source 0 3] set source [expr "0x$source"] - } { + } else { regexp {\w+\s*$} $line target set target [string range $target 0 3] set target [expr "0x$target"] @@ -702,3 +709,7 @@ class SubPrograms { return $result } } + +# >>> File inclusion guard +} +# <<< File inclusion guard |