summaryrefslogtreecommitdiff
path: root/lib/bottompanel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bottompanel')
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/bottomnotebook.tcl291
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/calculator.tcl291
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/cvarsview.tcl142
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/find_in_files.tcl133
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/graph.tcl171
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/graph_wdg.tcl97
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/messages.tcl172
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/terminal.tcl49
-rw-r--r--[-rwxr-xr-x]lib/bottompanel/todo.tcl258
9 files changed, 942 insertions, 662 deletions
diff --git a/lib/bottompanel/bottomnotebook.tcl b/lib/bottompanel/bottomnotebook.tcl
index 463f93d..d4d1293 100755..100644
--- a/lib/bottompanel/bottomnotebook.tcl
+++ b/lib/bottompanel/bottomnotebook.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 _BOTTOMNOTEBOOK_TCL ] } {
+set _BOTTOMNOTEBOOK_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements bottom panel of the project tab
@@ -45,14 +50,13 @@ class BottomNoteBook {
public variable cvarsview_frame ;# Identifier of tab of NoteBook widget for c variables
public variable graph_frame ;# Identifier of tab of NoteBook widget for graph
public variable messages_frame ;# Identifier of tab of NoteBook widget for messages box
- public variable todo_frame ;# Identifier of tab of NoteBook widget for todo box
+ public variable todo_frame ;# Identifier of tab of NoteBook widget for to do box
public variable calculator_frame ;# Identifier of tab of NoteBook widget for calculator
public variable terminal_frame ;# Identifier of tab of NoteBook widget for terminal
public variable findinfiles_frame ;# Identifier of tab of NoteBook widget for terminal
## Private
private variable pri_notebook ;# Identifier of NoteBook widget when panel is visible
- private variable sec_notebook ;# Identifier of NoteBook widget when panel is hidden
private variable main_frame ;# Identifier of frame containing both NoteBooks
private variable panel_hidding_ena 1 ;# Is panel hidding enabled
@@ -69,10 +73,10 @@ class BottomNoteBook {
if {$active_page == {Terminal}} {
set active_page {Simulator}
} elseif {
- [lsearch {Simulator CVarsView Graph Messages Todo Calculator FindInFiles} $active_page] == -1
- } {
- puts stderr "Invalid value of active page '$active_page', setting to {Simulator}"
- set active_page {Simulator}
+ [lsearch {Simulator CVarsView Graph Messages Todo Calculator FindInFiles} $active_page] == -1
+ } then {
+ puts stderr "Invalid value of active page '$active_page', setting to {Simulator}"
+ set active_page {Simulator}
}
}
@@ -86,11 +90,11 @@ class BottomNoteBook {
## Create Bottom NoteBook (This function must be called after contructor)
# @parm widget mainframe - Frame for bottom notebook
# @parm widget PaneWindow - parent pane window contaier
- # @parm String todoText - content of todo text
+ # @parm String todoText - content of to do text
# @parm List calculatorList - List of values for calculator (display content, radix, etc.)
# @parm List graph_config - Graph configuration list
# @return Widget - ID of frame containg both notebooks
- public method initiate_BottomNoteBook {mainframe PaneWindow todoText calculatorList graph_config} {
+ public method initalize_BottomNoteBook {mainframe PaneWindow todoText calculatorList graph_config} {
# set parent pane window
set parentPane $PaneWindow
@@ -99,18 +103,7 @@ class BottomNoteBook {
# Frame for primary and secondary notebook
set main_frame $mainframe
# Primary notebook
- set pri_notebook [NoteBook $main_frame.ntb_bottomNB_pri \
- -side top -bd 1 \
- -arcradius 4 -bg {#EEEEEE} \
- -font [font create -family {helvetica} -size -12 -weight bold] \
- ]
- # Secondary notebook
- set sec_notebook [NoteBook $main_frame.ntb_bottomNB_sec \
- -side top \
- -arcradius 4 \
- -borderwidth 1 -bg {#EEEEEE} \
- -font [font create -family {helvetica} -size -12 -weight bold] \
- ]
+ set pri_notebook [ModernNoteBook $main_frame.ntb_bottomNB_pri]
# Register notebook status bar tips
notebook_Sbar_set {bottomnb} [list \
@@ -127,150 +120,92 @@ class BottomNoteBook {
]
$pri_notebook bindtabs <Enter> "notebook_Sbar bottomnb"
$pri_notebook bindtabs <Leave> "Sbar {} ;#"
- $sec_notebook bindtabs <Enter> "notebook_Sbar bottomnb"
- $sec_notebook bindtabs <Leave> "Sbar {} ;#"
## create Primary NoteBook tabs
# Tab "Simulator"
- set simulator_frame [$pri_notebook insert end {Simulator} \
- -text [mc "Simulator"] \
- -image ::ICONS::16::kcmmemory \
- -raisecmd "$this bottomNB_set_active_page {Simulator}" \
- -helptext [mc "Simulator panel %s" "(Ctrl+1)"] \
- -createcmd [list $this CreateSimulatorGUI] \
+ set simulator_frame [$pri_notebook insert end {Simulator} \
+ -text [mc "Simulator"] \
+ -image ::ICONS::16::kcmmemory \
+ -raisecmd [list $this bottomNB_set_active_page {Simulator}] \
+ -helptext [mc "Simulator panel %s" "(Ctrl+1)"] \
+ -createcmd [list $this CreateSimulatorGUI] \
]
# Tab "C variables"
- set cvarsview_frame [$pri_notebook insert end {CVarsView} \
- -text [mc "C variables"] \
- -image ::ICONS::16::player_playlist \
- -raisecmd "$this bottomNB_set_active_page {CVarsView}" \
- -helptext [mc "Variables from C source code %s" ""] \
- -createcmd [list $this CreateCVarsViewGUI] \
+ set cvarsview_frame [$pri_notebook insert end {CVarsView} \
+ -text [mc "C variables"] \
+ -image ::ICONS::16::player_playlist \
+ -raisecmd [list $this bottomNB_set_active_page {CVarsView}] \
+ -helptext [mc "Variables from C source code %s" ""] \
+ -createcmd [list $this CreateCVarsViewGUI] \
]
# Tab "Graph"
set graph_frame [$pri_notebook insert end {Graph} \
-text [mc "IO Ports"] \
-image ::ICONS::16::graph \
- -raisecmd "$this bottomNB_set_active_page {Graph}" \
+ -raisecmd [list $this bottomNB_set_active_page {Graph}] \
-helptext [mc "Graph showing state of MCU ports %s" "(Ctrl+2)"] \
-createcmd [list $this CreateGraphGUI] \
]
# Tab "Messages"
- set messages_frame [$pri_notebook insert end {Messages} \
- -text [mc "Messages"] \
- -image ::ICONS::16::kcmsystem \
- -raisecmd "$this bottomNB_set_active_page {Messages}" \
- -helptext [mc "Compiler messages %s" "(Ctrl+3)"] \
- -createcmd [list $this CreateMessagesGUI] \
+ set messages_frame [$pri_notebook insert end {Messages} \
+ -text [mc "Messages"] \
+ -image ::ICONS::16::kcmsystem \
+ -raisecmd [list $this bottomNB_set_active_page {Messages}] \
+ -helptext [mc "Compiler messages %s" "(Ctrl+3)"] \
+ -createcmd [list $this CreateMessagesGUI] \
+ -leavecmd "
+ $pri_notebook itemconfigure {Messages} -image ::ICONS::16::kcmsystem
+ " \
]
# Tab "Notes"
set todo_frame [$pri_notebook insert end {Todo} \
-text [mc "Notes"] \
-image ::ICONS::16::camera_test \
- -raisecmd "$this bottomNB_set_active_page {Todo}" \
- -helptext [mc "Personal todo list & notepad %s" "(Ctrl+4)"]\
+ -raisecmd [list $this bottomNB_set_active_page {Todo}] \
+ -helptext [mc "Personal to do list & notepad %s" "(Ctrl+4)"]\
-createcmd [list $this CreateTodoGUI] \
]
# Tab "Calculator"
- set calculator_frame [$pri_notebook insert end {Calculator} \
- -text [mc "Calculator"] \
- -image ::ICONS::16::xcalc \
- -raisecmd "$this bottomNB_set_active_page {Calculator}" \
- -helptext [mc "Scientific calculator %s" "(Ctrl+5)"] \
- -createcmd [list $this CreateCalculatorGUI] \
+ set calculator_frame [$pri_notebook insert end {Calculator} \
+ -text [mc "Calculator"] \
+ -image ::ICONS::16::xcalc \
+ -raisecmd [list $this bottomNB_set_active_page {Calculator}] \
+ -helptext [mc "Scientific calculator %s" "(Ctrl+5)"] \
+ -createcmd [list $this CreateCalculatorGUI] \
]
if {!$::MICROSOFT_WINDOWS} { ;# Microsoft Windows has no terminal emulator
# Tab "Terminal"
- set terminal_frame [$pri_notebook insert end {Terminal} \
- -text [mc "Terminal"] \
- -image ::ICONS::16::terminal \
- -raisecmd "$this bottomNB_set_active_page {Terminal}" \
- -helptext [mc "Terminal emulator %s" ""] \
- -createcmd [list $this CreateTerminalEmulGUI] \
- -state [expr {${::PROGRAM_AVALIABLE(urxvt)} ? "normal" : "disabled"}] \
+ set terminal_frame [$pri_notebook insert end {Terminal} \
+ -text [mc "Terminal"] \
+ -image ::ICONS::16::terminal \
+ -raisecmd [list $this bottomNB_set_active_page {Terminal}] \
+ -helptext [mc "Terminal emulator %s" ""] \
+ -createcmd [list $this CreateTerminalEmulGUI] \
+ -state [expr {${::PROGRAM_AVAILABLE(urxvt)} ? "normal" : "disabled"}] \
]
}
# Tab "Find in files"
- set findinfiles_frame [$pri_notebook insert end {FindInFiles} \
- -text [mc "Find in files"] \
- -image ::ICONS::16::filefind \
- -raisecmd "$this bottomNB_set_active_page {FindInFiles}"\
- -helptext [mc "Find in files %s" ""] \
- -createcmd [list $this CreateFindInFilesGUI] \
+ set findinfiles_frame [$pri_notebook insert end {FindInFiles} \
+ -text [mc "Find in files"] \
+ -image ::ICONS::16::filefind \
+ -raisecmd [list $this bottomNB_set_active_page {FindInFiles}] \
+ -helptext [mc "Find in files %s" ""] \
+ -createcmd [list $this CreateFindInFilesGUI] \
]
# Tab "Hide"
- $pri_notebook insert end {Hide} \
- -text [mc "Hide"] \
- -image ::ICONS::16::2downarrow \
- -raisecmd "$this bottomNB_show_hide" \
- -helptext [mc "Hide this panel"] \
-
- ## Create Secondary NoteBook tabs
- # tab "Simulator"
- $sec_notebook insert end {Simulator} \
- -text [mc "Simulator"] \
- -image ::ICONS::16::kcmmemory \
- -raisecmd "$this bottomNB_show_hide Simulator" \
- -helptext [mc "Simulator panel %s" "(Ctrl+1)"]
- # tab "C variables"
- $sec_notebook insert end {CVarsView} \
- -text [mc "C variables"] \
- -image ::ICONS::16::player_playlist \
- -raisecmd "$this bottomNB_show_hide CVarsView" \
- -helptext [mc "Variables from C source code %s" ""]
- # tab "Graph"
- $sec_notebook insert end {Graph} \
- -text [mc "IO Ports"] \
- -image ::ICONS::16::graph \
- -raisecmd "$this bottomNB_show_hide Graph" \
- -helptext [mc "Graph showing state of MCU ports %s" "(Ctrl+2)"]
- # tab "Messages"
- $sec_notebook insert end {Messages} \
- -text [mc "Messages"] \
- -image ::ICONS::16::kcmsystem \
- -raisecmd "$this bottomNB_show_hide Messages" \
- -helptext [mc "Compiler messages %s" "(Ctrl+3)"]
- # tab "Notes"
- $sec_notebook insert end {Todo} \
- -text [mc "Notes"] \
- -image ::ICONS::16::camera_test \
- -raisecmd "$this bottomNB_show_hide Todo" \
- -helptext [mc "Personal todo list & notepad %s" "(Ctrl+4)"]
- # tab "Calculator"
- $sec_notebook insert end {Calculator} \
- -text [mc "Calculator"] \
- -image ::ICONS::16::xcalc \
- -raisecmd "$this bottomNB_show_hide Calculator" \
- -helptext [mc "Scientific calculator %s" "(Ctrl+5)"]
- if {!$::MICROSOFT_WINDOWS} { ;# Microsoft Windows has no terminal emulator
- # tab "Terminal"
- $sec_notebook insert end {Terminal} \
- -text [mc "Terminal"] \
- -image ::ICONS::16::terminal \
- -raisecmd "$this bottomNB_show_hide Terminal" \
- -helptext [mc "Terminal emulator %s" ""] \
- -state [expr {${::PROGRAM_AVALIABLE(urxvt)} ? "normal" : "disabled"}]
- }
- # tab "Find in files"
- $sec_notebook insert end {FindInFiles} \
- -text [mc "Find in files"] \
- -image ::ICONS::16::filefind \
- -raisecmd "$this bottomNB_show_hide FindInFiles" \
- -helptext [mc "Find in files %s" ""] \
- -createcmd [list $this CreateFindInFilesGUI]
- # tab "Show"
- $sec_notebook insert end {Show} \
- -text [mc "Show"] \
- -image ::ICONS::16::2uparrow \
- -raisecmd "$this bottomNB_show_hide" \
- -helptext [mc "Show this panel"]
+ $pri_notebook insert end {Hide} \
+ -text [mc "Hide"] \
+ -image ::ICONS::16::2downarrow \
+ -raisecmd [list $this bottomNB_show_hide] \
+ -helptext [mc "Hide this panel"] \
# Prepare panel componenets but do not create GUI elements
PrepareCalculator $calculator_frame $calculatorList
PrepareGraph $graph_frame $graph_config
PrepareMessages $messages_frame
PrepareTodo $todo_frame $todoText
+
PrepareSimulator $simulator_frame
PrepareCVarsView $cvarsview_frame
if {!$::MICROSOFT_WINDOWS} { ;# Microsoft Windows has no terminal emulator
@@ -278,25 +213,30 @@ class BottomNoteBook {
}
PrepareFindInFiles $findinfiles_frame
-
# take case of proper pane resizing
bind $parentPane <ButtonRelease-1> "$this bottomNB_panel_set_size"
# Show primary notebook if panel is visible or secondary notebook ohterwise
+ pack [$pri_notebook get_nb] -expand 1 -fill both -padx 5 -pady 5
if {$PanelVisible != 0} {
- pack $pri_notebook -expand 1 -fill both
- $parentPane paneconfigure $main_frame -minsize 190
- $parentPane configure -sashwidth 2
+ $parentPane paneconfigure $main_frame -minsize 215
+ $parentPane configure -sashwidth 4
# Raise tab
catch {$pri_notebook raise $active_page}
- } {
- pack $sec_notebook -anchor nw -fill x -expand 1
+ } else {
+ $pri_notebook hide_pages_area
+ $pri_notebook deselect_tab_button
+ $pri_notebook itemconfigure {Hide} \
+ -text [mc "Show"] \
+ -image ::ICONS::16::2uparrow \
+ -helptext [mc "Show this panel"]
+
$parentPane paneconfigure $main_frame -minsize 0
$parentPane configure -sashwidth 0
bind $parentPane <Button> {break}
set last_PanelSize $PanelSize
- set PanelSize 24
+ set PanelSize 34
}
}
@@ -309,7 +249,7 @@ class BottomNoteBook {
public method getBottomPanelSize {} {
if {$PanelVisible} {
return $PanelSize
- } {
+ } else {
return $last_PanelSize
}
}
@@ -332,13 +272,18 @@ class BottomNoteBook {
Calculator {$this CalculatorTabRaised}
FindInFiles {$this FindInFilesTabRaised}
}
- set active_page $pageName
+ if {$pageName != {Hide}} {
+ set active_page $pageName
+ }
+ if {!$PanelVisible} {
+ bottomNB_show_hide
+ }
}
## Show or hide the panel
- # @parm String args = NULL - name of active page (show panel)
+ # @parm String a_page={} - name of active page (show panel)
# @return void
- public method bottomNB_show_hide args {
+ public method bottomNB_show_hide {{a_page {}}} {
# If panel hidding is disabled -- abort
if {!$panel_hidding_ena} {return}
@@ -347,17 +292,17 @@ class BottomNoteBook {
if {$PanelVisible} {
$parentPane paneconfigure $main_frame -minsize 0
- # Ged rid of primary notebook
- pack forget $pri_notebook ;# Hide primary notebook
+ $pri_notebook hide_pages_area
+ $pri_notebook deselect_tab_button
+ $pri_notebook itemconfigure {Hide} \
+ -text [mc "Show"] \
+ -image ::ICONS::16::2uparrow \
+ -helptext [mc "Show this panel"]
set last_PanelSize $PanelSize ;# Save current panel size
- set PanelSize 24 ;# Set New panel size
+ set PanelSize 34 ;# Set New panel size
bottomNB_redraw_pane ;# Perform hidding
- # Create and show secondary notebook
- pack $sec_notebook -anchor nw -fill x -expand 1
- $sec_notebook compute_size
set panel_hidding_ena 0
- $sec_notebook raise $active_page
set panel_hidding_ena 1
$parentPane configure -sashwidth 0
bind $parentPane <Button> {break}
@@ -366,32 +311,34 @@ class BottomNoteBook {
set PanelVisible 0
# Show the panel
- } {
- $parentPane paneconfigure $main_frame -minsize 190
+ } else {
+ $parentPane paneconfigure $main_frame -minsize 215
- # Hide secondary notebook
- pack forget $sec_notebook
+ $pri_notebook show_pages_area
+ $pri_notebook itemconfigure {Hide} \
+ -text [mc "Hide"] \
+ -image ::ICONS::16::2downarrow \
+ -helptext [mc "Hide this panel"]
# Create and show primary notebook
set PanelSize $last_PanelSize ;# Restore panel size
bottomNB_redraw_pane ;# Perform showing
+
# Raise active page
- if {$args == {}} {
+ if {$a_page == {}} {
$pri_notebook raise $active_page
- } {
- $pri_notebook raise $args
+ } else {
+ $pri_notebook raise $a_page
}
- # Pack primary notebook
- pack $pri_notebook -expand 1 -fill both
# Restore sash width
- $parentPane configure -sashwidth 2
+ $parentPane configure -sashwidth 4
bind $parentPane <Button> {}
# Panel is now shown
set PanelVisible 1
}
- update idle
+ update idletasks
$this editor_procedure {} Configure {}
}
@@ -401,7 +348,7 @@ class BottomNoteBook {
set PanelSize [lindex [$parentPane sash coord 0] 1]
set PanelSize [expr {[winfo height $parentPane] - $PanelSize}]
- update idle
+ update idletasks
$this editor_procedure {} Configure {}
$this editor_procedure {} goto \
[$this editor_procedure {} get_current_line_number {}]
@@ -411,15 +358,17 @@ class BottomNoteBook {
# @parm Int by - pixels
# @return void
public method bottomNB_move_pane_up {by} {
- update idle
+ update idletasks
$parentPane sash place 0 0 [expr {[winfo height $parentPane] - $PanelSize - $by}]
}
## Redraw panel pane
# @return void
public method bottomNB_redraw_pane {} {
- update idle
- $parentPane sash place 0 0 [expr {[winfo height $parentPane] - $PanelSize}]
+ update idletasks
+ catch {
+ $parentPane sash place 0 0 [expr {[winfo height $parentPane] - $PanelSize}]
+ }
}
## Redraw panel pane on expose event
@@ -431,9 +380,9 @@ class BottomNoteBook {
}
set redraw_pane_in_progress 1
- update idle
+ update idletasks
$parentPane sash place 0 0 [expr {[winfo height $parentPane] - $PanelSize}]
- update idle
+ update idletasks
set redraw_pane_in_progress 0
}
@@ -445,7 +394,7 @@ class BottomNoteBook {
public method bottomNB_show_up {page} {
if {$PanelVisible} {
$pri_notebook raise $page
- } {
+ } else {
bottomNB_show_hide $page
}
}
@@ -466,4 +415,16 @@ class BottomNoteBook {
public method graph_itialize_simulator_graph_panel {graph_config} {
$this graph_change_mcu
}
-} \ No newline at end of file
+
+ ## Configure particular page on bottom notebook widget
+ # @parm String page - Page ID
+ # @parm List options - Any options acceptable by the notebook widget
+ # @return void
+ public method bottomnotebook_pageconfigure {page options} {
+ eval "$pri_notebook itemconfigure {$page} $options"
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/bottompanel/calculator.tcl b/lib/bottompanel/calculator.tcl
index 5196b40..b7ab722 100755..100644
--- a/lib/bottompanel/calculator.tcl
+++ b/lib/bottompanel/calculator.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 _CALCULATOR_TCL ] } {
+set _CALCULATOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
#
@@ -28,12 +33,12 @@
class Calculator {
- common count 0 ;# counter of instances
+ common calc_count 0 ;# counter of instances
# Font for numerical keypad
- common large_font [font create \
- -family {helveticat} \
- -size -12 \
- -weight {bold} \
+ common large_font [font create \
+ -family {helveticat} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight {bold} \
]
common oper_fg_color {#0000FF} ;# Foreground color for operator display
@@ -44,7 +49,7 @@ class Calculator {
# Variables related to object initialization
private variable parent ;# Teportary variable -- GUI parent
private variable calculatorList ;# Teportary variable -- COnfiguration list
- private variable gui_initialized 0 ;# Bool: GUI created
+ private variable calc_gui_initialized 0 ;# Bool: GUI created
# GUI variables
private variable calc_num_keypad ;# Container of left side of calc. (keypad)
@@ -138,11 +143,11 @@ class Calculator {
{{ASin} {AS} {calc_opr ASin 1} {} {}
{Arc sine}
{5} {} {} {Calculator_RED} {#FFDDDD} 0
- {Arc sine. Argument should be in the range \[-1,1\].}}
+ {Arc sine. Argument should be in the range [-1,1].}}
{{ACos} {AC} {calc_opr ACos 1} {} {}
{Arc cosine}
{5} {} {} {Calculator_RED} {#FFDDDD} 0
- {Arc cosine. Argument should be in the range \[-1,1\].}}
+ {Arc cosine. Argument should be in the range [-1,1].}}
{{ATan} {AT} {calc_opr ATan 1} {} {}
{Arc tangent}
{5} {} {} {Calculator_RED} {#FFDDDD} 0
@@ -226,8 +231,8 @@ class Calculator {
## object constructor
constructor {} {
# Initialize some variables
- incr count ;# Instance counter
- set calc_idx $count ;# Index of this object
+ incr calc_count ;# Instance counter
+ set calc_idx $calc_count;# Index of this object
set base Dec ;# Default numeric base
set angle rad ;# Default angle unit
set last_base $base ;# Last numeric base
@@ -263,7 +268,7 @@ class Calculator {
ttk::style configure Calculator_GRAY.TButton -padding 2
ttk::style map Calculator_GRAY.TButton \
- -background [list active {#DDDDDD} {!active !disabled} {#F8F8F8} disabled {#EEEEEE}]
+ -background [list active {#DDDDDD} {!active !disabled} {#F8F8F8} disabled ${::COMMON_BG_COLOR}]
ttk::style configure Calculator_PURPLE.TButton -padding 2 -font $large_font
ttk::style map Calculator_PURPLE.TButton \
@@ -460,9 +465,9 @@ class Calculator {
set calc_mem [string range $calc_mem 0 {end-2}]
}
set ::Calculator::calc_mem${cell}_$calc_idx $calc_mem
- } {
+ } else {
# Load memory content into main display
- set calc_display [subst "\$::Calculator::calc_mem${cell}_$calc_idx"]
+ set calc_display [subst -nocommands "\$::Calculator::calc_mem${cell}_$calc_idx"]
rewrite_display
}
}
@@ -490,7 +495,7 @@ class Calculator {
$calc_oper == {pow} || $calc_oper == {mod} ||
$calc_oper == {and} || $calc_oper == {or} ||
$calc_oper == {xor} || $calc_oper == {nand}
- } {
+ } then {
# Check display value length
if {$display == {}} {
Sbar [mc "Calculator: Unable to evaluate, missing argument"]
@@ -603,8 +608,8 @@ class Calculator {
set calc_display [expr {tan($calc_buffer)}]
}
}
- }]} {
- # If error occured -> show error message
+ }]} then {
+ # If error occurred -> show error message
Sbar [mc "Calculator: ERROR (result value is out of allowed range)"]
return
}
@@ -727,25 +732,25 @@ class Calculator {
# Determinate what memory cells aren't empty
for {set i 0} {$i < 3} {incr i} {
- set mem [[subst "\$mem_entry_$i"] get]
+ set mem [[subst -nocommands "\$mem_entry_$i"] get]
if {[string index $mem end] == {.}} {
append mem 0
}
set memory$i $mem
if {$mem == {} || $mem == 0} {
set mem$i 0
- } {
+ } else {
set mem$i 1
}
}
# Convert all non empty displays
- foreach cnd "$dis $buf $mem0 $mem1 $mem2" \
+ foreach cnd [list $dis $buf $mem0 $mem1 $mem2] \
var {calc_display calc_buffer memory0 memory1 memory2} {
if {$cnd} {
if {[catch {
- set $var [$command [subst "\$$var"]]
- }]} {
+ set $var [$command [subst -nocommands "\$$var"]]
+ }]} then {
Sbar [mc "Calculator: Value is too high to convert, value deleted !"]
set $var 0
}
@@ -754,8 +759,8 @@ class Calculator {
# Display new content of memory cells
for {set i 0} {$i < 3} {incr i} {
- [subst "\$mem_entry_$i"] delete 0 end
- [subst "\$mem_entry_$i"] insert end [subst "\$memory$i"]
+ [subst -nocommands "\$mem_entry_$i"] delete 0 end
+ [subst -nocommands "\$mem_entry_$i"] insert end [subst -nocommands "\$memory$i"]
}
}
@@ -764,7 +769,7 @@ class Calculator {
public method cal_switchBase {} {
# Get chosen value
- set base [subst "\$::Calculator::calc_base$calc_idx"]
+ set base [subst -nocommands "\$::Calculator::calc_base$calc_idx"]
# Convert display content to setected numeric system
if {$base == $last_base} {
@@ -852,32 +857,70 @@ class Calculator {
public method cal_switchAngle {} {
# Get chosen unit
- set angle [subst "\$::Calculator::calc_angle$calc_idx"]
+ set angle [subst -nocommands "\$::Calculator::calc_angle$calc_idx"]
# Convert all displays
- if {$angle != $last_angle} {
- # Convert display if is not empty
- if {[read_display_inDec] != {}} {
- write_display_inXbase [Angle::${last_angle}2${angle} $calc_display]
+ if {$angle == $last_angle} {
+ set last_angle $angle
+ return
+ }
+
+ # Convert display if is not empty
+ if {[read_display_inDec] != {}} {
+ write_display_inXbase [Angle::${last_angle}2${angle} $calc_display]
+ }
+
+ # Convert buffer if is not empty
+ if {[read_buffer_inDec] != {}} {
+ write_buffer_inXbase [Angle::${last_angle}2${angle} $calc_buffer]
+ }
+
+ # Conver memory cells
+ for {set i 0} {$i <3} {incr i} {
+ # Get memory cell value
+ set mem [[subst -nocommands "\$mem_entry_$i"] get]
+
+ # Convert to decimal value
+ if {$base != {Dec}} {
+ switch -- $base {
+ {Hex} { ;# from Hexadecimal
+ set mem [NumSystem::hex2dec $mem]
+ }
+ {Oct} { ;# from Octal
+ set mem [NumSystem::oct2dec $mem]
+ }
+ {Bin} { ;# from Binary
+ set mem [NumSystem::bin2dec $mem]
+ }
+ }
}
- # Convert buffer if is not empty
- if {[read_buffer_inDec] != {}} {
- write_buffer_inXbase [Angle::${last_angle}2${angle} $calc_buffer]
+
+ # Adjust that value
+ if {[string index $mem end] == {.}} {
+ append mem 0
}
- # Conver memory cells
- for {set i 0} {$i <3} {incr i} {
- # Get memory cell value
- set mem [[subst "\$mem_entry_$i"] get]
- # Adjust that value
- if {[string index $mem end] == {.}} {
- append mem 0
- }
- # Display new value
- if {$mem != {}} {
- set mem [Angle::${last_angle}2${angle} $mem]
- [subst "\$mem_entry_$i"] delete 0 end
- [subst "\$mem_entry_$i"] insert end $mem
+
+ # Display new value
+ if {$mem != {}} {
+ set mem [Angle::${last_angle}2${angle} $mem]
+
+ # Convert to back from decimal value
+ if {$base != {Dec}} {
+ switch -- $base {
+ {Hex} { ;# to Hexadecimal
+ set mem [NumSystem::dec2hex $mem]
+ }
+ {Oct} { ;# to Octal
+ set mem [NumSystem::dec2oct $mem]
+ }
+ {Bin} { ;# to Binary
+ set mem [NumSystem::dec2bin $mem]
+ }
+ }
}
+
+ [subst -nocommands "\$mem_entry_$i"] delete 0 end
+ [subst -nocommands "\$mem_entry_$i"] insert end $mem
}
}
@@ -920,7 +963,7 @@ class Calculator {
{Hex} { ;# to Hexadecimal
if {[catch {
set calc_display [NumSystem::dec2hex $dec_content]
- }]} {
+ }]} then {
Sbar [mc "Calculator: ERROR, result is too high (cannot be displayed)"]
set calc_display 0
}
@@ -928,7 +971,7 @@ class Calculator {
{Oct} { ;# to Octal
if {[catch {
set calc_display [NumSystem::dec2oct $dec_content]
- }]} {
+ }]} then {
Sbar [mc "Calculator: ERROR, result is too high (cannot be displayed)"]
set calc_display 0
}
@@ -936,14 +979,14 @@ class Calculator {
{Bin} { ;# to Binary
if {[catch {
set calc_display [NumSystem::dec2bin $dec_content]
- }]} {
+ }]} then {
Sbar [mc "Calculator: ERROR, result is too high (cannot be displayed)"]
set calc_display 0
}
}
}
# If selected numeric base is Dec -> do nothing
- } {
+ } else {
set calc_display $dec_content
}
@@ -986,7 +1029,7 @@ class Calculator {
{Hex} { ;# to Hexadecimal
if {[catch {
set calc_buffer [NumSystem::dec2hex $dec_content]
- }]} {
+ }]} then {
Sbar [mc "Calculator: ERROR, value is too high"]
set calc_buffer 0
}
@@ -994,7 +1037,7 @@ class Calculator {
{Oct} { ;# to Octal
if {[catch {
set calc_buffer [NumSystem::dec2oct $dec_content]
- }]} {
+ }]} then {
Sbar [mc "Calculator: ERROR, value is too high"]
set calc_buffer 0
}
@@ -1002,14 +1045,14 @@ class Calculator {
{Bin} { ;# to Binary
if {[catch {
set calc_buffer [NumSystem::dec2bin $dec_content]
- }]} {
+ }]} then {
Sbar [mc "Calculator: ERROR, value is too high"]
set calc_buffer 0
}
}
}
# If selected numeric base is Dec -> do nothing
- } {
+ } else {
set calc_buffer $dec_content
}
@@ -1040,16 +1083,16 @@ class Calculator {
}
## Read true content of main display widget converted
- # @parm args = False - adjust to float
+ # @parm args atf=0 - do not adjust to float
# @return Float - content of the main display
- private method reread_display args {
+ private method reread_display {{atf 0}} {
# Get content of the widget
set calc_display [$calc_display_widget get]
regsub {\,} $calc_display {.} calc_display
- # Adhust to float (if requested)
- if {$args != 1} {
+ # Adjust to float (if requested)
+ if {!$atf} {
if {[regexp {^\.} $calc_display]} {
set calc_display "0$calc_display"
} elseif {[regexp {\.$} $calc_display]} {
@@ -1106,7 +1149,7 @@ class Calculator {
if {$angle == {grad}} {
set dec_angle [Angle::grad2rad $dec_angle]
# From degrees
- } {
+ } else {
set dec_angle [Angle::deg2rad $dec_angle]
}
}
@@ -1124,7 +1167,7 @@ class Calculator {
if {$angle == {grad}} {
set dec_angle [Angle::rad2grad $dec_angle]
# To degrees
- } {
+ } else {
set dec_angle [Angle::rad2deg $dec_angle]
}
}
@@ -1183,7 +1226,7 @@ class Calculator {
$widget configure -style Calculator_Error.TEntry
}
return 1
- } {
+ } else {
Sbar [mc "Calculator: Trying to insert invalid value"]
return 0
}
@@ -1243,10 +1286,10 @@ class Calculator {
return
# Negate value
- } {
+ } else {
if {[regexp {^\-} $calc_display]} {
set calc_display [string range $calc_display 1 end]
- } {
+ } else {
set calc_display "-$calc_display"
}
}
@@ -1262,7 +1305,7 @@ class Calculator {
public method PrepareCalculator {_parent _calculatorList} {
set parent $_parent
set calculatorList $_calculatorList
- set gui_initialized 0
+ set calc_gui_initialized 0
}
## Inform this tab than it has became active
@@ -1271,13 +1314,20 @@ class Calculator {
$calc_display_widget selection range 0 end
$calc_display_widget icursor end
focus $calc_display_widget
+
+ update idletasks
+ $scrollable_frame yview scroll 0 units
}
## Initialize calculator GUI
# @return void
public method CreateCalculatorGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$calc_gui_initialized} {return}
+ set calc_gui_initialized 1
+
+ if {${::DEBUG}} {
+ puts "CreateCalculatorGUI \[ENTER\]"
+ }
# Create scrollable area
set scrollable_frame [ScrollableFrame $parent.scrollable_frame \
@@ -1307,7 +1357,7 @@ class Calculator {
set calc_buffer_widget [ttk::entry $frame0.calc_buffer \
-textvariable ::Calculator::calc_buffer$calc_idx \
-validate key \
- -validatecommand "$this calc_validate %W %P" \
+ -validatecommand [list $this calc_validate %W %P] \
-width 13 \
-style Calculator_Buffer.TEntry \
]
@@ -1319,7 +1369,7 @@ class Calculator {
-textvariable ::Calculator::calc_oper$calc_idx \
-validate all \
-width 3 \
- -validatecommand "$this calc_oper_validate %P" \
+ -validatecommand [list $this calc_oper_validate %P] \
-style Calculator_Oper.TEntry \
]
DynamicHelp::add $frame0.calc_oper -text [mc "Selected operation"]
@@ -1329,7 +1379,7 @@ class Calculator {
set calc_display_widget [ttk::entry $frame0.calc_displ \
-textvariable ::Calculator::calc_displ$calc_idx \
-validate key \
- -validatecommand "$this calc_validate %W %P" \
+ -validatecommand [list $this calc_validate %W %P] \
-width 13 \
-style Calculator_Display.TEntry \
]
@@ -1341,12 +1391,12 @@ class Calculator {
pack $calc_oper_widget -side left
pack $calc_display_widget -side left
# Create binding for displays
- bind $calc_buffer_widget <KP_Enter> "$this calc_Evaluate"
- bind $calc_oper_widget <KP_Enter> "$this calc_Evaluate"
- bind $calc_display_widget <KP_Enter> "$this calc_Evaluate"
- bind $calc_buffer_widget <Return> "$this calc_Evaluate"
- bind $calc_oper_widget <Return> "$this calc_Evaluate"
- bind $calc_display_widget <Return> "$this calc_Evaluate"
+ bind $calc_buffer_widget <KP_Enter> [list $this calc_Evaluate]
+ bind $calc_oper_widget <KP_Enter> [list $this calc_Evaluate]
+ bind $calc_display_widget <KP_Enter> [list $this calc_Evaluate]
+ bind $calc_buffer_widget <Return> [list $this calc_Evaluate]
+ bind $calc_oper_widget <Return> [list $this calc_Evaluate]
+ bind $calc_display_widget <Return> [list $this calc_Evaluate]
## Create: numeric base and angle unit switch + CA + C
@@ -1357,7 +1407,7 @@ class Calculator {
-values {Hex Dec Oct Bin} \
-textvariable ::Calculator::calc_base$calc_idx \
-width 4 \
- ] -side left
+ ] -side left -padx 2
bind $frame1.lf.calc_base_CB <<ComboboxSelected>> "$this cal_switchBase"
DynamicHelp::add $frame1.lf.calc_base_CB -text [mc "Numeric base"]
setStatusTip -widget $frame1.lf.calc_base_CB \
@@ -1368,7 +1418,7 @@ class Calculator {
-values {rad deg grad} \
-textvariable ::Calculator::calc_angle$calc_idx \
-width 4 \
- ] -side left
+ ] -side left -padx 2
bind $frame1.lf.calc_angle_CB <<ComboboxSelected>> "$this cal_switchAngle"
DynamicHelp::add $frame1.lf.calc_angle_CB -text [mc "Angle unit"]
setStatusTip -widget $frame1.lf.calc_angle_CB \
@@ -1379,9 +1429,9 @@ class Calculator {
# Button "Clear"
pack [ttk::button $frame1.rf.calc_Clear \
-text {C} \
- -command "$this calc_Clear" \
+ -command [list $this calc_Clear] \
-width 3 \
- ] -side left
+ ] -side left -padx 2
DynamicHelp::add $frame1.rf.calc_Clear \
-text [mc "Clear both displays"]
setStatusTip -widget $frame1.rf.calc_Clear \
@@ -1389,9 +1439,9 @@ class Calculator {
# Button "Clear actual"
pack [ttk::button $frame1.rf.calc_Clear_act \
-text {CA} \
- -command "$this calc_ClearActual" \
+ -command [list $this calc_ClearActual] \
-width 3 \
- ] -side left
+ ] -side left -padx 2
DynamicHelp::add $frame1.rf.calc_Clear_act \
-text [mc "Clear main display"]
setStatusTip -widget $frame1.rf.calc_Clear_act \
@@ -1399,9 +1449,9 @@ class Calculator {
# Button "Negate"
pack [ttk::button $frame1.rf.calc_Negate_dis \
-text {+/-} \
- -command "$this calc_NegateDis" \
+ -command [list $this calc_NegateDis] \
-width 3 \
- ] -side left
+ ] -side left -padx 2
DynamicHelp::add $frame1.rf.calc_Negate_dis \
-text [mc "Negate value in main display"]
setStatusTip -widget $frame1.rf.calc_Negate_dis \
@@ -1422,7 +1472,7 @@ class Calculator {
set entry [ttk::entry $frame_id.calc_mem_entry_${i} \
-textvariable ::Calculator::calc_mem${i}_${calc_idx} \
-validate all \
- -validatecommand "$this calc_validate %W %P" \
+ -validatecommand [list $this calc_validate %W %P] \
]
DynamicHelp::add $frame_id.calc_mem_entry_${i} -text [mc "Memory bank %s" $i]
pack $entry -side left
@@ -1433,7 +1483,7 @@ class Calculator {
-text [mc "Save"] \
-command "$this mem Save $i" \
-width 5 \
- ] -side left
+ ] -side left -padx 2 -pady 2
DynamicHelp::add $frame_id.calc_mem_save_button_${i} \
-text [mc "Save content of main display to this memory bank %s" $i]
setStatusTip -widget $frame_id.calc_mem_save_button_${i} \
@@ -1443,7 +1493,7 @@ class Calculator {
-text [mc "Load"] \
-command "$this mem Load $i" \
-width 5 \
- ] -side left
+ ] -side left -padx 2 -pady 2
DynamicHelp::add $frame_id.calc_mem_load_button_${i} \
-text [mc "Load content of this bank into main display"]
setStatusTip -widget $frame_id.calc_mem_load_button_${i} \
@@ -1475,7 +1525,7 @@ class Calculator {
for {set i 0} {$i < 5} {incr i} {
if {$i == 1} {
pack $calc_num_display.calc_num_display${i} -pady 10
- } {
+ } else {
pack $calc_num_display.calc_num_display${i}
}
}
@@ -1491,7 +1541,7 @@ class Calculator {
if {
$base != {Hex} && $base != {Dec} &&
$base != {Oct} && $base != {Bin}
- } {
+ } then {
set base [lindex ${X::project_edit_defaults} {3 1}]
puts stderr [mc "Invalid numerical base: '%s'" $base]
}
@@ -1553,14 +1603,14 @@ class Calculator {
## Get calculator list for later initialization
# @return List - resulting list of values
public method get_calculator_list {} {
- if {!$gui_initialized} {CreateCalculatorGUI}
+ if {!$calc_gui_initialized} {CreateCalculatorGUI}
return [list $base $angle \
[$calc_display_widget get] \
$calc_oper \
[$calc_buffer_widget get] \
- [subst "\$::Calculator::calc_mem0_$calc_idx"] \
- [subst "\$::Calculator::calc_mem1_$calc_idx"] \
- [subst "\$::Calculator::calc_mem2_$calc_idx"] \
+ [subst -nocommands "\$::Calculator::calc_mem0_$calc_idx"] \
+ [subst -nocommands "\$::Calculator::calc_mem1_$calc_idx"] \
+ [subst -nocommands "\$::Calculator::calc_mem2_$calc_idx"] \
[$timerscalc_freq_entry get] \
[$timerscalc_time_entry get] \
[$timerscalc_mode_spinbox get]]
@@ -1574,8 +1624,14 @@ class Calculator {
if {$timerscalc_validation_dis} {
return 1
}
+
+ # Ignore empty value
+ if {$content == {}} {
+ return 1
+ }
+
# If content is decimal number (max 5. digits) -> evaluate and return True
- if {[regexp {^\d*$} $content] && ([string length $content] < 6)} {
+ if {[regexp {^\d+(\.\d*)?$} $content] && ([string length $content] < 9)} {
calc_timerscalc_evaluate \
$content \
[$timerscalc_time_entry get] \
@@ -1601,7 +1657,7 @@ class Calculator {
if {$content > 2} {
return 0
}
- calc_timerscalc_evaluate \
+ calc_timerscalc_evaluate \
[$timerscalc_freq_entry get] \
[$timerscalc_time_entry get] \
$content
@@ -1659,7 +1715,7 @@ class Calculator {
foreach widget $widgets {
$widget configure -state normal
}
- } {
+ } else {
foreach widget $widgets {
$widget configure -state disabled
}
@@ -1679,12 +1735,15 @@ class Calculator {
set repeat 0
set correction 0
+ # Remove leading dot from the frequency value
+ set freq [string trimright $freq {.}]
+
# Check for validity of given values
if {$freq == {} || $freq == 0 || $time == {} || $mode == {} } {
set mode {invalid}
- } {
+ } else {
# Compute time in machine cycles
- set time [expr {int($time * (12000.0 / $freq))}]
+ set time [expr {int($time * ($freq / 12000.0))}]
}
# Perform computation for the given mode
@@ -1696,7 +1755,7 @@ class Calculator {
if {[expr {!($time & 0x1FFF)}]} {
incr repeat -1
set stepsPerIter 0x1FFF
- } {
+ } else {
set stepsPerIter [expr {$time / $repeat}]
set tmp [expr {0x2000 - $stepsPerIter}]
set TLx [expr {$tmp & 0x1F}]
@@ -1711,7 +1770,7 @@ class Calculator {
if {[expr {!($time & 0xFFFF)}]} {
incr repeat -1
set stepsPerIter 0xFFFF
- } {
+ } else {
set stepsPerIter [expr {$time / $repeat}]
set tmp [expr {0x10000 - $stepsPerIter}]
set TLx [expr {$tmp & 0xFF}]
@@ -1726,7 +1785,7 @@ class Calculator {
if {[expr {!($time & 0xFF)}]} {
incr repeat -1
set stepsPerIter 0xFF
- } {
+ } else {
set stepsPerIter [expr {$time / $repeat}]
set TLx [expr {0x100 - $stepsPerIter}]
set THx $TLx
@@ -1756,16 +1815,16 @@ class Calculator {
# Check for allowed length of results (string representation)
if {
- [string length [format "%o" $repeat]] > 6
- ||
- [string length [format "%o" $correction]] > 6
- } {
- set TLx 0
- set THx 0
- set repeat 0
- set correction 0
- calc_timerscalc_highlight 0
- Sbar [mc "Calculator: Unable to evaluate, result value is too high"]
+ [string length [format "%o" $repeat]] > 6
+ ||
+ [string length [format "%o" $correction]] > 6
+ } then {
+ set TLx 0
+ set THx 0
+ set repeat 0
+ set correction 0
+ calc_timerscalc_highlight 0
+ Sbar [mc "Calculator: Unable to evaluate, result value is too high"]
}
## Write results
@@ -1810,11 +1869,11 @@ class Calculator {
grid [label $top_frame.calc_timerscalc_mode_label \
-text [mc "Mode"] \
] -row 0 -column 2 -sticky w
- set timerscalc_mode_spinbox [spinbox \
+ set timerscalc_mode_spinbox [ttk::spinbox \
$top_frame.calc_timerscalc_mode_spinbox \
- -bg {#FFFFFF} -highlightthickness 0 \
-from 0 -to 2 -width 1 -validate key \
- -vcmd "$this calc_timerscalc_mode_validate %P" \
+ -validatecommand "$this calc_timerscalc_mode_validate %P" \
+ -command "$this calc_timerscalc_mode_validate \[$top_frame.calc_timerscalc_mode_spinbox get\]"
]
grid $timerscalc_mode_spinbox -row 0 -column 3 -sticky we
# time
@@ -2060,7 +2119,7 @@ class Calculator {
update
}
# Show scrollbar
- } {
+ } else {
if {![winfo ismapped $horizontal_scrollbar]} {
pack $horizontal_scrollbar -fill x -side top -before $scrollable_frame
}
@@ -2069,3 +2128,7 @@ class Calculator {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
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
diff --git a/lib/bottompanel/find_in_files.tcl b/lib/bottompanel/find_in_files.tcl
index d085110..dccc823 100755..100644
--- a/lib/bottompanel/find_in_files.tcl
+++ b/lib/bottompanel/find_in_files.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 _FIND_IN_FILES_TCL ] } {
+set _FIND_IN_FILES_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements panel "Find in files", GUI and function
@@ -28,12 +33,11 @@
# --------------------------------------------------------------------------
class FindInFiles {
-
- common count 0 ;# Counter of class instances
+ common find_inf_count 0 ;# Counter of class instances
# Variables related to object initialization
private variable parent ;# Widget: parent widget
- private variable gui_initialized 0 ;# Bool: GUI initialized
+ private variable find_inf_gui_initialized 0 ;# Bool: GUI initialized
private variable obj_idx ;# Int: Object index
private variable abort_variable 0 ;# Bool: Abort search
@@ -53,8 +57,8 @@ class FindInFiles {
constructor {} {
# Increment object counter
- incr count
- set obj_idx $count
+ incr find_inf_count
+ set obj_idx $find_inf_count
# Load configuration
set ::FindInFiles::recursive_$obj_idx [lindex $::CONFIG(FIND_IN_FILES_CONFIG) 0]
@@ -65,13 +69,13 @@ class FindInFiles {
set ::FindInFiles::pattern_$obj_idx [lindex $::CONFIG(FIND_IN_FILES_CONFIG) 5]
# Validate loaded configuration
- if {![string is boolean -strict [subst "\$::FindInFiles::recursive_$obj_idx"]]} {
+ if {![string is boolean -strict [subst -nocommands "\$::FindInFiles::recursive_$obj_idx"]]} {
set ::FindInFiles::recursive_$obj_idx 1
}
- if {![string is boolean -strict [subst "\$::FindInFiles::regular_expr_$obj_idx"]]} {
+ if {![string is boolean -strict [subst -nocommands "\$::FindInFiles::regular_expr_$obj_idx"]]} {
set ::FindInFiles::regular_expr_$obj_idx 0
}
- if {![string is boolean -strict [subst "\$::FindInFiles::case_sensitive_$obj_idx"]]} {
+ if {![string is boolean -strict [subst -nocommands "\$::FindInFiles::case_sensitive_$obj_idx"]]} {
set ::FindInFiles::case_sensitive_$obj_idx 1
}
}
@@ -88,7 +92,7 @@ class FindInFiles {
# @return void
public method PrepareFindInFiles {_parent} {
set parent $_parent
- set gui_initialized 0
+ set find_inf_gui_initialized 0
}
## Inform this tab than it has became active
@@ -102,8 +106,12 @@ class FindInFiles {
## Create GUI of messages tab
# @return void
public method CreateFindInFilesGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$find_inf_gui_initialized} {return}
+ set find_inf_gui_initialized 1
+
+ if {${::DEBUG}} {
+ puts "CreateFindInFilesGUI \[ENTER\]"
+ }
create_findinfilesgui
create_tags_and_bindings
@@ -150,7 +158,7 @@ class FindInFiles {
set ::FindInFiles::folder_$obj_idx [$this cget -projectPath]
bind $folder_entry <Return> "$this findinfiles_search"
bind $folder_entry <KP_Enter> "$this findinfiles_search"
- pack $folder_entry -side left -fill x -expand 1
+ pack $folder_entry -side left -fill x -expand 1 -pady 2
# Button "Select directory"
pack [ttk::button $folder_entry_frm.select_dir_but \
-image ::ICONS::16::fileopen \
@@ -186,8 +194,8 @@ class FindInFiles {
-width 7 \
]
setStatusTip -widget $clear_button -text [mc "Clear results"]
- pack $find_stop_button -side left
- pack $clear_button -side left
+ pack $find_stop_button -side left -padx 2
+ pack $clear_button -side left -padx 2
# Separator
pack [ttk::separator $top_bottom_frame.sep \
-orient vertical \
@@ -243,13 +251,22 @@ class FindInFiles {
## Bottom frame (text widget and its scrollbar)
set bottom_frame [frame $main_frame.bottom_frame]
- set text_widget [text $bottom_frame.text \
- -bg white -state disabled -bd 1 -wrap none \
- -highlightthickness 0 -exportselection 0 \
- -cursor left_ptr -width 0 -height 0 \
- -yscrollcommand "$bottom_frame.scrollbar set" \
- -font [font create -family helvetica -size -12] \
- -fg {#555555} \
+ set text_widget [text $bottom_frame.text \
+ -bg white \
+ -state disabled \
+ -bd 1 \
+ -wrap none \
+ -highlightthickness 0 \
+ -exportselection 0 \
+ -cursor left_ptr \
+ -width 0 \
+ -height 0 \
+ -yscrollcommand "$bottom_frame.scrollbar set" \
+ -font [font create \
+ -family helvetica \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ ] \
+ -fg {#555555} \
]
pack $text_widget -side left -fill both -expand 1
pack [ttk::scrollbar $bottom_frame.scrollbar \
@@ -269,7 +286,7 @@ class FindInFiles {
# @return void
private method create_tags_and_bindings {} {
# Create tags
- set bold_font [font create -family helvetica -size -12 -weight bold]
+ set bold_font [font create -family helvetica -size [expr {int(-12 * $::font_size_factor)}] -weight bold]
$text_widget tag configure tag_highlight -foreground {#000000} -font $bold_font
$text_widget tag configure tag_filename -foreground {#0000DD}
$text_widget tag configure tag_linenumber -foreground {#00DD00}
@@ -292,7 +309,7 @@ class FindInFiles {
{goto} "Go to this line"}
{command "Clear" {} 0 "findinfiles_clear"
{editdelete} "Clear this panel"}
- } $menu 0 "$this " 0 {}
+ } $menu 0 "$this " 0 {} [namespace current]
$menu entryconfigure [::mc "Clear"] -state disabled
}
@@ -302,7 +319,7 @@ class FindInFiles {
KIFSD::FSD ::fsd \
-title [mc "Choose directory - MCU 8051 IDE"] \
-fileson 0 -master . \
- -directory [subst "\$::FindInFiles::folder_$obj_idx"]
+ -directory [subst -nocommands "\$::FindInFiles::folder_$obj_idx"]
fsd setokcmd "set ::FindInFiles::folder_$obj_idx \[::fsd get\]"
fsd activate
}
@@ -311,11 +328,11 @@ class FindInFiles {
# @return void
public method findinfiles_search {} {
# Gain search options
- set folder [file normalize [subst "\$::FindInFiles::folder_$obj_idx"]]
- set mask [subst "\$::FindInFiles::mask_$obj_idx"]
- set pattern [subst "\$::FindInFiles::pattern_$obj_idx"]
- set reg_expr [subst "\$::FindInFiles::regular_expr_$obj_idx"]
- set case_sen [subst "\$::FindInFiles::case_sensitive_$obj_idx"]
+ set folder [file normalize [subst -nocommands "\$::FindInFiles::folder_$obj_idx"]]
+ set mask [subst -nocommands "\$::FindInFiles::mask_$obj_idx"]
+ set pattern [subst -nocommands "\$::FindInFiles::pattern_$obj_idx"]
+ set reg_expr [subst -nocommands "\$::FindInFiles::regular_expr_$obj_idx"]
+ set case_sen [subst -nocommands "\$::FindInFiles::case_sensitive_$obj_idx"]
# Validate search options
if {![string length $folder] || ![string length $mask] || ![string length $pattern]} {
@@ -369,7 +386,7 @@ class FindInFiles {
eval "append files { } \[glob -directory {$folder} -nocomplain -types {f l} -- $m\]"
}
}
- if {[subst "\$::FindInFiles::recursive_$obj_idx"]} {
+ if {[subst -nocommands "\$::FindInFiles::recursive_$obj_idx"]} {
append files { } [regsub -all {[\{\}]} [recursive_search $folder $mask] {\\&}]
}
@@ -396,7 +413,7 @@ class FindInFiles {
# Enable / Disable clear button and clear entry in the popup menu
if {[$text_widget index {1.0 lineend}] == {1.0}} {
set state disabled
- } {
+ } else {
set state normal
}
$menu entryconfigure [::mc "Clear"] -state $state
@@ -430,7 +447,7 @@ class FindInFiles {
# Open file
if {[catch {
set file [open $filename r]
- }]} {
+ }]} then {
return 0
}
@@ -474,7 +491,7 @@ class FindInFiles {
set found 0
if {$case_sen} {
set found [regexp -start $idx -- $pattern $line matched_str]
- } {
+ } else {
set found [regexp -nocase -start $idx -- $pattern $line matched_str]
}
@@ -489,7 +506,7 @@ class FindInFiles {
set last_idx $idx
}
# Pure string pattern
- } {
+ } else {
while {$idx != -1} {
set idx [string first $pattern $line $idx]
if {$last_idx >= $idx} {
@@ -571,7 +588,7 @@ class FindInFiles {
set index [$text_widget index [list @$x,$y linestart]]
if {[$text_widget compare $index == [list $index lineend]]} {
set state disabled
- } {
+ } else {
set state normal
}
$menu entryconfigure [::mc "Go to"] -state $state
@@ -619,9 +636,9 @@ class FindInFiles {
set filename [file join $folder $filename]
if {[$this openfile $filename 1 . def def 0 0 {}] != {}} {
$this switch_to_last
- update idle
+ update idletasks
$this editor_procedure {} parseAll {}
- } {
+ } else {
return
}
}
@@ -651,8 +668,8 @@ class FindInFiles {
{
if {$for_what == $number} {
set string $content
- } {
- set string [subst "\$::FindInFiles::$var"]
+ } else {
+ set string [subst -nocommands "\$::FindInFiles::$var"]
}
if {![string length $string]} {
set state disabled
@@ -676,7 +693,7 @@ class FindInFiles {
set y [winfo pointery .]
# Create legend window
- set win [toplevel .findinfiles_help_win -class {Help} -bg {#EEEEEE}]
+ set win [toplevel .findinfiles_help_win -class {Help} -bg ${::COMMON_BG_COLOR}]
set frame [frame $win.f -bg {#555555} -bd 0 -padx 1 -pady 1]
wm overrideredirect $win 1
@@ -703,14 +720,14 @@ class FindInFiles {
pack $frame -fill both -expand 1
# Fill the text widget
- $text insert end "Comma separated list of file masks (e.g \"*.c,*.h,*.asm\")\n"
- $text insert end "The mask may contain any of the following special characters:\n"
- $text insert end " ? Matches any single character.\n"
- $text insert end " * Matches any sequence of zero or more characters.\n"
- $text insert end " \[chars\] Matches any single character in chars.\n"
- $text insert end " If chars contains a sequence of the form a-b then any\n"
- $text insert end " character between a and b (inclusive) will match.\n"
- $text insert end " \x Matches the character x."
+ $text insert end [mc "Comma separated list of file masks (e.g \"*.c,*.h,*.asm\")\n"]
+ $text insert end [mc "The mask may contain any of the following special characters:\n"]
+ $text insert end [mc " ? Matches any single character.\n"]
+ $text insert end [mc " * Matches any sequence of zero or more characters.\n"]
+ $text insert end [mc " \[chars\] Matches any single character in chars.\n"]
+ $text insert end [mc " If chars contains a sequence of the form a-b then any\n"]
+ $text insert end [mc " character between a and b (inclusive) will match.\n"]
+ $text insert end [mc " \\x Matches the character x."]
# Show the text
$text configure -state disabled
@@ -738,13 +755,17 @@ class FindInFiles {
# - Intented for session management
# @return void
public method findinfiles_get_config {} {
- return [list \
- [subst "\$::FindInFiles::recursive_$obj_idx"] \
- [subst "\$::FindInFiles::regular_expr_$obj_idx"] \
- [subst "\$::FindInFiles::case_sensitive_$obj_idx"] \
- [subst "\$::FindInFiles::folder_$obj_idx"] \
- [subst "\$::FindInFiles::mask_$obj_idx"] \
- [subst "\$::FindInFiles::pattern_$obj_idx"] \
+ return [list \
+ [subst -nocommands "\$::FindInFiles::recursive_$obj_idx"] \
+ [subst -nocommands "\$::FindInFiles::regular_expr_$obj_idx"] \
+ [subst -nocommands "\$::FindInFiles::case_sensitive_$obj_idx"] \
+ [subst -nocommands "\$::FindInFiles::folder_$obj_idx"] \
+ [subst -nocommands "\$::FindInFiles::mask_$obj_idx"] \
+ [subst -nocommands "\$::FindInFiles::pattern_$obj_idx"] \
]
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/bottompanel/graph.tcl b/lib/bottompanel/graph.tcl
index e9def9b..3f21052 100755..100644
--- a/lib/bottompanel/graph.tcl
+++ b/lib/bottompanel/graph.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 _GRAPH_TCL ] } {
+set _GRAPH_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Graph panel in the bottom panel - shows states of ports
@@ -30,10 +35,14 @@ source "${::LIB_DIRNAME}/bottompanel/graph_wdg.tcl" ;# Graph widget
class Graph {
## COMMON
+ # Bool: The message: "Performance warning" was already displayed to the user
+ common performance_warning_already_shown 0
+ # Bool: show performance warning when enabling external HW simulation
+ common show_sim_per_warn ${::CONFIG(SHOW_PALE_WARN)}
# Variables related to object initialization
private variable data_list ;# Teportary variable -- Configuration list
- private variable gui_initialized 0 ;# Bool: GUI created
+ private variable graph_gui_initialized 0 ;# Bool: GUI created
private variable parent ;# Parent widget
private variable grid_mode {b} ;# Current grid mode (one of {b n x y})
@@ -66,7 +75,7 @@ class Graph {
## Object constructor
- constructor {} {
+ constructor {} {
# Configure localy used ttk styles
ttk::style configure Graph_ActiveTab.TButton \
-background {#AAAAFF} \
@@ -88,7 +97,10 @@ class Graph {
public method PrepareGraph {Parent _data_list} {
set parent $Parent
set data_list $_data_list
- set gui_initialized 0
+ set graph_gui_initialized 0
+
+ # Enable or disable PALE
+ $this pale_on_off [lindex $data_list 2]
}
## Inform this tab than it has became active
@@ -99,8 +111,12 @@ class Graph {
## Initialize graph
# @return void
public method CreateGraphGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$graph_gui_initialized} {return}
+ set graph_gui_initialized 1
+
+ if {${::DEBUG}} {
+ puts "CreateGraphGUI \[ENTER\]"
+ }
# Create panel frames
set top_bar [frame $parent.top_bar -bg {#CCCCCC}] ;# Buttons for switching pages
@@ -127,7 +143,7 @@ class Graph {
-command "$this graph_switch_grid_mode 1" \
]
DynamicHelp::add $grid_button -text [mc "Change grid"]
- setStatusTip -widget $grid_button -text [mc "Change grid morfology"]
+ setStatusTip -widget $grid_button -text [mc "Change grid morphology"]
pack $grid_button -anchor n
bind $grid_button <Button-1> "$this graph_switch_grid_mode 1; break"
bind $grid_button <Button-3> "$this graph_switch_grid_mode -1; break"
@@ -164,7 +180,7 @@ class Graph {
pack $clear_marks_button
# Create graphs
- set pages_manager [PagesManager $bottom_frame.pages_manager -background {#eeeeee}]
+ set pages_manager [PagesManager $bottom_frame.pages_manager -background ${::COMMON_BG_COLOR}]
set nb_state_frame [$pages_manager add {state}]
set nb_latches_frame [$pages_manager add {latches}]
set nb_output_frame [$pages_manager add {output}]
@@ -226,22 +242,41 @@ class Graph {
# Validate the loaded confiuration
foreach mark_flags {mark_flags_s mark_flags_l mark_flags_o} {
- set mark_flags_data [subst "\$$mark_flags"]
- if {
- ![regexp {^[01]+$} $mark_flags_data]
- ||
- [string bytelength $mark_flags_data] != 170
- } then {
- puts stderr "Invalid graph mark flags -- discarded"
- set $mark_flags [string repeat {0 } 170]
+ set mark_flags_data [subst -nocommands "\$$mark_flags"]
+ if {[string index $mark_flags_data 0] == {X}} {
+ set mark_flags_data [string range $mark_flags_data 1 end]
+ if {
+ [string length $mark_flags_data] != 43
+ ||
+ ![string is xdigit $mark_flags_data]
+ } then {
+ puts stderr "Invalid graph mark flags -- discarded"
+ set $mark_flags [string repeat {0 } 170]
+ } else {
+ set bin [::NumSystem::hex2bin $mark_flags_data]
+ set len [string length $bin]
+ if {$len < 170} {
+ set bin "[string repeat {0} [expr {170 - $len}]]$bin"
+ }
+ set $mark_flags [split $bin {}]
+ }
} else {
- set $mark_flags [split $mark_flags_data {}]
+ if {
+ ![regexp {^[01]+$} $mark_flags_data]
+ ||
+ [string bytelength $mark_flags_data] != 170
+ } then {
+ puts stderr "Invalid graph mark flags -- discarded"
+ set $mark_flags [string repeat {0 } 170]
+ } else {
+ set $mark_flags [split $mark_flags_data {}]
+ }
}
}
if {
$magnification != {0} && $magnification != {1} &&
$magnification != {2} && $magnification != {3}
- } {
+ } then {
puts stderr "Invalid graph magnification level -- setting to default"
set magnification 0
}
@@ -252,7 +287,7 @@ class Graph {
if {
$grid_mode != {b} && $grid_mode != {n} &&
$grid_mode != {y} && $grid_mode != {x}
- } {
+ } then {
puts stderr "Invalid graph grid mode -- setting to 'y'"
set grid_mode {y}
}
@@ -295,7 +330,7 @@ class Graph {
set win_y [winfo pointery .]
# Create legend window
- set win [toplevel .graph_help_win -class {Help} -bg {#EEEEEE}]
+ set win [toplevel .graph_help_win -class {Help} -bg ${::COMMON_BG_COLOR}]
set frame [frame $win.f -bg {#555555} -bd 0 -padx 1 -pady 1]
wm overrideredirect $win 1
@@ -349,7 +384,7 @@ class Graph {
$canvas create line $x 15 [expr {$x + 20}] 15 -fill {#000000} -width 2
# {X} Access to external memory
- } {
+ } else {
$canvas create rectangle $x 20 \
[expr {$x + 20}] 15 \
-fill {#00FF00} -width 0 -outline {#00FF00}
@@ -358,7 +393,7 @@ class Graph {
-fill {#FF0000} -width 0 -outline {#FF0000}
}
incr x 20
- # {-} Undeterminable state
+ # {-} Indeterminable state
$canvas create line $x 15 \
[expr {$x + 5}] 11 \
[expr {$x + 10}] 15 \
@@ -386,18 +421,18 @@ class Graph {
if {$nc_instead_of_X} {
set tmp_txt [mc "Not connected"]
# {X} Access to external memory
- } {
+ } else {
set tmp_txt [mc "Access to external memory"]
}
$canvas create line 40 23 40 86 50 86 \
-fill {#000000} -arrow first -arrowshape {6 6 2}
$canvas create text 50 86 -fill {#000000} -anchor w \
-text $tmp_txt -font $::smallfont
- # {-} Undeterminable state
+ # {-} Indeterminable state
$canvas create line 60 23 60 72 70 72 \
-fill {#000000} -arrow first -arrowshape {6 6 2}
$canvas create text 70 72 -fill {#000000} -anchor w \
- -text [mc "Undeterminable state"] -font $::smallfont
+ -text [mc "Indeterminable state"] -font $::smallfont
# {?} No voltage
$canvas create line 80 23 80 58 90 58 \
-fill {#000000} -arrow first -arrowshape {6 6 2}
@@ -467,15 +502,15 @@ class Graph {
}
## Draw interrupt line
- # @parm String = {} - If "nohistory" the history of interrupt lines will not be modified
+ # @parm String nh={} - If "nohistory" the history of interrupt lines will not be modified
# @return void
- public method graph_draw_interrupt_line args {
- if {!$gui_initialized} {CreateGraphGUI}
+ public method graph_draw_interrupt_line {{nh {}}} {
+ if {!$graph_gui_initialized} {CreateGraphGUI}
create_all_graph_widgets
- $graph_state graph_draw_interrupt_line $args
- $graph_latches graph_draw_interrupt_line $args
- $graph_output graph_draw_interrupt_line $args
+ $graph_state graph_draw_interrupt_line $nh
+ $graph_latches graph_draw_interrupt_line $nh
+ $graph_output graph_draw_interrupt_line $nh
}
## Draw new port states in the graph
@@ -483,7 +518,7 @@ class Graph {
# @parm List values - Values to display ...
# @return void
public method graph_new_output_state {target values} {
- if {!$gui_initialized} {CreateGraphGUI}
+ if {!$graph_gui_initialized} {CreateGraphGUI}
create_all_graph_widgets
switch -- $target {
@@ -522,6 +557,52 @@ class Graph {
public method graph_change_status_on {} {
set drawing_on [expr {!$drawing_on}]
graph_commit_state_on_off
+
+ # Show performance warning
+ if {$show_sim_per_warn && !$performance_warning_already_shown && $drawing_on} {
+ set performance_warning_already_shown 1
+ if {[winfo exists .performance_warning_dialog]} {
+ destroy .performance_warning_dialog
+ }
+ set dialog [toplevel .performance_warning_dialog]
+ set top_frame [frame $dialog.top]
+ pack [label $top_frame.img -image ::ICONS::32::messagebox_info] -side left -padx 5
+ pack [label $top_frame.txt -text [mc "You have just enabled simulation of external devices. Having this feature enabled causes serious reduction of simulator performance, the number of instructions executed per second in real time usually decreases by a factor of hundreds, maybe even thousands."] -wraplength 300 -justify left] -side left -fill both -padx 5
+
+ set bottom_frame [frame $dialog.bottom]
+ pack [checkbutton $bottom_frame.chb \
+ -text [mc "Do not display again"] \
+ -onvalue 0 \
+ -offvalue 1 \
+ -variable ::Graph::show_sim_per_warn \
+ ] -anchor e -pady 5
+ pack [ttk::button $bottom_frame.button_ok \
+ -text [mc "Ok"] -compound left \
+ -image ::ICONS::16::ok \
+ -command "grab release $dialog; destroy $dialog"\
+ ] -pady 10
+ bind $bottom_frame.button_ok <Return> "grab release $dialog; destroy $dialog"
+ bind $bottom_frame.button_ok <KP_Enter> "grab release $dialog; destroy $dialog"
+
+ # Pack window frames
+ pack $top_frame -expand 1 -padx 5 -pady 5
+ pack $bottom_frame -padx 5 -fill x
+
+ # Window manager options -- modal window
+ wm iconphoto $dialog ::ICONS::16::info
+ wm title $dialog [mc "Performance warning"]
+ wm resizable $dialog 0 0
+ wm transient $dialog .
+ catch {grab $dialog}
+ wm protocol $dialog WM_DELETE_WINDOW "
+ grab release $dialog
+ destroy $dialog
+ "
+ raise $dialog
+ update
+ focus -force $bottom_frame.button_ok
+ tkwait window $dialog
+ }
}
## Commit new ON/OFF state
@@ -544,13 +625,13 @@ class Graph {
# ON
if {$drawing_on} {
- $start_stop_button configure -style GreenBg.TButton -text "ON"
+ $start_stop_button configure -style GreenBg.TButton -text [mc "ON"]
$grid_button configure -state normal
$clear_marks_button configure -state normal
# OFF
} else {
- $start_stop_button configure -style RedBg.TButton -text "OFF"
+ $start_stop_button configure -style RedBg.TButton -text [mc "OFF"]
$zoom_in_button configure -state disabled
$zoom_out_button configure -state disabled
@@ -656,23 +737,17 @@ class Graph {
## Create GUI of all graphs
# @return void
private method create_all_graph_widgets {} {
- if {!$gui_initialized} {CreateGraphGUI}
+ if {!$graph_gui_initialized} {CreateGraphGUI}
- if {!$graph_state_created} {
- $graph_state CreateGraphGUI
- }
- if {!$graph_latches_created} {
- $graph_latches CreateGraphGUI
- }
- if {!$graph_output_created} {
- $graph_output CreateGraphGUI
- }
+ Graph_create_tab state
+ Graph_create_tab latches
+ Graph_create_tab output
}
## Get graph configuration values -- for project save
# @return List - Configuration list
public method graph_get_config {} {
- if {!$gui_initialized} {CreateGraphGUI}
+ if {!$graph_gui_initialized} {CreateGraphGUI}
create_all_graph_widgets
@@ -688,7 +763,7 @@ class Graph {
# @parm Int bits - Number of steps to take back
# @return void
public method graph_stepback {bits} {
- if {!$gui_initialized} {CreateGraphGUI}
+ if {!$graph_gui_initialized} {CreateGraphGUI}
if {!$drawing_on} {return}
create_all_graph_widgets
@@ -712,3 +787,7 @@ class Graph {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/bottompanel/graph_wdg.tcl b/lib/bottompanel/graph_wdg.tcl
index bcb2d62..a528bc5 100755..100644
--- a/lib/bottompanel/graph_wdg.tcl
+++ b/lib/bottompanel/graph_wdg.tcl
@@ -2,7 +2,7 @@
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2007-2008 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 _GRAPH_WDG_TCL ] } {
+set _GRAPH_WDG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Graph widget for showing port states
@@ -35,17 +40,20 @@ class GraphWidget {
# Big font (vertical header)
common big_font [font create \
-family $::DEFAULT_FIXED_FONT \
- -size -14 -weight bold \
+ -size -14 \
+ -weight bold \
]
# Small font (horizontal header)
common small_font [font create \
-family $::DEFAULT_FIXED_FONT \
- -size -14 -weight bold \
+ -size -14 \
+ -weight bold \
]
# Font for booleans values for each port
common bool_font [font create \
-family $::DEFAULT_FIXED_FONT \
- -size -12 -weight bold \
+ -size -12 \
+ -weight bold \
]
# Definition of graph popup menu
common GRAPHMENU {
@@ -53,7 +61,7 @@ class GraphWidget {
{} "Enable/Disable graph"}
{separator}
{command {Change grid} {} 1 "graph_switch_grid_mode 1"
- {} "Change grid morfology"}
+ {} "Change grid morphology"}
{separator}
{command {Zoom in} {} 1 "graph_zoom_in"
{viewmag_in} "Change bit length on X axis to a lower value"}
@@ -65,13 +73,13 @@ class GraphWidget {
}
# Variables related to object initialization
- private variable gui_initialized 0 ;# Bool: GUI created
+ private variable graph_w_gui_initialized 0 ;# Bool: GUI created
private variable _parent ;# Parent widget
private variable parent ;# Innert parent widget
private variable canvasWidget ;# ID of the canvas widget
private variable grid_mode {b} ;# Current grid mode (one of {b n x y})
- private variable drawing_on 1 ;# Bool: Graph enabled
+ private variable drawing_on 0 ;# Bool: Graph enabled
private variable magnification 0 ;# Magnification level (0..3)
private variable graph_elements ;# Array: IDs of graph elements (green and red lines)
private variable intr_lines {} ;# List of IDs of interrupt lines
@@ -100,12 +108,12 @@ class GraphWidget {
constructor {Parent super} {
set _parent $Parent
set Super $super
- set gui_initialized 0
+ set graph_w_gui_initialized 0
}
## Object destructor
destructor {
- if {$gui_initialized} {
+ if {$graph_w_gui_initialized} {
menu_Sbar_remove $menu
}
}
@@ -113,20 +121,20 @@ class GraphWidget {
## React to MCU change
# @return void
public method change_mcu {} {
- if {!$gui_initialized} {return}
+ if {!$graph_w_gui_initialized} {return}
foreach wdg [winfo children $_parent] {
destroy $wdg
}
- set gui_initialized 0
+ set graph_w_gui_initialized 0
CreateGraphGUI
}
## Initialize graph
# @return void
public method CreateGraphGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$graph_w_gui_initialized} {return}
+ set graph_w_gui_initialized 1
# Determinate number of ports and port indexes
set number_of_ports [$Super get_ports_info]
@@ -181,7 +189,7 @@ class GraphWidget {
# Create canvas popup menu
set menu $canvasWidget.menu
- menuFactory $GRAPHMENU $menu 0 "$Super " 0 {}
+ menuFactory $GRAPHMENU $menu 0 "$Super " 0 {} [namespace current]
# Set event bindings for the canvas widget
@@ -205,19 +213,19 @@ class GraphWidget {
}
## Draw interrupt line
- # @parm String = {} - If "nohistory" the history of interrupt lines will not be modified
+ # @parm String nh={} - If "nohistory" the history of interrupt lines will not be modified
# @return void
- public method graph_draw_interrupt_line args {
- if {!$gui_initialized} {CreateGraphGUI}
+ public method graph_draw_interrupt_line {{nh {}}} {
+ if {!$graph_w_gui_initialized} {CreateGraphGUI}
# Check if graph is enabled
if {!$drawing_on} {return}
# Adjust history
- if {$args != {nohistory}} {
+ if {$nh != {nohistory}} {
if {[llength $intr_history]} {
lset intr_history end 1
- } {
+ } else {
lappend intr_history 1
}
}
@@ -231,10 +239,10 @@ class GraphWidget {
}
# Adjust list of canvas elements related to this line
- if {$args != {nohistory}} {
+ if {$nh != {nohistory}} {
if {[llength $intr_lines]} {
lset intr_lines end $lines
- } {
+ } else {
lappend intr_lines $lines
}
}
@@ -251,7 +259,7 @@ class GraphWidget {
# @parm List - {# {P0_hex P1_hex P2_hex P3_hex P4_hex}}
# @return void
public method graph_new_output_state args {
- if {!$gui_initialized} {CreateGraphGUI}
+ if {!$graph_w_gui_initialized} {CreateGraphGUI}
# Check if graph is enabled
if {!$drawing_on} {return}
@@ -290,7 +298,7 @@ class GraphWidget {
if {[lindex $args 0] != {#}} {
lappend state_history [list {#} $args]
lappend intr_history 0
- } {
+ } else {
set args [lindex $args 1]
}
lappend intr_lines {}
@@ -359,6 +367,10 @@ class GraphWidget {
set txt {L}
set clr {#FF00AA}
}
+ default {
+ set txt {?}
+ set clr {#888888}
+ }
}
$canvasWidget create text $x $y \
@@ -385,7 +397,7 @@ class GraphWidget {
($idx / 8) * $port_length_in_px + ($pos * $step_x) + 20
}]
- # Determinate length of line elements acording to the current magnification level
+ # Determinate length of line elements according to the current magnification level
switch -- $magnification {
{0} {
set line_len 3
@@ -417,7 +429,7 @@ class GraphWidget {
if {$bool == {=}} {
set bool 0
set zero_color {#FF00AA}
- } {
+ } else {
set zero_color {#FF0000}
}
@@ -445,7 +457,7 @@ class GraphWidget {
$offset_x [expr {$offset_y + 0}] \
-fill $zero_color -tags graph]
}
- {-} { ;# From undeterminable state
+ {-} { ;# From indeterminable state
lappend lines [$canvasWidget create line \
$offset_x [expr {$offset_y + $half_edge}] \
$offset_x [expr {$offset_y + 0}] \
@@ -588,7 +600,7 @@ class GraphWidget {
[expr {$offset_x + 2*$line_len + $enge_inc0 + $enge_inc1}] $offset_y \
-fill {#FF8800} -tags graph]
- # "Undeterminable state" -> "Zero"
+ # "Indeterminable state" -> "Zero"
} elseif {$prev == {-} && $bool == 0} {
lappend lines [$canvasWidget create line \
$offset_x [expr {$offset_y + $half_edge}] \
@@ -596,7 +608,7 @@ class GraphWidget {
[expr {$offset_x + $step_x}] [expr {$offset_y + $full_edge}] \
-fill {#00FF00} -tags graph]
- # "Undeterminable state" -> "One"
+ # "Indeterminable state" -> "One"
} elseif {$prev == {-} && $bool == 1} {
lappend lines [$canvasWidget create line \
$offset_x [expr {$offset_y + $half_edge}] \
@@ -735,7 +747,7 @@ class GraphWidget {
set previous_state($idx) $bool
}
- ## Iterate over avaliable grid modes
+ ## Iterate over available grid modes
# @parm Int by - Iterate by
# @return void
public method graph_switch_grid_mode {_grid_mode} {
@@ -753,7 +765,7 @@ class GraphWidget {
adjust_grid
}
- ## Adjust grid morfology to the current grid mode
+ ## Adjust grid morphology to the current grid mode
# @return void
private method adjust_grid {} {
# Remove the current grid
@@ -796,7 +808,7 @@ class GraphWidget {
}
## Set graph configuration variables
- # @parm Char _grid_mode - Grid morfology (one of {'n' 'x' 'y' 'b'})
+ # @parm Char _grid_mode - Grid morphology (one of {'n' 'x' 'y' 'b'})
# @parm Int _magnification - Magnification mode (one of {0 1 2 3})
# @parm Bool _drawing_on - Widget enabled
# @parm List _mark_flags - List of mark flags (e.g {0 0 0 1 1 0})
@@ -811,10 +823,17 @@ class GraphWidget {
## Get mark flags
# @return String - String of boolean flags
public method graph_get_marks {} {
- return [join $mark_flags {}]
+ set result [::NumSystem::bin2hex [join $mark_flags {}]]
+ set len [string length $result]
+ if {$len < 43} {
+ set result "[string repeat {0} [expr {43 - $len}]]$result"
+ }
+
+ return "X$result"
}
## Adjust graph to the current magnification level
+ # @parm Int _magnification - Maginification level (0..3)
# @return void
public method commit_magnification {_magnification} {
set magnification $_magnification
@@ -864,7 +883,7 @@ class GraphWidget {
# @parm String - If "keephistory" then do not clear history
# @return void
public method clear_graph args {
- if {!$gui_initialized} {CreateGraphGUI}
+ if {!$graph_w_gui_initialized} {CreateGraphGUI}
catch {
$canvasWidget delete graph
@@ -898,7 +917,7 @@ class GraphWidget {
## Adjust object to the current value of flag 'drawing_on'
# @return void
public method commit_state_on_off {_drawing_on} {
- if {!$gui_initialized} {CreateGraphGUI}
+ if {!$graph_w_gui_initialized} {CreateGraphGUI}
set drawing_on $_drawing_on
# Enable widgets
@@ -1018,7 +1037,7 @@ class GraphWidget {
lset mark_flags $idx 1
# Remove mark
- } {
+ } else {
catch {
foreach elm [lindex $marks $idx] {
$canvasWidget delete $elm
@@ -1051,7 +1070,7 @@ class GraphWidget {
update
}
# Show scrollbar
- } {
+ } else {
if {![winfo ismapped $horizontal_scrollbar]} {
pack $horizontal_scrollbar -fill x -side top -before $scrollable_frame
}
@@ -1064,7 +1083,7 @@ class GraphWidget {
# @parm Int bits - Number of steps to take back
# @return void
public method graph_stepback {bits} {
- if {!$gui_initialized} {CreateGraphGUI}
+ if {!$graph_w_gui_initialized} {CreateGraphGUI}
if {!$drawing_on} {return}
# Remove elemets
@@ -1113,3 +1132,7 @@ class GraphWidget {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/bottompanel/messages.tcl b/lib/bottompanel/messages.tcl
index 51c96ce..e70c0a2 100755..100644
--- a/lib/bottompanel/messages.tcl
+++ b/lib/bottompanel/messages.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 _MESSAGES_TCL ] } {
+set _MESSAGES_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements messages text for the bottom panel of the project tab
@@ -32,14 +37,16 @@ class Messages {
common set_shortcuts {} ;# Currently set shortcut bindigs for messages text
common shortcuts_cat {messages} ;# Key shortcut categories related to messages text
# Normal font for messages text
- common messages_normal_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12]
+ common messages_normal_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ ]
# Bold font for messages text
- common messages_bold_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold]
+ common messages_bold_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ ]
# Definition of popup menu for messages text
common MESSAGESMENU {
{command {Select all} {Ctrl+A} 0 "select_all_messages_text"
@@ -64,13 +71,13 @@ class Messages {
# Variables related to object initialization
private variable parent ;# Widget: parent widget
- private variable gui_initialized 0 ;# Bool: GUI initialized
+ private variable msg_gui_initialized 0 ;# Bool: GUI initialized
# Variables related to search bar
private variable search_frame ;# Widget: Search bar frame
- private variable last_find_index {} ;# String: Index of last found occurence of the search string
- private variable search_string ;# String: Search string
- private variable search_string_length ;# Int: Length of the search string
+ private variable last_find_index {} ;# String: Index of last found occurrence of the search string
+ private variable search_string {} ;# String: Search string
+ private variable search_string_length 0 ;# Int: Length of the search string
private variable search_entry ;# Widget: Search bar entry box
private variable search_find_next ;# Widget: Button "Next"
private variable search_find_prev ;# Widget: Button "Prev"
@@ -90,20 +97,25 @@ class Messages {
# @return void
public method PrepareMessages {_parent} {
set parent $_parent
- set gui_initialized 0
+ set msg_gui_initialized 0
}
## Inform this tab than it has became active
# @return void
public method MessagesTabRaised {} {
+ $this bottomnotebook_pageconfigure {Messages} "-image ::ICONS::16::kcmsystem"
focus $messages_text
}
## Create GUI of messages tab
# @return void
public method CreateMessagesGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$msg_gui_initialized} {return}
+ set msg_gui_initialized 1
+
+ if {${::DEBUG}} {
+ puts "CreateMessagesGUI \[ENTER\]"
+ }
## Create GUI of main frame
set main_frame [frame $parent.main_frame]
@@ -180,7 +192,7 @@ class Messages {
-state disabled \
]
DynamicHelp::add $search_frame.find_next_but \
- -text [mc "Find next occurence of search string"]
+ -text [mc "Find next occurrence of search string"]
# Button: "Prev"
set search_find_prev [ttk::button $search_frame.find_prev_but \
-image ::ICONS::16::up0 \
@@ -189,7 +201,7 @@ class Messages {
-state disabled \
]
DynamicHelp::add $search_frame.find_prev_but \
- -text [mc "Find previous occurence of search string"]
+ -text [mc "Find previous occurrence of search string"]
# Button: "Close"
pack [ttk::button $search_frame.close_but \
-image ::ICONS::16::button_cancel \
@@ -216,7 +228,8 @@ class Messages {
-variable ::Todo::match_case \
-command "$this messages_text_perform_search 1 1.0" \
] -side left -padx 5
-
+ # Show the search bar frame
+ messages_text_find_dialog 0
messages_text_shortcuts_reevaluate
unset parent
@@ -225,18 +238,18 @@ class Messages {
## Select all text in messages text
# @return void
public method select_all_messages_text {} {
- if {!$gui_initialized} {CreateMessagesGUI}
+ if {!$msg_gui_initialized} {CreateMessagesGUI}
$messages_text tag add sel 1.0 end
}
## Copy selected text in messages text into clipboard
# @return void
public method copy_messages_text {} {
- if {!$gui_initialized} {CreateMessagesGUI}
+ if {!$msg_gui_initialized} {CreateMessagesGUI}
clipboard clear
if {[llength [$messages_text tag nextrange sel 1.0]]} {
clipboard append [$messages_text get sel.first sel.last]
- } {
+ } else {
clipboard append [$messages_text get 1.0 end]
}
}
@@ -244,7 +257,7 @@ class Messages {
## Create bindings for defined key shortcuts for messages text
# @return void
public method messages_text_shortcuts_reevaluate {} {
- if {!$gui_initialized} {CreateMessagesGUI}
+ if {!$msg_gui_initialized} {CreateMessagesGUI}
# Unset previous configuration
foreach key $set_shortcuts {
@@ -286,11 +299,11 @@ class Messages {
## Define popup menu for messages text
# @return void
public method messages_text_makePopupMenu {} {
- if {!$gui_initialized} {return}
+ if {!$msg_gui_initialized} {return}
if {[winfo exists $menu]} {
destroy $menu
}
- menuFactory $MESSAGESMENU $menu 0 "$this " 0 {}
+ menuFactory $MESSAGESMENU $menu 0 "$this " 0 {} [namespace current]
$menu entryconfigure [::mc "Find next"] -state disabled
$menu entryconfigure [::mc "Find previous"] -state disabled
}
@@ -308,14 +321,14 @@ class Messages {
## Clear all content of messages text
# @return void
public method clear_messages_text {} {
- if {!$gui_initialized} {CreateMessagesGUI}
+ if {!$msg_gui_initialized} {CreateMessagesGUI}
$messages_text configure -state normal
$messages_text delete 0.0 end
$messages_text configure -state disabled
}
- ## Goto line (in editor) which is somehow related to some tag in messages text
+ ## Go to line (in editor) which is somehow related to some tag in messages text
# @parm int x - relative x coordinate in messages text widget
# @parm int y - relative y coordinate in messages text widget
# @return void
@@ -323,7 +336,7 @@ class Messages {
# Determinate line number for editor
set idx [$messages_text index @$x,$y]
set line [$messages_text get "$idx linestart" "$idx lineend"]
- # Focus on editor and goto that line
+ # Focus on editor and go to that line
# Message from As31 assembler
if {[regexp {^(Error)|(Warning)\, line \d+} $line line]} {
@@ -331,16 +344,15 @@ class Messages {
set lineNum 0
}
- if {$lineNum} {
- $this editor_procedure {} focus_in {}
- $this editor_procedure {} goto $lineNum
+ if {!$lineNum} {
+ return
}
# Message from ASEM-51 assembler
} elseif {[regexp {^([^\(\)]+\(\d+(\,\d+)?\)\: \w+)} $line line]} {
if {![regexp {\(\d+(\,\d+)?\):} $line lineNum]} {
set lineNum 0
- } {
+ } else {
set lineNum [string range $lineNum 1 end-2]
set lineNum [lindex [split $lineNum {,}] 0]
}
@@ -353,9 +365,8 @@ class Messages {
}
}
}
- if {$lineNum} {
- $this editor_procedure {} focus_in {}
- $this editor_procedure {} goto "$lineNum"
+ if {!$lineNum} {
+ return
}
# GNU error message (from SDCC or ASL)
@@ -369,10 +380,7 @@ class Messages {
}
}
}
-
- set linenum [string trim $linenum {:}]
- $this editor_procedure {} focus_in {}
- $this editor_procedure {} goto $linenum
+ set lineNum [string trim $linenum {:}]
# Message from MCU8051IDE assembler
} elseif {[regexp {at \d+ in [^\:]+\:} $line line]} {
@@ -385,18 +393,23 @@ class Messages {
}
}
}
-
regexp {\d+} $line lineNum
- $this editor_procedure {} focus_in {}
- $this editor_procedure {} goto $lineNum
+
+ } else {
+ return
}
+
+ $this editor_procedure {} goto $lineNum
+ after idle "
+ $this editor_procedure {} focus_in {}
+ "
}
## Append text at the end of messages text
# @parm String txt - Text to append
- # @return Bool - True if error occured
+ # @return Bool - True if error occurred
public method messages_text_append {txt} {
- if {!$gui_initialized} {CreateMessagesGUI}
+ if {!$msg_gui_initialized} {CreateMessagesGUI}
# Enable the messages text widget
$messages_text configure -state normal
@@ -414,6 +427,8 @@ class Messages {
set warn 0
set suc 0
+ set spec 0
+
# Determinate number of the last line in the widget
set row [expr {int([$messages_text index end]) - 1}]
@@ -425,10 +440,29 @@ class Messages {
set err 1
# check for an error
- } elseif {[regexp {^(\|EN\|.*)|^(File access error:)|^(FAILED)|^(Compilation FAILED)|^(Pre-processing FAILED !)|^(Error:)|(^@@@@@ .+ @@@@@$)|(^.*returned errorcode.*)|^(Cannot open input file)|^(Cannot open file)|^(Errors in pass1, assembly aborted)|^(Errors in pass2, assembly aborted)} $text error]} {
+ } elseif {[regexp {^(\|EN\|.*)|^(File access error:)|^(FAILED)|^(Compilation FAILED)|^(Pre-processing FAILED !)|^(Error:)|(^@@@@@ .+ @@@@@$)|(^.*returned errorcode.*)|^(Cannot open input file)|^(Cannot open file)|^(Errors in pass1, assembly aborted)|^(Errors in pass2, assembly aborted)|(: command not found)|(cannot generate code for target 'mcs51')} $text error]} {
set len [string length $error]
set ern 1
+ if {[regexp {: command not found} $text error]} {
+ set spec 2
+ set len [string length $text]
+ } elseif {[regexp {cannot generate code for target 'mcs51'} $text error]} {
+ set spec 3
+ set len [string length $text]
+ }
+
+ # a special case of error; unable to find C debug file -- relevant only if user wants to start
+ #+ simulation right after compilation
+ } elseif {[regexp {^Unable to find \".*\"$} $text error]} {
+ set spec 1
+ set len [string length $error]
+ if {$::X::compilation_start_simulator} {
+ set ern 1
+ } else {
+ set warn 1
+ }
+
# check for warning which points to specific line in source code
} elseif {[regexp {^(\|WL\|.*)|^(Notice at \d+ in [^\:]+\:)|^(Warning at \d+ in [^\:]+\:)|^(.+:\d+: warning.*)|^(Warning\, line \d+)} $text warning]} {
set len [string length $warning]
@@ -453,9 +487,25 @@ class Messages {
regsub {^(\|[EWS][LN]\|)} $text {} text
# Insert specified text
- $messages_text insert end $text
+ $messages_text insert end [regsub -all "\a" [regsub -all {\\} [regsub -all {\\\\} $text "\a"] {}] {\\}]
$messages_text insert end "\n"
+ switch -- $spec {
+ 0 {}
+ 1 { ;# Unable to find "<some file>.cdb"
+ $messages_text insert end [mc " |\n"]
+ $messages_text insert end [mc " +-- Most probably that indicates that you have disabled debugging switch, if it is not that what you want then go to\n"]
+ $messages_text insert end [mc " \[Main Menu\] --> \[Configure\] --> \[Compiler configuration\] --> \[C language\] --> \[General\] and enable \"--debug\" compiler switch.\n"]
+ }
+ 2 { ;# /bin/sh: sdcc: command not found
+ $messages_text insert end [mc " |\n"]
+ $messages_text insert end [mc " +-- Most probably that indicates that you have not installed SDCC compiler\n"]
+ }
+ 3 { ;# cannot generate code for target 'mcs51'
+ $messages_text insert end [mc " |\n"]
+ $messages_text insert end [mc " +-- That means that your SDCC compiler does not support MCS-51 architecture, please install SDCC with support for 8051\n"]
+ }
+ }
# Insert appropriate text tags
if {$err || $ern || $war || $warn || $suc} {
@@ -482,6 +532,11 @@ class Messages {
$messages_text see end
$messages_text configure -state disabled
+ # Change tab icon if some warning or error was displayed there
+ if {$err || $ern || $warn || $war} {
+ $this bottomnotebook_pageconfigure {Messages} "-image ::ICONS::16::status_unknown"
+ }
+
return [expr {$err || $ern}]
}
@@ -494,14 +549,19 @@ class Messages {
}
## Show search bar
+ # @parm Bool do_focus_entrybox - Automatically focus the search EntryBox
# @return void
- public method messages_text_find_dialog {} {
+ public method messages_text_find_dialog {{do_focus 1}} {
if {![winfo ismapped $search_frame]} {
pack $search_frame -before $main_frame -side top -anchor w
$search_entry delete 0 end
- focus -force $search_entry
- } {
- focus -force $search_entry
+ if {$do_focus} {
+ focus -force $search_entry
+ }
+ } else {
+ if {$do_focus} {
+ focus -force $search_entry
+ }
}
}
@@ -532,12 +592,12 @@ class Messages {
if {$forw__back} {
set direction {-forwards}
- } {
+ } else {
set direction {-backwards}
}
if {${::Todo::match_case}} {
set last_find_index [$messages_text search $direction -- $search_string $from]
- } {
+ } else {
set last_find_index [$messages_text search $direction -nocase -- $search_string $from]
}
if {$last_find_index == {}} {
@@ -546,7 +606,7 @@ class Messages {
$search_find_prev configure -state disabled
$menu entryconfigure [::mc "Find next"] -state disabled
$menu entryconfigure [::mc "Find previous"] -state disabled
- } {
+ } else {
$search_entry configure -style StringFound.TEntry
$search_find_next configure -state normal
$search_find_prev configure -state normal
@@ -562,7 +622,7 @@ class Messages {
}
}
- ## Find next occurence of the search string
+ ## Find next occurrence of the search string
# @return void
public method messages_text_find_next {} {
if {![winfo ismapped $search_frame]} {
@@ -574,7 +634,7 @@ class Messages {
messages_text_perform_search 1 $last_find_index+${search_string_length}c
}
- ## Find previous occurence of the search string
+ ## Find previous occurrence of the search string
# @return void
public method messages_text_find_prev {} {
if {![winfo ismapped $search_frame]} {
@@ -630,3 +690,7 @@ class Messages {
$messages_text tag add hyper_link_over [lindex $range 0] [lindex $range 1]
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/bottompanel/terminal.tcl b/lib/bottompanel/terminal.tcl
index 6c373f8..894fd3b 100755..100644
--- a/lib/bottompanel/terminal.tcl
+++ b/lib/bottompanel/terminal.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 _TERMINAL_TCL ] } {
+set _TERMINAL_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides terminal emulator for bottom notebook
@@ -40,7 +45,7 @@ class Terminal {
private variable terminal_frame ;# Widget: ID of terminal container frame
private variable wrapper_frame ;# Widget: Wrapper frame for $terminal_frame
private variable parent ;# Widget: Parent frame
- private variable gui_initialized 0 ;# Bool: GUI initialized
+ private variable term_gui_initialized 0 ;# Bool: GUI initialized
private variable terminal_pid {} ;# Int: PID of terminal emulator
destructor {
@@ -52,7 +57,7 @@ class Terminal {
# @return void
public method PrepareTerminal {_parent} {
set parent $_parent
- set gui_initialized 0
+ set term_gui_initialized 0
}
## Inform this tab than it has became active
@@ -64,8 +69,8 @@ class Terminal {
## Create GUI
# @return void
public method CreateTerminalEmulGUI {} {
- if {$gui_initialized || !${::PROGRAM_AVALIABLE(urxvt)}} {return}
- set gui_initialized 1
+ if {$term_gui_initialized || !${::PROGRAM_AVAILABLE(urxvt)}} {return}
+ set term_gui_initialized 1
set wrapper_frame [frame $parent.wrapper_frame -relief sunken -bd 2]
pack $wrapper_frame -fill both -expand 1
@@ -83,7 +88,7 @@ class Terminal {
set pwd [pwd]
if {[catch {
cd [$this cget -projectPath]
- }]} {
+ }]} then {
cd ~
}
if {[catch {
@@ -93,13 +98,13 @@ class Terminal {
-fg ${configuration(fg)} \
-fn "xft:$configuration(font_family):pixelsize=$configuration(font_size)" & \
]
- } result]} {
+ } result]} then {
tk_messageBox \
-parent . \
-icon warning \
-type ok \
-title [mc "Unable to find urxvt"] \
- -message [mc "Unable to execute program \"urxvt\", terminal emulator is eiter not avaliable or badly configured."]
+ -message [mc "Unable to execute program \"urxvt\", terminal emulator is eiter not available or badly configured."]
puts stderr $result
}
cd $pwd
@@ -110,22 +115,32 @@ class Terminal {
## Restart terminal emulator
# @return void
public method terminal_restart {} {
- if {!$gui_initialized} {return}
- if {!${::PROGRAM_AVALIABLE(urxvt)}} {return}
- catch {
- exec kill $terminal_pid
+ if {!$term_gui_initialized} {return}
+ if {!${::PROGRAM_AVAILABLE(urxvt)}} {return}
+ foreach pid $terminal_pid {
+ if {$pid == [pid] || $pid == 0} {
+ continue
+ }
+ catch {
+ exec -- kill $pid
+ }
}
}
## Kill terminal emulator
# @return void
public method terminal_kill_childern {} {
- if {$gui_initialized} {
+ if {$term_gui_initialized} {
if {[info exists terminal_frame] && [winfo exists $terminal_frame]} {
bind $terminal_frame <Destroy> {}
}
- catch {
- exec kill $terminal_pid
+ foreach pid $terminal_pid {
+ if {$pid == [pid] || $pid == 0} {
+ continue
+ }
+ catch {
+ exec -- kill $pid
+ }
}
}
}
@@ -133,3 +148,7 @@ class Terminal {
# Initialize NS variables
array set ::Terminal::configuration ${::Terminal::configuration_def}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/bottompanel/todo.tcl b/lib/bottompanel/todo.tcl
index 6a7d8ff..21f79a5 100755..100644
--- a/lib/bottompanel/todo.tcl
+++ b/lib/bottompanel/todo.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 _TODO_TCL ] } {
+set _TODO_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides autonome GUI component intented for writing ToDo list
@@ -35,13 +40,15 @@ class Todo {
-family ${Editor::fontFamily} \
-size -${Editor::fontSize} \
]
- common normal_font [font create \
- -family {helvetica} \
- -size -12 -weight {normal} \
+ common normal_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight {normal} \
]
- common bold_font [font create \
- -family {helvetica} \
- -size -12 -weight {bold} \
+ common bold_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight {bold} \
]
# List of used text tags
common textTags {
@@ -64,7 +71,7 @@ class Todo {
# Definition of the popup menu
common TODOMENU {
{command {Undo} {Ctrl+Z} 0 "undo" {undo}
- "Undo last operaton"}
+ "Undo last operation"}
{command {Redo} {Ctrl+Shift+Z} 2 "redo" {redo}
"Take back last undo operation"}
{separator}
@@ -83,8 +90,8 @@ class Todo {
"Use bold font"}
{command {Italic text} {$todo:italic} 0 "italic" {text_italic}
"Use italic font"}
- {command {Striketrought text} {$todo:strike} 0 "strike" {text_strike}
- "Use striketrought font"}
+ {command {Strikethrough text} {$todo:strike} 0 "strike" {text_strike}
+ "Use strikethrough font"}
{command {Underline text} {$todo:under} 1 "under" {text_under}
"Use underline font"}
{separator}
@@ -96,7 +103,7 @@ class Todo {
# Variables related to object initialization
private variable input_text ;# String: initial content of the text widget
- private variable gui_initialized 0 ;# Bool: GUI created
+ private variable todo_gui_initialized 0 ;# Bool: GUI created
# Other variables
private variable main_frame ;# ID of main frame (text_widget; scrollbar; button_frame)
@@ -106,7 +113,7 @@ class Todo {
private variable parent_container ;# ID of parent contaner (some frame)
private variable button_bold ;# ID of button "Bold"
private variable button_italic ;# ID of button "Italic"
- private variable button_strike ;# ID of button "Striketrought"
+ private variable button_strike ;# ID of button "Strikethrough"
private variable button_under ;# ID of button "Underline"
private variable active_tags {} ;# Currently active tags
private variable menu {} ;# ID of popup menu
@@ -135,9 +142,9 @@ class Todo {
# Variables related to search bar
private variable search_frame ;# Widget: Search bar frame
- private variable last_find_index ;# String: Index of last found occurence of the search string
- private variable search_string ;# String: Search string
- private variable search_string_length ;# Int: Length of the search string
+ private variable last_find_index {} ;# String: Index of last found occurrence of the search string
+ private variable search_string {} ;# String: Search string
+ private variable search_string_length 0 ;# Int: Length of the search string
private variable search_entry ;# Widget: Search bar entry box
private variable search_find_next ;# Widget: Button "Next"
private variable search_find_prev ;# Widget: Button "Prev"
@@ -151,7 +158,7 @@ class Todo {
-relief flat
ttk::style map Todo_Active.TButton \
-relief [list active raised] \
- -background [list disabled {#EEEEEE} active $buttonActiveBg]
+ -background [list disabled ${::COMMON_BG_COLOR} active $buttonActiveBg]
ttk::style configure Todo_SemiAct.TButton \
-background $buttonSemiActBg \
@@ -159,7 +166,7 @@ class Todo {
-relief flat
ttk::style map Todo_SemiAct.TButton \
-relief [list active raised] \
- -background [list disabled {#EEEEEE} active $buttonSemiActBg]
+ -background [list disabled ${::COMMON_BG_COLOR} active $buttonSemiActBg]
}
## Object destructor
@@ -175,25 +182,25 @@ class Todo {
public method get_file_notes_config {} {
if {$panel_size < $panel_size_last} {
set panel_size_max $panel_size_last
- } {
+ } else {
set panel_size_max $panel_size
}
return [list $notes_visible $panel_size_max]
}
## Get contents of file specific notepad
- # @parm Int = <current> - Index in $LIST_file_notes
+ # @parm Int idx=<current> - Index in $LIST_file_notes
# @return void
- public method get_file_notes_data args {
+ public method get_file_notes_data {{idx {}}} {
CreateTodoGUI
- if {$args == {}} {
+ if {$idx == {}} {
return [$file_notes get 1.0 {end-1l lineend}]
- } {
- set w [lindex $LIST_file_notes $args]
+ } else {
+ set w [lindex $LIST_file_notes $idx]
if {$w == {}} {
return {}
- } {
+ } else {
return [$w get 1.0 {end-1l lineend}]
}
}
@@ -216,7 +223,7 @@ class Todo {
public method PrepareTodo {parentContainer _input_text} {
set parent_container $parentContainer
set input_text $_input_text
- set gui_initialized 0
+ set todo_gui_initialized 0
}
## Inform this tab than it has became active
@@ -279,7 +286,7 @@ class Todo {
## Redraw panel (move pane sash) acorning to current value of $PanelSize
# @return void
public method todo_panel_redraw_pane {} {
- if {!$gui_initialized} {return}
+ if {!$todo_gui_initialized} {return}
if {$redraw_pane_in_progress} {
after 50 "$this todo_panel_redraw_pane"
@@ -294,7 +301,7 @@ class Todo {
set redraw_pane_in_progress 0
}
- ## Set panel width acording to current sash position
+ ## Set panel width according to current sash position
# @return void
public method todo_panel_set_size {} {
set panel_size [lindex [$paned_win sash coord 0] 0]
@@ -316,7 +323,7 @@ class Todo {
set panel_size $panel_size_last
# Hide
- } {
+ } else {
pack forget $file_notes_pagesManager
pack $notes_invisible_frm -fill y -anchor nw
$paned_win paneconfigure $right_pane -minsize 20
@@ -382,11 +389,15 @@ class Todo {
return [$file_notes get 0.0 end]
}
- ## Initialize todo text
+ ## Initialize to do text
# @return void
public method CreateTodoGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$todo_gui_initialized} {return}
+ set todo_gui_initialized 1
+
+ if {${::DEBUG}} {
+ puts "CreateTodoGUI \[ENTER\]"
+ }
set paned_win [panedwindow $parent_container.paned_win \
-sashwidth 4 -showhandle 0 -opaqueresize 1 -orient horizontal \
@@ -407,7 +418,7 @@ class Todo {
# RIGHT PART
#
- set file_notes_pagesManager [PagesManager $right_pane.pmgr -background {#eeeeee}]
+ set file_notes_pagesManager [PagesManager $right_pane.pmgr -background ${::COMMON_BG_COLOR}]
$file_notes_pagesManager compute_size
set notes_invisible_frm [frame $right_pane.notes_invisible_frm]
@@ -460,7 +471,7 @@ class Todo {
-style Flat.TButton \
]
DynamicHelp::add $search_frame.find_next_but \
- -text [mc "Find next occurence of search string"]
+ -text [mc "Find next occurrence of search string"]
# Button: "Prev"
set search_find_prev [ttk::button $search_frame.find_prev_but \
-image ::ICONS::16::up0 \
@@ -469,7 +480,7 @@ class Todo {
-style Flat.TButton \
]
DynamicHelp::add $search_frame.find_prev_but \
- -text [mc "Find previous occurence of search string"]
+ -text [mc "Find previous occurrence of search string"]
# Button: "Close"
pack [ttk::button $search_frame.close_but \
-image ::ICONS::16::button_cancel \
@@ -500,6 +511,9 @@ class Todo {
# Pack main frame
pack $main_frame -fill both -expand 1
+ # Show the search bar frame
+ TodoProc_find_dialog 0
+
# Adjust text widget parameters
TodoProc_write_text_from_sgml $input_text
unset input_text
@@ -517,11 +531,12 @@ class Todo {
<Key-Down> <Key-Up>
<Key-Right> <Key-Left>
<Key-Next> <Key-Prior>
- } {
- bind $text_widget $key "
- [bind Text $key]
- $this recalc_left_panel insert
- break"
+ } \
+ {
+ bind $text_widget $key "
+ [bind Text $key]
+ $this recalc_left_panel insert
+ break"
}
bind $text_widget <KeyRelease> "break"
bind $text_widget <KeyPress> "$this TodoProc_Key %A; break"
@@ -540,7 +555,7 @@ class Todo {
]
DynamicHelp::add $button_bold -text [mc "Bold font"]
setStatusTip -widget $button_bold \
- -text {Use bold font}
+ -text [mc "Use bold font"]
# Button "Italic"
set button_italic [ttk::button $button_frame.todo_text_bI \
-image ::ICONS::16::text_italic \
@@ -550,16 +565,16 @@ class Todo {
DynamicHelp::add $button_italic \
-text [mc "Italic text"]
setStatusTip -widget $button_italic \
- -text {Use italic font}
- # Button "Striketrought"
+ -text [mc "Use italic font"]
+ # Button "Strikethrough"
set button_strike [ttk::button $button_frame.todo_text_bS \
-image ::ICONS::16::text_strike \
-command "$this TodoProc_strike" \
-style Flat.TButton \
]
DynamicHelp::add $button_strike \
- -text [mc "Striketrought font"]
- setStatusTip -widget $button_strike -text {Use striketrought font}
+ -text [mc "Strikethrough font"]
+ setStatusTip -widget $button_strike -text [mc "Use strikethrough font"]
# Button "Underline"
set button_under [ttk::button $button_frame.todo_text_bU \
-image ::ICONS::16::text_under \
@@ -569,11 +584,11 @@ class Todo {
DynamicHelp::add $button_under \
-text [mc "Underline font"]
setStatusTip -widget $button_under \
- -text {Use underline font}
+ -text [mc "Use underline font"]
# pack these buttons
foreach wdg $tagButtons {
- pack [subst "\$$wdg"]
+ pack [subst -nocommands "\$$wdg"]
}
# Button "Eraser"
pack [ttk::button $button_frame.todo_text_bE \
@@ -584,7 +599,7 @@ class Todo {
DynamicHelp::add $button_frame.todo_text_bE \
-text [mc "Erase text tags"]
setStatusTip -widget $button_frame.todo_text_bE \
- -text {Remove formating tags within selected area}
+ -text [mc "Remove formatting tags within selected area"]
# Button "Bookmark"
pack [ttk::button $button_frame.todo_text_bBm \
-image ::ICONS::16::$bookmarkImage \
@@ -609,7 +624,7 @@ class Todo {
## Recreate all text tags and font font for the text widget
# @return void
public method todo_refresh_font_settings {} {
- if {!$gui_initialized} {CreateTodoGUI}
+ if {!$todo_gui_initialized} {CreateTodoGUI}
$text_widget configure -font [font create \
-family ${Editor::fontFamily} \
-size -${Editor::fontSize} \
@@ -620,7 +635,7 @@ class Todo {
## Create bindings for defined key shortcuts
# @return void
public method TodoProc_shortcuts_reevaluate {} {
- if {!$gui_initialized} {CreateTodoGUI}
+ if {!$todo_gui_initialized} {CreateTodoGUI}
# Unset previous configuration
foreach key $set_shortcuts {
@@ -662,16 +677,16 @@ class Todo {
## Create popup menu
# @return void
public method TodoProc_makePopupMenu {} {
- if {!$gui_initialized} {return}
+ if {!$todo_gui_initialized} {return}
if {[winfo exists $menu]} {
destroy $menu
}
- menuFactory $TODOMENU $menu 0 "$this TodoProc_" 0 {}
+ menuFactory $TODOMENU $menu 0 "$this TodoProc_" 0 {} [namespace current]
$menu entryconfigure [::mc "Find next"] -state disabled
$menu entryconfigure [::mc "Find previous"] -state disabled
}
- ## Create text tags in todo text widget
+ ## Create text tags in to do text widget
# @return void
private method todo_create_tags {} {
# Tag "Bold"
@@ -713,7 +728,7 @@ class Todo {
[expr {[winfo rooty $text_widget] + [lindex $bbox 1] + 10}]
}
- ## Enable/Disable popup menu items acording to state of the text widget
+ ## Enable/Disable popup menu items according to state of the text widget
# Auxiliary procedure for 'TodoProc_popupMenu' and 'TodoProc_Key_Menu'
# @return void
private method popup_menu_disena {} {
@@ -723,7 +738,7 @@ class Todo {
$menu entryconfigure [::mc "Cut"] -state normal
}
$menu entryconfigure [::mc "Copy"] -state normal
- } {
+ } else {
$menu entryconfigure [::mc "Cut"] -state disabled
$menu entryconfigure [::mc "Copy"] -state disabled
}
@@ -732,11 +747,11 @@ class Todo {
}
}
- ## Write text to the text widget from SGML formated data
+ ## Write text to the text widget from SGML formatted data
# @parm String inputData - SGML data
# @return void
public method TodoProc_write_text_from_sgml {inputData} {
- if {!$gui_initialized} {CreateTodoGUI}
+ if {!$todo_gui_initialized} {CreateTodoGUI}
# Replace all \r\n shit with LF
regsub -all {(\r)|(\r\n)} $inputData "\n" inputData
@@ -752,8 +767,6 @@ class Todo {
regsub -all {&gt;} $inputData { } inputData
## Parse pair tags
- set lastStartIdx 0
- set lastEndIdx 0
foreach xmltag $xmlTags texttag $textTags {
# modify input data for later processing
@@ -768,7 +781,7 @@ class Todo {
# Translate XML tags to Tk's native text tags
set StartRow 1
set EndCol 0
- while 1 {
+ while {1} {
set SRow 0
set ERow 0
set tagLength [string length "<$xmltag>"]
@@ -778,7 +791,7 @@ class Todo {
set LFidx 0
set LastLFidx $LFidx
- while 1 {
+ while {1} {
set LFidx [string first "\n" $data $LFidx]
if {($LFidx >= $startIdx) || ($LFidx == -1)} {
set correction 0
@@ -789,7 +802,7 @@ class Todo {
set StartCol [expr {$startIdx - $LastLFidx - 1 + $correction}]
set StartRow [expr {$StartRow + $SRow}]
break
- } {
+ } else {
set LastLFidx $LFidx
incr SRow
incr LFidx
@@ -803,7 +816,7 @@ class Todo {
set LFidx 0
set LastLFidx $LFidx
- while 1 {
+ while {1} {
set LFidx [string first "\n" $data $LFidx]
if {($LFidx >= $endIdx) || ($LFidx == -1)} {
set correction 0
@@ -811,7 +824,7 @@ class Todo {
set EndCol [expr {$endIdx - $LastLFidx - $ERow + $correction}]
set EndRow [expr {$EndRow + $ERow}]
break
- } {
+ } else {
set LastLFidx $LFidx
incr ERow
incr LFidx
@@ -835,7 +848,7 @@ class Todo {
foreach tag $selfCtags {
set Row 1
set Col 0
- while 1 {
+ while {1} {
set tagIdx [string first "<$tag" $data]
set tagEndIdx [string first "/>" $data]
if {($tagEndIdx < $tagIdx) || ($tagIdx == -1)} {break}
@@ -845,7 +858,7 @@ class Todo {
set LFidx 0
set LastLFidx $LFidx
- while 1 {
+ while {1} {
set LFidx [string first "\n" $data $LFidx]
if {$LFidx >= $tagIdx} {
@@ -854,7 +867,7 @@ class Todo {
set Col [expr {$tagIdx - $LastLFidx - 1 + $correction}]
set Row [expr {$Row + $rowTmp}]
break
- } {
+ } else {
set LastLFidx $LFidx
incr rowTmp
incr LFidx
@@ -873,10 +886,10 @@ class Todo {
}
}
- ## Return content of text widget formated as SGML
+ ## Return content of text widget formatted as SGML
# @return String - SGML code
public method TodoProc_read_text_as_sgml {} {
- if {!$gui_initialized} {return $input_text}
+ if {!$todo_gui_initialized} {return $input_text}
# Determinate end index
set textEnd [$text_widget index end]
@@ -899,12 +912,12 @@ class Todo {
set i 0
set index {}
- while 1 {
+ while {1} {
set index [lindex $ranges $i]
if {$index == {}} {break}
- lappend tagList "$index $xmltag"
+ lappend tagList [list $index $xmltag]
incr i
- lappend tagList "[lindex $ranges $i] /$xmltag"
+ lappend tagList [list [lindex $ranges $i] "/$xmltag"]
incr i
}
}
@@ -936,12 +949,12 @@ class Todo {
incr col $colCorrection
set imageIdx "$row.$col"
- } {
+ } else {
set lastRow $row
set colCorrection 0
}
- lappend tagList "$imageIdx bookmark/"
+ lappend tagList [list $imageIdx {bookmark/}]
}
# Special reverse sorting of tag list
@@ -963,7 +976,7 @@ class Todo {
incr index
set char [string index $data $index]
set data [string replace $data $index $index "<$tag>$char"]
- } {
+ } else {
set char [string index $data $index]
set data [string replace $data $index $index "$char<$tag>"]
}
@@ -991,7 +1004,7 @@ class Todo {
if {$reverse} {
set A -1
set B 1
- } {
+ } else {
set A 1
set B -1
}
@@ -1010,7 +1023,7 @@ class Todo {
return $A
} elseif {$FC == $EC} {
return 0
- } {
+ } else {
return $B
}
} else {
@@ -1021,7 +1034,7 @@ class Todo {
## Get content of text widget as plain text
# @return String - result
public method read_plain_text {} {
- if {!$gui_initialized} {CreateTodoGUI}
+ if {!$todo_gui_initialized} {CreateTodoGUI}
return [$text_widget get 1.0]
}
@@ -1029,48 +1042,49 @@ class Todo {
# @return void
public method TodoProc_bold {} {
addRemoveTag tag_bold $button_bold
+ after idle [list focus $text_widget]
}
## Switch to italic font
# @return void
public method TodoProc_italic {} {
addRemoveTag tag_italic $button_italic
+ after idle [list focus $text_widget]
}
- ## Switch to striketrought font
+ ## Switch to strikethrough font
# @return void
public method TodoProc_strike {} {
addRemoveTag tag_overstrike $button_strike
+ after idle [list focus $text_widget]
}
## Switch to underline font
# @return void
public method TodoProc_under {} {
addRemoveTag tag_underline $button_under
+ after idle [list focus $text_widget]
}
## Erase tags
- # @parm List idxs = {} - Indexes of selected area
- # @parm Bool reset = 1 - Reset font settings on left panel
+ # @parm List idxs={} - Indexes of selected area
+ # @parm Bool reset=1 - Reset font settings on left panel
# @return Bool - result
- public method TodoProc_eraser args {
- if {$args == {}} {
+ public method TodoProc_eraser {{idxs {}} {reset 1}} {
+ if {$idxs == {}} {
set idxs [getSelectionIdx]
- set reset 1
- set active_tags {}
- } {
- set idxs [lindex $args 0]
- set reset [lindex $args 1]
}
if {$idxs == {}} {
- set active_tags {}
reset_left_panel
return 0
}
foreach tag $textTags {
$text_widget tag remove $tag [lindex $idxs 0] [lindex $idxs 1]
}
- if {$reset} {reset_left_panel}
+ if {$reset} {
+ reset_left_panel
+ set active_tags [list]
+ }
return 1
}
@@ -1125,7 +1139,7 @@ class Todo {
public method TodoProc_paste {} {
if {[catch {
set data [clipboard get]
- }]} {
+ }]} then {
return
}
catch {$text_widget delete sel.first sel.last}
@@ -1135,7 +1149,7 @@ class Todo {
## Clear all text
# @return void
public method TodoProc_clear {} {
- if {!$gui_initialized} {CreateTodoGUI}
+ if {!$todo_gui_initialized} {CreateTodoGUI}
catch {$text_widget delete 1.0 end}
}
@@ -1247,7 +1261,7 @@ class Todo {
return 1
}
- ## Set background color for button related to given text tag acording to given state
+ ## Set background color for button related to given text tag according to given state
# @parm String tag - name of text tag
# @parm Int state - state number (0 == passive; 1 == active; 2 == semi-active)
# @return void
@@ -1305,12 +1319,12 @@ class Todo {
foreach button $tagButtons {
# Determinate ID of button widget
- set buttonWdg [subst "\$$button"]
+ set buttonWdg [subst -nocommands "\$$button"]
# Determinate state number and set Bg
if {[lsearch $affected $button] != -1} {
setButtonBg $buttonWdg 1
- } {
+ } else {
setButtonBg $buttonWdg 0
}
}
@@ -1320,11 +1334,11 @@ class Todo {
# @return void
private method reset_left_panel {} {
foreach button $tagButtons {
- setButtonBg [subst "\$$button"] 0
+ setButtonBg [subst -nocommands "\$$button"] 0
}
}
- ## Set background color for given button acording to given state
+ ## Set background color for given button according to given state
# @parm Widget button - ID of button to modify
# @parm Int state - state number (0 == passive; 1 == active; 2 == semi-active)
# @return void
@@ -1352,13 +1366,20 @@ class Todo {
lappend active_tags $tagName
# Tag is active -> remove the tag
- } {
+ } else {
setButtonBg $buttonName 0
set active_tags [lreplace $active_tags $tagIdx $tagIdx]
}
- # Modify selected area
+ ## Modify the selected area
set idxs [getSelectionIdx]
+ # There is no selected area
+ if {$idxs == {}} {
+ set char_before_cursor [$text_widget get insert-1c insert]
+ if {$char_before_cursor == { } || $char_before_cursor == "\t" || $char_before_cursor == "\xC2"} {
+ set idxs [list [$text_widget index insert-1c] [$text_widget index insert]]
+ }
+ }
if {$idxs != {}} {
TodoProc_eraser $idxs 0
foreach tag $active_tags {
@@ -1369,7 +1390,7 @@ class Todo {
## Set given text tag for area determinated by given indexes
# @parm String tagName - name of text tag to set
- # @parm List idxs = {} - target area {first_idx last_idx}
+ # @parm List idxs - target area {first_idx last_idx}
# @return Bool - result
private method setTagAtSel {tagName idxs} {
if {$idxs == {}} {return 0}
@@ -1381,14 +1402,16 @@ class Todo {
# @return List - text indexes '{first last}' or '{}'
private method getSelectionIdx {} {
# Try to determinate indexes
+ set start {}
+ set end {}
catch {
- set start [$text_widget index sel.first]
- set end [$text_widget index sel.last]
+ set start [$text_widget index sel.first]
+ set end [$text_widget index sel.last]
}
# Return result
- if {[info exists start]} {
- return "$start $end"
- } {
+ if {$start != {} && $end != {}} {
+ return [list $start $end]
+ } else {
return {}
}
}
@@ -1402,14 +1425,19 @@ class Todo {
}
## Show search bar
+ # @parm Bool do_focus_entrybox - Automatically focus the search EntryBox
# @return void
- public method TodoProc_find_dialog {} {
+ public method TodoProc_find_dialog {{do_focus 1}} {
if {![winfo ismapped $search_frame]} {
pack $search_frame -before $main_frame -side top -anchor w
$search_entry delete 0 end
- focus -force $search_entry
- } {
- focus -force $search_entry
+ if {$do_focus} {
+ focus -force $search_entry
+ }
+ } else {
+ if {$do_focus} {
+ focus -force $search_entry
+ }
}
}
@@ -1440,12 +1468,12 @@ class Todo {
if {$forw__back} {
set direction {-forwards}
- } {
+ } else {
set direction {-backwards}
}
if {${::Todo::match_case}} {
set last_find_index [$text_widget search $direction -- $search_string $from]
- } {
+ } else {
set last_find_index [$text_widget search $direction -nocase -- $search_string $from]
}
if {$last_find_index == {}} {
@@ -1454,7 +1482,7 @@ class Todo {
$search_find_prev configure -state disabled
$menu entryconfigure [::mc "Find next"] -state disabled
$menu entryconfigure [::mc "Find previous"] -state disabled
- } {
+ } else {
$search_entry configure -style StringFound.TEntry
$search_find_next configure -state normal
$search_find_prev configure -state normal
@@ -1470,7 +1498,7 @@ class Todo {
}
}
- ## Find next occurence of the search string
+ ## Find next occurrence of the search string
# @return void
public method TodoProc_find_next {} {
if {![winfo ismapped $search_frame]} {
@@ -1482,7 +1510,7 @@ class Todo {
TodoProc_perform_search 1 $last_find_index+${search_string_length}c
}
- ## Find previous occurence of the search string
+ ## Find previous occurrence of the search string
# @return void
public method TodoProc_find_prev {} {
if {![winfo ismapped $search_frame]} {
@@ -1494,3 +1522,7 @@ class Todo {
TodoProc_perform_search 0 $last_find_index
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard