summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--[-rwxr-xr-x]lib/X.tcl3079
-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
-rw-r--r--[-rwxr-xr-x]lib/cli.tcl203
-rw-r--r--[-rwxr-xr-x]lib/compiler/assembler.tcl71
-rw-r--r--[-rwxr-xr-x]lib/compiler/codelisting.tcl210
-rw-r--r--[-rwxr-xr-x]lib/compiler/compiler.tcl248
-rw-r--r--[-rwxr-xr-x]lib/compiler/compilerconsts.tcl44
-rw-r--r--[-rwxr-xr-x]lib/compiler/disassembler.tcl149
-rw-r--r--[-rwxr-xr-x]lib/compiler/external_compiler.tcl220
-rw-r--r--[-rwxr-xr-x]lib/compiler/preprocessor.tcl1564
-rwxr-xr-xlib/configdialogs/global_config.tcl318
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/compiler_config.tcl (renamed from lib/configdialogs/compiler_config.tcl)885
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/configdialogues.tcl (renamed from lib/configdialogs/configdialogs.tcl)35
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/custom_commands_config.tcl (renamed from lib/configdialogs/custom_commands_config.tcl)172
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/editor_config.tcl (renamed from lib/configdialogs/editor_config.tcl)1016
-rw-r--r--lib/configdialogues/global_config.tcl535
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/rightpanel_config.tcl (renamed from lib/configdialogs/rightpanel_config.tcl)105
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/shortcuts_config.tcl (renamed from lib/configdialogs/shortcuts_config.tcl)128
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/simulator_config.tcl (renamed from lib/configdialogs/simulator_config.tcl)222
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/terminal_config.tcl (renamed from lib/configdialogs/terminal_config.tcl)74
-rw-r--r--[-rwxr-xr-x]lib/configdialogues/toolbar_config.tcl (renamed from lib/configdialogs/toolbar_config.tcl)146
-rw-r--r--[-rwxr-xr-x]lib/custom_command.tcl48
-rw-r--r--[-rwxr-xr-x]lib/dialogues/errorhandler.tcl (renamed from lib/dialogs/errorhandler.tcl)77
-rw-r--r--[-rwxr-xr-x]lib/dialogues/fsd.tcl (renamed from lib/dialogs/fsd.tcl)558
-rw-r--r--[-rwxr-xr-x]lib/dialogues/my_tk_messageBox.tcl (renamed from lib/dialogs/my_tk_messageBox.tcl)36
-rw-r--r--[-rwxr-xr-x]lib/dialogues/selectmcu.tcl (renamed from lib/dialogs/selectmcu.tcl)305
-rw-r--r--[-rwxr-xr-x]lib/dialogues/tips.tcl (renamed from lib/dialogs/tips.tcl)149
-rw-r--r--[-rwxr-xr-x]lib/editor/ASMsyntaxhighlight.tcl302
-rw-r--r--[-rwxr-xr-x]lib/editor/Csyntaxhighlight.tcl145
-rw-r--r--[-rwxr-xr-x]lib/editor/LSTsyntaxhighlight.tcl87
-rw-r--r--[-rwxr-xr-x]lib/editor/R_ASMsyntaxhighlight.tcl157
-rw-r--r--[-rwxr-xr-x]lib/editor/autocompletion.tcl135
-rw-r--r--[-rwxr-xr-x]lib/editor/commandline.tcl119
-rw-r--r--[-rwxr-xr-x]lib/editor/editor.tcl652
-rw-r--r--[-rwxr-xr-x]lib/editor/eventhandlers.tcl166
-rw-r--r--[-rwxr-xr-x]lib/editor/exports.tcl159
-rw-r--r--[-rwxr-xr-x]lib/editor/generalproc.tcl539
-rw-r--r--lib/editor/spell_check.tcl1325
-rw-r--r--[-rwxr-xr-x]lib/environment.tcl941
-rw-r--r--[-rwxr-xr-x]lib/external_command.tcl60
-rw-r--r--[-rwxr-xr-x]lib/leftpanel/filelist.tcl842
-rw-r--r--[-rwxr-xr-x]lib/leftpanel/fsbrowser.tcl158
-rw-r--r--[-rwxr-xr-x]lib/leftpanel/sfrwatches.tcl89
-rw-r--r--lib/lib/FSnotifications.tcl340
-rw-r--r--[-rwxr-xr-x]lib/lib/Math.tcl49
-rw-r--r--[-rwxr-xr-x]lib/lib/hexeditor.tcl311
-rw-r--r--[-rwxr-xr-x]lib/lib/ihextools.tcl38
-rw-r--r--[-rwxr-xr-x]lib/lib/innerwindow.tcl54
-rw-r--r--lib/lib/modern_notebook.tcl691
-rw-r--r--[-rwxr-xr-x]lib/lib/settings.tcl35
-rw-r--r--lib/list_of_files.txt136
-rwxr-xr-xlib/main.tcl390
-rw-r--r--[-rwxr-xr-x]lib/maintab.tcl120
-rw-r--r--lib/pale/ds1620.tcl1730
-rw-r--r--lib/pale/file_interface.tcl983
-rw-r--r--lib/pale/hd44780_cgrom.tcl1624
-rw-r--r--lib/pale/lcd_hd44780.tcl2954
-rw-r--r--[-rwxr-xr-x]lib/pale/leddisplay.tcl133
-rw-r--r--[-rwxr-xr-x]lib/pale/ledmatrix.tcl132
-rw-r--r--[-rwxr-xr-x]lib/pale/ledpanel.tcl97
-rw-r--r--[-rwxr-xr-x]lib/pale/matrixkeypad.tcl110
-rw-r--r--[-rwxr-xr-x]lib/pale/multiplexedleddisplay.tcl142
-rw-r--r--[-rwxr-xr-x]lib/pale/pale.tcl185
-rw-r--r--[-rwxr-xr-x]lib/pale/simplekeypad.tcl108
-rw-r--r--[-rwxr-xr-x]lib/pale/virtual_hw_component.tcl142
-rw-r--r--lib/pale/virtual_uart_term.tcl1682
-rw-r--r--[-rwxr-xr-x]lib/project.tcl137
-rw-r--r--lib/receive_and_print.tcl102
-rw-r--r--[-rwxr-xr-x]lib/rightpanel/hwmanager.tcl340
-rw-r--r--[-rwxr-xr-x]lib/rightpanel/instructiondetails.tcl98
-rw-r--r--[-rwxr-xr-x]lib/rightpanel/regwatches.tcl273
-rw-r--r--[-rwxr-xr-x]lib/rightpanel/rightpanel.tcl262
-rw-r--r--[-rwxr-xr-x]lib/rightpanel/subprograms.tcl107
-rw-r--r--[-rwxr-xr-x]lib/simulator/bitmap.tcl45
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_auxiliary_alo_functions.tcl23
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_backward_stepping.tcl13
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_control.tcl174
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_core.tcl31
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_external_interface_management.tcl162
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_hibernation.tcl39
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_initialization_cleanup.tcl57
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_instructions.tcl184
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_mcu_configuration.tcl107
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_memory_management.tcl85
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_opcodes.tcl11
-rw-r--r--lib/simulator/engine/engine_text_based_interface.tcl1087
-rw-r--r--[-rwxr-xr-x]lib/simulator/engine/engine_virtual_hw_controller.tcl143
-rw-r--r--[-rwxr-xr-x]lib/simulator/hibernate.tcl107
-rw-r--r--[-rwxr-xr-x]lib/simulator/interruptmonitor.tcl154
-rw-r--r--[-rwxr-xr-x]lib/simulator/sfrmap.tcl83
-rw-r--r--[-rwxr-xr-x]lib/simulator/simulator.tcl165
-rw-r--r--[-rwxr-xr-x]lib/simulator/simulator_gui.tcl470
-rw-r--r--[-rwxr-xr-x]lib/simulator/stackmonitor.tcl65
-rw-r--r--[-rwxr-xr-x]lib/simulator/stopwatch.tcl118
-rw-r--r--lib/simulator/uart_monitor.tcl886
-rwxr-xr-xlib/simulator/virtual_uart_term.tcl646
-rw-r--r--[-rwxr-xr-x]lib/utilities/asciichart.tcl89
-rw-r--r--[-rwxr-xr-x]lib/utilities/baseconverter.tcl (renamed from lib/utilities/baseconvertor.tcl)132
-rw-r--r--[-rwxr-xr-x]lib/utilities/eightsegment.tcl64
-rw-r--r--[-rwxr-xr-x]lib/utilities/hexeditdlg.tcl257
-rw-r--r--[-rwxr-xr-x]lib/utilities/notes.tcl51
-rw-r--r--[-rwxr-xr-x]lib/utilities/rs232debugger.tcl166
-rw-r--r--[-rwxr-xr-x]lib/utilities/speccalc.tcl611
-rw-r--r--[-rwxr-xr-x]lib/utilities/symbol_viewer.tcl104
-rw-r--r--lib/utilities/table_of_instructions.tcl692
113 files changed, 28688 insertions, 9915 deletions
diff --git a/lib/X.tcl b/lib/X.tcl
index 0875d3d..26cfb7f 100755..100644
--- a/lib/X.tcl
+++ b/lib/X.tcl
@@ -1,8 +1,8 @@
-#!/usr/bin/tclsh
+#!/usr/bin/wish
# 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,14 +21,19 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _X_TCL ] } {
+set _X_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# "Provides various dialogs and various variables for various things"
+# "Provides various dialogues and various variables for various things"
# For instance the "Go to" dialog is placed here
# --------------------------------------------------------------------------
# Dialog for selecting MCU and loading MCU details from definition file
-source "${::LIB_DIRNAME}/dialogs/selectmcu.tcl"
+source "${::LIB_DIRNAME}/dialogues/selectmcu.tcl"
namespace eval X {
@@ -43,7 +48,7 @@ namespace eval X {
variable project_menu_locked 1 ;# Bool: Indicates than there is at least one opened project
if {!$::MICROSOFT_WINDOWS} {
variable defaultDirectory ${::env(HOME)} ;# Default directory
- } {
+ } else {
variable defaultDirectory ${::env(USERPROFILE)} ;# Default directory
}
variable simulator_enabled {} ;# List of booleans: Simulator engaged
@@ -51,13 +56,13 @@ namespace eval X {
variable fsd_result {} ;# Value returnded by file selection dialog (in some cases)
variable projectmenu {.project_menu} ;# ID of Popup menu for project tabs
variable projectmenu_project {} ;# Object: project selected by project popup menu
- variable selectedView ;# Int: Selected editor by editor statusbar popup menu
+ variable selectedView ;# Object: Selected editor by editor statusbar popup menu
variable open_f_external_editor 0 ;# Bool: Use procedure __open to open new file for embedded external editor
variable file_recent_files {} ;# List: recently opened files
variable project_recent_files {} ;# List: recently opened projects
variable vhw_recent_files {} ;# List: recently opened Virtual HW files
# List of supported processors
- variable avaliable_processors [::SelectMCU::get_avaliable_processors]
+ variable available_processors [::SelectMCU::get_available_processors]
variable procedure_exit_in_progress 0 ;# Bool: proc "__exit" in progress
## Doxygen
@@ -69,11 +74,14 @@ namespace eval X {
## ASCII chart
variable ascii_chart_win_object {} ;# Object: ASCII chart window object
- ## 8-segment LED editor
+ ## Interactive 8051 instruction table
+ variable table_of_instructions_object {} ;# Object: Interactive 8051 instruction table
+
+ ## 8-Segment LED editor
variable eightsegment_editors {} ;# List: All 8-segment LED display editors invoked
- ## Base convertor
- variable base_convertors {} ;# List: All base convertor objects
+ ## Base converter
+ variable base_converters {} ;# List: All base converter objects
## Special calculator
variable spec_calc_objects {} ;# List: All special calculator objects
@@ -81,6 +89,14 @@ namespace eval X {
## UART/RS232 debugger
variable rs232debugger_objects {} ;# List: All "RS232 debugger" objects
+ ## LCD display controlled by HD44780
+ variable vhw_HD44780_rect ;# Array: Rectangles in dialog "Set display size"
+ variable vhw_HD44780_canvas ;# Widget: Canvas widget in dialog "Set display size"
+ variable vhw_HD44780_counter 0 ;# Int: Counter of dialog instances
+ variable vhw_HD44780_size_lbl ;# Widget: Label showing the LCD size in dialog "Set display size"
+ variable vhw_HD44780_dialog ;# Widget: Toplevel window of dialog "Set display size"
+ variable vhw_HD44780_size {0 0} ;# List of Int: LCD display size chosen by the user, {HEIGHT WIDTH}
+
## Dialog "Go to"
variable goto ;# Line where to go
@@ -98,7 +114,7 @@ namespace eval X {
variable find_option_sel ;# Bool: Search only in the seleted text
variable find_option_reg ;# Bool: Consider search string to be a regular expression
variable find_allow_selection ;# Bool: There is some selected text in editor
- variable find_retry_search ;# Bool: Search restarted from begining/end
+ variable find_retry_search ;# Bool: Search restarted from beginning/end
variable find_back_dir ;# Bool: Search backwards (real option)
variable find_history {} ;# List of the last 10 search strings
variable find_next_prev_in_P 0 ;# Bool: Procedure 'find_next_prev' in progress
@@ -121,8 +137,8 @@ namespace eval X {
variable select_directory_var {} ;# Selected directory
## Dialog "New project"
- variable project_new_name ;# Name of the new project
- variable project_new_dir ;# Directory of the new project
+ variable project_new_name {} ;# Name of the new project
+ variable project_new_dir {} ;# Directory of the new project
## Variable common for "New project" and "Edit project"
variable project_new_processor ;# Processor type (e.g. "8051")
@@ -142,7 +158,7 @@ namespace eval X {
variable project_edit_version ;# Project version
variable project_edit_date ;# Project date (last update)
variable project_edit_copyright ;# Copyright information
- variable project_edit_licence ;# Licence information
+ variable project_edit_license ;# License information
variable project_edit_authors ;# Project authors
variable project_edit_description ;# Project description
variable project_edit_clock ;# Default clock rate
@@ -172,19 +188,19 @@ namespace eval X {
variable compilation_success_callback {} ;# String: Indented for HW plugins
variable compilation_fail_callback {} ;# String: Indented for HW plugins
variable compilation_mess_project {} ;# Object: Project related to running compilation
- variable compilation_successfull 1 ;# Bool: Compilation successfull
+ variable compilation_successfull 1 ;# Bool: Compilation successful
variable compilation_in_progress 0 ;# Bool: Compiler engaged
variable compilation_progress 0 ;# Variable for compilation progressbar
variable compiler_pid 0 ;# Int: PID of external compiler if used
variable compilation_start_simulator 0 ;# Bool: Start simulator after successful compilation
variable compile_this_file_only 0 ;# Bool: Compile the current file only
- ## Dialog "Select input/uotput file"
+ ## Dialog "Select input/output file"
variable input_file ;# Input file
variable output_file ;# Output file
variable IO ;# Bool: 1 == choose input file; 0 == choose output file
- ### Dialogs "Hex->Bin; Bin->Hex; Sim->Hex; Sim->Bin; Nomalize Hex"
+ ### Dialogues "Hex->Bin; Bin->Hex; Sim->Hex; Sim->Bin; Nomalize Hex"
# Type of conversion
# 0 == Bin -> Hex
# 1 == Hex -> Bin
@@ -193,15 +209,15 @@ namespace eval X {
variable hex__bin
## XDATA/CODE/ERAM/EEPROM/UNI memory hexadecimal editors
- variable opended_code_mem_windows {} ;# List of project object with opened CODE memory hex editor
+ variable opened_code_mem_windows {} ;# List of project object with opened CODE memory hex editor
variable code_mem_window_objects {} ;# List of CODE memory hex editor objects
- variable opended_xdata_mem_windows {} ;# List of project object with opened XDATA memory hex editor
+ variable opened_xdata_mem_windows {} ;# List of project object with opened XDATA memory hex editor
variable xdata_mem_window_objects {} ;# List of XDATA memory hex editor objects
- variable opended_eram_windows {} ;# List of project object with opened ERAM hex editor
+ variable opened_eram_windows {} ;# List of project object with opened ERAM hex editor
variable eram_window_objects {} ;# List of ERAM hex editor objects
- variable opended_eeprom_mem_windows {} ;# List of project object with opened data EEPROM hex editor
+ variable opened_eeprom_mem_windows {} ;# List of project object with opened data EEPROM hex editor
variable eeprom_mem_window_objects {} ;# List of data EEPROM hex editor objects
- variable opended_eeprom_wr_bf_windows {} ;# List of project objects with opened data EEPROM write buffer editor
+ variable opened_eeprom_wr_bf_windows {} ;# List of project objects with opened data EEPROM write buffer editor
variable eeprom_wr_bf_window_objects {} ;# List of data EEPROM write buffer hex editor objects
variable eeprom_wr_buf_counter 0 ;# Counter of EEPROM write buffer hex editor objects
variable saving_progress 0 ;# Variable for progressbars representing saving progress
@@ -226,6 +242,7 @@ namespace eval X {
*.adf *.adb *.rel *.cdb *.mem *.lnk *.sym
*.omf *.rst *.hashes *bak
}
+ variable cleanup_files {} ;# List: Files marked for potential removal
## Dialog "Change letter case"
variable change_letter_case_options ;# Options (which fields should be adjusted)
@@ -247,7 +264,7 @@ namespace eval X {
variable PROJECTDETAILSWIN ;# ID of project details window
variable projectdetails_last_project {} ;# Project object of the last project details window
- ## Cutom commands related variables
+ ## Custom commands related variables
variable custom_cmd_dialog_index 0 ;# Index of results dialog (to keep win IDs unique)
variable custom_command_cmd ;# Array of custom commands (shell scripts)
variable custom_command_options ;# Array of Lists of custom command options
@@ -259,11 +276,23 @@ namespace eval X {
## Initialize custom commands related variables
# Shell scripts
set custom_command_cmd(0) [mc "echo \"This is a custom command\"\necho \"\tYou can configure it in Main menu->Configure->Edit user commands.\"\necho \"\tCustom commands are intended for running external programs from this IDE (e.g. program uploaders)\""]
- append custom_command_cmd(0) "\n\necho \"\nThis is a custom command\"\necho \"\tYou can configure it in Main menu->Configure->Edit user commands.\"\necho \"\tCustom commands are intended for running external programs from this IDE (e.g. program uploaders)\""
+
+ append custom_command_cmd(0) "\n\n"
+ append custom_command_cmd(0) "echo \"\"\n"
+ append custom_command_cmd(0) "echo \"%%URIS == \\\"%URIS\\\"\"\n"
+ append custom_command_cmd(0) "echo \"%%URI == \\\"%URI\\\"\"\n"
+ append custom_command_cmd(0) "echo \"%%directory == \\\"%directory\\\"\"\n"
+ append custom_command_cmd(0) "echo \"%%filename == \\\"%filename\\\"\"\n"
+ append custom_command_cmd(0) "echo \"%%basename == \\\"%basename\\\"\"\n"
+ append custom_command_cmd(0) "echo \"%%mainfile == \\\"%mainfile\\\"\"\n"
+ append custom_command_cmd(0) "echo \"%%line == \\\"%line\\\"\"\n"
+ append custom_command_cmd(0) "echo \"%%column == \\\"%column\\\"\"\n"
+ append custom_command_cmd(0) "echo \"%%selection == \\\"%selection\\\"\"\n"
+
set custom_command_cmd(1) $custom_command_cmd(0)
set custom_command_cmd(2) $custom_command_cmd(0)
# Command options
- set custom_command_options(0) {0 1 0}
+ set custom_command_options(0) {0 1 0 0}
set custom_command_options(1) $custom_command_options(0)
set custom_command_options(2) $custom_command_options(0)
# Command descritpions
@@ -321,7 +350,7 @@ namespace eval X {
"Compile this file"}
}
}
- # Menu bar items which are not avaliable when editor is in read only mode
+ # Menu bar items which are not available when editor is in read only mode
variable mainmenu_editor_readonly {
{ ".mainMenu.edit"
{ "Undo" "Redo" "Cut" "Paste" "Replace"
@@ -330,13 +359,13 @@ namespace eval X {
{ "Auto indent" "Change letter case" "Document current function"}
}
}
- # Menu bar items which are not avaliable only for C language
+ # Menu bar items which are not available only for C language
variable mainmenu_editor_c_only {
{ ".mainMenu.tools"
{ "Document current function"}
}
}
- # Menu bar items which are not avaliable when external embedded editor is used
+ # Menu bar items which are not available when external embedded editor is used
variable mainmenu_editor_external_na {
{.mainMenu.tools {
{Encoding} {End of line}
@@ -365,40 +394,52 @@ namespace eval X {
# Toolbar buttons which require opened project
variable toolbar_project_dependent_buttons {
- new open save save_as save_all close close_all undo redo cut
- copy paste find findnext findprev replace goto reload clear
- proj_save proj_edit proj_close proj_close_imm show_code_mem
- show_ext_mem start_sim reset step stepover animate run
- assemble disasm reformat_code toHTML toLaTeX cleanup custom0
- custom1 custom2 change_case forward back clear_hg intrmon
- hibernate resume stepback find_sim_cur line2addr show_exp_mem
- sfrmap show_eeprom show_eem_wr_b stopwatch bitmap
-
- ledpanel leddisplay ledmatrix mleddisplay simplekeypad
- matrixkeypad vhw_open vhw_load vhw_save vhw_saveas
- vhw_remove_all
-
- stack
+ new open save save_as
+ save_all close close_all undo
+ redo cut copy paste
+ find findnext findprev replace
+ goto reload clear proj_save
+ proj_edit proj_close proj_close_imm show_code_mem
+ show_ext_mem start_sim reset step
+ stepover animate run assemble
+ disasm reformat_code toHTML toLaTeX
+ cleanup custom0 custom1 custom2
+ change_case forward back clear_hg
+ intrmon hibernate resume stepback
+ find_sim_cur line2addr show_exp_mem sfrmap
+ show_eeprom show_eem_wr_b stopwatch bitmap
+ uartmon
+
+ ledpanel leddisplay ledmatrix mleddisplay
+ simplekeypad matrixkeypad vhw_open vhw_load
+ vhw_save vhw_saveas vhw_remove_all hd44780
+ ds1620 vuterm fintr
+
+ stack d52
}
# Toolbar buttons which require ENGAGED simulator
variable toolbar_simulator_engaged {
- reset step stepover animate run clear_hg
- find_sim_cur line2addr stepback hibernate resume
+ reset step stepover animate
+ run clear_hg find_sim_cur line2addr
+ stepback hibernate resume
}
# Toolbar buttons which require DISENGAGED simulator
variable toolbar_simulator_disengaged {
- new open close close_all undo redo cut
- copy paste replace reload assemble start_sim0
- disasm reformat_code change_case assemble0
+ new open close close_all
+ undo redo cut copy
+ paste replace reload assemble
+ start_sim0 disasm reformat_code change_case
+ assemble0 d52
}
- # Toolbar items which are not avaliable when editor is in read only mode
+ # Toolbar items which are not available when editor is in read only mode
variable toolbar_editor_readonly {
- undo redo cut paste replace reformat_code change_case
+ undo redo cut paste
+ replace reformat_code change_case
}
- # Toolbar items which are not avaliable only for C language
+ # Toolbar items which are not available only for C language
variable toolbar_editor_c_only {
}
- # Toolbar items which are not avaliable when external embedded editor is used
+ # Toolbar items which are not available when external embedded editor is used
variable toolbar_editor_external_na {
save save_as undo redo cut
copy paste find findnext findprev
@@ -439,7 +480,7 @@ namespace eval X {
{command "Move to end" "" 9
{__project_move_to_end}
"2rightarrow" "Move this tab to right the end of the tab bar"}
- } $projectmenu 0 "::X::" 0 {}
+ } $projectmenu 0 "::X::" 0 {} [namespace current]
}
## Switch current project
@@ -471,9 +512,10 @@ namespace eval X {
adjust_title
$actualProject adjust_compiler_settings
+ $actualProject switchfile
}
- ## Enable / Disable menu and toolbar item acording to current state of current project
+ ## Enable / Disable menu and toolbar item according to current state of current project
# @return void
proc disaena_menu_toolbar_for_current_project {} {
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
@@ -490,13 +532,16 @@ namespace eval X {
# Enable / Disabled stepback buttons
stepback_button_set_ena [$actualProject simulator_get_SBS_len]
- } {
+ } else {
Lock_simulator_menu
adjust_mainmenu_and_toolbar_to_editor \
${::editor_RO_MODE} \
[expr {1 == [$actualProject editor_procedure {} get_language {}]}]
}
+ # set MCU name in statusbar, kdb
+ .statusbarMCU configure -text [$actualProject cget -P_option_mcu_type]
+
## Disable/Enable menu+toolbar entries related to simulator controls which depends on current MCU
disena_simulator_menu $actualProject
}
@@ -546,8 +591,9 @@ namespace eval X {
if {[lindex $simulator_enabled $actualProjectIdx] == 1} {
if {$message} {
- tk_messageBox \
- -title [mc "Unable to compile"] \
+ tk_messageBox \
+ -parent . \
+ -title [mc "Unable to comply"] \
-icon info \
-type ok \
-message [mc "Simulator is engaged, shutdown the simulator first."]
@@ -586,9 +632,9 @@ namespace eval X {
}
## Open file
- # @parm Bool = 0 - 1 == New file (for embedded external editor); 0 == Open an existing file
+ # @parm Bool p_open_f_external_editor=0 - 1 == New file (for embedded external editor); 0 == Open an existing file
# @return void
- proc __open args {
+ proc __open {{p_open_f_external_editor 0}} {
variable actualProject ;# Object: Current project
variable actualProjectIdx ;# Index of the current project in $openedProjects
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
@@ -603,13 +649,11 @@ namespace eval X {
set critical_procedure_in_progress 1
# Parse input arguments
- set open_f_external_editor [lindex $args 0]
- if {$open_f_external_editor != 1} {
- set title [mc "Open file - MCU 8051 IDE"]
- set open_f_external_editor 0
- } {
+ set open_f_external_editor $p_open_f_external_editor
+ if {$open_f_external_editor} {
set title [mc "New file - MCU 8051 IDE"]
- set open_f_external_editor 1
+ } else {
+ set title [mc "Open file - MCU 8051 IDE"]
}
# Invoke the file selection dialog
@@ -640,11 +684,11 @@ namespace eval X {
foreach filename [X::fsd get] {
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $filename]} {
- set filename "[${X::actualProject} cget -ProjectDir]/$filename"
+ set filename "[${::X::actualProject} cget -ProjectDir]/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
- set filename [file join [${X::actualProject} cget -ProjectDir] $filename]
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
+ set filename [file join [${::X::actualProject} cget -ProjectDir] $filename]
}
}
set filename [file normalize $filename]
@@ -661,32 +705,34 @@ namespace eval X {
# Open the specified file
if {${::X::open_f_external_editor} || [file exists $filename]} {
- if {[${X::actualProject} openfile $filename 1 \
+ if {[${::X::actualProject} openfile $filename 1 \
[X::fsd get_window_name] def def 0 0 {}] != {}
- } {
- ${X::actualProject} switch_to_last
- update idle
- ${X::actualProject} editor_procedure {} parseAll {}
+ } then {
+ ${::X::actualProject} switch_to_last
+ update idletasks
+ ${::X::actualProject} editor_procedure {} parseAll {}
# Make LST read only
if {[file extension $filename] == {.lst}} {
set ::editor_RO_MODE 1
- ${X::actualProject} switch_editor_RO_MODE
+ ${::X::actualProject} switch_editor_RO_MODE
}
::X::recent_files_add 1 $filename
}
- } {
- ${X::actualProject} editor_new
- ${X::actualProject} save_as $filename
+
+ } else {
if {!${::Editor::editor_to_use}} {
tk_messageBox \
-type ok \
-icon warning \
- -parent [::X::fsd get_window_name] \
+ -parent . \
-title [mc "File not found - MCU 8051 IDE"] \
-message [mc "The selected file do not exist:\n%s" $filename]
}
+
+ ${::X::actualProject} editor_new
+ ${::X::actualProject} save_as $filename 1
}
}
}
@@ -726,6 +772,11 @@ namespace eval X {
if {$project_menu_locked} {return}
+ # Won't save read-only file
+ if {[$actualProject editor_procedure {} cget {-ro_mode}]} {
+ return
+ }
+
# This function is critical
if {$critical_procedure_in_progress} {return}
set critical_procedure_in_progress 1
@@ -747,17 +798,17 @@ namespace eval X {
-initialfile [lindex $filename 1] \
-title [mc "Save file - MCU 8051 IDE"] \
-directory $directory \
- -defaultmask $defaultmask -multiple 0 -filetypes {
- {{Assembly language} {*.asm} }
- {{C source} {*.c} }
- {{C header} {*.h} }
- {{All files} {*} }
- }
+ -defaultmask $defaultmask -multiple 0 -filetypes [list \
+ [list [mc "Assembly language"] {*.asm}] \
+ [list [mc "C source"] {*.c}] \
+ [list [mc "C header"] {*.h}] \
+ [list [mc "All files"] {*}] \
+ ]
# Save file after press of OK button
fsd setokcmd {
set filename [X::fsd get]
- ${X::actualProject} save_as $filename
+ ${::X::actualProject} save_as $filename
}
# activate the dialog
@@ -779,7 +830,7 @@ namespace eval X {
if {$critical_procedure_in_progress} {return}
set critical_procedure_in_progress 1
- # Save all opended files
+ # Save all opened files
$actualProject editor_save_all
set critical_procedure_in_progress 0
@@ -805,7 +856,7 @@ namespace eval X {
set critical_procedure_in_progress 0
}
- ## Close all opended files
+ ## Close all opened files
# @return void
proc __close_all {} {
variable actualProject ;# Object: Current project
@@ -934,7 +985,7 @@ namespace eval X {
# @return void
proc __find {} {
variable actualProject ;# Object: Current project
- variable find_String ;# Search string
+ variable find_String {} ;# Search string
variable find_option_CS ;# Bool: Case sensitive
variable find_option_back ;# Bool: Search backwards (checkbox)
variable find_option_cur ;# Book: Search from cursor
@@ -956,7 +1007,7 @@ namespace eval X {
}
# Create a new toplevel window for the dialog
- set win [toplevel .find -class {Find dialog} -bg {#EEEEEE}]
+ set win [toplevel .find -class {Find dialog} -bg ${::COMMON_BG_COLOR}]
# String to search for
label $win.findLabel -compound left -image ::ICONS::16::find -text [mc "Text to find:"]
@@ -982,7 +1033,7 @@ namespace eval X {
# Determinate wheather there is some selected text
if {[$actualProject editor_procedure {} getselection {}] == {}} {
set find_allow_selection 0
- } {
+ } else {
set find_allow_selection 1
}
@@ -992,18 +1043,18 @@ namespace eval X {
foreach opt { CS back cur sel reg } \
txt { "Case sensitive" "Backwards" "From cursor" "Selected text" "Regular expr." } \
helptext {
- {Case sensitive search}
- {Search backwards from the specified location}
- {Start search from cursor instead of begining}
- {Search within selected text only}
- {Use search string as regular expression}
+ "Case sensitive search"
+ "Search backwards from the specified location"
+ "Start search from cursor instead of beginning"
+ "Search within selected text only"
+ "Use search string as regular expression"
} \
{
# Disable/Enable "in selection" checkbox
if {$opt == {sel} && !$find_allow_selection} {
set state disabled
set X::find_option_sel 0
- } {
+ } else {
set state normal
}
@@ -1013,7 +1064,7 @@ namespace eval X {
-variable X::find_option_$opt \
-state $state \
] -column $col -row $row -sticky wns
- DynamicHelp::add $optionsFrame.option_$opt -text $helptext
+ DynamicHelp::add $optionsFrame.option_$opt -text [mc $helptext]
incr col
if {$col == 2} {
@@ -1084,7 +1135,7 @@ namespace eval X {
variable find_option_cur ;# Book: Search from cursor
variable find_option_sel ;# Bool: Search only in the seleted text
variable find_option_reg ;# Bool: Consider search string to be a regular expression
- variable find_retry_search ;# Bool: Search restarted from begining/end
+ variable find_retry_search ;# Bool: Search restarted from beginning/end
variable find_back_dir ;# Bool: Search backwards (real option)
variable find_history ;# List of the last 10 search strings
@@ -1113,7 +1164,7 @@ namespace eval X {
set find_option_notCS [expr {!$find_option_CS}]
if {!$find_allow_selection} {
set option_sel 0
- } {
+ } else {
set option_sel $find_option_sel
}
@@ -1147,10 +1198,10 @@ namespace eval X {
}
## Retry search -- auxiliary procedure for '__find'
- # Useful when search cursor reach begining/end of the document
+ # Useful when search cursor reach beginning/end of the document
# @return Bool result
proc retry_search {} {
- variable find_retry_search ;# Bool: Search restarted from begining/end
+ variable find_retry_search ;# Bool: Search restarted from beginning/end
variable find_String ;# Search string
variable find_option_back ;# Bool: Search backwards (checkbox)
variable find_option_cur ;# Book: Search from cursor
@@ -1178,29 +1229,29 @@ namespace eval X {
# Backward search
if {$find_back_dir} {
if {[tk_messageBox \
- -icon question \
- -type yesno \
- -parent . \
- -title [mc "Find - %s" ${::APPNAME}] \
- -message [mc "Begining of document reached\n\nContinue from end ?"] \
- ]} {
- set find_next_prev_in_P 0
- set find_backward_index end
- set find_forward_index 1.0
- set find_option_cur 0
- # Retry search
- find_next_prev [expr {!$find_option_back}]
+ -icon question \
+ -type yesno \
+ -parent . \
+ -title [mc "Find - %s" ${::APPNAME}] \
+ -message [mc "Beginning of document reached\n\nContinue from end ?"] \
+ ] == {yes}} then {
+ set find_next_prev_in_P 0
+ set find_backward_index end
+ set find_forward_index 1.0
+ set find_option_cur 0
+ # Retry search
+ find_next_prev [expr {!$find_option_back}]
}
# Forward search
- } {
+ } else {
if {[tk_messageBox \
-icon question \
-type yesno \
-parent . \
-title [mc "Find - %s" ${::APPNAME}] \
- -message [mc "End of document reached\n\nContinue from begining ?"] \
- ]} {
+ -message [mc "End of document reached\n\nContinue from beginning ?"] \
+ ] == {yes}} then {
set find_next_prev_in_P 0
set find_backward_index end
set find_forward_index 1.0
@@ -1215,7 +1266,7 @@ namespace eval X {
set find_retry_search 0
}
- ## Find next occurence of the search string
+ ## Find next occurrence of the search string
# @return void
proc __find_next {} {
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
@@ -1228,7 +1279,7 @@ namespace eval X {
find_next_prev 0
}
- ## Find previous occurence of the search string
+ ## Find previous occurrence of the search string
# @return void
proc __find_prev {} {
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
@@ -1241,7 +1292,7 @@ namespace eval X {
find_next_prev 1
}
- ## Find next/previous occurence of the search string
+ ## Find next/previous occurrence of the search string
# @parm Bool back_dir - Search backwards
# @return void
proc find_next_prev {back_dir} {
@@ -1254,11 +1305,11 @@ namespace eval X {
variable find_option_cur ;# Book: Search from cursor
variable find_option_sel ;# Bool: Search only in the seleted text
variable find_option_reg ;# Bool: Consider search string to be a regular expression
- variable find_retry_search ;# Bool: Search restarted from begining/end
+ variable find_retry_search ;# Bool: Search restarted from beginning/end
variable find_back_dir ;# Bool: Search backwards (real option)
variable find_next_prev_in_P ;# Bool: Procedure 'find_next_prev' in progress
- # This function is not avaliable for exeternal embedded editors
+ # This function is not available for exeternal embedded editors
if {${::Editor::editor_to_use}} {return}
# This function cannot run multithreaded
@@ -1282,16 +1333,16 @@ namespace eval X {
if {[$editor compare $find_forward_index == insert]} {
$editor mark set insert $find_backward_index
}
- } {
+ } else {
if {[$editor compare $find_backward_index == insert]} {
$editor mark set insert $find_forward_index
}
}
set index insert
- } {
+ } else {
if {$find_back_dir} {
set index $find_backward_index
- } {
+ } else {
set index $find_forward_index
}
}
@@ -1318,8 +1369,8 @@ namespace eval X {
# @return void
proc __replace {} {
variable actualProject ;# Object: Current project
- variable replace_String ;# String to replace
- variable replace_Replacement ;# Replacement for the search string
+ variable replace_String {} ;# String to replace
+ variable replace_Replacement {} ;# Replacement for the search string
variable replace_option_CS ;# Bool: Case sensitive
variable replace_option_back ;# Bool: Search backwards (checkbox)
variable replace_option_cur ;# Book: Search from cursor
@@ -1342,7 +1393,7 @@ namespace eval X {
}
# Create a new toplevel window for the dialog
- set win [toplevel .replace -class {Replace dialog} -bg {#EEEEEE}]
+ set win [toplevel .replace -class {Replace dialog} -bg ${::COMMON_BG_COLOR}]
# Create labelframe "String to find"
label $win.findLabel -compound left -image ::ICONS::16::find -text [mc "Text to find: "]
@@ -1373,7 +1424,7 @@ namespace eval X {
DynamicHelp::add $replaceFrame.entry -text [mc "Replacement for search string"]
# Create and pack options checkboxes labelframe
- label $win.optionsLabel -compound left -image ::ICONS::16::configure -text "Options"
+ label $win.optionsLabel -compound left -image ::ICONS::16::configure -text [mc "Options"]
set optionsFrame [ttk::labelframe $win.optionsFrame \
-labelwidget $win.optionsLabel \
]
@@ -1385,19 +1436,20 @@ namespace eval X {
foreach opt { CS back cur reg prompt} \
txt { "Case sensitive" "Backwards" "From cursor" "Regular expr." "Prompt on replace"} \
helptext {
- {Case sensitive search}
- {Search backwards from the specified location}
- {Start search from cursor instead of begining}
- {Use search string as regular expression}
- {Prompt on replace}
- } {
+ "Case sensitive search"
+ "Search backwards from the specified location"
+ "Start search from cursor instead of beginning"
+ "Use search string as regular expression"
+ "Prompt on replace"
+ } \
+ {
# Create checkbutton
grid [checkbutton $optionsFrame.option_$opt \
-text [mc $txt] \
-variable X::replace_option_$opt \
] -column $col -row $row -sticky wns
- DynamicHelp::add $optionsFrame.option_$opt -text $helptext
+ DynamicHelp::add $optionsFrame.option_$opt -text [mc $helptext]
incr col
if {$col == 2} {
@@ -1413,13 +1465,13 @@ namespace eval X {
-compound left \
-image ::ICONS::16::ok \
-command {X::replace_REPLACE} \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command {X::replace_CANCEL} \
- ] -side left
+ ] -side left -padx 2
pack $buttonFrame -pady 5
# Events binding (Enter == Replace; Escape == Cancel)
@@ -1492,36 +1544,36 @@ namespace eval X {
$replace_option_reg $replace_option_notCS \
$replace_String $replace_Replacement \
$replace_option_prompt X::replace_prompt]
- ]} {
- if {!$replace_option_cur} {return}
+ ]} then {
+ if {!$replace_option_cur} {return}
- set replace_option_cur_tmp $replace_option_cur
- set replace_option_cur 0
+ set replace_option_cur_tmp $replace_option_cur
+ set replace_option_cur 0
- # Retry search
- if {$replace_option_back} {
- if {[tk_messageBox \
- -icon question \
- -type yesno \
- -parent . \
- -title [mc "Replace - %s" ${::APPNAME}] \
- -message [mc "Begining of document reached\n\nContinue from end ?"] \
- ]} {
- replace_REPLACE
- }
- } {
- if {[tk_messageBox \
- -icon question \
- -type yesno \
- -parent . \
- -title [mc "Replace - %s" ${::APPNAME}] \
- -message [mc "End of document reached\n\nContinue from begining ?"] \
- ]} {
- replace_REPLACE
- }
+ # Retry search
+ if {$replace_option_back} {
+ if {[tk_messageBox \
+ -icon question \
+ -type yesno \
+ -parent . \
+ -title [mc "Replace - %s" ${::APPNAME}] \
+ -message [mc "Beginning of document reached\n\nContinue from end ?"] \
+ ]} then {
+ replace_REPLACE
}
+ } else {
+ if {[tk_messageBox \
+ -icon question \
+ -type yesno \
+ -parent . \
+ -title [mc "Replace - %s" ${::APPNAME}] \
+ -message [mc "End of document reached\n\nContinue from beginning ?"] \
+ ]} then {
+ replace_REPLACE
+ }
+ }
- set replace_option_cur $replace_option_cur_tmp
+ set replace_option_cur $replace_option_cur_tmp
}
}
@@ -1543,11 +1595,11 @@ namespace eval X {
if {$replace_prompt_opened} {
replace_prompt_DESTROY
# Open the dialog
- } {
+ } else {
set replace_prompt_opened 1
# Create dialog window and restore previous geometry
- toplevel .replace_prompt -class {Replace prompt dialog} -bg {#EEEEEE}
+ toplevel .replace_prompt -class {Replace prompt dialog} -bg ${::COMMON_BG_COLOR}
if {[info exists replace_prompt_geometry]} {
wm geometry .replace_prompt $replace_prompt_geometry
}
@@ -1558,7 +1610,7 @@ namespace eval X {
-image ::ICONS::32::help \
] -side left -padx 10
pack [label .replace_prompt.topFrame.label \
- -text [mc "Found an occurence of your search term.\nWhat do you want to do ?"] \
+ -text [mc "Found an occurrence of your search term.\nWhat do you want to do ?"] \
] -fill both -expand 1 -side right
# Create separator
@@ -1685,7 +1737,7 @@ namespace eval X {
# Create dialog window
set goto_opened 1
- set win [toplevel .goto -class {Goto dialog} -bg {#EEEEEE}]
+ set win [toplevel .goto -class {Go to dialog} -bg ${::COMMON_BG_COLOR}]
# Create window label frame
label $win.header -text [mc "Go to line"] -image ::ICONS::16::goto -compound left
@@ -1706,13 +1758,12 @@ namespace eval X {
-text [mc "Graphical representation of line where to go"]
# Create spinbox widget
- pack [spinbox $topFrame.spinbox \
+ pack [ttk::spinbox $topFrame.spinbox \
-from 1 -to $editor_lines \
- -textvariable X::goto \
+ -textvariable ::X::goto \
-validate key \
- -validatecommand {X::goto_validate %P} \
+ -validatecommand {::X::goto_validate %P}\
-width 6 \
- -command "$topFrame.spinbox selection range 0 end" \
] -side left
DynamicHelp::add $topFrame.spinbox -text [mc "Line where to go"]
@@ -1723,14 +1774,14 @@ namespace eval X {
-compound left \
-image ::ICONS::16::ok \
-command {X::goto_OK} \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command {X::goto_CANCEL} \
- ] -side left
- pack $buttonFrame -pady 5
+ ] -side left -padx 2
+ pack $buttonFrame -pady 5 -padx 5
# Events binding (Enter == Ok, Esc == CANCEL)
bind $win <KeyRelease-Return> {X::goto_OK; break}
@@ -1743,7 +1794,7 @@ namespace eval X {
# Nessesary window manager options -- modal window
wm iconphoto $win ::ICONS::16::goto
- wm title $win [mc "Goto line - MCU 8051 IDE"]
+ wm title $win [mc "Go to line - MCU 8051 IDE"]
wm minsize $win 200 100
wm protocol $win WM_DELETE_WINDOW {
X::goto_CANCEL
@@ -1762,7 +1813,7 @@ namespace eval X {
if {$value > $editor_lines} {
return 0
- } {
+ } else {
return 1
}
}
@@ -1843,7 +1894,7 @@ namespace eval X {
# Determinate initial directory
if {$project_menu_locked} {
set directory {~}
- } {
+ } else {
set directory [$actualProject cget -projectPath]
}
@@ -1867,10 +1918,10 @@ namespace eval X {
## Invoke dialog "New Project"
# @return void
proc __proj_new {} {
- variable avaliable_processors ;# List of supported processors
+ variable available_processors ;# List of supported processors
variable actualProject ;# Object: Current project
- variable project_new_name ;# Name of the new project
- variable project_new_dir ;# Directory of the new project
+ variable project_new_name {} ;# Name of the new project
+ variable project_new_dir {} ;# Directory of the new project
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
variable project_new_processor {AT89S52};# Processor type (e.g. "AT89C2051")
variable project_new_xdata_ena 0 ;# Bool: XDATA memory connected
@@ -1888,7 +1939,7 @@ namespace eval X {
if {$critical_procedure_in_progress} {return}
# Create dialog window
- set win [toplevel .project_new -class {New project} -bg {#EEEEEE}]
+ set win [toplevel .project_new -class {New project} -bg ${::COMMON_BG_COLOR}]
# Create window header (text and some icon)
set header [frame $win.header]
@@ -1946,14 +1997,14 @@ namespace eval X {
set proc_frame_top [frame $proc_frame.top]
set proc_frame_middle [frame $proc_frame.middle]
set proc_frame_middle_left [ttk::labelframe $proc_frame_middle.middle \
- -padding 5 -text [mc "XDATA"]]
+ -padding 5 -text [mc "External RAM (XDATA)"]]
set proc_frame_middle_right [ttk::labelframe $proc_frame_middle.right \
- -padding 5 -text [mc "XCODE"]]
+ -padding 5 -text [mc "External ROM/FLASH (XCODE)"]]
# Create components of top frame (Type: <ComboBox> <Button>)
pack [label $proc_frame_top.lbl -text [mc "Type:"]] -side left
pack [ttk::combobox $proc_frame_top.combo \
- -values $avaliable_processors \
+ -values $available_processors \
-state readonly \
-textvariable ::X::project_new_processor \
] -side left -fill x -fill x
@@ -1981,7 +2032,7 @@ namespace eval X {
set project_new_xd_scl [ttk::scale $proc_frame_left_btm.scale \
-orient horizontal \
-variable ::X::project_new_xdata \
- -from 0 -to 0xFFFF \
+ -from 0 -to 0x10000 \
-command "
set ::X::project_new_xdata \[expr {int(\${::X::project_new_xdata})}\]
$proc_frame_left_btm.spinbox selection range 0 end
@@ -1990,12 +2041,11 @@ namespace eval X {
DynamicHelp::add $project_new_xd_scl \
-text [mc "Amount of external data memory"]
pack $project_new_xd_scl -fill x -side left -expand 1 -padx 2
- set project_new_xd_spb [spinbox $proc_frame_left_btm.spinbox \
- -textvariable ::X::project_new_xdata \
- -width 5 -from 0 -to 0xFFFF \
- -bg white -validate all \
- -vcmd {::SelectMCU::validate_xdata %P} \
- -command "$proc_frame_left_btm.spinbox selection range 0 end ;#" \
+ set project_new_xd_spb [ttk::spinbox $proc_frame_left_btm.spinbox \
+ -textvariable ::X::project_new_xdata \
+ -width 5 -from 0 -to 0x10000 \
+ -validate all \
+ -validatecommand {::SelectMCU::validate_xdata %P} \
]
DynamicHelp::add $project_new_xd_spb \
-text [mc "Amount of external data memory"]
@@ -2015,7 +2065,7 @@ namespace eval X {
set project_new_xc_scl [ttk::scale $proc_frame_right_btm.scale \
-orient horizontal \
-variable ::X::project_new_xcode \
- -from 0 -to 0xFFFF \
+ -from 0 -to 0x10000 \
-command "
set ::X::project_new_xcode \[expr {int(\${::X::project_new_xcode})}\]
$proc_frame_right_btm.spinbox selection range 0 end
@@ -2024,12 +2074,11 @@ namespace eval X {
DynamicHelp::add $project_new_xc_scl \
-text [mc "Amount of total program memory minus internal program memory"]
pack $project_new_xc_scl -fill x -side left -expand 1 -padx 2
- set project_new_xc_spb [spinbox $proc_frame_right_btm.spinbox \
- -textvariable ::X::project_new_xcode \
- -width 5 -from 0 -to 0xFFFF \
- -bg white -validate all \
- -vcmd {::X::proj_new_validate_xcode %P} \
- -command "$proc_frame_right_btm.spinbox selection range 0 end ;#" \
+ set project_new_xc_spb [ttk::spinbox $proc_frame_right_btm.spinbox \
+ -textvariable ::X::project_new_xcode \
+ -width 5 -from 0 -to 0x10000 \
+ -validate all \
+ -validatecommand {::X::proj_new_validate_xcode %P} \
]
DynamicHelp::add $project_new_xc_spb \
-text [mc "Amount of total program memory minus internal program memory"]
@@ -2049,15 +2098,17 @@ namespace eval X {
-compound left \
-image ::ICONS::16::ok \
-command {X::project_new_OK} \
- ] -side left -padx 5
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command {X::project_new_CANCEL} \
- ] -side left -padx 5
+ ] -side left -padx 2
pack $buttonFrame -pady 5
+ focus -force $name.entry
+
# Adjust XDATA & XCODE controls
proj_new_mcu_changed
@@ -2082,7 +2133,7 @@ namespace eval X {
## Binding for processor type combobox -modifycmd
# Usage: ComboBox -modifycmd ::X::proj_new_mcu_changed
# This function gets informations about selected processor
- # and adjusts XCODE & XDATA memory constrols.
+ # and adjusts XCODE & XDATA memory controls.
# @return void
proc proj_new_mcu_changed {} {
variable project_new_processor ;# Processor type (e.g. "8051")
@@ -2097,7 +2148,7 @@ namespace eval X {
# Get processor details
set details [::SelectMCU::get_processor_details $project_new_processor]
if {$details == {}} {
- puts stderr "Unknown error occured in ::X::proj_new_mcu_changed !\nPlease check your installation."
+ puts stderr "Unknown error occurred in ::X::proj_new_mcu_changed !\nPlease check your installation."
return
}
@@ -2105,7 +2156,7 @@ namespace eval X {
if {[lindex $details 0] != {yes}} {
set project_new_xdata_ena 0
$project_new_xd_chb configure -state disabled
- } {
+ } else {
$project_new_xd_chb configure -state normal
}
@@ -2113,12 +2164,12 @@ namespace eval X {
if {[lindex $details 1] != {yes}} {
set project_new_xcode_ena 0
$project_new_xc_chb configure -state disabled
- } {
+ } else {
$project_new_xc_chb configure -state normal
}
# Adjust XCODE memory scale & spinbox maximum value
- set project_new_max_xcode [expr {0xFFFF - ([lindex $details 2] * 1024)}]
+ set project_new_max_xcode [expr {0x10000 - ([lindex $details 2] * 1024)}]
$project_new_xc_scl configure -to $project_new_max_xcode
$project_new_xc_spb configure -to $project_new_max_xcode
@@ -2127,7 +2178,7 @@ namespace eval X {
proj_new_xcode_disena
}
- ## Enable/Disable XDATA scale & spinbox acording to $project_new_xdata_ena
+ ## Enable/Disable XDATA scale & spinbox according to $project_new_xdata_ena
# @return void
proc proj_new_xdata_disena {} {
variable project_new_xd_scl ;# Widget: XDATA scale
@@ -2139,13 +2190,13 @@ namespace eval X {
$project_new_xd_scl state !disabled
$project_new_xd_spb configure -state normal
# Disable
- } {
+ } else {
$project_new_xd_scl state disabled
$project_new_xd_spb configure -state disabled
}
}
- ## Enable/Disable XCODE scale & spinbox acording to $project_new_xcode_ena
+ ## Enable/Disable XCODE scale & spinbox according to $project_new_xcode_ena
# @return void
proc proj_new_xcode_disena {} {
variable project_new_xc_scl ;# Widget: XCODE scale
@@ -2155,12 +2206,10 @@ namespace eval X {
# Enable
if {$project_new_xcode_ena} {
$project_new_xc_scl state !disabled
-# $project_new_xc_scl configure -troughcolor {#FFFFFF}
$project_new_xc_spb configure -state normal
# Disable
- } {
+ } else {
$project_new_xc_scl state disabled
-# $project_new_xc_scl configure -troughcolor {#AAAAAA}
$project_new_xc_spb configure -state disabled
}
}
@@ -2195,13 +2244,13 @@ namespace eval X {
# Determinate initial XDATA memory for the dialog
if {$project_new_xdata_ena} {
set xdata $project_new_xdata
- } {
+ } else {
set xdata 0
}
# Determinate initial XCODE memory for the dialog
if {$project_new_xcode_ena} {
set xcode $project_new_xcode
- } {
+ } else {
set xcode 0
}
@@ -2214,20 +2263,21 @@ namespace eval X {
# Process results
set project_new_processor [lindex $result 0]
set project_new_xdata [lindex $result 1]
- set project_new_xcoda [lindex $result 2]
- proj_new_mcu_changed
+ set project_new_xcode [lindex $result 2]
# Adjust XCODE & XDATA checkbuttons
if {$project_new_xdata} {
set project_new_xdata_ena 1
- } {
+ } else {
set project_new_xdata_ena 0
}
if {$project_new_xcode} {
set project_new_xcode_ena 1
- } {
+ } else {
set project_new_xcode_ena 0
}
+
+ proj_new_mcu_changed
}
## Cancel dialog "Create new project" -- auxiliary procedure for '__proj_new'
@@ -2264,7 +2314,7 @@ namespace eval X {
tk_messageBox \
-icon warning \
-type ok \
- -title [mc "Ivalid request"] \
+ -title [mc "Invalid request"] \
-message [mc "Both entries in section general must be filled."] \
-parent .project_new
set critical_procedure_in_progress 0
@@ -2301,20 +2351,20 @@ namespace eval X {
set critical_procedure_in_progress 0
return 0
}
- } {
+ } else {
# Check if this the project does not already exist
if {[file exists "$project_new_dir/$project_new_name.mcu8051ide"]} {
# Ask for owerwrite
if {
- ![tk_messageBox \
+ [tk_messageBox \
-icon question \
-type yesno \
-default no \
-parent .project_new \
-title [mc "File already exists - MCU 8051 IDE"] \
-message [mc "Some project with the same name already exists in the specified directory. \nDo you want to overwrite it ?"] \
- ]
- } {
+ ] != {yes}
+ } then {
# (No) -> Cancel
set critical_procedure_in_progress 0
return 0
@@ -2341,6 +2391,33 @@ namespace eval X {
}
set project_new_xdata [expr {int($project_new_xdata)}]
set project_new_xcode [expr {int($project_new_xcode)}]
+
+ ## Format of this list is: {
+ #+ {version date creator_ver} # tag: tk_mcuide_project
+ #+ {authors copyright license} # tag: authors copyright license
+ #+ {type clock xdata xcode} # tag: processor
+ #+ {watches_file scheme main_file auto_sw_enabled} # tag: options
+ #+ {grid_mode magnification drawing_on
+ #+ mark_flags_true_state mark_flags_latched
+ #+ mark_flags_output active_page} # tag: graph
+ #+ {description todo} # tag: descriptin todo
+ #+ {radix angle_unit # tag: calculator
+ #+ display0 display1 display2
+ #+ memory0 memory1 memory2
+ #+ frequency time mode}
+ #+ {other_options} # tag: other_options
+ #+ {compiler_options}
+ #+ {files_count {current_file # tag: files
+ #+ current_file2 pwin_sash pwin_orient}
+ #+ { # tag: file actual_line md5_hash path bookmarks breakpoints
+ #+ name active o_bookmark p_bookmark
+ #+ file_index read_only actual_line md5_hash
+ #+ path bookmarks breakpoints eol
+ #+ enc highlight notes
+ #+ }
+ #+ ...
+ #+ }
+ #+ }
set project_data [list \
[list {} [clock format [clock seconds] -format {%D}] {}]\
[list [file tail [file normalize ~]] {} {}] \
@@ -2360,18 +2437,18 @@ namespace eval X {
[list $calc_radix $calc_angle {} {} {} {} {} {}] \
{} {} \
[list 0 [list {} {} 0 {}]] \
- ]
+ ]
# Create a new project file
if {[catch {
- set prj_file [open "$project_new_dir/$project_new_name.mcu8051ide" w 420]
+ set prj_file [open "$project_new_dir/$project_new_name.mcu8051ide" w 0640]
}]} then {
# Failed
tk_messageBox \
-parent . \
-type ok \
-icon error \
- -message [mc "Unable to write to file:\n\"%s\"" $project_new_dir/$project_new_name.mcu8051ide]
+ -message [mc "Unable to write to file:\n\"%s\"" "$project_new_dir/$project_new_name.mcu8051ide"]
set critical_procedure_in_progress 0
return
}
@@ -2385,12 +2462,13 @@ namespace eval X {
set projectDescriptor [regsub -all -- {\s} $project_new_name {-}]
regsub -all {[\\\/\.\,`\!@#\$%\^&:\;\|\*\"\(\)\[\]\{\}]} $projectDescriptor \
{_} projectDescriptor
+ set projectDescriptor "project_${projectDescriptor}"
if {[lsearch -exact -ascii ${X::openedProjects} $projectDescriptor] != -1} {
append project_new_name {(0)}
append projectDescriptor {_0}
- while 1 {
+ while {1} {
if {[lsearch -exact -ascii ${X::openedProjects} $projectDescriptor] == -1} {break}
regexp {\d+$} $projectDescriptor index
@@ -2425,11 +2503,14 @@ namespace eval X {
}
disaena_menu_toolbar_for_current_project
+ # set MCU name in status bar, kdb
+ .statusbarMCU configure -text $project_new_processor
+
set critical_procedure_in_progress 0
}
## Disable menu items and functions functions which are
- # avaliable only if there is at least one opened project
+ # available only if there is at least one opened project
# @return void
proc Lock_project_menu {} {
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
@@ -2446,7 +2527,7 @@ namespace eval X {
adjust_mm_and_tb_ext_editor
}
- ## Enable menu items and functions functions which are avaliable only if there
+ ## Enable menu items and functions functions which are available only if there
# is at least one opened project and create NoteBook for project tabs
# @return void
proc Unlock_project_menu {} {
@@ -2510,10 +2591,10 @@ namespace eval X {
KIFSD::FSD fsd \
-title [mc "Open project - MCU 8051 IDE"] \
-directory $defaultDirectory \
- -defaultmask 0 -multiple 0 -filetypes {
- {{MCU 8051 IDE project} {*.mcu8051ide} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "MCU 8051 IDE project"] {*.mcu8051ide} ] \
+ [list [mc "All files"] {*} ] \
+ ]
# Open the selected after press of OK button
fsd setokcmd {
@@ -2526,7 +2607,7 @@ namespace eval X {
-parent . \
-title [mc "Error - MCU 8051 IDE"] \
-message [mc "Unable to load file: %s" $filename]
- } {
+ } else {
${::X::actualProject} editor_procedure {} highlight_visible_area {}
::X::recent_files_add 0 $filename
}
@@ -2540,7 +2621,7 @@ namespace eval X {
}
## Retrieve project related data from object of the current project
- # @parm Bool all_info - All data (include todo list and such)
+ # @parm Bool all_info - All data (include to do list and such)
# @return void
proc Project_retrieve_data_from_application {all_info} {
variable actualProject ;# Object: Current project
@@ -2552,7 +2633,7 @@ namespace eval X {
variable project_edit_version ;# Project version
variable project_edit_date ;# Project date (last update)
variable project_edit_copyright ;# Copyright information
- variable project_edit_licence ;# Licence information
+ variable project_edit_license ;# License information
variable project_edit_authors ;# Project authors
variable project_edit_description ;# Project description
variable project_edit_main_file ;# Project main file
@@ -2572,7 +2653,7 @@ namespace eval X {
set project_edit_date [ $actualProject cget -P_information_date ]
set project_edit_authors [ $actualProject cget -G_information_authors ]
set project_edit_copyright [ $actualProject cget -G_information_copyright ]
- set project_edit_licence [ $actualProject cget -G_information_licence ]
+ set project_edit_license [ $actualProject cget -G_information_license ]
set project_edit_clock [ $actualProject cget -P_option_clock ]
set project_edit_description [ $actualProject cget -project_description ]
set project_new_processor [ $actualProject cget -P_option_mcu_type ]
@@ -2621,7 +2702,7 @@ namespace eval X {
variable project_edit_version ;# Project version
variable project_edit_date ;# Project date (last update)
variable project_edit_copyright ;# Copyright information
- variable project_edit_licence ;# Licence information
+ variable project_edit_license ;# License information
variable project_edit_authors ;# Project authors
variable project_edit_description ;# Project description
variable project_edit_clock ;# Default clock rate
@@ -2644,6 +2725,12 @@ namespace eval X {
if {$project_menu_locked} {return}
+ # Do not attempt to save a project with read only flag set
+ if {[$actualProject cget -S_flag_read_only]} {
+ puts "Read-only project, saving aborted."
+ return
+ }
+
# This is critical procedure
if {$critical_procedure_in_progress} {return}
set critical_procedure_in_progress 1
@@ -2668,7 +2755,7 @@ namespace eval X {
[list \
$project_edit_authors \
[Project::escape_curlies $project_edit_copyright] \
- [Project::escape_curlies $project_edit_licence]] \
+ [Project::escape_curlies $project_edit_license]] \
[list \
$project_new_processor \
$project_edit_clock \
@@ -2702,9 +2789,10 @@ namespace eval X {
# Save project definition file
if {[catch {
- set prj_file [open $filename w 420]
+ set prj_file [open $filename w 0640]
}]} then {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "IO Error"] \
@@ -2721,15 +2809,16 @@ namespace eval X {
}
## Invoke dialog "Edit project"
+ # @parm Bool choose_MCU_now=0 - Invoke MCU selection dialog right away and inore other config options ...
# @return void
- proc __proj_edit {} {
+ proc __proj_edit {{choose_MCU_now 0}} {
variable actualProject ;# Object: Current project
- variable avaliable_processors ;# List of supported processors
+ variable available_processors ;# List of supported processors
variable project_edit_version ;# Project version
variable project_edit_date ;# Project date (last update)
variable project_edit_copyright ;# Copyright information
- variable project_edit_licence ;# Licence information
+ variable project_edit_license ;# License information
variable project_edit_authors ;# Project authors
variable project_edit_description ;# Project description
variable project_edit_clock ;# Default clock rate
@@ -2760,7 +2849,7 @@ namespace eval X {
Project_retrieve_data_from_application 0
# Create dialog window
- set win [toplevel .project_edit -class {Edit project} -bg {#EEEEEE}]
+ set win [toplevel .project_edit -class {Edit project} -bg ${::COMMON_BG_COLOR}]
# Create main frames (top.left; top.right; bottom)
set top_frame [frame $win.top]
@@ -2768,7 +2857,7 @@ namespace eval X {
set top_left_frame [frame $top_frame.left]
set top_right_frame [frame $top_frame.right]
- ## GENERAL INFORMATION (version, date, authors, copyright, licence)
+ ## GENERAL INFORMATION (version, date, authors, copyright, license)
label $win.lb_general_info_label \
-compound left \
-text [mc "General information"] \
@@ -2826,24 +2915,24 @@ namespace eval X {
] -row 3 -column 2 -sticky we -columnspan 2
DynamicHelp::add $bframe.copyright_entry -text [mc "Copyright information"]
- # licence
- grid [Label $bframe.licence_label \
- -text [mc "Licence"] \
- -helptext [mc "Name of the licence"] \
+ # license
+ grid [Label $bframe.license_label \
+ -text [mc "License"] \
+ -helptext [mc "Name of the license"] \
] -row 4 -column 1 -sticky w
- grid [ttk::entry $bframe.licence_entry \
- -textvariable X::project_edit_licence \
+ grid [ttk::entry $bframe.license_entry \
+ -textvariable X::project_edit_license \
-validate key \
-validatecommand {::X::project_edit_validate %P} \
] -row 4 -column 2 -sticky we -columnspan 2
- DynamicHelp::add $bframe.licence_entry -text [mc "Name of the licence"]
+ DynamicHelp::add $bframe.license_entry -text [mc "Name of the license"]
# authors
set tframe [frame .project_edit.top.left.lb_general_info.tframe]
pack $tframe -fill both -expand 1 -padx 5
- pack [Label $tframe.label \
- -text [mc "Authors:"] \
- -helptext {List of project authors (one per line)} \
+ pack [Label $tframe.label \
+ -text [mc "Authors:"] \
+ -helptext [mc "List of project authors (one per line)"] \
] -anchor w
pack [frame $tframe.frame] -fill both -expand 1
@@ -2869,9 +2958,9 @@ namespace eval X {
set proc_frame_top1 [frame $lb_compiler.top1]
set proc_frame_middle [frame $lb_compiler.middle]
set proc_frame_middle_left [ttk::labelframe $proc_frame_middle.middle \
- -padding 5 -text [mc "XDATA"]]
+ -padding 5 -text [mc "External RAM (XDATA)"]]
set proc_frame_middle_right [ttk::labelframe $proc_frame_middle.right \
- -padding 5 -text [mc "XCODE"]]
+ -padding 5 -text [mc "External ROM/FLASH (XCODE)"]]
# MCU clock frequency
grid [Label $proc_frame_top1.clock_label \
@@ -2897,7 +2986,10 @@ namespace eval X {
-style Flat.TButton \
-takefocus 0 \
-image ::ICONS::16::locationbar_erase \
- -command {set ::X::project_edit_main_file {}} \
+ -command {
+ set ::X::project_edit_main_file {}
+ ::X::proj_edit_mf_validator {}
+ } \
-state disabled \
]
DynamicHelp::add $proc_frame_top1.clear_but -text [mc "Clear"]
@@ -2908,6 +3000,7 @@ namespace eval X {
-validatecommand {::X::proj_edit_mf_validator %P} \
-textvariable X::project_edit_main_file \
] -row 1 -column 3 -sticky we
+ proj_edit_mf_validator ${::X::project_edit_main_file}
DynamicHelp::add $proc_frame_top1.file_entry \
-text [mc "Project main file (e.g. main.c)\n(empty string means always compile current file)"]
grid [ttk::button $proc_frame_top1.file_select_but \
@@ -2921,7 +3014,7 @@ namespace eval X {
# Create components of top frame (Type: <ComboBox> <Button>)
pack [label $proc_frame_top0.lbl -text [mc "Type:"] -width 14 -anchor w] -side left
pack [ttk::combobox $proc_frame_top0.combo \
- -values $avaliable_processors \
+ -values $available_processors \
-state readonly \
-textvariable ::X::project_new_processor\
] -side left -fill x
@@ -2949,7 +3042,7 @@ namespace eval X {
set project_new_xd_scl [ttk::scale $proc_frame_left_btm.scale \
-orient horizontal \
-variable ::X::project_new_xdata \
- -from 0 -to 0xFFFF \
+ -from 0 -to 0x10000 \
-command "
set ::X::project_new_xdata \[expr {int(\${::X::project_new_xdata})}\]
$proc_frame_left_btm.spinbox selection range 0 end
@@ -2958,23 +3051,23 @@ namespace eval X {
DynamicHelp::add $project_new_xd_scl \
-text [mc "Size of external data memory"]
pack $project_new_xd_scl -fill x -side left -expand 1 -padx 2
- set project_new_xd_spb [spinbox $proc_frame_left_btm.spinbox \
- -textvariable ::X::project_new_xdata \
- -width 5 -from 0 -to 0xFFFF \
- -bg white -validate all \
- -vcmd {::SelectMCU::validate_xdata %P} \
- -command "$proc_frame_left_btm.spinbox selection range 0 end ;#" \
+ set project_new_xd_spb [ttk::spinbox $proc_frame_left_btm.spinbox \
+ -textvariable ::X::project_new_xdata \
+ -width 5 -from 0 -to 0x10000 \
+ -validate all \
+ -validatecommand {::SelectMCU::validate_xdata %P} \
]
DynamicHelp::add $project_new_xd_spb \
-text [mc "Size of external data memory"]
pack $project_new_xd_spb -side right -after $project_new_xd_scl
pack $proc_frame_left_btm -fill both -expand 1
+ proj_new_xdata_disena
# Create components of XCODE labelframe
set project_new_xc_chb [checkbutton $proc_frame_middle_right.checkbutton \
- -variable ::X::project_new_xcode_ena \
- -text [mc "Enable"] \
- -command ::X::proj_new_xcode_disena \
+ -variable ::X::project_new_xcode_ena \
+ -text [mc "Enable"] \
+ -command ::X::proj_new_xcode_disena \
]
pack $project_new_xc_chb -anchor w
DynamicHelp::add $proc_frame_middle_right.checkbutton \
@@ -2983,7 +3076,7 @@ namespace eval X {
set project_new_xc_scl [ttk::scale $proc_frame_right_btm.scale \
-orient horizontal \
-variable ::X::project_new_xcode \
- -from 0 -to 0xFFFF \
+ -from 0 -to 0x10000 \
-command "
set ::X::project_new_xcode \[expr {int(\${::X::project_new_xcode})}\]
$proc_frame_right_btm.spinbox selection range 0 end
@@ -2992,17 +3085,17 @@ namespace eval X {
DynamicHelp::add $project_new_xc_scl \
-text [mc "Amount of total program memory minus internal program memory"]
pack $project_new_xc_scl -fill x -side left -expand 1 -padx 2
- set project_new_xc_spb [spinbox $proc_frame_right_btm.spinbox \
- -textvariable ::X::project_new_xcode \
- -width 5 -from 0 -to 0xFFFF \
- -bg white -validate all \
- -vcmd {::X::proj_new_validate_xcode %P} \
- -command "$proc_frame_right_btm.spinbox selection range 0 end ;#" \
+ set project_new_xc_spb [ttk::spinbox $proc_frame_right_btm.spinbox \
+ -textvariable ::X::project_new_xcode \
+ -width 5 -from 0 -to 0x10000 \
+ -validate all \
+ -validatecommand {::X::proj_new_validate_xcode %P} \
]
DynamicHelp::add $project_new_xc_spb \
-text [mc "Amount of total program memory minus internal program memory"]
pack $project_new_xc_spb -side right -after $project_new_xc_scl
pack $proc_frame_right_btm -fill both -expand 1
+ proj_new_xcode_disena
pack $proc_frame_top0 -anchor w -pady 5 -padx 10
pack $proc_frame_top1 -anchor w -pady 5 -padx 10
@@ -3011,8 +3104,13 @@ namespace eval X {
pack $proc_frame_middle -fill both -expand 1 -pady 5
pack $lb_compiler -fill both -expand 1
- # Adjust XDATA & XCODE controls
+ # Adjust XDATA & XCODE controls - TODO why is this needed here?
+ # editor window has just been created, user hasn't made any selections yet
+ # meaning that mcu has not changed
proj_new_mcu_changed
+ # Martin: Oh yes, now I remeber :) proj_new_mcu_changed has to be called here in order to ensure that the
+ # scale widgets don't offer values out of range. Try to remove the call and then invoke the project
+ # editing dialog and you will see.
## PROJECT DESCRIPTION
label $win.lb_desc_label \
@@ -3064,6 +3162,15 @@ namespace eval X {
X::project_edit_CANCEL
}
wm transient $win .
+
+ if {$choose_MCU_now} {
+ wm withdraw $win
+ proj_new_select_mcu .
+ project_edit_OK
+ return
+ }
+
+ update
catch {grab $win}
raise $win
tkwait window $win
@@ -3077,7 +3184,7 @@ namespace eval X {
variable project_edit_main_file_clr_but ;# Widget: Project main file clear button
if {[string length $string]} {
$project_edit_main_file_clr_but configure -state normal
- } {
+ } else {
$project_edit_main_file_clr_but configure -state disabled
}
return 1
@@ -3097,7 +3204,7 @@ namespace eval X {
set defaultmask 1
} elseif {$ext == {.h}} {
set defaultmask 2
- } {
+ } else {
set defaultmask 3
}
catch {delete object fsd}
@@ -3117,6 +3224,7 @@ namespace eval X {
set ::X::project_edit_main_file \
[string replace $::X::project_edit_main_file \
0 [string length [$::X::actualProject cget -projectPath]]]
+ ::X::proj_edit_mf_validator ${::X::project_edit_main_file}
}
}
fsd activate
@@ -3129,7 +3237,7 @@ namespace eval X {
proc project_edit_validate {string} {
if {[string length $string] > 40} {
return 0
- } {
+ } else {
return 1
}
}
@@ -3148,19 +3256,19 @@ namespace eval X {
# @parm String number - String to validate
# @return Bool - result
proc project_edit_CLOCK_validate {number} {
- if {![regexp {^\d*$} $number]} {return 0}
+ if {![regexp {^\d+(\.\d*)?$} $number]} {return 0}
if {$number > 99999} {return 0}
return 1
}
- ## Cancel dialog "Edit project" -- axiliary procedure for '__proj_edit'
+ ## Cancel dialog "Edit project" -- auxiliary procedure for '__proj_edit'
# @return void
proc project_edit_CANCEL {} {
grab release .project_edit
destroy .project_edit
}
- ## Save project values -- axiliary procedure for '__proj_edit'
+ ## Save project values -- auxiliary procedure for '__proj_edit'
# @return void
proc project_edit_OK {} {
variable actualProject ;# Object: Current project
@@ -3169,7 +3277,7 @@ namespace eval X {
variable project_edit_version ;# Project version
variable project_edit_date ;# Project date (last update)
variable project_edit_copyright ;# Copyright information
- variable project_edit_licence ;# Licence information
+ variable project_edit_license ;# License information
variable project_edit_clock ;# Default clock rate
variable project_edit_main_file ;# Project main file
variable project_new_processor ;# Processor type (e.g. "AT89C2051")
@@ -3178,6 +3286,7 @@ namespace eval X {
variable project_new_xdata ;# Int: Amount of XDATA memory
variable project_new_xcode ;# Int: Amount of XCODE memory
variable project_new_xc_spb ;# Widget: XCODE spinbox
+ variable project_edit_defaults ;# Some default project values
variable projectdetails_last_project {} ;# Project object of the last project details window
@@ -3189,10 +3298,14 @@ namespace eval X {
set project_new_xcode 0
}
+ # Set MCU name in status bar, kdb
+ .statusbarMCU configure -text $project_new_processor
+
# Adjust values
if {$project_edit_clock == {}} {
set project_edit_clock [lindex $project_edit_defaults {1 1}]
}
+ set project_edit_clock [string trimright $project_edit_clock {.}]
set project_new_xdata [expr {int($project_new_xdata)}]
set project_new_xcode [expr {int($project_new_xcode)}]
@@ -3204,15 +3317,16 @@ namespace eval X {
# Change object variables
foreach parm {
P_option_mcu_xdata P_option_mcu_xcode P_information_version
- P_information_date G_information_licence G_information_copyright
+ P_information_date G_information_license G_information_copyright
P_option_clock P_option_mcu_type P_option_main_file
} \
value {
project_new_xdata project_new_xcode project_edit_version
- project_edit_date project_edit_licence project_edit_copyright
+ project_edit_date project_edit_license project_edit_copyright
project_edit_clock project_new_processor project_edit_main_file
- } {
- $actualProject configure -$parm [subst "\$$value"]
+ } \
+ {
+ $actualProject configure -$parm [subst -nocommands "\$$value"]
}
$actualProject Simulator_set_clock $project_edit_clock
$actualProject configure -project_description \
@@ -3220,7 +3334,7 @@ namespace eval X {
$actualProject configure -G_information_authors \
[.project_edit.top.left.lb_general_info.tframe.frame.text get 1.0 end-1c]
- ## Adjust simulator control panel, register watches and hexeditors
+ ## Adjust simulator control panel, register watches and hex editors
# Hex editors
close_hexedit eram $actualProject
close_hexedit eeprom $actualProject
@@ -3232,7 +3346,7 @@ namespace eval X {
if {$xcode_prev != $project_new_xcode} {
close_hexedit code $actualProject
$actualProject simulator_resize_code_memory \
- [expr {$project_new_xcode + 0xFFFF - [$project_new_xc_spb cget -to]}]
+ [expr {$project_new_xcode + 0x10000 - [$project_new_xc_spb cget -to]}]
}
# Simulator control panel and register watches
if {$proc_prev != $project_new_processor} {
@@ -3273,10 +3387,11 @@ namespace eval X {
$actualProject configure -P_option_mcu_type $new_processor
$actualProject configure -procData \
[SelectMCU::get_processor_details $new_processor]
- $actualProject refresh_project_avaliable_SFR
+ $actualProject refresh_project_available_SFR
$actualProject stack_monitor_monitor_close
$actualProject interrupt_monitor_close
+ $actualProject uart_monitor_close
$actualProject simulator_initialize_mcu
$actualProject SimGUI_clean_up
$actualProject simulator_itialize_simulator_control_panel
@@ -3288,6 +3403,8 @@ namespace eval X {
$actualProject rightPanel_watch_disable
$actualProject sfr_watches_commit_new_sfr_set
$actualProject pale_MCU_changed
+ $actualProject stopwatch_clear_all C
+ $actualProject stopwatch_clear_all O
if {$was_enabled} {
__initiate_sim
@@ -3349,7 +3466,7 @@ namespace eval X {
if {$response == {yes}} {
close_project
return 1
- } {
+ } else {
return 0
}
}
@@ -3366,6 +3483,9 @@ namespace eval X {
variable simulator_enabled ;# List of booleans: Simulator engaged
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
+ # Make sure that there are no help windows visible
+ remove_all_help_windows
+
# This function is critical
if {$critical_procedure_in_progress} {return}
set critical_procedure_in_progress 1
@@ -3394,22 +3514,30 @@ namespace eval X {
# Raise nex tab or disable project menu and procedures
if {[llength $openedProjects] > 0} {
- set actualProject [lindex $openedProjects 0]
- .mainFrame.mainNB raise [string trimleft $actualProject {:}]
- } {
+ set actualProjectIdx 0
+ set actualProject [lindex $openedProjects $actualProjectIdx]
+ ${::main_nb} raise [string trimleft $actualProject {:}]
+ } else {
set project_menu_locked 1
Lock_project_menu
}
set critical_procedure_in_progress 0
+
+ update
+ foreach project $openedProjects {
+ $project bottomNB_redraw_pane
+ }
}
## Compile current file
- # @parm Bool = 0 - Force compilation -- ignore running critical procedure
- # @parm Bool = 0 - Start simulator after successful compilation
- # @parm Bool = 0 - Compile current file only (not the main file)
+ # @parm Bool force=0 - Force compilation -- ignore running critical procedure
+ # @parm Bool compilation_start_simulator=0 - Start simulator after successful compilation
+ # @parm Bool compile_this_file_only=0 - Compile current file only (not the main file)
# @return Bool - result or {}
- proc __compile args {
+ proc __compile {{force 0} {_compilation_start_simulator 0} {_compile_this_file_only 0}} {
+ variable simulator_enabled ;# List of booleans: Simulator engaged
+ variable actualProjectIdx ;# Index of the current project in $openedProjects
variable compilation_successfull ;# Bool: Compilation successfull
variable actualProject ;# Object: Current project
variable compilation_in_progress ;# Bool: Compiler engaged
@@ -3420,21 +3548,9 @@ namespace eval X {
variable compile_this_file_only ;# Bool: Compile the current file only
variable compilation_mess_project ;# Object: Project related to running compilation
- # Parse input arguments
- if {[lindex $args 0] == 1} {
- set force 1
- } {
- set force 0
- }
- if {[lindex $args 1] == 1} {
- set compilation_start_simulator 1
- } {
- set compilation_start_simulator 0
- }
- if {[lindex $args 2] == 1} {
- set compile_this_file_only 1
- } {
- set compile_this_file_only 0
+ # It is not allowed to compile the source code while simulator is engaged
+ if {[lindex $simulator_enabled $actualProjectIdx]} {
+ return {}
}
if {$project_menu_locked} {return}
@@ -3449,6 +3565,9 @@ namespace eval X {
return 0
}
+ set compile_this_file_only $_compile_this_file_only
+ set compilation_start_simulator $_compilation_start_simulator
+
# Compilation started
set compilation_mess_project $actualProject
set compilation_successfull 1
@@ -3466,7 +3585,7 @@ namespace eval X {
# Determinate name of file to compile
if {$compile_this_file_only} {
set input_file {}
- } {
+ } else {
set input_file [list \
[$actualProject cget -projectPath] \
[$actualProject cget -P_option_main_file] \
@@ -3475,7 +3594,7 @@ namespace eval X {
if {[lindex $input_file 1] == {}} {
set input_file [$actualProject editor_procedure {} getFileName {}]
set language [$actualProject editor_procedure {} get_language {}]
- } {
+ } else {
set ext [string trimleft [file extension [lindex $input_file 1]] {.}]
if {$ext == {c} || $ext == {h} || $ext == {cxx} || $ext == {cpp} || $ext == {cc}} {
set language 1
@@ -3491,7 +3610,7 @@ namespace eval X {
if {[regexp {\.[^\.]*$} $input_file_name input_file_extension]} {
regsub {\.[^\.]*$} $input_file_name {} input_file_name
set input_file_extension [string range $input_file_extension 1 end]
- } {
+ } else {
set input_file_extension {}
}
# Asjust file extension
@@ -3521,16 +3640,16 @@ namespace eval X {
## C language
if {$language == 1} {
- if {!${::PROGRAM_AVALIABLE(sdcc)} && !${::PROGRAM_AVALIABLE(sdcc-sdcc)}} {
+ if {!${::PROGRAM_AVAILABLE(sdcc)} && !${::PROGRAM_AVAILABLE(sdcc-sdcc)}} {
tk_messageBox \
-parent . \
-type ok \
-icon warning \
-title [mc "Compiler not found"] \
-message [mc "Unable to find sdcc, please install sdcc and restart MCU 8051 IDE"]
- } {
+ } else {
# Start compiler
- set compiler_pid [::ExternalCompiler::compile_C \
+ set compiler_pid [::ExternalCompiler::compile_C \
$cur_dir $input_file_name.$input_file_extension \
$iram_size $xram_size $code_size \
]
@@ -3539,26 +3658,26 @@ namespace eval X {
## Assembly language
} else {
- # Check if the choosen assembler is avaliable in the system
- set avaliable 0
+ # Check if the choosen assembler is available in the system
+ set available 0
switch -- $::ExternalCompiler::selected_assembler {
0 { ;# Native assembler
- set avaliable 1
+ set available 1
set assembler_name [mc "MCU 8051 IDE Native assembler"]
- set assembler_cmd {mcu8051ide --compile}
+ set assembler_cmd {mcu8051ide --assemble}
}
1 { ;# ASEM-51
- set avaliable ${::PROGRAM_AVALIABLE(asem)}
+ set available ${::PROGRAM_AVAILABLE(asem)}
set assembler_name "ASEM-51"
set assembler_cmd {asem}
}
2 { ;# ASL
- set avaliable ${::PROGRAM_AVALIABLE(asl)}
+ set available ${::PROGRAM_AVAILABLE(asl)}
set assembler_name "ASL"
set assembler_cmd {asl}
}
3 { ;# AS31
- set avaliable ${::PROGRAM_AVALIABLE(as31)}
+ set available ${::PROGRAM_AVAILABLE(as31)}
set assembler_name "AS31"
set assembler_cmd {as31}
}
@@ -3566,7 +3685,7 @@ namespace eval X {
error "Unknown internal error -- Invalid ID of the selected assembler"
}
}
- if {!$avaliable} {
+ if {!$available} {
tk_messageBox \
-parent . \
-type ok \
@@ -3587,7 +3706,7 @@ namespace eval X {
set ::Compiler::Settings::xram_size $xram_size
set ::Compiler::Settings::code_size $code_size
set ::PreProcessor::check_sfr_usage 1
- set ::PreProcessor::avaliable_SFR [string tolower [$actualProject cget -avaliable_SFR]]
+ set ::PreProcessor::available_SFR [string tolower [$actualProject cget -available_SFR]]
# Perform code compilation
if {[catch {
@@ -3602,7 +3721,7 @@ namespace eval X {
-icon error \
-type ok \
-title [mc "Compiler crash - MCU 8051 IDE"] \
- -message [mc "Compiler crased, we are terribly sorry about that.\n\nPlease report this bug via project web or mail to author and please don't forget to include source code on which this error occured."]
+ -message [mc "Compiler crashed, we are terribly sorry about that.\n\nPlease report this bug via project web or mail to author and please don't forget to include source code on which this error occurred."]
}
::Compiler::free_resources
set Compiler::Settings::ABORT_VARIABLE 0
@@ -3643,11 +3762,16 @@ namespace eval X {
# @parm String fail_callback - Procedure to call upon failed compilation
# @return void
proc compile_if_nessesary_and_callback {success_callback fail_callback} {
+ variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
variable actualProject ;# Object: Current project
variable compilation_in_progress ;# Bool: Compiler engaged
variable compilation_success_callback ;# String: Indented for HW plugins
variable compilation_fail_callback ;# String: Indented for HW plugins
+ if {$project_menu_locked} {
+ return
+ }
+
set compilation_success_callback $success_callback
set compilation_fail_callback $fail_callback
@@ -3660,7 +3784,7 @@ namespace eval X {
set full_file_name [$actualProject editor_procedure {} getFileName {}]
set language [$actualProject editor_procedure {} get_language {}]
set relative_name [lindex $full_file_name 1]
- } {
+ } else {
set ext [string trimleft [file extension $relative_name] {.}]
if {$ext == {c} || $ext == {h} || $ext == {cxx} || $ext == {cpp} || $ext == {cc}} {
set language 1
@@ -3674,7 +3798,7 @@ namespace eval X {
set full_file_name [file rootname $full_file_name]
if {$language != 1} {
append full_file_name {.adf}
- } {
+ } else {
append full_file_name {.hashes}
}
@@ -3706,7 +3830,7 @@ namespace eval X {
}
}]} then {
- if {[verify_md5_hashes 1 $expected_md5s]} {
+ if {[verify_md5_hashes 1 $expected_md5s [file dirname $full_file_name]]} {
__compile
return
}
@@ -3739,7 +3863,7 @@ namespace eval X {
set compilation_fail_callback {}
set compilation_success_callback {}
}
- } {
+ } else {
Sbar [mc "Compilation failed"]
if {$compilation_fail_callback != {}} {
eval "$compilation_fail_callback"
@@ -3767,9 +3891,9 @@ namespace eval X {
"\{"] \
0 0]
- # Backspace charactes
+ # Backspace characters
set idx 0
- while 1 {
+ while {1} {
set idx [string first "\b" $args $idx]
if {$idx == -1} {
break
@@ -3810,6 +3934,7 @@ namespace eval X {
set actualProjectIdx $actualProjectIdx_org
} elseif {$compilation_start_simulator && !$compilation_successfull} {
tk_messageBox \
+ -parent . \
-icon error \
-type ok \
-title [mc "Compilation failed"] \
@@ -3829,18 +3954,25 @@ namespace eval X {
if {!$::MICROSOFT_WINDOWS} { ;# There is no kill command on Microsoft Windows
# Kill doxygen
- if {$doxygen_pid} {
+ if {${doxygen_pid} != {}} {
foreach pid $doxygen_pid {
+ if {$pid == [pid] || $pid == 0} {
+ continue
+ }
catch {
- exec -- kill -9 $pid &
+ exec -- kill -9 $pid
}
}
+ }
- # Kill SDCC
- } elseif {${compiler_pid} != {} && ${compiler_pid} != 0} {
+ # Kill external compiler
+ if {${compiler_pid} != {}} {
foreach pid $compiler_pid {
+ if {$pid == [pid] || $pid == 0} {
+ continue
+ }
catch {
- exec -- kill -9 $pid &
+ exec -- kill -9 $pid
}
}
}
@@ -3907,12 +4039,17 @@ namespace eval X {
## Append text to messages text (bottom panel - tab "Messages")
# @parm String text - Text to append
- # @return Bool - True if error occured
+ # @return Bool - True if error occurred
proc messages_text_append {text} {
variable actualProject ;# Object: Current project
variable compilation_mess_project ;# Object: Project related to running compilation
+ variable compilation_successfull ;# Bool: Compilation successfull
- return [$compilation_mess_project messages_text_append $text]
+ set result [$compilation_mess_project messages_text_append $text]
+ if {$result} {
+ set compilation_successfull 0
+ }
+ return $result
}
## Copy selected text in messages text to clipboard (bottom panel - tab "Messages")
@@ -3982,11 +4119,12 @@ namespace eval X {
[$actualProject editor_procedure {} getLinesCount {}] == 1
&&
[$actualProject editor_procedure {} getLineContent 1] == {}
- } {
+ } then {
tk_messageBox \
+ -parent . \
-type ok \
-icon warning \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "This editor seems to be empty"]
return
}
@@ -4000,13 +4138,13 @@ namespace eval X {
incr max
# Create diwlog window
- set win [toplevel .exportToX_dialog -class [mc "Export dialog"] -bg {#EEEEEE}]
+ set win [toplevel .exportToX_dialog -class [mc "Export dialog"] -bg ${::COMMON_BG_COLOR}]
wm withdraw $win
# Label and progress bar
set main_frame [frame $win.main_frame]
pack [label $main_frame.header \
- -text [mc "Finishing highlight ..."] \
+ -text [mc "Finishing syntax highlight ..."] \
] -pady 10 -padx 20 -anchor w
pack [ttk::progressbar $main_frame.progress_bar \
-maximum $max \
@@ -4022,20 +4160,20 @@ namespace eval X {
-command "X::exportToX_abort $targetType" \
-image ::ICONS::16::cancel \
-compound left \
- ]
+ ] -pady 5
# Determinate target file name
set file [$actualProject editor_procedure {} getFileName {}]
set filename [lindex $file 1]
if {[lindex $file 0] != {}} {
set dir [lindex $file 0]
- } {
+ } else {
set dir [$actualProject cget -projectPath]
}
regsub {\.[^\.]*$} $filename {} filename
if {$targetType == "-html"} {
set suffix {html}
- } {
+ } else {
set suffix {tex}
}
append filename {.} $suffix
@@ -4043,9 +4181,10 @@ namespace eval X {
KIFSD::FSD fsd \
-initialfile $filename -directory $dir \
-title [mc "Export as %s - MCU 8051 IDE" [lindex $args 1]] \
- -defaultmask 0 -multiple 0 -filetypes [subst "
- {{[mc {[string toupper $suffix] file}]} {*.$suffix}}
- {{[mc {All files}]} {*}}"]
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc [string toupper $suffix] {file}] "*.$suffix"] \
+ [list [mc "All files"] {*}] \
+ ]
fsd setokcmd {
set ::X::fsd_result [X::fsd get]
}
@@ -4065,6 +4204,7 @@ namespace eval X {
if {[file exists $filename] && [file isfile $filename]} {
if {![file writable $filename]} {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "Permission denied"] \
@@ -4080,7 +4220,8 @@ namespace eval X {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $filename]]
] != {yes}
- } {
+ } then {
+ exportToX_abort $targetType
return
}
# Create a backup file
@@ -4091,9 +4232,10 @@ namespace eval X {
# Open target file
if {[catch {
- set file [open $filename w 420]
- }]} {
+ set file [open $filename w 0640]
+ }]} then {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "Permission denied"] \
@@ -4107,7 +4249,7 @@ namespace eval X {
wm iconphoto $win ::ICONS::16::html
wm deiconify $win
wm title $win [mc "[lindex $args 1] - MCU 8051 IDE"]
- wm minsize $win 450 70
+ wm minsize $win 450 110
wm protocol $win WM_DELETE_WINDOW {
exportToX_abort
}
@@ -4130,9 +4272,9 @@ namespace eval X {
# Export and write data
if {$targetType == "-html"} {
- puts -nonewline $file [$actualProject editor_procedure {} getDataAsXHTML {}]
+ $actualProject editor_procedure {} getDataAsXHTML $file
} elseif {$targetType == "-latex"} {
- puts -nonewline $file [$actualProject editor_procedure {} getDataAsLaTeX {}]
+ $actualProject editor_procedure {} getDataAsLaTeX $file
} else {
error "Unknown argument: $targetType\n\tpossible vaues are: -html -latex"
}
@@ -4140,7 +4282,7 @@ namespace eval X {
exportToX_abort $targetType
# Show result
- Sbar [mc "Expoted data saved to %s" $filename]
+ Sbar [mc "Exported data saved to %s" $filename]
}
## Abort export content of the current editor as XHTML/LaTeX
@@ -4181,15 +4323,16 @@ namespace eval X {
# - Save all projects
# - Save session file
# - Exit
- # @parm Bool = 0 - Print message "Exitong on user request"
+ # @parm Bool do_not_print_exit_message=0 - Print message "Exiting on user request"
+ # @parm Bool force=0 - Do not allow user to cancel the request
# @return void
- proc __exit args {
+ proc __exit {{do_not_print_exit_message 0} {force 0}} {
variable openedProjects ;# List of opened projects (Object references)
variable actualProject ;# Object: Current project
variable compilation_in_progress ;# Bool: Compiler engaged
variable procedure_exit_in_progress ;# Bool: proc "__exit" in progress
variable unsaved_projects ;# List: List of project object marked as "unsaved"
- variable eightsegment_editors ;# List: All 8-segment LED display editors invoked
+ variable eightsegment_editors ;# List: All 8-Segment LED display editors invoked
variable spec_calc_objects ;# List: All special calculator objects
variable rs232debugger_objects ;# List: All "RS232 debugger" objects
@@ -4204,13 +4347,6 @@ namespace eval X {
}
set procedure_exit_in_progress 1
- # Parse arguments
- if {[lindex $args 0] == 1} {
- set do_not_print_exit_message 1
- } {
- set do_not_print_exit_message 0
- }
-
# Ask hardware whether it's ready for exit
foreach project $openedProjects {
if {![$project hw_manager_comfirm_exit]} {
@@ -4234,25 +4370,26 @@ namespace eval X {
set unsaved_projects {}
foreach project $openedProjects {
foreach editor [$project cget -editors] {
- if {[$editor cget -modified]} {
- lappend unsaved_projects "{$project} {$editor}"
+ catch {
+ if {[$editor cget -modified]} {
+ lappend unsaved_projects [list $project $editor]
+ }
}
}
}
# Ask user for saving unsaved files -- use proc 'shutdown_dialog'
if {[llength $unsaved_projects] != 0} {
- switch -- [shutdown_dialog] {
+ switch -- [shutdown_dialog $force] {
0 { ;# SAVESELECTED
set i 0
foreach unsaved $unsaved_projects {
- set bool [subst "\$::unsavedfile$i"]
+ set bool [subst -nocommands "\$::unsavedfile$i"]
if {$bool == 1} {
[lindex [lindex $unsaved_projects $i] 1] save
}
incr i
}
-
}
1 { ;# SAVEALL
set last_project {}
@@ -4272,10 +4409,22 @@ namespace eval X {
}
}
+ # Stop watching for modifications in designaded files
+ FSnotifications::stop
+
if {!$do_not_print_exit_message} {
puts [mc "\nExiting program on user request ..."]
}
+ # Save session
+ if {[catch {
+ save_session
+ } result]} then {
+ puts stderr [mc "An error occurred when saving the last session"]
+ puts stderr $result
+ }
+
+
# Withdraw main window
wm withdraw .
# Withdraw all PALE windows
@@ -4284,23 +4433,20 @@ namespace eval X {
}
update
- # Save session
- if {[catch {
- save_session
- } result]} then {
- puts stderr [mc "An error occured when saving the last session"]
- puts stderr $result
- }
-
# Save all projects
foreach project $openedProjects {
$project kill_childern
set actualProject $project
+ puts [mc "Saving project: %s" $project]
__proj_save
}
- puts [mc "Program terminated"]
+ # Kill the spell checker used by the editor
+ if {!$::MICROSOFT_WINDOWS} {
+ ::Editor::kill_spellchecker_process
+ }
+ puts [mc "Program terminated"]
exit
}
@@ -4327,7 +4473,7 @@ namespace eval X {
variable project_recent_files ;# List: recently opened projects
variable vhw_recent_files ;# List: recently opened Virtual HW files
- variable base_convertors ;# List: All base convertor objects
+ variable base_converters ;# List: All base converter objects
variable change_letter_case_options ;# Options (which fields should be adjusted)
@@ -4338,7 +4484,7 @@ namespace eval X {
-type ok \
-icon error \
-title [mc "Permission denied"] \
- -message [mc "Unable to save running config"]
+ -message [mc "Unable to save running configuration"]
return 0
}
}
@@ -4394,36 +4540,46 @@ namespace eval X {
RS232_DEBUGGER {${::RS232Debugger::config_list}}
STACK_MON_GEOMETRY {${::StackMonitor::geometry}}
STACK_MON_COLLAPSED {${::StackMonitor::collapsed}}
+ SPELL_CHECK_ENABLED {${::Editor::spellchecker_enabled}}
+ SPELL_CHECK_DICTIONARY {${::Editor::spellchecker_dictionary}}
+ UART_MON_GEOMETRY {${::UARTMonitor::geometry}}
+ SHOW_PALE_WARN {${::Graph::show_sim_per_warn}}
}]
set ::CONFIG(LETTER_CASE) {}
for {set i 0} {$i < 21} {incr i} {
lappend ::CONFIG(LETTER_CASE) $change_letter_case_options($i)
}
- set ::CONFIG(BASE_CONVERTORS) {}
- foreach obj $base_convertors {
- lappend ::CONFIG(BASE_CONVERTORS) [$obj get_config]
+ set ::CONFIG(BASE_CONVERTERS) {}
+ foreach obj $base_converters {
+ lappend ::CONFIG(BASE_CONVERTERS) [$obj get_config]
}
# Open session file
if {[catch {
- set file [open $session_file w 420]
+ set file [open $session_file w 0640]
}]} then {
- tk_messageBox -parent . -type ok -icon error \
- -title [mc "Access denied"] \
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -icon error \
+ -title [mc "Access denied"] \
-message [mc "Unable to write to file: \"%s\"" $session_file]
return
}
# Write session file
- puts $file "# ${::APPNAME} [clock format [clock seconds] -format {%T %D}]"
- puts $file "# Please do not modify this file manualy.\n"
+ puts $file "# ${::APPNAME}"
+ puts $file "# Please do not modify this file manually.\n"
puts $file "# booleans"
if {$::MICROSOFT_WINDOWS} {
- # There is no such thing on Windows OS
- puts $file "WINDOW_ZOOMED = \"0\""
- } {
- puts $file "WINDOW_ZOOMED = \"[wm attributes . -zoomed]\""
+ if {[wm state .] == {zoomed}} {
+ puts $file "WINDOW_ZOOMED = 1"
+ } else {
+ puts $file "WINDOW_ZOOMED = 0"
+ }
+ } else {
+ puts $file "WINDOW_ZOOMED = [wm attributes . -zoomed]"
}
puts $file "LINE_NUMBERS = $::CONFIG(LINE_NUMBERS)"
puts $file "ICON_BORDER = $::CONFIG(ICON_BORDER)"
@@ -4436,6 +4592,8 @@ namespace eval X {
puts $file "ASK_ON_FILE_OPEN = $::CONFIG(ASK_ON_FILE_OPEN)"
puts $file "SHOW_EDITOR_TAB_BAR = $::CONFIG(SHOW_EDITOR_TAB_BAR)"
puts $file "STACK_MON_COLLAPSED = $::CONFIG(STACK_MON_COLLAPSED)"
+ puts $file "SPELL_CHECK_ENABLED = $::CONFIG(SPELL_CHECK_ENABLED)"
+ puts $file "SHOW_PALE_WARN = $::CONFIG(SHOW_PALE_WARN)"
puts $file "\n# integers"
puts $file "LEFT_PANEL_SIZE = $::CONFIG(LEFT_PANEL_SIZE)"
puts $file "RIGHT_PANEL_SIZE = $::CONFIG(RIGHT_PANEL_SIZE)"
@@ -4450,6 +4608,7 @@ namespace eval X {
puts $file "FILE_RECENT_FILES = \"$::CONFIG(FILE_RECENT_FILES)\""
puts $file "PROJECT_RECENT_FILES = \"$::CONFIG(PROJECT_RECENT_FILES)\""
puts $file "VHW_RECENT_FILES = \"$::CONFIG(VHW_RECENT_FILES)\""
+ puts $file "SPELL_CHECK_DICTIONARY = \"$::CONFIG(SPELL_CHECK_DICTIONARY)\""
puts $file "\n# lists"
puts $file "CLEANUP_OPTIONS = \"[regsub -all {\s+} $::CONFIG(CLEANUP_OPTIONS) { }]\""
puts $file "FIND_OPTIONS = \"$::CONFIG(FIND_OPTIONS)\""
@@ -4467,7 +4626,7 @@ namespace eval X {
puts $file "REGWATCHES_CONFIG = \"$::CONFIG(REGWATCHES_CONFIG)\""
puts $file "FILE_NOTES = \"$::CONFIG(FILE_NOTES)\""
puts $file "EIGHT_SEG_EDITOR = \"$::CONFIG(EIGHT_SEG_EDITOR)\""
- puts $file "BASE_CONVERTORS = \"$::CONFIG(BASE_CONVERTORS)\""
+ puts $file "BASE_CONVERTERS = \"$::CONFIG(BASE_CONVERTERS)\""
puts $file "SPEC_CALC = \"$::CONFIG(SPEC_CALC)\""
puts $file "RS232_DEBUGGER = \"$::CONFIG(RS232_DEBUGGER)\""
puts $file "\n# other"
@@ -4475,12 +4634,11 @@ namespace eval X {
puts $file "ACTIVE_PROJECT = $actualProjectIdx"
puts $file "INTR_MON_GEOMETRY = \"$::CONFIG(INTR_MON_GEOMETRY)\""
puts $file "STACK_MON_GEOMETRY = \"$::CONFIG(STACK_MON_GEOMETRY)\""
+ puts $file "UART_MON_GEOMETRY = \"$::CONFIG(UART_MON_GEOMETRY)\""
- set projects {}
- if {[winfo exists .mainFrame.mainNB]} {
- set projects_len [llength [.mainFrame.mainNB pages]]
- for {set i 0} {$i < $projects_len} {incr i} {
- set prj [.mainFrame.mainNB pages $i]
+ set projects [list]
+ foreach prj $openedProjects {
+ if {![$prj cget -S_flag_read_only]} { ;# Do not reopen read-only projects
lappend projects [file join \
[$prj cget -projectPath]\
[$prj cget -projectFile]\
@@ -4548,7 +4706,9 @@ namespace eval X {
LETTER_CASE {- - - - - - - - - - - - - - - - - - - - -}
KIFSD_CONFIG {}
HEXEDIT_CONFIG {+0+0 hex 0 left}
- INTR_MON_GEOMETRY {780x250}
+ INTR_MON_GEOMETRY {850x270}
+ UART_MON_GEOMETRY {850x270}
+ SHOW_PALE_WARN 1
SUBP_MON_CONFIG {1 1}
OPEN_WITH_DLG {}
FS_BROWSER_MASK {*.asm}
@@ -4562,20 +4722,32 @@ namespace eval X {
FILE_RECENT_FILES {}
PROJECT_RECENT_FILES {}
VHW_RECENT_FILES {}
- REGWATCHES_CONFIG {1 1}
+ REGWATCHES_CONFIG {1 1 0}
FILE_NOTES {1 200}
EIGHT_SEG_EDITOR {
{0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7}
{0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0}
}
- BASE_CONVERTORS {}
+ BASE_CONVERTERS {}
SPEC_CALC {}
ASK_ON_FILE_OPEN 1
SHOW_EDITOR_TAB_BAR 1
RS232_DEBUGGER {9600 n 8 1 1 0 {} {} 0 0}
STACK_MON_GEOMETRY {}
STACK_MON_COLLAPSED 1
+ SPELL_CHECK_ENABLED 1
+ SPELL_CHECK_DICTIONARY {}
}
+
+ # Set default dictionary for the spell checking
+ set ::CONFIG(SPELL_CHECK_DICTIONARY) [join \
+ [list \
+ [string tolower [lindex [split [::msgcat::mclocale] {_}] 0]] \
+ [string toupper [lindex [split [::msgcat::mclocale] {_}] 1]] \
+ ] \
+ {_} \
+ ]
+
if {$::MICROSOFT_WINDOWS} {
lset ::CONFIG(FIND_IN_FILES_CONFIG) 3 ${::env(USERPROFILE)}
}
@@ -4607,9 +4779,11 @@ namespace eval X {
STOPWATCH_CONFIG C_VARS_VIEW_CONF BITMAP_CONFIG
HW_MANAGER_CONFIG FILE_RECENT_FILES PROJECT_RECENT_FILES
REGWATCHES_CONFIG EIGHT_SEG_EDITOR VHW_RECENT_FILES
- BASE_CONVERTORS WINDOW_ZOOMED SPEC_CALC
+ BASE_CONVERTERS WINDOW_ZOOMED SPEC_CALC
ASK_ON_FILE_OPEN SHOW_EDITOR_TAB_BAR RS232_DEBUGGER
FILE_NOTES STACK_MON_GEOMETRY STACK_MON_COLLAPSED
+ SPELL_CHECK_ENABLED SPELL_CHECK_DICTIONARY UART_MON_GEOMETRY
+ SHOW_PALE_WARN
}
# List of datatypes for these keys
set datatypes {
@@ -4629,11 +4803,13 @@ namespace eval X {
S B S
B B S
S S B
+ B S G
+ B
}
# Open session file
set file [open $session_file r]
- while 1 {
+ while {1} {
# Break on EOF
if {[eof $file]} {
close $file
@@ -4706,9 +4882,9 @@ namespace eval X {
puts stderr "Invalid record REPLACE_OPTIONS -- setting to default value"
set ::CONFIG(REPLACE_OPTIONS) $default_REPLACE_OPTIONS
}
- if {![regexp {^\s*[01]\s+[01]\s*$} $::CONFIG(REGWATCHES_CONFIG)]} {
+ if {![regexp {^\s*[01]\s+[01]\s+[01]\s*$} $::CONFIG(REGWATCHES_CONFIG)]} {
puts stderr "Invalid record REGWATCHES_CONFIG -- setting to default value"
- set ::CONFIG(REGWATCHES_CONFIG) {1 1}
+ set ::CONFIG(REGWATCHES_CONFIG) {1 1 0}
}
# Adjust some configuration values
@@ -4751,18 +4927,19 @@ namespace eval X {
}
## Invoke dialog "Exit program"
+ # @parm Bool force=0 - Do not allow user to cancel the request
# @return Int - result
# '0' == Save selected
# '1' == Save all
# '2' == Discard
# '3' == Cancel
- proc shutdown_dialog {} {
+ proc shutdown_dialog {{force 0}} {
variable unsaved_projects ;# List: List of project object marked as "unsaved"
catch {unset ::exit_dialog_result}
# Create dialog window
- set dialog [toplevel .save_multiple_projects -class {Save multimple} -bg {#EEEEEE}]
+ set dialog [toplevel .save_multiple_projects -class {Save multimple} -bg ${::COMMON_BG_COLOR}]
# Create the top part of dialog (Header and some icon)
pack [frame $dialog.topframe] -fill x -expand 1
@@ -4774,7 +4951,7 @@ namespace eval X {
] -side right -fill x -expand 1
# Create the middle part of the dialog (list of unsaved files)
- pack [ttk::labelframe $dialog.lf -text [mc "Unsaved files"] -labelanchor nw -padding 5] -fill both -expand 1 -pady 10 -padx 10
+ ttk::labelframe $dialog.lf -text [mc "Unsaved files"] -labelanchor nw -padding 5
set last_project {}
set i 0
foreach unsaved $unsaved_projects {
@@ -4797,8 +4974,8 @@ namespace eval X {
}
# Create the bottom part of the dialog (buttons)
- pack [ttk::separator $dialog.separator -orient horizontal] -fill x -expand 1 -padx 10
- pack [frame $dialog.f] -pady 5 -padx 5
+ ttk::separator $dialog.separator -orient horizontal
+ frame $dialog.f
# button SAVESELECTED
pack [ttk::button $dialog.f.b_save_selected \
-text [mc "Save selected"] \
@@ -4830,15 +5007,22 @@ namespace eval X {
bind $dialog.f.b_discard <Return> {set ::exit_dialog_result 2}
bind $dialog.f.b_discard <KP_Enter> {set ::exit_dialog_result 2}
# button CANCEL
- pack [ttk::button $dialog.f.b_cancel \
- -text [mc "Cancel"] \
- -underline 0 \
- -compound left \
- -image ::ICONS::16::button_cancel \
- -command {set ::exit_dialog_result 3} \
- ] -side left -padx 5
- bind $dialog.f.b_cancel <Return> {set ::exit_dialog_result 3}
- bind $dialog.f.b_cancel <KP_Enter> {set ::exit_dialog_result 3}
+ if {!$force} {
+ pack [ttk::button $dialog.f.b_cancel \
+ -text [mc "Cancel"] \
+ -underline 0 \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command {set ::exit_dialog_result 3} \
+ ] -side left -padx 5
+ bind $dialog.f.b_cancel <Return> {set ::exit_dialog_result 3}
+ bind $dialog.f.b_cancel <KP_Enter> {set ::exit_dialog_result 3}
+ }
+
+ # Pack GUI parts
+ pack $dialog.lf -fill both -expand 1 -pady 10 -padx 10
+ pack $dialog.separator -fill x -expand 1 -padx 10
+ pack $dialog.f -pady 5 -padx 5
# Set key-events bindings
bind $dialog <Alt-Key-s> {set ::exit_dialog_result 0}
@@ -4854,11 +5038,23 @@ namespace eval X {
grab $dialog
focus -force $dialog.f.b_save_all
wm transient $dialog .
- wm protocol $dialog WM_DELETE_WINDOW "
- grab release $dialog
- destroy $dialog
- set ::exit_dialog_result 3
- "
+ if {!$force} {
+ wm protocol $dialog WM_DELETE_WINDOW "
+ grab release $dialog
+ destroy $dialog
+ set ::exit_dialog_result 3
+ "
+ } else {
+ wm protocol $dialog WM_DELETE_WINDOW "
+ tk_messageBox \
+ -parent $dialog \
+ -type ok \
+ -icon warning \
+ -title {[mc {Attention}]} \
+ -message {[mc {You have to chose one action}]}
+ "
+
+ }
vwait ::exit_dialog_result
grab release $dialog
destroy $dialog
@@ -4899,7 +5095,7 @@ namespace eval X {
set lineNum [$actualProject simulator_getCurrentLine]
if {$lineNum != {}} {
$actualProject move_simulator_line $lineNum
- } {
+ } else {
$actualProject editor_procedure {} unset_simulator_line {}
}
$actualProject Simulator_sync_PC_etc
@@ -4941,7 +5137,7 @@ namespace eval X {
set lineNum [$actualProject step]
if {$lineNum != {}} {
$actualProject move_simulator_line $lineNum
- } {
+ } else {
$actualProject editor_procedure {} unset_simulator_line {}
}
stepback_button_set_ena [$actualProject simulator_get_SBS_len]
@@ -4988,7 +5184,7 @@ namespace eval X {
set lineNum [$actualProject sim_stepover]
if {$lineNum != {}} {
$actualProject move_simulator_line $lineNum
- } {
+ } else {
$actualProject editor_procedure {} unset_simulator_line {}
}
@@ -5070,7 +5266,7 @@ namespace eval X {
set line_num [$actualProject sim_run]
if {$line_num != {}} {
$actualProject move_simulator_line $line_num
- } {
+ } else {
$actualProject editor_procedure {} unset_simulator_line {}
}
# Adjust simulator control panel
@@ -5098,6 +5294,8 @@ namespace eval X {
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
variable actualProjectIdx ;# Index of the current project in $openedProjects
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
+ variable opened_code_mem_windows ;# List of project object with opened CODE memory hex editor
+ variable code_mem_window_objects ;# List of CODE memory hex editor objects
if {$project_menu_locked} {return}
@@ -5116,7 +5314,7 @@ namespace eval X {
# Perform reset
$actualProject Simulator_reset $arg
$actualProject simulator_setWatchDogTimer 0
- # Move simulator cursor in editor to the begining of the program
+ # Move simulator cursor in editor to the beginning of the program
foreach editor [$actualProject cget -editors] {
$editor unset_simulator_line
}
@@ -5130,20 +5328,23 @@ namespace eval X {
$actualProject rightPanel_watch_sync_all
}
+ # Inform code memory hexadecimal editor about the reset
+ program_counter_changed $actualProject 0
+
# Finalize
set critical_procedure_in_progress 0
}
## Start/Shutdown simulator
- # @parm Bool = 0 - Load debug file for the current file only (not the main file)
+ # @parm Bool current_file_only=0 - Load debug file for the current file only (not the main file)
# @return void
- proc __initiate_sim args {
+ proc __initiate_sim {{current_file_only 0}} {
variable actualProject ;# Object: Current project
variable simulator_enabled ;# List of booleans: Simulator engaged
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
variable actualProjectIdx ;# Index of the current project in $openedProjects
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
- variable opended_code_mem_windows ;# List of project object with opened CODE memory hex editor
+ variable opened_code_mem_windows ;# List of project object with opened CODE memory hex editor
variable code_mem_window_objects ;# List of CODE memory hex editor objects
if {$project_menu_locked} {return}
@@ -5152,12 +5353,6 @@ namespace eval X {
if {$critical_procedure_in_progress} {return}
set critical_procedure_in_progress 1
- if {[lindex $args 0] == 1} {
- set current_file_only 1
- } {
- set current_file_only 0
- }
-
# Clear program timer
$actualProject simulator_clear_overall_time
@@ -5185,7 +5380,7 @@ namespace eval X {
}
# Inform code memory hexadecimal editor about that
- set idx [lsearch -exact -ascii $opended_code_mem_windows [string trimleft $actualProject {:}]]
+ set idx [lsearch -exact -ascii $opened_code_mem_windows [string trimleft $actualProject {:}]]
if {$idx != -1} {
[lindex $code_mem_window_objects $idx] simulator_stared_stopped 0
}
@@ -5205,7 +5400,7 @@ namespace eval X {
set full_file_name [$actualProject editor_procedure {} getFileName {}]
set language [$actualProject editor_procedure {} get_language {}]
set relative_name [lindex $full_file_name 1]
- } {
+ } else {
set ext [string trimleft [file extension $relative_name] {.}]
if {$ext == {c} || $ext == {h} || $ext == {cxx} || $ext == {cpp} || $ext == {cc}} {
set language 1
@@ -5219,7 +5414,7 @@ namespace eval X {
set full_file_name [file rootname $full_file_name]
if {$language == 1} {
append full_file_name {.cdb}
- } {
+ } else {
append full_file_name {.adf}
}
@@ -5252,10 +5447,11 @@ namespace eval X {
}]} then {
# MD5 hash verification failed -> ask for recompilation
- if {($language == 0 || $language == 1) && [verify_md5_hashes 1 $expected_md5s]} {
+ if {($language == 0 || $language == 1) && [verify_md5_hashes 1 $expected_md5s [file dirname $full_file_name]]} {
# Ask for recompilation
set response [
tk_messageBox \
+ -parent . \
-icon question \
-type yesno \
-default {yes} \
@@ -5272,6 +5468,7 @@ namespace eval X {
# (0) Compilation failed
if {!$compilation_result} {
tk_messageBox \
+ -parent . \
-icon error \
-type ok \
-title [mc "Compilation failed"] \
@@ -5288,12 +5485,13 @@ namespace eval X {
# Ask for recompilation
set response [
tk_messageBox \
+ -parent . \
-icon question \
-type yesno \
-title [mc "File not found"] \
-message [mc "Simulator data file not found.\nDo you want create it ?"]
]
- if {$response == {no}} {
+ if {$response != {yes}} {
set critical_procedure_in_progress 0
return
}
@@ -5303,6 +5501,7 @@ namespace eval X {
# (0) Compilation failed
if {!$compilation_result} {
tk_messageBox \
+ -parent . \
-icon error \
-type ok \
-title [mc "Compilation failed"] \
@@ -5331,6 +5530,7 @@ namespace eval X {
set simulator_file [open $full_file_name r]
}]} then {
tk_messageBox \
+ -parent . \
-icon warning \
-type ok \
-title [mc "Unable to start simulator"] \
@@ -5361,7 +5561,7 @@ namespace eval X {
# Raise tab "Simulator" on the bottom panel
if {[lsearch {Graph Simulator CVarsView} $bottom_page_ID] == -1} {
$actualProject bottomNB_show_up {Simulator}
- } {
+ } else {
$actualProject bottomNB_show_up $bottom_page_ID
}
@@ -5382,7 +5582,7 @@ namespace eval X {
$actualProject cvarsview_load_cdb $simulator_file
}
close $hex_file
- } {
+ } else {
$actualProject load_program_from_adf $simulator_file
}
@@ -5421,11 +5621,14 @@ namespace eval X {
if {$found} {
$actualProject Simulator_import_breakpoints \
$filename [$editor getBreakpoints]
- } {
+ } else {
$actualProject Simulator_import_breakpoints $filename {}
}
}
+ # Detect and report invalid breakpoints
+ $actualProject report_invalid_breakpoints
+
$actualProject now_frozen
# Set simulator cursor in editor to the first OP code
@@ -5436,7 +5639,7 @@ namespace eval X {
stepback_button_set_ena 0 ;# Disable StepBack controls
# Inform code memory hexadecimal editor about that
- set idx [lsearch -exact -ascii $opended_code_mem_windows [string trimleft $actualProject {:}]]
+ set idx [lsearch -exact -ascii $opened_code_mem_windows [string trimleft $actualProject {:}]]
if {$idx != -1} {
[lindex $code_mem_window_objects $idx] simulator_stared_stopped 1
}
@@ -5449,11 +5652,12 @@ namespace eval X {
## Verify MD5 hashes for the given files (only for current project)
# @parm Bool save_files - Save modified files mentioned in the given list
# @parm List hashes - {hash filename hash filename ...}
+ # @parm String dir - Directory where the function will search for the files mentioned in "$hashes"
# @return Int - Final result
# 0 == All correct
# 1 == Verification failed
# 2 == File access error
- proc verify_md5_hashes {save_files hashes} {
+ proc verify_md5_hashes {save_files hashes dir} {
variable actualProject ;# Object: Current project
# Local variables
@@ -5461,8 +5665,6 @@ namespace eval X {
set filenames {} ;# List of filenames only
set md5_hashes {} ;# List of md5 hashes only
- set dir [$actualProject cget -projectPath]
-
# Separate filenames and hashes
for {set i 0; set j 1} {$i < $len} {incr i 2; incr j 2} {
lappend filenames [file join $dir [lindex $hashes $j]]
@@ -5503,9 +5705,10 @@ namespace eval X {
set recorded_md5 [lindex $md5_hashes $i]
if {[catch {
set computed_md5 [::md5::md5 -hex -file [lindex $filenames $i]]
- }]} {
+ }]} then {
return 2
}
+
if {$recorded_md5 != $computed_md5} {
return 1
}
@@ -5529,16 +5732,16 @@ namespace eval X {
# File name is not valid -> invoke error message
if {
- $input_file == {} ||
- ![file exists $input_file] ||
- ![file isfile $input_file] ||
- (!$::MICROSOFT_WINDOWS && ![file writable $input_file]) ||
- (!$::MICROSOFT_WINDOWS && ![file readable $input_file])
- } {
- tk_messageBox \
- -parent . -icon warning \
- -title [mc "Error - MCU 8051 IDE"] \
- -message [mc "Unable to gain unlimited access to the given file"]
+ $input_file == {} ||
+ ![file exists $input_file] ||
+ ![file isfile $input_file] ||
+ (!$::MICROSOFT_WINDOWS && ![file writable $input_file]) ||
+ (!$::MICROSOFT_WINDOWS && ![file readable $input_file])
+ } then {
+ tk_messageBox \
+ -parent . -icon warning \
+ -title [mc "Error - MCU 8051 IDE"] \
+ -message [mc "Unable to gain unlimited access to the given file"]
# File name is valid -> normalize its content
} else {
# Progress dialog
@@ -5570,11 +5773,11 @@ namespace eval X {
# Destroy progress dialog
catch {destroy .prgDl}
- # No errors occured -> rewrite file
+ # No errors occurred -> rewrite file
if {!${::IHexTools::error_count}} {
if {[catch {
- set file [open $input_file w 420]
- }]} {
+ set file [open $input_file w 0640]
+ }]} then {
tk_messageBox \
-type ok \
-icon error \
@@ -5586,10 +5789,10 @@ namespace eval X {
puts -nonewline $file $data
close $file
}
- # Errors occured -> Invoke error message dialog
+ # Errors occurred -> Invoke error message dialog
} else {
# Create dialog window
- set dialog [toplevel .error_message_dialog -class {Error dialog} -bg {#EEEEEE}]
+ set dialog [toplevel .error_message_dialog -class {Error dialog} -bg ${::COMMON_BG_COLOR}]
# Create main frame (text widget and scrolbar)
set main_frame [frame $dialog.main_frame]
@@ -5619,7 +5822,7 @@ namespace eval X {
# Set window attributes
wm iconphoto $dialog ::ICONS::16::status_unknown
- wm title $dialog [mc "Error(s) occured while parsing IHEX file - %s" ${::APPNAME}]
+ wm title $dialog [mc "Error(s) occurred while parsing IHEX file - %s" ${::APPNAME}]
wm minsize $dialog 500 250
wm protocol $dialog WM_DELETE_WINDOW [mc "grab release %s; destroy %s" $dialog $dialog]
wm transient $dialog .
@@ -5633,7 +5836,7 @@ namespace eval X {
}
}
- ## Invkoke dialog for converting Binary files to Intel® HEX 8 files
+ ## Invoke dialog for converting Binary files to Intel® HEX 8 files
# @return void
proc __bin2hex {} {
variable hex__bin ;# Type of conversion
@@ -5642,7 +5845,7 @@ namespace eval X {
hex2bin2hex
}
- ## Invkoke dialog for converting Intel® HEX 8 files to Binary files
+ ## Invoke dialog for converting Intel® HEX 8 files to Binary files
# @return void
proc __hex2bin {} {
variable hex__bin ;# Type of conversion
@@ -5650,7 +5853,7 @@ namespace eval X {
hex2bin2hex
}
- ## Invkoke dialog for converting Simulator data files to Intel® HEX 8 files
+ ## Invoke dialog for converting Simulator data files to Intel® HEX 8 files
# @return void
proc __sim2hex {} {
variable hex__bin ;# Type of conversion
@@ -5658,7 +5861,7 @@ namespace eval X {
hex2bin2hex
}
- ## Invkoke dialog for converting Simulator data files to Binary files
+ ## Invoke dialog for converting Simulator data files to Binary files
# @return void
proc __sim2bin {} {
variable hex__bin ;# Type of conversion
@@ -5675,13 +5878,13 @@ namespace eval X {
if {$critical_procedure_in_progress} {return}
# Create dialog window
- set win [toplevel .hex2bin2hex_dialog -class {Conversion} -bg {#EEEEEE}]
+ set win [toplevel .hex2bin2hex_dialog -class {Conversion} -bg ${::COMMON_BG_COLOR}]
set mainframe [frame $win.frame]
# Label, Entry and Button "Input file"
- grid [Label $mainframe.lbl_input \
- -text [mc "Input file"] \
- -helptext {File to convert} \
+ grid [Label $mainframe.lbl_input \
+ -text [mc "Input file"] \
+ -helptext [mc "File to convert"] \
] -column 1 -row 1 -sticky w
grid [ttk::entry $mainframe.entry_input \
-textvariable X::input_file \
@@ -5827,11 +6030,11 @@ namespace eval X {
# Normalize name of input file
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $input_file]} {
- set filename "[${X::actualProject} cget -ProjectDir]/$input_file"
+ set filename "[${::X::actualProject} cget -ProjectDir]/$input_file"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $input_file]} {
- set filename [file join [${X::actualProject} cget -ProjectDir] $input_file]
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $input_file]} {
+ set filename [file join [${::X::actualProject} cget -ProjectDir] $input_file]
}
}
set input_file [file normalize $input_file]
@@ -5839,17 +6042,21 @@ namespace eval X {
# Normalize name of output file
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $output_file]} {
- set filename "[${X::actualProject} cget -ProjectDir]/$output_file"
+ set filename "[${::X::actualProject} cget -ProjectDir]/$output_file"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $output_file]} {
- set filename [file join [${X::actualProject} cget -ProjectDir] $output_file]
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $output_file]} {
+ set filename [file join [${::X::actualProject} cget -ProjectDir] $output_file]
}
}
set output_file [file normalize $output_file]
set win .hex2bin2hex_dialog
+ bind $win <KeyRelease-Return> {}
+ bind $win <KeyRelease-KP_Enter> {}
+ bind $win <KeyRelease-Escape> {}
+
# Diable entry widgets in file selection dialog
foreach wdg [subst {
$win.frame.entry_input
@@ -5888,7 +6095,9 @@ namespace eval X {
if {[file exists $output_file] && [file isfile $output_file]} {
if {![file writable $output_file]} {
tk_messageBox \
- -type ok -icon error -parent $win \
+ -type ok \
+ -icon error \
+ -parent $win \
-title [mc "Permission denied"] \
-message [mc "Unable to access file: %s" $output_file]
hex2bin2hex_CANCEL
@@ -5902,7 +6111,7 @@ namespace eval X {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $output_file]]
] != {yes}
- } {
+ } then {
hex2bin2hex_CANCEL
return
}
@@ -5922,6 +6131,7 @@ namespace eval X {
tk_messageBox \
-type ok \
-icon warning \
+ -parent $win \
-title [mc "File not found - MCU 8051 IDE"] \
-message [mc "Unable to open file '%s'" $input_file]
@@ -5934,6 +6144,7 @@ namespace eval X {
0 { ;# Bin -> Hex
$status_label configure -text [mc "Loading file ..."]
::IHexTools::load_bin_data $data
+ set data {}
if {!${::IHexTools::abort} && !${::IHexTools::error_count}} {
$status_label configure -text [mc "Saving file ..."]
$progressbar configure -maximum 16
@@ -5944,6 +6155,7 @@ namespace eval X {
$status_label configure -text [mc "Loading file ..."]
$progressbar configure -maximum [::IHexTools::get_number_of_iterations $data]
::IHexTools::load_hex_data $data
+ set data {}
if {!${::IHexTools::abort} && !${::IHexTools::error_count}} {
$status_label configure -text [mc "Saving file ..."]
$progressbar configure -maximum 16
@@ -5954,6 +6166,7 @@ namespace eval X {
$status_label configure -text [mc "Loading file ..."]
$progressbar configure -maximum [::IHexTools::get_number_of_iterations $data]
::IHexTools::load_sim_data $data
+ set data {}
if {!${::IHexTools::abort} && !${::IHexTools::error_count}} {
$status_label configure -text [mc "Saving file ..."]
$progressbar configure -maximum 16
@@ -5964,19 +6177,23 @@ namespace eval X {
$status_label configure -text [mc "Loading file ..."]
$progressbar configure -maximum [::IHexTools::get_number_of_iterations $data]
::IHexTools::load_sim_data $data
+ set data {}
if {!${::IHexTools::abort} && !${::IHexTools::error_count}} {
$status_label configure -text [mc "Saving file ..."]
$progressbar configure -maximum 16
set data [::IHexTools::get_bin_data]
}
}
+ default {
+ set data {}
+ }
}
# Write output file
- if {$data != {}} {
+ if {[string length $data]} {
if {[catch {
- set file [open $output_file w 420]
- }]} {
+ set file [open $output_file w 0640]
+ }]} then {
tk_messageBox \
-type ok \
-icon error \
@@ -5993,13 +6210,10 @@ namespace eval X {
}
}
- # If errors occured -> Invoke error message dialog
+ # If errors occurred -> Invoke error message dialog
if {${::IHexTools::error_count}} {
- # Destroy previous dialog
- hex2bin2hex_CANCEL
-
# Create dialog window
- set dialog [toplevel .error_message_dialog -class {Error dialog} -bg {#EEEEEE}]
+ set dialog [toplevel .error_message_dialog -class {Error dialog} -bg ${::COMMON_BG_COLOR}]
# Create main frame (text and scrollbar)
set main_frame [frame $dialog.main_frame]
@@ -6015,9 +6229,9 @@ namespace eval X {
pack $main_frame -fill both -expand 1
# Create button "Close"
- pack [ttk::button $dialog.ok_button \
- -text [mc "Close"] \
- -command "grab release $dialog; destroy $dialog" \
+ pack [ttk::button $dialog.ok_button \
+ -text [mc "Close"] \
+ -command "grab release $dialog; destroy $dialog"\
]
$text insert end ${::IHexTools::error_string}
@@ -6028,7 +6242,7 @@ namespace eval X {
wm title $dialog [mc "Corrupted file - MCU 8051 IDE"]
wm minsize $dialog 520 250
wm protocol $dialog WM_DELETE_WINDOW "grab release $dialog; destroy $dialog"
- wm transient $dialog .
+ wm transient $dialog .hex2bin2hex_dialog
grab $dialog
raise $dialog
tkwait window $dialog
@@ -6061,13 +6275,21 @@ namespace eval X {
proc select_input_output {io mask master} {
variable IO ;# Bool: 1 == choose input file; 0 == choose output file
variable actualProject ;# Object: Current project
+ variable openedProjects ;# List of opened projects (Object references)
+
set IO $io
+ if {[llength $openedProjects]} {
+ set project_dir [${::X::actualProject} cget -ProjectDir]
+ } else {
+ set project_dir ${::env(HOME)}
+ }
+
# Invoke the dialog
catch {delete object fsd}
KIFSD::FSD fsd \
-title [mc "Open file - MCU 8051 IDE"] \
- -directory [$actualProject cget -projectPath] \
+ -directory $project_dir \
-defaultmask 0 -multiple 0 -filetypes [list \
[list [mc "Input file"] "*.$mask"] \
[list [mc "All files"] {*}] \
@@ -6078,17 +6300,17 @@ namespace eval X {
set filename [X::fsd get]
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $filename]} {
- set filename "[${X::actualProject} cget -ProjectDir]/$filename"
+ set filename "$project_dir/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
- set filename [file join [${X::actualProject} cget -ProjectDir] $filename]
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
+ set filename [file join $project_dir $filename]
}
}
set filename [file normalize $filename]
if {${X::IO}} {
set X::input_file $filename
- } {
+ } else {
set X::output_file $filename
}
}
@@ -6128,37 +6350,41 @@ namespace eval X {
set filename [X::fsd get]
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $filename]} {
- set filename "[${X::actualProject} cget -ProjectDir]/$filename"
+ set filename "[${::X::actualProject} cget -ProjectDir]/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
- set filename [file join [${X::actualProject} cget -ProjectDir] $filename]
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
+ set filename [file join [${::X::actualProject} cget -ProjectDir] $filename]
}
}
set filename [file normalize $filename]
if {
- ![file exists $filename] ||
- ![file isfile $filename] ||
- (!$::MICROSOFT_WINDOWS && ![file readable $filename])
- } {
- tk_messageBox -type ok -icon warning \
- -parent [X::fsd get_window_name] \
- -title [mc "File not found - MCU 8051 IDE"] \
- -message [mc "The selected file %s does not exist." $filename]
+ ![file exists $filename] ||
+ ![file isfile $filename] ||
+ (!$::MICROSOFT_WINDOWS && ![file readable $filename])
+ } then {
+ tk_messageBox \
+ -type ok \
+ -icon warning \
+ -parent . \
+ -title [mc "File not found - MCU 8051 IDE"] \
+ -message [mc "The selected file %s does not exist." $filename]
} else {
set data [X::decompile $filename]
if {$data != {}} {
- ${X::actualProject} background_open $data
+ ${::X::actualProject} background_open $data
if {[lindex ${X::simulator_enabled} ${X::actualProjectIdx}] == 0} {
- ${X::actualProject} switch_to_last
+ ${::X::actualProject} switch_to_last
}
- } {
+ } else {
tk_messageBox \
- -type ok -icon warning \
- -title [mc "Decompilation failed"] \
- -message [mc "Decompilation failed -- see messages for details"]
+ -type ok \
+ -parent . \
+ -icon warning \
+ -title [mc "Disassembly failed"] \
+ -message [mc "Disassembly failed -- see messages for details"]
}
}
}
@@ -6184,8 +6410,10 @@ namespace eval X {
if {[catch {
set file [open $filename r]
}]} then {
- tk_messageBox -parent . \
- -icon warning -type ok \
+ tk_messageBox \
+ -parent . \
+ -icon warning \
+ -type ok \
-title [mc "Unable to open file"] \
-message [mc "Unable to read file '%s'" $filename]
return {}
@@ -6201,7 +6429,7 @@ namespace eval X {
set Compiler::Settings::TEXT_OUPUT_COMMAND X::messages_text_append
set Compiler::Settings::UPDATE_COMMAND {update}
- # Perform decompilation
+ # Perform disassembly
set data {}
set ::IHexTools::update 1
::IHexTools::load_hex_data [read $file]
@@ -6223,7 +6451,7 @@ namespace eval X {
messages_text_append [mc "FAILED"]
}
- # Free resources reserved during decompilation
+ # Free resources reserved during disassembly
::IHexTools::free_resources
return $data
@@ -6267,7 +6495,7 @@ namespace eval X {
if {$last_WIN_GEOMETRY == [wm geometry .]} {
return
# Refresh last window geometry variable
- } {
+ } else {
set last_WIN_GEOMETRY [wm geometry .]
}
@@ -6279,10 +6507,9 @@ namespace eval X {
set ::last_WIN_GEOMETRY_width ${::WIN_GEOMETRY_width}
foreach project $openedProjects {
catch {
- $project bottomNB_redraw_pane
- }
- catch {
$project leftpanel_redraw_pane
+ $project right_panel_redraw_pane
+ $project todo_panel_redraw_pane
}
}
}
@@ -6291,8 +6518,7 @@ namespace eval X {
set ::last_WIN_GEOMETRY_height ${::WIN_GEOMETRY_height}
foreach project $openedProjects {
catch {
- $project right_panel_redraw_pane
- $project todo_panel_redraw_pane
+ $project bottomNB_redraw_pane
}
}
}
@@ -6302,7 +6528,7 @@ namespace eval X {
# @return void
proc __about {} {
# Create dialog window
- set win [toplevel .about -class [mc "About dialog"] -bg {#EEEEEE}]
+ set win [toplevel .about -class [mc "About dialog"] -bg ${::COMMON_BG_COLOR}]
# Create dialog header
pack [label $win.header \
@@ -6314,18 +6540,29 @@ namespace eval X {
-family {helvetica}]
] -side top -pady 5
+ # Display short information about current translation
+ set translation_info "Translated into _Language_ by _Name_ (_country_) <_email_>"
+ if {[mc $translation_info] != $translation_info} {
+ pack [label $win.trans_info \
+ -text [mc $translation_info] \
+ -font [font create \
+ -size -12 \
+ -family {helvetica}]
+ ] -side top -pady 2
+ }
+
+
# Create notebook
- set nb [ttk::notebook $win.nb]
+ set nb [ModernNoteBook $win.nb]
# Create tab "About"
- set about_tab [frame $nb.about_tab]
- $nb add $about_tab -text [mc "About"]
- pack [text $about_tab.text \
- -width 0 -height 0 -cursor left_ptr \
- -yscrollcommand "$about_tab.scrollbar set" \
- -font [font create \
- -size -12 \
- -family {helvetica}] \
+ set about_tab [$nb insert end {About} -text [mc "About"]]
+ pack [text $about_tab.text \
+ -width 0 -height 0 -cursor left_ptr \
+ -yscrollcommand "$about_tab.scrollbar set" \
+ -font [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family {helvetica}] \
] -fill both -expand 1 -side left
pack [ttk::scrollbar $about_tab.scrollbar \
-orient vertical \
@@ -6333,24 +6570,21 @@ namespace eval X {
] -fill y -side right
# fill in the about tab
$about_tab.text insert end "${::APPNAME}\n"
- $about_tab.text insert end [mc "\tComplete IDE for MCS-51 based microconrollers.\n"]
- $about_tab.text insert end [mc "\tThis program is witten for POSIX Systems\n"]
+ $about_tab.text insert end [mc "An open source IDE for MCS-51 based microconrollers for POSIX Systems, this software is licenced under the GNU GPL v2 licence. You can find more at the project web page http://mcu8051ide.sourceforge.net\n"]
+ $about_tab.text insert end "\n(c) 2007, 2008, 2009, 2010, 2011, 2012 Martin Ošmera <mailto:martin.osmera@gmail.com>\n"
if {$::MICROSOFT_WINDOWS} {
- $about_tab.text insert end [mc "\tYOU ARE CURRENTLY USING VERSION FOR Microsoft® Windows®\n"]
+ $about_tab.text insert end "\n"
+ $about_tab.text insert end [mc "You are currently using version for Microsoft® Windows®.\n"]
+ $about_tab.text insert end "(This version was made using the FreeWrap tool, by Dennis R. LaBelle <freewrapmgr@users.sourceforge.net>.)\n"
}
- $about_tab.text insert end "\n(c) Martin Ošmera <martin.osmera@gmail.com>\n"
- $about_tab.text insert end [mc "Web: http://mcu8051ide.sourceforge.net\n"]
- $about_tab.text insert end [mc "Please post suggestions and comments at http://mcu8051ide.sf.net\n"]
- $about_tab.text insert end [mc "\n\nThanks to Kostya V. Ivanov for bug fixes.\n"]
- $about_tab.text insert end [mc "Thanks to SDCC development team for their great work !\n"]
- $about_tab.text insert end [mc "Thanks to %s for their help during development\n" "Fabricio Alcalde, Shakthi Kannan, Miroslav Hradílek, Kostya V. Ivanov"]
+ create_link_tag_in_text_widget $about_tab.text
+ convert_all_https_to_links $about_tab.text
# Finalize text widget creation
$about_tab.text configure -state disabled
# Create tab "Thanks to"
- set thanks_tab [frame $nb.thanks_tab]
- $nb add $thanks_tab -text [mc "Thanks to"]
+ set thanks_tab [$nb insert end {Thanks} -text [mc "Thanks to"]]
pack [text $thanks_tab.text \
-width 0 -height 0 -cursor left_ptr \
-yscrollcommand "$thanks_tab.scrollbar set" \
@@ -6360,73 +6594,44 @@ namespace eval X {
-command "$thanks_tab.text yview" \
] -fill y -side right
-
- $thanks_tab.text insert end [mc "Thanks to Fabricio Alcalde for bug reports and suggestions\n"]
- $thanks_tab.text insert end [mc "Thanks to Miroslav Hradílek for bug reports\n"]
+ $thanks_tab.text insert end [mc "Special thanks to Kara Blackowiak (USA) for submitting various help file fixes.\n\n"]
+ $thanks_tab.text insert end [mc "Thanks to Yuanhui Zhang for bug reports and help with debugging.\n"]
+ $thanks_tab.text insert end [mc "Thanks to Fabricio Alcalde for bug reports and suggestions.\n"]
+ $thanks_tab.text insert end [mc "Thanks to Marek Nožka for help with debugging.\n"]
+ $thanks_tab.text insert end [mc "Thanks to Miroslav Hradílek for bug reports.\n"]
+ $thanks_tab.text insert end [mc "Thanks to Trevor Spiteri for help with debugging (patches) the HD44780 simulator.\n"]
$thanks_tab.text insert end [mc "Thanks to Kostya V. Ivanov for significant bug fixes.\n"]
- $thanks_tab.text insert end [mc "Thanks to Shakthi Kannan for including this IDE in FEL\n\n"]
- $thanks_tab.text insert end [mc "SDCC developers:\n"]
- $thanks_tab.text insert end "\tBela Torok\n"
- $thanks_tab.text insert end "\tBernhard Held\n"
- $thanks_tab.text insert end "\tBorut Ražem\n"
- $thanks_tab.text insert end "\tDave Helton\n"
- $thanks_tab.text insert end "\tDaniel Drotos\n"
- $thanks_tab.text insert end "\tErik Petrich\n"
- $thanks_tab.text insert end "\tFrieder Ferlemann\n"
- $thanks_tab.text insert end "\tHans Dorn\n"
- $thanks_tab.text insert end "\tJerome Bessiere\n"
- $thanks_tab.text insert end "\tJesus Calvino-Fraga\n"
- $thanks_tab.text insert end "\tJohan Knol\n"
- $thanks_tab.text insert end "\tAlex Karahalios\n"
- $thanks_tab.text insert end "\tKarl Bongers\n"
- $thanks_tab.text insert end "\tKlaus Flittner\n"
- $thanks_tab.text insert end "\tKlaus Martin Hennemann\n"
- $thanks_tab.text insert end "\tKevin Vigor\n"
- $thanks_tab.text insert end "\tMaarten Brock\n"
- $thanks_tab.text insert end "\tMartin Dubuc\n"
- $thanks_tab.text insert end "\tMartin Helmling\n"
- $thanks_tab.text insert end "\tMichael Hope\n"
- $thanks_tab.text insert end "\tMichael Schmitt\n"
- $thanks_tab.text insert end "\tPaul Stoffregen\n"
- $thanks_tab.text insert end "\tSandeep Dutta\n"
- $thanks_tab.text insert end "\tScott Dattalo\n"
- $thanks_tab.text insert end "\tErik Petrich\n"
- $thanks_tab.text insert end "\tStephen M. Kenton\n"
- $thanks_tab.text insert end "\tSlade Rich\n"
- $thanks_tab.text insert end "\tShawn Masters\n"
- $thanks_tab.text insert end "\tPhilipp Krause\n"
- $thanks_tab.text insert end "\tStephen Williams\n"
- $thanks_tab.text insert end "\tRaphael Neider\n"
- $thanks_tab.text insert end "\tAnton Voloshin\n"
- $thanks_tab.text insert end "\tVangelis Rokas\n"
- $thanks_tab.text insert end "\tWim Lewis\n"
- $thanks_tab.text insert end [mc "\n(Please post suggestions to %s)\n" "martin.osmera@gmail.com"]
+ $thanks_tab.text insert end [mc "Thanks to Shakthi Kannan for including this IDE in FEL.\n\n"]
+ $thanks_tab.text insert end [mc "Thanks to all the SDCC developers.\n"]
$thanks_tab.text configure -state disabled
- # Create tab "Licence"
- set licence_tab [frame $nb.licence_tab]
- $nb add $licence_tab -text [mc "Licence"]
- pack [text $licence_tab.text \
- -width 0 -height 0 \
- -yscrollcommand "$licence_tab.scrollbar set" \
+ # Create tab "License"
+ set license_tab [$nb insert end {License} -text [mc "License"]]
+ pack [text $license_tab.text \
+ -width 0 -height 0 \
+ -yscrollcommand "$license_tab.scrollbar set" \
+ -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size -12 \
+ ] \
] -fill both -expand 1 -side left
- pack [ttk::scrollbar $licence_tab.scrollbar \
+ pack [ttk::scrollbar $license_tab.scrollbar \
-orient vertical \
- -command "$licence_tab.text yview" \
+ -command "$license_tab.text yview" \
] -fill y -side right
- # Fill in the licence tab
- if {[file exists "${::LIB_DIRNAME}/../data/licence.txt"]} {
- $licence_tab.text insert end [read [open "${::LIB_DIRNAME}/../data/licence.txt" {r}]]
- } {
- $licence_tab.text insert end [mc "FILE \"licence.txt\" WAS NOT FOUND\n\n"]
- $licence_tab.text insert end [mc "Text of the licence agreement is not availble,\n"]
- $licence_tab.text insert end [mc "please check your instalation."]
+ # Fill in the license tab
+ if {[file exists "${::ROOT_DIRNAME}/data/license.txt"]} {
+ $license_tab.text insert end [read [open "${::ROOT_DIRNAME}/data/license.txt" {r}]]
+ } else {
+ $license_tab.text insert end [mc "FILE \"license.txt\" WAS NOT FOUND\n\n"]
+ $license_tab.text insert end [mc "Text of the license agreement is not available,\n"]
+ $license_tab.text insert end [mc "please check your installation."]
}
- $licence_tab.text configure -state disabled
+ $license_tab.text configure -state disabled
# Pack NoteBook
- pack $nb -fill both -expand 1 -side top -padx 10
- $nb select $about_tab
+ pack [$nb get_nb] -fill both -expand 1 -side top -padx 10
+ $nb raise {About}
# Create button "Close"
pack [ttk::button $win.close \
-text [mc "Close"] \
@@ -6487,19 +6692,19 @@ namespace eval X {
-parent . \
-icon warning \
-type ok \
- -title [mc "Sorry, unable to compile"] \
+ -title [mc "Sorry, unable to comply"] \
-message [mc "Unable to indent C source without program indent, MCU 8051 IDE is unable to localize this program on Microsoft Windows operating system. So this feature is not available in version for MS Windows. Correction of this limitation is planed but right now it's not available."]
set critical_procedure_in_progress 0
return
}
# Check for program "indent"
- if {!${::PROGRAM_AVALIABLE(indent)}} {
+ if {!${::PROGRAM_AVAILABLE(indent)}} {
tk_messageBox \
-parent . \
-icon warning \
-type ok \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "Unable to indent C source without program indent, please install indent and restart MCU 8051 IDE."]
set critical_procedure_in_progress 0
return
@@ -6520,14 +6725,14 @@ namespace eval X {
-parent . \
-icon warning \
-type ok \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "Unable to indent C source code.\n\n%s" $result]
- } {
+ } else {
$actualProject filelist_reload_file
}
# Assembly language
- } {
+ } else {
# Prepare
set reformat_code_abort 0 ;# Reset auto indention abort flag
set editor_lines [$actualProject editor_linescount] ;# Number of lines in the editor
@@ -6545,10 +6750,10 @@ namespace eval X {
create_progress_bar .prgDl \
. \
{} \
- "Reformating code" \
+ [::mc "Reformatting code"] \
::X::compilation_progress \
$max \
- [mc "Reformating code"] \
+ [mc "Reformatting code"] \
::ICONS::16::filter \
[mc "Abort"] \
{::X::reformat_code_stop}
@@ -6568,7 +6773,9 @@ namespace eval X {
$editor configure -autoseparators 1
# Finalize
- catch {destroy .prgDl ;# Destroy progress dialog}
+ catch {
+ destroy .prgDl ;# Destroy progress dialog
+ }
}
set critical_procedure_in_progress 0
}
@@ -6591,7 +6798,8 @@ namespace eval X {
set new_content {} ;# Resulting string
# Parse input data (line by line)
- foreach line [split $data "\n"] {
+ set data [split $data "\n"]
+ foreach line $data {
if {$reformat_code_abort} {break} ;# Conditional abort
incr idx ;# Increment line number
@@ -6612,7 +6820,7 @@ namespace eval X {
# Determinate line with replaced strings and chars with underscores
set line_tmp $line
- while 1 {
+ while {1} {
if {![regexp {'[^']+'} $line_tmp str]} {break}
set len [string length $str]
regsub {'[^']+'} $line_tmp [string repeat {_} $len] line_tmp
@@ -6626,7 +6834,7 @@ namespace eval X {
set line [string range $line 0 [expr {$commentBegin - 1}]]
}
- # Determinate fields 0..2
+ # Determinate fields 0 and 1
set pos 0
for {set j 0} {$j < 2} {incr j} {
if {![regexp {^\s*[^\s]+} $line_tmp str]} {break}
@@ -6642,32 +6850,46 @@ namespace eval X {
# Remove leading white space from Field 2
set field_2 [regsub {^\s+} $line {}]
+ # Handle situation when there is no space between label and the 1st field
+ if {[regexp {[^\s:]+:[^\s:]+} $field_0]} {
+ set j [string first {:} $field_0]
+ append field_1 $field_2
+ set field_2 $field_1
+ set field_1 [string range $field_0 [expr {$j + 1}] end]
+ set field_0 [string range $field_0 0 $j]
+ }
+
# Field 1 >> Field 2; Field 0 -> Field 1; "" -> Field 0;
+ if {[string index $field_1 0] == {.}} {
+ set field_1_without_leading_dot [string range $field_1 1 end]
+ } else {
+ set field_1_without_leading_dot $field_1
+ }
if {
- [regexp {^\w+$} $field_0] &&
- ![regexp {^\d} $field_0] &&
- [lsearch -exact -ascii ${::ASMsyntaxHighlight::directive_type2} \
- [string toupper $field_1]] == -1
- } {
- append field_1 $field_2
- set field_2 $field_1
- set field_1 {}
- if {[string toupper $field_0] != {ENDM}} {
- set field_1 $field_0
- set field_0 {}
- }
+ [regexp {^\.?\w+$} $field_0] &&
+ ![regexp {^\d} $field_0] &&
+ [lsearch -exact -ascii ${::ASMsyntaxHighlight::directive_type2} \
+ [string toupper $field_1_without_leading_dot]] == -1
+ } then {
+ append field_1 $field_2
+ set field_2 $field_1
+ set field_1 {}
+ if {[string toupper $field_0] != {ENDM} && [string toupper $field_0] != {.ENDM}} {
+ set field_1 $field_0
+ set field_0 {}
+ }
}
# If line contains only comment then Field 3 -> Field 1
if {
- $field_3 != {} &&
- $field_0 == {} &&
- $field_1 == {} &&
- $field_2 == {} &&
- $commentBegin != 0
- } {
- set field_1 $field_3
- set field_3 {}
+ $field_3 != {} &&
+ $field_0 == {} &&
+ $field_1 == {} &&
+ $field_2 == {} &&
+ $commentBegin != 0
+ } then {
+ set field_1 $field_3
+ set field_3 {}
}
# Adjust space between operans/arguments
@@ -6675,13 +6897,13 @@ namespace eval X {
if {$field_2 != {}} {
# Strings/Chars to underscores
set field_2_tmp $field_2
- while 1 {
+ while {1} {
if {![regexp {'[^']+'} $field_2_tmp str]} {break}
set len [string length $str]
regsub {'[^']+'} $field_2_tmp [string repeat {_} $len] field_2_tmp
}
# Recomposite Field 2
- while 1 {
+ while {1} {
set i [string first {,} $field_2_tmp]
if {$i == -1} {
append field_2_new {, }
@@ -6714,7 +6936,7 @@ namespace eval X {
set correction 0
set falseLength [string length $line]
- while 1 {
+ while {1} {
set i [string first "\t" $line [expr {$i + 1}]]
if {$i == -1} {break}
@@ -6756,18 +6978,18 @@ namespace eval X {
if {$critical_procedure_in_progress} {return}
# Create dialog window
- set win [toplevel .cleanup -class [mc "Options dialog"] -bg {#EEEEEE}]
+ set win [toplevel .cleanup -class [mc "Options dialog"] -bg ${::COMMON_BG_COLOR}]
set bottom_frame [frame $win.buttonFrame]
set status_bar_lbl [label $bottom_frame.status_bar \
-justify left -anchor w \
]
# Create label frames
- set backup_labelframe [ttk::labelframe $win.backup_labelframe\
- -text [mc "Backup files"] \
+ set backup_labelframe [ttk::labelframe $win.backup_labelframe \
+ -text [mc "Backup files"] \
]
set other_labelframe [ttk::labelframe $win.other_labelframe \
- -text [mc "Other files"] \
+ -text [mc "Other files"] \
]
set i 0 ;# Checkbutton index
@@ -6794,7 +7016,7 @@ namespace eval X {
{HTML files}
{TeX sources}
{Register watches definition files}
- {MCU 8051 IDE Project}
+ {MCU 8051 IDE project}
{Hibernated programs}
{SDCC debug files}
{SDCC IHEX8 object files}
@@ -6804,7 +7026,7 @@ namespace eval X {
{C sources}
{C headers}
{Virtual Hardware Component}
- {Virtual HardWare}
+ {Virtual Hardware}
{Text files}
{All backup files}
} \
@@ -6816,7 +7038,11 @@ namespace eval X {
-variable __cleanup_$ID \
]
grid $button -row $row -column $col -sticky w -padx 5
- if {[lindex $::CONFIG(CLEANUP_OPTIONS) $i] != {0}} {$button select} {$button deselect}
+ if {[lindex $::CONFIG(CLEANUP_OPTIONS) $i] != {0}} {
+ $button select
+ } else {
+ $button deselect
+ }
bind $button <Enter> "$status_bar_lbl configure -text {$helptext}"
bind $button <Leave> "$status_bar_lbl configure -text {}"
@@ -6850,7 +7076,7 @@ namespace eval X {
{TeX sources}
{Hibernated programs}
{ASL: NoICE-compatible command file}
- {ASL: Atmel debub file used by the AVR tools}
+ {ASL: Atmel debug file used by the AVR tools}
{SDCC: The memory map for the load module}
{ASL object files}
{Macro definition file}
@@ -6862,7 +7088,7 @@ namespace eval X {
{SDCC debug files}
{SDCC: A file with a summary of the memory usage}
{SDCC: Linker script}
- {SDCC: Symbol listing for the sourcefile}
+ {SDCC: Symbol listing for the source file}
{OMF-51 object files}
{SDCC: Listing file updated with linkedit information}
{MD5 hashes for C source files}
@@ -6876,7 +7102,11 @@ namespace eval X {
-variable __cleanup__$ID \
]
grid $button -row $row -column $col -sticky w -padx 5
- if {[lindex $::CONFIG(CLEANUP_OPTIONS) $i] != {0}} {$button select} {$button deselect}
+ if {[lindex $::CONFIG(CLEANUP_OPTIONS) $i] != {0}} {
+ $button select
+ } else {
+ $button deselect
+ }
bind $button <Enter> "$status_bar_lbl configure -text {$helptext}"
bind $button <Leave> "$status_bar_lbl configure -text {}"
@@ -6909,13 +7139,13 @@ namespace eval X {
-compound left \
-image ::ICONS::16::ok \
-command {X::cleanup_OK} \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $win.buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command {X::cleanup_CANCEL} \
- ] -side left
+ ] -side left -padx 2
pack $bottom_frame -pady 5 -fill x -padx 5
# Events binding (Enter == Ok; Esc == Cancel)
@@ -6949,74 +7179,95 @@ namespace eval X {
# @return void
proc cleanup_OK {} {
variable cleanup_masks ;# GLOB patterns
+ variable cleanup_files ;# List: Files marked for potential removal
variable actualProject ;# Object: Current project
- # Invoke confirmation dialog
- if {
- ![tk_messageBox \
- -parent . \
- -icon question \
- -type yesno \
- -title [mc "Cleanup project folder"] \
- -message [mc "Are you sure ?"]
- ]
- } {
- return
- }
-
# Determinate list of GLOB expressions of selected for removal
set dir [$actualProject cget -projectPath]
- set files [list]
+ set cleanup_files [list]
foreach mask $cleanup_masks bool $::CONFIG(CLEANUP_OPTIONS) {
if {$bool} {
- lappend files $mask
+ lappend cleanup_files $mask
}
}
# Determinate list of files selected for removal
set files_n [list]
catch { ;# For Microsoft Windows it has to be enclosed by catch
- foreach f $files {
+ foreach f $cleanup_files {
append files_n { } [glob -directory $dir -nocomplain -type f $f]
}
}
- set files $files_n
+ set cleanup_files [lsort -unique $files_n]
+
+ # Finalize
+ cleanup_ask
+ }
+
+ ## Proceed with the project folder clean up
+ # @return void
+ proc cleanup_PROCEED {} {
+ variable cleanup_files ;# List: Files marked for potential removal
+
+ # Invoke confirmation dialog
+ if {
+ [tk_messageBox \
+ -parent .cleanup_ask \
+ -icon question \
+ -type yesno \
+ -title [mc "Cleanup project folder"] \
+ -message [mc "Are you sure ?"] \
+ ] != {yes}
+ } then {
+ return
+ }
# Remove the specified files
- set result {}
- foreach file $files {
- if {![catch {
+ set count 0
+ foreach file $cleanup_files {
+ if {[catch {
file delete -force -- $file
- }]} {
- lappend result $file
+ }]} then {
+ puts stderr "Unable to delete file: $file"
+ } else {
+ incr count
}
}
- # Finalize
+ tk_messageBox \
+ -parent .cleanup_ask \
+ -icon info \
+ -type ok \
+ -title [mc "Cleanup project folder"] \
+ -message [mc "%d file(s) removed." $count]
+
cleanup_CANCEL ;# Close dialog window
- cleanup_finish $result ;# Invoke results dialog
}
## Close dialog "Clean up project folder" -- auxiliary procedure for 'cleanup_OK'
# @return void
proc cleanup_CANCEL {} {
+ variable cleanup_files ;# List: Files marked for potential removal
+ set cleanup_files [list]
+
destroy .cleanup
}
## Show results of files removal -- auxiliary procedure for 'cleanup_OK'
- # @parm List files - list of removed files
# @return void
- proc cleanup_finish {files} {
+ proc cleanup_ask {} {
+ variable cleanup_files ;# List: Files marked for potential removal
+
# Create dialog window
- set win [toplevel .cleanup_finish -class {Results} -bg {#EEEEEE}]
+ set win [toplevel .cleanup_ask -class {Confirmation dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
- pack [label $win.header_label \
- -text [mc "These files were removed"] \
- -font [font create \
- -size -20 \
+ pack [label $win.header_label \
+ -text [mc "These files will be removed"] \
+ -font [font create \
+ -size [expr {int(-20 * $::font_size_factor)}] \
-family {helvetica}]
- ] -anchor center
+ ] -anchor center -side top -fill x
# Create top frame (text widget and scrollbar)
set frame [frame $win.top_frame]
@@ -7033,7 +7284,12 @@ namespace eval X {
]
# Fill in the text widget
- foreach txt $files {
+ foreach txt $cleanup_files {
+ # On MS Windows change '/' to '\' in file path
+ if {$::MICROSOFT_WINDOWS} {
+ regsub -all {/} $txt "\\" txt
+ }
+
$text insert end $txt
$text insert end "\n"
}
@@ -7042,20 +7298,27 @@ namespace eval X {
# Pack scrollbar and the text widget
pack $scrollbar -side right -fill y
pack $text -side left -fill both -expand 1
+ pack $frame -side top -fill both -expand 1 -pady 5 -padx 5
# Pack the top frame and create button "Ok"
- pack $frame -fill both -expand 1
- pack [ttk::button $win.ok_button \
- -text [mc "Ok"] \
+ set but_frame [frame $win.but_frame]
+ pack [ttk::button $but_frame.ok_button \
+ -text [mc "Proceed"] \
-compound left \
-image ::ICONS::16::ok \
- -command "destroy $win" \
- ] -anchor center -side bottom
-
- # Events binding (Enter/Escape == Ok)
- bind $win <KeyRelease-Return> "destroy $win; break"
- bind $win <KeyRelease-KP_Enter> "destroy $win; break"
- bind $win <KeyRelease-Escape> "destroy $win; break"
+ -command "
+ ::X::cleanup_PROCEED
+ destroy $win
+ " \
+ ] -side left -padx 5
+ pack [ttk::button $but_frame.cancel_button \
+ -text [mc "Cancel"] \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command [list destroy $win] \
+ ] -side left -padx 5
+ focus -force $but_frame.ok_button
+ pack $but_frame -side bottom -anchor e -pady 5 -pady 5
# Set window attributes -- modal window
wm iconphoto $win ::ICONS::16::emptytrash
@@ -7094,12 +7357,17 @@ namespace eval X {
-icon warning \
-type yesno \
-title [mc "Confirm termination - MCU 8051 IDE"] \
- -message [mc "This process is alredy in progress. Do you want to terminate it ?"]
+ -message [mc "This process is already in progress. Do you want to terminate it ?"]
] == {yes}} {
if {!$::MICROSOFT_WINDOWS} { ;# There is no kill command on Microsoft Windows
if {$custom_command_PID($cmd_num) != {}} {
- catch {
- exec -- kill -9 $custom_command_PID($cmd_num) &
+ foreach pid $custom_command_PID($cmd_num) {
+ if {$pid == [pid] || $pid == 0} {
+ continue
+ }
+ catch {
+ exec -- /bin/sh -c "kill -s 9 \$(ps -o pid --no-headers --ppid $pid)"
+ }
}
}
}
@@ -7112,13 +7380,14 @@ namespace eval X {
# Invoke confiramation dialog (if requested)
if {[lindex $custom_command_options($cmd_num) 0]} {
if {
- ![tk_messageBox \
- -parent . \
- -icon question \
- -type yesno \
+ [tk_messageBox \
+ -parent . \
+ -icon question \
+ -type yesno \
-title [mc "Confirmation required"] \
- -message [mc "Do you really want to execute\ncustom command %s ?" $cmd_num]]
- } {
+ -message [mc "Do you really want to execute\ncustom command %s ?" $cmd_num] \
+ ] != {yes}
+ } then {
set critical_procedure_in_progress 0
return
}
@@ -7137,20 +7406,22 @@ namespace eval X {
# Determinate editor object reference
set editor [$actualProject get_current_editor_object]
- if {[regexp {%URLS} $cmd]} {
- set URLS {}
+ regsub -all {%URL} $cmd {%URI} cmd
+
+ if {[regexp {%URIS} $cmd]} {
+ set URIS {}
foreach e [$actualProject cget -editors] {
set url [$e cget -fullFileName]
if {[regexp {\s} $url]} {
- append URLS "\"" $url "\"" { }
- } {
- append URLS $url { }
+ append URIS "\"" $url "\"" { }
+ } else {
+ append URIS $url { }
}
}
- regsub -all {%URLS} $cmd [string replace $URLS end end] cmd
+ regsub -all {%URIS} $cmd [string replace $URIS end end] cmd
}
- if {[regexp {%URL} $cmd]} {
- regsub -all {%URL} $cmd [$editor cget -fullFileName] cmd
+ if {[regexp {%URI} $cmd]} {
+ regsub -all {%URI} $cmd [$editor cget -fullFileName] cmd
}
if {[regexp {%directory} $cmd]} {
regsub -all {%directory} $cmd [$actualProject cget -projectPath] cmd
@@ -7178,7 +7449,7 @@ namespace eval X {
if {[regexp {%text} $cmd]} {
regsub -all {%text} $cmd [$editor getdata] cmd
}
- } {
+ } else {
if {[regsub -all {%(line|column|selection|text)} $cmd {} cmd]} {
tk_messageBox \
-parent . \
@@ -7191,12 +7462,19 @@ namespace eval X {
}
regsub -all "\a" $cmd {%} cmd
- # Execute specified command in a separate thread
+ ## Execute the specified command
set custom_command_NUM($cmd_num) $custom_command_counter
- set custom_command_PID($cmd_num) [exec -- tclsh \
- ${::LIB_DIRNAME}/custom_command.tcl [tk appname] \
- $custom_command_NUM($cmd_num) << $cmd & \
- ]
+ # Run in terminal
+ if {[lindex $custom_command_options($cmd_num) 3] && $::PROGRAM_AVAILABLE(urxvt)} {
+ exec_custom_cmd_in_terminal $cmd_num $cmd
+ custom_cmd_icon_reset $custom_command_NUM($cmd_num)
+ # Run normally
+ } else {
+ set custom_command_PID($cmd_num) [exec -- tclsh \
+ ${::LIB_DIRNAME}/custom_command.tcl [tk appname] \
+ $custom_command_NUM($cmd_num) << $cmd & \
+ ]
+ }
incr custom_command_counter
# Finalize
@@ -7215,7 +7493,7 @@ namespace eval X {
set i [custom_cmd_icon_reset $num]
if {$i == {}} {return}
- # Check if result dialogs are allowed
+ # Check if result dialogues are allowed
if {![lindex $custom_command_options($i) 1]} {return}
# Invoke results dialog
invoke_custom_cmd_dialog $i {#00DD00} [mc "Custom command finished"] $result
@@ -7233,12 +7511,107 @@ namespace eval X {
set i [custom_cmd_icon_reset $num]
if {$i == {}} {return}
- # Check if error dialogs are allowed
+ # Check if error dialogues are allowed
if {[lindex $custom_command_options($i) 2]} {return}
# Invoke error dialog
invoke_custom_cmd_dialog $i {#DD0000} [mc "Custom command failed"] $result
}
+ ## Execute custom command in terminal emulator
+ # @parm Int cmd_num - Number of the custom command to execute
+ # @parm String cmd - Command string to execute
+ # @return void
+ proc exec_custom_cmd_in_terminal {cmd_num cmd} {
+ variable custom_cmd_dialog_index ;# Index of results dialog (to keep win IDs unique)
+
+ incr custom_cmd_dialog_index
+
+ # Create dialog window
+ set win [toplevel .custom_cmd_dialog${custom_cmd_dialog_index} -class {Custom command running} -bg ${::COMMON_BG_COLOR}]
+
+ # Create dialog header
+ pack [label $win.header_label \
+ -compound left \
+ -text [mc "Custom command %s - MCU 8051 IDE" $cmd_num] \
+ -image ::ICONS::22::gear${cmd_num}_play \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-20 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
+ ] -pady 5
+
+ # Create main frame (text widget and scrollbar)
+ set main_frame [frame $win.main_frame -container 1]
+ bind $main_frame <Destroy> [list destroy $win]
+ pack $main_frame -fill both -expand 1 -padx 5 -pady 5
+
+ # Set window attributes
+ wm iconphoto $win ::ICONS::16::gear
+ wm title $win [mc "Custom command %s - MCU 8051 IDE" $cmd_num]
+ wm minsize $win 550 300
+ wm protocol $win WM_DELETE_WINDOW {}
+ update
+
+ # Run terminal emulator
+ if {[catch {
+ set terminal_pid [exec -- urxvt \
+ -embed [expr [winfo id $main_frame]] \
+ -hold -sr -b 0 -w 0 -bg ${::Terminal::configuration(bg)}\
+ -fg ${::Terminal::configuration(fg)} \
+ -fn "xft:${::Terminal::configuration(font_family)}:pixelsize=${::Terminal::configuration(font_size)}" \
+ -e bash -i -c $cmd \
+ & \
+ ]
+ } result]} then {
+ destroy $win
+ tk_messageBox \
+ -parent . \
+ -icon warning \
+ -type ok \
+ -title [mc "Unknow error"] \
+ -message [mc "Unable to execute your script in the urxvt terminal emulator."]
+ puts stderr $result
+ } else {
+ wm protocol $win WM_DELETE_WINDOW [list ::X::close_custom_cmd_term $terminal_pid $win]
+ }
+ }
+
+ ## Close terminal emulator with a custom command
+ # @parm Int pid - Terminal PID
+ # @parm Widget dialog - Dialog window in which the terminal is mapped
+ # @return void
+ proc close_custom_cmd_term {pid dialog} {
+ # Get list of child processes of the terminal
+ set children [list]
+ catch {
+ set children [exec -- /bin/sh -c "ps -o pid --no-headers --ppid $pid"]
+ }
+
+ # Ask user, if he/she wishes to kill the children, if there are any
+ if {
+ [llength $children]
+ &&
+ [tk_messageBox \
+ -parent $dialog \
+ -icon question \
+ -type yesno \
+ -title [mc "Kill the script?"] \
+ -message [mc "Closing this window terminates all child processes of the terminal.\n\nDo you want to proceed?"] \
+ ] != {yes}
+ } then {
+ return
+ }
+
+ # Kill the terminal
+ if {[catch {
+ exec -- kill $pid &
+ }]} then {
+ puts stderr "Something went wrong here..."
+ puts stderr $::errorInfo
+ }
+ }
+
## Invoke dialog window showing results of some custom command
# -- auxiliary procedure for 'custom_cmd_error' and 'custom_cmd_finish'
# @parm Int i - Index of the custom command (0..2)
@@ -7252,18 +7625,18 @@ namespace eval X {
incr custom_cmd_dialog_index
# Create dialog window
- set win [toplevel .custom_cmd_dialog${custom_cmd_dialog_index} -class {Custom command finished} -bg {#EEEEEE}]
+ set win [toplevel .custom_cmd_dialog${custom_cmd_dialog_index} -class {Custom command finished} -bg ${::COMMON_BG_COLOR}]
# Create dialog header
- pack [label $win.header_label \
- -compound left \
- -fg $color \
- -text $label \
- -image ::ICONS::22::gear$i \
- -font [font create \
- -family {helvetica} \
- -size -20 \
- -weight bold \
+ pack [label $win.header_label \
+ -compound left \
+ -fg $color \
+ -text $label \
+ -image ::ICONS::22::gear$i \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-20 * $::font_size_factor)}] \
+ -weight bold \
] \
] -pady 5
@@ -7305,16 +7678,16 @@ namespace eval X {
wm transient $win .
}
- ## Set toolbar button icon to default and determinate index of cutom command
+ ## Set toolbar button icon to default and determinate index of custom command
# -- auxiliary procedure for 'custom_cmd_error' and 'custom_cmd_finish'
# @parm Int num - Command number
- # @return Int - index of the specified cutom command (by TID) or {} (means 'not found')
+ # @return Int - index of the specified custom command (by TID) or {} (means 'not found')
proc custom_cmd_icon_reset {num} {
variable custom_command_NUM ;# Array of custom command numbers
variable custom_command_PID ;# Array of custom command TIDs (Thread IDentifiers)
# Search for command index
- set found 0 ;# Bool: Coresponding index found
+ set found 0 ;# Bool: Corresponding index found
for {set i 0} {$i < 3} {incr i} {
if {[string equal $custom_command_NUM($i) $num]} {
set found 1
@@ -7344,46 +7717,71 @@ namespace eval X {
}
# Create dialog window
- set win [toplevel .welcome -class [mc "Welcome dialog"] -bg {#EEEEEE}]
+ set win [toplevel .welcome -class {Welcome dialog} -bg ${::COMMON_BG_COLOR}]
# Create header label
- pack [label $win.header_label \
- -compound left -fg {#0000DD} \
- -text [mc "Welcome to MCU 8051 IDE !"] \
- -font [font create \
- -family {helvetica} \
- -size -20 \
- -weight {bold} \
- -slant {italic} \
- ] \
+ pack [label $win.header_label \
+ -compound left -fg {#0000DD} \
+ -text [mc "Welcome to MCU 8051 IDE !"] \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-20 * $::font_size_factor)}] \
+ -weight {bold} \
+ -slant {italic} \
+ ] \
] -pady 10
+ # Create frame for the text widget and its scrollbar
+ set text_frame [frame $win.text_frame]
+
# Create text widget showing the dialog message
- set text [text $win.text \
- -bg {#EEEEEE} -takefocus 0 \
- -width 0 -heigh 0 -bd 0 \
- -cursor left_ptr \
- -wrap word \
- -font [font create \
- -family {helvetica} \
- -size -12 \
- ] \
+ set text [text $text_frame.text \
+ -bg ${::COMMON_BG_COLOR} -takefocus 0 \
+ -width 0 -heigh 0 -bd 0 \
+ -cursor left_ptr \
+ -wrap word \
+ -yscrollcommand [list $text_frame.scrollbar set] \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ ] \
+ ]
+
+ # Create scrollbar for the text widget
+ set scrollbar [ttk::scrollbar $text_frame.scrollbar \
+ -command [list $text yview] \
+ -orient vertical \
]
- pack $text -fill both -expand 1 -padx 15
+
+ # Pack scrollbar and the text widget
+ pack $text -side left -fill both -expand 1
+ pack $scrollbar -side right -fill y
+ pack $text_frame -fill both -expand 1 -padx 15
# Create button "Ok"
pack [ttk::button $win.ok_button \
-text [mc "Ok"] \
+ -compound left \
+ -image ::ICONS::16::ok \
-command "grab release $win; destroy $win" \
] -pady 5
# Create label for opening demostration project
set open_demo_label [label $text.open_demo_label \
-text [mc "Click here to open demonstration project."] \
- -justify left -fg {#00DD00} -cursor hand1 \
+ -justify left \
+ -fg {#0055FF} \
+ -cursor hand2 \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ ] \
+ -image ::ICONS::16::2_rightarrow \
+ -compound left \
+ -padx 5 \
]
- bind $open_demo_label <Enter> {%W configure -fg {#0000DD}}
- bind $open_demo_label <Leave> {%W configure -fg {#00DD00}}
+ bind $open_demo_label <Enter> {%W configure -fg {#00DD00}}
+ bind $open_demo_label <Leave> {%W configure -fg {#0055FF}}
bind $open_demo_label <Button-1> "
grab release $win
destroy $win
@@ -7392,59 +7790,76 @@ namespace eval X {
"
# Load images
- set image_new [image create photo -format png \
- -file "${::LIB_DIRNAME}/../icons/16x16/filenew.png"]
- set image_start [image create photo -format png \
- -file "${::LIB_DIRNAME}/../icons/16x16/launch.png"]
- set image_step [image create photo -format png \
- -file "${::LIB_DIRNAME}/../icons/16x16/goto.png"]
+ set image_new ::ICONS::16::filenew
+ set image_start ::ICONS::16::launch
+ set image_step ::ICONS::16::goto
+ set image_list0 ::ICONS::16::dot_r
+ set image_list1 ::ICONS::16::dot_g
+ set image_list2 ::ICONS::16::dot
# Create text tags
- $text tag configure bold -font [font create \
- -family {times} \
- -size -12 \
- -weight bold \
+ $text tag configure bold -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
- $text tag configure header -font [font create \
- -family {times} \
- -size -12 \
- -weight bold \
- -underline 1 \
- ] -foreground {#0000FF}
+ $text tag configure header -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ -underline 1 \
+ ] -foreground {#0000DD}
# Fill in the text widget
- $text insert end [mc "MCU 8051 IDE is fully featured Integrated Development Enviroment"]
- $text insert end [mc " for MCS-51 based microcontollers. It's written for POSIX Operating Systems (GNU/Linux, etc.) "]
+ $text insert end [mc "MCU 8051 IDE is a fully featured Integrated Development Environment"]
+ $text insert end [mc " for MCS-51 based microcontrollers. It's written for POSIX Operating Systems (GNU/Linux, etc.) "]
if {$::MICROSOFT_WINDOWS} {
$text insert end [mc "and since version 1.3.5 it is also available for Microsoft® Windows® operating system."]
}
$text insert end "\n\n"
$text insert end [mc "Main features:"]
$text tag add header {insert linestart} insert
- $text insert end [mc "\n\t- Editor with syntax highlight, validation and popup-based completion"]
- $text insert end [mc "\n\t- MCS-51 Assembler and Disassembler"]
- $text insert end [mc "\n\t- MCS-51 Simulator (not all MCUs are fully supported !)"]
- $text insert end [mc "\n\t- Support for C language (using C compiler SDCC)"]
- $text insert end [mc "\n\t- Partial support for some HW tools"]
- $text insert end [mc "\n\t- Project management"]
- $text insert end [mc "\n\t- Custom editable commands (using shell scripts)"]
- $text insert end [mc "\n\t- Dynamic help for instruction at the current line"]
- $text insert end [mc "\n\t- Hexadecimal editor for eXternal RAM, Expanded RAM, Code memory, etc."]
- $text insert end [mc "\n\t- Scientific calculator"]
- $text insert end [mc "\n\t- Simple hardware simulation (LED's, etc.)"]
- $text insert end [mc "\n\t- Graph showing voltage levels on ports\n\n"]
+ $text insert end "\n\t"
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Editor with syntax highlight, validation and popup-based completion\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "MCS-51 Assembler and Disassembler\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "MCS-51 Simulator (not all MCUs are fully supported!)\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Support for C language (using C compiler SDCC)\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Partial support for some HW tools\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Project management\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Custom editable commands (using shell scripts)\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Dynamic help for instruction at the current line\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Hexadecimal editor for eXternal RAM, Expanded RAM, Code memory, etc.\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Scientific calculator\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Simple hardware simulation (LED's, etc.)\n\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Graph showing voltage levels on ports\n\n"]
$text insert end [mc "Where to start:"]
$text tag add header {insert linestart} insert
$text insert end [mc "\n\t1. Create a new project"]
$text image create end -image $image_new -padx 5
- $text insert end [mc "\n\t\t- Enter project name\n"]
- $text insert end [mc "\t\t- Choose project directory\n"]
- $text insert end [mc "\t\t- Choose microcontroller (e.g. AT89S52)\n"]
+ $text insert end "\n\t\t"
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Enter project name\n\t\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Choose project directory\n\t\t"]
+ $text image create end -image $image_list1 -padx 5
+ $text insert end [mc "Choose microcontroller (e.g. AT89S52)\n"]
$text insert end [mc "\t2. Write your code in the opened editor and click on "]
$text image create end -image $image_start -padx 5
- $text insert end [mc " to start simulator\n"]
- $text insert end [mc "\t3. Step your program by clicking on "]
+ $text insert end [mc " to start the simulator\n"]
+ $text insert end [mc "\t3. Step through your program by clicking on "]
$text image create end -image $image_step -padx 5
$text insert end "\n\t----\n\t"
$text window create end -window $open_demo_label
@@ -7454,19 +7869,21 @@ namespace eval X {
$text insert end [mc "Web site:"]
$text tag add bold {insert linestart} insert
$text insert end "\thttp://mcu8051ide.sourceforge.net\n"
- $text insert end [mc "Author:"]
+ $text insert end [mc "Authors:"]
$text tag add bold {insert linestart} insert
- $text insert end "\tMartin Ošmera <martin.osmera@gmail.com>\n\n"
+ $text insert end "\tMartin Ošmera <martin.osmera@gmail.com>\n"
$text insert end [mc "Thank you for using/trying MCU 8051 IDE."]
$text tag add bold {insert linestart} insert
+ create_link_tag_in_text_widget $text
+ convert_all_https_to_links $text
$text configure -state disabled
# Set window attributes
wm iconphoto $win ::ICONS::16::info
wm title $win [mc "Welcome to MCU 8051 IDE"]
- wm minsize $win 580 600
+ wm minsize $win 580 400
wm protocol $win WM_DELETE_WINDOW "grab release $win; destroy $win"
wm transient $win .
catch {grab $win}
@@ -7476,7 +7893,12 @@ namespace eval X {
## Open demostration project -- auxiliary procedure for '__welcome_dialog'
# @return void
proc open_demo_project {} {
- Project::open_project_file "${::LIB_DIRNAME}/../demo/Demo project.mcu8051ide"
+ variable openedProjects ;# List of opened projects (Object references)
+
+ if {[Project::open_project_file "${::INSTALLATION_DIR}/demo/Demo project.mcu8051ide"]} {
+ # The demostration project is for reading only, it cannot be saved
+ [lindex $openedProjects end] set_read_only
+ }
}
## Invoke dialog "Change letter case"
@@ -7492,15 +7914,15 @@ namespace eval X {
if {$critical_procedure_in_progress} {return}
# Create dialog window
- set win [toplevel .change_letter_case -class [mc "Options dialog"] -bg {#EEEEEE}]
+ set win [toplevel .change_letter_case -class [mc "Options dialog"] -bg ${::COMMON_BG_COLOR}]
# Create dialog header
- pack [label $win.header \
- -compound left \
- -image ::ICONS::22::change_case \
- -text [mc "Change letter case"] \
- -font [font create \
- -size -20 \
+ pack [label $win.header \
+ -compound left \
+ -image ::ICONS::22::change_case \
+ -text [mc "Change letter case"] \
+ -font [font create \
+ -size [expr {int(-20 * $::font_size_factor)}] \
-family {times}]
] -side top -pady 5
@@ -7529,15 +7951,16 @@ namespace eval X {
{Hexadecimal number} {Octal number}
{Decimal number} {Binary number}
{Constant} {Generic number}
- {Comment} {Control sequentce}
+ {Comment} {Control sequence}
{Symbol} {Directive}
{Label} {Instruction}
- {SFR register} {Indirect adress}
+ {SFR register} {Indirect address}
{Immediate hex} {Immediate oct}
{Immediate dec} {Immediate bin}
{Immediate const} {Immediate generic}
{Macro instruction}
- } {
+ } \
+ {
# Create label
grid [label $main_frame.label$i \
-text [mc $text] -justify left \
@@ -7547,17 +7970,17 @@ namespace eval X {
# Radiobutton "Uppercase"
grid [radiobutton $main_frame.upper$i \
- -value [mc "U"] -highlightthickness 0 -pady 0 \
+ -value {U} -highlightthickness 0 -pady 0 \
-variable ::X::change_letter_case_options($i) \
] -row $row -column [expr {$col * 4 + 1}] -sticky w
# Radiobutton "Lowercase"
grid [radiobutton $main_frame.lower$i \
- -value [mc "L"] -highlightthickness 0 -pady 0 \
+ -value {L} -highlightthickness 0 -pady 0 \
-variable ::X::change_letter_case_options($i) \
] -row $row -column [expr {$col * 4 + 2}] -sticky w
# Radiobutton "Keep"
grid [radiobutton $main_frame.keep$i \
- -value [mc "-"] -highlightthickness 0 -pady 0 \
+ -value {-} -highlightthickness 0 -pady 0 \
-variable ::X::change_letter_case_options($i) \
] -row $row -column [expr {$col * 4 + 3}] -sticky w
@@ -7585,7 +8008,7 @@ namespace eval X {
-text [mc "All "] \
-image ::ICONS::16::$image \
-command "::X::change_letter_case_all_to $state" \
- ] -side left
+ ] -side left -padx 2
}
# Create and pack buttons "OK" and "CANCEL"
pack [ttk::button $button_frame.ok_button \
@@ -7593,13 +8016,13 @@ namespace eval X {
-compound left \
-image ::ICONS::16::ok \
-command {X::change_letter_case_OK} \
- ] -side right
+ ] -side right -padx 2
pack [ttk::button $button_frame.cancel_button \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command {X::change_letter_case_CANCEL} \
- ] -side right
+ ] -side right -padx 2
# Events binding (Enter == Ok; Escape == Cancel)
bind $win <KeyRelease-Return> {::X::change_letter_case_OK; break}
@@ -7608,7 +8031,7 @@ namespace eval X {
# Pack frames
pack $main_frame -fill both -expand 1 -padx 10 -pady 10
- pack $button_frame -side bottom -fill x
+ pack $button_frame -side bottom -fill x -padx 5 -pady 5
# Set window attributes
wm iconphoto $win ::ICONS::16::change_case
@@ -7665,11 +8088,12 @@ namespace eval X {
[$actualProject editor_procedure {} getLinesCount {}] == 1
&&
[$actualProject editor_procedure {} getLineContent 1] == {}
- } {
+ } then {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "This editor seems to be empty"]
return
}
@@ -7681,7 +8105,7 @@ namespace eval X {
incr max
# Create progress dialog window
- set win [toplevel .change_letter_case_dialog -class {Progress dialog} -bg {#EEEEEE}]
+ set win [toplevel .change_letter_case_dialog -class {Progress dialog} -bg ${::COMMON_BG_COLOR}]
# Create label and progress bar
set main_frame [frame $win.main_frame]
@@ -7722,11 +8146,11 @@ namespace eval X {
$actualProject editor_procedure {} highlight_all {}
if {![winfo exists $win]} {return}
- # Determinate maximum value for the 2nd progress bar ("Formating")
+ # Determinate maximum value for the 2nd progress bar ("Formatting")
set max [$actualProject editor_procedure {} change_letter_case_get_count_of_iterations "{$options}"]
incr max
# Change progress bar header label
- $main_frame.header configure -text [mc "Formating ..."]
+ $main_frame.header configure -text [mc "Formatting ..."]
$main_frame.progress_bar configure -maximum $max
set compilation_progress 1 ;# Reset compilation progress variable
@@ -7833,7 +8257,10 @@ namespace eval X {
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
if {$project_menu_locked} {return}
- $actualProject switch_editor_RO_MODE
+ if {![$actualProject switch_editor_RO_MODE]} {
+ # Switch the flag back if the operation was unsuccessful
+ set ::editor_RO_MODE [expr {!$::editor_RO_MODE}]
+ }
}
## Prepare window "Project details"
@@ -7852,7 +8279,7 @@ namespace eval X {
if {$projectdetails_last_project == $project} {
project_details_move
return
- } {
+ } else {
set projectdetails_last_project $project
}
@@ -7869,7 +8296,6 @@ namespace eval X {
# Create window
set PROJECTDETAILSWIN [frame .project_details_win -bg {#BBBBFF}]
set project_details_win [frame $PROJECTDETAILSWIN.frm -bg {#FFFFFF}]
- bind $PROJECTDETAILSWIN <Button-1> "catch {destroy $PROJECTDETAILSWIN}"
# Create header
pack [label $project_details_win.header \
@@ -7893,13 +8319,17 @@ namespace eval X {
-anchor w -pady 0 -bg {#FFFFFF} \
] -row 0 -column 1 -sticky w -pady 0
# Path
- grid [label $main_frame.path_label \
- -text [mc "Path:"] -fg {#880033} \
- -anchor w -pady 0 -bg {#FFFFFF} \
+ grid [label $main_frame.path_label \
+ -text [mc "Path:"] -fg {#880033}\
+ -anchor w -pady 0 -bg {#FFFFFF} \
] -row 1 -column 0 -sticky w -pady 0
- grid [label $main_frame.path_value \
- -text [$project cget -projectPath] \
- -anchor w -pady 0 -bg {#FFFFFF} \
+ set path [$project cget -projectPath]
+ if {$::MICROSOFT_WINDOWS} {
+ regsub -all {/} $path "\\" path
+ }
+ grid [label $main_frame.path_value \
+ -text $path \
+ -anchor w -pady 0 -bg {#FFFFFF} \
] -row 1 -column 1 -sticky w -pady 0
# Separator
@@ -7943,10 +8373,10 @@ namespace eval X {
-anchor w -pady 0 -bg {#FFFFFF} \
] -row 6 -column 1 -sticky w -pady 0
- set more_details_avaliable 0
+ set more_details_available 0
# Version
if {[string length [$project cget -P_information_version]]} {
- set more_details_avaliable 1
+ set more_details_available 1
grid [label $main_frame.ver_label \
-text [mc "Version:"] -fg {#0000AA} \
-anchor w -pady 0 -bg {#FFFFFF} \
@@ -7958,7 +8388,7 @@ namespace eval X {
}
# Date
if {[string length [$project cget -P_information_date]]} {
- set more_details_avaliable 1
+ set more_details_available 1
grid [label $main_frame.date_label \
-text [mc "Date:"] -fg {#0000AA} \
-anchor w -pady 0 -bg {#FFFFFF} \
@@ -7968,22 +8398,22 @@ namespace eval X {
-text [$project cget -P_information_date] \
] -row 9 -column 1 -sticky w -pady 0
}
- # Licence
- if {[string length [$project cget -G_information_licence]]} {
- set more_details_avaliable 1
- grid [label $main_frame.licence_label \
- -text [mc "Licence:"] \
+ # License
+ if {[string length [$project cget -G_information_license]]} {
+ set more_details_available 1
+ grid [label $main_frame.license_label \
+ -text [mc "License:"] \
-fg {#0000AA} \
-anchor w -pady 0 -bg {#FFFFFF} \
] -row 10 -column 0 -sticky w -pady 0
- grid [label $main_frame.licence_value \
- -text [$project cget -G_information_licence] \
+ grid [label $main_frame.license_value \
+ -text [$project cget -G_information_license] \
-anchor w -pady 0 -bg {#FFFFFF} \
] -row 10 -column 1 -sticky w -pady 0
}
# Copyright
if {[string length [$project cget -G_information_copyright]]} {
- set more_details_avaliable 1
+ set more_details_available 1
grid [label $main_frame.copyright_label \
-text [mc "Copyright:"] \
-fg {#0000AA} -bg {#FFFFFF} \
@@ -7996,7 +8426,7 @@ namespace eval X {
}
# Authors
if {[string length $authors]} {
- set more_details_avaliable 1
+ set more_details_available 1
grid [label $main_frame.authors_label \
-text [mc "Authors:"] \
-fg {#0000AA} \
@@ -8008,7 +8438,7 @@ namespace eval X {
] -row 12 -column 1 -sticky w -pady 0
}
# Separator
- if {$more_details_avaliable} {
+ if {$more_details_available} {
grid [ttk::separator $main_frame.sep1 -orient horizontal \
] -row 7 -column 0 -columnspan 2 -sticky we -pady 5
}
@@ -8018,6 +8448,11 @@ namespace eval X {
pack $main_frame -fill both -expand 1 -padx 8 -pady 3
pack $project_details_win -fill both -expand 1 -padx 2 -pady 2
+ # Configure the window in a way that it will close when the user clicks on it
+ foreach w [concat $project_details_win [pack slaves $project_details_win] [grid slaves $main_frame]] {
+ bind $w <Button-1> {::X::close_project_details}
+ }
+
# Show window "Project details"
project_details_move
}
@@ -8041,7 +8476,6 @@ namespace eval X {
# @return void
proc close_project_details args {
variable PROJECTDETAILSWIN ;# ID of project details window
- variable projectdetails_last_project ;# Project object of the last project details window
# Hide the window
catch {place forget $PROJECTDETAILSWIN}
@@ -8063,18 +8497,18 @@ namespace eval X {
}
# Enable/Disable menu entries
- set tabindex [.mainFrame.mainNB index $project]
+ set tabindex [${::main_nb} index $project]
if {!$tabindex} {
$projectmenu entryconfigure [::mc "Move to beginning"] -state disabled
$projectmenu entryconfigure [::mc "Move left"] -state disabled
- } {
+ } else {
$projectmenu entryconfigure [::mc "Move to beginning"] -state normal
$projectmenu entryconfigure [::mc "Move left"] -state normal
}
- if {$tabindex == ([llength [.mainFrame.mainNB pages]] - 1)} {
+ if {$tabindex == ([llength [${::main_nb} pages]] - 1)} {
$projectmenu entryconfigure [::mc "Move right"] -state disabled
$projectmenu entryconfigure [::mc "Move to end"] -state disabled
- } {
+ } else {
$projectmenu entryconfigure [::mc "Move right"] -state normal
$projectmenu entryconfigure [::mc "Move to end"] -state normal
}
@@ -8140,7 +8574,7 @@ namespace eval X {
set actualProjectIdx [lsearch -exact -ascii $openedProjects $actualProject]
if {$actualProjectIdx == $tmp_idx} {
set this_closed 1
- } {
+ } else {
set this_closed 0
}
@@ -8164,7 +8598,7 @@ namespace eval X {
set actualProjectIdx [lsearch -exact -ascii $openedProjects $actualProject]
if {$actualProjectIdx == $tmp_idx} {
set this_closed 1
- } {
+ } else {
set this_closed 0
}
@@ -8184,13 +8618,13 @@ namespace eval X {
proc __project_move_to_left {} {
variable projectmenu_project ;# Object: project selected by project popup menu
- set index [.mainFrame.mainNB index $projectmenu_project]
+ set index [${::main_nb} index $projectmenu_project]
if {!$index} {
return
}
incr index -1
- .mainFrame.mainNB move $projectmenu_project $index
+ ${::main_nb} move $projectmenu_project $index
}
## Function for project popup menu
@@ -8199,13 +8633,13 @@ namespace eval X {
proc __project_move_to_right {} {
variable projectmenu_project ;# Object: project selected by project popup menu
- set index [.mainFrame.mainNB index $projectmenu_project]
- if {$index == ([llength [.mainFrame.mainNB index pages]] - 1)} {
+ set index [${::main_nb} index $projectmenu_project]
+ if {$index == ([llength [${::main_nb} index pages]] - 1)} {
return
}
incr index
- .mainFrame.mainNB move $projectmenu_project $index
+ ${::main_nb} move $projectmenu_project $index
}
## Function for project popup menu
@@ -8214,10 +8648,10 @@ namespace eval X {
proc __project_move_to_beginning {} {
variable projectmenu_project ;# Object: project selected by project popup menu
- if {![.mainFrame.mainNB index $projectmenu_project]} {
+ if {![${::main_nb} index $projectmenu_project]} {
return
}
- .mainFrame.mainNB move $projectmenu_project 0
+ ${::main_nb} move $projectmenu_project 0
}
## Function for project popup menu
@@ -8226,12 +8660,12 @@ namespace eval X {
proc __project_move_to_end {} {
variable projectmenu_project ;# Object: project selected by project popup menu
- set end [expr {[llength [.mainFrame.mainNB pages]] - 1}]
- if {[.mainFrame.mainNB index $projectmenu_project] == $end} {
+ set end [expr {[llength [${::main_nb} pages]] - 1}]
+ if {[${::main_nb} index $projectmenu_project] == $end} {
return
}
- .mainFrame.mainNB move $projectmenu_project $end
+ ${::main_nb} move $projectmenu_project $end
}
## Invert flag "allow breakpoints"
@@ -8240,7 +8674,7 @@ namespace eval X {
set ::CONFIG(BREAKPOINTS_ALLOWED) [expr {!$::CONFIG(BREAKPOINTS_ALLOWED)}]
}
- ## Refresh bookmarks in filesystem browser in all projects
+ ## Refresh bookmarks in file system browser in all projects
# @return void
proc refresh_bookmarks_in_fs_browsers {} {
variable openedProjects ;# List of opened projects (Object references)
@@ -8261,16 +8695,16 @@ namespace eval X {
# @parm Int new_PC - New value of PC (-1 after reset)
# @return void
proc program_counter_changed {project new_PC} {
- variable opended_code_mem_windows ;# List of project object with opened CODE memory hex editor
+ variable opened_code_mem_windows ;# List of project object with opened CODE memory hex editor
variable code_mem_window_objects ;# List of CODE memory hex editor objects
- set idx [lsearch -exact -ascii $opended_code_mem_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_code_mem_windows [string trimleft $project {:}]]
if {$idx != -1} {
set opcode [$project getCode $new_PC]
- if {[lsearch ${CompilerConsts::defined_OPCODE} $opcode] == -1} {
+ if {[lsearch ${::CompilerConsts::defined_OPCODE} $opcode] == -1} {
set ins_length 1
- } {
- set ins_length [lindex $CompilerConsts::Opcode($opcode) 2]
+ } else {
+ set ins_length [lindex $::CompilerConsts::Opcode($opcode) 2]
}
[lindex $code_mem_window_objects $idx] move_program_pointer $new_PC $ins_length
}
@@ -8281,19 +8715,19 @@ namespace eval X {
# @parm Int new_PC - New value of PC (-1 after reset)
# @return void
proc code_hex_editor_directly_move_program_pointer {project new_PC} {
- variable opended_code_mem_windows ;# List of project object with opened CODE memory hex editor
+ variable opened_code_mem_windows ;# List of project object with opened CODE memory hex editor
variable code_mem_window_objects ;# List of CODE memory hex editor objects
- set idx [lsearch -exact -ascii $opended_code_mem_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_code_mem_windows [string trimleft $project {:}]]
if {$idx != -1} {
if {$new_PC != -1} {
set opcode [$project getCode $new_PC]
- if {[lsearch ${CompilerConsts::defined_OPCODE} $opcode] == -1} {
+ if {[lsearch ${::CompilerConsts::defined_OPCODE} $opcode] == -1} {
set ins_length 1
- } {
- set ins_length [lindex $CompilerConsts::Opcode($opcode) 2]
+ } else {
+ set ins_length [lindex $::CompilerConsts::Opcode($opcode) 2]
}
- } {
+ } else {
set ins_length 0
}
[lindex $code_mem_window_objects $idx] move_program_pointer_directly $new_PC $ins_length
@@ -8304,10 +8738,10 @@ namespace eval X {
# @parm Object project - Project object
# @return void
proc refresh_code_mem_window {project} {
- variable opended_code_mem_windows ;# List of project object with opened CODE memory hex editor
+ variable opened_code_mem_windows ;# List of project object with opened CODE memory hex editor
variable code_mem_window_objects ;# List of CODE memory hex editor objects
- set idx [lsearch -exact -ascii $opended_code_mem_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_code_mem_windows [string trimleft $project {:}]]
if {$idx != -1} {
[lindex $code_mem_window_objects $idx] refresh
}
@@ -8317,10 +8751,10 @@ namespace eval X {
# @parm Object project - Project object
# @return void
proc refresh_xram_mem_window {project} {
- variable opended_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
+ variable opened_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
variable xdata_mem_window_objects ;# List of XDATA memory hex editor objects
- set idx [lsearch -exact -ascii $opended_xdata_mem_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_xdata_mem_windows [string trimleft $project {:}]]
if {$idx != -1} {
[lindex $xdata_mem_window_objects $idx] refresh
}
@@ -8330,10 +8764,10 @@ namespace eval X {
# @parm Object project - Project object
# @return void
proc refresh_eram_mem_window {project} {
- variable opended_eram_windows ;# List of project object with opened ERAM hex editor
+ variable opened_eram_windows ;# List of project object with opened ERAM hex editor
variable eram_window_objects ;# List of ERAM hex editor objects
- set idx [lsearch -exact -ascii $opended_eram_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_eram_windows [string trimleft $project {:}]]
if {$idx != -1} {
[lindex $eram_window_objects $idx] refresh
}
@@ -8343,24 +8777,24 @@ namespace eval X {
# @parm Object project - Project object
# @return void
proc refresh_eeprom_mem_window {project} {
- variable opended_eeprom_mem_windows ;# List of project object with opened ERAM hex editor
+ variable opened_eeprom_mem_windows ;# List of project object with opened ERAM hex editor
variable eeprom_mem_window_objects ;# List of ERAM hex editor objects
- set idx [lsearch -exact -ascii $opended_eeprom_mem_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_eeprom_mem_windows [string trimleft $project {:}]]
if {$idx != -1} {
[lindex $eeprom_mem_window_objects $idx] refresh
}
}
- ## Clear background highlight for certain cell in hexeditor of data EEPROM
+ ## Clear background highlight for certain cell in hex editor of data EEPROM
# @parm Int addr - Register address (absolute)
# @parm Object project - Project object
# @return void
proc sync_eeprom_clear_bg_hg {addr project} {
- variable opended_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
+ variable opened_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
variable eeprom_mem_window_objects ;# List of data EEPROM hex editor objects
- set idx [lsearch -exact -ascii $opended_eeprom_mem_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_eeprom_mem_windows [string trimleft $project {:}]]
if {$idx != -1} {
[lindex $eeprom_mem_window_objects $idx] set_bg_hg_clr $addr 0
}
@@ -8374,10 +8808,10 @@ namespace eval X {
# @parm Object project - Project object
# @return void
proc sync_eeprom_mem_window {addr hg project} {
- variable opended_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
+ variable opened_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
variable eeprom_mem_window_objects ;# List of data EEPROM hex editor objects
- set idx [lsearch -exact -ascii $opended_eeprom_mem_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_eeprom_mem_windows [string trimleft $project {:}]]
if {$idx != -1} {
set obj [lindex $eeprom_mem_window_objects $idx]
$obj reg_sync $addr
@@ -8392,20 +8826,20 @@ namespace eval X {
# @parm Object project - Project object
# @return void
proc sync_xram_mem_window {addr project} {
- variable opended_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
+ variable opened_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
variable xdata_mem_window_objects ;# List of XDATA memory hex editor objects
- variable opended_eram_windows ;# List of project object with opened ERAM hex editor
+ variable opened_eram_windows ;# List of project object with opened ERAM hex editor
variable eram_window_objects ;# List of ERAM hex editor objects
set project [string trimleft $project {:}]
# Syncronize XDATA
- set idx [lsearch -exact -ascii $opended_xdata_mem_windows $project]
+ set idx [lsearch -exact -ascii $opened_xdata_mem_windows $project]
if {$idx != -1} {
[lindex $xdata_mem_window_objects $idx] reg_sync $addr
}
# Syncronize ERAM
- set idx [lsearch -exact -ascii $opended_eram_windows $project]
+ set idx [lsearch -exact -ascii $opened_eram_windows $project]
if {$idx != -1} {
[lindex $eram_window_objects $idx] reg_sync $addr
}
@@ -8435,7 +8869,7 @@ namespace eval X {
show_X_memory eeprom
}
- ## Invoke hexeditor dialog
+ ## Invoke hex editor dialog
# @see __show_exp_mem, __show_ext_mem, __show_code_mem, __show_eeprom
# @parm String type - memory type (one of {eeprom xdata code eram})
# @return void
@@ -8446,13 +8880,13 @@ namespace eval X {
variable actualProjectIdx ;# Index of the current project in $openedProjects
variable simulator_enabled ;# List of booleans: Simulator engaged
- variable opended_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
+ variable opened_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
variable xdata_mem_window_objects ;# List of XDATA memory hex editor objects
- variable opended_code_mem_windows ;# List of project object with opened CODE memory hex editor
+ variable opened_code_mem_windows ;# List of project object with opened CODE memory hex editor
variable code_mem_window_objects ;# List of CODE memory hex editor objects
- variable opended_eram_windows ;# List of project object with opened ERAM hex editor
+ variable opened_eram_windows ;# List of project object with opened ERAM hex editor
variable eram_window_objects ;# List of ERAM hex editor objects
- variable opended_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
+ variable opened_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
variable eeprom_mem_window_objects ;# List of data EEPROM hex editor objects
if {$project_menu_locked} {return}
@@ -8463,29 +8897,29 @@ namespace eval X {
if {![$actualProject cget -P_option_mcu_xdata]} {
return
}
- set idx [lsearch -exact -ascii $opended_xdata_mem_windows $actualProject]
- set list_of_opened {opended_xdata_mem_windows}
+ set idx [lsearch -exact -ascii $opened_xdata_mem_windows $actualProject]
+ set list_of_opened {opened_xdata_mem_windows}
set window_objects {xdata_mem_window_objects}
}
{eram} {
if {![lindex [$actualProject cget -procData] 8]} {
return
}
- set idx [lsearch -exact -ascii $opended_eram_windows $actualProject]
- set list_of_opened {opended_eram_windows}
+ set idx [lsearch -exact -ascii $opened_eram_windows $actualProject]
+ set list_of_opened {opened_eram_windows}
set window_objects {eram_window_objects}
}
{code} {
- set idx [lsearch -exact -ascii $opended_code_mem_windows $actualProject]
- set list_of_opened {opended_code_mem_windows}
+ set idx [lsearch -exact -ascii $opened_code_mem_windows $actualProject]
+ set list_of_opened {opened_code_mem_windows}
set window_objects {code_mem_window_objects}
}
{eeprom} {
if {![lindex [$actualProject cget -procData] 32]} {
return
}
- set idx [lsearch -exact -ascii $opended_eeprom_mem_windows $actualProject]
- set list_of_opened {opended_eeprom_mem_windows}
+ set idx [lsearch -exact -ascii $opened_eeprom_mem_windows $actualProject]
+ set list_of_opened {opened_eeprom_mem_windows}
set window_objects {eeprom_mem_window_objects}
}
}
@@ -8500,7 +8934,7 @@ namespace eval X {
set critical_procedure_in_progress 0
return
# Show
- } {
+ } else {
set object "hexedit_${type}_${actualProject}"
HexEditDlg ::$object $actualProject $type
lappend $list_of_opened $actualProject
@@ -8522,7 +8956,7 @@ namespace eval X {
set filename [file rootname $filename]
if {$ext == {.c} || $ext == {.h} || $ext == {.cxx} || $ext == {.cpp} || $ext == {.cc}} {
append filename {.ihx}
- } {
+ } else {
append filename {.hex}
}
@@ -8549,11 +8983,11 @@ namespace eval X {
proc sync_eeprom_write_buffer {addr project} {
variable actualProject ;# Object: Current project
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
- variable opended_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
+ variable opened_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
variable eeprom_wr_bf_window_objects ;# List of data EEPROM write buffer hex editor objects
if {$project_menu_locked} {return}
- set idx [lsearch -exact -ascii $opended_eeprom_wr_bf_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_eeprom_wr_bf_windows [string trimleft $project {:}]]
if {$idx == -1} {return}
[string replace [lindex $eeprom_wr_bf_window_objects $idx] 0 0] \
setValue $addr [$project getEepromWrBufDEC $addr]
@@ -8565,11 +8999,11 @@ namespace eval X {
proc clear_eeprom_write_buffer {project} {
variable actualProject ;# Object: Current project
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
- variable opended_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
+ variable opened_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
variable eeprom_wr_bf_window_objects ;# List of data EEPROM write buffer hex editor objects
if {$project_menu_locked} {return}
- set idx [lsearch -exact -ascii $opended_eeprom_wr_bf_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_eeprom_wr_bf_windows [string trimleft $project {:}]]
if {$idx == -1} {return}
set hexeditor [string replace [lindex $eeprom_wr_bf_window_objects $idx] 0 0]
for {set addr 0} {$addr < 32} {incr addr} {
@@ -8584,11 +9018,11 @@ namespace eval X {
proc eeprom_write_buffer_set_offset {offset project} {
variable actualProject ;# Object: Current project
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
- variable opended_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
+ variable opened_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
variable eeprom_wr_bf_window_objects ;# List of data EEPROM write buffer hex editor objects
if {$project_menu_locked} {return}
- set idx [lsearch -exact -ascii $opended_eeprom_wr_bf_windows [string trimleft $project {:}]]
+ set idx [lsearch -exact -ascii $opened_eeprom_wr_bf_windows [string trimleft $project {:}]]
if {$idx == -1} {return}
if {$offset == {}} {
set offset [mc "< Undefined >"]
@@ -8596,7 +9030,7 @@ namespace eval X {
[lindex $eeprom_wr_bf_window_objects $idx].offset_frame.val configure -text $offset
}
- ## Binding for pseudo-events <cell_enter> and <cell_leave> in data EEPROM write buffer hexeditor
+ ## Binding for pseudo-events <cell_enter> and <cell_leave> in data EEPROM write buffer hex editor
# Set value of curosor label at the bottom of the window
# This function takes list of attributes with any length gerater
#+ than one but only first two are significant
@@ -8622,7 +9056,7 @@ namespace eval X {
# Modify content of cursor label
if {$addr == {}} {
$win.bottom_frame.cur_val configure -text { }
- } {
+ } else {
set addr [format %X $addr]
set len [string length $addr]
if {$len < 4} {
@@ -8634,13 +9068,13 @@ namespace eval X {
set foo_procedure_in_progress 0
}
- ## Invoke hexeditor with data EEPROM write buffer
+ ## Invoke hex editor with data EEPROM write buffer
# @return void
proc __show_eeprom_write_buffer {} {
variable actualProject ;# Object: Current project
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
- variable opended_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
+ variable opened_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
variable eeprom_wr_bf_window_objects ;# List of data EEPROM write buffer hex editor objects
variable eeprom_wr_buf_counter ;# Counter of EEPROM write buffer hex editor objects
@@ -8655,7 +9089,7 @@ namespace eval X {
set critical_procedure_in_progress 1
# Check if the dialog is not already opened
- if {[lsearch -exact -ascii $opended_eeprom_wr_bf_windows $actualProject] != -1} {
+ if {[lsearch -exact -ascii $opened_eeprom_wr_bf_windows $actualProject] != -1} {
close_hexedit eeprom_wr_bf $actualProject
set critical_procedure_in_progress 0
return
@@ -8663,11 +9097,11 @@ namespace eval X {
# Create dialog window
incr eeprom_wr_buf_counter
- set win [toplevel .eeprom_write_buffer_${eeprom_wr_buf_counter} -class {EEPROM} -bg {#EEEEEE}]
+ set win [toplevel .eeprom_write_buffer_${eeprom_wr_buf_counter} -class {EEPROM} -bg ${::COMMON_BG_COLOR}]
# Adjust NS variables
lappend eeprom_wr_bf_window_objects $win
- lappend opended_eeprom_wr_bf_windows $actualProject
+ lappend opened_eeprom_wr_bf_windows $actualProject
# Create window header
pack [label $win.header \
@@ -8676,17 +9110,19 @@ namespace eval X {
# Create offset label
set offset_frame [frame $win.offset_frame]
- pack [label $offset_frame.lbl \
- -text [mc "OFFSET = "] \
- -font [font create \
- -size -17 -weight bold \
- -family {helvetica}] \
+ pack [label $offset_frame.lbl \
+ -text [mc "OFFSET = "] \
+ -font [font create \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica}] \
] -side left
- pack [label $offset_frame.val \
- -fg {#0000FF} \
- -font [font create \
- -size -17 -weight bold \
- -family {helvetica}] \
+ pack [label $offset_frame.val \
+ -fg {#0000FF} \
+ -font [font create \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica}] \
] -side left
pack $offset_frame -anchor w
@@ -8712,13 +9148,13 @@ namespace eval X {
-compound left \
-image ::ICONS::16::button_cancel \
-command "X::close_hexedit eeprom_wr_bf $actualProject" \
- ] -side left -anchor w
- pack [label $bottom_frame.cur_val \
- -text { } -fg {#0000FF} \
- -font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ ] -side left -anchor w -padx 2 -pady 2
+ pack [label $bottom_frame.cur_val \
+ -text { } -fg {#0000FF} \
+ -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
] \
] -side right -anchor e -padx 5
pack [label $bottom_frame.cur_lbl \
@@ -8728,7 +9164,7 @@ namespace eval X {
# Configure dialog window
wm iconphoto $win ::ICONS::16::kcmmemory
- wm title $win [mc "EEPROM write buffer - %s - MCU 8051 IDE" $actualProject]
+ wm title $win [mc "EEPROM write buffer - %s - MCU 8051 IDE" [$actualProject cget -projectName]]
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW \
"X::close_hexedit eeprom_wr_bf $actualProject"
@@ -8744,51 +9180,51 @@ namespace eval X {
# @parm Object project - Project object descriptor
# @return void
proc close_hexedit {type project} {
- variable opended_code_mem_windows ;# List of project object with opened CODE memory hex editor
+ variable opened_code_mem_windows ;# List of project object with opened CODE memory hex editor
variable code_mem_window_objects ;# List of CODE memory hex editor objects
- variable opended_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
+ variable opened_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
variable xdata_mem_window_objects ;# List of XDATA memory hex editor objects
- variable opended_eram_windows ;# List of project object with opened ERAM hex editor
+ variable opened_eram_windows ;# List of project object with opened ERAM hex editor
variable eram_window_objects ;# List of ERAM hex editor objects
- variable opended_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
+ variable opened_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
variable eeprom_mem_window_objects ;# List of data EEPROM hex editor objects
- variable opended_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
+ variable opened_eeprom_wr_bf_windows ;# List of project objects with opened data EEPROM write buffer editor
variable eeprom_wr_bf_window_objects ;# List of data EEPROM write buffer hex editor objects
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
# Close CODE memory editor
if {$type == {code}} {
- set opended_windows_var {opended_code_mem_windows}
+ set opened_windows_var {opened_code_mem_windows}
set window_objects_var {code_mem_window_objects}
- set opended_windows $opended_code_mem_windows
+ set opened_windows $opened_code_mem_windows
set window_objects $code_mem_window_objects
# Close ERAM editor
} elseif {$type == {eram}} {
- set opended_windows_var {opended_eram_windows}
+ set opened_windows_var {opened_eram_windows}
set window_objects_var {eram_window_objects}
- set opended_windows $opended_eram_windows
+ set opened_windows $opened_eram_windows
set window_objects $eram_window_objects
# Close XDATA memory editor
} elseif {$type == {xdata}} {
- set opended_windows_var {opended_xdata_mem_windows}
+ set opened_windows_var {opened_xdata_mem_windows}
set window_objects_var {xdata_mem_window_objects}
- set opended_windows $opended_xdata_mem_windows
+ set opened_windows $opened_xdata_mem_windows
set window_objects $xdata_mem_window_objects
# Close data EEPROM editor
} elseif {$type == {eeprom}} {
- set opended_windows_var {opended_eeprom_mem_windows}
+ set opened_windows_var {opened_eeprom_mem_windows}
set window_objects_var {eeprom_mem_window_objects}
- set opended_windows $opended_eeprom_mem_windows
+ set opened_windows $opened_eeprom_mem_windows
set window_objects $eeprom_mem_window_objects
# Close EEPROM write buffer
} elseif {$type == {eeprom_wr_bf}} {
- set opended_windows_var {opended_eeprom_wr_bf_windows}
+ set opened_windows_var {opened_eeprom_wr_bf_windows}
set window_objects_var {eeprom_wr_bf_window_objects}
- set opended_windows $opended_eeprom_wr_bf_windows
+ set opened_windows $opened_eeprom_wr_bf_windows
set window_objects $eeprom_wr_bf_window_objects
# Close project independent hexadecimal editor
@@ -8802,16 +9238,16 @@ namespace eval X {
# Determinate editor index
- set idx [lsearch -exact -ascii $opended_windows $project]
+ set idx [lsearch -exact -ascii $opened_windows $project]
if {$idx == -1} {return}
# Destroy editor object
if {$type == {eeprom_wr_bf}} {
destroy [lindex $window_objects $idx]
- } {
+ } else {
delete object [lindex $window_objects $idx]
}
# Delete references
- set $opended_windows_var [lreplace $opended_windows $idx $idx]
+ set $opened_windows_var [lreplace $opened_windows $idx $idx]
set $window_objects_var [lreplace $window_objects $idx $idx]
}
@@ -8828,19 +9264,19 @@ namespace eval X {
if {[$actualProject editor_procedure {} cget -modified]} {
append title {[modified] }
}
- append title $actualProject
+ append title [$actualProject cget -projectName]
append title { : }
append title [$actualProject editor_procedure {} cget -filename]
append title { - MCU 8051 IDE}
wm title . $title
# Error -- default title
- }]} {
+ }]} then {
wm title . ${::APPNAME}
}
# No project opened -- default title
- } {
+ } else {
wm title . ${::APPNAME}
}
}
@@ -8850,11 +9286,11 @@ namespace eval X {
proc __sim_clear_highlight {} {
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
variable actualProject ;# Object: Current project
- variable opended_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
+ variable opened_xdata_mem_windows ;# List of project object with opened XDATA memory hex editor
variable xdata_mem_window_objects ;# List of XDATA memory hex editor objects
- variable opended_eram_windows ;# List of project object with opened ERAM hex editor
+ variable opened_eram_windows ;# List of project object with opened ERAM hex editor
variable eram_window_objects ;# List of ERAM hex editor objects
- variable opended_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
+ variable opened_eeprom_mem_windows ;# List of project object with opened data EEPROM hex editor
variable eeprom_mem_window_objects ;# List of data EEPROM hex editor objects
if {$project_menu_locked} {return}
@@ -8863,15 +9299,15 @@ namespace eval X {
$actualProject bitmap_clear_hg
$actualProject sfrmap_clear_hg
- set idx [lsearch -exact -ascii $opended_xdata_mem_windows $actualProject]
+ set idx [lsearch -exact -ascii $opened_xdata_mem_windows $actualProject]
if {$idx != -1} {
[lindex $xdata_mem_window_objects $idx] clear_highlight
}
- set idx [lsearch -exact -ascii $opended_eram_windows $actualProject]
+ set idx [lsearch -exact -ascii $opened_eram_windows $actualProject]
if {$idx != -1} {
[lindex $eram_window_objects $idx] clear_highlight
}
- set idx [lsearch -exact -ascii $opended_eeprom_mem_windows $actualProject]
+ set idx [lsearch -exact -ascii $opened_eeprom_mem_windows $actualProject]
if {$idx != -1} {
[lindex $eeprom_mem_window_objects $idx] clear_highlight
}
@@ -8920,7 +9356,7 @@ namespace eval X {
-parent . \
-type ok \
-icon warning \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "This operation cannot be performed on an untitled file"]
return
}
@@ -8930,7 +9366,7 @@ namespace eval X {
-parent . \
-type ok \
-icon warning \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "This file does not contain any part of the running program"]
return
}
@@ -8942,7 +9378,7 @@ namespace eval X {
set line2pc $line2pc_org_line
# Create dialog window
- set win [toplevel .goto_line2pc -class [mc "Goto dialog"] -bg {#EEEEEE}]
+ set win [toplevel .goto_line2pc -class [mc "Goto dialog"] -bg ${::COMMON_BG_COLOR}]
# Create window label frame
label $win.header \
@@ -8952,16 +9388,18 @@ namespace eval X {
# Create middle frame
set middle_frame [frame $win.middle_frame]
- pack [label $middle_frame.left_lbl \
- -text [mc "PC = "] \
- -font [font create \
- -size -16 -weight bold \
- -family {helvetica}] \
+ pack [label $middle_frame.left_lbl \
+ -text [mc "PC = "] \
+ -font [font create \
+ -size [expr {int(-16 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica}] \
] -side left
- set line2pc_value_lbl [label $middle_frame.right_lbl \
- -font [font create \
- -size -16 -weight bold \
- -family {helvetica}] \
+ set line2pc_value_lbl [label $middle_frame.right_lbl \
+ -font [font create \
+ -size [expr {int(-16 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica}] \
]
pack $line2pc_value_lbl -side left
set middle_right_frame [frame $middle_frame.right_frame]
@@ -8984,14 +9422,14 @@ namespace eval X {
-image ::ICONS::16::ok \
-command {X::line2pc_OK} \
]
- pack $line2pc_ok_button -side left
+ pack $line2pc_ok_button -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command {X::line2pc_CANCEL} \
] -side left
- pack $buttonFrame -after $middle_frame -pady 5
+ pack $buttonFrame -after $middle_frame -pady 5 -padx 2
## Create top frame
set topFrame [ttk::labelframe $win.topFrame -labelwidget $win.header -relief flat]
@@ -9004,19 +9442,20 @@ namespace eval X {
-variable ::X::line2pc \
-command "
set ::X::line2pc \[expr {int(\${::X::line2pc})}\]
+ ::X::line2pc_validate \$::X::line2pc $topFrame.spinbox
$topFrame.spinbox selection range 0 end
#" \
] -side left -expand 1 -fill x -padx 2
DynamicHelp::add $topFrame.scale \
-text [mc "Graphical representation of the line where to go"]
# Create spinbox widget
- pack [spinbox $topFrame.spinbox \
- -from 1 -to $line2pc_line_max \
- -textvariable X::line2pc \
- -validate all \
- -vcmd {X::line2pc_validate [expr {int(%P)}] %W} \
- -width 4 \
- -command "$topFrame.spinbox selection range 0 end ;#" \
+ pack [ttk::spinbox $topFrame.spinbox \
+ -from 1 -to $line2pc_line_max \
+ -textvariable ::X::line2pc \
+ -validate all \
+ -validatecommand {::X::line2pc_validate %P %W} \
+ -command "::X::line2pc_validate \$::X::line2pc $topFrame.spinbox" \
+ -width 4 \
] -side left
DynamicHelp::add $topFrame.spinbox -text [mc "Line where to go"]
@@ -9032,7 +9471,7 @@ namespace eval X {
# Nessesary window manager options -- modal window
wm iconphoto $win ::ICONS::16::exec
wm title $win [mc "Line to address"]
- wm minsize $win 350 100
+ wm minsize $win 380 140
wm protocol $win WM_DELETE_WINDOW {
X::line2pc_CANCEL
}
@@ -9055,9 +9494,16 @@ namespace eval X {
variable line2pc_ok_button ;# Widget: Button "OK"
variable line2pc_file_number ;# Int: File number
+ if {$content == {}} {
+ return 1
+ }
+
# Validate the given string
- if {![string is digit $content] || $content > $line2pc_line_max || $content < 0} {
- $line2pc_spinbox configure -bg {#FFFFFF}
+ set content [regsub {\..*$} $content {}]
+ if {![string is digit $content] || ($content > $line2pc_line_max) || ($content < 0)} {
+ catch {
+ $line2pc_spinbox configure -style TSpinbox
+ }
return 0
}
@@ -9073,12 +9519,14 @@ namespace eval X {
-text [mc "Unable to resolve"]
code_hex_editor_directly_move_program_pointer $actualProject -1
- $actualProject editor_procedure {} unset_simulator_line {} ;# Adjust editor
- $line2pc_ok_button configure -state disabled ;# Adjust Ok button
- $line2pc_spinbox configure -bg {#FFCCCC} ;# Adjust SpinBox
+ $actualProject editor_procedure {} unset_simulator_line {} ;# Adjust editor
+ $line2pc_ok_button configure -state disabled ;# Adjust Ok button
+ catch {
+ $line2pc_spinbox configure -style RedBg.TSpinbox ;# Adjust SpinBox
+ }
# Success
- } {
+ } else {
# Translate address to hexadecimal system
set addr_in_hex [format %X $line2pc_new_value]
set len [string length $addr_in_hex]
@@ -9092,8 +9540,10 @@ namespace eval X {
# Adjust editor
code_hex_editor_directly_move_program_pointer $actualProject $line2pc_new_value
$actualProject move_simulator_line [list $content $line2pc_file_number]
- $line2pc_ok_button configure -state normal ;# Adjust Ok button
- $line2pc_spinbox configure -bg {#CCFFCC} ;# Adjust SpinBox
+ $line2pc_ok_button configure -state normal ;# Adjust Ok button
+ catch {
+ $line2pc_spinbox configure -style GreenBg.TSpinbox ;# Adjust SpinBox
+ }
}
return 1
}
@@ -9115,7 +9565,7 @@ namespace eval X {
if {$line2pc_org_line == {}} {
$actualProject editor_procedure {} unset_simulator_line {}
- } {
+ } else {
$actualProject move_simulator_line $line2pc_org_line
}
code_hex_editor_directly_move_program_pointer $actualProject -1
@@ -9140,7 +9590,7 @@ namespace eval X {
$actualProject move_simulator_line $line2pc
if {$line2pc_jump} {
$actualProject setPC $line2pc_new_value
- } {
+ } else {
$actualProject simulator_subprog_call $line2pc_new_value
}
code_hex_editor_directly_move_program_pointer $actualProject -1
@@ -9154,7 +9604,7 @@ namespace eval X {
# @return void
proc __prev_editor_from_pmenu {} {
variable actualProject ;# Object: Current project
- variable selectedView ;# Int: Selected editor view
+ variable selectedView ;# Object: Selected editor view
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
@@ -9176,7 +9626,7 @@ namespace eval X {
# @return void
proc __next_editor_from_pmenu {} {
variable actualProject ;# Object: Current project
- variable selectedView ;# Int: Selected editor view
+ variable selectedView ;# Object: Selected editor view
variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
@@ -9227,7 +9677,7 @@ namespace eval X {
## Close current view (editor) from editor statusbar popup menu
# @return void
proc __close_current_view_from_pmenu {} {
- variable selectedView ;# Int: Selected editor view
+ variable selectedView ;# Object: Selected editor view
variable actualProject ;# Object: Current project
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
@@ -9305,7 +9755,7 @@ namespace eval X {
if {$hib_res} {
set title [mc "Hibernate running program - MCU 8051 IDE"]
set cmd {__hibernate_to}
- } {
+ } else {
set title [mc "Resume hibernated program - MCU 8051 IDE"]
set cmd {__resume_from}
}
@@ -9315,10 +9765,10 @@ namespace eval X {
KIFSD::FSD fsd \
-title $title -initialfile $initialfile \
-directory [$actualProject cget -projectPath] \
- -defaultmask 0 -multiple 0 -filetypes {
- {{MCU 8051 IDE Hibernated program} {*.m5ihib} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "MCU 8051 IDE hibernated program"] {*.m5ihib} ] \
+ [list [mc "All files"] {*} ] \
+ ]
# Open file after press of OK button
fsd setokcmd "
@@ -9352,11 +9802,11 @@ namespace eval X {
# Adjust the given name of the target file
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $filename]} {
- set filename "[${X::actualProject} cget -ProjectDir]/$filename"
+ set filename "[${::X::actualProject} cget -ProjectDir]/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
- set filename [file join [${X::actualProject} cget -ProjectDir] $filename]
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
+ set filename [file join [${::X::actualProject} cget -ProjectDir] $filename]
}
}
if {[file extension $filename] == {}} {
@@ -9374,7 +9824,7 @@ namespace eval X {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $filename]]
] != {yes}
- } {
+ } then {
return
}
# Create a backup file
@@ -9390,7 +9840,7 @@ namespace eval X {
}
if {![$actualProject hibernate_hibernate \
$filename [file tail $sourcefile] $sourcefile_md5 0 \
- ]} {
+ ]} then {
tk_messageBox \
-parent . \
-type ok \
@@ -9419,11 +9869,11 @@ namespace eval X {
# Adjust the given name of the target file
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $filename]} {
- set filename "[${X::actualProject} cget -ProjectDir]/$filename"
+ set filename "[${::X::actualProject} cget -ProjectDir]/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
- set filename [file join [${X::actualProject} cget -ProjectDir] $filename]
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
+ set filename [file join [${::X::actualProject} cget -ProjectDir] $filename]
}
}
set filename [file normalize $filename]
@@ -9452,7 +9902,7 @@ namespace eval X {
}
## Invoke interrupt monitor window
- # @parm Object project_object = actualProject - Project
+ # @parm Object project_object=actualProject - Project
# @return void
proc __interrupt_monitor args {
variable actualProject ;# Object: Current project
@@ -9461,13 +9911,24 @@ namespace eval X {
if {$project_menu_locked} {return}
if {[string length $args]} {
$args interrupt_monitor_invoke_dialog
- } {
+ } else {
$actualProject interrupt_monitor_invoke_dialog
}
}
+ ## Invoke UART monitor window
+ # @return void
+ proc __uart_monitor args {
+ variable actualProject ;# Object: Current project
+ variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
+
+ if {$project_menu_locked} {return}
+
+ $actualProject uart_monitor_invoke_dialog
+ }
+
## Invoke stack monitor window
- # @parm Object project_object = actualProject - Project
+ # @parm Object project_object=actualProject - Project
# @return void
proc __stack_monitor args {
variable actualProject ;# Object: Current project
@@ -9476,7 +9937,7 @@ namespace eval X {
if {$project_menu_locked} {return}
if {[string length $args]} {
$args stack_monitor_invoke_dialog
- } {
+ } else {
$actualProject stack_monitor_invoke_dialog
}
}
@@ -9525,7 +9986,7 @@ namespace eval X {
}
## Invoke independent hexadecimal editor
- # @return Object - Hexeditor object reference
+ # @return Object - Hex editor object reference
proc __hexeditor {} {
variable independent_hexeditor_count ;# Counter of intances of independent hexadecimal editor
incr independent_hexeditor_count
@@ -9543,7 +10004,7 @@ namespace eval X {
$actualProject editor_procedure {} document_current_func {}
}
- ## Create doxygen configguration file if it does not already exist
+ ## Create doxygen configuration file if it does not already exist
# @return void
proc create_doxyfile {} {
variable doxygen_pid ;# Int: Doxygen PID
@@ -9555,7 +10016,7 @@ namespace eval X {
-parent . \
-type ok \
-icon warning \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "Something is already running in background."]
return
}
@@ -9564,30 +10025,60 @@ namespace eval X {
make_progressBar_on_Sbar
if {[catch {
+ set path [$actualProject cget -projectPath]
+ if {$::MICROSOFT_WINDOWS} {
+ regsub -all {/} $path "\\" path
+ }
+ $actualProject messages_text_append "\ncd $path\n"
cd [$actualProject cget -projectPath]
- }]} {
+ }]} then {
tk_messageBox \
-parent . \
-type ok \
-icon warning \
-title [mc "Permission denied"] \
- -message [mc "Unable to change diectory to '%s'." [$actualProject cget -projectPath]]
+ -message [mc "Unable to change directory to '%s'." [$actualProject cget -projectPath]]
return
}
- if {![file exists Doxyfile]} {
- $actualProject messages_text_append "\ndoxygen -g Doxyfile\n"
- set doxygen_pid [exec -- \
- doxygen -g Doxyfile && doxygen -u Doxyfile |& \
- tclsh ${::LIB_DIRNAME}/external_command.tcl [tk appname] \
- ::X::doxygen_finish ::X::doxygen_message & \
- ]
- } {
- $actualProject messages_text_append "\ndoxygen -u Doxyfile\n"
- set doxygen_pid [exec -- \
- doxygen -u Doxyfile |& tclsh \
- ${::LIB_DIRNAME}/external_command.tcl [tk appname] \
- ::X::doxygen_finish ::X::doxygen_message & \
- ]
+ if {!$::MICROSOFT_WINDOWS} {
+ if {![file exists Doxyfile]} {
+ $actualProject messages_text_append "doxygen -g Doxyfile\n"
+ set doxygen_pid [exec -- \
+ doxygen -g Doxyfile && doxygen -u Doxyfile |& \
+ tclsh ${::LIB_DIRNAME}/external_command.tcl [tk appname] \
+ ::X::doxygen_finish ::X::doxygen_message & \
+ ]
+ } else {
+ $actualProject messages_text_append "doxygen -u Doxyfile\n"
+ set doxygen_pid [exec -- \
+ doxygen -u Doxyfile |& tclsh \
+ ${::LIB_DIRNAME}/external_command.tcl [tk appname] \
+ ::X::doxygen_finish ::X::doxygen_message & \
+ ]
+ }
+ } else {
+ if {![file exists Doxyfile]} {
+ $actualProject messages_text_append "doxygen -g Doxyfile\n"
+ set doxygen_pid [exec -- \
+ doxygen -g Doxyfile && doxygen -u Doxyfile \
+ |& \
+ "${::INSTALLATION_DIR}/external_command.bat" \
+ "${::INSTALLATION_DIR}/external_command.exe" \
+ "[tk appname]" \
+ ::X::doxygen_finish ::X::doxygen_message & \
+ ]
+ } else {
+ $actualProject messages_text_append "doxygen -u Doxyfile\n"
+ set doxygen_pid [exec -- \
+ doxygen -u Doxyfile \
+ |& \
+ "${::INSTALLATION_DIR}/external_command.bat" \
+ "${::INSTALLATION_DIR}/external_command.exe" \
+ "[tk appname]" \
+ ::X::doxygen_finish ::X::doxygen_message & \
+ ]
+ }
+
}
}
@@ -9606,8 +10097,8 @@ namespace eval X {
set doxygen_build_api_doc 0
if {[catch {
cd [$actualProject cget -projectPath]
- }]} {
- $actualProject messages_text_append [mc "\nUnable to change diectory to '%s'\n" [$actualProject cget -projectPath]]
+ }]} then {
+ $actualProject messages_text_append [mc "\nUnable to change directory to '%s'\n" [$actualProject cget -projectPath]]
destroy_progressBar_on_Sbar
set compilation_in_progress 0
set doxygen_pid 0
@@ -9652,13 +10143,13 @@ namespace eval X {
-parent . \
-type ok \
-icon warning \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "Something is already running in background."]
return
}
set doxygen_mess_project $actualProject
set doxygen_build_api_doc 1
- if {!$::PROGRAM_AVALIABLE(doxygen)} {
+ if {!$::PROGRAM_AVAILABLE(doxygen)} {
tk_messageBox \
-parent . \
-type ok \
@@ -9671,7 +10162,7 @@ namespace eval X {
create_doxyfile
}
- ## Run doxygen graphical frontend
+ ## Run doxygen graphical front-end
# @return void
proc __run_doxywizard {} {
variable doxygen_mess_project ;# Object: Project related to running doxygen compilation
@@ -9680,7 +10171,7 @@ namespace eval X {
variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
if {$project_menu_locked} {return}
- if {!$::PROGRAM_AVALIABLE(doxywizard)} {
+ if {!$::PROGRAM_AVAILABLE(doxywizard)} {
tk_messageBox \
-parent . \
-type ok \
@@ -9706,8 +10197,8 @@ namespace eval X {
set doxygen_mess_project $actualProject
if {[catch {
cd [$actualProject cget -projectPath]
- }]} {
- $actualProject messages_text_append [mc "\nError: Unable to change diectory to '%s'\n" [$actualProject cget -projectPath]]
+ }]} then {
+ $actualProject messages_text_append [mc "\nError: Unable to change directory to '%s'\n" [$actualProject cget -projectPath]]
return
}
@@ -9734,19 +10225,19 @@ namespace eval X {
-parent . \
-icon warning \
-type ok \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "Unable to gain file statistics while external editor is used"]
return
}
# Create dialog window (not modal)
incr statistics_counter
- set win [toplevel .statistics$statistics_counter -class {File statistics} -bg {#EEEEEE}]
+ set win [toplevel .statistics$statistics_counter -class {File statistics} -bg ${::COMMON_BG_COLOR}]
# Local variables
- set bold_font [font create -family {helvetica} -size -12 -weight bold]
- set normal_font [font create -family {helvetica} -size -12 -weight normal]
- set header_font [font create -family {helvetica} -size -20 -weight normal]
+ set bold_font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight bold]
+ set normal_font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight normal]
+ set header_font [font create -family {helvetica} -size [expr {int(-20 * $::font_size_factor)}] -weight normal]
set statistics [$actualProject editor_procedure {} getFileStatistics {}]
# Create window header
@@ -9784,7 +10275,7 @@ namespace eval X {
grid [Label $main_frame.c_other_name_lbl \
-text [mc "Other characters:"] \
-font $normal_font -pady 0 \
- -helptext [mc "All other charactes without EOLs (e.g. spaces and brackets)"] \
+ -helptext [mc "All other characters without EOLs (e.g. spaces and brackets)"] \
] -row 3 -column 1 -sticky w
grid [label $main_frame.c_other_value_lbl \
-text [lindex $statistics 2] \
@@ -9798,7 +10289,7 @@ namespace eval X {
grid [Label $main_frame.c_total_name_lbl \
-text [mc "Total characters:"] \
-font $normal_font -pady 0 \
- -helptext [mc "All charactes in the text without EOLs"] \
+ -helptext [mc "All characters in the text without EOLs"] \
] -row 5 -column 1 -sticky w
grid [label $main_frame.c_total_value_lbl \
-text [lindex $statistics 3] \
@@ -9861,7 +10352,7 @@ namespace eval X {
grid [Label $main_frame.l_empty_name_lbl \
-text [mc "Empty lines:"] \
-font $normal_font -pady 0 \
- -helptext [mc "Totaly empty lines (without even spaces)"] \
+ -helptext [mc "Totally empty lines (without even spaces)"] \
] -row 15 -column 1 -sticky w
grid [label $main_frame.l_empty_value_lbl \
-text [lindex $statistics 8] \
@@ -9915,18 +10406,18 @@ namespace eval X {
-compound left \
-image ::ICONS::16::ok \
-command "X::statistics_close $statistics_counter" \
- ] -side right
+ ] -side right -padx 2
pack [ttk::button $button_frame.copy \
-text [mc "Copy"] \
-compound left \
-image ::ICONS::16::editcopy \
-command "X::statistics_copy $statistics_counter" \
- ] -side left
+ ] -side left -padx 2
# Pack dialog frames
pack $dialog_header -side top -fill x -pady 5
pack $main_frame -side top -anchor nw -fill x -pady 15 -padx 10
- pack $button_frame -side bottom -anchor se
+ pack $button_frame -side bottom -anchor se -pady 5 -padx 5
# Set window manager options
wm iconphoto $win ::ICONS::16::graph
@@ -9980,15 +10471,15 @@ namespace eval X {
clipboard append [mc " Total lines:\t\t\t%s\n" [$main_frame.l_total_value_lbl cget -text]]
}
- ## Modify main menu and main toolbar acording to configuration of the current editor
+ ## Modify main menu and main toolbar according to configuration of the current editor
# @parm Bool read_only - 1 == Read only; 0 == Normal mode; {} == Do not change
# @parm Bool c_language - 1 == Uses C language; 0 == Uses Assembler; {} == Do not change
# @return void
proc adjust_mainmenu_and_toolbar_to_editor {read_only c_language} {
- variable mainmenu_editor_readonly ;# Menu bar items which are not avaliable when editor is in read only mode
- variable toolbar_editor_readonly ;# Tool bar items which are not avaliable when editor is in read only mode
- variable mainmenu_editor_c_only ;# Menu bar items which are not avaliable only for C language
- variable toolbar_editor_c_only ;# Toolbar items which are not avaliable only for C language
+ variable mainmenu_editor_readonly ;# Menu bar items which are not available when editor is in read only mode
+ variable toolbar_editor_readonly ;# Tool bar items which are not available when editor is in read only mode
+ variable mainmenu_editor_c_only ;# Menu bar items which are not available only for C language
+ variable toolbar_editor_c_only ;# Toolbar items which are not available only for C language
# Read only flag
if {$read_only != {}} {
@@ -10005,11 +10496,11 @@ namespace eval X {
}
## Conditionaly disable menu and toolbar items which
- #+ are not avaliable when external editor used
+ #+ are not available when external editor used
# @return void
proc adjust_mm_and_tb_ext_editor {} {
- variable mainmenu_editor_external_na ;# Menu bar items which are not avaliable when external embedded editor is used
- variable toolbar_editor_external_na ;# Toolbar items which are not avaliable when external embedded editor is used
+ variable mainmenu_editor_external_na ;# Menu bar items which are not available when external embedded editor is used
+ variable toolbar_editor_external_na ;# Toolbar items which are not available when external embedded editor is used
if {!${::Editor::editor_to_use}} {
return
@@ -10041,10 +10532,10 @@ namespace eval X {
}
}
- ## Invoke 8-segment LED display editor
+ ## Invoke 8-Segment LED display editor
# @return void
proc __eightsegment {} {
- variable eightsegment_editors ;# List: All 8-segment LED display editors invoked
+ variable eightsegment_editors ;# List: All 8-Segment LED display editors invoked
lappend eightsegment_editors [EightSegment #auto]
}
@@ -10056,11 +10547,11 @@ namespace eval X {
if {$ascii_chart_win_object != {}} {
if {[$ascii_chart_win_object is_visible]} {
$ascii_chart_win_object raise_window
- } {
+ } else {
$ascii_chart_win_object restore_window
}
- } {
- set ascii_chart_win_object [AsciiChart #this]
+ } else {
+ set ascii_chart_win_object [AsciiChart #auto]
}
}
@@ -10174,6 +10665,7 @@ namespace eval X {
if {$what == 2} {
if {[$actualProject pale_open_scenario $filename]} {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "IO Error"] \
@@ -10184,6 +10676,7 @@ namespace eval X {
} elseif {$what == -2} {
if {[$actualProject pale_load_scenarion $filename]} {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "IO Error"] \
@@ -10221,7 +10714,7 @@ namespace eval X {
-parent . \
-title [mc "Error - MCU 8051 IDE"] \
-message [mc "Unable to load file: %s" $filename]
- } {
+ } else {
$actualProject editor_procedure {} highlight_visible_area {}
}
@@ -10311,25 +10804,25 @@ namespace eval X {
Notes #auto {} {}
}
- ## Invoke "Base convertor"
+ ## Invoke "Base converter"
# @return void
- proc __base_convertor {} {
- variable base_convertors ;# List: All base convertor objects
+ proc __base_converter {} {
+ variable base_converters ;# List: All base converter objects
- set obj [BaseConvertor #auto]
- lappend base_convertors ::X::$obj
+ set obj [BaseConverter #auto]
+ lappend base_converters ::X::$obj
return $obj
}
- ## Close "Base convertor"
+ ## Close "Base converter"
# @return void
- proc __base_convertor_close {obj} {
- variable base_convertors ;# List: All base convertor objects
+ proc __base_converter_close {obj} {
+ variable base_converters ;# List: All base converter objects
- set idx [lsearch -ascii -exact $base_convertors $obj]
+ set idx [lsearch -ascii -exact $base_converters $obj]
if {$idx != -1} {
- set base_convertors [lreplace $base_convertors $idx $idx]
+ set base_converters [lreplace $base_converters $idx $idx]
}
}
@@ -10366,6 +10859,191 @@ namespace eval X {
return [LedMatrix #auto $actualProject]
}
+ ## Invoke "Virtual UART Terminal" (section Virtual Hardware)
+ # @return void
+ proc __vhw_UART_terminal {} {
+ variable actualProject ;# Object: Current project
+ variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
+
+ if {$project_menu_locked} {return}
+
+ return [VirtualUARTTerminal #auto $actualProject]
+ }
+
+ ## Invoke "File Interface" (section Virtual Hardware)
+ # @return void
+ proc __vhw_file_interface {} {
+ variable actualProject ;# Object: Current project
+ variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
+
+ if {$project_menu_locked} {return}
+
+ return [PaleFileInterface #auto $actualProject]
+ }
+
+ ## Invoke "LCD display controlled by HD44780" (section Virtual Hardware)
+ # @parm List $display_size={} - Size of the LCD display to create, format: {rows columns}, empty list means invoke size selection dialog
+ # @return void
+ #
+ # Note: If the first argument is omitted then this function will create a "Size selection dialog"
+ proc __vhw_HD44780 {{display_size {}}} {
+ variable actualProject ;# Object: Current project
+ variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
+ variable vhw_HD44780_rect ;# Array: Rectangles in dialog "Set display size"
+ variable vhw_HD44780_canvas ;# Widget: Canvas widget in dialog "Set display size"
+ variable vhw_HD44780_counter ;# Int: Counter of dialog instances
+ variable vhw_HD44780_size_lbl ;# Widget: Label showing the LCD size in dialog "Set display size"
+ variable vhw_HD44780_dialog ;# Widget: Toplevel window of dialog "Set display size"
+ variable vhw_HD44780_size ;# List of Int: LCD display size chosen by the user, {HEIGHT WIDTH}
+
+ # This function requires at least one project opened
+ if {$project_menu_locked} {return}
+
+ # LCD display size specified -- create the display and return
+ if {[llength $display_size]} {
+ set object [LcdHD44780 #auto $actualProject]
+ $object set_config [list [lindex $display_size 0] [lindex $display_size 1]]
+ return $object
+ }
+
+
+ # --------------------------------------------------------------
+ # Create the size selection dialog
+ # --------------------------------------------------------------
+
+ # Create the dialog window
+ set dialog [toplevel .set_lcd_size$vhw_HD44780_counter -class {Set display size} -bg ${::COMMON_BG_COLOR}]
+
+ # Set some namespace variables
+ incr vhw_HD44780_counter ;# Int: Counter of dialog instances
+ set vhw_HD44780_dialog $dialog ;# Widget: Toplevel window of dialog "Set display size"
+ set vhw_HD44780_size {0 0} ;# List of Int: LCD display size chosen by the user, {HEIGHT WIDTH}
+
+ # Create top frame (text: "Set display size" and actual display size)
+ set top_frame [frame $dialog.top_frame]
+ pack [label $top_frame.header_lbl \
+ -text [mc "Set display size"] \
+ -font [font create \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -family {helvetica}] \
+ ] -side left -padx 10
+ set vhw_HD44780_size_lbl [label $top_frame.size_lbl \
+ -text {0 × 0} \
+ -text [mc "Set display size"] \
+ -font [font create \
+ -size [expr {int(-16 * $::font_size_factor)}] \
+ -family {helvetica} -weight {bold}] \
+ ]
+ pack $vhw_HD44780_size_lbl -side right -padx 10
+ pack $top_frame -fill x
+
+ ## Create the matrix of rectangles for display size selection
+ set w 12
+ set h 17
+ set x0 3
+ set x $x0
+ set y 3
+ set canvas [canvas $dialog.canvas \
+ -bg {#FFFFFF} \
+ -height [expr {2 * ($h + 3) + 6}] \
+ -width [expr {40 * ($w + 3) + 6}] \
+ -bd 0 \
+ -highlightthickness 0 \
+ ]
+ set vhw_HD44780_canvas $canvas
+ for {set row 1} {$row <= 2} {incr row} {
+ for {set col 1} {$col <= 40} {incr col} {
+ set r [$canvas create rectangle \
+ $x \
+ $y \
+ [expr {$x + $w}] \
+ [expr {$y + $h}] \
+ -outline {#0000FF} \
+ ]
+
+ incr x $w
+ incr x 3
+
+ set vhw_HD44780_rect($row,$col) $r
+
+ $canvas bind $r <Enter> [list ::X::vhw_HD44780_ENTER $row $col]
+ $canvas bind $r <Leave> [list ::X::vhw_HD44780_ENTER 0 0]
+ $canvas bind $r <Button-1> [list ::X::vhw_HD44780_GO $row $col]
+ }
+ set x $x0
+ incr y $h
+ incr y 3
+ }
+ pack $canvas
+
+ # Set window parameters
+ wm iconphoto $dialog ::ICONS::16::set_lcd_size
+ wm title $dialog [mc "Set display size"]
+ wm resizable $dialog 0 0
+ wm protocol $dialog WM_DELETE_WINDOW {
+ X::vhw_HD44780_CANCEL
+ }
+ wm transient $dialog .
+ update
+ raise $dialog
+ catch {grab $dialog}
+
+ # Wait the dialog window is destroyed
+ tkwait window $dialog
+
+ # If the size was set then create the display
+ if {[lindex $vhw_HD44780_size 0] && [lindex $vhw_HD44780_size 1]} {
+ set object [LcdHD44780 #auto $actualProject]
+ $object set_config [list [lindex $vhw_HD44780_size 0] [lindex $vhw_HD44780_size 1]]
+ return $object
+ }
+ }
+
+ ## Handle pointer enter event in the canvas widget of the LCD display size selection dialog
+ # @parm Int target_row - Designated row
+ # @parm Int target_col - Designated column
+ # @return void
+ proc vhw_HD44780_ENTER {target_row target_col} {
+ variable vhw_HD44780_rect ;# Array: Rectangles in dialog "Set display size"
+ variable vhw_HD44780_canvas ;# Widget: Canvas widget in dialog "Set display size"
+ variable vhw_HD44780_size_lbl ;# Widget: Label showing the LCD size in dialog "Set display size"
+
+ # Adjust appearance of the matrix of rectangles
+ for {set row 1} {$row <= 2} {incr row} {
+ for {set col 1} {$col <= 40} {incr col} {
+ if {$row <= $target_row && $col <= $target_col} {
+ set fill {#AAFFDD}
+ } else {
+ set fill {#FFFFFF}
+ }
+ $vhw_HD44780_canvas itemconfigure $vhw_HD44780_rect($row,$col) -fill $fill
+ }
+ }
+
+ # Adjust contents of the label displaying the designated size
+ $vhw_HD44780_size_lbl configure -text [format {%d × %d} $target_row $target_col]
+ }
+
+ ## Set display size and close the LCD display size selection dialog
+ # @parm Int rows - Number of rows
+ # @parm Int cols - Number of columns
+ # @return void
+ proc vhw_HD44780_GO {rows cols} {
+ variable vhw_HD44780_size ;# List of Int: LCD display size chosen by the user, {HEIGHT WIDTH}
+ set vhw_HD44780_size [list $rows $cols]
+ vhw_HD44780_CANCEL
+ }
+
+ ## Close the LCD display size selection dialog
+ # @return void
+ proc vhw_HD44780_CANCEL {} {
+ variable vhw_HD44780_dialog ;# Widget: Toplevel window of dialog "Set display size"
+
+ if {[winfo exists $vhw_HD44780_dialog]} {
+ destroy $vhw_HD44780_dialog
+ }
+ }
+
## Invoke "Multiplexed LED display" (section Virtual Hardware)
# @return void
proc __vhw_M_LED_display {} {
@@ -10388,6 +11066,17 @@ namespace eval X {
return [SimpleKeyPad #auto $actualProject]
}
+ ## Invoke "DS1620 temperature sensor" (section Virtual Hardware)
+ # @return void
+ proc __vhw_ds1620 {} {
+ variable actualProject ;# Object: Current project
+ variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
+
+ if {$project_menu_locked} {return}
+
+ return [Ds1620 #auto $actualProject]
+ }
+
## Invoke "Matrix keypad" (section Virtual Hardware)
# @return void
proc __vhw_matrix_keypad {} {
@@ -10410,13 +11099,15 @@ namespace eval X {
# Ask user for save modified VHW scenario
if {[${::X::actualProject} pale_modified]} {
if {[tk_messageBox \
- -type yesno \
- -icon question \
+ -parent . \
+ -type yesno \
+ -icon question \
-title [mc "File modified"] \
-message [mc "The current VHW connections have been modified,\ndo you want to save them before closing ?"]
] == {yes}} then {
if {![$actualProject pale_save]} {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "IO Error"] \
@@ -10431,6 +11122,7 @@ namespace eval X {
-title [mc "Open file - Virtual HW - MCU 8051 IDE"] \
-directory [$actualProject cget -projectPath] \
-defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "All relevant"] {*.{vhw,vhc}}] \
[list [mc "Virtual HW"] {*.vhw}] \
[list [mc "VH component"] {*.vhc}] \
[list [mc "All files"] {*}] \
@@ -10441,11 +11133,12 @@ namespace eval X {
set filename [::fsd get]
if {[${::X::actualProject} pale_open_scenario $filename]} {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "IO Error"] \
-message [mc "Unable to read file:\n\"%s\"" $filename]
- } {
+ } else {
::X::recent_files_add 2 $filename
}
}
@@ -10468,6 +11161,7 @@ namespace eval X {
-title [mc "Load file - Virtual HW - MCU 8051 IDE"] \
-directory [$actualProject cget -projectPath] \
-defaultmask 0 -multiple 1 -filetypes [list \
+ [list [mc "All relevant"] {*.{vhw,vhc}}] \
[list [mc "Virtual HW"] {*.vhw}] \
[list [mc "VH component"] {*.vhc}] \
[list [mc "All files"] {*}] \
@@ -10478,11 +11172,12 @@ namespace eval X {
foreach filename [::fsd get] {
if {[${::X::actualProject} pale_load_scenarion $filename]} {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "IO Error"] \
-message [mc "Unable to read file:\n\"%s\"" $filename]
- } {
+ } else {
::X::recent_files_add 2 $filename
}
}
@@ -10538,7 +11233,7 @@ namespace eval X {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Do you want to overwrite it ?" [file tail $filename]]
] != {yes}
- } {
+ } then {
set abort 1
}
}
@@ -10546,11 +11241,12 @@ namespace eval X {
if {!$abort} {
if {![${::X::actualProject} pale_save_as $filename]} {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "IO Error"] \
-message [mc "Unable to save file:\n\"%s\"" $filename]
- } {
+ } else {
::X::recent_files_add 2 $filename
}
}
@@ -10576,14 +11272,14 @@ namespace eval X {
-title [mc "Are you sure ?"] \
-message [mc "Do you really want to remove all virtual hardware from the current simulation scenario ?"]
] != {yes}
- } {
+ } then {
return
}
$actualProject pale_forget_all
}
- ## Toggle fullscreen mode
+ ## Toggle full screen mode
# @return void
proc __toggle_fullscreen {} {
# Normal window
@@ -10592,14 +11288,21 @@ namespace eval X {
.mainIconBar.fullscreen configure -image ::ICONS::22::window_fullscreen
}
wm attributes . -fullscreen 0
- # Fullscreen window
- } {
+ # Full screen window
+ } else {
if {[winfo exists .mainIconBar.fullscreen]} {
.mainIconBar.fullscreen configure -image ::ICONS::22::window_nofullscreen
}
wm attributes . -fullscreen 1
}
+ # Without this help windows won't work properly on MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ after idle {
+ wm geometry . [wm geometry .]
+ }
+ }
+
# Restore position of bottom pane
after 300 {
foreach project ${::X::openedProjects} {
@@ -10630,19 +11333,189 @@ namespace eval X {
proc __functional_diagram {type} {
}
- ## Invoke a virtual terminal of the given type
- # @parm Int type -
+ ## Open arbitrary URI in user preffered application
+ # @parm String uri -- URI to open
# @return void
- proc __virtual_terminal {type} {
- variable actualProject ;# Object: Current project
- variable project_menu_locked ;# Bool: Indicates than there is at least one opened project
+ proc open_uri {uri} {
+ # On Linux and similars systems we use "xdg-open"
+ if {!$::MICROSOFT_WINDOWS} {
+ catch {
+ exec -- xdg-open $uri &
+ }
- if {$project_menu_locked} {return}
+ # On MS Windows we use its buildin command "start"
+ } else {
+ catch {
+ exec -- "cmd" "/c" "start [regsub -all {[^/\\]+\s[^/\\]*} $uri {"&"}]" &
+ }
+ }
+ }
- switch -- $type {
- {u} {
- $actualProject virtual_uart_termial_invoke_dialog
+ ## Open project web page in user preferred browser
+ # @return void
+ proc __web_page {} {
+ open_uri {http://mcu8051ide.sourceforge.net}
+ }
+
+ ## Open web page for reporting bugs in user preferred browser
+ # @return void
+ proc __bug_report {} {
+ open_uri {http://sourceforge.net/tracker/?group_id=185864&atid=914981}
+ }
+
+ ## Open handbook in user preferred PDF reader
+ # @return void
+ proc __handbook {} {
+ if {[file exists "${::INSTALLATION_DIR}/doc/handbook/mcu8051ide.${::GLOBAL_CONFIG(language)}.pdf"]} {
+ open_uri "${::INSTALLATION_DIR}/doc/handbook/mcu8051ide.${::GLOBAL_CONFIG(language)}.pdf"
+ } else {
+ open_uri "${::INSTALLATION_DIR}/doc/handbook/mcu8051ide.en.pdf"
+ }
+ }
+
+ ## Open web page with SDCC manual in user preferred browser
+ # @return void
+ proc __sdcc_manual {} {
+ open_uri {http://sdcc.sourceforge.net/doc/sdccman.html}
+ }
+
+ ## Open web page with ASEM-51 manual in user preferred browser
+ # @return void
+ proc __asem51_manual {} {
+ open_uri {http://plit.de/asem-51/docs.htm}
+ }
+
+ ## Open interactive 8051 instruction table
+ # @return void
+ proc __table_of_instructions {} {
+ variable table_of_instructions_object ;# Object: Interactive 8051 instruction table
+ if {$table_of_instructions_object != {}} {
+ if {[$table_of_instructions_object is_visible]} {
+ $table_of_instructions_object raise_window
+ } else {
+ $table_of_instructions_object restore_window
}
+ } else {
+ set table_of_instructions_object [TableOfInstructions #auto]
+ }
+ }
+
+ ## Make sure that there are no help windows visible
+ # @return void
+ proc remove_all_help_windows {} {
+ variable openedProjects ;# List of opened projects (Object references)
+
+ foreach project $openedProjects {
+ $project file_details_win_hide
}
+ ::Editor::close_completion_popup_window_NOW
+ close_project_details
+ help_window_hide
}
+
+ ## Perform secure send command
+ # Secure means that it will not crash or something like that in case of any errors.
+ # But instead it will popup an error message to the user (Tk dialog).
+ # @parm List args - Arguments for the send command
+ # @return void
+ proc secure_send args {
+ if {[catch {
+ eval "send $args"
+ } result]} then {
+ puts stderr "Unknown IO Error :: $result"
+ return 1
+
+ } else {
+ return 1
+ }
+ }
+
+ proc __d52 {} {
+ variable critical_procedure_in_progress ;# Bool: Disables procedures which takes a long time
+
+ if {$critical_procedure_in_progress} {return}
+
+ # Create dialog window
+ set win [toplevel .d52_open_dialog -class {Disassemble with D52} -bg ${::COMMON_BG_COLOR}]
+ set mainframe [frame $win.frame]
+
+ # Label, Entry and Button "Input file"
+ grid [Label $mainframe.lbl_input \
+ -text [mc "Input file"] \
+ -helptext [mc "File to disassemble"] \
+ ] -column 1 -row 1 -sticky w
+ grid [ttk::entry $mainframe.entry_input \
+ -textvariable X::input_file \
+ -width 50 \
+ ] -column 2 -row 1 -sticky we
+ DynamicHelp::add $mainframe.entry_input -text [mc "File to disassemble"]
+ grid [ttk::button $mainframe.button_select_input_file \
+ -image ::ICONS::16::fileopen \
+ -takefocus 0 \
+ -style Flat.TButton \
+ -command {
+ # Invoke file selection dialog
+ X::select_input_output 1 {{hex,ihx}} .d52_open_dialog
+ } \
+ ] -column 3 -row 1 -sticky e
+ DynamicHelp::add $mainframe.button_select_input_file \
+ -text [mc "Invoke dialog to select input file"]
+
+ # Create separator
+ grid [ttk::separator $mainframe.separator \
+ -orient horizontal \
+ ] -column 1 -columnspan 3 -row 2 -sticky we -pady 10
+
+ # Create buttons "Ok" and "Cancel"
+ set button_frame [frame $mainframe.button_frame]
+ pack [ttk::button $button_frame.button_ok \
+ -text [mc "Ok"] \
+ -command {X::d52_OK} \
+ -compound left \
+ -image ::ICONS::16::ok \
+ ] -side left -padx 5
+ pack [ttk::button $button_frame.button_cancel \
+ -text [mc "Cancel"] \
+ -command {X::d52_CANCEL} \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ ] -side left -padx 5
+ grid $button_frame -column 1 -columnspan 3 -row 3
+
+ pack $mainframe -fill both -expand 1 -padx 5 -pady 5
+
+ # Event bindings (Enter == Ok; Escape == Cancel)
+ bind $win <KeyRelease-Return> {X::d52_OK; break}
+ bind $win <KeyRelease-KP_Enter> {X::d52_OK; break}
+ bind $win <KeyRelease-Escape> {X::d52_CANCEL; break}
+
+ # Set window attributes -- modal window
+ wm iconphoto $win ::ICONS::16::d52
+ wm title $win [mc "Disassemble with D52 - MCU 8051 IDE"]
+ wm minsize $win 450 70
+ wm resizable $win 0 0
+ wm protocol $win WM_DELETE_WINDOW {
+ X::d52_CANCEL
+ }
+ wm transient $win .
+ catch {grab $win}
+ raise $win
+ tkwait window $win
+ }
+
+ proc d52_CANCEL {} {
+ catch {
+ destroy .d52_open_dialog
+ }
+ }
+
+ proc d52_OK {} {
+ variable input_file ;# Input file
+
+ d52_CANCEL
+ }
+}
+
+# >>> File inclusion guard
}
+# <<< File inclusion guard
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
diff --git a/lib/cli.tcl b/lib/cli.tcl
index d423339..63b28e0 100755..100644
--- a/lib/cli.tcl
+++ b/lib/cli.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 _CLI_TCL ] } {
+set _CLI_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Handle options given by command line interface
@@ -30,17 +35,17 @@
# SET COMMMAND LINE OPTIONS TO DEFAULTS
# --------------------------------------
set CLI_OPTION(notranslation) 0 ;# Disable i18n
-set CLI_OPTION(quiet) 0 ;# Don't display status of initialization progress on startup
+set CLI_OPTION(quiet) 0 ;# Don't display status of initialization progress on start-up
set CLI_OPTION(nosplash) 0 ;# Don't show splash screen
set CLI_OPTION(nocolor) 0 ;# Disable color output
set CLI_OPTION(defaults) 0 ;# Start with default settings
set CLI_OPTION(minimalized) 0 ;# Start with minimalized window
set CLI_OPTION(ignore_last) 0 ;# Start with an empty session
-set CLI_OPTION(check_libraries) 0 ;# Check if all nessery Tcl libraries are avaible
+set CLI_OPTION(check_libraries) 0 ;# Check if all necessary Tcl libraries are available
set CLI_OPTION(reset_settings) 0 ;# Reset all user settings to defaults
set CLI_OPTION(help) 0 ;# Show help message and exit
set CLI_OPTION(convert) 0 ;# Convert one file to another format
-set CLI_OPTION(no_opt) 0 ;# Disable optimalizations
+set CLI_OPTION(no_opt) 0 ;# Disable optimization
set CLI_OPTION(comp_quiet) 0 ;# Suppress compiler console output
set CLI_OPTION(no_sim) 0 ;# Do not generate SIM file
set CLI_OPTION(no_bin) 0 ;# Do not generate binary object code
@@ -50,13 +55,14 @@ set CLI_OPTION(warning_level) 0 ;# Compiler warning level
set CLI_OPTION(input_output) {} ;# List of file to convert: [0] == input file; [1] == output file
set CLI_OPTION(compile) {} ;# Compile this asm file and exit
set CLI_OPTION(open_project) {} ;# Open only project specified by this var if any
-set CLI_OPTION(config_file) {} ;# Specify path to file containg user settings
+set CLI_OPTION(config_file) {} ;# Specify path to file containing user settings
set CLI_OPTION(autoindent) {} ;# Specify path to file to indent
set CLI_OPTION(iram-size) {} ;# Size of internal data memory
set CLI_OPTION(xram-size) {} ;# Size of external data memory
set CLI_OPTION(code-size) {} ;# Size of program memory
set CLI_OPTION(disassemble) {} ;# IHEX8 file to disassemble
-set CLI_OPTION(no-plugins) 0 ;# Disable plugins
+set CLI_OPTION(no-plugins) 0 ;# Disable plug-ins
+set CLI_OPTION(simulator) 0 ;# Start simulator only
# ------------------------------------------------------------------------------
@@ -65,6 +71,8 @@ set CLI_OPTION(no-plugins) 0 ;# Disable plugins
if {$::MICROSOFT_WINDOWS} {
# Windows has no terminal control codes (at least I am not aware of them)
set CLI_OPTION(nocolor) 1
+ # It's usually only annoying to have verbose output on Windows
+ set CLI_OPTION(quiet) 1
}
# ------------------------------------------------------------------------------
@@ -102,7 +110,7 @@ proc CLI_set_memory_limit {option value maximum_in_hex memtype} {
if {[string index $arg end] == {k}} {
set arg [string replace $arg end end]
set kilo 1
- } {
+ } else {
set kilo 0
}
if {![string is digit -strict $arg]} {
@@ -113,7 +121,7 @@ proc CLI_set_memory_limit {option value maximum_in_hex memtype} {
set arg [expr {$arg * 1024}]
}
if {$arg > $maximum_in_hex} {
- puts stderr "Maximum acceptable size of $memtype memory is $maximum_in_hex ([expr $maximum_in_hex])"
+ puts stderr "Maximum acceptable size of $memtype memory is $maximum_in_hex ([expr {$maximum_in_hex}])"
exit 1
}
set CLI_OPTION($option) $arg
@@ -158,12 +166,12 @@ proc CLI_convert {i type} {
set file [lindex $argv [expr {$i + 2}]]
if {[file exists $file]} {
if {
- [file isdirectory $file] ||
- ![file writable $file]
- } {
- puts "${::APPNAME}"
- puts stderr "\tERROR: Unable to write to file '$file'"
- exit 1
+ [file isdirectory $file] ||
+ ![file writable $file]
+ } then {
+ puts "${::APPNAME}"
+ puts stderr "\tERROR: Unable to write to file '$file'"
+ exit 1
}
}
}
@@ -190,26 +198,35 @@ proc CLI_next_arg {i option key} {
# Check if the specified file does exist
if {
- [file isdirectory $::CLI_OPTION($key)] ||
- ![file exists $::CLI_OPTION($key)] ||
- (!$::MICROSOFT_WINDOWS && ![file readable $::CLI_OPTION($key)])]
- } {
- puts "${::APPNAME}"
- puts stderr "\tERROR: Unable to read file '$::CLI_OPTION($key)'"
- exit 1
+ [file isdirectory $::CLI_OPTION($key)] ||
+ ![file exists $::CLI_OPTION($key)] ||
+ (!$::MICROSOFT_WINDOWS && ![file readable $::CLI_OPTION($key)])
+ } then {
+ puts "${::APPNAME}"
+ puts stderr "\tERROR: Unable to read file '$::CLI_OPTION($key)'"
+ exit 1
}
}
-# PARSE COMMAND LINE OPTIONS
-# --------------------------
+## Parse command line options
+ # @return void
+proc parse_cli_options {} {
+ global argc ;# Int: Arguments count
+ global argv ;# List: Arguments list
+ global CLI_OPTION ;# Array: Commmand line options
+
+ # Open project file, if it's the only argument given to the program
+ if {$argc == 1 && [regexp {^.+\.mcu8051ide$} [lindex $argv 0]]} {
+ set CLI_OPTION(open_project) [file normalize [lindex $argv 0]]
+ return
+ }
-if {$argc} {
# iterate over all given arguments
for {set i 0} {$i < $argc} {incr i} {
set arg [lindex $argv $i]
# decide what to do with each of them
- switch -- $arg {
+ switch -exact -- $arg {
{--help} { ;# Display help message only
set CLI_OPTION(help) 1
@@ -217,7 +234,7 @@ if {$argc} {
{-h} { ;# Display help message only
set CLI_OPTION(help) 1
}
- {--quiet} { ;# Don't display initialization progress on startup
+ {--quiet} { ;# Don't display initialization progress on start-up
set CLI_OPTION(quiet) 1
}
{--no-translation} { ;# Disable i18n
@@ -226,7 +243,7 @@ if {$argc} {
{--no-i18n} { ;# Disable i18n
set CLI_OPTION(notranslation) 1
}
- {-q} { ;# Don't display initialization progress on startup
+ {-q} { ;# Don't display initialization progress on start-up
set CLI_OPTION(quiet) 1
}
{--nosplash} { ;# Don't show splash screen
@@ -264,6 +281,7 @@ if {$argc} {
CLI_next_arg $i {--config-file} {config_file}
incr i
}
+ {--assemble} -
{--compile} { ;# Compile asm file and exit
CLI_next_arg $i {--compile} {compile}
incr i
@@ -307,7 +325,7 @@ if {$argc} {
incr i
CLI_set_memory_limit {code-size} [lindex $argv $i] 0x10000 {code}
}
- {--no-opt} { ;# Disable optimalizations
+ {--no-opt} { ;# Disable optimization
set CLI_OPTION(no_opt) 1
}
{--comp-quiet} { ;# Suppress compiler console output
@@ -341,12 +359,26 @@ if {$argc} {
{--no-plugins} { ;# Disable plugins
set CLI_OPTION(no-plugins) 1
}
+ {--simulator} { ;# Start simulator only
+ set CLI_OPTION(simulator) 1
+ }
default { ;# Unknown option -- terminate program
puts stderr "Unknown command line option: '$arg'"
exit 1
}
}
}
+
+ # discard CLI arguments
+ set argc 0
+ set argv [list]
+}
+
+# PARSE COMMAND LINE OPTIONS
+# --------------------------
+
+if {$argc} {
+ parse_cli_options
}
# HANDLE CLI OPTIONS WHICH REQUIRE INSTANT RESPONSE
@@ -361,15 +393,15 @@ if {$CLI_OPTION(help)} {
set clr_end {}
set clr_opt {}
set clr_arg {}
- } {
+ } else {
puts "\033\[1mOptions:\033\[m"
set clr_end "\033\[m"
set clr_opt "\033\[32m"
set clr_arg "\033\[33;1m"
}
- puts "\t${clr_opt}--no-translation${clr_end},\tDisplay program language translation\n\t${clr_opt}--no-i18n${clr_end}"
+ puts "\t${clr_opt}--no-translation${clr_end},\tDisable program language translation\n\t${clr_opt}--no-i18n${clr_end}"
puts "\t${clr_opt}--help${clr_end}, ${clr_opt}-h${clr_end}\t\tDisplay this message"
- puts "\t${clr_opt}--quiet${clr_end}, ${clr_opt}-q${clr_end}\t\tDon't display status of initialization progress on startup"
+ puts "\t${clr_opt}--quiet${clr_end}, ${clr_opt}-q${clr_end}\t\tDon't display status of initialization progress on start-up"
puts "\t${clr_opt}--no-plugins${clr_end}\t\tDisable plugins"
puts "\t${clr_opt}--nosplash${clr_end}\t\tDon't show splash screen"
puts "\t${clr_opt}--nocolor${clr_end}, ${clr_opt}-n${clr_end}\t\tDisable color output"
@@ -378,7 +410,7 @@ if {$CLI_OPTION(help)} {
puts "\t${clr_opt}--minimalized${clr_end}\t\tStart with minimalized window"
puts "\t${clr_opt}--config-file ${clr_arg}filename${clr_end}\tSpecify path to file containg user settings"
puts "\t${clr_opt}--check-libraries${clr_end}\tCheck if all nessesary Tcl libraries are avaible"
- puts "\t${clr_opt}--ignore-last-session${clr_end}\tStart with an empty session (no project will be opened at startup)"
+ puts "\t${clr_opt}--ignore-last-session${clr_end}\tStart with an empty session (no project will be opened at start-up)"
puts "\t${clr_opt}--open-project ${clr_arg}project${clr_end}\tOpen only this project"
puts "\t${clr_opt}--reset-user-settings${clr_end}\tReset all user settings to defaults"
puts ""
@@ -390,13 +422,14 @@ if {$CLI_OPTION(help)} {
puts "\t${clr_opt}--normalize-hex ${clr_arg}input${clr_end}\tNormalize IHEX8 file"
puts ""
puts "\t${clr_opt}--disassemble ${clr_arg}hex_file${clr_end}\tDisaseble IHEX8 code to ${clr_arg}hex_file.asm${clr_end}"
- puts "\t${clr_opt}--compile ${clr_arg}asm_file${clr_end}\tCompile asm file and exit"
+ puts "\t${clr_opt}--assemble ${clr_arg}asm_file${clr_end}\tCompile asm file and exit"
+ puts "\t${clr_opt}--compile ${clr_arg}asm_file${clr_end}\tThe same as ``--assemble''"
puts "\t${clr_opt}--iram-size ${clr_arg}size${clr_end}\tSet size of internal data memory\t(eg. 1K or 1024) (default: 0x100)"
puts "\t${clr_opt}--code-size ${clr_arg}size${clr_end}\tSet size of program memory\t\t(eg. 1K or 1024) (default: 0x10000)"
puts "\t${clr_opt}--xram-size ${clr_arg}size${clr_end}\tSet size of external data memory\t(eg. 1K or 1024) (default: 0x10000)"
- puts "\t${clr_opt}--no-opt${clr_end}\t\tDisable optimalizations"
+ puts "\t${clr_opt}--no-opt${clr_end}\t\tDisable optimization"
puts "\t${clr_opt}--comp-quiet${clr_end}\t\tSuppress compiler console output"
- puts "\t${clr_opt}--no-sim${clr_end}\t\tDo not generate SIM file (for MCU 8051 IDE simulator)"
+ puts "\t${clr_opt}--no-sim${clr_end}\t\tDo not generate ADF file (Asm. Debug File for MCU 8051 IDE simulator)"
puts "\t${clr_opt}--no-bin${clr_end}\t\tDo not generate binary object code"
puts "\t${clr_opt}--no-lst${clr_end}\t\tDo not generate code listing"
puts "\t${clr_opt}--no-hex${clr_end}\t\tDo not generate IHEX8 object code"
@@ -406,6 +439,7 @@ if {$CLI_OPTION(help)} {
puts "\t\t${clr_arg}1${clr_end} - Errors + Warnings"
puts "\t\t${clr_arg}0${clr_end} - All (Default)"
puts ""
+ puts "\t${clr_opt}--simulator${clr_end}\t\tStart simulator only, see manual for more details"
exit
}
@@ -431,7 +465,7 @@ if {$CLI_OPTION(convert)} {
# Open input and output file
set input [open $input {r}]
- set output [open $output {w} 420]
+ set output [open $output {w} 0640]
fconfigure $input -translation binary
fconfigure $output -translation binary
@@ -476,7 +510,7 @@ if {$CLI_OPTION(convert)} {
if {${::IHexTools::error_count}} {
puts "FAILED !"
puts ${::IHexTools::error_string}
- } {
+ } else {
puts "Successful"
}
@@ -502,7 +536,7 @@ if {$CLI_OPTION(autoindent) != {}} {
exit 1
}
}
- puts "Formating ..."
+ puts "Formatting ..."
# Load and reformat file content
set ::X::reformat_code_abort 0
@@ -512,7 +546,7 @@ if {$CLI_OPTION(autoindent) != {}} {
close $file
# Save file
- set file [open $CLI_OPTION(autoindent) w 420]
+ set file [open $CLI_OPTION(autoindent) w 0640]
puts -nonewline $file $data
close $file
@@ -534,8 +568,8 @@ if {$CLI_OPTION(disassemble) != {}} {
# Open source and destination files
if {[catch {
set src_file [open $CLI_OPTION(disassemble) {r}]
- set trg_file [open [file rootname $CLI_OPTION(disassemble)].asm w 420]
- }]} {
+ set trg_file [open [file rootname $CLI_OPTION(disassemble)].asm w 0640]
+ }]} then {
puts stderr "Unable to open either \"$CLI_OPTION(disassemble)\" or \"[file rootname $CLI_OPTION(disassemble)].asm\""
exit 1
}
@@ -551,15 +585,15 @@ if {$CLI_OPTION(disassemble) != {}} {
if {${::IHexTools::error_count}} {
puts ${::IHexTools::error_string}
if {$CLI_OPTION(nocolor)} {
- puts "Decompilation FAILED"
- } {
- puts "\033\[31;1mDecompilation FAILED\033\[m"
+ puts "Disassembly FAILED"
+ } else {
+ puts "\033\[31;1mDisassembly FAILED\033\[m"
}
}
if {$CLI_OPTION(nocolor)} {
puts "Result stored in \"[file rootname $CLI_OPTION(disassemble)].asm\"\n"
- } {
+ } else {
puts "Result stored in \"\033\[34;1m[file rootname $CLI_OPTION(disassemble)].asm\033\[m\"\n"
}
@@ -574,7 +608,7 @@ if {$CLI_OPTION(disassemble) != {}} {
if {$CLI_OPTION(compile) != {}} {
# Import required sources
package require md5 2.0.1
- source "${::LIB_DIRNAME}/lib/Math.tcl" ;# Special mathematical operations
+ source "${::LIB_DIRNAME}/lib/Math.tcl" ;# Special mathematical operations
source "${::LIB_DIRNAME}/compiler/compiler.tcl" ;# 8051 Assemly language compiler
source "${::LIB_DIRNAME}/lib/ihextools.tcl" ;# Tools for manipulating with IHEX8
@@ -594,7 +628,7 @@ if {$CLI_OPTION(compile) != {}} {
set Compiler::Settings::xram_size $CLI_OPTION(xram-size)
}
- # Enable / Disable optimalizations
+ # Enable / Disable optimization
if {$CLI_OPTION(no_opt)} {
set Compiler::Settings::optim_ena 0
}
@@ -620,7 +654,7 @@ if {$CLI_OPTION(compile) != {}} {
# Initialize compiler
set result [Compiler::compile $directory $directory $filename $extension]
- # Exit acording to compilation result
+ # Exit according to compilation result
exit [expr {!$result}]
}
@@ -628,24 +662,24 @@ if {$CLI_OPTION(compile) != {}} {
if {$CLI_OPTION(check_libraries)} {
# Local varibale
- set librariesToCheck [llength $LIBRARIES_TO_LOAD] ;# Number of libs to check
+ set librariesToCheck [llength $::LIBRARIES_TO_LOAD] ;# Number of libs to check
set failsVer 0 ;# Number of libraries which didn't pass version check
set failsLib 0 ;# Number of libraries which could not be found
set failsTotal 0 ;# Number of fails tottaly
- puts "$APPNAME\n"
+ puts "$::APPNAME\n"
puts "\tChecking libraries..."
# Iterate over list of needed libraries
for {set i 0} {$i < $librariesToCheck} {incr i} {
# Local variables
- set library [lindex $LIBRARIES_TO_LOAD "$i 0"] ;# Library name
- set version [lindex $LIBRARIES_TO_LOAD "$i 1"] ;# Library version
+ set library [lindex $::LIBRARIES_TO_LOAD [list $i 0]] ;# Library name
+ set version [lindex $::LIBRARIES_TO_LOAD [list $i 1]] ;# Library version
# Print what library is currently being checked
if {$CLI_OPTION(nocolor)} {
puts "\t\t[expr {$i + 1}]/$librariesToCheck Checking for library $library"
- } {
+ } else {
puts "\t\t\033\[33m[expr {$i + 1}]/$librariesToCheck\033\[m \033\[37mChecking for library\033\[m \033\[32m$library\033\[m"
}
@@ -655,14 +689,14 @@ if {$CLI_OPTION(check_libraries)} {
if {[catch {package require $library}]} {
if {$CLI_OPTION(nocolor)} {
puts "NO !"
- } {
+ } else {
puts "\033\[31;01mNO !\033\[m"
}
incr failsLib
- } {
+ } else {
if {$CLI_OPTION(nocolor)} {
puts "YES"
- } {
+ } else {
puts "\033\[32;01mYES\033\[m"
}
}
@@ -670,21 +704,21 @@ if {$CLI_OPTION(check_libraries)} {
# Perform version check and diplay result
if {$CLI_OPTION(nocolor)} {
puts -nonewline "\t\t\tVersion $version\t... "
- } {
+ } else {
puts -nonewline "\t\t\tVersion \033\[36m$version\033\[m\t... "
}
flush stdout
if {[catch {package require $library $version}]} {
if {$CLI_OPTION(nocolor)} {
puts "NO !"
- } {
+ } else {
puts "\033\[31;01mNO !\033\[m"
}
incr failsVer
- } {
+ } else {
if {$CLI_OPTION(nocolor)} {
puts "YES"
- } {
+ } else {
puts "\033\[32;01mYES\033\[m"
}
}
@@ -693,7 +727,7 @@ if {$CLI_OPTION(check_libraries)} {
# Determinate number of total fails
if {$failsVer > $failsLib} {
set failsTotal $failsVer
- } {
+ } else {
set failsTotal $failsLib
}
@@ -704,16 +738,16 @@ if {$CLI_OPTION(check_libraries)} {
if {$CLI_OPTION(nocolor)} {
puts "\t\tNumber of fails: $failsTotal"
puts "\t\tPROGRAM WILL NOT RUN, please install the missing libraries"
- } {
+ } else {
puts "\t\tNumber of fails: \033\[31m$failsTotal\033\[m"
puts "\t\t\033\[31;01mPROGRAM WILL NOT RUN\033\[m, please install the missing libraries"
}
- } {
+ } else {
# SUCCESSFUL
if {$CLI_OPTION(nocolor)} {
puts "\t\tNumber of fails: $failsTotal"
puts "\t\tEverything seems ok"
- } {
+ } else {
puts "\t\tNumber of fails: \033\[32;01m$failsTotal\033\[m"
puts "\t\t\033\[32mEverything seems ok\033\[m"
}
@@ -723,3 +757,44 @@ if {$CLI_OPTION(check_libraries)} {
# done ...
exit
}
+
+# Start simulator only
+if {$CLI_OPTION(simulator)} {
+ puts [list $::SHORTNAME {SIM-ENGINE} $::VERSION]
+
+ # Import required libraries
+ package require Itcl 3.4
+ package require tdom 0.8
+
+ # Configure environment
+ set ::GUI_AVAILABLE 0
+ namespace import -force ::itcl::*
+
+ # Tools for manipulating with IHEX8
+ source "${::LIB_DIRNAME}/lib/ihextools.tcl"
+ # Simulator engine
+ source "${::LIB_DIRNAME}/simulator/engine/engine_core.tcl"
+ # PALE
+ source "${::LIB_DIRNAME}/pale/pale.tcl"
+ # Simulator enginine CLI
+ source "${::LIB_DIRNAME}/simulator/engine/engine_text_based_interface.tcl"
+ # Database of supported MCUs
+ source "${::LIB_DIRNAME}/dialogues/selectmcu.tcl"
+ #
+ source "${::LIB_DIRNAME}/lib/Math.tcl"
+ #
+ source "${::LIB_DIRNAME}/compiler/assembler.tcl"
+ #
+ source "${::LIB_DIRNAME}/compiler/compilerconsts.tcl"
+
+
+ # Enter main loop of the sim. engine CLI
+ SimulatorEngineCLI::enter_main_loop
+
+ # done ...
+ exit
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/compiler/assembler.tcl b/lib/compiler/assembler.tcl
index 5c41a28..17e5244 100755..100644
--- a/lib/compiler/assembler.tcl
+++ b/lib/compiler/assembler.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 _ASSEMBLER_TCL ] } {
+set _ASSEMBLER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Coverts precompiled source code to IHEX 8 format.
@@ -43,7 +48,7 @@
# ...
# hash - Hexadecimal MD5 hash of source code
# file - Filename of source code
-# filenum - File number (begining from 0)
+# filenum - File number (beginning from 0)
# line - Number of line in source code
# address - Code address
# code - Processor code
@@ -78,7 +83,7 @@ namespace eval assembler {
variable offset ;# Current address
variable data_len ;# Data length (for creating IHEX records)
variable data_field ;# Data field (for creating IHEX records)
- variable address ;# Address of begining of IHEX data field
+ variable address ;# Address of beginning of IHEX data field
variable operands ;# List of operand codes
variable opcode ;# OP code of the current instruction
variable bin_len ;# Lenght of binary data
@@ -106,7 +111,7 @@ namespace eval assembler {
variable lineNumber 0 ;# Number of line currently beeing parsed
variable opcode ;# OP code of the current instruction
variable operands ;# List of operand codes
- variable address ;# Address of begining of IHEX data field
+ variable address ;# Address of beginning of IHEX data field
variable opr_types ;# List of operand types
variable offset 0 ;# Current address
variable data_len 0 ;# Data length (for creating IHEX records)
@@ -137,7 +142,7 @@ namespace eval assembler {
foreach filename $included_files {
if {[catch {
append adf [::md5::md5 -hex -file $filename]
- } result]} {
+ } result]} then {
append adf 0
CompilationError [mc "File access error:\n%s" $result]
}
@@ -152,7 +157,9 @@ namespace eval assembler {
foreach line $code {
# Update GUI after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
free_resources
@@ -179,6 +186,7 @@ namespace eval assembler {
if {$opcode == { }} {
set opcode 32
}
+
set opcode [format %X $opcode]
set digits [string length $opcode]
if {$digits < 2} {
@@ -189,7 +197,7 @@ namespace eval assembler {
}
set nolist 1
- } {
+ } else {
# Check for instruction existence
if {[notAnInstruction $instruction]} {continue}
@@ -206,7 +214,7 @@ namespace eval assembler {
set offset $address
}
- # If data length overlaps 255 or adress is too high -> flush data buffer
+ # If data length overlaps 255 or address is too high -> flush data buffer
if {($pointer < $address) || (($data_len + $len) > ${::Compiler::Settings::max_ihex_rec_length})} {
write_bin
write_hex
@@ -214,7 +222,7 @@ namespace eval assembler {
set offset $address
set pointer $address
- # Unexpected adress
+ # Unexpected address
} elseif {$pointer > $address} {
CompilationError [mc "Invalid address at %s" 0x[format %X $address]]
set pointer $address
@@ -231,7 +239,7 @@ namespace eval assembler {
# Translate operands to 16|12|8-bit hex
set operands [oprs2hex]
- # Adjust inctruction OP code acording to the OP code mask and operands
+ # Adjust instruction OP code according to the OP code mask and operands
if {$mask != 0} {
# Determinate length of the first operand
set mask_bin [hex2binlist $mask]
@@ -259,12 +267,12 @@ namespace eval assembler {
set operand0 [string range $operand0 $opr_len end]
# Adjust OP code
- set idx 0
+ set op_idx 0
foreach mask_bit $mask_bin {
if {$mask_bit} {
- set opcode [lreplace $opcode $idx $idx [lindex $opcode_opr $idx]]
+ set opcode [lreplace $opcode $op_idx $op_idx [lindex $opcode_opr $op_idx]]
}
- incr idx
+ incr op_idx
}
# Finalize
@@ -290,7 +298,7 @@ namespace eval assembler {
append opcode [lindex $operands 1]
append opcode [lindex $operands 0]
# Other instructions
- } {
+ } else {
foreach opr $operands {
append opcode $opr
}
@@ -308,12 +316,13 @@ namespace eval assembler {
write_hex
if {${::Compiler::Settings::OBJECT}} {
append hex {:00000001FF}
+ append hex "\n"
}
# Return result
if {$error_count} {
return 0
- } {
+ } else {
return 1
}
}
@@ -327,7 +336,8 @@ namespace eval assembler {
data_field address operands
opcode bin_len error_count
fileNumber
- } {
+ } \
+ {
set ::assembler::$var {}
}
}
@@ -355,7 +365,7 @@ namespace eval assembler {
variable adf ;# Output simulator data
variable fileNumber ;# File number
variable lineNumber ;# Number of line currently beeing parsed
- variable address ;# Address of begining of IHEX data field
+ variable address ;# Address of beginning of IHEX data field
variable opcode ;# OP code of the current instruction
variable operands ;# List of operand codes
@@ -370,12 +380,12 @@ namespace eval assembler {
lappend new_code [expr "0x[lindex $operands 1]"]
lappend new_code [expr "0x[lindex $operands 0]"]
# Other instructions
- } {
+ } else {
foreach hex $operands {
if {[string length $hex] == 4} {
lappend new_code [expr "0x[string range $hex 0 1]"]
lappend new_code [expr "0x[string range $hex 2 3]"]
- } {
+ } else {
lappend new_code [expr "0x$hex"]
}
}
@@ -409,7 +419,7 @@ namespace eval assembler {
# Write binary data
for {set i 0; set j 1} {$i < $data_len} {incr i 2; incr j 2} {
set hex [string range $data_field $i $j]
- append bin [subst "\\x$hex"]
+ append bin [subst -nocommands "\\x$hex"]
incr bin_len
}
}
@@ -480,13 +490,18 @@ namespace eval assembler {
# Check for validity of the given operand
set opr [string trimleft $opr {#@/}]
- if {![regexp {^\d+$} $opr]} {
+ if {![string is digit -strict $opr]} {
CompilationError [mc "Invalid operand: '%s'" $opr]
break
}
# Convert to hexadecimal string
- set opr [format %X $opr]
+ set opr [string trimleft $opr 0]
+ if {$opr == {}} {
+ set opr 0
+ } else {
+ set opr [format %X $opr]
+ }
# Adjust length
set opr_len [string length $opr]
@@ -525,7 +540,7 @@ namespace eval assembler {
variable opr_types ;# List of operand types
# Iterate over operands definitions
- foreach definition [lindex $CompilerConsts::InstructionDefinition($instruction) 1] {
+ foreach definition [lindex $::CompilerConsts::InstructionDefinition($instruction) 1] {
# Determinate operand types
set opr_list [lindex $definition 0]
@@ -585,11 +600,15 @@ namespace eval assembler {
if {${::Compiler::Settings::WARNING_LEVEL} < 3} {
if {${::Compiler::Settings::NOCOLOR}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
- [::Compiler::msgc {EL}][mc "Compilation error at line %s: %s" "${lineNumber}${filename}" $errorInfo]
- } {
+ [::Compiler::msgc {EL}][mc "Compilation error at %s: %s" "${lineNumber}${filename}" $errorInfo]
+ } else {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
- [mc "\033\[31;1mCompilation error at line \033\[31;1;4m%s\033\[m%s: %s" $lineNumber $filename $errorInfo]
+ [mc "\033\[31;1mCompilation error at \033\[31;1;4m%s\033\[m%s: %s" $lineNumber $filename $errorInfo]
}
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/compiler/codelisting.tcl b/lib/compiler/codelisting.tcl
index 1940dc3..a760d4c 100755..100644
--- a/lib/compiler/codelisting.tcl
+++ b/lib/compiler/codelisting.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 _CODELISTING_TCL ] } {
+set _CODELISTING_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Hepler namespace to generate code listing.
@@ -68,42 +73,42 @@ namespace eval CodeListing {
set pageLines 0
# Validate compiler settings
- if {${Compiler::Settings::PAGELENGTH} < 5} {
+ if {${::Compiler::Settings::PAGELENGTH} < 5} {
set Compiler::Settings::PAGELENGTH 5
- } elseif {${Compiler::Settings::PAGELENGTH} == 0} {
+ } elseif {${::Compiler::Settings::PAGELENGTH} == 0} {
set Compiler::Settings::PAGING 0
}
- if {${Compiler::Settings::PAGEWIDTH} < 68} {
+ if {${::Compiler::Settings::PAGEWIDTH} < 68} {
set Compiler::Settings::PAGEWIDTH 68
- } elseif {${Compiler::Settings::PAGEWIDTH} == 0} {
+ } elseif {${::Compiler::Settings::PAGEWIDTH} == 0} {
set Compiler::Settings::PAGEWIDTH 116
}
# Create page header
- set header ${Compiler::Settings::INPUT_FILE_NAME}
- set len [string length ${Compiler::Settings::INPUT_FILE_NAME}]
+ set header ${::Compiler::Settings::INPUT_FILE_NAME}
+ set len [string length ${::Compiler::Settings::INPUT_FILE_NAME}]
if {$len < 15} {
append header [string repeat { } [expr {15 - $len}]]
}
- append header { } ${Compiler::Settings::TITLE}
+ append header { } ${::Compiler::Settings::TITLE}
set len [string length $header]
incr len 23
# Adjust page header width
- if {$len > ${Compiler::Settings::PAGEWIDTH}} {
- set header [string range $header 0 [expr {${Compiler::Settings::PAGEWIDTH} - 24}]]
+ if {$len > ${::Compiler::Settings::PAGEWIDTH}} {
+ set header [string range $header 0 [expr {${::Compiler::Settings::PAGEWIDTH} - 24}]]
append header {... }
- } elseif {$len < ${Compiler::Settings::PAGEWIDTH}} {
- set len [expr {${Compiler::Settings::PAGEWIDTH} - $len}]
+ } elseif {$len < ${::Compiler::Settings::PAGEWIDTH}} {
+ set len [expr {${::Compiler::Settings::PAGEWIDTH} - $len}]
append header [string repeat { } $len]
}
# Create date
- set len [string length ${Compiler::Settings::DATE}]
+ set len [string length ${::Compiler::Settings::DATE}]
if {$len > 10} {
- set Compiler::Settings::DATE [string range 0 7 ${Compiler::Settings::DATE}]
+ set Compiler::Settings::DATE [string range 0 7 ${::Compiler::Settings::DATE}]
append Compiler::Settings::DATE {...}
} elseif {$len < 10} {
@@ -111,11 +116,11 @@ namespace eval CodeListing {
append Compiler::Settings::DATE [string repeat { } $len]
}
- append header ${Compiler::Settings::DATE} { PAGE}
+ append header ${::Compiler::Settings::DATE} { PAGE}
# Create error summary and symbol table
create_error_summary
- if {${Compiler::Settings::SYMBOLS}} {
+ if {${::Compiler::Settings::SYMBOLS}} {
create_symbol_table
}
@@ -129,7 +134,7 @@ namespace eval CodeListing {
append lst ", 1 ERROR FOUND"
} elseif {$errors_count > 1} {
append lst ", $errors_count ERRORS FOUND"
- } {
+ } else {
append lst ", NO ERRORS FOUND"
}
@@ -137,7 +142,7 @@ namespace eval CodeListing {
append lst ", 1 WARNING"
} elseif {$warnings_count > 1} {
append lst ", $warnings_count WARNINGS"
- } {
+ } else {
append lst ", NO WARNINGS"
}
@@ -151,7 +156,7 @@ namespace eval CodeListing {
}
# Symbol table
- if {${Compiler::Settings::SYMBOLS}} {
+ if {${::Compiler::Settings::SYMBOLS}} {
append lst "\n\n"
append lst $symbol_table
}
@@ -168,14 +173,14 @@ namespace eval CodeListing {
## Directive LIST
# @access public
- # @parm Int idx - index where the directive occured
+ # @parm Int idx - index where the directive occurred
# @return void
proc directive_list {idx} {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
- if {${Compiler::Settings::_list} != 0} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
+ if {${::Compiler::Settings::_list} != 0} {return}
# Adjust code listing
set idx [getIdx $idx]
@@ -185,14 +190,14 @@ namespace eval CodeListing {
## Directive NOLIST
# @access public
- # @parm Int idx - index where the directive occured
+ # @parm Int idx - index where the directive occurred
# @return void
proc directive_nolist {idx} {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
- if {${Compiler::Settings::_list} != 0} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
+ if {${::Compiler::Settings::_list} != 0} {return}
# Adjust code listing
set idx [getIdx $idx]
@@ -224,7 +229,7 @@ namespace eval CodeListing {
# @return void
proc create_listing {data} {
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
variable lst ;# Resulting LST code
variable sync_map ;# Map of lines in code listing
@@ -255,8 +260,8 @@ namespace eval CodeListing {
variable symbol_table ;# Table of symbolic names
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
- if {!${Compiler::Settings::SYMBOLS}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::SYMBOLS}} {return}
# Iterate over definition ists and write them to the table
foreach def_list {
@@ -271,14 +276,14 @@ namespace eval CodeListing {
} char {
B C D I
X C N S
- } {
-
+ } \
+ {
# Get list of defined names
- set def_list [subst "\$PreProcessor::$def_list"]
+ set def_list [subst -nocommands "\$PreProcessor::$def_list"]
# Write defined names to the table
foreach var $def_list {
- set value [subst "\$PreProcessor::${val_array}($var)"]
+ set value [subst -nocommands "\$PreProcessor::${val_array}($var)"]
# Handle special constants
if {$char == {S}} {
@@ -290,7 +295,7 @@ namespace eval CodeListing {
1 0]
# Other constants ...
- } {
+ } else {
lappend symbol_table [list \
[string toupper $var] \
$char \
@@ -302,14 +307,14 @@ namespace eval CodeListing {
}
# Write defined variables (directive "SET")
- foreach var ${PreProcessor::defined_SET} {
- set value [lindex $PreProcessor::const_SET($var) {end 1}]
+ foreach var ${::PreProcessor::defined_SET} {
+ set value [lindex $::PreProcessor::const_SET($var) {end 1}]
lappend symbol_table [list [string toupper $var] { } NUMB [get_4hex $value] 1 1]
}
# Write defined special variables (directive "SET")
- foreach var ${PreProcessor::defined_SET_SPEC} {
- set value [lindex $PreProcessor::const_SET_SPEC($var) {end 1}]
+ foreach var ${::PreProcessor::defined_SET_SPEC} {
+ set value [lindex $::PreProcessor::const_SET_SPEC($var) {end 1}]
lappend symbol_table [list [string toupper $var] {S} SPEC [string toupper $value] 1 1]
}
@@ -317,7 +322,7 @@ namespace eval CodeListing {
set symbol_table [lsort -index 0 $symbol_table]
}
- ## Set flag used to 1 for symbol writen in table of symbols
+ ## Set flag used to 1 for symbol written in table of symbols
# @access public
# @parm String symbolic_name - Symbol name
# @parm String type - Symbol type
@@ -326,8 +331,8 @@ namespace eval CodeListing {
variable symbol_table ;# Table of symbolic names
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
- if {!${Compiler::Settings::SYMBOLS}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::SYMBOLS}} {return}
# Find the specified symbol in the table
set symbolic_name [string toupper $symbolic_name]
@@ -348,19 +353,19 @@ namespace eval CodeListing {
## Write error message to the code listing
# @access public
- # @parm Int idx - Index where the error occured
+ # @parm Int idx - Index where the error occurred
# @parm String info - Error message
# @return void
proc Error {idx info} {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Adjust index
set idx [getIdx $idx]
if {$idx == {}} {
- puts stderr "Compiler internal failure 0 -- code listing will not be complete"
+ puts stderr "Assembler internal failure 0 -- code listing will not be complete"
return
}
incr idx
@@ -372,19 +377,19 @@ namespace eval CodeListing {
## Write warning message to the code listing
# @access public
- # @parm Int idx - Index where the warning occured
+ # @parm Int idx - Index where the warning occurred
# @parm String info - Warning message
# @return void
proc Warning {idx info} {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Adjust index
set idx [getIdx $idx]
if {$idx == {}} {
- puts stderr "Compiler internal failure 4 -- code listing will not be complete"
+ puts stderr "Assembler internal failure 4 -- code listing will not be complete"
return
}
incr idx
@@ -402,12 +407,12 @@ namespace eval CodeListing {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Adjust index
set idx [getIdx $idx]
if {$idx == {}} {
- puts stderr "Compiler internal failure 5 -- code listing will not be complete"
+ puts stderr "Assembler internal failure 5 -- code listing will not be complete"
return
}
incr idx 2
@@ -426,13 +431,14 @@ namespace eval CodeListing {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Determinate original values
set sub_idx [getIdx $idx]
+
if {$sub_idx != {}} {
set new_values [lindex $lst [list $sub_idx 1]]
- } {
+ } else {
set new_values {}
}
@@ -468,7 +474,7 @@ namespace eval CodeListing {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Create empty space in code listing
insert_lines $idx [llength $macro_code]
@@ -479,10 +485,10 @@ namespace eval CodeListing {
set tmp_lst {}
# Adjust Macro expansion level and Inclusion level
- set IncLevel [lindex $lst "$idx 3"]
- set MacLevel [lindex $lst "$idx 4"]
+ set IncLevel [lindex $lst [list $idx 3]]
+ set MacLevel [lindex $lst [list $idx 4]]
if {![regexp {^\d+$} $MacLevel]} {
- puts stderr "Compiler internal failure 1 -- code listing will not be complete"
+ puts stderr "Assembler internal failure 1 -- code listing will not be complete"
return
}
incr MacLevel
@@ -493,7 +499,7 @@ namespace eval CodeListing {
}
# Set macro expansion level
- lset lst "$idx 4" $MacLevel
+ lset lst [list $idx 4] $MacLevel
# Insert code of macro to the current code listing
incr idx
@@ -515,7 +521,7 @@ namespace eval CodeListing {
variable new_sync_map ;# Tempotary Map of lines in code listing
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Reformat synchronization map
set new_sync_map {}
@@ -545,7 +551,7 @@ namespace eval CodeListing {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Adjust code listing
set idx [getIdx $idx]
@@ -554,7 +560,7 @@ namespace eval CodeListing {
if {[catch {
lset lst [list $idx 1] $opcode
}]} then {
- puts stderr "Compiler internal failure 2 -- code listing will not be complete"
+ puts stderr "Assembler internal failure 2 -- code listing will not be complete"
return
}
}
@@ -569,15 +575,15 @@ namespace eval CodeListing {
variable sync_map ;# Map of lines in code listing
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Adjust code listing
set idx [getIdx $idx]
if {$idx == {}} {return}
if {[catch {
- lset lst "$idx 0" [get_4hex $addr]
+ lset lst [list $idx 0] [get_4hex $addr]
}]} then {
- puts stderr "Compiler internal failure 3 -- code listing will not be complete"
+ puts stderr "Assembler internal failure 3 -- code listing will not be complete"
return
}
}
@@ -585,13 +591,14 @@ namespace eval CodeListing {
## Directive "END"
# @access public
# @parm Int idx - Source index
+ # @parm Bool preserve_current_line=false - Do not remove the `$idx' line from the sync. map
# @return void
- proc end_directive {idx} {
+ proc end_directive {idx {preserve_current_line 0}} {
variable sync_map ;# Map of lines in code listing
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Determinate target index
set lst_idx [getIdx $idx]
@@ -601,7 +608,12 @@ namespace eval CodeListing {
# Adjust code listing and synchronization map
set lst [lreplace $lst $lst_idx end]
- set sync_map [lreplace $sync_map $idx end]
+ if {$preserve_current_line} {
+ incr idx
+ }
+ if {$idx < [llength $sync_map]} {
+ set sync_map [lreplace $sync_map $idx end]
+ }
}
## Set value for symbol definition
@@ -613,14 +625,14 @@ namespace eval CodeListing {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Determinate target index
set idx [getIdx $idx]
if {$idx == {}} {return}
# Adjust code listing
- lset lst "$idx 2" [get_4hex $value]
+ lset lst [list $idx 2] [get_4hex $value]
}
## Set value for special symbol definition
@@ -642,7 +654,7 @@ namespace eval CodeListing {
variable lst ;# Resulting LST code
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Insert empty lines for the included code
insert_lines $idx [expr {[llength $data] - 1}]
@@ -651,8 +663,8 @@ namespace eval CodeListing {
set idx [getIdx $idx]
# Adjust macro expansion level and inclusion level
- set IncLevel [lindex $lst "$idx 3"]
- set MacLevel [lindex $lst "$idx 4"]
+ set IncLevel [lindex $lst [list $idx 3]]
+ set MacLevel [lindex $lst [list $idx 4]]
incr IncLevel
# Adjust the given source code
@@ -673,6 +685,12 @@ namespace eval CodeListing {
}
+ ## Get last index in the synchronization map
+ # @return Int - The index
+ proc get_last_index_in_sync_map {} {
+ return [expr {[llength ${::CodeListing::sync_map}] - 1}]
+ }
+
## Line removed -- adjust synchronization map
# @access public
# @parm Int idx - source index
@@ -681,24 +699,20 @@ namespace eval CodeListing {
variable sync_map ;# Map of lines in code listing
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
# Adjust synchronization map
- if {[catch {
- set sync_map [lreplace $sync_map $idx $idx]
- }]} {
- puts stderr "Still unresolved compiler bug. I am sorry for that, code listing will not be complete. (As far as I know there is only one bug of that kind)"
- }
+ set sync_map [lreplace $sync_map $idx $idx]
}
- ## Adjust synchronization map to create spece which cannot contain anything
+ ## Adjust synchronization map to create a space which cannot contain anything
# @access public
# @parm Int dest_idx - Target index
# @parm Int len - Number of lines
# @return void
proc insert_empty_lines {dest_idx len} {
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
variable sync_map ;# Map of lines in code listing
variable new_sync_map ;# Tempotary Map of lines in code listing
@@ -775,9 +789,9 @@ namespace eval CodeListing {
}
# Create new page if paging is enabled
- if {${Compiler::Settings::PAGING}} {
+ if {${::Compiler::Settings::PAGING}} {
incr pageLines
- if {$pageLines > ${Compiler::Settings::PAGELENGTH}} {
+ if {$pageLines > ${::Compiler::Settings::PAGELENGTH}} {
incr pageNum
set pageLines 1
append result "\n\f" $header { } $pageNum "\n\n"
@@ -798,7 +812,7 @@ namespace eval CodeListing {
incr lineNum -1
# Normal line
- } {
+ } else {
# Local variables
set addr [lindex $line 0] ;# Address field
set opcode [lindex $line 1] ;# Instruction OP code
@@ -810,7 +824,7 @@ namespace eval CodeListing {
# Adjust inclusion level
if {$IncLevel == 0} {
set IncLevel { }
- } {
+ } else {
set IncLevel "=$IncLevel"
if {[string length $IncLevel] == 2} {
append IncLevel { }
@@ -820,7 +834,7 @@ namespace eval CodeListing {
# Adjust macro expansion level
if {$MacLevel == 0} {
set MacLevel { }
- } {
+ } else {
set MacLevel "+$MacLevel"
if {[string length $MacLevel] == 2} {
append MacLevel { }
@@ -862,7 +876,7 @@ namespace eval CodeListing {
set line {}
append line $field0 { } $IncLevel { } $line_number
append line { } $MacLevel { } [tabs2spaces $code]
- append result [string range $line 0 [expr ${Compiler::Settings::PAGEWIDTH} - 1]] "\n"
+ append result [string range $line 0 [expr ${::Compiler::Settings::PAGEWIDTH} - 1]] "\n"
# Continue in unfinished opcode
if {$opcode_len > 10} {
@@ -887,7 +901,7 @@ namespace eval CodeListing {
# @return String - output data
proc tabs2spaces {data} {
set tmp {} ;# Auxiliary variable
- while 1 {
+ while {1} {
# Search for 1st tabulator
set idx [string first "\t" $data]
@@ -939,7 +953,7 @@ namespace eval CodeListing {
set error_summary {}
# Create new page
- if {${Compiler::Settings::PAGING}} {
+ if {${::Compiler::Settings::PAGING}} {
incr pageNum
set pageLines 0
append error_summary "\n\f" $header { } $pageNum "\n\n"
@@ -953,10 +967,10 @@ namespace eval CodeListing {
incr lineNum
# Create new page if nessesary
- if {${Compiler::Settings::PAGING}} {
+ if {${::Compiler::Settings::PAGING}} {
incr pageLines
- if {$pageLines > ${Compiler::Settings::PAGEWIDTH}} {
+ if {$pageLines > ${::Compiler::Settings::PAGEWIDTH}} {
incr pageNum
set pageLines 1
append error_summary "\n\f" $header { } $pageNum "\n\n"
@@ -968,7 +982,7 @@ namespace eval CodeListing {
if {[lindex $line {1 0}] == {ERROR:}} {
incr errors_count
- } {
+ } else {
incr warnings_count
}
@@ -992,7 +1006,7 @@ namespace eval CodeListing {
set result {}
# Create new page
- if {${Compiler::Settings::PAGING}} {
+ if {${::Compiler::Settings::PAGING}} {
incr pageNum
set pageLines 0
append result "\n\f" $header { } $pageNum "\n\n"
@@ -1006,10 +1020,10 @@ namespace eval CodeListing {
foreach var $symbol_table {
# Create new page if nessesary
- if {${Compiler::Settings::PAGING}} {
+ if {${::Compiler::Settings::PAGING}} {
incr pageLines
- if {$pageLines > ${Compiler::Settings::PAGEWIDTH}} {
+ if {$pageLines > ${::Compiler::Settings::PAGEWIDTH}} {
incr pageNum
set pageLines 1
append result "\n\f" $header { } $pageNum "\n\n"
@@ -1037,14 +1051,14 @@ namespace eval CodeListing {
# Adjust rd
if {$rd == 1} {
set rd {REDEFINABLE}
- } {
+ } else {
set rd {}
}
# Adjust nu
if {$nu == 1} {
set nu {NOT USED}
- } {
+ } else {
set nu { }
}
@@ -1056,7 +1070,7 @@ namespace eval CodeListing {
# Composite final line
if {$char != {S}} {
set h {H}
- } {
+ } else {
set nu { }
set h [string repeat { } [expr {5 - [string length $val]}]]
}
@@ -1105,7 +1119,7 @@ namespace eval CodeListing {
return $number
}
- ## Translate source index to target index acording to synchronization map
+ ## Translate source index to target index according to synchronization map
# @access private
# @parm Int idx - Source index
# @return Int - target index
@@ -1126,7 +1140,7 @@ namespace eval CodeListing {
# @return void
proc insert_lines {dest_idx len} {
# Check if code listing is enabled
- if {!${Compiler::Settings::PRINT}} {return}
+ if {!${::Compiler::Settings::PRINT}} {return}
if {$len == 0} {return}
variable sync_map ;# Map of lines in code listing
@@ -1167,3 +1181,7 @@ namespace eval CodeListing {
set sync_map $new_sync_map
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/compiler/compiler.tcl b/lib/compiler/compiler.tcl
index 35dea32..932e67a 100755..100644
--- a/lib/compiler/compiler.tcl
+++ b/lib/compiler/compiler.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,20 +21,25 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _COMPILER_TCL ] } {
+set _COMPILER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# 8051 COMPILER - BASE NAMESPACE
# --------------------------------------------------------------------------
# Include other parts
source "${::LIB_DIRNAME}/compiler/codelisting.tcl" ;# Code listing creator
-source "${::LIB_DIRNAME}/compiler/assembler.tcl" ;# Assemler
+source "${::LIB_DIRNAME}/compiler/assembler.tcl" ;# Assembler
source "${::LIB_DIRNAME}/compiler/disassembler.tcl" ;# Disassembler
source "${::LIB_DIRNAME}/compiler/preprocessor.tcl" ;# Preprocessor
source "${::LIB_DIRNAME}/compiler/compilerconsts.tcl" ;# Compiler constant definitons
source "${::LIB_DIRNAME}/compiler/external_compiler.tcl";# External compiler interface
namespace eval Compiler {
- variable error_count ;# Number of errors occured during compilation
+ variable error_count ;# Number of errors occurred during compilation
variable warning_count ;# Number of warning reported during compilation
variable in_IDE 0 ;# Bool: Running in IDE (I mean GUI)
@@ -46,10 +51,10 @@ namespace eval Compiler {
# @parm String project_dir - Project directory
# @parm String current_dir - Current working directory
# @parm String input_file_name - Name of input source code
- # @parm String input_file_extension = {} - Extension of input file
+ # @parm String input_file_extension={} - Extension of input file
# @return Bool - result
- proc compile {project_dir current_dir input_file_name input_file_extension} {
- variable error_count ;# Number of errors occured during compilation
+ proc compile {project_dir current_dir input_file_name {input_file_extension {}}} {
+ variable error_count ;# Number of errors occurred during compilation
variable warning_count ;# Number of warning reported during compilation
# Compiler settings to defaults
@@ -58,12 +63,12 @@ namespace eval Compiler {
# Adjust compiler settings
if {${::Compiler::Settings::_print} == 2} {
set ::Compiler::Settings::PRINT 0
- } {
+ } else {
set ::Compiler::Settings::PRINT 1
}
if {${::Compiler::Settings::_object} == 2} {
set ::Compiler::Settings::OBJECT 0
- } {
+ } else {
set ::Compiler::Settings::OBJECT 1
}
@@ -88,13 +93,13 @@ namespace eval Compiler {
set asm [open $file r]
set asm_data [read $asm]
close $asm
- }]} {
+ }]} then {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Unable to open the specified file. (%s)" $file]
- ${Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Compilation FAILED !"]
- } {
- ${Settings::TEXT_OUPUT_COMMAND} [mc "Unable to open the specified file. (\033\[34;1m%s\033\[m)" $file]
- ${Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mCompilation FAILED !\033\[m"]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Unable to open the specified file. (%s)" $file]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Compilation FAILED !"]
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Unable to open the specified file. (\033\[34;1m%s\033\[m)" $file]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mCompilation FAILED !\033\[m"]
}
return 0
}
@@ -102,34 +107,34 @@ namespace eval Compiler {
# Initialize preprocessor
if {!${::Compiler::Settings::QUIET}} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
"\n\n[::Compiler::msgc {SN}][mc {Compiling file: %s} $input_file_name$input_file_extension]"
- } {
- ${Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\n\nCompiling file: \033\[34;1m%s\033\[m" $input_file_name$input_file_extension]
}
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "Initializing pre-processor ..."]
}
set precompiledCode [PreProcessor::compile $current_dir $file $asm_data]
set asm_data {}
- incr error_count ${PreProcessor::error_count}
- incr warning_count ${PreProcessor::warning_count}
- if {${PreProcessor::error_count} > 0} {
+ incr error_count ${::PreProcessor::error_count}
+ incr warning_count ${::PreProcessor::warning_count}
+ if {${::PreProcessor::error_count} > 0} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Pre-processing FAILED !"]
- } {
- ${Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mPre-processing FAILED !\033\[m"]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Pre-processing FAILED !"]
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mPre-processing FAILED !\033\[m"]
}
report_status $current_dir $input_file_name
return 0
}
- if {${Settings::ABORT_VARIABLE}} {return 0}
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {return 0}
# Initialize Assembler
if {!${::Compiler::Settings::QUIET}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Compiling ..."]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Compiling ..."]
}
assembler::compile \
[md5::md5 -hex -file $file] \
@@ -139,152 +144,152 @@ namespace eval Compiler {
${::PreProcessor::included_files} \
$precompiledCode
set ::PreProcessor::included_files {}
- incr error_count ${assembler::error_count}
- if {${assembler::error_count} > 0} {
+ incr error_count ${::assembler::error_count}
+ if {${::assembler::error_count} > 0} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Compilation FAILED !"]
- } {
- ${Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mCompilation FAILED !\033\[m"]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Compilation FAILED !"]
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mCompilation FAILED !\033\[m"]
}
report_status $current_dir $input_file_name
return 0
}
- if {${Settings::ABORT_VARIABLE}} {return 0}
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {return 0}
# Write resulting object code
- if {${Settings::OBJECT}} {
- if {${Settings::OBJECT_FILE} != {}} {
- set object_file ${Settings::OBJECT_FILE}
- } {
+ if {${::Compiler::Settings::OBJECT}} {
+ if {${::Compiler::Settings::OBJECT_FILE} != {}} {
+ set object_file ${::Compiler::Settings::OBJECT_FILE}
+ } else {
set object_file $input_file_name
append object_file {.hex}
}
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "Creating IHEX8 ...\t\t\t-> \"%s\"" $object_file]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "Creating IHEX8 ...\t\t\t-> \"\033\[34;1m%s\033\[m\"" $object_file]
}
makeBackupFile $current_dir $object_file
if {[catch {
- set hex [open [file join $current_dir $object_file] w 420]
- }]} {
+ set hex [open [file join $current_dir $object_file] w 0640]
+ }]} then {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EN}][mc "Error: Unable to open file \"%s\" for writing" [file join $current_dir $object_file]]
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EN}][mc "Compilation FAILED !"]
- } {
- ${Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[31;1mError\033\[m: Unable to open file \"\033\[34;1m%s\033\[m\" for writing" [file join $current_dir $object_file]]
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[31;1mCompilation FAILED !\033\[m"]
}
report_status $current_dir $input_file_name
return 0
} else {
- puts -nonewline $hex ${assembler::hex}
+ puts -nonewline $hex ${::assembler::hex}
close $hex
}
}
- if {${Settings::ABORT_VARIABLE}} {return 0}
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {return 0}
# Write resulting binary object code
- if {${Settings::CREATE_BIN_FILE}} {
+ if {${::Compiler::Settings::CREATE_BIN_FILE}} {
if {!${::Compiler::Settings::QUIET}} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "Creating object file ...\t\t-> \"%s\"" "${input_file_name}.bin"]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "Creating object file ...\t\t-> \"\033\[34;1m%s\033\[m\"" "${input_file_name}.bin"]
}
}
makeBackupFile $current_dir "${input_file_name}.bin"
if {[catch {
- set bin [open [file join $current_dir $input_file_name.bin] w 420]
- }]} {
+ set bin [open [file join $current_dir $input_file_name.bin] w 0640]
+ }]} then {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EN}][mc "Error: Unable to open file \"%s\" for writing" [file join $current_dir $input_file_name.bin]]
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EN}][mc "Compilation FAILED !"]
- } {
- ${Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "Error: Unable to open file \"\033\[34;1m%s\033\[m\" for writing" [file join $current_dir "${input_file_name}.bin"]]
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[31;1mCompilation FAILED !\033\[m"]
}
report_status $current_dir $input_file_name
return 0
} else {
fconfigure $bin -translation binary
- puts -nonewline $bin ${assembler::bin}
+ puts -nonewline $bin ${::assembler::bin}
close $bin
}
set bin_data {}
}
set hex_data {}
- if {${Settings::ABORT_VARIABLE}} {return 0}
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {return 0}
# Write simulator data file
- if {${Settings::CREATE_SIM_FILE}} {
+ if {${::Compiler::Settings::CREATE_SIM_FILE}} {
if {!${::Compiler::Settings::QUIET}} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "Creating assembler debug file ...\t-> \"%s\"" "${input_file_name}.adf"]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "Creating simulator data file ...\t-> \"\033\[34;1m%s\033\[m\"" "${input_file_name}.adf"]
}
}
makeBackupFile $current_dir "${input_file_name}.adf"
if {[catch {
- set sim [open [file join $current_dir $input_file_name.adf] w 420]
- }]} {
+ set sim [open [file join $current_dir $input_file_name.adf] w 0640]
+ }]} then {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Settings::TEXT_OUPUT_COMMAND} \
- [::Compiler::msgc {EN}][mc "Error: Unable to open file \"%s]\" for writing" [file join $current_dir $input_file_name.adf]
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ [::Compiler::msgc {EN}][mc "Error: Unable to open file \"%s]\" for writing" [file join $current_dir $input_file_name.adf]]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EN}][mc "Compilation FAILED !"]
- } {
- ${Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[31;1mError\033\[m: Unable to open file \"\033\[34;1m%s\033\[m\" for writing" [file join $current_dir $input_file_name.adf]]
- ${Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[31;1mCompilation FAILED !\033\[m"]
}
report_status $current_dir $input_file_name
return 0
- } {
- puts -nonewline $sim ${assembler::adf}
+ } else {
+ puts -nonewline $sim ${::assembler::adf}
close $sim
}
}
- if {${Settings::ABORT_VARIABLE}} {return 0}
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {return 0}
# Report final status
report_status $current_dir $input_file_name
if {!${::Compiler::Settings::QUIET}} {
if {${::Compiler::Settings::optim_ena}} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
- [mc "Number of optimalizations performed: %s" ${::PreProcessor::optims}]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
- [mc "Number of optimalizations performed: \033\[1m%s\033\[m" ${::PreProcessor::optims}]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ [mc "Number of optimization performed: %s" ${::PreProcessor::optims}]
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ [mc "Number of optimization performed: \033\[1m%s\033\[m" ${::PreProcessor::optims}]
}
}
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {SN}][mc "Compilation successful. (time: %s sec.)" [expr {[clock seconds] - $sec}]]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[32;1mCompilation successful.\033\[m (time: %s sec.)" [expr {[clock seconds] - $sec}]]
}
}
@@ -307,25 +312,25 @@ namespace eval Compiler {
# @parm String input_file_name - Name of input file
# @return void
proc report_status {current_dir input_file_name} {
- variable error_count ;# Number of errors occured during compilation
+ variable error_count ;# Number of errors occurred during compilation
variable warning_count ;# Number of warning reported during compilation
# Determinate name of code listing file
- if {${Settings::PRINT_FILE} != {}} {
- set print_file ${Settings::PRINT_FILE}
- } {
+ if {${::Compiler::Settings::PRINT_FILE} != {}} {
+ set print_file ${::Compiler::Settings::PRINT_FILE}
+ } else {
set print_file $input_file_name
append print_file {.lst}
}
- # Message "Creting code listing file"
- if {!${::Compiler::Settings::QUIET}} {
+ # Message "Creating code listing file"
+ if {!${::Compiler::Settings::QUIET} && ${::Compiler::Settings::PRINT}} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
- [mc "Creting code listing file ...\t\t-> \"%s\"" $print_file]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
- [mc "Creting code listing file ...\t\t-> \"\033\[34;1m%s\033\[m\"" $print_file]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ [mc "Creating code listing file ...\t\t-> \"%s\"" $print_file]
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ [mc "Creating code listing file ...\t\t-> \"\033\[34;1m%s\033\[m\"" $print_file]
}
}
@@ -333,7 +338,7 @@ namespace eval Compiler {
if {!${::Compiler::Settings::QUIET}} {
if {$::TRANSLATION_LOADED} {
set text [mc "%s errors, %s warnings" $error_count $warning_count]
- } {
+ } else {
set text "$error_count error"
if {$error_count != 1} {
append text "s"
@@ -344,30 +349,32 @@ namespace eval Compiler {
}
}
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} $text
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} "\033\[1m$text\033\[m"
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} $text
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} "\033\[1m$text\033\[m"
}
}
# Write code listing file
- makeBackupFile $current_dir $print_file
- if {[catch {
- set lst [open [file join $current_dir $print_file] w 420]
- }]} {
- if {${::Compiler::Settings::NOCOLOR}} {
- ${Settings::TEXT_OUPUT_COMMAND} \
- [::Compiler::msgc {EN}][mc "Error: Unable to open file \"%s\" for writing" [file join $current_dir $print_file]]
- ${Settings::TEXT_OUPUT_COMMAND} [mc "Compilation FAILED !"]
- } {
- ${Settings::TEXT_OUPUT_COMMAND} \
- [::Compiler::msgc {EN}][mc "Error: Unable to open file \"\033\[34;1m%s\033\[m\" for writing" [file join $current_dir $print_file]]
- ${Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mCompilation FAILED !\033\[m"]
+ if {${::Compiler::Settings::PRINT}} {
+ makeBackupFile $current_dir $print_file
+ if {[catch {
+ set lst [open [file join $current_dir $print_file] w 0640]
+ }]} then {
+ if {${::Compiler::Settings::NOCOLOR}} {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ [::Compiler::msgc {EN}][mc "Error: Unable to open file \"%s\" for writing" [file join $current_dir $print_file]]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Compilation FAILED !"]
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ [::Compiler::msgc {EN}][mc "Error: Unable to open file \"\033\[34;1m%s\033\[m\" for writing" [file join $current_dir $print_file]]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mCompilation FAILED !\033\[m"]
+ }
+ return 0
+ } else {
+ puts -nonewline $lst [CodeListing::getListing]
+ close $lst
}
- return 0
- } else {
- puts -nonewline $lst [CodeListing::getListing]
- close $lst
}
}
@@ -388,7 +395,7 @@ namespace eval Compiler {
## Namespace containing compiler settings
namespace eval Settings {
- ## Peerhole optimalization enable flag
+ ## Peephole optimization enable flag
variable optim_ena 0 ;# Bool: 0 == disabled; 1 == enabled
## Memory limits
@@ -500,8 +507,9 @@ namespace eval Compiler {
} default {
_nomod_value _paging_value _pagelength_value _pagewidth_value
_title_value _date_value _object_file _print_file
- } {
- set $var [subst "\$$default"]
+ } \
+ {
+ set $var [subst -nocommands "\$$default"]
}
# Finalize
@@ -555,3 +563,7 @@ namespace eval Compiler {
# Compiler settings to defaults
Compiler::Settings::restoreDefaults
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/compiler/compilerconsts.tcl b/lib/compiler/compilerconsts.tcl
index 175ceb9..e8a71f4 100755..100644
--- a/lib/compiler/compilerconsts.tcl
+++ b/lib/compiler/compilerconsts.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 _COMPILERCONSTS_TCL ] } {
+set _COMPILERCONSTS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Defines compiler constatnts. This code is part of Compiler
@@ -67,11 +72,18 @@ namespace eval CompilerConsts {
}
# All compiler directives
variable AllDirectives {
- bit set equ code data
- xdata idata bseg dseg iseg
- xseg ds dbit cseg db
- dw include list nolist
+ endif endm end else exitm
+ list nolist dseg iseg bseg
+ xseg cseg skip name equ
+ bit set code data idata
+ xdata macro flag ds dw
+ db dbit include org if
+ using byte name rept times
+ elseif ifn elseifn ifdef elseifdef
+ ifndef elseifndef ifb elseifb
+ ifnb elseifnb local
}
+
# Addresses of SFR registers
variable MapOfSFRArea {
{P0 80} {SP 81} {DPL 82} {DPH 83}
@@ -146,7 +158,7 @@ namespace eval CompilerConsts {
# Format:
# {
# {Instruction} {Operands_count
- # {{Operand_type_0 Operand_type_1 ...} Code_length Opcode Opcode_mask Instr_cycles_per_iteration}
+ # {{Operand_type_0 Operand_type_1 ...} Code_length Opcode Opcode_mask Machine_cycles_per_iteration}
# ...
# }
# ...
@@ -705,9 +717,10 @@ namespace eval CompilerConsts {
MapOfSFRArea
MapOfSFRBitArea
progVectors
- } {
+ } \
+ {
variable $var
- set val [subst "\$$var"]
+ set val [subst -nocommands "\$$var"]
regsub -all {\s+} $val { } $var
}
@@ -743,6 +756,7 @@ namespace eval CompilerConsts {
incr def_idx
# Local variables
+ set time [lindex $code_def 4] ;# Time
set mask [lindex $code_def 3] ;# OP code mask
set opcode [lindex $code_def 2] ;# OP code
set len [lindex $code_def 1] ;# Code length
@@ -777,10 +791,10 @@ namespace eval CompilerConsts {
continue
}
lappend defined_OPCODE $opcode
- set Opcode($opcode) "$instruction {$operands} $len {}"
+ set Opcode($opcode) [list $instruction $operands $len {} $time]
}
# Non-zero OP code mask
- } {
+ } else {
# Translate OP code and its mask to list of booleans
set opcode [assembler::hex2binlist $opcode]
set mask [assembler::hex2binlist $mask]
@@ -808,7 +822,7 @@ namespace eval CompilerConsts {
}
# Determinate list of possible high-order values
- # of opreands acording to the mask
+ # of opreands according to the mask
set values {}
set tmp 0
set tmp_len 0
@@ -832,7 +846,7 @@ namespace eval CompilerConsts {
if {$mask_bit} {
append tmp [string index $val $idx]
incr idx
- } {
+ } else {
append tmp $opcode_bit
}
}
@@ -860,7 +874,7 @@ namespace eval CompilerConsts {
continue
}
lappend defined_OPCODE $opcode
- set Opcode($opcode) [list $instruction $operands $len $masked_opr]
+ set Opcode($opcode) [list $instruction $operands $len $masked_opr $time]
}
}
@@ -871,3 +885,7 @@ namespace eval CompilerConsts {
# Initialize NS variables
CompilerConsts::initialize
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/compiler/disassembler.tcl b/lib/compiler/disassembler.tcl
index b74fedf..6319c1e 100755..100644
--- a/lib/compiler/disassembler.tcl
+++ b/lib/compiler/disassembler.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 _DISASSEMBLER_TCL ] } {
+set _DISASSEMBLER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# Disassembler 8051
#
@@ -46,8 +51,8 @@ namespace eval disassembler {
variable hex_data {} ;# Raw input data
variable hex {} ;# Adjusted input data, list: {addr hex0 hex1 hex2 ...}
variable lineNum {} ;# Number of line currently beeing parsed
- variable error_count {} ;# Number of errors raised during decompilation
- variable warning_count {} ;# Number of warnings occured
+ variable error_count {} ;# Number of errors raised during disassembly
+ variable warning_count {} ;# Number of warnings occurred
variable label_idx {} ;# Label index
variable final_lbls 0 ;# Number of final labels
variable label ;# Array of tempotary labels, label(int) -> addr
@@ -58,7 +63,7 @@ namespace eval disassembler {
# GENERAL PURPOSE PROCEDURES
# ----------------------------------------------------------------
- ## Initiate decompilation
+ ## Initiate disassembly
# @parm string data - Input IHEX8 code
# @return string - output asm code or {}
proc compile {data} {
@@ -66,8 +71,8 @@ namespace eval disassembler {
variable hex_data ;# Raw input
variable hex ;# Adjusted input data, list: {addr hex0 hex1 hex2 ...}
variable lineNum ;# Number of line currently beeing parsed
- variable error_count ;# Number of errors raised during decompilation
- variable warning_count ;# Number of warnings occured
+ variable error_count ;# Number of errors raised during disassembly
+ variable warning_count ;# Number of warnings occurred
variable asm ;# Resulting source code
set error_count 0 ;# reset errors count
@@ -79,7 +84,7 @@ namespace eval disassembler {
regexp -all {\r\n?} hex_data "\n" hex_data
set hex_data [split $hex_data "\n"]
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {SN}][mc "Initializing disassembler ..."]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {SN}][mc "Initializing disassembler ..."]
# Verify input code validity and set variable 'hex'
adjust_code
@@ -87,17 +92,17 @@ namespace eval disassembler {
# Exit if the code does not seem to be valid
if {$error_count != 0} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EN}][mc "Disassembly FAILED ..."]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EN}][mc "\033\[31;1mDisassembly FAILED\033\[m ..."]
}
return {}
}
- if {${Compiler::Settings::ABORT_VARIABLE}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
free_resources
return {}
}
@@ -105,8 +110,8 @@ namespace eval disassembler {
# Convert processor code into asm code
decompile_code
- if {${Compiler::Settings::ABORT_VARIABLE}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}[mc "Aborted"]
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
free_resources
return {}
}
@@ -114,8 +119,8 @@ namespace eval disassembler {
# Create labels in resulting code
parse_labels
- if {${Compiler::Settings::ABORT_VARIABLE}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
free_resources
return {}
}
@@ -123,26 +128,26 @@ namespace eval disassembler {
# Final stage
final_stage
- if {${Compiler::Settings::ABORT_VARIABLE}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
free_resources
return {}
}
- # Free memory used during decompilation
+ # Free memory used during disassembly
free_resources
- if {${Compiler::Settings::ABORT_VARIABLE}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
+ if {${::Compiler::Settings::ABORT_VARIABLE}} {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EN}][mc "Aborted"]
free_resources
return {}
}
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {SN}][mc "Disassembly complete"]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} \
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[32;1mDisassembly complete\033\[m"]
}
@@ -167,7 +172,9 @@ namespace eval disassembler {
foreach line $hex_data {
- if {[expr {$lineNum % 10}] == 0} ${Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$lineNum % 10}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
incr lineNum ;# line number
@@ -209,7 +216,7 @@ namespace eval disassembler {
set len [expr "0x$len"]
set data [string range $line 8 {end-2}]
if {$len != ([string length $data] / 2)} {
- Error $lineNum [mc "Length field do not corespond true data length"]
+ Error $lineNum [mc "Length field do not correspond true data length"]
continue
}
@@ -217,11 +224,11 @@ namespace eval disassembler {
set addr_hex [string range $line 2 5]
set addr [expr "0x$addr_hex"]
if {$addr <= $pointer} {
- Error $lineNum [mc "Unexpected address -- code is not well formated"]
+ Error $lineNum [mc "Unexpected address -- code is not well formatted"]
continue
} elseif {$addr > ($pointer + 1)} {
set pointer $addr
- } {
+ } else {
incr pointer $len
}
@@ -262,7 +269,9 @@ namespace eval disassembler {
foreach line $hex {
- if {[expr {$idx % 10}] == 0} ${Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 10}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
incr idx
@@ -276,7 +285,7 @@ namespace eval disassembler {
if {$trailing_data_length} {
# Write trailing data
foreach opcode $trailing_data {
- append asm "_$pointer {DB 0${opcode}h {}} "
+ lappend asm _$pointer [list {DB} "0${opcode}h" {}]
incr pointer
}
# Reset trailing data
@@ -286,7 +295,7 @@ namespace eval disassembler {
# Adjust pointer
set pointer $addr_dec
- append asm "{} {} {} {ORG [HEX $addr]h {}} "
+ lappend asm {} {} {} [list {ORG} "[HEX $addr]h" {}]
}
# Number of data fields
@@ -295,7 +304,7 @@ namespace eval disassembler {
# Append trailing data from last parsing to the current line
if {$trailing_data_length} {
# append
- incr len $trailing_data_length
+ incr len $trailing_data_length
set line [concat $trailing_data $line]
# reset
set trailing_data_length 0
@@ -310,13 +319,13 @@ namespace eval disassembler {
set opcode [lindex $line $idx] ;# current opcode
# Search for he given opcode
- if {[lsearch ${CompilerConsts::defined_OPCODE} $opcode] == -1} {
+ if {[lsearch ${::CompilerConsts::defined_OPCODE} $opcode] == -1} {
# opcode not found -> write opcode directly to source code
- append asm "_$pointer {DB 0${opcode}h {}} "
+ lappend asm "_$pointer" [list {DB} "0${opcode}h" {}]
set length 1
} else {
# opcode found -> resolve it's definition
- set def $CompilerConsts::Opcode($opcode)
+ set def $::CompilerConsts::Opcode($opcode)
set instruction [lindex $def 0] ;# Instruction name
set opr_types [lindex $def 1] ;# Oprand types
@@ -338,15 +347,15 @@ namespace eval disassembler {
set opr {}
foreach type $opr_types {
- if {[lsearch ${CompilerConsts::FixedOperands} [string tolower $type]] != -1} {
+ if {[lsearch ${::CompilerConsts::FixedOperands} [string tolower $type]] != -1} {
# Fixed operand -> only copy
set opr $type
- } {
+ } else {
# Get operand value
incr idx
if {$idx > $len} {
- append asm "_$pointer {DB 0${opcode}h {}} "
+ lappend asm "_$pointer" [{DB} "0${opcode}h" {}]
set instruction_skipped 1
set length 1
incr idx -1
@@ -361,7 +370,7 @@ namespace eval disassembler {
incr idx
if {$idx > $len} {
- append asm "_$pointer {DB 0${opcode}h {}} "
+ lappend asm "_$pointer" [list {DB} "0${opcode}h" {}]
set instruction_skipped 1
set length 1
incr idx -2
@@ -373,7 +382,7 @@ namespace eval disassembler {
set opr "[HEX [lindex $line $idx]]h"
set tmp_opr [string range $opr 0 {end-1}]
set tmp_opr [expr "0x$tmp_opr"]
- foreach item ${CompilerConsts::MapOfSFRBitArea} {
+ foreach item ${::CompilerConsts::MapOfSFRBitArea} {
if {[expr "0x[lindex $item 1]"] == $tmp_opr} {
set opr [lindex $item 0]
break
@@ -384,7 +393,7 @@ namespace eval disassembler {
set opr "/[HEX [lindex $line $idx]]h"
set tmp_opr [string range $opr 1 {end-1}]
set tmp_opr [expr "0x$tmp_opr"]
- foreach item ${CompilerConsts::MapOfSFRBitArea} {
+ foreach item ${::CompilerConsts::MapOfSFRBitArea} {
if {[expr "0x[lindex $item 1]"] == $tmp_opr} {
set opr [lindex $item 0]
break
@@ -395,7 +404,7 @@ namespace eval disassembler {
set opr "[HEX [lindex $line $idx]]h"
set tmp_opr [string range $opr 0 {end-1}]
set tmp_opr [expr "0x$tmp_opr"]
- foreach item ${CompilerConsts::MapOfSFRArea} {
+ foreach item ${::CompilerConsts::MapOfSFRArea} {
if {[expr "0x[lindex $item 1]"] == $tmp_opr} {
set opr [lindex $item 0]
break
@@ -417,7 +426,7 @@ namespace eval disassembler {
if {$label($label_idx) > 0x0FFFF || $label($label_idx) < 0} {
set label($label_idx) [expr {$label($label_idx) & 0x0FFFF}]
- Warning "Code address overflow, instruction: $instruction"
+ Warning [mc "Code address overflow, instruction: %s" $instruction]
} elseif {$label($label_idx) == $pointer} {
unset label($label_idx)
incr label_idx -1
@@ -429,6 +438,7 @@ namespace eval disassembler {
set opr "lbl${label_idx}-"
set label($label_idx) "$mask_opr[lindex $line $idx]"
set label($label_idx) [expr "0x$label($label_idx)"]
+ set label($label_idx) [expr {($label($label_idx) & 0x007ff) | ($pointer & 0x0f800)}]
if {$label($label_idx) == $pointer} {
unset label($label_idx)
@@ -443,7 +453,7 @@ namespace eval disassembler {
incr idx
if {$idx > $len} {
- append asm "_$pointer {DB 0${opcode}h {}} "
+ lappend asm "_$pointer" [list {DB} "0${opcode}h" {}]
set length 1
incr idx -2
set instruction_skipped 1
@@ -471,8 +481,17 @@ namespace eval disassembler {
continue
}
+ # Swap operands in case if of instruction "MOV data, data"
+ if {
+ $instruction == {mov} &&
+ [lindex $opr_types 0] == {data} &&
+ [lindex $opr_types 1] == {data}
+ } then {
+ set operands [list [lindex $operands 1] [lindex $operands 0]]
+ }
+
# Append line to source code list
- append asm "_$pointer {$instruction {$operands} {}} "
+ lappend asm "_$pointer" [list $instruction $operands {}]
}
# Increment program address pointer
incr pointer $length
@@ -501,7 +520,7 @@ namespace eval disassembler {
if {$idx != -1} {
# Reuse an existing label
regsub -all "lbl${i}-" $asm "label$idx" asm
- } {
+ } else {
# Realy a new label
lappend addrs $label($i)
incr lbl_idx
@@ -517,7 +536,7 @@ namespace eval disassembler {
if {$idx == -1} {
# Not found
append equ_block "{} {CODE [HEX [format %X $addr]]h label$i} "
- } {
+ } else {
# Found
incr idx
lset asm [list $idx 2] "label$i"
@@ -544,7 +563,9 @@ namespace eval disassembler {
# Rewrite the source code
for {set i 1} {$i <= $len} {incr i 2} {
- if {[expr {$len % 5}] == 0} ${Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$len % 5}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
set line [lindex $asm $i] ;# Get line
@@ -554,7 +575,7 @@ namespace eval disassembler {
continue
# Not an empty line
- } {
+ } else {
set label [lindex $line 2] ;# label
set instr [lindex $line 0] ;# instruction
set oprs [lindex $line 1] ;# oprands
@@ -589,7 +610,7 @@ namespace eval disassembler {
variable hex_data ;# Raw input data
variable hex ;# Adjusted input data, list: {addr hex0 hex1 hex2 ...}
variable lineNum ;# Number of line currently beeing parsed
- variable error_count ;# Number of errors raised during decompilation
+ variable error_count ;# Number of errors raised during disassembly
variable label_idx ;# Label index
variable label ;# Array of tempotary labels, label(int) -> addr
variable asm ;# Resulting source code
@@ -620,12 +641,12 @@ namespace eval disassembler {
}
## Report warning message
- # @parm Int LineNumber - Number of line where it occured
+ # @parm Int LineNumber - Number of line where it occurred
# @parm String ErrorInfo - Text of the warning
# @return void
proc Warning {ErrorInfo} {
variable idx ;# Current position in asm list
- variable warning_count ;# Number of warnings occured
+ variable warning_count ;# Number of warnings occurred
# Increment warning counter
incr warning_count
@@ -633,32 +654,36 @@ namespace eval disassembler {
# Report the warning
if {${::Compiler::Settings::WARNING_LEVEL} < 2} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {WN}][mc "Warning: %s" $ErrorInfo]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\033\[33mWarning\033\[m: %s" $ErrorInfo]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {WN}][mc "Warning: %s" $ErrorInfo]
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\033\[33mWarning\033\[m: %s" $ErrorInfo]
}
}
}
## Error
- # @parm Int lineNumber - number of line, where the error occured
+ # @parm Int lineNumber - number of line, where the error occurred
# @parm String info - error string
proc Error {lineNumber info} {
variable error_count
incr error_count
if {$lineNumber != {}} {
if {${::Compiler::Settings::NOCOLOR}} {
- set lineNumber [mc " at line %s" $lineNumber]
- } {
- set lineNumber [mc " at line \033\[31;1;4m%s\033\[m" $lineNumber]
+ set lineNumber [mc " at %s" $lineNumber]
+ } else {
+ set lineNumber [mc " at \033\[31;1;4m%s\033\[m" $lineNumber]
}
}
if {${::Compiler::Settings::WARNING_LEVEL} < 3} {
if {${::Compiler::Settings::NOCOLOR}} {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EL}][mc "Error%s: %s" $lineNumber $info]
- } {
- ${Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mError%s\033\[m: %s" $lineNumber $info]
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [::Compiler::msgc {EL}][mc "Error%s: %s" $lineNumber $info]
+ } else {
+ ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\033\[31;1mError%s\033\[m: %s" $lineNumber $info]
}
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/compiler/external_compiler.tcl b/lib/compiler/external_compiler.tcl
index 3cf581b..5d8c6b2 100755..100644
--- a/lib/compiler/external_compiler.tcl
+++ b/lib/compiler/external_compiler.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 _EXTERNAL_COMPILER_TCL ] } {
+set _EXTERNAL_COMPILER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements interface to external compilers
@@ -163,7 +168,7 @@ namespace eval ExternalCompiler {
variable sdcc_string_options_def {
model --model-small
standard --std-sdcc89
- stack --pack-iram
+ stack {}
custom {}
}
# Current SDCC string options
@@ -192,6 +197,16 @@ namespace eval ExternalCompiler {
# Current semicolon separated optional string options
variable sdcc_scs_string_options
+ ## Make utility
+ # General options, this is an array!
+ variable makeutil_config
+ # Default values for the eneral options
+ variable makeutil_config_def {
+ c_ena 0
+ c_file {}
+ co_file {}
+ ct_file {}
+ }
## Make backup copies for files with the given extensions and remove original files
# (input_filename.extension -> input_filename.extension~)*
@@ -217,50 +232,76 @@ namespace eval ExternalCompiler {
proc compile_C {work_dir input_file iram xram code} {
variable input_filename ;# String: Name of file to compile (without extension)
variable compiler_used ;# Int: Compiler ID (1 == ASEM-51; 2 == ASL; 3 == AS31, other values have no meaning)
+ variable makeutil_config;# Make utility - general options
set compiler_used 0
set input_filename [file rootname $input_file]
backup_and_remove {asm cdb ihx}
set sdcc_opts [determinate_sdcc_options]
- if {${::PROGRAM_AVALIABLE(sdcc-sdcc)}} {
+ if {${::PROGRAM_AVAILABLE(sdcc-sdcc)}} {
set sdcc_cmd {sdcc-sdcc}
- } {
+ } else {
set sdcc_cmd {sdcc}
}
- ::X::messages_text_append [::Compiler::msgc {S}][mc "\n\nStarting compiler ..."]
+
+ # Normal way (POSIX)
if {!$::MICROSOFT_WINDOWS} {
- ::X::messages_text_append "\ncd \"$work_dir\"\n$sdcc_cmd -mmcs51 --iram-size $iram --xram-size $xram --code-size $code $sdcc_opts \"$input_file\""
- } {
- ::X::messages_text_append "\ncd \"$work_dir\"\n$sdcc_cmd -mmcs51 --iram-size $iram --xram-size $xram --code-size $code --nooverlay --noinduction --verbose --debug -V --std-sdcc89 --model-small --pack-iram \"$input_file\""
+ # Start GNU make
+ if {$makeutil_config(c_ena) && ${::PROGRAM_AVAILABLE(make)}} {
+ ::X::messages_text_append [::Compiler::msgc {S}][mc "\n\nStarting make ..."]
+ ::X::messages_text_append "\ncd \"${work_dir}\"\nmake -f \"${makeutil_config(c_file)}\" ${makeutil_config(co_file)} ${makeutil_config(ct_file)}"
+
+ # Start SDCC
+ } else {
+ ::X::messages_text_append [::Compiler::msgc {S}][mc "\n\nStarting compiler ..."]
+ ::X::messages_text_append "\ncd \"${work_dir}\"\n${sdcc_cmd} -mmcs51 --iram-size ${iram} --xram-size ${xram} --code-size ${code} ${sdcc_opts} \"${input_file}\""
+ }
+ # Microsoft Windows way
+ } else {
+ regsub -all {/} $work_dir "\\\\\\\\" work_dir
+ regsub -all {/} $input_file "\\\\\\\\" input_file
+
+ ::X::messages_text_append [::Compiler::msgc {S}][mc "\n\nStarting compiler ..."]
+ ::X::messages_text_append "\ncd \"${work_dir}\"\n${sdcc_cmd} -mmcs51 --iram-size ${iram} --xram-size ${xram} --code-size ${code} ${sdcc_opts} \"${input_file}\""
}
if {[catch {
cd $work_dir
- }]} {
+ }]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "\nError: Unable to change working directory to '%s'" $work_dir]
}
if {!$::MICROSOFT_WINDOWS} { ;# Normal way (POSIX)
- return [exec -- /bin/sh -c "$sdcc_cmd -mmcs51 \
- --iram-size $iram \
- --xram-size $xram \
- --code-size $code \
- $sdcc_opts \"$input_file\"" |& \
- tclsh "${::LIB_DIRNAME}/external_command.tcl" \
- [tk appname] \
- {::ExternalCompiler::ext_compilation_complete 1}\
- ::X::compilation_message & \
- ]
- } { ;# Microsoft Windows way
+ # Start GNU make
+ if {$makeutil_config(c_ena) && ${::PROGRAM_AVAILABLE(make)}} {
+ return [exec -- /bin/sh -c "make -f \"${makeutil_config(c_file)}\" ${makeutil_config(co_file)} ${makeutil_config(ct_file)}" |& \
+ tclsh "${::LIB_DIRNAME}/external_command.tcl" \
+ [tk appname] \
+ {::ExternalCompiler::ext_compilation_complete 1} \
+ ::X::compilation_message & \
+ ]
+
+ # Start SDCC
+ } else {
+ return [exec -- /bin/sh -c "$sdcc_cmd -mmcs51 \
+ --iram-size $iram \
+ --xram-size $xram \
+ --code-size $code \
+ $sdcc_opts \"$input_file\"" |& \
+ tclsh "${::LIB_DIRNAME}/external_command.tcl" \
+ [tk appname] \
+ {::ExternalCompiler::ext_compilation_complete 1}\
+ ::X::compilation_message & \
+ ]
+ }
+ } else { ;# Microsoft Windows way
eval [subst -nocommands {
- return [exec -- "${::LIB_DIRNAME}/sdcc.bat" \
- "${::LIB_DIRNAME}" \
- $iram \
- $xram \
- $code \
- "$input_file" \
+ return [exec -- "${::INSTALLATION_DIR}/startsdcc.bat" \
+ "${work_dir}" \
+ $sdcc_opts \
+ "${input_file}" \
|& \
- "${::LIB_DIRNAME}/external_command.bat" \
- "${::LIB_DIRNAME}/external_command.tcl" \
- [tk appname] \
+ "${::INSTALLATION_DIR}/external_command.bat" \
+ "${::INSTALLATION_DIR}/external_command.exe" \
+ "[tk appname]" \
{::ExternalCompiler::ext_compilation_complete 1} \
::X::compilation_message & \
]
@@ -292,7 +333,7 @@ namespace eval ExternalCompiler {
::X::messages_text_append "\ncd \"$work_dir\"\nas31 $as31_options \"$input_file\""
if {[catch {
cd $work_dir
- }]} {
+ }]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "\nError: Unable to change working directory to '%s'" $work_dir]
}
backup_and_remove {adf hex lst}
@@ -322,20 +363,47 @@ namespace eval ExternalCompiler {
set input_filename [file rootname $input_file_base]
set working_dir $work_dir
- set asem51_options [determinate_asem51_options]
::X::messages_text_append [::Compiler::msgc {S}][mc "\n\nStarting compiler ..."]
- ::X::messages_text_append "\ncd \"$work_dir\"\nasem $asem51_options \"$input_file\""
+
+ set asem51_options [determinate_asem51_options]
+ if {$::MICROSOFT_WINDOWS} {
+ regsub -all -- {--verbose} $asem51_options {} asem51_options
+ regsub -all -- {--} $asem51_options {/} asem51_options
+ regsub -all -- {=} $asem51_options {:} asem51_options
+ regsub -all -- {;} $asem51_options { /includes:} asem51_options
+ regsub -all {/} $work_dir "\\\\\\\\" work_dir
+ regsub -all {/} $input_file "\\\\\\\\" input_file
+ ::X::messages_text_append "\ncd \"$work_dir\"\nasem \"$input_file\" $asem51_options"
+ } else {
+ ::X::messages_text_append "\ncd \"$work_dir\"\nasem $asem51_options \"$input_file\""
+ }
if {[catch {
cd $work_dir
- }]} {
+ }]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "\nError: Unable to change working directory to '%s'" $work_dir]
}
backup_and_remove {adf hex lst omf}
- return [exec -- /bin/sh -c "asem $asem51_options \"$input_file\"" |& \
- tclsh "${::LIB_DIRNAME}/external_command.tcl" "[tk appname]" \
- ::ExternalCompiler::ext_compilation_complete ::X::compilation_message & \
- ]
+ if {!$::MICROSOFT_WINDOWS} { ;# Normal way (POSIX)
+ return [exec -- /bin/sh -c "asem $asem51_options \"$input_file\"" |& \
+ tclsh "${::LIB_DIRNAME}/external_command.tcl" "[tk appname]" \
+ ::ExternalCompiler::ext_compilation_complete ::X::compilation_message & \
+ ]
+ } else { ;# Microsoft Windows way
+ eval [subst -nocommands {
+ return [exec -- "${::INSTALLATION_DIR}/startasem.bat" \
+ "${work_dir}" \
+ "${input_file}" \
+ $asem51_options \
+ |& \
+ "${::INSTALLATION_DIR}/external_command.bat" \
+ "${::INSTALLATION_DIR}/external_command.exe" \
+ "[tk appname]" \
+ {::ExternalCompiler::ext_compilation_complete 1} \
+ ::X::compilation_message & \
+ ]
+ }]
+ }
}
## Start ASL (Assembler)
@@ -364,7 +432,7 @@ namespace eval ExternalCompiler {
::X::messages_text_append "\ncd \"$work_dir\"\nasl $asl_opts \"$input_file\""
if {[catch {
cd $work_dir
- }]} {
+ }]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "\nError: Unable to change working directory to '%s'" $work_dir]
}
return [exec -- /bin/sh -c "asl $asl_opts \"$input_file\" $additional_commands" |& \
@@ -383,18 +451,20 @@ namespace eval ExternalCompiler {
# List of files included files in the main file
set included_files [list]
+ set cbd_file {} ;# We will set this variable later ...
+
# Open C DeBug file generated by SDCC compiler
if {[catch {
set cdb_file [open $input_filename.cdb r]
- }]} {
+ }]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "\nUnable to find \"%s\"" [file rootname $input_filename].cdb]
return
}
# Open the hashes file for writing (possibly create the file)
if {[catch {
- set hs_file [open $input_filename.hashes w 420]
- }]} {
+ set hs_file [open $input_filename.hashes w 0640]
+ }]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "\nUnable to create \"%s\"" [file rootname $input_filename].hashes]
catch {close $cbd_file}
return
@@ -429,11 +499,11 @@ namespace eval ExternalCompiler {
}
## This function must be called after exteral compiler finished its work
- # @parm Int action = 0 - Action to perform after successfull compilation
+ # @parm Int action=0 - Action to perform after successfull compilation
# 0 - No action
# 1 - Copy <file>.ihx to <file>.hex
# @return void
- proc ext_compilation_complete args {
+ proc ext_compilation_complete {{action 0}} {
variable input_filename ;# String: Name of file to compile (without extension)
variable compiler_used ;# Int: Compiler ID (1 == ASEM-51; 2 == ASL; 3 == AS31, other values have no meaning)
variable assembler_ASEM51_addcfg;# Current ASEM-51 assembler configuration
@@ -464,10 +534,13 @@ namespace eval ExternalCompiler {
create_hashes_file
}
}
- ::X::messages_text_append [::Compiler::msgc {S}][mc "\nCompilation successful"]
+
+ if {$::X::compilation_successfull} {
+ ::X::messages_text_append [::Compiler::msgc {S}][mc "\nCompilation successful"]
+ }
# Perform specified after successfull compilation
- switch -- [lindex $args 0] {
+ switch -- $action {
0 { ;# No action
}
1 { ;# Copy <file>.ihx to <file>.hex
@@ -479,9 +552,10 @@ namespace eval ExternalCompiler {
}
}
}
+ }
# Compilation failed
- } {
+ if {!$::X::compilation_successfull} {
::X::messages_text_append [::Compiler::msgc {E}][mc "\nCompilation FAILED"]
}
::X::ext_compilation_complete
@@ -505,8 +579,8 @@ namespace eval ExternalCompiler {
# Try to open code listing file and some tempotary debug file
if {[catch {
set lst_file [open $input_filename.lst r]
- set adf_file [open $input_filename.adf w 420]
- } result]} {
+ set adf_file [open $input_filename.adf w 0640]
+ } result]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "File access error:\n%s" $result]
return 0
}
@@ -514,7 +588,6 @@ namespace eval ExternalCompiler {
# Write file header
puts $adf_file "# Assembler Debug File created by ${::APPNAME}"
puts $adf_file "# Used assembler: AS31"
- puts $adf_file "# Date: [clock format [clock seconds] -format {%D}]"
# Write MD5 of the source file
puts -nonewline $adf_file [::md5::md5 -hex -file $input_file_base]
@@ -550,8 +623,8 @@ namespace eval ExternalCompiler {
scan $h %x h
lappend adf_code $h
}
- }]} {
- ::X::messages_text_append [::Compiler::msgc {E}][mc "Unable to understand formulation at line %s in file %s" $line_number $input_filename.lst]
+ }]} then {
+ ::X::messages_text_append [::Compiler::msgc {E}][mc "Unable to understand formulation at %s in file %s" $line_number $input_filename.lst]
close $lst_file
close $adf_file
return 0
@@ -561,11 +634,11 @@ namespace eval ExternalCompiler {
if {$address == {}} {
puts -nonewline $adf_file { }
puts -nonewline $adf_file $adf_code
- } {
+ } else {
if {[catch {
scan $address %x address
- }]} {
- ::X::messages_text_append [::Compiler::msgc {E}][mc "Unable to understand formulation at line %s in file %s" $line_number $input_filename.lst]
+ }]} then {
+ ::X::messages_text_append [::Compiler::msgc {E}][mc "Unable to understand formulation at %s in file %s" $line_number $input_filename.lst]
close $lst_file
close $adf_file
return 0
@@ -603,8 +676,8 @@ namespace eval ExternalCompiler {
# Try to open code listing file and some tempotary debug file
if {[catch {
set lst_file [open $input_filename.lst r]
- set adf_file [open $input_filename._adf w 420]
- } result]} {
+ set adf_file [open $input_filename._adf w 0640]
+ } result]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "File access error:\n%s" $result]
return 0
}
@@ -619,7 +692,7 @@ namespace eval ExternalCompiler {
# Read 1 line
set line [gets $lst_file]
- # Normal line coresponding to certain line in source code
+ # Normal line corresponding to certain line in source code
if {[regexp {^ *\d+:(..)?} $line inclusion_level]} {
# Extract numbers after "line_num: inc_lvl "
set line [string range $line [string length $inclusion_level] end]
@@ -701,22 +774,21 @@ namespace eval ExternalCompiler {
# Open final debug file
if {[catch {
- set adf_file [open $input_filename.adf w 420]
- } result]} {
+ set adf_file [open $input_filename.adf w 0640]
+ } result]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "File access error:\n%s" $result]
return 0
}
# Write file header
puts $adf_file "# Assembler Debug File created by ${::APPNAME}"
puts $adf_file "# Used assembler: ASEM-51"
- puts $adf_file "# Date: [clock format [clock seconds] -format {%D}]"
# Create list of included files with MD5 hashes
set hashes_and_files {}
set project_dir_len [string length $project_dir]
foreach filename $included_files {
if {[catch {
lappend hashes_and_files [::md5::md5 -hex -file $filename]
- } result]} {
+ } result]} then {
lappend hashes_and_files 0
::X::messages_text_append [::Compiler::msgc {E}][mc "File access error:\n%s" $result]
}
@@ -730,7 +802,7 @@ namespace eval ExternalCompiler {
# Copy content of tempotary debug file to final debug file
if {[catch {
set adf__file [open $input_filename._adf r]
- } result]} {
+ } result]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "File access error:\n%s" $result]
return 0
}
@@ -756,8 +828,8 @@ namespace eval ExternalCompiler {
if {[catch {
set map_file [open $input_filename.map r] ;# ASL debug file
set hex_file [open $input_filename.hex r] ;# Machine code
- set adf_file [open $input_filename.adf w 420] ;# MCU 8051 IDE debug file
- } result]} {
+ set adf_file [open $input_filename.adf w 0640] ;# MCU 8051 IDE debug file
+ } result]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "File access error:\n%s" $result]
return 0
}
@@ -812,7 +884,7 @@ namespace eval ExternalCompiler {
set filename [file join $project_dir [file normalize $filename]]
if {[catch {
lappend hashes_and_files [::md5::md5 -hex -file $filename]
- } result]} {
+ } result]} then {
::X::messages_text_append [::Compiler::msgc {E}][mc "\nFile access error:\n%s" $result]
lappend hashes_and_files {0}
}
@@ -829,7 +901,6 @@ namespace eval ExternalCompiler {
seek $map_file 0
puts $adf_file "# Assembler Debug File created by ${::APPNAME}"
puts $adf_file "# Used assembler: ASL"
- puts $adf_file "# Date: [clock format [clock seconds] -format {%D}]"
puts $adf_file $hashes_and_files
unset hashes_and_files
@@ -914,7 +985,7 @@ namespace eval ExternalCompiler {
set val [::IHexTools::get_value $i]
if {$val > -1} {
lappend code [expr "0x$val"]
- } {
+ } else {
lappend code 0
}
}
@@ -956,7 +1027,7 @@ namespace eval ExternalCompiler {
if {$value != {}} {
if {[regexp {\s} $value]} {
append result { } $key { } "\"" $value "\""
- } {
+ } else {
append result { } $key { } $value
}
}
@@ -969,7 +1040,7 @@ namespace eval ExternalCompiler {
if {$value != {}} {
if {[regexp {\s} $value]} {
append result { } $key { } "\"" $value "\""
- } {
+ } else {
append result { } $key { } $value
}
}
@@ -986,7 +1057,7 @@ namespace eval ExternalCompiler {
set result $assembler_ASEM51_config(custom)
if {$assembler_ASEM51_config(-i) != {}} {
- append result { -i } {"} $assembler_ASEM51_config(i) {"}
+ append result " --includes=$assembler_ASEM51_config(-i)"
}
foreach opt {--omf-51 --columns --verbose} {
if {$assembler_ASEM51_config($opt)} {
@@ -1069,8 +1140,17 @@ namespace eval ExternalCompiler {
$::ExternalCompiler::sdcc_optional_string_options_def
array set ::ExternalCompiler::sdcc_scs_string_options \
$::ExternalCompiler::sdcc_scs_string_options_def
+
+ # Make utility
+ foreach {key value} ${::ExternalCompiler::makeutil_config_def} {
+ set ::ExternalCompiler::makeutil_config($key) $value
+ }
}
}
# Initialize NS variables
ExternalCompiler::initialize
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/compiler/preprocessor.tcl b/lib/compiler/preprocessor.tcl
index 4fca542..d4429ea 100755..100644
--- a/lib/compiler/preprocessor.tcl
+++ b/lib/compiler/preprocessor.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 _PREPROCESSOR_TCL ] } {
+set _PREPROCESSOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# 8051 Assembly language compiler preprocessor. This code is part of Compiler
@@ -34,11 +39,11 @@
#
# Basic principle of operation:
# 1) Remove comments and include files
-# 2) Process controll sequences ($SOMETHING)
+# 2) Process control sequences ($SOMETHING)
# 3) Define as much constants/variables as possible (with cross references)
# 4) Conditional compilation and directive USING
# 5) Define macro instructions
-# 6) Recomposite code acording to ORG directives
+# 6) Recomposite code according to ORG directives
# 7) Expand macro instructions (recursive with cross references)
# 8) Final stage
#
@@ -52,29 +57,30 @@
namespace eval PreProcessor {
## General
- variable asm {} ;# Resulting precompiled code
- variable tmp_asm {} ;# Tempotary auxiliary precompiled code
+ variable asm {} ;# Resulting pre-compiled code
+ variable tmp_asm {} ;# Temporary auxiliary pre-compiled code
variable lineNum 0 ;# Number of the current line
variable fileNum 0 ;# Number of the current file
variable program_memory ;# String of booleans: Map of program memory usage
variable idx 0 ;# Current position in asm list
- variable optims 0 ;# Number of performed optimalizations
+ variable optims 0 ;# Number of performed optimizations
variable macros_first 1 ;# Bool: Define and expand macro instruction before conditional
;#+ assembly and constants expansions
## Errors and warnings
- variable ErrorAtLine 0 ;# Bool: Error occured on the current line
- variable Error 0 ;# Bool: An error occured during precompilation
- variable error_count 0 ;# Number of errors occured
- variable warning_count 0 ;# Number of warnings occured
+ variable ErrorAtLine 0 ;# Bool: Error occurred on the current line
+ variable Error 0 ;# Bool: An error occurred during precompilation
+ variable error_count 0 ;# Number of errors occurred
+ variable warning_count 0 ;# Number of warnings occurred
## Conditional compilation
variable Enable 1 ;# Bool: Compilation enabled (conditional compilation)
variable IfElse_map ;# Array: Conditional compilation map ($IfElse_map($level) == $bool)
+ variable IfElse_pcam ;# Array: Conditional compilation -- Positive condition already met ($IfElse_pcam($level) == $bool)
variable IfElse_level 0 ;# Current level of conditional compilation evaluation
## Memory reservation
- variable selected_segment cseg ;# Current memory segment (one of {cseg bseg dseg iseg xseg})
+ variable selected_segment ;# Current memory segment (one of {cseg bseg dseg iseg xseg})
variable memory_reservation_map ;# Array: memory reservation map (see code)
variable segment_pointer ;# Current memory segment pointer
@@ -112,12 +118,13 @@ namespace eval PreProcessor {
## Macro expansion
variable macro ;# Array: Code of defined macro instructions
variable defined_MACRO {} ;# List of defined macro instructions
+ variable local_M_labels ;# Array of lists: Local labels in macros $local_M_labels($macro_name) == {integer label0 ... labelN}
variable macro_name_to_append ;# Name of currently defined macro instruction
## Special variables
variable original_expression ;# Auxiliary variable (see proc. 'ComputeExpr')
variable tmp ;# General purpose tempotary variable
- variable DB_asm {} ;# Tempotary asm code for creating code memory tables
+ variable DB_asm {} ;# Temporary asm code for creating code memory tables
variable included_files {} ;# List: Unique unsorted list of included files
variable working_dir {} ;# String: Current working directory
variable origin_d_addr {} ;# List: Addresses of static program blocks
@@ -126,7 +133,7 @@ namespace eval PreProcessor {
variable max_include_level 8 ;# Maximum inclusion level
variable max_macro_level 8 ;# Maximum macro expansion level
variable check_sfr_usage 0 ;# Bool: Check for legal usage of SFR and SFB
- variable avaliable_SFR {} ;# List: Avaliable SFR and SFB on the target MCU
+ variable available_SFR {} ;# List: Available SFR and SFB on the target MCU
# ----------------------------------------------------------------
@@ -143,13 +150,13 @@ namespace eval PreProcessor {
;#+ assembly and constants expansions
variable memory_reservation_map ;# Array: memory reservation map (see code)
variable working_dir ;# String: Current working directory
- variable asm ;# Resulting precompiled code
+ variable asm ;# Resulting pre-compiled code
variable segment_pointer ;# Current memory segment pointer
- variable error_count ;# Number of errors occured
- variable warning_count ;# Number of warnings occured
+ variable error_count ;# Number of errors occurred
+ variable warning_count ;# Number of warnings occurred
variable max_include_level ;# Maximum inclusion level
variable max_macro_level ;# Maximum macro expansion level
- variable optims ;# Number of performed optimalizations
+ variable optims ;# Number of performed optimizations
variable included_files ;# List: Unique unsorted list of included files
variable selected_segment ;# Current memory segment (one of {cseg bseg dseg iseg xseg})
variable const_EQU ;# Array: Constants defined by directive 'EQU'
@@ -169,11 +176,11 @@ namespace eval PreProcessor {
set memory_reservation_map(xseg) [ string repeat 0 65536]
# Set constants "??MCU_8051_IDE" and "??VERSION"
- lappend defined_EQU {??MCU_8051_IDE} {??VERSION}
- set const_EQU(??MCU_8051_IDE) 32849
+ lappend defined_EQU {??mcu_8051_ide} {??version}
+ set const_EQU(??mcu_8051_ide) 32849 ;# 8051h
scan $::VERSION "%d.%d.%d" i j k
set i [expr {($i << 8) + ($j << 4) + $k}]
- set const_EQU(??VERSION) $i
+ set const_EQU(??version) $i
# Reset counters of errors and warnings
set error_count 0
@@ -183,11 +190,7 @@ namespace eval PreProcessor {
set working_dir $current_dir
set included_files [list [file normalize [file join $current_dir $filename]]]
- # Message "formating code ..."
set asm $data
- if {!${::Compiler::Settings::QUIET}} {
- ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\tPreformating code ..."]
- }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -201,10 +204,6 @@ namespace eval PreProcessor {
# }
line_numbers
- # Message "include ..."
- if {!${::Compiler::Settings::QUIET}} {
- ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\tPutting program pieces together ..."]
- }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -213,7 +212,7 @@ namespace eval PreProcessor {
# Import code pieces (INCLUDE file.asm // $INCLUDE('file.inc'))
set counter 0
- while 1 {
+ while {1} {
if {![include_directive $current_dir]} {break}
incr counter
if {$counter > $max_include_level} {
@@ -225,10 +224,6 @@ namespace eval PreProcessor {
# Remove code after END directive
end_of_code
- # Message "encapsulating code ..."
- if {!${::Compiler::Settings::QUIET}} {
- ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\tEncapsulating code ..."]
- }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -261,11 +256,6 @@ namespace eval PreProcessor {
define_basic_symbolic_names
}
- # Message "Parsing constants, macros etc."
- if {!${::Compiler::Settings::QUIET}} {
- ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\tParsing constants, macros, etc. ..."]
- }
-
if {$macros_first} {
# Define macro instructions
define_macro_instructions
@@ -277,7 +267,7 @@ namespace eval PreProcessor {
# Expand macro instructions
set counter 0
- while 1 {
+ while {1} {
if {![expand_macro_instructions]} {break}
incr counter
if {$counter > $max_macro_level} {
@@ -299,21 +289,20 @@ namespace eval PreProcessor {
# - Data memory segment selection (BSEG, DSEG, ISEG, XSEG) (group 3)
# - Constant definitions (SET, EQU, BIT, DATA, IDATA, XDATA) (group 4)
# - Date memory reservation (DS, DBIT) (group 5)
- while 1 {
+ while {1} {
if {![parse_Consts_and_ConditionalCompilation {0 0 1 1 1 1} 1]} {
break
}
}
- parse_Consts_and_ConditionalCompilation {1 1 1 1 1 1} 1
- set selected_segment cseg
+ parse_Consts_and_ConditionalCompilation {1 1 1 1 1 1} 1
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
return
}
- # Parse code memory segmentation (CSEG DB DW)
+ # Process code memory related directives (CSEG DB DW)
code_segment 1
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
@@ -331,7 +320,7 @@ namespace eval PreProcessor {
}
}
- # Reassemble code acording to ORG directives
+ # Reassemble code according to ORG directives
origin_directive
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
@@ -339,15 +328,10 @@ namespace eval PreProcessor {
return
}
- # Message "Expanding macros"
- if {!${::Compiler::Settings::QUIET}} {
- ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\tExpanding macros ..."]
- }
-
if {!$macros_first} {
# Expand macro instructions
set counter 0
- while 1 {
+ while {1} {
if {![expand_macro_instructions]} {break}
incr counter
if {$counter > $max_macro_level} {
@@ -362,11 +346,6 @@ namespace eval PreProcessor {
}
}
- # Message "Final stage"
- if {!${::Compiler::Settings::QUIET}} {
- ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\tFinal stage ..."]
- }
-
## Do three things:
# * Convert code to this format:
# {
@@ -379,18 +358,14 @@ namespace eval PreProcessor {
# * Create map of program memory usage (bitmap)
parse_instructions
- # Perform code optimalizations
+ # Perform code optimizations
set optims 0
if {${::Compiler::Settings::optim_ena}} {
- # Message "Optimalizations"
- if {!${::Compiler::Settings::QUIET}} {
- ${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "\tOptimalizations ..."]
- }
- optimalization
+ optimization
}
# Final constants expansion
- while 1 {
+ while {1} {
if {![parse_Consts_and_ConditionalCompilation {0 0 1 1 1 1} 0]} {
break
}
@@ -434,6 +409,7 @@ namespace eval PreProcessor {
variable const_SET ;# Array: Constants defined by directive 'CODE'
variable const_EQU ;# Array: Constants defined by directive 'EQU'
variable macro ;# Array: Code of defined macro instructions
+ variable local_M_labels ;# Array of lists: Local labels in macros $local_M_labels($macro_name) == {integer label0 ... labelN}
variable program_memory ;# String of booleans: Map of program memory usage
variable labels ;# Array: Values of defined labels ($labels($label) == $address)
variable defined_BIT {} ;# List of defined bits (directove 'BIT')
@@ -449,6 +425,7 @@ namespace eval PreProcessor {
variable defined_MACRO {} ;# List of defined macro instructions
catch {unset macro}
+ catch {unset local_M_labels}
catch {unset memory_reservation_map}
catch {unset segment_pointer}
catch {unset const_BIT}
@@ -469,7 +446,7 @@ namespace eval PreProcessor {
# INTERNAL AUXILIARY PROCEDURES
# ----------------------------------------------------------------
- ## Define basic symbolic names acording to MapOfSFRArea, MapOfSFRBitArea and progVectors
+ ## Define basic symbolic names according to MapOfSFRArea, MapOfSFRBitArea and progVectors
# @return void
proc define_basic_symbolic_names {} {
variable const_BIT ;# Array: Bit values -- ($const_BIT($bit_name) == $value)
@@ -480,7 +457,7 @@ namespace eval PreProcessor {
variable defined_CODE ;# List of constants defined by 'CODE'
# Define bits
- foreach def ${CompilerConsts::MapOfSFRBitArea} {
+ foreach def ${::CompilerConsts::MapOfSFRBitArea} {
set var [lindex $def 0] ;# Name
set val [lindex $def 1] ;# Address
# Adjust name
@@ -491,7 +468,7 @@ namespace eval PreProcessor {
}
# Define registers
- foreach def ${CompilerConsts::MapOfSFRArea} {
+ foreach def ${::CompilerConsts::MapOfSFRArea} {
set var [lindex $def 0] ;# Name
set val [lindex $def 1] ;# Address
# Adjust name
@@ -502,7 +479,7 @@ namespace eval PreProcessor {
}
# Define Program vectors
- foreach def ${CompilerConsts::progVectors} {
+ foreach def ${::CompilerConsts::progVectors} {
set var [lindex $def 0] ;# Name
set val [lindex $def 1] ;# Address
# Adjust name
@@ -528,7 +505,7 @@ namespace eval PreProcessor {
if {[regexp {^\w+} $data control]} {
regsub {^\w+} $data {} data
set control [string tolower $control]
- } {
+ } else {
set control {}
}
@@ -548,12 +525,12 @@ namespace eval PreProcessor {
if {[string index $argument 0] == {'}} {
if {[string index $argument end] != {'}} {
SyntaxError $lineNum $fileNum [mc "Invalid argument: %s" $argument]
- } {
+ } else {
set argument [string trimleft $argument {'}]
set argument [string trimright $argument {'}]
}
}
- } {
+ } else {
set argument {}
}
@@ -572,20 +549,20 @@ namespace eval PreProcessor {
# @parm String setting - Target configuration variable
# @parm String value - New configuration value
# @return Bool - One if setting was accepted, zero if setting was dismissed
- proc AssemlerContol {condition setting value} {
+ proc AssemblerContol {condition setting value} {
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
# Determinate condition value
- set condition [subst "\${::Compiler::Settings::$condition}"]
+ set condition [subst -nocommands "\${::Compiler::Settings::$condition}"]
# Accept
if {$condition == 0} {
set Compiler::Settings::$setting $value
return 1
# Dismiss
- } {
- Notice $lineNum $fileNum [mc "Control %s has been overrriden (by compiler settings)" $setting]
+ } else {
+ Notice $lineNum $fileNum [mc "Control %s has been overridden (by compiler settings)" $setting]
return 0
}
}
@@ -594,7 +571,7 @@ namespace eval PreProcessor {
# @parm String control - Control sequence (name only)
# @parm String argument - Argument (without parantesis and quotes)
# @return Bool - result (1 == success; 0 == error message)
- proc AssemlerContol_expect_one_argument {control argument} {
+ proc AssemblerContol_expect_one_argument {control argument} {
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
@@ -610,7 +587,7 @@ namespace eval PreProcessor {
# @parm String control - Control sequence (name only)
# @parm String argument - Argument (without parantesis and quotes)
# @return Bool - result (1 == success; 0 == error message)
- proc AssemlerContol_expect_no_argument {control argument} {
+ proc AssemblerContol_expect_no_argument {control argument} {
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
@@ -624,8 +601,8 @@ namespace eval PreProcessor {
## Evaluate and remove control sequences
# @return void
proc parse_controls {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
@@ -642,7 +619,9 @@ namespace eval PreProcessor {
incr idx
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -669,178 +648,178 @@ namespace eval PreProcessor {
set control [lindex $ctrl 0] ;# Name
set argument [lindex $ctrl 1] ;# Argument
- # Adjust compiler settings acording to the control sequence
+ # Adjust compiler settings according to the control sequence
switch -- $control {
{nomacrosfirst} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
set macros_first 0
}
}
{eject} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
CodeListing::directive_eject $idx
}
}
{ej} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
CodeListing::directive_eject $idx
}
}
{nolist} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
CodeListing::directive_nolist $idx
}
}
{noli} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
CodeListing::directive_nolist $idx
}
}
{list} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
CodeListing::directive_list $idx
}
}
{li} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
CodeListing::directive_list $idx
}
}
{nomod} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _nomod NOMOD 1
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _nomod NOMOD 1
}
}
{nomod51} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _nomod NOMOD 1
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _nomod NOMOD 1
}
}
{nomo} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _nomod NOMOD 1
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _nomod NOMOD 1
}
}
{paging} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _paging PAGING 1
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _paging PAGING 1
}
}
{pi} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _paging PAGING 1
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _paging PAGING 1
}
}
{nopaging} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _paging PAGING 0
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _paging PAGING 0
}
}
{nopi} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _paging PAGING 0
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _paging PAGING 0
}
}
{pagewidth} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
if {[regexp {^\d+$} $argument]} {
- AssemlerContol _pagewidth PAGEWIDTH $argument
- } {
+ AssemblerContol _pagewidth PAGEWIDTH $argument
+ } else {
SyntaxError $lineNum $fileNum \
[mc "Invalid argument (must be integer): %s" $argument]
}
}
}
{pw} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
if {[regexp {^\d+$} $argument]} {
- AssemlerContol _pagewidth PAGEWIDTH $argument
- } {
+ AssemblerContol _pagewidth PAGEWIDTH $argument
+ } else {
SyntaxError $lineNum $fileNum \
[mc "Invalid argument (must be integer): %s" $argument]
}
}
}
{pagelength} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
if {[regexp {^\d+$} $argument]} {
- AssemlerContol _pagelength PAGELENGTH $argument
- } {
+ AssemblerContol _pagelength PAGELENGTH $argument
+ } else {
SyntaxError $lineNum $fileNum \
[mc "Invalid argument (must be integer): %s" $argument]
}
}
}
{pl} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
if {[regexp {^\d+$} $argument]} {
- AssemlerContol _pagelength PAGELENGTH $argument
- } {
+ AssemblerContol _pagelength PAGELENGTH $argument
+ } else {
SyntaxError $lineNum $fileNum \
[mc "Invalid argument (must be integer): %s" $argument]
}
}
}
{title} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
- AssemlerContol _title TITLE $argument
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
+ AssemblerContol _title TITLE $argument
}
}
{tt} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
- AssemlerContol _title TITLE $argument
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
+ AssemblerContol _title TITLE $argument
}
}
{date} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
- AssemlerContol _date DATE $argument
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
+ AssemblerContol _date DATE $argument
}
}
{da} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
- AssemlerContol _date DATE $argument
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
+ AssemblerContol _date DATE $argument
}
}
{object} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
- AssemlerContol _object OBJECT_FILE $argument
- AssemlerContol _object OBJECT 1
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
+ AssemblerContol _object OBJECT_FILE $argument
+ AssemblerContol _object OBJECT 1
}
}
{noobject} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _object OBJECT 0
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _object OBJECT 0
}
}
{nosb} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _symbols SYMBOLS 0
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _symbols SYMBOLS 0
}
}
{nosymbols} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _symbols SYMBOLS 0
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _symbols SYMBOLS 0
}
}
{noprint} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _print PRINT 0
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _print PRINT 0
}
}
{symbols} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _symbols SYMBOLS 1
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _symbols SYMBOLS 1
}
}
{sb} {
- if {[AssemlerContol_expect_no_argument $control $argument]} {
- AssemlerContol _symbols SYMBOLS 1
+ if {[AssemblerContol_expect_no_argument $control $argument]} {
+ AssemblerContol _symbols SYMBOLS 1
}
}
{print} {
- if {[AssemlerContol_expect_one_argument $control $argument]} {
- AssemlerContol _print PRINT_FILE $argument
- AssemlerContol _print PRINT 1
+ if {[AssemblerContol_expect_one_argument $control $argument]} {
+ AssemblerContol _print PRINT_FILE $argument
+ AssemblerContol _print PRINT 1
}
}
default {
@@ -858,20 +837,19 @@ namespace eval PreProcessor {
# @parm Bool ignore_undefined - Ignore undefined symbolic names
# @return void
proc code_segment {ignore_undefined} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable selected_segment ;# Current memory segment (one of {cseg bseg dseg iseg xseg})
variable segment_pointer ;# Current memory segment pointer
- variable DB_asm ;# Tempotary asm code for creating code memory tables
variable idx ;# Current position in asm list
# Reset NS variables
- set DB_asm {}
- set value {}
set tmp_asm {}
set segment_pointer(cseg) {}
+
+ set value {}
set idx -1
# Iterate over the code
@@ -879,7 +857,9 @@ namespace eval PreProcessor {
incr idx
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -909,32 +889,41 @@ namespace eval PreProcessor {
# Directive 'CSEG' - code segment selection
} elseif {$directive == {cseg}} {
+ set discontinue 0
- # Check if there is no label
+ # Check if there is a label
if {[lindex $cmd 0] != {}} {
SyntaxError $lineNum $fileNum [mc "CSEG cannot take any label: %s" [lindex $cmd 0]]
- continue
+ set discontinue 1
}
- # Select code segment
- set selected_segment {cseg}
+ if {!$discontinue} {
+ # Set the code segment
+ set selected_segment {cseg}
- # Remove this line from the code listing
- CodeListing::delete_line $idx
+ # Check for presence of an address expression
+ set expr [lindex $cmd 2]
+ if {$expr == {}} {
+ set segment_pointer(cseg) {}
+ set discontinue 1
+ }
- # Check for presence of address expression
- set expr [lindex $cmd 2]
- if {$expr == {}} {
- set segment_pointer(cseg) {}
- continue
+ if {!$discontinue} {
+ # Check for presence of 'AT' operator (CSEG AT addr)
+ if {[string tolower [lindex $expr 0]] != {at}} {
+ SyntaxError $lineNum $fileNum [mc "Missing `AT' operator"]
+ set discontinue 1
+ }
+ set expr [lreplace $expr 0 0]
+ }
}
- # Check for presence of 'AT' operator (CSEG AT addr)
- if {[string tolower [lindex $expr 0]] != {at}} {
- SyntaxError $lineNum $fileNum [mc "Missing `AT' operator"]
+ # Remove this line from the code listing
+ if {$discontinue} {
+ CodeListing::delete_line $idx
+ incr idx -1
continue
}
- set expr [lreplace $expr 0 0]
# Determinate, set and validate segment pointer
set value [ComputeExpr $expr]
@@ -947,9 +936,11 @@ namespace eval PreProcessor {
# Set pointer
set segment_pointer(cseg) $value
# Adjust code
- lappend DB_asm [list $lineNum [list {ORG} $value]]
- } {
+ lappend tmp_asm [list $lineNum $fileNum [list {ORG} $value]]
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" $expr]
+ CodeListing::delete_line $idx
+ incr idx -1
}
# Line does not contain any of {CSEG DB DW}
@@ -960,13 +951,12 @@ namespace eval PreProcessor {
# Finalize code adjustment
append tmp_asm { }
- append tmp_asm $DB_asm
set asm $tmp_asm
}
## Reserve code memory (byte or word) -- directives 'DB' 'DW'
# -- auxiliary procedure for proc. 'code_segment'
- # This procedure writes result to NS variable 'DB_asm' or 'tmp_asm'
+ # This procedure writes result to NS variable 'tmp_asm'
# @parm String cmd - Line of source code adjusted by proc. 'split_line'
# @parm String directive - Directive name (one of {DB DW})
# @parm String idx - Source index (precompiled code list)
@@ -977,8 +967,7 @@ namespace eval PreProcessor {
variable fileNum ;# Number of the current file
variable selected_segment ;# Current memory segment (one of {cseg bseg dseg iseg xseg})
variable segment_pointer ;# Current memory segment pointer
- variable DB_asm ;# Tempotary asm code for creating code memory tables
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
# Determinate maximum value
if {$directive == {db}} {
@@ -987,7 +976,7 @@ namespace eval PreProcessor {
} elseif {$directive == {dw}} {
set directive_db 0
set max 65535
- } {
+ } else {
CompilationError $lineNum $fileNum "Unknown error 7"
return
}
@@ -1023,9 +1012,11 @@ namespace eval PreProcessor {
# Iterate over directive operands
set first_time 1
set undefined 0
+ set total_len 0
foreach opr $operands {
set undefined 0
set len -1
+
# Operand is a string
if {![isExpression $opr] && ([string index $opr 0] == {'}) && ([string index $opr end] == {'})} {
# Adjust operand
@@ -1052,33 +1043,27 @@ namespace eval PreProcessor {
continue
# Valid value
- } {
+ } else {
if {$first_time} {
set line [list [list $lineNum $fileNum "${label}DB $value"]]
- } {
+ } else {
set line [list [list $lineNum $fileNum [list DB $value]]]
}
set first_time 0
lappend values $value
}
- # Adjust precompiled code
- if {$segment_pointer(cseg) != {}} {
- append DB_asm { }
- append DB_asm $line
- } {
- append tmp_asm { }
- append tmp_asm $line
- }
incr len
+
+ # Adjust precompiled code
+ append tmp_asm { }
+ append tmp_asm $line
}
# Adjust code listing
CodeListing::db $idx $values
CodeListing::insert_empty_lines $idx $len
- incr idx $len
-
# Operand is a direct numerical value, expression, constant, label or variable
} else {
@@ -1093,7 +1078,7 @@ namespace eval PreProcessor {
set value $opr
# Invalid value
- } {
+ } else {
CompilationError $lineNum $fileNum [mc "Invalid expression `%s'" $opr]
continue
}
@@ -1116,20 +1101,23 @@ namespace eval PreProcessor {
if {$directive_db} {
if {$first_time} {
set line [list [list $lineNum $fileNum "${label}DB $value"]]
- } {
+ } else {
set line [list [list $lineNum $fileNum [list DB $value]]]
}
- CodeListing::db $idx $value
+
incr len
set first_time 0
+ # Adjust code listing
+ CodeListing::db $idx $value
+
# Two bytes (directive DW)
- } {
+ } else {
# Spilt value into high- and low-order bytes
if {$undefined} {
set H_value "(($value) / 256)"
set L_value "(($value) % 256)"
- } {
+ } else {
set H_value [expr {$value / 256}]
set L_value [expr {$value % 256}]
}
@@ -1138,35 +1126,34 @@ namespace eval PreProcessor {
[list $lineNum $fileNum "${label}DB {$H_value}"]\
[list $lineNum $fileNum [list {DB} $L_value]] \
]
- } {
+ } else {
set line [list \
[list $lineNum $fileNum [list {DB} $H_value]] \
[list $lineNum $fileNum [list {DB} $L_value]] \
]
}
+
+ incr len 2
set first_time 0
# Adjust code listing
CodeListing::db $idx [list $H_value $L_value]
CodeListing::insert_empty_lines $idx 1
-
- incr len 2
- incr idx $len
}
# Adjust precompiled code
- if {$segment_pointer(cseg) != {}} {
- append DB_asm { }
- append DB_asm $line
- } {
- append tmp_asm { }
- append tmp_asm $line
- }
+ append tmp_asm { }
+ append tmp_asm $line
}
+
+ incr len
+ incr total_len $len
}
CodeListing::insert_empty_lines $idx [expr {[llength $operands] - 1}]
- return $len
+
+ incr total_len -1
+ return $total_len
}
## Split the given line of code into label, command and argumet(s)
@@ -1176,7 +1163,7 @@ namespace eval PreProcessor {
# Determinate label
if {[regexp {^\w+:} $line label]} {
regsub {^\w+:\s*} $line {} line
- } {
+ } else {
set label {}
}
# If line contains only label -> return only label
@@ -1187,7 +1174,7 @@ namespace eval PreProcessor {
# Determinate command and argumet(s)
if {![regexp {^\s*\.?\w+} $line command]} {
set command {}
- } {
+ } else {
set command [string tolower [string trim $command]]
}
set argument [regsub {^[^\s]+\s*} $line {}]
@@ -1212,7 +1199,7 @@ namespace eval PreProcessor {
if {$instruction == {db}} {
set new_operands $operands
set operands {}
- } {
+ } else {
set new_operands {}
}
@@ -1221,6 +1208,7 @@ namespace eval PreProcessor {
# Fixed value (eg. 'A')
if {[isFixed $opr]} {
+ set char {}
set opr_val $opr
# Regular value
@@ -1229,14 +1217,14 @@ namespace eval PreProcessor {
set char [string index $opr 0]
if {$char == {#} || $char == {@} || $char == {/}} {
set opr [string replace $opr 0 0]
- } {
+ } else {
set char {}
}
- set opr_val $char
+ set opr_val {}
# Value is an expression
if {[isExpression $opr]} {
- append opr_val [ComputeExpr $opr {} $address]
+ append opr_val [ComputeExpr $opr $ignore_undefined $address]
# Value is bit addres represented by dot notation
} elseif {[regexp {^\w+\.\w+$} $opr]} {
@@ -1245,7 +1233,7 @@ namespace eval PreProcessor {
if {!$ignore_undefined} {
SyntaxError $lineNum $fileNum [mc "Expected bit address: %s" $opr]
}
- } {
+ } else {
set bitAddr [getBitAddr $opr $ignore_undefined]
if {$bitAddr == {}} {set bitAddr 0}
append opr_val $bitAddr
@@ -1282,33 +1270,44 @@ namespace eval PreProcessor {
}
# Adjust relative offset
- if {[string is digit -strict $opr_val] && $type == {code8}} {
- incr opr_val -$address
- incr opr_val -$instr_lenght
- if {($opr_val > 127) || ($opr_val < -128)} {
- incr opr_val -0x10000
+ if {[string is digit -strict $opr_val]} {
+ if {$type == {code8}} {
+ incr opr_val -$address
+ incr opr_val -$instr_lenght
if {($opr_val > 127) || ($opr_val < -128)} {
+ incr opr_val -0x10000
+ if {($opr_val > 127) || ($opr_val < -128)} {
+ if {!$ignore_undefined} {
+ SyntaxError $lineNum $fileNum \
+ [mc "Label is too far for 8-bit relative addressing.\nTry to disable peephole optimizations if they are on."]
+ }
+ set opr_val 0
+ }
+ }
+ if {$opr_val < 0} {
+ incr opr_val 0x100
+ }
+ } elseif {$type == {code11}} {
+ if {($opr_val & 0x0f800) != (($address + $instr_lenght) & 0x0f800)} {
if {!$ignore_undefined} {
- SyntaxError $lineNum $fileNum \
- [mc "Label is too far for 8-bit relative addressing.\nTry to disable peephole optimalizations if they are on."]
+ SyntaxError $lineNum $fileNum [mc "Operand value out of range: `%s' (`%s')" $opr $opr_val]
}
set opr_val 0
+ } else {
+ set opr_val [expr {$opr_val & 0x007ff}]
}
}
- if {$opr_val < 0} {
- incr opr_val 0x100
- }
}
}
# Adjust list of operands
- lappend new_operands $opr_val
+ lappend new_operands "${char}${opr_val}"
# Check for valid value range
if {$opr_val != {} && ![checkRange $opr_val $type]} {
if {!$ignore_undefined && [string is digit -strict $opr_val]} {
SyntaxError $lineNum $fileNum [mc "Operand value out of range: `%s' (`%s')" $opr $opr_val]
- } {
+ } else {
return {}
}
}
@@ -1321,8 +1320,8 @@ namespace eval PreProcessor {
## Finaly precompiled encapsulate code to the resulting form
# @return void
proc final_stage {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
@@ -1337,7 +1336,9 @@ namespace eval PreProcessor {
incr idx
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -1367,11 +1368,11 @@ namespace eval PreProcessor {
}
# Check for instruction validity
- } elseif {[lsearch -exact -ascii ${CompilerConsts::AllInstructions} $instruction] == -1} {
+ } elseif {[lsearch -exact -ascii ${::CompilerConsts::AllInstructions} $instruction] == -1} {
if {[string index $address end] == {:}} {
- SyntaxError $lineNum $fileNum [mc "Invalid label declaration: `%s'\n\tLabels can contain alfanumeric characters only and must not begin with a digit" $address]
- } {
- SyntaxError $lineNum $fileNum [mc "Unknown keyword: `%s'\n\t`%s' is neighter macro nor instruction nor directive" [lindex $address 0] [lindex $address 0]]
+ SyntaxError $lineNum $fileNum [mc "Invalid label declaration: `%s'\n\tLabels can contain alphanumeric characters only and must not begin with a digit" $address]
+ } else {
+ SyntaxError $lineNum $fileNum [mc "Unknown keyword: `%s'\n\t`%s' is neither macro nor instruction nor directive" [lindex $address 0] [lindex $address 0]]
}
continue
}
@@ -1416,7 +1417,7 @@ namespace eval PreProcessor {
$ignore_undefined \
]
# Register is regular number
- } {
+ } else {
set regAddr [COprToDec $opr0]
}
@@ -1427,7 +1428,7 @@ namespace eval PreProcessor {
$ignore_undefined \
]
# Bit is regular number
- } {
+ } else {
set bitNum [COprToDec $opr1]
}
@@ -1439,7 +1440,7 @@ namespace eval PreProcessor {
# Register is in high bit addressable area
if {$regAddr > 31 && $regAddr < 48} {
- return [expr {$regAddr - 32 + $bitNum}]
+ return [expr {($regAddr - 32) * 8 + $bitNum}]
# Register bit addressable SFR
} elseif {[lsearch -exact -ascii {128 136 144 152 160 168 176 184 208 224 240} $regAddr] != -1} {
return [expr {$regAddr + $bitNum}]
@@ -1458,7 +1459,7 @@ namespace eval PreProcessor {
variable fileNum ;# Number of the current file
# If the given operand is fixed string -> return it unchanged
- if {[lsearch -exact -ascii ${CompilerConsts::FixedOperands} [string tolower $operand]] != -1} {
+ if {[lsearch -exact -ascii ${::CompilerConsts::FixedOperands} [string tolower $operand]] != -1} {
return $operand
}
@@ -1466,10 +1467,23 @@ namespace eval PreProcessor {
set char [string index $operand 0]
if {$char == {#} || $char == {@} || $char == {/}} {
set operand [string replace $operand 0 0]
- } {
+ } else {
set char {}
}
+ # Handle prefix notation for hexadecimal numbers, like 0xfa
+ if {
+ [string index $operand 0] == {0}
+ &&
+ ([string index $operand 1] == {x} || [string index $operand 1] == {X})
+ } then {
+ set operand [string replace $operand 0 1]
+ if {![string is digit [string index $operand 0]]} {
+ set operand "0${operand}"
+ }
+ append operand {h}
+ }
+
# Determinate numeric base and adjust operand string
set base [string index $operand end]
set operand [string range $operand 0 {end-1}]
@@ -1481,17 +1495,17 @@ namespace eval PreProcessor {
# Convert and return
if {[NumSystem::isdec $operand]} {
return "$char$operand"
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s'" "${char}${operand}"]
}
- # Value is charater
+ # Value is a charater
} elseif {$base == {'}} {
# Remove leading quote
if {[string index $operand 0] != {'}} {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s'" "${char}${operand}"]
return {}
- } {
+ } else {
set operand [string range $operand 1 end]
}
}
@@ -1503,7 +1517,7 @@ namespace eval PreProcessor {
if {[NumSystem::ishex $operand]} {
set operand [expr "0x$operand"]
return "$char$operand"
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s'" "${operand}${base}"]
return {}
}
@@ -1512,7 +1526,7 @@ namespace eval PreProcessor {
if {[NumSystem::isbin $operand]} {
set operand [NumSystem::bin2dec $operand]
return "$char$operand"
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s'" "${operand}${base}"]
return {}
}
@@ -1521,7 +1535,7 @@ namespace eval PreProcessor {
if {[NumSystem::isoct $operand]} {
set operand [NumSystem::oct2dec $operand]
return "$char$operand"
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s'" "${operand}${base}"]
return {}
}
@@ -1530,7 +1544,7 @@ namespace eval PreProcessor {
if {[NumSystem::isoct $operand]} {
set operand [NumSystem::oct2dec $operand]
return "$char$operand"
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s'" "${operand}${base}"]
return {}
}
@@ -1538,7 +1552,7 @@ namespace eval PreProcessor {
{'} { ;# From character
if {[string length $operand] != 0} {
set operand $char[character2number [subst -nocommands -novariables $operand]]
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s'" $operand]
return {}
}
@@ -1546,7 +1560,7 @@ namespace eval PreProcessor {
{d} { ;# From decimal (no conversion)
if {[NumSystem::isdec $operand]} {
return "$char$operand"
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s'" "${operand}${base}"]
return {}
}
@@ -1571,10 +1585,10 @@ namespace eval PreProcessor {
set operand [string tolower $operand]
# Fixed operand
- if {[lsearch -exact -ascii ${CompilerConsts::FixedOperands} $operand] != -1} {
+ if {[lsearch -exact -ascii ${::CompilerConsts::FixedOperands} $operand] != -1} {
if {$operand == $type} {
return 1
- } {
+ } else {
return 0
}
}
@@ -1583,7 +1597,7 @@ namespace eval PreProcessor {
set char [string index $operand 0]
if {$char == {#} || $char == {@} || $char == {/}} {
set operand [string trimleft $operand {#@/}]
- } {
+ } else {
set char {}
}
@@ -1607,7 +1621,11 @@ namespace eval PreProcessor {
}
# Check for allowed range
- if {$operand > $max || $operand < 0} {return 0} {return 1}
+ if {$operand > $max || $operand < 0} {
+ return 0
+ } else {
+ return 1
+ }
}
## Determinate whether the given string is an expression
@@ -1621,9 +1639,9 @@ namespace eval PreProcessor {
set expression [string trimleft $expression "\t "]
set expression [string trimright $expression "\t "]
- if {[regexp {[ \+\-\=<>\(\)\*/%]} $expression]} {
+ if {[regexp {[ \?\+\-\=<>\(\)\*/%]} $expression]} {
return 1
- } {
+ } else {
return 0
}
}
@@ -1633,9 +1651,9 @@ namespace eval PreProcessor {
# @return Bool - result (1 == is fixed; 0 == is not fixed)
proc isFixed {operand} {
set operand [string tolower $operand]
- if {[lsearch -exact -ascii ${CompilerConsts::FixedOperands} $operand] != -1} {
+ if {[lsearch -exact -ascii ${::CompilerConsts::FixedOperands} $operand] != -1} {
return 1
- } {
+ } else {
return 0
}
}
@@ -1653,7 +1671,7 @@ namespace eval PreProcessor {
# Check if the string starts with a digit or quote
if {[regexp {^(\d|')} $symbolic_name]} {
return 0
- } {
+ } else {
return 1
}
}
@@ -1668,7 +1686,7 @@ namespace eval PreProcessor {
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable check_sfr_usage;# Bool: Check for legal usage of SFR and SFB
- variable avaliable_SFR ;# List: Avaliable SFR and SFB on the target MCU
+ variable available_SFR ;# List: Available SFR and SFB on the target MCU
variable const_BIT ;# Array: Bit values -- ($const_BIT($bit_name) == $value)
variable const_CODE ;# Array: Constants defined by directive 'CODE'
@@ -1699,13 +1717,13 @@ namespace eval PreProcessor {
if {
([lsearch -exact -ascii $defined_LABEL $symbolic_name] == -1) &&
($symbolic_name != "\$")
- } {
+ } then {
continue
}
if {$symbolic_name == "\$"} {
set value $address
- } {
+ } else {
set value $labels($symbolic_name)
}
CodeListing::symbol_used $symbolic_name {label}
@@ -1737,9 +1755,9 @@ namespace eval PreProcessor {
if {
[lsearch -ascii -exact $::CompilerConsts::defined_SFR $symbolic_name] != -1
&&
- [lsearch -ascii -exact $avaliable_SFR $symbolic_name] == -1
- } {
- Warning $lineNum $fileNum [mc "Special function register \"%s\" is not avaliable on the target MCU" [string toupper $symbolic_name]]
+ [lsearch -ascii -exact $available_SFR $symbolic_name] == -1
+ } then {
+ Warning $lineNum $fileNum [mc "Special function register \"%s\" is not available on the target MCU" [string toupper $symbolic_name]]
}
}
@@ -1754,9 +1772,9 @@ namespace eval PreProcessor {
if {
[lsearch -ascii -exact $::CompilerConsts::defined_SFRBitArea $symbolic_name] != -1
&&
- [lsearch -ascii -exact $avaliable_SFR $symbolic_name] == -1
- } {
- Warning $lineNum $fileNum [mc "Special function bit \"%s\" is not avaliable on the target MCU" [string toupper $symbolic_name]]
+ [lsearch -ascii -exact $available_SFR $symbolic_name] == -1
+ } then {
+ Warning $lineNum $fileNum [mc "Special function bit \"%s\" is not available on the target MCU" [string toupper $symbolic_name]]
}
}
@@ -1771,7 +1789,7 @@ namespace eval PreProcessor {
set val [const_value $symbolic_name $lineNum]
if {$val == {}} {
break
- } {
+ } else {
CodeListing::symbol_used $symbolic_name {equset}
return $val
}
@@ -1789,19 +1807,19 @@ namespace eval PreProcessor {
return {}
}
- ## Perform peerhole optimalization
+ ## Perform peerhole optimization
# This function must be called between "parse_instructions" and "final_stage"
# @return void
- proc optimalization {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ proc optimization {} {
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
variable labels ;# Array: Values of defined labels ($labels($label) == $address)
variable defined_LABEL ;# List of defined labels
variable program_memory ;# String of booleans: Map of program memory usage
- variable optims ;# Number of performed optimalizations
+ variable optims ;# Number of performed optimizations
variable origin_d_addr ;# List: Addresses of static program blocks
# Iterate over the code
@@ -1810,7 +1828,9 @@ namespace eval PreProcessor {
for {set idx 0} {$idx < $asm_len} {incr idx} {
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -1876,7 +1896,7 @@ namespace eval PreProcessor {
} elseif {
[lindex $operand_types 0] != {code8} &&
[lindex $operand_types 0] != {code11} &&
- [lindex $operands_abs 0] < 2048
+ ($address & 0x0f800) == ([lindex $operands_abs 0] & 0x0f800)
} then {
set instruction {ajmp}
set operand_types {code11}
@@ -1888,7 +1908,7 @@ namespace eval PreProcessor {
## A)
if {[string is digit -strict [lindex $operands_abs 0]]} {
set diff [expr {$address - [lindex $operands_abs 0]}]
- } {
+ } else {
set diff 200 ;# Some value out of range [-126; 129]
}
if {$diff >= -126 && $diff <= 129} {
@@ -1906,7 +1926,7 @@ namespace eval PreProcessor {
{ajmp} { ;# AJMP code8 --> SJMP code8
if {[string is digit -strict [lindex $operands_abs 0]]} {
set diff [expr {$address - [lindex $operands_abs 0]}]
- } {
+ } else {
set diff 200 ;# Some value out of range [-126; 129]
}
if {$diff >= -126 && $diff <= 129} {
@@ -1915,7 +1935,11 @@ namespace eval PreProcessor {
}
}
{call} { ;# CALL code11 --> ACALL code11
- if {[lindex $operand_types 0] != {code11} && [lindex $operands_abs 0] < 2048} {
+ if {
+ [lindex $operand_types 0] != {code11}
+ &&
+ ($address & 0x0f800) == ([lindex $operands_abs 0] & 0x0f800)
+ } then {
set instruction {acall}
set operand_types {code11}
set bytes_saved 1
@@ -1935,7 +1959,7 @@ namespace eval PreProcessor {
[lindex $operands_abs 0] == 224
&&
[lindex $operand_types 0] == {data}
- } {
+ } then {
if {[lindex $operands_abs 1] != {A}} {
lset operands 0 A
lset operand_types 0 a
@@ -1946,7 +1970,7 @@ namespace eval PreProcessor {
[lindex $operands_abs 1] == 224
&&
[lindex $operand_types 1] == {data}
- } {
+ } then {
lset operands 1 A
lset operand_types 1 a
set bytes_saved 1
@@ -1955,7 +1979,7 @@ namespace eval PreProcessor {
}
if {$bytes_saved} {
- # Increment number of performed optimalizations
+ # Increment number of performed optimizations
incr optims
# Shift code
@@ -1995,8 +2019,8 @@ namespace eval PreProcessor {
## Evaluate and remove instructions
# @return void
proc parse_instructions {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
@@ -2027,7 +2051,9 @@ namespace eval PreProcessor {
incr idx
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -2042,7 +2068,7 @@ namespace eval PreProcessor {
## Conditionaly change program pointer
if {![regexp {^\s*\w+} $line first_field]} {
set first_field {}
- } {
+ } else {
set first_field [string trim $first_field]
}
if {$first_field == {ORG}} {
@@ -2055,15 +2081,27 @@ namespace eval PreProcessor {
## Determinate label
if {[regexp {^\w+:} $line label]} {
# Check for label validity
+ set lbl [string trimright $label {:}]
if {[regexp {^\w*:$} $label] && ![regexp {^\d} $label]} {
-
- set label [string trimright $label {:}]
- if {[isReservedKeyword $label]} {
- Warning $lineNum $fileNum [mc "Reserved keyword used as label"]
+ if {
+ [lsearch -exact -ascii ${::CompilerConsts::defined_SFR} $lbl] != -1
+ ||
+ [lsearch -exact -ascii ${::CompilerConsts::defined_progVectors} $lbl] != -1
+ ||
+ [lsearch -exact -ascii ${::CompilerConsts::defined_SFRBitArea} $lbl] != -1
+ ||
+ [lsearch -exact -ascii ${::CompilerConsts::FixedOperands} $lbl] != -1
+ } then {
+ SyntaxError $lineNum $fileNum [mc "Unable redefine constant: %s" $lbl]
+ } else {
+ set label $lbl
+ if {[isReservedKeyword $label]} {
+ Warning $lineNum $fileNum [mc "Reserved keyword used as label"]
+ }
+ lappend local_labels $label
}
- lappend local_labels $label
- } {
- SyntaxError $lineNum $fileNum [mc "Invalid label: `%s' \n\t(labels can contain only alfanumeric characters and must not begin with a digit)" $label]
+ } else {
+ SyntaxError $lineNum $fileNum [mc "Invalid label: `%s' \n\t(labels can contain only alphanumeric characters and must not begin with a digit)" $label]
}
# Remove label from the line
@@ -2080,7 +2118,7 @@ namespace eval PreProcessor {
## Determinate instruction
if {![regexp {^\s*\.?\w+} $line instruction]} {
set instruction {}
- } {
+ } else {
set instruction [string tolower [string trim $instruction]]
}
@@ -2090,7 +2128,7 @@ namespace eval PreProcessor {
if {$skip == {}} {
set instruction_len 0
SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" [regsub {^\s*\.?\w+\s*} $line {}]]
- } {
+ } else {
set instruction_len $skip
}
@@ -2105,7 +2143,7 @@ namespace eval PreProcessor {
# Regular instruction
} else {
# Check for instruction validity
- if {[lsearch -exact -ascii ${CompilerConsts::AllInstructions} $instruction] == -1} {
+ if {[lsearch -exact -ascii ${::CompilerConsts::AllInstructions} $instruction] == -1} {
lappend tmp_asm [list $lineNum $fileNum {C} $line]
continue
}
@@ -2181,19 +2219,31 @@ namespace eval PreProcessor {
}
## Determinate whether the given string is reserved keyword
- # @parm String string - string to evaluate
+ # @parm String string - String to evaluate
+ # @parm Bool symbols_too - Consider also special register names
# @return Bool - result (1 == is reserved; 0 == is not reserved)
- proc isReservedKeyword {string} {
+ proc isReservedKeyword {string {symbols_too 0}} {
set string [string tolower $string]
if {
- [lsearch -exact -ascii ${CompilerConsts::AllInstructions} $string] != -1
+ [lsearch -exact -ascii ${::CompilerConsts::AllInstructions} $string] != -1
||
- [lsearch -exact -ascii ${CompilerConsts::AllDirectives} $string] != -1
- } {
+ [lsearch -exact -ascii ${::CompilerConsts::AllDirectives} $string] != -1
+ ||
+ [lsearch -exact -ascii ${::CompilerConsts::FixedOperands} $string] != -1
+ } then {
return 1
- } {
+ } elseif {$symbols_too && (
+ [lsearch -exact -ascii ${::CompilerConsts::defined_SFR} $string] != -1
+ ||
+ [lsearch -exact -ascii ${::CompilerConsts::defined_progVectors} $string] != -1
+ ||
+ [lsearch -exact -ascii ${::CompilerConsts::defined_SFRBitArea} $string] != -1
+ )
+ } then {
+ return 1
+ } else {
return 0
}
}
@@ -2215,8 +2265,8 @@ namespace eval PreProcessor {
set list_of_labels [string tolower $list_of_labels]
foreach label $list_of_labels {
if {[lsearch -exact -ascii $defined_LABEL $label] != -1} {
- SyntaxError $lineNum $fileNum [mc "Label is already defined: `%s'" $label]
- } {
+ SyntaxError $lineNum $fileNum [mc "Label was already defined: `%s'" $label]
+ } else {
lappend defined_LABEL $label
set labels($label) $address
}
@@ -2241,7 +2291,7 @@ namespace eval PreProcessor {
set l [llength $operands]
for {set i 0} {$i < $l} {incr i} {
set o [lindex $operands $i]
- if {[lsearch -exact -ascii ${CompilerConsts::FixedOperands} [string tolower $o]] != -1} {
+ if {[lsearch -exact -ascii ${::CompilerConsts::FixedOperands} [string tolower $o]] != -1} {
set operands [lreplace $operands $i $i [string toupper $o]]
}
}
@@ -2262,7 +2312,7 @@ namespace eval PreProcessor {
set n [const_value $o $lineNum 1]
set operands [lreplace $operands $i $i $n]
- Notice $lineNum $fileNum [mc "Overwriting `%s' with `%s' (acording to your previous definition!)" [string toupper $o] [string toupper $n]]
+ Notice $lineNum $fileNum [mc "Overwriting `%s' with `%s' (according to your previous definition!)" [string toupper $o] [string toupper $n]]
}
}
@@ -2273,19 +2323,19 @@ namespace eval PreProcessor {
}
# Find instruction set for given instruction
- if {[lsearch -exact -ascii ${CompilerConsts::AllInstructions} $instruction] == -1} {
+ if {[lsearch -exact -ascii ${::CompilerConsts::AllInstructions} $instruction] == -1} {
CompilationError $lineNum $fileNum "Unknown error 3"
return {}
}
- set ins_def $CompilerConsts::InstructionDefinition($instruction)
+ set ins_def $::CompilerConsts::InstructionDefinition($instruction)
# Check for valid operands count
set max_oprs [lindex $ins_def 0]
if {[llength $operands] > $max_oprs} {
- SyntaxError $lineNum $fileNum [mc "Too many operands, %s can take only %s operand[expr {$max_oprs ? {} : {s}}]" $instruction $max_oprs]
+ SyntaxError $lineNum $fileNum [mc "Too many operands, %s can take only %s operand[expr {$max_oprs == 1 ? {} : {s}}]" $instruction $max_oprs]
return {}
} elseif {[llength $operands] < $max_oprs} {
- SyntaxError $lineNum $fileNum [mc "Too few operands, %s must take exactly %s operand[expr {$max_oprs ? {} : {s}}]" $instruction $max_oprs]
+ SyntaxError $lineNum $fileNum [mc "Too few operands, %s must take exactly %s operand[expr {$max_oprs == 1 ? {} : {s}}]" $instruction $max_oprs]
return {}
}
@@ -2330,7 +2380,7 @@ namespace eval PreProcessor {
$operands_i != {C}
&&
$operands_i != {/C}
- } {
+ } then {
incr i
continue
}
@@ -2361,7 +2411,7 @@ namespace eval PreProcessor {
# No matching operand set found -> error
if {!$match} {
- SyntaxError $lineNum $fileNum [mc "Invalid operand set: %s %s" $instruction [join $operands {,}]]
+ SyntaxError $lineNum $fileNum [mc "Invalid set of operands: %s %s" $instruction [join $operands {,}]]
return {}
}
@@ -2391,7 +2441,7 @@ namespace eval PreProcessor {
set operand [string tolower $operand]
# Fixed value
- if {[lsearch -exact -ascii ${CompilerConsts::FixedOperands} $operand] != -1} {
+ if {[lsearch -exact -ascii ${::CompilerConsts::FixedOperands} $operand] != -1} {
return [string toupper $operand]
}
@@ -2401,6 +2451,13 @@ namespace eval PreProcessor {
{^#.*$} { return {imm8 imm16} }
}
+ # determinate whether the instruction can changed content of PC
+ if {[lsearch {} $instruction] == -1} {
+ set no_branch 1
+ } else {
+ set no_branch 0
+ }
+
# Variable length operand (pseudo-instructions: "CALL <code>" and "JMP <code>")
if {$instruction == {jmp} || $instruction == {call}} {
# Value is an expression
@@ -2425,7 +2482,7 @@ namespace eval PreProcessor {
return {code16}
} elseif {(abs($address - $operand) > 126) || $instruction == {call}} {
return {code11}
- } {
+ } else {
return {code8}
}
@@ -2437,7 +2494,7 @@ namespace eval PreProcessor {
} elseif {[lsearch ${::CompilerConsts::defined_SFRBitArea} $operand] != -1} {
return {bit /bit}
- # Interrupt vector
+ # Address in program memory
} elseif {[lsearch ${::CompilerConsts::defined_progVectors} $operand] != -1} {
return {code16 code11 code8}
@@ -2450,11 +2507,12 @@ namespace eval PreProcessor {
## Expand macro instructions
# @return Bool - macro expanded
proc expand_macro_instructions {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable macro ;# Array: Code of defined macro instructions
+ variable local_M_labels ;# Array of lists: Local labels in macros $local_M_labels($macro_name) == {integer label0 ... labelN}
variable defined_MACRO ;# List of defined macro instructions
variable idx ;# Current position in asm list
@@ -2478,7 +2536,9 @@ namespace eval PreProcessor {
incr idx
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -2499,7 +2559,7 @@ namespace eval PreProcessor {
}
if {![regexp {^\s*\.?\w+} $line instruction]} {
set instruction {}
- } {
+ } else {
set instruction [string tolower [string trim $instruction]]
}
regsub {^\.?\w+\s*} $line {} operands
@@ -2513,14 +2573,14 @@ namespace eval PreProcessor {
set repeat 1
# Get code of the macro
- set macro_code [getMacro $instruction [getOperands $operands 0]]
+ set macro_code [getMacro $instruction [getOperands $operands 1]]
if {$macro_code == {}} {continue}
# Adjust the precompiled code and code listing
if {$label != {}} {
lappend tmp_asm [list $lineNum $fileNum $label]
set del_line 0
- } {
+ } else {
set del_line 1
}
@@ -2541,11 +2601,11 @@ namespace eval PreProcessor {
return $repeat
}
- ## Debuging procedure
+ ## Debugging procedure
# Write current content of the precompiled code to stdout
# @return void
proc write_asm {} {
- variable asm ;# Resulting precompiled code
+ variable asm ;# Resulting pre-compiled code
puts ""
set idx -1
foreach line $asm {
@@ -2554,11 +2614,11 @@ namespace eval PreProcessor {
}
}
- ## Debuging procedure
+ ## Debugging procedure
# Write current content of the tempotary precompiled code to stdout
# @return void
proc write_tmp_asm {} {
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
puts ""
set idx -1
foreach line $tmp_asm {
@@ -2573,11 +2633,12 @@ namespace eval PreProcessor {
# @return List - code of the macro
proc getMacro {macro_name args} {
variable macro ;# Array: Code of defined macro instructions
+ variable local_M_labels ;# Array of lists: Local labels in macros $local_M_labels($macro_name) == {integer label0 ... labelN}
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
- # Adjust list of armuments
- set args [join $args]
+ # Adjust list of arguments
+ set args [lindex $args 0]
# Local variables
set new_operands {} ;# Instruction operands
@@ -2585,34 +2646,57 @@ namespace eval PreProcessor {
# Determinate code of the macro and its operands
set macro_code $macro($macro_name)
- set m_args [lindex $macro_code 0]
+ set m_pars [lindex $macro_code 0]
set macro_code [lindex $macro_code 1]
# Check for valid number of arguments
- set arg_len_diff [expr {[llength $args] - [llength $m_args]}]
+ set arg_len_diff [expr {[llength $args] - [llength $m_pars]}]
if {$arg_len_diff < 0} {
set arg_len_diff [expr {$arg_len_diff * -1}]
- SyntaxError $lineNum $fileNum [mc "Too few arguments, %s argument(s) missing: %s ..." $arg_len_diff $macro_name]
+ SyntaxError $lineNum $fileNum [mc "Too few arguments, %d argument(s) missing for %s ..." $arg_len_diff $macro_name]
return {}
} elseif {$arg_len_diff > 0} {
- SyntaxError $lineNum $fileNum [mc "Too many arguments, $s extra argument(s)" $arg_len_diff]
+ SyntaxError $lineNum $fileNum [mc "Too many arguments, %d extra argument(s)" $arg_len_diff]
return {}
}
- # Substitute macro arguments
+ # Increment counter of expansions of this macro
+ lset local_M_labels($macro_name) 0 [expr {1 + [lindex $local_M_labels($macro_name) 0]}]
+
+ # Substitute macro parametrs
foreach line $macro_code {
set new_operands {}
+ # Determinate label
+ if {![regexp {^(\?\?)?[A-Za-z_][^\s:]*:\s*} $line label]} {
+ set label {}
+ } else {
+ regsub {^(\?\?)?[A-Za-z_][^\s:]:*\s*} $line {} line
+ regsub -all {\s+} $label {} label
+ set label [string trimright $label {:}]
+ if {[lsearch -ascii -exact $local_M_labels($macro_name) $label] != -1} {
+ set label "${macro_name}_[lindex $local_M_labels($macro_name) 0]__${label}"
+ }
+ }
+
# Determinate instruction and operands
if {![regexp {^\.?\w+\s*} $line instruction]} {
set instruction {}
+ } else {
+ regsub -all {\s+} $instruction {} instruction
}
regsub {^\.?\w+\s*} $line {} operands
if {$operands == {}} {
lappend result $instruction
continue
}
- set operands [getOperands $operands 0]
+
+ if {[lsearch -ascii -exact {if ifn ifdef ifndef elseif elseifn elseifdef elseifndef} [string tolower $instruction]] == -1} {
+ set operands [getOperands $operands 0]
+ set if_statement 0
+ } else {
+ set if_statement 1
+ }
# Perform substitution
foreach opr $operands {
@@ -2623,25 +2707,43 @@ namespace eval PreProcessor {
($char == {/}) ||
($char == {#}) ||
($char == {@})
- } {
+ } then {
set opr [string range $opr 1 end]
- } {
+ } else {
set char {}
}
- # Find operand in macro armunets
- set idx [lsearch -exact -ascii $m_args $opr]
- if {$idx != -1} {
- set opr [lindex $args $idx]
+ # Find operand in macro parameters
+ set new_opr [list]
+ regsub -all {[\(\)]} $opr { & } opr
+ foreach o $opr {
+ set idx [lsearch -exact -ascii $m_pars $o]
+ if {$idx != -1} {
+ set o [lindex $args $idx]
+
+ if {[isReservedKeyword [lindex $m_pars $idx] 1]} {
+ Warning $lineNum $fileNum [mc "Reserved keyword substituted with macro argument: %s --> %s" [lindex $m_pars $idx] [lindex $args $idx]]
+ }
+ }
+
+ append new_opr $o { }
}
- lappend new_operands "$char$opr"
+ lappend new_operands "$char$new_opr"
}
# Recomposite line of macro instruction code
- set operands [join $new_operands {, }]
+ if {$if_statement} {
+ set operands [join $new_operands { }]
+ } else {
+ set operands [join $new_operands {, }]
+ }
append instruction "\t"
append instruction $operands
+
+ if {$label != {}} {
+ set instruction "${label}:\t${instruction}"
+ }
lappend result $instruction
}
@@ -2660,16 +2762,16 @@ namespace eval PreProcessor {
set simple_operands $operands ;# Original string without strings and chars
set result {} ;# Resulting list
- # Convert strings and quoted charaters to underscores
- while 1 {
+ # Convert strings and quoted characters to underscores
+ while {1} {
if {![regexp {'[^']*'} $simple_operands str]} {break}
set padding [string repeat {_} [string length $str]]
regsub {'[^']*'} $simple_operands $padding simple_operands
}
- # Determinate oprands
- while 1 {
+ # Determinate operands
+ while {1} {
set idx [string first {,} $simple_operands]
if {$idx == -1} {break}
@@ -2688,7 +2790,7 @@ namespace eval PreProcessor {
lappend result $operands
if {$keep_case} {
return $result
- } {
+ } else {
return [string tolower $result]
}
}
@@ -2696,11 +2798,12 @@ namespace eval PreProcessor {
## Parse and remove definitions of macro instructions
# @return void
proc define_macro_instructions {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable macro ;# Array: Code of defined macro instructions
+ variable local_M_labels ;# Array of lists: Local labels in macros $local_M_labels($macro_name) == {integer label0 ... labelN}
variable defined_MACRO ;# List of defined macro instructions
variable idx ;# Current position in asm list
variable macro_name_to_append ;# Name of currently defined macro instruction
@@ -2710,20 +2813,21 @@ namespace eval PreProcessor {
set idx -1
# Local variables
- set Macro 0 ;# Bool: definition opened
- set Exitm 0 ;# Bool: Definition terminated by directive 'EXITM'
- set NoMacro 0 ;# Definition failed
- set del_line 1 ;# Bool: remove this line
- set macro_name {} ;# Name of the macro
- set macro_args {} ;# List of arguments for the macro
- set rept_macro 0 ;# Bool: repeat macro starts
+ set Macro 0 ;# Bool: definition opened
+ set NoMacro 0 ;# Definition failed
+ set del_line 1 ;# Bool: remove this line
+ set macro_name {} ;# Name of the macro
+ set macro_params {} ;# List of the macro parameters
+ set rept_macro 0 ;# Bool: repeat macro starts
# Iterate over the code
foreach line $asm {
incr idx
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -2740,12 +2844,12 @@ namespace eval PreProcessor {
# Spilt line into first 2 separate fields
if {![regexp {^\s*\.?\w+} $line field0]} {
set field0 {}
- } {
+ } else {
set field0 [string trim $field0]
}
if {![regexp {^\s*\.?\w+:?\s+\.?\w+} $line field1]} {
set field1 {}
- } {
+ } else {
regexp {\.?\w+$} $field1 field1
}
set field0_l [regsub {^\.} [string tolower $field0] {}]
@@ -2755,17 +2859,17 @@ namespace eval PreProcessor {
if {$field0_l == {rept} || $field0_l == {times}} {
if {$Macro} {
SyntaxError $lineNum $fileNum \
- [mc "Cannot define macro inside anoner one -- macro processing failed"]
- } {
- regsub {^\s*\.?\w+\s*} $line {} macro_args
- set macro_args [ComputeExpr $macro_args]
- if {$macro_args == {}} {
- SyntaxError $lineNum $fileNum [mc "Missign number of repeats"]
+ [mc "Cannot define macro inside another one -- macro processing failed"]
+ } else {
+ regsub {^\s*\.?\w+\s*} $line {} macro_params
+ set macro_params [ComputeExpr $macro_params]
+ if {$macro_params == {}} {
+ SyntaxError $lineNum $fileNum [mc "Missing number of repeats"]
set NoMacro 1
- } elseif {$macro_args < 0} {
+ } elseif {$macro_params < 0} {
Warning $lineNum $fileNum [mc "Number of repeats is lower than zero"]
set NoMacro 1
- } elseif {$macro_args == 0} {
+ } elseif {$macro_params == 0} {
Notice $lineNum $fileNum [mc "Zero number of repeats"]
set NoMacro 1
}
@@ -2781,69 +2885,66 @@ namespace eval PreProcessor {
} elseif {$field1_l == {macro}} {
if {$Macro} {
SyntaxError $lineNum $fileNum \
- [mc "Cannot define macro inside anoner one -- macro processing failed"]
- } {
- # Determinate name and arguments
- regsub {^\w+\s+\.?\w+\s*} $line {} macro_args
- set macro_args [getOperands $macro_args 0]
+ [mc "Cannot define macro inside another one -- macro processing failed"]
+ } else {
+ # Determinate name and parameters
+ regsub {^\w+\s+\.?\w+\s*} $line {} macro_params
+ set macro_params [getOperands $macro_params 0]
set macro_name $field0_l
+ foreach parm $macro_params {
+ if {[isReservedKeyword $parm 1]} {
+ Warning $lineNum $fileNum [mc "Reserved keyword used as macro parameter: %s in macro %s" $parm $macro_name]
+ }
+ }
+
# Check for validity of the name
- if {
- ([lsearch -exact -ascii ${CompilerConsts::AllInstructions} $macro_name] != -1)
- ||
- ([lsearch -exact -ascii ${CompilerConsts::AllDirectives} $macro_name] != -1)
- } {
+ if {[isReservedKeyword $macro_name]} {
# Invalid name
SyntaxError $lineNum $fileNum [mc "Macro name is reserved keyword: %s" $macro_name]
set NoMacro 1
- } {
+ } else {
+ # Check for validity of the name (again, but invoke only warning this time)
+ if {[isReservedKeyword $macro_name 1]} {
+ # Invalid name
+ Warning $lineNum $fileNum [mc "Macro name is reserved keyword: %s" $macro_name]
+ set NoMacro 1
+ }
# Valid name
if {[lsearch -exact -ascii $defined_MACRO $macro_name] != -1} {
SyntaxError $lineNum $fileNum [mc "Macro `%s' is already defined" $macro_name]
set NoMacro 1
- } {
+ } else {
set macro_name_to_append $macro_name
- set macro($macro_name) {}
+ set macro($macro_name) [list]
+ set local_M_labels($macro_name) [list 0]
}
set Macro 1
}
}
- # Exit macro definition
- } elseif {$field0_l == {exitm}} {
- if {!$Macro} {
- Warning $lineNum $fileNum [mc "Unable to exit macro, no macro is opened"]
- }
- set Exitm 1
- set rept_macro 0
-
- # Directive takes no arguments
- if {[string length $field1_l]} {
- Warning $lineNum $fileNum [mc "Directive %s takes no arguments" [string toupper $field0_l]]
- }
-
# Close macro definition
} elseif {$field0_l == {endm}} {
# No macro was opened
if {!$Macro} {
SyntaxError $lineNum $fileNum [mc "Unable to close macro, no macro is opened"]
# Close macro
- } {
+ } else {
if {$rept_macro} {
set line $macro($macro_name)
set macro($macro_name) [list]
- for {set i 0} {$i < $macro_args} {incr i} {
+ set local_M_labels($macro_name) [list 0]
+ for {set i 0} {$i < $macro_params} {incr i} {
set macro($macro_name) [concat $macro($macro_name) $line]
}
- set macro_args {}
+ set macro_params {}
set del_line 0
lappend tmp_asm [list $lineNum $fileNum $macro_name]
}
- if {!($Exitm || $NoMacro)} {
- set macro($macro_name) [list $macro_args $macro($macro_name)]
+ if {!$NoMacro} {
+ set macro($macro_name) [list $macro_params $macro($macro_name)]
regsub -all {\s+} $macro($macro_name) { } macro($macro_name)
regsub -all "\\\{ " $macro($macro_name) "\{" macro($macro_name)
@@ -2853,7 +2954,6 @@ namespace eval PreProcessor {
# Reset some local variables
set Macro 0
- set Exitm 0
set NoMacro 0
set rept_macro 0
@@ -2866,20 +2966,26 @@ namespace eval PreProcessor {
} else {
# Part of macro definition
if {$Macro} {
- if {[regexp {^\w+:} $line]} {
- Warning $lineNum $fileNum [mc "Bad layout: Macros cannot contain labels -- label deleted"]
- regsub {^\w+:\s*} $line {} line
- }
- if {!($Exitm || $NoMacro)} {
- lappend macro($macro_name) $line
+ # Register local label in the macro
+ if {$field0_l == {local}} {
+ if {[regexp {^\w+$} $field1_l]} {
+ lappend local_M_labels($macro_name) $field1_l
+ } else {
+ SyntaxError $lineNum $fileNum [mc "Invalid label specification: ``%s''" $field0_l]
+ }
+ # Append the line to the currenly opened macro
+ } else {
+ if {!$NoMacro} {
+ lappend macro($macro_name) $line
+ }
}
# Common line
- } {
+ } else {
if {$field0_l == {macro}} {
SyntaxError $lineNum $fileNum [mc "Missing name of macro"]
- } elseif {[regexp {^\s*\w+:} $line] && ($field1_l == {endm} || $field1_l == {exitm})} {
- SyntaxError $lineNum $fileNum [mc "Labels are not allowed before directives ENDM and EXITM"]
- } {
+ } elseif {[regexp {^\s*\w+:} $line] && ($field1_l == {endm})} {
+ SyntaxError $lineNum $fileNum [mc "Labels are not allowed before directives ENDM"]
+ } else {
lappend tmp_asm [list $lineNum $fileNum $line]
}
set del_line 0
@@ -2902,8 +3008,8 @@ namespace eval PreProcessor {
# @return Bool - code included
proc include_directive {dir} {
variable included_files ;# List: Unique unsorted list of included files
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
@@ -2921,7 +3027,9 @@ namespace eval PreProcessor {
set line_org $line
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -2941,14 +3049,14 @@ namespace eval PreProcessor {
regsub {^\s*\w+:\s*} $line {} line
set label [string trimleft $label " \t"]
set label [string trimright $label " \t"]
- } {
+ } else {
set label {}
}
# Determinate directive
if {![regexp {^\s*\.?\w+} $line directive]} {
set directive {}
- } {
+ } else {
set directive [string trim $directive]
}
set directive_l [string tolower $directive]
@@ -2958,7 +3066,7 @@ namespace eval PreProcessor {
regsub {^\s*\.?\w+} $line {} file_name
regsub {^\s+} $file_name {} file_name
if {![string length $file_name]} {
- SyntaxError $lineNum $fileNum [mc "Missing filename"]
+ SyntaxError $lineNum $fileNum [mc "Missing file name"]
}
set asm [lreplace $asm $idx $idx [list $lineNum $fileNum $label]]
@@ -2967,7 +3075,7 @@ namespace eval PreProcessor {
set file_name [regsub -nocase -- {^[\s ]*\$include[\s ]*} $file_name {}]
set file_name [string range $file_name 1 end-1]
if {![string length $file_name]} {
- SyntaxError $lineNum $fileNum [mc "Missing filename"]
+ SyntaxError $lineNum $fileNum [mc "Missing file name"]
}
set asm [lreplace $asm $idx $idx [list $lineNum $fileNum $label]]
@@ -2984,7 +3092,7 @@ namespace eval PreProcessor {
([string index $file_name 0] == "\"" && [string index $file_name end] == "\"")
||
([string index $file_name 0] == {'} && [string index $file_name end] == {'})
- } {
+ } then {
set file_name [string range $file_name 1 end-1]
}
set file_name [string trim $file_name]
@@ -3036,7 +3144,7 @@ namespace eval PreProcessor {
proc getFile {dir file file_number} {
variable fileNum ;# Number of the current file
variable lineNum ;# Number of the current line
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
set tmp_asm {}
@@ -3044,13 +3152,13 @@ namespace eval PreProcessor {
if {[string index $file 0] == {'}} {
if {[string index $file end] != {'}} {
SyntaxError $lineNum $fileNum [mc "Invalid expression: `%s'" $file]
- } {
+ } else {
set file [string range $file 1 {end-1}]
}
} elseif {[string index $file 0] == "\""} {
if {[string index $file end] != "\""} {
SyntaxError $lineNum $fileNum [mc "Invalid expression: `%s'" $file]
- } {
+ } else {
set file [string range $file 1 {end-1}]
}
}
@@ -3061,10 +3169,10 @@ namespace eval PreProcessor {
set file [open $file r]
set data [read $file]
close $file
- }]} {
+ }]} then {
CompilationError $lineNum $fileNum [mc "Unable to open file: %s" $file]
return {}
- } {
+ } else {
# Any EOL to LF
regsub -all {\r\n?} $data "\n" data
@@ -3078,7 +3186,7 @@ namespace eval PreProcessor {
return $tmp_asm
}
# File does not exist
- } {
+ } else {
CompilationError $lineNum $fileNum [mc "File not found: %s" $file]
return {}
}
@@ -3087,7 +3195,7 @@ namespace eval PreProcessor {
## Parse and remove directive(s) 'END'
# @return void
proc end_of_code {} {
- variable asm ;# Resulting precompiled code
+ variable asm ;# Resulting pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
@@ -3104,7 +3212,9 @@ namespace eval PreProcessor {
incr idx
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -3117,20 +3227,23 @@ namespace eval PreProcessor {
set line [lindex $line 2]
# Skip lines without word 'END'
- if {![regexp -nocase {\.?end} $line]} {
+ if {![regexp -nocase {end} $line]} {
continue
}
+ regsub {\s*;.*$} $line {} line
+ regsub -all {:} $line {: } line
+
# Determinate 1st and 2nd field of the line
- if {![regexp {^\s*\.?\w+} $line field0]} {
+ if {![regexp {^\s*[^\s]+} $line field0]} {
set field0 {}
- } {
+ } else {
set field0 [string trim $field0]
}
- if {![regexp {^\s*\.?\w+\s+\.?\w+} $line field1]} {
+ if {![regexp {^\s*[^\s]+\s+[^\s]+} $line field1]} {
set field1 {}
- } {
- regexp {\.?\w+$} $field1 field1
+ } else {
+ regexp {[^\s]+$} $field1 field1
}
set field0 [string tolower [regsub {^\.} $field0 {}]]
set field1 [string tolower [regsub {^\.} $field1 {}]]
@@ -3145,14 +3258,14 @@ namespace eval PreProcessor {
[regexp {^\w+:$} $field0]
&&
($field1 == {end})
- } {
+ } then {
# Determinate content of the last line of the code (that label)
if {![regexp {^\w+:$} $field0 last_line]} {
set last_line {}
}
# Check if the line does not contain anything except the label and 'END'
- regsub {^\w+:\s*} $line {} line
+ regsub {^\s*\w+:\s*} $line {} line
set line [string tolower $line]
if {$line != {end}} {
SyntaxError $lineNum $fileNum [mc "Extra symbols after `END' directive"]
@@ -3166,13 +3279,15 @@ namespace eval PreProcessor {
# Directive 'end' detected -> adjust the code
if {$end} {
set asm [lreplace $asm $idx end]
+ set preserve_current_line 0
if {$last_line != {}} {
lappend asm [list $lineNum $fileNum $last_line]
+ set preserve_current_line 1
}
- CodeListing::end_directive $idx
- incr idx
+ CodeListing::end_directive $idx $preserve_current_line
+
# Directive 'end' not found -> invoke warning
- } {
+ } else {
Warning 0 0 [mc "Missing `END' directive"]
}
}
@@ -3180,14 +3295,14 @@ namespace eval PreProcessor {
## Parse and remove directive(s) 'ORG' and reorganize the current code
# @return void
proc origin_directive {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
variable defined_LABEL ;# List of defined labels
variable labels ;# Array: Values of defined labels ($labels($label) == $address)
- variable ErrorAtLine ;# Bool: Error occured on the current line
+ variable ErrorAtLine ;# Bool: Error occurred on the current line
variable origin_d_addr ;# List: Addresses of static program blocks
# Reset NS variables
@@ -3209,7 +3324,9 @@ namespace eval PreProcessor {
set ErrorAtLine 0
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -3239,7 +3356,7 @@ namespace eval PreProcessor {
# Directive ORG detected
if {![regexp {^\s*\.?\w+} $line field0]} {
set field0 {}
- } {
+ } else {
set field0 [string trim $field0]
}
if {[regsub {^\.} $field0 {}] == {org}} {
@@ -3250,7 +3367,7 @@ namespace eval PreProcessor {
if {$line == {}} {
SyntaxError $lineNum $fileNum [mc "Missing address"]
set error 1
- } {
+ } else {
set value [ComputeExpr $line]
}
@@ -3262,7 +3379,7 @@ namespace eval PreProcessor {
SyntaxError $lineNum $fileNum [mc "Label already defined: `%s'" $label]
set error 1
}
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Invalid label: `%s'" $label]
set error 1
}
@@ -3292,7 +3409,7 @@ namespace eval PreProcessor {
set last_value $value
# Directive ORG wasn't detected
- } {
+ } else {
lappend tmp_asm [list $lineNum $fileNum $line]
}
}
@@ -3313,6 +3430,7 @@ namespace eval PreProcessor {
set organization [lsort -index 0 -integer $organization]
set last_line {} ;# Last line number
+ set last_file {} ;# Last file number
set last_addr {} ;# Last address or origin
set new_organization {} ;# New organization map
@@ -3368,7 +3486,7 @@ namespace eval PreProcessor {
# @parm Bool first - match the first
# @return Int - list index
proc lineNum2idx {line_number file_number first} {
- variable asm ;# Resulting precompiled code
+ variable asm ;# Resulting pre-compiled code
set idx -1
set ln 0
@@ -3387,7 +3505,7 @@ namespace eval PreProcessor {
}
if {$idx < 0} {
return 0
- } {
+ } else {
return $idx
}
}
@@ -3400,8 +3518,8 @@ namespace eval PreProcessor {
## Convert the current code into numbered list (see proc. 'compile')
# @return void
proc line_numbers {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
@@ -3422,7 +3540,9 @@ namespace eval PreProcessor {
incr idx
incr lineNum
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -3440,7 +3560,7 @@ namespace eval PreProcessor {
}
## Evaluate and remove directives related to:
- # - Donditional compilation (IF, ELSE, ENDIF) (group 0)
+ # - Conditional compilation (IF, ELSE, ENDIF) (group 0)
# - Code listing enable/disable (LIST, NOLIST) (group 1)
# - Active bank selection (USING) (group 2)
# - Data memory segment selection (BSEG, DSEG, ISEG, XSEG) (group 3)
@@ -3450,9 +3570,9 @@ namespace eval PreProcessor {
# @parm Bool ignore_undefined - Ignore undefined symbolic names
# @return Bool - Anything expanded
proc parse_Consts_and_ConditionalCompilation {groups ignore_undefined} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
- variable ErrorAtLine ;# Bool: Error occured on the current line
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
+ variable ErrorAtLine ;# Bool: Error occurred on the current line
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
@@ -3460,6 +3580,8 @@ namespace eval PreProcessor {
variable memory_reservation_map ;# Array: memory reservation map (see code)
variable defined_SET ;# List of variables defined by 'SET'
variable const_SET ;# Array: Constants defined by directive 'CODE'
+ variable selected_segment ;# Current memory segment (one of {cseg bseg dseg iseg xseg})
+ variable segment_pointer ;# Current memory segment pointer
# Reset NS variables
set idx -1
@@ -3482,7 +3604,9 @@ namespace eval PreProcessor {
}
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -3497,7 +3621,7 @@ namespace eval PreProcessor {
set line [lindex $line 2]
regsub -nocase -- {if\(} $line {if (} line ;# Make construction "IF(something)" valid
# Final level pass
- } {
+ } else {
set line [lindex $line 3]
}
@@ -3507,7 +3631,7 @@ namespace eval PreProcessor {
# Determinate 1st field of the line
if {![regexp {^\s*\.?\w+:?} $line line_first_field]} {
set line_first_field {}
- } {
+ } else {
set line_first_field [string trim $line_first_field]
}
set directive0 [string tolower $line_first_field]
@@ -3516,7 +3640,7 @@ namespace eval PreProcessor {
# Determinate 2nd field of the line
if {![regexp {^\s*\.?\w+:?\s*\.?\w+} $line directive1]} {
set directive1 {}
- } {
+ } else {
regsub {^\s*\.?\w+:?\s*} $directive1 {} directive1
set directive1 [string trim $directive1]
}
@@ -3527,67 +3651,67 @@ namespace eval PreProcessor {
# Constant definition (SET EQU BIT ...) without constant to define (syntax error)
if {
- [lindex $groups 4] && $Enable &&
- ([lsearch -exact -ascii ${CompilerConsts::ConstDefinitionDirectives} $directive0] != -1)
- } {
- if {[regexp {^\s*\.?\w+\s+\w+\s*\,\s*.+$} $line]} {
- Warning $lineNum $fileNum [mc "This formulation is deprecated, consider usage of \"<Const> <Directive> <Value>\" instead"]
-
- set line_expr {}
- regsub {^\s*\.?\w+\s+\w+\s*\,\s*} $line {} line_expr
- set line_aux $directive1
- append line_aux { } $directive0 { } $line_expr
-
- set loc_result [define_const $directive0 $line_aux $idx $ignore_undefined]
- if {$loc_result == 2} {
- lappend tmp_asm [list $lineNum $fileNum $line]
- set deleteLine 0
- } elseif {$loc_result == 0} {
- set fin_result 1
- }
- } {
- SyntaxError $lineNum $fileNum [mc "Missing name of constant to define"]
- }
+ [lindex $groups 4] && $Enable &&
+ ([lsearch -exact -ascii ${::CompilerConsts::ConstDefinitionDirectives} $directive0] != -1)
+ } then {
+ if {[regexp {^\s*\.?\w+\s+\w+\s*\,\s*.+$} $line]} {
+ Warning $lineNum $fileNum [mc "This formulation is deprecated, consider usage of \"<Const> <Directive> <Value>\" instead"]
- # Constant definition (SET EQU BIT ...)
- } elseif {
- [lindex $groups 4] && $Enable &&
- ([lsearch -exact -ascii ${CompilerConsts::ConstDefinitionDirectives} $directive1] != -1)
- } {
- set loc_result [define_const $directive1 $line $idx $ignore_undefined]
+ set line_expr {}
+ regsub {^\s*\.?\w+\s+\w+\s*\,\s*} $line {} line_expr
+ set line_aux $directive1
+ append line_aux { } $directive0 { } $line_expr
+
+ set loc_result [define_const $directive0 $line_aux $idx $ignore_undefined]
if {$loc_result == 2} {
lappend tmp_asm [list $lineNum $fileNum $line]
set deleteLine 0
} elseif {$loc_result == 0} {
set fin_result 1
}
+ } else {
+ SyntaxError $lineNum $fileNum [mc "Missing name of constant to define"]
+ }
+
+ # Constant definition (SET EQU BIT ...)
+ } elseif {
+ [lindex $groups 4] && $Enable &&
+ ([lsearch -exact -ascii ${::CompilerConsts::ConstDefinitionDirectives} $directive1] != -1)
+ } then {
+ set loc_result [define_const $directive1 $line $idx $ignore_undefined]
+ if {$loc_result == 2} {
+ lappend tmp_asm [list $lineNum $fileNum $line]
+ set deleteLine 0
+ } elseif {$loc_result == 0} {
+ set fin_result 1
+ }
# Listing control (LIST, NOLIST)
} elseif {
- [lindex $groups 1] && (
- ($directive0 == {list}) ||
- ($directive0 == {nolist}) ||
- ($directive1 == {list} && [regexp {^\w+:$} $directive0 label]) ||
- ($directive1 == {nolist} && [regexp {^\w+:$} $directive0 label])
- )
- } {
- # Warning messages
- if {($directive0 == {list} || $directive0 == {nolist}) && [string length $directive1]} {
- Warning $lineNum $fileNum [mc "Directive %s takes no arguments" [string toupper $directive0]]
- } elseif {($directive1 == {list} || $directive1 == {nolist}) && [string length [regsub {^\s*\.?\w+:?\s+\.?\w+} $line {}]]} {
- Warning $lineNum $fileNum [mc "Directive %s takes no arguments" [string toupper $directive1]]
- }
+ [lindex $groups 1] && (
+ ($directive0 == {list}) ||
+ ($directive0 == {nolist}) ||
+ ($directive1 == {list} && [regexp {^\w+:$} $directive0 label]) ||
+ ($directive1 == {nolist} && [regexp {^\w+:$} $directive0 label])
+ )
+ } then {
+ # Warning messages
+ if {($directive0 == {list} || $directive0 == {nolist}) && [string length $directive1]} {
+ Warning $lineNum $fileNum [mc "Directive %s takes no arguments" [string toupper $directive0]]
+ } elseif {($directive1 == {list} || $directive1 == {nolist}) && [string length [regsub {^\s*\.?\w+:?\s+\.?\w+} $line {}]]} {
+ Warning $lineNum $fileNum [mc "Directive %s takes no arguments" [string toupper $directive1]]
+ }
- if {($directive0 == {nolist}) || ($directive1 == {nolist})} {
- CodeListing::directive_nolist $idx
- } {
- CodeListing::directive_list $idx
- }
+ if {($directive0 == {nolist}) || ($directive1 == {nolist})} {
+ CodeListing::directive_nolist $idx
+ } else {
+ CodeListing::directive_list $idx
+ }
- if {($label != {}) && $Enable} {
- lappend tmp_asm [list $lineNum $fileNum $label]
- set deleteLine 0
- }
+ if {($label != {}) && $Enable} {
+ lappend tmp_asm [list $lineNum $fileNum $label]
+ set deleteLine 0
+ }
# Active bank selection directive -- in 1st field (USING)
} elseif {[lindex $groups 2] && $Enable && ($directive0 == {using})} {
@@ -3603,28 +3727,28 @@ namespace eval PreProcessor {
# Active bank selection directive -- in 2nd field (USING)
} elseif {
- [lindex $groups 2] && ($directive1 == {using}) && $Enable
- &&
- ([regexp {^\w+:$} $directive0 label])
- } {
- set loc_result [define_active_bank \
- [regsub {^\w+:\s*\.?\w+\s*} $line {}] $ignore_undefined \
- ]
- set deleteLine 0
- if {$loc_result == 2} {
- lappend tmp_asm [list $lineNum $fileNum $line]
- } elseif {$loc_result == 0} {
- lappend tmp_asm [list $lineNum $fileNum $label]
- set fin_result 1
- } else {
- lappend tmp_asm [list $lineNum $fileNum $label]
- }
+ [lindex $groups 2] && ($directive1 == {using}) && $Enable
+ &&
+ ([regexp {^\w+:$} $directive0 label])
+ } then {
+ set loc_result [define_active_bank \
+ [regsub {^\w+:\s*\.?\w+\s*} $line {}] $ignore_undefined \
+ ]
+ set deleteLine 0
+ if {$loc_result == 2} {
+ lappend tmp_asm [list $lineNum $fileNum $line]
+ } elseif {$loc_result == 0} {
+ lappend tmp_asm [list $lineNum $fileNum $label]
+ set fin_result 1
+ } else {
+ lappend tmp_asm [list $lineNum $fileNum $label]
+ }
# Data segment selection (XSEG DSEG ...)
} elseif {
[lindex $groups 3] && $Enable &&
- ([lsearch -exact -ascii ${CompilerConsts::ConstDataSegmentSelectionDirectives} $directive0] != -1)
- } {
+ ([lsearch -exact -ascii ${::CompilerConsts::ConstDataSegmentSelectionDirectives} $directive0] != -1)
+ } then {
set loc_result [data_segment_selection \
$directive0 $directive1 $line $idx $ignore_undefined \
]
@@ -3635,11 +3759,32 @@ namespace eval PreProcessor {
set fin_result 1
}
+ # ORG in other than CODE segment
+ } elseif {
+ $directive0 == {org} || $directive1 == {org}
+ } then {
+ if {$selected_segment != {cseg}} {
+ regsub {org} $line "$selected_segment at" line
+
+ set address {}
+ if {$directive0 == {org}} {
+ set address [ComputeExpr $directive1]
+ } elseif {$directive1 == {org}} {
+ set address [ComputeExpr [regsub {^\w+:\s*\.?\w+\s*} $line {}]]
+ }
+ if {$address != {}} {
+ set segment_pointer($selected_segment) $address
+ }
+ }
+
+ lappend tmp_asm [list $lineNum $fileNum $line]
+ set deleteLine 0
+
# Data memory reservation -- without label (DBIT 125)
} elseif {
[lindex $groups 5] && $Enable &&
- ([lsearch -exact -ascii ${CompilerConsts::ConstDataMemoryReservationDirectives} $directive0] != -1)
- } {
+ ([lsearch -exact -ascii ${::CompilerConsts::ConstDataMemoryReservationDirectives} $directive0] != -1)
+ } then {
regsub {^\.?\w+\s*} $line {} value
set loc_result [data_memory_reservation {} $directive0 $value $idx $ignore_undefined]
if {$loc_result == 2} {
@@ -3653,8 +3798,8 @@ namespace eval PreProcessor {
} elseif {
[lindex $groups 5] && [regexp {^\w+:$} $line_first_field] && $Enable
&&
- ([lsearch -exact -ascii ${CompilerConsts::ConstDataMemoryReservationDirectives} $directive1] != -1)
- } {
+ ([lsearch -exact -ascii ${::CompilerConsts::ConstDataMemoryReservationDirectives} $directive1] != -1)
+ } then {
regsub {^\s*\w+:\s*\.?\w+\s*} $line {} value
set loc_result [data_memory_reservation \
$line_first_field $directive1 $value $idx $ignore_undefined \
@@ -3666,14 +3811,14 @@ namespace eval PreProcessor {
set fin_result 1
}
- # Conditional compilation statement -- in 2nd field (IF ELSE ENDIF IFNDEF IFDEF IFN)
+ # Conditional compilation statement -- in 2nd field (IF ELSE ENDIF IFNDEF IFDEF IFN ELSEIF ELSEIFN ELSEIFDEF ELSEIFNDEF)
} elseif {
[lindex $groups 0] && (
- [lsearch -ascii -exact {if else endif ifndef ifdef ifn} $directive1] != -1
+ [lsearch -ascii -exact {if else endif ifndef ifdef ifn elseif elseifn elseifdef elseifndef} $directive1] != -1
) && (
[regexp {^\w+:$} $line_first_field label]
)
- } {
+ } then {
# Is compilation enabled ?
if {$Enable} {
lappend tmp_asm [list $lineNum $fileNum $label]
@@ -3689,12 +3834,12 @@ namespace eval PreProcessor {
}
} else {
- # Conditional compilation statement -- in 1st field (IF ELSE ENDIF IFNDEF IFDEF IFN)
+ # Conditional compilation statement -- in 1st field (IF ELSE ENDIF IFNDEF IFDEF IFN ELSEIFN ELSEIFDEF ELSEIFNDEF)
if {
[lindex $groups 0] && (
- [lsearch -ascii -exact {if else endif ifndef ifdef ifn} $directive0] != -1
+ [lsearch -ascii -exact {if else endif ifndef ifdef ifn elseif elseifn elseifdef elseifndef} $directive0] != -1
)
- } {
+ } then {
regsub {^\.?\w+\s*} $line {} value
@@ -3704,11 +3849,15 @@ namespace eval PreProcessor {
}
If_Else_Endif $directive0 $value
- } {
+ } else {
# Is compilation enabled ?
if {$Enable} {
lappend tmp_asm [list $lineNum $fileNum $line]
set deleteLine 0
+
+ if {$directive0 == {cseg} || $directive1 == {cseg}} {
+ set selected_segment {cseg}
+ }
}
}
}
@@ -3787,7 +3936,7 @@ namespace eval PreProcessor {
if {![string length $expr]} {
SyntaxError $lineNum $fileNum [mc "Missing size"]
set value 1
- } {
+ } else {
set value [ComputeExpr $expr $ignore_undefined]
}
@@ -3823,10 +3972,10 @@ namespace eval PreProcessor {
($selected_segment != {dseg}) &&
($selected_segment != {iseg}) &&
($selected_segment != {xseg})
- } {
+ } then {
Warning $lineNum $fileNum [mc "Using `%s' directive, but currently active segment is `%s'" [string toupper $directive] [string toupper $selected_segment]]
set seg {dseg}
- } {
+ } else {
set seg $selected_segment
}
@@ -3834,7 +3983,7 @@ namespace eval PreProcessor {
return [reserve_memory $label $seg $value $idx]
# Unknown request -> compilation error
- } {
+ } else {
CompilationError $lineNum $fileNum "Unknown error 4"
return 1
}
@@ -3907,7 +4056,7 @@ namespace eval PreProcessor {
}
}
- # Check if there is enought free space in the segment
+ # Check if there is enough free space in the segment
set end [expr {$segment_pointer($segment) + $value}]
if {$end > $max} {
Warning $lineNum $fileNum [mc "Exceeding %s segment boundary by %s $unit." $segment_name [expr {$max - $end}]]
@@ -3957,10 +4106,10 @@ namespace eval PreProcessor {
set const [string trimright $label {:}]
# Assing block pointer to symbolic name specified by label
- if {[lsearch -exact -ascii [subst "\$defined_$const_type"] $const] != -1} {
+ if {[lsearch -exact -ascii [subst -nocommands "\$defined_$const_type"] $const] != -1} {
SyntaxError $lineNum $fileNum [mc "Unable redefine constant: %s" $const]
return 1
- } {
+ } else {
# Check if this symbol is not already defined
if {[isConstAlreadyDefined $const]} {
Warning $lineNum $fileNum [mc "Ambiguous symbol definition: %s" $const]
@@ -3997,11 +4146,17 @@ namespace eval PreProcessor {
set const_name [string tolower $const_name]
# Search all lists of symbolic names
- if {[lsearch -exact -ascii [concat \
- $defined_BIT $defined_CODE $defined_DATA \
- $defined_IDATA $defined_XDATA $defined_SET \
- $defined_EQU $defined_MACRO $defined_SET_SPEC \
- $defined_EQU_SPEC] $const_name] != -1} {
+ if {
+ [lsearch -exact -ascii [concat \
+ $defined_BIT $defined_CODE $defined_DATA \
+ $defined_IDATA $defined_XDATA $defined_SET \
+ $defined_EQU $defined_MACRO $defined_SET_SPEC \
+ $defined_EQU_SPEC \
+ ${::CompilerConsts::defined_progVectors} \
+ ${::CompilerConsts::defined_SFRBitArea} \
+ ${::CompilerConsts::defined_SFR} \
+ ] $const_name] != -1
+ } then {
return 1
}
return 0
@@ -4021,7 +4176,7 @@ namespace eval PreProcessor {
variable selected_segment ;# Current memory segment (one of {cseg bseg dseg iseg xseg})
variable segment_pointer ;# Current memory segment pointer
- # Change memory segment
+ # Change memory segment
set selected_segment $directive
if {[regsub {^\.} [string tolower $line] {}] == $directive} {
return 0
@@ -4064,12 +4219,17 @@ namespace eval PreProcessor {
} else {
set segment_pointer($selected_segment) $value
CodeListing::set_addr $idx $value
- return 0
+
+ if {$ignore_undefined} {
+ return 2
+ } else {
+ return 0
+ }
}
return 1
}
- ## Take care of conditional compilation control directives (IF, ELSE, ENDIF)
+ ## Take care of conditional compilation control directives (IF, ELSE, ENDIF, IFN, IFDEF, IFNDEF, ELSEIF ELSEIFN ELSEIFDEF ELSEIFNDEF)
# --auxiliary procedure for 'parse_Consts_and_ConditionalCompilation'
# @parm String directive - Directive
# @parm String cond - Expression of the condition
@@ -4078,9 +4238,11 @@ namespace eval PreProcessor {
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable IfElse_map ;# Array: Conditional compilation map ($IfElse_map($level) == $bool)
+ variable IfElse_pcam ;# Array: Conditional compilation -- Positive condition already met ($IfElse_pcam($level) == $bool)
variable IfElse_level ;# Current level of conditional compilation evaluation
variable Enable ;# Bool: Compilation enabled (conditional compilation)
+ set cond_orig $cond
switch -- $directive {
{if} {
# Missing condition expression
@@ -4090,10 +4252,14 @@ namespace eval PreProcessor {
}
# Evaluate the condition expression
- set cond [ComputeExpr $cond]
- if {$cond == {}} {
- SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" $cond]
- set cond 1
+ if {$Enable} {
+ set cond [ComputeExpr $cond]
+ if {$cond == {}} {
+ SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" $cond_orig]
+ set cond 1
+ }
+ } else {
+ set cond 0
}
# Increment counter of nested block level
@@ -4101,6 +4267,7 @@ namespace eval PreProcessor {
# Adjust map of conditional compilation map and flag "Enable"
set IfElse_map($IfElse_level) $cond
+ set IfElse_pcam($IfElse_level) $cond
if {!$Enable || !$cond} {
set Enable 0
}
@@ -4113,9 +4280,13 @@ namespace eval PreProcessor {
}
# Evaluate the condition expression
- set cond [ComputeExpr $cond]
- if {$cond == {}} {
- SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" $cond]
+ if {$Enable} {
+ set cond [ComputeExpr $cond]
+ if {$cond == {}} {
+ SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" $cond_orig]
+ set cond 1
+ }
+ } else {
set cond 1
}
@@ -4127,6 +4298,7 @@ namespace eval PreProcessor {
# Adjust map of conditional compilation map and flag "Enable"
set IfElse_map($IfElse_level) $cond
+ set IfElse_pcam($IfElse_level) $cond
if {!$Enable || !$cond} {
set Enable 0
}
@@ -4142,13 +4314,14 @@ namespace eval PreProcessor {
}
# Evaluate the condition expression
- set cond [isConstAlreadyDefined $cond]
+ set cond [expr {$Enable && [isConstAlreadyDefined $cond]}]
# Increment counter of nested block level
incr IfElse_level
# Adjust map of conditional compilation map and flag "Enable"
set IfElse_map($IfElse_level) $cond
+ set IfElse_pcam($IfElse_level) $cond
if {!$Enable || !$cond} {
set Enable 0
}
@@ -4164,13 +4337,14 @@ namespace eval PreProcessor {
}
# Evaluate the condition expression
- set cond [expr {![isConstAlreadyDefined $cond]}]
+ set cond [expr {$Enable && ![isConstAlreadyDefined $cond]}]
# Increment counter of nested block level
incr IfElse_level
# Adjust map of conditional compilation map and flag "Enable"
set IfElse_map($IfElse_level) $cond
+ set IfElse_pcam($IfElse_level) $cond
if {!$Enable || !$cond} {
set Enable 0
}
@@ -4178,8 +4352,62 @@ namespace eval PreProcessor {
{else} {
if {[llength [array names IfElse_map $IfElse_level]] == 0} {
SyntaxError $lineNum $fileNum [mc "Unexpected `ELSE'"]
- } {
- set IfElse_map($IfElse_level) [expr {!$IfElse_map($IfElse_level)}]
+ } else {
+ set IfElse_map($IfElse_level) [expr {!$IfElse_pcam($IfElse_level)}]
+ set Enable 1
+ for {set i 1} {$i <= $IfElse_level} {incr i} {
+ set Enable [expr {$IfElse_map($i) && $Enable}]
+ }
+ }
+ }
+ {elseifn} -
+ {elseifdef} -
+ {elseifndef} -
+ {elseif} {
+ if {[llength [array names IfElse_map $IfElse_level]] == 0} {
+ SyntaxError $lineNum $fileNum [mc "Unexpected `ELSEIF'"]
+ } else {
+ # Missing condition expression
+ if {![string length $cond]} {
+ SyntaxError $lineNum $fileNum [mc "Missing condition"]
+ set cond 1
+ }
+
+ # Evaluate the condition expression
+ if {
+ !$IfElse_pcam($IfElse_level)
+ &&
+ ($IfElse_level == 1 || $IfElse_map([expr {$IfElse_level - 1}]))
+ } then {
+ switch -- $directive {
+ {elseif} {
+ set cond [ComputeExpr $cond]
+ }
+ {elseifn} {
+ set cond [ComputeExpr $cond]
+ if {$cond != {}} {
+ set cond [expr {!$cond}]
+ }
+ }
+ {elseifdef} {
+ set cond [isConstAlreadyDefined $cond]
+ }
+ {elseifndef} {
+ set cond [expr {![isConstAlreadyDefined $cond]}]
+ }
+ }
+ if {$cond == {}} {
+ SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" $cond_orig]
+ set cond 1
+ }
+ } else {
+ set cond 0
+ }
+
+ if {$cond} {
+ set IfElse_pcam($IfElse_level) 1
+ }
+ set IfElse_map($IfElse_level) $cond
set Enable 1
for {set i 1} {$i <= $IfElse_level} {incr i} {
set Enable [expr {$IfElse_map($i) && $Enable}]
@@ -4197,13 +4425,13 @@ namespace eval PreProcessor {
}
# Invalid directive usage
- } {
+ } else {
incr IfElse_level
SyntaxError $lineNum $fileNum [mc "Unexpected `ENDIF'"]
}
}
default {
- CompilationError $lineNum $fileNum "`$directive' is not a if/else/endif directive (procedure: If_Else_Endif)"
+ CompilationError $lineNum $fileNum "`$directive' is not a if/else/endif/ifn/ifdef/ifndef/elseif directive (procedure: If_Else_Endif)"
}
}
}
@@ -4239,7 +4467,7 @@ namespace eval PreProcessor {
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
- variable ErrorAtLine ;# Bool: Error occured on the current line
+ variable ErrorAtLine ;# Bool: Error occurred on the current line
# Handle directive "FLAG", which has the same meaning as "BIT"
if {$directive == {flag}} {
@@ -4249,7 +4477,7 @@ namespace eval PreProcessor {
# Detrminate 1st field and the last (3rd) field
if {![regexp {^\s*\w+} $line const]} {
set const {} ;# symbolic name
- } {
+ } else {
set const [string tolower [string trim $const]] ;# symbolic name
}
if {![regsub {^\w+\s+\.?\w+\s+} $line {} value]} {
@@ -4266,14 +4494,14 @@ namespace eval PreProcessor {
# Does value field contain comma ?
if {[string first {,} $value] != -1} {
# Is const field an instruction ?
- if {[lsearch -exact -ascii ${CompilerConsts::AllInstructions} $const] != -1} {
+ if {[lsearch -exact -ascii ${::CompilerConsts::AllInstructions} $const] != -1} {
# yes -> skip this line
if {$ignore_undefined} {
return 2
- } {
+ } else {
return 1
}
- } {
+ } else {
# no -> remove line & report syntax error
SyntaxError $lineNum $fileNum [mc "Invalid expression: `%s'" $value]
return 1
@@ -4306,6 +4534,7 @@ namespace eval PreProcessor {
Notice $lineNum $fileNum [mc "Special value (with no numerical representation) assigned to constant: %s <- %s" [string toupper $const] [string toupper $value]]
set special_value 1
} else {
+ set value_orig $value
set value [ComputeExpr $value $ignore_undefined]
}
@@ -4314,14 +4543,14 @@ namespace eval PreProcessor {
if {$ignore_undefined} {
return 2
}
- SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" $value]
+ SyntaxError $lineNum $fileNum [mc "Invalid expression `%s'" $value_orig]
return 1
}
# Adjust code listing
if {$special_value} {
CodeListing::set_spec_value $idx $value
- } {
+ } else {
CodeListing::set_value $idx $value
}
# Define symbolic name
@@ -4360,12 +4589,12 @@ namespace eval PreProcessor {
}
{data} {
if {
- ([lsearch -exact -ascii $defined_IDATA $const] != -1)
- ||
- ([lsearch -exact -ascii $defined_DATA $const] != -1)
- } {
- SyntaxError $lineNum $fileNum [mc "Trying to overwrite constant: %s" $const]
- return 1
+ ([lsearch -exact -ascii $defined_IDATA $const] != -1)
+ ||
+ ([lsearch -exact -ascii $defined_DATA $const] != -1)
+ } then {
+ SyntaxError $lineNum $fileNum [mc "Trying to overwrite constant: %s" $const]
+ return 1
}
if {$value > 0xFF} {
SyntaxError $lineNum $fileNum [mc "Expression out of range"]
@@ -4381,12 +4610,12 @@ namespace eval PreProcessor {
}
{idata} {
if {
- ([lsearch -exact -ascii $defined_IDATA $const] != -1)
- ||
- ([lsearch -exact -ascii $defined_DATA $const] != -1)
- } {
- SyntaxError $lineNum $fileNum [mc "Trying to overwrite constant: %s" $const]
- return 1
+ ([lsearch -exact -ascii $defined_IDATA $const] != -1)
+ ||
+ ([lsearch -exact -ascii $defined_DATA $const] != -1)
+ } then {
+ SyntaxError $lineNum $fileNum [mc "Trying to overwrite constant: %s" $const]
+ return 1
}
if {$value > 0xFF} {
SyntaxError $lineNum $fileNum [mc "Expression out of range"]
@@ -4426,7 +4655,7 @@ namespace eval PreProcessor {
set idx [lsearch -exact -ascii $defined_SET $const]
if {$idx != -1} {
set defined_SET [lreplace $defined_SET $idx $idx]
- } {
+ } else {
set idx [lsearch -exact -ascii $defined_SET_SPEC $const]
if {$idx != -1} {
set defined_SET_SPEC [lreplace $defined_SET_SPEC $idx $idx]
@@ -4440,7 +4669,7 @@ namespace eval PreProcessor {
if {$special_value} {
set const_EQU_SPEC($const) [string tolower $value]
lappend defined_EQU_SPEC $const
- } {
+ } else {
set const_EQU($const) $value
lappend defined_EQU $const
}
@@ -4483,19 +4712,19 @@ namespace eval PreProcessor {
# Set (new) variable value
if {[lsearch -exact -ascii $defined_SET $const] != -1} {
Notice $lineNum $fileNum [mc "Setting new variable value: %s <- %s" $const $value]
- } {
+ } else {
if {[isConstAlreadyDefined $const]} {
Warning $lineNum $fileNum [mc "Ambiguous symbol definition: %s" $const]
}
if {$special_value} {
lappend defined_SET_SPEC $const
- } {
+ } else {
lappend defined_SET $const
}
}
if {$special_value} {
lappend const_SET_SPEC($const) [list $lineNum $value]
- } {
+ } else {
lappend const_SET($const) [list $lineNum $value]
}
return 0
@@ -4511,18 +4740,19 @@ namespace eval PreProcessor {
if {
([lsearch -exact -ascii $defined_SET $const] != -1) ||
([lsearch -exact -ascii $defined_EQU $const] != -1)
- } {
+ } then {
return 1
- } {
+ } else {
return 0
}
}
## Get constant/variable value
- # @parm list args - {const_name [lineNumber]}
- # @parm Bool special_value = 0 - Allow special values like (A, AB, R0, etc.)
+ # @parm String const - const_name
+ # @parm Int line={} -lineNumber
+ # @parm Bool special_value=0 - Allow special values like (A, AB, R0, etc.)
# @return mixed - value or emty string if nothing found
- proc const_value args {
+ proc const_value {const {line {}} {special_value 0}} {
variable defined_SET ;# List of variables defined by 'SET'
variable defined_EQU ;# List of constants defined by 'EQU'
variable const_SET ;# Array: Constants defined by directive 'CODE'
@@ -4533,16 +4763,6 @@ namespace eval PreProcessor {
variable defined_SET_SPEC ;# List of special variables defined by 'SET'
variable defined_EQU_SPEC ;# List of special constants defined by 'EQU'
-
- # Determinate name of the constant and line number
- set const [lindex $args 0]
- set line [lindex $args 1]
-
- set special_value [lindex $args 2]
- if {$special_value != 1} {
- set special_value 0
- }
-
# Constants defined by directive 'EQU'
if {[lsearch -exact -ascii $defined_EQU $const] != -1} {
return $const_EQU($const)
@@ -4585,18 +4805,18 @@ namespace eval PreProcessor {
}
## Compute value of the given expression
- # @parm String - Expression to evaluate
- # @parm Bool = 0 - Ignore undefined symbolic names
- # @parm Int = {} - Current instruction address (for `$' expansion)
+ # @parm String expression - Expression to evaluate
+ # @parm Bool ignore_undefined=0 - Ignore undefined symbolic names
+ # @parm Int address={} - Current instruction address (for `$' expansion)
# @return Int - result or {}
- proc ComputeExpr args {
+ proc ComputeExpr {expression {ignore_undefined 0} {address {}}} {
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable original_expression ;# Auxiliary variable (see proc. 'ComputeExpr')
variable tmp ;# General purpose tempotary variable
- variable ErrorAtLine ;# Bool: Error occured on the current line
+ variable ErrorAtLine ;# Bool: Error occurred on the current line
variable check_sfr_usage ;# Bool: Check for legal usage of SFR and SFB
- variable avaliable_SFR ;# List: Avaliable SFR and SFB on the target MCU
+ variable available_SFR ;# List: available SFR and SFB on the target MCU
variable const_BIT ;# Array: Bit values -- ($const_BIT($bit_name) == $value)
variable const_CODE ;# Array: Constants defined by directive 'CODE'
@@ -4617,15 +4837,11 @@ namespace eval PreProcessor {
variable labels ;# Array: Values of defined labels ($labels($label) == $address)
variable defined_LABEL ;# List of defined labels
+ variable selected_segment ;# Current memory segment (one of {cseg bseg dseg iseg xseg})
+ variable segment_pointer ;# Current memory segment pointer
+
set ErrorAtLine 0
- # Parse arguments
- set expression [lindex $args 0]
- set ignore_undefined [lindex $args 1]
- set address [lindex $args 2]
- if {$ignore_undefined == {}} {
- set ignore_undefined 0
- }
# Make backup copy of the original expression
set original_expression $expression
@@ -4639,7 +4855,7 @@ namespace eval PreProcessor {
if {[regexp {[\(\)]} $expression]} {
set left_p 0
set idx 0
- while 1 {
+ while {1} {
set idx [string first {(} $expression $idx]
if {$idx == -1} {break}
incr idx
@@ -4647,7 +4863,7 @@ namespace eval PreProcessor {
}
set right_p 0
set idx 0
- while 1 {
+ while {1} {
set idx [string first {)} $expression $idx]
if {$idx == -1} {break}
incr idx
@@ -4655,7 +4871,7 @@ namespace eval PreProcessor {
}
if {$right_p != $left_p} {
- SyntaxError $lineNum $fileNum [mc "Invalid expression - paranthesis are not balanced: `%s'" $original_expression]
+ SyntaxError $lineNum $fileNum [mc "Invalid expression - parentheses are not balanced: `%s'" $original_expression]
}
}
@@ -4678,12 +4894,12 @@ namespace eval PreProcessor {
([string first {low} [string tolower $expression]] != -1)
||
([string first {high} [string tolower $expression]] != -1)
- } {
- foreach operator {low high} \
- before {0xFF&int( int(} \
+ } then {
+ foreach operator {low high} \
+ before {0xFF&int( int(} \
after {) )/0x100} \
{
- while 1 {
+ while {1} {
if {![regexp -nocase -- "\\s$operator\\s+((\\w+)|(\\(\[^\\(\\)\]+\\)))" $expression str]} {
break
}
@@ -4709,6 +4925,21 @@ namespace eval PreProcessor {
foreach word [replace_in_strings $expression { } "\a"] {
if {$word == {}} {continue}
+ # Handle prefix notation for hexadecimal numbers, like 0xfa
+ if {
+ [string index $word 0] == {0}
+ &&
+ ([string index $word 1] == {x} || [string index $word 1] == {X})
+ &&
+ [string is xdigit [string index $word 2]]
+ } then {
+ set word [string replace $word 0 1]
+ if {![string is digit [string index $word 0]]} {
+ set word "0${word}"
+ }
+ append word {h}
+ }
+
if {[regexp {^\d\w+$} $word] && ![regexp {^\d+$} $word]} {
set base [string index $word end]
set word [string range $word 0 {end-1}]
@@ -4722,37 +4953,37 @@ namespace eval PreProcessor {
{h} {
if {![NumSystem::ishex $word]} {
SyntaxError $lineNum $fileNum [mc "Invalid numeric value: %s (should be hexadecimal number)" "${word}h"]
- } {
+ } else {
set word [expr "0x$word"]
}
}
{b} {
if {![NumSystem::isbin $word]} {
SyntaxError $lineNum $fileNum [mc "Invalid numeric value: %s (should be binary number)" "${word}b"]
- } {
+ } else {
set word [NumSystem::bin2dec $word]
}
}
{o} {
if {![NumSystem::isoct $word]} {
SyntaxError $lineNum $fileNum [mc "Invalid numeric value: %s (should be octal number)" "${word}o"]
- } {
+ } else {
set word [NumSystem::oct2dec $word]
}
}
{q} {
if {![NumSystem::isoct $word]} {
SyntaxError $lineNum $fileNum [mc "Invalid numeric value: %s (should be octal number)" "${word}q"]
- } {
+ } else {
set word [NumSystem::oct2dec $word]
}
}
}
- } {
+ } else {
if {[string index $word end] == {'}} {
if {[string index $word 0] != {'}} {
SyntaxError $lineNum $fileNum [mc "Invalid value: `%s' (should be char)" $word]
- } {
+ } else {
set word [string range $word 1 end-1]
regsub -all "\a" $word { } word
set word [character2number [subst -nocommands -novariables $word]]
@@ -4767,15 +4998,29 @@ namespace eval PreProcessor {
# Expand possible constants and variables
foreach word $expression {
if {$word == {}} {continue}
- # Current instruction address `$'
- if {$address != {} && $word == {$}} {
- set word $address
+ # Dollar sign (`$')
+ if {$word == {$}} {
+ # Current instruction address
+ if {$address != {}} {
+ set word $address
+ # Address pointer in the selected memory segment
+ } elseif {$selected_segment != {cseg}} {
+ set word $segment_pointer($selected_segment)
+ } elseif {!$ignore_undefined} {
+ SyntaxError $lineNum $fileNum [mc "Value of `\$' is unknown at this point" $word]
+ set ErrorAtLine 1
+ }
+
lappend tmp $word
continue
}
# Normal symbolic name
- if {![regexp {^[A-Za-z_].*$} $word]} {
+ if {![regexp {^(\?\?)?[A-Za-z_].*$} $word]} {
+ set word [string trimleft $word 0]
+ if {$word == {}} {
+ set word 0
+ }
lappend tmp $word
continue
}
@@ -4792,9 +5037,9 @@ namespace eval PreProcessor {
if {
[lsearch -ascii -exact $::CompilerConsts::defined_SFR $word] != -1
&&
- [lsearch -ascii -exact $avaliable_SFR $word] == -1
- } {
- Warning $lineNum $fileNum [mc "Special function register \"%s\" is not avaliable on the target MCU" [string toupper $word]]
+ [lsearch -ascii -exact $available_SFR $word] == -1
+ } then {
+ Warning $lineNum $fileNum [mc "Special function register \"%s\" is not available on the target MCU" [string toupper $word]]
}
}
set word $const_DATA($word)
@@ -4820,9 +5065,9 @@ namespace eval PreProcessor {
if {
[lsearch -ascii -exact $::CompilerConsts::defined_SFRBitArea $word] != -1
&&
- [lsearch -ascii -exact $avaliable_SFR $word] == -1
- } {
- Warning $lineNum $fileNum [mc "Special function bit \"%s\" is not avaliable on the target MCU" [string toupper $word]]
+ [lsearch -ascii -exact $available_SFR $word] == -1
+ } then {
+ Warning $lineNum $fileNum [mc "Special function bit \"%s\" is not available on the target MCU" [string toupper $word]]
}
}
CodeListing::symbol_used $word {bit}
@@ -4839,6 +5084,7 @@ namespace eval PreProcessor {
return {}
}
SyntaxError $lineNum $fileNum [mc "Undefined symbol name: %s" $word]
+ set ErrorAtLine 1
set word 1
}
@@ -4853,11 +5099,15 @@ namespace eval PreProcessor {
# Compute expression and return possible result
if {[catch {
set expression [expr "$expression"]
- }]} {
+ }]} then {
return {}
}
- set tmp [expr {int($expression)}]
+ if {[catch {
+ set tmp [expr {int($expression)}]
+ }]} then {
+ return {}
+ }
if {($tmp - $expression) != 0} {
Notice $lineNum $fileNum [mc "Floating point value converted to integer value `%s' -> `%s'" $expression $tmp]
}
@@ -4880,8 +5130,8 @@ namespace eval PreProcessor {
## Remove comments and redutant white space
# @return void
proc trim_code {} {
- variable asm ;# Resulting precompiled code
- variable tmp_asm ;# Tempotary auxiliary precompiled code
+ variable asm ;# Resulting pre-compiled code
+ variable tmp_asm ;# Temporary auxiliary pre-compiled code
variable lineNum ;# Number of the current line
variable fileNum ;# Number of the current file
variable idx ;# Current position in asm list
@@ -4896,7 +5146,9 @@ namespace eval PreProcessor {
incr idx
# Update after each 25 iterations
- if {[expr {$idx % 25}] == 0} ${::Compiler::Settings::UPDATE_COMMAND}
+ if {[expr {$idx % 25}] == 0} {
+ ${::Compiler::Settings::UPDATE_COMMAND}
+ }
if {${::Compiler::Settings::ABORT_VARIABLE}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} [mc "Aborted"]
free_resources
@@ -4917,10 +5169,10 @@ namespace eval PreProcessor {
# Remove comment
set tmp_line $line
- while 1 {
+ while {1} {
if {[regexp {'[^']*'} $tmp_line str]} {
regsub {'[^']*'} $tmp_line [string repeat {_} [string length $str]] tmp_line
- } {
+ } else {
break
}
}
@@ -4954,7 +5206,7 @@ namespace eval PreProcessor {
# @return String - result
proc replace_in_strings {string search replacement} {
set idx 0
- while 1 {
+ while {1} {
if {![regexp -start $idx -- {'[^']*'} $string str]} {
break
}
@@ -4980,7 +5232,7 @@ namespace eval PreProcessor {
if {[string length $value] == 1} {
binary scan $value c value
return $value
- } {
+ } else {
if {[string index $value 0] == "\\"} {
set value [string range $value 1 end]
switch -- $value {
@@ -5016,7 +5268,7 @@ namespace eval PreProcessor {
return {}
}
}
- } {
+ } else {
SyntaxError $lineNum $fileNum [mc "Cannot to use string `%s' as value" $value]
return {}
}
@@ -5024,15 +5276,15 @@ namespace eval PreProcessor {
}
## Report error message -- compilation error (bug in compiler ?)
- # @parm Int LineNumber - Number of line where the error occured
- # @parm Int FileNumber - Number of file where the error occured, {} == unknown
+ # @parm Int LineNumber - Number of line where the error occurred
+ # @parm Int FileNumber - Number of file where the error occurred, {} == unknown
# @parm String ErrorInfo - Error string
# @return void
proc CompilationError {LineNumber FileNumber ErrorInfo} {
variable included_files ;# List: Unique unsorted list of included files
variable working_dir ;# String: Current working directory
variable idx ;# Current position in asm list
- variable error_count ;# Number of errors occured
+ variable error_count ;# Number of errors occurred
# Increment error counter
incr error_count
@@ -5050,14 +5302,14 @@ namespace eval PreProcessor {
set filename "\"$filename\""
}
set filename [mc " in %s" $filename]
- } {
+ } else {
set filename {}
}
if {${::Compiler::Settings::WARNING_LEVEL} < 3} {
if {${::Compiler::Settings::NOCOLOR}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EL}][mc "Compilation error at %s: %s" "$LineNumber$filename" $ErrorInfo]
- } {
+ } else {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[31;1mCompilation error\033\[m at \033\[31;1;4m%s\033\[m%s: %s" $LineNumber $filename $ErrorInfo]
}
@@ -5065,8 +5317,8 @@ namespace eval PreProcessor {
}
## Report notice
- # @parm Int LineNumber - Number of line where it occured
- # @parm Int FileNumber - Number of file where the error occured, {} == unknown
+ # @parm Int LineNumber - Number of line where it occurred
+ # @parm Int FileNumber - Number of file where the error occurred, {} == unknown
# @parm String ErrorInfo - Text of the notice
# @return void
proc Notice {LineNumber FileNumber ErrorInfo} {
@@ -5082,14 +5334,14 @@ namespace eval PreProcessor {
set filename "\"$filename\""
}
set filename [mc " in %s" $filename]
- } {
+ } else {
set filename {}
}
if {${::Compiler::Settings::WARNING_LEVEL} < 1} {
if {${::Compiler::Settings::NOCOLOR}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {WL}][mc "Notice at %s: %s" "$LineNumber$filename" $ErrorInfo]
- } {
+ } else {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[33;1mNotice\033\[m at \033\[33;1;4m%s\033\[m%s: %s" $LineNumber $filename $ErrorInfo]
}
@@ -5097,15 +5349,15 @@ namespace eval PreProcessor {
}
## Report warning message
- # @parm Int LineNumber - Number of line where it occured
- # @parm Int FileNumber - Number of file where the error occured, {} == unknown
+ # @parm Int LineNumber - Number of line where it occurred
+ # @parm Int FileNumber - Number of file where the error occurred, {} == unknown
# @parm String ErrorInfo - Text of the warning
# @return void
proc Warning {LineNumber FileNumber ErrorInfo} {
variable working_dir ;# String: Current working directory
variable included_files ;# List: Unique unsorted list of included files
variable idx ;# Current position in asm list
- variable warning_count ;# Number of warnings occured
+ variable warning_count ;# Number of warnings occurred
# Increment warning counter
incr warning_count
@@ -5123,32 +5375,32 @@ namespace eval PreProcessor {
set filename "\"$filename\""
}
set filename [mc " in %s" $filename]
- } {
+ } else {
set filename {}
}
if {${::Compiler::Settings::WARNING_LEVEL} < 2} {
if {${::Compiler::Settings::NOCOLOR}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {WL}][mc "Warning at %s: %s" "$LineNumber$filename" $ErrorInfo]
- } {
+ } else {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[33mWarning\033\[m at \033\[33;4m%s\033\[m%s: %s" $LineNumber $filename $ErrorInfo]
}
}
}
- ## Report error message -- syntax error (badly formated input code)
- # @parm Int LineNumber - Number of line where the error occured
- # @parm Int FileNumber - Number of file where the error occured, {} == unknown
+ ## Report error message -- syntax error (badly formatted input code)
+ # @parm Int LineNumber - Number of line where the error occurred
+ # @parm Int FileNumber - Number of file where the error occurred, {} == unknown
# @parm String ErrorInfo - Error string
# @return void
proc SyntaxError {LineNumber FileNumber ErrorInfo} {
variable working_dir ;# String: Current working directory
variable included_files ;# List: Unique unsorted list of included files
variable idx ;# Current position in asm list
- variable error_count ;# Number of errors occured
- variable ErrorAtLine ;# Bool: Error occured on the current line
- variable Error ;# Bool: An error occured during precompilation
+ variable error_count ;# Number of errors occurred
+ variable ErrorAtLine ;# Bool: Error occurred on the current line
+ variable Error ;# Bool: An error occurred during precompilation
# Adjust NS variable
incr error_count
@@ -5168,17 +5420,21 @@ namespace eval PreProcessor {
set filename "\"$filename\""
}
set filename [mc " in %s" $filename]
- } {
+ } else {
set filename {}
}
if {${::Compiler::Settings::WARNING_LEVEL} < 3} {
if {${::Compiler::Settings::NOCOLOR}} {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[::Compiler::msgc {EL}][mc "Syntax error at %s: %s" "$LineNumber$filename" $ErrorInfo]
- } {
+ } else {
${::Compiler::Settings::TEXT_OUPUT_COMMAND} \
[mc "\033\[31;1mSyntax error\033\[m at \033\[31;1;4m%s\033\[m%s: %s" $LineNumber $filename $ErrorInfo]
}
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/global_config.tcl b/lib/configdialogs/global_config.tcl
deleted file mode 100755
index a5a422b..0000000
--- a/lib/configdialogs/global_config.tcl
+++ /dev/null
@@ -1,318 +0,0 @@
-#!/usr/bin/tclsh
-# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
-
-############################################################################
-# Copyright (C) 2007-2009 by Martin Ošmera #
-# martin.osmera@gmail.com #
-# #
-# This program is free software; you can redistribute it and#or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation; either version 2 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program; if not, write to the #
-# Free Software Foundation, Inc., #
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
-############################################################################
-
-# --------------------------------------------------------------------------
-# DESCRIPTION
-# Implements global configuration dialog
-# --------------------------------------------------------------------------
-
-
-## Global configuration dialog
- # see Array OPTION in root NS
-namespace eval global {
-
- variable dialog_opened 0 ;# Bool: True if this dialog is already opened
- variable win ;# ID of dialog toplevel window
-
- variable avaliable_languages ;# List of avaliable languages
-
- ## Configuration variables
- variable show_splash ;# Bool: Show splash creen on startup
- variable show_tips ;# Bool: Show tips on startup
- variable language ;# String: Language
-
- ## Create the dialog
- # @return void
- proc mkDialog {} {
- variable win ;# ID of toplevel dialog window
- variable dialog_opened ;# Bool: True if this dialog is already opened
- variable avaliable_languages ;# List of avaliable languages
-
- # Destroy the dialog if it's alredy opened
- if {$dialog_opened} {
- destroy .global_config_dialog
- }
- set dialog_opened 1
-
- # Get settings from main NS
- getSettings
-
- # Determinate avaliable languages
- get_languages
-
- # Create toplevel window
- set win [toplevel .global_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
-
- # Create window header
- label $win.header_label \
- -compound left \
- -image ::ICONS::32::kcmmemory \
- -text [mc "MCU 8051 IDE configuration"] \
- -font [font create -size -20]
-
- # Create horizontal separator
- Separator $win.sep -orient horizontal
-
- ## Create middle frame
- set middle_frame [frame $win.middle_frame]
- # Checkbutton "Display splash screen"
- grid [Label $middle_frame.lbl_splash \
- -text [mc "Display splash screen"] \
- -helptext [mc "Show splash screen on startup"] \
- ] -row 0 -column 0 -sticky w
- grid [checkbutton $middle_frame.chb_splash \
- -variable ::configDialogs::global::show_splash \
- ] -row 0 -column 1 -sticky w
- DynamicHelp::add $middle_frame.chb_splash \
- -text [mc "Show splash screen on startup"]
- # Checkbutton "Show tips on startup"
- grid [Label $middle_frame.lbl_tips \
- -text [mc "Show tips on startup"] \
- -helptext [mc "Invoke dialog with tip of the day on startup"] \
- ] -row 1 -column 0 -sticky w
- grid [checkbutton $middle_frame.chb_tips \
- -variable ::configDialogs::global::show_tips \
- ] -row 1 -column 1 -sticky w
- DynamicHelp::add $middle_frame.chb_tips \
- -text [mc "Invoke dialog with tip of the day on startup"]
- # Combo "Language"
- grid [Label $middle_frame.lbl_lang \
- -text [mc "Language"] \
- -helptext [mc "Your preferred language"] \
- ] -row 2 -column 0 -sticky w
- grid [ttk::combobox $middle_frame.cb_lang \
- -values $avaliable_languages \
- -state readonly \
- -textvariable ::configDialogs::global::language \
- ] -row 2 -column 1 -sticky w
- bind $middle_frame.cb_lang <<ComboboxSelected>> \
- {::configDialogs::global::language_changed}
- DynamicHelp::add $middle_frame.cb_lang \
- -text [mc "Your preferred language"]
- # Separator
- grid [ttk::separator $middle_frame.sep -orient horizontal] -columnspan 2 -sticky we -row 3 -column 0 -pady 5
- # Checkbutton "Do not ask whether ..."
- grid [text $middle_frame.lbl_ask \
- -wrap word -height 4 -width 0 -bg {#EEEEEE} -bd 0 \
- ] -row 4 -column 0 -sticky we
- $middle_frame.lbl_ask insert end [mc "Do not always ask whether to add file to the project after the file is opened"]
- $middle_frame.lbl_ask configure -state disabled
- grid [checkbutton $middle_frame.cb_ask \
- -onvalue 0 -offvalue 1 \
- -variable ::FileList::ask__append_file_to_project \
- ] -row 4 -column 1 -sticky w
-
- # Finalize
- grid columnconfigure $middle_frame 0 -minsize 200
-
- ## Button frame at the bottom
- set but_frame [frame $win.button_frame]
- # Button "Reset"
- pack [ttk::button $but_frame.but_default \
- -text [mc "Reset to defaults"] \
- -command {::configDialogs::global::DEFAULTS} \
- ] -side left
- DynamicHelp::add $but_frame.but_default \
- -text [mc "Reset all settings to defaults"]
- # Button "Ok"
- pack [ttk::button $but_frame.but_ok \
- -text [mc "Ok"] \
- -compound left \
- -image ::ICONS::16::ok \
- -command {::configDialogs::global::OK} \
- ] -side right
- DynamicHelp::add $but_frame.but_ok \
- -text [mc "Commit new settings"]
- # Button "Cancel"
- pack [ttk::button $but_frame.but_cancel \
- -text [mc "Cancel"] \
- -compound left \
- -image ::ICONS::16::button_cancel \
- -command {::configDialogs::global::CANCEL} \
- ] -side right
- DynamicHelp::add $but_frame.but_cancel \
- -text [mc "Take changes back and close dialog"]
-
- # Pack frames and notebook
- pack $win.header_label -side top -pady 6
- pack $win.sep -side top -fill x -after $win.header_label
- pack $middle_frame -side top -padx 10 -anchor nw -pady 10
- pack $but_frame -side bottom -fill x -expand 1 -anchor s -padx 10 -pady 5
-
- # Set window attributes
- wm iconphoto $win ::ICONS::16::configure
- wm transient $win .
- wm title $win [mc "Configure MCU 8051 IDE"]
- wm minsize $win 380 250
- raise $win
- catch {grab $win}
- wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::global::CANCEL
- }
- tkwait window $win
- }
-
- ## Application language changed
- # Takes any set of arguments and discards them
- # @parm List - meaningless
- # @return void
- proc language_changed args {
- tk_messageBox \
- -parent .global_config_dialog \
- -type ok -icon info \
- -title [mc "Application language changed"] \
- -message [mc "Language for this application has been changed. The change will take effect upon next start of application"]
- }
-
- ## Retrieve list of avaliable translations
- # @return void
- proc get_languages {} {
- variable avaliable_languages ;# List of avaliable languages
-
- set avaliable_languages {en}
- set tmp [list]
- catch { ;# For Microsoft Windows it has to be enclosed by catch
- set tmp [glob -nocomplain -types f -tails \
- -directory "${::LIB_DIRNAME}/../translations" *.msg \
- ]
- }
-
- foreach translation $tmp {
- lappend avaliable_languages [file rootname $translation]
- }
- }
-
- ## Set configuration variable
- # @parm String variable - variable to set
- # @parm Mixed value - new value
- proc set_variable {variable value} {
- variable show_splash ;# Bool: Show splash creen on startup
- variable show_tips ;# Bool: Show tips on startup
- variable language ;# String: Language
-
- getSettings
-
- switch -- $variable {
- {splash} {
- set show_splash $value
- }
- {tips} {
- set show_tips $value
- }
- {language} {
- set language $value
- }
- }
-
- use_settings
- save_config
- }
-
- ## Retrieve settings from main NS
- # @return void
- proc getSettings {} {
- variable show_splash ;# Bool: Show splash creen on startup
- variable show_tips ;# Bool: Show tips on startup
- variable language ;# String: Language
-
- set show_splash ${::GLOBAL_CONFIG(splash)}
- set show_tips ${::GLOBAL_CONFIG(tips)}
- set language ${::GLOBAL_CONFIG(language)}
- }
-
- ## Set application acording to local settings
- # @return void
- proc use_settings {} {
- variable show_splash ;# Bool: Show splash creen on startup
- variable show_tips ;# Bool: Show tips on startup
- variable language ;# String: Language
-
- if {${::GLOBAL_CONFIG(language)} != $language} {
- set lang_changed 1
- } {
- set lang_changed 0
- }
-
- set ::GLOBAL_CONFIG(splash) $show_splash
- set ::GLOBAL_CONFIG(tips) $show_tips
- set ::GLOBAL_CONFIG(language) $language
-
- if {$lang_changed} {
- ::X::switch_language
- }
- }
-
- ## Save settings to the config file
- # @return void
- proc save_config {} {
- variable show_splash ;# Bool: Show splash creen on startup
- variable show_tips ;# Bool: Show tips on startup
- variable language ;# String: Language
-
- if {[catch {
- set conf_file [open "${::CONFIG_DIR}/base.conf" w]
- puts -nonewline $conf_file \
- [list $show_splash $show_tips $language]
- close $conf_file
- }]} {
- puts stderr [mc "Unable to write to base configuration file"]
- }
- }
-
- ## Destroy the dialog
- # @return void
- proc CANCEL {} {
- variable win ;# ID of toplevel dialog window
- variable dialog_opened ;# Bool: True if this dialog is already opened
-
- # Destroy dialog window
- set dialog_opened 0
- grab release $win
- destroy $win
- }
-
- ## Use settings and destroy the dialog
- # @return void
- proc OK {} {
- variable win ;# ID of toplevel dialog window
-
- # Use and save settings
- use_settings
- save_config
-
- # Destroy dialog window
- CANCEL
- }
-
- ## Restrore defaults
- # @return void
- proc DEFAULTS {} {
- variable show_splash ;# Bool: Show splash creen on startup
- variable show_tips ;# Bool: Show tips on startup
- variable language ;# String: Language
-
- set show_splash 1
- set show_tips 1
- set language {en}
- }
-}
diff --git a/lib/configdialogs/compiler_config.tcl b/lib/configdialogues/compiler_config.tcl
index 87df5e7..2f261ea 100755..100644
--- a/lib/configdialogs/compiler_config.tcl
+++ b/lib/configdialogues/compiler_config.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 _COMPILER_CONFIG_TCL ] } {
+set _COMPILER_CONFIG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements compilers configuration dialog
@@ -67,7 +72,7 @@ namespace eval compiler {
variable option_CREATE_BIN_FILE ;# Generate binary object code
variable option_QUIET ;# Verbose
variable opt_WARNING_LEVEL ;# Warning level
- variable option_optim_ena ;# Enable optimalizations
+ variable option_optim_ena ;# Enable optimization
variable max_ihex_rec_length ;# Int: Maximum length of IHEX-8 record
variable primary_tab_asm ;# Widget: Tab "Assembly language"
@@ -88,7 +93,7 @@ namespace eval compiler {
variable as31_custom_opts_text ;# Widget: Text widget "Custom options for AS31"
# External assembler configuration
- variable selected_assembler ;# Int: Preffered assembler (0==MCU8051IDE;1==ASEM-51;2==ASL;3==AS31)
+ variable selected_assembler ;# Int: Preferred assembler (0==MCU8051IDE;1==ASEM-51;2==ASL;3==AS31)
variable assembler_ASEM51_config;# Array: ASEM-51 configuration
variable assembler_ASEM51_addcfg;# Array: ASEM-51 additional configuration
variable assembler_ASL_config ;# Array: ASL configuration
@@ -102,6 +107,8 @@ namespace eval compiler {
variable sdcc_opt_str_opt ;# Array: SDCC configuration
variable sdcc_scs_str_opt ;# Array: SDCC configuration
+ # GNU Make utility configuration
+ variable makeutil_config ;# Array: Make utility configuration
## Create the dialog
# @return void
@@ -112,6 +119,7 @@ namespace eval compiler {
variable primary_tab_asm ;# Widget: Tab "MAIN/Assembly language"
variable primary_tab_c ;# Widget: Tab "MAIN/C language"
+ variable primary_tab_make ;# Widget: Tab "MAIN/GNU make"
variable assembler_tab_compiler ;# Widget: Tab "Assembly language/Compiler"
variable assembler_tab_M8I ;# Widget: Tab "MCU8051IDE"
variable assembler_tab_ASEM51 ;# Widget: Tab "ASEM-51"
@@ -129,7 +137,7 @@ namespace eval compiler {
set as31_custom_opts_text {}
- # Destroy the dialog if it's alredy opened
+ # Destroy the dialog if it's already opened
if {$dialog_opened} {
destroy .compiler_config_dialog
}
@@ -149,101 +157,66 @@ namespace eval compiler {
getSettings
# Create toplevel window
- set win [toplevel .compiler_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
+ set win [toplevel .compiler_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
-compound left \
-image ::ICONS::32::exec \
-text [mc "Compiler configuration"] \
- -font [font create \
- -size -20]
+ -font [font create \
+ -size [expr {int(-20 * $::font_size_factor)}] \
+ ]
# Create primary notebook and its tabs
- set primaryNB [ttk::notebook $win.nb]
- set ::configDialogs::compiler::create_C_tab__already_done 0
- bind $primaryNB <<NotebookTabChanged>> {after idle {
- set tab_index [%W index [%W select]]
-
- if {!$::MICROSOFT_WINDOWS} {
- if {!${::configDialogs::compiler::create_C_tab__already_done}} {
- set ::configDialogs::compiler::create_C_tab__already_done 1
- ::configDialogs::compiler::create_C_tab
- }
- }
- }}
+ set primaryNB [ModernNoteBook $win.nb_p]
- set primary_tab_asm [frame $primaryNB.primary_tab_asm]
- $primaryNB add $primary_tab_asm \
- -text [mc "Assembly language"] \
- -image ::ICONS::16::asm \
- -compound left
+ # Tab: Assembly language
+ set primary_tab_asm [$primaryNB insert end primary_tab_asm \
+ -text [mc "Assembly language"] \
+ -image ::ICONS::16::asm \
+ ]
+
+ # Tab: C language -- SDCC
+ set primary_tab_c [$primaryNB insert end primary_tab_c \
+ -text [mc "C language -- SDCC"] \
+ -image ::ICONS::16::source_c \
+ -createcmd {::configDialogues::compiler::create_C_tab} \
+ ]
if {!$::MICROSOFT_WINDOWS} {
- set primary_tab_c [frame $primaryNB.primary_tab_c]
- $primaryNB add $primary_tab_c \
- -text [mc "C language -- SDCC"] \
- -image ::ICONS::16::source_c \
- -compound left
+ # Tab: GNU make utility
+ set primary_tab_make [$primaryNB insert end primary_tab_make \
+ -text [mc "GNU make utility"] \
+ -image ::ICONS::16::text_x_makefile \
+ -createcmd {::configDialogues::compiler::create_make_tab} \
+ ]
}
# Create notebook "Assembly language" and its pages
- set secondaryNB [ttk::notebook $primary_tab_asm.secondaryNB]
- set ::configDialogs::compiler::secondaryNB__tabs_created [list]
- if {!$::MICROSOFT_WINDOWS} { ;# There is no support for external assembler on Microsoft Windows
- bind $secondaryNB <<NotebookTabChanged>> {after idle {
- set tab_index [%W index [%W select]]
- if {[lsearch ${::configDialogs::compiler::secondaryNB__tabs_created} $tab_index] == -1} {
- lappend ::configDialogs::compiler::secondaryNB__tabs_created $tab_index
- switch -- $tab_index {
- 0 {::configDialogs::compiler::create_compiler_tab}
- 1 {::configDialogs::compiler::create_asm_tab}
- 2 {::configDialogs::compiler::create_ASEM51_tab}
- 3 {::configDialogs::compiler::create_ASL_tab}
- 4 {::configDialogs::compiler::create_AS31_tab}
- }
- }
- }}
- }
-
- if {!$::MICROSOFT_WINDOWS} { ;# There is no support for external assembler on Microsoft Windows
- set assembler_tab_compiler [frame $secondaryNB.assembler_tab_compiler]
- $secondaryNB add $assembler_tab_compiler\
- -text [mc "Compiler"]
+ set secondaryNB [ModernNoteBook $primary_tab_asm.secondaryNB]
+
+ set assembler_tab_compiler [$secondaryNB insert end assembler_tab_compiler -text [mc "Assembler"] -createcmd {::configDialogues::compiler::create_compiler_tab}]
+ set assembler_tab_M8I [$secondaryNB insert end assembler_tab_M8I -text "MCU8051IDE" -createcmd {::configDialogues::compiler::create_asm_tab}]
+ set assembler_tab_ASEM51 [$secondaryNB insert end assembler_tab_ASEM51 -text "ASEM-51" -createcmd {::configDialogues::compiler::create_ASEM51_tab}]
+ if {!$::MICROSOFT_WINDOWS} { ;# There is no support for these external assemblers on Microsoft Windows
+ set assembler_tab_ASL [$secondaryNB insert end assembler_tab_ASL -text "ASL" -createcmd {::configDialogues::compiler::create_ASL_tab}]
+ set assembler_tab_AS31 [$secondaryNB insert end assembler_tab_AS31 -text "AS31" -createcmd {::configDialogues::compiler::create_AS31_tab}]
}
- set assembler_tab_M8I [frame $secondaryNB.assembler_tab_M8I]
- $secondaryNB add $assembler_tab_M8I \
- -text "MCU8051IDE"
- if {!$::MICROSOFT_WINDOWS} { ;# There is no support for external assembler on Microsoft Windows
- set assembler_tab_ASEM51 [frame $secondaryNB.assembler_tab_ASEM51]
- $secondaryNB add $assembler_tab_ASEM51 \
- -text "ASEM-51"
- set assembler_tab_ASL [frame $secondaryNB.assembler_tab_ASL]
- $secondaryNB add $assembler_tab_ASL \
- -text "ASL"
- set assembler_tab_AS31 [frame $secondaryNB.assembler_tab_AS31]
- $secondaryNB add $assembler_tab_AS31 \
- -text "AS31"
- }
- pack $secondaryNB -fill both -expand 1
+ pack [$secondaryNB get_nb] -fill both -expand 1
# Raise pages in notebooks
- $primaryNB select $primary_tab_asm
- if {!$::MICROSOFT_WINDOWS} { ;# There is no support for external assembler on Microsoft Windows
- $secondaryNB select $assembler_tab_compiler
- } {
- ::configDialogs::compiler::create_asm_tab
- $secondaryNB select $assembler_tab_M8I
- }
+ $primaryNB raise primary_tab_asm
+ $secondaryNB raise assembler_tab_compiler
## Button frame at the bottom
set but_frame [frame $win.button_frame]
# Button "Reset"
pack [ttk::button $but_frame.but_default \
-text [mc "Reset to defaults"] \
- -command {::configDialogs::compiler::DEFAULTS} \
-
+ -command {::configDialogues::compiler::DEFAULTS}\
+
] -side left
DynamicHelp::add $but_frame.but_default \
-text [mc "Reset all settings to defaults"]
@@ -252,8 +225,8 @@ namespace eval compiler {
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::compiler::OK} \
- ] -side right
+ -command {::configDialogues::compiler::OK} \
+ ] -side right -padx 2
DynamicHelp::add $but_frame.but_ok \
-text [mc "Commit new settings"]
# Button "Cancel"
@@ -261,30 +234,210 @@ namespace eval compiler {
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {::configDialogs::compiler::CANCEL} \
- ] -side right
+ -command {::configDialogues::compiler::CANCEL} \
+ ] -side right -padx 2
DynamicHelp::add $but_frame.but_cancel \
-text [mc "Take changes back and close dialog"]
# Pack frames and notebook
pack $but_frame -side bottom -fill x -anchor s -padx 5 -pady 5
pack $win.header_label -side top -pady 6
- pack $primaryNB -side top -fill both -padx 5
+ pack [$primaryNB get_nb] -side top -fill both -padx 5 -expand 1
# Set window attributes
wm iconphoto $win ::ICONS::16::configure
wm transient $win .
wm title $win [mc "Configure compiler - %s" ${::APPNAME}]
- wm geometry $win 450x460
+ wm geometry $win 470x510
wm resizable $win 0 0
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::compiler::CANCEL
+ ::configDialogues::compiler::CANCEL
}
tkwait window $win
}
+ ## Create tab "GNU make utility"
+ # @return void
+ proc create_make_tab {} {
+ variable primary_tab_make ;# Widget: Tab "MAIN/GNU make"
+
+ if {!${::PROGRAM_AVAILABLE(make)}} {
+ pack [label $primary_tab_make.warning_lbl \
+ -fg {#DD0000} \
+ -text [mc "Make utility is not available, please install GNU make and restart the IDE."] \
+ ] -pady 10
+ return
+ }
+
+ set primary_tab_make [frame $primary_tab_make.f]
+ pack $primary_tab_make -side top -anchor w -padx 5 -pady 10 -fill both -expand 1
+
+ #
+ ## C compiler
+ #
+ grid [checkbutton $primary_tab_make.chb_c_ena \
+ -text [mc "Use this Makefile instead of calling C compiler directly:"] \
+ -onvalue 1 -offvalue 0 \
+ -variable ::configDialogues::compiler::makeutil_config(c_ena) \
+ -command [list ::configDialogues::compiler::make_tab__chb_ena c] \
+ ] -column 0 -row 0 -sticky w -padx 5 -columnspan 4
+
+ grid [ttk::label $primary_tab_make.clng_make_label \
+ -text [mc "Makefile:"]
+ ] -column 0 -row 1 -padx 5 -pady 5 -sticky w
+ grid [ttk::button \
+ $primary_tab_make.clng_clear_but \
+ -style Flat.TButton \
+ -takefocus 0 \
+ -image ::ICONS::16::locationbar_erase \
+ -command [list ::configDialogues::compiler::make_tab__clr_but c]\
+ -state disabled \
+ ] -column 1 -row 1
+ DynamicHelp::add $primary_tab_make.clng_clear_but -text [mc "Clear the entrybox"]
+ grid [ttk::entry $primary_tab_make.clng_make_entry \
+ -width 0 -validate all \
+ -textvariable ::configDialogues::compiler::makeutil_config(c_file) \
+ -validatecommand [list ::configDialogues::compiler::make_tab__entry_validator c %P] \
+ ] -column 2 -row 1 -sticky we
+ grid [ttk::button $primary_tab_make.clng_flsel_but \
+ -style Flat.TButton \
+ -takefocus 0 \
+ -image ::ICONS::16::fileopen \
+ -command [list ::configDialogues::compiler::make_tab__flsel_but c] \
+ ] -row 1 -column 3 -sticky e
+ DynamicHelp::add $primary_tab_make.clng_flsel_but -text [mc "Select Makefile"]
+
+ grid [ttk::label $primary_tab_make.copt_make_label \
+ -text [mc "Options:"]
+ ] -column 0 -row 2 -padx 5 -pady 5 -sticky w
+ grid [ttk::button \
+ $primary_tab_make.colng_clear_but \
+ -style Flat.TButton \
+ -takefocus 0 \
+ -image ::ICONS::16::locationbar_erase \
+ -command [list ::configDialogues::compiler::make_tab__clr_but co]\
+ -state disabled \
+ ] -column 1 -row 2
+ DynamicHelp::add $primary_tab_make.colng_clear_but -text [mc "Clear the entrybox"]
+ grid [ttk::entry $primary_tab_make.copt_make_entry \
+ -width 0 -validate all \
+ -textvariable ::configDialogues::compiler::makeutil_config(co_file) \
+ -validatecommand [list ::configDialogues::compiler::make_tab__entry_validator co %P] \
+ ] -column 2 -row 2 -sticky we
+
+ grid [ttk::label $primary_tab_make.ctrg_make_label \
+ -text [mc "Targets:"]
+ ] -column 0 -row 3 -padx 5 -pady 5 -sticky w
+ grid [ttk::button \
+ $primary_tab_make.ctlng_clear_but \
+ -style Flat.TButton \
+ -takefocus 0 \
+ -image ::ICONS::16::locationbar_erase \
+ -command [list ::configDialogues::compiler::make_tab__clr_but ct]\
+ -state disabled \
+ ] -column 1 -row 3
+ DynamicHelp::add $primary_tab_make.ctlng_clear_but -text [mc "Clear the entrybox"]
+ grid [ttk::entry $primary_tab_make.ctrg_make_entry \
+ -width 0 -validate all \
+ -textvariable ::configDialogues::compiler::makeutil_config(ct_file) \
+ -validatecommand [list ::configDialogues::compiler::make_tab__entry_validator ct %P] \
+ ] -column 2 -row 3 -sticky we
+
+ grid columnconfigure $primary_tab_make 2 -weight 1
+
+ # Adjust GUI to the current config
+ make_tab__adjust_gui
+
+ update idletasks
+ focus $primary_tab_make.clng_make_entry
+ }
+
+ ## Enable or disable widgets related to Makefile usage configuration
+ # according to content of certain configuration variables.
+ # @return void
+ proc make_tab__adjust_gui {} {
+ # Enable of disable (other) widgets for configuration related to makefiles
+ make_tab__chb_ena c
+ }
+
+ ## Enable or disable widgets for further configuration
+ #
+ # Enable them only if usage of Makefile instead of direct call of a
+ # compiler/assembler was enabled.
+ # @parm Char lang -'c' == C language
+ # @return void
+ proc make_tab__chb_ena {lang} {
+ variable primary_tab_make ;# Widget: Tab "MAIN/GNU make"
+
+ if {$::configDialogues::compiler::makeutil_config(${lang}_ena) && ${::PROGRAM_AVAILABLE(make)}} {
+ make_tab__entry_validator $lang $::configDialogues::compiler::makeutil_config(${lang}_file)
+ make_tab__entry_validator ${lang}o $::configDialogues::compiler::makeutil_config(${lang}o_file)
+ make_tab__entry_validator ${lang}t $::configDialogues::compiler::makeutil_config(${lang}t_file)
+ set state {normal}
+ } else {
+ set state {disabled}
+ }
+
+ if {[winfo exists $primary_tab_make.f]} {
+ $primary_tab_make.${lang}lng_make_entry configure -state $state
+ $primary_tab_make.${lang}lng_flsel_but configure -state $state
+ $primary_tab_make.${lang}opt_make_entry configure -state $state
+ $primary_tab_make.${lang}trg_make_entry configure -state $state
+ }
+ }
+
+ ## Invoke file selection dialog for the Makefile entrybox
+ # @parm Char lang -'c' == C language
+ # @return void
+ proc make_tab__flsel_but {lang} {
+ variable primary_tab_make ;# Widget: Tab "MAIN/GNU make"
+
+ catch {delete object ::fsd}
+ KIFSD::FSD ::fsd \
+ -initialfile $::configDialogues::compiler::makeutil_config(${lang}_file) \
+ -directory [file dirname $::configDialogues::compiler::makeutil_config(${lang}_file)] \
+ -title [mc "Select Makefile - %s - MCU 8051 IDE" $::X::actualProject] \
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "All files"] {*} ] \
+ ]
+ ::fsd setokcmd [subst {
+ set uri \[::fsd get\]
+ set ::configDialogues::compiler::makeutil_config(${lang}_file) \$uri
+ ::configDialogues::compiler::make_tab__entry_validator $lang \$uri
+ }]
+ fsd activate
+ }
+
+ ## Clear the Makefile entrybox (action for the Clear button)
+ # @parm Char lang -'c' == C language
+ # @return void
+ proc make_tab__clr_but {lang} {
+ variable primary_tab_make ;# Widget: Tab "MAIN/GNU make"
+
+ set ::configDialogues::compiler::makeutil_config(${lang}_file) {}
+ make_tab__entry_validator $lang {}
+ }
+
+ ## Disable the clear button if the entrybox is empty, enable it otherwise
+ # @parm Char lang -'c' == C language
+ # @parm String content - Content of the entrybox
+ # @return void
+ proc make_tab__entry_validator {lang content} {
+ variable primary_tab_make ;# Widget: Tab "MAIN/GNU make"
+
+ if {$content == {}} {
+ set state disabled
+ } else {
+ set state normal
+ }
+
+ $primary_tab_make.${lang}lng_clear_but configure -state $state
+
+ return 1
+ }
+
## Create tab "C language"
# @return void
proc create_C_tab {} {
@@ -296,18 +449,7 @@ namespace eval compiler {
variable tertialy_tab_Custom ;# Widget: Tab "MAIN/C language/Custom"
# Create notebook
- set tertialyNB [ttk::notebook $primary_tab_c.nb]
- set ::configDialogs::compiler::tertialyNB__tabs_created [list]
- bind $tertialyNB <<NotebookTabChanged>> {after idle {
- set tab_index [%W index [%W select]]
-
- if {[lsearch ${::configDialogs::compiler::tertialyNB__tabs_created} $tab_index] == -1} {
- lappend ::configDialogs::compiler::tertialyNB__tabs_created $tab_index
-
- configDialogs::compiler::create_T_tab \
- [lindex [list {General} {Code} {Optimization} {Linker} {Custom}] $tab_index]
- }
- }}
+ set tertialyNB [ModernNoteBook $primary_tab_c.nb_t]
# Create notebook tabs
foreach tab {
@@ -324,14 +466,16 @@ namespace eval compiler {
Custom
} \
{
- set frame [frame $tertialyNB.frame_${tab}]
+ set frame [$tertialyNB insert end $tab \
+ -createcmd [list ::configDialogues::compiler::create_T_tab $tab] \
+ -text [mc $text] \
+ ]
set tertialy_tab_$var $frame
- $tertialyNB add $frame -text [mc $text]
}
# Finalize
- $tertialyNB select $tertialyNB.frame_General
- pack $tertialyNB -fill both -expand 1
+ $tertialyNB raise {General}
+ pack [$tertialyNB get_nb] -fill both -expand 1
}
## Create certain tab in notebook "C language"
@@ -401,8 +545,8 @@ namespace eval compiler {
{
grid [radiobutton $local_frame.chb_${local_row}_$col \
-value $name -text $name \
- -variable ::configDialogs::compiler::sdcc_str_opt(standard) \
- ] -column $col -row $local_row -sticky w
+ -variable ::configDialogues::compiler::sdcc_str_opt(standard) \
+ ] -column $col -row $local_row -sticky w -padx 5
DynamicHelp::add $local_frame.chb_${local_row}_$col -text [mc $helptext]
incr col
@@ -419,25 +563,25 @@ namespace eval compiler {
pack $local_frame -side top -fill x
grid [Label $local_frame.lbl_$local_row -anchor w \
- -text {Include path} \
+ -text [mc "Include path"] \
-helptext [mc "Add to the include path, as in -Ipath\nPaths are separated by semicolons (`;')"] \
- ] -column 0 -row $local_row -sticky w
+ ] -column 0 -row $local_row -sticky w -padx 5
grid [ttk::entry $local_frame.chb_$local_row \
-width 0 \
- -textvariable ::configDialogs::compiler::sdcc_scs_str_opt(-I) \
- ] -column 1 -row $local_row -sticky we
+ -textvariable ::configDialogues::compiler::sdcc_scs_str_opt(-I) \
+ ] -column 1 -row $local_row -sticky we -padx 5
DynamicHelp::add $local_frame.chb_$local_row \
- -text [mc "Add to the include (*.h) path, as in -Ipath\nPaths are separated by semicolons (`;')"]
+ -text [mc "Add to the include path, as in -Ipath\nPaths are separated by semicolons (`;')"]
incr local_row
grid [Label $local_frame.lbl_$local_row -anchor w \
- -text {Disable warning} \
+ -text [mc "Disable warning"] \
-helptext [mc "Disable specific warning (--disable-warning)\nNumbers are separated by semicolons (`;')"] \
- ] -column 0 -row $local_row -sticky w
+ ] -column 0 -row $local_row -sticky w -padx 5
grid [ttk::entry $local_frame.chb_$local_row \
-width 0 \
- -textvariable ::configDialogs::compiler::sdcc_scs_str_opt(--disable-warning) \
- ] -column 1 -row $local_row -sticky we
+ -textvariable ::configDialogues::compiler::sdcc_scs_str_opt(--disable-warning) \
+ ] -column 1 -row $local_row -sticky we -padx 5
DynamicHelp::add $local_frame.chb_$local_row -text [mc "Disable specific warning (--disable-warning)\nNumbers are separated by semicolons (`;')"] \
incr local_row
@@ -481,7 +625,7 @@ namespace eval compiler {
grid columnconfigure $local_frame 0 -minsize 25
grid columnconfigure $local_frame 3 -minsize 20
grid [label $local_frame.c_standard -text [mc "Model:"]] \
- -columnspan 6 -column 0 -row 0 -sticky w
+ -columnspan 6 -column 0 -row 0 -sticky w -padx 5
set local_row 1
set col 1
@@ -497,9 +641,9 @@ namespace eval compiler {
{
grid [radiobutton $local_frame.chb_${local_row}_$col \
-value $name -text $name \
- -variable ::configDialogs::compiler::sdcc_str_opt(model) \
- ] -column $col -row $local_row -sticky w
- DynamicHelp::add $local_frame.chb_${local_row}_$col -text $helptext
+ -variable ::configDialogues::compiler::sdcc_str_opt(model) \
+ ] -column $col -row $local_row -sticky w -padx 5
+ DynamicHelp::add $local_frame.chb_${local_row}_$col -text [mc $helptext]
incr col
if {$col >= 3} {
@@ -508,7 +652,7 @@ namespace eval compiler {
}
}
- pack [ttk::separator $frame.sep_0 -orient horizontal] -fill x -pady 5
+ pack [ttk::separator $frame.sep_0 -orient horizontal] -fill x -pady 5 -padx 5
set local_row 0
set local_frame [frame $frame.local_frame_1]
@@ -517,11 +661,11 @@ namespace eval compiler {
grid [Label $local_frame.lbl_$local_row -anchor w \
-text {--codeseg} \
-helptext [mc "Use this name for the code segment"] \
- ] -column 0 -row $local_row -sticky w
+ ] -column 0 -row $local_row -sticky w -padx 5
grid [ttk::entry $local_frame.chb_$local_row \
-width 0 \
- -textvariable ::configDialogs::compiler::sdcc_opt_str_opt(--codeseg) \
- ] -column 1 -row $local_row -sticky we
+ -textvariable ::configDialogues::compiler::sdcc_opt_str_opt(--codeseg) \
+ ] -column 1 -row $local_row -sticky we -padx 5
DynamicHelp::add $local_frame.chb_$local_row \
-text [mc "Use this name for the code segment"]
incr local_row
@@ -529,16 +673,16 @@ namespace eval compiler {
grid [Label $local_frame.lbl_$local_row -anchor w \
-text {--constseg} \
-helptext [mc "Use this name for the const segment"] \
- ] -column 0 -row $local_row -sticky w
+ ] -column 0 -row $local_row -sticky w -padx 5
grid [ttk::entry $local_frame.chb_$local_row \
-width 0 \
- -textvariable ::configDialogs::compiler::sdcc_opt_str_opt(--constseg) \
- ] -column 1 -row $local_row -sticky we
+ -textvariable ::configDialogues::compiler::sdcc_opt_str_opt(--constseg) \
+ ] -column 1 -row $local_row -sticky we -padx 5
DynamicHelp::add $local_frame.chb_$local_row -text [mc "Use this name for the const segment"] \
incr local_row
grid columnconfigure $local_frame 1 -weight 1
- pack [ttk::separator $frame.sep_1 -orient horizontal] -fill x -pady 5
+ pack [ttk::separator $frame.sep_1 -orient horizontal] -fill x -pady 5 -padx 5
}
{Optimization} {
set conf_affected(SDCC_Optimization) 1
@@ -589,14 +733,14 @@ namespace eval compiler {
} \
{
grid [Label $local_frame.lbl_$local_row -anchor w \
- -text $name -helptext [subst $helptext] \
- ] -column 0 -row $local_row -sticky w
+ -text $name -helptext [mc [subst $helptext]] \
+ ] -column 0 -row $local_row -sticky w -padx 5
grid [ttk::entry $local_frame.chb_$local_row \
-width 0 \
- -textvariable ::configDialogs::compiler::sdcc_scs_str_opt($name) \
- ] -column 1 -row $local_row -sticky we
+ -textvariable ::configDialogues::compiler::sdcc_scs_str_opt($name) \
+ ] -column 1 -row $local_row -sticky we -padx 5
DynamicHelp::add $local_frame.chb_$local_row \
- -text [subst $helptext]
+ -text [mc [subst $helptext]]
incr local_row
}
foreach name {
@@ -615,40 +759,23 @@ namespace eval compiler {
} \
{
grid [Label $local_frame.lbl_$local_row -anchor w \
- -text $name -helptext $helptext \
- ] -column 0 -row $local_row -sticky w
+ -text $name -helptext [mc $helptext] \
+ ] -column 0 -row $local_row -sticky w -padx 5
grid [ttk::entry $local_frame.chb_$local_row \
-width 0 \
- -textvariable ::configDialogs::compiler::sdcc_opt_str_opt($name) \
- ] -column 1 -row $local_row -sticky we
- DynamicHelp::add $local_frame.chb_$local_row -text $helptext
+ -textvariable ::configDialogues::compiler::sdcc_opt_str_opt($name) \
+ ] -column 1 -row $local_row -sticky we -padx 5
+ DynamicHelp::add $local_frame.chb_$local_row -text [mc $helptext]
incr local_row
}
- pack [ttk::separator $frame.sep_0 -orient horizontal] -fill x -pady 5
+ pack [ttk::separator $frame.sep_0 -orient horizontal] -fill x -pady 5 -padx 5
set local_frame [frame $frame.local_frame_0]
pack $local_frame -side top -anchor w
grid columnconfigure $local_frame 0 -minsize 25
- pack [ttk::separator $frame.sep_1 -orient horizontal] -fill x -pady 5
+ pack [ttk::separator $frame.sep_1 -orient horizontal] -fill x -pady 5 -padx 5
grid [label $local_frame.c_standard -text [mc "Stack:"]] \
-columnspan 3 -column 0 -row 0 -sticky w
-
- set local_row 1
- foreach name {
- --pack-iram --no-pack-iram
- } helptext {
- {Tells the linker to pack variables in internal ram}
- {Tells the linker not to pack variables in internal ram}
- } \
- {
- grid [radiobutton $local_frame.chb_${local_row} \
- -value $name -text $name \
- -variable ::configDialogs::compiler::sdcc_str_opt(stack) \
- ] -column 1 -row $local_row -sticky w
- DynamicHelp::add $local_frame.chb_${local_row} -text $helptext
-
- incr local_row
- }
}
{Custom} {
set conf_affected(SDCC_Custom) 1
@@ -670,13 +797,13 @@ namespace eval compiler {
$sdcc_custom_opts_text insert end $sdcc_str_opt(custom)
pack $main_frame -side top -fill both -expand 1
- } {
+ } else {
set col 0
foreach name $names helptext $helptexts {
grid [checkbutton $main_frame.chb_${row}_$col \
-text $name -onvalue 1 -offvalue 0 \
- -variable ::configDialogs::compiler::sdcc_bool_opt($name) \
- ] -column $col -row $row -sticky w
+ -variable ::configDialogues::compiler::sdcc_bool_opt($name) \
+ ] -column $col -row $row -sticky w -padx 5
DynamicHelp::add $main_frame.chb_${row}_$col -text [mc $helptext]
incr col
@@ -700,8 +827,8 @@ namespace eval compiler {
set main_frame [frame $assembler_tab_compiler.frame]
# Preferred editor
grid [label $main_frame.editor_lbl \
- -text [mc "Preferred assemler:"] -anchor w \
- ] -row 0 -column 0 -sticky w
+ -text [mc "Preferred assembler:"] -anchor w \
+ ] -row 0 -column 0 -sticky w -padx 10 -pady 10
set row 1
set i 0
foreach text {
@@ -711,12 +838,12 @@ namespace eval compiler {
{AS31}
} helptext {
{MCU 8051 IDE native assembler - Sophisticated but slow}
- {Sophisticated and very fast assembler writen by W.W. Heinz}
+ {Sophisticated and very fast assembler written by W.W. Heinz}
{Multiplatform assembler written by Alfred Arnold}
{Simple 8051 assembler}
} {
grid [radiobutton $main_frame.rabut_$i \
- -variable ::configDialogs::compiler::selected_assembler \
+ -variable ::configDialogues::compiler::selected_assembler \
-value $i -text $text -state disabled \
] -column 0 -padx 25 -row $row -sticky w
DynamicHelp::add $main_frame.rabut_$i -text [mc $helptext]
@@ -724,13 +851,13 @@ namespace eval compiler {
incr row
}
$main_frame.rabut_0 configure -state normal
- if {${::PROGRAM_AVALIABLE(asem)}} {
+ if {${::PROGRAM_AVAILABLE(asem)}} {
$main_frame.rabut_1 configure -state normal
}
- if {${::PROGRAM_AVALIABLE(asl)}} {
+ if {${::PROGRAM_AVAILABLE(asl)}} {
$main_frame.rabut_2 configure -state normal
}
- if {${::PROGRAM_AVALIABLE(as31)}} {
+ if {${::PROGRAM_AVAILABLE(as31)}} {
$main_frame.rabut_3 configure -state normal
}
@@ -739,8 +866,11 @@ namespace eval compiler {
incr row
grid [text $main_frame.notes \
- -bg {#EEEEEE} -bd 0 -highlightthickness 0 -wrap word \
- -font [font create -family {helvetiva} -size -12] \
+ -bg ${::COMMON_BG_COLOR} -bd 0 -highlightthickness 0 -wrap word \
+ -font [font create \
+ -family {helvetiva} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ ] \
] -row $row -column 0 -sticky we -columnspan 2 -padx 10
$main_frame.notes insert end [mc "Notes to assemblers:\n"]
@@ -748,7 +878,9 @@ namespace eval compiler {
$main_frame.notes insert end [mc " b) ASEM-51 is a great assembler written by W.W. Heinz.\n"]
$main_frame.notes insert end [mc " You can find it at http://plit.de/asem-51/home.htm\n"]
$main_frame.notes insert end [mc " c) ASL: http://linux.maruhn.com/sec/asl.html\n"]
- $main_frame.notes insert end [mc " d) AS31: http://www.pjrc.com/tech/8051/\n"]
+ $main_frame.notes insert end [mc " d) AS31: http://www.pjrc.com/tech/8051\n"]
+ create_link_tag_in_text_widget $main_frame.notes
+ convert_all_https_to_links $main_frame.notes
$main_frame.notes configure -state disabled
@@ -783,13 +915,13 @@ namespace eval compiler {
} \
{
pack [checkbutton $main_frame.checkbutton_$i \
- -text $name -onvalue 1 -offvalue 0 \
- -variable ::configDialogs::compiler::assembler_ASEM51_config($name) \
- ] -anchor nw
- DynamicHelp::add $main_frame.checkbutton_$i -text $helptext
+ -text [mc $name] -onvalue 1 -offvalue 0 \
+ -variable ::configDialogues::compiler::assembler_ASEM51_config($name) \
+ ] -anchor nw -padx 5
+ DynamicHelp::add $main_frame.checkbutton_$i -text [mc $helptext]
incr i
}
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
# Additional options
set main_frame [frame $assembler_tab_ASEM51.frame_a]
@@ -802,15 +934,15 @@ namespace eval compiler {
{Generate <file>.adb (MCU 8051 IDE Assembler Debug File) from <file>.lst}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
pack [checkbutton $main_frame.chb_$i \
- -text $text -onvalue 1 -offvalue 0 \
- -variable ::configDialogs::compiler::assembler_ASEM51_addcfg($var) \
- ] -anchor w
+ -text [mc $text] -onvalue 1 -offvalue 0 \
+ -variable ::configDialogues::compiler::assembler_ASEM51_addcfg($var) \
+ ] -anchor w -padx 5
DynamicHelp::add $main_frame.chb_$i -text $helptext
incr i
}
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
pack [ttk::separator $assembler_tab_ASEM51.sep_1 -orient horizontal] -fill x -pady 5
# Create second frame (Include path and custom flags)
@@ -819,20 +951,20 @@ namespace eval compiler {
grid [Label $main_frame.lbl_0 -anchor w \
-text [mc "Include paths:"] \
-helptext [mc "Option -i\nSeparate directories by colons (`:')"] \
- ] -column 0 -row 0 -sticky w
+ ] -column 0 -row 0 -sticky w -padx 5
grid [ttk::entry $main_frame.entry \
- -textvariable ::configDialogs::compiler::assembler_ASEM51_config(-i) \
- ] -column 1 -row 0 -sticky we
+ -textvariable ::configDialogues::compiler::assembler_ASEM51_config(-i) \
+ ] -column 1 -row 0 -sticky we -padx 5
DynamicHelp::add $main_frame.entry \
-text [mc "Option -i\nSeparate directories by colons (`:')"]
grid [Label $main_frame.lbl_1 \
-anchor w \
-text [mc "Custom options:"] \
- ] -column 0 -row 1 -sticky w
+ ] -column 0 -row 1 -sticky w -padx 5
# Configure grid and pack main frame 1
grid columnconfigure $main_frame 1 -weight 1
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
# Text widget "Custom options"
set main_frame [frame $assembler_tab_ASEM51.frame2]
@@ -846,8 +978,8 @@ namespace eval compiler {
-command "$asm51_custom_opts_text yview" \
] -side right -fill y
$asm51_custom_opts_text insert end \
- $::configDialogs::compiler::assembler_ASEM51_config(custom)
- pack $main_frame -fill both -expand 1
+ $::configDialogues::compiler::assembler_ASEM51_config(custom)
+ pack $main_frame -fill both -expand 1 -pady 5
}
## Create tab "AS31"
@@ -870,15 +1002,15 @@ namespace eval compiler {
} text {
{Generate a listing file, option `-l'}
} helptext {
- {This option tells the assembler to generate a listing file.\n\nTHIS OPTION IS REQUIRED BY THIS IDE TO GENERATE BEBUG FILE !}
+ {This option tells the assembler to generate a listing file.\n\nTHIS OPTION IS REQUIRED BY THIS IDE TO GENERATE DEBUG FILE !}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
grid [checkbutton $main_frame.checkbutton_$i \
-text [mc $text] -onvalue 1 -offvalue 0 \
- -variable ::configDialogs::compiler::assembler_AS31_config($name) \
- ] -sticky w -row $row -column $col
- DynamicHelp::add $main_frame.checkbutton_$i -text [mc $helptext]
+ -variable ::configDialogues::compiler::assembler_AS31_config($name) \
+ ] -sticky w -row $row -column $col -padx 5
+ DynamicHelp::add $main_frame.checkbutton_$i -text $helptext
incr i
incr col
@@ -890,7 +1022,7 @@ namespace eval compiler {
for {set i 0} {$i < 4} {incr i} {
grid columnconfigure $main_frame $i -weight 1
}
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
# Additional options
set main_frame [frame $assembler_tab_AS31.frame_a]
@@ -903,15 +1035,15 @@ namespace eval compiler {
{Generate <file>.adb (MCU 8051 IDE Assembler Debug File)\nfrom <file>.lst}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
pack [checkbutton $main_frame.chb_$i \
-text [mc $text] -onvalue 1 -offvalue 0 \
- -variable ::configDialogs::compiler::assembler_AS31_addcfg($var) \
- ] -anchor w
- DynamicHelp::add $main_frame.chb_$i -text [mc $helptext]
+ -variable ::configDialogues::compiler::assembler_AS31_addcfg($var) \
+ ] -anchor w -padx 5
+ DynamicHelp::add $main_frame.chb_$i -text $helptext
incr i
}
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
pack [ttk::separator $assembler_tab_AS31.sep_1 -orient horizontal] -fill x
# Create second frame (EntryBoxes and ComboBoxes)
@@ -920,21 +1052,21 @@ namespace eval compiler {
foreach name {
-F
} helptext {
- {This options specifies the output format that is to be used.\n\nSee AS31 manual page for more datails ...}
+ {This options specifies the output format that is to be used.\n\nSee AS31 manual page for more details ...}
} values {
{hex tdr byte od srec2 srec3 srec4}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
grid [Label $main_frame.lbl_$row -anchor w \
-text $name -helptext [mc $helptext] \
- ] -column 0 -row $row -sticky w
+ ] -column 0 -row $row -sticky w -padx 5
grid [ttk::combobox $main_frame.entry_$row \
-state readonly \
-values $values \
- -textvariable ::configDialogs::compiler::assembler_AS31_config($name) \
- ] -column 1 -row $row -sticky we
- DynamicHelp::add $main_frame.entry_$row -text [mc $helptext]
+ -textvariable ::configDialogues::compiler::assembler_AS31_config($name) \
+ ] -column 1 -row $row -sticky we -padx 5
+ DynamicHelp::add $main_frame.entry_$row -text $helptext
incr row
}
foreach name {
@@ -943,26 +1075,26 @@ namespace eval compiler {
{This option specifies a format specific string which is\npassed to the format generator. Both format "tdr" and the\nsrecord formats use this option.}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
grid [Label $main_frame.lbl_$row -anchor w \
- -text $name -helptext [mc $helptext] \
- ] -column 0 -row $row -sticky w
+ -text $name -helptext $helptext \
+ ] -column 0 -row $row -sticky w -padx 5
grid [ttk::entry $main_frame.entry_$row \
- -textvariable ::configDialogs::compiler::assembler_AS31_config($name) \
- ] -column 1 -row $row -sticky we
+ -textvariable ::configDialogues::compiler::assembler_AS31_config($name) \
+ ] -column 1 -row $row -sticky we -padx 5
DynamicHelp::add $main_frame.entry_$row \
- -text [mc $helptext]
+ -text $helptext
incr row
}
# Custom flags
grid [Label $main_frame.lbl_$row -anchor w \
-text [mc "Custom options:"] \
- ] -column 0 -row $row -sticky w
+ ] -column 0 -row $row -sticky w -padx 5
# Configure grid and pack main frame 1
grid columnconfigure $main_frame 1 -weight 1
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
# Text widget "Custom options"
set main_frame [frame $assembler_tab_AS31.frame2]
@@ -976,7 +1108,7 @@ namespace eval compiler {
-command "$as31_custom_opts_text yview" \
] -side right -fill y
$as31_custom_opts_text insert end \
- $::configDialogs::compiler::assembler_AS31_config(custom)
+ $::configDialogues::compiler::assembler_AS31_config(custom)
pack $main_frame -fill both -expand 1
}
@@ -1016,12 +1148,12 @@ namespace eval compiler {
{Turn on extended error reporting. With extended error\nreporting, several error and warning messages will also\nprint the item that created the message, e.g. the name of\nan unknown instruction. When this option is given twice,\nthe erroneous source line is additinally printed.}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
grid [checkbutton $main_frame.checkbutton_$i \
-text $name -onvalue 1 -offvalue 0 \
- -variable ::configDialogs::compiler::assembler_ASL_config($name) \
- ] -sticky w -row $row -column $col
- DynamicHelp::add $main_frame.checkbutton_$i -text [mc $helptext]
+ -variable ::configDialogues::compiler::assembler_ASL_config($name) \
+ ] -sticky w -row $row -column $col -padx 5
+ DynamicHelp::add $main_frame.checkbutton_$i -text $helptext
incr i
incr col
@@ -1033,7 +1165,7 @@ namespace eval compiler {
for {set i 0} {$i < 4} {incr i} {
grid columnconfigure $main_frame $i -weight 1
}
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
pack [ttk::separator $assembler_tab_ASL.sep_0 -orient horizontal] -fill x
# Additional options
@@ -1049,15 +1181,15 @@ namespace eval compiler {
{Generate <file>.adb (MCU 8051 IDE Assembler Debug File)\nfrom <file>.hex and <file>.map}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
pack [checkbutton $main_frame.chb_$i \
-text [mc $text] -onvalue 1 -offvalue 0 \
- -variable ::configDialogs::compiler::assembler_ASL_addcfg($var) \
+ -variable ::configDialogues::compiler::assembler_ASL_addcfg($var) \
] -anchor w
- DynamicHelp::add $main_frame.chb_$i -text [mc $helptext]
+ DynamicHelp::add $main_frame.chb_$i -text $helptext
incr i
}
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
pack [ttk::separator $assembler_tab_ASL.sep_1 -orient horizontal] -fill x
# Create second frame (EntryBoxes and ComboBoxes)
@@ -1078,16 +1210,16 @@ namespace eval compiler {
}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
grid [Label $main_frame.lbl_$row -anchor w \
-text $name -helptext [mc $helptext] \
- ] -column 0 -row $row -sticky w
+ ] -column 0 -row $row -sticky w -padx 5
grid [ttk::combobox $main_frame.entry_$row \
-state readonly \
-values $values \
- -textvariable ::configDialogs::compiler::assembler_ASL_config($name) \
- ] -column 1 -row $row -sticky we
- DynamicHelp::add $main_frame.entry_$row -text [mc $helptext]
+ -textvariable ::configDialogues::compiler::assembler_ASL_config($name) \
+ ] -column 1 -row $row -sticky we -padx 5
+ DynamicHelp::add $main_frame.entry_$row -text $helptext
incr row
}
foreach name {
@@ -1097,25 +1229,25 @@ namespace eval compiler {
{-i <path\[:path...\]>\tAdd new entries to the list of paths that are\n\tsearched for include files. New entries are\n\tprepended to the current include path list,\n\tso if multiple paths are given with one\n\tcommand-line parameter, they will be entered\n\tinto the path list in reverse order.}
} \
{
- set helptext [subst $helptext]
+ set helptext [mc [subst $helptext]]
grid [Label $main_frame.lbl_$row -anchor w \
-text $name -helptext [mc $helptext] \
- ] -column 0 -row $row -sticky w
+ ] -column 0 -row $row -sticky w -padx 5
grid [ttk::entry $main_frame.entry_$row \
- -textvariable ::configDialogs::compiler::assembler_ASL_config($name) \
- ] -column 1 -row $row -sticky we
- DynamicHelp::add $main_frame.entry_$row -text [mc $helptext]
+ -textvariable ::configDialogues::compiler::assembler_ASL_config($name) \
+ ] -column 1 -row $row -sticky we -padx 5
+ DynamicHelp::add $main_frame.entry_$row -text $helptext
incr row
}
# Custom flags
grid [Label $main_frame.lbl_$row -anchor w \
-text [mc "Custom options:"] \
- ] -column 0 -row $row -sticky w
+ ] -column 0 -row $row -sticky w -padx 5
# Configure grid and pack main frame 1
grid columnconfigure $main_frame 1 -weight 1
- pack $main_frame -fill x
+ pack $main_frame -fill x -padx 5
# Text widget "Custom options"
set main_frame [frame $assembler_tab_ASL.frame2]
@@ -1129,7 +1261,7 @@ namespace eval compiler {
-command "$asl_custom_opts_text yview" \
] -side right -fill y
$asl_custom_opts_text insert end \
- $::configDialogs::compiler::assembler_ASL_config(custom)
+ $::configDialogues::compiler::assembler_ASL_config(custom)
pack $main_frame -fill both -expand 1
}
@@ -1143,14 +1275,12 @@ namespace eval compiler {
set conf_affected(MCU8051IDE) 1
## Create notebook
- set nb0 [ttk::notebook $assembler_tab_M8I.nb]
-
+ set nb0 [ModernNoteBook $assembler_tab_M8I.nb_m]
+
# Tab "Output"
- set ouput_tab [frame $nb0.ouput_tab]
- $nb0 add $ouput_tab -text [mc "Output"]
+ set ouput_tab [$nb0 insert end ouput_tab -text [mc "Output"]]
# Tab "Directives"
- set directives_tab [frame $nb0.directives_tab]
- $nb0 add $directives_tab -text [mc "Directives"]
+ set directives_tab [$nb0 insert end directives_tab -text [mc "Directives"]]
#
## Tab "Output"
@@ -1160,155 +1290,160 @@ namespace eval compiler {
grid [Label $ouput_tab.source_label \
-text [mc "Source"] -anchor c \
-helptext [mc "Use value defined in source code"] \
- ] -column 2 -row 0 -sticky we
+ ] -column 2 -row 0 -sticky we -padx 5
grid [Label $ouput_tab.always_label \
-text [mc "Always"] -anchor c \
-helptext [mc "Generate always"] \
- ] -column 3 -row 0 -sticky we
+ ] -column 3 -row 0 -sticky we -padx 5
grid [Label $ouput_tab.never_label \
-text [mc "Never"] -anchor c \
-helptext [mc "Never generate"] \
- ] -column 4 -row 0 -sticky we
+ ] -column 4 -row 0 -sticky we -padx 5
# Code listing
grid [Label $ouput_tab.lst_label -anchor w \
-text [mc "Generate code listing"] \
-helptext [mc "Should compiler generate *.lst files"] \
- ] -column 1 -row 1 -sticky we
+ ] -column 1 -row 1 -sticky we -padx 5
grid [radiobutton $ouput_tab.lst_radio0 -value 0 \
- -variable ::configDialogs::compiler::option__print \
- ] -column 2 -row 1
+ -variable ::configDialogues::compiler::option__print \
+ ] -column 2 -row 1 -padx 5
grid [radiobutton $ouput_tab.lst_radio1 -value 1 \
- -variable ::configDialogs::compiler::option__print \
- ] -column 3 -row 1
+ -variable ::configDialogues::compiler::option__print \
+ ] -column 3 -row 1 -padx 5
grid [radiobutton $ouput_tab.lst_radio2 -value 2 \
- -variable ::configDialogs::compiler::option__print \
- ] -column 4 -row 1
+ -variable ::configDialogues::compiler::option__print \
+ ] -column 4 -row 1 -padx 5
# Table of symbols
grid [Label $ouput_tab.sym_label -anchor w \
-text [mc "Table of symbols (in *.lst)"] \
-helptext [mc "Include table of used symbolic names to code listing"] \
- ] -column 1 -row 2 -sticky we
+ ] -column 1 -row 2 -sticky we -padx 5
grid [radiobutton $ouput_tab.sym_radio0 -value 0 \
- -variable ::configDialogs::compiler::option__symbols \
- ] -column 2 -row 2
+ -variable ::configDialogues::compiler::option__symbols \
+ ] -column 2 -row 2 -padx 5
grid [radiobutton $ouput_tab.sym_radio1 -value 1 \
- -variable ::configDialogs::compiler::option__symbols \
- ] -column 3 -row 2
+ -variable ::configDialogues::compiler::option__symbols \
+ ] -column 3 -row 2 -padx 5
grid [radiobutton $ouput_tab.sym_radio2 -value 2 \
- -variable ::configDialogs::compiler::option__symbols \
- ] -column 4 -row 2
+ -variable ::configDialogues::compiler::option__symbols \
+ ] -column 4 -row 2 -padx 5
# Hex object code
grid [Label $ouput_tab.hex_label -anchor w \
-text [mc "Generate object code (ihex8)"] \
-helptext [mc "Generate object code in format Intel Hex 8 (*.hex)"] \
- ] -column 1 -row 3 -sticky we
+ ] -column 1 -row 3 -sticky we -padx 5
grid [radiobutton $ouput_tab.hex_radio0 -value 0 \
- -variable ::configDialogs::compiler::option__object \
- ] -column 2 -row 3
+ -variable ::configDialogues::compiler::option__object \
+ ] -column 2 -row 3 -padx 5
grid [radiobutton $ouput_tab.hex_radio1 -value 1 \
- -variable ::configDialogs::compiler::option__object \
- ] -column 3 -row 3
+ -variable ::configDialogues::compiler::option__object \
+ ] -column 3 -row 3 -padx 5
grid [radiobutton $ouput_tab.hex_radio2 -value 2 \
- -variable ::configDialogs::compiler::option__object \
- ] -column 4 -row 3
+ -variable ::configDialogues::compiler::option__object \
+ ] -column 4 -row 3 -padx 5
grid [ttk::separator $ouput_tab.sep0 \
-orient horizontal \
- ] -column 0 -row 4 -columnspan 5 -sticky we -pady 5
+ ] -column 0 -row 4 -columnspan 5 -sticky we -pady 5 -padx 5
# Sim object code
grid [Label $ouput_tab.sim_label -anchor w \
-text [mc "Generate code for simulator"] \
-helptext [mc "Generate *.sim file for simulator"] \
- ] -column 1 -row 5 -sticky we
- grid [checkbutton $ouput_tab.sim_check \
- -variable ::configDialogs::compiler::option_CREATE_SIM_FILE \
- ] -column 2 -row 5 -sticky w -columnspan 3
+ ] -column 1 -row 5 -sticky we -padx 5
+ grid [checkbutton $ouput_tab.sim_check \
+ -variable ::configDialogues::compiler::option_CREATE_SIM_FILE \
+ ] -column 2 -row 5 -sticky w -columnspan 3 -padx 5
# Bin object code
grid [Label $ouput_tab.bin_label -anchor w \
-text [mc "Generate binary object code"] \
-helptext [mc "Generate binary object code (*.bin)"] \
- ] -column 1 -row 6 -sticky we
+ ] -column 1 -row 6 -sticky we -padx 5
grid [checkbutton $ouput_tab.bin_check \
- -variable ::configDialogs::compiler::option_CREATE_BIN_FILE \
- ] -column 2 -row 6 -sticky w -columnspan 3
+ -variable ::configDialogues::compiler::option_CREATE_BIN_FILE \
+ ] -column 2 -row 6 -sticky w -columnspan 3 -padx 5
grid [ttk::separator $ouput_tab.sep1 \
-orient horizontal \
- ] -column 0 -row 7 -columnspan 5 -sticky we -pady 5
+ ] -column 0 -row 7 -columnspan 5 -sticky we -pady 5 -padx 5
# Compier warning level
grid [Label $ouput_tab.warning_label -anchor w \
-text [mc "Warning level"] \
-helptext [mc "What kind of messages should be included in compiler log output"] \
- ] -column 1 -row 8 -sticky we
+ ] -column 1 -row 8 -sticky we -padx 5
grid [ttk::combobox $ouput_tab.warning_combo \
- -textvariable ::configDialogs::compiler::opt_WARNING_LEVEL \
- -values {
- {All}
- {Errors + Warnings}
- {Errros only}
- {Nothing}
- } \
+ -textvariable ::configDialogues::compiler::opt_WARNING_LEVEL \
+ -values [list \
+ [mc "All"] \
+ [mc "Errors + Warnings"] \
+ [mc "Errros only"] \
+ [mc "Nothing"] \
+ ] \
-state readonly -width 17 \
- ] -column 2 -row 8 -sticky w -columnspan 3
+ ] -column 2 -row 8 -sticky w -columnspan 3 -padx 5
DynamicHelp::add $ouput_tab.warning_combo \
-text [mc "What kind of messages should be included in compiler log output"]
# Verbose
grid [Label $ouput_tab.verbose_label -anchor w \
-text [mc "Verbose"] \
- -helptext [mc "Should compiler inoform user about what it is doing"] \
- ] -column 1 -row 9 -sticky we
+ -helptext [mc "Should compiler inform user about what it is doing"] \
+ ] -column 1 -row 9 -sticky we -padx 5
grid [checkbutton $ouput_tab.verbose_check \
-onvalue 0 -offvalue 1 \
- -variable ::configDialogs::compiler::option_QUIET \
- ] -column 2 -row 9 -sticky w -columnspan 3
+ -variable ::configDialogues::compiler::option_QUIET \
+ ] -column 2 -row 9 -sticky w -columnspan 3 -padx 5
grid [ttk::separator $ouput_tab.sep2 \
-orient horizontal \
- ] -column 0 -row 10 -columnspan 5 -sticky we -pady 5
+ ] -column 0 -row 10 -columnspan 5 -sticky we -pady 5 -padx 5
- # Enable optimalizations
+ # Enable optimization
grid [Label $ouput_tab.optim_label -anchor w \
- -text [mc "Enable optimalizations"] \
- -helptext [mc "Enable peephole optimalizations"]\
- ] -column 1 -row 11 -sticky we
+ -text [mc "Enable optimization"] \
+ -helptext [mc "Enable peephole optimization"]\
+ ] -column 1 -row 11 -sticky we -padx 5
grid [checkbutton $ouput_tab.optim_check \
-onvalue 1 -offvalue 0 \
- -variable ::configDialogs::compiler::option_optim_ena \
- ] -column 2 -row 11 -sticky w -columnspan 3
+ -variable ::configDialogues::compiler::option_optim_ena \
+ ] -column 2 -row 11 -sticky w -columnspan 3 -padx 5
# Maximum length of IHEX-8 record
grid [Label $ouput_tab.ih8_max_len_lbl -anchor w \
-text [mc "Maximum HEX record data length"] \
- -helptext [mc "Maximum length of Intel HEX 8 record data field.\n\nGeneraly it doesn't matter what is set here. But some (badly written)\nprogrammes may refuse to load files containing records which exceeds\ncertain length.\n\nHigher value also results in smaller .hex files\n\nValue equal to 0 will be treated as 1"] \
- ] -column 1 -row 12 -sticky we
- grid [spinbox $ouput_tab.ih8_max_len_spbox \
- -from 0 -to 255 -bg white -validate all -width 4 \
- -textvariable ::configDialogs::compiler::max_ihex_rec_length \
- -vcmd "::configDialogs::compiler::ih8_max_len_spbox_val %P"
- ] -column 2 -row 12 -sticky w -columnspan 3
+ -helptext [mc "Maximum length of Intel HEX 8 record data field.\n\nGenerally it doesn't matter what is set here. But some (badly written)\nprogrammers may refuse to load files containing records which exceeds\ncertain length.\n\nHigher value also results in smaller .hex files\n\nValue equal to 0 will be treated as 1"] \
+ ] -column 1 -row 12 -sticky we -padx 5
+ grid [ttk::spinbox $ouput_tab.ih8_max_len_spbox \
+ -from 0 -to 255 -validate all -width 4 \
+ -textvariable ::configDialogues::compiler::max_ihex_rec_length \
+ -validatecommand "::configDialogues::compiler::ih8_max_len_spbox_val %P" \
+ ] -column 2 -row 12 -sticky w -columnspan 3 -padx 5
+
#
## Tab "Directives"
#
# Header
- grid [label $directives_tab.header \
- -anchor w -text [mc "Ignore directives"] \
- -font [font create -family {helvetica} -size -17 -weight bold] \
+ grid [label $directives_tab.header \
+ -anchor w -text [mc "Ignore directives"] \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
] -column 0 -row 0 -columnspan 3 -sticky we -pady 10 -padx 10
grid [label $directives_tab.accept_label \
-text [mc "Accept"] -anchor w \
- ] -column 1 -row 1
+ ] -column 1 -row 1 -padx 5
grid [label $directives_tab.ignore_label \
-text [mc "Ignore"] -anchor w \
- ] -column 2 -row 1
+ ] -column 2 -row 1 -padx 5
# Create matrix of radio buttons
set row 2
@@ -1328,26 +1463,27 @@ namespace eval compiler {
{}
{}
{}
- } {
-
+ } \
+ {
# Label
grid [Label $directives_tab.${var}_label \
-text $txt -anchor w -highlightthickness 0 -bd 0 \
-helptext $helptext \
- ] -column 0 -row $row -sticky we
+ ] -column 0 -row $row -sticky we -padx 5
# Accept
grid [radiobutton $directives_tab.${var}_radio0 -value 0 \
- -variable ::configDialogs::compiler::option__${var} \
- ] -column 1 -row $row
+ -variable ::configDialogues::compiler::option__${var} \
+ ] -column 1 -row $row -padx 5
# Ignore
grid [radiobutton $directives_tab.${var}_radio1 -value 1 \
- -variable ::configDialogs::compiler::option__${var} \
- ] -column 2 -row $row
+ -variable ::configDialogues::compiler::option__${var} \
+ ] -column 2 -row $row -padx 5
incr row
}
- pack $nb0 -side top -fill both -expand 1
+ $nb0 raise ouput_tab
+ pack [$nb0 get_nb] -side top -fill both -expand 1
}
## Validate content of spinbox "Max length of IHEX-8 record"
@@ -1373,7 +1509,7 @@ namespace eval compiler {
variable opt_WARNING_LEVEL ;# Warning level
variable max_ihex_rec_length ;# Int: Maximum length of IHEX-8 record
- variable selected_assembler ;# Int: Preffered assembler (0==MCU8051IDE;1==ASEM-51;2==ASL)
+ variable selected_assembler ;# Int: Preferred assembler (0==MCU8051IDE;1==ASEM-51;2==ASL)
variable assembler_ASEM51_config;# Array: ASEM-51 configuration
variable assembler_ASEM51_addcfg;# Array: ASEM-51 additional configuration
variable assembler_ASL_config ;# Array: ASL configuration
@@ -1386,22 +1522,24 @@ namespace eval compiler {
variable sdcc_opt_str_opt ;# Array: SDCC configuration
variable sdcc_scs_str_opt ;# Array: SDCC configuration
+ variable makeutil_config ;# Array: Make utility configuration
+
## Assembler: MCU8051IDE
# Set local option variables
foreach var $defaults {
set var [lindex $var 0]
- set ::configDialogs::compiler::option_${var} [subst "\$::Compiler::Settings::$var"]
+ set ::configDialogues::compiler::option_${var} [subst -nocommands "\$::Compiler::Settings::$var"]
}
- set max_ihex_rec_length ${Compiler::Settings::max_ihex_rec_length}
+ set max_ihex_rec_length ${::Compiler::Settings::max_ihex_rec_length}
- # Set warning level
- set tmp {All}
+ # Set warning level
+ set tmp [mc "All"]
switch -- ${::Compiler::Settings::WARNING_LEVEL} {
- 0 {set tmp {All}}
- 1 {set tmp {Errors + Warnings}}
- 2 {set tmp {Errros only}}
- 3 {set tmp {Nothing}}
+ 0 {set tmp [mc "All"]}
+ 1 {set tmp [mc "Errors + Warnings"]}
+ 2 {set tmp [mc "Errros only"]}
+ 3 {set tmp [mc "Nothing"]}
default {puts stderr "Invalid WARNING_LEVEL value"}
}
set opt_WARNING_LEVEL $tmp
@@ -1427,9 +1565,15 @@ namespace eval compiler {
array set sdcc_opt_str_opt [array get ::ExternalCompiler::sdcc_optional_string_options]
# Copy semicolon separated optional string options
array set sdcc_scs_str_opt [array get ::ExternalCompiler::sdcc_scs_string_options]
+
+ ## GNU Make utility configuration
+ # General options
+ foreach key [array names ::ExternalCompiler::makeutil_config] {
+ set makeutil_config($key) $::ExternalCompiler::makeutil_config($key)
+ }
}
- ## Set compiler acording to local settings
+ ## Set compiler according to local settings
# @return void
proc use_settings {} {
variable defaults ;# List of default settings
@@ -1437,7 +1581,7 @@ namespace eval compiler {
variable conf_affected ;# Array of Bool: Affected parts of configuration
variable max_ihex_rec_length ;# Int: Maximum length of IHEX-8 record
- variable selected_assembler ;# Int: Preffered assembler (0==MCU8051IDE;1==ASEM-51;2==ASL)
+ variable selected_assembler ;# Int: Preferred assembler (0==MCU8051IDE;1==ASEM-51;2==ASL)
variable assembler_ASEM51_config;# Array: ASEM-51 configuration
variable assembler_ASEM51_addcfg;# Array: ASEM-51 additional configuration
variable assembler_ASL_config ;# Array: ASL configuration
@@ -1455,12 +1599,14 @@ namespace eval compiler {
variable sdcc_opt_str_opt ;# Array: SDCC configuration
variable sdcc_scs_str_opt ;# Array: SDCC configuration
+ variable makeutil_config ;# Array: Make utility configuration
+
## Assembler: MCU8051IDE
if {$conf_affected(MCU8051IDE)} {
# Set option variables
foreach var $defaults {
set var [lindex $var 0]
- set ::Compiler::Settings::$var [subst "\$::configDialogs::compiler::option_${var}"]
+ set ::Compiler::Settings::$var [subst -nocommands "\$::configDialogues::compiler::option_${var}"]
}
if {![string length $max_ihex_rec_length]} {
set max_ihex_rec_length 0
@@ -1469,23 +1615,23 @@ namespace eval compiler {
# Set warning level
set tmp ${::Compiler::Settings::WARNING_LEVEL}
- switch -- $opt_WARNING_LEVEL {
- {All} {
+ switch -- $opt_WARNING_LEVEL [subst {
+ {[mc "All"]} {
set tmp 0
}
- {Errors + Warnings} {
+ [mc "Errors + Warnings"] {
set tmp 1
}
- {Errros only} {
+ {[mc "Errros only"]} {
set tmp 2
}
- {Nothing} {
+ {[mc "Nothing"]} {
set tmp 3
}
default {
puts stderr "Invalid WARNING_LEVEL value"
}
- }
+ }]
set ::Compiler::Settings::WARNING_LEVEL $tmp
}
@@ -1534,7 +1680,7 @@ namespace eval compiler {
if {
$conf_affected(SDCC_Linker) || $conf_affected(SDCC_Optimization) ||
$conf_affected(SDCC_Code) || $conf_affected(SDCC_General)
- } {
+ } then {
# Copy boolean options
array set ::ExternalCompiler::sdcc_bool_options [array get sdcc_bool_opt]
# Copy string options
@@ -1545,6 +1691,12 @@ namespace eval compiler {
array set ::ExternalCompiler::sdcc_scs_string_options [array get sdcc_scs_str_opt]
}
+ ## GNU Make utility configuration
+ # General options
+ foreach key [array names ::ExternalCompiler::makeutil_config] {
+ set ::ExternalCompiler::makeutil_config($key) $makeutil_config($key)
+ }
+
${::X::actualProject} retrieve_compiler_settings
}
@@ -1555,16 +1707,16 @@ namespace eval compiler {
variable defaults ;# List of default settings
## Assembler: MCU8051IDE
- # Save option variables
+ # Save option variables
foreach var $defaults {
set var [lindex $var 0]
::settings setValue \
"Compiler/$var" \
- [subst "\$::Compiler::Settings::${var}"]
+ [subst -nocommands "\$::Compiler::Settings::${var}"]
}
::settings setValue "Compiler/max_ihex_rec_length" \
${::Compiler::Settings::max_ihex_rec_length}
- # Save warning level
+ # Save warning level
::settings setValue "Compiler/WARNING_LEVEL" \
${::Compiler::Settings::WARNING_LEVEL}
@@ -1599,6 +1751,13 @@ namespace eval compiler {
[array get ::ExternalCompiler::$array]
}
+ ## GNU Make utility configuration
+ # General options
+ foreach key [array names ::ExternalCompiler::makeutil_config] {
+ ::settings setValue "Compiler/make_${key}" \
+ $::ExternalCompiler::makeutil_config($key)
+ }
+
# Synchronize
::settings saveConfig
}
@@ -1610,7 +1769,7 @@ namespace eval compiler {
variable max_ihex_rec_length ;# Int: Maximum length of IHEX-8 record
## Assembler: MCU8051IDE
- # Load normal options
+ # Load normal options
foreach item $defaults {
set var [lindex $item 0]
set val [lindex $item 1]
@@ -1626,10 +1785,10 @@ namespace eval compiler {
![string is digit -strict ${::Compiler::Settings::max_ihex_rec_length}] ||
${::Compiler::Settings::max_ihex_rec_length} < 0 ||
${::Compiler::Settings::max_ihex_rec_length} > 255
- } {
+ } then {
set ::Compiler::Settings::max_ihex_rec_length 255
}
- # Load warning level
+ # Load warning level
set ::Compiler::Settings::WARNING_LEVEL \
[ ::settings getValue \
"Compiler/WARNING_LEVEL" \
@@ -1643,7 +1802,7 @@ namespace eval compiler {
]
## Assembler: ASEM51
- # Base config
+ # Base config
set conf [::settings getValue "Compiler/assembler_ASEM51_config" \
$::ExternalCompiler::assembler_ASEM51_config_def \
]
@@ -1657,7 +1816,7 @@ namespace eval compiler {
set ::ExternalCompiler::assembler_ASEM51_config($key) $val
}
}
- # Additional config
+ # Additional config
set conf [::settings getValue "Compiler/assembler_ASEM51_addcfg" \
$::ExternalCompiler::assembler_ASEM51_addcfg_def \
]
@@ -1687,7 +1846,7 @@ namespace eval compiler {
set ::ExternalCompiler::assembler_ASL_config($key) $val
}
}
- # Additional config
+ # Additional config
set conf [::settings getValue "Compiler/ASL" \
$::ExternalCompiler::assembler_ASL_addcfg_def \
]
@@ -1717,7 +1876,7 @@ namespace eval compiler {
set ::ExternalCompiler::assembler_AS31_config($key) $val
}
}
- # Additional config
+ # Additional config
set conf [::settings getValue "Compiler/AS31" \
$::ExternalCompiler::assembler_AS31_addcfg_def \
]
@@ -1738,7 +1897,7 @@ namespace eval compiler {
sdcc_optional_string_options sdcc_scs_string_options
} {
set conf [::settings getValue \
- "Compiler/$array" [subst "\$::ExternalCompiler::${array}_def"] \
+ "Compiler/$array" [subst -nocommands "\$::ExternalCompiler::${array}_def"] \
]
set len [llength $conf]
for {set i 0} {$i < $len} {incr i} {
@@ -1751,6 +1910,15 @@ namespace eval compiler {
}
}
}
+
+ ## GNU Make utility configuration
+ # General options
+ foreach {key def_value} ${::ExternalCompiler::makeutil_config_def} {
+ set conf [::settings getValue \
+ "Compiler/make_${key}" $def_value \
+ ]
+ set ::ExternalCompiler::makeutil_config($key) $conf
+ }
}
## Destroy the dialog
@@ -1793,7 +1961,7 @@ namespace eval compiler {
variable as31_custom_opts_text ;# Widget: Text widget "Custom options for AS31"
# External assembler configuration
- variable selected_assembler ;# Int: Preffered assembler (0==MCU8051IDE;1==ASEM-51;2==ASL)
+ variable selected_assembler ;# Int: Preferred assembler (0==MCU8051IDE;1==ASEM-51;2==ASL)
variable assembler_ASEM51_config;# Array: ASEM-51 configuration
variable assembler_ASEM51_addcfg;# Array: ASEM-51 additional configuration
variable assembler_ASL_config ;# Array: ASL configuration
@@ -1807,6 +1975,9 @@ namespace eval compiler {
variable sdcc_opt_str_opt ;# Array: SDCC configuration
variable sdcc_scs_str_opt ;# Array: SDCC configuration
+ # GNU Make utility configuration
+ variable makeutil_config ;# Array: Make utility configuration
+
# Confirmation dialog
if {
[tk_messageBox \
@@ -1816,26 +1987,26 @@ namespace eval compiler {
-title [mc "Restore defaults"] \
-message [mc "Are you sure that you want restore default settings ?"] \
] != {yes}
- } {
+ } then {
return
}
## Preferred assembler
set selected_assembler $::ExternalCompiler::selected_assembler_def
## Assembler MCU8051IDE
- # Restore normal options
+ # Restore normal options
foreach item $defaults {
set var [lindex $item 0]
set val [lindex $item 1]
- set ::configDialogs::compiler::option_${var} $val
+ set ::configDialogues::compiler::option_${var} $val
}
set max_ihex_rec_length 16
- # Warning level
- set opt_WARNING_LEVEL {All}
+ # Warning level
+ set opt_WARNING_LEVEL [mc "All"]
## ASEM-51
array set assembler_ASEM51_addcfg $::ExternalCompiler::assembler_ASEM51_addcfg_def
array set assembler_ASEM51_config $::ExternalCompiler::assembler_ASEM51_config_def
- # Custom options
+ # Custom options
if {[winfo exists $asm51_custom_opts_text]} {
$asm51_custom_opts_text delete 1.0 end
$asm51_custom_opts_text insert end $assembler_ASEM51_config(custom)
@@ -1843,7 +2014,7 @@ namespace eval compiler {
## ASL
array set assembler_ASL_addcfg $::ExternalCompiler::assembler_ASL_addcfg_def
array set assembler_ASL_config $::ExternalCompiler::assembler_ASL_config_def
- # Custom options
+ # Custom options
if {[winfo exists $asl_custom_opts_text]} {
$asl_custom_opts_text delete 1.0 end
$asl_custom_opts_text insert end $assembler_ASL_config(custom)
@@ -1851,25 +2022,37 @@ namespace eval compiler {
## AS31
array set assembler_AS31_addcfg $::ExternalCompiler::assembler_AS31_addcfg_def
array set assembler_AS31_config $::ExternalCompiler::assembler_AS31_config_def
- # Custom options
+ # Custom options
if {[winfo exists $as31_custom_opts_text]} {
$as31_custom_opts_text delete 1.0 end
$as31_custom_opts_text insert end $assembler_AS31_config(custom)
}
## SDCC
- # Copy boolean options
+ # Copy boolean options
array set sdcc_bool_opt ${::ExternalCompiler::sdcc_bool_options_def}
- # Copy string options
+ # Copy string options
array set sdcc_str_opt ${::ExternalCompiler::sdcc_string_options_def}
- # Copy optional strings
+ # Copy optional strings
array set sdcc_opt_str_opt ${::ExternalCompiler::sdcc_optional_string_options_def}
- # Copy semicolon separated optional string options
+ # Copy semicolon separated optional string options
array set sdcc_scs_str_opt ${::ExternalCompiler::sdcc_scs_string_options_def}
- # Custom options
+ # Custom options
if {[winfo exists $sdcc_custom_opts_text]} {
$sdcc_custom_opts_text delete 1.0 end
$sdcc_custom_opts_text insert end $sdcc_str_opt(custom)
}
+
+ ## GNU Make utility configuration
+ # General options
+ foreach {key value} ${::ExternalCompiler::makeutil_config_def} {
+ set makeutil_config($key) $value
+ }
+ # Adjust GUI to the current config
+ make_tab__adjust_gui
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/configdialogs.tcl b/lib/configdialogues/configdialogues.tcl
index cbffd16..7dba24e 100755..100644
--- a/lib/configdialogs/configdialogs.tcl
+++ b/lib/configdialogues/configdialogues.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,9 +21,14 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _CONFIGDIALOGUES_TCL ] } {
+set _CONFIGDIALOGUES_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# Implements various configuration dialogs
+# Implements various configuration dialogues
#
# Currently implemented:
# - Editor configuration
@@ -37,15 +42,19 @@
# - Terminal configuration
# --------------------------------------------------------------------------
-namespace eval configDialogs {
- # Load all available configuration dialogs into one common namespace
- source "${::LIB_DIRNAME}/configdialogs/editor_config.tcl" ;# Editor configuration dialog
- source "${::LIB_DIRNAME}/configdialogs/compiler_config.tcl" ;# Compiler configuration dialog
- source "${::LIB_DIRNAME}/configdialogs/rightpanel_config.tcl" ;# Right panel configuration dialog
- source "${::LIB_DIRNAME}/configdialogs/toolbar_config.tcl" ;# Main toolbar configuration dialog
- source "${::LIB_DIRNAME}/configdialogs/custom_commands_config.tcl" ;# Custom commands configuration dialog
- source "${::LIB_DIRNAME}/configdialogs/shortcuts_config.tcl" ;# Shortcuts configuration dialog
- source "${::LIB_DIRNAME}/configdialogs/global_config.tcl" ;# Global configuration dialog
- source "${::LIB_DIRNAME}/configdialogs/simulator_config.tcl" ;# Simulator configuration dialog
- source "${::LIB_DIRNAME}/configdialogs/terminal_config.tcl" ;# Terminal configuration dialog
+namespace eval configDialogues {
+ # Load all available configuration dialogues into one common namespace
+ source "${::LIB_DIRNAME}/configdialogues/editor_config.tcl" ;# Editor configuration dialog
+ source "${::LIB_DIRNAME}/configdialogues/compiler_config.tcl" ;# Compiler configuration dialog
+ source "${::LIB_DIRNAME}/configdialogues/rightpanel_config.tcl" ;# Right panel configuration dialog
+ source "${::LIB_DIRNAME}/configdialogues/toolbar_config.tcl" ;# Main toolbar configuration dialog
+ source "${::LIB_DIRNAME}/configdialogues/custom_commands_config.tcl" ;# Custom commands configuration dialog
+ source "${::LIB_DIRNAME}/configdialogues/shortcuts_config.tcl" ;# Shortcuts configuration dialog
+ source "${::LIB_DIRNAME}/configdialogues/global_config.tcl" ;# Global configuration dialog
+ source "${::LIB_DIRNAME}/configdialogues/simulator_config.tcl" ;# Simulator configuration dialog
+ source "${::LIB_DIRNAME}/configdialogues/terminal_config.tcl" ;# Terminal configuration dialog
+}
+
+# >>> File inclusion guard
}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/custom_commands_config.tcl b/lib/configdialogues/custom_commands_config.tcl
index e04ae1d..0919d21 100755..100644
--- a/lib/configdialogs/custom_commands_config.tcl
+++ b/lib/configdialogues/custom_commands_config.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 _CUSTOM_COMMANDS_CONFIG_TCL ] } {
+set _CUSTOM_COMMANDS_CONFIG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements custom commands configuration dialog
@@ -31,10 +36,10 @@ namespace eval custom_commands {
variable dialog_opened 0 ;# Bool: True if this dialog is already opened
# Font for text widgets
- variable cmd_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ variable cmd_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
variable text_0 ;# ID of text widget for command 0
@@ -45,11 +50,12 @@ namespace eval custom_commands {
variable cmfr_dialog ;# Array of Bool: Variable for checkbutton "Confirmation dialog"
variable results_dialog ;# Array of Bool: Variable for checkbutton "Show results"
variable ignore_errors ;# Array of Bool: Variable for checkbutton "Ignore errors"
+ variable run_in_term ;# Array of Bool: Variable for checkbutton "Ignore errors"
## Create the dialog
- # @parm Int = 0 - number of tab to raise
+ # @parm Int tab_number=0 - number of tab to raise
# @return void
- proc mkDialog args {
+ proc mkDialog {{tab_number 0}} {
variable win ;# ID of toplevel dialog window
variable dialog_opened ;# Bool: True if this dialog is already opened
variable cmd_font ;# Font for text widgets
@@ -62,78 +68,88 @@ namespace eval custom_commands {
variable cmfr_dialog ;# Array of Bool: Variable for checkbutton "Confirmation dialog"
variable results_dialog ;# Array of Bool: Variable for checkbutton "Show results"
variable ignore_errors ;# Array of Bool: Variable for checkbutton "Ignore errors"
+ variable run_in_term ;# Array of Bool: Variable for checkbutton "Ignore errors"
- # Destroy the dialog if it's alredy opened
+ # Destroy the dialog if it's already opened
if {$dialog_opened} {
destroy .custom_commands_config_dialog
}
set dialog_opened 1
# Create toplevel window
- set win [toplevel .custom_commands_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
+ set win [toplevel .custom_commands_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
-compound left \
-image ::ICONS::22::gear \
-text [mc "Edit custom commands"] \
- -font [font create -size -20]
+ -font [font create -size [expr {int(-20 * $::font_size_factor)}]]
# Create notebook
- set nb [ttk::notebook $win.nb]
+ set nb [ModernNoteBook $win.nb]
# Create notebook tabs
for {set idx 0} {$idx < 3} {incr idx} {
# Create tab
- set tab [frame $nb.frame_${idx}]
- $nb add $tab -image ::ICONS::22::gear$idx
+ set tab [$nb insert end tab_$idx -image ::ICONS::22::gear$idx]
# Create "Short description" (entry and label)
pack [Label $tab.desc_label \
-text [mc "Short description"] \
- -helptext [mc "This string will be used as status bar tip (max. 50 chars)"]
- ] -anchor w
+ -helptext [mc "This string will be used as status bar tip (max. 100 chars)"]
+ ] -anchor w -padx 5 -pady 5
pack [ttk::entry $tab.desc_entry \
-validate key \
- -textvariable ::configDialogs::custom_commands::description($idx) \
- -validatecommand {::configDialogs::custom_commands::desc_validate %P} \
- ] -fill x
+ -textvariable ::configDialogues::custom_commands::description($idx) \
+ -validatecommand {::configDialogues::custom_commands::desc_validate %P} \
+ ] -fill x -padx 5
## Create options labelframe
label $tab.labelframe_label -compound left -image ::ICONS::16::configure -text [mc "Options"]
set frame [ttk::labelframe $tab.labelframe -labelwidget $tab.labelframe_label]
- # Create checkbutton "Confirmation dialog"
+ # Create checkbutton "Confirmation dialog"
set button [checkbutton $frame.cmfr_cbutton -anchor w \
-text [mc "Confirmation dialog"] \
- -variable ::configDialogs::custom_commands::cmfr_dialog($idx) \
+ -variable ::configDialogues::custom_commands::cmfr_dialog($idx) \
]
- pack $button -anchor w
- DynamicHelp::add $button -text [mc "Invkoke dialog to confirm command execution"]
- # Create checkbutton "Show results"
+ grid $button -sticky w -row 1 -column 1 -padx 5 -pady 2
+ DynamicHelp::add $button -text [mc "Invoke dialog to confirm command execution."]
+ # Create checkbutton "Show results"
set button [checkbutton $frame.results_cbutton \
-text [mc "Show results"] -anchor w \
- -variable ::configDialogs::custom_commands::results_dialog($idx) \
+ -variable ::configDialogues::custom_commands::results_dialog($idx) \
]
- pack $button -anchor w
- DynamicHelp::add $button -text [mc "After finish show dialog with results"]
- # Create checkbutton "Ignore errors"
+ grid $button -sticky w -row 2 -column 1 -padx 5 -pady 2
+ DynamicHelp::add $button -text [mc "After finish show dialog with results."]
+ # Create checkbutton "Ignore errors"
set button [checkbutton $frame.ignore_cbutton \
-text [mc "Ignore errors"] -anchor w \
- -variable ::configDialogs::custom_commands::ignore_errors($idx) \
+ -variable ::configDialogues::custom_commands::ignore_errors($idx) \
+ ]
+ grid $button -sticky w -row 1 -column 2 -padx 5 -pady 2
+ DynamicHelp::add $button -text [mc "Do not invoke error dialog if the process fails."]
+ # Create checkbutton "Run in terminal"
+ set button [checkbutton $frame.run_in_term_button \
+ -text [mc "Run in terminal"] -anchor w \
+ -variable ::configDialogues::custom_commands::run_in_term($idx) \
]
- pack $button -anchor w
- DynamicHelp::add $button -text [mc "Do not invoke error dialog if the process fail"]
+ grid $button -sticky w -row 2 -column 2 -padx 5 -pady 2
+ DynamicHelp::add $button -text [mc "Run interactively in terminal emulator."]
+ if {!$::PROGRAM_AVAILABLE(urxvt)} {
+ $button configure -state disabled
+ }
pack $frame -fill x -pady 10 -padx 5
# Create label "Commands to execute" and help button
set frame [frame $tab.cmd_label_frame]
pack [label $frame.label \
- -text [mc "Shell script to execute"] \
- ] -side left
+ -text [mc "Bash script to execute."] \
+ ] -side left -padx 5
pack [ttk::button $frame.button \
-image ::ICONS::16::help \
-style Flat.TButton \
- -command {::configDialogs::custom_commands::show_help} \
+ -command {::configDialogues::custom_commands::show_help} \
] -side right
DynamicHelp::add $frame.button \
-text [mc "Show help"]
@@ -152,16 +168,17 @@ namespace eval custom_commands {
-orient vertical \
-command "$text yview" \
] -side right -fill y
- pack $frame -fill both -expand 1
+ pack $frame -fill both -expand 1 -padx 5
# Set NS variable -- text widget reference
set text_$idx $text
# Get settins from the program
- if {[regexp {\s*[01]\s+[01]\s+[01]\s*} $::X::custom_command_options($idx)]} {
+ if {[regexp {\s*[01]\s+[01]\s+[01]\s+[01]\s*} $::X::custom_command_options($idx)]} {
set cmfr_dialog($idx) [lindex $::X::custom_command_options($idx) 0]
set results_dialog($idx) [lindex $::X::custom_command_options($idx) 1]
set ignore_errors($idx) [lindex $::X::custom_command_options($idx) 2]
+ set run_in_term($idx) [lindex $::X::custom_command_options($idx) 3]
}
set description($idx) $::X::custom_command_desc($idx)
@@ -169,32 +186,29 @@ namespace eval custom_commands {
}
# Raise tab
- if {$args == {}} {
- set args 0
- }
- $nb select [lindex [$nb tabs] $args]
+ $nb raise [lindex [$nb pages] $tab_number]
# Create button frame at the bottom
set but_frame [frame $win.button_frame]
# Button "Ok"
- pack [ttk::button $but_frame.but_ok \
+ pack [ttk::button $but_frame.but_ok \
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::custom_commands::OK} \
- ] -side right
+ -command {::configDialogues::custom_commands::OK} \
+ ] -side right -padx 2 -pady 2
# Button "Cancel"
- pack [ttk::button $but_frame.but_cancel \
- -text [mc "Cancel"] \
- -compound left \
- -image ::ICONS::16::button_cancel \
- -command {::configDialogs::custom_commands::CANCEL} \
- ] -side right
+ pack [ttk::button $but_frame.but_cancel \
+ -text [mc "Cancel"] \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command {::configDialogues::custom_commands::CANCEL} \
+ ] -side right -padx 2 -pady 2
# Pack frames and notebook
pack $but_frame -side bottom -fill x -expand 0 -anchor s -padx 10 -pady 5
pack $win.header_label -side top -pady 6
- pack $nb -side top -fill both -expand 1 -padx 10
+ pack [$nb get_nb] -side top -fill both -expand 1 -padx 10
# Finalize dialog creation
wm iconphoto $win ::ICONS::16::configure
@@ -204,7 +218,7 @@ namespace eval custom_commands {
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::custom_commands::CANCEL
+ ::configDialogues::custom_commands::CANCEL
}
tkwait window $win
}
@@ -212,7 +226,7 @@ namespace eval custom_commands {
## Show help window
# @return void
proc show_help {} {
- # Destroy prevoius help window
+ # Destroy previous help window
if {[winfo exists .custom_commands_help]} {
destroy .custom_commands_help
return
@@ -221,7 +235,7 @@ namespace eval custom_commands {
set y [winfo pointery .]
# Create new help window
- set win [toplevel .custom_commands_help -class {Help} -bg {#EEEEEE}]
+ set win [toplevel .custom_commands_help -class {Help} -bg ${::COMMON_BG_COLOR}]
set frame [frame $win.f -bg {#555555} -bd 0 -padx 1 -pady 1]
wm overrideredirect $win 1
@@ -247,27 +261,35 @@ namespace eval custom_commands {
pack $frame -fill both -expand 1
# Create text tags
- $text tag configure tag_bold_small \
- -font [font create -weight bold -size -12 -family $::DEFAULT_FIXED_FONT]
- $text tag configure tag_bold_big \
- -foreground {#0000DD} -underline 1 \
- -font [font create -weight bold -size -14 -family $::DEFAULT_FIXED_FONT]
+ $text tag configure tag_bold_small \
+ -font [font create \
+ -weight bold \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family $::DEFAULT_FIXED_FONT \
+ ]
+ $text tag configure tag_bold_big \
+ -foreground {#0000DD} -underline 1 \
+ -font [font create \
+ -weight bold \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -family $::DEFAULT_FIXED_FONT \
+ ]
# Fill in the text widget
$text insert end [mc "VARIABLES:"]
$text tag add tag_bold_big {insert linestart} {insert lineend}
- $text insert end "\n %URL"
+ $text insert end "\n %URI"
$text tag add tag_bold_small {insert linestart} {insert lineend}
- $text insert end [mc "\t\tThe full URL of the current file\n"]
- $text insert end " %URLS"
+ $text insert end [mc "\t\tThe full URI of the current file\n"]
+ $text insert end " %URIS"
$text tag add tag_bold_small {insert linestart} {insert lineend}
- $text insert end [mc "\t\tList of the URLs of all open documents\n"]
+ $text insert end [mc "\t\tList of the URIs of all open documents\n"]
$text insert end " %directory"
$text tag add tag_bold_small {insert linestart} {insert lineend}
$text insert end [mc "\t\tProject directory\n"]
$text insert end " %filename"
$text tag add tag_bold_small {insert linestart} {insert lineend}
- $text insert end [mc "\t\tThe filename of the current document\n"]
+ $text insert end [mc "\t\tThe file name of the current document\n"]
$text insert end " %basename"
$text tag add tag_bold_small {insert linestart} {insert lineend}
$text insert end [mc "\t\tSame as %filename, but without extension\n"]
@@ -295,14 +317,14 @@ namespace eval custom_commands {
[list insert linestart+${start}c] \
[list insert linestart+${end}c]
}
- $text insert end [mc "\nare not avaliable if external editor is used"]
+ $text insert end [mc "\nare not available if external editor is used"]
# Show the text widget
$text configure -state disabled
pack $text -side bottom -fill both -expand 1
# Set window attributes
- wm geometry $win "=400x270+$x+$y"
+ wm geometry $win "=420x330+$x+$y"
wm protocol $win WM_DELETE_WINDOW "
grab release $win
destroy $win
@@ -320,9 +342,9 @@ namespace eval custom_commands {
# @parm String content - String to validate
# @return Bool - result
proc desc_validate {content} {
- if {[string length $content] > 50} {
+ if {[string length $content] > 100} {
return 0
- } {
+ } else {
return 1
}
}
@@ -334,6 +356,7 @@ namespace eval custom_commands {
variable cmfr_dialog ;# Array of Bool: Variable for checkbutton "Confirmation dialog"
variable results_dialog ;# Array of Bool: Variable for checkbutton "Show results"
variable ignore_errors ;# Array of Bool: Variable for checkbutton "Ignore errors"
+ variable run_in_term ;# Array of Bool: Variable for checkbutton "Ignore errors"
variable text_0 ;# ID of text widget for command 0
variable text_1 ;# ID of text widget for command 1
@@ -342,15 +365,16 @@ namespace eval custom_commands {
for {set i 0} {$i < 3} {incr i} {
# Change content of configuration variables
set ::X::custom_command_options($i) \
- "$cmfr_dialog($i) $results_dialog($i) $ignore_errors($i)"
+ "$cmfr_dialog($i) $results_dialog($i) $ignore_errors($i) $run_in_term($i)"
set ::X::custom_command_desc($i) $description($i)
- set ::X::custom_command_cmd($i) [regsub {\n$} [[subst "\$text_${i}"] get 1.0 end] {}]
+ set ::X::custom_command_cmd($i) [regsub {\n$} [[subst -nocommands "\$text_${i}"] get 1.0 end] {}]
# Change status tips
if {[winfo exists .mainIconBar.custom$i]} {
setStatusTip \
-widget .mainIconBar.custom$i \
-text [mc "Custom command %s: %s" $i $description($i)]
+ ::DynamicHelp::add .mainIconBar.custom$i -text [mc "Custom command %s: %s" $i $description($i)]
}
}
}
@@ -377,9 +401,17 @@ namespace eval custom_commands {
proc load_config {} {
for {set i 0} {$i < 3} {incr i} {
# Options
+ set def_options $::X::custom_command_options($i)
set ::X::custom_command_options($i) [::settings \
getValue "Custom command $i/options" \
$::X::custom_command_options($i)]
+ if {![regexp {\s*[01]\s+[01]\s+[01]\s+[01]\s*} $::X::custom_command_options($i)]} {
+ puts stderr "Invalid custom command options, setting to defaults."
+ set ::X::custom_command_options($i) $def_options
+ }
+ if {!$::PROGRAM_AVAILABLE(urxvt)} {
+ set ::X::custom_command_options($i) [lreplace $::X::custom_command_options($i) 3 3 0]
+ }
# Description
set ::X::custom_command_desc($i) [::settings \
getValue "Custom command $i/description" \
@@ -416,3 +448,7 @@ namespace eval custom_commands {
CANCEL
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/editor_config.tcl b/lib/configdialogues/editor_config.tcl
index bd51a55..7936eda 100755..100644
--- a/lib/configdialogs/editor_config.tcl
+++ b/lib/configdialogues/editor_config.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 _EDITOR_CONFIG_TCL ] } {
+set _EDITOR_CONFIG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements editor configuration dialog
@@ -33,7 +38,7 @@ namespace eval editor {
variable win ;# ID of dialog toplevel window
variable button_index 0 ;# Button index (for creating many buttons)
- variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
+ variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
variable changed ;# Bool: Settings changed
variable apply_button ;# ID of button "Apply"
@@ -51,7 +56,7 @@ namespace eval editor {
variable highlight_tab_lst ;# Widget: Tab "Syntax highlight"/"Code listing"
## Tab "Editor"
- ## Int: Editor to use
+ ## Int: Editor to use
# 0 - Native editor
# 1 - Vim
# 2 - Emacs
@@ -66,12 +71,13 @@ namespace eval editor {
variable intentation_mode ;# Editor indentation mode
variable spaces_no_tabs ;# Bool: Use spaces instead of tabs
variable number_of_spaces ;# Int: Number of spaces to use instead of tab
+ variable tab_width ;# Int: Tab width
variable autosave ;# Int: Autosave interval in minutes (0 == disabled)
variable auto_brackets ;# Automaticaly insert oposite brackets, quotes, etc.
variable hg_trailing_sp ;# Bool: Highlight trailing space
variable auto_completion ;# Bool: Enable popup-based completion
variable cline_completion ;# Bool: Enable popup-based completion for command line
- variable avaliable_encodings {
+ variable available_encodings {
utf-8 iso8859-1 iso8859-2
iso8859-3 iso8859-4 iso8859-5
iso8859-6 iso8859-7 iso8859-8
@@ -88,6 +94,7 @@ namespace eval editor {
variable color_current_line ;# RGB: Backgound color for current line
variable color_bookmark ;# RGB: Backgound color for bookmarks
variable color_breakpoint ;# RGB: Backgound color for breakpoints
+ variable color_breakpoint_I ;# RGB: Backgound color for invalid breakpoints
variable color_simulator_line ;# RGB: Backgound color for simulator line
variable color_error_line ;# RGB: Backgound color for line containing an error
variable color_trailing_space ;# RGB: Backgound color for trailing space
@@ -101,7 +108,7 @@ namespace eval editor {
variable sample_text_family ;# Font family
## Tab "Assembler syntax highlight"
- variable hightlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
+ variable highlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
variable list_of_tags_asm ;# List: Highlighting tags
variable highlight_tab_scr_text_asm ;# ID of text widget for configuring syntax
variable highlight_tab_scr_sample_text_asm ;# ID of text widget for sample text
@@ -109,26 +116,26 @@ namespace eval editor {
variable highlight_tab_checkbuttons_asm
## Tab "C" syntax highlight"
- variable hightlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
+ variable highlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
variable list_of_tags_C ;# List: Highlighting tags
variable highlight_tab_scr_text_C ;# ID of text widget for configuring syntax
variable highlight_tab_scr_sample_text_C ;# ID of text widget for sample text
- # List of checkbuttons affected by changing cursor position in sample text
+ # List of checkbuttons affected by changing cursor position in sample text
variable highlight_tab_checkbuttons_C
## Tab "LST" syntax highlight"
- variable hightlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
+ variable highlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
variable list_of_tags_lst ;# List: Highlighting tags
variable highlight_tab_scr_text_lst ;# ID of text widget for configuring syntax
variable highlight_tab_scr_sample_text_lst ;# ID of text widget for sample text
- # List of checkbuttons affected by changing cursor position in sample text
+ # List of checkbuttons affected by changing cursor position in sample text
variable highlight_tab_checkbuttons_lst
## Create the dialog
- # @parm String = {} - Tab to raise on start up
+ # @parm String tab_to_raise={} - Tab to raise on start up
# @return void
- proc mkDialog args {
+ proc mkDialog {{tab_to_raise {}}} {
variable nb ;# Widget: Notebook itself
variable editor_tab ;# Widget: Tab "Editor"
variable general_tab ;# Widget: Tab "General"
@@ -150,9 +157,9 @@ namespace eval editor {
variable win ;# ID of dialog toplevel window
variable dialog_opened ;# Bool: True if this dialog is already opened
variable button_index ;# Button index (for creating many buttons)
- variable hightlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
- variable hightlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
- variable hightlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
+ variable highlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
+ variable highlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
+ variable highlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
set button_index 0
@@ -167,125 +174,113 @@ namespace eval editor {
# Get settings from the program
getSettings
# Create toplevel window
- set win [toplevel .editor_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
+ set win [toplevel .editor_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
-compound left \
-image ::ICONS::32::configure \
-text [mc "Editor configuration"] \
- -font [font create -size -20]
+ -font [font create -size [expr {int(-20 * $::font_size_factor)}]]
+
+ # Create button "Apply" in advance
+ set but_frame [frame $win.button_frame]
+ set apply_button [ttk::button $but_frame.but_apply \
+ -text [mc "Apply"] \
+ -state disabled \
+ -compound left \
+ -image ::ICONS::16::ok \
+ -command {::configDialogues::editor::APPLY} \
+ ]
# Create notebook
- set nb [ttk::notebook $win.nb]
- bind $nb <<NotebookTabChanged>> {after idle {
- set tab_index [%W index [%W select]]
-
- if {[lsearch ${::configDialogs::editor::tab_created_so_far} $tab_index] == -1} {
- lappend ::configDialogs::editor::tab_created_so_far $tab_index
-
- if {!$::MICROSOFT_WINDOWS} {
- ::configDialogs::editor::create_tab \
- [lindex \
- [list editor general colors fonts highlight] \
- $tab_index \
- ]
- } else { ;# External editors are not available on Microsoft Windows
- ::configDialogs::editor::create_tab \
- [lindex \
- [list general colors fonts highlight] \
- $tab_index \
- ]
- }
- }
- }}
- set ::configDialogs::editor::tab_created_so_far [list]
+ set nb [ModernNoteBook $win.nb]
+ set ::configDialogues::editor::tab_created_so_far [list]
# Create Tab "Editor"
if {!$::MICROSOFT_WINDOWS} { ;# External editors are not available on Microsoft Windows
- set editor_tab [frame $nb.editor_tab]
- $nb add $editor_tab -text [mc "Editor"]
+ set editor_tab [$nb insert end editor_tab -text [mc "Editor"] -createcmd {::configDialogues::editor::create_tab editor}]
}
# Create Tab "General"
- set general_tab [frame $nb.general_tab]
- $nb add $general_tab -text [mc "General"]
+ set general_tab [$nb insert end general_tab \
+ -text [mc "General"] \
+ -createcmd {::configDialogues::editor::create_tab general} \
+ ]
# Create Tab "Colors"
- set colors_tab [frame $nb.colors_tab]
- $nb add $colors_tab -text [mc "Colors"]
+ set colors_tab [$nb insert end colors_tab \
+ -text [mc "Colors"] \
+ -createcmd {::configDialogues::editor::create_tab colors} \
+ ]
# Create Tab "Fonts"
- set fonts_tab [frame $nb.fonts_tab]
- $nb add $fonts_tab -text [mc "Fonts"]
+ set fonts_tab [$nb insert end fonts_tab \
+ -text [mc "Fonts"] \
+ -createcmd {::configDialogues::editor::create_tab fonts} \
+ ]
# Create Tab "Highlight"
- set highlight_tab [frame $nb.highlight_tab]
- $nb add $highlight_tab -text [mc "Syntax highlight"]
+ set highlight_tab [$nb insert end highlight_tab \
+ -text [mc "Syntax highlight"] \
+ -createcmd {::configDialogues::editor::create_tab highlight} \
+ ]
#
## Finalize
#
- if {[string length $args]} {
+ if {[string length $tab_to_raise]} {
if {!$::MICROSOFT_WINDOWS} { ;# External editors are not available on Microsoft Windows
- $nb select [lindex [$nb tabs] \
- [lsearch [list {Editor} {General} {Colors} {Fonts} {Highlight}] $args]]
- } {
- $nb select [lindex [$nb tabs] \
- [lsearch [list {General} {Colors} {Fonts} {Highlight}] $args]]
+ $nb raise [lindex [$nb pages] \
+ [lsearch [list {Editor} {General} {Colors} {Fonts} {Highlight}] $tab_to_raise]]
+ } else {
+ $nb raise [lindex [$nb pages] \
+ [lsearch [list {General} {Colors} {Fonts} {Highlight}] $tab_to_raise]]
}
- } {
+ } else {
if {!$::MICROSOFT_WINDOWS} { ;# External editors are not available on Microsoft Windows
if {$editor_to_use} {
- foreach tab [list $highlight_tab $general_tab] {
- $nb tab $tab -state disabled
+ foreach tab [list highlight_tab general_tab] {
+ $nb itemconfigure $tab -state disabled
}
- $nb select $editor_tab
- } {
- $nb select $general_tab
+ $nb raise editor_tab
+ } else {
+ $nb raise general_tab
}
- } {
- $nb select $general_tab
+ } else {
+ $nb raise general_tab
}
}
# Create button frame at the bottom
- set but_frame [frame $win.button_frame]
- # Button "Apply"
- set apply_button [ttk::button $but_frame.but_apply \
- -text [mc "Apply"] \
- -state disabled \
- -compound left \
- -image ::ICONS::16::ok \
- -command {::configDialogs::editor::APPLY} \
- ]
pack $apply_button -side left
- # Button "Ok"
- pack [ttk::button $but_frame.but_ok \
+ # Button "Ok"
+ pack [ttk::button $but_frame.but_ok \
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::editor::OK} \
- ] -side right
- # Button "Cancel"
+ -command {::configDialogues::editor::OK} \
+ ] -side right -padx 2
+ # Button "Cancel"
pack [ttk::button $but_frame.but_cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {::configDialogs::editor::CANCEL} \
- ] -side right
+ -command {::configDialogues::editor::CANCEL} \
+ ] -side right -padx 2
# Pack frames and notebook
pack $but_frame -side bottom -fill x -expand 0 -anchor s -padx 10 -pady 5
pack $win.header_label -side top -pady 6
- pack $nb -side top -fill both -expand 1 -padx 10
+ pack [$nb get_nb] -side top -fill both -expand 1 -padx 10
# Finalize creation of the dialog
wm transient $win .
wm iconphoto $win ::ICONS::16::configure
wm title $win [mc "Editor configuration - %s" ${::APPNAME}]
- wm geometry $win =380x440
- wm resizable $win 0 0
+ wm geometry $win =350x500
+ wm resizable $win 0 1
+ wm minsize $win 350 470
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::editor::CANCEL
+ ::configDialogues::editor::CANCEL
}
tkwait window $win
}
@@ -299,7 +294,7 @@ namespace eval editor {
variable general_tab ;# Widget: Tab "General"
variable colors_tab ;# Widget: Tab "Colors"
variable fonts_tab ;# Widget: Tab "Fonts"
- variable avaliable_encodings ;# Avaliable encodings
+ variable available_encodings ;# available encodings
variable highlight_tab ;# Widget: Tab "Syntax highlight"
variable highlight_tab_asm ;# Widget: Tab "Syntax highlight"/"Assembler"
variable highlight_tab_C ;# Widget: Tab "Syntax highlight"/"C language"
@@ -320,42 +315,48 @@ namespace eval editor {
# Preferred editor
grid [label $editor_top_frame.editor_lbl \
-text [mc "Preferred editor:"] -anchor w \
- ] -row 0 -column 0 -sticky w
+ ] -row 0 -column 0 -sticky w -pady 10 -padx 10
set row 1
set i 0
- foreach text {
- {Native editor} Vim Emacs Nano dav le
- } {
+ foreach text [list \
+ [mc "Native editor"] \
+ {Vim} \
+ {Emacs} \
+ {Nano} \
+ {dav} \
+ {le} \
+ ] {
grid [radiobutton $editor_top_frame.rabut_$i \
- -variable ::configDialogs::editor::editor_to_use \
+ -variable ::configDialogues::editor::editor_to_use \
-value $i -text $text -state disabled \
- -command ::configDialogs::editor::editor_to_use_changed \
+ -command ::configDialogues::editor::editor_to_use_changed \
] -column 0 -padx 25 -row $row -sticky w
incr i
incr row
}
$editor_top_frame.rabut_0 configure -state normal
- if {${::PROGRAM_AVALIABLE(urxvt)}} {
- if {${::PROGRAM_AVALIABLE(vim)}} {
+ if {${::PROGRAM_AVAILABLE(urxvt)}} {
+ if {${::PROGRAM_AVAILABLE(vim)}} {
$editor_top_frame.rabut_1 configure -state normal
}
- if {${::PROGRAM_AVALIABLE(emacs)}} {
+ if {${::PROGRAM_AVAILABLE(emacs)}} {
$editor_top_frame.rabut_2 configure -state normal
}
- if {${::PROGRAM_AVALIABLE(nano)}} {
+ if {${::PROGRAM_AVAILABLE(nano)}} {
$editor_top_frame.rabut_3 configure -state normal
}
- if {${::PROGRAM_AVALIABLE(dav)}} {
+ if {${::PROGRAM_AVAILABLE(dav)}} {
$editor_top_frame.rabut_4 configure -state normal
}
- if {${::PROGRAM_AVALIABLE(le)}} {
+ if {${::PROGRAM_AVAILABLE(le)}} {
$editor_top_frame.rabut_5 configure -state normal
}
}
- grid [label $editor_top_frame.editor_note \
- -fg {#555555} -font [font create \
- -family {helvetica} \
- -size -14 -slant italic \
+ grid [label $editor_top_frame.editor_note \
+ -fg {#555555} -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -slant italic \
] \
-text [mc "(This change will take effect upon next start.)"] \
] -row 20 -column 0 -columnspan 2 -sticky w
@@ -381,72 +382,85 @@ namespace eval editor {
# Item: "Auto brackets"
grid [Label $editing_labelframe.autob_lbl \
-text [mc "Auto brackets"] \
- -helptext [mc "If you type a left bracket, editor\nwill automaticaly insert right bracket"] \
+ -helptext [mc "If you type a left bracket, editor\nwill automatically insert right bracket"] \
] -row 1 -column 0 -sticky w -padx 5
- grid [checkbutton $editing_labelframe.autob_chbutton \
- -variable ::configDialogs::editor::auto_brackets \
- -command ::configDialogs::editor::settings_changed \
+ grid [checkbutton $editing_labelframe.autob_chbutton \
+ -variable ::configDialogues::editor::auto_brackets \
+ -command ::configDialogues::editor::settings_changed \
] -row 1 -column 1 -sticky w -padx 5
DynamicHelp::add $editing_labelframe.autob_chbutton \
- -text [mc "When you type a left bracket editor\nwill automaticaly insert right bracket"]
+ -text [mc "When you type a left bracket editor\nwill automatically insert right bracket"]
# Item: "Indentation mode"
grid [Label $editing_labelframe.imode_lbl \
-text [mc "Indentation mode"] \
- -helptext [mc "What to do when you press enter\n\tnone\t- start on the begining of the next line\n\tnormal\t- keep indention of the previous line"] \
+ -helptext [mc "What to do when you press enter\n\tnone\t- start on the beginning of the next line\n\tnormal\t- keep indention of the previous line"] \
] -row 2 -column 0 -sticky w -padx 5
- grid [ttk::combobox $editing_labelframe.imode_cb \
- -values [list [mc "none"] [mc "normal"]] \
- -state readonly \
- -width 0 \
- -textvariable ::configDialogs::editor::intentation_mode \
+ grid [ttk::combobox $editing_labelframe.imode_cb \
+ -values [list [mc "none"] [mc "normal"]] \
+ -state readonly \
+ -width 0 \
+ -textvariable ::configDialogues::editor::intentation_mode \
] -row 2 -column 1 -sticky we -padx 5
bind $editing_labelframe.imode_cb <<ComboboxSelected>> \
- {::configDialogs::editor::settings_changed}
+ {::configDialogues::editor::settings_changed}
DynamicHelp::add $editing_labelframe.imode_cb \
- -text [mc "What to do when you press enter\n\tnone\t- start on the begining of the next line\n\tnormal\t- keep indention of the previous line"]
- # Item: "Insert ' ' instead of '\t'"
+ -text [mc "What to do when you press enter\n\tnone\t- start on the beginning of the next line\n\tnormal\t- keep indention of the previous line"]
+ # Item: "Tab width"
+ grid [Label $editing_labelframe.tabw_lbl\
+ -text [mc "Tab width"] \
+ -helptext [mc "Maximum width of the tab character, measured in number of spaces"] \
+ ] -row 3 -column 0 -sticky w -padx 5
+ grid [ttk::spinbox $editing_labelframe.tabw_spinbox \
+ -from 1 -to 40 -validate all \
+ -validatecommand "::configDialogues::editor::tabw_spinbox_val %P" \
+ -textvariable ::configDialogues::editor::tab_width \
+ -command ::configDialogues::editor::settings_changed \
+ ] -row 3 -column 1 -sticky we -padx 5
+ DynamicHelp::add $editing_labelframe.tabw_spinbox \
+ -text [mc "Maximum width of the tab character, measured in number of spaces"]
+ # Item: "Insert spaces instead of tabs"
grid [Label $editing_labelframe.tabis_lbl \
- -text [mc "Insert ' ' instead of '\\t'"] \
+ -text [mc "Insert spaces instead of tabs"] \
-helptext [mc "Use spaces instead of tabs"] \
- ] -row 3 -column 0 -sticky w -padx 5
+ ] -row 4 -column 0 -sticky w -padx 5
grid [checkbutton $editing_labelframe.tabis_chbutton \
- -variable ::configDialogs::editor::spaces_no_tabs \
- -command ::configDialogs::editor::settings_changed \
- ] -row 3 -column 1 -sticky w -padx 5
+ -variable ::configDialogues::editor::spaces_no_tabs \
+ -command ::configDialogues::editor::settings_changed \
+ ] -row 4 -column 1 -sticky w -padx 5
DynamicHelp::add $editing_labelframe.tabis_chbutton \
-text [mc "Use spaces instead of tabs"]
# Item: "Number of spaces"
grid [Label $editing_labelframe.nofs_lbl \
-text [mc "Number of spaces"] \
-helptext [mc "Number of spaces to use instead of tabs"] \
- ] -row 4 -column 0 -sticky w -padx 5
- grid [spinbox $editing_labelframe.nofs_spinbox \
- -from 1 -to 16 -bg white -validate all \
- -vcmd "::configDialogs::editor::nofs_spinbox_val %P" \
- -textvariable ::configDialogs::editor::number_of_spaces \
- -command ::configDialogs::editor::settings_changed \
- ] -row 4 -column 1 -sticky we -padx 5
+ ] -row 5 -column 0 -sticky w -padx 5
+ grid [ttk::spinbox $editing_labelframe.nofs_spinbox \
+ -from 1 -to 16 -validate all \
+ -validatecommand "::configDialogues::editor::nofs_spinbox_val %P" \
+ -textvariable ::configDialogues::editor::number_of_spaces \
+ -command ::configDialogues::editor::settings_changed \
+ ] -row 5 -column 1 -sticky we -padx 5
DynamicHelp::add $editing_labelframe.nofs_spinbox \
-text [mc "Number of spaces to use instead of tabs"]
# Item: "Enable autocompletion"
grid [Label $editing_labelframe.completion_lbl \
-text [mc "Enable autocompletion"] \
-helptext [mc "Enable popup-based autocompletion"] \
- ] -row 5 -column 0 -sticky w -padx 5
+ ] -row 6 -column 0 -sticky w -padx 5
grid [checkbutton $editing_labelframe.completion_chbutton \
- -variable ::configDialogs::editor::auto_completion \
- -command ::configDialogs::editor::settings_changed \
- ] -row 5 -column 1 -sticky w -padx 5
+ -variable ::configDialogues::editor::auto_completion \
+ -command ::configDialogues::editor::settings_changed \
+ ] -row 6 -column 1 -sticky w -padx 5
DynamicHelp::add $editing_labelframe.completion_chbutton \
-text [mc "Enable popup-based autocompletion"]
# Item: "Highlight trailing space"
grid [Label $editing_labelframe.trail_sp_lbl \
-text [mc "Highlight trailing space"] \
- ] -row 6 -column 0 -sticky w -padx 5
+ ] -row 7 -column 0 -sticky w -padx 5
grid [checkbutton $editing_labelframe.trail_sp_chbutton \
- -variable ::configDialogs::editor::hg_trailing_sp \
- -command ::configDialogs::editor::settings_changed \
- ] -row 6 -column 1 -sticky w -padx 5
+ -variable ::configDialogues::editor::hg_trailing_sp \
+ -command ::configDialogues::editor::settings_changed \
+ ] -row 7 -column 1 -sticky w -padx 5
# Finalize
grid columnconfigure $editing_labelframe 0 -minsize 200
grid columnconfigure $editing_labelframe 1 -weight 1
@@ -459,7 +473,7 @@ namespace eval editor {
grid [checkbutton $open_labelframe.show_editor_tab_bar_chb \
-onvalue 1 -offvalue 0 \
-variable ::CONFIG(SHOW_EDITOR_TAB_BAR) \
- -command ::configDialogs::editor::settings_changed \
+ -command ::configDialogues::editor::settings_changed \
] -row 0 -column 1 -sticky w -padx 5
# Item: "Default charset"
@@ -470,11 +484,11 @@ namespace eval editor {
grid [ttk::combobox $open_labelframe.charset_cb \
-width 0 \
-state readonly \
- -values $avaliable_encodings \
- -textvariable ::configDialogs::editor::default_encoding \
+ -values $available_encodings \
+ -textvariable ::configDialogues::editor::default_encoding \
] -row 1 -column 1 -sticky we -padx 5
bind $open_labelframe.charset_cb <<ComboboxSelected>> \
- {::configDialogs::editor::settings_changed}
+ {::configDialogues::editor::settings_changed}
DynamicHelp::add $open_labelframe.charset_cb \
-text [mc "When you open file with unknown encoding\nthis encoding will be used"]
# Item: "Default EOL"
@@ -483,28 +497,28 @@ namespace eval editor {
-helptext [mc "When you open file with unknown\nEOL (End Of Line) this EOL will be used"] \
] -row 2 -column 0 -sticky w -padx 5
grid [ttk::combobox $open_labelframe.eol_cb \
- -textvariable ::configDialogs::editor::default_eol \
+ -textvariable ::configDialogues::editor::default_eol \
-width 0 \
-state readonly \
-values {{lf} {cr} {crlf}} \
] -row 2 -column 1 -sticky we -padx 5
bind $open_labelframe.eol_cb <<ComboboxSelected>> \
- {::configDialogs::editor::settings_changed}
+ {::configDialogues::editor::settings_changed}
DynamicHelp::add $open_labelframe.eol_cb \
-text [mc "When you open file with unknown\nEOL (End Of Line) this EOL will be used"]
# Item: "Autosave"
grid [Label $open_labelframe.autosave_lbl \
- -text [mc "Autosave interval"] \
+ -text [mc "Autosave interval \[minutes\]"] \
-helptext [mc "Autosave interval in minutes (0 means disabled)"] \
] -row 3 -column 0 -sticky w -padx 5
grid [ttk::combobox $open_labelframe.autosave_cb \
-width 0 \
-state readonly \
-values {0 1 2 5 10 15 20 30 45 60} \
- -textvariable ::configDialogs::editor::autosave \
+ -textvariable ::configDialogues::editor::autosave \
] -row 3 -column 1 -sticky we -padx 5
bind $open_labelframe.autosave_cb <<ComboboxSelected>> \
- {::configDialogs::editor::settings_changed}
+ {::configDialogues::editor::settings_changed}
DynamicHelp::add $open_labelframe.autosave_cb \
-text [mc "Autosave interval in minutes (0 means disabled)"]
# Finalize
@@ -518,19 +532,19 @@ namespace eval editor {
-helptext [mc "Enable popup-based autocompletion"] \
] -row 0 -column 0 -sticky w -padx 5
grid [checkbutton $cmd_labelframe.completion_chbutton \
- -variable ::configDialogs::editor::cline_completion \
- -command ::configDialogs::editor::settings_changed \
+ -variable ::configDialogues::editor::cline_completion \
+ -command ::configDialogues::editor::settings_changed \
] -row 0 -column 1 -sticky w -padx 5
# Finalize
grid columnconfigure $cmd_labelframe 0 -minsize 200
grid columnconfigure $cmd_labelframe 1 -weight 1
# Pack label frames of tab "General"
- pack $editing_labelframe -fill both -expand 1 -padx 5
- pack $open_labelframe -fill both -expand 1 -padx 5 -pady 10
- pack $cmd_labelframe -fill both -expand 1 -padx 5
+ pack $editing_labelframe -fill both -expand 1 -padx 5 -pady 5
+ pack $open_labelframe -fill both -expand 1 -padx 5 -pady 5
+ pack $cmd_labelframe -fill both -expand 1 -padx 5 -pady 5
}
- {colors} {;# Tab "Colors"
+ {colors} { ;# Tab "Colors"
# Create label frames
set frm_textAreaBackfround [ttk::labelframe \
$colors_tab.textAreaBackfround \
@@ -546,19 +560,21 @@ namespace eval editor {
# Create buttons in label frame "Text area background"
set row 0
foreach name {
- normal_text selected_text current_line
- bookmark simulator_line breakpoint
- error_line trailing_space
- } text {
- {Normal text} {Selected text} {Current line}
- {Bookmark} {Simulator line} {Breakpoint}
- {Line with an error} {Trailing space}
- } {
-
- mk_button_select_menu \
- $frm_textAreaBackfround \
- "::configDialogs::editor::color_$name" \
- $name \
+ normal_text selected_text current_line
+ bookmark simulator_line breakpoint
+ breakpoint_I error_line trailing_space
+ } text [list \
+ [mc "Normal text"] [mc "Selected text"] \
+ [mc "Current line"] [mc "Bookmark"] \
+ [mc "Simulator line"] [mc "Breakpoint"] \
+ [mc "Invalid breakpoint"] [mc "Line with an error"] \
+ [mc "Trailing space"] \
+ ] {
+
+ mk_button_select_menu \
+ $frm_textAreaBackfround \
+ "::configDialogues::editor::color_$name" \
+ $name \
$text
}
@@ -569,14 +585,15 @@ namespace eval editor {
foreach name {
iconBorder_bg lineNumbers_bg
lineNumbers_fg
- } text {
- {Icon border background} {Line numbers background}
- {Line numbers foreground}
- } {
+ } text [list \
+ [mc "Icon border background"] \
+ [mc "Line numbers background"] \
+ [mc "Line numbers foreground"] \
+ ] {
mk_button_select_menu \
$frm_additionalElements \
- "::configDialogs::editor::color_$name" \
+ "::configDialogues::editor::color_$name" \
$name \
$text
@@ -584,8 +601,8 @@ namespace eval editor {
}
# Pack label frames
- pack $frm_textAreaBackfround -fill both -expand 1 -pady 5
- pack $frm_additionalElements -fill both -expand 1 -pady 5
+ pack $frm_textAreaBackfround -fill both -expand 1 -pady 5 -padx 5
+ pack $frm_additionalElements -fill both -expand 1 -pady 5 -padx 5
}
{fonts} { ;# Tab "Fonts"
# Create frames
@@ -607,17 +624,21 @@ namespace eval editor {
-highlightthickness 0 \
-height 15 \
-width 25 \
+ -font [font create \
+ -size -13 \
+ -family {helvetica} \
+ ] \
]
pack $scrollbar -side right -fill y
pack $listBox -side left -fill both -expand 1
- $listBox bindText <1> {::configDialogs::editor::select_font_family %W}
+ $listBox bindText <1> {::configDialogues::editor::select_font_family %W}
if {[winfo exists $listBox.c]} {
bind $listBox.c <Button-5> {%W yview scroll +5 units; break}
bind $listBox.c <Button-4> {%W yview scroll -5 units; break}
}
# Create size listbox
- set scrollbar [ttk::scrollbar $top_right_frame.scrollbar \
+ set scrollbar [ttk::scrollbar $top_right_frame.scrollbar\
-orient vertical \
-command "$top_right_frame.list_box yview" \
]
@@ -629,10 +650,14 @@ namespace eval editor {
-width 7 \
-height 15 \
-highlightthickness 0 \
+ -font [font create \
+ -size -13 \
+ -family {helvetica} \
+ ] \
]
pack $scrollbar -side right -fill y
pack $listBox -side left -fill y
- $listBox bindText <1> {::configDialogs::editor::select_font_size %W}
+ $listBox bindText <1> {::configDialogues::editor::select_font_size %W}
if {[winfo exists $listBox.c]} {
bind $listBox.c <Button-5> {%W yview scroll +5 units; break}
bind $listBox.c <Button-4> {%W yview scroll -5 units; break}
@@ -640,7 +665,7 @@ namespace eval editor {
# Create sample text entry
set sample_text [entry $bottom_frame.entry \
- -bg #EEEEEE \
+ -bg ${::COMMON_BG_COLOR} \
-bd 0 \
-width 30 \
-font [font create \
@@ -659,7 +684,7 @@ namespace eval editor {
# Fill up sizes listbox
for {set i 4} {$i < 22} {incr i} {
- $top_right_frame.list_box insert end $i -text $i
+ $listBox insert end $i -text "$i"
if {$i == $sample_text_size} {
$top_right_frame.list_box selection set $i
}
@@ -671,46 +696,44 @@ namespace eval editor {
# Fill up fonts listbox
after idle [subst {
- set i 0
- foreach font \[font families\] {
- set font_ref \[font create -family \$font\]
- if {!\[font metrics \$font_ref -fixed\]} {
+ if {[winfo exists $top_left_frame.list_box]} {
+ set i 0
+ foreach font \[font families\] {
+ set font_ref \[font create -family \$font\]
+ if {!\[font metrics \$font_ref -fixed\]} {
+ font delete \$font_ref
+ continue
+ }
font delete \$font_ref
- continue
- }
- font delete \$font_ref
- $top_left_frame.list_box insert end \$i -text \$font
- if {\$font == {$sample_text_family}} {
- $top_left_frame.list_box selection set \$i
+ $top_left_frame.list_box insert end \$i -text \$font
+ if {\$font == {$sample_text_family}} {
+ $top_left_frame.list_box selection set \$i
+ }
+ incr i
+ update
}
- incr i
- update
+ destroy $bottom_frame.progress
}
- destroy $bottom_frame.progress
}]
}
- {highlight} { ;# Tab "Syntax highlight"
- set highlight_notebook [ttk::notebook $highlight_tab.nb]
- bind $highlight_notebook <<NotebookTabChanged>> {after idle {
- set tab_index [%W index [%W select]]
-
- if {[lsearch ${::configDialogs::editor::hn_tab_created_so_far} $tab_index] == -1} {
- lappend ::configDialogs::editor::hn_tab_created_so_far $tab_index
- ::configDialogs::editor::create_highlight_tab $tab_index
- }
- }}
- set ::configDialogs::editor::hn_tab_created_so_far [list]
-
- set highlight_tab_asm [frame $highlight_notebook.highlight_tab_asm]
- $highlight_notebook add $highlight_tab_asm -text [mc "Assembler"]
- set highlight_tab_C [frame $highlight_notebook.highlight_tab_C]
- $highlight_notebook add $highlight_tab_C -text [mc "C language"]
- set highlight_tab_lst [frame $highlight_notebook.highlight_tab_lst]
- $highlight_notebook add $highlight_tab_lst -text [mc "Code listing"]
-
- $highlight_notebook select $highlight_tab_asm
- pack $highlight_notebook -fill both -expand 1
+ {highlight} { ;# Tab "Syntax highlight"
+ set highlight_notebook [ModernNoteBook $highlight_tab.nb]
+ set highlight_tab_asm [$highlight_notebook insert end highlight_tab_asm \
+ -createcmd {::configDialogues::editor::create_highlight_tab 0} \
+ -text [mc "Assembler"] \
+ ]
+ set highlight_tab_C [$highlight_notebook insert end highlight_tab_C \
+ -createcmd {::configDialogues::editor::create_highlight_tab 1} \
+ -text [mc "C language"] \
+ ]
+ set highlight_tab_lst [$highlight_notebook insert end highlight_tab_lst \
+ -createcmd {::configDialogues::editor::create_highlight_tab 2} \
+ -text [mc "Code listing"] \
+ ]
+
+ $highlight_notebook raise highlight_tab_asm
+ pack [$highlight_notebook get_nb] -fill both -expand 1
}
}
}
@@ -723,9 +746,9 @@ namespace eval editor {
# @retuer void
proc create_highlight_tab {language} {
## General
- variable hightlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
- variable hightlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
- variable hightlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
+ variable highlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
+ variable highlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
+ variable highlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
variable highlight_tab_asm ;# Widget: Tab "Syntax highlight"/"Assembler"
variable highlight_tab_C ;# Widget: Tab "Syntax highlight"/"C language"
variable highlight_tab_lst ;# Widget: Tab "Syntax highlight"/"Code listing"
@@ -752,15 +775,15 @@ namespace eval editor {
switch -- $language {
0 {
set tab_frame $highlight_tab_asm
- set hightlight_tags $hightlight_tags_asm
+ set highlight_tags $highlight_tags_asm
}
1 {
set tab_frame $highlight_tab_C
- set hightlight_tags $hightlight_tags_C
+ set highlight_tags $highlight_tags_C
}
2 {
set tab_frame $highlight_tab_lst
- set hightlight_tags $hightlight_tags_lst
+ set highlight_tags $highlight_tags_lst
}
}
@@ -777,20 +800,44 @@ namespace eval editor {
]
# SRC header (in SCR frame)
set highlight_tab_scr_header [text $highlight_tab_scr_frm.scr_text_h \
- -bd 0 -height 2 -bg {#DFDFDF} -height 1 -width 0 \
- -cursor left_ptr -font [font create -family any -size -16] \
+ -bd 0 \
+ -height 2 \
+ -bg {#DFDFDF} \
+ -height 1 \
+ -width 0 \
+ -cursor left_ptr \
+ -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size -16 \
+ ] \
]
bind $highlight_tab_scr_header <<Selection>> {false_selection %W}
bind $highlight_tab_scr_header <ButtonRelease-3> {break}
bind $highlight_tab_scr_header <Key-Menu> {break}
- # list of tags (in SCR frame)
+ # Padding above the list of tags (see below)
+ set padding_widget [text $highlight_tab_scr_frm.padding \
+ -bd 0 \
+ -bg {#FFFFFF} \
+ -cursor left_ptr \
+ -font [font create \
+ -size -15 \
+ -family $::DEFAULT_FIXED_FONT \
+ ] \
+ -height 1 \
+ -width 1 \
+ ]
+ # List of tags (in SCR frame)
set highlight_tab_scr_text [text $highlight_tab_scr_frm.scr_text_c \
-bd 0 \
-bg {#FFFFFF} \
-cursor left_ptr \
- -font ${::Editor::defaultFont_bold} \
+ -font [font create \
+ -size -12 \
+ -family $::DEFAULT_FIXED_FONT \
+ ] \
-yscrollcommand "$highlight_tab_scrollbar set" \
-width 1 \
+ -tabstyle wordprocessor \
]
$highlight_tab_scr_text tag configure sel_user \
-borderwidth 1 -background {#CCCCFF} -relief raised
@@ -799,7 +846,7 @@ namespace eval editor {
1 {set sh_ns CsyntaxHighlight}
2 {set sh_ns LSTsyntaxHighlight}
}
- ${sh_ns}::create_tags $highlight_tab_scr_text ${::Editor::fontSize} ${::Editor::fontFamily} $hightlight_tags
+ ${sh_ns}::create_tags $highlight_tab_scr_text 12 $::DEFAULT_FIXED_FONT $highlight_tags 1
bind $highlight_tab_scr_text <<Selection>> {false_selection %W}
bind $highlight_tab_scr_text <ButtonRelease-3> {break}
bind $highlight_tab_scr_text <Key-Menu> {break}
@@ -807,13 +854,21 @@ namespace eval editor {
bind $highlight_tab_scr_text <Button-5> "$highlight_tab_scr_text yview scroll +1 units"
# Sample text
set highlight_tab_scr_sample_text [text $tab_frame.scr_text_sample \
- -bd 1 -bg {#FFFFFF} -width 0 -height 3 -maxundo 0 \
- -wrap none -selectborderwidth 1 -highlightcolor gray \
+ -bd 1 \
+ -bg {#FFFFFF} \
+ -width 0 \
+ -height 3 \
+ -maxundo 0 \
+ -wrap none \
+ -selectborderwidth 1 \
+ -highlightcolor gray \
+ -tabstyle wordprocessor \
+ -font [font create -weight bold -size -12 -family $::DEFAULT_FIXED_FONT] \
]
- ${sh_ns}::create_tags $highlight_tab_scr_sample_text 12 $::DEFAULT_FIXED_FONT $hightlight_tags
- bind $highlight_tab_scr_sample_text <KeyRelease> "::configDialogs::editor::parse %K $language"
+ ${sh_ns}::create_tags $highlight_tab_scr_sample_text 12 $::DEFAULT_FIXED_FONT $highlight_tags
+ bind $highlight_tab_scr_sample_text <KeyRelease> "::configDialogues::editor::parse %K $language"
bind $highlight_tab_scr_sample_text <ButtonPress-1> \
- "::configDialogs::editor::syntax_sample_text_click %x %y $language"
+ "::configDialogues::editor::syntax_sample_text_click %x %y $language"
switch -- $language {
0 {
$highlight_tab_scr_sample_text insert end [join [list \
@@ -835,15 +890,16 @@ namespace eval editor {
}
2 {
$highlight_tab_scr_sample_text insert end [join {
- { 0055 18 X data 55h} \
- { =1 32 sub_0:} \
- {0014 1122 =1 33 +1 inc A} \
+ { 0055 18 X data 55h} \
+ { =1 32 sub_0:} \
+ {0014 1122 =1 33 +1 inc A} \
} "\n"]
}
}
# Pack widgets
pack $highlight_tab_scr_header -in $highlight_tab_scr_frm -fill x -expand 1 -anchor n
+ pack $padding_widget -in $highlight_tab_scr_frm -fill x
pack $highlight_tab_scr_text -in $highlight_tab_scr_frm -fill both -expand 1
pack $highlight_tab_scrollbar -side right -fill y
pack $highlight_tab_scr_frm -side left -expand 1 -fill both
@@ -867,7 +923,7 @@ namespace eval editor {
set row 0 ;# Number of current row
set list_of_tags {} ;# List of highlighting tags
set highlight_tab_checkbuttons {} ;# List of check buttons
- foreach key $hightlight_tags {
+ foreach key $highlight_tags {
incr row
# Local variables
@@ -886,21 +942,21 @@ namespace eval editor {
# Determinate font weight
if {$bold} {
set weight bold
- } {
+ } else {
set weight normal
}
# Determinate font slant
if {$italic} {
set slant italic
- } {
+ } else {
set slant roman
}
# Initialize some NS variables
- set ::configDialogs::editor::__${language}_${row}_italic $italic
- set ::configDialogs::editor::__${language}_${row}_overstrike $overstrike
- set ::configDialogs::editor::__${language}_${row}_bold $bold
+ set ::configDialogues::editor::__${language}_${row}_italic $italic
+ set ::configDialogues::editor::__${language}_${row}_overstrike $overstrike
+ set ::configDialogues::editor::__${language}_${row}_bold $bold
# Insert tag name and some '\t'
$highlight_tab_scr_text insert end $content
@@ -911,33 +967,45 @@ namespace eval editor {
$highlight_tab_scr_text insert end [string repeat { } [expr {24 - $len}]]
# Insert checkbutton "Italic"
- set button [checkbutton $highlight_tab_scr_frm.italic_${row} \
- -command "::configDialogs::editor::change_style italic $row $language" \
- -variable ::configDialogs::editor::__${language}_${row}_italic \
- -relief flat -pady 0 -highlightthickness 0 -bg {#FFFFFF} \
- -activebackground {#FFFFFF} \
+ set button [checkbutton $highlight_tab_scr_frm.italic_${row} \
+ -command "::configDialogues::editor::change_style italic $row $language"\
+ -variable ::configDialogues::editor::__${language}_${row}_italic \
+ -relief flat \
+ -pady 0 \
+ -highlightthickness 0 \
+ -bg {#FFFFFF} \
+ -activebackground {#FFFFFF} \
+ -selectcolor {#FFFFFF} \
]
lappend localButtons $button
$highlight_tab_scr_text window create end -window $button
$highlight_tab_scr_text insert end " "
# Insert checkbutton "Overstike"
- set button [checkbutton $highlight_tab_scr_frm.overstrike_${row} \
- -command "::configDialogs::editor::change_style overstrike $row $language" \
- -variable ::configDialogs::editor::__${language}_${row}_overstrike \
- -relief flat -pady 0 -highlightthickness 0 -bg {#FFFFFF} \
- -activebackground {#FFFFFF} \
+ set button [checkbutton $highlight_tab_scr_frm.overstrike_${row} \
+ -command "::configDialogues::editor::change_style overstrike $row $language" \
+ -variable ::configDialogues::editor::__${language}_${row}_overstrike \
+ -relief flat \
+ -pady 0 \
+ -highlightthickness 0 \
+ -bg {#FFFFFF} \
+ -activebackground {#FFFFFF} \
+ -selectcolor {#FFFFFF} \
]
lappend localButtons $button
$highlight_tab_scr_text window create end -window $button
$highlight_tab_scr_text insert end " "
# Insert checkbutton "Bold"
- set button [checkbutton $highlight_tab_scr_frm.bold_${row} \
- -command "::configDialogs::editor::change_style bold $row $language" \
- -variable ::configDialogs::editor::__${language}_${row}_bold \
- -relief flat -pady 0 -highlightthickness 0 -bg {#FFFFFF} \
- -activebackground {#FFFFFF} \
+ set button [checkbutton $highlight_tab_scr_frm.bold_${row} \
+ -command "::configDialogues::editor::change_style bold $row $language" \
+ -variable ::configDialogues::editor::__${language}_${row}_bold \
+ -relief flat \
+ -pady 0 \
+ -highlightthickness 0 \
+ -bg {#FFFFFF} \
+ -activebackground {#FFFFFF} \
+ -selectcolor {#FFFFFF} \
]
lappend localButtons $button
$highlight_tab_scr_text window create end -window $button
@@ -947,7 +1015,7 @@ namespace eval editor {
set button [button $highlight_tab_scr_frm.color_${row} \
-bd 1 -relief raised -pady 0 -highlightthickness 0 \
-bg $color -activebackground $color -width 3 \
- -command "::configDialogs::editor::select_bg_color $highlight_tab_scr_frm.color_${row} $row $language" \
+ -command "::configDialogues::editor::select_bg_color $highlight_tab_scr_frm.color_${row} $row $language" \
]
$highlight_tab_scr_text window create end -window $button
@@ -992,7 +1060,7 @@ namespace eval editor {
${sh_ns}::highlight $highlight_tab_scr_sample_text $i
}
- } {
+ } else {
parse {} 1
}
}
@@ -1001,7 +1069,7 @@ namespace eval editor {
# @return void
proc editor_to_use_changed {} {
variable nb ;# Widget: Notebook itself
- variable editor_to_use ;# Int: Prefred editor
+ variable editor_to_use ;# Int: Preferred editor
variable general_tab ;# Widget: Tab "General"
variable highlight_tab ;# Widget: Tab "Syntax highlight"
@@ -1009,42 +1077,42 @@ namespace eval editor {
if {$editor_to_use} {
set state disabled
- } {
+ } else {
set state normal
}
- foreach tab [list $general_tab $highlight_tab] {
- $nb tab $tab -state $state
+ foreach tab [list general_tab highlight_tab] {
+ $nb itemconfigure tab -state $state
}
}
## Create some text tag in the given text widget
# @parm Widget text_widget - target text widget
- # @parm Int item - index of the tag (in variable hightlight_tags)
+ # @parm Int item - index of the tag (in variable highlight_tags)
# @parm Int language - Highlighting pattern
# 0 - Assembler
# 1 - C language
# 2 - Code listing
# @return void
proc create_tags {text_widget item language} {
- variable hightlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
- variable hightlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
- variable hightlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
+ variable highlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
+ variable highlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
+ variable highlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
# Determinate set of highlighting tags
switch -- $language {
0 {
- set hightlight_tags $hightlight_tags_asm
+ set highlight_tags $highlight_tags_asm
}
1 {
- set hightlight_tags $hightlight_tags_C
+ set highlight_tags $highlight_tags_C
}
2 {
- set hightlight_tags $hightlight_tags_lst
+ set highlight_tags $highlight_tags_lst
}
}
# Gain tag definition
- set item [lindex $hightlight_tags $item]
+ set item [lindex $highlight_tags $item]
# Create array of tag attributes
for {set i 0} {$i < 5} {incr i} {
set tag($i) [lindex $item $i]
@@ -1054,37 +1122,43 @@ namespace eval editor {
if {$tag(1) == {}} {
set tag(1) black
}
- # Font weight
+ # Font slant
if {$tag(3) == 1} {
set tag(3) italic
- } {
+ } else {
set tag(3) roman
}
- # Font slant
- if {$tag(4) == 1} {
- set tag(4) bold
- } {
+
+ # Font weight
+ if {!$::MICROSOFT_WINDOWS} {
+ if {$tag(4) == 1} {
+ set tag(4) bold
+ } else {
+ set tag(4) normal
+ }
+ } else {
set tag(4) normal
}
# Create the tag
- $text_widget tag configure $tag(0) \
- -foreground $tag(1) \
- -font [ font create \
- -overstrike $tag(2) \
- -slant $tag(3) \
- -weight $tag(4) \
- -size -12 \
- -family $::DEFAULT_FIXED_FONT]
+ $text_widget tag configure $tag(0) \
+ -foreground $tag(1) \
+ -font [ font create \
+ -overstrike $tag(2) \
+ -slant $tag(3) \
+ -weight $tag(4) \
+ -size -12 \
+ -family $::DEFAULT_FIXED_FONT \
+ ]
}
## Call procedure syntax_find
# @parm Int x - relative X coordinate
# @parm Int y - relative Y coordinate
# @parm Int language - Highlighting pattern
- # 0 - Assembler
- # 1 - C language
- # 2 - Code listing
+ # 0 - Assembler
+ # 1 - C language
+ # 2 - Code listing
# @return void
proc syntax_sample_text_click {x y language} {
variable highlight_tab_scr_sample_text_asm ;# ID of text widget for sample text
@@ -1158,7 +1232,10 @@ namespace eval editor {
set index [$highlight_tab_scr_text index sel_user.first]
set buttons [lindex $highlight_tab_checkbuttons [expr {int($index) - 1}]]
foreach button $buttons {
- $button configure -bg {#FFFFFF} -activebackground {#FFFFFF}
+ $button configure \
+ -bg {#FFFFFF} \
+ -selectcolor {#FFFFFF} \
+ -activebackground {#FFFFFF}
}
$highlight_tab_scr_text tag remove sel_user 1.0 end
}
@@ -1167,6 +1244,19 @@ namespace eval editor {
set index [$highlight_tab_scr_sample_text index $text_index]
set index [$highlight_tab_scr_sample_text tag names $index]
+ # Remove tags subdued to other tags which are also contained in the tag list
+ if {[llength $index] > 1} {
+ set idx [lsearch -ascii -exact $index tag_c_dox_comment]
+ if {$idx != -1} {
+ set index [lreplace $index $idx $idx]
+ }
+
+ set idx [lsearch -ascii -exact $index tag_normal]
+ if {$idx != -1} {
+ set index [lreplace $index $idx $idx]
+ }
+ }
+
# If the tag could not be determinated -> abort
set index [lindex $index 0]
if {$index == {}} {return}
@@ -1178,7 +1268,10 @@ namespace eval editor {
# Change background color for checkbuttons related to the tag
set buttons [lindex $highlight_tab_checkbuttons $index]
foreach button $buttons {
- $button configure -bg {#CCCCFF} -activebackground {#CCCCFF}
+ $button configure \
+ -bg {#CCCCFF} \
+ -selectcolor {#CCCCFF} \
+ -activebackground {#CCCCFF}
}
# Select row related to the tag
@@ -1211,6 +1304,8 @@ namespace eval editor {
}
}
+ set lineNumber [expr {int([$widget index insert])}]
+
# Keep indentication level after line break
if {$key == "KP_Enter" || $key == "Return"} {
# Get content of previous line
@@ -1230,33 +1325,33 @@ namespace eval editor {
}
# Syntax highlight for assembler or code listing
- if {$language == 0 && $language == 2} {
+ if {$language == 0 || $language == 2} {
# Highlight current line
if {[lsearch {
Left Right Down Up Insert Home Prior
End Next Shift_R Control_R Alt_L Alt_R
Control_L Shift_L Escape
- } $key] == -1} {
+ } $key] == -1} then {
if {$language == 0} {
- ASMsyntaxHighlight::highlight $widget $lineNumber
- } {
- LSTsyntaxHighlight::highlight $widget $lineNumber
+ ::ASMsyntaxHighlight::highlight $widget $lineNumber
+ } else {
+ ::LSTsyntaxHighlight::highlight $widget $lineNumber
}
}
# Syntax highlight for C language
- } {
+ } else {
# Highlight all lines
if {[lsearch {
Left Right Down Up Insert Home Prior
End Next Shift_R Control_R Alt_L Alt_R
Control_L Shift_L Escape
- } $key] == -1} {
+ } $key] == -1} then {
set status 1
set end_line [expr {int([$widget index end])}]
for {set line 0} {$line < $end_line} {incr line} {
- set status [CsyntaxHighlight::highlight \
- $widget $line $status \
+ set status [::CsyntaxHighlight::highlight \
+ $widget $line $status \
]
}
}
@@ -1320,9 +1415,9 @@ namespace eval editor {
# 2 - Code listing
# @return void
proc change_style {what row language} {
- variable hightlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
- variable hightlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
- variable hightlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
+ variable highlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
+ variable highlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
+ variable highlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
variable highlight_tab_scr_text_C ;# ID of text widget for configuring syntax
variable highlight_tab_scr_sample_text_C ;# ID of text widget for sample text
@@ -1339,33 +1434,33 @@ namespace eval editor {
0 {
set highlight_tab_scr_sample_text $highlight_tab_scr_sample_text_asm
set highlight_tab_scr_text $highlight_tab_scr_text_asm
- set hightlight_tags hightlight_tags_asm
+ set highlight_tags highlight_tags_asm
}
1 {
set highlight_tab_scr_sample_text $highlight_tab_scr_sample_text_C
set highlight_tab_scr_text $highlight_tab_scr_text_C
- set hightlight_tags hightlight_tags_C
+ set highlight_tags highlight_tags_C
}
2 {
set highlight_tab_scr_sample_text $highlight_tab_scr_sample_text_lst
set highlight_tab_scr_text $highlight_tab_scr_text_lst
- set hightlight_tags hightlight_tags_lst
+ set highlight_tags highlight_tags_lst
}
}
# Decide what to change
switch -- $what {
overstrike {
- lset $hightlight_tags "$row 2" \
- [subst "\${::configDialogs::editor::__${language}_[expr {$row + 1}]_overstrike}"]
+ lset $highlight_tags [list $row 2] \
+ [subst -nocommands "\${::configDialogues::editor::__${language}_[expr {$row + 1}]_overstrike}"]
}
italic {
- lset $hightlight_tags "$row 3" \
- [subst "\${::configDialogs::editor::__${language}_[expr {$row + 1}]_italic}"]
+ lset $highlight_tags [list $row 3] \
+ [subst -nocommands "\${::configDialogues::editor::__${language}_[expr {$row + 1}]_italic}"]
}
bold {
- lset $hightlight_tags "$row 4" \
- [subst "\${::configDialogs::editor::__${language}_[expr {$row + 1}]_bold}"]
+ lset $highlight_tags [list $row 4] \
+ [subst -nocommands "\${::configDialogues::editor::__${language}_[expr {$row + 1}]_bold}"]
}
default {return}
}
@@ -1382,12 +1477,33 @@ namespace eval editor {
# @parm String content - content to validate
# @return Bool - success
proc nofs_spinbox_val {content} {
+ if {![string length $content]} {
+ return 1
+ }
if {![string is digit $content]} {
return 0
}
if {$content > 16 || $content < 1} {
return 0
}
+ ::configDialogues::editor::settings_changed
+ return 1
+ }
+
+ ## Validate content of tabw_spinbox
+ # @parm String content - content to validate
+ # @return Bool - success
+ proc tabw_spinbox_val {content} {
+ if {![string length $content]} {
+ return 1
+ }
+ if {![string is digit $content]} {
+ return 0
+ }
+ if {$content > 40 || $content < 1} {
+ return 0
+ }
+ ::configDialogues::editor::settings_changed
return 1
}
@@ -1401,9 +1517,9 @@ namespace eval editor {
# @return void
proc select_bg_color {button row language} {
variable win ;# ID of dialog toplevel window
- variable hightlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
- variable hightlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
- variable hightlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
+ variable highlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
+ variable highlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
+ variable highlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
variable highlight_tab_scr_text_asm ;# ID of text widget for configuring syntax
variable highlight_tab_scr_sample_text_asm ;# ID of text widget for sample text
@@ -1417,20 +1533,20 @@ namespace eval editor {
0 {
set highlight_tab_scr_sample_text $highlight_tab_scr_sample_text_asm
set highlight_tab_scr_text $highlight_tab_scr_text_asm
- set hightlight_tags_var hightlight_tags_asm
- set hightlight_tags $hightlight_tags_asm
+ set highlight_tags_var highlight_tags_asm
+ set highlight_tags $highlight_tags_asm
}
1 {
set highlight_tab_scr_sample_text $highlight_tab_scr_sample_text_C
set highlight_tab_scr_text $highlight_tab_scr_text_C
- set hightlight_tags_var hightlight_tags_C
- set hightlight_tags $hightlight_tags_C
+ set highlight_tags_var highlight_tags_C
+ set highlight_tags $highlight_tags_C
}
2 {
set highlight_tab_scr_sample_text $highlight_tab_scr_sample_text_lst
set highlight_tab_scr_text $highlight_tab_scr_text_lst
- set hightlight_tags_var hightlight_tags_lst
- set hightlight_tags $hightlight_tags_lst
+ set highlight_tags_var highlight_tags_lst
+ set highlight_tags $highlight_tags_lst
}
}
@@ -1442,7 +1558,7 @@ namespace eval editor {
}
# Invoke new color selection dialog
- set color [lindex $hightlight_tags "$row 1"]
+ set color [lindex $highlight_tags [list $row 1]]
set color [SelectColor .select_color \
-parent $win \
-color $color \
@@ -1451,7 +1567,7 @@ namespace eval editor {
# Change button background color
if {$color != {}} {
- lset $hightlight_tags_var "$row 1" $color
+ lset $highlight_tags_var [list $row 1] $color
$button configure -bg $color -activebackground $color
}
@@ -1484,7 +1600,7 @@ namespace eval editor {
tag_label {return {Label}}
tag_instruction {return {Instruction}}
tag_sfr {return {SFR register}}
- tag_indirect {return {Indirect adress}}
+ tag_indirect {return {Indirect address}}
tag_imm_char {return {Immediate char}}
tag_imm_hex {return {Immediate hex}}
tag_imm_oct {return {Immediate oct}}
@@ -1498,6 +1614,7 @@ namespace eval editor {
tag_c_data_type {return {Data type}}
tag_c_dec {return {Decimal}}
tag_c_hex {return {Hexadecimal}}
+ tag_c_bin {return {Binary number}}
tag_c_oct {return {Octal}}
tag_c_char {return {Char}}
tag_c_float {return {Float}}
@@ -1542,7 +1659,7 @@ namespace eval editor {
variable button_index ;# Button index (for creating many buttons)
# Get color from the given variable
- set color [subst "\${$variable}"]
+ set color [subst -nocommands "\${$variable}"]
# Create button label
grid [label $parent.${name}${button_index} \
@@ -1554,7 +1671,7 @@ namespace eval editor {
set button [button $parent.but_normal_text$button_index \
-bd 1 -relief raised -pady 0 -highlightthickness 0 \
-bg $color -width 10 -activebackground $color \
- -command "::configDialogs::editor::select_color $variable $parent.but_normal_text$button_index"
+ -command "::configDialogues::editor::select_color $variable $parent.but_normal_text$button_index"
]
# Show button
@@ -1578,10 +1695,10 @@ namespace eval editor {
}
# Invoke new color selection dialog
- set color [subst "\$$variable"]
- set color [SelectColor .select_color \
- -parent $win \
- -color $color \
+ set color [subst -nocommands "\$$variable"]
+ set color [SelectColor .select_color \
+ -parent $win \
+ -color $color \
-title [mc "Select color - %s" ${::APPNAME}] \
]
@@ -1604,6 +1721,7 @@ namespace eval editor {
variable intentation_mode ;# Editor indentation mode
variable spaces_no_tabs ;# Bool: Use spaces instead of tabs
variable number_of_spaces ;# Number of spaces to use instead of tab
+ variable tab_width ;# Int: Tab width
variable autosave ;# Int: Autosave interval in minutes (0 == disabled)
variable auto_completion ;# Bool: Enable popup-base completion
variable cline_completion ;# Bool: Enable popup-based completion for command line
@@ -1615,6 +1733,7 @@ namespace eval editor {
variable color_current_line ;# RGB: Backgound color for current line
variable color_bookmark ;# RGB: Backgound color for bookmarks
variable color_breakpoint ;# RGB: Backgound color for breakpoints
+ variable color_breakpoint_I ;# RGB: Backgound color for invalid breakpoints
variable color_simulator_line ;# RGB: Backgound color for simulator line
variable color_error_line ;# RGB: Backgound color for line containing an error
variable color_trailing_space ;# RGB: Backgound color for trailing space
@@ -1625,38 +1744,40 @@ namespace eval editor {
variable sample_text_size ;# Font size
variable sample_text_family ;# Font family
- variable hightlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
- variable hightlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
- variable hightlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
+ variable highlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
+ variable highlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
+ variable highlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
# Get highlighting tags
- set hightlight_tags_asm ${::ASMsyntaxHighlight::hightlight_tags}
- set hightlight_tags_C ${::CsyntaxHighlight::hightlight_tags}
- set hightlight_tags_lst ${::LSTsyntaxHighlight::hightlight_tags}
+ set highlight_tags_asm ${::ASMsyntaxHighlight::highlight_tags}
+ set highlight_tags_C ${::CsyntaxHighlight::highlight_tags}
+ set highlight_tags_lst ${::LSTsyntaxHighlight::highlight_tags}
# Get data from editor NS
- set intentation_mode [mc ${Editor::intentation_mode}]
- set spaces_no_tabs ${Editor::spaces_no_tabs}
- set number_of_spaces ${Editor::number_of_spaces}
- set auto_completion ${Editor::auto_completion}
- set cline_completion ${Editor::cline_completion}
- set autosave ${Editor::autosave}
- set auto_brackets ${Editor::auto_brackets}
- set hg_trailing_sp ${Editor::hg_trailing_sp}
- set sample_text_size ${Editor::fontSize}
- set sample_text_family ${Editor::fontFamily}
- set color_normal_text ${Editor::normal_text_bg}
- set color_iconBorder_bg ${Editor::iconBorder_bg}
- set color_lineNumbers_bg ${Editor::lineNumbers_bg}
- set color_lineNumbers_fg ${Editor::lineNumbers_fg}
- set editor_to_use [::settings getValue \
- "Editor config/editor_to_use" ${Editor::editor_to_use} \
+ set intentation_mode [mc ${::Editor::intentation_mode}]
+ set spaces_no_tabs ${::Editor::spaces_no_tabs}
+ set number_of_spaces ${::Editor::number_of_spaces}
+ set tab_width ${::Editor::tab_width}
+ set auto_completion ${::Editor::auto_completion}
+ set cline_completion ${::Editor::cline_completion}
+ set autosave ${::Editor::autosave}
+ set auto_brackets ${::Editor::auto_brackets}
+ set hg_trailing_sp ${::Editor::hg_trailing_sp}
+ set sample_text_size ${::Editor::fontSize}
+ set sample_text_family ${::Editor::fontFamily}
+ set color_normal_text ${::Editor::normal_text_bg}
+ set color_iconBorder_bg ${::Editor::iconBorder_bg}
+ set color_lineNumbers_bg ${::Editor::lineNumbers_bg}
+ set color_lineNumbers_fg ${::Editor::lineNumbers_fg}
+ set editor_to_use [::settings getValue \
+ "Editor config/editor_to_use" \
+ ${::Editor::editor_to_use} \
]
# Get data from filelist NS
- set default_encoding ${FileList::default_encoding}
- set default_eol ${FileList::default_eol}
+ set default_encoding ${::FileList::default_encoding}
+ set default_eol ${::FileList::default_eol}
foreach record ${::Editor::line_markers} {
set key [lindex $record 0]
@@ -1675,6 +1796,9 @@ namespace eval editor {
{tag_breakpoint} {
set color_breakpoint $val
}
+ {tag_breakpoint_INVALID} {
+ set color_breakpoint_I $val
+ }
{tag_simulator_curr} {
set color_simulator_line $val
}
@@ -1684,6 +1808,9 @@ namespace eval editor {
{tag_trailing_space} {
set color_trailing_space $val
}
+ default {
+ error "Error: Inconsistency in configuration managment, ::Editor::line_markers"
+ }
}
}
}
@@ -1698,6 +1825,7 @@ namespace eval editor {
variable intentation_mode ;# Editor indentation mode
variable spaces_no_tabs ;# Bool: Use spaces instead of tabs
variable number_of_spaces ;# Number of spaces to use instead of tab
+ variable tab_width ;# Int: Tab width
variable autosave ;# Int: Autosave interval in minutes (0 == disabled)
variable auto_completion ;# Bool: Enable popup-base completion
variable cline_completion ;# Bool: Enable popup-based completion for command line
@@ -1710,6 +1838,7 @@ namespace eval editor {
variable color_current_line ;# RGB: Backgound color for current line
variable color_bookmark ;# RGB: Backgound color for bookmarks
variable color_breakpoint ;# RGB: Backgound color for breakpoints
+ variable color_breakpoint_I ;# RGB: Backgound color for invalid breakpoints
variable color_simulator_line ;# RGB: Backgound color for simulator line
variable color_error_line ;# RGB: Backgound color for line containing an error
variable color_trailing_space ;# RGB: Backgound color for trailing space
@@ -1720,13 +1849,13 @@ namespace eval editor {
variable sample_text_size ;# Font size
variable sample_text_family ;# Font family
- variable hightlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
- variable hightlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
- variable hightlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
+ variable highlight_tags_asm ;# List: Definition of colors and styles for assembler syntax highlighting
+ variable highlight_tags_C ;# List: Definition of colors and styles for C syntax highlighting
+ variable highlight_tags_lst ;# List: Definition of colors and styles for LST syntax highlighting
- if {!$Editor::auto_completion && $auto_completion} {
+ if {!${::Editor::auto_completion} && $auto_completion} {
set autocompletion_turned_on 1
- } {
+ } else {
set autocompletion_turned_on 0
}
@@ -1751,18 +1880,25 @@ namespace eval editor {
if {$number_of_spaces != {}} {
set Editor::number_of_spaces $number_of_spaces
- } {
+ } else {
set Editor::number_of_spaces 8
}
-
- set Editor::line_markers [list \
- "sel $color_selected_text" \
- "tag_current_line $color_current_line" \
- "tag_bookmark $color_bookmark" \
- "tag_breakpoint $color_breakpoint" \
- "tag_simulator_curr $color_simulator_line" \
- "tag_error_line $color_error_line" \
- "tag_trailing_space $color_trailing_space"]
+ if {$tab_width != {}} {
+ set Editor::tab_width $tab_width
+ } else {
+ set Editor::tab_width 8
+ }
+
+ set Editor::line_markers [list \
+ [list sel $color_selected_text ] \
+ [list tag_current_line $color_current_line ] \
+ [list tag_bookmark $color_bookmark ] \
+ [list tag_breakpoint $color_breakpoint ] \
+ [list tag_simulator_curr $color_simulator_line ] \
+ [list tag_error_line $color_error_line ] \
+ [list tag_trailing_space $color_trailing_space ] \
+ [list tag_breakpoint_INVALID $color_breakpoint_I ] \
+ ]
set Editor::defaultFont [font create \
-size -$sample_text_size \
@@ -1775,9 +1911,9 @@ namespace eval editor {
]
## Syntax highlight
- set ::ASMsyntaxHighlight::hightlight_tags $hightlight_tags_asm
- set ::CsyntaxHighlight::hightlight_tags $hightlight_tags_C
- set ::LSTsyntaxHighlight::hightlight_tags $hightlight_tags_lst
+ set ::ASMsyntaxHighlight::highlight_tags $highlight_tags_asm
+ set ::CsyntaxHighlight::highlight_tags $highlight_tags_C
+ set ::LSTsyntaxHighlight::highlight_tags $highlight_tags_lst
}
## Adjust all editors to fit new settings
@@ -1786,7 +1922,7 @@ namespace eval editor {
variable autocompletion_turned_on
# Check if there is at least 1 opened editor
- if {[llength ${X::openedProjects}] == 0} {
+ if {[llength ${::X::openedProjects}] == 0} {
return 0
}
@@ -1795,6 +1931,7 @@ namespace eval editor {
# Refresh font settings in right panel
$project rightPanel_refresh_font_settings 1
+ $project rightPanel_clear_symbol_list
# Adjust tab bar
$project show_hide_tab_bar
@@ -1809,13 +1946,19 @@ namespace eval editor {
}
ASMsyntaxHighlight::create_tags \
[$editor cget -editor] \
- ${Editor::fontSize} \
- ${Editor::fontFamily}
+ ${::Editor::fontSize} \
+ ${::Editor::fontFamily}
CsyntaxHighlight::create_tags \
[$editor cget -editor] \
- ${Editor::fontSize} \
- ${Editor::fontFamily}
+ ${::Editor::fontSize} \
+ ${::Editor::fontFamily}
+ LSTsyntaxHighlight::create_tags \
+ [$editor cget -editor] \
+ ${::Editor::fontSize} \
+ ${::Editor::fontFamily}
}
+
+ $project rightPanel_refresh_symbols
}
# done ...
@@ -1825,14 +1968,15 @@ namespace eval editor {
## Set status changed to True
# @return true
proc settings_changed {} {
+ variable apply_button ;# ID of button "Apply"
variable changed ;# Bool: Settings changed
variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
- variable apply_button ;# ID of button "Apply"
if {$changed} {return}
set changed 1
set anything_modified 1
+
$apply_button configure -state normal
}
@@ -1883,7 +2027,7 @@ namespace eval editor {
variable changed ;# Bool: Settings changed
# Check if there is at least 1 opened editor
- if {[llength ${X::openedProjects}] == 0} {
+ if {[llength ${::X::openedProjects}] == 0} {
return 0
}
@@ -1891,37 +2035,40 @@ namespace eval editor {
set changed 0
$apply_button configure -state disabled
+ ${::X::actualProject} rightPanel_clear_symbol_list
+
# Adjust NS variables
use_settings
## Apply settings in current editor
- set actualEditor [${X::actualProject} cget -actualEditor]
- set actualEditor2 [${X::actualProject} cget -actualEditor2]
- ${X::actualProject} show_hide_tab_bar
- ${X::actualProject} rightPanel_refresh_font_settings 0
- ${X::actualProject} editor_procedure $actualEditor change_colors {}
- ${X::actualProject} editor_procedure $actualEditor refresh_font_settings {}
- ${X::actualProject} editor_procedure $actualEditor define_line_markers {}
+ set actualEditor [${::X::actualProject} cget -actualEditor]
+ set actualEditor2 [${::X::actualProject} cget -actualEditor2]
+ ${::X::actualProject} show_hide_tab_bar
+ ${::X::actualProject} rightPanel_refresh_font_settings 0
+ ${::X::actualProject} editor_procedure $actualEditor change_colors {}
+ ${::X::actualProject} editor_procedure $actualEditor refresh_font_settings {}
+ ${::X::actualProject} editor_procedure $actualEditor define_line_markers {}
if {$actualEditor2 >= 0} {
- ${X::actualProject} editor_procedure $actualEditor2 change_colors {}
- ${X::actualProject} editor_procedure $actualEditor2 refresh_font_settings {}
- ${X::actualProject} editor_procedure $actualEditor2 define_line_markers {}
+ ${::X::actualProject} editor_procedure $actualEditor2 change_colors {}
+ ${::X::actualProject} editor_procedure $actualEditor2 refresh_font_settings {}
+ ${::X::actualProject} editor_procedure $actualEditor2 define_line_markers {}
}
- set editors [${X::actualProject} cget -editors]
+ set editors [${::X::actualProject} cget -editors]
ASMsyntaxHighlight::create_tags [[lindex $editors $actualEditor] cget -editor] \
- ${Editor::fontSize} ${Editor::fontFamily}
+ ${::Editor::fontSize} ${::Editor::fontFamily}
CsyntaxHighlight::create_tags [[lindex $editors $actualEditor] cget -editor] \
- ${Editor::fontSize} ${Editor::fontFamily}
+ ${::Editor::fontSize} ${::Editor::fontFamily}
LSTsyntaxHighlight::create_tags [[lindex $editors $actualEditor] cget -editor] \
- ${Editor::fontSize} ${Editor::fontFamily}
+ ${::Editor::fontSize} ${::Editor::fontFamily}
if {$actualEditor2 >= 0} {
ASMsyntaxHighlight::create_tags [[lindex $editors $actualEditor2] cget -editor] \
- ${Editor::fontSize} ${Editor::fontFamily}
+ ${::Editor::fontSize} ${::Editor::fontFamily}
CsyntaxHighlight::create_tags [[lindex $editors $actualEditor2] cget -editor] \
- ${Editor::fontSize} ${Editor::fontFamily}
+ ${::Editor::fontSize} ${::Editor::fontFamily}
LSTsyntaxHighlight::create_tags [[lindex $editors $actualEditor2] cget -editor] \
- ${Editor::fontSize} ${Editor::fontFamily}
+ ${::Editor::fontSize} ${::Editor::fontFamily}
}
+ ${::X::actualProject} rightPanel_refresh_symbols
# done ...
return 1
@@ -1933,10 +2080,10 @@ namespace eval editor {
variable editor_to_use ;# Int: Prefred editor
# Section "Syntax highlight"
- foreach item [concat \
- ${::ASMsyntaxHighlight::hightlight_tags} \
- ${::CsyntaxHighlight::hightlight_tags} \
- ${::LSTsyntaxHighlight::hightlight_tags} \
+ foreach item [concat \
+ ${::ASMsyntaxHighlight::highlight_tags} \
+ ${::CsyntaxHighlight::highlight_tags} \
+ ${::LSTsyntaxHighlight::highlight_tags} \
] {
set key [lindex $item 0]
set value [lrange $item 1 end]
@@ -1948,7 +2095,7 @@ namespace eval editor {
normal_text_bg iconBorder_bg lineNumbers_bg lineNumbers_fg
fontSize fontFamily line_markers
} {
- ::settings setValue "Editor colors/$key" [subst "\$::Editor::$key"]
+ ::settings setValue "Editor colors/$key" [subst -nocommands "\$::Editor::$key"]
}
# Section "Editor config"
@@ -1957,8 +2104,9 @@ namespace eval editor {
number_of_spaces auto_brackets
auto_completion autosave
cline_completion hg_trailing_sp
+ tab_width
} {
- ::settings setValue "Editor config/$key" [subst "\$::Editor::$key"]
+ ::settings setValue "Editor config/$key" [subst -nocommands "\$::Editor::$key"]
}
::settings setValue "Editor config/default_encoding" ${::FileList::default_encoding}
::settings setValue "Editor config/default_eol" ${::FileList::default_eol}
@@ -1971,38 +2119,38 @@ namespace eval editor {
## Load configuration from config file
# @return void
proc load_config {} {
- variable avaliable_encodings ;# Encodings supported by editor
+ variable available_encodings ;# Encodings supported by editor
## Section "Syntax highlight"
- # Assembler
- set hightlight_tags {}
- foreach item ${::ASMsyntaxHighlight::hightlight_tags} {
+ # Assembler
+ set highlight_tags {}
+ foreach item ${::ASMsyntaxHighlight::highlight_tags} {
set key [lindex $item 0]
set value [lrange $item 1 end]
set value [::settings getValue "Syntax highlight/$key" $value]
- lappend hightlight_tags "$key $value"
+ lappend highlight_tags [concat $key $value]
}
- set ::ASMsyntaxHighlight::hightlight_tags $hightlight_tags
- # C language
- set hightlight_tags {}
- foreach item ${::CsyntaxHighlight::hightlight_tags} {
+ set ::ASMsyntaxHighlight::highlight_tags $highlight_tags
+ # C language
+ set highlight_tags {}
+ foreach item ${::CsyntaxHighlight::highlight_tags} {
set key [lindex $item 0]
set value [lrange $item 1 end]
set value [::settings getValue "Syntax highlight/$key" $value]
- lappend hightlight_tags "$key $value"
+ lappend highlight_tags [concat $key $value]
}
- set ::CsyntaxHighlight::hightlight_tags $hightlight_tags
- unset hightlight_tags
- # Code listing
- set hightlight_tags {}
- foreach item ${::LSTsyntaxHighlight::hightlight_tags} {
+ set ::CsyntaxHighlight::highlight_tags $highlight_tags
+ unset highlight_tags
+ # Code listing
+ set highlight_tags {}
+ foreach item ${::LSTsyntaxHighlight::highlight_tags} {
set key [lindex $item 0]
set value [lrange $item 1 end]
set value [::settings getValue "Syntax highlight/$key" $value]
- lappend hightlight_tags "$key $value"
+ lappend highlight_tags [concat $key $value]
}
- set ::LSTsyntaxHighlight::hightlight_tags $hightlight_tags
- unset hightlight_tags
+ set ::LSTsyntaxHighlight::highlight_tags $highlight_tags
+ unset highlight_tags
# Section "Editor config"
foreach key {
@@ -2010,9 +2158,9 @@ namespace eval editor {
number_of_spaces auto_brackets
auto_completion autosave
cline_completion editor_to_use
- hg_trailing_sp
+ hg_trailing_sp tab_width
} {
- set value [subst "\$::Editor::$key"]
+ set value [subst -nocommands "\$::Editor::$key"]
set value [::settings getValue "Editor config/$key" $value]
set ::Editor::$key $value
}
@@ -2022,14 +2170,14 @@ namespace eval editor {
${::Editor::editor_to_use} < 0
||
${::Editor::editor_to_use} > 5
- } {
+ } then {
set ::Editor::editor_to_use 0
puts stderr [mc "Invalid key: '%s'" {editor_to_use}]
} elseif {${::Editor::editor_to_use}} {
- if {!${::PROGRAM_AVALIABLE(urxvt)}} {
- puts stderr [mc "Unable to use external embedded editor because rxvt-unicode is not avaliable"]
+ if {!${::PROGRAM_AVAILABLE(urxvt)}} {
+ puts stderr [mc "Unable to use external embedded editor because rxvt-unicode is not available"]
set ::Editor::editor_to_use 0
- } {
+ } else {
switch -- ${::Editor::editor_to_use} {
1 {set program {vim} }
2 {set program {emacs} }
@@ -2037,8 +2185,8 @@ namespace eval editor {
4 {set program {dav} }
5 {set program {le} }
}
- if {!$::PROGRAM_AVALIABLE($program)} {
- puts stderr [mc "Program %s is not avaliable. Using native editor." $program]
+ if {!$::PROGRAM_AVAILABLE($program)} {
+ puts stderr [mc "Program %s is not available. Using native editor." $program]
set ::Editor::editor_to_use 0
}
}
@@ -2058,16 +2206,25 @@ namespace eval editor {
if {![string is digit -strict ${::Editor::autosave}]} {
set Editor::autosave 0
puts stderr [mc "Invalid key: '%s'" {autosave}]
- } {
+ } else {
if {${::Editor::autosave} > 60 || ${::Editor::autosave} < 0} {
- set Editor::number_of_spaces 0
+ set Editor::autosave 0
puts stderr [mc "Invalid key: '%s'" {autosave}]
}
}
+ if {![string is digit -strict ${::Editor::tab_width}]} {
+ set Editor::tab_width 8
+ puts stderr [mc "Invalid key: '%s'" {tab_width}]
+ } else {
+ if {${::Editor::tab_width} > 40 || ${::Editor::tab_width} < 1} {
+ set Editor::tab_width 8
+ puts stderr [mc "Invalid key: '%s'" {tab_width}]
+ }
+ }
if {![string is digit -strict ${::Editor::number_of_spaces}]} {
set FileList::number_of_spaces 8
puts stderr [mc "Invalid key: '%s'" {number_of_spaces}]
- } {
+ } else {
if {${::Editor::number_of_spaces} > 16 || ${::Editor::number_of_spaces} < 1} {
set FileList::number_of_spaces 8
puts stderr [mc "Invalid key: '%s'" {number_of_spaces}]
@@ -2085,25 +2242,24 @@ namespace eval editor {
${::Editor::intentation_mode} != {none}
&&
${::Editor::intentation_mode} != {normal}
- } {
+ } then {
set FileList::intentation_mode {normal}
puts stderr [mc "Invalid key: '%s'" {intentation_mode}]
}
set FileList::default_encoding [::settings getValue \
"Editor config/default_encoding" {utf-8}]
- if {[lsearch $avaliable_encodings ${FileList::default_encoding}] == -1} {
+ if {[lsearch $available_encodings ${FileList::default_encoding}] == -1} {
set FileList::default_encoding {utf-8}
puts stderr [mc "Invalid key: '%s'" {default_encoding}]
}
- set FileList::default_eol [::settings getValue \
- "Editor config/default_eol" {lf}]
+ set FileList::default_eol [::settings getValue "Editor config/default_eol" {lf}]
if {
${FileList::default_eol} != {lf} &&
${FileList::default_eol} != {cr} &&
${FileList::default_eol} != {crlf}
- } {
+ } then {
set FileList::default_eol {lf}
puts stderr [mc "Invalid key: '%s'" {default_eol}]
}
@@ -2113,7 +2269,7 @@ namespace eval editor {
normal_text_bg iconBorder_bg lineNumbers_bg lineNumbers_fg
fontSize fontFamily line_markers
} {
- set value [subst "\$::Editor::$key"]
+ set value [subst -nocommands "\$::Editor::$key"]
set value [::settings getValue "Editor colors/$key" $value]
set valid 1
@@ -2122,7 +2278,7 @@ namespace eval editor {
if {$key == {line_markers}} {
foreach def ${::Editor::line_markers} new $value {
if {![string equal [lindex $def 0] [lindex $new 0]]} {
- puts stderr [mc "Invalid key: '%s'" [lindex $new 0]]
+ puts stderr [mc "-- Invalid key: '%s'" [lindex $new 0]]
set valid 0
break
}
@@ -2146,3 +2302,7 @@ namespace eval editor {
]
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogues/global_config.tcl b/lib/configdialogues/global_config.tcl
new file mode 100644
index 0000000..66ca346
--- /dev/null
+++ b/lib/configdialogues/global_config.tcl
@@ -0,0 +1,535 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# 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 #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _GLOBAL_CONFIG_TCL ] } {
+set _GLOBAL_CONFIG_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+# Implements global configuration dialog
+# --------------------------------------------------------------------------
+
+
+## Global configuration dialog
+ # see Array OPTION in root NS
+namespace eval global {
+
+ variable dialog_opened 0 ;# Bool: True if this dialog is already opened
+ variable win ;# ID of dialog toplevel window
+
+ variable available_languages ;# List: Available languages (their codes)
+ variable language_names ;# List: Available languages (their names)
+
+ ## Configuration variables
+ variable show_splash ;# Bool: Show splash creen on start-up
+ variable show_tips ;# Bool: Show tips on start-up
+ variable language ;# String: Language code
+ variable language_name ;# String: Language name
+ variable font_size ;# Float: Global font size factor
+ variable font_size_desc ;# String: Global font size factor in its "string" form (I mean description)
+ variable background ;# String: Human readable description of the common background color
+ variable wstyle ;# String: Preffered widget style
+
+ ## Create the dialog
+ # @return void
+ proc mkDialog {} {
+ variable win ;# ID of toplevel dialog window
+ variable dialog_opened ;# Bool: True if this dialog is already opened
+ variable available_languages ;# List: Available languages (their codes)
+ variable language_names ;# List: Available languages (their names)
+
+ # Destroy the dialog if it's already opened
+ if {$dialog_opened} {
+ destroy .global_config_dialog
+ }
+ set dialog_opened 1
+
+ # Determinate available languages
+ get_languages
+
+ # Get settings from main NS
+ getSettings
+
+ # Create toplevel window
+ set win [toplevel .global_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
+
+ # Create window header
+ label $win.header_label \
+ -compound left \
+ -image ::ICONS::32::kcmmemory \
+ -text [mc "MCU 8051 IDE configuration"] \
+ -font [font create -size [expr {int(-20 * $::font_size_factor)}]]
+
+ # Create horizontal separator
+ Separator $win.sep -orient horizontal
+
+ ## Create middle frame
+ set middle_frame [frame $win.middle_frame]
+ # Checkbutton "Display splash screen"
+ grid [Label $middle_frame.lbl_splash \
+ -text [mc "Display splash screen"] \
+ -helptext [mc "Show splash screen on start-up"] \
+ ] -row 0 -column 0 -sticky w
+ grid [checkbutton $middle_frame.chb_splash \
+ -variable ::configDialogues::global::show_splash \
+ ] -row 0 -column 1 -sticky w
+ DynamicHelp::add $middle_frame.chb_splash \
+ -text [mc "Show splash screen on start-up"]
+ # Checkbutton "Show tips on start-up"
+ grid [Label $middle_frame.lbl_tips \
+ -text [mc "Show tips on start-up"] \
+ -helptext [mc "Invoke dialog with tip of the day on start-up"] \
+ ] -row 1 -column 0 -sticky w
+ grid [checkbutton $middle_frame.chb_tips \
+ -variable ::configDialogues::global::show_tips \
+ ] -row 1 -column 1 -sticky w
+ DynamicHelp::add $middle_frame.chb_tips \
+ -text [mc "Invoke dialog with tip of the day on start-up"]
+ # Combo "Language"
+ grid [Label $middle_frame.lbl_lang \
+ -text [mc "Language"] \
+ -helptext [mc "Your preferred language"] \
+ ] -row 2 -column 0 -sticky w
+ grid [ttk::combobox $middle_frame.cb_lang \
+ -values $language_names \
+ -state readonly \
+ -textvariable ::configDialogues::global::language_name \
+ ] -row 2 -column 1 -sticky w
+ bind $middle_frame.cb_lang <<ComboboxSelected>> {
+ bind %W <<ComboboxSelected>> {
+ set ::configDialogues::global::language \
+ [lindex ${::configDialogues::global::available_languages} [%W current]]
+ }
+ set ::configDialogues::global::language \
+ [lindex ${::configDialogues::global::available_languages} [%W current]]
+ ::configDialogues::global::language_changed
+ }
+ DynamicHelp::add $middle_frame.cb_lang \
+ -text [mc "Your preferred language"]
+ # SpinBox "Font Size Factor"
+ grid [Label $middle_frame.lbl_fontsize \
+ -text [mc "Global font size factor"] \
+ -helptext [mc "Allows you to adjust size of (almost) all fonts used in this IDE"] \
+ ] -row 3 -column 0 -sticky w
+ grid [ttk::combobox $middle_frame.cb_fontsize \
+ -values [list \
+ [mc "Normal"] [mc "A little larger"] \
+ [mc "Notably larger"] [mc "Much larger"] \
+ [mc "Huge"] [mc "Too BIG"] \
+ ] \
+ -state readonly \
+ -textvariable ::configDialogues::global::font_size_desc \
+ ] -row 3 -column 1 -sticky w
+ bind $middle_frame.cb_fontsize <<ComboboxSelected>> "
+ bind $middle_frame.cb_fontsize <<ComboboxSelected>> {}
+ ::configDialogues::global::fontsize_changed
+ "
+ DynamicHelp::add $middle_frame.cb_fontsize \
+ -text [mc "Allows you to adjust size of (almost) all fonts used in this IDE"]
+
+ # Combo "Widget style"
+ grid [Label $middle_frame.lbl_style \
+ -text [mc "Widget style"] \
+ -helptext [mc "Your preferred widget style"] \
+ ] -row 4 -column 0 -sticky w
+ grid [ttk::combobox $middle_frame.cb_style \
+ -values [ttk::style theme names] \
+ -state readonly \
+ -textvariable ::configDialogues::global::wstyle \
+ ] -row 4 -column 1 -sticky w
+ bind $middle_frame.cb_style <<ComboboxSelected>> "
+ bind $middle_frame.cb_style <<ComboboxSelected>> {}
+ ::configDialogues::global::restart_required
+ "
+ DynamicHelp::add $middle_frame.cb_style \
+ -text [mc "Your preferred widget style"]
+
+ # Combo "Background color"
+ if {!$::MICROSOFT_WINDOWS} {
+ grid [Label $middle_frame.lbl_background \
+ -text [mc "Background color"] \
+ -helptext [mc "Common background color for almost everything in the GUI"] \
+ ] -row 5 -column 0 -sticky w
+ grid [ttk::combobox $middle_frame.cb_background \
+ -values [list \
+ {Default} {Windows} \
+ {Tk} {Light} \
+ {Dark} \
+ ] \
+ -state readonly \
+ -textvariable ::configDialogues::global::background \
+ ] -row 5 -column 1 -sticky w
+ bind $middle_frame.cb_background <<ComboboxSelected>> "
+ bind $middle_frame.cb_background <<ComboboxSelected>> {}
+ ::configDialogues::global::restart_required
+ "
+ DynamicHelp::add $middle_frame.cb_background \
+ -text [mc "Common background color for almost everything in the GUI"]
+ }
+
+ # Separator
+ grid [ttk::separator $middle_frame.sep -orient horizontal] \
+ -columnspan 2 -sticky we -row 10 -column 0 -pady 5
+ # Checkbutton "Do not ask whether ..."
+ grid [text $middle_frame.lbl_ask \
+ -wrap word \
+ -height 4 \
+ -width 0 \
+ -bg ${::COMMON_BG_COLOR} \
+ -bd 0 \
+ ] -row 11 -column 0 -sticky we
+ $middle_frame.lbl_ask insert end [mc "Do not always ask whether to add file to the project after the file is opened"]
+ $middle_frame.lbl_ask configure -state disabled
+ grid [checkbutton $middle_frame.cb_ask \
+ -onvalue 0 -offvalue 1 \
+ -variable ::FileList::ask__append_file_to_project \
+ ] -row 11 -column 1 -sticky w
+ # Checkbutton "Do not show performnace warning ..."
+ grid [text $middle_frame.lbl_dont_per_warn \
+ -wrap word \
+ -height 4 \
+ -width 0 \
+ -bg ${::COMMON_BG_COLOR} \
+ -bd 0 \
+ ] -row 12 -column 0 -sticky we
+ $middle_frame.lbl_dont_per_warn insert end [mc "Do not show performance warning when enabling external HW simulation."]
+ $middle_frame.lbl_dont_per_warn configure -state disabled
+ grid [checkbutton $middle_frame.cb_dont_per_warn\
+ -onvalue 0 -offvalue 1 \
+ -variable ::Graph::show_sim_per_warn \
+ ] -row 12 -column 1 -sticky w
+
+ # Finalize
+ grid columnconfigure $middle_frame 0 -minsize 200
+
+ ## Button frame at the bottom
+ set but_frame [frame $win.button_frame]
+ # Button "Reset"
+ pack [ttk::button $but_frame.but_default \
+ -text [mc "Reset to defaults"] \
+ -command {::configDialogues::global::DEFAULTS} \
+ ] -side left
+ DynamicHelp::add $but_frame.but_default \
+ -text [mc "Reset all settings to defaults"]
+ # Button "Ok"
+ pack [ttk::button $but_frame.but_ok \
+ -text [mc "Ok"] \
+ -compound left \
+ -image ::ICONS::16::ok \
+ -command {::configDialogues::global::OK} \
+ ] -side right -padx 2
+ DynamicHelp::add $but_frame.but_ok \
+ -text [mc "Commit new settings"]
+ # Button "Cancel"
+ pack [ttk::button $but_frame.but_cancel \
+ -text [mc "Cancel"] \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command {::configDialogues::global::CANCEL} \
+ ] -side right -padx 2
+ DynamicHelp::add $but_frame.but_cancel \
+ -text [mc "Take changes back and close dialog"]
+
+ # Pack frames and notebook
+ pack $win.header_label -side top -pady 6
+ pack $win.sep -side top -fill x -after $win.header_label
+ pack $middle_frame -side top -padx 10 -anchor nw -pady 10
+ pack $but_frame -side bottom -fill x -expand 1 -anchor s -padx 5 -pady 5
+
+ # Set window attributes
+ wm iconphoto $win ::ICONS::16::configure
+ wm transient $win .
+ wm title $win [mc "Configure MCU 8051 IDE"]
+ wm minsize $win 380 380
+ raise $win
+ catch {grab $win}
+ wm protocol $win WM_DELETE_WINDOW {
+ ::configDialogues::global::CANCEL
+ }
+ tkwait window $win
+ }
+
+ ## Application language changed
+ # Takes any set of arguments and discards them
+ # @parm List - meaningless
+ # @return void
+ proc language_changed args {
+ tk_messageBox \
+ -parent .global_config_dialog \
+ -type ok -icon info \
+ -title [mc "Application language changed"] \
+ -message [mc "Language for this application has been changed. The change will take effect upon next start of application"]
+ }
+
+ ## Display message "The change will take effect upon next start of application"
+ # Takes any set of arguments and discards them
+ # @parm List - meaningless
+ # @return void
+ proc restart_required args {
+ tk_messageBox \
+ -parent .global_config_dialog \
+ -type ok -icon info \
+ -title [mc "Restart required"] \
+ -message [mc "The change will take effect upon next start of application"]
+ }
+
+
+ ## Global font size factor changed
+ # Takes any set of arguments and discards them
+ # @parm List - meaningless
+ # @return void
+ proc fontsize_changed args {
+ tk_messageBox \
+ -parent .global_config_dialog \
+ -type ok -icon info \
+ -title [mc "Global font size factor changed"] \
+ -message [mc "The change will take effect upon next start of application"]
+ }
+
+ ## Retrieve list of available translations
+ # @return void
+ proc get_languages {} {
+ variable available_languages ;# List: Available languages (their codes)
+ variable language_names ;# List: Available languages (their names)
+
+ set available_languages {en}
+ set tmp [list]
+ catch { ;# For Microsoft Windows it has to be enclosed in catch block
+ set tmp [glob -nocomplain -types f -tails \
+ -directory "${::INSTALLATION_DIR}/translations" *.msg \
+ ]
+ }
+
+ foreach translation $tmp {
+ lappend available_languages [file rootname $translation]
+ }
+
+ set language_names [list]
+ foreach lang $available_languages {
+ set idx [lsearch -ascii -exact ${::LANGUAGE_CODES} $lang]
+ if {$idx == -1} {
+ lappend language_names $lang
+ } else {
+ incr idx
+ lappend language_names [lindex ${::LANGUAGE_CODES} $idx]
+ }
+ }
+ }
+
+ ## Set configuration variable
+ # @parm String variable - variable to set
+ # @parm Mixed value - new value
+ proc set_variable {variable value} {
+ variable show_splash ;# Bool: Show splash creen on start-up
+ variable show_tips ;# Bool: Show tips on start-up
+ variable language ;# String: Language
+ variable font_size ;# Float: Global font size factor
+ variable background ;# String: Human readable description of the common background color
+ variable wstyle ;# String: Preffered widget style
+
+ getSettings
+
+ switch -- $variable {
+ {splash} {
+ set show_splash $value
+ }
+ {tips} {
+ set show_tips $value
+ }
+ {language} {
+ set language $value
+ }
+ {fontsize} {
+ set font_size $value
+ }
+ {background} {
+ set background $value
+ }
+ {wstyle} {
+ set wstyle $value
+ }
+ default {
+ puts stderr "::configDialogues::global::set_variable(): `$variable' was not recognized"
+ }
+ }
+
+ use_settings
+ save_config
+ }
+
+ ## Retrieve settings from main NS
+ # @return void
+ proc getSettings {} {
+ variable show_splash ;# Bool: Show splash creen on start-up
+ variable show_tips ;# Bool: Show tips on start-up
+ variable language ;# String: Language code
+ variable language_name ;# String: Language name
+ variable available_languages ;# List: Available languages (their codes)
+ variable language_names ;# List: Available languages (their names)
+ variable font_size ;# Float: Global font size factor
+ variable font_size_desc ;# String: Global font size factor in its "string" form (I mean description)
+ variable background ;# String: Human readable description of the common background color
+ variable wstyle ;# String: Preffered widget style
+
+ set show_splash ${::GLOBAL_CONFIG(splash)}
+ set show_tips ${::GLOBAL_CONFIG(tips)}
+ set language ${::GLOBAL_CONFIG(language)}
+ set font_size $::font_size_factor
+ set background ${::GLOBAL_CONFIG(background)}
+ set wstyle ${::GLOBAL_CONFIG(wstyle)}
+
+ switch -- $font_size {
+ 1.0 {set font_size_desc [mc "Normal"] }
+ 1.1 {set font_size_desc [mc "A little larger"] }
+ 1.2 {set font_size_desc [mc "Notably larger"] }
+ 1.3 {set font_size_desc [mc "Much larger"] }
+ 1.4 {set font_size_desc [mc "Huge"] }
+ 1.5 {set font_size_desc [mc "Too BIG"] }
+ default {set font_size_desc [mc "Normal"] }
+ }
+
+ if {[catch {
+ set language_name [lindex $language_names [lsearch -ascii -exact $available_languages $language]]
+ }]} then {
+ set language_name {<unknown>}
+ }
+ }
+
+ ## Set application according to local settings
+ # @return void
+ proc use_settings {} {
+ variable show_splash ;# Bool: Show splash creen on start-up
+ variable show_tips ;# Bool: Show tips on start-up
+ variable language ;# String: Language code
+ variable font_size ;# Float: Global font size factor
+ variable font_size_desc ;# String: Global font size factor in its "string" form (I mean description)
+ variable background ;# String: Human readable description of the common background color
+ variable wstyle ;# String: Preffered widget style
+
+ switch -- $font_size_desc [subst {
+ {[mc "Normal"]} {set font_size 1.0}
+ {[mc "A little larger"]} {set font_size 1.1}
+ {[mc "Notably larger"]} {set font_size 1.2}
+ {[mc "Much larger"]} {set font_size 1.3}
+ {[mc "Huge"]} {set font_size 1.4}
+ {[mc "Too BIG"]} {set font_size 1.5}
+ default {set font_size 1.0}
+
+ }]
+
+ if {${::GLOBAL_CONFIG(language)} != $language} {
+ set lang_changed 1
+ } else {
+ set lang_changed 0
+ }
+
+ set ::GLOBAL_CONFIG(splash) $show_splash
+ set ::GLOBAL_CONFIG(tips) $show_tips
+ set ::GLOBAL_CONFIG(language) $language
+ set ::font_size_factor $font_size
+ set ::GLOBAL_CONFIG(background) $background
+ set ::GLOBAL_CONFIG(wstyle) $wstyle
+
+ if {$lang_changed} {
+ ::X::switch_language
+ }
+ }
+
+ ## Save settings to the config file
+ # @return void
+ proc save_config {} {
+ variable show_splash ;# Bool: Show splash creen on start-up
+ variable show_tips ;# Bool: Show tips on start-up
+ variable language ;# String: Language code
+ variable font_size ;# Float: Global font size factor
+ variable background ;# String: Human readable description of the common background color
+ variable wstyle ;# String: Preffered widget style
+
+ if {[catch {
+ set conf_file [open "${::CONFIG_DIR}/base.conf" w]
+ puts -nonewline $conf_file \
+ [list $show_splash $show_tips $language $font_size $background $wstyle]
+ close $conf_file
+ }]} then {
+ puts stderr [mc "Unable to write to base configuration file"]
+ }
+ }
+
+ ## Destroy the dialog
+ # @return void
+ proc CANCEL {} {
+ variable win ;# ID of toplevel dialog window
+ variable dialog_opened ;# Bool: True if this dialog is already opened
+
+ # Destroy dialog window
+ set dialog_opened 0
+ grab release $win
+ destroy $win
+ }
+
+ ## Use settings and destroy the dialog
+ # @return void
+ proc OK {} {
+ variable win ;# ID of toplevel dialog window
+
+ # Use and save settings
+ use_settings
+ save_config
+
+ # Destroy dialog window
+ CANCEL
+ }
+
+ ## Restrore defaults
+ # @return void
+ proc DEFAULTS {} {
+ variable show_splash ;# Bool: Show splash creen on start-up
+ variable show_tips ;# Bool: Show tips on start-up
+ variable language ;# String: Language code
+ variable language_name ;# String: Language name
+ variable available_languages ;# List: Available languages (their codes)
+ variable language_names ;# List: Available languages (their names)
+ variable font_size_desc ;# String: Global font size factor in its "string" form (I mean description)
+ variable background ;# String: Human readable description of the common background color
+ variable wstyle ;# String: Preffered widget style
+
+ set show_splash 1
+ set show_tips 1
+ set language {en}
+ set font_size_desc {Normal}
+ set background {Default}
+ set wstyle {clam}
+
+ if {[catch {
+ set language_name [lindex $language_names [lsearch -ascii -exact $available_languages $language]]
+ }]} then {
+ set language_name {<unknown>}
+ }
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/rightpanel_config.tcl b/lib/configdialogues/rightpanel_config.tcl
index 4161b4f..0cace4e 100755..100644
--- a/lib/configdialogs/rightpanel_config.tcl
+++ b/lib/configdialogues/rightpanel_config.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 _RIGHTPANEL_CONFIG_TCL ] } {
+set _RIGHTPANEL_CONFIG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements right panel configuration dialog
@@ -39,9 +44,9 @@ namespace eval rightPanel {
variable watch_text_tags ;# Highlighting tags for register watches
## Create the dialog
- # @parm Int = 0 - number of tab to raise
+ # @parm Int tab_number=0 - number of tab to raise
# @return void
- proc mkDialog args {
+ proc mkDialog {{tab_number 0}} {
variable win ;# ID of toplevel dialog window
variable dialog_opened ;# Bool: True if this dialog is already opened
@@ -51,7 +56,7 @@ namespace eval rightPanel {
variable instruction_tags ;# Highlighting tags for instruction details
variable watch_text_tags ;# Highlighting tags for register watches
- # Destroy the dialog if it's alredy opened
+ # Destroy the dialog if it's already opened
if {$dialog_opened} {
destroy .rightPanel_config_dialog
}
@@ -63,22 +68,20 @@ namespace eval rightPanel {
getSettings
# Create toplevel window
- set win [toplevel .rightPanel_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
+ set win [toplevel .rightPanel_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
-compound left \
-text [mc "Right panel configuration"] \
- -font [font create -size -20]
+ -font [font create -size [expr {int(-20 * $::font_size_factor)}]]
## Create notebook
- set nb [ttk::notebook $win.nb]
+ set nb [ModernNoteBook $win.nb]
# Tab "Register watches"
- set watches_tab [frame $nb.watches_tab]
- $nb add $watches_tab -text [mc "Register watches"]
+ set watches_tab [$nb insert end watches_tab -text [mc "Register watches"]]
# Tab "Instruction details"
- set instruction_tab [frame $nb.instruction_tab]
- $nb add $instruction_tab -text [mc "Instruction details"]
+ set instruction_tab [$nb insert end instruction_tab -text [mc "Instruction details"]]
#
## Tab "Register watches"
@@ -109,7 +112,7 @@ namespace eval rightPanel {
# Checkbutton "Bold"
set checkbutton [checkbutton $watches_tab.chbut_${tag_name} \
-pady 0 -highlightthickness 0 \
- -command "::configDialogs::rightPanel::change_style $idx 1" \
+ -command "::configDialogues::rightPanel::change_style $idx 1" \
]
if {$boldItalic == {1}} {
$checkbutton select
@@ -120,7 +123,7 @@ namespace eval rightPanel {
grid [button $watches_tab.but_${tag_name} \
-bd 1 -relief raised -pady 0 -highlightthickness 0 \
-bg $color -width 10 -activebackground $color \
- -command "::configDialogs::rightPanel::select_color $idx $watches_tab.but_${tag_name} 1"
+ -command "::configDialogues::rightPanel::select_color $idx $watches_tab.but_${tag_name} 1"
] -column 2 -row $row -sticky ns -padx 10
incr row ;# Row in the grid
@@ -128,7 +131,7 @@ namespace eval rightPanel {
}
# Adjust the grid
- grid columnconfigure $watches_tab 0 -minsize 200
+ grid columnconfigure $watches_tab 0 -minsize 150
#
@@ -165,7 +168,7 @@ namespace eval rightPanel {
# Checkbutton "Bold"
set checkbutton [checkbutton $instruction_tab.chbut_${tag_name} \
-pady 0 -highlightthickness 0 \
- -command "::configDialogs::rightPanel::change_style $idx 0" \
+ -command "::configDialogues::rightPanel::change_style $idx 0" \
]
if {$boldItalic} {
$checkbutton select
@@ -176,7 +179,7 @@ namespace eval rightPanel {
grid [button $instruction_tab.but_${tag_name} \
-bd 1 -relief raised -pady 0 -highlightthickness 0 \
-bg $color -width 10 -activebackground $color \
- -command "::configDialogs::rightPanel::select_color $idx $instruction_tab.but_${tag_name} 0"
+ -command "::configDialogues::rightPanel::select_color $idx $instruction_tab.but_${tag_name} 0"
] -column 3 -row $row -sticky ns -padx 10
@@ -185,13 +188,13 @@ namespace eval rightPanel {
}
# Adjust the grid
- grid columnconfigure $instruction_tab 1 -minsize 200
+ grid columnconfigure $instruction_tab 1 -minsize 150
# Raise appropriate tab
- if {$args == {}} {
- $nb select $watches_tab
- } {
- $nb select [lindex [$nb tabs] $args]
+ if {$tab_number == {}} {
+ $nb raise watches_tab
+ } else {
+ $nb raise [lindex [$nb pages] $tab_number]
}
# Create button frame at the bottom
@@ -202,7 +205,7 @@ namespace eval rightPanel {
-text [mc "Apply"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::rightPanel::APPLY} \
+ -command {::configDialogues::rightPanel::APPLY} \
]
pack $apply_button -side left
# Button "Ok"
@@ -210,31 +213,31 @@ namespace eval rightPanel {
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::rightPanel::OK} \
- ] -side right
+ -command {::configDialogues::rightPanel::OK} \
+ ] -side right -padx 2
# Button "Cancel"
pack [ttk::button $but_frame.but_cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {::configDialogs::rightPanel::CANCEL} \
- ] -side right
+ -command {::configDialogues::rightPanel::CANCEL} \
+ ] -side right -padx 2
# Pack frames and notebook
pack $but_frame -side bottom -fill x -expand 0 -anchor s -padx 10 -pady 5
pack $win.header_label -side top -pady 6
- pack $nb -side top -fill both -expand 1 -padx 10
+ pack [$nb get_nb] -side top -fill both -expand 1 -padx 10
# Finalize creation of the dialog
wm iconphoto $win ::ICONS::16::configure
wm transient $win .
wm title $win [mc "Configure right panel - %s" ${::APPNAME}]
- wm geometry $win =390x380
+ wm geometry $win =340x380
wm resizable $win 0 0
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::rightPanel::CANCEL
+ ::configDialogues::rightPanel::CANCEL
}
tkwait window $win
}
@@ -254,12 +257,12 @@ namespace eval rightPanel {
{tag_A} {return "A"}
{tag_AB} {return "AB"}
{tag_SFR} {return "C, R0..R7"}
- {tag_indr} {return "@R0, @R0 etc."}
- {tag_Baddr} {return "Bit"}
+ {tag_indr} {return "@R0, @R0[mc { etc.}]"}
+ {tag_Baddr} {return [mc "Bit"]}
{tag_Xaddr} {return "XDATA"}
{tag_Eaddr} {return "EDATA"}
{tag_addr} {return "IDATA"}
- {tag_name} {return "Name"}
+ {tag_name} {return [mc "Name"]}
default {return {}}
}
}
@@ -273,13 +276,13 @@ namespace eval rightPanel {
variable watch_text_tags ;# Highlighting tags for register watches
if {$for} {
- if {[lindex $watch_text_tags "$row 2"] != 1} {
- lset watch_text_tags "$row 2" 1
- } {
- lset watch_text_tags "$row 2" {}
+ if {[lindex $watch_text_tags [list $row 2]] != 1} {
+ lset watch_text_tags [list $row 2] 1
+ } else {
+ lset watch_text_tags [list $row 2] {}
}
- } {
- lset instruction_tags "$row 2" [expr {!([lindex $instruction_tags "$row 2"])}]
+ } else {
+ lset instruction_tags [list $row 2] [expr {!([lindex $instruction_tags [list $row 2]])}]
}
# Adjust status changed
@@ -303,9 +306,9 @@ namespace eval rightPanel {
# Invoke new color selection dialog
if {$for} {
- set color [lindex $watch_text_tags "$row 1"]
- } {
- set color [lindex $instruction_tags "$row 1"]
+ set color [lindex $watch_text_tags [list $row 1]]
+ } else {
+ set color [lindex $instruction_tags [list $row 1]]
}
set color [SelectColor .select_color \
-parent $win \
@@ -316,9 +319,9 @@ namespace eval rightPanel {
# Change button background color
if {$color != {}} {
if {$for} {
- lset watch_text_tags "$row 1" $color
- } {
- lset instruction_tags "$row 1" $color
+ lset watch_text_tags [list $row 1] $color
+ } else {
+ lset instruction_tags [list $row 1] $color
}
$button configure -bg $color -activebackground $color
@@ -402,14 +405,14 @@ namespace eval rightPanel {
set key [lindex $item 0]
set value [lrange $item 1 end]
set value [::settings getValue "Instruction details/$key" $value]
- lappend instruction_tags "$key $value"
+ lappend instruction_tags [concat $key $value]
}
foreach item ${::RegWatches::watch_text_tags} {
# Load config
set key [lindex $item 0]
set value [lrange $item 1 end]
set value [::settings getValue "Register watches/$key" $value]
- lappend watch_text_tags "$key $value"
+ lappend watch_text_tags [concat $key $value]
}
set ::InstructionDetails::instruction_tags $instruction_tags
set ::RegWatches::watch_text_tags $watch_text_tags
@@ -478,7 +481,7 @@ namespace eval rightPanel {
variable changed ;# Bool: Settings changed
# Check if there is at least 1 opened editor
- if {[llength ${X::openedProjects}] == 0} {
+ if {[llength ${::X::openedProjects}] == 0} {
return 0
}
@@ -489,10 +492,14 @@ namespace eval rightPanel {
# Adjust NS variables
use_settings
# Adjust GUI in current project
- ${X::actualProject} rightPanel_refresh_instruction_highlighting
- ${X::actualProject} rightPanel_refresh_regwatches_highlighting
+ ${::X::actualProject} rightPanel_refresh_instruction_highlighting
+ ${::X::actualProject} rightPanel_refresh_regwatches_highlighting
# done ...
return 1
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/shortcuts_config.tcl b/lib/configdialogues/shortcuts_config.tcl
index e0be8fe..612dc6a 100755..100644
--- a/lib/configdialogs/shortcuts_config.tcl
+++ b/lib/configdialogues/shortcuts_config.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 _SHORTCUTS_CONFIG_TCL ] } {
+set _SHORTCUTS_CONFIG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements shortcuts configuration dialog
@@ -39,22 +44,22 @@ namespace eval shortcuts {
# Empty image
variable empty_image [image create bitmap]
# Font for entry "Current shortcut"
- variable current_entry_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -weight bold \
- -size -12 \
+ variable current_entry_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -weight [expr {$::MICROSOFT_WINDOWS ? "normal" : "bold"}] \
+ -size [expr {int(-12 * $::font_size_factor)}] \
]
# Normal font for tree widget nodes
- variable node_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -weight normal \
- -size -12 \
+ variable node_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -weight normal \
+ -size [expr {int(-12 * $::font_size_factor)}] \
]
# Bold font for tree widget nodes
- variable node_font_b [font create \
- -family {helvetica} \
- -weight bold \
- -size -14 \
+ variable node_font_b [font create \
+ -family {helvetica} \
+ -weight bold \
+ -size [expr {int(-14 * $::font_size_factor)}] \
]
variable status_label ;# ID of status label
@@ -112,25 +117,25 @@ namespace eval shortcuts {
# Get settings from the program
getSettings
- # Create list of hardcoded shortcuts related to main window
+ # Create list of hard-coded shortcuts related to main window
set root_hard_cd {}
foreach key ${::HARDCODED_SHORTCUTS} {
lappend root_hard_cd [simplify_key_seq $key]
}
# Create toplevel window
- set win [toplevel .shortcuts_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
+ set win [toplevel .shortcuts_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
-compound left \
-image ::ICONS::32::configure \
-text [mc "Configure key shortcuts"] \
- -font [font create -size -20]
+ -font [font create -size [expr {int(-20 * $::font_size_factor)}]]
# Create header labels for label frames
set top_lf_label [label $win.top_lf_label \
- -text [mc "Avaliable items"] \
+ -text [mc "available items"] \
-image ::ICONS::16::view_choose \
-compound left \
]
@@ -156,7 +161,7 @@ namespace eval shortcuts {
] -side left
set search_entry [ttk::entry $search_frame.entry \
-validate all \
- -validatecommand {::configDialogs::shortcuts::search %P} \
+ -validatecommand {::configDialogues::shortcuts::search %P} \
]
DynamicHelp::add $search_frame.entry \
-text [mc "Enter your search string here"]
@@ -176,7 +181,7 @@ namespace eval shortcuts {
set tree_frame [frame $top_labelframe.tree_frame]
pack $tree_frame -fill both -expand 1
- # Create tree widget showing avaliable items
+ # Create tree widget showing available items
set treeWidget [Tree $tree_frame.tree \
-selectfill 1 \
-showlines 1 \
@@ -191,7 +196,7 @@ namespace eval shortcuts {
-yscrollcommand "$tree_frame.scrollbar set" \
-crossopenimage ::ICONS::16::1downarrow \
-crosscloseimage ::ICONS::16::1rightarrow \
- -selectcommand {::configDialogs::shortcuts::item_selected} \
+ -selectcommand {::configDialogues::shortcuts::item_selected} \
]
pack $treeWidget -fill both -expand 1 -side left
bind $treeWidget <Button-5> {%W yview scroll +5 units; break}
@@ -246,7 +251,7 @@ namespace eval shortcuts {
# Determinate image ID
if {$image != {}} {
set image "::ICONS::16::$image"
- } {
+ } else {
set image $empty_image
}
@@ -273,22 +278,22 @@ namespace eval shortcuts {
-text [mc "Current shortcut:"] \
] -row 0 -column 0 -sticky w
set current_entry [ttk::entry $bottom_labelframe.current_entry \
- -validatecommand {::configDialogs::shortcuts::cur_entry_val %P} \
+ -validatecommand {::configDialogues::shortcuts::cur_entry_val %P} \
]
grid $current_entry -row 0 -column 1
bind $current_entry <KeyPress> \
- {::configDialogs::shortcuts::current_entry_key %K; break}
+ {::configDialogues::shortcuts::current_entry_key %K; break}
bind $current_entry <Control-KeyPress> \
- {::configDialogs::shortcuts::current_entry_key Ctrl+%K; break}
+ {::configDialogues::shortcuts::current_entry_key Ctrl+%K; break}
bind $current_entry <Alt-KeyPress> \
- {::configDialogs::shortcuts::current_entry_key Alt+%K; break}
+ {::configDialogues::shortcuts::current_entry_key Alt+%K; break}
bind $current_entry <Control-Alt-KeyPress> \
- {::configDialogs::shortcuts::current_entry_key Ctrl+Alt+%K; break}
+ {::configDialogues::shortcuts::current_entry_key Ctrl+Alt+%K; break}
set clear_button [ttk::button $bottom_labelframe.clear_button \
-image ::ICONS::16::clear_left \
-state disabled \
-style Flat.TButton \
- -command {::configDialogs::shortcuts::clear_current} \
+ -command {::configDialogues::shortcuts::clear_current} \
]
DynamicHelp::add $bottom_labelframe.clear_button -text [mc "Clear"]
grid $clear_button -row 0 -column 2 -sticky w
@@ -304,7 +309,7 @@ namespace eval shortcuts {
set default_button [ttk::button $bottom_labelframe.default_button \
-image ::ICONS::16::up0 \
-state disabled \
- -command {::configDialogs::shortcuts::to_default} \
+ -command {::configDialogues::shortcuts::to_default} \
-style Flat.TButton \
]
DynamicHelp::add $bottom_labelframe.default_button -text [mc "Restore default"]
@@ -312,7 +317,7 @@ namespace eval shortcuts {
# Button "Accept"
set accept_button [ttk::button $bottom_labelframe.accept_button \
- -command {::configDialogs::shortcuts::accept_current} \
+ -command {::configDialogues::shortcuts::accept_current} \
-text [mc "Accept"] \
-compound left \
-image ::ICONS::16::ok \
@@ -322,7 +327,7 @@ namespace eval shortcuts {
grid $accept_button -row 0 -column 4 -rowspan 2
# Button "Original"
set discard_button [ttk::button $bottom_labelframe.discard_button \
- -command {::configDialogs::shortcuts::discard_current} \
+ -command {::configDialogues::shortcuts::discard_current} \
-text [mc "Original"] \
-compound left \
-image ::ICONS::16::button_cancel \
@@ -346,7 +351,7 @@ namespace eval shortcuts {
# Button "Reset"
pack [ttk::button $but_frame.but_default \
-text [mc "Defaults"] \
- -command {::configDialogs::shortcuts::DEFAULTS} \
+ -command {::configDialogues::shortcuts::DEFAULTS} \
] -side left
DynamicHelp::add $but_frame.but_default -text [mc "Reset all settings to defaults"]
# Button "Ok"
@@ -354,16 +359,16 @@ namespace eval shortcuts {
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::shortcuts::OK} \
- ] -side right
+ -command {::configDialogues::shortcuts::OK} \
+ ] -side right -padx 2
DynamicHelp::add $but_frame.but_ok -text [mc "Commit new settings"]
# Button "Cancel"
pack [ttk::button $but_frame.but_cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {::configDialogs::shortcuts::CANCEL} \
- ] -side right
+ -command {::configDialogues::shortcuts::CANCEL} \
+ ] -side right -padx 2
DynamicHelp::add $but_frame.but_cancel -text [mc "Take changes back and close dialog"]
# Pack frames
@@ -380,7 +385,7 @@ namespace eval shortcuts {
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::shortcuts::CANCEL
+ ::configDialogues::shortcuts::CANCEL
}
tkwait window $win
}
@@ -415,6 +420,7 @@ namespace eval shortcuts {
# Clear and disable componets of the bottom frame
$current_entry delete 0 end
+ cur_entry_val {}
$default_entry configure -text {}
$status_label configure -text {}
$current_entry configure -state disabled
@@ -466,6 +472,7 @@ namespace eval shortcuts {
$current_entry configure -state normal
$current_entry delete 0 end
$current_entry insert end [simplify_key_seq [lindex $data 2]]
+ cur_entry_val [simplify_key_seq [lindex $data 2]]
$default_entry configure -text [simplify_key_seq [lindex $data 1]]
$default_button configure -state normal
ena_dis__accept_discard 0
@@ -488,6 +495,7 @@ namespace eval shortcuts {
# Clear entry "Custom shortcut"
$current_entry delete 0 end
+ cur_entry_val {}
# Adjust key combination
set lastchar [string index $key_seq end]
@@ -495,7 +503,7 @@ namespace eval shortcuts {
if {[string is lower -strict $lastchar]} {
set key_seq [string replace $key_seq \
end end [string toupper $lastchar]]
- } {
+ } else {
set key_seq [string replace $key_seq end end \
"Shift+[string toupper $lastchar]"]
}
@@ -507,35 +515,39 @@ namespace eval shortcuts {
$status_label configure -text [mc "Modifier required (Control or Alt)"]
} elseif {[lsearch $root_hard_cd $key_seq] != -1} {
$status_label configure -text \
- [mc "This combination is hardcoded in the main window, so it cannot be used"]
+ [mc "This combination is hard-coded in the main window, so it cannot be used"]
} elseif {[lsearch [$treeWidget itemcget [$treeWidget parent $currentNode] -data] $key_seq] != -1} {
$status_label configure -text \
- [mc "This combination is hardcoded, so it cannot be used"]
+ [mc "This combination is hard-coded, so it cannot be used"]
} else {
set changed 1
}
if {!$changed} {
$current_entry insert end $key_seq
+ cur_entry_val $key_seq
ena_dis__accept_discard 0
return
}
# Change content of entry "Custom shortcut"
$current_entry insert end $key_seq
+ cur_entry_val $key_seq
# Check if the given combination is not already assigned to something
set name [lindex [key_seq_to_name \
[extend_key_seq $key_seq] \
[$treeWidget parent $currentNode]] 1]
- if {$name != {}} {
+ if {$name != {} && $name != [string trim [lindex [$treeWidget itemcget $currentNode -data] 0]]} {
$status_label configure -text \
[mc "The '%s' key combination has already been assigned to \"%s\"." $key_seq $name]
- } {
+ } else {
$status_label configure -text {}
}
- # Enable buttons "Accept" and "Original"
- ena_dis__accept_discard 1
+ # Enable buttons "Accept" and "Original" (but only if user is not trying to redefine a shortcut with the same key combination)
+ if {$name != [string trim [lindex [$treeWidget itemcget $currentNode -data] 0]]} {
+ ena_dis__accept_discard 1
+ }
}
## Clear entry "Custom shortcut"
@@ -552,6 +564,7 @@ namespace eval shortcuts {
}
# Clear the entry widget and status label
$current_entry delete 0 end
+ cur_entry_val {}
$status_label configure -text {}
# Enable buttons "Accept" and "Original"
ena_dis__accept_discard 1
@@ -568,7 +581,7 @@ namespace eval shortcuts {
# Enable/Disable button "Clear"
if {$content == {}} {
$clear_button configure -state disabled
- } {
+ } else {
$clear_button configure -state normal
}
@@ -595,6 +608,7 @@ namespace eval shortcuts {
set key [$default_entry cget -text]
$current_entry delete 0 end
$current_entry insert 0 $key
+ cur_entry_val $key
# Check if the new setting is unique
set name [lindex [key_seq_to_name \
@@ -648,7 +662,7 @@ namespace eval shortcuts {
-text $txt \
-data [list $txt $dt {}]
# Keep
- } {
+ } else {
$status_label configure -text {}
}
@@ -674,10 +688,11 @@ namespace eval shortcuts {
variable currentNode ;# ID of the currently selected tree node
variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
- # Restore prevoius content of entry "Current shortcut"
+ # Restore previous content of entry "Current shortcut"
$current_entry delete 0 end
$current_entry insert end [simplify_key_seq \
[lindex [$treeWidget itemcget $currentNode -data] 2]]
+ cur_entry_val [$current_entry get]
# Clear status label
$status_label configure -text {}
@@ -695,13 +710,14 @@ namespace eval shortcuts {
variable win ;# ID of toplevel dialog window
set changed 0
- if {![tk_messageBox \
+ if {[tk_messageBox \
-type yesno \
-parent $win \
-icon question \
-title [mc "Item changed"] \
- -message [mc "The prevoius item was modified. Do you want to save it ?"] \
- ]} {
+ -message [mc "The previous item was modified. Do you want to save it ?"] \
+ ] != {yes}
+ } then {
return
}
@@ -765,7 +781,7 @@ namespace eval shortcuts {
if {$ena_dis} {
$discard_button configure -state normal
$accept_button configure -state normal
- } {
+ } else {
$discard_button configure -state disabled
$accept_button configure -state disabled
}
@@ -858,7 +874,7 @@ namespace eval shortcuts {
# Adjust right panel
$project rightPanel_makePopupMenu
$project rightPanel_watch_shortcuts_reevaluate
- # Adjust todo list
+ # Adjust to do list
$project TodoProc_makePopupMenu
$project TodoProc_shortcuts_reevaluate
# Adjust messages text
@@ -957,14 +973,14 @@ namespace eval shortcuts {
variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
# Ask user
- if {![tk_messageBox \
+ if {[tk_messageBox \
-parent $win \
-type yesno \
-title [mc "Confirmation required"] \
-icon question \
-message [mc "This will discard all shortcut settings and replace them with defaults. Are you sure by that ?"]\
- ]
- } {
+ ] != {yes}
+ } then {
return
}
@@ -1013,3 +1029,7 @@ namespace eval shortcuts {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/simulator_config.tcl b/lib/configdialogues/simulator_config.tcl
index 38e9e49..bbfd2b0 100755..100644
--- a/lib/configdialogs/simulator_config.tcl
+++ b/lib/configdialogues/simulator_config.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 _SIMULATOR_CONFIG_TCL ] } {
+set _SIMULATOR_CONFIG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements simulator configuration dialog
@@ -30,6 +35,8 @@ namespace eval simulator {
variable win ;# ID of toplevel dialog window
variable dialog_opened 0 ;# Bool: True if this dialog is already opened
+ variable on_color_button ;# Widget: Button "ON color" in section "Colors"
+ variable off_color_button ;# Widget: Button "OFF color" in section "Colors"
# List of default settings
variable defaults {
@@ -50,6 +57,9 @@ namespace eval simulator {
{ignore_invalid_UMC 0}
{ignore_invalid_TMC 0}
{undefined_value 2}
+ {ignore_invalid_brkpoints 0}
+ {on_color #00CC00}
+ {off_color #DD0000}
}
# Option variables
@@ -70,15 +80,19 @@ namespace eval simulator {
variable ignore_invalid_UMC ;# Bool: Ignore invalid UART mode change
variable ignore_invalid_TMC ;# Bool: Ignore invalid Timer/Counter mode change
variable undefined_value ;# Int: How to handle undefined values (0 == 0; 1 == 255; 2 == random)
-
+ variable ignore_invalid_brkpoints ;# Bool: Do not warn user about invalid (unreachable) breakpoints
+ variable on_color ;# RGB: Color to display a bit name for a bit set to log. 1
+ variable off_color ;# RGB: Color to display a bit name for a bit set to log. 0
## Create the dialog
# @return void
proc mkDialog {} {
- variable win ;# ID of toplevel dialog window
- variable dialog_opened ;# Bool: True if this dialog is already opened
+ variable win ;# ID of toplevel dialog window
+ variable dialog_opened ;# Bool: True if this dialog is already opened
+ variable on_color_button ;# Widget: Button "ON color" in section "Colors"
+ variable off_color_button ;# Widget: Button "OFF color" in section "Colors"
- # Destroy the dialog if it's alredy opened
+ # Destroy the dialog if it's already opened
if {$dialog_opened} {
destroy .simulator_config_dialog
}
@@ -88,7 +102,7 @@ namespace eval simulator {
getSettings
# Create toplevel window
- set win [toplevel .simulator_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
+ set win [toplevel .simulator_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
@@ -99,16 +113,15 @@ namespace eval simulator {
-size -20]
## Create notebook
- set nb [ttk::notebook $win.nb]
- # Tab "Warning dialogs"
- set warnings_tab [frame $nb.warnings_tab]
- $nb add $warnings_tab -text [mc "Warning dialogs"]
+ set nb [ModernNoteBook $win.nb]
+ # Tab "Warning dialogues"
+ set warnings_tab [$nb insert end warnings_tab -text [mc "Warning dialogues"]]
+
# Tab "Other"
- set other_tab [frame $nb.other_tab]
- $nb add $other_tab -text [mc "Other"]
+ set other_tab [$nb insert end other_tab -text [mc "Other"]]
#
- ## Tab "Warning dialogs"
+ ## Tab "Warning dialogues"
#
set row 0
foreach text {
@@ -132,13 +145,15 @@ namespace eval simulator {
{Ignore UART frame discard}
{Ignore illegal UART mode change}
{Ignore illegal Timer/Counter mode change}
+ {-}
+ {Do not complain about invalid breakpoints}
} helptext {
{Check this to disable warning on stack overflow}
{Check this to disable warning on stack underflow}
{-}
{Check this to disable warning on\ninvalid instruction}
- {Do not stop simulation on device reset\ninvoked by watchog timer overflow}
- {Do not show warning dialog when program tring to return from interrupt which has not been invoked}
+ {Do not stop simulation on device reset\ninvoked by watchdog timer overflow}
+ {Do not show warning dialog when program trying to return from interrupt which has not been invoked}
{Do not display warning dialog when\nreading from write-only register}
{-}
{Do not display dialog "Undefined result" when simulated program\naccessing unimplemented Internal Data Memory (IDATA) or SFR area}
@@ -153,6 +168,8 @@ namespace eval simulator {
{Check this to disable warning on UART frame discard}
{Check this to disable warning on illegal UART mode change}
{Check this to disable warning on illegal Timer/Counter mode change}
+ {-}
+ {Disable warning: "warning: Invalid breakpoint"}
} variable {
ignore_stack_overflow ignore_stack_underflow
-
@@ -167,6 +184,8 @@ namespace eval simulator {
-
ignore_invalid_USB ignore_invalid_UMC
ignore_invalid_TMC
+ -
+ ignore_invalid_brkpoints
} {
incr row
@@ -180,10 +199,11 @@ namespace eval simulator {
# Create
grid [Label $warnings_tab.label__$row \
- -text $text -helptext [subst $helptext] \
+ -text [mc $text] \
+ -helptext [subst [mc $helptext]] \
] -row $row -column 0 -sticky w -padx 5
grid [checkbutton $warnings_tab.chbutton_$row \
- -variable ::configDialogs::simulator::$variable \
+ -variable ::configDialogues::simulator::$variable \
] -row $row -column 1 -sticky e -padx 5
DynamicHelp::add $warnings_tab.chbutton_$row \
-text [subst $helptext]
@@ -201,17 +221,17 @@ namespace eval simulator {
]
pack [radiobutton $undefined_labelframe.random \
-value 2 -text [mc "Return random value"] \
- -variable ::configDialogs::simulator::undefined_value \
+ -variable ::configDialogues::simulator::undefined_value \
] -anchor w
pack [radiobutton $undefined_labelframe.zero \
-value 0 -text [mc "Return zero value"] \
- -variable ::configDialogs::simulator::undefined_value \
+ -variable ::configDialogues::simulator::undefined_value \
] -anchor w
pack [radiobutton $undefined_labelframe.one \
-value 1 -text [mc "Return highest possible value"] \
- -variable ::configDialogs::simulator::undefined_value \
+ -variable ::configDialogues::simulator::undefined_value \
] -anchor w
- pack $undefined_labelframe -fill x -padx 5 -pady 10
+ pack $undefined_labelframe -fill x -padx 5 -pady 5
# LabelFrame: "Reverse run"
set reverse_run_labelframe [ttk::labelframe $other_tab.reverse_run_labelframe \
@@ -221,61 +241,135 @@ namespace eval simulator {
-text [mc "Stack capacity"] \
-helptext [mc "Number of steps which can be taken back"] \
] -row 4 -column 0 -sticky w -padx 5
- grid [spinbox $reverse_run_labelframe.rrun_spinbox \
- -from 0 -to 1000 -bg white -validate all -width 4 \
- -vcmd "::configDialogs::simulator::rrun_spinbox_val %P" \
- -textvariable ::configDialogs::simulator::reverse_run_steps \
+ grid [ttk::spinbox $reverse_run_labelframe.rrun_spinbox \
+ -from 0 -to 1000 -validate all -width 4 \
+ -validatecommand "::configDialogues::simulator::rrun_spinbox_val %P" \
+ -textvariable ::configDialogues::simulator::reverse_run_steps \
] -row 4 -column 1 -sticky we -padx 5
DynamicHelp::add $reverse_run_labelframe.rrun_spinbox \
-text [mc "Number of steps which can be taken back"]
grid columnconfigure $reverse_run_labelframe 0 -minsize 250
grid columnconfigure $reverse_run_labelframe 1 -weight 1
- pack $reverse_run_labelframe -fill x -padx 5 -pady 10
+ pack $reverse_run_labelframe -fill x -padx 5 -pady 5
+
+ # LabelFrame: "Colors"
+ set colors_labelframe [ttk::labelframe $other_tab.colors_labelframe \
+ -text [mc "Colors"] -padding 7 \
+ ]
+ set row -1
+ foreach text {
+ {ON color}
+ {OFF color}
+ } helptext {
+ {Color to display a bit name for a bit set to log. 1}
+ {Color to display a bit name for a bit set to log. 0}
+ } variable {
+ on_color
+ off_color
+ } buttonvar {
+ on_color_button
+ off_color_button
+ } {
+ incr row
+
+ set text [mc $text]
+ set helptext [mc $helptext]
+ set variable "::configDialogues::simulator::$variable"
+
+ # Get color from the given variable
+ set color [subst -nocommands "\${$variable}"]
+
+ # Create label
+ grid [Label $colors_labelframe.lbl$row \
+ -text $text \
+ -helptext $helptext \
+ ] -row $row -column 0 -sticky w -padx 5
+
+ # Create button
+ set button [button $colors_labelframe.button$row \
+ -bd 1 -relief raised -pady 0 -highlightthickness 0 \
+ -bg $color -width 10 -activebackground $color \
+ -command "::configDialogues::simulator::select_color $variable $colors_labelframe.button$row"
+ ]
+ grid $button -row $row -column 1 -sticky we -padx 5
+ set $buttonvar $button
+ DynamicHelp::add $colors_labelframe.button$row -text $helptext
+ }
+ grid columnconfigure $colors_labelframe 0 -minsize 250
+ grid columnconfigure $colors_labelframe 1 -weight 1
+ pack $colors_labelframe -fill x -padx 5 -pady 5
# Raise tab "Output"
- $nb select $warnings_tab
+ $nb raise warnings_tab
# Create button frame at the bottom
set but_frame [frame $win.button_frame]
- # Button "Defaults"
+ # Button "Defaults"
pack [ttk::button $but_frame.but_default \
-text [mc "Defaults"] \
- -command {::configDialogs::simulator::DEFAULTS} \
+ -command {::configDialogues::simulator::DEFAULTS} \
] -side left
DynamicHelp::add $but_frame.but_default -text [mc "Reset settings to defaults"]
- # Button "Ok"
- pack [ttk::button $but_frame.but_ok \
+ # Button "Ok"
+ pack [ttk::button $but_frame.but_ok \
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::simulator::OK} \
- ] -side right
- # Button "Cancel"
+ -command {::configDialogues::simulator::OK} \
+ ] -side right -padx 2
+ # Button "Cancel"
pack [ttk::button $but_frame.but_cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {::configDialogs::simulator::CANCEL} \
- ] -side right
+ -command {::configDialogues::simulator::CANCEL} \
+ ] -side right -padx 2
# Pack frames and notebook
pack $win.header_label -side top -pady 6
- pack $nb -side top -fill both -expand 1 -padx 10
- pack $but_frame -side top -fill x -expand 1 -anchor s -padx 10 -pady 5
+ pack [$nb get_nb] -side top -fill both -expand 1 -padx 10
+ pack $but_frame -side top -fill x -anchor s -padx 10 -pady 5
# Set window attributes
wm iconphoto $win ::ICONS::16::configure
wm transient $win .
wm title $win [mc "Simulator configuration - %s" ${::APPNAME}]
- wm minsize $win 380 480
+ wm minsize $win 380 520
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::simulator::CANCEL
+ ::configDialogues::simulator::CANCEL
}
tkwait window $win
}
+ ## Select some color (command for buttons in labelbox "Colors")
+ # @parm Variable variable - variable containing current color (format RGB)
+ # @parm Widget button - ID of button which invoked this procedure
+ # @return void
+ proc select_color {variable button} {
+ variable win ;# ID of dialog toplevel window
+
+ # Destroy previously opened color selection dialog
+ if {[winfo exists .select_color]} {
+ destroy .select_color
+ }
+
+ # Invoke new color selection dialog
+ set color [subst -nocommands "\$$variable"]
+ set color [SelectColor .select_color \
+ -parent $win \
+ -color $color \
+ -title [mc "Select color - %s" ${::APPNAME}] \
+ ]
+
+ # Set new content of the given variable and button background color
+ if {$color != {}} {
+ set $variable $color
+ $button configure -bg $color -activebackground $color
+ }
+ }
+
## Validate contents of spinbox in section "Reverse Run"
# @parm String content - String to validate
# @return Bool - validation result (0 == failed; 1 == successfull)
@@ -309,6 +403,7 @@ namespace eval simulator {
variable ignore_EEPROM_WR_fail ;# Bool: Ignore EEPROM write failure
variable ignore_EEPROM_WR_abort ;# Bool: Ignore EEPROM write abort
variable undefined_value ;# Int: How to handle undefined values (0 == 0; 1 == 255; 2 == random)
+ variable ignore_invalid_brkpoints ;# Bool: Do not warn user about invalid (unreachable) breakpoints
getSettings
set $variable $value
@@ -324,11 +419,15 @@ namespace eval simulator {
# Set local option variables
foreach var $defaults {
set var [lindex $var 0]
- set ::configDialogs::simulator::${var} [subst "\$::Simulator::$var"]
+ if {$var == {on_color} || $var == {off_color}} {
+ set ::configDialogues::simulator::${var} [subst -nocommands "\$::Simulator_GUI::${var}"]
+ } else {
+ set ::configDialogues::simulator::${var} [subst -nocommands "\$::Simulator::${var}"]
+ }
}
}
- ## Set simulator acording to local settings
+ ## Set simulator according to local settings
# @return void
proc use_settings {} {
variable reverse_run_steps ;# Int: Number of steps which can be taken back
@@ -342,7 +441,11 @@ namespace eval simulator {
# Set option variables
foreach var $defaults {
set var [lindex $var 0]
- set ::Simulator::$var [subst "\$::configDialogs::simulator::${var}"]
+ if {$var == {on_color} || $var == {off_color}} {
+ set ::Simulator_GUI::$var [subst -nocommands "\$::configDialogues::simulator::${var}"]
+ } else {
+ set ::Simulator::$var [subst -nocommands "\$::configDialogues::simulator::${var}"]
+ }
}
}
@@ -354,7 +457,11 @@ namespace eval simulator {
# Save option variables
foreach var $defaults {
set var [lindex $var 0]
- ::settings setValue "Simulator/$var" [subst "\$::Simulator::${var}"]
+ if {$var == {on_color} || $var == {off_color}} {
+ ::settings setValue "Simulator/$var" [subst -nocommands "\$::Simulator_GUI::${var}"]
+ } else {
+ ::settings setValue "Simulator/$var" [subst -nocommands "\$::Simulator::${var}"]
+ }
}
# Synchronize
@@ -370,7 +477,11 @@ namespace eval simulator {
foreach item $defaults {
set var [lindex $item 0]
set val [lindex $item 1]
- set ::Simulator::${var} [::settings getValue "Simulator/$var" $val]
+ if {$var == {on_color} || $var == {off_color}} {
+ set ::Simulator_GUI::${var} [::settings getValue "Simulator/$var" $val]
+ } else {
+ set ::Simulator::${var} [::settings getValue "Simulator/$var" $val]
+ }
}
}
@@ -400,15 +511,17 @@ namespace eval simulator {
## Restrore defaults
# @return void
proc DEFAULTS {} {
- variable win ;# ID of toplevel dialog window
- variable defaults ;# List of default settings
+ variable win ;# ID of toplevel dialog window
+ variable defaults ;# List of default settings
+ variable on_color_button ;# Widget: Button "ON color" in section "Colors"
+ variable off_color_button ;# Widget: Button "OFF color" in section "Colors"
if {[tk_messageBox \
-parent $win \
-type yesno \
-icon question \
-title [mc "Are you sure ?"] \
- -message [mc "Are you sure you want to resore default settings"] \
+ -message [mc "Are you sure you want to restore default settings"] \
] != {yes}} {
return
}
@@ -417,7 +530,18 @@ namespace eval simulator {
foreach item $defaults {
set var [lindex $item 0]
set val [lindex $item 1]
- set ::configDialogs::simulator::${var} $val
+ set ::configDialogues::simulator::${var} $val
+
+ # Update colors of color buttons
+ if {$var == {on_color}} {
+ $on_color_button configure -bg $val -activebackground $val
+ } elseif {$var == {off_color}} {
+ $off_color_button configure -bg $val -activebackground $val
+ }
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/terminal_config.tcl b/lib/configdialogues/terminal_config.tcl
index 831540f..732b5cb 100755..100644
--- a/lib/configdialogs/terminal_config.tcl
+++ b/lib/configdialogues/terminal_config.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_CONFIG_TCL ] } {
+set _TERMINAL_CONFIG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements terminal configuration dialog
@@ -50,7 +55,7 @@ namespace eval terminal {
variable fg_clr_but ;# Widget: Button for selecting foreground color
variable bg_clr_but ;# Widget: Button for selecting background color
- # Destroy the dialog if it's alredy opened
+ # Destroy the dialog if it's already opened
if {$dialog_opened} {
destroy .terminal_config_dialog
}
@@ -62,12 +67,12 @@ namespace eval terminal {
getSettings
# Create toplevel window
- set win [toplevel .terminal_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
+ set win [toplevel .terminal_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
-text [mc "Terminal configuration"] \
- -font [font create -size -20]
+ -font [font create -size [expr {int(-20 * $::font_size_factor)}]]
# Create horizontal separator
Separator $win.sep -orient horizontal
@@ -83,7 +88,7 @@ namespace eval terminal {
-bd 1 -relief raised -pady 0 -width 10 \
-bg $configuration(fg) \
-activebackground $configuration(fg) \
- -command "::configDialogs::terminal::select_color {foreground} fg $main_frame.fg_but" \
+ -command "::configDialogues::terminal::select_color {foreground} fg $main_frame.fg_but" \
]
grid $fg_clr_but -column 1 -row $row -sticky wens
incr row
@@ -95,7 +100,7 @@ namespace eval terminal {
-bd 1 -relief raised -pady 0 -width 10 \
-bg $configuration(bg) \
-activebackground $configuration(bg) \
- -command "::configDialogs::terminal::select_color {background} bg $main_frame.bg_but" \
+ -command "::configDialogues::terminal::select_color {background} bg $main_frame.bg_but" \
]
grid $bg_clr_but -column 1 -row $row -sticky wens
incr row
@@ -103,11 +108,11 @@ namespace eval terminal {
grid [label $main_frame.font_size_lbl \
-text [mc "Font size"] \
] -row $row -column 0 -sticky w
- grid [spinbox $main_frame.font_size_spb \
- -from 4 -to 22 -validate all -width 0 \
- -vcmd {::configDialogs::terminal::font_size_valiade %P} \
- -textvariable ::configDialogs::terminal::configuration(font_size) \
- -command ::configDialogs::terminal::font_changed \
+ grid [ttk::spinbox $main_frame.font_size_spb \
+ -from 4 -to 22 -validate all -width 0 \
+ -validatecommand {::configDialogues::terminal::font_size_valiade %P} \
+ -textvariable ::configDialogues::terminal::configuration(font_size) \
+ -command ::configDialogues::terminal::font_changed \
] -row $row -column 1 -sticky we
incr row
# Font family
@@ -118,10 +123,10 @@ namespace eval terminal {
-state readonly \
-values [lsort [font families]] \
-width 20 \
- -textvariable ::configDialogs::terminal::configuration(font_family) \
+ -textvariable ::configDialogues::terminal::configuration(font_family) \
] -row $row -column 1 -sticky we
bind $main_frame.font_family_cbx <<ComboboxSelected>> \
- {::configDialogs::terminal::font_changed}
+ {::configDialogues::terminal::font_changed}
incr row
# Example text
set selected_font [font create \
@@ -141,7 +146,7 @@ namespace eval terminal {
-text [mc "Use settings and restart terminal emulator"] \
-compound left \
-image ::ICONS::16::reload \
- -command {::configDialogs::terminal::RESTART} \
+ -command {::configDialogues::terminal::RESTART} \
]
## Button frame at the bottom
@@ -149,7 +154,7 @@ namespace eval terminal {
# Button "Reset"
pack [ttk::button $but_frame.but_default \
-text [mc "Reset to defaults"] \
- -command {::configDialogs::terminal::DEFAULTS} \
+ -command {::configDialogues::terminal::DEFAULTS} \
] -side left
DynamicHelp::add $but_frame.but_default \
-text [mc "Reset all settings to defaults"]
@@ -158,8 +163,8 @@ namespace eval terminal {
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::terminal::OK} \
- ] -side right
+ -command {::configDialogues::terminal::OK} \
+ ] -side right -padx 2
DynamicHelp::add $but_frame.but_ok \
-text [mc "Commit new settings"]
# Button "Cancel"
@@ -167,8 +172,8 @@ namespace eval terminal {
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {::configDialogs::terminal::CANCEL} \
- ] -side right
+ -command {::configDialogues::terminal::CANCEL} \
+ ] -side right -padx 2
DynamicHelp::add $but_frame.but_cancel \
-text [mc "Take changes back and close dialog"]
@@ -183,11 +188,11 @@ namespace eval terminal {
wm iconphoto $win ::ICONS::16::configure
wm transient $win .
wm title $win [mc "Configure terminal emulator"]
- wm minsize $win 380 250
+ wm minsize $win 380 280
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::terminal::CANCEL
+ ::configDialogues::terminal::CANCEL
}
tkwait window $win
}
@@ -196,12 +201,18 @@ namespace eval terminal {
# @pamr String content - String to valiadte
# @return void
proc font_size_valiade {content} {
+ if {$content == {}} {
+ return 1
+ }
if {![string is digit $content]} {
return 0
}
- if {$content < 4 || $content > 22} {
+ if {$content > 22} {
return 0
}
+ after idle {
+ ::configDialogues::terminal::font_changed
+ }
return 1
}
@@ -213,6 +224,10 @@ namespace eval terminal {
variable selected_font ;# Font: Current font
variable changed ;# Bool: Settings changed
+ if {$configuration(font_size) == {} || $configuration(font_size) < 4} {
+ return
+ }
+
font delete $selected_font
set selected_font [font create \
-family $configuration(font_family) \
@@ -264,10 +279,13 @@ namespace eval terminal {
array set configuration [array get ::Terminal::configuration]
}
- ## Set application acording to local settings
+ ## Set application according to local settings
# @return void
proc use_settings {} {
variable configuration ;# Array: Configuration array
+ if {$configuration(font_size) == {} || $configuration(font_size) < 4} {
+ set configuration(font_size) 13
+ }
array set ::Terminal::configuration [array get configuration]
}
@@ -295,11 +313,11 @@ namespace eval terminal {
}
# Validate configuration
- if {![regexp {^#[0-9a-fA-F]{6}$} ${::Terminal::configuration(bg)}]} {
+ if {![regexp {^#[0-9a-fA-F]{6,12}$} ${::Terminal::configuration(bg)}]} {
puts stderr [mc "Invalid value of key: '%s'" {bg}]
set ::Terminal::configuration(bg) {#FFFFFF}
}
- if {![regexp {^#[0-9a-fA-F]{6}$} ${::Terminal::configuration(fg)}]} {
+ if {![regexp {^#[0-9a-fA-F]{6,12}$} ${::Terminal::configuration(fg)}]} {
puts stderr [mc "Invalid value of key: '%s'" {fg}]
set ::Terminal::configuration(fg) {#000000}
}
@@ -309,7 +327,7 @@ namespace eval terminal {
${::Terminal::configuration(font_size)} < 4
||
${::Terminal::configuration(font_size)} > 22
- } {
+ } then {
puts stderr [mc "Invalid value of key: '%s'" {font_size}]
set ::Terminal::configuration(font_size) 13
}
@@ -372,3 +390,7 @@ namespace eval terminal {
-activebackground $configuration(bg)
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/configdialogs/toolbar_config.tcl b/lib/configdialogues/toolbar_config.tcl
index 1ae5b5c..abddd01 100755..100644
--- a/lib/configdialogs/toolbar_config.tcl
+++ b/lib/configdialogues/toolbar_config.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,11 +21,17 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _TOOLBAR_CONFIG_TCL ] } {
+set _TOOLBAR_CONFIG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements main toolbar configuration dialog
# --------------------------------------------------------------------------
+
namespace eval toolbar {
variable win ;# ID of toplevel dialog window
variable dialog_opened 0 ;# Bool: True if this dialog is already opened
@@ -35,7 +41,7 @@ namespace eval toolbar {
variable apply_button ;# ID of button "Apply"
variable current_ListBox ;# ID of ListBox containing current toolbar setup
- variable options_ListBox ;# ID of ListBox containing avaliable icons
+ variable options_ListBox ;# ID of ListBox containing available icons
variable current_search_entry ;# ID of search EntryBox for $current_ListBox
variable options_search_entry ;# ID of search EntryBox for $options_ListBox
variable current_search_clear ;# ID of search EntryBox clear button for $current_ListBox
@@ -56,7 +62,7 @@ namespace eval toolbar {
variable apply_button ;# ID of button "Apply"
variable current_ListBox ;# ID of ListBox containing current toolbar setup
- variable options_ListBox ;# ID of ListBox containing avaliable icons
+ variable options_ListBox ;# ID of ListBox containing available icons
variable current_search_entry ;# ID of search EntryBox for $current_ListBox
variable options_search_entry ;# ID of search EntryBox for $options_ListBox
variable current_search_clear ;# ID of search EntryBox clear button for $current_ListBox
@@ -66,7 +72,7 @@ namespace eval toolbar {
variable right_button ;# ID of button "Right"
variable down_button ;# ID of button "Down"
- # Destroy the dialog if it's alredy opened
+ # Destroy the dialog if it's already opened
if {$dialog_opened} {
destroy .toolbar_config_dialog
}
@@ -75,14 +81,14 @@ namespace eval toolbar {
set changed 0
# Create toplevel window
- set win [toplevel .toolbar_config_dialog -class {Configuration dialog} -bg {#EEEEEE}]
+ set win [toplevel .toolbar_config_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
label $win.header_label \
-compound left \
-image ::ICONS::32::configure \
-text [mc "Toolbar configuration"] \
- -font [font create -size -20]
+ -font [font create -size [expr {int(-20 * $::font_size_factor)}]]
# Create main frame (ListBoxes and Arrows)
set main_frame [frame $win.main_frame]
@@ -94,28 +100,28 @@ namespace eval toolbar {
-image ::ICONS::16::up \
-state disabled \
-style Flat.TButton \
- -command {::configDialogs::toolbar::up} \
+ -command {::configDialogues::toolbar::up} \
]
# Arrow "Left"
set left_button [ttk::button $arrows.left \
-image ::ICONS::16::left \
-state disabled \
-style Flat.TButton \
- -command {::configDialogs::toolbar::left} \
+ -command {::configDialogues::toolbar::left} \
]
# Arrow "Right"
set right_button [ttk::button $arrows.right \
-image ::ICONS::16::right \
-state disabled \
-style Flat.TButton \
- -command {::configDialogs::toolbar::right} \
+ -command {::configDialogues::toolbar::right} \
]
# Arrow "Down"
set down_button [ttk::button $arrows.down \
-image ::ICONS::16::down \
-state disabled \
-style Flat.TButton \
- -command {::configDialogs::toolbar::down} \
+ -command {::configDialogues::toolbar::down} \
]
# Place arrows to the grid
@@ -124,7 +130,7 @@ namespace eval toolbar {
grid $right_button -column 2 -row 1
grid $down_button -column 1 -row 2
- # Create ListBox of avaliable items and its scrollbar
+ # Create ListBox of available items and its scrollbar
set options_frame [frame $main_frame.options_frame]
set listbox_frame [frame $options_frame.listbox_frame]
set options_ListBox [ListBox $listbox_frame.options_ListBox \
@@ -145,11 +151,11 @@ namespace eval toolbar {
-command "$options_ListBox yview" \
] -side right -after $options_ListBox -fill y
- # Create search bar for ListBox of avaliable items
+ # Create search bar for ListBox of available items
set search_frame [frame $options_frame.search_frame]
set options_search_entry [ttk::entry $search_frame.entry \
-validate all \
- -validatecommand {::configDialogs::toolbar::search O %P} \
+ -validatecommand {::configDialogues::toolbar::search O %P} \
]
DynamicHelp::add $search_frame.entry -text [mc "Search for a string in ListBox"]
pack $options_search_entry -side left -fill x -expand 1
@@ -163,9 +169,9 @@ namespace eval toolbar {
-text [mc "Clear"]
pack $options_search_clear -side right -after $options_search_entry
- # Pack frames of the left part (avaliable items)
+ # Pack frames of the left part (available items)
pack $search_frame -fill x
- pack [label $options_frame.label -text [mc "Avaliable items"]] -pady 5
+ pack [label $options_frame.label -text [mc "available items"]] -pady 5
pack $listbox_frame -fill both -expand 1
@@ -194,7 +200,7 @@ namespace eval toolbar {
set search_frame [frame $current_frame.search_frame]
set current_search_entry [ttk::entry $search_frame.entry \
-validate all \
- -validatecommand {::configDialogs::toolbar::search C %P} \
+ -validatecommand {::configDialogues::toolbar::search C %P} \
]
DynamicHelp::add $search_frame.entry -text [mc "Search for a string in ListBox"]
pack $current_search_entry -side left -fill x -expand 1
@@ -216,9 +222,9 @@ namespace eval toolbar {
# Set event bindings for ListBoxes
bind $options_ListBox <<ListboxSelect>> \
- "::configDialogs::toolbar::reevaluateArrows"
+ "::configDialogues::toolbar::reevaluateArrows"
bind $current_ListBox <<ListboxSelect>> \
- "::configDialogs::toolbar::reevaluateArrows"
+ "::configDialogues::toolbar::reevaluateArrows"
# Pack left ListBox, arrows frame, right ListBox
@@ -234,7 +240,7 @@ namespace eval toolbar {
# Button "Defaults"
pack [ttk::button $but_frame.but_default \
-text [mc "Defaults"] \
- -command {::configDialogs::toolbar::DEFAULTS} \
+ -command {::configDialogues::toolbar::DEFAULTS} \
] -side left
DynamicHelp::add $but_frame.but_default \
-text [mc "Reset settings to defaults"]
@@ -243,24 +249,24 @@ namespace eval toolbar {
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::toolbar::OK} \
- ] -side right
+ -command {::configDialogues::toolbar::OK} \
+ ] -side right -padx 2
# Button "Apply"
- set apply_button [ttk::button $but_frame.but_apply \
+ set apply_button [ttk::button $but_frame.but_apply \
-state disabled \
-text [mc "Apply"] \
-compound left \
-image ::ICONS::16::ok \
- -command {::configDialogs::toolbar::APPLY} \
+ -command {::configDialogues::toolbar::APPLY} \
]
- pack $apply_button -side right
+ pack $apply_button -side right -padx 2
# Button "Cancel"
pack [ttk::button $but_frame.but_cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {::configDialogs::toolbar::CANCEL} \
- ] -side right
+ -command {::configDialogues::toolbar::CANCEL} \
+ ] -side right -padx 2
# Pack frames and notebook
pack $but_frame -side bottom -fill x -expand 0 -anchor s -padx 10 -pady 5
@@ -275,22 +281,37 @@ namespace eval toolbar {
raise $win
catch {grab $win}
wm protocol $win WM_DELETE_WINDOW {
- ::configDialogs::toolbar::CANCEL
+ if {${::configDialogues::toolbar::anything_modified}} {
+ set result [tk_messageBox \
+ -parent .toolbar_config_dialog \
+ -title [mc "Save changes?"] \
+ -icon question \
+ -type yesno \
+ -message [mc "The settings have been changed. Do you want to save the changes?"] \
+ ]
+ if {$result == {yes}} {
+ ::configDialogues::toolbar::OK
+ } else {
+ ::configDialogues::toolbar::CANCEL
+ }
+ } else {
+ ::configDialogues::toolbar::CANCEL
+ }
}
tkwait window $win
}
## Validator procedure for search EntryBoxes
# Search for the given string in the given ListBox and
- #+ adjust EntryBox background color acording to search result
+ #+ adjust EntryBox background color according to search result
# @parm Char where -
- # "O" (O as Omega not 0 as zero) == Options ListBox (avaliable items)
+ # "O" (O as Omega not 0 as zero) == Options ListBox (available items)
# "C" == ListBox containing current onfiguration
# @parm String what - String to search for
# @return Bool - Always true
proc search {where what} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
- variable options_ListBox ;# ID of ListBox containing avaliable icons
+ variable options_ListBox ;# ID of ListBox containing available icons
variable current_search_entry ;# ID of search EntryBox for $current_ListBox
variable options_search_entry ;# ID of search EntryBox for $options_ListBox
variable current_search_clear ;# ID of search EntryBox clear button for $current_ListBox
@@ -300,7 +321,7 @@ namespace eval toolbar {
set listbox $current_ListBox
set entry $current_search_entry
set clearbut $current_search_clear
- } {
+ } else {
set listbox $options_ListBox
set entry $options_search_entry
set clearbut $options_search_clear
@@ -311,7 +332,7 @@ namespace eval toolbar {
$entry configure -style TEntry
$clearbut configure -state disabled
return 1
- } {
+ } else {
$clearbut configure -state normal
}
@@ -324,7 +345,7 @@ namespace eval toolbar {
[$listbox itemcget $item -text] \
] \
] != -1
- } {
+ } then {
$listbox selection clear
$listbox selection set $item
$listbox see $item
@@ -344,7 +365,7 @@ namespace eval toolbar {
# @return void
proc fillListBox {definition} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
- variable options_ListBox ;# ID of ListBox containing avaliable icons
+ variable options_ListBox ;# ID of ListBox containing available icons
# Fill in left ListBox
$options_ListBox insert end sep -text [mc " -- SEPARATOR --"]
@@ -355,9 +376,9 @@ namespace eval toolbar {
# Skip invalid items
if {[lsearch $definition $item] != -1} {continue}
# Insert item
- $options_ListBox insert end $item \
- -text [lindex ${::ICONBAR_ICONS} "$i 0"] \
- -image ::ICONS::16::[lindex ${::ICONBAR_ICONS} "$i 2"]
+ $options_ListBox insert end $item \
+ -text [mc [lindex ${::ICONBAR_ICONS} [list $i 0]]] \
+ -image ::ICONS::16::[lindex ${::ICONBAR_ICONS} [list $i 2]]
}
# Fill in right ListBox
@@ -371,31 +392,31 @@ namespace eval toolbar {
if {$i == -1} {continue}
incr i
# Insert regular item
- $current_ListBox insert end $key \
- -text [lindex ${::ICONBAR_ICONS} "$i 0"] \
- -image ::ICONS::16::[lindex ${::ICONBAR_ICONS} "$i 2"]
+ $current_ListBox insert end $key \
+ -text [mc [lindex ${::ICONBAR_ICONS} [list $i 0]]] \
+ -image ::ICONS::16::[lindex ${::ICONBAR_ICONS} [list $i 2]]
}
}
- ## Enable/Disable arrow buttons acording to selection in ListBoxes
+ ## Enable/Disable arrow buttons according to selection in ListBoxes
# @return void
proc reevaluateArrows {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
- variable options_ListBox ;# ID of ListBox containing avaliable icons
+ variable options_ListBox ;# ID of ListBox containing available icons
variable left_button ;# ID of button "Left"
variable right_button ;# ID of button "Right"
# Button "Left"
if {[$current_ListBox selection get] == {}} {
$left_button configure -state disabled
- } {
+ } else {
$left_button configure -state normal
}
# Button "Right"
if {[$options_ListBox selection get] == {}} {
$right_button configure -state disabled
- } {
+ } else {
$right_button configure -state normal
}
@@ -404,7 +425,7 @@ namespace eval toolbar {
}
- ## Enable/Disable Up/Down arrow acording to selection in the right ListBox
+ ## Enable/Disable Up/Down arrow according to selection in the right ListBox
# @return void
proc reevaluateUpDown {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
@@ -420,7 +441,7 @@ namespace eval toolbar {
set curIndex [$current_ListBox index $sel]
if {$curIndex == 0} {
$up_button configure -state disabled
- } {
+ } else {
$up_button configure -state normal
}
@@ -428,11 +449,11 @@ namespace eval toolbar {
set numberOfItems [llength [$current_ListBox items]]
if {$curIndex == ($numberOfItems - 1)} {
$down_button configure -state disabled
- } {
+ } else {
$down_button configure -state normal
}
# Empty selection
- } {
+ } else {
$up_button configure -state disabled
$down_button configure -state disabled
}
@@ -485,7 +506,7 @@ namespace eval toolbar {
# @return void
proc left {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
- variable options_ListBox ;# ID of ListBox containing avaliable icons
+ variable options_ListBox ;# ID of ListBox containing available icons
# Local variables
set sel [$current_ListBox selection get] ;# ID of the selected item
@@ -496,15 +517,15 @@ namespace eval toolbar {
# Regular item (no separator)
if {![regexp {^\d+$} $sel]} {
- # Find index of the item (in avaliable icons)
+ # Find index of the item (in available icons)
set i [lsearch ${::ICONBAR_ICONS} $sel]
if {$i == -1} {return}
incr i
# Insert removed item into left ListBox
$options_ListBox insert 1 $sel \
- -text [lindex ${::ICONBAR_ICONS} "$i 0"] \
- -image ::ICONS::16::[lindex ${::ICONBAR_ICONS} "$i 2"]
+ -text [lindex ${::ICONBAR_ICONS} [list $i 0]] \
+ -image ::ICONS::16::[lindex ${::ICONBAR_ICONS} [list $i 2]]
}
# Restore selection
@@ -529,13 +550,13 @@ namespace eval toolbar {
# @return void
proc right {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
- variable options_ListBox ;# ID of ListBox containing avaliable icons
+ variable options_ListBox ;# ID of ListBox containing available icons
# Determinate target index
set sel [$current_ListBox selection get]
if {$sel == {}} {
set trgIdx {end}
- } {
+ } else {
set trgIdx [$current_ListBox index $sel]
}
# Determinate source index and source item ID
@@ -546,13 +567,13 @@ namespace eval toolbar {
if {$sel == {sep}} {
$current_ListBox insert $trgIdx #auto -text [mc " -- SEPARATOR --"]
# Regular item
- } {
+ } else {
set i [lsearch ${::ICONBAR_ICONS} $sel]
if {$i == -1} {return}
incr i
$current_ListBox insert $trgIdx $sel \
- -text [lindex ${::ICONBAR_ICONS} "$i 0"] \
- -image ::ICONS::16::[lindex ${::ICONBAR_ICONS} "$i 2"]
+ -text [lindex ${::ICONBAR_ICONS} [list $i 0]] \
+ -image ::ICONS::16::[lindex ${::ICONBAR_ICONS} [list $i 2]]
$options_ListBox delete $sel
}
@@ -629,6 +650,7 @@ namespace eval toolbar {
iconbar_redraw
set anything_modified 0
::X::disaena_menu_toolbar_for_current_project
+ set anything_modified 0
}
# Get rid of dialog window
@@ -643,14 +665,16 @@ namespace eval toolbar {
variable win ;# ID of dialog toplevel window
variable changed ;# Bool: Settings changed
variable dialog_opened ;# Bool: True if this dialog is already opened
+ variable anything_modified ;# Bool: Settings changed (stay set to 1 even after APPLY)
# Apply new settings
- if {$changed} {
+ if {$anything_modified} {
use_settings ;# Adjust NS variables
iconbar_redraw ;# Adjust GUI
save_config ;# Save new config
# Restore previous state of menu items (enabled / disabled)
::X::disaena_menu_toolbar_for_current_project
+ set anything_modified 0
}
# Get rid of dialog window
@@ -683,7 +707,7 @@ namespace eval toolbar {
# @return void
proc DEFAULTS {} {
variable current_ListBox ;# ID of ListBox containing current toolbar setup
- variable options_ListBox ;# ID of ListBox containing avaliable icons
+ variable options_ListBox ;# ID of ListBox containing available icons
variable win ;# ID of dialog toplevel window
# Ask user
@@ -704,3 +728,7 @@ namespace eval toolbar {
settings_changed
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/custom_command.tcl b/lib/custom_command.tcl
index 63a42c5..6a5393f 100755..100644
--- a/lib/custom_command.tcl
+++ b/lib/custom_command.tcl
@@ -1,8 +1,11 @@
-#!/usr/bin/tclsh
+#!/bin/sh
+# the next line restarts using wish \
+exec tclsh "$0" "$@"
+
# 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 #
@@ -29,6 +32,7 @@
# --------------------------------------------------------------------------
# Initialize
+encoding system {utf-8}
package require Tk
wm withdraw .
wm command . "$argv0 $argv"
@@ -42,41 +46,9 @@ wm client . [info hostname]
proc secure_send args {
if {[catch {
eval "send $args"
- } result]} {
- puts "Unknown IO Error :: $result"
- tk_messageBox \
- -title "Unknown IO Error" \
- -icon error \
- -type ok \
- -message "$result"
-
- if {[ \
- tk_messageBox \
- -title "X server security workaround" \
- -icon warning \
- -type yesno \
- -message "If the error was related to X server security, it is possible to temporarily workaround it by running this command: \"/bin/sh << 'for i in `xhost`; do xhost -\$i; done'\"\n\nDo you want to do it ?"
- ] == {yes}} then {
- catch {
- exec -- /bin/sh << {xhost -; for i in `xhost`; do xhost -$i; done}
- }
- } else {
- exit 1
- }
-
- if {[catch {
- eval "send $args"
- }]} {
- tk_messageBox \
- -title "Workaround failed" \
- -icon error \
- -type ok \
- -message "Sorry this doesn't work ...\nIt's a strange bug somewhere in your operating system"
- exit 1
- }
-
+ } result]} then {
+ puts stderr "Unknown IO Error :: $result"
return 1
-
} else {
return 1
}
@@ -89,8 +61,8 @@ while {![eof stdin]} {
}
# Execute loaded command
-if {[catch {exec /bin/sh << $cmd} result]} {
- secure_send [lindex $argv 0] ::X::custom_cmd_error [lindex $argv 1] "{" [regsub -all {[\{\}]} $result {\\&}] "}"
+if {[catch {exec bash << $cmd} result] && ![string equal $::errorCode NONE]} {
+ secure_send [lindex $argv 0] ::X::custom_cmd_error [lindex $argv 1] "{" [regsub -all {[\{\}]} $result {\\&}] "}"
} else {
secure_send [lindex $argv 0] ::X::custom_cmd_finish [lindex $argv 1] "{" [regsub -all {[\{\}]} $result {\\&}] "}"
}
diff --git a/lib/dialogs/errorhandler.tcl b/lib/dialogues/errorhandler.tcl
index ac1b553..93e1cf4 100755..100644
--- a/lib/dialogs/errorhandler.tcl
+++ b/lib/dialogues/errorhandler.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,13 +21,18 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _ERRORHANDLER_TCL ] } {
+set _ERRORHANDLER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Background error handler
# --------------------------------------------------------------------------
namespace eval ErrorHandler {
- variable num_of_opended 0 ;# Int: Number of currently opened dialogs
+ variable num_of_opened 0 ;# Int: Number of currently opened dialogues
variable count 0 ;# Int: Counter of ivokations
variable enabled 1 ;# Bool: Dialog window enabled
@@ -37,13 +42,13 @@ namespace eval ErrorHandler {
proc open_dialog {message} {
variable count ;# Int: Counter of ivokations
variable enabled ;# Bool: Dialog window enabled
- variable num_of_opended ;# Int: Number of currently opened dialogs
+ variable num_of_opened ;# Int: Number of currently opened dialogues
- if {$num_of_opended > 2} {
- puts stderr "ERROR MESSAGE SUPPRESED (too many error dialogs opened at the time)"
+ if {$num_of_opened > 2} {
+ puts stderr "ERROR MESSAGE SUPPRESED (too many error dialogues opened at the time)"
return
}
- incr num_of_opended
+ incr num_of_opened
# Send error message to standard error output
puts stderr [string repeat # 64]
@@ -66,7 +71,7 @@ namespace eval ErrorHandler {
# Create dialog window
if {!$enabled} {return}
incr count
- set win [toplevel .error_dialog$count -bg {#EE0000} -class {Error message} -bg {#EEEEEE}]
+ set win [toplevel .error_dialog$count -bg {#EE0000} -class {Error message} -bg ${::COMMON_BG_COLOR}]
# Create window frames
set main_frame [frame $win.main_frame]
@@ -75,13 +80,13 @@ namespace eval ErrorHandler {
set bottom_frame [frame $main_frame.bottom_frame]
# Create window header
- pack [label $top_frame.header_lbl \
- -text [mc "PROGRAM ERROR "] \
- -bg {#EE0000} -fg {#FFFFFF} \
- -font [font create \
- -family helvetica \
- -size -24 \
- -weight bold \
+ pack [label $top_frame.header_lbl \
+ -text [mc "PROGRAM ERROR "] \
+ -bg {#EE0000} -fg {#FFFFFF} \
+ -font [font create \
+ -family helvetica \
+ -size [expr {int(-24 * $::font_size_factor)}] \
+ -weight bold \
] \
] -side left -fill x -expand 1
@@ -98,26 +103,34 @@ namespace eval ErrorHandler {
] -fill y -side right
# Create text tags
- $middle_frame.text tag configure tag_bold \
- -font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -weight bold \
- -size -14 \
+ $middle_frame.text tag configure tag_bold \
+ -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -weight bold \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ ]
+ $middle_frame.text tag configure tag_tt \
+ -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
]
- $middle_frame.text tag configure tag_big_bold \
- -font [font create \
- -family {helvetica} \
- -weight bold \
- -size -17 \
+ $middle_frame.text tag configure tag_big_bold \
+ -font [font create \
+ -family {helvetica} \
+ -weight bold \
+ -size [expr {int(-17 * $::font_size_factor)}] \
]
# Write error message
- $middle_frame.text insert end [mc "Error log saved in: %s\n" "${::X::defaultDirectory}/mcu8051ide_errors.log"]
- $middle_frame.text insert end [mc "Please send this file to %s or report this bug at http://mcu8051ide.sf.net/forum\n\n\n" <martin.osmera@gmail.com>]
- $middle_frame.text tag add tag_big_bold 1.0 3.0
+ $middle_frame.text insert end [mc "Error log saved in: %s\n" "${::X::defaultDirectory}[file separator]mcu8051ide_errors.log"]
+ $middle_frame.text insert end [mc "Please send this file to %s\nor report this bug at: http://sourceforge.net/tracker/?group_id=185864&atid=914981\n\n\n" {<martin.osmera@gmail.com>}]
+ create_link_tag_in_text_widget $middle_frame.text
+ convert_all_https_to_links $middle_frame.text
+ $middle_frame.text tag add tag_big_bold 1.0 4.0
$middle_frame.text insert end [mc "ERROR DETAILS:\n--------------\n"]
- $middle_frame.text tag add tag_bold 5.0 7.0
+ $middle_frame.text tag add tag_bold 6.0 8.0
$middle_frame.text insert end $::errorInfo
+ $middle_frame.text tag add tag_tt 8.0 end
$middle_frame.text configure -state disabled
# Create button frame
@@ -159,9 +172,9 @@ namespace eval ErrorHandler {
# @parm Int number - Dialog unique number
# @return void
proc close_dialog {number} {
- variable num_of_opended ;# Int: Number of currently opened dialogs
+ variable num_of_opened ;# Int: Number of currently opened dialogues
- incr num_of_opended -1
+ incr num_of_opened -1
destroy .error_dialog$number
}
}
@@ -170,3 +183,7 @@ namespace eval ErrorHandler {
proc bgerror {message} {
::ErrorHandler::open_dialog $message
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/dialogs/fsd.tcl b/lib/dialogues/fsd.tcl
index 959eae4..fce7e24 100755..100644
--- a/lib/dialogs/fsd.tcl
+++ b/lib/dialogues/fsd.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 _FSD_TCL ] } {
+set _FSD_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# This class provides file selection dialog
@@ -34,7 +39,7 @@
# -initialfile String = {} ;# Initial file
# -directory String = {~} ;# Initiali directory
# -multiple Bool = 0 ;# Allow selection of multiple files (get will return list instead of string)
-# -filetypes List = {{All} {*}} ;# { {{Some string} {GLOB} ... }
+# -filetypes List = {{All} {*}} ;# { {{Some string} {GLOB}} ... }
# -defaultmask Int = 0 ;# Number of detault mask (see -filetypes) (1st is zero)
# -modal Bool = 1 ;# Create as modal window
# -doubleclick Bool = 0 ;# Use double click to open folder instead of single click
@@ -55,28 +60,28 @@ itcl::class KIFSD::FSD {
common bookmark_change_command {} ;# Command to invoke on bokmark change
# Font for quick navigation panel
- common quick_nav_panel_font [font create \
- -family {helvetica} \
- -size -12 \
- -weight bold \
+ common quick_nav_panel_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
# Font for files listbox in mode (Short view)
- common listbox_font_short [font create \
- -family {helvetica} \
- -size -14 \
- -weight normal \
+ common listbox_font_short [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight normal \
]
# Font for files listbox in mode (Detailed view) and directories listbox
- common listbox_font_detailed [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight normal \
+ common listbox_font_detailed [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight normal \
]
# Font for listbox header
- common listbox_header_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ common listbox_header_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
## Values given by constructor arguments
@@ -84,7 +89,7 @@ itcl::class KIFSD::FSD {
private variable option_filetypes {{All} {*}} ;# File types
if {!$::MICROSOFT_WINDOWS} {
variable option_directory ${::env(HOME)} ;# Initial directory
- } {
+ } else {
variable option_directory ${::env(USERPROFILE)} ;# Initial directory
}
private variable option_master {.} ;# Window master
@@ -118,8 +123,8 @@ itcl::class KIFSD::FSD {
private variable dir_combobox ;# Widget: Directory ComboBox
private variable toolbar ;# Widget: Frame containing toolbar
private variable quick_access_bar ;# Widget: Quick access bar ListBox
- private variable dir_listbox_scrollbar ;# Widget: Directory ListBox scrollbar
- private variable dir_listbox ;# Widget: Directory ListBox
+ private variable dir_listbox_scrollbar {} ;# Widget: Directory ListBox scrollbar
+ private variable dir_listbox {} ;# Widget: Directory ListBox
private variable main_paned_window ;# Widget: Paned window for quick access bar and other LBs
private variable leftframe ;# Widget: Frame contaning quick access bar and its scrollbar
private variable rightframe ;# Widget: Frame containing directory & file ListBoxes
@@ -130,10 +135,13 @@ itcl::class KIFSD::FSD {
private variable file_listbox ;# Widget: Files ListBox
private variable file_listbox_header ;# Widget: Header for files ListBox
private variable file_listbox_frame ;# Widget: Frame for $file_listbox_header and $file_listbox
- private variable file_listbox_vscrollbar ;# Widget: Vertical scollbar for files ListBox
- private variable file_listbox_hscrollbar ;# Widget: Hotizontal scollbar for files ListBox
+ private variable file_listbox_vscrollbar {} ;# Widget: Vertical scollbar for files ListBox
+ private variable file_listbox_hscrollbar {} ;# Widget: Hotizontal scollbar for files ListBox
private variable right_top_right_top_frame ;# Widget: Frame for $file_listbox_frame and scrollbars
+ proc static_reload {object args} {
+ catch [list $object reload]
+ }
## Dialog constructor
# For complite list of possible arguments see desctiption above
@@ -141,6 +149,7 @@ itcl::class KIFSD::FSD {
# Configure local ttk styles
ttk::style configure FSD_RedBg.TCombobox -fieldbackground {#FFDDDD}
+ ttk::style configure FSD_RedBg.TEntry -fieldbackground {#FFDDDD}
## Parse given arguments and set appropriate object variables
set arglen [llength $args]
@@ -152,21 +161,21 @@ itcl::class KIFSD::FSD {
incr i
set option_modal [lindex $args $i]
if {![string is boolean -strict $option_modal]} {
- error "-fileson must have value eighter 0 or 1"
+ error "-modal must have value either 0 or 1"
}
}
-doubleclick {
incr i
set option_doubleclick [lindex $args $i]
if {![string is boolean -strict $option_doubleclick]} {
- error "-doubleclick must have value eighter 0 or 1"
+ error "-doubleclick must have value either 0 or 1"
}
}
-autoclose {
incr i
set option_autoclose [lindex $args $i]
if {![string is boolean -strict $option_autoclose]} {
- error "-autoclose must have value eighter 0 or 1"
+ error "-autoclose must have value either 0 or 1"
}
}
-initialfile {
@@ -177,7 +186,7 @@ itcl::class KIFSD::FSD {
incr i
set option_multiple [lindex $args $i]
if {![string is boolean -strict $option_multiple]} {
- error "-multiple must have value eighter 0 or 1"
+ error "-multiple must have value either 0 or 1"
}
}
-defaultmask {
@@ -207,7 +216,7 @@ itcl::class KIFSD::FSD {
incr i
set option_fileson [lindex $args $i]
if {![string is boolean -strict $option_modal]} {
- error "-fileson must have value eighter 0 or 1"
+ error "-fileson must have value either 0 or 1"
}
}
default {
@@ -254,7 +263,11 @@ itcl::class KIFSD::FSD {
# @return void
private method create_dialog {} {
# Determinate window name (path)
- set win_base .[string tolower [regsub -all {:} $this {}]]
+ set win_base {}
+ if {$option_master != {.}} {
+ set win_base $option_master
+ }
+ append win_base .[string tolower [regsub -all {:} $this {}]]
set win $win_base
set i 0
while [winfo exists $win] {
@@ -264,11 +277,11 @@ itcl::class KIFSD::FSD {
}
# Create and configure dialog window
- toplevel $win -bg {#EEEEEE}
+ toplevel $win -bg ${::COMMON_BG_COLOR}
wm iconphoto $win ::ICONS::16::fileopen
wm withdraw $win
wm title $win $option_title
- wm minsize $win 540 260
+ wm minsize $win 540 290
wm protocol $win WM_DELETE_WINDOW "catch {itcl::delete object $this}"
wm transient $win $option_master
wm geometry $win ${::KIFSD::FSD::config(win_geometry)}
@@ -344,7 +357,7 @@ itcl::class KIFSD::FSD {
set dir_listbox [ListBox $right_top_left_frame.dir_listbox \
-bd 1 -padx 19 -selectfill 1 -width 1 -highlightcolor {#BBBBFF} \
-selectmode single -highlightthickness 0 -bg white -deltay 18 \
- -yscrollcommand "catch {$this dir_listbox_scroll}" \
+ -yscrollcommand "$this dir_listbox_scroll" \
]
set dir_listbox_scrollbar [ttk::scrollbar \
$right_top_left_frame.scrollbar \
@@ -366,7 +379,7 @@ itcl::class KIFSD::FSD {
# Create files ListBox
if {$option_multiple} {
set selmode {multiple}
- } {
+ } else {
set selmode {single}
}
set right_top_right_top_frame [frame $right_top_right_frame.right_top_right_top_frame]
@@ -379,25 +392,34 @@ itcl::class KIFSD::FSD {
$file_listbox_header delete 1.0 end
if {!$::MICROSOFT_WINDOWS} {
$file_listbox_header insert end \
- [mc " Name\t\t\t\t Size Rights Date "]
+ [mc " Name Size Rights Date "]
} else {
$file_listbox_header insert end \
- [mc " Name\t\t\t\t Size Date "]
+ [mc " Name Size Date "]
}
bindtags $file_listbox_header $file_listbox_header
$file_listbox_header configure -state disabled
- set file_listbox [ListBox $file_listbox_frame.file_listbox -height 1 \
- -selectfill 1 -selectbackground {#88AAFF} -bd 1 -padx 17 -width 1 \
- -selectmode $selmode -highlightthickness 0 -bg white -deltay 18 \
- -yscrollcommand "catch {$this file_listbox_vscroll}" -highlightcolor {#BBBBFF} \
- -xscrollcommand "catch {$this file_listbox_hscroll}" \
+ set file_listbox [ListBox $file_listbox_frame.file_listbox \
+ -bd 1 \
+ -padx 17 \
+ -width 1 \
+ -height 1 \
+ -bg white \
+ -deltay 18 \
+ -selectfill 1 \
+ -selectmode $selmode \
+ -highlightthickness 0 \
+ -selectbackground {#88AAFF} \
+ -highlightcolor {#BBBBFF} \
+ -yscrollcommand "$this file_listbox_vscroll" \
+ -xscrollcommand "$this file_listbox_hscroll" \
]
pack $file_listbox -fill both -expand 1
if {${::KIFSD::FSD::config(detailed_view)}} {
$file_listbox configure -multicolumn 0
set listbox_font $listbox_font_detailed
pack $file_listbox_header -before $file_listbox -fill x -expand 0
- } {
+ } else {
$file_listbox configure -multicolumn 1
set listbox_font $listbox_font_short
}
@@ -433,8 +455,8 @@ itcl::class KIFSD::FSD {
] -sticky w -column 0 -row 1
set location_cb [ttk::combobox $right_bottom_frame.location_cb \
- -values {} \
- -exportselection 0 \
+ -values {} \
+ -exportselection 0 \
]
bind $location_cb <<ComboboxSelected>> "$file_listbox selection clear"
DynamicHelp::add $location_cb -text [mc "Selected file(s)"]
@@ -444,7 +466,18 @@ itcl::class KIFSD::FSD {
set tmp_option_filetypes {}
foreach type $option_filetypes {
- lappend tmp_option_filetypes "[lindex $type 0] ([lindex $type 1])"
+ set glob_masks [lindex $type 1]
+ if {[regexp {^\*\.\{\w+(,\w+)*\}$} $glob_masks]} {
+ set glob_masks [split $glob_masks {{,}}]
+ set glob_masks [lreplace $glob_masks 0 0]
+ set glob_masks [lreplace $glob_masks end end]
+ set glob_masks_new [list]
+ foreach ext $glob_masks {
+ lappend glob_masks_new [format "*.%s" $ext]
+ }
+ set glob_masks [join $glob_masks_new {, }]
+ }
+ lappend tmp_option_filetypes "[lindex $type 0] ($glob_masks)"
}
set filter_cb [ttk::combobox $right_bottom_frame.filter_cb \
-state readonly \
@@ -475,14 +508,14 @@ itcl::class KIFSD::FSD {
-image ::ICONS::16::ok \
-command [list $this ok] \
]
- grid $ok_button -sticky w -column 2 -row 0 -padx 7
+ grid $ok_button -sticky w -column 2 -row 0 -padx 7 -pady 2
grid [ttk::button $right_bottom_frame.cancel_button \
-text [mc "Cancel"] \
-compound left \
-width 8 \
-image ::ICONS::16::button_cancel \
-command "itcl::delete object $this" \
- ] -sticky w -column 2 -row 1 -padx 7
+ ] -sticky w -column 2 -row 1 -padx 7 -pady 2
grid columnconfigure $right_bottom_frame 1 -weight 1
@@ -529,7 +562,8 @@ itcl::class KIFSD::FSD {
{bookmark_menu}}
{configure "Configure" {configure}
{config_menu}}
- } {
+ } \
+ {
# Create separator
if {$item == {separator}} {
pack [ttk::separator $toolbar.sep$si \
@@ -616,7 +650,7 @@ itcl::class KIFSD::FSD {
## Create entries for configuraion menu (accessable from toolbar)
# Entry: "Sorting"
- $win.config_menu add cascade -label [mc "Sorting"] -underline 1 -menu $sorting_menu
+ $win.config_menu add cascade -label [mc "Sorting"] -underline 1 -menu $sorting_menu -image ::ICONS::16::sort_incr -compound left
$win.config_menu add separator
# Entry: "Short view"
$win.config_menu add command -label [mc "Short view"] -compound left \
@@ -787,7 +821,7 @@ itcl::class KIFSD::FSD {
append dir {/}
}
}
-
+
# Check if the specified directory is valid
if {![file exists $dir] || ![file isdirectory $dir]} {
tk_messageBox \
@@ -811,6 +845,8 @@ itcl::class KIFSD::FSD {
}
# Option separate_folders ON
+ FSnotifications::forget $current_directory
+ FSnotifications::watch $dir [list KIFSD::FSD::static_reload $this]
set current_directory $dir
if {${::KIFSD::FSD::config(separate_folders)} && $option_fileson} {
# Fill up directory ListBox with directories
@@ -818,7 +854,7 @@ itcl::class KIFSD::FSD {
foreach folder [dir_cmd $dir 1] {
if {$folder == {..}} {
set image {up}
- } {
+ } else {
set image {fileopen}
}
$dir_listbox insert end #auto \
@@ -833,7 +869,7 @@ itcl::class KIFSD::FSD {
if {${::KIFSD::FSD::config(detailed_view)}} {
set filename [lindex $file 1]
set file [lindex $file 0]
- } {
+ } else {
set filename $file
}
$file_listbox insert end #auto \
@@ -925,18 +961,18 @@ itcl::class KIFSD::FSD {
}
}
- # Fill up location ComboBox with avaliable files or directories
+ # Fill up location ComboBox with available files or directories
if {$option_fileson} {
$location_cb configure -values [file_cmd $dir $current_mask 1]
- } {
+ } else {
$location_cb configure -values [dir_cmd $dir 1]
}
- $location_cb configure -text {}
+ $location_cb set {}
# Fill up directory ComboBox
set values {}
set folder $dir
- while 1 {
+ while {1} {
lappend values $folder
if {$folder == [file separator]} {break}
if {$::MICROSOFT_WINDOWS} {
@@ -961,10 +997,10 @@ itcl::class KIFSD::FSD {
$dir_combobox icursor end
# Enable / Disable button "Up (Parent folder)"
- if {$dir == [file separator]} {
+ if {$dir == {/} || $dir == "\\"} {
$toolbar.up configure -state disabled
$win.listbox_menu entryconfigure [mc "Up"] -state disabled
- } {
+ } else {
$toolbar.up configure -state normal
$win.listbox_menu entryconfigure [mc "Up"] -state normal
}
@@ -977,7 +1013,7 @@ itcl::class KIFSD::FSD {
reload
}
- ## Show / Hide quick access bar acording to configuration variable quick_access_panel
+ ## Show / Hide quick access bar according to configuration variable quick_access_panel
# @return void
public method quick_access_panel_onoff {} {
# Show the panel
@@ -991,7 +1027,7 @@ itcl::class KIFSD::FSD {
$main_paned_window sash place 0 ${::KIFSD::FSD::config(main_PW_size)} 0
if {$dialog_loaded} {update}
# Hide the panel
- } {
+ } else {
if {[winfo ismapped $main_paned_window]} {
set ::KIFSD::FSD::config(main_PW_size) \
[lindex [$main_paned_window sash coord 0] {0 0}]
@@ -1003,7 +1039,7 @@ itcl::class KIFSD::FSD {
}
}
- ## Show / Hide folders ListBox acording to configuration variable separate_folders
+ ## Show / Hide folders ListBox according to configuration variable separate_folders
# This function will show folders ListBox only if option_fileson == 1
# @return void
public method separate_folders_onoff {} {
@@ -1019,7 +1055,7 @@ itcl::class KIFSD::FSD {
if {$dialog_loaded} {update}
# Hide folders ListBox
- } {
+ } else {
if {[winfo ismapped $right_paned_window]} {
set ::KIFSD::FSD::config(right_PW_size) \
[lindex [$right_paned_window sash coord 0] {0 0}]
@@ -1063,7 +1099,7 @@ itcl::class KIFSD::FSD {
pack forget $dir_listbox_scrollbar
}
# Show scrollbar
- } {
+ } else {
if {![winfo ismapped $dir_listbox_scrollbar]} {
pack $dir_listbox_scrollbar -fill y -expand 1 -after $dir_listbox
}
@@ -1108,7 +1144,7 @@ itcl::class KIFSD::FSD {
# @return void
public method edit_bookmarks {} {
# Create dialog window
- set dialog [toplevel ${win}_edit_bookmarks -class {Edit bookmarks} -bg {#EEEEEE}]
+ set dialog [toplevel $win.edit_bookmarks -class {Edit bookmarks} -bg ${::COMMON_BG_COLOR}]
# Create top frame (ListBox containing bookmarks and its scrollbar)
set top_frame [frame $dialog.top_frame]
@@ -1133,39 +1169,40 @@ itcl::class KIFSD::FSD {
set bottom_frame [frame $dialog.bottom_frame]
# Button: "Remove"
pack [ttk::button $bottom_frame.remove \
- -text "Remove" \
+ -text [::mc "Remove"] \
-compound left \
-image ::ICONS::16::editdelete \
-command "$this edit_bookmarks_remove" \
-width 8 \
- ] -side left
+ ] -side left -padx 2
# Button: "Edit"
pack [ttk::button $bottom_frame.edit \
- -text "Edit" \
+ -text [::mc "Edit"] \
-compound left \
-image ::ICONS::16::edit \
-command "$this edit_bookmarks_edit" \
-width 8 \
- ] -side left
+ ] -side left -padx 2
# Button: "Up"
pack [ttk::button $bottom_frame.up \
- -text "Up" \
+ -text [::mc "Up"] \
-compound left \
-image ::ICONS::16::up \
-command "$this edit_bookmarks_up" \
-width 8 \
- ] -side left
+ ] -side left -padx 2
# Button: "Down"
pack [ttk::button $bottom_frame.down \
- -text "Down" \
+ -text [::mc "Down"] \
-compound left \
-image ::ICONS::16::down \
-command "$this edit_bookmarks_down" \
-width 8 \
- ] -side left
+ ] -side left -padx 2
# Button: "Ok"
pack [ttk::button $bottom_frame.ok \
- -text "Ok" -compound left \
+ -text [::mc "Ok"] \
+ -compound left \
-image ::ICONS::16::ok \
-width 8 \
-command "
@@ -1173,10 +1210,10 @@ itcl::class KIFSD::FSD {
grab release $dialog
destroy $dialog
" \
- ] -side right
+ ] -side right -padx 2
# Button: "Cancel"
pack [ttk::button $bottom_frame.cancel \
- -text "Cancel" \
+ -text [::mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-width 8 \
@@ -1184,11 +1221,11 @@ itcl::class KIFSD::FSD {
grab release $dialog
destroy $dialog
" \
- ] -side right
+ ] -side right -padx 2
# Pack dialog frames (top and bottom)
- pack $top_frame -side top -fill both -expand 1
- pack $bottom_frame -side top -after $top_frame -fill x -expand 0 -pady 5
+ pack $top_frame -side top -fill both -expand 1 -pady 5 -padx 5
+ pack $bottom_frame -side top -after $top_frame -fill x -expand 0 -pady 5 -padx 5
# Configure dialog window
wm iconphoto $dialog ::ICONS::16::bookmark
@@ -1201,7 +1238,7 @@ itcl::class KIFSD::FSD {
"
if {[winfo ismapped $win]} {
wm transient $dialog $win
- } {
+ } else {
wm transient $dialog .
}
grab $dialog
@@ -1240,7 +1277,7 @@ itcl::class KIFSD::FSD {
![$bookmark_edit_listbox index $item]
||
([llength [$bookmark_edit_listbox items]] < 2)
- } {
+ } then {
return
}
$bookmark_edit_listbox move $item [expr {[$bookmark_edit_listbox index $item] - 1}]
@@ -1256,7 +1293,7 @@ itcl::class KIFSD::FSD {
[$bookmark_edit_listbox index $item]
>=
([llength [$quick_access_bar items]] - 1)
- } {
+ } then {
return
}
$bookmark_edit_listbox move $item [expr {[$bookmark_edit_listbox index $item] + 1}]
@@ -1308,7 +1345,7 @@ itcl::class KIFSD::FSD {
public method activate {} {
wm resizable $win 1 1
wm deiconify $win
- update idle
+ update idletasks
if {[winfo ismapped $right_paned_window]} {
$right_paned_window sash place 0 ${::KIFSD::FSD::config(right_PW_size)} 0
}
@@ -1333,7 +1370,7 @@ itcl::class KIFSD::FSD {
}
return $result
# Return String
- } {
+ } else {
return [file join $current_directory [$location_cb get]]
}
}
@@ -1341,7 +1378,9 @@ itcl::class KIFSD::FSD {
## Destroy dialog object
# @return void
public method close_dialog {} {
- itcl::delete object $this
+ catch {
+ itcl::delete object $this
+ }
}
## Set command to invoke from root namespace on action "Ok"
@@ -1354,17 +1393,23 @@ itcl::class KIFSD::FSD {
## Ok action - command for button "Ok"
# @return void
public method ok {} {
- if {$option_autoclose} {wm withdraw $win}
- uplevel #0 $ok_command
- if {$option_autoclose} {close_dialog}
+ if {$option_autoclose} {
+ wm withdraw $win
+ set ok_command_tmp $ok_command
+ set ok_command {}
+ uplevel #0 $ok_command_tmp
+ close_dialog
+ } else {
+ uplevel #0 $ok_command
+ }
}
## Command for files ListBox horizontal scrollbar
# Takes any list of arguments (see code)
# @return void
public method file_listbox_hscrollbar_cmd args {
- eval "$file_listbox_header xview $args"
eval "$file_listbox xview $args"
+ eval "$file_listbox_header xview $args"
}
## Scroll files ListBox vertically
@@ -1381,7 +1426,7 @@ itcl::class KIFSD::FSD {
}
# Show scrollbar
- } {
+ } else {
if {![winfo ismapped $file_listbox_vscrollbar]} {
pack $file_listbox_vscrollbar \
-after $file_listbox_frame \
@@ -1398,6 +1443,7 @@ itcl::class KIFSD::FSD {
# @parm Float frac1 - 2nd fraction (see Tk manual)
# @return void
public method file_listbox_hscroll {frac0 frac1} {
+
# Hide scrollbar
if {$frac0 == 0 && $frac1 == 1} {
if {[winfo ismapped $file_listbox_hscrollbar]} {
@@ -1406,7 +1452,7 @@ itcl::class KIFSD::FSD {
}
# Show scrollbar
- } {
+ } else {
if {![winfo ismapped $file_listbox_hscrollbar]} {
pack $file_listbox_hscrollbar \
-after $right_top_right_top_frame \
@@ -1423,7 +1469,11 @@ itcl::class KIFSD::FSD {
# @return void
public method quick_access_bar_select {} {
if {$option_doubleclick} {return}
- change_directory [$quick_access_bar itemcget [$quick_access_bar selection get] -data]
+ catch {
+ change_directory \
+ [$quick_access_bar itemcget \
+ [$quick_access_bar selection get] -data]
+ }
}
## Event handler for quick access bar ListBox, item event <Double-1>
@@ -1431,32 +1481,57 @@ itcl::class KIFSD::FSD {
# @return void
public method quick_access_bar_doubleclick {item} {
if {!$option_doubleclick} {return}
- change_directory [$quick_access_bar itemcget [$quick_access_bar selection get] -data]
+ catch {
+ change_directory \
+ [$quick_access_bar itemcget \
+ [$quick_access_bar selection get] -data]
+ }
}
## Event handler for directories ListBox, item event <Double-1>
# @parm String item - Item identifier
# @return void
public method dir_listbox_doubleclick {item} {
+ # Abort if dirs ListBox widget is no longer available
+ if {![winfo exists $dir_listbox]} {
+ return
+ }
if {!$option_doubleclick} {return}
- change_directory [file join $current_directory \
- [$dir_listbox itemcget $item -text]]
+ catch {
+ change_directory [file join $current_directory \
+ [$dir_listbox itemcget $item -text]]
+ }
}
## Event handler for directories ListBox, event <<ListboxSelect>>
# @return void
public method dir_listbox_select {} {
+ # Abort if dirs ListBox widget is no longer available
+ if {![winfo exists $dir_listbox]} {
+ return
+ }
if {$option_doubleclick} {return}
- change_directory [file join $current_directory \
- [$dir_listbox itemcget [$dir_listbox selection get] -text]]
+ catch {
+ change_directory [file normalize [file join $current_directory \
+ [$dir_listbox itemcget [$dir_listbox selection get] -text]]]
+ }
}
## Event handler for files ListBox, item event <Double-1>
# @parm String item - Item identifier
# @return void
public method file_listbox_doubleclick {item} {
- # Item directory or {} if it is file
- set folder [lindex [$file_listbox itemcget $item -data] 1]
+ # Abort if files ListBox widget is no longer available
+ if {![winfo exists $file_listbox]} {
+ return
+ }
+
+ # Item directory or {} if it's a file
+ if {[catch {
+ set folder [lindex [$file_listbox itemcget $item -data] 1]
+ }]} then {
+ return
+ }
if {!$option_fileson} {
if {$folder != {}} {
@@ -1482,7 +1557,7 @@ itcl::class KIFSD::FSD {
public method file_listbox_scroll args {
if {${::KIFSD::FSD::config(detailed_view)}} {
set cmd {yview}
- } {
+ } else {
set cmd {xview}
}
eval "$file_listbox.c $cmd scroll $args"
@@ -1493,7 +1568,7 @@ itcl::class KIFSD::FSD {
public method file_listbox_select {} {
set selection [$file_listbox selection get]
- # Change directory if item was folder
+ # Change directory if the item represents a directory
if {$option_fileson && !${::KIFSD::FSD::config(separate_folders)}} {
set folder [$file_listbox itemcget [lindex $selection end] -data]
set folder [lindex $folder 1]
@@ -1505,7 +1580,7 @@ itcl::class KIFSD::FSD {
}
}
- # Change content of location ComboBox if item was file
+ # Change content of location ComboBox if item is a file
if {[llength $selection] == 1} {
set index [lindex [$file_listbox itemcget $selection -data] [expr {$option_fileson ? 0 : 1}]]
if {$index != {..}} {
@@ -1521,7 +1596,7 @@ itcl::class KIFSD::FSD {
append text [lindex [$file_listbox itemcget $item -data] [expr {$option_fileson ? 0 : 1}]]
append text "\" "
}
- $location_cb configure -text $text
+ $location_cb set $text
}
}
@@ -1558,7 +1633,9 @@ itcl::class KIFSD::FSD {
set item_menu_request 0
return
}
- tk_popup $win.quick_access_panel_menu $x $y
+ catch {
+ tk_popup $win.quick_access_panel_menu $x $y
+ }
}
## Invoke popup menu for particular item in ListBox of Quick access bar
@@ -1575,14 +1652,14 @@ itcl::class KIFSD::FSD {
# Enable / Disabled entry "Move down"
if {$current_item_index >= ($len - 1)} {
$win.quick_access_panel_item_menu entryconfigure [mc "Move down"] -state disabled
- } {
+ } else {
$win.quick_access_panel_item_menu entryconfigure [mc "Move down"] -state normal
}
# Enable / Disabled entry "Move up"
if {!$current_item_index || ($len < 2)} {
$win.quick_access_panel_item_menu entryconfigure [mc "Move up"] -state disabled
- } {
+ } else {
$win.quick_access_panel_item_menu entryconfigure [mc "Move up"] -state normal
}
@@ -1631,7 +1708,7 @@ itcl::class KIFSD::FSD {
## Invoke dialog to add entry to quick access bar
# @return void
public method quick_access_panel_add_entry {} {
- set data [qa_panel_dialog "Add entry" {3} {New entry} {~}]
+ set data [qa_panel_dialog "Add entry" {3} [::mc "New entry"] {~}]
if {![string length [lindex $data 1]]} {return}
if {![string length [lindex $data 2]]} {return}
lappend ::KIFSD::FSD::config(quick_access_bar_data) $data
@@ -1657,9 +1734,9 @@ itcl::class KIFSD::FSD {
# @return void
public method qa_panel_dialog_icon {index} {
for {set i 0} {$i < 4} {incr i} {
- ${win}_qa_panel_dialog.labelframe.button_$i configure -style Flat.TButton
+ ${win}.qa_panel_dialog.labelframe.button_$i configure -style Flat.TButton
}
- ${win}_qa_panel_dialog.labelframe.button_$index configure -style TButton
+ ${win}.qa_panel_dialog.labelframe.button_$index configure -style TButton
set ::KIFSD::FSD::qa_panel_dialog_icon $index
}
@@ -1671,7 +1748,7 @@ itcl::class KIFSD::FSD {
proc not_empty_entry_validator {widget content} {
if {![string length $content]} {
$widget configure -style StringNotFound.TEntry
- } {
+ } else {
$widget configure -style TEntry
}
return 1
@@ -1688,7 +1765,7 @@ itcl::class KIFSD::FSD {
# @return List - {new_icon_number new_name new_url}
private method qa_panel_dialog {title icon name url} {
# Create dialog window
- set dialog [toplevel "${win}_qa_panel_dialog" -class {Configuration dialog} -bg {#EEEEEE}]
+ set dialog [toplevel ${win}.qa_panel_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
# Set dialog variables
set ::KIFSD::FSD::qa_panel_dialog_icon $icon
@@ -1699,11 +1776,11 @@ itcl::class KIFSD::FSD {
set mid_frame [frame $dialog.middle]
# Label: "Name"
grid [label $mid_frame.name_lbl \
- -text "Name" \
+ -text [::mc "Name"] \
] -row 0 -column 0 -sticky w
# Label: "URL"
grid [label $mid_frame.url_lbl \
- -text "URL" \
+ -text [::mc "URL"] \
] -row 1 -column 0 -sticky w
# EntryBox: "Name"
grid [ttk::entry $mid_frame.name_entry \
@@ -1724,7 +1801,7 @@ itcl::class KIFSD::FSD {
# Create frame for selecting icon
pack [ttk::labelframe $dialog.labelframe \
- -text "Icon" \
+ -text [::mc "Icon"] \
] -fill none -expand 1 -anchor w -padx 10
foreach icon {hdd_unmount folder_home desktop bookmark_folder} index {0 1 2 3} {
pack [ttk::button $dialog.labelframe.button_$index \
@@ -1741,7 +1818,7 @@ itcl::class KIFSD::FSD {
set bot_frame [frame $dialog.bot]
# Button: "Ok"
pack [ttk::button $bot_frame.ok \
- -text "Ok" \
+ -text [::mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
-command "
@@ -1751,11 +1828,11 @@ itcl::class KIFSD::FSD {
destroy $dialog
}
}" \
- ] -side left -fill none -expand 0
+ ] -side left -fill none -expand 0 -padx 2
# Button: "Cancel"
- pack [ttk::button $bot_frame.cancel \
- -text "Cancel" \
- -compound left \
+ pack [ttk::button $bot_frame.cancel \
+ -text [::mc "Cancel"] \
+ -compound left \
-image ::ICONS::16::button_cancel \
-command "
set ::KIFSD::FSD::qa_panel_dialog_url_entry {}
@@ -1763,7 +1840,7 @@ itcl::class KIFSD::FSD {
set ::KIFSD::FSD::qa_panel_dialog_icon {}
grab release $dialog
destroy $dialog" \
- ] -side left -fill none -expand 0
+ ] -side left -fill none -expand 0 -padx 2
pack $bot_frame -anchor e -padx 10 -pady 5
# Configure dialog window
@@ -1871,34 +1948,34 @@ itcl::class KIFSD::FSD {
# Determinate URL to delete
if {$cur_listbox == {dir}} {
set filename [$dir_listbox itemcget $current_item -text]
- } {
+ } else {
set data [$file_listbox itemcget $current_item -data]
if {[lindex $data 0] == {}} {
set filename [lindex $data 1]
- } {
+ } else {
set filename [lindex $data 0]
}
}
if {$filename == {}} {return}
# Invoke confirmation dialog
- if {[tk_messageBox \
- -parent $win \
- -type yesno \
- -icon question \
- -title "Delete file" \
- -message "Do you really want to delete file:\n$filename"]
+ if {[tk_messageBox \
+ -parent $win \
+ -type yesno \
+ -icon question \
+ -title [::mc "Delete file"] \
+ -message [::mc "Do you really want to delete file:\n%s" $filename]]
==
{yes}
- } {
+ } then {
# Delete file/directory (+ invoke error dialog)
if {[catch {file delete -force -- [file join $current_directory $filename]}]} {
tk_messageBox \
-parent $win \
-type ok \
-icon warning \
- -title "Permission denied" \
- -message "Unable to remove file:\n$filename"
+ -title [::mc "Permission denied"] \
+ -message [::mc "Unable to remove file:\n%s" $filename]
}
}
reload
@@ -1921,7 +1998,7 @@ itcl::class KIFSD::FSD {
public method rename_item_command {} {
if {$cur_listbox == {dir}} {
set listbox $dir_listbox
- } {
+ } else {
set listbox $file_listbox
}
@@ -1943,8 +2020,8 @@ itcl::class KIFSD::FSD {
-parent $win \
-type ok \
-icon warning \
- -title "Permission denied" \
- -message "Unable to rename file:\n$original"
+ -title [::mc "Permission denied"] \
+ -message [::mc "Unable to rename file:\n%s" $original]
}
reload
}
@@ -1956,12 +2033,12 @@ itcl::class KIFSD::FSD {
if {$cur_listbox == {dir}} {
set name [$dir_listbox itemcget $current_item -text]
set type "Directory"
- } {
+ } else {
set name [$file_listbox itemcget $current_item -data]
if {[lindex $name 0] == {}} {
set name [lindex $name 1]
set type "Directory"
- } {
+ } else {
set name [lindex $name 0]
set type "File"
}
@@ -1974,8 +2051,8 @@ itcl::class KIFSD::FSD {
-parent $win \
-type ok \
-icon warning \
- -title "Unknown Error" \
- -message "This file apparently does not exist"
+ -title [::mc "Unknown Error"] \
+ -message [::mc "This file apparently does not exist"]
return
}
# Determinate size
@@ -2000,8 +2077,8 @@ itcl::class KIFSD::FSD {
}
# Create dialog window and Notebook
- set dialog [toplevel ${win}_properties_dialog -class {Configuration dialog} -bg {#EEEEEE}]
- set nb [NoteBook $dialog.nb -bg {#EEEEEE}]
+ set dialog [toplevel $win.properties_dialog -class {Configuration dialog} -bg ${::COMMON_BG_COLOR}]
+ set nb [NoteBook $dialog.nb -bg ${::COMMON_BG_COLOR}]
$nb insert end general -text "General"
if {!$::MICROSOFT_WINDOWS} { ;# Microsoft Windows has no file rights (compatible with posix rights)
$nb insert end permission -text "Permissions"
@@ -2014,7 +2091,7 @@ itcl::class KIFSD::FSD {
# Name:
set row 0
grid [label $frame.lbl_$row \
- -text "Name:" -anchor w \
+ -text [::mc "Name:"] -anchor w \
-font $listbox_font_short \
] -column 0 -row $row -sticky w -pady 3
set ::KIFSD::FSD::item_properties(name) $name
@@ -2025,11 +2102,11 @@ itcl::class KIFSD::FSD {
] -column 1 -row $row -sticky w -pady 3
# Type, Location, Size, Modified, Accessed
incr row
- foreach lbl {Type Location Size Modified Accessed} \
+ foreach lbl [list "Type" "Location" "Size" "Modified" "Accessed"] \
value [list $type $current_directory $size $modified $accessed] \
{
grid [label $frame.lbl_$row \
- -text "$lbl:" -anchor w \
+ -text "[::mc $lbl]:" -anchor w \
-font $listbox_font_short \
] -column 0 -row $row -sticky w -pady 3
grid [label $frame.val_lbl_$row \
@@ -2043,15 +2120,16 @@ itcl::class KIFSD::FSD {
if {!$::MICROSOFT_WINDOWS} { ;# Microsoft Windows has no file rights (compatible with posix rights)
set frame [$nb getframe permission]
set ap_frame [ttk::labelframe $frame.ap_frame \
- -text "Access permissions" \
+ -text [::mc "Access permissions"] \
]
set i 0
- foreach text {Class Read Write Exec Owner Group Others} \
+ foreach text [list "Class" "Read" "Write" "Exec" "Owner" "Group" "Others"] \
row {0 0 0 0 1 2 3} \
col {0 1 2 3 0 0 0} \
{
grid [label $ap_frame.lbl_$i \
- -text $text -justify center \
+ -text [::mc $text] \
+ -justify center \
] -row $row -column $col -sticky w -padx 4 -pady 4
incr i
}
@@ -2070,16 +2148,16 @@ itcl::class KIFSD::FSD {
pack $ap_frame -side top -fill x -expand 1 -padx 5 -pady 5 -anchor nw
set own_frame [ttk::labelframe $frame.own_frame \
- -text "Ownership" \
+ -text [::mc "Ownership"] \
]
- grid [label $own_frame.owner_lbl \
- -text "Owner" -font $listbox_font_short \
+ grid [label $own_frame.owner_lbl \
+ -text [::mc "Owner"] -font $listbox_font_short \
] -row 0 -column 0 -padx 10 -pady 3 -sticky w
grid [label $own_frame.owner_val_lbl \
-text $owner -anchor w \
] -row 0 -column 1 -padx 10 -pady 3 -sticky we
- grid [label $own_frame.group_lbl \
- -text "Group" -font $listbox_font_short \
+ grid [label $own_frame.group_lbl \
+ -text [::mc "Group"] -font $listbox_font_short \
] -row 1 -column 0 -padx 10 -pady 3 -sticky w
grid [label $own_frame.group_val_lbl \
-text $group -anchor w \
@@ -2092,27 +2170,27 @@ itcl::class KIFSD::FSD {
# Create bottom frame (buttons: "Ok" and "Cancel")
set bottom_frame [frame $dialog.bottom_frame]
pack [ttk::button $bottom_frame.ok \
- -text "Ok" \
+ -text [::mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
-command "$this properties_ok $dialog $fullname" \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $bottom_frame.cancel \
- -text "Cancel" \
+ -text [::mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command "
grab release $dialog
destroy $dialog
" \
- ]
+ ] -side left -padx 2
# Pack notebook and bottom frame
pack $nb -fill both -expand 1 -padx 10 -pady 5
pack $bottom_frame -anchor e -after $nb -padx 10 -pady 5
# Configure dialog window
- wm title $dialog "Item properties"
+ wm title $dialog [::mc "Item properties"]
wm minsize $dialog 280 320
wm protocol $dialog WM_DELETE_WINDOW "
grab release $dialog
@@ -2140,9 +2218,12 @@ itcl::class KIFSD::FSD {
}
if {[catch {file attributes $file -permissions "0[format {%o} $perm]"}]} {
set error 1
- tk_messageBox -type ok -icon warning -parent $dialog \
- -title "Permission denied" \
- -message "Unable to change permission for file:\n[file tail $file]"
+ tk_messageBox \
+ -type ok \
+ -icon warning \
+ -parent $dialog \
+ -title [::mc "Permission denied"] \
+ -message [::mc "Unable to change permissions for file:\n%s" [file tail $file]]
}
}
set dir [file dirname $file]
@@ -2152,11 +2233,14 @@ itcl::class KIFSD::FSD {
file rename -force -- \
$file [file join $dir \
${::KIFSD::FSD::item_properties(name)}]}]
- } {
+ } then {
set error 1
- tk_messageBox -type ok -icon warning -parent $dialog \
- -title "Permission denied" \
- -message "Unable to rename file:\n[file tail $file]\n\t=>\n${::KIFSD::FSD::item_properties(name)}"
+ tk_messageBox \
+ -type ok \
+ -icon warning \
+ -parent $dialog \
+ -title [::mc "Permission denied"] \
+ -message [::mc "Unable to rename file:%s" "\n[file tail $file]\n\t=>\n${::KIFSD::FSD::item_properties(name)}"]
}
reload
}
@@ -2176,21 +2260,21 @@ itcl::class KIFSD::FSD {
if {![file exists $content] || ![file isdirectory $content]} {
if {$combobox != {}} {
$combobox configure -style FSD_RedBg.TCombobox
- } {
- $widget configure -bg {#FFDDDD}
+ } else {
+ $widget configure -style FSD_RedBg.TEntry
}
- } {
+ } else {
if {$combobox != {}} {
$combobox configure -style TCombobox
- } {
- $widget configure -bg {#DDFFDD}
+ } else {
+ $widget configure -style TEntry
}
# Fill directory location combobox
if {$combobox != {}} {
set folder $content
set values {}
- while 1 {
+ while {1} {
lappend values $folder
if {$folder == [file separator]} {break}
if {$::MICROSOFT_WINDOWS} {
@@ -2216,9 +2300,10 @@ itcl::class KIFSD::FSD {
}
## Reload content of directories ListBox and files ListBox
+ # @param List args - all arguments are ignored
# @return void
- public method reload {} {
- update idle
+ public method reload {args} {
+ update idletasks
change_directory $current_directory
}
@@ -2231,7 +2316,7 @@ itcl::class KIFSD::FSD {
## Go to parrent folder
# @return void
public method up {} {
- change_directory [file join $current_directory {..}]
+ change_directory [file normalize [file join $current_directory {..}]]
}
## Go back in history
@@ -2260,7 +2345,7 @@ itcl::class KIFSD::FSD {
if {![llength $back_history]} {
$toolbar.back configure -state disabled
$win.listbox_menu entryconfigure [mc "Back"] -state disabled
- } {
+ } else {
$toolbar.back configure -state normal
$win.listbox_menu entryconfigure [mc "Back"] -state normal
}
@@ -2294,7 +2379,7 @@ itcl::class KIFSD::FSD {
if {![llength $forward_history]} {
$toolbar.forward configure -state disabled
$win.listbox_menu entryconfigure [mc "Forward"] -state disabled
- } {
+ } else {
$toolbar.forward configure -state normal
$win.listbox_menu entryconfigure [mc "Forward"] -state normal
}
@@ -2306,7 +2391,7 @@ itcl::class KIFSD::FSD {
# @return void
public method newdir {} {
# Create dialog window
- set dialog [toplevel ${win}_new_dir -class {New directory} -bg {#EEEEEE}]
+ set dialog [toplevel $win.new_dir -class {New directory} -bg ${::COMMON_BG_COLOR}]
# Create dialog header and EntryBox
pack [label $dialog.header -justify left -text [mc "Create new folder in:\n%s" $current_directory]] \
@@ -2325,13 +2410,13 @@ itcl::class KIFSD::FSD {
-compound left \
-image ::ICONS::16::clear_left \
-command "$dialog.entry delete 0 end" \
- ] -side left -expand 0
+ ] -side left -expand 0 -padx 2
pack [ttk::button $button_frame.ok \
-text [mc "Ok"] \
-compound left \
-image ::ICONS::16::ok \
-command [list $this create_new_folder] \
- ] -side left -expand 0
+ ] -side left -expand 0 -padx 2
pack [ttk::button $button_frame.cancel \
-text [mc "Cancel"] \
-compound left \
@@ -2340,7 +2425,7 @@ itcl::class KIFSD::FSD {
grab release $dialog
destroy $dialog
" \
- ] -side left -expand 0
+ ] -side left -expand 0 -padx 2
pack $button_frame -side bottom -anchor e -expand 0 -padx 5 -pady 5
# Configure dialog window
@@ -2363,7 +2448,7 @@ itcl::class KIFSD::FSD {
## Confirm dialog "Create new folder"
# @return void
public method create_new_folder {} {
- set dialog "${win}_new_dir"
+ set dialog ${win}.new_dir
set folder [$dialog.entry get]
set error 0
@@ -2377,7 +2462,7 @@ itcl::class KIFSD::FSD {
-type ok \
-title [mc "Unable to create folder"] \
-message [mc "Unable to create the specified folder"]
- } {
+ } else {
grab release $dialog
destroy $dialog
reload
@@ -2393,22 +2478,22 @@ itcl::class KIFSD::FSD {
# Determinate sorting order
if {${::KIFSD::FSD::config(reverse_sorting)}} {
set order "-decreasing"
- } {
+ } else {
set order "-increasing"
}
if {${::KIFSD::FSD::config(sorting)} == {name}} {
if {${::KIFSD::FSD::config(case_insensitive)}} {
set method "-dictionary"
- } {
+ } else {
set method "-ascii"
}
return [lsort $method $order $items]
- } {
+ } else {
if {${::KIFSD::FSD::config(sorting)} == {size}} {
# Sort by size
set index 2
- } {
+ } else {
# Sort by date
set index 1
}
@@ -2516,7 +2601,7 @@ itcl::class KIFSD::FSD {
[file mtime [file join $dir $file]] \
[file size [file join $dir $file]] \
]
- }]} {
+ }]} then {
lappend result [list $file 0 0]
}
}
@@ -2532,7 +2617,7 @@ itcl::class KIFSD::FSD {
[file mtime [file join $dir $file]] \
[file size [file join $dir $file]] \
]
- }]} {
+ }]} then {
lappend result [list $file 0 0]
}
}
@@ -2542,62 +2627,46 @@ itcl::class KIFSD::FSD {
}
## Get list of items to load to directories ListBox
- # @parm String - Source directory
- # @parm Bool = 0 - No details
+ # @parm String dir - Source directory
+ # @parm Bool no_detail=0 - No details
# @return List - {text text ...}
- proc dir_cmd args {
- # Parse input arguments
- set dir [lindex $args 0]
- set no_detail [lindex $args 1]
- if {$no_detail == {}} {
- set no_detail 0
- }
-
+ proc dir_cmd {dir {no_detail 0}} {
# Normalize directory and determinate its parent
set dir [file normalize $dir]
if {$dir != {/}} {
set parent {..}
- } {
+ } else {
set parent {}
}
if {${::KIFSD::FSD::config(sorting)} == {name}} {
set result [sort_items [get_dirs_simple $dir]]
- } {
+ } else {
set result [sort_items [get_dirs_extended $dir]]
}
if {!$no_detail && ${::KIFSD::FSD::config(detailed_view)}} {
return [concat $parent [add_details $result $dir]]
- } {
+ } else {
return [concat $parent $result]
}
}
## Get list of items to load to files ListBox
- # @parm String - Source directory
- # @parm GLOB - GLOB expression which must match each returned file
- # @parm Bool = 0 - Detailed view
+ # @parm String dir - Source directory
+ # @parm GLOB mask - GLOB expression which must match each returned file
+ # @parm Bool no_detail=0 - Detailed view
# @return List - {text text ...}
- proc file_cmd args {
- # Parse input arguments
- set dir [lindex $args 0]
- set mask [lindex $args 1]
- set no_detail [lindex $args 2]
- if {$no_detail == {}} {
- set no_detail 0
- }
-
-
+ proc file_cmd {dir mask {no_detail 0}} {
if {${::KIFSD::FSD::config(sorting)} == {name}} {
set result [sort_items [get_files_simple $dir $mask]]
- } {
+ } else {
set result [sort_items [get_files_extended $dir $mask]]
}
if {!$no_detail && ${::KIFSD::FSD::config(detailed_view)}} {
return [add_details $result $dir]
- } {
+ } else {
return $result
}
}
@@ -2617,7 +2686,7 @@ itcl::class KIFSD::FSD {
append line {...}
}
if {[catch {
- append line [string repeat "\t" [expr {4 - ([string length $line] / 8)}]]
+ append line [string repeat { } [expr {35 - [string length $line]}]]
set size [file size $fullfilename]
if {$size < 1024} {
append size { B}
@@ -2625,7 +2694,7 @@ itcl::class KIFSD::FSD {
set size [expr {($size * 10) / 1024}]
if {$size > 1023} {
set size [expr {$size / 10}]
- } {
+ } else {
set size [string range $size 0 {end-1}].[string range $size end end]
}
append size { kB}
@@ -2633,7 +2702,7 @@ itcl::class KIFSD::FSD {
set size [expr {($size * 10) / 1048576}]
if {$size > 1023} {
set size [expr {$size / 10}]
- } {
+ } else {
set size [string range $size 0 {end-1}].[string range $size end end]
}
append size { MB}
@@ -2641,21 +2710,21 @@ itcl::class KIFSD::FSD {
set size [expr {($size * 10) / 1073741824}]
if {$size > 1023} {
set size [expr {$size / 10}]
- } {
+ } else {
set size [string range $size 0 {end-1}].[string range $size end end]
}
append size { GB}
} else {
set size {>1TB}
}
- }]} {
+ }]} then {
append line { - ---- -------- -----}
} else {
if {!$::MICROSOFT_WINDOWS} {
append line [string repeat { } [expr {8 - [string length $size]}]] $size " " \
[string range [lindex [file attributes $fullfilename] 5] {end-3} end] " " \
[clock format [file mtime $fullfilename] -format {%D %R}]
- } {
+ } else {
append line [string repeat { } [expr {8 - [string length $size]}]] $size " " \
[clock format [file mtime $fullfilename] -format {%D %R}]
}
@@ -2676,12 +2745,12 @@ itcl::class KIFSD::FSD {
# Determinate list of directories
if {${::KIFSD::FSD::config(sorting)} == {name}} {
set result [concat [get_dirs_simple $dir] [get_files_simple $dir $mask]]
- } {
+ } else {
set result [concat [get_dirs_extended $dir] [get_files_extended $dir $mask]]
}
if {$dir != {/}} {
set parent [list [list {..} {u}]]
- } {
+ } else {
set parent {}
}
set tmp_result {}
@@ -2692,16 +2761,16 @@ itcl::class KIFSD::FSD {
if {![file exists [file join $dir $item]]} {continue}
if {[file isdirectory [file join $dir $item]]} {
lappend tmp_result [concat [add_details [list $item] $dir] d]
- } {
+ } else {
lappend tmp_result [concat [add_details [list $item] $dir] f]
}
}
- } {
+ } else {
foreach item [sort_items $result] {
if {![file exists [file join $dir $item]]} {continue}
if {[file isdirectory [file join $dir $item]]} {
lappend tmp_result [list $item d]
- } {
+ } else {
lappend tmp_result [list $item f]
}
}
@@ -2722,12 +2791,13 @@ itcl::class KIFSD::FSD {
if {$config == {}} {
return
}
+
if {[catch {
array set ::KIFSD::FSD::config $config
- }]} {
+ }]} then {
puts stderr "KI File Selection Dialog: Unable to load the given configuration string -- using default"
return 0
- } {
+ } else {
return 1
}
}
@@ -2737,6 +2807,27 @@ itcl::class KIFSD::FSD {
public method get_window_name {} {
return $win
}
+
+ ## Determinate path to the "Desktop" folder.
+ # @return String - The path, e.g. "~/Arbeitsfläche" in case of German Ubuntu.
+ proc get_desktop_dir {} {
+ if {![catch {
+ set f [open "~/.config/user-dirs.dirs" "r"]
+ }]} then {
+ while {![eof $f]} {
+ set l [gets $f]
+ if {[string first "XDG_DESKTOP_DIR=" $l] != -1} {
+ if {[regexp {"[^\"]+"} $l d]} {
+ set d [string range $d 1 end-1]
+ regsub {\$HOME} $d {~} d
+ return $d
+ }
+ }
+ }
+ close $f
+ }
+ return "~/Desktop"
+ }
}
## Text variables for dialog "Edit entry in Quick access bar"
@@ -2746,7 +2837,6 @@ set KIFSD::FSD::qa_panel_dialog_icon {} ;# Icon number [0;3]
## Dialog configuration array (these values are daults)
# Invalid configuration list may cause program error !
-
array set KIFSD::FSD::config {
win_geometry {720x380}
detailed_view 0
@@ -2760,11 +2850,6 @@ array set KIFSD::FSD::config {
right_PW_size 200
main_PW_size 180
bookmarks {}
- quick_access_bar_data {
- {0 {/} {/}}
- {1 {Home} {~}}
- {2 {Desktop} {~/Desktop}}
- }
}
if {$::MICROSOFT_WINDOWS} {
@@ -2772,4 +2857,15 @@ if {$::MICROSOFT_WINDOWS} {
{0 {System Drive ${::env(SystemDrive)}} {${::env(SystemDrive)}}}
{1 {Documents and Settings} {${::env(USERPROFILE)}}}
}]
+} else {
+ set KIFSD::FSD::config(quick_access_bar_data) [subst {
+ {0 {/} {/}}
+ {0 {Removable media} {/media}}
+ {1 {Home} {~}}
+ {2 {Desktop} {[KIFSD::FSD::get_desktop_dir]}}
+ }]
+}
+
+# >>> File inclusion guard
}
+# <<< File inclusion guard
diff --git a/lib/dialogs/my_tk_messageBox.tcl b/lib/dialogues/my_tk_messageBox.tcl
index 1a559fe..0698e9e 100755..100644
--- a/lib/dialogs/my_tk_messageBox.tcl
+++ b/lib/dialogues/my_tk_messageBox.tcl
@@ -2,7 +2,7 @@
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2009 by Martin Ošmera #
+# Copyright (C) 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 _MY_TK_MESSAGEBOX_TCL ] } {
+set _MY_TK_MESSAGEBOX_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Replacement for Tk's tk_messageBox. Usage is the same as tk_messageBox,
@@ -34,6 +39,7 @@ namespace eval my_tk_messageBox {
## Namespace variables
variable return_value {} ;# String: Dialog return value (e.g. "abort")
variable dialog ;# Widget: Dialog toplevel window
+ variable count 0 ;# Int: Counter of object instances
# Buttons available in the dialog
variable available_buttons {
abort retry ignore
@@ -60,9 +66,11 @@ namespace eval my_tk_messageBox {
variable button_icons ;# Icons for available buttons
variable available_buttons ;# Buttons available in the dialog
variable dialog ;# Widget: Dialog toplevel window
+ variable count ;# Int: Counter of object instances
- set dialog [toplevel .my_tk_messageBox]
+ set dialog [toplevel .my_tk_messageBox_${count}]
set buttons [list]
+ incr count
# Translate icon name
switch -- $arg_icon {
@@ -119,8 +127,8 @@ namespace eval my_tk_messageBox {
# Create top frame (dialog icon and text of the message)
set top_frame [frame $dialog.top]
- pack [label $top_frame.img -image ::ICONS::32::$arg_icon] -side left
- pack [label $top_frame.txt -text $arg_message -wraplength 300] -side left -fill both
+ pack [label $top_frame.img -image ::ICONS::32::$arg_icon] -side left -padx 5
+ pack [label $top_frame.txt -text $arg_message -wraplength 300 -justify left] -side left -fill both -padx 5
# Create bottom bar with dialog buttons
set bottom_frame [frame $dialog.bottom]
@@ -139,10 +147,15 @@ namespace eval my_tk_messageBox {
] -side left -padx 2
bind $bottom_frame.button_${button} <Return> "::my_tk_messageBox::button_press $button"
bind $bottom_frame.button_${button} <KP_Enter> "::my_tk_messageBox::button_press $button"
+ bind $bottom_frame.button_${button} <Escape> "
+ grab release $dialog
+ destroy $dialog
+ set ::my_tk_messageBox::return_value {}
+ "
}
# Pack window frames
- pack $top_frame -expand 1 -padx 10 -pady 10
+ pack $top_frame -expand 1 -pady 10 -padx 5
pack $bottom_frame -padx 5 -pady 10
# Window manager options -- modal window
@@ -159,7 +172,9 @@ namespace eval my_tk_messageBox {
set ::my_tk_messageBox::return_value {}
"
update
- grab $dialog
+ catch {
+ grab $dialog
+ }
# Wait for user response
tkwait window $dialog
@@ -191,7 +206,8 @@ namespace eval my_tk_messageBox {
foreach subdir {16x16 32x32} ns {16 32} icons {
{cancel info help status_unknown ok button_cancel reload forward no}
{messagebox_critical messagebox_info help messagebox_warning button_ok}
- } {
+ } \
+ {
foreach icon $icons {
set filename [file join $directory {../icons} $subdir "${icon}.png"]
@@ -266,7 +282,7 @@ proc my_tk_messageBox args {
if {![string length $arg_title]} {
if {![string length $arg_icon]} {
set arg_title {Message}
- } {
+ } else {
set arg_title [string toupper [string index $arg_icon 0]]
append arg_title [string range $arg_icon 1 end]
}
@@ -281,3 +297,7 @@ proc my_tk_messageBox args {
# Replace Tk's command "tk_messageBox"
rename tk_messageBox old_tk_messageBox
rename my_tk_messageBox tk_messageBox
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/dialogs/selectmcu.tcl b/lib/dialogues/selectmcu.tcl
index 86d2fae..584a59f 100755..100644
--- a/lib/dialogs/selectmcu.tcl
+++ b/lib/dialogues/selectmcu.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 _SELECTMCU_TCL ] } {
+set _SELECTMCU_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# This namespace implements "MCU selection" dialog.
@@ -36,8 +41,8 @@
# Other functions
# ==================================
#
-# SelectMCU::get_avaliable_processors
-# -> List of avaliable processors (e.g. {80C51 AT89C52 AT89C4051})
+# SelectMCU::get_available_processors
+# -> List of available processors (e.g. {80C51 AT89C52 AT89C4051})
#
# SelectMCU::get_processor_details processor_type
# -> List of MCU definition (see proc. xml_data_parser1)
@@ -45,21 +50,22 @@
namespace eval SelectMCU {
# String: Path to MCUs definition file
- variable definition_file "${::LIB_DIRNAME}/../data/mcus.xml"
- # List: Avaliable MCU vendors
- variable vendors {all Atmel Intel}
+ variable definition_file "${::ROOT_DIRNAME}/data/mcus.xml"
+ # List: available MCU vendors
+ variable vendors [list [mc "all"] "Atmel" "Intel"]
variable selected_mcu {} ;# List: Dialog return value {mcu_type xdata xcode}
variable definition_data {} ;# List: Values gained from $definition_file
- variable mcu_names {} ;# List: Avaliable processors
- variable maximum_xcode 0xFFFF ;# Int: Maximum external program memory (0xFFFF - internal)
- variable vendor {all} ;# String: Selected vendor
+ variable local_definition_data {} ;# List: Basically the same as $definition_data but containing only the shown items
+ variable mcu_names {} ;# List: Available processors (and show in the list)
+ variable maximum_xcode 0x10000 ;# Int: Maximum external program memory (0x10000 - internal)
+ variable vendor [mc "all"] ;# String: Selected vendor
## Variables related to GUI
variable parent ;# Widget: Dialog parent (another window)
variable win ;# Widget: Dialog window
variable search_bar ;# Widget: Search bar entry box
variable search_bar_clear ;# Widget: Search bar clear button
- variable listbox_widget ;# Widget: List box containing avaliable MCUs
+ variable listbox_widget ;# Widget: List box containing available MCUs
variable value_lbl_uart ;# Widget: Label "UART:" - value
variable value_lbl_voltage ;# Widget: Label "Operating voltage:" - value
variable value_lbl_interrupts ;# Widget: Label "Interrupts:" - value
@@ -68,9 +74,9 @@ namespace eval SelectMCU {
variable more_details_text ;# Widget: TextWidget "More details:"
variable more_details_scrollbar ;# Widget: Scrollbar for $more_details_text
variable details_xdata_aval ;# Widget: Frame containing scale and spinbox for XDATA memory
- variable details_xdata_note ;# Widget: Frame containing label "NOT AVALIABLE" for XDATA memory
+ variable details_xdata_note ;# Widget: Frame containing label "NOT available" for XDATA memory
variable details_xcode_aval ;# Widget: Frame containing scale and spinbox for XCODE memory
- variable details_xcode_nota ;# Widget: Frame containing label "NOT AVALIABLE" for XCODE memory
+ variable details_xcode_nota ;# Widget: Frame containing label "NOT available" for XCODE memory
variable name_label ;# Widget: Label containing name of selected MCU
variable image_label ;# Widget: Label with image for selected MCU
variable xdata_scale ;# Widget: Scale for XDATA memory
@@ -86,31 +92,36 @@ namespace eval SelectMCU {
variable current_mcu ;# String: Name of MCU currently being parsed
## Fonts used in the selection dialog
- # ListBox containing avaliable fonts
- variable listbox_widget_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- -weight bold \
- ]
- # ListBox header -- label widget above the ListBox
- variable listbox_header_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- ]
- # Label with the MCU name
- variable name_font [font create \
- -family {helvetica} -size -20 \
- -weight bold \
- ]
- # Labels like "Vendor:", "UART:", "Timers:", etc.
- variable normal_font [font create \
- -family {helvetica} -size -12 \
- ]
- # Labels with values like for "Vendor:", "Timers:", etc.
- variable bold_font [font create \
- -family {helvetica} -size -12 \
- -weight bold \
- ]
+ if {$::GUI_AVAILABLE} {
+ # ListBox containing available fonts
+ variable listbox_widget_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
+ ]
+ # ListBox header -- label widget above the ListBox
+ variable listbox_header_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ ]
+ # Label with the MCU name
+ variable name_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-20 * $::font_size_factor)}] \
+ -weight bold \
+ ]
+ # Labels like "Vendor:", "UART:", "Timers:", etc.
+ variable normal_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ ]
+ # Labels with values like for "Vendor:", "Timers:", etc.
+ variable bold_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ ]
+ }
## Invoke MCU selection dialog
# @parm Widget Parent - Dialog parent (some window)
@@ -138,7 +149,11 @@ namespace eval SelectMCU {
# Finalize window creation
wm iconphoto $win ::ICONS::16::kcmmemory
wm title $win [mc "Choose MCU - MCU 8051 IDE"]
- wm minsize $win 720 500
+ if {$::font_size_factor > 1.0} {
+ wm minsize $win 870 500
+ } else {
+ wm minsize $win 720 500
+ }
wm protocol $win WM_DELETE_WINDOW {
::SelectMCU::cancel
}
@@ -148,14 +163,18 @@ namespace eval SelectMCU {
grab $win
}
- # Initialize XDATA & XCODE scales
+ # Initialize search bar
$search_bar insert end [lindex $initial 0]
focus -force $search_bar
$search_bar selection range 0 end
+
+ set selected_mcu [lindex $initial 0]
+
+ # Initialize XDATA & XCODE scales
if {[lindex $initial 1]} {
set ::SelectMCU::xdata_ena 1
set ::SelectMCU::xdata_value [lindex $initial 1]
- } {
+ } else {
set ::SelectMCU::xdata_ena 0
set ::SelectMCU::xdata_value 0
xdata_disena
@@ -163,27 +182,27 @@ namespace eval SelectMCU {
if {[lindex $initial 2]} {
set ::SelectMCU::xcode_ena 1
set ::SelectMCU::xcode_value [lindex $initial 2]
- } {
+ } else {
set ::SelectMCU::xcode_ena 0
set ::SelectMCU::xcode_value 0
xcode_disena
}
- # Diplay window
+ # Wait until the window is destroyed
tkwait window $win
# Create resulting string
if {$selected_mcu == {}} {
set result {}
- } {
+ } else {
if {${::SelectMCU::xdata_ena}} {
set xdata ${::SelectMCU::xdata_value}
- } {
+ } else {
set xdata 0
}
- if {${::SelectMCU::xcode_value}} {
+ if {${::SelectMCU::xcode_ena}} {
set xcode ${::SelectMCU::xcode_value}
- } {
+ } else {
set xcode 0
}
@@ -203,18 +222,24 @@ namespace eval SelectMCU {
# @return void
proc fill_gui {} {
variable definition_data ;# List: Values gained from $definition_file
- variable listbox_widget ;# Widget: List box containing avaliable MCUs
- variable listbox_widget_font ;# ListBox containing avaliable fonts
- variable mcu_names ;# List: Avaliable processors
+ variable local_definition_data ;# List: Basically the same as $definition_data but containing only the shown items
+ variable listbox_widget ;# Widget: List box containing available MCUs
+ variable listbox_widget_font ;# ListBox containing available fonts
+ variable mcu_names ;# List: available processors
variable vendor ;# String: Selected vendor
+ set mcu_names {}
+ set local_definition_data {}
+
# Iterate over defined MCUs
foreach mcu $definition_data {
# Filter specific vendors
- if {$vendor != {all} && [lindex $mcu 11] != $vendor} {
+ if {$vendor != [mc "all"] && [lindex $mcu 11] != $vendor} {
continue
}
+ lappend local_definition_data $mcu
+
# MCU type
set mcu_type [lindex $mcu 0]
lappend mcu_names $mcu_type
@@ -253,7 +278,7 @@ namespace eval SelectMCU {
variable win ;# Widget: Dialog window
variable search_bar ;# Widget: Search bar entry box
variable search_bar_clear ;# Widget: Search bar clear button
- variable listbox_widget ;# Widget: List box containing avaliable MCUs
+ variable listbox_widget ;# Widget: List box containing available MCUs
variable value_lbl_uart ;# Widget: Label "UART:" - value
variable value_lbl_voltage ;# Widget: Label "Operating voltage:" - value
variable value_lbl_interrupts ;# Widget: Label "Interrupts:" - value
@@ -262,10 +287,10 @@ namespace eval SelectMCU {
variable more_details_text ;# Widget: TextWidget "More details:"
variable more_details_scrollbar ;# Widget: Scrollbar for $more_details_text
variable details_xdata_aval ;# Widget: Frame containing scale and spinbox for XDATA memory
- variable details_xdata_note ;# Widget: Frame containing label "NOT AVALIABLE" for XDATA memory
+ variable details_xdata_note ;# Widget: Frame containing label "NOT available" for XDATA memory
variable details_xcode_aval ;# Widget: Frame containing scale and spinbox for XCODE memory
- variable details_xcode_nota ;# Widget: Frame containing label "NOT AVALIABLE" for XCODE memory
- variable listbox_widget_font ;# ListBox containing avaliable fonts
+ variable details_xcode_nota ;# Widget: Frame containing label "NOT available" for XCODE memory
+ variable listbox_widget_font ;# ListBox containing available fonts
variable listbox_header_font ;# ListBox header -- label widget above the ListBox
variable bold_font ;# Labels with values like for "Vendor:", "Timers:", etc.
variable normal_font ;# Labels like "Vendor:", "UART:", "Timers:", etc.
@@ -276,10 +301,10 @@ namespace eval SelectMCU {
variable xdata_spinbox ;# Widget: Scale for XDATA memory
variable xcode_spinbox ;# Widget: SpinBox for XCODE memory
variable xcode_scale ;# Widget: Scale for XCODE memory
- variable vendors ;# List: Avaliable MCU vendors
+ variable vendors ;# List: available MCU vendors
# Create toplevel window
- set win [toplevel .selectmcu_dialog -class {Select MCU} -bg {#EEEEEE}]
+ set win [toplevel .selectmcu_dialog -class {Select MCU} -bg ${::COMMON_BG_COLOR}]
# Create search bar widgets (but don't pack them)
set search_bar_frame [frame $win.search_bar_frame]
@@ -326,7 +351,7 @@ namespace eval SelectMCU {
-font $listbox_header_font \
-bg {#DDDDDD} -bd 0 -padx 25 \
-justify left -anchor w \
- -text [mc "Processor type\t\tCODE mem. IDATA mem. IO lines Frequency"] \
+ -text [mc "Processor Type\t\tCODE/PMEM IDATA/IRAM GPIO Frequency"] \
] -fill x
# Create remaining parts of top frame and pack them
@@ -369,7 +394,7 @@ namespace eval SelectMCU {
-image [image create photo] -text { } \
-width 200 -height 200 -compound left \
]
- DynamicHelp::add $image_label -text [mc "One of avaliable packages for selected microcontroller"]
+ DynamicHelp::add $image_label -text [mc "One of available packages for selected microcontroller"]
pack $name_label -fill x
pack $image_label -padx 5
@@ -410,7 +435,7 @@ namespace eval SelectMCU {
set more_details_text [text $details_middle_bottom.text \
-yscrollcommand ::SelectMCU::details_scrollbar_set \
-width 0 -heigh 0 -bd 0 -relief flat -font $bold_font \
- -highlightthickness 0 -state disabled -bg {#EEEEEE} \
+ -highlightthickness 0 -state disabled -bg ${::COMMON_BG_COLOR} \
-cursor left_ptr -fg {#555555} -wrap word \
]
set more_details_scrollbar [ttk::scrollbar \
@@ -426,16 +451,16 @@ namespace eval SelectMCU {
# Cretate XDATA and XCODE scales and such
set details_right_top [ttk::labelframe $details_right.top \
- -text [mc "External RAM"] \
+ -text [mc "External RAM (XDATA)"] \
]
set details_right_bottom [ttk::labelframe $details_right.bottom \
- -text [mc "External Program Memory"] \
+ -text [mc "External ROM/FLASH (XCODE)"] \
]
- set details_xdata_note [label $details_right_top.not_avaliable \
- -text [mc "NOT AVALIABLE"] -fg {#FF8888} \
+ set details_xdata_note [label $details_right_top.not_available \
+ -text [mc "NOT available"] -fg {#FF8888} \
]
- set details_xdata_aval [frame $details_right_top.avaliable]
+ set details_xdata_aval [frame $details_right_top.available]
pack [checkbutton $details_xdata_aval.checkbutton \
-variable ::SelectMCU::xdata_ena \
-text [mc "Enable"] \
@@ -447,7 +472,7 @@ namespace eval SelectMCU {
set xdata_scale [ttk::scale $details_right_top_btm.scale \
-orient horizontal \
-variable ::SelectMCU::xdata_value \
- -from 0 -to 0xFFFF \
+ -from 0 -to 0x10000 \
-command "
set ::SelectMCU::xdata_value \[expr {int(\${::SelectMCU::xdata_value})}\]
$details_right_top_btm.spinbox selection range 0 end
@@ -456,22 +481,21 @@ namespace eval SelectMCU {
DynamicHelp::add $details_right_top_btm.scale \
-text [mc "Amount of external data memory"]
pack $xdata_scale -fill x -side left -expand 1 -padx 2
- set xdata_spinbox [spinbox $details_right_top_btm.spinbox \
- -textvariable ::SelectMCU::xdata_value \
- -width 5 -from 0 -to 0xFFFF \
- -bg white -validate all \
- -vcmd {::SelectMCU::validate_xdata %P} \
- -command "$details_right_top_btm.spinbox selection range 0 end ;#" \
+ set xdata_spinbox [ttk::spinbox $details_right_top_btm.spinbox \
+ -textvariable ::SelectMCU::xdata_value \
+ -width 5 -from 0 -to 0x10000 \
+ -validate all \
+ -validatecommand {::SelectMCU::validate_xdata %P} \
]
DynamicHelp::add $details_right_top_btm.spinbox \
-text [mc "Amount of external data memory"]
pack $xdata_spinbox -side right -after $details_right_top_btm.scale
pack $details_right_top_btm -fill both -expand 1
- set details_xcode_nota [label $details_right_bottom.not_avaliable \
- -text [mc "NOT AVALIABLE"] -fg {#FF8888} \
+ set details_xcode_nota [label $details_right_bottom.not_available \
+ -text [mc "NOT available"] -fg {#FF8888} \
]
- set details_xcode_aval [frame $details_right_bottom.avaliable]
+ set details_xcode_aval [frame $details_right_bottom.available]
pack [checkbutton $details_xcode_aval.checkbutton \
-variable ::SelectMCU::xcode_ena \
-text [mc "Enable"] \
@@ -483,7 +507,7 @@ namespace eval SelectMCU {
set xcode_scale [ttk::scale $details_right_bottom_btm.scale \
-orient horizontal \
-variable ::SelectMCU::xcode_value \
- -from 0 -to 0xFFFF \
+ -from 0 -to 0x10000 \
-command "
set ::SelectMCU::xcode_value \[expr {int(\${::SelectMCU::xcode_value})}\]
#" \
@@ -491,11 +515,11 @@ namespace eval SelectMCU {
DynamicHelp::add $details_right_bottom_btm.scale \
-text [mc "Amount of total program memory minus internal program memory"]
pack $xcode_scale -fill x -side left -expand 1 -padx 2
- set xcode_spinbox [spinbox $details_right_bottom_btm.spinbox \
- -textvariable ::SelectMCU::xcode_value \
- -width 5 -from 0 -to 0xFFFF \
- -bg white -validate all \
- -vcmd {::SelectMCU::validate_xcode %P} \
+ set xcode_spinbox [ttk::spinbox $details_right_bottom_btm.spinbox \
+ -textvariable ::SelectMCU::xcode_value \
+ -width 5 -from 0 -to 0x10000 \
+ -validate all \
+ -validatecommand {::SelectMCU::validate_xcode %P} \
]
DynamicHelp::add $details_right_bottom_btm.spinbox \
-text [mc "Amount of total program memory minus internal program memory"]
@@ -521,22 +545,22 @@ namespace eval SelectMCU {
-compound left \
-image ::ICONS::16::ok \
-command {::SelectMCU::close_window} \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command {::SelectMCU::cancel} \
- ] -side left
+ ] -side left -padx 2
pack [ttk::separator $win.sep -orient horizontal] -fill x
- pack $buttonFrame -side bottom -after $details_frame -anchor e -padx 10 -pady 5
+ pack $buttonFrame -side bottom -after $details_frame -anchor e -padx 5 -pady 5
}
## Close MCU selection dialog and force its return value to an empty string
# @return void
proc close_window {} {
variable definition_data ;# List: Values gained from $definition_file
- variable mcu_names ;# List: Avaliable processors
+ variable mcu_names ;# List: available processors
variable win ;# Widget: Dialog window
set definition_data {}
@@ -565,7 +589,7 @@ namespace eval SelectMCU {
# Open definition file
if {[catch {
set file [open $definition_file {r}]
- }]} {
+ }]} then {
tk_messageBox \
-parent $parent \
-type ok \
@@ -587,19 +611,19 @@ namespace eval SelectMCU {
if {$mcu_definition != {}} {
foreach val $mcu_definition {
if {$val == {}} {
- error "Incomplite definition for [lindex $mcu_definition 0]"
+ error "Incomplete definition for [lindex $mcu_definition 0]"
}
}
lappend definition_data $mcu_definition
}
- } result]} {
+ } result]} then {
set definition_data {}
tk_messageBox \
-parent $parent \
-icon warning \
-type ok \
-title [mc "Error"] \
- -message [mc "MCUs database file is currupted,\nplease check your installation"]
+ -message [mc "MCUs database file is corrupted (code:600),\nplease check your installation"]
puts stderr $result
close $file
return 0
@@ -613,7 +637,7 @@ namespace eval SelectMCU {
## Get list of MCUs defined in the database
# @return List - Defined processors (e.g. {8051 AT89C2051 ...})
- proc get_avaliable_processors {} {
+ proc get_available_processors {} {
variable definition_data ;# List: Values gained from $definition_file
variable definition_file ;# String: Path to MCUs definition file
variable expected ;# String: Expected next XML element
@@ -625,7 +649,7 @@ namespace eval SelectMCU {
# Open database file
if {[catch {
set file [open $definition_file {r}]
- }]} {
+ }]} then {
puts stderr "Unable to open file containing supported MCUs, please check your installation"
return {}
}
@@ -638,9 +662,9 @@ namespace eval SelectMCU {
# Start XML parser
if {[catch {
$parser parse [read $file]
- } result]} {
+ } result]} then {
set definition_data {}
- puts stderr "MCUs database file is currupted,\nplease check your installation"
+ puts stderr "MCUs database file is corrupted (code:641),\nplease check your installation"
puts stderr $result
}
@@ -671,7 +695,7 @@ namespace eval SelectMCU {
# Open database file
if {[catch {
set file [open $definition_file {r}]
- }]} {
+ }]} then {
puts stderr "Unable to open file containing supported MCUs, please check your installation"
return {}
}
@@ -685,9 +709,9 @@ namespace eval SelectMCU {
# Start XML parser
if {[catch {
$parser parse [read $file]
- } result]} {
+ } result]} then {
set definition_data {}
- puts stderr "MCUs database file is currupted,\nplease check your installation"
+ puts stderr "MCUs database file is corrupted (code:688),\nplease check your installation"
puts stderr $result
}
@@ -697,7 +721,7 @@ namespace eval SelectMCU {
return $definition_data
}
- ## XML parser handler for procedure get_avaliable_processors -- Takes XML tags
+ ## XML parser handler for procedure get_available_processors -- Takes XML tags
# @parm String arg1 - name of the element
# @parm List attrs - list of attributes '{attr0 val0 attr1 val1 ...}'
# @return void
@@ -705,7 +729,7 @@ namespace eval SelectMCU {
variable definition_data ;# List: Values gained from $definition_file
variable expected ;# String: Expected next XML element
- # Check for consistent formating
+ # Check for consistent formatting
if {$arg1 != $expected} {
error "Bad element `$arg1'"
}
@@ -763,19 +787,19 @@ namespace eval SelectMCU {
# Validate and store data
switch -- $current_element {
- {bits} { ;# Incomplite registers
+ {bits} { ;# Incomplete registers
if {![regexp {([0-9A-Fa-f]{4})?(\s+[0-9A-Fa-f]{4})*} $arg1]} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 18 $arg1
}
{writeonly} { ;# Write only registers
if {![regexp {([0-9A-Fa-f]{2})?(\s+[0-9A-Fa-f]{2})*} $arg1]} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 19 $arg1
}
- {sfr} { ;# Avaliable special function registers and bit addressable bits in SFR
+ {sfr} { ;# available special function registers and bit addressable bits in SFR
lset definition_data 43 $arg1
set mcu_definition {} ;# This is the last tag
@@ -843,8 +867,8 @@ namespace eval SelectMCU {
{code} {
incr i
set val [lindex $attrs $i]
- if {![string is digit -strict $val] || $val < 0 || $val > 0xFFFF} {
- error "MCUs database file currupted"
+ if {![string is digit -strict $val] || $val < 0 || $val > 0x10000} {
+ error "MCUs database file corrupted"
}
lset definition_data 2 $val
}
@@ -852,7 +876,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {![string is digit -strict $val] || $val < 0 || $val > 256} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 3 $val
}
@@ -860,7 +884,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {![string is digit -strict $val] || $val < 0 || $val > 256} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 4 $val
}
@@ -879,8 +903,8 @@ namespace eval SelectMCU {
{eram} {
incr i
set val [lindex $attrs $i]
- if {![string is digit -strict $val] || $val < 0 || $val > 0xFFFF} {
- error "MCUs database file currupted"
+ if {![string is digit -strict $val] || $val < 0 || $val > 0x10000} {
+ error "MCUs database file corrupted"
}
lset definition_data 8 $val
}
@@ -900,7 +924,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {$val != {} && ![regexp {^[01]{8}$} $val]} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 12 $val
}
@@ -908,7 +932,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {$val != {} && ![regexp {^[01]{8}$} $val]} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 13 $val
}
@@ -916,7 +940,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {$val != {} && ![regexp {^[01]{8}$} $val]} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 14 $val
}
@@ -924,7 +948,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {$val != {} && ![regexp {^[01]{8}$} $val]} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 15 $val
}
@@ -932,7 +956,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {$val != {} && ![regexp {^[01]{8}$} $val]} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 16 $val
}
@@ -992,7 +1016,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {![string is digit -strict $val]} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data 32 $val
}
@@ -1078,7 +1102,7 @@ namespace eval SelectMCU {
variable definition_data ;# List: Values gained from $definition_file
if {$value != {yes} && $value != {no}} {
- error "MCUs database file currupted"
+ error "MCUs database file corrupted"
}
lset definition_data $index $value
}
@@ -1093,7 +1117,7 @@ namespace eval SelectMCU {
variable current_element ;# String: Current XML element
variable take_data ;# Bool: Take element data on next parsing cycle
variable mcu_definition ;# List: Definition of MCU currently being parsed
- variable vendors ;# List: Avaliable MCU vendors
+ variable vendors ;# List: available MCU vendors
if {$arg1 != $expected} {
error "Bad element `$arg1'"
@@ -1107,7 +1131,7 @@ namespace eval SelectMCU {
if {$mcu_definition != {}} {
foreach val $mcu_definition {
if {$val == {}} {
- error "Incomplite definition for [lindex $mcu_definition 0]"
+ error "Incomplete definition for [lindex $mcu_definition 0]"
}
}
lappend definition_data $mcu_definition
@@ -1120,7 +1144,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {![string is alnum -strict $val]} {
- error "MCU name must match ^[\w\d]+$"
+ error "MCU name must match ^\[\w\d\]+$"
}
lset mcu_definition 0 $val
}
@@ -1176,7 +1200,7 @@ namespace eval SelectMCU {
incr i
set val [lindex $attrs $i]
if {$val != {yes} && $val != {no}} {
- error "Attribute UART must be eighter \"yes\" or \"no\""
+ error "Attribute UART must be either \"yes\" or \"no\""
}
lset mcu_definition 7 $val
}
@@ -1250,7 +1274,7 @@ namespace eval SelectMCU {
variable current_element ;# String: Current XML element
variable take_data ;# Bool: Take element data on next parsing cycle
variable mcu_definition ;# List: Definition of MCU currently being parsed
- variable vendors ;# List: Avaliable MCU vendors
+ variable vendors ;# List: available MCU vendors
if {!$take_data} {
return
@@ -1278,8 +1302,9 @@ namespace eval SelectMCU {
# @return void
proc select_item args {
variable definition_data ;# List: Values gained from $definition_file
+ variable local_definition_data ;# List: Basically the same as $definition_data but containing only the shown items
variable selected_mcu ;# List: Dialog return value {mcu_type xdata xcode}
- variable listbox_widget ;# Widget: List box containing avaliable MCUs
+ variable listbox_widget ;# Widget: List box containing available MCUs
variable value_lbl_uart ;# Widget: Label "UART:" - value
variable value_lbl_voltage ;# Widget: Label "Operating voltage:" - value
variable value_lbl_interrupts ;# Widget: Label "Interrupts:" - value
@@ -1287,17 +1312,17 @@ namespace eval SelectMCU {
variable value_lbl_vendor ;# Widget: Label "Vendor" - value
variable more_details_text ;# Widget: TextWidget "More details:"
variable details_xdata_aval ;# Widget: Frame containing scale and spinbox for XDATA memory
- variable details_xdata_note ;# Widget: Frame containing label "NOT AVALIABLE" for XDATA memory
+ variable details_xdata_note ;# Widget: Frame containing label "NOT available" for XDATA memory
variable details_xcode_aval ;# Widget: Frame containing scale and spinbox for XCODE memory
- variable details_xcode_nota ;# Widget: Frame containing label "NOT AVALIABLE" for XCODE memory
+ variable details_xcode_nota ;# Widget: Frame containing label "NOT available" for XCODE memory
variable name_label ;# Widget: Label containing name of selected MCU
variable image_label ;# Widget: Label with image for selected MCU
variable xcode_spinbox ;# Widget: SpinBox for XCODE memory
variable xcode_scale ;# Widget: Scale for XCODE memory
- variable maximum_xcode ;# Int: Maximum external program memory (0xFFFF - internal)
+ variable maximum_xcode ;# Int: Maximum external program memory (0x10000 - internal)
# Get MCU definition for the selected processor
- set mcu [lindex $definition_data \
+ set mcu [lindex $local_definition_data \
[$listbox_widget index [$listbox_widget selection get]] \
]
set mcu_name [lindex $mcu 0]
@@ -1305,7 +1330,7 @@ namespace eval SelectMCU {
return
}
set selected_mcu $mcu_name
- set maximum_xcode [expr {0xFFFF - ([lindex $mcu 3] * 1024)}]
+ set maximum_xcode [expr {0x10000 - ([lindex $mcu 3] * 1024)}]
# Configure detail labels
$name_label configure -text $mcu_name
@@ -1331,7 +1356,7 @@ namespace eval SelectMCU {
pack forget $details_xdata_aval
}
pack $details_xdata_note -fill both -expand 1
- } {
+ } else {
if {[winfo ismapped $details_xdata_note]} {
pack forget $details_xdata_note
}
@@ -1343,7 +1368,7 @@ namespace eval SelectMCU {
pack forget $details_xcode_aval
}
pack $details_xcode_nota -fill both -expand 1
- } {
+ } else {
$xcode_spinbox configure -to $maximum_xcode
$xcode_scale configure -to $maximum_xcode
if {[winfo ismapped $details_xcode_nota]} {
@@ -1369,9 +1394,9 @@ namespace eval SelectMCU {
update
if {[catch {
$image_label configure -text { } -image [image create photo \
- -format png -file "${::LIB_DIRNAME}/../icons/mcu/$mcu_name.png"
+ -format png -file "${::ROOT_DIRNAME}/icons/mcu/$mcu_name.png"
]
- }]} {
+ }]} then {
$image_label configure \
-fg {#DD0000} \
-text [mc " Image not found"] \
@@ -1394,7 +1419,7 @@ namespace eval SelectMCU {
pack forget $more_details_scrollbar
}
# Show scrollbar
- } {
+ } else {
if {![winfo ismapped $more_details_scrollbar]} {
pack $more_details_scrollbar \
-side right -fill y \
@@ -1411,7 +1436,7 @@ namespace eval SelectMCU {
$search_bar delete 0 end
}
- ## Search for the give string in the listbox of avaliable processors
+ ## Search for the give string in the listbox of available processors
# Primary purpose is validator for search entry box, it also
#+ ajusts search entry box background color
# @parm String string - Part of MCU name
@@ -1419,8 +1444,8 @@ namespace eval SelectMCU {
proc search {string} {
variable search_bar ;# Widget: Search bar entry box
variable search_bar_clear ;# Widget: Search bar clear button
- variable listbox_widget ;# Widget: List box containing avaliable MCUs
- variable mcu_names ;# List: Avaliable processors
+ variable listbox_widget ;# Widget: List box containing available MCUs
+ variable mcu_names ;# List: Available processors (and show in the list)
# Search for empty string -> abort
if {![string length $string]} {
@@ -1468,7 +1493,7 @@ namespace eval SelectMCU {
if {${::SelectMCU::xdata_ena}} {
$xdata_scale state !disabled
$xdata_spinbox configure -state normal
- } {
+ } else {
$xdata_scale state disabled
$xdata_spinbox configure -state disabled
}
@@ -1483,7 +1508,7 @@ namespace eval SelectMCU {
if {${::SelectMCU::xcode_ena}} {
$xcode_scale state !disabled
$xcode_spinbox configure -state normal
- } {
+ } else {
$xcode_scale state disabled
$xcode_spinbox configure -state disabled
}
@@ -1499,7 +1524,7 @@ namespace eval SelectMCU {
if {$string == {}} {
return 1
}
- if {$string < 0 || $string > 0xFFFF} {
+ if {$string < 0 || $string > 0x10000} {
return 0
}
@@ -1510,7 +1535,7 @@ namespace eval SelectMCU {
# @parm String string - String to validate
# @return Bool - Validation result
proc validate_xcode {string} {
- variable maximum_xcode ;# Int: Maximum external program memory (0xFFFF - internal)
+ variable maximum_xcode ;# Int: Maximum external program memory (0x10000 - internal)
if {![string is digit $string]} {
return 0
@@ -1528,10 +1553,14 @@ namespace eval SelectMCU {
## This functionshould be changecmd for vendor comboBox
# @return void
proc change_vendor {} {
- variable listbox_widget ;# Widget: List box containing avaliable MCUs
+ variable listbox_widget ;# Widget: List box containing available MCUs
clear_search_bar
$listbox_widget delete [$listbox_widget items]
fill_gui
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/dialogs/tips.tcl b/lib/dialogues/tips.tcl
index 1c8b988..d2df211 100755..100644
--- a/lib/dialogs/tips.tcl
+++ b/lib/dialogues/tips.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,13 +21,18 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _TIPS_TCL ] } {
+set _TIPS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# Provides facility to show tips on startup
+# Provides facility to show tips on start-up
# * Tips are readed from file deindef in NS variable "tips_file"
# * Format of definition file is XML and it supports mutiple languages
# * Usage is simple: execute procedure "::Tips::show_tip_of_the_day_win"
-# * It requires NS ConfigDialogs (see ${::GLOBAL_CONFIG(tips)})
+# * It requires NS ConfigDialogues (see ${::GLOBAL_CONFIG(tips)})
# --------------------------------------------------------------------------
namespace eval Tips {
@@ -36,20 +41,20 @@ namespace eval Tips {
variable tip_of_the_day_show_again ;# Bool: Show "Tip of the day"
variable tips_data ;# List containing tips data
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable current_tip ;# Number of the currently displayed tip
variable expected ;# Expeceted element
variable take_data ;# Bool: Append data section to $tips_data
# File containing tips data
- variable tips_file "${::LIB_DIRNAME}/../data/tips.xml"
+ variable tips_file "${::INSTALLATION_DIR}/data/tips.xml"
- ## Invoke dialog "Tip on startup"
+ ## Invoke dialog "Tip on start-up"
# @return void
proc show_tip_of_the_day_win {} {
variable tip_of_the_day_win ;# ID of window "Tip of the day"
variable tip_of_the_day_text ;# ID of text widget in "Tip of the day"
variable tip_of_the_day_show_again ;# Bool: Show "Tip of the day"
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable tip_of_the_day_show_again ;# Bool: Show "Tip of the day"
# Set value of checkbox "Show again"
@@ -58,16 +63,16 @@ namespace eval Tips {
load_tips_file
# Create toplevel window
- set win [toplevel .tip_of_the_day -class {Tip of the day} -bg {#EEEEEE}]
+ set win [toplevel .tip_of_the_day -class {Tip of the day} -bg ${::COMMON_BG_COLOR}]
set tip_of_the_day_win $win
# Create window header
pack [label $win.header \
-text [mc "Did you know ... "] \
- -font [font create \
- -family {times} \
- -size -25 \
- -weight bold \
+ -font [font create \
+ -family {times} \
+ -size [expr {int(-25 * $::font_size_factor)}] \
+ -weight bold \
] \
-compound right \
-image ::ICONS::32::help \
@@ -75,14 +80,14 @@ namespace eval Tips {
# Create middle frame (text windget and scrollbar)
set middle_frame [frame $win.middle_frame]
- set text [text $middle_frame.text \
- -width 0 -height 0 -bg white \
- -wrap word \
- -yscrollcommand "$middle_frame.scrollbar set" \
- -font [font create \
- -family {helvetica} \
- -size -17 \
- -weight normal \
+ set text [text $middle_frame.text \
+ -width 0 -height 0 -bg white \
+ -wrap word \
+ -yscrollcommand "$middle_frame.scrollbar set" \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight normal \
] \
]
pack $text -side left -fill both -expand 1
@@ -94,11 +99,11 @@ namespace eval Tips {
## Create bottom frame
set bottom_frame [frame $win.bottom_frame]
- # - CheckButton "Show tips on startup"
+ # - CheckButton "Show tips on start-up"
pack [checkbutton $bottom_frame.chbutton \
-variable ::Tips::tip_of_the_day_show_again \
-command {::Tips::tip_otd_show_again} \
- -text [mc "Show tips on startup"] \
+ -text [mc "Show tips on start-up"] \
] -side left -anchor e
# - Button "Close"
pack [ttk::button $bottom_frame.close_but \
@@ -107,7 +112,7 @@ namespace eval Tips {
-image ::ICONS::16::button_cancel \
-command {::Tips::tip_otd_CLOSE} \
-width 8 \
- ] -side right -anchor w
+ ] -side right -anchor w -padx 2
# - Button "Next"
pack [ttk::button $bottom_frame.next_but \
-compound left \
@@ -115,7 +120,7 @@ namespace eval Tips {
-image ::ICONS::16::right \
-command {::Tips::tip_otd_NEXT} \
-width 8 \
- ] -side right -anchor w
+ ] -side right -anchor w -padx 2
# - Button "Previous"
pack [ttk::button $bottom_frame.prev_but \
-compound left \
@@ -123,18 +128,27 @@ namespace eval Tips {
-image ::ICONS::16::left \
-command {::Tips::tip_otd_PREV} \
-width 8 \
- ] -side right -anchor w
+ ] -side right -anchor w -padx 2
# Pack window frames
pack $middle_frame -side top -fill both -expand 1 -padx 10 -pady 5
pack $bottom_frame -side bottom -fill x -after $middle_frame -padx 10 -pady 5
# Configure text tags
- $text tag configure tag_bold -font [font create \
- -family {helvetica} \
- -size -17 \
- -weight bold \
+ $text tag configure tag_bold -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
]
+ # Configure text tags
+ $text tag configure tag_code -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight normal \
+ ] -foreground {#DD8800}
+
+ # Create tag for external hyperlinks
+ create_link_tag_in_text_widget $text
# Determinate random number of tip to show
expr {srand([clock seconds])}
@@ -158,7 +172,7 @@ namespace eval Tips {
# @return void
proc load_tips_file {} {
variable tips_data ;# List containing tips data
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable tips_file ;# File containing tips data
variable expected ;# Expeceted element
variable take_data ;# Bool: Append data section to $tips_data
@@ -172,7 +186,7 @@ namespace eval Tips {
# Open file
if {[catch {
set file [open $tips_file {r}]
- }]} {
+ }]} then {
tk_messageBox \
-parent . \
-type ok \
@@ -191,7 +205,7 @@ namespace eval Tips {
# Start XML parser
if {[catch {
$parser parse [read $file]
- } result]} {
+ } result]} then {
set number_of_tips 0
set tips_data {}
tk_messageBox \
@@ -214,7 +228,7 @@ namespace eval Tips {
# @return void
proc xml_data_parser_data {arg1} {
variable tips_data ;# List containing tips data
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable current_tip ;# Number of the currently displayed tip
variable expected ;# Expeceted element
variable take_data ;# Bool: Append data section to $tips_data
@@ -237,7 +251,7 @@ namespace eval Tips {
# @return void
proc xml_data_parser_element {arg1 attrs} {
variable tips_data ;# List containing tips data
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable current_tip ;# Number of the currently displayed tip
variable expected ;# Expeceted element
variable take_data ;# Bool: Append data section to $tips_data
@@ -257,13 +271,11 @@ namespace eval Tips {
}
incr i
- ## Take data if ...
- # No translation has been loaded and current text is in English
- if {!${::TRANSLATION_LOADED} || [lindex $attrs $i] == {en}} {
- set take_data 1
- # Or if some translation has been loaded and it conforms with the text
- } elseif {[lindex $attrs $i] == ${::GLOBAL_CONFIG(language)}} {
+ # Take data only if some translation has been loaded and it conforms with the text
+ if {[string tolower [lindex $attrs $i]] == [string tolower ${::GLOBAL_CONFIG(language)}]} {
set take_data 1
+ } else {
+ set take_data 0
}
}
}
@@ -272,7 +284,7 @@ namespace eval Tips {
# @return void
proc tip_otd_CLOSE {} {
variable tips_data ;# List containing tips data
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable current_tip ;# Number of the currently displayed tip
variable tip_of_the_day_win ;# ID of window "Tip of the day"
@@ -291,7 +303,7 @@ namespace eval Tips {
# @return void
proc display_tip {tip_number} {
variable tips_data ;# List containing tips data
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable current_tip ;# Number of the currently displayed tip
variable tip_of_the_day_text ;# ID of text widget in "Tip of the day"
@@ -311,23 +323,28 @@ namespace eval Tips {
incr current_tip -1
}
- # Create map of bold font tags
- set bold_tag_map {}
+ # Create map of bold and code font tags
+ set bold_tag_map [list]
+ set code_tag_map [list]
set content [lindex $tips_data $current_tip]
- while 1 {
- set tag_pair {}
-
- set idx [string first {<b>} $content]
- if {$idx == -1} {break}
- regsub {<b>} $content {} content
- lappend tag_pair $idx
-
- set idx [string first {</b>} $content]
- if {$idx == -1} {break}
- regsub {</b>} $content {} content
- lappend tag_pair $idx
-
- lappend bold_tag_map $tag_pair
+ foreach map {bold_tag_map code_tag_map} \
+ tag {b c} \
+ {
+ while {1} {
+ set tag_pair {}
+
+ set idx [string first "<$tag>" $content]
+ if {$idx == -1} {break}
+ regsub "<$tag>" $content {} content
+ lappend tag_pair $idx
+
+ set idx [string first "</$tag>" $content]
+ if {$idx == -1} {break}
+ regsub "</$tag>" $content {} content
+ lappend tag_pair $idx
+
+ lappend $map $tag_pair
+ }
}
# Fill text widget
@@ -336,13 +353,19 @@ namespace eval Tips {
foreach pair $bold_tag_map {
$tip_of_the_day_text tag add tag_bold $start+[lindex $pair 0]c $start+[lindex $pair 1]c
}
+ foreach pair $code_tag_map {
+ $tip_of_the_day_text tag add tag_code $start+[lindex $pair 0]c $start+[lindex $pair 1]c
+ }
$tip_of_the_day_text configure -state disabled
+
+ # Detect external hyperlinks and make the functional
+ convert_all_https_to_links $tip_of_the_day_text
}
## Show next tip
# @return void
proc tip_otd_NEXT {} {
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable current_tip ;# Number of the currently displayed tip
incr current_tip
@@ -355,7 +378,7 @@ namespace eval Tips {
## Show previous tip
# @return void
proc tip_otd_PREV {} {
- variable number_of_tips ;# Number of tips avaliable
+ variable number_of_tips ;# Number of tips available
variable current_tip ;# Number of the currently displayed tip
incr current_tip -1
@@ -370,6 +393,10 @@ namespace eval Tips {
proc tip_otd_show_again {} {
variable tip_of_the_day_show_again ;# Bool: Show "Tip of the day"
- ::configDialogs::global::set_variable tips $tip_of_the_day_show_again
+ ::configDialogues::global::set_variable tips $tip_of_the_day_show_again
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/ASMsyntaxhighlight.tcl b/lib/editor/ASMsyntaxhighlight.tcl
index fe364d5..1486201 100755..100644
--- a/lib/editor/ASMsyntaxhighlight.tcl
+++ b/lib/editor/ASMsyntaxhighlight.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 _ASMSYNTAXHIGHLIGHT_TCL ] } {
+set _ASMSYNTAXHIGHLIGHT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements syntax highlighting interface for assembly language
@@ -31,7 +36,7 @@ namespace eval ASMsyntaxHighlight {
# {
# {tag_name ?foreground? ?overstrike? ?italic? ?bold?}
# }
- variable hightlight_tags {
+ variable highlight_tags {
{tag_char #880066 0 0 0}
{tag_hex #8800BB 0 0 0}
{tag_oct #880000 0 0 0}
@@ -94,9 +99,9 @@ namespace eval ASMsyntaxHighlight {
# directives with argument(s) but without any label
variable directive_type1 {
- DSEG ISEG BSEG XSEG CSEG SKIP NAME
+ DSEG ISEG BSEG XSEG CSEG SKIP NAME LOCAL
}
- # directives for constants definitions
+ # directives for symbol definitions
variable directive_type2 {
EQU BIT SET CODE DATA IDATA XDATA MACRO FLAG
}
@@ -115,7 +120,7 @@ namespace eval ASMsyntaxHighlight {
variable expr_symbols {
= + - * / > < %
}
-
+
# control sequencies without any argument
variable controls_type0 {
NOLIST NOMOD NOOBJECT NOPAGING NOPRINT
@@ -185,26 +190,22 @@ namespace eval ASMsyntaxHighlight {
variable validation_L1 1 ;# Bool: Advancet validation enabled
## Define highlighting text tags in the given text widget
- # @parm Widget - ID of the target text widget
- # @parm Int - font size
- # @parm String - font family
- # @parm List = default - Highlighting tags definition
+ # @parm Widget text_widget - ID of the target text widget
+ # @parm Int fontSize - font size
+ # @parm String fontFamily - font family
+ # @parm List highlight=default - Highlighting tags definition
+ # @parm Bool nobold=0 - Ignore bold flag
# @return void
- proc create_tags args {
- variable hightlight_tags ;# Highlight tags definition
+ proc create_tags {text_widget fontSize fontFamily {highlight {}} {nobold 0}} {
+ variable highlight_tags ;# Highlight tags definition
# Handle arguments
- set text_widget [lindex $args 0] ;# text widget
- set fontSize [lindex $args 1] ;# font size
- set fontFamily [lindex $args 2] ;# font family
- if {[llength $args] > 3} { ;# highlighting definition
- set hightlight [lindex $args 3]
- } {
- set hightlight $hightlight_tags
+ if {$highlight == {}} { ;# highlighting definition
+ set highlight $highlight_tags
}
# Iterate over highlighting tags definition
- foreach item $hightlight {
+ foreach item $highlight {
# Create array of tag attributes
for {set i 0} {$i < 5} {incr i} {
set tag($i) [lindex $item $i]
@@ -217,13 +218,13 @@ namespace eval ASMsyntaxHighlight {
# Fonr slant
if {$tag(3) == 1} {
set tag(3) italic
- } {
+ } else {
set tag(3) roman
}
# Font weight
- if {$tag(4) == 1} {
+ if {$tag(4) == 1 && !$nobold} {
set tag(4) bold
- } {
+ } else {
set tag(4) normal
}
@@ -253,13 +254,13 @@ namespace eval ASMsyntaxHighlight {
}
## Perform syntax highlight on the given line in the given widget
- # @parm Widget Editor - Text widget
- # @parm Int LineNumber - Number of line to highlight
- # @parm Bool inline_asm - Inline assembler
- # @parm Int boundary_0 = 0 - Start index
- # @parm Int boundary_1 = end - End index
+ # @parm Widget p_editor - Text widget
+ # @parm Int linenumber - Number of line to highlight
+ # @parm Bool inlineasm - Inline assembler
+ # @parm Int linestart=0 - Start index
+ # @parm Int lineend=end - End index
# @return Bool - result
- proc highlight args {
+ proc highlight {p_editor linenumber {inlineasm 0} {linestart {}} {lineend {}}} {
variable editor ;# ID of the text widget
variable lineNumber ;# Number of current line
variable lineStart ;# Index of line start
@@ -282,27 +283,22 @@ namespace eval ASMsyntaxHighlight {
variable validation_L0 ;# Bool: Basic validation enabled
# Parse input arguments
- set editor [lindex $args 0]
- set lineNumber [lindex $args 1]
- set inline_asm [lindex $args 2]
- set lineStart [lindex $args 3]
- set lineEnd [lindex $args 4]
- if {$inline_asm == {}} {
- set inline_asm 0
- }
- if {$lineStart == {}} {
+ set editor $p_editor
+ set lineNumber $linenumber
+ set inline_asm $inlineasm
+ if {$linestart == {}} {
set lineStart $lineNumber.0
- } {
- set lineStart $lineNumber.$lineStart
+ } else {
+ set lineStart $lineNumber.$linestart
}
- if {$lineEnd == {}} {
- set lineEnd [$editor index "$lineStart lineend"]
- } {
+ if {$lineend == {}} {
+ set lineEnd [$editor index [list $lineStart lineend]]
+ } else {
set lineEnd $lineNumber.$lineEnd
}
- if {[lindex $args 3] != {}} {
- set start_offset [lindex $args 3]
- } {
+ if {$linestart != {}} {
+ set start_offset $linestart
+ } else {
set start_offset 0
}
@@ -339,7 +335,7 @@ namespace eval ASMsyntaxHighlight {
if {$comment_start == 0} {
set data {}
delete_tags
- } {
+ } else {
set data [string range $data 0 [expr {$comment_start - 1}]]
regsub {\s+$} $data {} data
}
@@ -358,7 +354,13 @@ namespace eval ASMsyntaxHighlight {
}
# Determinate 1st segment of the line
- regexp {^\s*[^\s:\(]+:?} $data seg_0
+ regexp {^\s*[^\s]+:?} $data seg_0
+ if {[regexp {\w\(} $seg_0]} {
+ regsub {\(.*$} $seg_0 {} seg_0
+ }
+ if {[string last {:} $seg_0] != -1} {
+ set seg_0 [string range $seg_0 0 [string last {:} $seg_0]]
+ }
set seg_0_end [string length $seg_0]
regsub {^\s+} $seg_0 {} seg_0
@@ -415,7 +417,7 @@ namespace eval ASMsyntaxHighlight {
if {![string length $seg_2]} {
put_error_on_segment 1
}
-
+
set seg_1 [string tolower $seg_1]
if {$seg_1 == {db} || $seg_1 == {.db} || $seg_1 == {byte} || $seg_1 == {.byte}} {
parse_operands
@@ -423,7 +425,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_string \
$lineNumber.$seg_2_start \
[list $lineNumber.0 lineend]
- } {
+ } else {
parse_expressions
}
}
@@ -444,7 +446,7 @@ namespace eval ASMsyntaxHighlight {
if {
$validation_L0 &&
([regexp {^\d} $seg_1] || ![regexp {^\w+$} $seg_1])
- } {
+ } then {
put_error_on_segment 1
}
determinate_segment_2
@@ -464,7 +466,7 @@ namespace eval ASMsyntaxHighlight {
if {![string length $seg_2]} {
put_error_on_segment 0
}
-
+
set seg_0 [string tolower $seg_0]
if {$seg_0 == {db} || $seg_0 == {.db} || $seg_0 == {byte} || $seg_0 == {.byte}} {
parse_operands
@@ -472,7 +474,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_string \
$lineNumber.$seg_2_start \
[list $lineNumber.0 lineend]
- } {
+ } else {
parse_expressions
}
}
@@ -494,6 +496,7 @@ namespace eval ASMsyntaxHighlight {
{unknown} {
determinate_segment_1
set seg_1_info [parse_segment $seg_1_start $seg_1_end $seg_1]
+
switch -- [lindex $seg_1_info 0] {
{control_0} {
determinate_segment_2
@@ -521,7 +524,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_string \
$lineNumber.$seg_2_start \
[list $lineNumber.0 lineend]
- } {
+ } else {
parse_expressions
}
}
@@ -529,7 +532,7 @@ namespace eval ASMsyntaxHighlight {
if {
$validation_L0 &&
([regexp {^\d} $seg_0] || ![regexp {^\w+$} $seg_0])
- } {
+ } then {
put_error_on_segment 0
}
@@ -540,7 +543,7 @@ namespace eval ASMsyntaxHighlight {
$lineNumber.$seg_0_end
determinate_segment_2
parse_arguments
- } {
+ } else {
$editor tag add tag_constant_def \
$lineNumber.$seg_0_start \
$lineNumber.$seg_0_end
@@ -561,11 +564,12 @@ namespace eval ASMsyntaxHighlight {
}
{unknown} {
$editor tag add tag_macro $lineNumber.$seg_0_start $lineNumber.$seg_0_end
+
if {
$validation_L0 &&
([regexp {^\d} $seg_0] || ![regexp {^\w+$} $seg_0])
- } {
- put_error_on_segment 0
+ } then {
+ put_error_on_segment 0
}
determinate_segment_1_take_back
determinate_segment_2
@@ -576,7 +580,7 @@ namespace eval ASMsyntaxHighlight {
if {
$validation_L0 &&
([regexp {^\d} $seg_0] || ![regexp {^\w+$} $seg_0])
- } {
+ } then {
put_error_on_segment 0
}
}
@@ -592,7 +596,7 @@ namespace eval ASMsyntaxHighlight {
# @return void
proc delete_tags {} {
variable editor ;# ID of the text widget
- variable hightlight_tags ;# Highlight tags definition
+ variable highlight_tags ;# Highlight tags definition
variable lineStart ;# Index of line start
variable lineEnd ;# Index of line end
@@ -603,8 +607,8 @@ namespace eval ASMsyntaxHighlight {
$editor tag remove $tag $lineStart_truestart $lineStart_truestart+1l
}
- # Remove tags acording to pattern
- foreach tag $hightlight_tags {
+ # Remove tags according to pattern
+ foreach tag $highlight_tags {
$editor tag remove [lindex $tag 0] $lineStart_truestart $lineEnd
}
}
@@ -633,13 +637,14 @@ namespace eval ASMsyntaxHighlight {
variable last_index_backup ;# Auxiliary variable (some index)
# Line is empty
- if {![regexp {^\s*[^\s\(]+} $data seg_1]} {
+ # if {![regexp {^\s*[^\s\(]+} $data seg_1]}
+ if {![regexp {^\s*[^\s]+} $data seg_1]} {
set seg_1 {}
set seg_1_end $last_index
set seg_1_start $last_index
# Line is not empty
- } {
+ } else {
set data_backup $data
set last_index_backup $last_index
@@ -692,16 +697,17 @@ namespace eval ASMsyntaxHighlight {
# @parm String segment_data - content of segment to parse
# @return List - {segment_type expression_length} or {segment_type {}} or {{} {}}
proc parse_segment {start end segment_data} {
- variable controls_type0 ;# control sequencies without any argument
- variable controls_type1 ;# control sequencies with exactly 1 argument
+ variable controls_type0 ;# control sequencies without any argument
+ variable controls_type1 ;# control sequencies with exactly 1 argument
- variable keyword_lists ;# list of all reserved keywords
- variable editor ;# ID of the text widget
- variable lineNumber ;# Number of current line
- variable lineStart ;# Index of line start
- variable lineEnd ;# Index of line end
- variable data ;# Content of the line
- variable validation_L0 ;# Bool: Basic validation enabled
+ variable keyword_lists ;# list of all reserved keywords
+ variable editor ;# ID of the text widget
+ variable lineNumber ;# Number of current line
+ variable lineStart ;# Index of line start
+ variable lineEnd ;# Index of line end
+ variable data ;# Content of the line
+ variable validation_L0 ;# Bool: Basic validation enabled
+ variable inline_asm ;# Bool: Is inline assembler
# Local variables
set seg_type {} ;# segment type
@@ -729,7 +735,7 @@ namespace eval ASMsyntaxHighlight {
set seg_type $type
break
}
- } {
+ } else {
if {[lsearch -ascii -exact $keyword_list $segment_data] != -1} {
$editor tag add $tag $lineNumber.$start $lineNumber.$end
set seg_type $type
@@ -740,7 +746,6 @@ namespace eval ASMsyntaxHighlight {
# If segment type could not be recognized -> check for labels, macro's and controls
if {$seg_type == {}} {
-
# Handle compiler control sequences
if {[string index $segment_data 0] == {$}} {
set segment_data [string range $segment_data 1 end]
@@ -789,12 +794,22 @@ namespace eval ASMsyntaxHighlight {
}
# Labels
- } elseif {[regexp -nocase {^\w+:$} $segment_data]} {
+ } elseif {[regexp -nocase {^[^\s]*:$} $segment_data]} {
$editor tag add tag_label $lineNumber.$start $lineNumber.$end
set seg_type label
+ if {$inline_asm} {
+ if {![regexp -nocase {^\w+\$:$} $segment_data]} {
+ $editor tag add tag_error $lineNumber.$start $lineNumber.$end
+ }
+ } else {
+ if {![regexp -nocase {^[a-zA-Z]\w*:$} $segment_data]} {
+ $editor tag add tag_error $lineNumber.$start $lineNumber.$end
+ }
+ }
+
# Unknown type - possibly macro instruction
- } {
+ } else {
set seg_type unknown
}
}
@@ -817,9 +832,9 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_symbol $lineNumber.$start_index $lineNumber.[expr {$start_index + 1}]
set end [expr {$end_index - 1}]
$editor tag add tag_symbol $lineNumber.$end $lineNumber.$end_index
-
+
$editor tag add tag_string $lineNumber.[expr {$start_index + 1}] $lineNumber.$end
- } {
+ } else {
if {$validation_L0} {
$editor tag add tag_error \
$lineNumber.$control_start $lineNumber.$control_end
@@ -840,7 +855,7 @@ namespace eval ASMsyntaxHighlight {
variable seg_0_end ;# End index of seg_0
variable seg_1_end ;# End index of seg_1
variable seg_2_end ;# End index of seg_2
-
+
if {!$validation_L0} {
return
}
@@ -876,9 +891,9 @@ namespace eval ASMsyntaxHighlight {
if {[regexp {^\s*$} $seg_2]} {return 0}
- while 1 {
+ while {1} {
# Handle redutant commas
- while 1 {
+ while {1} {
if {![regexp {^\s*\,} $seg_2]} {break}
set space_len 0
@@ -964,9 +979,9 @@ namespace eval ASMsyntaxHighlight {
set original_data $seg_2
set data [hide_strings $seg_2]
- while 1 {
+ while {1} {
# Handle redutant commas
- while 1 {
+ while {1} {
if {![regexp {^\s*\,} $data]} {break}
set space_len 0
@@ -1003,7 +1018,7 @@ namespace eval ASMsyntaxHighlight {
set space_len [string length $space]
set opr_start [expr {$last_index + $space_len}]
set operand [string range $operand $space_len end]
- } {
+ } else {
set opr_start $last_index
}
@@ -1012,7 +1027,7 @@ namespace eval ASMsyntaxHighlight {
set space_len [string length $space]
set opr_end [expr {$operand_len - $space_len}]
set operand [string range $operand 0 $opr_end]
- } {
+ } else {
set opr_end $operand_len
}
incr opr_end $last_index
@@ -1058,7 +1073,7 @@ namespace eval ASMsyntaxHighlight {
default {
if {[lsearch -ascii -exact {R0 R1 R2 R3 R4 R5 R6 R7 DPTR A AB C} $opr] != -1} {
lappend opr_types $opr
- } {
+ } else {
lappend opr_types {D}
}
}
@@ -1091,14 +1106,14 @@ namespace eval ASMsyntaxHighlight {
if {$validation_L0 && $len < 3} {
put_tag_on_operand tag_error
}
- if {$len > 3} {
+ if {$len > 3 && [string index $operand 1] != "\\"} {
put_tag_on_operand tag_string
- } {
+ } else {
put_tag_on_operand tag_imm_char
}
# Label in inline assembler
- } elseif {[regexp {^\d+\$$} $operand]} {
+ } elseif {[regexp {^\w+\$$} $operand]} {
put_tag_on_operand tag_imm_constant
# Operand has no value => incorrect operand
@@ -1108,10 +1123,10 @@ namespace eval ASMsyntaxHighlight {
$lineNumber.$opr_start $lineNumber.$opr_start+1c
} elseif {
- $validation_L0 &&
- ([string length $operand] == 0 || ![regexp {^[\w\$\.\\]+$} $operand])
- } {
- put_tag_on_operand tag_error
+ $validation_L0 &&
+ ([string length $operand] == 0 || ![regexp {^(\?\?)?[\w\$\.\\]+$} $operand])
+ } then {
+ put_tag_on_operand tag_error
# Operand value determinated successfully
} else {
@@ -1136,7 +1151,7 @@ namespace eval ASMsyntaxHighlight {
$operand != {DPTR} &&
$operand != {A+PC} &&
$operand != {A+DPTR}
- } {
+ } then {
put_tag_on_operand tag_error
}
@@ -1150,12 +1165,11 @@ namespace eval ASMsyntaxHighlight {
$lineNumber.$opr_start $lineNumber.$opr_start+1c
} elseif {
- $validation_L0 &&
- ([string length $operand] == 0 || ![regexp {^'?[\w\.]+'?$} $operand])
- } {
-
- # Operand has no value => incorrect operand
- put_tag_on_operand tag_error
+ $validation_L0 &&
+ ([string length $operand] == 0 || ![regexp {^'?[\w\.]+'?$} $operand])
+ } then {
+ # Operand has no value => incorrect operand
+ put_tag_on_operand tag_error
} else {
parse_operand_auxiliary $spec_bits {
@@ -1187,7 +1201,7 @@ namespace eval ASMsyntaxHighlight {
put_tag_on_operand tag_sfr
# Something else than SFR
- } {
+ } else {
parse_operand_auxiliary2 $tag_list
}
}
@@ -1206,9 +1220,9 @@ namespace eval ASMsyntaxHighlight {
variable inline_asm ;# Is inline assembler
# Label in inline assembler
- if {$inline_asm && [regexp {^\d+\$$} $operand]} {
+ if {$inline_asm && [regexp {^\w+\$$} $operand]} {
put_tag_on_operand [lindex $tag_list 6]
-
+
# Expression
} elseif {[regexp {\(|\)|\+|\-|\%|\=|\>|\<|\*|\/} $operand]} {
parse_expression $operand $opr_start $opr_end
@@ -1248,14 +1262,14 @@ namespace eval ASMsyntaxHighlight {
}
# Radix determinated correctly - continue normaly
- } {
+ } else {
# check for allowed operand value range
if {$validation_L0 && $opr_in_dec == {error}} {
## Operand value is invalid => incorrect operand
put_tag_on_operand tag_error
- } {
+ } else {
if {$validation_L0 && ($opr_in_dec > 65535 || $opr_in_dec < 0)} {
## Operand value is out of range => incorrect operand
@@ -1263,7 +1277,7 @@ namespace eval ASMsyntaxHighlight {
}
}
- # highlight acording to numeric base
+ # highlight according to numeric base
switch -- $opr_base {
{hex} {put_tag_on_operand [lindex $tag_list 1]}
{dec} {put_tag_on_operand [lindex $tag_list 2]}
@@ -1274,13 +1288,13 @@ namespace eval ASMsyntaxHighlight {
}
}
- # defined by a symbolic name
- } {
+ # Defined as a symbolic name
+ } else {
put_tag_on_operand [lindex $tag_list 6]
if {
- $validation_L0 && ($operand != {$}) && ![regexp {^\w+$} $operand]
- } {
- put_tag_on_operand tag_error
+ $validation_L0 && ($operand != {$}) && ![regexp {^(\?\?)?\w+$} $operand]
+ } then {
+ put_tag_on_operand tag_error
}
}
}
@@ -1302,6 +1316,18 @@ namespace eval ASMsyntaxHighlight {
# @parm String number - number to analyze
# @return List - {base decimal_value} or {base "error"}
proc which_radix {norange number} {
+ # Handle prefix notation for hexadecimal numbers, like 0xfa
+ if {
+ [string index $number 0] == {0}
+ &&
+ ([string index $number 1] == {x} || [string index $number 1] == {X})
+ &&
+ [string is xdigit [string index $number 2]]
+ } then {
+ set number [string replace $number 0 1]
+ append number {h}
+ }
+
set original_len [string length $number]
set len [string length [string trimleft $number {0}]]
if {$original_len > 1 && $len == 1} {
@@ -1318,12 +1344,12 @@ namespace eval ASMsyntaxHighlight {
if {[string index $number 0] == {'}} {
set number [string range $number 1 end]
- set base ascii
- if {[string length $number] == 1} {
+ set base {ascii}
+ if {[string length $number] == 1 || [string index $number 0] == "\\"} {
set dec_val 0
} elseif {[string length $number] > 1} {
- set base string
+ set base {string}
set dec_val 0
}
}
@@ -1358,7 +1384,7 @@ namespace eval ASMsyntaxHighlight {
if {[regexp {^[0-7]*$} $number]} {
if {$len != 3} {
set dec_val 0
- } {
+ } else {
if {[string index $number 0] <= 3} {
set dec_val 0
}
@@ -1376,7 +1402,7 @@ namespace eval ASMsyntaxHighlight {
if {[regexp {^[0-7]*$} $number]} {
if {$len != 3} {
set dec_val 0
- } {
+ } else {
if {[string index $number 0] <= 3} {
set dec_val 0
}
@@ -1399,7 +1425,7 @@ namespace eval ASMsyntaxHighlight {
}
# done ...
- return "$base $dec_val"
+ return [list $base $dec_val]
}
## Highlight expressions (eg. '( 10d - X MOD 55h)')
@@ -1426,7 +1452,7 @@ namespace eval ASMsyntaxHighlight {
# Remove strings
set e_idx 0
- while 1 {
+ while {1} {
if {![regexp -start $e_idx -- {'[^']*'} $data string_data]} {
break
}
@@ -1443,28 +1469,28 @@ namespace eval ASMsyntaxHighlight {
}
# remove and highlight '('
- set opended_par 0
- while 1 {
+ set opened_par 0
+ while {1} {
set symbol_idx [string first {(} $data]
if {$symbol_idx == -1} {break}
- incr opended_par
+ incr opened_par
set data [string replace $data $symbol_idx $symbol_idx { }]
incr symbol_idx $start_index
$editor tag add tag_symbol $lineNumber.$symbol_idx $lineNumber.[expr {$symbol_idx + 1}]
}
# remove and highlight ')'
- while 1 {
+ while {1} {
set symbol_idx [string first {)} $data]
if {$symbol_idx == -1} {break}
- incr opended_par -1
+ incr opened_par -1
set data [string replace $data $symbol_idx $symbol_idx { }]
incr symbol_idx $start_index
$editor tag add tag_symbol $lineNumber.$symbol_idx $lineNumber.[expr {$symbol_idx + 1}]
}
# chcek if parenthesies are balanced
- if {$validation_L0 && $opended_par != 0} {
+ if {$validation_L0 && $opened_par != 0} {
$editor tag add tag_error $lineNumber.$start_index $lineNumber.$end_index
}
@@ -1473,7 +1499,7 @@ namespace eval ASMsyntaxHighlight {
regsub -all {\t} $adjusted_data { } adjusted_data
append adjusted_data { }
foreach symbol $expr_instructions {
- while 1 {
+ while {1} {
set symbol_idx [string first " $symbol " $adjusted_data]
if {$symbol_idx == -1} {break}
set original_symbol_idx $symbol_idx
@@ -1500,7 +1526,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_error \
$lineNumber.[expr {$symbol_idx + 1}] \
$lineNumber.$symbol_end_index
- } {
+ } else {
foreach smb $expr_instructions {
if {![string first $smb $tmp]} {
$editor tag add tag_error \
@@ -1515,7 +1541,7 @@ namespace eval ASMsyntaxHighlight {
}
# Highlight expression symbols (1 char) and remove them from the string
foreach symbol $expr_symbols {
- while 1 {
+ while {1} {
set symbol_idx [string first $symbol $data]
if {$symbol_idx == -1} {break}
set original_symbol_idx $symbol_idx
@@ -1530,9 +1556,9 @@ namespace eval ASMsyntaxHighlight {
$validation_L0 && (
!$original_symbol_idx
||
- ![regexp {^\s*((\'\\?[^']\')|\w|\$)} [string range $data $symbol_idx_org_1 end]]
+ ![regexp {^\s*((\'\\?[^']+\')|\w|\$)} [string range $data $symbol_idx_org_1 end]]
)
- } {
+ } then {
$editor tag add tag_error \
$lineNumber.$symbol_idx \
$lineNumber.$symbol_idx_1
@@ -1544,7 +1570,7 @@ namespace eval ASMsyntaxHighlight {
set last_index $start_index
set original_data $data
set data [hide_strings $data]
- while 1 {
+ while {1} {
if {![regexp {[^\s]+} $data value]} {break}
@@ -1595,11 +1621,11 @@ namespace eval ASMsyntaxHighlight {
} elseif {[regexp {^(\d|')} $data]} {
# Gain information about the value
- set opr_info [which_radix 1 $data]
+ set opr_info [which_radix 1 [$editor get $lineNumber.$start_index $lineNumber.$end_index]]
set opr_base [lindex $opr_info 0]
set opr_in_dec [lindex $opr_info 1]
- # Highlight value acording to info
+ # Highlight value according to info
if {$opr_base == {}} {
$editor tag add tag_unknown_base $lineNumber.$start_index $lineNumber.$end_index
if {$validation_L0 && ![regexp {^[0-9A-Fa-f]+$} $data]} {
@@ -1611,7 +1637,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_error $lineNumber.$start_index $lineNumber.$end_index
}
- # Highlight acording to numeric base
+ # Highlight according to numeric base
switch -- $opr_base {
{hex} { ;# Hexadecimal
$editor tag add tag_hex $lineNumber.$start_index $lineNumber.$end_index
@@ -1638,11 +1664,11 @@ namespace eval ASMsyntaxHighlight {
# Constant
if {[lsearch -ascii -exact $spec_registers [string toupper $data]] != -1} {
set tag tag_sfr
- } {
+ } else {
set tag tag_constant
}
$editor tag add $tag $lineNumber.$start_index $lineNumber.$end_index
- if {$validation_L0 && ![regexp {^((\w+)|\$)$} $data]} {
+ if {$validation_L0 && ![regexp {^(((\?\?)?\w+)|\$)$} $data]} {
$editor tag add tag_error $lineNumber.$start_index $lineNumber.$end_index
}
}
@@ -1655,7 +1681,7 @@ namespace eval ASMsyntaxHighlight {
if {[string first {'} $data] == -1} {return $data}
# Perform replacement
- while 1 {
+ while {1} {
if {![regexp {'[^']*'} $data string]} {
break
}
@@ -1673,3 +1699,7 @@ namespace eval ASMsyntaxHighlight {
foreach item ${::ASMsyntaxHighlight::all_controls} {
lappend ::ASMsyntaxHighlight::all_controls__with_dolar "\$$item"
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/Csyntaxhighlight.tcl b/lib/editor/Csyntaxhighlight.tcl
index 8bdc913..c4ecd2a 100755..100644
--- a/lib/editor/Csyntaxhighlight.tcl
+++ b/lib/editor/Csyntaxhighlight.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 _CSYNTAXHIGHLIGHT_TCL ] } {
+set _CSYNTAXHIGHLIGHT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements syntax highlighting interface for ISO C language
@@ -40,18 +45,23 @@ namespace eval CsyntaxHighlight {
#if #ifdef #ifndef
#else #elif #endif
#line #pragma #undef
+ #warning
}
# List of data type specifiers
variable data_types {
void int float double char signed unsigned
long short uchar ushort uint ulong const
export extern static mutable volatile
+
+ __data __near __xdata __far __idata __pdata __code
+ __bit __sfr __sfr16 __sfr32 __sbit __at
}
# List of C keywords
variable keywords {
auto break case _endasm while union continue
default do else enum sizeof for namespace
if goto return struct switch typedef using
+ _asm __asm __endasm
}
# List of doxygen tags -- No argument
variable doxy_tags_type0 {
@@ -69,7 +79,8 @@ namespace eval CsyntaxHighlight {
# List of doxygen tags -- Name after tag
variable doxy_tags_type2 {
@brief @ingroup @name @mainpage
- @fn @var @typedef
+ @fn @var @typedef @author
+ @authors
}
# List of HTML tags (HTML 4.0 Strict)
variable html_tags {
@@ -99,11 +110,12 @@ namespace eval CsyntaxHighlight {
# {
# {tag_name ?foreground? ?overstrike? ?italic? ?bold?}
# }
- variable hightlight_tags {
+ variable highlight_tags {
{tag_c_keyword #0000DD 0 0 1}
{tag_c_data_type #00CC00 0 0 1}
{tag_c_dec #0000FF 0 0 0}
{tag_c_hex #8800FF 0 0 0}
+ {tag_c_bin #5555AA 0 0 0}
{tag_c_oct #883300 0 0 0}
{tag_c_char #DD00DD 0 0 0}
{tag_c_float #AA00AA 0 0 0}
@@ -127,26 +139,22 @@ namespace eval CsyntaxHighlight {
}
## Define highlighting text tags in the given text widget
- # @parm Widget - ID of the target text widget
- # @parm Int - font size
- # @parm String - font family
- # @parm List = default - Highlighting tags definition
+ # @parm Widget text_widget - ID of the target text widget
+ # @parm Int fontSize - font size
+ # @parm String fontFamily - font family
+ # @parm List highlight=default - Highlighting tags definition
+ # @parm Bool nobold=0 - Ignore bold flag
# @return void
- proc create_tags args {
- variable hightlight_tags ;# Highlight tags definition
+ proc create_tags {text_widget fontSize fontFamily {highlight {}} {nobold 0}} {
+ variable highlight_tags ;# Highlight tags definition
# Handle arguments
- set text_widget [lindex $args 0] ;# text widget
- set fontSize [lindex $args 1] ;# font size
- set fontFamily [lindex $args 2] ;# font family
- if {[llength $args] > 3} { ;# highlighting definition
- set hightlight [lindex $args 3]
- } {
- set hightlight $hightlight_tags
+ if {$highlight == {}} { ;# highlighting definition
+ set highlight $highlight_tags
}
# Iterate over highlighting tags definition
- foreach item $hightlight {
+ foreach item $highlight {
# Create array of tag attributes
for {set i 0} {$i < 5} {incr i} {
set tag($i) [lindex $item $i]
@@ -159,13 +167,13 @@ namespace eval CsyntaxHighlight {
# Fonr slant
if {$tag(3) == 1} {
set tag(3) italic
- } {
+ } else {
set tag(3) roman
}
# Font weight
- if {$tag(4) == 1} {
+ if {$tag(4) == 1 && !$nobold} {
set tag(4) bold
- } {
+ } else {
set tag(4) normal
}
@@ -190,6 +198,7 @@ namespace eval CsyntaxHighlight {
tag_c_bracket tag_c_symbol tag_c_keyword
tag_c_data_type tag_c_char tag_c_dec
tag_c_oct tag_c_hex tag_c_float
+ tag_c_bin
} {
$text_widget tag raise $t tag_normal
}
@@ -245,7 +254,7 @@ namespace eval CsyntaxHighlight {
$editor tag add tag_c_preprocessor $line_start $line_end-1c
$editor tag add tag_c_symbol $line_end-1c $line_end
return 7
- } {
+ } else {
$editor tag add tag_c_preprocessor $line_start $line_end
return 1
}
@@ -274,7 +283,7 @@ namespace eval CsyntaxHighlight {
# Highlight directive argument
if {$directive == {#include}} {
set prep_tag {tag_c_prep_lib}
- } {
+ } else {
set prep_tag {tag_c_preprocessor}
}
@@ -284,7 +293,7 @@ namespace eval CsyntaxHighlight {
set cur_line_end $com_start
incr cur_line_end -1
set cur_line_end $line_number.$cur_line_end
- } {
+ } else {
set cur_line_end $line_end
}
@@ -308,14 +317,14 @@ namespace eval CsyntaxHighlight {
return $cur_status
# Inline assembler
- } elseif {[regexp {^\s*_asm\s*$} $line_content]} {
+ } elseif {[regexp {^\s*_?_asm\s*$} $line_content]} {
$editor tag add tag_c_keyword $line_start $line_end
return 5
}
}
# Split line into fields with different highlight status
- while 1 {
+ while {1} {
set incr_last_i 0
switch -- $status {
1 { ;# Normal
@@ -384,12 +393,12 @@ namespace eval CsyntaxHighlight {
}
4 { ;# String
set l_idx $last_idx_s
- while 1 {
+ while {1} {
set idx [string first "\"" $line_content $l_idx]
if {$idx < 1} {break}
if {[string index $line_content [expr {$idx - 1}]] == "\\"} {
incr l_idx
- } {
+ } else {
break
}
}
@@ -399,7 +408,7 @@ namespace eval CsyntaxHighlight {
set status 1
}
5 { ;# Inline assembler
- if {[regexp {^\s*_endasm[^\w]*} $line_content]} {
+ if {[regexp {^\s*_?_endasm[^\w]*} $line_content]} {
mode_normal 0 [string length $line_content]
return 1
}
@@ -409,10 +418,10 @@ namespace eval CsyntaxHighlight {
break
}
6 { ;# Inline assembler -- within asm block
- if {[regexp {^\s*_endasm[^\w]*} $line_content]} {
+ if {[regexp {^\s*_?_endasm[^\w]*} $line_content]} {
mode_normal 0 [string length $line_content]
return 1
- } {
+ } else {
break
}
}
@@ -437,14 +446,14 @@ namespace eval CsyntaxHighlight {
# Return final status
if {$this_line_only} {
return 1
- } {
+ } else {
return $status
}
}
## Auxiliary procedure for procedure highlight
# This procedure calls other procedures to perform syntax
- #+ highlight acording to the given highlight status
+ #+ highlight according to the given highlight status
# @parm Int status - Highlight status
# @parm Int idx0 - Start index
# @parm Int idx1 - End index
@@ -501,7 +510,7 @@ namespace eval CsyntaxHighlight {
set string [string range $line_content $idx0 [expr {$idx1 - 1}]]
# Highlight escaped characters and character between them
- while 1 {
+ while {1} {
# Search for backslash
set idx [string first "\\" $string $idx]
if {$idx == -1} {break}
@@ -545,18 +554,18 @@ namespace eval CsyntaxHighlight {
set words [split [regsub -all {>} [regsub -all {<} $string { &}] {& }]]
# Adjust HTML tags with argument(s) (they must be represented as a single word)
- set tag_opended 0
+ set tag_opened 0
set result_words {}
foreach word $words {
- if {!$tag_opended} {
+ if {!$tag_opened} {
append result_words { } ;# Insert a common space
- } {
+ } else {
append result_words "\xA0" ;# Insert NBSP
}
- if {!$tag_opended && [regexp {^<\w+$} $word]} {
- set tag_opended 1
- } elseif {$tag_opended && [string index $word end] == {>}} {
- set tag_opended 0
+ if {!$tag_opened && [regexp {^<\w+$} $word]} {
+ set tag_opened 1
+ } elseif {$tag_opened && [string index $word end] == {>}} {
+ set tag_opened 0
}
append result_words [regsub -all {[\{\}]} $word {\\&}]
}
@@ -670,7 +679,7 @@ namespace eval CsyntaxHighlight {
$editor tag add tag_c_dox_hargval \
$line_number.[expr {$idx0 + $idx + $sub_idx + $first_equ_mark}] \
$line_number.[expr {$idx0 + $idx + $sub_idx + $sub_len}]
- } {
+ } else {
set first_equ_mark $sub_len
}
@@ -727,7 +736,7 @@ namespace eval CsyntaxHighlight {
if {
$char == {(} || $char == {)} || $char == "\{" ||
$char == "\}" || $char == {[} || $char == {]}
- } {
+ } then {
$editor tag add tag_c_bracket $line_number.$j $line_number.$j+1c
# Other symbols
@@ -743,7 +752,7 @@ namespace eval CsyntaxHighlight {
{
set idx -1
foreach word $words {
- while 1 {
+ while {1} {
incr idx
set idx [string first $word $string $idx]
if {$idx == -1} {break}
@@ -765,7 +774,7 @@ namespace eval CsyntaxHighlight {
set idx -1
set len 0
set tags {}
- foreach word [split $string {   ;=,+-<>!|&*/?:%^\{\}[]()}] {
+ foreach word [split $string {   ;=,+-<>!|&*/?:%^{}[]()}] {
if {$word == {}} {continue}
incr idx
@@ -774,9 +783,11 @@ namespace eval CsyntaxHighlight {
# Char
if {![string is digit -strict [string index $word 0]]} {
- if {[regexp {^'[^']*'$} $word]} {
+ if {$word == {''}} {
+ set tags {tag_error}
+ } elseif {[regexp {^'[^']+'$} $word]} {
set tags {tag_c_char}
- } {
+ } else {
continue
}
@@ -787,10 +798,10 @@ namespace eval CsyntaxHighlight {
set tags {tag_c_dec}
} elseif {!$validation_L0 || [regexp {^0[0-7]+$} $word]} {
set tags {tag_c_oct}
- } {
+ } else {
set tags {tag_c_oct tag_error}
}
- } {
+ } else {
set tags {tag_c_dec}
}
@@ -801,12 +812,26 @@ namespace eval CsyntaxHighlight {
||
[string index $word 1] == {X}
)
- } {
- if {!$validation_L0 || [string is xdigit -strict [string range $word 2 end]]} {
- set tags {tag_c_hex}
- } {
- set tags {tag_c_hex tag_error}
- }
+ } then {
+ if {!$validation_L0 || [string is xdigit -strict [string range $word 2 end]]} {
+ set tags {tag_c_hex}
+ } else {
+ set tags {tag_c_hex tag_error}
+ }
+
+ # Bin
+ } elseif {
+ [string index $word 0] == {0} && (
+ [string index $word 1] == {b}
+ ||
+ [string index $word 1] == {B}
+ )
+ } then {
+ if {!$validation_L0 || [regexp {^[01]+$} [string range $word 2 end]]} {
+ set tags {tag_c_bin}
+ } else {
+ set tags {tag_c_bin tag_error}
+ }
# Float
} elseif {[regexp {^\d+\.\d+$} $word]} {
@@ -832,7 +857,7 @@ namespace eval CsyntaxHighlight {
# @return void
proc delete_tags {} {
variable editor ;# Widget: Editor text widget
- variable hightlight_tags ;# Highlight tags definition
+ variable highlight_tags ;# Highlight tags definition
variable line_start ;# Index of line start
variable line_end ;# Index of line end
@@ -842,12 +867,16 @@ namespace eval CsyntaxHighlight {
$editor tag remove c_lang_func $line_start $line_start+1l
$editor tag remove c_lang_var $line_start $line_start+1l
- # Remove tags acording to pattern
- foreach tag $hightlight_tags {
+ # Remove tags according to pattern
+ foreach tag $highlight_tags {
$editor tag remove [lindex $tag 0] $line_start $line_end
}
- foreach tag $::ASMsyntaxHighlight::hightlight_tags {
+ foreach tag $::ASMsyntaxHighlight::highlight_tags {
$editor tag remove [lindex $tag 0] $line_start $line_end
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/LSTsyntaxhighlight.tcl b/lib/editor/LSTsyntaxhighlight.tcl
index c108de9..62f622f 100755..100644
--- a/lib/editor/LSTsyntaxhighlight.tcl
+++ b/lib/editor/LSTsyntaxhighlight.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 _LSTSYNTAXHIGHLIGHT_TCL ] } {
+set _LSTSYNTAXHIGHLIGHT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements syntax highlighting interface for code listing
@@ -33,7 +38,7 @@ namespace eval LSTsyntaxHighlight {
# {
# {tag_name ?foreground? ?overstrike? ?italic? ?bold?}
# }
- variable hightlight_tags {
+ variable highlight_tags {
{tag_lst_number #000000 0 0 1}
{tag_lst_code #000000 0 0 1}
{tag_lst_address #000000 0 0 1}
@@ -74,26 +79,22 @@ namespace eval LSTsyntaxHighlight {
## Define highlighting text tags in the given text widget
- # @parm Widget - ID of the target text widget
- # @parm Int - font size
- # @parm String - font family
- # @parm List = default - Highlighting tags definition
+ # @parm Widget text_widget - ID of the target text widget
+ # @parm Int fontSize - font size
+ # @parm String fontFamily - font family
+ # @parm List highlight=default - Highlighting tags definition
+ # @parm Bool nobold=0 - Ignore bold flag
# @return void
- proc create_tags args {
- variable hightlight_tags ;# Highlight tags definition
+ proc create_tags {text_widget fontSize fontFamily {highlight {}} {nobold 0}} {
+ variable highlight_tags ;# Highlight tags definition
# Handle arguments
- set text_widget [lindex $args 0] ;# text widget
- set fontSize [lindex $args 1] ;# font size
- set fontFamily [lindex $args 2] ;# font family
- if {[llength $args] > 3} { ;# highlighting definition
- set hightlight [lindex $args 3]
- } {
- set hightlight $hightlight_tags
+ if {$highlight == {}} { ;# highlighting definition
+ set highlight $highlight_tags
}
# Iterate over highlighting tags definition
- foreach item $hightlight {
+ foreach item $highlight {
# Create array of tag attributes
for {set i 0} {$i < 5} {incr i} {
set tag($i) [lindex $item $i]
@@ -106,13 +107,13 @@ namespace eval LSTsyntaxHighlight {
# Fonr slant
if {$tag(3) == 1} {
set tag(3) italic
- } {
+ } else {
set tag(3) roman
}
# Font weight
- if {$tag(4) == 1} {
+ if {$tag(4) == 1 && !$nobold} {
set tag(4) bold
- } {
+ } else {
set tag(4) normal
}
@@ -152,7 +153,7 @@ namespace eval LSTsyntaxHighlight {
# Remove current highlighting tags
if {[string length [string trim $line_content]]} {
delete_tags
- } {
+ } else {
return 0
}
@@ -169,7 +170,7 @@ namespace eval LSTsyntaxHighlight {
return 1
}
}
-
+
# Search for error/warning messages
if {[regexp {^(\s+@@@@@)|^(\*\*\*\*)|^(\s+\^)} $line_content]} {
$editor tag add tag_lst_error $line_start $line_end
@@ -194,7 +195,7 @@ namespace eval LSTsyntaxHighlight {
if {${::ExternalCompiler::selected_assembler} == 3} {
set asm_start_index 19
as31_highlight 19
-|
+
# ASEM-51
} elseif {
[regexp {^\s*\d+(\:|\+)} $line_content] ||
@@ -205,7 +206,7 @@ namespace eval LSTsyntaxHighlight {
set asm_start_index 33
set idx -1
set cor 0
- while 1 {
+ while {1} {
set idx [string first "\t" $lineText [expr {$idx + 1}]]
if {$idx == -1} {break}
@@ -224,28 +225,32 @@ namespace eval LSTsyntaxHighlight {
sdcc_highlight 32
::R_ASMsyntaxHighlight::highlight $editor $line_number 1 32
return 1
-
+
# MCU 8051 IDE Assembler
} else {
set asm_start_index 31
mcu8051ide_highlight $asm_start_index
}
- # Highlight assembly code
+ # Highlight remaining assembly code
::ASMsyntaxHighlight::highlight $editor $line_number 1 $asm_start_index
+
+ # Make sure there are no ASM error tags, they don't make sense here
+ $editor tag remove tag_error $line_number.$asm_start_index $line_end
+
return 1
}
- ## Remove previously defined syntax highlighting tags
+ ## Remove previously put syntax highlighting tags
# @return void
proc delete_tags {} {
- variable hightlight_tags ;# Highlight tags definition
+ variable highlight_tags ;# Highlight tags definition
variable editor ;# Widget: Editor text widget
variable line_start ;# Index of line start
variable line_end ;# Index of line end
- # Remove tags acording to pattern
- foreach tag $hightlight_tags {
+ # Remove tags according to pattern
+ foreach tag $highlight_tags {
$editor tag remove [lindex $tag 0] $line_start $line_end
}
}
@@ -292,7 +297,7 @@ namespace eval LSTsyntaxHighlight {
variable line_content ;# String: Line content
variable line_start ;# Index of line start
variable line_end ;# Index of line end
-
+
set idx 0 ;# Regular expression match start index
set foo 0 ;# Foo :)
@@ -305,11 +310,11 @@ namespace eval LSTsyntaxHighlight {
set idx [string first $substring $line_content $idx]
$editor tag add tag_lst_line $line_number.$idx $line_number.[expr {$idx + $substr_len}]
incr idx $substr_len
- } {
+ } else {
set idx 6
set foo 1
}
-
+
# Highlight for inclusion level
if {[regexp -start $idx -- {\A[ \d]\d} $line_content substring]} {
set substr_len [string length $substring]
@@ -345,7 +350,7 @@ namespace eval LSTsyntaxHighlight {
$editor tag add tag_lst_number $line_number.$idx $line_number.[expr {$idx + $substr_len}]
incr idx $substr_len
}
-
+
# Highlight processor code
} elseif {[regexp -start $idx -- {\A\s+([[:xdigit:]]{2} )*[[:xdigit:]]{2}} $line_content substring]} {
set substr_len [string length $substring]
@@ -377,13 +382,13 @@ namespace eval LSTsyntaxHighlight {
variable line_content ;# String: Line content
variable line_start ;# Index of line start
variable line_end ;# Index of line end
-
+
set idx 0 ;# Regular expression match start index
-
+
# Alter line
set line_content [string range $line_content 0 [expr {$asm_start_index - 1}]]
-
- # Highlight processor code
+
+ # Highlight processor code
if {[regexp -start $idx -- {\A [[:xdigit:]]{2,}} $line_content substring]} {
set substr_len [string length $substring]
set idx [string first $substring $line_content $idx]
@@ -400,7 +405,7 @@ namespace eval LSTsyntaxHighlight {
set idx [string first $substring $line_content $idx]
$editor tag add tag_lst_address $line_number.$idx $line_number.[expr {$idx + $substr_len}]
incr idx $substr_len
-
+
# Highlight processor code
if {[regexp -start $idx -- {\A\s+[[:xdigit:]]{2,}} $line_content substring]} {
set substr_len [string length $substring]
@@ -417,7 +422,7 @@ namespace eval LSTsyntaxHighlight {
$editor tag add tag_lst_number $line_number.$idx $line_number.[expr {$idx + $substr_len}]
incr idx $substr_len
}
-
+
# Highlight inclusion level
if {[regexp -start $idx -- {\A\s+\=\d+} $line_content substring]} {
set substr_len [string length $substring]
@@ -441,3 +446,7 @@ namespace eval LSTsyntaxHighlight {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/R_ASMsyntaxhighlight.tcl b/lib/editor/R_ASMsyntaxhighlight.tcl
index 2408bff..250da57 100755..100644
--- a/lib/editor/R_ASMsyntaxhighlight.tcl
+++ b/lib/editor/R_ASMsyntaxhighlight.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 _R_ASMSYNTAXHIGHLIGHT_TCL ] } {
+set _R_ASMSYNTAXHIGHLIGHT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements syntax highlighting interface for reallocable assembly
@@ -86,24 +91,20 @@ namespace eval R_ASMsyntaxHighlight {
variable validation_L1 1 ;# Bool: Advancet validation enabled
## Define highlighting text tags in the given text widget
- # @parm Widget - ID of the target text widget
- # @parm Int - font size
- # @parm String - font family
- # @parm List = default - Highlighting tags definition
+ # @parm Widget text_widget - ID of the target text widget
+ # @parm Int fontSize - font size
+ # @parm String fontFamily - font family
+ # @parm List highlight=default - Highlighting tags definition
+ # @parm Bool nobold=0 - Ignore bold flag
# @return void
- proc create_tags args {
+ proc create_tags {text_widget fontSize fontFamily {highlight {}} {nobold 0}} {
# Handle arguments
- set text_widget [lindex $args 0] ;# text widget
- set fontSize [lindex $args 1] ;# font size
- set fontFamily [lindex $args 2] ;# font family
- if {[llength $args] > 3} { ;# highlighting definition
- set hightlight [lindex $args 3]
- } {
- set hightlight $::ASMsyntaxHighlight::hightlight_tags
+ if {$highlight == {}} { ;# highlighting definition
+ set highlight $::ASMsyntaxHighlight::highlight_tags
}
# Iterate over highlighting tags definition
- foreach item $hightlight {
+ foreach item $highlight {
# Create array of tag attributes
for {set i 0} {$i < 5} {incr i} {
set tag($i) [lindex $item $i]
@@ -116,13 +117,13 @@ namespace eval R_ASMsyntaxHighlight {
# Fonr slant
if {$tag(3) == 1} {
set tag(3) italic
- } {
+ } else {
set tag(3) roman
}
# Font weight
- if {$tag(4) == 1} {
+ if {$tag(4) == 1 && !$nobold} {
set tag(4) bold
- } {
+ } else {
set tag(4) normal
}
@@ -142,13 +143,13 @@ namespace eval R_ASMsyntaxHighlight {
}
## Perform syntax highlight on the given line in the given widget
- # @parm Widget Editor - Text widget
- # @parm Int LineNumber - Number of line to highlight
- # @parm Bool inline_asm - Inline assembler
- # @parm Int boundary_0 = 0 - Start index
- # @parm Int boundary_1 = end - End index
+ # @parm Widget p_editor - Text widget
+ # @parm Int linenumber - Number of line to highlight
+ # @parm Bool inlineasm=0 - Inline assembler
+ # @parm Int linestart=0 - Start index
+ # @parm Int lineend=end - End index
# @return Bool - result
- proc highlight args {
+ proc highlight {p_editor linenumber {inlineasm 0} {linestart {}} {lineend {}}} {
variable editor ;# ID of the text widget
variable lineNumber ;# Number of current line
variable lineStart ;# Index of line start
@@ -170,27 +171,22 @@ namespace eval R_ASMsyntaxHighlight {
variable validation_L0 ;# Bool: Basic validation enabled
# Parse input arguments
- set editor [lindex $args 0]
- set lineNumber [lindex $args 1]
- set inline_asm [lindex $args 2]
- set lineStart [lindex $args 3]
- set lineEnd [lindex $args 4]
- if {$inline_asm == {}} {
- set inline_asm 0
- }
- if {$lineStart == {}} {
+ set editor $p_editor
+ set lineNumber $linenumber
+ set inline_asm $inlineasm
+ if {$linestart == {}} {
set lineStart $lineNumber.0
- } {
- set lineStart $lineNumber.$lineStart
+ } else {
+ set lineStart $lineNumber.$linestart
}
- if {$lineEnd == {}} {
+ if {$lineend == {}} {
set lineEnd [$editor index "$lineStart lineend"]
- } {
+ } else {
set lineEnd $lineNumber.$lineEnd
}
- if {[lindex $args 3] != {}} {
- set start_offset [lindex $args 3]
- } {
+ if {$linestart != {}} {
+ set start_offset $linestart
+ } else {
set start_offset 0
}
@@ -227,7 +223,7 @@ namespace eval R_ASMsyntaxHighlight {
if {$comment_start == 0} {
set data {}
delete_tags
- } {
+ } else {
set data [string range $data 0 [expr {$comment_start - 1}]]
regsub {\s+$} $data {} data
}
@@ -295,7 +291,7 @@ namespace eval R_ASMsyntaxHighlight {
if {
$validation_L0 &&
([regexp {^\d} $seg_1] || ![regexp {^\w+$} $seg_1])
- } {
+ } then {
put_error_on_segment 1
}
determinate_segment_2
@@ -314,7 +310,7 @@ namespace eval R_ASMsyntaxHighlight {
determinate_segment_2
if {[string tolower $seg_0] == {.optsdcc}} {
$editor tag add tag_string $lineNumber.$seg_0_end $lineEnd
- } {
+ } else {
parse_expressions
}
}
@@ -376,8 +372,8 @@ namespace eval R_ASMsyntaxHighlight {
# Remove tag error
$editor tag remove tag_error $lineStart_truestart $lineEnd
- # Remove tags acording to pattern
- foreach tag $::ASMsyntaxHighlight::hightlight_tags {
+ # Remove tags according to pattern
+ foreach tag $::ASMsyntaxHighlight::highlight_tags {
$editor tag remove [lindex $tag 0] $lineStart_truestart $lineEnd
}
}
@@ -412,7 +408,7 @@ namespace eval R_ASMsyntaxHighlight {
set seg_1_start $last_index
# Line is not empty
- } {
+ } else {
set data_backup $data
set last_index_backup $last_index
@@ -508,7 +504,7 @@ namespace eval R_ASMsyntaxHighlight {
} elseif {$segment_data == {=} || $segment_data == {==}} {
$editor tag add tag_symbol $lineNumber.$start $lineNumber.$end
set seg_type {assignment}
- } {
+ } else {
set seg_type {unknown}
}
}
@@ -565,9 +561,9 @@ namespace eval R_ASMsyntaxHighlight {
if {[regexp {^\s*$} $seg_2]} {return 0}
- while 1 {
+ while {1} {
# Handle redutant commas
- while 1 {
+ while {1} {
if {![regexp {^\s*\,} $seg_2]} {break}
set space_len 0
@@ -639,9 +635,9 @@ namespace eval R_ASMsyntaxHighlight {
set original_data $seg_2
set data [hide_strings $seg_2]
- while 1 {
+ while {1} {
# Handle redutant commas
- while 1 {
+ while {1} {
if {![regexp {^\s*\,} $data]} {break}
set space_len 0
@@ -672,7 +668,7 @@ namespace eval R_ASMsyntaxHighlight {
set space_len [string length $space]
set opr_start [expr {$last_index + $space_len}]
set operand [string range $operand $space_len end]
- } {
+ } else {
set opr_start $last_index
}
@@ -681,7 +677,7 @@ namespace eval R_ASMsyntaxHighlight {
set space_len [string length $space]
set opr_end [expr {$operand_len - $space_len}]
set operand [string range $operand 0 $opr_end]
- } {
+ } else {
set opr_end $operand_len
}
incr opr_end $last_index
@@ -725,7 +721,7 @@ namespace eval R_ASMsyntaxHighlight {
default {
if {[lsearch -ascii -exact {R0 R1 R2 R3 R4 R5 R6 R7 DPTR A AB C} $opr] != -1} {
lappend ::ASMsyntaxHighlight::opr_types $opr
- } {
+ } else {
lappend ::ASMsyntaxHighlight::opr_types {D}
}
}
@@ -756,7 +752,7 @@ namespace eval R_ASMsyntaxHighlight {
if {$len > 3} {
put_tag_on_operand tag_string
- } {
+ } else {
put_tag_on_operand tag_imm_char
}
@@ -773,7 +769,7 @@ namespace eval R_ASMsyntaxHighlight {
} elseif {
$validation_L0 &&
([string length $operand] == 0 || ![regexp {^[\w\.\\]+$} $operand])
- } {
+ } then {
# put_tag_on_operand tag_error
# Operand value determinated successfully
@@ -804,12 +800,11 @@ namespace eval R_ASMsyntaxHighlight {
$lineNumber.$opr_start $lineNumber.$opr_start+1c
} elseif {
- $validation_L0 &&
- ([string length $operand] == 0 || ![regexp {^'?[\w\.]+'?$} $operand])
- } {
-
- # Operand has no value => incorrect operand
-# put_tag_on_operand tag_error
+ $validation_L0 &&
+ ([string length $operand] == 0 || ![regexp {^'?[\w\.]+'?$} $operand])
+ } then {
+ # Operand has no value => incorrect operand
+# put_tag_on_operand tag_error
} else {
parse_operand_auxiliary $::ASMsyntaxHighlight::spec_bits {
@@ -841,7 +836,7 @@ namespace eval R_ASMsyntaxHighlight {
put_tag_on_operand tag_sfr
# Something else than SFR
- } {
+ } else {
parse_operand_auxiliary2 $tag_list
}
}
@@ -897,8 +892,8 @@ namespace eval R_ASMsyntaxHighlight {
put_tag_on_operand [lindex $tag_list 0]
# Radix determinated correctly - continue normaly
- } {
- # highlight acording to numeric base
+ } else {
+ # highlight according to numeric base
switch -- $opr_base {
{hex} {put_tag_on_operand [lindex $tag_list 1]}
{dec} {put_tag_on_operand [lindex $tag_list 2]}
@@ -910,7 +905,7 @@ namespace eval R_ASMsyntaxHighlight {
}
# defined by a symbolic name
- } {
+ } else {
put_tag_on_operand [lindex $tag_list 6]
}
}
@@ -996,7 +991,7 @@ namespace eval R_ASMsyntaxHighlight {
if {[regexp {^[0-7]*$} $number]} {
if {$len != 3} {
set dec_val 0
- } {
+ } else {
if {[string index $number 0] <= 3} {
set dec_val 0
}
@@ -1014,7 +1009,7 @@ namespace eval R_ASMsyntaxHighlight {
if {[regexp {^[0-7]*$} $number]} {
if {$len != 3} {
set dec_val 0
- } {
+ } else {
if {[string index $number 0] <= 3} {
set dec_val 0
}
@@ -1037,7 +1032,7 @@ namespace eval R_ASMsyntaxHighlight {
}
# done ...
- return "$base $dec_val"
+ return [list $base $dec_val]
}
## Highlight expressions (eg. '( 10d - X MOD 55h)')
@@ -1062,7 +1057,7 @@ namespace eval R_ASMsyntaxHighlight {
# Remove strings
set e_idx 0
- while 1 {
+ while {1} {
if {![regexp -start $e_idx -- {'[^']*'} $data string_data]} {
break
}
@@ -1079,22 +1074,22 @@ namespace eval R_ASMsyntaxHighlight {
}
# remove and highlight '('
- set opended_par 0
- while 1 {
+ set opened_par 0
+ while {1} {
set symbol_idx [string first {(} $data]
if {$symbol_idx == -1} {break}
- incr opended_par
+ incr opened_par
set data [string replace $data $symbol_idx $symbol_idx { }]
incr symbol_idx $start_index
$editor tag add tag_symbol $lineNumber.$symbol_idx $lineNumber.[expr {$symbol_idx + 1}]
}
# remove and highlight ')'
- while 1 {
+ while {1} {
set symbol_idx [string first {)} $data]
if {$symbol_idx == -1} {break}
- incr opended_par -1
+ incr opened_par -1
set data [string replace $data $symbol_idx $symbol_idx { }]
incr symbol_idx $start_index
$editor tag add tag_symbol $lineNumber.$symbol_idx $lineNumber.[expr {$symbol_idx + 1}]
@@ -1105,7 +1100,7 @@ namespace eval R_ASMsyntaxHighlight {
regsub {\t} $adjusted_data { } adjusted_data
# highlight expr. symbols (1 char) and remove them from the string
foreach symbol $expr_symbols {
- while 1 {
+ while {1} {
set symbol_idx [string first $symbol $data]
if {$symbol_idx == -1} {break}
set original_symbol_idx $symbol_idx
@@ -1122,7 +1117,7 @@ namespace eval R_ASMsyntaxHighlight {
set last_index $start_index
set original_data $data
set data [hide_strings $data]
- while 1 {
+ while {1} {
if {![regexp {[^\s]+} $data value]} {break}
set value_S_idx [string first $value $data]
@@ -1175,13 +1170,13 @@ namespace eval R_ASMsyntaxHighlight {
set opr_base [lindex $opr_info 0]
set opr_in_dec [lindex $opr_info 1]
- # Highlight value acording to info
+ # Highlight value according to info
if {$opr_base == {}} {
$editor tag add tag_unknown_base $lineNumber.$start_index $lineNumber.$end_index
return
}
- # Highlight acording to numeric base
+ # Highlight according to numeric base
switch -- $opr_base {
{hex} { ;# Hexadecimal
$editor tag add tag_hex $lineNumber.$start_index $lineNumber.$end_index
@@ -1217,7 +1212,7 @@ namespace eval R_ASMsyntaxHighlight {
if {[string first {'} $data] == -1} {return $data}
# Perform replacement
- while 1 {
+ while {1} {
if {![regexp {'[^']*'} $data string]} {
break
}
@@ -1230,3 +1225,7 @@ namespace eval R_ASMsyntaxHighlight {
return $data
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/autocompletion.tcl b/lib/editor/autocompletion.tcl
index a5c9234..04dca79 100755..100644
--- a/lib/editor/autocompletion.tcl
+++ b/lib/editor/autocompletion.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,20 +21,64 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _AUTOCOMPLETION_TCL ] } {
+set _AUTOCOMPLETION_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements autocompletion related procedures
# This file should be loaded into class Editor in file "editor.tcl"
# --------------------------------------------------------------------------
-
-## Refresh list of avaliable SFR's and SFB's on the target uC
+common invoke_com_win_in_p 0 ;# Bool: invoke_completion_popup_window in progress
+common completion_win_opened 0 ;# Bool: Editor popup-based completion window opended
+
+## Array: Strings available for autocompletion
+ # Index 0 - Labels in assembly
+ # Index 1 - Constants/variables
+ # Index 2 - C variables
+ # Index 3 - Macros
+ # Index 4 - SFR's
+ # Index 5 - Expression symbols
+ # Index 6 - Doxygen tags
+ # Index 7 - C Functions
+private variable autocompletion_list
+private variable completion_win_str_i 1.0 ;# TextIndex: String to complete - start index
+private variable completion_win_end_i 1.0 ;# TextIndex: String to complete - end index
+private variable completion_win_mode 0 ;# Int: Completion window mode
+private variable comp_win_loading_in_p 0 ;# Bool: Completion window list loading is in progress
+private variable comp_win_loading_max 1 ;# Int: Maximum for progressbar in the completion window
+private variable macl_invocations 0 ;# Int: Number of invocations of "manage_autocompletion_list"
+private variable doxytag_fg {#000000} ;# Color: Highlight color for doxygen tag
+private variable indirect_fg {#000000} ;# Color: Highlight color for indirect address
+private variable symbol_fg {#000000} ;# Color: Highlight color for asm. symbol
+private variable sfr_fg {#000000} ;# Color: Highlight color for SFR
+private variable label_fg {#000000} ;# Color: Highlight color for asm. label
+private variable macro_fg {#000000} ;# Color: Highlight color for asm. macro
+private variable const_fg {#000000} ;# Color: Highlight color for asm. const
+private variable dir_fg {#000000} ;# Color: Highlight color for asm. directive
+private variable cs_fg {#000000} ;# Color: Highlight color for constrol sequence
+private variable ins_fg {#000000} ;# Color: Highlight color for instruction
+private variable doxytag_font ${::Editor::defaultFont} ;# Font: Font for doxygen tag
+private variable indirect_font ${::Editor::defaultFont} ;# Font: Font for indirect address
+private variable symbol_font ${::Editor::defaultFont} ;# Font: Font for asm. symbol
+private variable sfr_font ${::Editor::defaultFont} ;# Font: Font for SFR
+private variable label_font ${::Editor::defaultFont} ;# Font: Font for asm. label
+private variable macro_font ${::Editor::defaultFont} ;# Font: Font for asm. macro
+private variable const_font ${::Editor::defaultFont} ;# Font: Font for asm. const
+private variable dir_font ${::Editor::defaultFont} ;# Font: Font for asm. directive
+private variable cs_font ${::Editor::defaultFont} ;# Font: Font for constrol sequence
+private variable ins_font ${::Editor::defaultFont} ;# Font: Font for instruction
+
+
+## Refresh list of available SFR's and SFB's on the target uC
# @return void
-public method refresh_avaliable_SFR {} {
- set autocompletion_list(4) [lsort -ascii [$parentObject cget -avaliable_SFR]]
+public method refresh_available_SFR {} {
+ set autocompletion_list(4) [lsort -ascii [$parentObject cget -available_SFR]]
}
-
## Clear list of words for autocompletion window
# @return void
public method clear_autocompletion_list {} {
@@ -49,14 +93,21 @@ public method clear_autocompletion_list {} {
#+ autocompletion list up to date
# @parm TextIndex start_index - Start
# @parm TextIndex end_index - End
+ # @parm Bool do_spellcheck - Perform spell check
# @return void
-public method detete_text_in_editor {start_index end_index} {
+public method detete_text_in_editor {start_index end_index {do_spellcheck 1}} {
autocompletion_maybe_important_change $start_index $end_index
+ if {$do_spellcheck} {
+ spellcheck_change_detected_pre
+ }
$editor delete $start_index $end_index
+ if {$do_spellcheck} {
+ spellcheck_change_detected_post
+ }
}
## Inform autocompletion mechanism about possibly deleted symbol
- # @parm TextIndex start_index - Begining on area to to analyze
+ # @parm TextIndex start_index - Beginning on area to to analyze
# @parm TextIndex end_index - End on area to to analyze
# @return void
public method autocompletion_maybe_important_change {start_index end_index} {
@@ -97,7 +148,7 @@ public method autocompletion_maybe_important_change {start_index end_index} {
set idx [lsearch -ascii -exact $autocompletion_list($index) $string]
if {$idx != -1} {
$parentObject rightPanel_adjust_symbol_list \
- all $string $index 0
+ all $string $index 0 $this
set autocompletion_list($index) \
[lreplace $autocompletion_list($index) $idx $idx]
@@ -135,24 +186,33 @@ private method autocompletion_c_syntax_analyze {line_number} {
set end 0
set string {}
- # Find part which consist of alfanumeric characters
- if {![regexp -start $start -- {\w+} $line string]} {
- return
+ # Find part which consist of alphanumeric characters
+ while {1} {
+ if {![regexp -start $start -- {\w+} $line string]} {
+ return
+ }
+
+ incr start
+ set end [expr {$start + [string length $string]}]
+
+ if {[string is digit [string index $string 0]]} {
+ incr start [string length $string]
+ } else {
+ break
+ }
}
- set start [string first $string $line $start]
- set end [expr {$start + [string length $string]}]
# Mark the word
if {[regexp -start $end -- {\s*\(} $line]} {
$editor tag add c_lang_func $line_number.$start $line_number.$end
- } {
+ } else {
$editor tag add c_lang_var $line_number.$start $line_number.$end
}
}
}
## Inform autocompletion mechanism about possibly newly defined symbol
- # @parm Int line_number - Line number
+ # @parm Int line_number - Line number
# @return void
public method manage_autocompletion_list {line_number} {
# Detect new symbol
@@ -184,7 +244,7 @@ public method manage_autocompletion_list {line_number} {
||
[lsearch -ascii -exact ${::CsyntaxHighlight::keywords} $string] != -1
} then {
- return
+ continue
}
}
@@ -196,9 +256,9 @@ public method manage_autocompletion_list {line_number} {
# Append to the autocompletion list
if {[lsearch -ascii -exact $autocompletion_list($index) $string] == -1} {
lappend autocompletion_list($index) $string
-
$parentObject rightPanel_adjust_symbol_list \
- $line_number $string $index 1
+ $line_number $string $index 1 $this
+ $parentObject rightPanel_sm_select $line_number
}
}
}
@@ -220,7 +280,7 @@ public method manage_autocompletion_list {line_number} {
# 2 - C functions
# 3 - Indirect values
# 4 - Doxygen tags
- # @parm String str - Incomplite instruction or directive
+ # @parm String str - Incomplete instruction or directive
# @parm Int x - Relative X position of the popup window (relative to editor)
# @parm Int y - Relative Y position of the popup window (relative to editor)
# @return void
@@ -281,13 +341,14 @@ private method invoke_completion_popup_window {mode start_idx end_idx} {
# Create lisbox and scrollbar
set frame [frame $win.frame]
- set listbox [ListBox $frame.listbox \
- -relief flat -bd 0 -selectfill 1 \
- -selectbackground {#AAAAFF} \
- -bg white -cursor left_ptr \
+ set listbox [ListBox $frame.listbox \
+ -relief flat -bd 0 -selectfill 0 \
+ -selectbackground {#AAAAFF} \
+ -bg white -cursor left_ptr \
-yscrollcommand "$frame.scrollbar set" \
- -selectmode single -width 0 -height 0 \
- -highlightthickness 0 -padx 2 \
+ -selectmode single -width 0 -height 0 \
+ -highlightthickness 0 -padx 2 \
+ -font $defaultFont_bold \
]
set completion_listbox $listbox
pack $listbox -side left -fill both -expand 1
@@ -316,7 +377,7 @@ private method invoke_completion_popup_window {mode start_idx end_idx} {
set listbox ".completion_win.frame.listbox"
$listbox selection clear
$listbox delete [$listbox items]
- update idle
+ update idletasks
if {$loading || $comp_win_loading_in_p} {
if {!($comp_win_loading_max > 1)} {
@@ -456,7 +517,7 @@ private method invoke_completion_popup_window {mode start_idx end_idx} {
}
# Control sequences
- } {
+ } else {
foreach command ${::ASMsyntaxHighlight::all_controls__with_dolar} {
set shortcmd [string range $command 0 $end]
if {$shortcmd == $str} {
@@ -615,10 +676,10 @@ public method close_completion_popup_window {} {
#+ state of this object
# @return void
proc close_completion_popup_window_NOW {} {
- if {$invoke_com_win_in_p} {return}
- set invoke_com_win_in_p 1
+ if {${::Editor::invoke_com_win_in_p}} {return}
+ set ::Editor::invoke_com_win_in_p 1
- if {$completion_win_opened} {
+ if {${::Editor::completion_win_opened}} {
catch {
grab release .completion_win
}
@@ -627,8 +688,8 @@ proc close_completion_popup_window_NOW {} {
}
}
- set completion_win_opened 0
- set invoke_com_win_in_p 0
+ set ::Editor::completion_win_opened 0
+ set ::Editor::invoke_com_win_in_p 0
}
## Auxiliary method for method "Key"
@@ -788,7 +849,7 @@ private method aux_Key_autocompletion_5 {wordstart wordend} {
## Determinate color for instructions, directives, etc.
# @return void
private method refresh_highlighting_for_autocompletion {} {
- foreach key ${::ASMsyntaxHighlight::hightlight_tags} {
+ foreach key ${::ASMsyntaxHighlight::highlight_tags} {
if {[lindex $key 0] == {tag_instruction}} {
set ins_fg [lindex $key 1]
set ins_font [$editor tag cget tag_instruction -font]
@@ -828,7 +889,7 @@ private method refresh_highlighting_for_autocompletion {} {
}
if {$prog_language == 1} {
- foreach key ${::CsyntaxHighlight::hightlight_tags} {
+ foreach key ${::CsyntaxHighlight::highlight_tags} {
if {[lindex $key 0] == {tag_c_dox_tag}} {
set doxytag_fg [lindex $key 1]
set doxytag_font [$editor tag cget tag_c_dox_tag -font]
@@ -836,3 +897,7 @@ private method refresh_highlighting_for_autocompletion {} {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/commandline.tcl b/lib/editor/commandline.tcl
index 4fe39c3..4e15e0a 100755..100644
--- a/lib/editor/commandline.tcl
+++ b/lib/editor/commandline.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 _COMMANDLINE_TCL ] } {
+set _COMMANDLINE_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements procedures related to editor command line
@@ -50,7 +55,7 @@ public method cmd_line_key {key} {
{Delete} {
if {[llength [$cmd_line tag nextrange sel 1.0]]} {
$cmd_line delete sel.first sel.last
- } {
+ } else {
if {[$cmd_line index insert] != [$cmd_line index {insert lineend}]} {
$cmd_line delete insert {insert+1c}
}
@@ -59,7 +64,7 @@ public method cmd_line_key {key} {
{BackSpace} {
if {[llength [$cmd_line tag nextrange sel 1.0]]} {
$cmd_line delete sel.first sel.last
- } {
+ } else {
if {[$cmd_line index insert] != [$cmd_line index {insert linestart}]} {
$cmd_line delete {insert-1c} insert
}
@@ -149,7 +154,7 @@ public method cmd_line_enter {} {
}
set command [cmd_line_get_possible_cmds $command]
if {$command == {}} {
- Sbar [mc "EDITOR COMMAND LINE: invalid command, type `help list' to get list of avaliable commands"]
+ Sbar [mc "EDITOR COMMAND LINE: invalid command, type `help list' to get list of available commands"]
return
} elseif {[llength $command] > 1} {
Sbar [mc "Ambiguous command"]
@@ -164,8 +169,8 @@ public method cmd_line_enter {} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "char"]
}
if {![llength $args]} {
- cmd_line_help_window {Help} [mc \
- "This is MCU 8051 IDE command line\n\nusage: <b>command \[argumets\]</b>\n\nEnter <b>help list</b> for list of avaliable commands or\n<b>help <STRING command></b> for help for individual command"]
+ cmd_line_help_window [mc "Help"] [mc \
+ "This is MCU 8051 IDE command line\n\nusage: <b>command \[arguments\]</b>\n\nEnter <b>help list</b> for list of available commands or\n<b>help <STRING command></b> for help for individual command"]
return
}
set command [lindex $args 0]
@@ -179,7 +184,7 @@ public method cmd_line_enter {} {
switch -- $command {
{list} {
- cmd_line_help_window [mc "Avaliable commands"] \
+ cmd_line_help_window [mc "Available commands"] \
"<b>d2h</b> [mc {DEC -> HEX}]
<b>d2o</b> [mc {DEC -> OCT}]
<b>d2b</b> [mc {DEC -> BIN}]
@@ -199,7 +204,7 @@ public method cmd_line_enter {} {
<b>breakpoint</b> [mc {Add/Remove breakpoint}]
<b>capitalize</b> [mc {Capitalize selection}]
<b>clear</b> [mc {Clear history}]
- <b>comment</b> [mc {Comment slected text}]
+ <b>comment</b> [mc {Comment selected text}]
<b>copy</b> [mc {Copy selection}]
<b>custom</b> [mc {Custom command}]
<b>cut</b> [mc {Cut selection}]
@@ -236,11 +241,11 @@ public method cmd_line_enter {} {
}
{hibernate} {
cmd_line_help_window [mc "Command hibernate"] [mc \
- "<b>hibernate</b> \[<STRING target-file>\]\nHibernate running program (avaliliable only when simulator is stated).\n\nThis function saves current state of the simulator engine for future resumption. If no target is not specified it will invoke file selection dialog"]
+ "<b>hibernate</b> \[<STRING target-file>\]\nHibernate running program (available only when simulator is stated).\n\nThis function saves current state of the simulator engine for future resumption. If no target is not specified it will invoke file selection dialog"]
}
{resume} {
cmd_line_help_window [mc "Command resume"] [mc \
- "<b>resume</b> \[<STRING source-file>\]\nResume hibernated program (avaliliable only when simulator is stated).\n\nThis function restores previous state of the simulator engine stored in the given file. If no source is not specified it will invoke file selection dialog"]
+ "<b>resume</b> \[<STRING source-file>\]\nResume hibernated program (available only when simulator is stated).\n\nThis function restores previous state of the simulator engine stored in the given file. If no source is not specified it will invoke file selection dialog"]
}
{switch-mcu} {
cmd_line_help_window [mc "Command switch-mcu"] [mc \
@@ -248,15 +253,15 @@ public method cmd_line_enter {} {
}
{set-xcode} {
cmd_line_help_window [mc "Command set-xcode"] [mc \
- "<b>set-xcode</b> <INT size>\nChange capacity of external program memory.\nNote: this command also close CODE memory hexeditor"]
+ "<b>set-xcode</b> <INT size>\nChange capacity of external program memory.\nNote: this command also close CODE memory hex editor"]
}
{set-xdata} {
cmd_line_help_window [mc "Command set-xdata"] [mc \
- "<b>set-xdata</b> <INT size>\nChange capacity of external data memory.\nNote: this command also close XDATA memory hexeditor"]
+ "<b>set-xdata</b> <INT size>\nChange capacity of external data memory.\nNote: this command also close XDATA memory hex editor"]
}
{run} {
cmd_line_help_window [mc "Command run"] [mc \
- "Run simulation (avaliliable only when simulator is stated)"]
+ "Run simulation (available only when simulator is stated)"]
}
{exit} {
cmd_line_help_window [mc "Command exit"] [mc \
@@ -276,7 +281,7 @@ public method cmd_line_enter {} {
}
{help} {
cmd_line_help_window [mc "Command help"] [mc \
- "<b>help</b> <STRING command>\nShows help for the given command\n\n<b>help list</b>\nShows list of avaliable command"]
+ "<b>help</b> <STRING command>\nShows help for the given command\n\n<b>help list</b>\nShows list of available command"]
}
{open} {
cmd_line_help_window [mc "Command open"] [mc \
@@ -304,7 +309,7 @@ public method cmd_line_enter {} {
}
{date} {
cmd_line_help_window [mc "Command date"] [mc \
- "<b>date</b> <STRING format>\nInserts formated date at the current position in text\n\n<b>Format string:</b>\n%% => %\n%a => Weekday name (Mon, Tue, etc.)\n%A => Weekday name (Monday, Tuesday, etc.)\n%b => Month name (Jan, Feb, etc.)\n%B => Full month name\n%C => Year (19 or 20)\n%d => Day of month (01 - 31)\n%D => %m/%d/%y\n%h => Abbreviated month name.\n%H => Hour (00 - 23)\n%I => Hour (01 - 12)\n%j => Day of year (001 - 366)\n%k => Hour (0 - 23)\n%l => Hour (1 - 12).\n%m => Month (01 - 12)\n%M => Minute (00 - 59)\n%n => Newline\n%p => AM/PM\n%R => %H:%M.\n%s => Unix timestamp\n%S => Seconds (00 - 59)\n%t => Tab\n%T => %H:%M:%S.\n%u => Weekday number (Monday = 1, Sunday = 7)\n%w => Weekday number (Sunday = 0, Saturday = 6)\n%y => Year without century (00 - 99)\n%Y => Year with century (e.g. 1459)"]
+ "<b>date</b> <STRING format>\nInserts formatted date at the current position in text\n\n<b>Format string:</b>\n%% => %\n%a => Weekday name (Mon, Tue, etc.)\n%A => Weekday name (Monday, Tuesday, etc.)\n%b => Month name (Jan, Feb, etc.)\n%B => Full month name\n%C => Year (19 or 20)\n%d => Day of month (01 - 31)\n%D => %m/%d/%y\n%h => Abbreviated month name.\n%H => Hour (00 - 23)\n%I => Hour (01 - 12)\n%j => Day of year (001 - 366)\n%k => Hour (0 - 23)\n%l => Hour (1 - 12).\n%m => Month (01 - 12)\n%M => Minute (00 - 59)\n%n => Newline\n%p => AM/PM\n%R => %H:%M.\n%s => Unix timestamp\n%S => Seconds (00 - 59)\n%t => Tab\n%T => %H:%M:%S.\n%u => Weekday number (Monday = 1, Sunday = 7)\n%w => Weekday number (Sunday = 0, Saturday = 6)\n%y => Year without century (00 - 99)\n%Y => Year with century (e.g. 1459)"]
}
{clear} {
cmd_line_help_window [mc "Command clear"] [mc \
@@ -344,7 +349,7 @@ public method cmd_line_enter {} {
}
{toupper} {
cmd_line_help_window [mc "Command toupper"] [mc \
- "Convert selected text to upppercase"]
+ "Convert selected text to uppercase"]
}
{capitalize} {
cmd_line_help_window [mc "Command capitalize"] [mc \
@@ -392,11 +397,11 @@ public method cmd_line_enter {} {
}
{step} {
cmd_line_help_window [mc "Command step"] [mc \
- "Step program (avaliliable only when simulator is stated)"]
+ "Step program (available only when simulator is stated)"]
}
{animate} {
cmd_line_help_window [mc "Command animate"] [mc \
- "Animate program (avaliliable only when simulator is stated)"]
+ "Animate program (available only when simulator is stated)"]
}
{d2h} {
cmd_line_help_window [mc "Command d2h"] [mc \
@@ -459,7 +464,7 @@ public method cmd_line_enter {} {
if {![llength $args]} {
::X::__hibernate
- } {
+ } else {
::X::__hibernate_to [lindex $args 0] $filename
}
Sbar [mc "Success"]
@@ -472,7 +477,7 @@ public method cmd_line_enter {} {
if {![llength $args]} {
::X::__resume
- } {
+ } else {
::X::__resume_from [lindex $args 0] $filename
}
Sbar [mc "Success"]
@@ -486,15 +491,15 @@ public method cmd_line_enter {} {
set arg [string toupper [lindex $args 0]]
if {$arg == {list}} {
set arg {}
- foreach mcu ${::X::avaliable_processors} {
+ foreach mcu ${::X::available_processors} {
append arg $mcu
append arg "\n"
}
cmd_line_help_window {Supported microcontrollers} $arg
- } {
- if {[lsearch ${::X::avaliable_processors} $arg] == -1} {
+ } else {
+ if {[lsearch ${::X::available_processors} $arg] == -1} {
Sbar [mc "EDITOR COMMAND LINE: Unsupported processor `%s'" "$arg"]
- } {
+ } else {
::X::change_processor $arg
}
}
@@ -525,13 +530,13 @@ public method cmd_line_enter {} {
set icode [expr {[lindex [${::X::actualProject} cget -procData] 2] * 1024}]
if {$arg > (0xFFFF - $icode)} {
- Sbar [mc "EDITOR COMMAND LINE: This MCU has CODE memory limit 0x10000 B (65536) (command: %s)"] "set-xdata"
+ Sbar [mc "EDITOR COMMAND LINE: This MCU has CODE memory limit 0x10000 B (65536) (command: %s)"] "set-xcode"
return
}
if {[lindex [${::X::actualProject} cget -procData] 1] != {yes}} {
Sbar [mc "This MCU cannot have connected external program memory"]
- } {
+ } else {
${::X::actualProject} configure -P_option_mcu_xcode $arg
::X::close_hexedit code ${::X::actualProject}
${::X::actualProject} simulator_resize_code_memory $arg
@@ -568,7 +573,7 @@ public method cmd_line_enter {} {
if {[lindex [${::X::actualProject} cget -procData] 0] != {yes}} {
Sbar [mc "This MCU cannot have connected external data memory"]
- } {
+ } else {
${::X::actualProject} configure -P_option_mcu_xdata $arg
::X::close_hexedit xdata ${::X::actualProject}
${::X::actualProject} simulator_resize_xdata_memory $arg
@@ -601,17 +606,17 @@ public method cmd_line_enter {} {
}
if {$fullFileName != {}} {
set dir [file dirname $fullFileName]
- } {
+ } else {
set dir $projectPath
}
set filename [file join $dir [lindex $args 0]]
if {![file exists $filename] || ![file isfile $filename]} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "unindent"]
}
- if {[${X::actualProject} openfile $filename 1 . def def 0 0 {}] != {}} {
- ${X::actualProject} switch_to_last
- update idle
- ${X::actualProject} editor_procedure {} parseAll {}
+ if {[${::X::actualProject} openfile $filename 1 . def def 0 0 {}] != {}} {
+ ${::X::actualProject} switch_to_last
+ update idletasks
+ ${::X::actualProject} editor_procedure {} parseAll {}
Sbar [mc "Success"]
}
}
@@ -639,7 +644,7 @@ public method cmd_line_enter {} {
{date} {
if {[catch {$editor insert insert [clock format [clock seconds] -format $args]}]} {
Sbar [mc "EDITOR COMMAND LINE: Invalid format string"]
- } {
+ } else {
parse [expr {int([$editor index insert])}]
Sbar [mc "Success"]
}
@@ -647,7 +652,7 @@ public method cmd_line_enter {} {
{char} {
if {[llength $args] > 1} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "char"]
- } {
+ } else {
Sbar [mc "Success"]
}
set char [lindex $args 0]
@@ -661,7 +666,7 @@ public method cmd_line_enter {} {
{goto} {
if {[llength $args] > 1} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "goto"]
- } {
+ } else {
Sbar [mc "Success"]
}
set target_line [lindex $args 0]
@@ -672,7 +677,7 @@ public method cmd_line_enter {} {
}
if {$target_line > [editor_linescount]} {
Sbar [mc "Target line out of range"]
- } {
+ } else {
goto $target_line
Sbar [mc "Success"]
}
@@ -680,7 +685,7 @@ public method cmd_line_enter {} {
{replace} {
if {[llength $args] > 2} {
Sbar [mc "EDITOR COMMAND LINE: wrong # args (command: %s)" "replace"]
- } {
+ } else {
Sbar [mc "Success"]
}
set pattern [lindex $args 0]
@@ -754,8 +759,8 @@ public method cmd_line_enter {} {
set result [find $fromCursor $Backwards $regExp $noCase $inSelection 1.0 $pattern]
if {[lindex $result 0] == -1} {
Sbar [mc "String not found: %s" [lindex $result 1]]
- } {
- Sbar [mc "Found %s occurences" [lindex $result 2]]
+ } else {
+ Sbar [mc "Found %s occurrence" [lindex $result 2]]
}
}
{cut} {
@@ -850,14 +855,14 @@ public method cmd_line_enter {} {
command_without_args $args
}
default {
- Sbar [mc "EDITOR COMMAND LINE: invalid command, type `help list' to get list of avaliable commands"]
+ Sbar [mc "EDITOR COMMAND LINE: invalid command, type `help list' to get list of available commands"]
}
}
# Manage command line history
if {int([$cmd_line index end-1l]) == int([$cmd_line index insert])} {
$cmd_line insert {insert lineend} "\n"
- } {
+ } else {
set txt [$cmd_line get {insert linestart} {insert lineend}]
$cmd_line mark set insert end
$cmd_line insert insert $txt
@@ -959,9 +964,9 @@ private method command_without_args {args} {
}
## Highlight current contents of editor command line
- # @parm Bool = 0 - Disable popup-based completion
+ # @parm Bool no_completion=0 - Disable popup-based completion
# @return void
-private method cmd_line_highlight args {
+private method cmd_line_highlight {{no_completion 0}} {
# Remove all tags from command line
foreach tag {tag_cmd tag_argument tag_option tag_error} {
$cmd_line tag remove $tag {insert linestart} {insert lineend}
@@ -988,7 +993,7 @@ private method cmd_line_highlight args {
if {[llength $command] == 1} {
$cmd_line tag add tag_cmd $startIdx $lineNumber.$endIdx
} elseif {$endIdx && [llength $command] > 1 && [$cmd_line compare $lineNumber.$endIdx == insert]} {
- if {$cline_completion && $args != 1} {
+ if {$cline_completion && !$no_completion} {
# Automaticaly complete command
set possible_cmd [lindex $command 0]
set insert [$cmd_line index insert]
@@ -1012,7 +1017,7 @@ private method cmd_line_highlight args {
incr endIdx [string length $opt]
if {[lsearch $commands_with_option $command] != -1} {
$cmd_line tag add tag_option $lineNumber.$startIdx $lineNumber.$endIdx
- } {
+ } else {
$cmd_line tag add tag_error $lineNumber.$startIdx $lineNumber.$endIdx
}
}
@@ -1078,7 +1083,7 @@ private method cmd_line_menu_postdown {commands} {
%W selection set"
# Finalize window initialization (global grab)
- update idle
+ update idletasks
catch {
grab -global $win
raise $win
@@ -1100,7 +1105,7 @@ private method cmd_line_menu_postdown {commands} {
public method cmd_line_down {} {
if {![winfo exists $cmd_line_listbox]} {
return 0
- } {
+ } else {
$cmd_line_listbox selection set [$cmd_line_listbox item 0]
focus -force $cmd_line_listbox
return 1
@@ -1167,14 +1172,14 @@ private method cmd_line_help_window {header content} {
}
# Create window
- set win [toplevel .editor_cmd_help_widow -bg {#EEEEEE}]
+ set win [toplevel .editor_cmd_help_widow -bg ${::COMMON_BG_COLOR}]
wm overrideredirect $win 1
bind $win <ButtonPress-1> "$this cmd_line_win_B1 %X %Y"
bind $win <FocusOut> "$this cmd_line_menu_close_now"
# Create header
- set header_frame [frame $win.header]
+ set header_frame [frame $win.header -bg {#AAAAFF}]
pack [label $header_frame.lbl_heder \
-text $header -fg {#FF0000} \
-bg {#AAAAFF} -bd 0 -anchor w \
@@ -1207,7 +1212,7 @@ private method cmd_line_help_window {header content} {
# Create map of bold font tags
regsub -all -line {^\t+} $content {} content
set bold_tag_map {}
- while 1 {
+ while {1} {
set tag_pair {}
set idx [string first {<b>} $content]
@@ -1241,7 +1246,7 @@ private method cmd_line_help_window {header content} {
# Show the window
set x [winfo rootx $cmd_line]
set y [expr {[winfo rooty $cmd_line] + [winfo height $cmd_line]}]
- update idle
+ update idletasks
if {150 > ([winfo height .] - $y)} {
incr y -150
incr y -[winfo height $cmd_line]
@@ -1255,21 +1260,25 @@ private method cmd_line_help_window {header content} {
}
## Focus on editor / editor command line
- # @parm Bool = 0 - Do not call proc. "cmd_line_on"
+ # @parm Bool no_cmd_line_on=0 - Do not call proc. "cmd_line_on"
# @return void
-public method cmd_line_focus args {
+public method cmd_line_focus {{no_cmd_line_on 0}} {
# Show command line
if {![winfo viewable $cmd_line]} {
pack $cmd_line -side top -fill x
- if {$args != 1} {
+ if {!$no_cmd_line_on} {
${::X::actualProject} cmd_line_on
}
}
if {[focus] == $cmd_line} {
focus $editor
- } {
+ } else {
focus $cmd_line
}
update
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/editor.tcl b/lib/editor/editor.tcl
index d4d9bec..e375386 100755..100644
--- a/lib/editor/editor.tcl
+++ b/lib/editor/editor.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 _EDITOR_TCL ] } {
+set _EDITOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements source code editor with syntax highligh and
@@ -46,23 +51,6 @@ source "${::LIB_DIRNAME}/editor/LSTsyntaxhighlight.tcl"
set ::editor_search_count 0
class Editor {
-
- # Load procedures related to editor command line
- source "${::LIB_DIRNAME}/editor/commandline.tcl"
-
- # Load procedures related to exports to other data formats
- source "${::LIB_DIRNAME}/editor/exports.tcl"
-
- # Load autocompletion related procedures
- source "${::LIB_DIRNAME}/editor/autocompletion.tcl"
-
- # Load general purpose procedures
- source "${::LIB_DIRNAME}/editor/generalproc.tcl"
-
- # Load event handlers
- source "${::LIB_DIRNAME}/editor/eventhandlers.tcl"
-
-
## COMMON
## Editor to use
# 0 - Native editor
@@ -118,32 +106,36 @@ class Editor {
{tag_simulator_curr #AAFFAA}
{tag_error_line #FFDDDD}
{tag_trailing_space #E8FFF0}
+ {tag_breakpoint_INVALID #888888}
}
# Font for command line: Normal help window text
- common cl_hw_nrml_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
+ common cl_hw_nrml_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
]
# Font for command line: Bold help window text
- common cl_hw_bold_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- -weight bold \
+ common cl_hw_bold_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
]
# Font for command line: Subheader in help window text
- common cl_hw_hdr_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- -weight bold \
+ common cl_hw_hdr_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
]
# Font for command line: Main header in help window text
- common cmd_line_win_font [font create \
- -size -17 -weight bold \
- -family {helvetica} \
+ common cmd_line_win_font [font create \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica} \
]
- common cmd_line_fontSize 14 ;# Font size for command line
- common cmd_line_fontFamily $::DEFAULT_FIXED_FONT ;# Font family for command line
+ # Font size for command line
+ common cmd_line_fontSize [expr {int(14 * $::font_size_factor)}]
+ # Font family for command line
+ common cmd_line_fontFamily $::DEFAULT_FIXED_FONT
# Font for editor command line
common cmd_line_font [font create \
-family $cmd_line_fontFamily \
@@ -174,8 +166,13 @@ class Editor {
Unindent Uppercase Lowercase Capitalize
}
- common fontSize 13 ;# Default font size
- common fontFamily $::DEFAULT_FIXED_FONT ;# Default font family
+ # Maximum width of the tab character, measured in number of spaces
+ common tab_width 8
+
+ # Default font size
+ common fontSize [expr {int(13 * $::font_size_factor)}]
+ # Default font family
+ common fontFamily $::DEFAULT_FIXED_FONT
# Default font for editor
common defaultFont \
@@ -193,17 +190,17 @@ class Editor {
common defaultCharWidth 0 ;# Width of one character of the default font
common defaultCharHeight 0 ;# Height of one character of the default font
# Font for status bar (Normal)
- common statusBarFont \
- [font create \
- -size -12 \
- -family $::DEFAULT_FIXED_FONT \
+ common statusBarFont \
+ [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family $::DEFAULT_FIXED_FONT \
]
# Font for status bar (Bold)
- common statusBarBoldFont \
- [font create \
- -size -12 \
- -weight bold \
- -family $::DEFAULT_FIXED_FONT \
+ common statusBarBoldFont \
+ [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ -family $::DEFAULT_FIXED_FONT \
]
# Definition of editor popup menu
common EDITORMENU {
@@ -257,17 +254,17 @@ class Editor {
{checkbutton "Bookmark" {$edit:bookmark} {::Editor::bookmark} 1 0 0
{Bookmark ${::Editor::pmenu_cline}}}
{separator}
- {command "Configure panel" "" 0 {configDialogs_mkDialog Colors}
+ {command "Configure panel" "" 0 {configDialogues_mkDialog Colors}
{configure} "Invoke editor configuration dialog"}
{command "Hide" "" 0 {show_hine_IconB}
{2leftarrow} "Hide this panel"}
}
# Definition of popup menu for line numbers
common LNMENU {
- {checkbutton "Breakpont" {$edit:breakpoint} {::Editor::breakpoint} 1 0 0
+ {checkbutton "Breakpoint" {$edit:breakpoint} {::Editor::breakpoint} 1 0 0
{Breakpoint ${::Editor::pmenu_cline}}}
{separator}
- {command "Configure panel" "" 0 {configDialogs_mkDialog Colors}
+ {command "Configure panel" "" 0 {configDialogues_mkDialog Colors}
{configure} "Invoke editor configuration dialog"}
{command "Hide panel" "" 0 {show_hine_LineN}
{2leftarrow} "Hide this panel"}
@@ -283,7 +280,7 @@ class Editor {
{view_remove} ""}
{separator}
{command "Back" {$edit:prev} 0 {__prev_editor_from_pmenu}
- {left} "Go to prevoius file in the file list"}
+ {left} "Go to previous file in the file list"}
{command "Forward" {$edit:next} 0 {__next_editor_from_pmenu}
{right} "Go to next file in the file list"}
}
@@ -292,11 +289,11 @@ class Editor {
public variable editor ;# text widget identifier
public variable ed_sc_frame ;# frame identifier (need packing)
public variable show_iconBorder 1 ;# on/off indicator for Icon Border (bool)
- public variable show_lineNum 1 ;# on/off indicator for Line NUmbers (bool)
+ public variable show_lineNum 1 ;# on/off indicator for Line Numbers (bool)
public variable iconBorder ;# Identifier of Icon Border text widget
public variable lineNumbers ;# Identifier of Line Numbers text widget
public variable scrollbar ;# Identifier of scrollbar widget
- public variable lastEnd 1 ;# Last end index of Edior text widget (for speed optimalization)
+ public variable lastEnd 2 ;# Last end index of Editor text widget (for speed optimization)
public variable Sbar_lock_file ;# Identifier of image label widget at the left site of status bar
public variable Sbar_sim_mode ;# Identifier of label widget at the left site of status bar
public variable Sbar_ssim_mode
@@ -307,7 +304,7 @@ class Editor {
public variable Sbar_total ;# ID of label showing total number of lines
public variable Sbar_image ;# Identifier of floppy disk icon at the middle site of status bar
public variable Sbar_fileName ;# Identifier of the text of filename at the right site of status bar
- public variable Sbar_prog_lang ;# ID of text specifing file type at the right site of status bar
+ public variable Sbar_prog_lang ;# ID of text specifying file type at the right site of status bar
public variable fullFileName ;# Full file name of the current file ("" == untitled)
public variable filename ;# Name of currently opened file or 'untitled'
public variable modified 0 ;# Boolean value indicating than the text has been modified since last save
@@ -316,6 +313,7 @@ class Editor {
public variable ro_mode 0 ;# Bool: Read only mode
## PRIVATE
+ private variable file_change_notif_flg 0 ;# Bool: The opened file was modified on disk by another program
private variable finishigh_hg_dlg_wdg {} ;# Widget: Finishing highlight dialog
private variable finishigh_hg_dlg_tmr {} ;# Timer: Finishing highlight dialog
private variable object_initialized 0 ;# Bool: Flag "Object initialized"
@@ -335,7 +333,7 @@ class Editor {
private variable left_frame_L ;# ID of frame containing Line Numbers
private variable left_frame_R ;# ID of frame containing Icon Border
private variable LN_menu ;# Identifier of popup menu for line numbers
- private variable frozen 0 ;# True if editor is in simulator mode
+ private variable frozen 0 ;# Bool: True if the editor is in simulator mode
private variable getDataAsXHTML_abort 0 ;# Set this variable to 1 to immediate stop export to XHTML
private variable getDataAsLaTeX_abort 0 ;# Set this variable to 1 to immediate stop export to LaTeX
private variable changeLCase_abort 0 ;# Set this variable to 1 to immediate stop changing letter case
@@ -356,7 +354,7 @@ class Editor {
private variable autosave_timer {} ;# ID of autosave timer (command "after")
private variable key_handler_buffer {} ;# List: Buffer for <Key> event handler
private variable key_handler_in_progress 0 ;# Bool: <Key> event handler in progress
- private variable statusbar_menu_config {} ;# List: Statusbra menu configuration list
+ private variable statusbar_menu_config {} ;# List: Status bar menu configuration list
private variable auto_switching_lock 0 ;# Bool: Automatic file switching enabled
private variable selection_in_progress 0 ;# Bool: Procedure "editor_selection" in progress
private variable selection_mode 0 ;# Bool: Block selection mode flag
@@ -373,49 +371,32 @@ class Editor {
private variable top_frame_idx 0 ;# Int: Unique number of container frame for embedded editor
private variable pid {} ;# Int: Process indentifier of embedded external editor (e.g. Vim)
- ## Array: Strings avaliable for autocompletion
- # Index 0 - Labels in assembly
- # Index 1 - Constants/variables
- # Index 2 - C variables
- # Index 3 - Macros
- # Index 4 - SFR's
- # Index 5 - Expression symbols
- # Index 6 - Doxygen tags
- # Index 7 - C Functions
- common invoke_com_win_in_p 0 ;# Bool: invoke_completion_popup_window in progress
- common completion_win_opened 0 ;# Bool: Editor popup-based completion window opended
- private variable autocompletion_list
- private variable completion_win_str_i 1.0 ;# TextIndex: String to complete - start index
- private variable completion_win_end_i 1.0 ;# TextIndex: String to complete - end index
- private variable completion_win_mode 0 ;# Int: Completion window mode
- private variable comp_win_loading_in_p 0 ;# Bool: Completion window list loading is in progress
- private variable comp_win_loading_max 1 ;# Int: Maximum for progressbar in the completion window
- private variable macl_invocations 0 ;# Int: Number of invocations of "manage_autocompletion_list"
- private variable doxytag_fg {#000000} ;# Color: Highlight color for doxygen tag
- private variable indirect_fg {#000000} ;# Color: Highlight color for indirect address
- private variable symbol_fg {#000000} ;# Color: Highlight color for asm. symbol
- private variable sfr_fg {#000000} ;# Color: Highlight color for SFR
- private variable label_fg {#000000} ;# Color: Highlight color for asm. label
- private variable macro_fg {#000000} ;# Color: Highlight color for asm. macro
- private variable const_fg {#000000} ;# Color: Highlight color for asm. const
- private variable dir_fg {#000000} ;# Color: Highlight color for asm. directive
- private variable cs_fg {#000000} ;# Color: Highlight color for constrol sequence
- private variable ins_fg {#000000} ;# Color: Highlight color for instruction
- private variable doxytag_font $defaultFont ;# Font: Font for doxygen tag
- private variable indirect_font $defaultFont ;# Font: Font for indirect address
- private variable symbol_font $defaultFont ;# Font: Font for asm. symbol
- private variable sfr_font $defaultFont ;# Font: Font for SFR
- private variable label_font $defaultFont ;# Font: Font for asm. label
- private variable macro_font $defaultFont ;# Font: Font for asm. macro
- private variable const_font $defaultFont ;# Font: Font for asm. const
- private variable dir_font $defaultFont ;# Font: Font for asm. directive
- private variable cs_font $defaultFont ;# Font: Font for constrol sequence
- private variable ins_font $defaultFont ;# Font: Font for instruction
+
+
+ # Load procedures related to editor command line
+ source "${::LIB_DIRNAME}/editor/commandline.tcl"
+
+ # Load procedures related to exports to other data formats
+ source "${::LIB_DIRNAME}/editor/exports.tcl"
+
+ # Load autocompletion related procedures
+ source "${::LIB_DIRNAME}/editor/autocompletion.tcl"
+
+ # Load general purpose procedures
+ source "${::LIB_DIRNAME}/editor/generalproc.tcl"
+
+ # Load event handlers
+ source "${::LIB_DIRNAME}/editor/eventhandlers.tcl"
+
+ # Spell checker interface
+ source "${::LIB_DIRNAME}/editor/spell_check.tcl"
+
+
## Object constructor
# @parm Bool create_tags - Create highlighting tags
- # @parm String eol_char - EOL (one of {lf cr crlf})
- # @parm String enc - Character encoding (some iso-8859-x or utf-8)
+ # @parm String eol_char - EOL (one of {lf cr crlf})
+ # @parm String enc - Character encoding (some iso-8859-x or utf-8)
# @parm Bool read_only - Read only flag
# @parm Bool switch_lock - Automatic file switching enabled
# @parm widget parentobject - Reference to parent object
@@ -427,6 +408,14 @@ class Editor {
constructor {create_tags eol_char enc read_only switch_lock parentobject fileName filepath Cmd_prefix data sh} {
close_completion_popup_window_NOW
+ set bold_font [font create -size -$fontSize -family $fontFamily -weight {bold}]
+ set italic_font [font create -size -$fontSize -family $fontFamily -slant {italic}]
+ if {[font metrics $bold_font -displayof . -linespace] < [font metrics $italic_font -displayof . -linespace]} {
+ set defaultFont_bold $italic_font
+ } else {
+ set defaultFont_bold $bold_font
+ }
+
# Configure specific ttk styles
ttk::style configure Editor_DarkBg.TButton \
-background {#DDDDDD} \
@@ -435,7 +424,7 @@ class Editor {
-relief flat
ttk::style map Editor_DarkBg.TButton \
-relief [list active raised !active flat]
-
+
# increment instance counter
incr count
@@ -455,11 +444,11 @@ class Editor {
set parentObject $parentobject ;# Identifier parent GUI component (some frame widget)
set fullFileName $filepath ;# Full file name (including path) of current file
set filename $fileName ;# Name of currently opened file or 'untitled'
- refresh_avaliable_SFR
+ refresh_available_SFR
if {$sh == {}} {
determinate_prog_lang 0
- } {
+ } else {
set prog_language_old $prog_language
set prog_language $sh
}
@@ -472,19 +461,22 @@ class Editor {
}
# Create frames
- set ed_sc_frame [frame .editor_frame$count]
- set top_frame [frame $ed_sc_frame.editor_top_frame -relief sunken -bd 1]
- set left_frame [frame $top_frame.editor_left_frame]
- set left_frame_L [frame $left_frame.left -bg $iconBorder_bg]
- set left_frame_R [frame $left_frame.right -bg $lineNumbers_bg]
- set bottom_frame [frame $ed_sc_frame.bottom_frame]
- set statusbar [frame $bottom_frame.editor_status -bg #DDDDDD]
+ set ed_sc_frame [frame .editor_frame$count]
+ set top_frame [frame $ed_sc_frame.editor_top_frame -relief sunken -bd 1]
+ set left_frame [frame $top_frame.editor_left_frame]
+ set left_frame_L [frame $left_frame.left -bg $iconBorder_bg]
+ set left_frame_R [frame $left_frame.right -bg $lineNumbers_bg]
+ set bottom_frame [frame $ed_sc_frame.bottom_frame]
+ set statusbar [frame $bottom_frame.editor_status -bg #DDDDDD]
# Create command line
- set cmd_line [text $bottom_frame.cmd_line \
- -bd 1 -bg #FFFFFF -highlightcolor #8888FF \
- -highlightthickness 1 -height 1 \
- -font $cmd_line_font \
+ set cmd_line [text $bottom_frame.cmd_line \
+ -bd 1 \
+ -bg {#FFFFFF} \
+ -highlightcolor {#8888FF} \
+ -highlightthickness 1 \
+ -height 1 \
+ -font $cmd_line_font \
]
setStatusTip -widget $cmd_line \
-text [mc "Editor command line, type `help' for more"]
@@ -537,8 +529,9 @@ class Editor {
# Create "Editor"
frame $top_frame.f -bd 0 -bg $normal_text_bg -cursor xterm
+
+ set tab_width_un [expr {$tab_width * [font measure $defaultFont_bold 0]}]
set editor [text $top_frame.f.editor \
- -yscrollcommand "$this scrollSet" \
-bg $normal_text_bg \
-font $defaultFont_bold \
-undo 1 -exportselection 1 \
@@ -547,6 +540,7 @@ class Editor {
-selectborderwidth 1 \
-bd 0 -relief flat \
-tabstyle wordprocessor \
+ -tabs [list $tab_width_un left] \
]
bind $top_frame.f <Button-1> "$this click_under_editor %x %y; break"
bind $top_frame.f <Button-4> "$this scroll scroll -3 units; break"
@@ -581,21 +575,21 @@ class Editor {
pack $top_frame -side top -fill both -expand 1
## Create statusbar
- set stat_menu $statusbar.popup_menu
+ set stat_menu $statusbar.popup_menu
set status_left [frame $statusbar.editor_status_left -bg #DDDDDD]
- set status_middle [frame $statusbar.editor_status_middle -width 16 -bg #DDDDDD -width 20]
+ set status_middle [frame $statusbar.editor_status_middle -width 16 -bg #DDDDDD]
set status_right [frame $statusbar.editor_status_right -bg #DDDDDD]
set ins_mode_lbl [Label $statusbar.ins_mode_lbl \
- -text [mc "INS"] -fg #000000 -pady 0 \
- -bg #DDDDDD -cursor hand2 \
- -helptext [mc "Insertion mode"] \
- -font $statusBarBoldFont \
+ -text [mc "INS"] -fg #000000 -pady 0 \
+ -bg #DDDDDD -cursor hand2 \
+ -helptext [mc "Insertion mode"] \
+ -font $statusBarBoldFont \
]
set sel_mode_lbl [Label $statusbar.sel_mode_lbl \
- -text [mc "NORM"] -fg #000000 -pady 0 \
- -bg #DDDDDD -cursor hand2 \
- -helptext [mc "Selection mode"] \
- -font $statusBarBoldFont -width 7 \
+ -text [mc "NORM"] -fg #000000 -pady 0 \
+ -bg #DDDDDD -cursor hand2 \
+ -helptext [mc "Selection mode"] \
+ -font $statusBarBoldFont -width 7 \
]
setStatusTip -widget $sel_mode_lbl -text [mc "Selection mode -- BLK == block; NORM == normal"]
bind $sel_mode_lbl <Button-1> "$this switch_sel_mode"
@@ -603,7 +597,7 @@ class Editor {
pack $status_left -side left -padx 10
pack $status_middle -side left
pack $ins_mode_lbl -side left -padx 5
- pack $sel_mode_lbl -side left -padx 5
+ pack $sel_mode_lbl -side left -padx 5 -pady 3
pack $status_right -side right -fill x -padx 10
# Frame for "Line: x Col: x Total: x"
@@ -715,6 +709,7 @@ class Editor {
}
# Create text tags
+ $editor tag configure tag_wrong_spelling -underline 1
if {$create_tags} {
create_highlighting_tags
}
@@ -766,6 +761,10 @@ class Editor {
bind $editor <Button-4> "$this scroll scroll -3 units; break"
bind $editor <Button-5> "$this scroll scroll +3 units; break"
+ bind $editor <XF86Back> {::X::__prev_editor}
+ bind $editor <XF86Forward> {::X::__next_editor}
+ bind $editor <XF86Reload> {::X::__reload}
+
# Other
foreach key {
<Double-Shift-Button-1> <Shift-Button-1>
@@ -815,6 +814,8 @@ class Editor {
$this recalc_status_counter {}
}
break"
+ bind $editor <Control-Shift-Up> "$this control_shift_updown 1; break"
+ bind $editor <Control-Shift-Down> "$this control_shift_updown 0; break"
bind $editor <Control-Insert> "$this copy; break"
bind $editor <Shift-Insert> "$this paste; break"
bind $editor <Shift-Delete> "$this cut; break"
@@ -822,6 +823,8 @@ class Editor {
bind $editor <Control-Key-Up> "$this control_up; break"
bind $editor <Key-Down> "$this down; break"
bind $editor <Key-Up> "$this up; break"
+ bind $editor <Control-Key-Home> "$this control_home; break"
+ bind $editor <Control-Key-End> "$this control_end; break"
bind $editor <Key-Home> "$this home_press; break"
bind $editor <Shift-Key-Home> "$this shift_home; break"
bind $editor <Key-Insert> "$this switch_ins_ovr; break"
@@ -842,7 +845,7 @@ class Editor {
bind $editor <Shift-KP_Enter> "$this shift_enter; break"
bind $editor <Return> "$this enter; break"
bind $editor <KP_Enter> "$this enter; break"
- bind $editor <Key> "$this Key %A; break"
+ bind $editor <Key> "$this Key %A %K; break"
bind $editor <KeyRelease> "$this KeyRelease %K; break"
bind $editor <ButtonRelease-3> "$this popupMenu %X %Y %x %y; break"
bind $editor <Key-Menu> "$this Key_Menu; break"
@@ -897,17 +900,20 @@ class Editor {
update
break"
bind $editor <Button-1> "
+ # Check spelling on the line which we are now leaving
+ $this spellcheck_check_all \[expr {int(\[%W index insert\])}\]
+
[bind Text <Button-1>]
$this rightPanel_adjust \[expr {int(\[%W index insert\])}\]
$this resetUpDownIndex
- $this recalc_status_counter {%x %y}
+ $this recalc_status_counter
focus -force $editor
break"
bind $editor <B1-Motion> "
[bind Text <B1-Motion>]
$this rightPanel_adjust \[expr {int(\[%W index @%x,%y\])}\]
$this resetUpDownIndex
- $this recalc_status_counter {%x %y}
+ $this recalc_status_counter
break"
bind $editor <<Selection>> "$this editor_selection; break"
@@ -957,7 +963,6 @@ class Editor {
bind $editor <FocusIn> "$parentObject filelist_editor_selected $this"
bind $cmd_line <FocusIn> "$parentObject filelist_editor_selected $this"
-
# Set event bindings for "Line numbers"
bind $lineNumbers <Button-1> "
$parentObject filelist_editor_selected $this
@@ -989,15 +994,19 @@ class Editor {
bindtags $iconBorder [list $iconBorder . all]
# Finalize initialization
+ $editor configure -yscrollcommand "$this scrollSet"
set object_initialized 1
change_RO_MODE $ro_mode
+
+ # Start watching for changes in the file
+ FSnotifications::watch $fullFileName [list ::Editor::file_change_notif $this]
}
## Object destructor
destructor {
if {$editor_to_use} {
kill_childern
- } {
+ } else {
# Stop autosave timer
catch {
after cancel $autosave_timer
@@ -1051,21 +1060,36 @@ class Editor {
public method refresh_font_settings {} {
if {$editor_to_use} {return}
+ # Set new font specification variables
+ set defaultCharHeight_org $defaultCharHeight
+ set defaultFont [font create -size -$fontSize -family $fontFamily]
+ set bold_font [font create -size -$fontSize -family $fontFamily -weight {bold}]
+ set italic_font [font create -size -$fontSize -family $fontFamily -slant {italic}]
+ if {[font metrics $bold_font -displayof $editor -linespace] < [font metrics $italic_font -displayof $editor -linespace]} {
+ set defaultFont_bold $italic_font
+ } else {
+ set defaultFont_bold $bold_font
+ }
+ set defaultCharWidth [font measure $defaultFont_bold -displayof $editor { }]
+ set defaultCharHeight [font metrics $defaultFont_bold -displayof $editor -linespace]
+
# Remove all text tags
foreach tag [$editor tag names] {
if {[lsearch {
sel tag_current_line tag_bookmark
- tag_breakpoint tag_simulator_curr tag_error_line
+ tag_breakpoint tag_breakpoint_INVALID tag_simulator_curr
+ tag_error_line
} $tag] != -1
} then {
break
}
$editor tag remove $tag 1.0 end
}
- # Change fonts
+ # Change fonts and tab width
+ set tab_width_un [expr {$tab_width * [font measure $defaultFont_bold 0]}]
$iconBorder configure -font $defaultFont_bold
$lineNumbers configure -font $defaultFont_bold
- $editor configure -font $defaultFont_bold
+ $editor configure -font $defaultFont_bold -tabs [list $tab_width_un left]
$lineNumbers tag configure right -justify right
$lineNumbers tag configure center -justify center
@@ -1074,19 +1098,13 @@ class Editor {
# Enable writing to the left border
$iconBorder configure -state normal
- # Set new font
- set defaultCharHeight_org $defaultCharHeight
- set defaultFont [font create -size -$fontSize -family $fontFamily]
- set defaultFont_bold [font create -size -$fontSize -family $fontFamily -weight {bold}]
- set defaultCharWidth [font measure $defaultFont_bold -displayof $editor { }]
- set defaultCharHeight [font metrics $defaultFont_bold -displayof $editor -linespace]
# Adjust bookmark images
if {$defaultCharHeight_org != $defaultCharHeight} {
set indexes {}
if {$defaultCharHeight_org < 9} {
set idx 1.0
set idx_prev $idx
- while 1 {
+ while {1} {
set idx [$iconBorder search -exact -- {*} $idx]
if {$idx == {}} {break}
if {[$iconBorder compare $idx_prev >= $idx]} {break}
@@ -1094,7 +1112,7 @@ class Editor {
set idx_prev $idx
set idx [$iconBorder index "$idx+1c"]
}
- } {
+ } else {
foreach img [$iconBorder image names] {
lappend indexes [$iconBorder index $img]
}
@@ -1104,10 +1122,10 @@ class Editor {
$iconBorder delete $idx "$idx+1c"
$iconBorder insert $idx {*}
}
- } {
+ } else {
if {$defaultCharHeight < 15} {
set image {dot}
- } {
+ } else {
set image {bookmark}
}
foreach idx $indexes {
@@ -1122,7 +1140,7 @@ class Editor {
$iconBorder configure -state disabled
# Reset line wrap settings
set highlighted_lines [string repeat 0 [string bytelength $highlighted_lines]]
- update idle
+ update idletasks
highlight_visible_area
# Adjust editor height
@@ -1135,7 +1153,7 @@ class Editor {
if {$ins_ovr_mode} {
$ins_mode_lbl configure -text [mc "INS"] -fg #000000
$editor configure -blockcursor 0
- } {
+ } else {
$ins_mode_lbl configure -text [mc "OVR"] -fg #FF0000
$editor configure -blockcursor 1
}
@@ -1168,7 +1186,7 @@ class Editor {
## Determinate whether editor text has been modified
# and adjust internal variables
# @parm bool force - 1: "I'm sure it has been modified !"
- # 0: "discover it automaticaly"
+ # 0: "discover it automatically"
# @return bool - a new modified flag or {}
public method recalc_status_modified {force} {
@@ -1189,11 +1207,11 @@ class Editor {
catch {
after cancel $autosave_timer
}
- set autosave_timer [after [expr {$autosave * 60000}] [list $this save]]
+ set autosave_timer [after [expr {$autosave * 60000}] "catch {$this save}"]
}
# Not modifed
- } {
+ } else {
# Adjust editor status bar
pack forget $Sbar_image
@@ -1212,24 +1230,18 @@ class Editor {
return $modified
}
- ## Call ::configDialogs::mkDialog $args
+ ## Call ::configDialogues::mkDialog $args
# @return void
- public method configDialogs_mkDialog args {
- ::configDialogs::editor::mkDialog $args
+ public method configDialogues_mkDialog args {
+ ::configDialogues::editor::mkDialog $args
}
## Recalculate variables related to bookmarks, line numbers and list of highlighted lines
- # @parm Bool force = 1 - perform recalcutaion even if length of text wasn't changed
+ # @parm Bool force=1 - perform recalcutaion even if length of text wasn't changed
# @return bool - 0: failed; 1: successful
- public method recalc_left_frame args {
+ public method recalc_left_frame {{force 0}} {
if {$editor_to_use} {return}
- # Parse arguments
- set force [lindex $args 0]
- if {$force == {}} {
- set force 0
- }
-
# Determinate editor lines count and End index
set End [$editor index end]
set Tlines [expr {int($End)}]
@@ -1245,8 +1257,7 @@ class Editor {
incr Tlines -1
# Determinate iconBorder lines count - 1
- set Ilines [expr {int([$iconBorder index end]) - $number_of_wraps}]
- incr Ilines -1
+ set Ilines [expr {int([$iconBorder index end]) - $number_of_wraps - 1}]
# Remove wrap markers from line numbers
if {$number_of_wraps && ($Ilines != $Tlines)} {
@@ -1315,13 +1326,13 @@ class Editor {
$parentObject rightPanel_shift_symbols $Actline [expr {$Actline - $diff - 1}]
# rewrite breakpoints
- rewrite_breakpoint_tags
+ rewrite_breakpoint_tags 1
## Some lines have been added
} elseif {$Ilines < $Tlines} {
# Determinate how many lines should be added
- set diff $Tlines
- incr diff -$Ilines
+ set diff [expr {$Tlines - $Ilines}]
+
set ins [string repeat "\n" $diff]
set BMStr [string range [string repeat {0 } $diff] 0 end-1]
set insIndex $Actline
@@ -1379,8 +1390,8 @@ class Editor {
$editor tag add tag_bookmark [expr {$insIndex - 1}].0 $insIndex.0
}
- } {
- # Adjust list of highlighted lines
+ } else {
+ # Adjust list of lighted lines
set highlighted_lines [string replace \
$highlighted_lines $insIndex $insIndex \
[string repeat 0 [expr {$diff + 1}]]]
@@ -1409,7 +1420,7 @@ class Editor {
$iconBorder configure -state disabled
# rewrite breakpoints
- rewrite_breakpoint_tags
+ rewrite_breakpoint_tags 1
}
## Recalculate Line Numbers
@@ -1426,7 +1437,7 @@ class Editor {
if {$Llines > $Tlines} { ;# too many lines -> remove some ones
$lineNumbers delete $End end
- } elseif {$Llines < $Tlines} { ;# not enought lines -> add some ones
+ } elseif {$Llines < $Tlines} { ;# not enough lines -> add some ones
# Create string to insert to Line Numbers
set ins {}
for {set i [expr {$Llines + 1}]} {$i <= $Tlines} {incr i} {
@@ -1444,16 +1455,15 @@ class Editor {
# Restore wrap markers
if {$number_of_wraps} {
set remaining $number_of_wraps
- set i 1
- foreach wrap $map_of_wraped_lines {
+ for {set i [expr {[llength $map_of_wraped_lines] - 1}]} {$i > 0} {incr i -1} {
+ set wrap [lindex $map_of_wraped_lines $i]
if {$wrap > 0} {
- $lineNumbers insert $i.0 [string repeat "$wrap_char\n" $wrap]
- $lineNumbers tag add center $i.0 [expr {$i + $wrap}].0
- incr i $wrap
+ set ln [expr {$i + 1}]
+ $lineNumbers insert $ln.0 [string repeat "$wrap_char\n" $wrap]
+ $lineNumbers tag add center $ln.0 [expr {$ln + $wrap}].0
incr remaining -$wrap
}
if {!$remaining} {break}
- incr i
}
}
# Disable Line Numbers
@@ -1481,16 +1491,19 @@ class Editor {
# Adjust list of bookmarks
if {[lindex $bookmarks $lineNumber] == 1} {
$parentObject rightPanel_bm_select $lineNumber
- } {
+ } else {
$parentObject rightPanel_bm_unselect
}
# Adjust list of breakpoints
if {[lindex $breakpoints $lineNumber] == 1} {
$parentObject rightPanel_bp_select $lineNumber
- } {
+ } else {
$parentObject rightPanel_bp_unselect
}
+
+ # Adjust list of symbols
+ $parentObject rightPanel_sm_select $lineNumber
}
## Line wrapping manager - variant 2
@@ -1507,7 +1520,7 @@ class Editor {
set new_wrap [get_count_of_lines $line_number.0 "$line_number.0 lineend"]
incr new_wrap -1
# Empty line
- } {
+ } else {
set new_wrap 0
}
@@ -1519,7 +1532,7 @@ class Editor {
if {$line_number >= [llength $map_of_wraped_lines]} {
Configure
return
- } {
+ } else {
lset map_of_wraped_lines $line_number $new_wrap
}
@@ -1536,10 +1549,9 @@ class Editor {
$iconBorder configure -state normal
if {$new_wrap > $wrap} {
set diff [expr {$new_wrap - $wrap}]
- set ins [string repeat "$wrap_char\n" $diff]
incr number_of_wraps $diff
- $lineNumbers insert $line_number.0 $ins
- $iconBorder insert $line_number.0 $ins
+ $lineNumbers insert $line_number.0 [string repeat "$wrap_char\n" $diff]
+ $iconBorder insert $line_number.0 [string repeat "\n" $diff]
$lineNumbers tag add center $line_number.0 [expr {$line_number + $diff}].0
} elseif {$new_wrap < $wrap} {
set diff [expr {$wrap - $new_wrap}]
@@ -1578,7 +1590,7 @@ class Editor {
if {$line_number >= [llength $map_of_wraped_lines]} {
Configure
return
- } {
+ } else {
lset map_of_wraped_lines $line_number $new_wrap
}
@@ -1595,14 +1607,13 @@ class Editor {
$iconBorder configure -state normal
if {$new_wrap > $wrap} {
set diff [expr {$new_wrap - $wrap}]
- set ins [string repeat "$wrap_char\n" $diff]
incr number_of_wraps $diff
- $lineNumbers insert $line_number.0 $ins
- $iconBorder insert $line_number.0 $ins
+ $lineNumbers insert $line_number.0 [string repeat "$wrap_char\n" $diff]
+ $iconBorder insert $line_number.0 [string repeat "\n" $diff]
$lineNumbers tag add center $line_number.0 [expr {$line_number + $diff}].0
} elseif {$new_wrap < $wrap} {
set diff [expr {$wrap - $new_wrap}]
- incr number_of_wraps $diff
+ set number_of_wraps [expr {$number_of_wraps - $diff}]
$lineNumbers delete $line_number.0 $line_number.0+${diff}l
$iconBorder delete $line_number.0 $line_number.0+${diff}l
}
@@ -1673,7 +1684,7 @@ class Editor {
if {$highlight_status == {}} {
set highlight_status 0
}
- } {
+ } else {
set highlight_status 1
}
@@ -1717,12 +1728,15 @@ class Editor {
set i $lineNumber
set last_visible_line [expr {int([lindex [$editor yview] 1] * int([$editor index end])) + 1}]
- # Highlight all line after the current one until it is nessesary
- while 1 {
+ # Highlight all line after the current one until it is not nessesary
+ while {1} {
autocompletion_maybe_important_change $i.0 $i.0
set highlight_status_org [string index $highlighted_lines $i]
set highlight_status [CsyntaxHighlight::highlight $editor $i $highlight_status]
autocompletion_c_syntax_analyze $i
+ if {$i == $lineNumber} {
+ manage_autocompletion_list $i
+ }
set highlighted_lines \
[string replace $highlighted_lines $i $i $highlight_status]
if {
@@ -1761,9 +1775,10 @@ class Editor {
## Parse given line
# Restore highlight, recalculate counters on status bar, adjust right panel
- # @parm Int lineNumber - number of the target line
+ # @parm Int lineNumber - Number of the target line
+ # @parm Bool force_spell_check - Force spelling check
# @return Bool - result from wrap manager
- public method parse {lineNumber} {
+ public method parse {lineNumber {force_spell_check 0}} {
# Check if the given line number is valid
if {$lineNumber >= int([$editor index end])} {
set lineNumber [expr {int([$editor index end]) - 1}]
@@ -1772,7 +1787,7 @@ class Editor {
# Is the given line number is the current line ?
if {int([$editor index insert]) == $lineNumber} {
set curLine 1
- } {
+ } else {
set curLine 0
}
@@ -1827,6 +1842,11 @@ class Editor {
validate_line $lineNumber 0
}
+ # Check spelling if not current line and if enabled
+ if {!$curLine || $force_spell_check} {
+ spellcheck_check_all $lineNumber 1
+ }
+
# Recalculate counters on status bar
if {$curLine} {
recalc_status_counter {}
@@ -1840,7 +1860,7 @@ class Editor {
if {${::ASMsyntaxHighlight::validation_L0}} {
if {[llength [$editor tag nextrange tag_error $lineNumber.0 [list $lineNumber.0 lineend]]]} {
set add 1
- } {
+ } else {
set remove 1
}
# Remove tag "tag_error_line"
@@ -1859,7 +1879,7 @@ class Editor {
if {[lindex $bookmarks $lineNumber] == 1} {
set image {bm_ex}
- } {
+ } else {
set image {exclamation}
}
@@ -1902,19 +1922,21 @@ class Editor {
}
## Finalize syntax validation on the given line (validates operands only)
- # @parm Int - Number of line in source code
- # @parm Bool = 1 - Affect panel "Instruction details"
+ # @parm Int line - Number of line in source code
+ # @parm Bool ins_det=1 - Affect panel "Instruction details"
# @return void
- private method validate_line args {
- # Parse input arguments
- set line [lindex $args 0]
- set ins_det [lindex $args 1]
- if {$ins_det == {}} {
- set ins_det 1
+ private method validate_line {line {ins_det 1}} {
+ # Check if basic validation is enabled
+ if {!${::ASMsyntaxHighlight::validation_L0}} {
+ return
}
- # Check if basic validation is enabled
- if {!${::ASMsyntaxHighlight::validation_L0}} {return}
+ # Validate breakpoint first
+ if {[is_breakpoint_valid $line]} {
+ mark_breakpoint_as_valid $line
+ } else {
+ mark_breakpoint_as_invalid $line
+ }
# Detereminate range of instruction tag
set ins_range [$editor tag nextrange tag_instruction $line.0 "$line.0 lineend"]
@@ -1927,11 +1949,12 @@ class Editor {
if {[lsearch -ascii -exact ${CompilerConsts::AllInstructions} $instruction] == -1} {
return
}
- } {
+
+ } else {
return
}
- # Inset selection in "Instruction details" tab on the Right Panel
+ # Unset selection in "Instruction details" tab on the Right Panel
if {$ins_det} {
$parentObject rightPanel_ins_unselect
}
@@ -1970,7 +1993,7 @@ class Editor {
if {$opr_set == $operands} {
if {$i} {
lappend matches0 $idx
- } {
+ } else {
lappend matches $idx
}
}
@@ -1998,7 +2021,7 @@ class Editor {
}
}
- # Highlight coresponding operand sets in "Instruction details"
+ # Highlight corresponding operand sets in "Instruction details"
if {[llength $matches] || [llength $matches0]} {
if {$ins_det} {
if {[llength $matches]} {
@@ -2008,7 +2031,7 @@ class Editor {
$parentObject rightPanel_ins_select 0 $matches0
}
}
- } {
+ } else {
$editor tag add tag_error [lindex $ins_range 0] [lindex $ins_range 1]
}
@@ -2016,7 +2039,7 @@ class Editor {
set sfr_range_start $line.0
set sfr_range {}
set sfr_name {}
- while 1 {
+ while {1} {
# Try to find SFR
set sfr_range [$editor tag nextrange tag_sfr $sfr_range_start [list $line.0 lineend]]
if {![llength $sfr_range]} {
@@ -2030,10 +2053,10 @@ class Editor {
if {[string index $sfr_name 0] == {/}} {
set sfr_name [string range $sfr_name 1 end]
}
-
+
if {
[lsearch -ascii -exact \
- [$parentObject cget -avaliable_SFR] \
+ [$parentObject cget -available_SFR] \
[string toupper $sfr_name] \
] == -1
} then {
@@ -2043,8 +2066,8 @@ class Editor {
}
}
- ## Adjust content of the given line in list of bookmakrs and list of breakpoint (in right panel)
- # This function should be called after change content of any line
+ ## Adjust content of the given line in list of bookmarks and list of breakpoint (in right panel)
+ # This function should be called after change in content of a line
# @parm Int lineNumber - line number
# @return void
private method rightPanel_changeLineContent {lineNumber} {
@@ -2054,6 +2077,7 @@ class Editor {
$parentObject rightPanel_add_bookmark $lineNumber
$parentObject rightPanel_bm_select $lineNumber
}
+
# Adjust list of breakpoints
if {[lindex $breakpoints $lineNumber] == 1} {
$parentObject rightPanel_remove_breakpoint $lineNumber
@@ -2090,7 +2114,7 @@ class Editor {
private method wrap_aux_line2idx {line} {
if {$number_of_wraps} {
set i 1
- while 1 {
+ while {1} {
incr line [expr { -1 - [lindex $map_of_wraped_lines $i]}]
if {$line < 1 || $line == {}} {break}
incr i
@@ -2104,7 +2128,7 @@ class Editor {
## Focus on the editor widget
# @return void
public method focus_in {} {
- focus $editor
+ focus -force $editor
}
## Get ranges for all highlighting tags on the given line
@@ -2119,9 +2143,9 @@ class Editor {
# Iterate over defined highlighting tags
foreach tag [concat \
- ${ASMsyntaxHighlight::hightlight_tags} \
- ${CsyntaxHighlight::hightlight_tags} \
- ${LSTsyntaxHighlight::hightlight_tags} \
+ ${ASMsyntaxHighlight::highlight_tags} \
+ ${CsyntaxHighlight::highlight_tags} \
+ ${LSTsyntaxHighlight::highlight_tags} \
{tag_macro_def tag_constant_def} \
] {
@@ -2130,7 +2154,7 @@ class Editor {
# Determinate range of the tag
set range {}
- while 1 {
+ while {1} {
# Determinate start index
set startIdx [lindex $range [expr {[llength $range] - 1}]]
if {$startIdx == {}} {
@@ -2157,9 +2181,63 @@ class Editor {
return $ranges
}
+ ## Make breakpoint on the specified line as VALID (reachable)
+ # @param Int line_number - line number
+ # @return void
+ private method mark_breakpoint_as_valid {line_number} {
+ if {[lindex $breakpoints $line_number] != 1} {
+ return
+ }
+
+ set line_number [wrap_aux_idx2line $line_number]
+
+ $lineNumbers tag remove tag_breakpoint_INVALID $line_number.0 [list $line_number.0+1l]
+ $lineNumbers tag add tag_breakpoint $line_number.0 [list $line_number.0+1l]
+ }
+
+ ## Make breakpoint on the specified line as INVALID (unreachable)
+ # @param Int line_number - line number
+ # @return void
+ private method mark_breakpoint_as_invalid {line_number} {
+ if {[lindex $breakpoints $line_number] != 1} {
+ return
+ }
+
+ set line_number [wrap_aux_idx2line $line_number]
+
+ $lineNumbers tag remove tag_breakpoint $line_number.0 [list $line_number.0+1l]
+ $lineNumbers tag add tag_breakpoint_INVALID $line_number.0 [list $line_number.0+1l]
+ }
+
+ ## Determinate whether breakpoint on the specified line is valid or could be
+ #+ valid in case there is no breakpoint yet
+ # @param Int line_number - line number
+ # @return Bool - 1 == is valid; 0 == is NOT valid
+ private method is_breakpoint_valid {line_number} {
+
+ if {$prog_language == 2 || $prog_language == 3} {
+ return 0
+ }
+
+ if {
+ !$prog_language
+ &&
+ ${::ASMsyntaxHighlight::validation_L0}
+ &&
+ ![llength [$editor tag nextrange tag_instruction $line_number.0 [list $line_number.0 lineend]]]
+ &&
+ ![llength [$editor tag nextrange tag_macro $line_number.0 [list $line_number.0 lineend]]]
+ } then {
+ return 0
+ }
+
+ return 1
+ }
+
## Restore breakpoint tags in "Line numbers"
+ # @parm Bool ignore_wrap=0 - Ignore line wrapping (see recalc_left_frame)
# @return void
- private method rewrite_breakpoint_tags {} {
+ private method rewrite_breakpoint_tags {{ignore_wrap 0}} {
if {$editor_to_use} {return}
# Enable line numbers
@@ -2167,10 +2245,33 @@ class Editor {
# Remove current tags
$lineNumbers tag remove tag_breakpoint 1.0 end
+ $lineNumbers tag remove tag_breakpoint_INVALID 1.0 end
+
# Restore tags
- foreach line [lsearch -ascii -exact -all $breakpoints 1] {
- append line {.0}
- $lineNumbers tag add tag_breakpoint $line "$line+1l"
+ if {!$ignore_wrap && $number_of_wraps} {
+ set i 0
+ set line 0
+ foreach wrap $map_of_wraped_lines {
+ if {[lindex $breakpoints $line] == 1} {
+ if {[is_breakpoint_valid $line]} {
+ $lineNumbers tag add tag_breakpoint $i.0 "$i.0+1l"
+ } else {
+ $lineNumbers tag add tag_breakpoint_INVALID $i.0 "$i.0+1l"
+ }
+ }
+
+ incr wrap
+ incr i $wrap
+ incr line
+ }
+ } else {
+ foreach line [lsearch -ascii -exact -all $breakpoints 1] {
+ if {[is_breakpoint_valid $line]} {
+ $lineNumbers tag add tag_breakpoint $line.0 "$line.0+1l"
+ } else {
+ $lineNumbers tag add tag_breakpoint_INVALID $line.0 "$line.0+1l"
+ }
+ }
}
# Disable line numbers
@@ -2187,7 +2288,7 @@ class Editor {
# Create tag in editor
$editor tag configure [lindex $tag_definition 0] -background [lindex $tag_definition 1]
# Create tag in line numbers
- if {[lindex $tag_definition 0] == {tag_breakpoint}} {
+ if {[lsearch {tag_breakpoint_INVALID tag_breakpoint} [lindex $tag_definition 0]] != -1} {
$lineNumbers tag configure [lindex $tag_definition 0] \
-background [lindex $tag_definition 1] -relief raised -borderwidth 1
}
@@ -2248,16 +2349,16 @@ class Editor {
# @return void
public method makePopupMenu {} {
if {[winfo exists $menu]} {destroy $menu}
- menuFactory $EDITORMENU $menu 0 $cmd_prefix 0 {}
+ menuFactory $EDITORMENU $menu 0 $cmd_prefix 0 {} [namespace current]
if {[winfo exists $stat_menu]} {destroy $stat_menu}
- menuFactory $STATMENU $stat_menu 0 {::X::} 0 {}
+ menuFactory $STATMENU $stat_menu 0 {::X::} 0 {} [namespace current]
if {[winfo exists $IB_menu]} {destroy $IB_menu}
- menuFactory $IBMENU $IB_menu 0 "$this " 0 {}
+ menuFactory $IBMENU $IB_menu 0 "$this " 0 {} [namespace current]
if {[winfo exists $LN_menu]} {destroy $LN_menu}
- menuFactory $LNMENU $LN_menu 0 "$this " 0 {}
+ menuFactory $LNMENU $LN_menu 0 "$this " 0 {} [namespace current]
}
## Configure state of statusbar popup menu entries
@@ -2271,40 +2372,35 @@ class Editor {
set statusbar_menu_config [list 1 1 1 1]
}
if {$split != {}} {
- lset statusbar_menu_config 0 $split
+ lset statusbar_menu_config 0 [expr "$split"]
}
if {$close != {}} {
- lset statusbar_menu_config 1 $close
+ lset statusbar_menu_config 1 [expr "$close"]
}
if {$prev != {}} {
- lset statusbar_menu_config 2 $prev
+ lset statusbar_menu_config 2 [expr "$prev"]
}
if {$next != {}} {
- lset statusbar_menu_config 3 $next
+ lset statusbar_menu_config 3 [expr "$next"]
}
}
## Rewrite left site of editor status bar
- # @parm List - Relative mouse cursor coordinates ({%x,%y})
- # {} == keyboard input (eg. leftArrow pressed)
- # @parm Bool = 1 - Highlight current line and such things
+ # @parm List coord={} - Relative mouse cursor coordinates ({%x,%y})
+ # {} == keyboard input (eg. leftArrow pressed)
+ # @parm Bool perform_highlight=1 - Highlight current line and such things
# @return void
- public method recalc_status_counter args {
+ public method recalc_status_counter {{coord {}} {perform_highlight 1}} {
if {$editor_to_use} {return}
- # Procedure can executed only in editor mode
- if {$frozen} {return}
+# # Procedure can executed only in normal editor mode
+# if {$frozen} {return}
# Parse arguments
- if {[lindex $args 0] == {}} {
+ if {$coord == {}} {
set coord insert
- } {
- set coord "@[lindex $args {0 0}],[lindex $args {0 1}]"
- }
- if {[lindex $args 1] == {}} {
- set perform_highlight 1
- } {
- set perform_highlight [lindex $args 1]
+ } else {
+ set coord "@[lindex $coord 0],[lindex $coord 1]"
}
# Translate text index into number
@@ -2319,7 +2415,7 @@ class Editor {
if {[regexp {\t} $lineText]} {
set idx -1
set cor 0
- while 1 {
+ while {1} {
set idx [string first "\t" $lineText [expr {$idx + 1}]]
if {$idx == -1 || $idx > $Index} {break}
@@ -2337,7 +2433,7 @@ class Editor {
incr tmp
$editor tag add tag_current_line $line.0 $tmp.0
set last_cur_line $line
- } {
+ } else {
$editor tag add tag_current_line $line.0 $tmp.0
}
@@ -2399,15 +2495,15 @@ class Editor {
if {[llength $ins_range]} {
$parentObject rightPanel_ins_change [$editor get [lindex $ins_range 0] [lindex $ins_range 1]]
- } {
+ } else {
set ins_range [$editor tag nextrange tag_directive {insert linestart} {insert lineend}]
if {[llength $ins_range]} {
$parentObject rightPanel_dir_change D [$editor get [lindex $ins_range 0] [lindex $ins_range 1]]
- } {
+ } else {
set ins_range [$editor tag nextrange tag_control {insert linestart} {insert lineend}]
if {[llength $ins_range]} {
$parentObject rightPanel_dir_change C [$editor get [lindex $ins_range 0] [lindex $ins_range 1]]
- } {
+ } else {
$parentObject rightPanel_ins_clear
}
}
@@ -2427,7 +2523,7 @@ class Editor {
} then {
if {$up__down} {
return [$editor index {insert-1l linestart}]
- } {
+ } else {
return [$editor index {insert+1l linestart}]
}
@@ -2439,14 +2535,14 @@ class Editor {
# Determinate target column number
if {!$lastUpDownIndex} {
set lastUpDownIndex $col
- } {
+ } else {
set col $lastUpDownIndex
}
# Traslate column number to text index
if {$up__down} {
incr lineNum -1
- } {
+ } else {
incr lineNum
}
@@ -2464,7 +2560,7 @@ class Editor {
if {[string first "\t" $lineText] != -1} {
set idx -1
set cor 0
- while 1 {
+ while {1} {
set idx [string first "\t" $lineText [expr {$idx + 1}]]
if {$idx == -1} {break}
@@ -2480,6 +2576,9 @@ class Editor {
# @parm Int col - Column number
# @return TextIndex - Resulting insertIndex
private method column_to_text_index {lineNum col} {
+ if {!$col} {
+ return 0
+ }
set lineText [$editor get $lineNum.0 [list $lineNum.0 lineend]]
if {[string first "\t" $lineText] != -1} {
@@ -2564,7 +2663,7 @@ class Editor {
# Determinate width of the selected block
if {abs($col_s1 - $col_s0) < abs($col_e1 - $col_e0)} {
set width [expr {abs($col_s1 - $col_s0)}]
- } {
+ } else {
set width [expr {abs($col_e1 - $col_e0)}]
}
@@ -2572,14 +2671,15 @@ class Editor {
$editor tag remove sel 0.0 end
set col 0
for {set row $row_s0} {$row <= $row_e1} {incr row} {
- set col [column_to_text_index $row $col_s0]
- if {[$editor compare $row.$col >= [list $row.0 lineend]]} {
+ set col0 [column_to_text_index $row $col_s0]
+ set col1 [column_to_text_index $row [expr {$col_s0 + $width}]]
+ if {[$editor compare $row.$col0 >= [list $row.0 lineend]]} {
continue
}
- if {[$editor compare $row.$col+${width}c > [list $row.0 lineend]]} {
- $editor tag add sel $row.$col [list $row.0 lineend]
- } {
- $editor tag add sel $row.$col $row.$col+${width}c
+ if {[$editor compare $row.$col1 > [list $row.0 lineend]]} {
+ $editor tag add sel $row.$col0 [list $row.0 lineend]
+ } else {
+ $editor tag add sel $row.$col0 $row.$col1
}
}
}
@@ -2635,7 +2735,7 @@ class Editor {
if {[catch {
if {$filename == {}} {
cd [$parentObject cget -projectPath]
- } {
+ } else {
cd [file dirname $filename]
}
}]} then {
@@ -2650,7 +2750,7 @@ class Editor {
+sb -bg "$normal_text_bg" -b 0 -w 0 -sl 0 \
-fn "xft:$fontFamily:pixelsize=$fontSize" \
-e $cmd &]
- } {
+ } else {
set pid [exec -- urxvt -embed [expr [winfo id $top_frame]] \
+sb -bg "$normal_text_bg" -b 0 -w 0 -sl 0 \
-fn "xft:$fontFamily:pixelsize=$fontSize" \
@@ -2662,7 +2762,7 @@ class Editor {
+sb -bg "$normal_text_bg" -b 0 -w 0 -sl 0 \
-fn "xft:$fontFamily:pixelsize=$fontSize" \
-e $cmd $opt &]
- } {
+ } else {
set pid [exec -- urxvt -embed [expr [winfo id $top_frame]] \
+sb -bg "$normal_text_bg" -b 0 -w 0 -sl 0 \
-fn "xft:$fontFamily:pixelsize=$fontSize" \
@@ -2676,7 +2776,7 @@ class Editor {
-icon error \
-type ok \
-title [mc "FATAL ERROR"] \
- -message [mc "Unable to start embedded editor due to an unknow error. This error did not occured in MCU 8051 IDE code but somewhere else. Please try to restart MCU 8051 IDE with --reset-user-settings"]
+ -message [mc "Unable to start embedded editor due to an unknown error. This error did not occurred in MCU 8051 IDE code but somewhere else. Please try to restart MCU 8051 IDE with --reset-user-settings"]
}
# Return to previous directory
@@ -2687,7 +2787,7 @@ class Editor {
# @parm String filename - Name of file to open with the external editor
# @return void
public method recreate_terminal {filename} {
- update idle
+ update idletasks
if {![winfo exists $ed_sc_frame]} {return}
set top_frame [frame $ed_sc_frame.top_frame_$top_frame_idx -container 1]
pack $top_frame -expand 1 -fill both
@@ -2697,7 +2797,7 @@ class Editor {
incr top_frame_idx
}
- ## Determinate file type acording to its name externsion
+ ## Determinate file type according to its name extension
# @parm Bool reset - Reset syntax highlight
# @return void
private method determinate_prog_lang {reset} {
@@ -2727,12 +2827,16 @@ class Editor {
private method prog_lang_changed {} {
if {$editor_to_use} {return}
# Clear current highlighting tags
- $editor tag remove tag_error 0.0 end
- $editor tag remove tag_error_line 0.0 end
- foreach tag [concat \
- ${::CsyntaxHighlight::hightlight_tags} \
- ${::ASMsyntaxHighlight::hightlight_tags} \
- ${LSTsyntaxHighlight::hightlight_tags} \
+ $editor tag remove tag_error 0.0 end
+ $editor tag remove tag_error_line 0.0 end
+ $editor tag remove tag_constant_def 0.0 end
+ $editor tag remove tag_macro_def 0.0 end
+ $editor tag remove c_lang_func 0.0 end
+ $editor tag remove c_lang_var 0.0 end
+ foreach tag [concat \
+ ${::CsyntaxHighlight::highlight_tags} \
+ ${::ASMsyntaxHighlight::highlight_tags} \
+ ${::LSTsyntaxHighlight::highlight_tags} \
] {
$editor tag remove [lindex $tag 0] 0.0 end
}
@@ -2760,7 +2864,7 @@ class Editor {
# Adjust main menu and main toolbar
if {$prog_language == 1} {
set uses_c 1
- } {
+ } else {
set uses_c 0
}
::X::adjust_mainmenu_and_toolbar_to_editor {} $uses_c
@@ -2779,8 +2883,12 @@ class Editor {
$Sbar_prog_lang configure -fg {#00DDEE} -text "LST"
} elseif {$prog_language == 3} {
$Sbar_prog_lang configure -fg {#0000DD} -text "ASX"
- } {
+ } else {
$Sbar_prog_lang configure -fg {#00CC00} -text "ASM"
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/eventhandlers.tcl b/lib/editor/eventhandlers.tcl
index c6d1083..279b2e2 100755..100644
--- a/lib/editor/eventhandlers.tcl
+++ b/lib/editor/eventhandlers.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 _EVENTHANDLERS_TCL ] } {
+set _EVENTHANDLERS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements event handlers
@@ -138,7 +143,7 @@ public method scroll args {
if {$unit != {p}} {
incr line [lindex $args 1]
- } {
+ } else {
incr line [expr {30 * [lindex $args 1]}]
}
incr line -1
@@ -157,7 +162,7 @@ public method scroll args {
}
highlight_visible_area ;# Highlight lines which hasn't been highlighted yet
- update idle
+ update idletasks
set tmp_row $row
if {$number_of_wraps} {
@@ -187,7 +192,7 @@ public method scroll args {
}
# Done ...
- update idle
+ update idletasks
set scroll_in_progress 0
}
@@ -207,12 +212,12 @@ public method popupMenu {X Y x y} {
]
if {$address == {}} {
set state {disabled}
- } {
+ } else {
set state {normal}
}
$menu entryconfigure [::mc "LJMP this line"] -state $state
$menu entryconfigure [::mc "LCALL this line"] -state $state
- } {
+ } else {
$menu entryconfigure [::mc "LJMP this line"] -state disabled
$menu entryconfigure [::mc "LCALL this line"] -state disabled
}
@@ -262,7 +267,7 @@ public method statusbar_popup_menu {editor X Y} {
if {[lindex $statusbar_menu_config 0] != 0} {
set state normal
- } {
+ } else {
set state disabled
}
$stat_menu entryconfigure [::mc "Split vertical"] -state $state
@@ -270,21 +275,21 @@ public method statusbar_popup_menu {editor X Y} {
if {[lindex $statusbar_menu_config 1] != 0} {
set state normal
- } {
+ } else {
set state disabled
}
$stat_menu entryconfigure [::mc "Close current view"] -state $state
if {[lindex $statusbar_menu_config 2] != 0} {
set state normal
- } {
+ } else {
set state disabled
}
$stat_menu entryconfigure [::mc "Back"] -state $state
if {[lindex $statusbar_menu_config 3] != 0} {
set state normal
- } {
+ } else {
set state disabled
}
$stat_menu entryconfigure [::mc "Forward"] -state $state
@@ -322,9 +327,83 @@ public method control_up {} {
$editor yview scroll -1 units
}
+## Handles event: "Control-Shift-Key-Up" and "Control-Shift-Key-Down"
+ # @parm Bool up__down - 1 == Control-Shift-Key-Up; 0 == Control-Shift-Key-Down
+ # @return void
+public method control_shift_updown {up__down} {
+ if {$up__down} {
+ if {int([$editor index insert]) == 1} {
+ return
+ }
+ } else {
+ if {(int([$editor index insert]) + 1) == int([$editor index end])} {
+ return
+ }
+ }
+
+ $editor configure -autoseparators 0
+ if {$up__down} {
+ set target_idx [$editor index {insert-1l}]
+ autocompletion_maybe_important_change [$editor index {insert-1l linestart}] [$editor index {insert lineend}]
+ } else {
+ set target_idx [$editor index {insert+1l}]
+ autocompletion_maybe_important_change [$editor index {insert linestart}] [$editor index {insert+1l lineend}]
+ }
+
+ catch {
+ $editor tag remove sel 1.0 end
+ }
+
+ set line0 [$editor get {insert linestart} {insert lineend}]
+ if {$up__down} {
+ set line1 [$editor get {insert-1l linestart} {insert-1l lineend}]
+ } else {
+ set line1 [$editor get {insert+1l linestart} {insert+1l lineend}]
+ }
+
+ $editor delete {insert linestart} {insert lineend}
+ if {$up__down} {
+ $editor delete {insert-1l linestart} {insert-1l lineend}
+ } else {
+ $editor delete {insert+1l linestart} {insert+1l lineend}
+ }
+
+ $editor insert insert $line1
+ if {$up__down} {
+ $editor insert {insert-1l} $line0
+ } else {
+ $editor insert {insert+1l} $line0
+ }
+
+ set idx [expr {int([$editor index insert])}]
+ parse $idx
+ manage_autocompletion_list $idx
+ if {$up__down} {
+ set idx [expr {int([$editor index insert-1l])}]
+ } else {
+ set idx [expr {int([$editor index insert+1l])}]
+ }
+ parse $idx
+ manage_autocompletion_list $idx
+
+ # Check spelling on the other line
+ update
+ spellcheck_check_all [expr {int([$editor index insert])}] 1
+
+ # Move insertion cursor
+ $editor mark set insert $target_idx
+ $editor see insert
+
+ $editor edit separator
+ $editor configure -autoseparators 1
+}
+
## Handles event: "Shift-Key-Down"
# @return void
public method shift_down {} {
+ # Check spelling on the line which we are noe leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
tk::TextKeySelect $editor [get_up_down_idx 0]
# Adjust selection in list of bookmarks and list of breakpoints
@@ -338,6 +417,9 @@ public method shift_down {} {
## Handles event: "Shift-Key-Up"
# @return void
public method shift_up {} {
+ # Check spelling on the line which we are noe leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
tk::TextKeySelect $editor [get_up_down_idx 1]
# Adjust selection in list of bookmarks and list of breakpoints
@@ -351,6 +433,9 @@ public method shift_up {} {
## Handles event: "Key-Up"
# @return void
public method up {} {
+ # Check spelling on the line which we are now leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
# Move insertion cursor
$editor mark set insert [get_up_down_idx 1]
@@ -370,6 +455,9 @@ public method up {} {
## Handles event: "Key-Down"
# @return void
public method down {} {
+ # Check spelling on the line which we are now leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
# Focus completion popup window
if {$completion_win_opened} {
catch {
@@ -427,7 +515,7 @@ public method shift_home {} {
}
# Nothing selected
- } {
+ } else {
set idx [$editor index insert]
home_press
catch {
@@ -436,12 +524,32 @@ public method shift_home {} {
if {[$editor compare $idx < insert]} {
$editor tag add sel $idx insert
- } {
+ } else {
$editor tag add sel insert $idx
}
}
}
+## Handles event: "Control-Key-Home"
+ # @return void
+public method control_home {} {
+ $editor mark set insert 1.0
+ rightPanel_adjust [expr {int([$editor index insert])}]
+ resetUpDownIndex
+ recalc_status_counter {} 0
+ $editor see insert
+}
+
+## Handles event: "Control-Key-End"
+ # @return void
+public method control_end {} {
+ $editor mark set insert end
+ rightPanel_adjust [expr {int([$editor index insert])}]
+ resetUpDownIndex
+ recalc_status_counter {} 0
+ $editor see insert
+}
+
## Handles event: "Key-Home"
# @return void
public method home_press {} {
@@ -455,10 +563,10 @@ public method home_press {} {
set col [string length $space]
if {$col_original == $col} {
$editor mark set insert $row.0
- } {
+ } else {
$editor mark set insert $row.$col
}
- } {
+ } else {
$editor mark set insert $row.0
}
@@ -468,6 +576,7 @@ public method home_press {} {
}
# Adjust status bar counters
+ resetUpDownIndex
recalc_status_counter {} 0
$editor see insert
}
@@ -477,7 +586,7 @@ public method home_press {} {
public method tab_press {} {
if {$spaces_no_tabs} {
set indent_char [string repeat { } $number_of_spaces]
- } {
+ } else {
set indent_char "\t"
}
@@ -486,7 +595,7 @@ public method tab_press {} {
Key $indent_char
# Something selected -> indent
- } {
+ } else {
# convert selection indexes to line numbers
set start [expr {int([$editor index sel.first])}]
set end_o [$editor index sel.last]
@@ -514,6 +623,9 @@ public method shift_enter {} {
if {$critical_edit_proc} {return}
set critical_edit_proc 1
+ # Check spelling on the line which we are noe leaving
+ spellcheck_check_all [expr {int([$editor index insert])}]
+
deleteselection
$editor insert insert "\n"
@@ -553,10 +665,13 @@ public method enter {} {
set idx [expr {int($idx)}]
incr idx
+ # Check spelling on the line which we are noe leaving
+ spellcheck_check_all $idx
+
# Keep indention of the previous line
if {$intentation_mode == {normal}} {
- # Determinate indetication charactes
+ # Determinate indetication characters
set prev_line [$editor get \
[$editor index {insert-1l linestart}] \
[$editor index {insert-1l lineend}] \
@@ -620,7 +735,7 @@ public method KeyRelease {key} {
if {[lsearch {ISO_Next_Group ISO_Prev_Group Alt_R Alt_L Control Meta Shift_L Shift_R} $key] == -1} {
if {$do_not_hide_comp_win} {
set do_not_hide_comp_win 0
- } {
+ } else {
close_completion_popup_window
}
}
@@ -628,8 +743,8 @@ public method KeyRelease {key} {
## Handles event: 'Key'
# @return void
-public method Key {key} {
- # Skip values with no meaning
+public method Key {key {key_k {}}} {
+ # Skip values with no meaning for us herw
if {![string is print -strict $key] && $key != "\t"} {
return
}
@@ -643,6 +758,7 @@ public method Key {key} {
set key_handler_in_progress 1
set scroll_in_progress 1 ;# Block scrolling
+ spellcheck_change_detected_pre
autocompletion_maybe_important_change insert insert
$editor configure -autoseparators 0
@@ -665,7 +781,7 @@ public method Key {key} {
$editor tag remove sel 1.0 end
# Insert the selected character twice
- } {
+ } else {
set next_char [$editor get insert insert+1c]
$editor insert insert $key
switch -- $key {
@@ -730,6 +846,7 @@ public method Key {key} {
set key_handler_in_progress 0
update
set scroll_in_progress 0 ;# Unblock scrolling
+ spellcheck_change_detected_post
}
## Handles event: 'Key-Delete'
@@ -738,7 +855,7 @@ public method key_delete {} {
if {![$this deleteselection 1]} {
if {[$editor compare {insert linestart} != {insert+1c linestart}]} {
set remove_trailing_space 1
- } {
+ } else {
set remove_trailing_space 0
}
@@ -752,6 +869,7 @@ public method key_delete {} {
$this resetUpDownIndex
$this recalc_left_frame
+ $this parse [expr {int([$editor index insert])}]
update
}
@@ -779,3 +897,7 @@ public method key_backspace {} {
$this parse [expr {int([$editor index insert])}]
update
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/exports.tcl b/lib/editor/exports.tcl
index 2ce2ed4..26441c7 100755..100644
--- a/lib/editor/exports.tcl
+++ b/lib/editor/exports.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 _EXPORTS_TCL ] } {
+set _EXPORTS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements exports to other data formats (XHTML && LaTeX)
@@ -73,9 +78,9 @@ public method highlight_all {} {
public method getDataAsXHTML_count_of_iterations {} {
set result 0
foreach tag_def [concat \
- ${ASMsyntaxHighlight::hightlight_tags} \
- ${CsyntaxHighlight::hightlight_tags} \
- ${LSTsyntaxHighlight::hightlight_tags} \
+ ${ASMsyntaxHighlight::highlight_tags} \
+ ${CsyntaxHighlight::highlight_tags} \
+ ${LSTsyntaxHighlight::highlight_tags} \
] {
set range [$editor tag ranges [lindex $tag_def 0]]
incr result [llength $range]
@@ -91,8 +96,8 @@ public method getDataAsLaTeX_abort_now {} {
}
## Export editor content as LaTeX source (include colors)
- # @return String - LaTeX source code
-public method getDataAsLaTeX {} {
+ # @parm File file - Target data channel
+public method getDataAsLaTeX {file} {
# Reset abort variables
set getDataAsLaTeX_abort 0
@@ -122,22 +127,22 @@ public method getDataAsLaTeX {} {
}
# Create LaTeX preamble
- set latex "\\documentclass\[a4paper,12pt\]{article}"
- append latex "\n\n% Creator: ${::APPNAME}\n\n"
- append latex "\\usepackage\[utf-8\]{inputenc}\n"
- append latex "\\usepackage\[T1\]{fontenc}\n"
- append latex "\\usepackage{color}\n"
- append latex "\\title{$filename}\n"
- append latex "\\date{[clock format [clock seconds] -format {%D}]}\n"
- append latex "\n% define highlighting\n"
+ puts -nonewline $file "\\documentclass\[a4paper,12pt\]{article}"
+ puts -nonewline $file "\n\n% Creator: ${::APPNAME}\n\n"
+ puts -nonewline $file "\\usepackage\[utf8\]{inputenc}\n"
+ puts -nonewline $file "\\usepackage\[T1\]{fontenc}\n"
+ puts -nonewline $file "\\usepackage{color}\n"
+ puts -nonewline $file "\\title{$filename}\n"
+ puts -nonewline $file "\\date{[clock format [clock seconds] -format {%D}]}\n"
+ puts -nonewline $file "\n% define highlighting\n"
## Determinate highlighting tag ranges and define colors for 'color' package
set ranges {}
# Iterate over predefined highlighting tags
foreach tag_def [concat \
- ${ASMsyntaxHighlight::hightlight_tags} \
- ${CsyntaxHighlight::hightlight_tags} \
- ${LSTsyntaxHighlight::hightlight_tags} \
+ ${ASMsyntaxHighlight::highlight_tags} \
+ ${CsyntaxHighlight::highlight_tags} \
+ ${LSTsyntaxHighlight::highlight_tags} \
] {
# Conditional abort
@@ -148,13 +153,24 @@ public method getDataAsLaTeX {} {
# Local variables
set color [lindex $tag_def 1] ;# RGB color
- set red [string range $color 1 2] ;# Color - RED
- set green [string range $color 3 4] ;# Color - GREEN
- set blue [string range $color 5 6] ;# Color - BLUE
set tag [lindex $tag_def 0] ;# Tag name
set range [$editor tag ranges $tag] ;# List of tag ranges
set len [llength $range] ;# Number of ranges
- set mirror_tag {} ;# Tag with exatly the same highlight
+ set mirror_tag {} ;# Tag with exatly the same highlight
+
+ # Convert 48b color format to 24b format
+ if {[string length $color] == 13} {
+ set new_color {#}
+ for {set i 1} {$i < [string length $color]} {incr i 4} {
+ append new_color [string range $color $i [expr {$i + 1}]]
+ }
+ set color $new_color
+ }
+
+ # Decompose the color code
+ set red [string range $color 1 2] ;# Color - RED
+ set green [string range $color 3 4] ;# Color - GREEN
+ set blue [string range $color 5 6] ;# Color - BLUE
# Determinate mirror tag
switch -- $tag {
@@ -163,7 +179,7 @@ public method getDataAsLaTeX {} {
}
if {$mirror_tag != {}} {
set mirror_range [$editor tag ranges $mirror_tag]
- } {
+ } else {
set mirror_range {}
}
@@ -179,7 +195,7 @@ public method getDataAsLaTeX {} {
set green [string range [expr "0x$green / 255.0"] 0 4]
set blue [string range [expr "0x$blue / 255.0"] 0 4]
# Define color (for package color)
- append latex "\\definecolor{highlight_$tag}{rgb}{$red, $green, $blue}\n"
+ puts -nonewline $file "\\definecolor{highlight_$tag}{rgb}{$red, $green, $blue}\n"
# Adjust map of text tags
set mirror_tag {}
@@ -220,7 +236,7 @@ public method getDataAsLaTeX {} {
set spaces 0
set correction 0
- while 1 {
+ while {1} {
set idx [string first "\t" $textLine [expr {$idx + 1}]]
if {$idx == -1} {break}
@@ -258,7 +274,7 @@ public method getDataAsLaTeX {} {
# Determinate string to insert
if {[lindex $range 2]} {
set tag "'\{\\color{highlight_[lindex $range 1]}\\verb'"
- } {
+ } else {
set tag "'\}\\verb'"
}
@@ -289,13 +305,10 @@ public method getDataAsLaTeX {} {
regsub -all "\a" $text {'\\verb"'"\\verb'} text
# Create final LaTeX document
- append latex "\n\n\\begin{document}\n"
- append latex "\\ \\\\\n"
- append latex $text
- append latex "\n\\end{document}"
-
- # Return result
- return $latex
+ puts -nonewline $file "\n\n\\begin{document}\n"
+ puts -nonewline $file "\\ \\\\\n"
+ puts -nonewline $file $text
+ puts -nonewline $file "\n\\end{document}"
}
## Abort export to XHTML
@@ -305,8 +318,8 @@ public method getDataAsXHTML_abort_now {} {
}
## Export editor content as XHTML source (include colors)
- # @return String - XHTML source code
-public method getDataAsXHTML {} {
+ # @parm File file - Target data channel
+public method getDataAsXHTML {file} {
# Reset abort variables
set getDataAsXHTML_abort 0
@@ -336,26 +349,26 @@ public method getDataAsXHTML {} {
}
# Create XHTML header
- set html "<?xml version='1.0' encoding='utf-8' standalone='no'?>\n"
- append html "<!DOCTYPE html PUBLIC\n"
- append html "\t'-//W3C//DTD XHTML 1.1//EN'\n"
- append html "\t'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\n"
- append html "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>\n"
- append html "<!--\n\tCreator: ${::APPNAME}\n\tDate: [clock format [clock seconds] -format {%D}]\n-->\n"
- append html "\t<head>\n"
- append html "\t\t<title>$filename</title>\n"
- append html "\t\t<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=UTF-8\" />\n"
- append html "\t\t<meta name=\"Generator\" content=\"${::APPNAME}\" />\n"
- append html "\t\t<style type=\"text/css\">\n"
- append html "\t\t\tbody {\n\t\t\t\tfont-family: $fontFamily;\n\t\t\t\tfont-size: ${fontSize}px;\n\t\t\t}\n"
+ puts -nonewline $file "<?xml version='1.0' encoding='utf-8' standalone='no'?>\n"
+ puts -nonewline $file "<!DOCTYPE html PUBLIC\n"
+ puts -nonewline $file "\t'-//W3C//DTD XHTML 1.1//EN'\n"
+ puts -nonewline $file "\t'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\n"
+ puts -nonewline $file "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>\n"
+ puts -nonewline $file "<!-- Creator: ${::APPNAME} -->\n"
+ puts -nonewline $file "\t<head>\n"
+ puts -nonewline $file "\t\t<title>$filename</title>\n"
+ puts -nonewline $file "\t\t<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=UTF-8\" />\n"
+ puts -nonewline $file "\t\t<meta name=\"Generator\" content=\"${::APPNAME}\" />\n"
+ puts -nonewline $file "\t\t<style type=\"text/css\">\n"
+ puts -nonewline $file "\t\t\tbody {\n\t\t\t\tfont-family: $fontFamily;\n\t\t\t\tfont-size: ${fontSize}px;\n\t\t\t}\n"
## Determinate highlighting tag ranges and define inline CSS
set ranges {}
# Iterate over predefined highlighting tags
foreach tag_def [concat \
- ${ASMsyntaxHighlight::hightlight_tags} \
- ${CsyntaxHighlight::hightlight_tags} \
- ${LSTsyntaxHighlight::hightlight_tags} \
+ ${ASMsyntaxHighlight::highlight_tags} \
+ ${CsyntaxHighlight::highlight_tags} \
+ ${LSTsyntaxHighlight::highlight_tags} \
] {
# Conditional abort
@@ -377,7 +390,7 @@ public method getDataAsXHTML {} {
}
if {$mirror_tag != {}} {
set mirror_range [$editor tag ranges $mirror_tag]
- } {
+ } else {
set mirror_range {}
}
@@ -388,19 +401,30 @@ public method getDataAsXHTML {} {
# Adjust tag name
set tag [string replace $tag 0 3]
+ set color [lindex $tag_def 1]
+
+ # Convert 48b color format to 24b format
+ if {[string length $color] == 13} {
+ set new_color {#}
+ for {set i 1} {$i < [string length $color]} {incr i 4} {
+ append new_color [string range $color $i [expr {$i + 1}]]
+ }
+ set color $new_color
+ }
+
# create CSS
- append html "\t\t\t.$tag {\n"
- append html "\t\t\t\tcolor: [lindex $tag_def 1];\n"
+ puts -nonewline $file "\t\t\t.$tag {\n"
+ puts -nonewline $file "\t\t\t\tcolor: $color;\n"
if {[lindex $tag_def 2]} {
- append html "\t\t\t\ttext-decoration: line-through;\n"
+ puts -nonewline $file "\t\t\t\ttext-decoration: line-through;\n"
}
if {[lindex $tag_def 3]} {
- append html "\t\t\t\tfont-style: italic;\n"
+ puts -nonewline $file "\t\t\t\tfont-style: italic;\n"
}
if {[lindex $tag_def 4]} {
- append html "\t\t\t\tfont-weight: bold;\n"
+ puts -nonewline $file "\t\t\t\tfont-weight: bold;\n"
}
- append html "\t\t\t}\n"
+ puts -nonewline $file "\t\t\t}\n"
for {set i 0} {$i < $len} {incr i} {
lappend ranges [list [lindex $range $i] $tag 1]
@@ -416,8 +440,8 @@ public method getDataAsXHTML {} {
}
}
}
- append html "\t\t</style>\n"
- append html "\t</head>\n"
+ puts -nonewline $file "\t\t</style>\n"
+ puts -nonewline $file "\t</head>\n"
# Sort tag ranges (recursive)
set ranges [lsort -command "::FileList::editor__sort_tag_ranges" $ranges]
@@ -457,7 +481,7 @@ public method getDataAsXHTML {} {
# Deterinate string to insert
if {[lindex $range 2]} {
set tag "span class='[lindex $range 1]'"
- } {
+ } else {
set tag {/span}
}
@@ -475,12 +499,13 @@ public method getDataAsXHTML {} {
regsub -all "\b" $text {\&gt;} text
# Create final XHTML document
- append html "\t<body>\n\t\t<pre>\n"
- append html "\t\t<!-- CODE BLOCK - begin -->\n"
- append html $text
- append html "\t\t<!-- CODE BLOCK - end -->\n"
- append html "\t\t</pre>\n\t</body>\n</html>"
-
- # Return result
- return $html
+ puts -nonewline $file "\t<body>\n\t\t<pre>\n"
+ puts -nonewline $file "\t\t<!-- CODE BLOCK - begin -->\n"
+ puts -nonewline $file $text
+ puts -nonewline $file "\t\t<!-- CODE BLOCK - end -->\n"
+ puts -nonewline $file "\t\t</pre>\n\t</body>\n</html>"
+}
+
+# >>> File inclusion guard
}
+# <<< File inclusion guard
diff --git a/lib/editor/generalproc.tcl b/lib/editor/generalproc.tcl
index f73be85..3bf8767 100755..100644
--- a/lib/editor/generalproc.tcl
+++ b/lib/editor/generalproc.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 _GENERALPROC_TCL ] } {
+set _GENERALPROC_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements general purpose procedures
@@ -43,7 +48,7 @@ public method switch_sel_mode {} {
if {$selection_mode} {
adjust_selection_to_block
$sel_mode_lbl configure -text [mc "BLK"] -fg #0088CC
- } {
+ } else {
if {[llength [$editor tag nextrange sel 1.0]]} {
$editor tag add sel sel.first sel.last
}
@@ -73,7 +78,7 @@ public method getBreakpoints {} {
# @parm Bool inSelection - Search in the selected block / search globaly
# @parm String Sindex - index in the text where the search should start
# @parm String String - String to search
- # @return List - {indexMatchBegining indexMatchEnd matchesCount}
+ # @return List - {indexMatchBeginning indexMatchEnd matchesCount}
public method find {fromCursor Backwards regExp noCase inSelection Sindex String} {
## adjust search options
@@ -85,10 +90,10 @@ public method find {fromCursor Backwards regExp noCase inSelection Sindex String
if {$inSelection} {
set Sindex sel.first
set Eindex sel.last
- } {
+ } else {
if {$Backwards} {
set Eindex 1.0
- } {
+ } else {
set Eindex {end}
}
}
@@ -97,12 +102,12 @@ public method find {fromCursor Backwards regExp noCase inSelection Sindex String
if {$fromCursor} {
# Sindex
set Sindex {insert}
- } {
+ } else {
# Sindex
if {$Sindex == {}} {
if {$Backwards} {
set Sindex end
- } {
+ } else {
set Sindex 1.0
}
}
@@ -112,7 +117,7 @@ public method find {fromCursor Backwards regExp noCase inSelection Sindex String
if {$Backwards} {
append Sindex -[expr {[string length $String] - 1}]c
set direction {-backwards}
- } {
+ } else {
set direction {-forwards}
}
@@ -125,7 +130,7 @@ public method find {fromCursor Backwards regExp noCase inSelection Sindex String
set index [$editor search $direction $regexp -nocase \
-count {::editor_search_count} -- \
$String $Sindex $Eindex]
- } {
+ } else {
set index [$editor search $direction $regexp \
-count {::editor_search_count} -- \
$String $Sindex $Eindex]
@@ -149,14 +154,14 @@ public method find {fromCursor Backwards regExp noCase inSelection Sindex String
# Goto line with the found match and select that matched string
if {$Backwards} {
goto $lineNumber.$colNumber
- } {
+ } else {
goto $lineNumber.$end_col
}
$editor tag remove sel 1.0 end
$editor tag add sel $index $lineNumber.$end_col
- # set result acording to values determinated above
+ # set result according to values determinated above
set matches "$index $lineNumber.$end_col ${::editor_search_count}"
- } {
+ } else {
# set result to something like 'nothing found'
set matches "$Sindex $Sindex 0"
}
@@ -196,33 +201,58 @@ public method replace {fromCursor Backwards regExp noCase SearchString Replaceme
if {$critical_edit_proc} {return 0}
set critical_edit_proc 1
- ## Derminate indexes of area to be affected
+ ## Derminate indexes of the area to be affected
if {$fromCursor} {
# from actual cursor position
set index {insert}
- } {
+ } else {
if {$Backwards} {
set index {end}
- } {
+ } else {
set index 1.0
}
}
## Perform replacement for each match
- while $remaining {
+ set index_org {}
+ set index_new {}
+ while {1} {
# Initiate search and determinate count of remaining matches
- set result [find $fromCursor $Backwards $regExp $noCase 0 $index $SearchString]
-
- set remaining [lindex $result 2]
- if {$remaining == 0} {break}
-
- # Determinate index where to reinitiate search
- set index [lindex $result [expr {!$Backwards}]]
+ set last_chance 0
+ while {1} {
+ set result [find $fromCursor $Backwards $regExp $noCase 0 $index $SearchString]
+
+ set remaining [lindex $result 2]
+ if {$remaining == 0} {break}
+
+ # Determinate index where to reinitiate search
+ set index_org $index_new
+ set index [lindex $result [expr {!$Backwards}]]
+ set index_new $index
+ if {$index_org == $index} {
+ if {$last_chance} {
+ break
+ } else {
+ if {!$Backwards} {
+ set index [$editor index [list $index {+1c}]]
+ } else {
+ set index [$editor index [list $index {-1c}]]
+ }
+ set last_chance 1
+ }
+ } else {
+ set last_chance 0
+ break
+ }
+ }
+ if {$last_chance || $remaining == 0 || $remaining == {}} {
+ break
+ }
- # "Annoy user" if there is requested confirmation before each replace
+ # Ask user if there is requested confirmation before each replace
if {$confirm} {
# invoke confirmation command and setup new parameters
- switch [$confirmCMD] {
+ switch -- [$confirmCMD] {
0 { ;# Replace
set cnd 1
}
@@ -246,8 +276,8 @@ public method replace {fromCursor Backwards regExp noCase SearchString Replaceme
break
}
}
- } {
- # automaticaly replace all without any prompt
+ } else {
+ # automatically replace all without any prompt
set cnd 1
}
@@ -272,7 +302,7 @@ public method replace {fromCursor Backwards regExp noCase SearchString Replaceme
for {set line $start} {$line <= $end} {incr line} {
parse $line
}
- } {
+ } else {
for {set line $start} {$line <= $end} {incr line} {
restore_line_markers $line
}
@@ -303,9 +333,9 @@ public method replace {fromCursor Backwards regExp noCase SearchString Replaceme
# @return void
public method select_all {} {
catch {
- $editor tag remove sel 1.0 end
+ $editor tag remove sel 1.0 end
}
- $editor tag add sel 1.0 end
+ $editor tag add sel 1.0 end
}
## Comment the selected area or current line
@@ -323,7 +353,7 @@ public method comment {} {
if {[getselection] == {}} {
set restore_sel 0
set end $start
- } {
+ } else {
set restore_sel 1
set start [expr {int([$editor index sel.first])}]
set end_o [$editor index sel.last]
@@ -345,7 +375,7 @@ public method comment {} {
set by_lines 1
set restore_sel 0
set end $start
- } {
+ } else {
set start_o [$editor index sel.first]
set start [expr {int($start_o)}]
set end_o [$editor index sel.last]
@@ -353,7 +383,7 @@ public method comment {} {
if {$end == $end_o && $start == $start_o} {
set restore_sel 1
set by_lines 1
- } {
+ } else {
set restore_sel 0
set by_lines 0
}
@@ -370,7 +400,7 @@ public method comment {} {
restore_line_markers $line
}
# Comment only selected characters
- } {
+ } else {
$editor insert $end_o { */}
$editor insert $start_o {/* }
$editor tag add sel sel.first-3c sel.last+3c
@@ -388,7 +418,7 @@ public method comment {} {
# Restore highlight
if {$prog_language == 1 && ![string index $highlighted_lines $start] == 6} {
parse $start
- } {
+ } else {
for {set i $start} {$i <= $end} {incr i} {
parse $i
}
@@ -417,7 +447,7 @@ public method uncomment {} {
if {[getselection] == {}} {
set restore_sel 0
set end $start
- } {
+ } else {
set restore_sel 1
set start [expr {int([$editor index sel.first])}]
set end_o [$editor index sel.last]
@@ -431,7 +461,7 @@ public method uncomment {} {
set line_data [$editor get $line.0 "$line.0 lineend"]
if {[regexp {^\s*;\s*} $line_data comment]} {
- detete_text_in_editor $line.0 $line.[string length $comment]
+ detete_text_in_editor $line.0 $line.[string length $comment] 0
regsub {;} $comment {} comment
$editor insert $line.0 $comment
restore_line_markers $line
@@ -447,7 +477,7 @@ public method uncomment {} {
set by_lines 1
set restore_sel 0
set end $start
- } {
+ } else {
set start_o [$editor index sel.first]
set start [expr {int($start_o)}]
set end_o [$editor index sel.last]
@@ -455,7 +485,7 @@ public method uncomment {} {
if {$end == $end_o && $start == $start_o} {
set restore_sel 1
set by_lines 1
- } {
+ } else {
set restore_sel 0
set by_lines 0
}
@@ -476,8 +506,8 @@ public method uncomment {} {
set succesful 1
set start_data [string length $start_data]
set end_data [string length $end_data]
- detete_text_in_editor $end_o-${end_data}c $end_o
- detete_text_in_editor $start_o $start_o+${start_data}c
+ detete_text_in_editor $end_o-${end_data}c $end_o 0
+ detete_text_in_editor $start_o $start_o+${start_data}c 0
}
}
@@ -486,13 +516,13 @@ public method uncomment {} {
set line_data [$editor get $line.0 [list $line.0 lineend]]
if {[regexp {^\s*// ?} $line_data line_data]} {
set line_data [string length $line_data]
- detete_text_in_editor $line.0 $line.$line_data
+ detete_text_in_editor $line.0 $line.$line_data 0
manage_autocompletion_list $line
set succesful 1
}
restore_line_markers $line
}
- } {
+ } else {
$editor edit separator
$editor configure -autoseparators 1
return $succesful
@@ -504,7 +534,7 @@ public method uncomment {} {
# Restore highlight
if {$prog_language == 1 && ![string index $highlighted_lines $start] == 6} {
parse $start
- } {
+ } else {
for {set i $start} {$i <= $end} {incr i} {
parse $i
}
@@ -517,6 +547,13 @@ public method uncomment {} {
}
+ # Perform spell checking for all the affected lines
+ if {$spellchecker_enabled} {
+ for {set i $start} {$i <= $end} {incr i} {
+ spellcheck_check_all $i
+ }
+ }
+
# Return result
return $succesful
}
@@ -545,7 +582,7 @@ public method goto {textIndex} {
[$editor index "$textIndex +1 line linestart"]
}
recalc_status_counter {} 0
- update idle
+ update idletasks
$editor see insert
}
@@ -599,7 +636,7 @@ public method indent {} {
set restore_sel 0
set start [expr {int([$editor index insert])}]
set end $start
- } {
+ } else {
set restore_sel 1
set start [expr {int([$editor index sel.first])}]
set end_o [$editor index sel.last]
@@ -610,7 +647,7 @@ public method indent {} {
# indent each line in the block
if {$spaces_no_tabs} {
set indent_char [string repeat { } $number_of_spaces]
- } {
+ } else {
set indent_char "\t"
}
for {set line $start} {$line <= $end} {incr line} {
@@ -635,7 +672,7 @@ public method unindent {} {
set restore_sel 0
set start [expr {int([$editor index insert])}]
set end [expr {int([$editor index insert])}]
- } {
+ } else {
set restore_sel 1
set start [expr {int([$editor index sel.first])}]
set end_o [$editor index sel.last]
@@ -655,7 +692,7 @@ public method unindent {} {
} elseif {[regexp {^\t} $line_data]} {
detete_text_in_editor $line.0 $line.1
}
- } {
+ } else {
if {[regexp {^[\t( )]} $line_data]} {
detete_text_in_editor $line.0 $line.1
}
@@ -717,15 +754,15 @@ public method get_md5 {} {
## Add/Remove bookmark to/from current line
# Directly depends on variable "bookmarks" (managed by proc. recalc_left_frame)
- # @parm Int = NULL - target text index
+ # @parm Int idx=NULL - target text index
# @return bool - 0: bookmark removed; 1: bookmark created
-public method Bookmark args {
+public method Bookmark {{idx {}}} {
if {$editor_to_use} {return}
# Determinate line number
- if {$args != {}} {
- set lineNumber [expr {int($args)}]
- } {
+ if {$idx != {}} {
+ set lineNumber [expr {int($idx)}]
+ } else {
set lineNumber [expr {int([$editor index insert])}]
}
@@ -758,10 +795,10 @@ public method Bookmark args {
$iconBorder image create $lineNumber_i.0 \
-image ::ICONS::16::dot \
-align center
- } {
+ } else {
if {[llength [$editor tag nextrange tag_error $lineNumber.0 [list $lineNumber.0 lineend]]]} {
set image {bm_ex}
- } {
+ } else {
set image {bookmark}
}
$iconBorder image create $lineNumber_i.0 \
@@ -769,7 +806,7 @@ public method Bookmark args {
-align center
}
# Remove icon
- } {
+ } else {
$iconBorder delete $lineNumber_i.0 $lineNumber_i.2
if {
[llength [$editor tag nextrange tag_error $lineNumber.0 [list $lineNumber.0 lineend]]]
@@ -794,14 +831,14 @@ public method Bookmark args {
$parentObject rightPanel_add_bookmark $lineNumber
$parentObject rightPanel_bm_select $lineNumber
# Remove the tag
- } {
+ } else {
$editor tag remove tag_bookmark $lineNumber.0 $tmp.0
$parentObject rightPanel_remove_bookmark $lineNumber
$parentObject rightPanel_bm_unselect
}
# Enable scrolling
- update idle
+ update idletasks
set scroll_in_progress 0
# Done ...
@@ -810,14 +847,14 @@ public method Bookmark args {
## Add/Remove breapoint to/from current line
# Directly depends on variable "breakpoints" (managed by proc. recalc_left_frame)
- # @parm Int = NULL - target text index
+ # @parm Int idx=NULL - target text index
# @return bool - 0: breakpoint removed; 1: breakpoint created; or {}
-public method Breakpoint args {
+public method Breakpoint {{idx {}}} {
# Determinate line number
- if {$args != {}} {
- set lineNumber [expr {int($args)}]
- } {
+ if {$idx != {}} {
+ set lineNumber [expr {int($idx)}]
+ } else {
set lineNumber [expr {int([$editor index insert])}]
}
@@ -844,12 +881,21 @@ public method Breakpoint args {
# Add the tag
if {$make} {
- $lineNumbers tag add tag_breakpoint $lineNumber_i.0 $tmp.0
+ # Detereminate whether the breakpoint will be valid or not
+ if {[is_breakpoint_valid $lineNumber]} {
+ set tag {tag_breakpoint}
+ } else {
+ set tag {tag_breakpoint_INVALID}
+ }
+
+ $lineNumbers tag add $tag $lineNumber_i.0 $tmp.0
$parentObject rightPanel_add_breakpoint $lineNumber
$parentObject rightPanel_bp_select $lineNumber
+
# Remove the tag
- } {
+ } else {
$lineNumbers tag remove tag_breakpoint $lineNumber_i.0 $tmp.0
+ $lineNumbers tag remove tag_breakpoint_INVALID $lineNumber_i.0 $tmp.0
$parentObject rightPanel_remove_breakpoint $lineNumber
$parentObject rightPanel_bp_unselect
}
@@ -863,7 +909,7 @@ public method Breakpoint args {
}
# Enable scrolling
- update idle
+ update idletasks
set scroll_in_progress 0
# done ...
@@ -910,6 +956,7 @@ public method clear_all_breakpoints {} {
# Clear breakpoint tags from line numbers
$lineNumbers tag remove tag_breakpoint 1.0 end
+ $lineNumbers tag remove tag_breakpoint_INVALID 1.0 end
# Clear right panel
$parentObject rightPanel_clear_all_breakpoints
@@ -991,7 +1038,7 @@ public method insertData {data position} {
# Insert data
$editor insert $position [regsub -all {[\u0000-\u0008\u000B-\u000C\u000E-\u001F\u007F-\u009F]} $data {}]
# Highlight
- update idle
+ update idletasks
parseAll
}
@@ -1065,7 +1112,7 @@ private method get_count_of_lines {index0 index1} {
# Translate tabulators to spaces
set idx -1
set cor 0
- while 1 {
+ while {1} {
set idx [string first "\t" $lineText [expr {$idx + 1}]]
if {$idx == -1} {break}
@@ -1076,7 +1123,7 @@ private method get_count_of_lines {index0 index1} {
set line_width [font measure $defaultFont_bold -displayof $editor $lineText]
incr line_width [expr {$cor * $defaultCharWidth}]
# Line doesn't contain tabulators
- } {
+ } else {
set line_width [font measure $defaultFont_bold -displayof $editor $lineText]
}
@@ -1090,14 +1137,6 @@ private method get_count_of_lines {index0 index1} {
return $new_wrap
}
-## Get data of bookmarks and breapoints
- # @return List - {bookmarks breakpoints} (eg. {00011 10100})
-public method export_line_markers_data {} {
- set result [join $bookmarks {}]
- lappend result [join $breakpoints {}]
- return $result
-}
-
## Get total number of lines in editor
# @return Int - result
public method getLinesCount {} {
@@ -1107,28 +1146,66 @@ public method getLinesCount {} {
return [expr {int($result) - 1}]
}
+## Get data of bookmarks and breapoints
+ # @return List - {bookmarks breakpoints} (eg. {{1 15 96} {2 45}})
+public method export_line_markers_data {} {
+ set foo [lsearch -ascii -exact -all $bookmarks 1]
+ if {![llength $foo]} {
+ set foo 0
+ }
+ set bar [lsearch -ascii -exact -all $breakpoints 1]
+ if {![llength $bar]} {
+ set bar 0
+ }
+ return [list $foo $bar]
+}
+
## Import list of bookmarks and breapoints
# This function also validates given input data
# This function does not do anything with the right panel
- # @parm String Bookmarks - bookmakrs (eg. 00011010)
- # @parm String Breakpoints - breakpoints (eg. 011010000000)
+ # @parm String Bookmarks - bookmakrs (eg. {1 15 96})
+ # @parm String Breakpoints - breakpoints (eg. {2 45})
# @return void
public method import_line_markers_data {Bookmarks Breakpoints} {
if {$editor_to_use} {return}
+ # Determinate number of the last line in the editor
+ set lastEnd [expr {int([$editor index end])}]
+
# Check validity of the given data
- if {![regexp {^[01]*$} $Bookmarks]} {
- puts stderr [mc "Invalid list of bookmarks -- bookmarks discarded"]
+ if {[string index $Bookmarks 0] == {0}} {
+ if {![regexp {^[01]*$} $Bookmarks]} {
+ puts stderr [mc "Invalid list of bookmarks -- bookmarks discarded"]
+ set Bookmarks {}
+ }
+ } else {
+ set foo $Bookmarks
set Bookmarks {}
+ for {set i 0} {$i <= $lastEnd} {incr i} {
+ if {[lsearch -ascii -exact $foo $i] != -1} {
+ append Bookmarks 1
+ } else {
+ append Bookmarks 0
+ }
+ }
}
- if {![regexp {^[01]*$} $Breakpoints]} {
- puts stderr [mc "Invalid list of breakpoints -- bookmarks discarded"]
+ if {[string index $Breakpoints 0] == {0}} {
+ if {![regexp {^[01]*$} $Breakpoints]} {
+ puts stderr [mc "Invalid list of breakpoints -- bookmarks discarded"]
+ set Breakpoints {}
+ }
+ } else {
+ set foo $Breakpoints
set Breakpoints {}
+ for {set i 0} {$i <= $lastEnd} {incr i} {
+ if {[lsearch -ascii -exact $foo $i] != -1} {
+ append Breakpoints 1
+ } else {
+ append Breakpoints 0
+ }
+ }
}
- # Determinate number of the last line in the editor
- set lastEnd [expr {int([$editor index end])}]
-
# Initialize list of highlighted lines
set highlighted_lines [string repeat 0 $lastEnd]
@@ -1164,7 +1241,7 @@ public method import_line_markers_data {Bookmarks Breakpoints} {
$iconBorder image create $line.0 \
-image ::ICONS::16::dot \
-align center
- } {
+ } else {
$iconBorder image create $line.0 \
-image ::ICONS::16::bookmark \
-align center
@@ -1269,7 +1346,7 @@ public method set_lock {bool} {
DynamicHelp::add $Sbar_lock_file -text [mc "Unlock file switching"]
$Sbar_lock_file configure \
-image ::ICONS::16::lock
- } {
+ } else {
setStatusTip -widget $Sbar_lock_file -text [mc "File switching unlocked"]
Sbar -freeze [mc "File switching unlocked"]
DynamicHelp::add $Sbar_lock_file -text [mc "Lock file switching"]
@@ -1280,12 +1357,18 @@ public method set_lock {bool} {
}
## Invert simulator lock
- # @retunr void
+ # @return void
public method invert_lock {} {
set_lock [expr {!$auto_switching_lock}]
$parentObject set_editor_lock $this $auto_switching_lock
}
+## Get value of internal flag "frozen"
+ # @return Bool - True if the editor is in simulator mode, or disabled mode
+public method get_flag_frozen {} {
+ return $frozen
+}
+
## Switch from editor mode to simulator mode
# This operation will cause error if editor is in mode disabled
# @return void
@@ -1309,7 +1392,7 @@ public method freeze {} {
if {!$frozen} {
pack $Sbar_ssim_mode -side right
pack $Sbar_lock_file -side left
- } {
+ } else {
pack $Sbar_sim_mode -side right
}
# Disable some popup menu items
@@ -1357,7 +1440,6 @@ public method thaw {} {
if {!$ro_mode} {
$editor configure -state normal
}
- focus -force $editor
set idx [$editor index "insert linestart"]
$editor tag add tag_current_line $idx "$idx + 1 line"
pack $Sbar_CRT_frame
@@ -1379,6 +1461,11 @@ public method thaw {} {
}
# Recalculate counters
recalc_status_counter {} 0
+
+ # Check the flag "file_change_notif_flg" and if set, inform the user
+ #+ about modification to the currently opened file done by another
+ #+ program.
+ check_file_change_notif
}
## Move simulator line (line representing current position in simulator engine)
@@ -1442,12 +1529,15 @@ public method highlight_visible_area {} {
# Highlight the current view
for {set line $start} {$line <= $end} {incr line} {
if {[string index $highlighted_lines $line] == 0} {
- if {![parse $line]} {
+ if {![parse $line 1]} {
if {$line != $start} {break}
}
}
}
+ # Ensure that the current line is also checked for correct spelling
+ spellcheck_check_all [expr {int([$editor index insert])}] 1
+
# Restore previous editor state
if {$frozen} {$editor configure -state disabled}
}
@@ -1458,6 +1548,7 @@ public method highlight_visible_area {} {
# if it is not then invoke procedure 'X::__save_as'
# @return Bool - result
public method save {} {
+ if {$ro_mode} {return 1}
if {$editor_to_use} {return 1}
if {$save_in_progress} {return 1}
set save_in_progress 1
@@ -1474,9 +1565,13 @@ public method save {} {
catch {
file rename -force $fullFileName "$fullFileName~"
}
+
+ # Stop watching for modification of this file on disk (we will reenable it later)
+ FSnotifications::forget $fullFileName
}
+
if {[catch {
- set chanel [open $fullFileName w 420]
+ set chanel [open $fullFileName w 0640]
}]} then {
tk_messageBox \
-parent . \
@@ -1485,6 +1580,10 @@ public method save {} {
-title [mc "Permission denied"] \
-message [mc "Unable to open file:\n\"%s\"\nfor writing" $fullFileName]
set save_in_progress 0
+
+ # Again start watching for modification of this file on disk
+ FSnotifications::watch $fullFileName [list ::Editor::file_change_notif $this]
+
return 0
}
fconfigure $chanel -translation $eol -encoding $encoding
@@ -1494,6 +1593,9 @@ public method save {} {
$editor edit modified 0
set modified 0
+ # Again start watching for modification of this file on disk
+ FSnotifications::watch $fullFileName [list ::Editor::file_change_notif $this]
+
# Stop autosave timer
catch {
after cancel $autosave_timer
@@ -1501,17 +1603,174 @@ public method save {} {
}
# Change application status
- Sbar [mc "File %s saved" $fullFileName]
::X::adjust_title
set save_in_progress 0
if {$fullFileName == {}} {
return 0
- } {
+ } else {
+ if {$::MICROSOFT_WINDOWS} { ;# "/" --> "\"
+ regsub -all {/} $fullFileName "\\" fullFileName_win
+ } else {
+ set fullFileName_win $fullFileName
+ }
+ Sbar [mc "File %s saved" $fullFileName_win]
return 1
}
}
+## Set internal flag "file_change_notif_flg" to true
+ #
+ # The flag indicates that the file opened in this editor was modified on disk
+ # by another program. The flag is automatically cleared when the user is
+ # informed about the modification to the file.
+ #
+ # @return void
+public method set_file_change_notif_flg {} {
+ set file_change_notif_flg 1
+}
+
+## Check flag "file_change_notif_flg" and if set, inform the user about this.
+ #
+ # The flag file_change_notif_flg indicates that the file opened in this editor
+ # was modified on disk by another program. The flag is automatically cleared by
+ # this method. The user is informed via a dialog window giving him three
+ # options, reload the file, overwrite it on disk, and ignore it.
+ #
+ # @return void
+public method check_file_change_notif {} {
+ # Check the flag, and clear it if it was set
+ if {!$file_change_notif_flg} {
+ return
+ }
+ set file_change_notif_flg 0
+
+ # Create the dialog window
+ set dialog [toplevel .file_change_notif_dlg]
+
+ # Create top frame (dialog icon and text of the message)
+ set dlg_top_frame [frame $dialog.top_frame]
+ pack [label $dlg_top_frame.image -image ::ICONS::32::messagebox_warning] -side left -padx 5
+ pack [label $dlg_top_frame.label \
+ -justify left \
+ -text [mc "The file '%s' was modified from outside of this program.\n\nWhat do you want to do with the modified file?" [file tail $fullFileName]] \
+ ] -side left -fill x -expand 1 -padx 5
+
+ # Create bottom bar with dialog buttons
+ set button_frame [frame $dialog.button_frame]
+ pack [ttk::button $button_frame.button_reload \
+ -text [mc "Reload in editor"] \
+ -compound left \
+ -image ::ICONS::16::reload \
+ -command "
+ $parentObject filelist_reload_file $this 1
+ grab release $dialog
+ destroy $dialog
+ " \
+ ] -side left -padx 2
+ pack [ttk::button $button_frame.button_overwrt \
+ -text [mc "Overwrite on disk"] \
+ -compound left \
+ -image ::ICONS::16::filesave \
+ -command "
+ $this save
+ grab release $dialog
+ destroy $dialog
+ " \
+ ] -side left -padx 2
+ pack [ttk::button $button_frame.button_cancel \
+ -text [mc "Do nothing"] \
+ -compound left \
+ -image ::ICONS::16::cancel \
+ -command "
+ grab release $dialog
+ destroy $dialog
+ " \
+ ] -side left -padx 2
+
+ # Pack window frames
+ pack $dlg_top_frame -side top -fill x -expand 1 -padx 5 -pady 10
+ pack $button_frame -side bottom -side right -padx 5 -pady 5
+
+ bind $dialog <Escape> "
+ grab release $dialog
+ destroy $dialog
+ "
+
+ # Set dialog attributes (modal window)
+ wm iconphoto $dialog ::ICONS::16::status_unknown
+ wm title $dialog [mc "File changed on disk"]
+ wm state $dialog normal
+ wm minsize $dialog 400 110
+ wm transient $dialog .
+ wm protocol $dialog WM_DELETE_WINDOW "
+ grab release $dialog
+ destroy $dialog
+ "
+ update
+ catch {
+ grab $dialog
+ }
+ raise $dialog
+ focus -force $button_frame.button_cancel
+ tkwait window $dialog
+}
+
+## File change notification callback
+ #
+ # This function is supposed to be called by the FSnotifications component when
+ # a modification to the currently opened file was made by another program.
+ #
+ # @return void
+proc file_change_notif {editor_ref filename} {
+ # This call is invalid if there are no projects opened
+ if {![llength ${::X::openedProjects}]} {
+ return
+ }
+
+ # Attempt to find the corresponding project and editor index number
+ foreach project ${::X::openedProjects} {
+ set list_of_editors [$project cget -editors]
+ set actual_editor [$project cget -actualEditor]
+ set actual_editor2 [$project cget -actualEditor2]
+ set editor_idx [lsearch -ascii -exact $list_of_editors $editor_ref]
+
+ if {$editor_idx == -1} {
+ # Editor editor index number not found, move on to another project
+ continue
+ }
+
+ # Try to get the "frozen" flag from the editor
+ if {[catch {
+ set editor_frozen [$editor_ref get_flag_frozen]
+ }]} then {
+ # Unable to comply, that probably means that the editor
+ # does not exist any more
+ return
+ }
+
+ # Set the "file_change_notif_flg" flag
+ $project editor_procedure $editor_idx set_file_change_notif_flg {}
+
+ # Check the "file_change_notif_flg" flag right away, if the
+ #+ editor is currently visible to the user
+ if {
+ ($project == ${::X::actualProject})
+ &&
+ ($editor_idx == $actual_editor || $editor_idx == $actual_editor2)
+ } then {
+ # If the editor is in frozen state, i.e. the MCU
+ # simulator is engaged, then don't annoy with nonsense
+ # messages, and instead inform the user later.
+ if {!$editor_frozen} {
+ $project editor_procedure $editor_idx check_file_change_notif {}
+ }
+ }
+
+ break
+ }
+}
+
## Set variable 'fullFileName' for later file save (method 'save')
# note: also change editors status bar
# @parm String full_filename - the full filename (including path)
@@ -1520,6 +1779,16 @@ public method save {} {
public method set_FileName {full_filename rootName} {
if {$editor_to_use} {return}
+ # Start watching for changes in the file (on disk)
+ if {$fullFileName != {}} {
+ # Stop watching the old file
+ FSnotifications::watch forget $fullFileName
+ }
+ if {$full_filename != {}} {
+ # Start watching the new file
+ FSnotifications::watch $full_filename [list ::Editor::file_change_notif $this]
+ }
+
# set variables
set fullFileName $full_filename
set filename $rootName
@@ -1535,7 +1804,7 @@ public method getFileName {} {
return [list [file dirname $fullFileName] $filename]
}
-## Change letter case acording to the given options
+## Change letter case according to the given options
# @parm List options - list of 21 values, each must be one of {- L -U}
# '-' - keep case
# 'U' - Uppercase
@@ -1563,13 +1832,13 @@ public method change_letter_case {options} {
tag_imm_dec tag_imm_bin
tag_imm_constant tag_imm_unknown
tag_macro
- } \
+ } \
{
# Evaluate option
if {$option == {-}} {continue}
if {$option == {U}} {
set option {toupper}
- } {
+ } else {
set option {tolower}
}
@@ -1744,7 +2013,7 @@ public method copy {} {
Sbar [mc "Unable to execute: nothing selected"]
return 0
# Adjust clipboard content
- } {
+ } else {
clipboard clear
clipboard append $data
return 1
@@ -1752,11 +2021,11 @@ public method copy {} {
}
## Paste clipboard content to the text at the cursor position
- # @parm Bool = 0 - Use X selection instead of the clipboard
- # @
- # @
+ # @parm Bool use_X_sel=0 - Use X selection instead of the clipboard
+ # @parm Int x - X coordinate
+ # @parm Int y - Y coordinate
# @return bool - 1: successful; 0: failed
-public method paste args {
+public method paste {{use_X_sel 0} {x {}} {y {}}} {
if {$critical_edit_proc} {return}
set critical_edit_proc 1
@@ -1765,9 +2034,9 @@ public method paste args {
set original_cur_pos [$editor index insert]
}
- if {[lindex $args 0] == {1}} {
+ if {$use_X_sel} {
set cmd {selection}
- } {
+ } else {
set cmd {clipboard}
}
@@ -1780,9 +2049,7 @@ public method paste args {
return 0
}
- if {[lindex $args 0] == {1}} {
- set x [lindex $args 1]
- set y [lindex $args 2]
+ if {$use_X_sel} {
$editor mark set insert @$x,$y
catch {
$editor tag remove sel 0.0 end
@@ -1793,15 +2060,16 @@ public method paste args {
$editor configure -autoseparators 0
deleteselection
recalc_left_frame
- # insert data to the text, restore syntax hightlight and return 1
+ # insert data to the text, restore syntax highlight
$editor insert [$editor index insert] $data
recalc_left_frame
recalc_status_counter {}
$editor see [$editor index insert]
- update idle
+ update idletasks
set line [expr {int([$editor index insert])}]
rightPanel_adjust $line
parse $line
+ spellcheck_check_all $line 2 ;# Perform spell check for the current line
highlight_visible_area
$editor edit separator
$editor configure -autoseparators 1
@@ -1895,7 +2163,7 @@ public method cut {} {
set critical_edit_proc 0
return 0
# Cut
- } {
+ } else {
# Adjust clipboard content
deleteselection
clipboard clear
@@ -1957,8 +2225,10 @@ public method kill_childern {} {
if {$editor_to_use} {
bind $top_frame <Destroy> {}
if {!$::MICROSOFT_WINDOWS} { ;# There is no kill command on Microsoft Windows
- catch {
- exec -- kill $pid
+ if {$pid != [pid] && $pid != 0} {
+ catch {
+ exec -- kill $pid
+ }
}
}
catch {
@@ -1967,7 +2237,7 @@ public method kill_childern {} {
}
}
-## Get ID of file type (programing language used)
+## Get ID of file type (programming language used)
# @return Int - 0 == Assembly language; 1 == C language
public method get_language {} {
if {$prog_language == -1} {
@@ -1979,12 +2249,12 @@ public method get_language {} {
} else {
return 0
}
- } {
+ } else {
return $prog_language
}
}
-## Set file type (programing language used)
+## Set file type (programming language used)
# @parm Int lang - -1 == unknown; 0 == Assembly language; 1 == C language
# @return void
public method force_language {lang} {
@@ -2173,7 +2443,7 @@ public method getFileStatistics {} {
if {$found} {continue}
if {[string is wordchar -strict $char]} {
incr words_and_numbers
- } {
+ } else {
incr others
}
}
@@ -2181,7 +2451,7 @@ public method getFileStatistics {} {
# Determinate line type excluding empty lines
if {$last_words == $words && $last_keywords == $keywords && $last_comments < $comments} {
incr commented_lines
- } {
+ } else {
incr normal_lines
}
}
@@ -2200,12 +2470,22 @@ public method getFileStatistics {} {
}
## Set read only mode
- # @parm Bool mode_frag - 1 == Read only; 0 = Read and write
- # @return void
+ # @parm Bool mode_frag - 1 == Read only; 0 == Read and write
+ # @return Bool - true == ok; false == cannot comply!
public method change_RO_MODE {mode_frag} {
if {$editor_to_use} {return}
set ro_mode $mode_frag
+ if {!$ro_mode && [$parentObject cget -S_flag_read_only]} {
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -icon warning \
+ -title [mc "Read-only project"] \
+ -message [mc "This project has a special purpose, modifications to this project are not allowed."]
+ return 0
+ }
+
# Set to read only
if {$ro_mode} {
$editor configure -state disabled
@@ -2220,7 +2500,7 @@ public method change_RO_MODE {mode_frag} {
set state {disabled}
# Set to normal mode
- } {
+ } else {
$editor configure -state normal
$ins_mode_lbl configure \
-bg {#DDDDDD} \
@@ -2237,6 +2517,7 @@ public method change_RO_MODE {mode_frag} {
$menu entryconfigure [::mc $entry] -state $state
}
::X::adjust_mainmenu_and_toolbar_to_editor $ro_mode {}
+ return 1
}
## Perform program jump
@@ -2257,7 +2538,7 @@ public method ljmp_this_line {} {
set lineNum [$parentObject simulator_getCurrentLine]
if {$lineNum != {}} {
$parentObject move_simulator_line $lineNum
- } {
+ } else {
$parentObject editor_procedure {} unset_simulator_line {}
}
$parentObject Simulator_sync_PC_etc
@@ -2268,8 +2549,8 @@ public method ljmp_this_line {} {
public method lcall_this_line {} {
if {$editor_to_use} {return}
# Determinate target address
- set address [$parentObject simulator_line2address \
- [expr {int([$editor index insert])}] \
+ set address [$parentObject simulator_line2address \
+ [expr {int([$editor index insert])}] \
[$parentObject simulator_get_filenumber $fullFileName] \
]
if {$address == {}} {
@@ -2281,8 +2562,12 @@ public method lcall_this_line {} {
set lineNum [$parentObject simulator_getCurrentLine]
if {$lineNum != {}} {
$parentObject move_simulator_line $lineNum
- } {
+ } else {
$parentObject editor_procedure {} unset_simulator_line {}
}
$parentObject Simulator_sync_PC_etc
-} \ No newline at end of file
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/editor/spell_check.tcl b/lib/editor/spell_check.tcl
new file mode 100644
index 0000000..7759607
--- /dev/null
+++ b/lib/editor/spell_check.tcl
@@ -0,0 +1,1325 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# 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 #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _SPELL_CHECK_TCL ] } {
+set _SPELL_CHECK_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+# Spell checker interface used by the source code editor.
+#
+# Used spell checker is Hunspell.
+#
+#
+# COMMUNICATION CONNECTIONS WITH HUNSPELL:
+# -----------------------------------------
+#
+# +-------------------+ (4) +----------+ (5) +------------------+
+# | receive_and_print | | | Hunspell | | | external_command |
+# | (RAP) | ---> | | ---> | |
+# +-------------------+ +----------+ +------------------+
+# ^ |--(2) |--3
+# (1)--| v v
+# +--------------------------------------------------------+
+# | spell_check |
+# +--------------------------------------------------------+
+#
+# 1: Send a word to check along with commands to execute in case of correct and wrong spelling
+# 2: Receive the identifier for IPC with the RAP (variable spellchecker_RAP_ID)
+# 3: Receive response from the Hunspell via IPC
+# 4: Send a word to check to the Hunspell via a pipe
+# 5: Receive response from the Hunspell via a pipe
+#
+# --------------------------------------------------------------------------
+
+## COMMON
+common spellchecker_enabled 0 ;# Bool: Flag spell checking enabled
+common spellchecker_dictionary {} ;# String: Dictionary to use (e.g. en_US or cs_CZ)
+common spellchecker_process_pid [list] ;# List of Ints: Process identifiers of the spell checker and support processes
+common spellchecker_command_LIFO [list] ;# List: LIFO for commands invoked by spell checker {correct_spelling_cmd wrong_spelling_cmd}
+common spellchecker_RAP_ID {} ;# String: Application name of ``receive_and_print'' for IPC
+common spellchecker_attempts_to_restart 0 ;# Int: Number of failed attempts to restart the spell checker process
+common spellchecker_started_flag ;# None: When this variable is set that means that the spell checker process has been started
+common spellchecker_start_failed 0 ;# Bool: Flag spellchecker_started_flag was set but the spell checker process was not actually started
+common spellchecker_start_timer {} ;# AfterTimer: Watch dog timer for start of of the spell checker process
+common available_dictionaries [list] ;# List of Strings: Dictionaries available to the Hunspell
+common hunspell_process {} ;# Channel: Hunspell process invoked by command open in order to gain list of dictionaries
+
+## PRIVATE
+private variable spellcheck_line_pre {} ;# String: Content of the line where change_detected_pre was performed
+private variable spellcheck_line_number {} ;# Int: Number of the last line where change_detected_pre was performed, see spellcheck_check_all
+private variable spellcheck_lock 0 ;# Bool: Inhibit method ``spellcheck_check_all''
+
+## COMMON
+
+## List: Language codes and language names according to: ISO-639-1
+ # Format:
+ # {
+ # { Language_Name Language_Code }
+ # ...
+ # }
+common LANGUAGE_CODES_AND_NAMES {
+ {{Abkhazian} {ab}} {{Afar} {aa}}
+ {{Afrikaans} {af}} {{Akan} {ak}}
+ {{Albanian} {sq}} {{Amharic} {am}}
+ {{Arabic} {ar}} {{Aragonese} {an}}
+ {{Armenian} {hy}} {{Assamese} {as}}
+ {{Avaric} {av}} {{Avestan} {ae}}
+ {{Aymara} {ay}} {{Azerbaijani} {az}}
+ {{Bambara} {bm}} {{Bashkir} {ba}}
+ {{Basque} {eu}} {{Belarusian} {be}}
+ {{Bengali} {bn}} {{Bihari languages} {bh}}
+ {{Bislama} {bi}} {{Bokmål, Norwegian} {nb}}
+ {{Bosnian} {bs}} {{Breton} {br}}
+ {{Bulgarian} {bg}} {{Burmese} {my}}
+ {{Castilian} {es}} {{Catalan} {ca}}
+ {{Central Khmer} {km}} {{Chamorro} {ch}}
+ {{Chechen} {ce}} {{Chewa} {ny}}
+ {{Chichewa} {ny}} {{Chinese} {zh}}
+ {{Chuang} {za}} {{Church Slavic} {cu}}
+ {{Church Slavonic} {cu}} {{Chuvash} {cv}}
+ {{Cornish} {kw}} {{Corsican} {co}}
+ {{Cree} {cr}} {{Croatian} {hr}}
+ {{Czech} {cs}} {{Danish} {da}}
+ {{Dhivehi} {dv}} {{Divehi} {dv}}
+ {{Dutch} {nl}} {{Dzongkha} {dz}}
+ {{English} {en}} {{Esperanto} {eo}}
+ {{Estonian} {et}} {{Ewe} {ee}}
+ {{Faroese} {fo}} {{Fijian} {fj}}
+ {{Finnish} {fi}} {{Flemish} {nl}}
+ {{French} {fr}} {{Fulah} {ff}}
+ {{Gaelic} {gd}} {{Galician} {gl}}
+ {{Ganda} {lg}} {{Georgian} {ka}}
+ {{German} {de}} {{Gikuyu} {ki}}
+ {{Greek, Modern} {el}} {{Greenlandic} {kl}}
+ {{Guarani} {gn}} {{Gujarati} {gu}}
+ {{Haitian} {ht}} {{Haitian Creole} {ht}}
+ {{Hausa} {ha}} {{Hebrew} {he}}
+ {{Herero} {hz}} {{Hindi} {hi}}
+ {{Hiri Motu} {ho}} {{Hungarian} {hu}}
+ {{Icelandic} {is}} {{Ido} {io}}
+ {{Igbo} {ig}} {{Indonesian} {id}}
+ {{Interlingue} {ie}} {{Inuktitut} {iu}}
+ {{Inupiaq} {ik}} {{Irish} {ga}}
+ {{Italian} {it}} {{Japanese} {ja}}
+ {{Javanese} {jv}} {{Kalaallisut} {kl}}
+ {{Kannada} {kn}} {{Kanuri} {kr}}
+ {{Kashmiri} {ks}} {{Kazakh} {kk}}
+ {{Kikuyu} {ki}} {{Kinyarwanda} {rw}}
+ {{Kirghiz} {ky}} {{Komi} {kv}}
+ {{Kongo} {kg}} {{Korean} {ko}}
+ {{Kuanyama} {kj}} {{Kurdish} {ku}}
+ {{Kwanyama} {kj}} {{Kyrgyz} {ky}}
+ {{Lao} {lo}} {{Latin} {la}}
+ {{Latvian} {lv}} {{Letzeburgesch} {lb}}
+ {{Limburgan} {li}} {{Limburger} {li}}
+ {{Limburgish} {li}} {{Lingala} {ln}}
+ {{Lithuanian} {lt}} {{Luba-Katanga} {lu}}
+ {{Luxembourgish} {lb}} {{Macedonian} {mk}}
+ {{Malagasy} {mg}} {{Malay} {ms}}
+ {{Malayalam} {ml}} {{Maldivian} {dv}}
+ {{Maltese} {mt}} {{Manx} {gv}}
+ {{Maori} {mi}} {{Marathi} {mr}}
+ {{Marshallese} {mh}} {{Moldavian} {ro}}
+ {{Moldovan} {ro}} {{Mongolian} {mn}}
+ {{Nauru} {na}} {{Navaho} {nv}}
+ {{Navajo} {nv}} {{Ndebele, North} {nd}}
+ {{Ndebele, South} {nr}} {{Ndonga} {ng}}
+ {{Nepali} {ne}} {{North Ndebele} {nd}}
+ {{Northern Sami} {se}} {{Norwegian} {no}}
+ {{Norwegian Bokmål} {nb}} {{Norwegian Nynorsk} {nn}}
+ {{Nuosu} {ii}} {{Nyanja} {ny}}
+ {{Nynorsk, Norwegian} {nn}} {{Occidental} {ie}}
+ {{Occitan} {oc}} {{Ojibwa} {oj}}
+ {{Old Bulgarian} {cu}} {{Old Church Slavonic} {cu}}
+ {{Old Slavonic} {cu}} {{Oriya} {or}}
+ {{Oromo} {om}} {{Ossetian} {os}}
+ {{Ossetic} {os}} {{Pali} {pi}}
+ {{Panjabi} {pa}} {{Pashto} {ps}}
+ {{Persian} {fa}} {{Polish} {pl}}
+ {{Portuguese} {pt}} {{Punjabi} {pa}}
+ {{Pushto} {ps}} {{Quechua} {qu}}
+ {{Romanian} {ro}} {{Romansh} {rm}}
+ {{Rundi} {rn}} {{Russian} {ru}}
+ {{Samoan} {sm}} {{Sango} {sg}}
+ {{Sanskrit} {sa}} {{Sardinian} {sc}}
+ {{Scottish Gaelic} {gd}} {{Serbian} {sr}}
+ {{Shona} {sn}} {{Sichuan Yi} {ii}}
+ {{Sindhi} {sd}} {{Sinhala} {si}}
+ {{Sinhalese} {si}} {{Slovak} {sk}}
+ {{Slovenian} {sl}} {{Somali} {so}}
+ {{Sotho, Southern} {st}} {{South Ndebele} {nr}}
+ {{Spanish} {es}} {{Sundanese} {su}}
+ {{Swahili} {sw}} {{Swati} {ss}}
+ {{Swedish} {sv}} {{Tagalog} {tl}}
+ {{Tahitian} {ty}} {{Tajik} {tg}}
+ {{Tamil} {ta}} {{Tatar} {tt}}
+ {{Telugu} {te}} {{Thai} {th}}
+ {{Tibetan} {bo}} {{Tigrinya} {ti}}
+ {{Tonga} {to}} {{Tsonga} {ts}}
+ {{Tswana} {tn}} {{Turkish} {tr}}
+ {{Turkmen} {tk}} {{Twi} {tw}}
+ {{Uighur} {ug}} {{Ukrainian} {uk}}
+ {{Urdu} {ur}} {{Uyghur} {ug}}
+ {{Uzbek} {uz}} {{Valencian} {ca}}
+ {{Venda} {ve}} {{Vietnamese} {vi}}
+ {{Volapük} {vo}} {{Walloon} {wa}}
+ {{Welsh} {cy}} {{Western Frisian} {fy}}
+ {{Wolof} {wo}} {{Xhosa} {xh}}
+ {{Yiddish} {yi}} {{Yoruba} {yo}}
+ {{Zhuang} {za}} {{Zulu} {zu}}
+}
+
+## List: Country codes with names of their flags file in directory ``${::ROOT_DIRNAME}/icons/flag/''
+ # Format:
+ # {
+ # { Country_Name Country_Code Flag_File_Name_Without_Extension }
+ # ...
+ # }
+common COUNTRY_CODES_AND_FLAGS {
+ {{Afghanistan} AF Afghanistan}
+ {{Åland Islands} AX {}}
+ {{Albania} AL Albania}
+ {{Algeria} DZ Algeria}
+ {{American Samoa} AS American_Samoa}
+ {{Andorra} AD Andorra}
+ {{Angola} AO Angola}
+ {{Anguilla} AI Anguilla}
+ {{Antarctica} AQ {}}
+ {{Antigua And Barbuda} AG Antigua_and_Barbuda}
+ {{Argentina} AR Argentina}
+ {{Armenia} AM Armenia}
+ {{Aruba} AW Aruba}
+ {{Australia} AU Australia}
+ {{Austria} AT Austria}
+ {{Azerbaijan} AZ Azerbaijan}
+
+ {{Bahamas} BS Bahamas}
+ {{Bahrain} BH Bahrain}
+ {{Bangladesh} BD Bangladesh}
+ {{Barbados} BB Barbados}
+ {{Belarus} BY Belarus}
+ {{Belgium} BE Belgium}
+ {{Belize} BZ Belize}
+ {{Benin} BJ Benin}
+ {{Bermuda} BM Bermuda}
+ {{Bhutan} BT Bhutan}
+ {{Bolivia, Plurinational State Of} BO Bolivia}
+ {{Bosnia And Herzegovina} BA Bosnia}
+ {{Botswana} BW Botswana}
+ {{Bouvet Island} BV {}}
+ {{Brazil} BR Brazil}
+ {{British Indian Ocean Territory} IO {}}
+ {{Brunei Darussalam} BN Brunei}
+ {{Bulgaria} BG Bulgaria}
+ {{Burkina Faso} BF Burkina_Faso}
+ {{Burundi} BI Burundi}
+
+ {{Cambodia} KH Cambodia}
+ {{Cameroon} CM Cameroon}
+ {{Canada} CA Canada}
+ {{Cape Verde} CV Cape_Verde}
+ {{Cayman Islands} KY Cayman_Islands}
+ {{Central African Republic} CF Central_African_Republic}
+ {{Chad} TD Chad}
+ {{Chile} CL Chile}
+ {{China} CN China}
+ {{Christmas Island} CX Christmas_Island}
+ {{Cocos (Keeling) Islands} CC {}}
+ {{Colombia} CO Colombia}
+ {{Comoros} KM Comoros}
+ {{Congo} CG Republic_of_the_Congo}
+ {{Congo, The Democratic Republic Of The} CD Democratic_Republic_of_the_Congo}
+ {{Cook Islands} CK Cook_Islands}
+ {{Costa Rica} CR Costa_Rica}
+ {{Côte D'Ivoire} CI Cote_dIvoire}
+ {{Croatia} HR Croatia}
+ {{Cuba} CU Cuba}
+ {{Cyprus} CY Cyprus}
+ {{Czech Republic} CZ Czech_Republic}
+
+ {{Denmark} DK Denmark}
+ {{Djibouti} DJ Djibouti}
+ {{Dominica} DM Dominica}
+ {{Dominican Republic} DO Dominican_Republic}
+
+ {{Ecuador} EC Ecuador}
+ {{Egypt} EG Egypt}
+ {{El Salvador} SV El_Salvador}
+ {{Equatorial Guinea} GQ Equatorial_Guinea}
+ {{Eritrea} ER Eritrea}
+ {{Estonia} EE Estonia}
+ {{Ethiopia} ET Ethiopia}
+
+ {{Falkland Islands (Malvinas)} FK Falkland_Islands}
+ {{Faroe Islands} FO Faroe_Islands}
+ {{Fiji} FJ Fiji}
+ {{Finland} FI Finland}
+ {{France} FR France}
+ {{French Guiana} GF {}}
+ {{French Polynesia} PF French_Polynesia}
+ {{French Southern Territories} TF {}}
+
+ {{Gabon} GA Gabon}
+ {{Gambia} GM Gambia}
+ {{Georgia} GE Georgia}
+ {{Germany} DE Germany}
+ {{Ghana} GH Ghana}
+ {{Gibraltar} GI Gibraltar}
+ {{Greece} GR Greece}
+ {{Greenland} GL Greenland}
+ {{Grenada} GD Grenada}
+ {{Guadeloupe} GP {}}
+ {{Guam} GU Guam}
+ {{Guatemala} GT Guatemala}
+ {{Guernsey} GG {}}
+ {{Guinea} GN Guinea}
+ {{Guinea-Bissau} GW Guinea_Bissau}
+ {{Guyana} GY Guyana}
+
+ {{Haiti} HT Haiti}
+ {{Heard Island And Mcdonald Islands} HM {}}
+ {{Holy See (Vatican City State)} VA {}}
+ {{Honduras} HN Honduras}
+ {{Hong Kong} HK Hong_Kong}
+ {{Hungary} HU Hungary}
+
+ {{Iceland} IS Iceland}
+ {{India} IN India}
+ {{Indonesia} ID Indonesia}
+ {{Iran, Islamic Republic Of} IR Iran}
+ {{Iraq} IQ Iraq}
+ {{Ireland} IE Ireland}
+ {{Isle Of Man} IM {}}
+ {{Israel} IL Israel}
+ {{Italy} IT Italy}
+
+ {{Jamaica} JM Jamaica}
+ {{Japan} JP Japan}
+ {{Jersey} JE {}}
+ {{Jordan} JO Jordan}
+
+ {{Kazakhstan} KZ Kazakhstan}
+ {{Kenya} KE Kenya}
+ {{Kiribati} KI Kiribati}
+ {{Korea, Democratic People'S Republic Of} KP North_Korea}
+ {{Korea, Republic Of} KR South_Korea}
+ {{Kuwait} KW Kuwait}
+ {{Kyrgyzstan} KG Kyrgyzstan}
+
+ {{Lao People'S Democratic Republic} LA Laos}
+ {{Latvia} LV Latvia}
+ {{Lebanon} LB Lebanon}
+ {{Lesotho} LS Lesotho}
+ {{Liberia} LR Liberia}
+ {{Libyan Arab Jamahiriya} LY Libya}
+ {{Liechtenstein} LI Liechtenstein}
+ {{Lithuania} LT Lithuania}
+ {{Luxembourg} LU Luxembourg}
+
+ {{Macao} MO Macao}
+ {{Macedonia, The Former Yugoslav Republic Of} MK Macedonia}
+ {{Madagascar} MG Madagascar}
+ {{Malawi} MW Malawi}
+ {{Malaysia} MY Malaysia}
+ {{Maldives} MV Maldives}
+ {{Mali} ML Mali}
+ {{Malta} MT Malta}
+ {{Marshall Islands} MH Marshall_Islands}
+ {{Martinique} MQ Martinique}
+ {{Mauritania} MR Mauritania}
+ {{Mauritius} MU Mauritius}
+ {{Mayotte} YT {}}
+ {{Mexico} MX Mexico}
+ {{Micronesia, Federated States Of} FM Micronesia}
+ {{Moldova, Republic Of} MD Moldova}
+ {{Monaco} MC Monaco}
+ {{Mongolia} MN Mongolia}
+ {{Montenegro} ME {}}
+ {{Montserrat} MS Montserrat}
+ {{Morocco} MA Morocco}
+ {{Mozambique} MZ Mozambique}
+ {{Myanmar} MM Myanmar}
+
+ {{Namibia} NA Namibia}
+ {{Nauru} NR Nauru}
+ {{Nepal} NP Nepal}
+ {{Netherlands} NL Netherlands}
+ {{Netherlands Antilles} AN Netherlands_Antilles}
+ {{New Caledonia} NC {}}
+ {{New Zealand} NZ New_Zealand}
+ {{Nicaragua} NI Nicaragua}
+ {{Niger} NE Niger}
+ {{Nigeria} NG Nigeria}
+ {{Niue} NU Niue}
+ {{Norfolk Island} NF Norfolk_Island}
+ {{Northern Mariana Islands} MP {}}
+ {{Norway} NO Norway}
+
+ {{Oman} OM Oman}
+
+ {{Pakistan} PK Pakistan}
+ {{Palau} PW Palau}
+ {{Palestinian Territory, Occupied} PS {}}
+ {{Panama} PA Panama}
+ {{Papua New Guinea} PG Papua_New_Guinea}
+ {{Paraguay} PY Paraguay}
+ {{Peru} PE Peru}
+ {{Philippines} PH Philippines}
+ {{Pitcairn} PN Pitcairn_Islands}
+ {{Poland} PL Poland}
+ {{Portugal} PT Portugal}
+ {{Puerto Rico} PR Puerto_Rico}
+
+ {{Qatar} QA Qatar}
+
+ {{Réunion} RE {}}
+ {{Romania} RO Romania}
+ {{Russian Federation} RU Russian_Federation}
+ {{Rwanda} RW Rwanda}
+
+ {{Saint Barthélemy} BL {}}
+ {{Saint Helena, Ascension And Tristan Da Cunha} SH {}}
+ {{Saint Kitts And Nevis} KN Saint_Kitts_and_Nevis}
+ {{Saint Lucia} LC Saint_Lucia}
+ {{Saint Martin} MF {}}
+ {{Saint Pierre And Miquelon} PM Saint_Pierre}
+ {{Saint Vincent And The Grenadines} VC Saint_Vicent_and_the_Grenadines}
+ {{Samoa} WS Samoa}
+ {{San Marino} SM San_Marino}
+ {{Sao Tome And Principe} ST Sao_Tome_and_Principe}
+ {{Saudi Arabia} SA Saudi_Arabia}
+ {{Senegal} SN Senegal}
+ {{Serbia} RS {}}
+ {{Seychelles} SC Seychelles}
+ {{Sierra Leone} SL Sierra_Leone}
+ {{Singapore} SG Singapore}
+ {{Slovakia} SK Slovakia}
+ {{Slovenia} SI Slovenia}
+ {{Solomon Islands} SB Soloman_Islands}
+ {{Somalia} SO Somalia}
+ {{South Africa} ZA South_Africa}
+ {{South Georgia And The South Sandwich Islands} GS South_Georgia}
+ {{Spain} ES Spain}
+ {{Sri Lanka} LK Sri_Lanka}
+ {{Sudan} SD Sudan}
+ {{Suriname} SR Suriname}
+ {{Svalbard And Jan Mayen} SJ {}}
+ {{Swaziland} SZ Swaziland}
+ {{Sweden} SE Sweden}
+ {{Switzerland} CH Switzerland}
+ {{Syrian Arab Republic} SY Syria}
+
+ {{Taiwan, Province Of China} TW Taiwan}
+ {{Tajikistan} TJ Tajikistan}
+ {{Tanzania, United Republic Of} TZ Tanzania}
+ {{Thailand} TH Thailand}
+ {{Timor-Leste} TL Timor-Leste}
+ {{Togo} TG Togo}
+ {{Tokelau} TK {}}
+ {{Tonga} TO Tonga}
+ {{Trinidad And Tobago} TT Trinidad_and_Tobago}
+ {{Tunisia} TN Tunisia}
+ {{Turkey} TR Turkey}
+ {{Turkmenistan} TM Turkmenistan}
+ {{Turks And Caicos Islands} TC Turks_and_Caicos_Islands}
+ {{Tuvalu} TV Tuvalu}
+
+ {{Uganda} UG Uganda}
+ {{Ukraine} UA Ukraine}
+ {{United Arab Emirates} AE UAE}
+ {{United Kingdom} GB United_Kingdom}
+ {{United States} US United_States_of_America}
+ {{United States Minor Outlying Islands} UM {}}
+ {{Uruguay} UY Uruguay}
+ {{Uzbekistan} UZ Uzbekistan}
+
+ {{Vanuatu} VU Vanuatu}
+ {{Vatican City State} VA Vatican_City}
+ {{Venezuela, Bolivarian Republic Of} VE Venezuela}
+ {{Viet Nam} VN Vietnam}
+ {{Virgin Islands, British} VG British_Virgin_Islands}
+ {{Virgin Islands, U.S.} VI US_Virgin_Islands}
+
+ {{Wallis And Futuna} WF Wallis_and_Futuna}
+ {{Western Sahara} EH {}}
+
+ {{Yemen} YE Yemen}
+ {{Zambia} ZM Zambia}
+ {{Zimbabwe} ZW Zimbabwe}
+}
+
+## Kill spell checker and its support processes
+ # @return void
+proc kill_spellchecker_process {} {
+ # Reset some class variables
+ set ::Editor::spellchecker_RAP_ID {}
+ set ::Editor::spellchecker_command_LIFO [list]
+
+ # Abort if the spell checker process is not running
+ if {${::Editor::spellchecker_process_pid} == {}} {
+ return
+ }
+
+ # Kill the spell checker and its support processes
+ foreach pid ${::Editor::spellchecker_process_pid} {
+ if {$pid == [pid] || $pid == 0} {
+ continue
+ }
+ catch {
+ exec -- kill $pid 2>/dev/null
+ }
+ }
+ set ::Editor::spellchecker_process_pid {}
+}
+
+## Restart the spell checker process with new new configuration
+ # @return void
+proc restart_spellchecker_process {} {
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ kill_spellchecker_process
+
+ if {[lsearch -ascii -exact ${::Editor::available_dictionaries} ${::Editor::spellchecker_dictionary}] == -1} {
+ set ::Editor::spellchecker_enabled 0
+ set ::Editor::spellchecker_dictionary {}
+ } else {
+ start_spellchecker_process
+ wait_for_spellchecker_process
+ }
+}
+
+## Start the spell checker (Hunspell) and its support processes
+ # @return void
+proc start_spellchecker_process {} {
+ # Abort if either the feature is disabled or the Hunspell is not available
+ if {!${::Editor::spellchecker_enabled} || !${::PROGRAM_AVAILABLE(hunspell)}} {
+ return
+ }
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Start watch dog timer
+ set ::Editor::spellchecker_start_timer [after 10000 {
+ set ::Editor::spellchecker_start_failed 1
+ set ::Editor::spellchecker_started_flag 1
+ }]
+
+ # Attempt to start the processes
+ if {[catch {
+ set ::Editor::spellchecker_process_pid [exec -- \
+ tclsh ${::LIB_DIRNAME}/receive_and_print.tcl \
+ [tk appname] \
+ ::Editor::set_spellchecker_RAP_ID \
+ | hunspell \
+ -a \
+ -i utf8 \
+ -d ${::Editor::spellchecker_dictionary} \
+ | tclsh ${::LIB_DIRNAME}/external_command.tcl \
+ [tk appname] \
+ ::Editor::spellchecker_exit_callback \
+ ::Editor::spellchecker_receive_response \
+ & \
+ ]
+ }]} then {
+ # FAILURE
+ set ::Editor::spellchecker_start_failed 1
+ set ::Editor::spellchecker_started_flag 1
+ }
+}
+
+## Wait until the spell checker (Hunspell) and its support processes are started
+ # @return void
+proc wait_for_spellchecker_process {} {
+ # Abort if either the feature is disabled or the Hunspell is not available
+ if {!${::Editor::spellchecker_enabled} || !${::PROGRAM_AVAILABLE(hunspell)}} {
+ return
+ }
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Wait until the spell checker (Hunspell) and its support processes are started
+ vwait ::Editor::spellchecker_started_flag
+ unset ::Editor::spellchecker_started_flag
+
+ # Stop the watch dog timer
+ catch {
+ after cancel ${::Editor::spellchecker_start_timer}
+ }
+
+ # Handle spellchecker start-up failure
+ if {${::Editor::spellchecker_start_failed}} {
+ # Set some class variables
+ set ::Editor::spellchecker_RAP_ID {}
+ set ::Editor::spellchecker_enabled 0
+ set ::Editor::spellchecker_start_failed 0
+
+ # Destroy the splash screen if displayed
+ if {[winfo exists .splash]} {
+ destroy .splash
+ }
+
+ # Display graphical error message
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -icon error \
+ -title [mc "Hunspell error"] \
+ -message [mc "Unable to start the spell checker. Please try to re-install the hunspell. Spell checking function will not be available"]
+ }
+}
+
+## Receive the identifier for IPC with the RAP
+ # @parm String id - Appname of the receive_and_print process
+ # @return void
+proc set_spellchecker_RAP_ID {id} {
+ set ::Editor::spellchecker_RAP_ID $id
+}
+
+## Handle Hunspell process termination
+ #
+ # It is assumed that the process terminates only on some error condition or
+ # on an explicit request for termination. Aim of this method is attempt to
+ # restart the Hunspell process and its support processes if it crashed for any
+ # reason.
+ #
+ # @parm List args - Anything, it doesn't matter
+ # @return void
+proc spellchecker_exit_callback {args} {
+ # Abort if the termination was intentional
+ if {${::Editor::spellchecker_RAP_ID} == {}} {
+ return
+ }
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ set ::Editor::spellchecker_RAP_ID {}
+ puts stderr "Spell checker process exited -- attempting to restart"
+
+ # Attempt to restart
+ incr ::Editor::spellchecker_attempts_to_restart
+ if {${::Editor::spellchecker_attempts_to_restart} < 10} {
+ start_spellchecker_process
+ } else {
+ puts stderr "Attempt to restart failed, to many attempts -- aborting"
+ set spellchecker_attempts_to_restart 0
+ }
+}
+
+## Receive response from the Hunspell
+ # @parm List args - One line of the response
+ # @return void
+proc spellchecker_receive_response {args} {
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # We are interested only in the first field of the response
+ set response [string trim [lindex $args 0]]
+
+ # Handle the initial response (sent once the Hunspell is started)
+ if {[lindex $response 0] == {@(#)}} {
+ set spellchecker_command_LIFO [list]
+ set ::Editor::spellchecker_started_flag 1
+ return
+ }
+
+ # Decide what to do with the response
+ switch -- $response {
+ {} { ;# Empty response -- means nothing
+ }
+ {*} { ;# Word is correct
+ catch {
+ eval [lindex $spellchecker_command_LIFO {0 0}]
+ }
+ set spellchecker_command_LIFO [lreplace $spellchecker_command_LIFO 0 0]
+ }
+ default { ;# Everything else
+ catch {
+ eval [lindex $spellchecker_command_LIFO {0 1}]
+ }
+ set spellchecker_command_LIFO [lreplace $spellchecker_command_LIFO 0 0]
+ }
+ }
+}
+
+## Send a word to the Hunspell process for evaluation
+ # @parm String word - Work to check for correct spelling
+ # @parm String wrong_command = {} - Command to execute here if the word is badly spelled
+ # @parm String correct_command = {} - Command to execute here if the word is correctly spelled
+ # @return void
+proc spellchecker_check_word {word {wrong_command {}} {correct_command {}}} {
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Abort if receive and print process has not been initialized
+ if {${::Editor::spellchecker_RAP_ID} == {}} {
+ return
+ }
+
+ # Append command to their queue
+ lappend spellchecker_command_LIFO [list $correct_command $wrong_command]
+
+ # Send the word to the Hunspell process
+ if {!${::MICROSOFT_WINDOWS}} {
+ ::X::secure_send ${::Editor::spellchecker_RAP_ID} print_line "{$word}"
+ } else {
+ dde eval ${::Editor::spellchecker_RAP_ID} print_line "{$word}"
+ }
+}
+
+## Refresh list of available spell checker dictionaries (refresh in GUI)
+ # @return void
+proc refresh_available_dictionaries {} {
+ # Abort if the Hunspell program is not available
+ if {!${::PROGRAM_AVAILABLE(hunspell)}} {
+ return
+ }
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Set widget descriptor for the dictionary selection menu
+ set m {.spell_checker_conf_menu}
+
+ # Destroy the dictionary selection menu if it exists
+ if {[winfo exists $m]} {
+ destroy $m
+ }
+
+ # Create new dictionary selection menu
+ menu $m ;# Main part
+ menu $m.by_country ;# Cascade "Set dictionary by country"
+ menu $m.by_language ;# Cascade "Set dictionary by language"
+
+ # Define contents of the newly created menu
+ $m add command \
+ -label [mc "Refresh list of dictionaries"] \
+ -image ::ICONS::16::reload \
+ -compound left \
+ -command {
+ ::Editor::refresh_available_dictionaries
+ ::Editor::adjust_spell_checker_config_button
+ }
+ $m add command \
+ -label [mc "Turn off spell checking"] \
+ -image ::ICONS::16::exit \
+ -compound left \
+ -command {::Editor::switch_SC_dictionary {}}
+ $m add separator
+ $m add cascade \
+ -label [mc "Set dictionary by language"] \
+ -menu $m.by_language
+ $m add cascade \
+ -label [mc "Set dictionary by country"] \
+ -menu $m.by_country
+
+ ## Get list of available Hunspell dictionaries
+ set ::Editor::available_dictionaries [list]
+ # Start watchdog timer for the Hunspell process
+ set spellchecker_start_timer [after 10000 {
+ catch {
+ close ${::Editor::hunspell_process}
+ }
+ }]
+ if {[catch {
+ # Run Hunspell in a mode in which it prints available dictionaries
+ if {!${::MICROSOFT_WINDOWS}} {
+ set hunspell_process [open {| /bin/sh -c "hunspell -D 2>&1 | awk '{print(\$0)} /^LOADED DICTIONARY/ {exit 0}' || exit 1"} "r"]
+ } else {
+ puts stderr "Sorry, this feature is not implemented on MS Windows yet."
+ error "Not available on Windows."
+ }
+
+ }]} then {
+ # Error condition
+ puts stderr "Unable to start the Hunspell process"
+
+ } else {
+ # Bool: Accept this line of output from the process
+ set accept_flag 0
+
+ # Read list of dictionaries (file names along with pats)
+ while {![eof $hunspell_process]} {
+ # Read line from the process
+ set line [gets $hunspell_process]
+
+ # Ignore everything besides section ``AVAILABLE DICTIONARIES''
+ if {![string first {AVAILABLE DICTIONARIES} $line]} {
+ set accept_flag 1
+ continue
+ } elseif {![string first {LOADED DICTIONARY:} $line]} {
+ break
+ } elseif {!$accept_flag} {
+ continue
+ }
+
+ # Determinate language code and country code and append it to the
+ #+ list of available dictionaries
+ set line [lindex [split $line [file separator]] end]
+ set line [split $line {_}]
+ if {[lindex $line 0] == {hyph}} {
+ continue
+# set line [lreplace $line 0 0]
+ }
+ if {![string length [lindex $line 0]] || ![string length [lindex $line 1]]} {
+ continue
+ }
+ if {![string is alpha [lindex $line 0]] || ![string is alpha [lindex $line 1]]} {
+ continue
+ }
+ set dictionary [string tolower [lindex $line 0]]_[string toupper [lindex $line 1]]
+ if {[lsearch -ascii -exact ${::Editor::available_dictionaries} $dictionary] == -1} {
+ lappend ::Editor::available_dictionaries $dictionary
+ }
+ }
+ }
+
+ # Cancel the watchdog timer
+ catch {
+ after cancel $spellchecker_start_timer
+ }
+
+ # If there are no dictionaries available to use then abort right away
+ if {![llength ${::Editor::available_dictionaries}]} {
+ return
+ }
+
+
+ ## Enrich the gained list with some additional information
+ #
+ # Format of the resulting list:
+ # {
+ # {Language_code Country_code Country_name Language_name Flag_icon}
+ # ...
+ # }
+ set available_dictionaries_complex [list]
+ foreach dictionary ${::Editor::available_dictionaries} {
+ # Determinate language code and country code
+ set dictionary [split $dictionary {_}] ;# List: Language and country codes, e.g. {en GB}
+ set language_code [lindex $dictionary 0] ;# String: Language code, e.g. "en"
+ set country_code [lindex $dictionary 1] ;# String: County code, e.g. "GB"
+ set country_and_flag {} ;# List: Country name and flag icon name, e.g. {"United Kingdom" United_Kingdom}
+ set country_name {} ;# String: Country name, e.g. "United Kingdom"
+ set flag_icon {} ;# String: Flag icon name, e.g. "United_Kingdom"
+ set language_name {} ;# String: Language name, e.g. "English"
+
+ # Determinate country name and flag file name
+ set idx [lsearch -ascii -exact -index 1 ${::Editor::COUNTRY_CODES_AND_FLAGS} $country_code]
+ if {$idx != -1} {
+ set country_and_flag [lindex ${::Editor::COUNTRY_CODES_AND_FLAGS} $idx]
+ set country_name [lindex $country_and_flag 0]
+ set flag_icon [lindex $country_and_flag 2]
+ } else {
+ set country_name $country_code
+ }
+ if {$flag_icon == {}} {
+ set flag_icon {empty}
+ }
+
+ # Determinate language name
+ set idx [lsearch -ascii -exact -index 1 ${::Editor::LANGUAGE_CODES_AND_NAMES} $language_code]
+ if {$idx != -1} {
+ set language_name [lindex ${::Editor::LANGUAGE_CODES_AND_NAMES} [list $idx 0]]
+ } else {
+ set language_name $language_code
+ }
+
+ if {$country_name == {}} {
+ set country_name {???}
+ }
+ if {$language_name == {}} {
+ set language_name {???}
+ }
+
+ # Append item to the resulting list
+ lappend available_dictionaries_complex [list $language_code $country_code [mc $country_name] [mc $language_name] $flag_icon]
+ }
+
+ # Generate content of the "Set by country" menu
+ set local_menu {}
+ set capital_leter {}
+ set last_capital_leter {}
+ foreach dictionary [lsort -dictionary -index 2 [lsort -dictionary -index 3 $available_dictionaries_complex]] {
+ # Gain some facts about the dictionary file
+ set language_code [lindex $dictionary 0]
+ set country_code [lindex $dictionary 1]
+ set country_name [lindex $dictionary 2]
+ set language_name [lindex $dictionary 3]
+ set flag_icon [lindex $dictionary 4]
+
+ # Create sub-menu if necessary
+ set capital_leter [string toupper [string index $country_name 0]]
+
+ if {$capital_leter != $last_capital_leter} {
+ set last_capital_leter $capital_leter
+ set local_menu [menu $m.by_country.m_[string tolower $capital_leter]]
+ $m.by_country add cascade -label "$capital_leter ..." -menu $local_menu
+ }
+
+ # Create the menu item
+ $local_menu add command \
+ -command "::Editor::switch_SC_dictionary {${language_code}_${country_code}}" \
+ -label "$country_name ($language_name)" \
+ -image ::ICONS::flag::$flag_icon \
+ -compound left
+ }
+
+ # Generate content of the "Set by language" menu
+ set local_menu {}
+ set capital_leter {}
+ set last_capital_leter {}
+ foreach dictionary [lsort -dictionary -index 3 [lsort -dictionary -index 2 $available_dictionaries_complex]] {
+ # Gain some facts about the dictionary file
+ set language_code [lindex $dictionary 0]
+ set country_code [lindex $dictionary 1]
+ set country_name [lindex $dictionary 2]
+ set language_name [lindex $dictionary 3]
+ set flag_icon [lindex $dictionary 4]
+
+ # Create sub-menu if necessary
+ set capital_leter [string toupper [string index $language_name 0]]
+ if {$capital_leter != $last_capital_leter} {
+ set last_capital_leter $capital_leter
+ set local_menu [menu $m.by_language.m_[string tolower $capital_leter]]
+ $m.by_language add cascade -label "$capital_leter ..." -menu $local_menu
+ }
+
+ # Create the menu item
+ $local_menu add command \
+ -command "::Editor::switch_SC_dictionary {${language_code}_${country_code}}" \
+ -label "$language_name ($country_name)" \
+ -image ::ICONS::flag::$flag_icon \
+ -compound left
+ }
+}
+
+## Switch current dictionary
+ # @parm String dictionary - Dictionary name like: ``en_GB'' or ``en_AU''
+ # @return void
+proc switch_SC_dictionary {dictionary} {
+ # Abort if the Hunspell program is not available
+ if {!${::PROGRAM_AVAILABLE(hunspell)}} {
+ return
+ }
+
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Chech whether the requested dictionary is available
+ if {[lsearch -ascii -exact ${::Editor::available_dictionaries} $dictionary] == -1} {
+ set dictionary {}
+ }
+
+ # Empty dictionary name means disable the feature
+ if {[string length $dictionary]} {
+ set ::Editor::spellchecker_enabled 1
+ } else {
+ set ::Editor::spellchecker_enabled 0
+ }
+
+ # Adjust configuration button
+ .statusbarSB configure \
+ -image ::ICONS::16::player_time \
+ -text "<>"
+
+ # Clear spell checker's tags in all text editors
+ foreach project ${::X::openedProjects} {
+ foreach editor [$project cget -editors] {
+ $editor spellchecker_clear_tags
+ }
+ }
+
+ # Switch the dictionary
+ set ::Editor::spellchecker_dictionary $dictionary
+ restart_spellchecker_process
+ adjust_spell_checker_config_button
+
+ # Refresh all editors
+ foreach project ${::X::openedProjects} {
+ foreach editor [$project cget -editors] {
+ $editor parseAll
+ }
+ }
+}
+
+## Adjust spell checker configuration button to current spell checker configuration
+ # @return void
+proc adjust_spell_checker_config_button {} {
+ # Abort if the Hunspell program is not available
+ if {!${::PROGRAM_AVAILABLE(hunspell)}} {
+ return
+ }
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Spell checker configuration menu
+ set m {.spell_checker_conf_menu}
+
+ ## Spell checker is DISABLED
+ if {!$::Editor::spellchecker_enabled} {
+ $m entryconfigure [mc "Turn off spell checking"] -state disabled
+ .statusbarSB configure \
+ -image ::ICONS::flag::empty \
+ -text "none"
+
+ ## Spell checker is ENABLED
+ } else {
+ $m entryconfigure [mc "Turn off spell checking"] -state normal
+
+ set c_l [split ${::Editor::spellchecker_dictionary} {_}]
+ set idx [lsearch -ascii -exact -index 1 ${::Editor::COUNTRY_CODES_AND_FLAGS} [lindex $c_l 1]]
+ if {$idx != -1} {
+ set flag_icon [lindex ${::Editor::COUNTRY_CODES_AND_FLAGS} [list $idx 2]]
+ } else {
+ set flag_icon {empty}
+ }
+
+ .statusbarSB configure \
+ -image ::ICONS::flag::$flag_icon \
+ -text [lindex $c_l 0]
+ }
+}
+
+## By calling this method we mark the target line as something which is a subject for a change
+ # Purpose is to handle insertions of single characters and deletions of single characters
+ # @note This method inhibits method spellcheck_check_all until spellcheck_change_detected_post is called
+ # @see spellcheck_change_detected_post
+ # @parm Int line_number = {} - Number of the target line, {} means the current line
+ # @return void
+private method spellcheck_change_detected_pre {{line_number {}}} {
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Abort conditions
+ if {!$spellchecker_enabled || !${::PROGRAM_AVAILABLE(hunspell)}} {
+ return
+ }
+
+ # Inhibit method spellcheck_check_all until spellcheck_change_detected_post is called
+ set spellcheck_lock 1
+
+ # Adjust parameters
+ if {$line_number == {}} {
+ set line_number [expr {int([$editor index insert])}]
+ }
+
+ # Store the target line
+ set spellcheck_line_number $line_number
+ set spellcheck_line_pre [$editor get [list $line_number.0 linestart] [list $line_number.0 lineend]]
+}
+
+## By calling this method we finalize the process started by calling to method spellcheck_change_detected_pre
+ # Purpose is to handle insertions of single characters and deletions of single characters
+ # @see spellcheck_change_detected_pre
+ # @parm Int line_number = {} - Number of the target line, {} means the current line
+ # @return void
+private method spellcheck_change_detected_post {{line_number {}}} {
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Abort conditions
+ if {!$spellchecker_enabled || !${::PROGRAM_AVAILABLE(hunspell)}} {
+ return
+ }
+
+ # cancel the inhibition of method spellcheck_check_all
+ set spellcheck_lock 0
+
+ # Adjust parameters
+ if {$line_number == {}} {
+ set line_number [expr {int([$editor index insert])}]
+ }
+
+ # Determinate ranges of text indexes delimiting strings to check for spelling
+ if {$prog_language == -1} {
+ set target_ranges [list [list $line_number.0 [$editor index [list $line_number.0 lineend]]]]
+ } else {
+ set target_ranges [list]
+ set range [list $line_number.0 $line_number.0]
+ while {1} {
+ set range [concat \
+ [$editor tag nextrange tag_comment [lindex $range 1] [list $line_number.0 lineend]] \
+ [$editor tag nextrange tag_c_comment [lindex $range 1] [list $line_number.0 lineend]] \
+ [$editor tag nextrange tag_c_dox_comment [lindex $range 1] [list $line_number.0 lineend]] \
+ ]
+
+ if {![llength $range]} {
+ break
+ }
+
+ lappend target_ranges $range
+ }
+ }
+
+ # Gain entire line from the editor
+ set line [$editor get [list $line_number.0 linestart] [list $line_number.0 lineend]]
+
+ if {[string length $line] > [string length $spellcheck_line_pre]} {
+ set new_longer_that_org 1
+ } else {
+ set new_longer_that_org 0
+ }
+
+ # Compare the line to its previous content and check changed word(s)
+ set fixed_shift 0 ;# Total pre string shift from all cycles
+ set force_check 0 ;# Enforce spell check of the next word regardless the comparison
+ foreach range $target_ranges {
+ # Determinate start and end column
+ scan [lindex $range 0] {%d.%d} _ start
+ scan [lindex $range 1] {%d.%d} _ end
+
+ set word {} ;# String: Word to check
+ set char {} ;# Char: Character gained from the source line
+ set idx_pre $start ;# Int: Index in $spellcheck_line_pre
+ set word_len 0 ;# Int: Length of the word
+ set skip_word 0 ;# Bool: Flag skip this one word
+ set change_detected 0 ;# Bool: Flag the word was changed
+ set char_next [string index $line $start] ;# Char: Same as char but maybe a little ahead
+
+ # Take into accound shift from previous cycles
+ incr idx_pre $fixed_shift
+
+ for {set idx $start} {$idx < $end} {incr idx; incr idx_pre} {
+ set char $char_next
+ set char_next [string index $line [expr {$idx + 1}]]
+ set char_pre_next [string index $spellcheck_line_pre [expr {$idx_pre + 1}]]
+ set char_pre [string index $spellcheck_line_pre $idx_pre]
+
+ if {[string is alnum $char]} {
+ # If the word contains one or more digits, skip it, digits in a word
+ #+ would cause Hunspell to behave in a way that we don't want here
+ if {[string is digit $char]} {
+ set skip_word 1
+ }
+
+ # Lines are different
+ if {$char_pre != $char} {
+ set change_detected 1
+
+ # Character deleted -- shift the pre string >> 1
+ if {$char_pre_next == $char && !$new_longer_that_org} {
+ incr idx_pre
+ incr fixed_shift
+ # Character inserted -- shift the pre string << 1
+ } elseif {$char_pre == $char_next && $new_longer_that_org} {
+ incr idx_pre -1
+ incr fixed_shift -1
+ }
+
+ # Character appended at the end of the word -- shift the pre string << 1,
+ #+ and check for the next word unconditionally
+ } elseif {
+ [string is alnum $char_pre_next]
+ &&
+ ![string is alnum $char_next]
+ &&
+ $char_pre_next != $char_next
+ } then {
+ incr idx_pre -1
+ incr fixed_shift -1
+ set change_detected 1
+ set force_check 1
+ }
+
+ # Append the character to the word
+ append word $char
+ incr word_len
+
+ # This is not the last character in the line
+ if {$idx < ($end - 1)} {
+ continue
+ # This IS the last character in the line
+ } else {
+ incr idx
+ }
+ }
+
+ # Skip empty words
+ if {!$word_len} {
+ continue
+ }
+
+ # Send the word to the spell checker
+ if {$change_detected && !$skip_word} {
+ set change_detected 0
+ $editor tag remove tag_wrong_spelling $line_number.$idx-${word_len}c-1c $line_number.$idx
+
+ spellchecker_check_word $word \
+ [list $editor tag add tag_wrong_spelling $line_number.$idx-${word_len}c $line_number.$idx] \
+ [list $editor tag remove tag_wrong_spelling $line_number.$idx-${word_len}c $line_number.$idx]
+ }
+
+ # Enforce spell check of the next word regardless the comparison
+ if {$force_check} {
+ set force_check 0
+ set change_detected 1
+ }
+
+ # Reset
+ set word {}
+ set word_len 0
+ set skip_word 0
+ }
+ }
+}
+
+## Check spelling on the specified line
+ #
+ # This method will not perform the task if $spellcheck_line_number is equal to
+ # the given source line, unless the force parameter is set to true.
+ # @note
+ # Spell checking is performed only for comments unless the programming language
+ # is not specified
+ # @parm Int line_number - Number of line to check
+ # @parm Int force = 0 - 1: Force the method to perform the spell check; 2: Force even over $spellcheck_lock
+ # @return void
+public method spellcheck_check_all {line_number {force 0}} {
+ # This function was not yet ported to MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ return
+ }
+
+ # Abort conditions
+ if {($force != 2 && $spellcheck_lock) || !$spellchecker_enabled || !${::PROGRAM_AVAILABLE(hunspell)}} {
+ return
+ }
+ if {!$force && ($spellcheck_line_number != $line_number)} {
+ return
+ }
+ set spellcheck_line_number {}
+
+ # Remove bad spelling tags
+ $editor tag remove tag_wrong_spelling $line_number.0 [list $line_number.0 lineend]
+
+ # Determinate ranges of text indexes delimiting strings to check for spelling
+ if {$prog_language == -1} {
+ set target_ranges [list [list $line_number.0 [$editor index [list $line_number.0 lineend]]]]
+ } else {
+ set target_ranges [list]
+ set range [list $line_number.0 $line_number.0]
+ while {1} {
+ set range [concat \
+ [$editor tag nextrange tag_comment [lindex $range 1] [list $line_number.0 lineend]] \
+ [$editor tag nextrange tag_c_comment [lindex $range 1] [list $line_number.0 lineend]] \
+ [$editor tag nextrange tag_c_dox_comment [lindex $range 1] [list $line_number.0 lineend]] \
+ ]
+
+ if {![llength $range]} {
+ break
+ }
+
+ lappend target_ranges $range
+ }
+ }
+
+ # Gain entire line from the editor
+ set line [$editor get $line_number.0 [list $line_number.0 lineend]]
+
+ # Check spelling for the given ranges
+ foreach range $target_ranges {
+ # Determinate start and end column
+ scan [lindex $range 0] {%d.%d} _ start
+ scan [lindex $range 1] {%d.%d} _ end
+
+ set word {} ;# String: Word to check
+ set char {} ;# Char: Character gained from the source line
+ set word_len 0 ;# Int: Length of the word
+ set skip_word 0 ;# Bool: Flag skip this one word
+
+ # Iterate over characters in the source line
+ for {set idx $start} {$idx < $end} {incr idx} {
+ set char [string index $line $idx]
+
+ if {[string is alnum $char]} {
+ # If the word contains one or more digits, skip it digits in a word
+ #+ would cause Hunspell to behave in a way that we don't want here
+ if {[string is digit $char]} {
+ set skip_word 1
+ }
+
+ # Append the character to the word
+ append word $char
+ incr word_len
+
+ # This is not the last character in the line
+ if {$idx < ($end - 1)} {
+ continue
+ # This IS the last character in the line
+ } else {
+ incr idx
+ }
+ }
+
+ # Skip empty words
+ if {!$word_len} {
+ continue
+ }
+
+ # Send the word to the spell checker
+ if {!$skip_word} {
+ spellchecker_check_word \
+ $word \
+ [list $editor tag add tag_wrong_spelling $line_number.$idx-${word_len}c $line_number.$idx]
+ }
+
+ # Reset
+ set word {}
+ set word_len 0
+ set skip_word 0
+ }
+ }
+}
+
+## Clear all tags marking the misspelled words
+ # @return void
+public method spellchecker_clear_tags {} {
+ $editor tag remove tag_wrong_spelling 0.0 end
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/environment.tcl b/lib/environment.tcl
index 33af4a3..c64f41b 100755..100644
--- a/lib/environment.tcl
+++ b/lib/environment.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 _ENVIRONMENT_TCL ] } {
+set _ENVIRONMENT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# * Defines some settings and procedures
@@ -40,6 +45,15 @@ if {![X::restore_session]} {
set show_welcome_dialog 1
}
+# Restore spell checker configuration from the last session
+if {${::PROGRAM_AVAILABLE(hunspell)}} {
+ set ::Editor::spellchecker_enabled ${::CONFIG(SPELL_CHECK_ENABLED)}
+ set ::Editor::spellchecker_dictionary ${::CONFIG(SPELL_CHECK_DICTIONARY)}
+} else {
+ set ::Editor::spellchecker_enabled 0
+ set ::Editor::spellchecker_dictionary {}
+}
+
# Some key shortcuts for main window
bind . <Control-Key-1> {manipulate_panel {sim} ; break}
bind . <Control-Key-2> {manipulate_panel {graph} ; break}
@@ -62,6 +76,7 @@ bind . <Control-Key-0> {manipulate_panel {sub} ; break}
# General widget bindings
bind Menu <Button> {+catch {%W configure -cursor left_ptr}}
+bind Text <ButtonPress-1> {+focus %W}
bind Text <Control-d> {}
bind Text <Control-b> {}
bind Text <Control-a> {}
@@ -74,6 +89,7 @@ bind Text <KP_Enter> "[bind Text <Return>]; break"
bind Text <Control-Key-z> {catch {%W edit undo}; break}
bind Text <Control-Key-Z> {catch {%W edit redo}; break}
bind Text <Control-Key-c> {tk_textCopy %W; break}
+bind Text <Control-Key-C> {tk_textCopy %W; break}
bind Text <Control-Key-x> {tk_textCut %W; break}
bind Text <Control-Key-v> {
catch {
@@ -104,19 +120,25 @@ bind Entry <Control-Key-a> {%W selection range 0 end; break}
bind TEntry <Control-Key-a> {%W selection range 0 end; break}
# Dynamic help (Bwidget)
-DynamicHelp::configure -font [font create -size -14 -family {helvetica}] -delay 500 -background {#FFFFDD}
+DynamicHelp::configure -font [font create -size [expr {int(-14 * $::font_size_factor)}] -family {helvetica}] -delay 500 -background {#FFFFDD}
# General purpose fonts
set smallfont_color {#5599DD}
-set smallfont [font create -size -10 -family {helvetica} -weight normal]
-set smallfont_bold [font create -size -10 -family {helvetica} -weight bold]
+set smallfont [font create -size [expr {int(-10 * $::font_size_factor)}] -family {helvetica} -weight normal]
+set smallfont_bold [font create -size [expr {int(-10 * $::font_size_factor)}] -family {helvetica} -weight bold]
# LOAD PROGRAM ICONS
# -----------------------------
-foreach directory {16x16 22x22 32x32} ns {16 22 32} {
+foreach directory {16x16 22x22 32x32 flag} ns {16 22 32 flag} {
namespace eval ::ICONS::${ns} {}
- foreach filename [glob "${::LIB_DIRNAME}/../icons/${directory}/*.png"] {
- set filename [file normalize $filename]
+ if {!$::MICROSOFT_WINDOWS} {
+ # Use glob
+ set list_of_icons [glob "${::ROOT_DIRNAME}/icons/${directory}/*.png"]
+ } else {
+ # Use ZIP Virtual File System (freeWrap)
+ set list_of_icons [zvfs::list "${::ROOT_DIRNAME}/icons/${directory}/*.png"]
+ }
+ foreach filename $list_of_icons {
set iconname [file tail $filename]
regexp {^\w+} $iconname iconname
if {[catch {
@@ -134,45 +156,55 @@ tk appname "mcu8051ide"
wm command . "mcu8051ide $argv"
wm client . [info hostname]
tk scaling 1.0
-tk_setPalette \
- activeBackground {#EEEEEE} \
- foreground {#000000} \
- selectColor {#FFFFFF} \
- activeForeground {#0000DD} \
- highlightBackground {#EEEEEE} \
- selectBackground {#9999BB} \
- background {#EEEEEE} \
- highlightColor {#000000} \
- selectForeground {#FFFFFF} \
- disabledForeground {#888888} \
- insertBackground {#000000} \
- troughColor {#EEEEEE}
+tk_setPalette \
+ activeBackground ${::COMMON_BG_COLOR} \
+ foreground {#000000} \
+ selectColor {#FFFFFF} \
+ activeForeground {#0000DD} \
+ highlightBackground ${::COMMON_BG_COLOR} \
+ selectBackground {#9999BB} \
+ background ${::COMMON_BG_COLOR} \
+ highlightColor {#000000} \
+ selectForeground {#FFFFFF} \
+ disabledForeground {#888888} \
+ insertBackground {#000000} \
+ troughColor ${::COMMON_BG_COLOR}
wm title . "MCU 8051 IDE"
wm state . normal
+wm minsize . 640 480
wm geometry . $::CONFIG(WINDOW_GEOMETRY)
-if {!$::MICROSOFT_WINDOWS} {
- # There is no such thing on Windows OS
- wm attributes . -zoomed $::CONFIG(WINDOW_ZOOMED)
+if {$::CONFIG(WINDOW_ZOOMED)} {
+ if {!$::MICROSOFT_WINDOWS} {
+ wm attributes . -zoomed $::CONFIG(WINDOW_ZOOMED)
+ } else {
+ wm state . zoomed
+
+ # Without this help windows won't work properly on MS Windows
+ after idle {
+ update
+ wm geometry . [wm geometry .]
+ }
+ }
}
wm protocol . WM_DELETE_WINDOW {::X::__exit}
wm iconphoto . ::ICONS::16::mcu8051ide
-. configure -bg {#EEEEEE}
+. configure -bg ${::COMMON_BG_COLOR}
# Dynamic Data Exchange on Microsoft Windows
if {$::MICROSOFT_WINDOWS} {
dde servername -force -- [tk appname]
}
-ttk::style theme use clam
+ttk::style theme use ${::GLOBAL_CONFIG(wstyle)}
# - ttk
set TTK_COMMON_BG {#E0E0E0}
ttk::style configure TFrame \
- -background {#EEEEEE}
+ -background ${::COMMON_BG_COLOR}
ttk::style configure TNotebook \
- -background {#EEEEEE} \
+ -background ${::COMMON_BG_COLOR} \
-fieldbackground {red}
ttk::style map TNotebook \
-background [list \
@@ -181,8 +213,8 @@ ttk::style map TNotebook \
pressed green \
]
-font configure TkTextFont -family {helvetica} -size -12 -weight {normal}
-font configure TkDefaultFont -family {helvetica} -size -12 -weight {normal}
+font configure TkTextFont -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}
+font configure TkDefaultFont -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}
ttk::style configure StringNotFound.TEntry \
-fieldbackground {#FFDDDD}
@@ -229,15 +261,16 @@ ttk::style map Simulator_watchdogEntry_2.TEntry \
-foreground [list readonly {#888888}]
ttk::style configure TLabelframe \
- -background {#EEEEEE}
+ -background ${::COMMON_BG_COLOR}
ttk::style configure TLabel \
- -background {#EEEEEE}
+ -background ${::COMMON_BG_COLOR}
ttk::style configure TButton \
-background $TTK_COMMON_BG \
-padding 0
ttk::style configure RedBg.TButton \
- -padding 0
+ -padding 0 \
+ -font [font create -family $::DEFAULT_FIXED_FONT -size -12 -weight {normal}]
ttk::style map RedBg.TButton \
-background [list \
active {#FFBBBB} \
@@ -248,7 +281,8 @@ ttk::style map RedBg.TButton \
!active {#000000} \
]
ttk::style configure GreenBg.TButton \
- -padding 0
+ -padding 0 \
+ -font [font create -family $::DEFAULT_FIXED_FONT -size -12 -weight {normal}]
ttk::style map GreenBg.TButton \
-background [list \
active {#BBFFBB} \
@@ -259,26 +293,26 @@ ttk::style map GreenBg.TButton \
!active {#000000} \
]
-ttk::style configure Flat.TButton \
- -background {#EEEEEE} \
- -padding 0 \
- -borderwidth 1 \
+ttk::style configure Flat.TButton \
+ -background ${::COMMON_BG_COLOR} \
+ -padding 0 \
+ -borderwidth 1 \
-relief flat
ttk::style map Flat.TButton \
-relief [list active raised] \
- -background [list disabled {#EEEEEE}]
+ -background [list disabled ${::COMMON_BG_COLOR}]
ttk::style configure TMenubutton \
-padding 0 \
-background $TTK_COMMON_BG
ttk::style configure Flat.TMenubutton \
-padding 0 \
- -background {#EEEEEE} \
+ -background ${::COMMON_BG_COLOR}\
-borderwidth 1 \
-relief flat
ttk::style map Flat.TMenubutton \
-relief [list active raised] \
- -background [list disabled {#EEEEEE}]
+ -background [list disabled ${::COMMON_BG_COLOR}]
ttk::style configure FlatWhite.TButton \
-padding 0 \
@@ -290,23 +324,23 @@ ttk::style map FlatWhite.TButton \
-background [list disabled {#FFFFFF}]
ttk::style configure ToolButton.TButton \
- -background {#EEEEEE} \
+ -background ${::COMMON_BG_COLOR}\
-padding 1 \
-borderwidth 1 \
-relief flat
ttk::style map ToolButton.TButton \
-relief [list active raised] \
- -background [list disabled {#EEEEEE}]
+ -background [list disabled ${::COMMON_BG_COLOR}]
ttk::style configure TCombobox \
-background $TTK_COMMON_BG \
- -fieldfont [font create -family {helvetica} -size -12 -weight {normal}]
-ttk::style map TCombobox \
- -foreground [list disabled {#888888}] \
- -fieldbackground [list \
- readonly $TTK_COMMON_BG \
- disabled {#EEEEEE} \
- {!readonly !disabled} {#FFFFFF} \
+ -fieldfont [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}]
+ttk::style map TCombobox \
+ -foreground [list disabled {#888888}] \
+ -fieldbackground [list \
+ readonly $TTK_COMMON_BG \
+ disabled ${::COMMON_BG_COLOR} \
+ {!readonly !disabled} {#FFFFFF} \
]
ttk::style configure TScrollbar \
@@ -322,16 +356,19 @@ ttk::style map TScale \
]
ttk::style configure TProgressbar \
- -background $TTK_COMMON_BG \
- -troughcolor {#F8F8F8}
+ -background {#CCCCFF} \
+ -troughcolor $TTK_COMMON_BG
+
+ttk::style configure GreenBg.TSpinbox -fieldbackground {#CCFFCC}
+ttk::style configure RedBg.TSpinbox -fieldbackground {#FFCCCC}
-update idle
+update idletasks
## Widget styles
# Load images for checkbuttons and radiobuttons
foreach i {raoff raon choff chon} {
if {[catch {
- image create photo ::ICONS::$i -file "${::LIB_DIRNAME}/../icons/other/$i.png" -format png
+ image create photo ::ICONS::$i -file "${::ROOT_DIRNAME}/icons/other/$i.png" -format png
} result]} then {
puts stderr {}
puts -nonewline stderr $result
@@ -339,73 +376,81 @@ foreach i {raoff raon choff chon} {
}
}
# - Menu
-option add *Menu.activeForeground {#FFFFFF} userDefault
+if {!${::MICROSOFT_WINDOWS}} {
+ option add *Menu.background {#F8F8F8} userDefault
+ option add *Menu.relief raised userDefault
+ option add *Menu.borderWidth 1 userDefault
+} else {
+ option add *Menu.background {#FFFFFF} userDefault
+ option add *Menu.relief flat userDefault
+ option add *Menu.borderWidth 0 userDefault
+}
option add *Menu.activeBackground {#8888DD} userDefault
+option add *Menu.activeForeground {#FFFFFF} userDefault
+option add *Menu.font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}] userDefault
option add *Menu.activeBorderWidth 1 userDefault
option add *Menu.cursor left_ptr userDefault
option add *Menu.tearOff 0 userDefault
-option add *Menu.borderWidth 1 userDefault
-option add *Menu.relief raised userDefault
-option add *Menu.background {#F8F8F8} userDefault
-option add *Menu.font [font create -family {helvetica} -size -12 -weight {normal}] userDefault
# - Label
option add *Label.highlightThickness 0 userDefault
# - Entry
option add *Entry.highlightThickness 0 userDefault
option add *Entry.BorderWidth 1 userDefault
-option add *Entry.font [font create -family {helvetica} -size -12 -weight {normal}] userDefault
+option add *Entry.font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}] userDefault
# - Text
option add *Text.Background {#FFFFFF} userDefault
option add *Text.highlightThickness 0 userDefault
option add *Text.BorderWidth 1 userDefault
option add *Text.Relief sunken userDefault
-option add *Text.font [font create -family {helvetica} -size -12 -weight {normal}] userDefault
+option add *Text.font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}] userDefault
# - Spinbox
option add *Spinbox.Background {#FFFFFF} userDefault
option add *Spinbox.highlightThickness 0 userDefault
+option add *Spinbox.ExportSelection 0 userDefault
# - Scrollbar
option add *Scrollbar.activeBackground {#8888FF} userDefault
option add *Scrollbar.BorderWidth 1 userDefault
-option add *Scrollbar.Background {#EEEEEE} userDefault
-option add *Scrollbar.troughColor {#EEEEEE} userDefault
+option add *Scrollbar.Background ${::COMMON_BG_COLOR} userDefault
+option add *Scrollbar.troughColor ${::COMMON_BG_COLOR} userDefault
option add *Scrollbar.Relief sunken userDefault
option add *Scrollbar.activeRelief raised userDefault
option add *Scrollbar.elementBorderWidth 1 userDefault
# - Button
option add *Button.activeForeground {#0000DD} interactive
-option add *Button.font [font create -family {helvetica} -size -12 -weight {normal}] userDefault
+option add *Button.font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}] userDefault
# - Radiobutton
option add *Radiobutton.BorderWidth 0 userDefault
option add *Radiobutton.Image ::ICONS::raoff userDefault
option add *Radiobutton.SelectImage ::ICONS::raon userDefault
-option add *Radiobutton.selectColor {#EEEEEE} userDefault
+option add *Radiobutton.selectColor ${::COMMON_BG_COLOR} userDefault
option add *Radiobutton.Compound left userDefault
option add *Radiobutton.IndicatorOn 0 userDefault
-option add *Radiobutton.font [font create -family {helvetica} -size -12 -weight {normal}] userDefault
+option add *Radiobutton.font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}] userDefault
# - Checkbutton
option add *Checkbutton.BorderWidth 0 userDefault
option add *Checkbutton.Image ::ICONS::choff userDefault
option add *Checkbutton.SelectImage ::ICONS::chon userDefault
-option add *Checkbutton.selectColor {#EEEEEE} userDefault
+option add *Checkbutton.selectColor ${::COMMON_BG_COLOR} userDefault
option add *Checkbutton.Compound left userDefault
option add *Checkbutton.IndicatorOn 0 userDefault
-option add *Radiobutton.font [font create -family {helvetica} -size -12 -weight {normal}] userDefault
+option add *Radiobutton.font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}] userDefault
# - Scale
option add *Scale.activeBackground {#8888FF} userDefault
# - NoteBook
-option add *NoteBook.font [font create -family {helvetica} -size -12 -weight {normal}] userDefault
-option add *NoteBook.Background {#EEEEEE} userDefault
-option add *NoteBook.ActiveBackground {#EEEEEE} userDefault
+option add *NoteBook.font [font create -family {helvetica} -size [expr {int(-12 * $::font_size_factor)}] -weight {normal}] userDefault
+option add *NoteBook.Background ${::COMMON_BG_COLOR} userDefault
+option add *NoteBook.ActiveBackground {#AAAADD} userDefault
# - TopLevel and Frame
-option add *Toplevel.Background {#EEEEEE} userDefault
-option add *Frame.Background {#EEEEEE} userDefault
-option add *PagesManager.Background {#EEEEEE} userDefault
+option add *Toplevel.Background ${::COMMON_BG_COLOR} userDefault
+option add *Frame.Background ${::COMMON_BG_COLOR} userDefault
+option add *PagesManager.Background ${::COMMON_BG_COLOR} userDefault
# - Others ...
-option add *Panedwindow.Background {#EEEEEE} userDefault
-option add *Listbox.Background {#EEEEEE} userDefault
-option add *Button.Background {#EEEEEE} userDefault
-option add *Label.Background {#EEEEEE} userDefault
-option add *Canvas.Background {#EEEEEE} userDefault
+option add *Panedwindow.Background ${::COMMON_BG_COLOR} userDefault
+option add *Listbox.Background ${::COMMON_BG_COLOR} userDefault
+option add *Button.Background ${::COMMON_BG_COLOR} userDefault
+option add *Label.Background ${::COMMON_BG_COLOR} userDefault
+option add *Canvas.Background ${::COMMON_BG_COLOR} userDefault
+option add *ComboBox.ExportSelection 0 userDefault
# MEMORY CELL HELP WINDOW
@@ -441,7 +486,7 @@ proc create_help_window {root val addr} {
# Create logical frame structure
set ::HELPWINDOW [frame ${root}help_window -bd 0 -bg {#BBBBFF} -padx 2 -pady 2]
- pack [frame ${::HELPWINDOW}.top] -fill x -expand 1
+ pack [frame ${::HELPWINDOW}.top -bg {#BBBBFF}] -fill x -expand 1
pack [label ${::HELPWINDOW}.top.img -bg {#BBBBFF}] -side left
pack [label ${::HELPWINDOW}.top.tit -bg {#BBBBFF}] -side left -fill x -expand 1
pack [frame ${::HELPWINDOW}.msg -bg {#FFFFFF}] -fill both -expand 1
@@ -457,7 +502,7 @@ proc create_help_window {root val addr} {
if {[lindex $addr 1] == {BIT}} {
set help_window_for_bit 1
create_help_window_bit [lindex $addr 0]
- } {
+ } else {
set help_window_for_bit 0
create_help_window_byte $val
}
@@ -487,7 +532,7 @@ proc create_help_window_bit {addr} {
set x0 40
set y0 0
- set y1 11
+ set y1 16
# Create 8 bit rectangles in the canvas
for {set i 7} {$i >= 0} {incr i -1} {
@@ -497,17 +542,18 @@ proc create_help_window_bit {addr} {
if {[${::X::actualProject} getBit $bit_addr]} {
set fill $::BitMap::one_fill
set outline $::BitMap::one_outline
- } {
+ } else {
set fill $::BitMap::zero_fill
set outline $::BitMap::zero_outline
}
# Create label for the bit
- $canvas create text [expr {$x0 + 6}] $y0 \
- -text $i -anchor n -font $::Simulator_GUI::smallfont \
+ $canvas create text [expr {$x0 + 6}] $y0 \
+ -text $i \
+ -anchor n \
+ -font $::Simulator_GUI::smallfont \
-fill $::Simulator_GUI::small_color
-
# Create bit rectagle
set help_window_bit($i) [$canvas create \
rectangle $x0 $y1 \
@@ -536,7 +582,7 @@ proc create_help_window_bit {addr} {
# Create arrow pointing to the bit
set arr_pos [expr {47 + ((7 - $bit_number) * 14)}]
set help_window_bit(A) [$canvas create line \
- 40 45 $arr_pos 45 $arr_pos 24 \
+ 40 45 $arr_pos 45 $arr_pos 29 \
-arrow last -fill black \
]
}
@@ -561,8 +607,8 @@ proc create_help_window_byte {val} {
set dec [NumSystem::hex2dec $val]
# Character
if {$dec > 31 && $dec < 127} {
- set char [subst "\\u00$val"]
- } {
+ set char [subst -nocommands "\\u00$val"]
+ } else {
set char {}
}
# Binary
@@ -703,7 +749,7 @@ proc help_window_update {addr new_value} {
if {$help_window_for_bit} {
help_window_update_bit [lindex $addr 0] $new_value
- } {
+ } else {
help_window_update_byte $addr $new_value
}
}
@@ -725,7 +771,7 @@ proc help_window_update_bit {addr new_value} {
if {[${::X::actualProject} getBit $bit_addr]} {
set fill $::BitMap::one_fill
set outline $::BitMap::one_outline
- } {
+ } else {
set fill $::BitMap::zero_fill
set outline $::BitMap::zero_outline
}
@@ -751,8 +797,8 @@ proc help_window_update_byte {addr new_value} {
set dec [NumSystem::hex2dec $new_value]
# Character
if {$dec > 31 && $dec < 127} {
- set char [subst "\\u00$new_value"]
- } {
+ set char [subst -nocommands "\\u00$new_value"]
+ } else {
set char {}
}
# Binary
@@ -807,7 +853,7 @@ proc help_window_show {X Y} {
# Ensure than help window wont exceed boundaries of the main window
if {$help_window_for_bit} {
if {$x_coord > ($x_lim - 160)} {incr x_coord -170}
- } {
+ } else {
if {$x_coord > ($x_lim - 100)} {incr x_coord -110}
}
if {$y_coord > ($y_lim - 100)} {incr y_coord -110}
@@ -823,31 +869,56 @@ proc help_window_show {X Y} {
# GENERAL PURPOSE PROCEDURES
# -----------------------------
-##
- #
+## Create a new toplevel window with a progress bar within
+ # @parm Widget window_path - Chosen path for the new window
+ # @parm Widget transient - Parent of the window
+ # @parm String textvariable - Variable contaning the message
+ # @parm String text - A string to display as the message in the window
+ # (meaningful only when no textvariable was specified)
+ # @parm Int maximum - Maximum value for the progress bar
+ # @parm String title - Title on the window
+ # @parm Image iconphoto - Image to display in the window
+ # (previously created with "image create" command)
+ # @parm String abort_text - Text to display in the abort button (default: "Abort")
+ # @parm String abort_command - Command to invoke when abort button is pressed
+ # (empty string means do not display abort the button)
# @return void
-proc create_progress_bar {window_path transient textvariable text variable maximum title iconphoto abort_text abort_command} {
+proc create_progress_bar {window_path transient textvariable text variable maximum title iconphoto {abort_text {}} {abort_command {}}} {
+ # Create a new top level windows
toplevel $window_path
+
+ # Display the image
pack [label $window_path.image \
-image ::ICONS::32::user_away \
] -side left -anchor n -padx 10 -pady 15
+
+ # Create and show a frame where other widgets will be shown in
pack [frame $window_path.f] -side right -fill both
+
+ # Create widget containing the message
if {$textvariable != {}} {
pack [label $window_path.f.label \
-textvariable $textvariable \
] -anchor w -padx 5 -pady 5
- } {
+ } else {
pack [label $window_path.f.label \
-text $text \
] -anchor w -padx 5 -pady 5
}
+
+ # Create the progress bar widget
pack [ttk::progressbar $window_path.f.progressbar \
-mode determinate \
-length 330 \
-maximum $maximum \
-variable $variable \
] -fill x -padx 5 -pady 5
+
+ # Create the abort button
if {$abort_command != {}} {
+ if {$abort_text == {}} {
+ set abort_text [mc "Abort"]
+ }
pack [ttk::button $window_path.f.button \
-compound left \
-image ::ICONS::16::cancel \
@@ -856,9 +927,11 @@ proc create_progress_bar {window_path transient textvariable text variable maxim
] -padx 5 -pady 5 -anchor e
}
+ # Set window parameters
wm title $window_path $title
wm transient $window_path $transient
wm iconphoto $window_path $iconphoto
+ wm resizable $window_path 0 0
update
catch {
raise $window_path
@@ -896,25 +969,92 @@ proc enc2name {enc} {
}
}
+## Create hyperlink tag in the specifid text widget
+ # @parm Widget widget - Target
+ # @return void
+set hyperlink_cur_orig {}
+proc create_link_tag_in_text_widget {widget} {
+ $widget tag configure hyperlink_normal -foreground #0055FF -underline 1
+ $widget tag configure hyperlink_over -foreground #0055FF -underline 0
+
+ $widget tag bind hyperlink_normal <Enter> {
+ set range [%W tag nextrange hyperlink_normal {@%x,%y linestart}]
+ if {$range != {}} {
+ set ::hyperlink_cur_orig [%W cget -cursor]
+ %W tag remove hyperlink_normal [lindex $range 0] [lindex $range 1]
+ %W tag add hyperlink_over [lindex $range 0] [lindex $range 1]
+ %W configure -cursor hand2
+ }
+ }
+ $widget tag bind hyperlink_over <Leave> {
+ set range [%W tag nextrange hyperlink_over {0.0}]
+ if {$range != {}} {
+ %W tag remove hyperlink_over [lindex $range 0] [lindex $range 1]
+ %W tag add hyperlink_normal [lindex $range 0] [lindex $range 1]
+ %W configure -cursor $::hyperlink_cur_orig
+ }
+ }
+ $widget tag bind hyperlink_over <Button-1> {
+ set range [%W tag nextrange hyperlink_over {0.0}]
+ if {$range != {}} {
+ set url [%W get [lindex $range 0] [lindex $range 1]]
+ if {[regexp {[\w\.]+@[\w\.]+} $url]} {
+ set url "mailto:$url"
+ }
+ ::X::open_uri $url
+ }
+ }
+}
+
+## Automatically convert all strings beginning with "http://" to hypertext tags
+ # @parm Widget widget - Target text widget
+ # @return void
+proc convert_all_https_to_links {widget} {
+ foreach re [list {http://[^\s]+} {[\w\.]+@[\w\.]+}] {
+ set idx {1.0}
+ set end {1.0}
+ set org {1.0}
+ set s {}
+
+ while {1} {
+ set org $idx
+ set idx [$widget search -forwards -regexp -nocase $re $end]
+
+ if {$idx == {} || [$widget compare $org >= $idx]} {
+ break
+ }
+
+ if {![regexp $re [$widget get $idx [list $idx lineend]] s]} {
+ break
+ }
+
+ set s [string length $s]
+ set end [$widget index [list $idx + $s c]]
+
+ $widget tag add hyperlink_normal $idx $end
+ }
+ }
+}
+
## Load global configuration
# @return void
proc loadApplicationConfiguration {} {
# Load configuration file
if {$::CLI_OPTION(config_file) == {}} {
Settings settings ${::CONFIG_DIR} "config.conf"
- } {
+ } else {
Settings settings \
[file dirname $::CLI_OPTION(config_file)] \
[file tail $::CLI_OPTION(config_file)]
}
- # If configuration file is unavaliable -> invoke error message
+ # If configuration file is unavailable -> invoke error message
if {![settings isReady]} {
tk_messageBox \
-type ok \
-icon error \
-title [mc "Permission denied"] \
- -message [mc "Unable to save config file"]
+ -message [mc "Unable to save configuration file"]
}
# Reset settings to defaults
@@ -924,43 +1064,43 @@ proc loadApplicationConfiguration {} {
settings clear
# Editor configuration
- configDialogs::editor::getSettings
- configDialogs::editor::save_config
+ configDialogues::editor::getSettings
+ configDialogues::editor::save_config
# Right panel settings
- configDialogs::rightPanel::getSettings
- configDialogs::rightPanel::save_config
+ configDialogues::rightPanel::getSettings
+ configDialogues::rightPanel::save_config
# Compiler configuration
- configDialogs::compiler::getSettings
- configDialogs::compiler::save_config
+ configDialogues::compiler::getSettings
+ configDialogues::compiler::save_config
# Main tool bar
set ::ICONBAR_CURRENT ${::ICONBAR_DEFAULT}
- configDialogs::toolbar::save_config
+ configDialogues::toolbar::save_config
# Custom commands
- configDialogs::custom_commands::save_config
+ configDialogues::custom_commands::save_config
# Shortcuts
- configDialogs::shortcuts::load_config
- configDialogs::shortcuts::getSettings
- configDialogs::shortcuts::save_config
+ configDialogues::shortcuts::load_config
+ configDialogues::shortcuts::getSettings
+ configDialogues::shortcuts::save_config
# Simulator configuration
- configDialogs::simulator::getSettings
- configDialogs::simulator::save_config
+ configDialogues::simulator::getSettings
+ configDialogues::simulator::save_config
# Terminal emulator
if {!$::MICROSOFT_WINDOWS} { ;# There is no terminal emulator on Windows
- configDialogs::terminal::getSettings
- configDialogs::terminal::save_config
+ configDialogues::terminal::getSettings
+ configDialogues::terminal::save_config
}
# Load settings
- } {
- configDialogs::editor::load_config ;# Editor configuration
- configDialogs::rightPanel::load_config ;# Right panel settings
- configDialogs::compiler::load_config ;# Compiler configuration
- configDialogs::toolbar::load_config ;# Main tool bar
- configDialogs::custom_commands::load_config ;# Custom commands
- configDialogs::shortcuts::load_config ;# Shortcuts
- configDialogs::simulator::load_config ;# Simulator
+ } else {
+ configDialogues::editor::load_config ;# Editor configuration
+ configDialogues::rightPanel::load_config ;# Right panel settings
+ configDialogues::compiler::load_config ;# Compiler configuration
+ configDialogues::toolbar::load_config ;# Main tool bar
+ configDialogues::custom_commands::load_config ;# Custom commands
+ configDialogues::shortcuts::load_config ;# Shortcuts
+ configDialogues::simulator::load_config ;# Simulator
if {!$::MICROSOFT_WINDOWS} { ;# There is no terminal emulator on Windows
- configDialogs::terminal::load_config ;# Terminal emulator
+ configDialogues::terminal::load_config ;# Terminal emulator
}
}
}
@@ -980,62 +1120,62 @@ set false_selection_dis 0
# @parm String what_to_do - ID of tab to activate
# @return void
proc manipulate_panel {what_to_do} {
- if {![llength ${X::openedProjects}] || ${X::actualProject} == {}} {
+ if {![llength ${::X::openedProjects}] || ${::X::actualProject} == {}} {
return
}
switch -- $what_to_do {
{sim} { ;# "Bottom / Simulator"
- ${X::actualProject} bottomNB_show_up Simulator
+ ${::X::actualProject} bottomNB_show_up Simulator
}
{graph} { ;# "Bottom" / "Graph"
- ${X::actualProject} bottomNB_show_up Graph
+ ${::X::actualProject} bottomNB_show_up Graph
}
{mess} { ;# "Bottom / Messages"
- ${X::actualProject} bottomNB_show_up Messages
+ ${::X::actualProject} bottomNB_show_up Messages
}
{todo} { ;# "Bottom / Todo"
- ${X::actualProject} bottomNB_show_up Todo
+ ${::X::actualProject} bottomNB_show_up Todo
}
{calc} { ;# "Bottom / Calculator"
- ${X::actualProject} bottomNB_show_up Calculator
+ ${::X::actualProject} bottomNB_show_up Calculator
}
{bsh} { ;# "Bottom / Show_Hide"
- ${X::actualProject} bottomNB_show_hide
+ ${::X::actualProject} bottomNB_show_hide
}
{book} { ;# "Right / Bookmarks"
- ${X::actualProject} rightPanel_show_up Bookmarks
+ ${::X::actualProject} rightPanel_show_up Bookmarks
}
{brk} { ;# "Right / Breakpoints"
- ${X::actualProject} rightPanel_show_up Breakpoints
+ ${::X::actualProject} rightPanel_show_up Breakpoints
}
{wtch} { ;# "Right / Watches"
- ${X::actualProject} rightPanel_show_up Watches
+ ${::X::actualProject} rightPanel_show_up Watches
}
{ins} { ;# "Right / Instruction details"
- ${X::actualProject} rightPanel_show_up Instruction
+ ${::X::actualProject} rightPanel_show_up Instruction
}
{sub} { ;# "Right / Subprograms"
- ${X::actualProject} rightPanel_show_up Subprograms
+ ${::X::actualProject} rightPanel_show_up Subprograms
}
{rsh} { ;# "Right / Show_Hide"
- ${X::actualProject} right_panel_show_hide
+ ${::X::actualProject} right_panel_show_hide
}
{lsh} { ;# "Left / Show_Hide"
- ${X::actualProject} filelist_show_hide
+ ${::X::actualProject} filelist_show_hide
}
{open} { ;# "Left / Opened files"
- ${X::actualProject} filelist_show_up opened_files
+ ${::X::actualProject} filelist_show_up opened_files
}
{proj} { ;# "Left / Project files"
- ${X::actualProject} filelist_show_up project_files
+ ${::X::actualProject} filelist_show_up project_files
}
- {fsb} { ;# "Left / Filesystem browser"
- ${X::actualProject} filelist_show_up fs_browser
+ {fsb} { ;# "Left / File system browser"
+ ${::X::actualProject} filelist_show_up fs_browser
}
- {sfr} { ;# "Left / Filesystem browser"
- ${X::actualProject} filelist_show_up sfr_watches
+ {sfr} { ;# "Left / File system browser"
+ ${::X::actualProject} filelist_show_up sfr_watches
}
}
}
@@ -1050,8 +1190,9 @@ proc manipulate_panel {what_to_do} {
# }
# @parm String path - menu root
# @parm Bool tearoff - tearoff menu on/off (default: false)
+ # @parm String trg_ns = "::" - Target namespace (for i18n)
# @return Bool - return code
-proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
+proc menuFactory {pattern path tearoff cmdPrefix shortcuts options {trg_ns {::}}} {
# Create menu widget
eval "menu $path -tearoff $tearoff $options"
@@ -1070,12 +1211,16 @@ proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
set menu(5) "::ICONS::16::$menu(5)"
}
+ # Do i18n
+ set menu(1) [namespace eval $trg_ns "mc {$menu(1)}"]
+ set menu(6) [namespace eval $trg_ns "mc {$menu(6)}"]
+
# Adjust accelerator value
set menu(2) [adjust_menu_accelerator $menu(2)]
# Create menu command
$path add command \
- -label [mc $menu(1)] \
+ -label $menu(1) \
-accelerator $menu(2) \
-underline $menu(3) \
-command "$cmdPrefix$menu(4)" \
@@ -1084,7 +1229,7 @@ proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
# Status bar tip
if {$menu(6) != {}} {
set itemIndex [$path index end]
- menu_Sbar_add $path $itemIndex [mc $menu(6)]
+ menu_Sbar_add $path $itemIndex $menu(6)
bind $path <<MenuSelect>> "menu_Sbar $path \[%W index active\]"
bind $path <Leave> {Sbar {}}
}
@@ -1096,12 +1241,16 @@ proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
set menu(5) "${cmdPrefix}$menu(5)"
}
+ # Do i18n
+ set menu(1) [namespace eval $trg_ns "mc {$menu(1)}"]
+ set menu(7) [namespace eval $trg_ns "mc {$menu(7)}"]
+
# Adjust accelerator value
set menu(2) [adjust_menu_accelerator $menu(2)]
# Create radio button item
$path add radiobutton \
- -label [mc $menu(1)] \
+ -label $menu(1) \
-accelerator $menu(2) \
-variable $menu(3) \
-value $menu(4) \
@@ -1111,12 +1260,12 @@ proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
-indicatoron 0 \
-image ::ICONS::raoff \
-selectimage ::ICONS::raon \
- -selectcolor {#EEEEEE}
+ -selectcolor ${::COMMON_BG_COLOR}
# Status bar tip
if {$menu(7) != {}} {
set itemIndex [$path index end]
- menu_Sbar_add $path $itemIndex [mc $menu(7)]
+ menu_Sbar_add $path $itemIndex $menu(7)
bind $path <<MenuSelect>> "menu_Sbar $path \[%W index active\]"
bind $path <Leave> {Sbar {}}
}
@@ -1126,12 +1275,17 @@ proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
if {$menu(7) != {}} {
set menu(7) "${cmdPrefix}$menu(7)"
}
+
+ # Do i18n
+ set menu(1) [namespace eval $trg_ns "mc {$menu(1)}"]
+ set menu(8) [namespace eval $trg_ns "mc {$menu(8)}"]
+
# Adjust accelerator value
set menu(2) [adjust_menu_accelerator $menu(2)]
# Create checkbutton item
$path add checkbutton \
- -label [mc $menu(1)] \
+ -label $menu(1) \
-accelerator $menu(2) \
-variable $menu(3) \
-onvalue $menu(4) \
@@ -1142,11 +1296,11 @@ proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
-image ::ICONS::choff \
-indicatoron 0 \
-selectimage ::ICONS::chon \
- -selectcolor {#EEEEEE}
+ -selectcolor ${::COMMON_BG_COLOR}
# Status bar tip
if {$menu(8) != {}} {
set itemIndex [$path index end]
- menu_Sbar_add $path $itemIndex [mc $menu(8)]
+ menu_Sbar_add $path $itemIndex $menu(8)
bind $path <<MenuSelect>> "menu_Sbar $path \[%W index active\]"
bind $path <Leave> {Sbar {}}
}
@@ -1156,14 +1310,16 @@ proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
set menu(4) "$path$menu(4)"
# Create new menu for cascade
if {$menu(7) != {}} {
- menuFactory $menu(7) $menu(4) $menu(5) $cmdPrefix $menu(6) $options
+ menuFactory $menu(7) $menu(4) $menu(5) $cmdPrefix $menu(6) $options $trg_ns
}
+ # Do i18n
+ set menu(1) [namespace eval $trg_ns "mc {$menu(1)}"]
# Item icon
if {$menu(3) != {}} {
set menu(3) "::ICONS::16::$menu(3)"
}
# Add cascade to this menu
- $path add cascade -label [mc $menu(1)] -underline $menu(2) \
+ $path add cascade -label $menu(1) -underline $menu(2) \
-image $menu(3) -menu $menu(4) -compound left
}
{} {return}
@@ -1188,7 +1344,7 @@ proc ena_dis_menu_buttons {EnaDis pattern} {
# Determinate state
if {$EnaDis} {
set state normal
- } {
+ } else {
set state disabled
}
# Set state
@@ -1209,7 +1365,7 @@ proc ena_dis_iconBar_buttons {EnaDis pathPrefix buttonList} {
# Determinate state
if {$EnaDis} {
set state normal
- } {
+ } else {
set state disabled
}
# Set state
@@ -1228,9 +1384,10 @@ proc ena_dis_iconBar_buttons {EnaDis pathPrefix buttonList} {
# {?name? ?helptext? ?imageName? ?command? [?statusTip?]}
# {separator}
# }
+ # @parm String trg_ns = "::" - Target namespace (for i18n)
# @return void
set iconBarFactory_sep_index 0 ;# Separator index
-proc iconBarFactory {container cmdPrefix pathPrefix imageNS pattern} {
+proc iconBarFactory {container cmdPrefix pathPrefix imageNS pattern {trg_ns {::}}} {
global iconBarFactory_sep_index ;# Separator index
# Parse pattern
@@ -1256,12 +1413,12 @@ proc iconBarFactory {container cmdPrefix pathPrefix imageNS pattern} {
-image "$imageNS$parm(2)" \
-style ToolButton.TButton \
]
- DynamicHelp::add $buttonWidget -text $parm(1)
+ ::DynamicHelp::add $buttonWidget -text [namespace eval $trg_ns "mc {[lindex $button 1]}"]
# Pack it
pack $buttonWidget -in $container -side left -padx 2
# Set status bar tip
if {[llength $button] == 5} {
- setStatusTip -widget $buttonWidget -text [lindex $button 4]
+ setStatusTip -widget $buttonWidget -text [namespace eval $trg_ns "mc {[lindex $button 4]}"]
}
}
}
@@ -1317,6 +1474,7 @@ proc show_statusbar_history {} {
# @parm String txt - initial text
# @return void
proc makeStatusbar {txt} {
+ # Button "Set syntax validation level"
pack [frame .statusbarF -height 30p] -fill x -expand 0 -side bottom
pack [ttk::button .statusbarVB \
-style TButton \
@@ -1324,19 +1482,49 @@ proc makeStatusbar {txt} {
-compound left \
-width 6 \
] -in .statusbarF -side left
- DynamicHelp::add .statusbarVB -text [mc "Change validation level"]
+ DynamicHelp::add .statusbarVB -text [mc "Change level of syntax validation."]
bind .statusbarVB <Button-3> {change_validation_level {down}; break}
bind .statusbarVB <Button-1> {change_validation_level {up}; break}
- pack [ArrowButton .statusbarF.arr_but \
- -dir top -clean 2 -bd 0 \
- -helptext [mc "Show statusbar history"] \
- -command {show_statusbar_history} \
- -height 14 -width 14 -bg {#eeeeee} \
+ # This function was not yet ported to MS Windows
+ if {!$::MICROSOFT_WINDOWS} {
+ # Button "Configure spell checking"
+ pack [ttk::menubutton .statusbarSB \
+ -style TButton \
+ -compound left \
+ -width 6 \
+ -direction above \
+ -menu .spell_checker_conf_menu \
+ -image ::ICONS::flag::empty \
+ -text "none" \
+ ] -in .statusbarF -side left
+ if {${::PROGRAM_AVAILABLE(hunspell)}} {
+ DynamicHelp::add .statusbarSB -text [mc "Configure spell checker"]
+ } else {
+ DynamicHelp::add .statusbarSB -text [mc "Spell checker (hunspell) is not available."]
+ .statusbarSB configure -state disabled
+ }
+ }
+
+ # Button "Show status bar history"
+ pack [ArrowButton .statusbarF.arr_but \
+ -dir top -clean 2 -bd 0 \
+ -helptext [mc "Show status bar history"] \
+ -command {show_statusbar_history} \
+ -height 14 -width 14 -bg ${::COMMON_BG_COLOR} \
] -side left -padx 7
- setStatusTip -widget .statusbarF.arr_but -text [mc "Show statusbar history"]
- pack [label .statusbarL -text $txt -anchor w -justify left] \
+ setStatusTip -widget .statusbarF.arr_but -text [mc "Show status bar history"]
+
+ # Status bar
+ pack [label .statusbarL -text $txt -anchor w -justify left] \
-in .statusbarF -side left -fill x -expand 1
+ # MCU currently in use
+ pack [label .statusbarMCU -text "" -cursor hand2 -anchor e -justify right -fg {#000000}] \
+ -in .statusbarF -side right -padx 5
+ DynamicHelp::add .statusbarMCU -text [mc "MCU chosen for simulation"]
+ bind .statusbarMCU <Enter> {%W configure -fg {#0000DD}}
+ bind .statusbarMCU <Leave> {%W configure -fg {#000000}}
+ bind .statusbarMCU <Button-1> {::X::__proj_edit 1}
}
set sbarAfterId {} ;# Sbar timer ID
set status_bar_history {} ;# Sbar history
@@ -1381,7 +1569,7 @@ proc change_validation_level {arg} {
set ::CsyntaxHighlight::validation_L1 0 ;# Bool: Basic validation enabled
set ::ASMsyntaxHighlight::validation_L0 0 ;# Bool: Basic validation enabled
set ::ASMsyntaxHighlight::validation_L1 0 ;# Bool: Advancet validation enabled
- } {
+ } else {
.statusbarVB configure -text " $::CONFIG(VALIDATION_LEVEL)"
.statusbarVB configure -style TButton
setStatusTip -widget .statusbarVB -text [mc "Current validation level: %s" $::CONFIG(VALIDATION_LEVEL)]
@@ -1394,7 +1582,7 @@ proc change_validation_level {arg} {
if {$::CONFIG(VALIDATION_LEVEL) == 2} {
set ::ASMsyntaxHighlight::validation_L1 1 ;# Bool: Advancet validation enabled
set ::CsyntaxHighlight::validation_L1 1 ;# Bool: Basic validation enabled
- } {
+ } else {
set ::ASMsyntaxHighlight::validation_L1 0 ;# Bool: Advancet validation enabled
set ::CsyntaxHighlight::validation_L1 0 ;# Bool: Basic validation enabled
}
@@ -1466,7 +1654,7 @@ proc simulator_Sbar {txt mode object} {
if {![string length $txt]} {
return
}
- pack [label .simulator_Sbar -text $txt -fg {#DD8800} -cursor hand1] -in .statusbarF -side right
+ pack [label .simulator_Sbar -text $txt -fg {#DD8800} -cursor hand2] -in .statusbarF -side right
if {$mode} {
bind .simulator_Sbar <Enter> {%W configure -fg {#0000DD}}
bind .simulator_Sbar <Leave> {%W configure -fg {#DD8800}}
@@ -1557,6 +1745,9 @@ proc menu_Sbar_add {menu item text} {
# @parm Widget menu - ID of the menu
# @return void
proc menu_Sbar_remove {menu} {
+ if {$menu == {}} {
+ return
+ }
# Determinate menu index
set idx [lsearch ${::menuSbar_menus} $menu]
if {$idx == -1} {
@@ -1584,7 +1775,7 @@ proc menu_Sbar {menu item} {
}
if {[lsearch $::menuSbar_items($menu) $item] != -1} {
Sbar -freeze $::menuSbar_texts(${menu},${item})
- } {
+ } else {
Sbar {}
}
}
@@ -1626,7 +1817,7 @@ set SHORTCUTS_LIST {
{statistics} {{} ::X::__statistics {}
{File statistics}}
{fullscreen} {{Control-Key-XF86_Switch_VT_11} ::X::__toggle_fullscreen window_fullscreen
- {Toggle fullscreen mode}}
+ {Toggle full screen mode}}
} {project {Project management} {}
{proj_new} {{} ::X::__proj_new filenew
{New project}}
@@ -1692,22 +1883,30 @@ set SHORTCUTS_LIST {
{resume} {{} ::X::__resume resume
{Simulator: Resume}}
{intrmon} {{} ::X::__interrupt_monitor kcmdf
- {Interrupt monitor}}
+ {Interrupt Monitor}}
+ {uartmon} {{} ::X::__uart_monitor __blockdevice
+ {UART Monitor}}
{stopwatch} {{} ::X::__stopwatch_timer player_time
{Stopwatch}}
} {virtual_hw {Virtual HW} {}
{ledpanel} {{} {::X::__vhw_LED_panel} ledpanel
- {LED panel}}
+ {LED Panel}}
{leddisplay} {{} {::X::__vhw_LED_display} leddisplay
- {LED display}}
+ {LED Display}}
{ledmatrix} {{} {::X::__vhw_LED_matrix} ledmatrix
- {LED matrix}}
+ {LED Matrix}}
+ {hd44780} {{} {::X::__vhw_HD44780} hd44780
+ {LCD display controlled by HD44780}}
{mleddisplay} {{} {::X::__vhw_M_LED_display} mleddisplay
{Multiplexed LED display}}
{simplekeypad} {{} {::X::__vhw_keys} simplekeypad
- {Simple keypad}}
+ {Simple Keypad}}
{matrixkeypad} {{} {::X::__vhw_matrix_keypad} matrixkeypad
- {Matrix keypad}}
+ {Matrix Keypad}}
+ {ds1620} {{} {::X::__ds1620} ds1620
+ {DS1620 thermometer}}
+ {fintr} {{} {::X::__vhw_file_interface} compfile1
+ {File Interface}}
{vhw_open} {{} {::X::__open_VHW} fileopen
{Open}}
{vhw_load} {{} {::X::__load_VHW} fileimport
@@ -1725,6 +1924,8 @@ set SHORTCUTS_LIST {
{Compile this file only}}
{disasm} {{} ::X::__disasm disasm
{Disassemble}}
+ {d52} {{} ::X::__d52 d52
+ {Disassemble with D52}}
{auto_indent} {{} ::X::__reformat_code filter
{Auto indent}}
{change_case} {{} ::X::__change_letter_case change_case
@@ -1763,24 +1964,28 @@ set SHORTCUTS_LIST {
{hexeditor} {{} ::X::__hexeditor ascii
{Hex Editor}}
{symb_view} {{} ::X::__symb_view symbol
- {Symbol table}}
+ {Symbol Table}}
{8seg} {{} ::X::__eightsegment 8seg
- {8-segment editor}}
+ {8-Segment Editor}}
{ascii_c} {{} ::X::__ascii_chart math_matrix
- {ASCII chart}}
+ {ASCII Chart}}
+ {toi} {{} ::X::__table_of_instructions fsview
+ {8051 Instruction Table}}
{notes} {{} ::X::__notes pencil
- {Scribble notepad}}
- {bc} {{} ::X::__base_convertor kaboodleloop
- {Base Convertor}}
+ {Scribble Notepad}}
+ {bc} {{} ::X::__base_converter kaboodleloop
+ {Base Converter}}
{rs232} {{} ::X::__rs232debugger chardevice
{UART/RS232 Debugger}}
} {help {Help} {}
{about} {{} ::X::__about mcu8051ide
{About dialog}}
- {welcome} {{} ::X::__welcome_dialog {}
- {Welcome dialog}}
- {tips} {{} ::X::__tip_of_the_day help
- {Tip of the day}}
+ {welcome} {{} ::X::__welcome_dialog info
+ {Welcome Dialog}}
+ {tips} {{} ::X::__tip_of_the_day help
+ {Tip of the Day}}
+ {hbook} {{Key-F1} ::X::__handbook contents
+ {Handbook}}
} {messages {Messages text} {Control-Key-c Control-Key-a}
{clear_mess} {{} {$this clear_messages_text} editdelete
{Clear messages}}
@@ -1799,7 +2004,7 @@ set SHORTCUTS_LIST {
{italic} {Control-Key-i {$this TodoProc_italic} text_italic
{Italic text}}
{strike} {Control-Key-q {$this TodoProc_strike} text_strike
- {Striketrought text}}
+ {Strikethrough text}}
{under} {Control-Key-u {$this TodoProc_under} text_under
{Underline text}}
{edrase} {Control-Key-e {$this TodoProc_eraser} eraser
@@ -1823,7 +2028,7 @@ set SHORTCUTS_LIST {
{Move down}}
{bottom} {{} {$this rightPanel_watch_move_bottom} bottom
{Move to bottom}}
- {remove} {{Control-Delete} {$this rightPanel_watch_remove} button_cancel
+ {remove} {{Control-Delete} {$this rightPanel_watch_remove} button_cancel
{Remove}}
{remove_all} {{} {$this rightPanel_watch_clear} editdelete
{Remove all}}
@@ -1917,6 +2122,9 @@ set SHORTCUTS_LIST {
{Block selection mode}}
}
}
+# Intentionally hidden functions, these haven't been fully implemented yet
+# virtual_hw: {vuterm} {{} {::X::__vhw_UART_terminal} _chardevice
+# {Virtual UART termnal}}
## Traslate menu accelerator string to human readable key sequence
# @parm String value - string to translate (for instance: $main:quit)
@@ -2079,9 +2287,9 @@ set MAINMENU {
{command "Find" "$edit:find" 0 {X::__find} "find"
"Find a string in the text"}
{command "Find next" "$edit:find_next" 5 {X::__find_next} "1downarrow"
- "Find next occurence of search string"}
+ "Find next occurrence of search string"}
{command "Find previous" "$edit:find_prev" 10 {X::__find_prev} "1uparrow"
- "Find previous occurence of search string"}
+ "Find previous occurrence of search string"}
{separator}
{command "Replace" "$edit:replace" 0 {X::__replace} ""
"Replace some string with another"}
@@ -2102,7 +2310,7 @@ set MAINMENU {
{cascade "View" 0 "" .display false 1 {
{checkbutton "Read only mode" "$sim:readonly" {::editor_RO_MODE} 1 0 5
{::X::switch_editor_RO_MODE}
- "Set current editor to readonly/normal mode"}
+ "Set current editor to read only/normal mode"}
{command "Switch to command line" "$edit:cmd_line" 7 {X::__switch_to_cmd_line}
"" "Switch to editor command line"}
{separator}
@@ -2130,8 +2338,8 @@ set MAINMENU {
""}
}}
{separator}
- {command "Fullscreen mode" "$main:fullscreen" 0 {X::__toggle_fullscreen}
- "window_fullscreen" "Toggle fullscreen mode"}
+ {command "Full screen mode" "$main:fullscreen" 0 {X::__toggle_fullscreen}
+ "window_fullscreen" "Toggle full screen mode"}
{separator}
{command "Clear messages panel" "$messages:clear_mess" 0 {X::__clear_messages_text}
"editdelete" "Clear messages panel"}
@@ -2163,23 +2371,21 @@ set MAINMENU {
"launch_this" "Start simulator engine and load current file only"}
{separator}
{command "Step back" "$sim:stepback" 5 {X::__stepback}
- "undo" "Step program back by 1 inctruction"}
+ "undo" "Step program back by 1 instruction"}
{command "Step" "$sim:step" 3 {X::__step}
- "goto" "Step program by 1 inctruction"}
+ "goto" "Step program by 1 instruction"}
{command "Step over" "$sim:stepover" 5 {X::__stepover}
"goto2" "Step program by 1 line of code"}
{command "Animate" "$sim:animate" 0 {X::__animate}
"1rightarrow" "Run program and show results after each change"}
{command "Run" "$sim:run" 2 {X::__run}
- "2rightarrow" "Run program and show results periodicaly in some interval"}
+ "2rightarrow" "Run program and show results periodically in some interval"}
{separator}
{command "Hiberante program" "$sim:hiberante" 0 {X::__hibernate}
"bar5" "Save current state of simulator engine to a file for future resumption"}
{command "Resume hibernated program" "$sim:resume" 4 {X::__resume}
"resume" "Resume hibernated program"}
{separator}
- {command "Interrupt monitor" "$sim:intrmon" 6 {X::__interrupt_monitor}
- "kcmdf" "Dialog in which you can controll MCU interrupts"}
{command "Stopwatch" "$sim:stopwatch" 4 {X::__stopwatch_timer}
"player_time" "Configurable stopwatch timer which can stop simulation on various conditions"}
{separator}
@@ -2208,7 +2414,7 @@ set MAINMENU {
{command "Show Data EEPROM" "$sim:show_eeprom" 5 {X::__show_eeprom}
"kcmmemory_P" "Invoke hex editor with data EEPROM"}
{command "Show EEPROM write buffer" "$sim:show_eem_wb" 14 {X::__show_eeprom_write_buffer}
- "kcmmemory_B" "Invoke hexeditor editor with data EEPROM write buffer"}
+ "kcmmemory_B" "Invoke hex editor editor with data EEPROM write buffer"}
{separator}
{cascade "Reset" 0 "rebuild" .virtual_mcu_reset false 1 {
{command "Only SFR" "$sim:reset-" 0 {X::__reset -}
@@ -2220,20 +2426,41 @@ set MAINMENU {
{command "Random values" "$sim:resete" 0 {X::__reset r}
"rebuild" "Reset all internal registers to random values"}
}}
+ {separator}
+ {command "Interrupt monitor" "$sim:intrmon" 6 {X::__interrupt_monitor}
+ "kcmdf" "Dialog in which you can control MCU interrupts"}
}}
{cascade "Virtual HW" 8 "" .virtual_hw false 1 {
- {command "LED panel" "$virtual_hw:ledpanel" 2 {X::__vhw_LED_panel}
+ {command "LED Panel" "$virtual_hw:ledpanel" 2 {X::__vhw_LED_panel}
"ledpanel" ""}
- {command "LED display" "$virtual_hw:leddisplay" 10 {X::__vhw_LED_display}
+ {command "LED Display" "$virtual_hw:leddisplay" 10 {X::__vhw_LED_display}
"leddisplay" ""}
- {command "LED matrix" "$virtual_hw:ledmatrix" 4 {X::__vhw_LED_matrix}
+ {command "LED Matrix" "$virtual_hw:ledmatrix" 4 {X::__vhw_LED_matrix}
"ledmatrix" ""}
- {command "Multiplexed LED display" "$virtual_hw:mleddisplay" 1 {X::__vhw_M_LED_display}
+ {command "Multiplexed LED Display" "$virtual_hw:mleddisplay" 1 {X::__vhw_M_LED_display}
"mleddisplay" ""}
- {command "Simple keypad" "$virtual_hw:simplekeypad" 1 {X::__vhw_keys}
+ {command "Simple Keypad" "$virtual_hw:simplekeypad" 1 {X::__vhw_keys}
"simplekeypad" ""}
- {command "Matrix keypad" "$virtual_hw:matrixkeypad" 7 {X::__vhw_matrix_keypad}
+ {command "Matrix Keypad" "$virtual_hw:matrixkeypad" 7 {X::__vhw_matrix_keypad}
"matrixkeypad" ""}
+ {cascade "LCD display (HD44780)" 13 "hd44780" .hd44780 false 1 {
+ {command "1 × 8" "" 0 {X::__vhw_HD44780 {1 8}}
+ "hd44780" "LCD display controlled by HD44780"}
+ {command "2 × 8" "" 0 {X::__vhw_HD44780 {2 8}}
+ "hd44780" "LCD display controlled by HD44780"}
+ {command "2 × 16" "" 0 {X::__vhw_HD44780 {2 16}}
+ "hd44780" "LCD display controlled by HD44780"}
+ {command "2 × 20" "" 0 {X::__vhw_HD44780 {2 20}}
+ "hd44780" "LCD display controlled by HD44780"}
+ {command "2 × 40" "" 0 {X::__vhw_HD44780 {2 40}}
+ "hd44780" "LCD display controlled by HD44780"}
+ {command "Any" "" 0 {X::__vhw_HD44780}
+ "hd44780" "LCD display controlled by HD44780"}
+ }}
+ {command "DS1620 temperature sensor" "$virtual_hw:ds1620" 8 {X::__vhw_ds1620}
+ "ds1620" "Simulated DS1620 thermometer"}
+ {command "File Interface" "$virtual_hw:fintr" 1 {X::__vhw_file_interface}
+ "compfile1" "Read & Write GPIO states from/to a file"}
{separator}
{command "Open" "$virtual_hw:vhw_open" 0 {X::__open_VHW}
"fileopen" "Load VHW connections from a file"}
@@ -2249,7 +2476,6 @@ set MAINMENU {
"filesave" "Save current VHW connections to a file"}
{command "Save as" "$virtual_hw:vhw_saveas" 1 {X::__save_as_VHW}
"filesaveas" "Save current VHW connections under a different name"}
-
{separator}
{command "Remove all" "$virtual_hw:vhw_remove_all" 0 {X::__remove_all_VHW}
"editdelete" "Remove all VHW"}
@@ -2283,7 +2509,7 @@ set MAINMENU {
{command "Document current function" "$tools:doc_cur_f" 4 {X::__document_current_func}
"" "Create doxygen documentation for function on current line"}
{command "Run doxywizard" "$tools:doxywizard" 7 {X::__run_doxywizard}
- "" "Run doxygen frondend"}
+ "" "Run doxygen front-end"}
{command "Clear C API documentation" "$tools:clr_doc" 8 {X::__clear_documentation}
"" "Remove C API documentation created by doxygen"}
{command "Build C API documentation" "$tools:doxygen" 9 {X::__generate_documentation}
@@ -2311,64 +2537,80 @@ set MAINMENU {
{command "Normalize Intel 8 hex file" "$utilities:normalize_hex" 0 {X::__normalize_hex}
"hh" "Reformat the given IHEX8"}
{separator}
- {command "Hex editor" "$utilities:hexeditor" 1 {X::__hexeditor}
+ {command "Hex Editor" "$utilities:hexeditor" 1 {X::__hexeditor}
"ascii" "Invoke project independent hexadecimal editor with capacity of 64KB"}
- {command "Symbol table" "$utilities:symb_view" 7 {X::__symb_view}
+ {command "Symbol Table" "$utilities:symb_view" 7 {X::__symb_view}
"symbol" "Assembly language symbol table viewer"}
- {command "8-segment editor" "$utilities:8seg" 4 {X::__eightsegment}
- "8seg" "8-segment LED display editor"}
- {command "ASCII chart" "$utilities:ascii_c" 0 {X::__ascii_chart}
- "math_matrix" "ASCII chart"}
+ {command "8-Segment Editor" "$utilities:8seg" 4 {X::__eightsegment}
+ "8seg" "8-Segment LED Display Editor"}
+ {command "ASCII Chart" "$utilities:ascii_c" 0 {X::__ascii_chart}
+ "math_matrix" "ASCII Chart"}
+ {command "8051 Instruction Table" "$utilities:toi" 0 {X::__table_of_instructions}
+ "fsview" "Interactive table of 8051 instructions"}
{separator}
- {command "Scribble notepad" "$utilities:notes" 10 {X::__notes}
+ {command "Scribble Notepad" "$utilities:notes" 10 {X::__notes}
"pencil" ""}
- {command "Base convertor" "$utilities:bc" 5 {X::__base_convertor}
+ {command "Base Converter" "$utilities:bc" 5 {X::__base_converter}
"kaboodleloop" ""}
- {command "Special calculator" "" 1 {X::__spec_calc}
+ {command "Special Calculator" "" 1 {X::__spec_calc}
"xcalc" ""}
{separator}
{command "UART/RS232 Debugger" "$utilities:rs232" 2 {X::__rs232debugger}
"chardevice" ""}
}}
{cascade "Configure" 0 "" .configure false 0 {
- {command "Configure Editor" "" 0 {::configDialogs::editor::mkDialog}
+ {command "Configure Editor" "" 0 {::configDialogues::editor::mkDialog}
"configure"
"Editor configuration (colors, fonts, highlighting, etc.)"}
- {command "Configure Compiler" "" 1 {::configDialogs::compiler::mkDialog}
+ {command "Configure Compiler" "" 1 {::configDialogues::compiler::mkDialog}
"configure"
"Various compilation options"}
- {command "Configure Simulator" "" 12 {::configDialogs::simulator::mkDialog}
+ {command "Configure Simulator" "" 12 {::configDialogues::simulator::mkDialog}
"configure"
"Opens simulator configuration dialog"}
- {command "Configure Right Panel" "" 2 {::configDialogs::rightPanel::mkDialog}
+ {command "Configure Right Panel" "" 2 {::configDialogues::rightPanel::mkDialog}
"configure"
- "Right panel configration (instruction details colors)"}
- {command "Configure Main Toolbar" "" 3 {::configDialogs::toolbar::mkDialog}
+ "Right panel configuration (instruction details colors)"}
+ {command "Configure Main Toolbar" "" 3 {::configDialogues::toolbar::mkDialog}
"configure_toolbars"
"Adjust content of the main toolbar (under main menu)"}
- {command "Edit custom commands" "" 3 {::configDialogs::custom_commands::mkDialog}
+ {command "Edit custom commands" "" 3 {::configDialogues::custom_commands::mkDialog}
"configure"
- "Set or modify user defined commads"}
- {command "Configure shortcuts" "" 10 {::configDialogs::shortcuts::mkDialog}
+ "Set or modify user defined commands"}
+ {command "Configure shortcuts" "" 10 {::configDialogues::shortcuts::mkDialog}
"configure_shortcuts"
"Set or modify key shortcuts"}
- {command "Configure terminal emulator" "" 12 {::configDialogs::terminal::mkDialog}
+ {command "Configure terminal emulator" "" 12 {::configDialogues::terminal::mkDialog}
"terminal"
"Configure embedded terminal emulator -- RXVT-UNICODE"}
- {command "Configure MCU 8051 IDE" "" 4 {::configDialogs::global::mkDialog}
+ {command "Configure MCU 8051 IDE" "" 4 {::configDialogues::global::mkDialog}
"mcu8051ide"
"Invoke global configuration dialog"}
}}
{cascade "Help" 0 "" .help false 1 {
{command "About" "$help:about" 0 {X::__about}
- "kcmmemory" "About MCU 8051 IDE"}
- {command "Welcome dialog" "$help:welcome" 0 {X::__welcome_dialog}
- "" "Invoke dialog which you have seen on the first start"}
- {command "Tip of the day" "$help:tips" 0 {X::__tip_of_the_day}
- "" "Some tips about how to use this program more efficiently"}
+ "mcu8051ide" "About MCU 8051 IDE"}
+ {command "Welcome Dialog" "$help:welcome" 0 {X::__welcome_dialog}
+ "info" "Invoke dialog which you have seen on the first start"}
+ {command "Tip of the Day" "$help:tips" 0 {X::__tip_of_the_day}
+ "idea" "Some tips about how to use this program more efficiently"}
+ {separator}
+ {command "Project web page" "" 8 {::X::__web_page}
+ "html" ""}
+ {command "Report a bug" "" 9 {::X::__bug_report}
+ "bug" ""}
+ {separator}
+ {command "ASEM-51 manual" "" 0 {::X::__asem51_manual}
+ "asem51" ""}
+ {command "SDCC manual" "" 0 {::X::__sdcc_manual}
+ "sdcc" ""}
+ {separator}
+ {command "Handbook" "" 0 {::X::__handbook}
+ "contents" ""}
}}
}
-# This belongs to the "Virtual MCU"
+# Intentionally hidden functions, these haven't been fully implemented yet
+# This belongs to the "Virtual MCU":
# {separator}
# {cascade "Functional diagrams" 0 "blockdevice" .virtual_mcu_fd false 1 {
# {command "Timer/Counter 0" "" 14 {X::__functional_diagram 0}
@@ -2389,13 +2631,19 @@ set MAINMENU {
# "flag" ""}
# }}
# {separator}
-# {command "Virtual UART termnal" "" 8 {X::__virtual_terminal u}
-# "chardevice" ""}
# {command "Virtual SPI termnal" "" 9 {X::__virtual_terminal s}
# "chardevice" ""}
#
+# Virtual MCU: {command "UART Monitor" "$sim:uartmon" 1 {X::__uart_monitor}
+# "__blockdevice" "Dialog in which you can control UART operations"}
+#
+# Virtual HW: {command "Virtual UART terminal" "$virtual_hw:vuterm" 8 {X::__vhw_UART_terminal}
+# "_chardevice" "Simulated UART terminal connected to the MCU simulator"}
+#
+# Tools: {command "Disassemble with D52" "$tools:d52" 15 {X::__d52}
+# "d52" ""}
+# {separator}
#
-
## (Re)Draw main menu
# @return void
@@ -2410,8 +2658,15 @@ proc mainmenu_redraw {} {
}
# Create main menu
. configure -menu .mainMenu
- menuFactory $MAINMENU .mainMenu 0 {} 0 {}
- .mainMenu configure -bd 0 -bg {#EEEEEE} -activeforeground {#6666FF} -activebackground {#EEEEEE} -activeborderwidth 1
+ menuFactory $MAINMENU .mainMenu 0 {} 0 {} [namespace current]
+ if {!${::MICROSOFT_WINDOWS}} {
+ .mainMenu configure \
+ -activeborderwidth 1 \
+ -bg ${::COMMON_BG_COLOR} \
+ -activeforeground {#6666FF} \
+ -activebackground ${::COMMON_BG_COLOR} \
+ -bd 0
+ }
# Restore lists of recent files
for {set i 0} {$i < 3} {incr i} {
@@ -2429,18 +2684,19 @@ proc mainmenu_redraw {} {
iso8859-6 iso8859-7 iso8859-8
iso8859-9 iso8859-10 iso8859-13
iso8859-14 iso8859-15 iso8859-16
- } {
- .mainMenu.tools.encoding add radiobutton \
- -label [enc2name $enc] \
- -value $enc \
- -accelerator [string toupper $enc] \
- -variable ::editor_encoding \
- -command {::X::change_encoding} \
- -indicatoron 0 \
- -compound left \
- -image ::ICONS::raoff \
- -selectimage ::ICONS::raon \
- -selectcolor {#EEEEEE}
+ } \
+ {
+ .mainMenu.tools.encoding add radiobutton \
+ -label [mc [enc2name $enc]] \
+ -value $enc \
+ -accelerator [string toupper $enc] \
+ -variable ::editor_encoding \
+ -command {::X::change_encoding} \
+ -indicatoron 0 \
+ -compound left \
+ -image ::ICONS::raoff \
+ -selectimage ::ICONS::raon \
+ -selectcolor ${::COMMON_BG_COLOR}
}
.mainMenu.tools.encoding entryconfigure 0 -foreground {#0000FF} -underline 0
@@ -2457,17 +2713,20 @@ proc mainmenu_redraw {} {
-compound left \
-image ::ICONS::raoff \
-selectimage ::ICONS::raon \
- -selectcolor {#EEEEEE}
+ -selectcolor ${::COMMON_BG_COLOR}
}
# Window geometry correction
wm geometry . $::CONFIG(WINDOW_GEOMETRY)
- update idle
+ update idletasks
+ if {!$::MICROSOFT_WINDOWS && $::CONFIG(WINDOW_ZOOMED)} {
+ wm attributes . -zoomed $::CONFIG(WINDOW_ZOOMED)
+ }
# Enable / Disable menu items
if {${::X::project_menu_locked}} {
::X::Lock_project_menu
- } {
+ } else {
::X::disena_simulator_menu ${::X::actualProject}
if {![lindex ${::X::simulator_enabled} ${::X::actualProjectIdx}]} {
::X::Lock_simulator_menu
@@ -2483,10 +2742,9 @@ proc mainmenu_redraw {} {
.mainMenu.tools delete [::mc "Custom command 2"]
.mainMenu.tools delete [::mc "Run doxywizard"]
.mainMenu.tools delete [::mc "Clear C API documentation"]
- .mainMenu.tools delete [::mc "Build C API documentation"]
}
- # Disable menu items which are not avaliable when external editor used
+ # Disable menu items which are not available when external editor used
::X::adjust_mm_and_tb_ext_editor
}
@@ -2505,9 +2763,9 @@ menuFactory {
show_hide_main_toolbar
} "2uparrow" "Hide main toolbar"}
{command "Configure Toolbar" "" 0
- {::configDialogs::toolbar::mkDialog}
+ {::configDialogues::toolbar::mkDialog}
"configure_toolbars" "Configure main toolbar"}
-} $TOOLBAR_FRAME.menu 0 {} 0 {}
+} $TOOLBAR_FRAME.menu 0 {} 0 {} [namespace current]
bind .mainIconBar <ButtonRelease-3> "tk_popup $TOOLBAR_FRAME.menu %X %Y"
# Create popup menu for custom commands
@@ -2516,13 +2774,13 @@ menuFactory {
{set ::CONFIG(TOOLBAR_VISIBLE) 0; show_hide_main_toolbar}
"2uparrow" "Hide main toolbar"}
{command "Configure Toolbar" "" 0
- {::configDialogs::toolbar::mkDialog}
+ {::configDialogues::toolbar::mkDialog}
"configure_toolbars" "Configure main toolbar"}
{separator}
- {command "Configure cutom commands" "" 1
- {::configDialogs::custom_commands::mkDialog ${::CUTOM_CMD_MENU_CMD_INDEX}}
- "configure" "Invoke cutom commands configuration dialog"}
-} $TOOLBAR_FRAME.cutom_cmd_menu 0 {} 0 {}
+ {command "Configure custom commands" "" 1
+ {::configDialogues::custom_commands::mkDialog ${::CUSTOM_CMD_MENU_CMD_INDEX}}
+ "configure" "Invoke custom commands configuration dialog"}
+} $TOOLBAR_FRAME.custom_cmd_menu 0 {} 0 {} [namespace current]
# Create show button
Label $TOOLBAR_FRAME.show_label \
@@ -2534,8 +2792,8 @@ bind $TOOLBAR_FRAME.show_label <Button-1> {
show_hide_main_toolbar
}
-# Help variable for 'cutom_cmd_menu' -- index of selected command
-set CUTOM_CMD_MENU_CMD_INDEX 0
+# Help variable for 'custom_cmd_menu' -- index of selected command
+set CUSTOM_CMD_MENU_CMD_INDEX 0
## Definition of all possoble items for main icon bar
# format: {
@@ -2573,9 +2831,9 @@ set ICONBAR_ICONS {
{find} { "Find a string in the text" {find} {find}
{find} {Find a string in the text}}
{findnext} { "Find next" {1downarrow} {1downarrow}
- {find_next} {Find next occurence of search string}}
+ {find_next} {Find next occurrence of search string}}
{findprev} { "Find previous" {1uparrow} {1uparrow}
- {find_prev} {Find previous occurence of search string}}
+ {find_prev} {Find previous occurrence of search string}}
{replace} { "Replace" {find} {find}
{replace} "Replace some string with another"}
{goto} { "Jump to line" {goto} {goto}
@@ -2609,7 +2867,9 @@ set ICONBAR_ICONS {
{show_eeprom} { "Show data EEPROM" {memory_P} {kcmmemory_P}
{show_eeprom} "Invoke hex editor with data EEPROM"}
{show_eem_wr_b} { "Show EEPROM write buffer" {memory_B} {kcmmemory_B}
- {show_eeprom_write_buffer} "Invoke hexeditor editor with data EEPROM write buffer"}
+ {show_eeprom_write_buffer} "Invoke hex editor editor with data EEPROM write buffer"}
+ {stack} { "Show stack" {memory_ST} {kcmmemory_ST}
+ {stack_monitor} "Invoke MCU stack monitor"}
{start_sim} { "Start / Shutdown simulator" {fork} {launch}
{initiate_sim} {Load debug file into simulator engine}}
{start_sim0} { "Debug this file only" {fork_this} {launch_this}
@@ -2629,7 +2889,7 @@ set ICONBAR_ICONS {
{resume} { "Resume program" {resume} {resume}
{resume} "Resume hibernated program"}
{intrmon} { "Interrupt monitor" {kcmdf} {kcmdf}
- {interrupt_monitor} "Dialog in which you can controll MCU interrupts"}
+ {interrupt_monitor} "Dialog in which you can control MCU interrupts"}
{stopwatch} { "Stopwatch" {history} {player_time}
{stopwatch_timer} "Configurable stopwatch timer which stop simulation on various conditions"}
{clear_hg} { "Clear highlight" {editclear} {editclear}
@@ -2642,12 +2902,14 @@ set ICONBAR_ICONS {
{disasm} "Disassemble object code and open new editor with the result"}
{hexeditor} { "Hex Editor" {binary} {ascii}
{hexeditor} "Invoke project independent hexadecimal editor with capacity of 64KB"}
- {symbol_tbl} { "Symbol table" {symbol} {symbol}
+ {symbol_tbl} { "Symbol Table" {symbol} {symbol}
{symb_view} "Assembly language symbol table viewer"}
- {8seg} { "8-segment editor" {8seg} {8seg}
- {eightsegment} "8-segment LED display editor"}
- {ascii_c} { "ASCII chart" {math_matrix} {math_matrix}
- {ascii_chart} "ASCII chart"}
+ {8seg} { "8-Segment Editor" {8seg} {8seg}
+ {eightsegment} "8-Segment LED display editor"}
+ {ascii_c} { "ASCII Chart" {math_matrix} {math_matrix}
+ {ascii_chart} "ASCII Chart"}
+ {toi} { "8051 Instruction Table" {fsview} {fsview}
+ {table_of_instructions} "Interactive table of 8051 instructions"}
{reformat_code} { "Auto indent" {filter} {filter}
{reformat_code} "Reformat source code (Indention level ...)"}
{change_case} { "Change letter case" {change_case} {change_case}
@@ -2666,6 +2928,8 @@ set ICONBAR_ICONS {
{exec_custom_cmd 2} {}}
{about} { "About" {mcu8051ide} {mcu8051ide}
{about} "About MCU 8051 IDE"}
+ {hbook} { "Handbook" contents contents
+ {handbook} "Display the documentation for MCU 8051 IDE"}
{forward} { "Forward" {forward} {1rightarrow}
{next_editor} "Switch to the next editor"}
{back} { "Back" {back} {1leftarrow}
@@ -2677,52 +2941,64 @@ set ICONBAR_ICONS {
{line2addr} { "Jump to line" {goto} {goto}
{simulator_set_PC_by_line} "Translate line number to address in program memory and set PC to that address"}
{stepback} { "Step back" {undo} {undo}
- {stepback} "Step program back by 1 inctruction"}
- {notes} { "Scribble notepad" {pencil} {pencil}
- {notes} "Scribble notepad"}
- {ledpanel} { "LED panel" {ledpanel} {ledpanel}
- {vhw_LED_panel} "LED panel"}
- {leddisplay} { "LED display" {leddisplay} {leddisplay}
- {vhw_LED_display} "LED display"}
- {ledmatrix} { "LED matrix" {ledmatrix} {ledmatrix}
- {vhw_LED_matrix} "LED matrix"}
- {mleddisplay} { "Multiplexed LED display" {mleddisplay} {mleddisplay}
- {vhw_M_LED_display} "Multiplexed LED display"}
- {simplekeypad} { "Simple keypad" {simplekeypad} {simplekeypad}
- {vhw_keys} "Simple keypad"}
- {matrixkeypad} { "Matrix keypad" {matrixkeypad} {matrixkeypad}
- {vhw_matrix_keypad} "Matrix keypad"}
- {vhw_open} { "VHW Open" {fileopen} {fileopen}
+ {stepback} "Step program back by 1 instruction"}
+ {notes} { "Scribble Notepad" {pencil} {pencil}
+ {notes} "Scribble Notepad"}
+ {ledpanel} { "LED Panel" {ledpanel} {ledpanel}
+ {vhw_LED_panel} "LED Panel"}
+ {leddisplay} { "LED Display" {leddisplay} {leddisplay}
+ {vhw_LED_display} "LED Display"}
+ {ledmatrix} { "LED Matrix" {ledmatrix} {ledmatrix}
+ {vhw_LED_matrix} "LED Matrix"}
+ {mleddisplay} { "Multiplexed LED Display" {mleddisplay} {mleddisplay}
+ {vhw_M_LED_display} "Multiplexed LED Display"}
+ {simplekeypad} { "Simple Keypad" {simplekeypad} {simplekeypad}
+ {vhw_keys} "Simple Keypad"}
+ {matrixkeypad} { "Matrix Keypad" {matrixkeypad} {matrixkeypad}
+ {vhw_matrix_keypad} "Matrix Keypad"}
+ {hd44780} { "LCD display (HD44780)" {hd44780} {hd44780}
+ {vhw_HD44780} "LCD display controlled by HD44780"}
+ {ds1620} { "DS1620 thermometer" {ds1620} {ds1620}
+ {vhw_ds1620} "Simulated DS1620 temperature sensor"}
+ {fintr} { "File Interface" {compfile1} {compfile1}
+ {vhw_file_interface} "Read & Write GPIO states from/to a file"}
+ {vhw_open} { "VHW Open" {fileopen} {fileopen}
{open_VHW} "Load VHW connections from a file"}
- {vhw_load} { "VHW Load" {fileimport} {fileimport}
+ {vhw_load} { "VHW Load" {fileimport} {fileimport}
{load_VHW} "Import VHW connections from a file"}
- {vhw_save} { "VHW Save" {filesave} {filesave}
+ {vhw_save} { "VHW Save" {filesave} {filesave}
{save_VHW} "Save current VHW connections to a file"}
- {vhw_saveas} { "VHW Save as" {filesaveas} {filesaveas}
+ {vhw_saveas} { "VHW Save as" {filesaveas} {filesaveas}
{save_as_VHW} "Save current VHW connections under a different name"}
- {vhw_remove_all} { "VHW Remove all" {editdelete} {editdelete}
+ {vhw_remove_all} { "VHW Remove all" {editdelete} {editdelete}
{remove_all_VHW} "Remove all VHW"}
- {bc} { "Base Convertor" {kaboodleloop} {kaboodleloop}
- {base_convertor} "Base Convertor"}
- {fullscreen} { "Toggle fullscreen mode" {window_fullscreen} {window_fullscreen}
- {toggle_fullscreen} "Fullscreen mode"}
- {spec_calc} { "Special calculator" {xcalc} {xcalc}
- {spec_calc} "Special calculator"}
- {stack} { "Show stack" {memory_ST} {kcmmemory_ST}
- {stack_monitor} "Invoke MCU stack monitor"}
- {rs232} { "UART/RS232 Debugger" {_chardevice} {chardevice}
+ {bc} { "Base Converter" {kaboodleloop} {kaboodleloop}
+ {base_converter} "Base Converter"}
+ {fullscreen} { "Toggle full screen mode" {window_fullscreen} {window_fullscreen}
+ {toggle_fullscreen} "Full screen mode"}
+ {spec_calc} { "Special Calculator" {xcalc} {xcalc}
+ {spec_calc} "Special Calculator"}
+ {rs232} { "UART/RS232 Debugger" {_chardevice} {chardevice}
{rs232debugger} "UART/RS232 Debugger"}
}
+# Intentionally hidden functions, these haven't been fully implemented yet
+# {uartmon} { "UART monitor" {__blockdevice} {__blockdevice}
+# {uart_monitor} "Dialog in which you can control UART operations"}
+# {d52} { "Disassemble with D52" {d52} {d52}
+# {d52} "Disassemble object code using D52 disassembler"}
+# {vuterm} { "Virtual UART terminal" {chardevice} {_chardevice}
+# {vhw_UART_terminal} "Simulated UART terminal connected to the MCU simulator"}
## Definition of default main icon bar
# format: {
# item_ID item_ID ...
# }
set ICONBAR_DEFAULT {
- new open | save save_as save_all | close exit | fullscreen |
- project_new project_open | find goto | hibernate resume |
- custom0 custom1 | leddisplay matrixkeypad | notes | assemble |
- start_sim step stepback
+ new open | save save_as save_all
+ | close exit | fullscreen | project_new project_open
+ | find goto | hibernate resume | custom0
+ custom1 | leddisplay matrixkeypad | notes | assemble
+ | start_sim step stepback
}
## Definition of icons current main icon bar
@@ -2731,7 +3007,7 @@ set ICONBAR_DEFAULT {
# }
set ICONBAR_CURRENT {}
-## (Re)draw icon bar acording to $ICONBAR_CURRENT
+## (Re)draw icon bar according to $ICONBAR_CURRENT
# @return void
proc iconbar_redraw {} {
::toolbar::iconbar_redraw
@@ -2793,12 +3069,13 @@ namespace eval toolbar {
if {[regexp {^custom\d+$} $key]} {
regexp {\d+} $key num
setStatusTip -widget $button -text [mc "Custom command %s: %s" $num $::X::custom_command_desc($num)]
+ ::DynamicHelp::add $button -text [mc "Custom command %s: %s" $num $::X::custom_command_desc($num)]
bind $button <ButtonRelease-3> [subst {
- set CUTOM_CMD_MENU_CMD_INDEX $num
- tk_popup $::TOOLBAR_FRAME.cutom_cmd_menu %X %Y
+ set CUSTOM_CMD_MENU_CMD_INDEX $num
+ tk_popup $::TOOLBAR_FRAME.custom_cmd_menu %X %Y
}]
# For normal commands
- } {
+ } else {
setStatusTip -widget $button -text [mc [lindex $def 4]]
bind $button <ButtonRelease-3> {tk_popup $::TOOLBAR_FRAME.menu %X %Y}
}
@@ -2820,7 +3097,7 @@ namespace eval toolbar {
}
}
-## Show/Hide main toolbar acording to value of config variable TOOLBAR_VISIBLE
+## Show/Hide main toolbar according to value of config variable TOOLBAR_VISIBLE
# @return void
proc show_hide_main_toolbar {} {
# Show the toolbar
@@ -2833,7 +3110,7 @@ proc show_hide_main_toolbar {} {
pack forget $::TOOLBAR_FRAME.show_label
}
# Hide the toolbar
- } {
+ } else {
catch {
${::X::actualProject} bottomNB_move_pane_up -11
}
@@ -2874,7 +3151,7 @@ menuFactory {
{command {Clear} {} 1 "GPM_entry_clear" {editdelete} {}}
{separator}
{command {Select all} {Ctrl+A} 0 "GPM_entry_selall" {} {}}
-} .gpm_entry_menu 0 {} 0 {}
+} .gpm_entry_menu 0 {} 0 {} [namespace current]
# Menu for text widgets
menuFactory {
{command {Undo} {Ctrl+Z} 0 "GPM_text_undo" {undo} {}}
@@ -2886,7 +3163,7 @@ menuFactory {
{command {Clear} {} 1 "GPM_text_clear" {editdelete} {}}
{separator}
{command {Select all} {Ctrl+A} 0 "GPM_text_selall" {} {}}
-} .gpm_text_menu 0 {} 0 {}
+} .gpm_text_menu 0 {} 0 {} [namespace current]
# Widget identifiers
set GPM_entry_widget {} ;# Entry widget
@@ -2921,7 +3198,7 @@ proc GPM_entry_key_menu {Widget} {
[expr {[winfo rooty $Widget] + [lindex $bbox 1] + 10}]
}
-## Enable/Disable popup menu items acording to state of the widget
+## Enable/Disable popup menu items according to state of the widget
# For entry widgets. Auxiliary procedure for 'GPM_entry_popup' and 'GPM_entry_key_menu'
# @return void
proc GPM_entry_menu_disena {} {
@@ -2936,7 +3213,7 @@ proc GPM_entry_menu_disena {} {
.gpm_entry_menu entryconfigure [::mc "Cut"] -state normal
}
.gpm_entry_menu entryconfigure [::mc "Copy"] -state normal
- } {
+ } else {
.gpm_entry_menu entryconfigure [::mc "Cut"] -state disabled
.gpm_entry_menu entryconfigure [::mc "Copy"] -state disabled
}
@@ -2974,7 +3251,7 @@ proc GPM_text_key_menu {Widget} {
[expr {[winfo rooty $Widget] + [lindex $bbox 1] + 10}]
}
-## Enable/Disable popup menu items acording to state of the widget
+## Enable/Disable popup menu items according to state of the widget
# For text widgets. Auxiliary procedure for 'GPM_text_popup' and 'GPM_text_key_menu'
# @return void
proc GPM_text_menu_disena {} {
@@ -3152,13 +3429,15 @@ proc GPM_text_selall {} {
}
}
-# FINALIZE BASIC ENVIROMENT INITIALIZATION
+# FINALIZE BASIC ENVIRONMENT INITIALIZATION
# -----------------------------------------
show_hide_main_toolbar ;# Show/Hide Main toolbar
pack [frame .mainFrame] -fill both -expand 1 ;# Frame for central widget
+::Editor::refresh_available_dictionaries ;# Refresh list of available spell checker dictionaries
makeStatusbar {} ;# Create status bar
+::Editor::adjust_spell_checker_config_button ;# Adjust spell checker configuration button to current spell checker configuration
change_validation_level $::CONFIG(VALIDATION_LEVEL) ;# Restore previous validation level
-::X::initialize ;# Intialize X NS
+::X::initialize ;# Initialize X NS
::KIFSD::FSD::load_config_array $::CONFIG(KIFSD_CONFIG) ;# Restore configuration of file selection dialog
::HexEditDlg::loadConfig $::CONFIG(HEXEDIT_CONFIG) ;# Restore hexaeditor configuration
::KIFSD::FSD::set_bookmark_change_command {::X::refresh_bookmarks_in_fs_browsers}
@@ -3169,16 +3448,22 @@ if {$show_welcome_dialog} {
set X::critical_procedure_in_progress 0
X::__welcome_dialog
set X::critical_procedure_in_progress 1
-} elseif {${GLOBAL_CONFIG(tips)}} {
+} elseif {${::GLOBAL_CONFIG(tips)}} {
X::__tip_of_the_day
}
# Create project notebook
# -----------------------------------------
-NoteBook .mainFrame.mainNB -side top -arcradius 4 -bd 1 -bg {#EEEEEE}
+set ::main_nb [ModernNoteBook .mainFrame.mainNB -autohide 1]
# Project details window
-.mainFrame.mainNB bindtabs <Enter> {::X::create_project_details}
-.mainFrame.mainNB bindtabs <Motion> {::X::project_details_move}
-.mainFrame.mainNB bindtabs <Leave> {::X::close_project_details}
-.mainFrame.mainNB bindtabs <ButtonRelease-3> {::X::invoke_project_menu %X %Y}
+${::main_nb} bindtabs <Enter> {::X::create_project_details}
+${::main_nb} bindtabs <Motion> {::X::project_details_move}
+${::main_nb} bindtabs <Leave> {::X::close_project_details}
+${::main_nb} bindtabs <ButtonRelease-3> {::X::invoke_project_menu %X %Y}
+
+bind Menu <Map> ::X::remove_all_help_windows
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/external_command.tcl b/lib/external_command.tcl
index 959cd29..552a73a 100755..100644
--- a/lib/external_command.tcl
+++ b/lib/external_command.tcl
@@ -1,8 +1,11 @@
-#!/usr/bin/tclsh
+#!/bin/sh
+# the next line restarts using wish \
+exec tclsh "$0" "$@"
+
# 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 +24,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _EXTERNAL_COMMAND_TCL ] } {
+set _EXTERNAL_COMMAND_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Send input read from strandard input to certain Tk application via
@@ -36,12 +44,13 @@
# --------------------------------------------------------------------------
# Initialize
+encoding system {utf-8}
package require Tk
wm withdraw .
wm command . "$argv0 $argv"
wm client . [info hostname]
-# Partse agruments
+# Parse agruments
set target_app [lindex $argv 0]
set final_cmd [lindex $argv 1]
set line_cmd [lindex $argv 2]
@@ -69,39 +78,8 @@ if {$::MICROSOFT_WINDOWS} {
proc secure_send args {
if {[catch {
eval "send $args"
- } result]} {
- puts "Unknown IO Error :: $result"
- tk_messageBox \
- -title "Unknown IO Error" \
- -icon error \
- -type ok \
- -message "$result"
-
- if {[ \
- tk_messageBox \
- -title "X server security workaround" \
- -icon warning \
- -type yesno \
- -message "If the error was related to X server security, it is possible to temporarily workaround it by running this command: \"/bin/sh << 'for i in `xhost`; do xhost -\$i; done'\"\n\nDo you want to do it ?"
- ] == {yes}} then {
- catch {
- exec -- /bin/sh << {xhost -; for i in `xhost`; do xhost -$i; done}
- }
- } else {
- exit 1
- }
-
- if {[catch {
- eval "send $args"
- }]} {
- tk_messageBox \
- -title "Workaround failed" \
- -icon error \
- -type ok \
- -message "Sorry this doesn't work ...\nIt's a strange bug somewhere in your operating system"
- exit 1
- }
-
+ } result]} then {
+ puts stderr "Unknown IO Error :: $result"
return 1
} else {
@@ -119,7 +97,7 @@ if {$line_cmd == {}} {
if {!${::MICROSOFT_WINDOWS}} {
secure_send $target_app $final_cmd "{" [regsub -all {[\{\}]} $result {\\&}] "}"
- } {
+ } else {
dde eval $target_app $final_cmd "{ [regsub -all {[\{\}]} $result {\\&}] }"
}
@@ -128,16 +106,20 @@ if {$line_cmd == {}} {
while {![eof stdin]} {
if {!${::MICROSOFT_WINDOWS}} {
secure_send $target_app $line_cmd "{" [regsub -all {[\{\}]} [gets stdin] {\\&}] "}"
- } {
+ } else {
dde eval $target_app $line_cmd "{ [regsub -all {[\{\}]} [gets stdin] {\\&}] }"
}
}
if {!${::MICROSOFT_WINDOWS}} {
secure_send $target_app $final_cmd
- } {
+ } else {
dde eval $target_app $final_cmd
}
}
exit 0
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/leftpanel/filelist.tcl b/lib/leftpanel/filelist.tcl
index c5f5c14..4c65e36 100755..100644
--- a/lib/leftpanel/filelist.tcl
+++ b/lib/leftpanel/filelist.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,12 +21,17 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _FILELIST_TCL ] } {
+set _FILELIST_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides:
# - List of opened files
# - List of project files
-# - Filesystem browser
+# - File system browser
# - Management of opened files, project files and code editors
# --------------------------------------------------------------------------
@@ -42,7 +47,7 @@ class FileList {
# String: Textvariable for dialog "Open with ..."
common open_with ${::CONFIG(OPEN_WITH_DLG)}
common open_with_cnfr 0 ;# Bool: Confirm dialog "Open with ..."
- common count 0 ;# Instances counter
+ common fl_lst_count 0 ;# Instances counter
common file_indexes {} ;# List of line indexes (auxiliary variable for opening multiple files)
common ac_index_in_fl ;# Index of actual editor filelist
common default_encoding {utf-8} ;# Default encoding
@@ -55,7 +60,7 @@ class FileList {
}
# Font for opened file in project files list
common opened_file_font [font create \
- -weight bold \
+ -weight normal \
-slant roman \
-size -12 \
-family $::DEFAULT_FIXED_FONT \
@@ -69,6 +74,8 @@ class FileList {
]
# Font for icon borders
common icon_border_font [font create \
+ -weight normal \
+ -slant roman \
-size -12 \
-family $::DEFAULT_FIXED_FONT \
]
@@ -115,12 +122,12 @@ class FileList {
{command {Move to bottom} {} 12 "filelist_move_bottom" {bottom}
"Move this file to the bottom of the list"}
{separator}
- {cascade "Sort items by" 11 "" .sort_by false 1 {
+ {cascade "Sort items by" 11 "sort_incr" .sort_by false 1 {
{command {Document Name} {} 9 "sort_file_list N 1" {} {}}
{command {File URL} {} 5 "sort_file_list U 1" {} {}}
{command {File Size in B} {} 5 "sort_file_list S 1" {} {}}
}}
- {cascade "Open with" 6 "" .open_with false 1 {
+ {cascade "Open with" 6 "fileopen" .open_with false 1 {
{command {gvim} {} 1 "filelist_open_with 1 gvim" {gvim} {}}
{command {emacs} {} 1 "filelist_open_with 1 emacs" {emacs} {}}
{command {kwrite} {} 0 "filelist_open_with 1 kwrite" {kwrite} {}}
@@ -211,7 +218,7 @@ class FileList {
}
## PUBLIC
- public variable actualEditor ;# Object number of currently selected editor
+ public variable actualEditor 0 ;# Object number of currently selected editor
public variable actualEditor2 -2 ;# Object number of currently selected editor in the second view
public variable ProjectDir ;# Reference to directory of actual project
public variable editors {} ;# list of editor objects
@@ -284,9 +291,11 @@ class FileList {
private variable PanelVisible $::CONFIG(LEFT_PANEL) ;# Bool: panel visible
private variable PanelSize $::CONFIG(LEFT_PANEL_SIZE) ;# Panel width (in pixels)
- private variable editor_to_freeze_obj ;# Object: Editor to freeze after simulator startup
+ private variable editor_to_freeze_obj ;# Object: Editor to freeze after simulator start-up
private variable filetabs_frm ;# Widget: Frame contaning the tab bar
private variable filetabs_nb ;# Widget: Tab bar's notebook widget
+ private variable switchfile_in_progress 0 ;# Bool: Method switchfile is in progress
+ private variable last_selected_item {} ;# String: ID of the last selected opened file
## PROTECTED
protected variable file_count 0 ;# counter of opened files
@@ -300,8 +309,8 @@ class FileList {
## object constructor
constructor {} {
# increment instance counter
- incr count
- set obj_idx $count
+ incr fl_lst_count
+ set obj_idx $fl_lst_count
}
## Object destructor
@@ -322,7 +331,7 @@ class FileList {
# @parm List filelist - List of files to open (full filenames including path)
# @parm Bool editor_sw_lock - Enable aoutomatic file switching during simulation
# @return void
- public method initiate_FileList {parentPane projectDir FileList editor_sw_lock} {
+ public method initalize_FileList {parentPane projectDir FileList editor_sw_lock} {
# Object variables
set parent $parentPane ;# ID of parent container widget
@@ -335,36 +344,34 @@ class FileList {
# Create notebook frame
set leftPanel [frame $parentPane.frm_FileList_leftPanel]
# Create notebook
- set notebook [NoteBook $leftPanel.nb_FileList \
- -side top -arcradius 4 -bg {#EEEEEE} \
- ]
+ set notebook [ModernNoteBook $leftPanel.nb_FileList]
# Create tab "Hide"
$notebook insert end "button_SH" -image ::ICONS::16::2leftarrow \
- -raisecmd "$this filelist_show_hide" \
+ -raisecmd [list $this filelist_show_hide] \
-helptext [mc "Hide this panel"]
# Create tab for list of opened files
set listbox_opened_files_frame [$notebook insert end "opened_files" \
-image ::ICONS::16::fileopen \
- -raisecmd "$this Left_panel_set_active_page opened_files" \
+ -raisecmd [list $this Left_panel_set_active_page opened_files] \
-helptext [mc "Opened files"] \
]
# Create tab for list of project files
set listbox_project_files_frame [$notebook insert end "project_files" \
-image ::ICONS::16::project_open \
- -raisecmd "$this Left_panel_set_active_page project_files" \
+ -raisecmd [list $this Left_panel_set_active_page project_files] \
-helptext [mc "Files in the project"] \
]
# Create tab for file system browser
set fs_browser_frame [$notebook insert end "fs_browser" \
-image ::ICONS::16::exec \
- -raisecmd "$this Left_panel_set_active_page fs_browser" \
- -helptext [mc "Filesystem browser"] \
+ -raisecmd [list $this Left_panel_set_active_page fs_browser] \
+ -helptext [mc "File system browser"] \
-createcmd [list $this CreateFSBrowserGUI] \
]
# Create tab for SFR watches
set sfr_watches_frame [$notebook insert end "sfr_watches" \
-image ::ICONS::16::kcmmemory \
- -raisecmd "$this Left_panel_set_active_page sfr_watches" \
+ -raisecmd [list $this Left_panel_set_active_page sfr_watches] \
-helptext [mc "List of SFR's"] \
-createcmd [list $this CreateSFRWatchesGUI] \
]
@@ -377,9 +384,9 @@ class FileList {
# Register notebook status bar tips
notebook_Sbar_set {filelist} [list \
button_SH [mc "Hide the panel"] \
- opened_files [mc "Opended files"] \
+ opened_files [mc "Opened files"] \
project_files [mc "Files of the current project"] \
- fs_browser [mc "Filesystem browser"] \
+ fs_browser [mc "File system browser"] \
sfr_watches [mc "Special Function Registers"] \
]
$notebook bindtabs <Enter> "notebook_Sbar filelist"
@@ -389,7 +396,6 @@ class FileList {
set lsbox_frame [frame $listbox_opened_files_frame.lsbox_frame]
set listbox_opened_files_bm [text $lsbox_frame.icon_border \
-font $icon_border_font \
- -cursor left_ptr \
-width 2 \
-bd 0 \
-pady 1 \
@@ -397,17 +403,23 @@ class FileList {
-bg {#DDDDDD} \
-exportselection 0 \
-takefocus 0 \
- -cursor hand1 \
+ -cursor hand2 \
]
$listbox_opened_files_bm tag configure center -justify center
$listbox_opened_files_bm delete 1.0 end
setStatusTip -widget $listbox_opened_files_bm \
-text [mc "Bookmarks for opened files"]
set listbox_opened_files [ListBox $lsbox_frame.listbox_opened_files \
- -selectmode single -selectfill 0 -bg white \
- -selectbackground white -highlightcolor {#BBBBFF} \
- -selectforeground {#0000FF} -bd 1 \
- -highlightthickness 0 -deltay 15 -padx 14 \
+ -selectmode single \
+ -selectfill 0 \
+ -bg {#FFFFFF} \
+ -selectbackground {#FFFFFF} \
+ -highlightcolor {#BBBBFF} \
+ -selectforeground {#0000FF} \
+ -bd 1 \
+ -highlightthickness 0 \
+ -deltay 15 \
+ -padx 14 \
-yscrollcommand "$this filelist_o_scrollbar_set" \
]
setStatusTip -widget $listbox_opened_files \
@@ -420,7 +432,7 @@ class FileList {
# Create popup menu for icon border
set IB_o_menu $listbox_opened_files_bm.ib_o_menu
- menuFactory $OPENEDFILESIBMENU $IB_o_menu 0 "$this " 0 {}
+ menuFactory $OPENEDFILESIBMENU $IB_o_menu 0 "$this " 0 {} [namespace current]
# Create bottom frame
set listbox_opened_files_bottom_frame [frame $listbox_opened_files_frame.bottom_frame]
@@ -474,6 +486,9 @@ class FileList {
# Frame for opened files
set listbox_opened_files_top_frame [frame \
$listbox_opened_files_frame.listbox_opened_files_top_frame]
+ pack [label $listbox_opened_files_top_frame.listbox_opened_files_label \
+ -text [mc "Opened Files:"] -anchor w \
+ ] -fill x -side top -anchor w -pady 5
# Button box for "Opened files"
set opened_files_buttonBox [frame \
$listbox_opened_files_top_frame.opened_files_buttonBox]
@@ -481,22 +496,18 @@ class FileList {
set main_frame [frame $parentPane.main_frame]
# Create filetabs notebook
- set filetabs_frm [frame $main_frame.filetabs_frm -height 16]
+ set filetabs_frm [frame $main_frame.filetabs_frm]
pack [ttk::button $filetabs_frm.add_button \
-image ::ICONS::16::filenew \
-command {::X::__new} \
-style Flat.TButton \
- ] -side left
- set filetabs_nb [NoteBook $filetabs_frm.filetabs_nb \
- -side top -arcradius 4 -bg {#EEEEEE} \
- -font [font create -family {Helvetica} -size -12] \
- ]
- pack configure $filetabs_nb.c -fill x -expand 0
- pack $filetabs_nb -fill x -anchor sw -side left -expand 1
- $filetabs_nb bindtabs <Enter> "$this file_details_win_create_from_ftnb"
- $filetabs_nb bindtabs <Leave> "$this file_details_win_hide"
- $filetabs_nb bindtabs <Motion> "$this file_details_win_move"
- $filetabs_nb bindtabs <ButtonRelease-3> "$this filetabs_nb_popup_menu %X %Y"
+ ] -side left
+ set filetabs_nb [ModernNoteBook $filetabs_frm.filetabs_nb -nomanager 1]
+ pack [$filetabs_nb get_nb] -fill x -anchor sw -side left -expand 1
+ $filetabs_nb bindtabs <Enter> [list $this file_details_win_create_from_ftnb]
+ $filetabs_nb bindtabs <Leave> [list $this file_details_win_hide]
+ $filetabs_nb bindtabs <Motion> [list $this file_details_win_move]
+ $filetabs_nb bindtabs <ButtonRelease-3> [list $this filetabs_nb_popup_menu %X %Y]
pack [ttk::button $filetabs_frm.close_button \
-image ::ICONS::16::fileclose \
-command {::X::__close} \
@@ -527,7 +538,7 @@ class FileList {
"Move selected file to the top of the list"}
{bottom "Move item to bottom" {bottom} {filelist_move_bottom}
"Move selected file to the bottom of the list"}
- }
+ } [namespace current]
# Pack GUI components of tab "Opened files"
pack $opened_files_buttonBox -side left
@@ -543,7 +554,6 @@ class FileList {
set ls_frame [frame $listbox_project_files_frame.ls_frame]
set listbox_project_files_bm [text $ls_frame.icon_border \
-font $icon_border_font \
- -cursor left_ptr \
-width 2 \
-bd 0 \
-pady 1 \
@@ -551,16 +561,22 @@ class FileList {
-bg {#DDDDDD} \
-exportselection 0 \
-takefocus 0 \
- -cursor hand1 \
+ -cursor hand2 \
]
$listbox_project_files_bm delete 1.0 end
$listbox_project_files_bm tag configure center -justify center
setStatusTip -widget $listbox_project_files_bm \
-text [mc "Bookmarks for project files"]
set listbox_project_files [ListBox $ls_frame.listbox_project_files \
- -selectmode single -highlightthickness 0 -bd 1 -padx 0 \
- -selectbackground white -bg white -deltay 15 \
- -selectforeground {#0000FF} -highlightcolor {#BBBBFF} \
+ -selectmode single \
+ -highlightthickness 0 \
+ -bd 1 \
+ -padx 0 \
+ -selectbackground {#FFFFFF} \
+ -bg {#FFFFFF} \
+ -deltay 15 \
+ -selectforeground {#0000FF} \
+ -highlightcolor {#BBBBFF} \
-yscrollcommand "$this filelist_p_scrollbar_set" \
]
setStatusTip -widget $listbox_project_files \
@@ -573,7 +589,7 @@ class FileList {
# Create popup menu for icon border
set IB_p_menu $listbox_project_files.ib_o_menu
- menuFactory $PROJECTFILESIBMENU $IB_p_menu 0 "$this " 0 {}
+ menuFactory $PROJECTFILESIBMENU $IB_p_menu 0 "$this " 0 {} [namespace current]
# Create search panel
set search_panel [frame $listbox_project_files_frame.search_panel]
@@ -584,7 +600,7 @@ class FileList {
]
DynamicHelp::add $project_search_entry -text [mc "Search for file"]
setStatusTip -widget $project_search_entry \
- -text [mc "Search for certain file name in list of project files"]
+ -text [mc "Search for certain file name in list of project files"]
pack $project_search_entry -side left -fill x -expand 1
set project_search_clear_button [ttk::button \
$search_panel.clear_button \
@@ -602,7 +618,7 @@ class FileList {
# Create header (label and icon bar) for tab "Project files"
set topFrame [frame $listbox_project_files_frame.listbox_project_files_top_frame]
pack [label $topFrame.listbox_project_files_label \
- -text [mc "Project files:"] -anchor w \
+ -text [mc "Project Files:"] -anchor w \
] -fill x -side top -anchor w -pady 5
set project_files_buttonBox [frame $topFrame.listbox_project_files_buttonBox]
pack $project_files_buttonBox -side bottom -anchor w -expand 0
@@ -624,7 +640,7 @@ class FileList {
{remove "Remove this file from the project" {editdelete}
{filelist_remove_file_from_project}
"Exclude this file from list of files of this project"}
- }
+ } [namespace current]
# Evaluate icon bars button states (tab "Project files")
FileList_project_disEna_buttons
@@ -668,15 +684,15 @@ class FileList {
DynamicHelp::add $button_bar.but_proj_open -text [mc "Files in the current project"]
setStatusTip -widget $button_bar.but_proj_open \
-text [mc "Files of the current project"]
- # Button "Filesystem browser"
+ # Button "File system browser"
pack [ttk::button $button_bar.but_fs_browser \
-image ::ICONS::16::exec \
-style ToolButton.TButton \
-command "$this filelist_show_up fs_browser" \
]
- DynamicHelp::add $button_bar.but_fs_browser -text [mc "Filesystem browser"]
+ DynamicHelp::add $button_bar.but_fs_browser -text [mc "File system browser"]
setStatusTip -widget $button_bar.but_fs_browser \
- -text [mc "Filesystem browser"]
+ -text [mc "File system browser"]
# Button "SFR watches"
pack [ttk::button $button_bar.but_sfr_watches \
-image ::ICONS::16::kcmmemory \
@@ -689,13 +705,13 @@ class FileList {
# Show the left panel
if {$PanelVisible != 0} {
- pack $notebook -expand 1 -fill both
+ pack [$notebook get_nb] -expand 1 -fill both -padx 5 -pady 5
# Raise active page in the panel notebook
catch {
$notebook raise $active_page
}
- } {
+ } else {
set last_sash $PanelSize
pack $button_bar -side top -anchor nw
}
@@ -741,7 +757,7 @@ class FileList {
# Create popup menus
set opened_files_menu $listbox_opened_files.opened_files_menu
set project_files_menu $listbox_project_files.project_files_menu
- set filetabs_pu_menu $filetabs_nb.filetabs_pu_menu
+ set filetabs_pu_menu [$filetabs_nb get_nb].filetabs_pu_menu
filelist_makePopupMenu
# Create Editor object for each file in $filelist and insert it into ListBox of opened files
@@ -786,7 +802,7 @@ class FileList {
$actualEditor < [llength $editors]
&&
$actualEditor >= 0
- } { ;# Valid value
+ } then { ;# Valid value
$listbox_opened_files selection set [lindex [$listbox_opened_files items] $actualEditor]
set actualEditor -1
switchfile
@@ -795,7 +811,7 @@ class FileList {
set actualEditor -1
if {![llength $editors]} {
editor_new
- } {
+ } else {
$listbox_opened_files selection set [lindex [$listbox_opened_files items] 0]
switchfile
}
@@ -822,20 +838,20 @@ class FileList {
if {$pwin_orient == {vertical}} {
if {!$multiview_sash_pos} {
- set multiview_sash_pos [expr {[winfo width $pagesManager] / 2}]
- }
- set minsize 300
- } {
- if {!$multiview_sash_pos} {
set multiview_sash_pos [expr {[winfo height $pagesManager] / 2}]
}
set minsize 80
+ } else {
+ if {!$multiview_sash_pos} {
+ set multiview_sash_pos [expr {[winfo width $pagesManager] / 2}]
+ }
+ set minsize 300
}
$multiview_paned_win paneconfigure $pagesManager -minsize $minsize
$multiview_paned_win paneconfigure $pagesManager2 -minsize $minsize
pack [[lindex $editors $actualEditor2] cget -ed_sc_frame] \
-in $pagesManager2 -fill both -expand 1
- } {
+ } else {
pack $pagesManager -fill both -expand 1
}
foreach editor $editors {
@@ -843,12 +859,12 @@ class FileList {
}
# Set panel width
- update idle
+ update idletasks
if {$PanelVisible != 0} {
$parent paneconfigure $leftPanel -minsize 155
$parent configure -sashwidth 2
$parent sash place 0 $PanelSize 0
- } {
+ } else {
$parent paneconfigure $leftPanel -minsize 0
$parent configure -sashwidth 0
$parent sash place 0 25 2
@@ -858,10 +874,10 @@ class FileList {
# Update multiview sash position
if {$splitted} {
- update idle
+ update idletasks
if {$pwin_orient == {vertical}} {
$multiview_paned_win sash place 0 0 $multiview_sash_pos
- } {
+ } else {
$multiview_paned_win sash place 0 $multiview_sash_pos 0
}
}
@@ -890,7 +906,7 @@ class FileList {
set eol [lindex $file_eol $index]
set read_only [lindex $file_ro_mode $index]
regexp -line -- {^.*$} [$this get_file_notes_data $index] note
- } {
+ } else {
if {![$listbox_project_files exists $item]} {
return
}
@@ -901,7 +917,7 @@ class FileList {
set eol [lindex $data 1]
set encoding [lindex $data 2]
set read_only [lindex $data 3]
- } {
+ } else {
set filename "[lindex $data 5][lindex $data 0]"
set eol [lindex $data 8]
set encoding [lindex $data 9]
@@ -919,7 +935,6 @@ class FileList {
# Create window
set ::FILEDETAILSWIN [frame .file_details_win -bg {#AADDFF}]
set file_details_win [frame ${::FILEDETAILSWIN}.frm -bg {#FFFFFF}]
- bind ${::FILEDETAILSWIN} <Button-1> "catch {destroy ${::FILEDETAILSWIN}}"
# Determinate file type and set appropriate icon
set ext [string trimleft [file extension $filename] {.}]
@@ -987,7 +1002,7 @@ class FileList {
}
if {$size < 1024} {
append size { B}
- } {
+ } else {
set kB [expr {$size / 1024}]
set B [expr {$size % 1024}]
set MB [expr {$kB / 1024}]
@@ -1021,8 +1036,12 @@ class FileList {
-fg {#0000AA} \
-anchor w -bg {#FFFFFF} \
] -row 0 -column 0 -sticky w -pady 0
+ set path [file dirname $filename]
+ if {$::MICROSOFT_WINDOWS} {
+ regsub -all {/} $path "\\" path
+ }
grid [label $main_frame.path_value \
- -text [file dirname $filename] \
+ -text $path \
-anchor w -bg {#FFFFFF} \
] -row 0 -column 1 -sticky w -pady 0
@@ -1116,6 +1135,17 @@ class FileList {
] -row 9 -column 0 -sticky w -pady 0 -columnspan 2
}
+ # Configure the window in a way that it will close when the user clicks on it
+ foreach w [concat $file_details_win \
+ $main_frame \
+ [pack slaves $file_details_win] \
+ [pack slaves $header] \
+ [grid slaves $main_frame] \
+ ] \
+ {
+ bind $w <Button-1> [list $this file_details_win_hide]
+ }
+
# Pack main frame
grid columnconfigure $main_frame 0 -minsize 90
pack $main_frame -fill both -expand 1 -padx 8 -pady 3
@@ -1167,14 +1197,14 @@ class FileList {
destroy $filetabs_pu_menu
}
- menuFactory $PROJECTFILESMENU $project_files_menu 0 "$this " 0 {}
- menuFactory $OPENEDFILESMENU $opened_files_menu 0 "$this " 0 {}
- menuFactory $FILETABSPUMENU $filetabs_pu_menu 0 "$this " 0 {}
+ menuFactory $PROJECTFILESMENU $project_files_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $OPENEDFILESMENU $opened_files_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $FILETABSPUMENU $filetabs_pu_menu 0 "$this " 0 {} [namespace current]
foreach program {gvim emacs kwrite gedit} \
program_name {gvim emacs kwrite gedit} \
{
- if {!$::PROGRAM_AVALIABLE($program)} {
+ if {!$::PROGRAM_AVAILABLE($program)} {
foreach menu [list $project_files_menu $opened_files_menu $filetabs_pu_menu] {
${menu}.open_with entryconfigure [::mc $program_name] -state disabled
}
@@ -1192,14 +1222,21 @@ class FileList {
}
## Reload the current file
+ # @parm Object target_editor - Editor object where the reload is supposed to take place
+ # @parm Bool force - Don't ask whether the file should be saved first, in case it was modified
# @return Bool - result
- public method filelist_reload_file {} {
- if {$splitted && $selectedView} {
- set editor_idx $actualEditor2
- } {
- set editor_idx $actualEditor
+ public method filelist_reload_file {{target_editor {}} {force 0}} {
+ if {$target_editor == {}} {
+ if {$splitted && $selectedView} {
+ set editor_idx $actualEditor2
+ } else {
+ set editor_idx $actualEditor
+ }
+ set editor [lindex $editors $editor_idx]
+ } else {
+ set editor_idx [lsearch -ascii -exact $editors $target_editor]
+ set editor $target_editor
}
- set editor [lindex $editors $editor_idx]
# Local variables
set fullFileName [$editor cget -fullFileName] ;# Full filename
@@ -1209,7 +1246,7 @@ class FileList {
![file exists $fullFileName] ||
[file isdirectory $fullFileName] ||
(!$::MICROSOFT_WINDOWS && ![file readable $fullFileName])
- } {
+ } then {
tk_messageBox \
-title [mc "File not found"] \
-icon error \
@@ -1221,7 +1258,7 @@ class FileList {
if {$fullFileName != {}} {
# Prompt user is the file was modified
- if {[$editor cget -modified] != 0} {
+ if {!$force && ([$editor cget -modified] != 0)} {
set response [tk_messageBox \
-title [mc "Are you sure ?"] \
-icon question \
@@ -1254,9 +1291,11 @@ class FileList {
fconfigure $file -encoding $enc
set data {}
if {[regsub -all {[\u0000-\u0008\u000B-\u000C\u000E-\u001F\u007F-\u009F]} [read $file] {} data]} {
- tk_messageBox -parent . \
- -type ok -icon warning \
- -title [mc "Binary File Opened - MCU 8015 IDE"] \
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -icon warning \
+ -title [mc "Binary File Opened - MCU 8015 IDE"] \
-message [mc "The file %s is binary, saving it will result corrupted file." $fullFileName]
}
[$editor cget -editor] insert end [regsub -all {\r\n?} $data "\n"]
@@ -1376,13 +1415,17 @@ class FileList {
$this todo_switch_editor $ac
if {${::ASMsyntaxHighlight::validation_L1}} {
[lindex $editors $actualEditor] parse_current_line
- } {
+ } else {
[lindex $editors $actualEditor] adjust_instruction_details
}
set file_indexes {}
}
+ public method is_splitted {} {
+ return $splitted
+ }
+
## Switch from Normal mode to Simulator mode
# @return void
public method freeze {} {
@@ -1393,7 +1436,7 @@ class FileList {
# Freeze editor
if {$splitted && $selectedView} {
set editor_to_freeze $actualEditor2
- } {
+ } else {
set editor_to_freeze $actualEditor
}
set idx 0
@@ -1401,7 +1444,7 @@ class FileList {
if {$idx == $editor_to_freeze} {
$editor freeze
set editor_to_freeze_obj $editor
- } {
+ } else {
$editor disable
}
incr idx
@@ -1414,7 +1457,7 @@ class FileList {
$project_files_menu entryconfigure [::mc "Close file"] -state disabled
}
- ## This method should be called immediately after simulator startup
+ ## This method should be called immediately after simulator start-up
#+ in order to inform editors about the change
# @return void
public method now_frozen {} {
@@ -1446,13 +1489,21 @@ class FileList {
$project_files_menu entryconfigure [::mc "Close file"] -state normal
if {$simulator_editor_obj != {}} {
- $listbox_opened_files itemconfigure [lindex \
- $file_descriptors [lsearch -ascii -exact \
- $editors $simulator_editor_obj \
- ] \
- ] -fg {#000000}
+ set idx [lsearch -ascii -exact $editors $simulator_editor_obj]
+ if {$idx != -1} {
+ $listbox_opened_files itemconfigure [lindex $file_descriptors $idx] -fg {#000000}
+ } else {
+ set simulator_editor_obj {}
+ }
}
set simulator_editor_obj {}
+
+ if {$splitted && $selectedView} {
+ set editor_idx $actualEditor2
+ } else {
+ set editor_idx $actualEditor
+ }
+ focus -force [[lindex $editors $editor_idx] cget -editor]
}
## Set variable containing ID of active page
@@ -1471,12 +1522,12 @@ class FileList {
public method getLeftPanelSize {} {
if {$PanelVisible} {
return $PanelSize
- } {
+ } else {
return $last_sash
}
}
- ## Set panel width acording to current sash position
+ ## Set panel width according to current sash position
# @return void
public method left_panel_set_size {} {
set PanelSize [lindex [$parent sash coord 0] 0]
@@ -1497,12 +1548,12 @@ class FileList {
if {$PanelVisible} {
$parent paneconfigure $leftPanel -minsize 0
- pack forget $notebook
+ pack forget [$notebook get_nb]
# Show button bar
pack $button_bar -side top -anchor nw
# Move the paned window sash and remember current position
set last_sash [lindex [$parent sash coord 0] 0]
- update idle
+ update idletasks
$parent sash place 0 25 2
# Hide the sash
bind $parent <Button> {break}
@@ -1512,16 +1563,16 @@ class FileList {
return 0
# Show the panel
- } {
+ } else {
$parent paneconfigure $leftPanel -minsize 155
$notebook raise $active_page
# Hide button bar
pack forget $button_bar
# Show the panel
- pack $notebook -expand 1 -fill both
+ pack [$notebook get_nb] -expand 1 -fill both -padx 5 -pady 5
# Restore the paned window sash position to the previous state
- update idle
+ update idletasks
$parent sash place 0 $last_sash 0
# Show the sash
bind $parent <Button> {}
@@ -1548,11 +1599,17 @@ class FileList {
set index [$listbox_opened_files index $item] ;# Item index
set target [expr {$index - 1}] ;# Target index
+ if {$last_selected_item == $item} {
+ return
+ }
+ set last_selected_item $item
+
# 1st item cannot be moved up
if {$index == 0} {return}
- # Move item in listbox
+ # Move item in listbox and the notebook
$listbox_opened_files move $item $target
+ $filetabs_nb move $item $target
# Move item in list of bookmarks and icon border
if {[lindex $opened_files_bookmarks $index] != [lindex $opened_files_bookmarks $target]} {
# Determinate bookmark flag for source and target index
@@ -1568,12 +1625,12 @@ class FileList {
$listbox_opened_files_bm delete $target.0 [list $target.0 lineend]
if {$trg_bm} {
$listbox_opened_files_bm image create $index.0 \
- -image ::ICONS::16::bookmark \
+ -image ::ICONS::16::bookmark \
-align center
}
if {$idx_bm} {
$listbox_opened_files_bm image create $target.0 \
- -image ::ICONS::16::bookmark \
+ -image ::ICONS::16::bookmark \
-align center
}
}
@@ -1595,6 +1652,7 @@ class FileList {
# Move item in listbox
$listbox_opened_files move $item $target
+ $filetabs_nb move $item $target
# Move item in list of bookmarks and icon border
if {[lindex $opened_files_bookmarks $index] != [lindex $opened_files_bookmarks $target]} {
# Determinate bookmark flag for source and target index
@@ -1633,6 +1691,7 @@ class FileList {
# Move item
$listbox_opened_files move $item 0
+ $filetabs_nb move $item 0
# Move item in list of bookmarks
set bm [lindex $opened_files_bookmarks $index]
set opened_files_bookmarks [lreplace $opened_files_bookmarks $index $index]
@@ -1660,6 +1719,7 @@ class FileList {
# Move item in listbox
$listbox_opened_files move $item end
+ $filetabs_nb move $item end
# Move item in list of bookmarks
set bm [lindex $opened_files_bookmarks $index]
set opened_files_bookmarks [lreplace $opened_files_bookmarks $index $index]
@@ -1682,6 +1742,11 @@ class FileList {
## Show up editor asociated with the currently selected item in the file list (opened files)
# @return void
public method switchfile {} {
+ if {$switchfile_in_progress} {
+ return
+ }
+ set switchfile_in_progress 1
+
# Ensure that autocompletion window is closed
::Editor::close_completion_popup_window_NOW
@@ -1691,6 +1756,10 @@ class FileList {
# Adjust filetabs notebook
set page [lindex [$filetabs_nb pages] $editor_idx]
+ if {$page == {}} {
+ set switchfile_in_progress 0
+ return
+ }
$filetabs_nb raise $page
$filetabs_nb see $page
@@ -1699,13 +1768,13 @@ class FileList {
if {$editor_idx == $actualEditor} {
set selectedView 0
}
- } {
+ } else {
if {$editor_idx == $actualEditor2} {
set selectedView 1
}
}
- # Show up the coresponding editor
+ # Show up the corresponding editor
rightPanel_switch_editor_vars $editor_idx
$this todo_switch_editor_vars $editor_idx
# Right/Bottom view selected
@@ -1724,7 +1793,7 @@ class FileList {
set editor [lindex $editors $actualEditor2]
# Left/Top view selected
- } {
+ } else {
if {$editor_idx != $actualEditor} {
if {!$do_not_forget_editor && $actualEditor >= 0} {
set editor [lindex $editors $actualEditor]
@@ -1741,10 +1810,11 @@ class FileList {
set do_not_forget_editor 0
$opened_search_entry delete 0 end
- update idle
+ update idletasks
editor_procedure {} Configure {}
editor_procedure {} scroll {scroll +0 lines}
editor_procedure {} highlight_visible_area {}
+ editor_procedure {} check_file_change_notif {}
update
rightPanel_switch_page $editor_idx
$this todo_switch_editor $editor_idx
@@ -1756,13 +1826,13 @@ class FileList {
# Adjust command line status
if {$editor_command_line_on} {
$editor cmd_line_force_on
- } {
+ } else {
$editor cmd_line_force_off
}
# Adjust tab "Instruction details" on the right panel
if {${::ASMsyntaxHighlight::validation_L1}} {
$editor parse_current_line
- } {
+ } else {
$editor adjust_instruction_details
}
# move arrow image
@@ -1776,6 +1846,8 @@ class FileList {
${::editor_RO_MODE} [expr {[$editor get_language] == 1}]
# Focus on the editor
focus -force [$editor cget -editor]
+ update
+ set switchfile_in_progress 0
}
## Switch to the next editor
@@ -1809,7 +1881,7 @@ class FileList {
if {$item == $actualEditor || $item == $actualEditor2} {
set item {end-1}
}
- } {
+ } else {
set item {end}
}
$listbox_opened_files selection set [lindex $file_descriptors $item]
@@ -1825,7 +1897,7 @@ class FileList {
# Is the file part of the project ?
if {[getItemNameFromProjectList [$editor cget -fullFileName]] != {}} {
set state disabled
- } {
+ } else {
set state normal
}
$opened_files_menu entryconfigure [::mc "Append to project"] -state $state
@@ -1835,7 +1907,7 @@ class FileList {
set item_idx [$listbox_opened_files index $item]
if {$item_idx == 0} {
set state disabled
- } {
+ } else {
set state normal
}
$opened_files_menu entryconfigure [::mc "Move up"] -state $state
@@ -1847,7 +1919,7 @@ class FileList {
# Items: "Move down" and "Move to bottom"
if {($item_idx + 1) >= [llength [$listbox_opened_files items]]} {
set state disabled
- } {
+ } else {
set state normal
}
$opened_files_menu entryconfigure [::mc "Move down"] -state $state
@@ -1908,7 +1980,7 @@ class FileList {
} {
$opened_files_menu entryconfigure [::mc $entry] -state normal
}
- # It is not so easy to open the file with an external editor on Microsoft Windows as
+ # It is not so easy to open the file with an external editor on Microsoft Windows as
# it is on a POSIX system, that's why this feature is disabled here
if {$::MICROSOFT_WINDOWS} {
$opened_files_menu entryconfigure [::mc {Open with}] -state disabled
@@ -1922,7 +1994,7 @@ class FileList {
set fullFileName [[lindex $editors [lsearch $file_descriptors $item]] cget -fullFileName]
if {$fullFileName == {} || [getItemNameFromProjectList $fullFileName] != {}} {
set state disabled
- } {
+ } else {
set state normal
}
$opened_files_menu entryconfigure [::mc "Append to project"] -state $state
@@ -1987,26 +2059,34 @@ class FileList {
# Parse record
set rfi 0
foreach var {
- file_name active o_bookmark p_bookmark
- file_index read_only file_line file_md5
- file_path file_BMs file_BPs eol
- enc sh notes
- } {
- set $var [lindex $record $rfi]
- incr rfi
+ file_name active o_bookmark p_bookmark
+ file_index read_only file_line file_md5
+ file_path file_BMs file_BPs eol
+ enc sh notes
+ } {
+ set $var [lindex $record $rfi]
+ incr rfi
}
# Adjust file path
- if {[string index $file_path 0] != {/}} {
- set file_path "$project_path/$file_path"
+ if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
+ if {[string index $file_path 0] != {/}} {
+ set file_path "$project_path/$file_path"
+ }
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $file_path]} {
+ set file_path "$project_path/$file_path"
+ }
}
# Determinate full file name
set full_file_name "$file_path$file_name"
# Check for file usebility
if {
- ![file exists $full_file_name] ||
- [file isdirectory $full_file_name] ||
+ ![file exists $full_file_name]
+ ||
+ [file isdirectory $full_file_name]
+ ||
(!$::MICROSOFT_WINDOWS && ![file readable $full_file_name])
} then {
lappend file_indexes_fb {}
@@ -2014,19 +2094,6 @@ class FileList {
continue
}
- # Compare file MD5
- if {[catch {
- if {[md5::md5 -hex -file $file_path$file_name] != $file_md5} {
- lappend changed_files $file_path$file_name
- }
- }]} then {
- tk_messageBox \
- -icon warning \
- -type ok \
- -title [mc "Unknown error"] \
- -message [mc "Raised error during md5 checking file %s. Maybe md5 extension is not correctly loaded." $file_name]
- }
-
# Chech for valid EOL and Encoding
if {$eol != {lf} && $eol != {cr} && $eol != {crlf}} {
set eol $default_eol
@@ -2041,6 +2108,20 @@ class FileList {
puts stderr "Read only flag -- using default (0)"
}
+ # Compare file MD5
+ if {[catch {
+ if {!$read_only && [md5::md5 -hex -file $file_path$file_name] != $file_md5} {
+ lappend changed_files $file_path$file_name
+ }
+ }]} then {
+ tk_messageBox \
+ -parent . \
+ -icon warning \
+ -type ok \
+ -title [mc "Unknown error"] \
+ -message [mc "Error raised during md5 checking file %s. Maybe md5 extension is not correctly loaded." $file_name]
+ }
+
# Insert bookmark to icon border for project files
if {[llength $project_files_bookmarks]} {
$listbox_project_files_bm insert end "\n"
@@ -2049,7 +2130,7 @@ class FileList {
lappend project_files_bookmarks 1
$listbox_project_files_bm image create [list {end-1l} linestart] \
-image ::ICONS::16::bookmark -align center
- } {
+ } else {
lappend project_files_bookmarks 0
}
$listbox_project_files_bm tag add center 0.0 end
@@ -2068,7 +2149,7 @@ class FileList {
$sh $notes \
]
continue
- } {
+ } else {
$listbox_project_files insert end #auto \
-font $opened_file_font -fill {#000000} \
-text $file_name -data [list $file_path$file_name $eol $enc $read_only]
@@ -2110,16 +2191,7 @@ class FileList {
# Invoke progress dialog
set max [llength $file_indexes_fb]
if {!$max} {set max 1}
- create_progress_bar .prgDl \
- . \
- ::FileList::open_files_cur_file \
- {} \
- ::FileList::open_files_progress \
- $max \
- [mc "Opening project files"] \
- ::ICONS::16::fileopen \
- [mc "Abort"] \
- {set ::FileList::open_files_abort 1}
+ .prgDl.f.progressbar configure -maximum $max
# Adjust lists of files to open
if {!$keep_order} {
@@ -2136,7 +2208,7 @@ class FileList {
# Check for validity of list of file indexes
if {$unopened_files != {}} {
set file_indexes $file_indexes_fb
- } {
+ } else {
for {set i 0} {$i < $num_of_opened_files} {incr i} {
if {[lsearch -ascii -exact $file_indexes $i] == -1} {
set file_indexes $file_indexes_fb
@@ -2168,7 +2240,7 @@ class FileList {
incr i -1
set file_indexes [lrange $file_indexes 0 $i]
set file_indexes_fb [lrange $file_indexes_fb 0 $i]
- } {
+ } else {
set file_indexes {}
set file_indexes_fb {}
}
@@ -2195,7 +2267,7 @@ class FileList {
# Invoke dialog "File(s) not found"
if {$unopened_files != {}} {
# Create toplevel window
- set win [toplevel .file_not_found$obj_idx -class {Error dialog} -bg {#EEEEEE}]
+ set win [toplevel .file_not_found$obj_idx -class {Error dialog} -bg ${::COMMON_BG_COLOR}]
# Create window header
pack [frame $win.frame1] -side top -fill x -anchor nw
@@ -2248,21 +2320,18 @@ class FileList {
# Set window attributes
wm iconphoto $win ::ICONS::16::status_unknown
+ wm transient $win .
wm title $win [mc "File(s) not found"]
wm geometry $win 500x200
- wm protocol $win WM_DELETE_WINDOW "
- grab release $win
- destroy $win
- "
+ wm protocol $win WM_DELETE_WINDOW [list destroy $win]
update
- catch {grab $win}
raise $win
}
# Invoke dialog "File(s) changed"
if {$changed_files != {}} {
# Create dialog toplevel window
- set win [toplevel .changed_files$obj_idx -class {File changed} -bg {#EEEEEE}]
+ set win [toplevel .changed_files$obj_idx -class {File changed} -bg ${::COMMON_BG_COLOR}]
# Create dialog header
pack [frame $win.frame1] -side top -fill x -anchor nw
@@ -2273,8 +2342,8 @@ class FileList {
] -side left -fill x
# Create text widget and scrollbar
- pack [frame $win.frame2] -side top -expand 1 -fill both -pady 10 -padx 5
- pack [text $win.frame2.text -height 5 -width 50 \
+ pack [frame $win.frame2] -side top -expand 1 -fill both -pady 3 -padx 5
+ pack [text $win.frame2.text -height 0 -width 0 \
-yscrollcommand "$win.frame2.scrollbar set"] -side left -fill both -expand 1
pack [ttk::scrollbar $win.frame2.scrollbar \
-orient vertical \
@@ -2285,7 +2354,7 @@ class FileList {
foreach file $changed_files {
if {[file exists $file_path$file_name]} {
set time [clock format [file mtime $file_path$file_name] -format {%T %D}]
- } {
+ } else {
set time " -----\t"
}
$win.frame2.text insert end "$time\t$file\n"
@@ -2320,15 +2389,13 @@ class FileList {
"
# Set window attributes
+ wm minsize $win 200 100
+ wm transient $win .
wm iconphoto $win ::ICONS::16::info
wm title $win [mc "File(s) changed"]
wm geometry $win 500x200
- wm protocol $win WM_DELETE_WINDOW "
- grab release $win
- destroy $win
- "
+ wm protocol $win WM_DELETE_WINDOW [list destroy $win]
update
- catch {grab $win}
raise $win
}
}
@@ -2359,17 +2426,18 @@ class FileList {
if {$file_path != {}} {
# Report error if the file does not exist
if {
- !${::Editor::editor_to_use} && (
- ![file exists $file_path] ||
- ![file isfile $file_path] ||
- (!$::MICROSOFT_WINDOWS && ![file readable $file_path])
- )
- } {
- tk_messageBox \
- -type ok \
- -title [mc "File not found - MCU 8051 IDE"] \
- -message [mc "File %s not found !" $file_path] \
- -icon error
+ !${::Editor::editor_to_use} && (
+ ![file exists $file_path] ||
+ ![file isfile $file_path] ||
+ (!$::MICROSOFT_WINDOWS && ![file readable $file_path])
+ )
+ } then {
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -title [mc "File not found - MCU 8051 IDE"] \
+ -message [mc "File %s not found !" $file_path] \
+ -icon error
set newfile 1
}
@@ -2383,7 +2451,7 @@ class FileList {
}
if {$untitled_num == -1} {
set file_name "untitled"
- } {
+ } else {
set file_name "untitled$untitled_num"
}
incr untitled_num
@@ -2395,15 +2463,31 @@ class FileList {
}
if {$untitled_num == -1} {
set file_name "untitled"
- } {
+ } else {
set file_name "untitled$untitled_num"
}
incr untitled_num
set newfile 1
}
- # Check if the file isn't already opened
+
if {!$newfile} {
+ # Check if the file isn't dangerously large
+ set file_size [file size $file_path]
+ if {$file_size > 10485760} {
+ if {[tk_messageBox \
+ -parent . \
+ -type yesno \
+ -default no \
+ -icon warning \
+ -title [mc "Dangerously large file!"] \
+ -message [mc "WARNING: The file you are about to open is larger than 10MB!\n\nOpening extremely big source code files might lead your system to run out of operating memory, then the MCU 8051 IDE might got killed by the operating system!\n\nARE YOU SURE you want to proceed?"] \
+ ] != {yes}} then {
+ return {}
+ }
+ }
+
+ # Check if the file isn't already opened
set idx 0
foreach editor $editors {
if {[$editor cget -fullFileName] == $file_path} {
@@ -2411,7 +2495,7 @@ class FileList {
$listbox_opened_files selection set $item
switchfile
set lastItem $item
- Sbar [mc "File: %s is alredy opened." $file_path]
+ Sbar [mc "File: %s is already opened." $file_path]
return {}
}
incr idx
@@ -2432,10 +2516,10 @@ class FileList {
set file_descriptor [regsub -all -- {-} $file_descriptor {--}]
set file_descriptor [regsub -all -- {\s} $file_descriptor {-}]
# Handle similar file descriptors of different files
- while 1 {
+ while {1} {
if {[lsearch $file_descriptors $file_descriptor] != -1} {
append file_descriptor {_}
- } {
+ } else {
break
}
}
@@ -2470,38 +2554,47 @@ class FileList {
set ::FileList::dialog_response 0
set win [toplevel .append_to_the_project_dialog]
- pack [label $win.label -text [mc "Do you want to append this file to the project ?\n%s" $file_name]] -fill x -pady 5 -padx 5
-
- pack [frame $win.frm] -pady 5
- pack [ttk::button $win.frm.yes_button -text [mc "Yes"] -command "
- set ::FileList::dialog_response 1
- grab release $win
- destroy $win" \
- ] -side left
- bind $win.frm.yes_button <Return> "
+ set top_frame [frame $win.top]
+ pack [label $top_frame.img -image ::ICONS::32::help] -side left -padx 5
+ pack [label $top_frame.txt \
+ -justify left \
+ -text [mc "Do you want to add this file to the project ?\n%s" $file_name] \
+ ] -side left -padx 5
+ set chb [checkbutton $win.chb \
+ -text [mc "Do not ask again"] \
+ -onvalue 0 \
+ -offvalue 1 \
+ -variable ::FileList::ask__append_file_to_project \
+ ]
+ set bottom_frame [frame $win.bottom]
+ pack [ttk::button $bottom_frame.button_yes \
+ -text [mc "Yes"] -compound left \
+ -image ::ICONS::16::ok \
+ -command "
+ set ::FileList::dialog_response 1
+ grab release $win
+ destroy $win" \
+ ] -side left -padx 2 -pady 5
+ bind $bottom_frame.button_yes <Return> "
set ::FileList::dialog_response 1
grab release $win
destroy $win"
- bind $win.frm.yes_button <KP_Enter> "
+ bind $bottom_frame.button_yes <KP_Enter> "
set ::FileList::dialog_response 1
grab release $win
destroy $win"
- pack [ttk::button $win.frm.no_button -text [mc "No"] -command "
- grab release $win
- destroy $win" \
- ] -side left
- bind $win.frm.no_button <Return> "
- grab release $win
- destroy $win"
- bind $win.frm.no_button <KP_Enter> "
- grab release $win
- destroy $win"
-
- pack [ttk::separator $win.sep -orient horizontal] -fill x -pady 10
- pack [checkbutton $win.chb -text [mc "Do not ask again"] -onvalue 0 -offvalue 1 -variable ::FileList::ask__append_file_to_project] -anchor w
- pack [text $win.tip -fg {#888888} -bg {#EEEEEE} -height 2 -width 0 -bd 0] -fill x
- $win.tip insert end [mc "Tip: You can enable/disable this dialog in MCU 8051 IDE configuration dialog."]
- $win.tip configure -state disabled
+ pack [ttk::button $bottom_frame.button_no \
+ -text [mc "No"] -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command "grab release $win; destroy $win" \
+ ] -side left -padx 2 -pady 5
+ bind $bottom_frame.button_no <KP_Enter> "grab release $win; destroy $win"
+ bind $bottom_frame.button_no <KP_Enter> "grab release $win; destroy $win"
+
+ # Pack window frames
+ pack $top_frame -fill x -padx 5 -pady 10
+ pack $chb -anchor e -padx 5
+ pack $bottom_frame -pady 10
# Set window attributes
wm iconphoto $win ::ICONS::16::help
@@ -2509,13 +2602,13 @@ class FileList {
wm resizable $win 0 0
wm transient $win .
catch {grab $win}
- focus -force $win.frm.yes_button
wm protocol $win WM_DELETE_WINDOW "
grab release $win
destroy $win
"
raise $win
update
+ focus -force $bottom_frame.button_yes
tkwait window $win
if {$::FileList::dialog_response } {
@@ -2536,8 +2629,10 @@ class FileList {
set file [open $file_path]
fconfigure $file -encoding $enc
if {[regsub -all {[\u0000-\u0008\u000B-\u000C\u000E-\u001F\u007F-\u009F]} [read $file] {} data]} {
- tk_messageBox -parent . \
- -type ok -icon warning \
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -icon warning \
-title [mc "Binary File Opened - MCU 8015 IDE"] \
-message [mc "The file %s is binary, saving it will result corrupted file." $file_path]
}
@@ -2549,7 +2644,7 @@ class FileList {
$file_name $file_path "$this editor_procedure {} " \
[regsub -all {\r\n?} $data "\n"] $sh \
]
- } {
+ } else {
set editor [Editor "::editor${file_count}_$obj_idx" \
[expr {!$fast}] $eol $enc $read_only $file_switching_enabled $this \
$file_name $file_path "$this editor_procedure {} " {} $sh \
@@ -2571,7 +2666,7 @@ class FileList {
}
$filetabs_nb insert end $file_descriptor \
-text $file_name -image ::ICONS::16::$icon \
- -raisecmd "$this switch_file_from_filetabs $file_descriptor"
+ -raisecmd [list $this switch_file_from_filetabs $file_descriptor]
$filetabs_nb see $file_descriptor
# Conditionaly show Line Numbers and Icon Border
@@ -2615,7 +2710,7 @@ class FileList {
switchfile
}
- ## Show file details windows from files tab (or something ...)
+ ## Show file details window from files tab (or something ...)
# $filetabs_nb bindtabs <Enter> "$this file_details_win_create_from_ftnb"
# @parm String page - Page ID
# @return void
@@ -2638,8 +2733,9 @@ class FileList {
## Save currently opened file under a given filename
# note: should be used only for saving untitled files !
# @parm String filename - Full file name including path
- # @return bool - 1: (maybe) successful; 0: argument is empty
- public method save_as {filename} {
+ # @parm Bool keep_extension - Do not alter file extension by assuming that file with no extension should end with ".asm"
+ # @return Bool - 1: (maybe) successful; 0: argument is empty
+ public method save_as {filename {keep_extension 0}} {
# Handle empty argument
if {$filename == {}} {return 0}
@@ -2647,16 +2743,18 @@ class FileList {
# Adjust filename
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $filename]} {
- set filename "[$this cget -ProjectDir]/$filename"
+ set filename "[$this cget -ProjectDir]/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
set filename [file join [$this cget -ProjectDir] $filename]
}
}
set filename [file normalize $filename]
- if {[file extension $filename] == {}} {
- append filename {.asm}
+ if {!$keep_extension} {
+ if {[file extension $filename] == {}} {
+ append filename {.asm}
+ }
}
# Determinate file rootname
set rootname [file tail $filename]
@@ -2670,7 +2768,7 @@ class FileList {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" $rootname]
] != {yes}
- } {
+ } then {
return 1
}
}
@@ -2683,7 +2781,7 @@ class FileList {
# Determinate some additional informations
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
set editor [lindex $editors $idx]
@@ -2691,6 +2789,7 @@ class FileList {
set original_rootname [$editor cget -filename] ;# Original file rootname
# Mark the file as opened (in listbox of project files)
+ set already_in_project 0
foreach item [$listbox_project_files items] {
if {[$listbox_project_files itemcget $item -text] != $original_rootname} {
continue
@@ -2700,6 +2799,7 @@ class FileList {
if {[lindex $data 0] != $fullFileName} {continue}
lset data 0 $filename
$listbox_project_files itemconfigure $item -data $data -text $rootname
+ set already_in_project 1
}
# Set new file name
@@ -2708,14 +2808,17 @@ class FileList {
$this todo_change_filename $idx $rootname
# Ask for appending the file to the project
- set response [tk_messageBox \
- -title [mc "Add file ?"] \
- -icon question -type yesno \
- -parent $parent \
- -message [mc "Do you want to append this file to the project ?\n%s" $rootname]
- ]
- if {$response == {yes}} {
- filelist_append_to_prj
+ if {!$already_in_project} {
+ set response [tk_messageBox \
+ -title [mc "Add file ?"] \
+ -icon question \
+ -type yesno \
+ -parent $parent \
+ -message [mc "Do you want to add this file to the project ?\n%s" $rootname]
+ ]
+ if {$response == {yes}} {
+ filelist_append_to_prj
+ }
}
::X::recent_files_add 1 $filename
@@ -2726,7 +2829,7 @@ class FileList {
# ---------------------------------------------------------------------
- # EDITOR PROCEDURES
+ # EDITOR FUNCTIONS
# ---------------------------------------------------------------------
## Show/Hide line numbers
@@ -2735,7 +2838,7 @@ class FileList {
if {$lineNumbers} {
set lineNumbers 0
foreach editor $editors {$editor hideLineNumbers}
- } {
+ } else {
set lineNumbers 1
foreach editor $editors {$editor showLineNumbers}
}
@@ -2747,7 +2850,7 @@ class FileList {
if {$iconBorder} {
set iconBorder 0
foreach editor $editors {$editor hideIconBorder}
- } {
+ } else {
set iconBorder 1
foreach editor $editors {$editor showIconBorder}
}
@@ -2758,10 +2861,10 @@ class FileList {
public method editor_linescount {} {
if {$splitted && $selectedView} {
set tmp $actualEditor2
- } {
+ } else {
set tmp $actualEditor
}
- set tmp [[lindex $editors $tmp] cget -lastEnd]
+ set tmp [expr {int([[[lindex $editors $tmp] cget -editor] index end])}]
return [expr {$tmp-1}]
}
@@ -2770,7 +2873,7 @@ class FileList {
public method editor_actLineNumber {} {
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
return [expr {int([[lindex $editor_wdgs $idx] index insert])}]
@@ -2786,7 +2889,7 @@ class FileList {
if {$objectNumber == {}} {
if {$splitted && $selectedView} {
set objectNumber $actualEditor2
- } {
+ } else {
set objectNumber $actualEditor
}
}
@@ -2846,13 +2949,13 @@ class FileList {
# List header
if {$splitted} {
set _actualEditor2 $actualEditor2
- } {
+ } else {
set _actualEditor2 -1
}
if {$splitted} {
if {$pwin_orient == {vertical}} {
set idx 1
- } {
+ } else {
set idx 0
}
set multiview_sash_pos [lindex [$multiview_paned_win sash coord 0] $idx]
@@ -2897,6 +3000,9 @@ class FileList {
lset data 1 {no}
# Set file path
set path [lindex $data 5]
+ if {$::MICROSOFT_WINDOWS} { ;# "\" --> "/"
+ regsub -all "\\\\" $path {/} path
+ }
if {[string first $project_path $path] == 0} {
lset data 5 [string range $path $project_path_length end]
}
@@ -2908,7 +3014,7 @@ class FileList {
lappend file_list $data
# Opened file
- } {
+ } else {
# Find the file in list of opened files
foreach editor $editors {
# Local variables
@@ -2921,6 +3027,9 @@ class FileList {
# Set file path
set path [lindex $data 5]
+ if {$::MICROSOFT_WINDOWS} { ;# "\" --> "/"
+ regsub -all "\\\\" $path {/} path
+ }
if {[string first $project_path $path] == 0} {
lset data 5 [string range $path $project_path_length end]
}
@@ -2969,7 +3078,7 @@ class FileList {
regexp {^.*[\\\/]} $file_name path
if {[catch {
set md5_hash [md5::md5 -hex -hex -file $file_name]
- }]} {
+ }]} then {
set md5_hash {}
}
@@ -2997,7 +3106,7 @@ class FileList {
public method editor_save {} {
if {$splitted && $selectedView} {
[lindex $editors $actualEditor2] save
- } {
+ } else {
[lindex $editors $actualEditor] save
}
}
@@ -3041,13 +3150,13 @@ class FileList {
$editor insertData $data {}
[$editor cget -editor] edit modified 0
[$editor cget -editor] edit reset
- } {
+ } else {
set dir [${::X::actualProject} cget -ProjectDir]
catch {
file delete -force -- [file join $dir .#special:tmp]
}
- set file [open [file join $dir .#special:tmp] w 420]
+ set file [open [file join $dir .#special:tmp] w 0640]
puts -nonewline $file $data
close $file
@@ -3069,10 +3178,10 @@ class FileList {
if {$editorIdx == {}} {
if {$splitted && $selectedView} {
set editorIdx $actualEditor2
- } {
+ } else {
set editorIdx $actualEditor
}
- } {
+ } else {
if {$editorIdx == $actualEditor} {
set selectedView 0
} elseif {$editorIdx == $actualEditor2} {
@@ -3083,12 +3192,13 @@ class FileList {
# Ask user for saving the file (if was modified)
if {$ask && [$editor cget -modified]} {
- set response [tk_messageBox \
- -type yesnocancel \
+ set response [tk_messageBox \
+ -parent . \
+ -type yesnocancel \
-title [mc "Close document - MCU 8051 IDE"] \
- -icon question \
- -default yes \
- -message [mc "The document %s have been modified.\nDo you want to save it ?" [[lindex $editors $editorIdx] cget -fullFileName]]]
+ -icon question \
+ -default yes \
+ -message [mc "The document %s has been modified.\nDo you want to save it ?" [file tail [[lindex $editors $editorIdx] cget -fullFileName]]]]
if {$response == {yes}} {
$editor save
@@ -3137,27 +3247,31 @@ class FileList {
# Adjust object variables
foreach var {editors file_descriptors editor_wdgs file_eol file_encoding file_ro_mode file_sh} {
- set $var [lreplace [subst "\$$var"] $editorIdx $editorIdx]
+ set $var [lreplace [subst -nocommands "\$$var"] $editorIdx $editorIdx]
}
- if {$actualEditor > $editorIdx} {
+ if {$actualEditor == $editorIdx} {
+ set actualEditor {x}
+ } elseif {$actualEditor > $editorIdx} {
incr actualEditor -1
}
- if {$actualEditor2 > $editorIdx} {
+ if {$actualEditor2 == $editorIdx} {
+ set actualEditor2 {x}
+ } elseif {$actualEditor2 > $editorIdx} {
incr actualEditor2 -1
}
- if {$actualEditor == $editorIdx || $actualEditor2 == $editorIdx} {
+ if {$actualEditor == {x} || $actualEditor2 == {x}} {
set do_not_forget_editor 1
- if {$actualEditor == $editorIdx} {
+ if {$actualEditor == {x}} {
set actualEditor -1
}
- if {$actualEditor2 == $editorIdx} {
+ if {$actualEditor2 == {x}} {
set actualEditor2 -1
}
# Conditionaly open a new editor
if {$splitted} {
set min 2
- } {
+ } else {
set min 1
}
if {[llength $file_descriptors] < $min} {
@@ -3197,7 +3311,7 @@ class FileList {
if {$unsaved != {}} {
save_multiple_files $allowCancelButton
return 0
- } {
+ } else {
if {!$projectClose} {
editor_force_close_all
}
@@ -3239,7 +3353,7 @@ class FileList {
] -side right -fill x -expand 1
# Create the middle part of the dialog (list of unsaved files)
- pack [tkk::labelframe $dialog.lf \
+ pack [ttk::labelframe $dialog.lf \
-text [mc "Unsaved files"] \
] -fill both -expand 1 -pady 10 -padx 10
set i 0
@@ -3257,25 +3371,25 @@ class FileList {
pack [ttk::separator $dialog.separator -orient horizontal] -fill x -expand 1
pack [frame $dialog.f]
# SAVESELECTED
- pack [ttk::button $dialog.f.b_save_selected \
- -text [mc "Save selected"] \
- -compound left \
- -image ::ICONS::16::filesave \
- -command {${X::actualProject} save_multiple_files_SAVESELECTED} \
+ pack [ttk::button $dialog.f.b_save_selected \
+ -text [mc "Save selected"] \
+ -compound left \
+ -image ::ICONS::16::filesave \
+ -command {${::X::actualProject} save_multiple_files_SAVESELECTED} \
] -side left
# SAVEALL
pack [ttk::button $dialog.f.b_save_all \
-text [mc "Save all"] \
-compound left \
-image ::ICONS::16::save_all \
- -command {${X::actualProject} save_multiple_files_SAVEALL} \
+ -command {${::X::actualProject} save_multiple_files_SAVEALL} \
] -side left
# DESTROY
pack [ttk::button $dialog.f.b_discard \
-text [mc "Discard"] \
-compound left \
-image ::ICONS::16::editdelete \
- -command {${X::actualProject} save_multiple_files_DESTROY} \
+ -command {${::X::actualProject} save_multiple_files_DESTROY} \
] -side left
# CANCEL
if {$allowCancelButton} {
@@ -3283,7 +3397,7 @@ class FileList {
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
- -command {${X::actualProject} save_multiple_files_CANCEL} \
+ -command {${::X::actualProject} save_multiple_files_CANCEL} \
] -side left
}
@@ -3313,7 +3427,7 @@ class FileList {
public method save_multiple_files_SAVESELECTED {} {
set i 0
foreach editor $unsaved {
- set cnd [subst "\${::unsavedfile$i}"]
+ set cnd [subst -nocommands "\${::unsavedfile$i}"]
if {$cnd} {$editor save}
incr i
}
@@ -3365,21 +3479,21 @@ class FileList {
${project_files_buttonBox}open configure -state disabled
# Simulator disengaged
- } {
+ } else {
# Opened file
if {[llength [$listbox_project_files itemcget $item -data]] < 5} {
${project_files_buttonBox}close configure -state normal
${project_files_buttonBox}open configure -state disabled
# Unopened file
- } {
+ } else {
${project_files_buttonBox}close configure -state disabled
${project_files_buttonBox}open configure -state normal
}
}
# Nothing selected
- } {
+ } else {
${project_files_buttonBox}remove configure -state disabled
${project_files_buttonBox}open configure -state disabled
${project_files_buttonBox}close configure -state disabled
@@ -3438,7 +3552,7 @@ class FileList {
}
$project_files_menu entryconfigure [::mc "Open file"] -state disabled
# Unopened file
- } {
+ } else {
if {!$frozen} {
$project_files_menu entryconfigure [::mc "Close file"] -state disabled
}
@@ -3448,7 +3562,7 @@ class FileList {
# Movement commands
if {[$listbox_project_files index $item] == 0} {
set state disabled
- } {
+ } else {
set state normal
}
$project_files_menu entryconfigure [::mc "Move up"] -state $state
@@ -3456,7 +3570,7 @@ class FileList {
if {[$listbox_project_files index $item] == ([llength [$listbox_project_files items]] - 1)} {
set state disabled
- } {
+ } else {
set state normal
}
$project_files_menu entryconfigure [::mc "Move down"] -state $state
@@ -3611,7 +3725,7 @@ class FileList {
set item [$listbox_project_files selection get] ;# Item ID
set record [$listbox_project_files itemcget $item -data] ;# Item data
- # If the file is already opended -- abort
+ # If the file is already opened -- abort
if {[llength $record] == 4} {return}
# Parse item data
@@ -3623,10 +3737,11 @@ class FileList {
# Check for file existence
if {![file exists $file_path$file_name]} {
- tk_messageBox \
+ tk_messageBox \
-title [mc "File not found"] \
- -icon error \
- -type ok \
+ -parent . \
+ -icon error \
+ -type ok \
-message [mc "File %s could not be located at the specified location." $file_name]
return
}
@@ -3634,15 +3749,17 @@ class FileList {
# Verify file MD5 hash
if {[catch {
if {[md5::md5 -hex -file $file_path$file_name] != $file_md5} {
- tk_messageBox \
- -icon warning \
- -type ok \
+ tk_messageBox \
+ -icon warning \
+ -parent . \
+ -type ok \
-title [mc "File changed"] \
-message [mc "File \"%s\" was modified since last project save\nTime: %s" $file_name [clock format [file mtime $file_path$file_name] -format {%T %D}]]
}
}]} then {
tk_messageBox \
-icon warning \
+ -parent . \
-type ok \
-title [mc "Unknown error"] \
-message [mc "Raised error during md5 checking file %s. Maybe md5 extension is not correctly loaded." $file_name]
@@ -3769,7 +3886,7 @@ class FileList {
}
# Unopened file
- } {
+ } else {
if { "[lindex $data 5][lindex $data 0]" == $fullFileName} {
return $item
}
@@ -3785,7 +3902,7 @@ class FileList {
public method change_encoding {} {
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
if {[lindex $file_encoding $idx] == ${::editor_encoding}} {
@@ -3800,7 +3917,7 @@ class FileList {
set ::editor_encoding $original_encoding
lset file_encoding $idx $original_encoding
[lindex $editors $idx] configure -encoding $original_encoding
- } {
+ } else {
# Configure list of project files
set filename [[lindex $editors $idx] cget -fullFileName]
foreach item [$listbox_project_files items] {
@@ -3819,7 +3936,7 @@ class FileList {
public method change_EOL {} {
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
if {[lindex $file_eol $idx] == ${::editor_EOL}} {
@@ -3843,11 +3960,11 @@ class FileList {
}
## Change RO mode in the current editor
- # @return void
+ # @return Bool - true == ok; false == cannot comply!
public method switch_editor_RO_MODE {} {
if {$splitted && $selectedView} {
set idx $actualEditor2
- } {
+ } else {
set idx $actualEditor
}
if {[lindex $file_ro_mode $idx] == ${::editor_RO_MODE}} {
@@ -3855,26 +3972,23 @@ class FileList {
}
# Configure editor
+ if {![[lindex $editors $idx] change_RO_MODE ${::editor_RO_MODE}]} {
+ return 0
+ }
lset file_ro_mode $idx ${::editor_RO_MODE}
- [lindex $editors $idx] change_RO_MODE ${::editor_RO_MODE}
# Configure list of project files
set filename [[lindex $editors $idx] cget -fullFileName]
foreach item [$listbox_project_files items] {
set data [$listbox_project_files itemcget $item -data]
- # Unknown bug workaround :-(
- if {[llength $data] < 4} {
- puts "data == {$data}" ;# Dump
- lappend data {}
- }
-
if {[lindex $data 0] == $filename} {
lset data 3 ${::editor_RO_MODE}
$listbox_project_files itemconfigure $item -data $data
break
}
}
+ return 1
}
## Adjust scrollbar for listbox of opened files
@@ -3889,7 +4003,7 @@ class FileList {
set o_scrollbar_visible 0
}
# Show scrollbar
- } {
+ } else {
if {!$o_scrollbar_visible} {
pack $opened_files_scrollbar \
-side left \
@@ -3924,7 +4038,7 @@ class FileList {
set p_scrollbar_visible 0
}
# Show scrollbar
- } {
+ } else {
if {!$p_scrollbar_visible} {
pack $project_files_scrollbar \
-side left \
@@ -4116,7 +4230,7 @@ class FileList {
$filetabs_nb itemconfigure $page -image ::ICONS::16::$icon
# Add bookmark
- } {
+ } else {
lset opened_files_bookmarks $line 1
incr line
$listbox_opened_files_bm image create $line.0 \
@@ -4172,7 +4286,7 @@ class FileList {
incr line
$listbox_project_files_bm delete $line.0 [list $line.0 lineend]
# Add bookmark
- } {
+ } else {
lset project_files_bookmarks $line 1
incr line
$listbox_project_files_bm image create $line.0 \
@@ -4217,7 +4331,7 @@ class FileList {
if {$splitted && $selectedView} {
[lindex $editors $actualEditor2] cmd_line_focus 1
- } {
+ } else {
[lindex $editors $actualEditor] cmd_line_focus 1
}
}
@@ -4243,7 +4357,7 @@ class FileList {
# Save current sash position
if {$pwin_orient == {vertical}} {
set idx 1
- } {
+ } else {
set idx 0
}
set multiview_sash_pos [lindex [$multiview_paned_win sash coord 0] $idx]
@@ -4261,18 +4375,14 @@ class FileList {
# Determinate which editor will be visible now
if {$editor_object != {}} {
- set editor_object [lsearch $editors $editor_object]
- if {$editor_object == $actualEditor2} {
- set selectedView 1
- } {
- set selectedView 0
+ set editor_object [lsearch -ascii -exact $editors $editor_object]
+ if {$editor_object == $actualEditor} {
+ $listbox_opened_files selection set [lindex $file_descriptors $actualEditor2]
+ } elseif {$editor_object == $actualEditor2} {
+ $listbox_opened_files selection set [lindex $file_descriptors $actualEditor]
}
}
- # Insure than the choosen editor (see above) is (in)visible
- if {!$selectedView} {
- $listbox_opened_files selection set [lindex $file_descriptors $actualEditor2]
- }
set selectedView 0
set splitted 0
set actualEditor2 -1
@@ -4329,17 +4439,31 @@ class FileList {
private method split_editor {vert_or_horz} {
if {$splitted} {return}
+ set pwin_orient_orig $pwin_orient
+
# Determinate orientation
if {$vert_or_horz} {
set pwin_orient {horizontal}
- } {
+ } else {
set pwin_orient {vertical}
}
$multiview_paned_win configure -orient $pwin_orient
+ if {$pwin_orient_orig != $pwin_orient} {
+ set multiview_sash_pos 0
+ }
+
# Validate sash position
- if {!$multiview_sash_pos} {
- set multiview_sash_pos [expr {[winfo width $pagesManager] / 2}]
+ if {$pwin_orient == {vertical}} {
+ if {!$multiview_sash_pos} {
+ set multiview_sash_pos [expr {[winfo height $pagesManager] / 2}]
+ }
+ set minsize 80
+ } else {
+ if {!$multiview_sash_pos} {
+ set multiview_sash_pos [expr {[winfo width $pagesManager] / 2}]
+ }
+ set minsize 300
}
# Unmap current pages manager and remap it with the second one into paned window
@@ -4349,19 +4473,14 @@ class FileList {
$multiview_paned_win add $pagesManager2 -after $pagesManager
# Configure minimum size for panes
- if {$vert_or_horz} {
- set minsize 300
- } {
- set minsize 80
- }
$multiview_paned_win paneconfigure $pagesManager -minsize $minsize
$multiview_paned_win paneconfigure $pagesManager2 -minsize $minsize
# Move paned window sash
- update idle
+ update idletasks
if {$pwin_orient == {vertical}} {
$multiview_paned_win sash place 0 0 $multiview_sash_pos
- } {
+ } else {
$multiview_paned_win sash place 0 $multiview_sash_pos 0
}
@@ -4377,10 +4496,10 @@ class FileList {
if {$len > 1} {
if {$actualEditor < ($len - 1)} {
set actualEditor2 [expr {$actualEditor + 1}]
- } {
+ } else {
set actualEditor2 0
}
- } {
+ } else {
set selectedView 1
editor_new
set selectedView 0
@@ -4398,7 +4517,7 @@ class FileList {
set listbox $listbox_opened_files
set bookmarks_text $listbox_opened_files_bm
set bookmarks_var {opened_files_bookmarks}
- } {
+ } else {
set listbox $listbox_project_files
set bookmarks_text $listbox_project_files_bm
set bookmarks_var {project_files_bookmarks}
@@ -4420,7 +4539,7 @@ class FileList {
set data [lindex $data 5]
# Opened file
- } {
+ } else {
set data [lindex $data 0]
}
}
@@ -4434,7 +4553,7 @@ class FileList {
set path [lindex $path 5]
# Opened file
- } {
+ } else {
set path [lindex $path 0]
}
}
@@ -4471,7 +4590,7 @@ class FileList {
}
}
# By size (integer comparison)
- } {
+ } else {
for {set i 1} {$i < $num_of_items} {incr i} {
for {set j 1; set k 0} {$j < $num_of_items} {incr j; incr k} {
if {[lindex $items $k] > [lindex $items $j]} {
@@ -4492,7 +4611,7 @@ class FileList {
#+ No GUI will be affected
set new_items_order {}
set bookmarks_new {}
- set bookmarks_org [subst "\$$bookmarks_var"]
+ set bookmarks_org [subst -nocommands "\$$bookmarks_var"]
for {set i 0} {$i < $num_of_items} {incr i} {
set idx [lindex $new_order $i]
lappend new_items_order [$listbox items $idx]
@@ -4525,7 +4644,7 @@ class FileList {
return
}
set filename [$listbox_opened_files itemcget $item -data]
- } {
+ } else {
set item [$listbox_project_files selection get]
if {![$listbox_project_files exists $item]} {
return
@@ -4533,7 +4652,7 @@ class FileList {
set data [$listbox_project_files itemcget $item -data]
if {[llength $data] < 5} {
set filename [lindex $data 0]
- } {
+ } else {
set filename "[lindex $data 5][lindex $data 0]"
}
}
@@ -4549,7 +4668,7 @@ class FileList {
# Start external editor
if {[catch {
exec $command "$filename" &
- }]} {
+ }]} then {
tk_messageBox \
-parent . \
-icon error \
@@ -4565,7 +4684,7 @@ class FileList {
set ::FileList::open_with_cnfr 0
# Create toplevel window
- set win [toplevel .open_with_other_dlg -class {Open with ...} -bg {#EEEEEE}]
+ set win [toplevel .open_with_other_dlg -class {Open with ...} -bg ${::COMMON_BG_COLOR}]
# Create label, entryBox and horizontal separator
pack [label $win.lbl -text [mc "Enter command to execute:"]] -fill x -anchor w -padx 5
@@ -4573,7 +4692,6 @@ class FileList {
-textvariable ::FileList::open_with \
-width 0 \
] -fill x -padx 10 -anchor w
-# pack [ttk::separator $win.sep -orient horizontal] -fill x -padx 5 -pady 10
bind $win.ent <Return> "grab release $win; destroy $win"
bind $win.ent <KP_Enter> "grab release $win; destroy $win"
@@ -4589,7 +4707,7 @@ class FileList {
grab release $win
destroy $win
" \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
@@ -4598,7 +4716,7 @@ class FileList {
grab release $win
destroy $win
" \
- ] -side left
+ ] -side left -padx 2
pack $buttonFrame -side bottom -padx 5 -pady 5 -anchor e
# Set window attributes
@@ -4620,7 +4738,7 @@ class FileList {
# Return result
if {${::FileList::open_with_cnfr}} {
return ${::FileList::open_with}
- } {
+ } else {
return {}
}
}
@@ -4688,21 +4806,30 @@ class FileList {
if {$file_number != {} && $simulator_editor != $file_number} {
# Gain target file name
set file_name [$this simulator_get_filename $file_number]
+ if {$::MICROSOFT_WINDOWS} { ;# "/" --> "\"
+ regsub -all {/} $file_name "\\" file_name
+ }
# Search for the given file and try to switch to it
if {$file_switching_enabled || $simulator_editor == -1} {
foreach item [$listbox_opened_files items] {
- if {$file_name != [$listbox_opened_files itemcget $item -data]} {
+ set item_data [$listbox_opened_files itemcget $item -data]
+ if {$::MICROSOFT_WINDOWS} { ;# "/" --> "\"
+ regsub -all {/} $item_data "\\" item_data
+ }
+
+ if {$file_name != $item_data} {
continue
}
$listbox_opened_files selection set $item
+
if {$simulator_editor_obj != {}} {
$simulator_editor_obj disable
- $listbox_opened_files itemconfigure [lindex \
- $file_descriptors [lsearch -ascii -exact \
- $editors $simulator_editor_obj \
- ] \
+ $listbox_opened_files itemconfigure [lindex \
+ $file_descriptors [lsearch -ascii -exact\
+ $editors $simulator_editor_obj \
+ ] \
] -fg {#000000}
}
$listbox_opened_files itemconfigure $item -fg {#FF0000}
@@ -4711,11 +4838,14 @@ class FileList {
]
$simulator_editor_obj freeze
$simulator_editor_obj move_simulator_line $line_number
+
switchfile
set simulator_editor $file_number
+
return
}
}
+
Sbar [mc "Simulator: unable to switch to file: '%s'" $file_name]
# Move simulator pointer directly
@@ -4754,7 +4884,7 @@ class FileList {
## Redraw panel pane
# @return void
public method leftpanel_redraw_pane {} {
- update idle
+ update idletasks
if {$PanelVisible != 0} {
$parent sash place 0 $PanelSize 0
}
@@ -4765,7 +4895,7 @@ class FileList {
public method get_current_editor_object {} {
if {$splitted && $selectedView} {
set editor_num $actualEditor2
- } {
+ } else {
set editor_num $actualEditor
}
return [lindex $editors $editor_num]
@@ -4779,7 +4909,7 @@ class FileList {
if {![winfo ismapped $filetabs_frm]} {
if {$splitted} {
set before $multiview_paned_win
- } {
+ } else {
set before $pagesManager
}
pack $filetabs_frm -fill x -before $before
@@ -4787,7 +4917,7 @@ class FileList {
filelist_adjust_size_of_tabbar
}
# Hide
- } {
+ } else {
if {[winfo ismapped $filetabs_frm]} {
pack forget $filetabs_frm
}
@@ -4801,7 +4931,7 @@ class FileList {
$filetabs_nb see [lindex [$filetabs_nb pages] 0]
update
catch {
- $filetabs_nb.c configure -height 20
+ $filetabs_nb.c configure -height [expr {int(20 * $::font_size_factor)}]
}
$filetabs_nb see [$filetabs_nb raise]
@@ -4822,3 +4952,7 @@ class FileList {
}
}
set ::FileList::ask__append_file_to_project ${::CONFIG(ASK_ON_FILE_OPEN)}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/leftpanel/fsbrowser.tcl b/lib/leftpanel/fsbrowser.tcl
index 0a28d82..631eb3e 100755..100644
--- a/lib/leftpanel/fsbrowser.tcl
+++ b/lib/leftpanel/fsbrowser.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 _FSBROWSER_TCL ] } {
+set _FSBROWSER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements file system browser for the left panel
@@ -28,7 +33,7 @@
class FSBrowser {
- # Definition of popup menu for filesystem browser, part: configure
+ # Definition of popup menu for file system browser, part: configure
common FSMENU_CONFIGURE {
{cascade "Sorting" 0 "" .sorting false 1 {
{radiobutton "By Name" "" {::KIFSD::FSD::config(sorting)}
@@ -53,7 +58,7 @@ class FSBrowser {
{filelist_fsb_reload} "Show / Ignore files starting with dot"}
}
- # Definition of popup menu for filesystem browser, part: listbox
+ # Definition of popup menu for file system browser, part: listbox
common FSMENU_LISTBOX {
{command {Up} {} 0 "filelist_fsb_up" {up}
"Go to parent folder"}
@@ -65,7 +70,7 @@ class FSBrowser {
{command {Home} {} 0 "filelist_fsb_gohome" {gohome}
"Go to your home folder"}
{command {Reload} {} 1 "filelist_fsb_reload" {reload}
- "Reload filelist"}
+ "Reload file list"}
{separator}
{command {Rename} {} 0 "filelist_fsb_rename" {edit}
"Rename file"}
@@ -80,7 +85,7 @@ class FSBrowser {
"Show file properties"}
}
- # Definition of popup menu for filesystem browser, part: bookmarks
+ # Definition of popup menu for file system browser, part: bookmarks
common FSMENU_BOOKMARKS {
{command {Add bookmark} {} 0 "filelist_fsb_add_bookmark"
{bookmark_add} "Bookmark the current folder"}
@@ -90,29 +95,29 @@ class FSBrowser {
}
## PRIVATE
- private variable fs_browser_selected_item {} ;# Item selected by popup menu for filesystem browser
+ private variable fs_browser_selected_item {} ;# Item selected by popup menu for file system browser
private variable fs_browser_selection_in_P 0 ;# Procedure "filelist_fsb_select" in progress
- private variable fs_browser_listbox_top_frame ;# Top frame of filesystem browser
- private variable forward_history {} ;# List of forward history (filesystem browser)
- private variable back_history {} ;# List of backward history (filesystem browser)
- private variable fs_browser_current_dir ;# Current directory (filesystem browser)
- private variable fs_browser_conf_menu ;# ID of filesystem browser configuration menu
+ private variable fs_browser_listbox_top_frame ;# Top frame of file system browser
+ private variable forward_history {} ;# List of forward history (file system browser)
+ private variable back_history {} ;# List of backward history (file system browser)
+ private variable fs_browser_current_dir ;# Current directory (file system browser)
+ private variable fs_browser_conf_menu ;# ID of files ystem browser configuration menu
private variable fs_browser_dir_ok ;# Button: Confirm location
- private variable fs_browser_listbox_menu ;# ID of popup menu for filesystem browser
- private variable fs_browser_bm_menu ;# ID of bookmarks popup menu (filesystem browser)
- private variable fs_browser_toolbar ;# ID of filesystem browser toolbar
+ private variable fs_browser_listbox_menu ;# ID of popup menu for file system browser
+ private variable fs_browser_bm_menu ;# ID of bookmarks popup menu (file system browser)
+ private variable fs_browser_toolbar ;# ID of file system browser toolbar
private variable fs_browser_dir ;# ComboBox: Current directory
private variable fs_browser_listbox ;# ListBox: Files & Directories
- private variable fs_browser_listbox_v_scrollbar ;# Vertical scrollbar for filesystem browser
- private variable fs_browser_listbox_h_scrollbar ;# Horizontal scrollbar for filesystem browser
+ private variable fs_browser_listbox_v_scrollbar ;# Vertical scrollbar for file system browser
+ private variable fs_browser_listbox_h_scrollbar ;# Horizontal scrollbar for file system browser
private variable fs_browser_filter ;# ComboBox: Filter
private variable item_menu_invoked 0 ;# Bool: Item menu request
- # Current GLOB filter for filesystem browser
+ # Current GLOB filter for file system browser
private variable fs_browser_current_mask ${::CONFIG(FS_BROWSER_MASK)}
# Variables related to object initialization
private variable parent
- private variable gui_initialized 0
+ private variable fsb_gui_initialized 0
constructor {} {
# Configure local ttk styles
@@ -130,14 +135,14 @@ class FSBrowser {
# @return void
public method PrepareFSBrowser {_parent} {
set parent $_parent
- set gui_initialized 0
+ set fsb_gui_initialized 0
}
## Create GUI of tab "File system browser"
# @return void
public method CreateFSBrowserGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$fsb_gui_initialized} {return}
+ set fsb_gui_initialized 1
set fs_browser_current_dir [$this cget -projectPath]
@@ -157,8 +162,8 @@ class FSBrowser {
{current "Current document folder" {next} {filelist_fsb_current_doc_folder}
"Go to directory containing the current document"}
{configure "Configure" {configure} {filelist_fsb_popup_config_menu}
- "Filesystem browser configuration menu"}
- }
+ "File system browser configuration menu"}
+ } [namespace current]
${fs_browser_toolbar}forward configure -state disabled
${fs_browser_toolbar}back configure -state disabled
@@ -240,7 +245,7 @@ class FSBrowser {
bind $fs_browser_filter <Return> [list $this filelist_fsb_filter_ok]
bind $fs_browser_filter <KP_Enter> [list $this filelist_fsb_filter_ok]
bind $fs_browser_filter <<ComboboxSelected>> [list $this filelist_fsb_filter_ok]
- DynamicHelp::add $fs_browser_filter -text [mc "Filter"]
+ DynamicHelp::add $fs_browser_filter -text [mc "Filter"]
setStatusTip -widget $fs_browser_filter \
-text [mc "File filter"]
set val [lsearch -exact -ascii {{*.asm} {*.inc} {*.c} {*.h} {*}} $fs_browser_current_mask]
@@ -250,7 +255,7 @@ class FSBrowser {
$fs_browser_filter current $val
pack $fs_browser_filter -fill x -expand 1 -side left
- # Pack componets of filesystem browser
+ # Pack componets of file system browser
pack $fs_browser_toolbar -anchor w
pack $fs_browser_dir_frame -fill x -pady 3
pack $fs_browser_listbox_frame -fill both -expand 1
@@ -262,12 +267,12 @@ class FSBrowser {
set fs_browser_bm_menu $parent.bm_menu
filelist_fsb_makePopupMenu
- # Initialize filesystem browser
+ # Initialize file system browser
filelist_fsb_change_dir $fs_browser_current_dir
filelist_fsb_refresh_bookmarks
}
- ## Popup bookmarks menu for filesystem browser
+ ## Popup bookmarks menu for file system browser
# @return void
public method filelist_fsb_popup_bm_menu {} {
set x [winfo rootx ${fs_browser_toolbar}bookmark]
@@ -277,7 +282,7 @@ class FSBrowser {
tk_popup $fs_browser_bm_menu $x $y
}
- ## Popup configuration menu for filesystem browser
+ ## Popup configuration menu for file system browser
# @return void
public method filelist_fsb_popup_config_menu {} {
set x [winfo rootx ${fs_browser_toolbar}configure]
@@ -287,7 +292,7 @@ class FSBrowser {
tk_popup $fs_browser_conf_menu $x $y
}
- ## Popup filesystem browser listbox menu
+ ## Popup file system browser listbox menu
# @parm Int x - Relative horizontal position of mouse pointer
# @parm Int y - Relative vertical position of mouse pointer
# @return void
@@ -306,7 +311,7 @@ class FSBrowser {
tk_popup $fs_browser_listbox_menu $x $y
}
- ## Popup filesystem browser listbox menu
+ ## Popup file system browser listbox menu
# @parm Int x - Relative horizontal position of mouse pointer
# @parm Int y - Relative vertical position of mouse pointer
# @parm String item - Selected item (file of directory)
@@ -325,11 +330,11 @@ class FSBrowser {
tk_popup $fs_browser_listbox_menu $x $y
}
- ## Change current directory in filesystem browser
+ ## Change current directory in file system browser
# @parm String dir - New directory location
# @return void
public method filelist_fsb_change_dir {dir} {
- if {!$gui_initialized} {CreateFSBrowserGUI}
+ if {!$fsb_gui_initialized} {CreateFSBrowserGUI}
if {$::MICROSOFT_WINDOWS} {
# Transform for instance "C:" to "C:/"
@@ -340,14 +345,16 @@ class FSBrowser {
# Check if the given directory is valid
if {![file exists $dir] || ![file isdirectory $dir]} {
- tk_messageBox -parent . \
+ tk_messageBox
+ -parent . \
-title [mc "Invalid directory"] \
- -type ok -icon warning \
+ -type ok \
+ -icon warning \
-message [mc "The specified directory does not exist:\n%s" $dir]
return
}
- # Normalize path and configure toolbar (history control)
+ # Normalize path and configure toolbar (history controll)
set dir [file normalize $dir]
if {$dir != $fs_browser_current_dir} {
lappend back_history $fs_browser_current_dir
@@ -399,7 +406,7 @@ class FSBrowser {
if {$dir == [file separator]} {
$fs_browser_listbox_menu entryconfigure [::mc "Up"] -state disabled
${fs_browser_toolbar}up configure -state disabled
- } {
+ } else {
$fs_browser_listbox_menu entryconfigure [::mc "Up"] -state normal
${fs_browser_toolbar}up configure -state normal
}
@@ -407,7 +414,7 @@ class FSBrowser {
# Fill directory location combobox
set values {}
set folder $dir
- while 1 {
+ while {1} {
lappend values $folder
if {$folder == [file separator]} {break}
if {$::MICROSOFT_WINDOWS} {
@@ -444,7 +451,7 @@ class FSBrowser {
-parent . \
-icon info \
-type ok \
- -title [mc "Unable to compile"] \
+ -title [mc "Unable to comply"] \
-message [mc "Unable to open source file while simulator is engaged."]
return
}
@@ -491,7 +498,7 @@ class FSBrowser {
}
# Open directory
- } {
+ } else {
filelist_fsb_change_dir \
[file join $fs_browser_current_dir [lindex $file 1]]
}
@@ -512,7 +519,7 @@ class FSBrowser {
# This method shoul be called after FSD close
# @return void
public method filelist_fsb_refresh_bookmarks {} {
- if {!$gui_initialized} {CreateFSBrowserGUI}
+ if {!$fsb_gui_initialized} {CreateFSBrowserGUI}
# Clear current bookmarks entries
if {[$fs_browser_bm_menu index end] > 2} {
@@ -555,15 +562,15 @@ class FSBrowser {
set fs_browser_current_dir $tmp
# File selected -> bookmark current directory
- } {
+ } else {
filelist_fsb_add_bookmark
}
}
- ## Reload filesystem browser contents
+ ## Reload file system browser contents
# @return void
public method filelist_fsb_reload {} {
- if {!$gui_initialized} {CreateFSBrowserGUI}
+ if {!$fsb_gui_initialized} {CreateFSBrowserGUI}
filelist_fsb_change_dir $fs_browser_current_dir
}
@@ -599,7 +606,7 @@ class FSBrowser {
if {![llength $back_history]} {
${fs_browser_toolbar}back configure -state disabled
$fs_browser_listbox_menu entryconfigure [::mc "Back"] -state disabled
- } {
+ } else {
${fs_browser_toolbar}back configure -state normal
$fs_browser_listbox_menu entryconfigure [::mc "Back"] -state normal
}
@@ -633,7 +640,7 @@ class FSBrowser {
if {![llength $forward_history]} {
${fs_browser_toolbar}forward configure -state disabled
$fs_browser_listbox_menu entryconfigure [::mc "Forward"] -state disabled
- } {
+ } else {
${fs_browser_toolbar}forward configure -state normal
$fs_browser_listbox_menu entryconfigure [::mc "Forward"] -state normal
}
@@ -648,7 +655,7 @@ class FSBrowser {
set file [$this editor_procedure {} getFileName {}]
if {[lindex $file 0] != {}} {
set dir [lindex $file 0]
- } {
+ } else {
set dir $projectPath
}
# Change current directory
@@ -697,7 +704,7 @@ class FSBrowser {
-message [mc "Do you really want to delete file:\n%s" $filename]]
==
{yes}
- } {
+ } then {
if {[catch {file delete -force -- [file join $fs_browser_current_dir $filename]}]} {
tk_messageBox \
-parent . \
@@ -714,7 +721,7 @@ class FSBrowser {
# @return void
public method filelist_fsb_new_folder {} {
# Create dialog window
- set dialog [toplevel .new_dir_dialog -class {New folder} -bg {#EEEEEE}]
+ set dialog [toplevel .new_dir_dialog -class {New folder} -bg ${::COMMON_BG_COLOR}]
# Create header
pack [label $dialog.header \
@@ -774,7 +781,7 @@ class FSBrowser {
# Local variables
set dialog .new_dir_dialog ;# ID of dialog window
set folder [$dialog.entry get] ;# Name of folder to create
- set error 0 ;# Bool: error occured
+ set error 0 ;# Bool: error occurred
# Check for folder name validity
if {$folder == {}} {
@@ -783,10 +790,13 @@ class FSBrowser {
# Create new folder
if {$error || [catch {file mkdir [file join $fs_browser_current_dir $folder]}]} {
- tk_messageBox -parent $dialog -icon warning -type ok \
+ tk_messageBox \
+ -parent $dialog \
+ -icon warning \
+ -type ok \
-title [mc "Unable to create folder"] \
-message [mc "Unable to create the specified folder"]
- } {
+ } else {
# Remove dialog and reload browser
grab release $dialog
destroy $dialog
@@ -809,7 +819,7 @@ class FSBrowser {
if {[lindex $name 0] == {}} {
set name [lindex $name 1]
set type [mc "Directory"]
- } {
+ } else {
set name [lindex $name 0]
set type [mc "File"]
}
@@ -842,8 +852,8 @@ class FSBrowser {
# Create dialog window componets
- set dialog [toplevel .properties_dialog -class {File properties} -bg {#EEEEEE}] ;# Toplevel window itself
- set nb [NoteBook $dialog.nb -bg {#EEEEEE}] ;# NoteBook
+ set dialog [toplevel .properties_dialog -class {File properties} -bg ${::COMMON_BG_COLOR}] ;# Toplevel window itself
+ set nb [ModernNoteBook $dialog.nb] ;# NoteBook
set bottom_frame [frame $dialog.bottom_frame] ;# Button frame
# Create tabs in NoteBook
@@ -953,7 +963,7 @@ class FSBrowser {
]
# Pack NoteBook and bottom frame
- pack $nb -fill both -expand 1 -padx 10 -pady 5
+ pack [$nb get_nb] -fill both -expand 1 -padx 10 -pady 5
pack $bottom_frame -anchor e -after $nb -padx 10 -pady 5
# Configure dialog window
@@ -987,7 +997,10 @@ class FSBrowser {
# Change permissions
if {[catch {file attributes $file -permissions "0[format {%o} $perm]"}]} {
set error 1
- tk_messageBox -type ok -icon warning -parent $dialog \
+ tk_messageBox \
+ -type ok \
+ -icon warning \
+ -parent $dialog \
-title [mc "Permission denied"] \
-message [mc "Unable to change permissions for file:\n%s" [file tail $file]]
}
@@ -1000,16 +1013,19 @@ class FSBrowser {
file rename -force -- \
$file [file join $dir \
${::KIFSD::FSD::item_properties(name)}]}]
- } {
+ } then {
set error 1
- tk_messageBox -type ok -icon warning -parent $dialog \
+ tk_messageBox \
+ -type ok \
+ -icon warning \
+ -parent $dialog \
-title [mc "Permission denied"] \
-message [mc "Unable to rename file:\n%s\n\t=>\n%s" [file tail $file] ${::KIFSD::FSD::item_properties(name)}]
}
filelist_fsb_reload
}
- # If no error occured, close dialog
+ # If no error occurred, close dialog
if {!$error} {
grab release $dialog
destroy $dialog
@@ -1048,7 +1064,7 @@ class FSBrowser {
# Fill directory location combobox
set folder $content
set values {}
- while 1 {
+ while {1} {
lappend values $folder
if {$folder == [file separator]} {break}
if {$::MICROSOFT_WINDOWS} {
@@ -1068,7 +1084,7 @@ class FSBrowser {
}
}
$fs_browser_dir configure -values $values
- } {
+ } else {
$fs_browser_dir_ok configure -state disabled
$fs_browser_dir configure -style FSBrowser_RedBg.TCombobox
}
@@ -1082,7 +1098,7 @@ class FSBrowser {
filelist_fsb_change_dir [$fs_browser_dir get]
}
- ## Verticaly scroll FileSystem browser ListBox
+ ## Verticaly scroll File System browser ListBox
# @parm Float frac0 - Fraction of top visible area
# @parm Float frac1 - Fraction of bottom visible area
# @return void
@@ -1095,7 +1111,7 @@ class FSBrowser {
}
# Otherwise -> create scrollbar
- } {
+ } else {
if {![winfo ismapped $fs_browser_listbox_v_scrollbar]} {
pack $fs_browser_listbox_v_scrollbar \
-after $fs_browser_listbox \
@@ -1106,7 +1122,7 @@ class FSBrowser {
}
}
- ## Horizontaly scroll FileSystem browser ListBox
+ ## Horizontaly scroll File System browser ListBox
# @parm Float frac0 - Fraction of top visible area
# @parm Float frac1 - Fraction of bottom visible area
# @return void
@@ -1119,7 +1135,7 @@ class FSBrowser {
}
# Otherwise -> create scrollbar
- } {
+ } else {
if {![winfo ismapped $fs_browser_listbox_h_scrollbar]} {
pack $fs_browser_listbox_h_scrollbar \
-after $fs_browser_listbox_top_frame \
@@ -1133,7 +1149,7 @@ class FSBrowser {
## Recreate popup menus
# @return void
public method filelist_fsb_makePopupMenu {} {
- if {!$gui_initialized} {return}
+ if {!$fsb_gui_initialized} {return}
if {[winfo exists $fs_browser_conf_menu]} {
destroy $fs_browser_conf_menu
}
@@ -1144,9 +1160,9 @@ class FSBrowser {
destroy $fs_browser_bm_menu
}
- menuFactory $FSMENU_CONFIGURE $fs_browser_conf_menu 0 "$this " 0 {}
- menuFactory $FSMENU_LISTBOX $fs_browser_listbox_menu 0 "$this " 0 {}
- menuFactory $FSMENU_BOOKMARKS $fs_browser_bm_menu 0 "$this " 0 {}
+ menuFactory $FSMENU_CONFIGURE $fs_browser_conf_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $FSMENU_LISTBOX $fs_browser_listbox_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $FSMENU_BOOKMARKS $fs_browser_bm_menu 0 "$this " 0 {} [namespace current]
if {![llength $back_history]} {
$fs_browser_listbox_menu entryconfigure [::mc "Back"] -state disabled
@@ -1162,3 +1178,7 @@ class FSBrowser {
return $fs_browser_current_mask
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/leftpanel/sfrwatches.tcl b/lib/leftpanel/sfrwatches.tcl
index ba47dc5..8c1a8e4 100755..100644
--- a/lib/leftpanel/sfrwatches.tcl
+++ b/lib/leftpanel/sfrwatches.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 _SFRWATCHES_TCL ] } {
+set _SFRWATCHES_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides SFR watches for left panel
@@ -30,26 +35,26 @@ class SFRWatches {
## COMMON
# Font for addresses and register names
- common main_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- -weight bold \
+ common main_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
]
# Just another font but not bold
- common roman_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
+ common roman_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
]
# Fonr for register entry boxes
- common entry_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ common entry_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
## PRIVATE
private variable text_widget ;# Widget: Text widget containing SFR watches
- private variable scrollbar ;# Widget: Scrollbar for $text_widget
+ private variable scrollbar {} ;# Widget: Scrollbar for $text_widget
private variable search_entry ;# Widget: Search entry box at the bottom of the panel
private variable search_clear_but ;# Widget: Button "Clear" at the bottom of the panel
private variable main_left_frame ;# Widget: Frame containing $text_widget and its header label
@@ -57,20 +62,20 @@ class SFRWatches {
private variable validation_ena 1 ;# Bool: SFR entry box validation enabled
private variable haddr2idx ;# Array: $haddr2idx($hex_addr) --> row_in_text_widget - 1
private variable addr2idx ;# Array: $addr2idx($dec_addr) --> row_in_text_widget - 1
- private variable reg2idx ;# Array: $addr2idx($register_name_upppercase) --> row_in_text_widget - 1
+ private variable reg2idx ;# Array: $addr2idx($register_name_uppercase) --> row_in_text_widget - 1
private variable last_selected_line 0 ;# Int: Selected row in the text widget
private variable search_ena 1 ;# Bool: Search enabled
private variable menu ;# Widget: Popup menu for the text widget
# Variables related to object initialization
private variable parent ;# Parent GUI object (tempotary variable)
- private variable gui_initialized 0 ;# GUI ready
+ private variable sfrw_gui_initialized 0 ;# GUI ready
constructor {} {
}
destructor {
- if {$gui_initialized} {
+ if {$sfrw_gui_initialized} {
menu_Sbar_remove $menu
}
}
@@ -80,14 +85,14 @@ class SFRWatches {
# @return void
public method PrepareSFRWatches {_parent} {
set parent $_parent
- set gui_initialized 0
+ set sfrw_gui_initialized 0
}
## Initialize SFR watches GUI
# @return void
public method CreateSFRWatchesGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$sfrw_gui_initialized} {return}
+ set sfrw_gui_initialized 1
set validation_ena 0
create_GUI
@@ -106,10 +111,10 @@ class SFRWatches {
# @parm String reg - SFR name (e.g. PSW)
# @return Widget - Created entry box
private method create_entry {i type addr reg} {
- # Determinate entry box width
+ # Determine entry box width
if {$type == {hex}} {
set width 2
- } {
+ } else {
set width 3
}
@@ -146,7 +151,7 @@ class SFRWatches {
$text_widget.dec_entry_${i} selection clear
update
$text_widget.dec_entry_${i} icursor 0"
- } {
+ } else {
bind $entry <Key-Left> "
focus $text_widget.hex_entry_${i}
$text_widget.hex_entry_${i} selection clear
@@ -165,7 +170,7 @@ class SFRWatches {
# Iterate over defined SFRs ({{addr name} ... })
foreach reg [$this simulator_get_sfrs] {
- # Determinate hexadecimal address
+ # Determine hexadecimal address
set addr [lindex $reg 0]
set hex_addr [format %X $addr]
if {[string length $hex_addr] == 1} {
@@ -173,7 +178,7 @@ class SFRWatches {
} elseif {[string length $hex_addr] == 3} {
set hex_addr [string replace $hex_addr 0 0]
}
- # Determinate register name and make it 8 characters long
+ # Determine register name and make it 8 characters long
set reg [lindex $reg 1]
set reg_org $reg
switch -- $reg {
@@ -264,7 +269,7 @@ class SFRWatches {
{} "Set this register to 0"}
{command {Set to 0xFF} {} 9 "sfr_watches_set_current_to FF"
{} "Set this register to 255"}
- } $menu 0 "$this " 0 {}
+ } $menu 0 "$this " 0 {} [namespace current]
# Set event bindings for the text widget
bindtags $text_widget $text_widget
@@ -321,13 +326,17 @@ class SFRWatches {
# @parm Float frac1 - 2nd fraction
# @return void
public method sfr_watches_scroll_set {frac0 frac1} {
+ if {$scrollbar == {}} {
+ return
+ }
+
# Hide scrollbar
if {$frac0 == 0 && $frac1 == 1} {
if {[winfo ismapped $scrollbar]} {
pack forget $scrollbar
}
# Show scrollbar
- } {
+ } else {
if {![winfo ismapped $scrollbar]} {
pack $scrollbar \
-side left \
@@ -351,7 +360,7 @@ class SFRWatches {
$search_entry configure -style TEntry
sfr_watches_select_line 1 0 hex
return 1
- } {
+ } else {
$search_clear_but configure -state normal
}
@@ -363,7 +372,7 @@ class SFRWatches {
# Search successful
if {![string first $string $str]} {
$search_entry configure -style StringFound.TEntry
- sfr_watches_select_line 1 [expr {[subst "\${${arr}(${str})}"] + 1}] hex
+ sfr_watches_select_line 1 [expr {[subst -nocommands "\${${arr}(${str})}"] + 1}] hex
return 1
}
}
@@ -392,7 +401,7 @@ class SFRWatches {
-bg {#FFFFFF} -disabledbackground {#FFFFFF}
}
set cursor [$text_widget.${type}_entry_$last_selected_line index insert]
- } {
+ } else {
set cursor 0
}
@@ -454,7 +463,7 @@ class SFRWatches {
return 0
}
set value [expr "0x$value"]
- } {
+ } else {
if {![string is digit $value]} {
set validation_ena 1
return 0
@@ -475,7 +484,7 @@ class SFRWatches {
if {$type == {hex}} {
$text_widget.dec_entry_$addr2idx($addr) delete 0 end
$text_widget.dec_entry_$addr2idx($addr) insert 0 $value
- } {
+ } else {
set value [format %X $value]
if {[string length $value] == 1} {
set value "0$value"
@@ -492,7 +501,7 @@ class SFRWatches {
## Remove all SFRs for the text widget and unregister them
# @return void
private method clear_gui {} {
- if {!$gui_initialized} {return}
+ if {!$sfrw_gui_initialized} {return}
# Clear SFR name label highlight in simultor contol panel
if {$last_selected_line} {
@@ -518,13 +527,13 @@ class SFRWatches {
# @parm Int new_val - New SFR value
# @return void
public method sfr_watches_sync {addr new_val} {
- if {!$gui_initialized} {return}
+ if {!$sfrw_gui_initialized} {return}
# Prevent recursion
if {!$validation_ena} {return}
set validation_ena 0
- # Check if this SFR is avaliable here
+ # Check if this SFR is available here
if {[lsearch [array names addr2idx] $addr] == -1} {
set validation_ena 1
return
@@ -560,7 +569,7 @@ class SFRWatches {
## Enable this panel
# @return vois
public method sfr_watches_enable {} {
- if {!$gui_initialized} {return}
+ if {!$sfrw_gui_initialized} {return}
$menu entryconfigure [::mc "Set to 0x00"] -state normal
$menu entryconfigure [::mc "Set to 0xFF"] -state normal
for {set i 0} {$i < $entry_count} {incr i} {
@@ -572,7 +581,7 @@ class SFRWatches {
## Disable this panel
# @return vois
public method sfr_watches_disable {} {
- if {!$gui_initialized} {return}
+ if {!$sfrw_gui_initialized} {return}
$menu entryconfigure [::mc "Set to 0x00"] -state disabled
$menu entryconfigure [::mc "Set to 0xFF"] -state disabled
for {set i 0} {$i < $entry_count} {incr i} {
@@ -582,10 +591,10 @@ class SFRWatches {
}
## This function shuld be call after processor was changed
- # Reload avaliable SFRs
+ # Reload available SFRs
# @return void
public method sfr_watches_commit_new_sfr_set {} {
- if {!$gui_initialized} {return}
+ if {!$sfrw_gui_initialized} {return}
clear_gui
fill_gui
}
@@ -618,3 +627,7 @@ class SFRWatches {
sfr_watches_select_line 0 $line $type
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/lib/FSnotifications.tcl b/lib/lib/FSnotifications.tcl
new file mode 100644
index 0000000..be1d477
--- /dev/null
+++ b/lib/lib/FSnotifications.tcl
@@ -0,0 +1,340 @@
+#!/usr/bin/tclsh
+
+############################################################################
+# Copyright (C) 2011 by Martin Ošmera #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+
+# >>> File inclusion guard
+if { ! [ info exists _FSNOTIFICATIONS_TCL ] } {
+set _FSNOTIFICATIONS_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+# Mechanism for watching over a set of files for modifications made to them
+# on the storage device where there are stored on. It periodically checks
+# modification times of the specified files and generate notifications when
+# some of these times changes.
+# --------------------------------------------------------------------------
+
+namespace eval FSnotifications {
+ variable watch_interval -1 ;# Int: Interval for periodical mtime checks, in ms
+ variable watch_timer {} ;# Object: The watch timer
+
+ # List: Watched files, format:
+ # {
+ # { # <-- Group of files
+ # {directory mtime callback} # <-- Directory specification
+ # { # <-- List of files
+ # {file mtime callback} # <-- File specification
+ # ...
+ # }
+ # } ...
+ # }
+ variable watched_files {}
+
+
+ # ----------------------------------------------------------------------
+ # "PUBLIC" FUNCTIONS
+ # ----------------------------------------------------------------------
+
+ ## Start watching
+ # @parm Int: interval=1500 - Interval for periodical mtime checks, in ms
+ # @return void
+ proc init {{interval 1500}} {
+ variable watch_timer ;# Int: Interval for periodical mtime checks, in ms
+ variable watch_interval ;# Object: The watch timer
+
+ set watch_interval $interval
+
+ # Start the watch timer
+ if {$watch_timer == {}} {
+ set watch_timer [after $watch_interval [list FSnotifications::timeout]]
+ }
+ }
+
+ ## Stop watching
+ # @return void
+ proc stop {} {
+ variable watch_timer ;# Object: The watch timer
+
+ if {$watch_timer != {}} {
+ catch {
+ after cancel $watch_timer
+ }
+ }
+ }
+
+ ## Watch over the specified file
+ # @parm String: filename - Name of the file, or directory, to watch including path
+ # @parm String: callback - Change notification (some command string)
+ # @return Bool - true == File actually added; false == something went wrong
+ proc watch {filename callback} {
+ variable watched_files ;# List: Watched files
+
+ # Check for existence of the specified file
+ if {$filename == {} || ![file exists $filename]} {
+ return 0
+ }
+
+ # Watch directory
+ if {[file isdirectory $filename]} {
+ # Attempt to find already existing group of files
+ set group_index -1
+ foreach group $watched_files {
+ incr group_index
+
+ # Local variables
+ set directory [lindex $group 0] ;# List: Directory specification
+ set files [lindex $group 1] ;# List: List of files
+
+ # Group found
+ if {[lindex $directory 0] == $filename} {
+ # No callback specified -> do nothing
+ if {$callback == {}} {
+ return 0
+ # Set new callback
+ } else {
+ lset watched_files [list $group_index 0 2] $callback
+ return 1
+ }
+ }
+ }
+
+ # Group not found, create a new one
+ lappend watched_files [list [list $filename [file mtime $filename] $callback] [list]]
+
+ # Watch regular file
+ } else {
+ # Local variables
+ set dirname [file dirname $filename] ;# Directory name
+ set tailname [file tail $filename] ;# File name
+
+ # Attempt to find already existing group of files
+ set group_index -1
+ foreach group $watched_files {
+ incr group_index
+
+ # Local variables
+ set directory [lindex $group 0] ;# List: Directory specification
+ set files [lindex $group 1] ;# List: List of files
+
+ # Group found
+ if {[lindex $directory 0] == $dirname} {
+ set file_index -1
+ foreach file_spec $files {
+ incr file_index
+
+ # Local variables
+ set file_name [lindex $file_spec 0] ;# Name of file
+ set file_mtime_rec [lindex $file_spec 1];# Time of the last modification
+ set file_callback [lindex $file_spec 2] ;# Notification callback
+
+ # Set new callback for the specified file
+ if {$file_name == $tailname} {
+ lset watched_files [list $group_index 1 $file_index 2] $callback
+ return 1
+ }
+ }
+
+ # File specification not found, create a new one
+ lappend files [list $tailname [file mtime $filename] $callback]
+
+ # Alter the corresponding group
+ lset watched_files [list $group_index 1] $files
+ return 1
+ }
+ }
+
+ # Group not found, create a new one and create the file specification right away
+ set dir_spec [list $dirname [file mtime $dirname] {}]
+ set file_list [list [list $tailname [file mtime $filename] $callback]]
+ lappend watched_files [list $dir_spec $file_list]
+ return 1
+ }
+ }
+
+ ## Discontinue watching over the specified file
+ # @parm String: filename - Name of the file, or directory, including path
+ # @parm Bool: entire_dir=0 -
+ # If case the filename is directory, stop watching for the entire
+ # directory including all files in it
+ # @return Bool - true == File actually added; false == something went wrong
+ proc forget {filename {entire_dir 0}} {
+ variable watched_files ;# List: Watched files
+
+ # File or directory name has not to be empty
+ if {$filename == {}} {
+ return 0
+ }
+
+ set result 0
+ set dirname [file dirname $filename]
+ set tailname [file tail $filename]
+
+ # Attempt to find the corresponding group of files
+ set o_size [llength $watched_files]
+ for {set group_index 0} {$group_index < $o_size} {incr group_index} {
+
+ # Group directory name matches the filename parameter,
+ #+ so we are about to forget about a directory
+ if {[lindex $watched_files [list $group_index 0 0]] == $filename} {
+
+ # Remove the entire group if the list of files is empty, that means
+ #+ that we were watching only the directory itself, not any particular
+ #+ files in it. Or in case that the removal of the entire directory
+ #+ has been enforced by entire_dir parameter.
+ if {![llength [lindex $watched_files [list $group_index 1]]] || $entire_dir} {
+ set watched_files [lreplace $watched_files $group_index $group_index]
+ set result 1
+
+ # If the group is not empty, then remove just the notification
+ #+ callback for the directory itself.
+ } else {
+ lset watched_files [list $group_index 0 2] {}
+ }
+ }
+
+ # Group directory name matches the directory of the filename
+ #+ parameter, so we about to forget about only a file from
+ #+ that group
+ if {[lindex $watched_files [list $group_index 0 0]] == $dirname} {
+ # Attempt to find the file specification in the group's list of files
+ set fl_size [llength [lindex $watched_files [list $group_index 1]]]
+ for {set file_index 0} {$file_index < $fl_size} {incr file_index} {
+ # File specification found
+ if {[lindex $watched_files [list $group_index 1 $file_index 0]] == $tailname} {
+ # Remove the designated file specification from the group
+ set dir_spec [lindex $watched_files [list $group_index 0]]
+ set file_list [lindex $watched_files [list $group_index 1]]
+ set file_list [lreplace $file_list $file_index $file_index]
+ set watched_files [lreplace $watched_files $group_index $group_index [list $dir_spec $file_list]]
+ set result 1
+ }
+ }
+ }
+ }
+
+ return $result
+ }
+
+
+ # ----------------------------------------------------------------------
+ # INTERNAL FUNCTIONS
+ # ----------------------------------------------------------------------
+
+ ## This function performs the watching itself, it supposed to be called
+ # by the watch timer.
+ # @return void
+ proc timeout {} {
+ variable watch_timer ;# Object: The watch timer
+ variable watched_files ;# List: Watched files
+ variable watch_interval ;# Int: Interval for periodical mtime checks, in ms
+
+ set auto_remove [list]
+
+ # Iterate over the groups
+ set o_size [llength $watched_files]
+ for {set group_index 0} {$group_index < $o_size} {incr group_index} {
+ # Bool: the group is no longer valid, it's directory has
+ #+ been removed from the file system
+ set dir_removed_from_FS 0
+ # String: Directory of the group
+ set dir_name [lindex $watched_files [list $group_index 0 0]]
+
+ # The group directory must exists and must be a directory, otherwise, remove the group
+ if {![file exists $dir_name] || ![file isdirectory $dir_name]} {
+ set dir_removed_from_FS 1
+ lappend auto_remove $dir_name
+ }
+
+ # If the group is no longer valid, we still have to send
+ #+ notifications for all the files in it
+ if {$dir_removed_from_FS} {
+ set dir_mtime_rec -1
+ set dir_mtime_cur -2
+ # Get the last known directory modification time and the current one
+ } else {
+ set dir_mtime_rec [lindex $watched_files [list $group_index 0 1]]
+ set dir_mtime_cur [file mtime $dir_name]
+ }
+
+ # Compare the modification times (detect change in the directory itself)
+ if {$dir_mtime_rec != $dir_mtime_cur} {
+ # Update the recorded directory modification time
+ lset watched_files [list $group_index 0 1] $dir_mtime_cur
+ # Invoke notification callback
+ set dir_callback [lindex $watched_files [list $group_index 0 2]]
+ if {$dir_callback != {}} {
+ uplevel #0 "$dir_callback {$dir_name}"
+ }
+ }
+
+ # Iterate over files in the group
+ set fl_size [llength [lindex $watched_files [list $group_index 1]]]
+ for {set file_index 0} {$file_index < $fl_size} {incr file_index} {
+ set file_removed_from_FS 0
+ set file_name [lindex $watched_files [list $group_index 1 $file_index 0]]
+ set file_name [file join $dir_name $file_name]
+
+ # Check if the file spec. is still valid
+ if {
+ !$dir_removed_from_FS
+ &&
+ ( ![file exists $file_name] || [file isdirectory $file_name] )
+ } then {
+ set file_removed_from_FS 1
+ lappend auto_remove $file_name
+ }
+
+ # If the group is no longer valid, or the file has been removed from the
+ #+ file system, we still have to send notifications for all the files in it
+ if {$dir_removed_from_FS || $file_removed_from_FS} {
+ set file_mtime_rec -1
+ set file_mtime_cur -2
+ } else {
+ set file_mtime_rec [lindex $watched_files [list $group_index 1 $file_index 1]]
+ set file_mtime_cur [file mtime $file_name]
+ }
+
+ # Compare the modification times (detect change in the file)
+ if {$file_mtime_rec != $file_mtime_cur} {
+ # Update the recorded file modification time
+ lset watched_files [list $group_index 1 $file_index 1] $file_mtime_cur
+ # Invoke notification callback
+ set file_callback [lindex $watched_files [list $group_index 1 $file_index 2]]
+ uplevel #0 "$file_callback {$file_name}"
+ }
+ }
+ }
+
+ # Forget files and directories removed from the file system
+ foreach file_to_remove $auto_remove {
+ forget $file_to_remove 1
+ }
+
+ # Again start the watch timer
+ set watch_timer [after $watch_interval [list FSnotifications::timeout]]
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/lib/Math.tcl b/lib/lib/Math.tcl
index bf2be0d..af5e0ae 100755..100644
--- a/lib/lib/Math.tcl
+++ b/lib/lib/Math.tcl
@@ -1,7 +1,7 @@
#!/usr/bin/tclsh
############################################################################
-# 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 #
@@ -20,6 +20,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _MATH_TCL ] } {
+set _MATH_TCL _
+# <<< File inclusion guard
# --------------------------------------------------------------------------
# DESCRIPTION
# Primarily implements convertions between numeric systems and angle units.
@@ -51,7 +56,7 @@
# puts [ NumSystem::bin2hex 1111.01 ] ;# --> F.4
# puts [ NumSystem::bin2dec 1111.01 ] ;# --> 15.25
# puts [ NumSystem::bin2oct 1111.01 ] ;# --> 17.2
- #
+ #
# puts [ NumSystem::ascii2dec @ ] ;# --> 64
# puts [ NumSystem::ascii2bin @ ] ;# --> 01000000
#
@@ -273,7 +278,7 @@ namespace eval NumSystem {
if {[regexp {\.\d+$} $number frac]} {
set frac [string range $frac 1 end]
set nofrac 0
- } {
+ } else {
set frac {}
set nofrac 1
}
@@ -334,7 +339,7 @@ namespace eval NumSystem {
if {$result != {}} {
return [dec2bin $result]
}
-
+
return $result
}
@@ -348,7 +353,7 @@ namespace eval NumSystem {
}
set result {}
scan $number {%c} result
-
+
return $result
}
@@ -363,7 +368,7 @@ namespace eval NumSystem {
proc asserthex {number} {
if {![ishex $number]} {
error "asserthex: Excepted hexadecimal value but got \"$number\""
- } {
+ } else {
return 1
}
}
@@ -375,7 +380,7 @@ namespace eval NumSystem {
proc assertdec {number} {
if {![isdec $number]} {
error "assertdec: Excepted decimal value but got \"$number\""
- } {
+ } else {
return 1
}
}
@@ -387,7 +392,7 @@ namespace eval NumSystem {
proc assertoct {number} {
if {![isoct $number]} {
error "assertoct: Excepted octal value but got \"$number\""
- } {
+ } else {
return 1
}
}
@@ -399,7 +404,7 @@ namespace eval NumSystem {
proc assertbin {number} {
if {![isbin $number]} {
error "assertbin: Excepted binary value but got \"$number\""
- } {
+ } else {
return 1
}
}
@@ -466,7 +471,7 @@ namespace eval NumSystem {
if {$base == 8} {
assertoct $number
set char_len 3
- } {
+ } else {
asserthex $number
set char_len 4
}
@@ -478,7 +483,7 @@ namespace eval NumSystem {
if {[regexp {\.[^\.]+$} $number frac]} {
set frac [string range $frac 1 end]
set nofrac 0
- } {
+ } else {
set frac {}
set nofrac 1
}
@@ -486,7 +491,7 @@ namespace eval NumSystem {
# compute int. part
if {$base == 8} {
set int [expr "0$int"]
- } {
+ } else {
set int [expr "0x$int"]
}
@@ -513,7 +518,7 @@ namespace eval NumSystem {
if {$base == 8} {
set v3 $v0
- } {
+ } else {
set v3 [expr {$v0 / 2}]
}
set v2 [expr {$v3 / 2}]
@@ -569,7 +574,7 @@ namespace eval NumSystem {
set mod_1 2
set padding {}
set convCmd {oct_to_bin}
- } {
+ } else {
set modulo 4
set mod_1 3
set padding {0}
@@ -581,7 +586,7 @@ namespace eval NumSystem {
if {[regexp {\.\d+$} $number frac]} {
set frac [string range $frac 1 end]
set nofrac 0
- } {
+ } else {
set frac {}
set nofrac 1
}
@@ -670,7 +675,7 @@ namespace eval NumSystem {
if {[regexp {\.\d+$} $number frac]} {
set frac [string range $frac 1 end]
set nofrac 0
- } {
+ } else {
set frac {}
set nofrac 1
}
@@ -817,7 +822,7 @@ namespace eval NumSystem {
return 0
}
- # 3rd condition (dot must not be at the begining or end)
+ # 3rd condition (dot must not be at the beginning or end)
if {[regexp {^\.} $number]} {return 0}
if {[regexp {\.$} $number]} {return 0}
@@ -940,7 +945,11 @@ namespace eval Angle {
}
# is negative or something else ?
- if {$angle < 0} {set minus 1} {set minus 0}
+ if {$angle < 0} {
+ set minus 1
+ } else {
+ set minus 0
+ }
# adjust angle value
set angle [expr {$angle / $base}]
@@ -952,3 +961,7 @@ namespace eval Angle {
return $angle
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/lib/hexeditor.tcl b/lib/lib/hexeditor.tcl
index ceb9192..fc3c5e6 100755..100644
--- a/lib/lib/hexeditor.tcl
+++ b/lib/lib/hexeditor.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,31 +21,43 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _HEXEDITOR_TCL ] } {
+set _HEXEDITOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# This class provides simple hexeditor with selectable view mode
+# This class provides simple hex editor with selectable view mode
# and optional ascii view. See constructor and section
# "GENERAL PUBLIC INTERFACE" for more details.
# --------------------------------------------------------------------------
class HexEditor {
- common DEBUG 0 ;# Bool: More secure input data checking
# Font for editor text widget(s) - normal size
- common view_font_n [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -15 \
- ]
+ if {!$::MICROSOFT_WINDOWS} {
+ common view_font_n [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-15 * $::font_size_factor)}] \
+ ]
+ } else {
+ common view_font_n [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-15 * $::font_size_factor)}] \
+ -weight bold \
+ ]
+ }
# Font for editor headers - normal size
- common header_font_n [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -15 \
- -weight bold \
+ common header_font_n [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-15 * $::font_size_factor)}] \
+ -weight bold \
]
# Font for editor headers - small size
- common header_font_s [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ common header_font_s [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
common view_font_s $header_font_s ;# Font for editor text widget(s) - small size
common header_bg {#9999FF} ;# Background color for headers
@@ -103,7 +115,7 @@ class HexEditor {
private variable in_cell 0 ;# Bool: mouse pointer in cell (see code below)
private variable motion_binding 0 ;# Bool: Bindings for special mouse events set
private variable view_mode ;# Current view mode (one of {dec hec oct bin})
- private variable ascii_view ;# Bool: Ascii view avaliable
+ private variable ascii_view ;# Bool: Ascii view available
private variable address_length ;# Int: Length of addresses on left address bar
private variable physical_height ;# Int: Height of view in rows
private variable width ;# Int: Number of cells in left view in one row
@@ -162,7 +174,7 @@ class HexEditor {
if {$small} {
set view_font $view_font_s
set header_font $header_font_s
- } {
+ } else {
set view_font $view_font_n
set header_font $header_font_n
}
@@ -189,6 +201,11 @@ class HexEditor {
catch {
destroy $main_frame
}
+
+ # Remove find dialog window if exists
+ if {[winfo exists $find_dialog_win]} {
+ destroy $find_dialog_win
+ }
}
## Create popup menu (for left & right view)
@@ -210,14 +227,17 @@ class HexEditor {
"find_next" {1downarrow} {}}
{command {Find previous} {Shift+F3} 8
"find_prev" {1uparrow} {}}
- } $popup_menu 0 "$this " 0 {}
+ {separator}
+ {command {Fill with pseudo-random values} {} 0
+ "text_random" {} {}}
+ } $popup_menu 0 "$this " 0 {} [namespace current]
# Configure menu entries
$popup_menu entryconfigure [::mc "Find next"] -state disabled
$popup_menu entryconfigure [::mc "Find previous"] -state disabled
}
- ## Create all hexeditor widgets expect popup menu
+ ## Create all hex editor widgets expect popup menu
# @return void
private method create_gui {} {
# Determinate width of left view text widget and cell width
@@ -240,13 +260,16 @@ class HexEditor {
}
# Create button "Select All" in left top corner
- set left_top_button [button $main_frame.left_top_button \
- -bg $header_bg -bd 0 -padx 0 -pady 0 \
- -activebackground white -relief flat \
- -highlightthickness 0 \
- -command "$main_frame.left_view tag add sel 1.0 end" \
- ]
- DynamicHelp::add $main_frame.left_top_button -text [mc "Select all"]
+ if {!$::MICROSOFT_WINDOWS} {
+ set left_top_button [button $main_frame.left_top_button \
+ -bg $header_bg -bd 0 -padx 0 -pady 0 \
+ -activebackground white -relief flat \
+ -highlightthickness 0 \
+ -command "$main_frame.left_view tag add sel 1.0 end" \
+ ]
+ DynamicHelp::add $main_frame.left_top_button -text [mc "Select all"]
+ grid $left_top_button -row 0 -column 0 -sticky nsew
+ }
# Create left address bar
set left_address_bar [text $main_frame.left_address_bar \
-height $physical_height -width $address_length \
@@ -256,7 +279,6 @@ class HexEditor {
-yscrollcommand "$this scrollSet" \
-cursor left_ptr \
]
- grid $left_top_button -row 0 -column 0 -sticky nsew
grid $left_address_bar -row 1 -column 0 -sticky ns
# Create horizontal header for left view
@@ -315,7 +337,7 @@ class HexEditor {
grid rowconfigure $main_frame 1 -weight 1
}
- ## Create event bindings for all hexeditor widgets (except popup menu)
+ ## Create event bindings for all hex editor widgets (except popup menu)
# @return void
private method create_bindings {} {
## LEFT PART
@@ -363,6 +385,8 @@ class HexEditor {
} {
bind $left_view $key "[bind Text $key]; break"
}
+ bind $left_view <Double-Button-1> {break}
+ bind $left_view <Triple-Button-1> {break}
bind $left_view <Button-4> "$this scroll scroll -3 units"
bind $left_view <Button-5> "$this scroll scroll +3 units"
@@ -430,6 +454,8 @@ class HexEditor {
} {
bind $right_view $key "[bind Text $key]; break"
}
+ bind $right_view <Double-Button-1> {break}
+ bind $right_view <Triple-Button-1> {break}
bind $right_view <Button-4> "$this scroll scroll -3 units"
bind $right_view <Button-5> "$this scroll scroll +3 units"
@@ -449,31 +475,35 @@ class HexEditor {
-background $current_full_bg \
-foreground {#000000}
# Cursor position for active view and inactive view
- foreach widget [list $left_header $left_view] {
+ foreach widget [list $left_header $left_view] \
+ font [list $header_font $view_font] \
+ {
$widget tag configure tag_current_full \
- -font $header_font \
+ -font $font \
-background $current_full_bg \
-foreground {#000000}
$widget tag configure tag_current_half \
- -font $header_font \
+ -font $font \
-background $current_half_bg \
-foreground {#000000}
}
# Nth row backrgound
- $left_view tag configure tag_n_row -background $n_row_bg
+ $left_view tag configure tag_n_row \
+ -background $n_row_bg \
+ -font $view_font
# Cell highlight
$left_view tag configure tag_hg \
-foreground $highlight_fg \
- -font $header_font
+ -font $view_font
$left_view tag configure tag_bg_hg \
-background $highlight_bg \
- -font $header_font
+ -font $view_font
$left_view tag configure tag_bg_hg1 \
-background $highlight_bg1 \
- -font $header_font
+ -font $view_font
$left_view tag configure tag_bg_hg2 \
-background $highlight_bg2 \
- -font $header_font
+ -font $view_font
# Other tags
$left_view tag configure normal_font \
-font $view_font
@@ -525,28 +555,30 @@ class HexEditor {
# Cursor position for active view
$right_view tag configure tag_current_full \
- -font $header_font \
+ -font $view_font \
-background $current_full_bg
# Cursor position for inactive view
$right_view tag configure tag_current_half \
- -font $header_font \
+ -font $view_font \
-background $current_half_bg
# Nth row backrgound
- $right_view tag configure tag_n_row -background $n_row_bg
+ $right_view tag configure tag_n_row \
+ -background $n_row_bg \
+ -font $view_font
# Cell highlight
$right_view tag configure tag_hg \
-foreground $highlight_fg \
- -font $header_font
+ -font $view_font
$right_view tag configure tag_bg_hg \
-background $highlight_bg \
- -font $header_font
+ -font $view_font
$right_view tag configure tag_bg_hg1 \
-background $highlight_bg1 \
- -font $header_font
+ -font $view_font
$right_view tag configure tag_bg_hg2 \
-background $highlight_bg2 \
- -font $header_font
+ -font $view_font
# Other tags
$right_view tag configure normal_font \
@@ -638,7 +670,7 @@ class HexEditor {
$left_header delete 1.0 end
if {$view_mode == {hex}} {
set space { }
- } {
+ } else {
$left_header insert end { }
set space { }
}
@@ -704,7 +736,7 @@ class HexEditor {
if {$cell} {
if {$view_mode != {hex}} {
set start_col [expr {$cell * 4}]
- } {
+ } else {
set start_col [expr {$cell * 3}]
}
}
@@ -713,7 +745,7 @@ class HexEditor {
set end_col $start_col
if {$view_mode != {hex}} {
incr end_col 3
- } {
+ } else {
incr end_col 2
}
@@ -730,13 +762,13 @@ class HexEditor {
if {$view == {left}} {
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
scan [$left_view index $index] {%d.%d} row col
set cell [expr {($col / $step)}]
# Right view
- } {
+ } else {
scan [$right_view index $index] {%d.%d} row cell
}
@@ -751,7 +783,7 @@ class HexEditor {
private method col_to_start_end {col} {
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
@@ -835,7 +867,7 @@ class HexEditor {
if {($col % 4) == 3} {
set index [$left_view index "$index+1c"]
}
- } {
+ } else {
if {($col % 3) == 2} {
set index [$left_view index "$index+1c"]
}
@@ -854,7 +886,7 @@ class HexEditor {
scan [$right_view index insert] {%d.%d} row cell
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
set cursor_address_original $cursor_address
@@ -933,6 +965,43 @@ class HexEditor {
}
}
+ ## Fill the selected are with random values
+ # @return void
+ public method text_random {} {
+ #
+ if {$selected_view == {left}} {
+ set view_widget $left_view
+
+ } elseif {$ascii_view && $selected_view == {right}} {
+ set view_widget $right_view
+
+ } else {
+ return
+ }
+
+ #
+ if {![llength [$view_widget tag nextrange sel 0.0]]} {
+ return
+ }
+
+ #
+ set start_address [index_to_address $selected_view [$view_widget index sel.first]]
+ set end_address [index_to_address $selected_view [$view_widget index sel.last]]
+
+ #
+ for {set i $start_address} {$i <= $end_address} {incr i} {
+ if {$i >= $total_capacity} {
+ break
+ }
+
+ set value [expr {int(256 * rand()) & 0x0ff}]
+ setValue $i $value
+ if {$cell_value_changed_cmd_set} {
+ eval "$cell_value_changed_cmd $i $value"
+ }
+ }
+ }
+
## Synchronize selection in right view with left view
# Binding for event <<Selection>>
# @return void
@@ -944,7 +1013,7 @@ class HexEditor {
if {![llength [$right_view tag nextrange sel 0.0]]} {
set selection_sync_in_P 0
set anything_selected 0
- } {
+ } else {
set anything_selected 1
}
@@ -968,7 +1037,7 @@ class HexEditor {
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
@@ -1033,7 +1102,7 @@ class HexEditor {
eval $scroll_action_cmd
}
- update idle
+ update idletasks
set scroll_in_progress 0
}
@@ -1050,7 +1119,7 @@ class HexEditor {
if {![llength [$left_view tag nextrange sel 0.0]]} {
set selection_sync_in_P 0
set anything_selected 0
- } {
+ } else {
set anything_selected 1
}
@@ -1106,7 +1175,7 @@ class HexEditor {
# Get clipboard contents
if {[catch {
set text [clipboard get]
- }]} {
+ }]} then {
set text {}
}
# If clipboard empty then return
@@ -1316,7 +1385,7 @@ class HexEditor {
}
}
- ## Invoke hexeditor popup menu
+ ## Invoke hex editor popup menu
# @parm String side - "left" or "right"
# @parm Int x - Relative mouse pointer position
# @parm Int y - Relative mouse pointer position
@@ -1328,7 +1397,7 @@ class HexEditor {
if {$selected_view == {left}} {
set widget $left_view
left_view_move_insert $x $y
- } {
+ } else {
set widget $right_view
}
@@ -1343,16 +1412,16 @@ class HexEditor {
# Configure popup menu
if {[llength [$widget tag nextrange sel 0.0]]} {
$popup_menu entryconfigure [::mc "Copy"] -state normal
- } {
+ } else {
$popup_menu entryconfigure [::mc "Copy"] -state disabled
}
if {[catch {
if {[string length [clipboard get]]} {
$popup_menu entryconfigure [::mc "Paste"] -state normal
- } {
+ } else {
$popup_menu entryconfigure [::mc "Paste"] -state disabled
}
- }]} {
+ }]} then {
$popup_menu entryconfigure [::mc "Paste"] -state disabled
}
@@ -1449,7 +1518,7 @@ class HexEditor {
if {($val < 127) && [string is print -strict $char]} {
$right_view insert $cell $char
$right_view tag remove tag_np $cell "$cell+1c"
- } {
+ } else {
$right_view insert $cell {.}
$right_view tag add tag_np $cell "$cell+1c"
}
@@ -1459,7 +1528,7 @@ class HexEditor {
# Adjust insertion cursor
if {($row == $height) && ($col >= ($left_view_width - 1))} {
left_view_adjust_cursor
- } {
+ } else {
left_view_movement 0 Right
}
}
@@ -1541,7 +1610,7 @@ class HexEditor {
}
if {$col == $col_s} {
set correction {-2c}
- } {
+ } else {
set correction {-1c}
}
}
@@ -1552,7 +1621,7 @@ class HexEditor {
}
if {$col == $col_e} {
set correction {+2c}
- } {
+ } else {
set correction {+1c}
}
}
@@ -1599,10 +1668,10 @@ class HexEditor {
# Adjust selection
if {!$select} {
set cur_idx [$left_view index insert]
- } {
+ } else {
if {[$left_view compare $cur_idx <= insert]} {
$left_view tag add sel $cur_idx insert
- } {
+ } else {
$left_view tag add sel insert $cur_idx
}
}
@@ -1687,7 +1756,7 @@ class HexEditor {
scan $index {%d.%d} row col
if {$view_mode != {hex}} {
set step 4
- } {
+ } else {
set step 3
}
@@ -1730,13 +1799,13 @@ class HexEditor {
return $popup_menu
}
- ## Get list of values from hexeditor
+ ## Get list of values from hex editor
# @parm Int start - Start address
# @parm Int end - End address
# @return List - List of decimal values (e.g. {0 226 {} {} 126 {} 6 8})
public method get_values {start end} {
# Check for allowed address range
- if {$DEBUG} {
+ if {${::DEBUG}} {
if {$end >= $total_capacity} {
error "Address out of range"
}
@@ -1764,7 +1833,7 @@ class HexEditor {
if {$view_mode != {hex}} {
set step 4
set len 3
- } {
+ } else {
set step 3
set len 2
}
@@ -1813,7 +1882,7 @@ class HexEditor {
if {$start == $end} {
return [lindex $result 0]
- } {
+ } else {
return $result
}
}
@@ -1837,7 +1906,7 @@ class HexEditor {
$left_view delete $row.$start_col $row.$end_col
if {$view_mode != {hex}} {
$left_view insert $row.$start_col { }
- } {
+ } else {
$left_view insert $row.$start_col { }
}
$left_view mark set insert $index
@@ -1854,7 +1923,7 @@ class HexEditor {
if {$cursor_address == $address} {
if {$selected_view == {left}} {
left_view_adjust_cursor
- } {
+ } else {
right_view_adjust_cursor
}
}
@@ -1867,7 +1936,7 @@ class HexEditor {
}
# Validate input address and value
- if {$DEBUG} {
+ if {${::DEBUG}} {
if {$address >= $total_capacity} {
error "Address out of range"
}
@@ -1926,7 +1995,7 @@ class HexEditor {
if {($original_value < 127) && [string is print -strict $value]} {
$right_view insert $row.$cell $value
$right_view tag remove tag_np $row.$cell "$row.$cell+1c"
- } {
+ } else {
$right_view insert $row.$cell {.}
$right_view tag add tag_np $row.$cell $row.$end_col
}
@@ -1945,7 +2014,7 @@ class HexEditor {
if {$cursor_address == $address} {
if {$selected_view == {left}} {
left_view_adjust_cursor
- } {
+ } else {
right_view_adjust_cursor
}
}
@@ -1962,7 +2031,7 @@ class HexEditor {
}
if {$selected_view == {left}} {
focus $right_view
- } {
+ } else {
focus $left_view
}
}
@@ -1994,7 +2063,7 @@ class HexEditor {
# @return void
public method set_bg_hg {address bool type} {
# Validate input address
- if {$DEBUG} {
+ if {${::DEBUG}} {
if {$address >= $total_capacity} {
error "Address out of range"
}
@@ -2020,7 +2089,7 @@ class HexEditor {
set tag {tag_bg_hg2}
}
}
- if {[subst "\$${arr}($address)"] == $bool} {
+ if {[subst -nocommands "\$${arr}($address)"] == $bool} {
return
}
set ${arr}($address) $bool
@@ -2035,7 +2104,7 @@ class HexEditor {
# Create highlight
if {$bool} {
set bool {add}
- } {
+ } else {
set bool {remove}
}
$left_view tag $bool $tag $row.$start_col $row.$end_col
@@ -2050,7 +2119,7 @@ class HexEditor {
# @return void
public method setHighlighted {address bool} {
# Validate input address
- if {$DEBUG} {
+ if {${::DEBUG}} {
if {$address >= $total_capacity} {
error "Address out of range"
}
@@ -2077,7 +2146,7 @@ class HexEditor {
# Create highlight
if {$bool} {
set bool {add}
- } {
+ } else {
set bool {remove}
}
$left_view tag $bool tag_hg $row.$start_col $row.$end_col
@@ -2152,7 +2221,7 @@ class HexEditor {
$left_view mark set insert $row.$start_col
$left_view see insert
left_view_adjust_cursor
- } {
+ } else {
$right_view mark set insert $row.$cell
$right_view see insert
right_view_adjust_cursor
@@ -2177,7 +2246,7 @@ class HexEditor {
# Adjust cursor
if {$selected_view == {left}} {
$left_view see $row.$start_col
- } {
+ } else {
$right_view see $row.$cell
}
}
@@ -2256,7 +2325,7 @@ class HexEditor {
[index_to_address {left} [$left_view index sel.first+1c]] \
[index_to_address {left} [$left_view index sel.last-1c]] \
]
- } {
+ } else {
return {}
}
}
@@ -2340,13 +2409,13 @@ class HexEditor {
foreach val $values {
if {!$first} {
$left_view insert $lineend { }
- } {
+ } else {
set first 0
}
if {$val == {}} {
$left_view insert $lineend $space
continue
- } {
+ } else {
set val [string trimleft $val 0]
if {$val == {}} {
set val 0
@@ -2358,7 +2427,7 @@ class HexEditor {
set val [expr "0x$val"]
# HEX -> OCT
- } {
+ } else {
set val [expr "0x$val"]
set val [format {%o} $val]
}
@@ -2369,7 +2438,7 @@ class HexEditor {
set val [format %X $val]
# DEC -> OCT
- } {
+ } else {
set val [format %o $val]
}
}
@@ -2380,7 +2449,7 @@ class HexEditor {
set val [format %X $val]
# OCT -> DEC
- } {
+ } else {
set val [expr "0$val"]
}
}
@@ -2418,31 +2487,39 @@ class HexEditor {
}
}
- ## Set hexeditor enabled/disabled state
+ ## Set hex editor enabled/disabled state
# @parm Bool bool - 1 == enabled; 0 == disabled
# @return void
public method setDisabled {bool} {
set disabled $bool
- # Set state for left view
if {$bool} {
- $left_view configure -state disabled
+ set state {disabled}
+ } else {
+ set state {normal}
+ }
+
+ # Set state for the left view
+ $left_view configure -state $state
+ if {$bool} {
$left_view configure -bg {#F8F8F8} -fg {#999999} ;#DDDDDD
- } {
- $left_view configure -state normal
+ } else {
$left_view configure -bg {#FFFFFF} -fg {#000000}
}
- # Set state for right view
+ # Set state for the right view
if {$ascii_view} {
+ $right_view configure -state $state
if {$bool} {
- $right_view configure -state disabled
$right_view configure -bg {#F8F8F8} -fg {#999999} ;#DDDDDD
- } {
- $right_view configure -state normal
+ } else {
$right_view configure -bg {#FFFFFF} -fg {#000000}
}
}
+
+ # Set state for certain menu entries
+ $popup_menu entryconfigure [::mc "Paste"] -state $state
+ $popup_menu entryconfigure [::mc "Fill with pseudo-random values"] -state $state
}
## Get reference of left view text widget
@@ -2481,7 +2558,7 @@ class HexEditor {
}
}
- ## Find next occurence of search string
+ ## Find next occurrence of search string
# @return Bool - 0 == Invalid call; 1 == Valid call
public method find_next {} {
if {$last_find_index == {}} {
@@ -2489,13 +2566,13 @@ class HexEditor {
}
if {$find_opt(bw)} {
set result [find_FIND $last_find_index-[string length $text_to_find]c]
- } {
+ } else {
set result [find_FIND $last_find_index]
}
return $result
}
- ## Find previous occurence of search string
+ ## Find previous occurrence of search string
# @return Bool - 0 == Invalid call; 1 == Valid call
public method find_prev {} {
if {$last_find_index == {}} {
@@ -2507,7 +2584,7 @@ class HexEditor {
if {$find_opt(bw)} {
set result [find_FIND $last_find_index-[string length $text_to_find]c]
- } {
+ } else {
set result [find_FIND $last_find_index]
}
@@ -2518,10 +2595,12 @@ class HexEditor {
## Invoke dialog: Find string
# @return Bool - 1 == string found; 0 == string not found
public method find_dialog {} {
- # Create toplevel find_dialog_window
+ # Remove previous find dialog windows
if {[winfo exists $find_dialog_win]} {
destroy $find_dialog_win
}
+
+ # Create toplevel find_dialog_window
incr find_dialog_count
set find_dialog_win [toplevel .hex_editor_find_dialog_$find_dialog_count]
@@ -2579,13 +2658,13 @@ class HexEditor {
-compound left \
-image ::ICONS::16::ok \
-command "$this find_FIND" \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-text [mc "Cancel"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command "$this find_CANCEL" \
- ] -side left
+ ] -side left -padx 2
# Events binding (Enter == Find; Escape == Cancel)
bind $find_dialog_win <KeyRelease-Return> "$this find_FIND; break"
@@ -2594,7 +2673,7 @@ class HexEditor {
# Pack dialog frames
pack $top_frame -fill both -anchor nw -padx 5 -pady 5
- pack $buttonFrame -side bottom -anchor e -padx 5
+ pack $buttonFrame -side bottom -anchor e -padx 5 -pady 5
# Window manager options -- modal find_dialog_window
wm iconphoto $find_dialog_win ::ICONS::16::find
@@ -2613,7 +2692,7 @@ class HexEditor {
tkwait window $find_dialog_win
if {$last_find_index == {}} {
return 0
- } {
+ } else {
return 1
}
}
@@ -2629,18 +2708,18 @@ class HexEditor {
set start_index [lindex $args 0]
if {$where_to_search == {left}} {
set widget $left_view
- } {
+ } else {
set widget $right_view
}
if {$find_opt(bw)} {
set direction {-backwards}
- } {
+ } else {
set direction {-forwards}
}
if {$start_index == {}} {
if {$find_opt(fc)} {
set start_index [$widget index insert]
- } {
+ } else {
set start_index 1.0
}
}
@@ -2663,13 +2742,13 @@ class HexEditor {
set result 1
# String not found
- } {
+ } else {
$popup_menu entryconfigure [::mc "Find next"] -state disabled
$popup_menu entryconfigure [::mc "Find previous"] -state disabled
if {[winfo exists $find_dialog_win]} {
set parent $find_dialog_win
- } {
+ } else {
set $main_frame
}
tk_messageBox \
@@ -2703,3 +2782,7 @@ array set ::HexEditor::find_opt {
fc 1
bw 0
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/lib/ihextools.tcl b/lib/lib/ihextools.tcl
index 071b178..458f799 100755..100644
--- a/lib/lib/ihextools.tcl
+++ b/lib/lib/ihextools.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 _IHEXTOOLS_TCL ] } {
+set _IHEXTOOLS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides some tools for manipulating IHEX8, binary and sim files.
@@ -100,7 +105,7 @@ namespace eval IHexTools {
set index 0 ;# Last search result
# Get number of LF chracters
- while 1 {
+ while {1} {
set index [string first "\n" $data $index]
if {$index == -1} {break}
incr index
@@ -217,7 +222,7 @@ namespace eval IHexTools {
# Return result
if {$error_count} {
return 0
- } {
+ } else {
return 1
}
}
@@ -276,15 +281,19 @@ namespace eval IHexTools {
# Adjust input data
regsub -all {\r\n?} $data "\n" data ;# Any EOL to LF
- regsub -all -line {\s*#.*$} $data {} data ;# Remove comments
- regsub {^[^\n]+\n} $data {} data ;# Discard the first line
+ regsub -all {\s*#[^\n]*\n} $data {} data ;# Remove comments
- set lineNum 0 ;# Line number
+ set lineNum -1 ;# Line number
# Iterate over lines in the given data
foreach line [split $data "\n"] {
incr lineNum ;# Increment line number
+ # Discard the first line
+ if {!$lineNum} {
+ continue
+ }
+
# Skip empty lines
if {$line == {}} {continue}
@@ -330,7 +339,7 @@ namespace eval IHexTools {
# Return result
if {$error_count} {
return 0
- } {
+ } else {
return 1
}
}
@@ -356,12 +365,12 @@ namespace eval IHexTools {
# Convert it to binary value
if {$hex == {}} {
append pad "\0"
- } {
+ } else {
if {$pad != {}} {
append result $pad
set pad {}
}
- append result [subst "\\x$hex"]
+ append result [subst -nocommands "\\x$hex"]
}
# Increment address
incr addr
@@ -446,6 +455,7 @@ namespace eval IHexTools {
# Append EOF and return result
append result {:00000001FF}
+ append result "\n"
return $result
}
@@ -474,7 +484,7 @@ namespace eval IHexTools {
set result $content($addr)
if {$result == {}} {
return -1
- } {
+ } else {
return $result
}
}
@@ -510,7 +520,7 @@ namespace eval IHexTools {
}
## Append error message to error_string
- # @parm Int line - Number of line where the error occured
+ # @parm Int line - Number of line where the error occurred
# @parm String - Error message
# @return void
proc Error {line string} {
@@ -518,6 +528,10 @@ namespace eval IHexTools {
variable error_string ;# Error messages
incr error_count
- append error_string [mc "Error at line %s:\t" $line] $string "\n"
+ append error_string [mc "Error at %s:\t" $line] $string "\n"
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/lib/innerwindow.tcl b/lib/lib/innerwindow.tcl
index f1d2505..4195e2d 100755..100644
--- a/lib/lib/innerwindow.tcl
+++ b/lib/lib/innerwindow.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 _INNERWINDOW_TCL ] } {
+set _INNERWINDOW_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -87,7 +92,7 @@ class InnerWindow {
ttk::style map InnerWindow_Active.TButton \
-background [list active $active_titclr] \
-relief [list active raised]
-
+
ttk::style configure InnerWindow_Inactive.TButton \
-background $inactive_titclr \
-padding 0 \
@@ -96,7 +101,7 @@ class InnerWindow {
ttk::style map InnerWindow_Inactive.TButton \
-background [list active $inactive_titclr] \
-relief [list active raised]
-
+
# Set object variables
set max_X 1000
set max_Y 1000
@@ -201,27 +206,27 @@ class InnerWindow {
}
## Get and/or set window geometry including frame and title bar
- # @parm Int = {} - Width
- # @parm Int = {} - Height
- # @parm Int = {} - Relative position -- X
- # @parm Int = {} - Relative position -- Y
+ # @parm Int w={} - Width
+ # @parm Int h={} - Height
+ # @parm Int x={} - Relative position -- X
+ # @parm Int y={} - Relative position -- Y
# Note: If you want to set only certain attributes then set others as {}
# @return Current window geometry {W H X Y}
- public method geometry args {
+ public method geometry {{w {}} {h {}} {x {}} {y {}}} {
# Set geometry
- if {[llength $args]} {
- if {[string length [lindex $args 0]]} {
- place $win -width [lindex $args 0]
+ if {$w != {} || $h != {} || $x != {} || $y != {}} {
+ if {[string length $w]} {
+ place $win -width $w
}
- if {[string length [lindex $args 1]]} {
- place $win -height [lindex $args 1]
- set win_height [lindex $args 1]
+ if {[string length $h]} {
+ place $win -height $h
+ set win_height $h
}
- if {[string length [lindex $args 2]]} {
- place $win -x [lindex $args 2]
+ if {[string length $x]} {
+ place $win -x $x
}
- if {[string length [lindex $args 3]]} {
- place $win -y [lindex $args 3]
+ if {[string length $y]} {
+ place $win -y $y
}
update
}
@@ -252,6 +257,10 @@ class InnerWindow {
## Event handler: window frame <FocusOut>
# @return void
public method focusout {} {
+ if {![winfo exists $win]} {
+ return
+ }
+
update
foreach widget [list $title_bar $title_label $win] {
$widget configure -bg $inactive_titclr
@@ -259,7 +268,6 @@ class InnerWindow {
foreach widget [list $close_button $coll_exp_but] {
$widget configure -style InnerWindow_Inactive.TButton
}
-
update
}
@@ -275,7 +283,7 @@ class InnerWindow {
pack forget $main_frame
place $win -height [expr {[winfo height $win.title_bar] + 4}]
# Unshade
- } {
+ } else {
set image _1uparrow
pack $main_frame -fill both -expand 1
place $win -height $win_height
@@ -335,7 +343,7 @@ class InnerWindow {
focus $win
if {!$menu_created} {
- menuFactory $MENU $menu 0 "$this " 0 {}
+ menuFactory $MENU $menu 0 "$this " 0 {} [namespace current]
set menu_created 1
}
@@ -358,3 +366,7 @@ class InnerWindow {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/lib/modern_notebook.tcl b/lib/lib/modern_notebook.tcl
new file mode 100644
index 0000000..a9760ed
--- /dev/null
+++ b/lib/lib/modern_notebook.tcl
@@ -0,0 +1,691 @@
+#! /usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# Copyright (C) 2012 by Martin Ošmera #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+proc ModernNoteBook {pathname args} {
+ if {[llength $args]} {
+ return [ModernNoteBookClass #auto $pathname $args]
+ } else {
+ return [ModernNoteBookClass #auto $pathname]
+ }
+}
+class ModernNoteBookClass {
+ common font_size 12
+ common button_font [font create -family {helvetica} -size [expr {int(-$font_size * $::font_size_factor)}] -weight {normal}]
+
+ private variable button_counter 0
+ private variable tab_but_enter_cmd {}
+ private variable tab_but_leave_cmd {}
+ private variable event_bindings [list]
+ private variable common_tab_but_width 0
+ private variable common_tab_but_height 0
+ private variable scroll_buttons_visible 0
+ private variable total_tabbar_width 0
+ private variable last_width -1
+
+ private variable pages [list]
+ private variable options
+
+ private variable current_page -1
+ private variable tabbar_hidden 0
+
+ private variable main_frame
+ private variable tab_bar_frame
+ private variable pages_area_frame
+ private variable pages_area_frame_f
+ private variable tab_bar_frame_left
+ private variable tab_bar_frame_middle
+ private variable tab_bar_frame_middle_sc
+ private variable tab_bar_frame_right
+ private variable tab_bar_frame_left_b
+ private variable tab_bar_frame_right_b
+
+ constructor {pathname args} {
+ set options(pathname) $pathname
+ set options(homogeneous) 0
+ set options(autohide) 0
+ set options(tabpady) 0
+ set options(nomanager) 0
+
+ set args [lindex $args 0]
+ set length [llength $args]
+ for {set i 0; set j 1} {$i < $length} {incr i 2; incr j 2} {
+ set attr [lindex $args $i]
+ set val [lindex $args $j]
+
+ switch -- $attr {
+ {-homogeneous} {
+ if {![string is boolean $val]} {
+ error "Argument to option $attr must be a boolean."
+ }
+ set options(homogeneous) $val
+ }
+ {-autohide} {
+ if {![string is boolean $val]} {
+ error "Argument to option $attr must be a boolean."
+ }
+ set options(autohide) $val
+ }
+ {-tabpady} {
+ if {![string is digit $val]} {
+ error "Argument to option $attr must be an integer."
+ }
+ set options(tabpady) $val
+ }
+ {-nomanager} {
+ if {![string is boolean $val]} {
+ error "Argument to option $attr must be a boolean."
+ }
+ set options(nomanager) $val
+ }
+ {-font} {
+ set button_font $val
+ set font_size [expr {abs([font configure $val -size])}]
+ }
+ default {
+ error "Unknown argument: $attr"
+ }
+ }
+ }
+
+ set main_frame [frame $pathname]
+ set tab_bar_frame [frame $main_frame.tab_bar_frame]
+ set pages_area_frame_f [frame $main_frame.pages_area_frame -bd 1 -relief raised]
+ pack $pages_area_frame_f -side bottom -fill both -expand 1
+ set pages_area_frame [PagesManager $pages_area_frame_f.pages_manager]
+
+ set tab_bar_frame_right [frame $tab_bar_frame.right_frame]
+ set tab_bar_frame_middle [frame $tab_bar_frame.middle_frame]
+
+ if {!$options(autohide)} {
+ pack $tab_bar_frame -side top -fill both -before $pages_area_frame_f
+ } else {
+ set tabbar_hidden 1
+ $pages_area_frame_f configure -bd 0
+ }
+ if {!$options(nomanager)} {
+ pack $pages_area_frame -side bottom -fill both -expand 1
+ } else {
+ pack forget $pages_area_frame_f
+ }
+
+ pack $tab_bar_frame_right -side right -fill y
+ pack $tab_bar_frame_middle -fill x -expand 1 -side left -after $tab_bar_frame_right
+
+ set tab_bar_frame_middle [ScrollableFrame $tab_bar_frame_middle.inner_frame -height $common_tab_but_height]
+ set tab_bar_frame_middle_sc [$tab_bar_frame_middle getframe]
+ pack $tab_bar_frame_middle -fill x
+
+ set tab_bar_frame_left [ttk::button \
+ $tab_bar_frame_right.button_l \
+ -style Flat.TButton \
+ -image ::ICONS::16::1leftarrow \
+ -command [list $tab_bar_frame_middle xview scroll -10 units] \
+ ]
+ set tab_bar_frame_right [ttk::button \
+ $tab_bar_frame_right.button_r \
+ -style Flat.TButton \
+ -image ::ICONS::16::1rightarrow \
+ -command [list $tab_bar_frame_middle xview scroll 10 units] \
+ ]
+ }
+
+
+ public method show_pages_area {} {
+ if {$options(nomanager)} {
+ pack $pages_area_frame -side bottom -fill both -expand 1
+ set options(nomanager) 0
+ }
+ }
+ public method hide_pages_area {} {
+ if {!$options(nomanager)} {
+ pack forget $pages_area_frame
+ set options(nomanager) 1
+ }
+ }
+ public method deselect_tab_button {} {
+ set current_page -1
+ redraw_tab_bar
+ }
+
+ public method get_nb {} {
+ return $options(pathname)
+ }
+
+ public method itemconfigure {page args} {
+ set idx [lsearch -index 0 -ascii -exact $pages $page]
+ if {$idx == -1} {
+ error "No such page: $page"
+ return
+ }
+ set page_spec [lindex $pages $idx]
+
+ set arg_createcmd [lindex $page_spec 1]
+ set arg_image [lindex $page_spec 2]
+ set arg_leavecmd [lindex $page_spec 3]
+ set arg_raisecmd [lindex $page_spec 4]
+ set arg_state [lindex $page_spec 5]
+ set arg_text [lindex $page_spec 6]
+ set arg_helptext [lindex $page_spec 7]
+ set length [llength $args]
+ for {set i 0; set j 1} {$i < $length} {incr i 2; incr j 2} {
+ set attr [lindex $args $i]
+ set val [lindex $args $j]
+
+ switch -- $attr {
+ {-createcmd} {
+ set arg_createcmd $val
+ }
+ {-image} {
+ set arg_image $val
+ }
+ {-leavecmd} {
+ set arg_leavecmd $val
+ }
+ {-raisecmd} {
+ set arg_raisecmd $val
+ }
+ {-state} {
+ if {$val == {normal}} {
+ set val 0
+ } elseif {$val == {disabled}} {
+ set val 1
+ } else {
+ error "Possible values of $attr are: \"normal\" and \"disabled\"."
+ }
+ set arg_state $val
+ }
+ {-text} {
+ set arg_text $val
+ }
+ {-helptext} {
+ set arg_helptext $val
+ }
+ default {
+ error "Unknown argument: $attr"
+ }
+ }
+ }
+
+ set pages [lreplace $pages $idx $idx [list $page $arg_createcmd $arg_image $arg_leavecmd $arg_raisecmd $arg_state $arg_text $arg_helptext {} 0]]
+ redraw_tab_bar_completely
+ }
+
+ private method redraw_tab_bar_completely {} {
+ set common_tab_but_width 0
+ set common_tab_but_height 0
+ redraw_tab_bar 1
+ redraw_tab_bar
+ handle_resize
+ }
+
+ public method insert {index page args} {
+ set arg_createcmd {}
+ set arg_image {}
+ set arg_leavecmd {}
+ set arg_raisecmd {}
+ set arg_state 0
+ set arg_text {}
+ set arg_helptext {}
+ set length [llength $args]
+ for {set i 0; set j 1} {$i < $length} {incr i 2; incr j 2} {
+ set attr [lindex $args $i]
+ set val [lindex $args $j]
+
+ switch -- $attr {
+ {-createcmd} {
+ set arg_createcmd $val
+ }
+ {-image} {
+ set arg_image $val
+ }
+ {-leavecmd} {
+ set arg_leavecmd $val
+ }
+ {-raisecmd} {
+ set arg_raisecmd $val
+ }
+ {-state} {
+ if {$val == {normal}} {
+ set val 0
+ } elseif {$val == {disabled}} {
+ set val 1
+ } else {
+ error "Possible values of $attr are: \"normal\" and \"disabled\"."
+ }
+ set arg_state $val
+ }
+ {-text} {
+ set arg_text $val
+ }
+ {-helptext} {
+ set arg_helptext $val
+ }
+ default {
+ error "Unknown argument: $attr"
+ }
+ }
+ }
+
+ if {[lsearch -ascii -exact -index 0 $pages $page] != -1} {
+ error "Page already exists: $page"
+ }
+
+ if {$current_page != -1} {
+ set current_page_id [lindex $pages [list $current_page 0]]
+ }
+ set pages [linsert $pages $index [list $page $arg_createcmd $arg_image $arg_leavecmd $arg_raisecmd $arg_state $arg_text $arg_helptext 0 {} 0]]
+ $pages_area_frame add $page
+ [$pages_area_frame getframe $page] configure -bg ${::COMMON_BG_COLOR} -padx 5 -pady 5
+ if {$current_page != -1} {
+ set current_page [lsearch -index 0 -ascii -exact $pages $current_page_id]
+ if {$current_page != -1} {
+ $this see $current_page_id
+ }
+ }
+
+ redraw_tab_bar_completely
+
+ if {$options(autohide) && ([llength $pages] > 1)} {
+ show_hide_tabbar 1
+ }
+
+ return [$pages_area_frame getframe $page]
+ }
+ public method bindtabs {event command} {
+ if {$event == {<Enter>}} {
+ set tab_but_enter_cmd $command
+ } elseif {$event == {<Leave>}} {
+ set tab_but_leave_cmd $command
+ } else {
+ set idx [lsearch -ascii -exact -index 0 $event_bindings $event]
+ if {$idx == -1} {
+ lappend event_bindings [list $event $command]
+ } else {
+ set event_bindings [lreplace $event_bindings $idx $idx [list $event $command]]
+ }
+ reset_event_bindings
+ }
+ }
+
+ public method see {page} {
+ set idx [lsearch -index 0 -ascii -exact $pages $page]
+ if {$idx == -1} {
+ error "No such page: $page"
+ return
+ }
+
+ $tab_bar_frame_middle see [lindex $pages [list $idx end-1]]
+ }
+ public method getframe {page} {
+ return [$pages_area_frame getframe $page]
+ }
+
+ public method move {page index} {
+ set idx [lsearch -index 0 -ascii -exact $pages $page]
+ if {$idx == -1} {
+ error "No such page: $page"
+ return
+ }
+ if {$index != {end} && $index >= [llength $pages]} {
+ error "Index out of range: $index"
+ return
+ }
+
+ if {$current_page != -1} {
+ set current_page_id [lindex $pages [list $current_page 0]]
+ }
+ set page_spec [lindex $pages $idx]
+ set pages [lreplace $pages $idx $idx]
+ set pages [linsert $pages $index $page_spec]
+ if {$current_page != -1} {
+ set current_page [lsearch -index 0 -ascii -exact $pages $current_page_id]
+ if {$current_page != -1} {
+ $this see $current_page_id
+ }
+ }
+ redraw_tab_bar
+ }
+ public method pages {} {
+ set result [list]
+ foreach page_spec $pages {
+ lappend result [lindex $page_spec 0]
+ }
+ return $result
+ }
+ public method index {page} {
+ return [lsearch -index 0 -ascii -exact $pages $page]
+ }
+ public method delete {page} {
+ set idx [lsearch -index 0 -ascii -exact $pages $page]
+ if {$idx == -1} {
+ error "No such page: $page"
+ return
+ }
+ $pages_area_frame delete $page
+ if {($current_page != -1) && ($current_page != $idx)} {
+ set current_page_id [lindex $pages [list $current_page 0]]
+ }
+ set pages [lreplace $pages $idx $idx]
+ if {![llength $pages]} {
+ set current_page -1
+ } elseif {$current_page == $idx} {
+ set current_page -1
+ } elseif {$current_page != -1} {
+ set current_page [lsearch -index 0 -ascii -exact $pages $current_page_id]
+ if {$current_page != -1} {
+ $this see $current_page_id
+ }
+ }
+ if {$options(autohide) && ([llength $pages] < 2)} {
+ show_hide_tabbar 0
+ } else {
+ redraw_tab_bar_completely
+ }
+ }
+ public method show_hide_tabbar {{show {}}} {
+ if {$show == {}} {
+ return $tabbar_hidden
+ }
+
+ if {![string is boolean $show]} {
+ error "show must be a boolean ({$show} given)"
+ }
+
+ if {$show && $tabbar_hidden} {
+ # Show it
+ if {$options(nomanager)} {
+ pack $tab_bar_frame -side top -fill both
+ } else {
+ pack $tab_bar_frame -side top -fill both -before $pages_area_frame_f
+ }
+ set tabbar_hidden 0
+ $pages_area_frame_f configure -bd 1
+ } elseif {!$show && !$tabbar_hidden} {
+ # Hide it
+ pack forget $tab_bar_frame
+ set tabbar_hidden 1
+ $pages_area_frame_f configure -bd 0
+ }
+ }
+
+ public method raise {{page {}} {by_click 0}} {
+ if {$page == {}} {
+ if {$current_page == -1} {
+ return {}
+ }
+ return [lindex $pages [list $current_page 0]]
+ }
+
+ set idx [lsearch -index 0 -ascii -exact $pages $page]
+ if {$idx == -1} {
+ error "No such page: $page"
+ return
+ }
+ if {$current_page == $idx || [lindex $pages [list $idx 5]]} {
+ return
+ }
+
+ if {$current_page != -1 && $current_page < [llength $pages]} {
+ uplevel #0 [lindex $pages [list $current_page 3]]
+ set_tab_but_bg_color n [lindex $pages [list $current_page end-1]]
+ }
+
+ $pages_area_frame raise $page
+ $this see $page
+
+ set current_page $idx
+ if {$by_click} {
+ set_tab_but_bg_color ae [lindex $pages [list $current_page end-1]]
+ } else {
+ set_tab_but_bg_color a [lindex $pages [list $current_page end-1]]
+ }
+ if {![lindex $pages [list $current_page end]]} {
+ lset pages [list $current_page end] 1
+ set createcmd [lindex $pages [list $current_page 1]]
+ if {$createcmd != {}} {
+ uplevel #0 $createcmd
+ }
+ }
+ set raisecmd [lindex $pages [list $current_page 4]]
+ if {$raisecmd != {}} {
+ uplevel #0 $raisecmd
+ }
+ }
+
+ private method redraw_tab_bar {{only_compute 0}} {
+ if {!$only_compute} {
+ destroy $tab_bar_frame_middle
+ ScrollableFrame $tab_bar_frame_middle -height $common_tab_but_height
+ set tab_bar_frame_middle_sc [$tab_bar_frame_middle getframe]
+ pack $tab_bar_frame_middle -fill x -expand 1
+
+ bind $tab_bar_frame_middle <Configure> [list $this handle_resize]
+ }
+
+ set total_tabbar_width 0
+ set i -1
+ foreach page_spec $pages {
+ incr i
+ set tab_but [draw_button $tab_bar_frame_middle_sc $i [lindex $page_spec 6] [lindex $page_spec 2] [lindex $page_spec 7] $only_compute]
+ lset pages [list $i end-1] $tab_but
+
+ if {$only_compute} {
+ continue
+ }
+
+ pack $tab_but -side left
+ if {![lindex $page_spec 5]} {
+ bind $tab_but <Button-1> [format "%s\n%s" update [list $this raise [lindex $page_spec 0] 1]]
+ }
+ }
+ }
+
+ private method draw_button {target page_idx {text {}} {image {}} {helptext {}} {only_compute 0}} {
+ set label_width [font measure $button_font $text]
+ set image_width 0
+ set image_height 0
+ if {$image != {}} {
+ set image_width [image width $image]
+ set image_height [image height $image]
+ } else {
+ set image_height 16
+ }
+ set canvas_width [expr {$label_width + $image_width + 15}]
+ set canvas_height [expr {(($font_size > $image_height) ? $font_size : $image_height) + 6 + $options(tabpady)}]
+ if {$image_width} {
+ incr canvas_width 5
+ }
+
+ if {$options(homogeneous)} {
+ if {$canvas_width > $common_tab_but_width} {
+ set common_tab_but_width $canvas_width
+ } else {
+ set canvas_width $common_tab_but_width
+ }
+ }
+ if {$canvas_height > $common_tab_but_height} {
+ set common_tab_but_height $canvas_height
+ } else {
+ set canvas_height $common_tab_but_height
+ }
+
+ if {$only_compute} {
+ return {}
+ }
+
+ set cnv [canvas $target.b_$button_counter -bg {#E0E0E0} -width $canvas_width -height $canvas_height \
+ -bd 0 \
+ -highlightthickness 0 \
+ ]
+
+ set x 7
+ set y [expr {1 + int($canvas_height / 2)}]
+ if {$image != {}} {
+ $cnv create image $x $y -image $image -anchor w
+ incr x $image_width
+ incr x 5
+ if {$image_height > $canvas_height} {
+ incr y [expr {int(ceil(($image_height - $canvas_height) / 2))}]
+ }
+ }
+ $cnv create text $x $y -font $button_font -anchor w -justify left -text $text -tags txt
+
+ $cnv create line 1 0 [expr {$canvas_width - 1}] 0 -tags bg1
+ $cnv create line 1 1 [expr {$canvas_width - 1}] 1 -tags bg2
+ $cnv create line 0 1 0 $canvas_height -tags bg1
+ $cnv create line 1 1 1 $canvas_height -tags bg2
+ $cnv create line [expr {$canvas_width - 1}] 1 [expr {$canvas_width - 1}] $canvas_height -tags bg1
+ $cnv create line [expr {$canvas_width - 2}] 1 [expr {$canvas_width - 2}] $canvas_height -tags bg3
+ if {[lindex $pages [list $page_idx 5]]} {
+ set_tab_but_bg_color d $cnv
+ } elseif {$page_idx == $current_page} {
+ set_tab_but_bg_color a $cnv
+ } else {
+ set_tab_but_bg_color n $cnv
+ }
+
+ if {$helptext != {}} {
+ DynamicHelp::add $cnv -text $helptext
+ }
+
+ bind $cnv <Enter> +[list $this tab_but_enter $page_idx]
+ bind $cnv <Leave> +[list $this tab_but_leave $page_idx]
+ set_event_bindings $cnv $page_idx
+
+ incr button_counter
+ incr total_tabbar_width $canvas_width
+ return $cnv
+ }
+
+ private method set_event_bindings {but page_idx} {
+ foreach env_cmd $event_bindings {
+ bind $but [lindex $env_cmd 0] [format "%s %s" [lindex $env_cmd 1] [lindex $pages $page_idx 0]]
+ }
+ }
+
+ private method reset_event_bindings {} {
+ set i -1
+ foreach page_spec $pages {
+ incr i
+ set_event_bindings [lindex $page_spec end-1] $i
+ }
+ }
+
+ public method handle_resize {} {
+ if {$tabbar_hidden || ![winfo exists $tab_bar_frame_middle] || ![winfo viewable $tab_bar_frame_middle]} {
+ return
+ }
+ set current_width [winfo width $tab_bar_frame_middle]
+ if {$current_width == $last_width} {
+ return
+ }
+ set last_width $current_width
+
+ if {($current_width < $total_tabbar_width) && !$scroll_buttons_visible} {
+ set scroll_buttons_visible 1
+ pack $tab_bar_frame_left -side left
+ pack $tab_bar_frame_right -side left
+ } elseif {($current_width >= $total_tabbar_width) && $scroll_buttons_visible} {
+ set scroll_buttons_visible 0
+ pack forget $tab_bar_frame_left
+ pack forget $tab_bar_frame_right
+ }
+ }
+
+ private method set_tab_but_bg_color {code but} {
+ switch -- $code {
+ {a} {
+ set bg0 {#E0E0FF}
+ set bg1 {#9999FF}
+ set bg2 {#AAAAFF}
+ set bg3 {#CFCDFF}
+ set txt_fg {#000000}
+ }
+ {ae} {
+ set bg0 {#CCCCFF}
+ set bg1 {#9999FF}
+ set bg2 {#AAAAFF}
+ set bg3 {#CFCDFF}
+ set txt_fg {#000000}
+ }
+ {n} {
+ set bg0 ${::COMMON_BG_COLOR}
+ set bg1 {#BBBBBB}
+ set bg2 {#EEEBE7}
+ set bg3 {#CFCDC8}
+ set txt_fg {#000000}
+ }
+ {ne} {
+ set bg0 {#CCCCFF}
+ set bg1 {#9999CC}
+ set bg2 {#AAAADD}
+ set bg3 {#CFCDC8}
+ set txt_fg {#000000}
+ }
+ {d} {
+ set bg0 ${::COMMON_BG_COLOR}
+ set bg1 {#BBBBBB}
+ set bg2 {#EEEBE7}
+ set bg3 {#CFCDC8}
+ set txt_fg {#888888}
+ }
+ default {
+ error "ModernNoteBookClass::set_tab_but_bg_color: Invalid argument: code={$code}"
+ }
+ }
+
+ $but configure -bg $bg0
+ $but itemconfigure bg1 -fill $bg1
+ $but itemconfigure bg2 -fill $bg2
+ $but itemconfigure bg3 -fill $bg3
+ $but itemconfigure txt -fill $txt_fg
+ }
+
+ public method tab_but_enter {page_idx} {
+ set but [lindex $pages [list $page_idx end-1]]
+ if {[lindex $pages [list $page_idx 5]]} {
+ return
+ } elseif {$current_page == $page_idx} {
+ set_tab_but_bg_color ae $but
+ } else {
+ set_tab_but_bg_color ne $but
+ }
+ if {$tab_but_enter_cmd != {}} {
+ uplevel #0 [format "%s %s" $tab_but_enter_cmd [lindex $pages $page_idx 0]]
+ }
+ }
+
+ public method tab_but_leave {page_idx} {
+ set but [lindex $pages [list $page_idx end-1]]
+ if {[lindex $pages [list $page_idx 5]]} {
+ return
+ } elseif {$current_page == $page_idx} {
+ set_tab_but_bg_color a $but
+ } else {
+ set_tab_but_bg_color n $but
+ }
+ if {$tab_but_leave_cmd != {}} {
+ uplevel #0 [format "%s %s" $tab_but_leave_cmd [lindex $pages $page_idx 0]]
+ }
+ }
+}
diff --git a/lib/lib/settings.tcl b/lib/lib/settings.tcl
index 3c50466..8dd1c53 100755..100644
--- a/lib/lib/settings.tcl
+++ b/lib/lib/settings.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 _SETTINGS_TCL ] } {
+set _SETTINGS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements interface to program settings (which are stored in a file)
@@ -28,7 +33,7 @@
class Settings {
common dir_sep [file separator] ;# Directory separator (eg. '/')
- common count 0 ;# Counter of instances
+ common settings_count 0 ;# Counter of instances
private variable isEmpty 1 ;# Is settings array empty
private variable isReady 0 ;# Is interface ready
@@ -42,10 +47,10 @@ class Settings {
# @parm String configDir - Path to directory with settings file
# @parm String configFileName - Name of file with settings
constructor {configDir configFileName} {
- incr count ;# increment instance conter
+ incr settings_count ;# increment instance conter
# Incalize object variables
- set configArray "::Settings::S$count" ;# Array of settings
+ set configArray "::Settings::S${settings_count}" ;# Array of settings
set directory [string trimright $configDir "/\/"] ;# Path to directory with settings file
set filename [string trimleft $configFileName "/\/"] ;# Name of file with settings
set fileFullPath "${directory}${dir_sep}${filename}" ;# Full name of settings file
@@ -54,7 +59,7 @@ class Settings {
if {![file exists $fileFullPath]} {
if {[catch {
file mkdir $directory
- close [open $fileFullPath w 420]
+ close [open $fileFullPath w 0640]
}]} then {
return
} else {
@@ -65,7 +70,7 @@ class Settings {
} else {
if {$::MICROSOFT_WINDOWS || ([file readable $fileFullPath] && [file writable $fileFullPath])} {
set isReady 1
- } {
+ } else {
return
}
}
@@ -129,7 +134,7 @@ class Settings {
# Set variable isEmpty
if {[array size $configArray] != 0} {
set isEmpty 0
- } {
+ } else {
set isEmpty 1
}
@@ -147,7 +152,7 @@ class Settings {
}
# Local variables
- set configFile [open $fileFullPath w 420] ;# ID of config file chanel
+ set configFile [open $fileFullPath w 0640] ;# ID of config file chanel
set categories {general} ;# Name of current category
# Determinate list of categories
@@ -172,7 +177,7 @@ class Settings {
# Determinate key
regsub {^[^/]*/} $fullKey {} key
# Determinate value
- set value [subst "\$$configArray\(\$fullKey\)"]
+ set value [subst -nocommands "\$$configArray\(\$fullKey\)"]
regsub -all "\n" $value "\a" value
# Save key and value
puts $configFile "$key=\"$value\""
@@ -212,7 +217,7 @@ class Settings {
if {[i_contains $key]} {
unset "$configArray\($key\)"
return 1
- } {
+ } else {
return 0
}
}
@@ -233,7 +238,7 @@ class Settings {
private method i_contains {key} {
if {[array names $configArray -exact $key] == {}} {
return 0
- } {
+ } else {
return 1
}
}
@@ -258,8 +263,8 @@ class Settings {
# Check if the given key is defined
if {[i_contains $key]} {
- return [subst "\$$configArray\(\$key\)"]
- } {
+ return [subst -nocommands "\$$configArray\(\$key\)"]
+ } else {
return $default
}
}
@@ -291,3 +296,7 @@ class Settings {
return 1
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/list_of_files.txt b/lib/list_of_files.txt
new file mode 100644
index 0000000..112e79f
--- /dev/null
+++ b/lib/list_of_files.txt
@@ -0,0 +1,136 @@
+This file contains descriptions for files in this directory and its
+subdirectories. The aim is to make navigation through the code easier. Lines in
+this file might be very long.
+
+Last update: December 8, 2011
+Notes:
+ * List of files was generated by "tree" command
+ * This file might be incomplete
+ * Some file from 1.4.x version are not mentined here
+
+lib | Source files of the IDE
+├── bottompanel | Bottom panel in the main window
+│   ├── bottomnotebook.tcl | "Root component" of the bottom panel
+│   ├── calculator.tcl | Tab: Calculator
+│   ├── cvarsview.tcl | Tab: C variables
+│   ├── find_in_files.tcl | Tab: Find in files
+│   ├── graph.tcl | Tab: IO ports
+│   ├── graph_wdg.tcl | Graph widget used in the tab "IO ports"
+│   ├── messages.tcl | Tab: Messages
+│   ├── terminal.tcl | Tab: Terminal emulator
+│   └── todo.tcl | Tab: Notes
+├── cli.tcl | Implementation of the command line interface (CLI)
+├── compiler | Built-in assembler and interfaces for cooperation with external assemblers and SDCC compiler
+│   ├── assembler.tcl | Built-in assembler: Processes preprocessed code to generate object file and to instruct code listing generator
+│   ├── codelisting.tcl | Built-in assembler: Code listing generator
+│   ├── compilerconsts.tcl | Built-in assembler: Instruction set definition, etc. used by the assembler and other components of the IDE
+│   ├── compiler.tcl | Built-in assembler: Manages assembler settings, serves as entry point to assembler and prints some messages
+│   ├── disassembler.tcl | 8051 disassembler
+│   ├── external_compiler.tcl | Interface for cooperation with external assemblers and SDCC compiler
+│   └── preprocessor.tcl | Built-in assembler: Assembler pre-processor
+├── configdialogues | Graphical configuration dialogues
+│   ├── configdialogues.tcl | Root part of the configuration dialogues
+│   ├── compiler_config.tcl | Assembler and compiler configuration dialog
+│   ├── custom_commands_config.tcl | Configuration of user defined commands
+│   ├── editor_config.tcl | Source code editor configuration
+│   ├── global_config.tcl | "MCU 8051 IDE configuration dialog"
+│   ├── rightpanel_config.tcl | Settings for the right panel
+│   ├── shortcuts_config.tcl | Configuration dialog for key shortcuts
+│   ├── simulator_config.tcl | MCU simulator configuration dialog
+│   ├── terminal_config.tcl | Configuration of embedded terminal emulator (urxvt)
+│   └── toolbar_config.tcl | Configuration of the main toolbar
+├── custom_command.tcl | Implementation of user defined commands
+├── dialogues | Various GUI dialogues commonly used in the IDE
+│   ├── errorhandler.tcl | Reports internal program errors, bugs in the IDE
+│   ├── fsd.tcl | File selection dialog
+│   ├── my_tk_messageBox.tcl | Replacement for tk_messageBox
+│   ├── selectmcu.tcl | Dialog for MCU selection and tools for reading "database" of supported MCUs
+│   └── tips.tcl | Dialog "Tip of the Day" along with every functionality whit the dialog needs, see also file data/tips.xml
+├── editor | Built-in source code editor with all its components including support for external embedded editors like vim, etc.
+│   ├── editor.tcl | Root component of the editor
+│   ├── autocompletion.tcl | Auto-completion and dynamic generation of table of symbols used in the code
+│   ├── commandline.tcl | Editor command line
+│   ├── eventhandlers.tcl | Handlers for GUI events in the editor
+│   ├── exports.tcl | Export to XHTML and LaTeX
+│   ├── generalproc.tcl | General functions used by or provided by the editor
+│   ├── spell_check.tcl | Interface to the spell checker used by the IDE, Hunspell
+│   ├── ASMsyntaxhighlight.tcl | Syntax highlight for assembly language
+│   ├── Csyntaxhighlight.tcl | Syntax highlight for C language
+│   ├── LSTsyntaxhighlight.tcl | Syntax highlight for code listing
+│   └── R_ASMsyntaxhighlight.tcl | Syntax highlight for SDCC generated code for relocatable assembler
+├── environment.tcl | Root component of the entire GUI
+├── external_command.tcl | Interface for communication with an external program, like compiler or bash
+├── leftpanel | Left panel in the main window
+│   ├── filelist.tcl | Root component and tab "List of opened files" and tab "List of project files"
+│   ├── fsbrowser.tcl | Tab: File system browser
+│   └── sfrwatches.tcl | Tab: SFR watches
+├── lib | Things useful for this IDE and written for this IDE
+│   ├── hexeditor.tcl | Hexadecimal editor
+│   ├── ihextools.tcl | Tools for manipulating with Intel 8 Hex files
+│   ├── innerwindow.tcl | Implementation of MDI (Multiple document interface) in the IDE, for instance "Base Converter" tool use it
+│   ├── Math.tcl | Conversions between numeral systems and angle units in floating point arithmetic
+│   └── settings.tcl | Manipulation with IDE configuration file
+├── list_of_files.txt | This file
+├── maintab.tcl | Root component the GUI representing one opened project ...
+├── main.tcl | Main file of the entire IDE
+├── pale | "PALE" stands for Peripheral Abstraction Layer Engine, which essentially means nothing, but it implements the "Virtual HW"
+│   ├── pale.tcl | The PALE. This simulator component implements MCU simulation from point of view of electrical device
+│   ├── virtual_hw_component.tcl | Base class for all "Virtual HW" instances
+│   ├── leddisplay.tcl | Single LED display
+│   ├── multiplexedleddisplay.tcl | Multiplexed LED display
+│   ├── ledmatrix.tcl | LED matrix
+│   ├── ledpanel.tcl | LED panel
+│   ├── simplekeypad.tcl | Array of buttons
+│   ├── matrixkeypad.tcl | Matrix keypad
+│   ├── lcd_hd44780.tcl | Simulator of LCD character display controlled by HD44780.
+│   ├── hd44780_cgrom.tcl | Font definitions for HD44780 display driver simulator
+│   ├── ds1620.tcl | Simulator of DS1620 digital thermometer
+│   ├── virtual_uart_term.tcl | Simulated UART interface
+│   └── file_interface.tcl | File R/W interface to PALE
+├── project.tcl | Manages project files (extension .mcu8051ide), writing to them and reading from them
+├── rightpanel | Right panel in the main window
+│   ├── rightpanel.tcl | Root component of the panel
+│   ├── hwmanager.tcl | Tab: "Hardware plug-ins manager"
+│   ├── instructiondetails.tcl | Tab: "Instruction details"
+│   ├── regwatches.tcl | Tab: "register watches"
+│   └── subprograms.tcl | Tab: "Subprograms monitor"
+├── simulator | MCU Simulator
+│   ├── engine | Simulator engine
+│   │   ├── engine_auxiliary_alo_functions.tcl | Auxiliary ALO functions
+│   │   ├── engine_backward_stepping.tcl | Backward stepping related procedures
+│   │   ├── engine_control.tcl | Control procedures
+│   │   ├── engine_core.tcl | Simulator engine core
+│   │   ├── engine_external_interface_management.tcl | External interface management procedures
+│   │   ├── engine_hibernation.tcl | Hibernation related procedures
+│   │   ├── engine_initialization_cleanup.tcl | Initialization & cleanup related procedures
+│   │   ├── engine_instructions.tcl | Instruction procedures
+│   │   ├── engine_mcu_configuration.tcl | MCU configuration related procedures
+│   │   ├── engine_memory_management.tcl | Memory management related procedures
+│   │   ├── engine_opcodes.tcl | Opcode procedures
+│   │   ├── engine_text_based_interface.tcl | Command line interface for the simulator engine
+│   │   └── engine_virtual_hw_controller.tcl | Virtual hw controller procedures
+│   ├── simulator.tcl | Main part of the simulator
+│   ├── hibernate.tcl | Program hibernation functionality
+│   ├── bitmap.tcl | GUI tool: Bit addressable area viewer
+│   ├── interruptmonitor.tcl | GUI tool: Interrupt monitor
+│   ├── sfrmap.tcl | GUI tool: Map of SFR area
+│   ├── simulator_gui.tcl | GUI tool: Main simulator panel (displayed on the bottom panel)
+│   ├── stackmonitor.tcl | GUI tool: MCU stack monitor
+│   ├── stopwatch.tcl | GUI tool: Stopwatch timer
+│   └── uart_monitor.tcl | GUI tool: Monitor of simulated UART operations
+├── utilities | Other GUI tools which might be useful during the development for 8051
+│   ├── asciichart.tcl | ASCII chart viewer
+│   ├── table_of_instructions.tcl | Interactive table of 8051 instructions
+│   ├── baseconverter.tcl | Base converter
+│   ├── eightsegment.tcl | 8-segment editor
+│   ├── hexeditdlg.tcl | Project independent hexadecimal editor
+│   ├── notes.tcl | Scribble notepad
+│   ├── rs232debugger.tcl | RS-232/UART debugger
+│   ├── speccalc.tcl | Special calculator
+│   └── symbol_viewer.tcl | Assembly language symbol table viewer
+└── X.tcl | Well ... a little of everything, callback functions for the main menu, etc. dialogues like "Find", "Go to" and "Replace" and so on ...
+
+--------------------------------------------------------------------------------
+
+12 directories, 133 files
+135k lines of code, 4.1M of source code
diff --git a/lib/main.tcl b/lib/main.tcl
index 6a0f033..115d9a8 100755
--- a/lib/main.tcl
+++ b/lib/main.tcl
@@ -1,8 +1,11 @@
-#!/usr/bin/tclsh
+#!/bin/sh
+# the next line restarts using wish \
+exec tclsh "$0" "$@"
+
# 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 +24,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _MAIN_TCL ] } {
+set _MAIN_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -29,15 +37,18 @@
# GENERAL CONSTANTS
# -----------------------------
+set DEBUG 0 ;# Turn on debugging
encoding system {utf-8} ;# System encoding
set LIB_DIRNAME [file normalize [file dirname $argv0]] ;# Path to directory where the *.tcl file are located
-set VERSION "1.3.7" ;# Program version
-set SHORTNAME "MCU8051IDE" ;# Program short name (without white space)
-set APPNAME "MCU 8051 IDE v$VERSION" ;# Full program name
-set MIN_TCL_VER "8.5" ;# Minimum required Tcl version
+set INSTALLATION_DIR [file normalize "$LIB_DIRNAME/.."] ;# Path to the main executable (this file)
+set ROOT_DIRNAME [file normalize "$LIB_DIRNAME/.."] ;# On Linux it's the same as INSTALLATION_DIR, but it's different on MS Windows
+set VERSION "1.4.7" ;# Version of this IDE
+set SHORTNAME "MCU8051IDE" ;# Program short name (without white space)
+set APPNAME "MCU 8051 IDE v$VERSION" ;# Full program name
+set MIN_TCL_VER "8.5" ;# Minimum required Tcl version
set APPLICATION_LOADED 0 ;# True if program is loaded
set TRANSLATION_LOADED 0 ;# Bool: Translation loaded
-set MICROSOFT_WINDOWS {} ;# Bool: Windows OS running on the host computer
+set MICROSOFT_WINDOWS 0 ;# Bool: Windows OS running on the host computer
set CONFIG_DIR {} ;# Directory containing configuration files
# Check for correct Tcl version
@@ -48,25 +59,38 @@ if {[package vcompare $::tcl_version $::MIN_TCL_VER] < 0} {
exit 1
}
-## Tcl packages used by this prgram
+# Make sure that there is "ttk::spinbox" even when Tk version is lower than 8.5.9
+namespace eval ttk {
+ proc spinbox {args} {
+ eval "set result \[::spinbox $args\]"
+ return $result
+ }
+}
+
+## Tcl packages used by this software
# Format: {
# {pkg_name pkg_verison}
# ...
# }
set LIBRARIES_TO_LOAD {
- {BWidget 1.7}
+ {BWidget 1.8}
{Itcl 3.4}
- {Tcl 8.2}
{md5 2.0}
{Tk 8.5}
{img::png 1.3}
{tdom 0.8}
{Tclx 8.0}
+ {Tcl 8.2}
}
## Bool:
- # 1 == library TclX is avaliable
- # 0 == library TclX is NOT avaliable
+ # 1 == Normal GUI operation
+ # 0 == Program GUI suppressed
+set ::GUI_AVAILABLE 1
+
+## Bool:
+ # 1 == library TclX is available
+ # 0 == library TclX is NOT available
#
# TclX is used here only to handle signals (e.g. SIGINT), so the IDE can run
# without it, that's the reason for this variable. If TCLX_AVAILABLE is 0 then
@@ -77,15 +101,26 @@ set ::TCLX_AVAILABLE 1
set ::MICROSOFT_WINDOWS 0
if {[string first {Windows} ${tcl_platform(os)}] != -1} {
# Note:
- # Microsoft Windows is NOT a POSIX system and because of that we need
- # to do some workarounds here in order to make the IDE functional there.
+ # Microsoft Windows is NOT a POSIX system, and because of that, we need
+ # to do some workarounds here in order to make the IDE functional.
set ::MICROSOFT_WINDOWS 1
+
+ set LIB_DIRNAME_SPECIFIC_FOR_MS_WINDOWS "<AIPCS:LIB_DIRNAME_SPECIFIC_FOR_MS_WINDOWS>" ;# <-- The auto. inst. pkg. creation script will fill this in
+ set AUTO_PATH_FOR_MS_WINDOWS "<AIPCS:AUTO_PATH_FOR_MS_WINDOWS>" ;# <-- The auto. inst. pkg. creation script will fill this in
+ set INSTALLATION_DIR $LIB_DIRNAME
+ set LIB_DIRNAME $LIB_DIRNAME_SPECIFIC_FOR_MS_WINDOWS
+ set ROOT_DIRNAME [regsub {\/\w+\/?$} $LIB_DIRNAME {}]
+
+ foreach dir $AUTO_PATH_FOR_MS_WINDOWS {
+ lappend ::auto_path "${::ROOT_DIRNAME}/${dir}"
+ }
+ set env(ITCL_LIBRARY) "${::ROOT_DIRNAME}/libraries/itcl"
}
# Set directory containing configuration files according to the host OS
if {!$::MICROSOFT_WINDOWS} {
- set CONFIG_DIR [file join $::env(HOME) .[string tolower ${::SHORTNAME}]]
-} {
+ set CONFIG_DIR [file join ${::env(HOME)} .[string tolower ${::SHORTNAME}]]
+} else {
set CONFIG_DIR [file join ${::env(USERPROFILE)} ".[string tolower ${::SHORTNAME}]"]
}
@@ -99,15 +134,21 @@ source "${::LIB_DIRNAME}/cli.tcl"
if {!$::CLI_OPTION(quiet)} {
if {$::CLI_OPTION(nocolor)} {
- puts "WARNING:"
- puts "\tThis program is distributed with ABSOLUTELY NO WARRANTY !"
+ puts "IMPORTANT INFORMATION:"
+ puts "\tThis program is distributed in the hope that it will be useful, but with ABSOLUTELY NO WARRANTY !"
+ puts "\tThis is free software, so you are free to change and redistribute it."
+ puts "\tLicense: GNU General Public License version 2 or later"
puts "\tPlease report bugs at http://mcu8051ide.sf.net"
- puts "\tAuthor: Martin Osmera <martin.osmera@gmail.com>"
- } {
- puts "WARNING:"
- puts "\tThis program is distributed with ABSOLUTELY NO WARRANTY !"
+ puts "Authors:"
+ puts "\tMartin Osmera <martin.osmera@gmail.com>"
+ } else {
+ puts "IMPORTANT INFORMATION :"
+ puts "\tThis program is distributed in the hope that it will be useful, but with \033\[31;1mABSOLUTELY NO WARRANTY !\033\[m"
+ puts "\tThis is free software, so you are free to change and redistribute it."
+ puts "\tLicense: GNU General Public License version 2 or later"
puts "\tPlease report bugs at \033\[34;1mhttp://mcu8051ide.sf.net\033\[m"
- puts "\tAuthor: Martin Osmera \033\[33;1m<martin.osmera@gmail.com>\033\[m"
+ puts "Authors:"
+ puts "\tMartin Osmera \033\[33;1m<martin.osmera@gmail.com>\033\[m"
}
}
@@ -128,13 +169,13 @@ proc libraryLoadFailed {library} {
if {[lsearch {Linux} ${::tcl_platform(os)}] == -1} {
puts stderr "FATAL ERROR: Unsupported operating system. ${::tcl_platform(os)}"
- puts stderr "You can contact author of the project at <martin.osmera@gmail.com> if you want to get you OS supported."
+ puts stderr "You can contact authors of the project at <martin.osmera@gmail.com> if you want to get you OS supported."
exit 1
}
if {[lsearch {x86_64 i386 i486 i586 i686 x86} ${::tcl_platform(machine)}] == -1} {
puts stderr "FATAL ERROR: Unsupported system architecture. ${::tcl_platform(machine)}"
- puts stderr "You can contact author of the project at <martin.osmera@gmail.com> if you want to get you OS supported."
+ puts stderr "You can contact authors of the project at <martin.osmera@gmail.com> if you want to get you OS supported."
exit 1
}
@@ -145,8 +186,8 @@ proc libraryLoadFailed {library} {
puts "\nPlease try to run mcu8051ide with --check-libraries to see what's wrong."
exit 1
- } {
- puts stderr "WORKAROUND SUCCESSFULL ... \n(But don't be much happy about this, it is still serious failure. And please don't forget to comply to developers of your Linux distribution. Missing library is: ${library} version ${library_version})"
+ } else {
+ puts stderr "WORKAROUND SUCCESSFUL ... \n(But don't be much happy about this, it is still serious failure. And please don't forget to comply to developers of your Linux distribution. Missing library is: ${library} version ${library_version})"
return
}
@@ -160,7 +201,7 @@ proc libraryLoadFailed {library} {
# Print error message
if {$::CLI_OPTION(nocolor)} {
puts stderr "\n\nERROR: Unable to load library $library"
- } {
+ } else {
puts stderr "\n\n\033\[31mERROR:\033\[m Unable to load library \033\[32m$library\033\[m"
}
@@ -175,7 +216,7 @@ proc libraryLoadFailed {library} {
# -----------------------------
# Load Tk ToolKit
set T [lindex [time {
- if {[catch {package require img::png 1.3}]} {
+ if {[catch {package require img::png 1.3} e]} {
libraryLoadFailed "img::png"
}
if {[catch {package require Tk $::MIN_TCL_VER} errinfo]} {
@@ -187,50 +228,92 @@ wm withdraw .
update
# Determinate default Fixed font
-set ::DEFAULT_FIXED_FONT {DejaVu Sans Mono}
-if {[lsearch -ascii -exact [font families] {DejaVu Sans Mono}] == -1} {
- set ::DEFAULT_FIXED_FONT {Courier}
+set ::DEFAULT_FIXED_FONT {Courier}
+if {!$::MICROSOFT_WINDOWS} {
+ if {[lsearch -ascii -exact [font families] {DejaVu Sans Mono}] != -1} {
+ set ::DEFAULT_FIXED_FONT {DejaVu Sans Mono}
+ }
}
+# Set default background color
+set ::COMMON_BG_COLOR [. cget -bg]
+
# ------------------------------------------------------------------------------
# Microsoft Windows OS specific code
# ------------------------------------------------------------------------------
if {$::MICROSOFT_WINDOWS} {
# Print windows related warning
puts ""
- puts " THE IDE WAS ORIGINALY DESIGNED FOR POSIX, SO IT IS POSSIBLE THAT SOME"
- puts " FUNCTIONALITY WILL BE LIMITED ON YOUR OS DUE TO ABSENCE OF CERTAIN"
- puts " POSIX FUNCTIONALITY !"
+ puts " THE IDE WAS ORIGINALY WRITTEN FOR POSIX, SO IT IS POSSIBLE THAT SOME"
+ puts " FUNCTIONALITY WILL BE LIMITED ON MS WINDOWS DUE TO ABSENCE OF CERTAIN"
+ puts " POSIX FUNCTIONALITY!"
puts ""
+}
+# ------------------------------------------------------------------------------
- # Redefine the "bind" command, because on Windows binding a callback to
- # event, which does not exist on Windows would cause program crash
- rename bind original_command_bind
- proc microsoft_windows_specific_bind args {
+
+# ------------------------------------------------------------------------------
+# Make key shortcuts independent on Caps Lock.
+# ------------------------------------------------------------------------------
+rename bind original_command_bind
+proc mcu8051ide_bind args {
+ set widget [lindex $args 0]
+ set event_str [lindex $args 1]
+ set command [lindex $args 2]
+
+ if {[llength $args] > 3} {
+ error "Too many arguments to bind command."
+ } elseif {[llength $args] == 2} {
+ return [original_command_bind $widget $event_str]
+ }
+
+ # MS Windows doesn't recognize ISO and XFree86 codes
+ if {$::MICROSOFT_WINDOWS} {
if {
- [string first {ISO_} [lindex $args 1]] != -1 ||
- [string first {XF86_} [lindex $args 1]] != -1
- } {
+ [string first {ISO} $event_str] != -1 ||
+ [string first {XF86} $event_str] != -1
+ } then {
return
}
+ }
+
+ if {
+ [string index $event_str end-2] == {-}
+ &&
+ [string is alpha [string index $event_str end-1]]
+ &&
+ [string index $event_str end] == {>}
+ } then {
+ set letter [string index $event_str end-1]
+ set event_str [string range $event_str 1 end-2]
+ if {[string is upper $letter]} {
+ set event_str "Shift-${event_str}"
+ }
- eval "original_command_bind $args"
+ original_command_bind $widget "<${event_str}[string toupper $letter]>" $command
+ original_command_bind $widget "<${event_str}[string tolower $letter]>" $command
+ } else {
+ original_command_bind $widget $event_str $command
}
- rename microsoft_windows_specific_bind bind
}
+rename mcu8051ide_bind bind
# ------------------------------------------------------------------------------
-
# Load base config file
# -----------------------------
+# Initialize variable containing the font size factor
+set font_size_factor 1.0
+
# Load i18n library
# (It must be loaded here because ::msgcat::mclocale must be available when
# base config file is being loaded)
incr T [lindex [time {
if {[catch {package require msgcat 1.3.4}]} {
libraryLoadFailed "msgcat"
- } {
+ } else {
+ namespace import -force ::msgcat::mc
+ namespace import -force ::msgcat::mcset
namespace import -force ::msgcat::*
}
}] 0]
@@ -240,7 +323,7 @@ if {![file exists ${::CONFIG_DIR}]} {
puts "\nCreating program configuration files in directory: \"[file normalize ${::CONFIG_DIR}]\""
if {!$::MICROSOFT_WINDOWS} {
puts "Welcome in this IDE, [file tail [file normalize ~]] !"
- } {
+ } else {
catch { ;# Make the configuration directory in Microsoft Windows hidden
file attributes $::CONFIG_DIR -hidden 1
}
@@ -253,10 +336,16 @@ if {[catch {
# File doesn't exits -> create it with default configuration
}]} then {
# Default settings
+ set detected_lang [string tolower [lindex [split [::msgcat::mclocale] {_}] 0]]
+ if {{} != [lindex [split [::msgcat::mclocale] {_}] 1]} {
+ append detected_lang {_} [string toupper [lindex [split [::msgcat::mclocale] {_}] 1]]
+ }
array set GLOBAL_CONFIG [list \
splash 1 \
tips 1 \
- language [::msgcat::mclocale] \
+ language $detected_lang \
+ background {Default} \
+ wstyle {clam} \
]
# Create the file
@@ -264,11 +353,14 @@ if {[catch {
set conf_file [open "${::CONFIG_DIR}/base.conf" w]
puts -nonewline $conf_file [list \
$GLOBAL_CONFIG(splash) \
- $GLOBAL_CONFIG(splash) \
+ $GLOBAL_CONFIG(tips) \
$GLOBAL_CONFIG(language) \
+ ${::font_size_factor} \
+ $GLOBAL_CONFIG(background) \
+ $GLOBAL_CONFIG(wstyle) \
]
close $conf_file
- }]} {
+ }]} then {
puts stderr "Unable to create base configuration file"
}
# File exits -> read configuration from it
@@ -277,48 +369,89 @@ if {[catch {
set data [read $conf_file]
close $conf_file
- # Set configuration acording to the file contents
+ # Set configuration according to the file contents
set GLOBAL_CONFIG(splash) [lindex $data 0]
set GLOBAL_CONFIG(tips) [lindex $data 1]
set GLOBAL_CONFIG(language) [lindex $data 2]
+ set ::font_size_factor [lindex $data 3]
+ set GLOBAL_CONFIG(background) [lindex $data 4]
+ set GLOBAL_CONFIG(wstyle) [lindex $data 5]
## Validate read values
- if {![string is boolean -strict ${GLOBAL_CONFIG(splash)}]} {
+ if {![regexp {^1\.\d+$} $::font_size_factor] || $::font_size_factor < 1.0 || $::font_size_factor >= 2.0} {
+ set ::font_size_factor 1.0
+ }
+ if {![string is boolean -strict ${::GLOBAL_CONFIG(splash)}]} {
set GLOBAL_CONFIG(splash) 1
}
- if {![string is boolean -strict ${GLOBAL_CONFIG(tips)}]} {
+ if {![string is boolean -strict ${::GLOBAL_CONFIG(tips)}]} {
set GLOBAL_CONFIG(tips) 1
}
+ # This feature is not supported on MS Windows due to BWidget
+ if {!$::MICROSOFT_WINDOWS} {
+ switch -- ${::GLOBAL_CONFIG(background)} {
+ {Default} {set ::COMMON_BG_COLOR {#eeeeee}}
+ {Windows} {set ::COMMON_BG_COLOR {#ece9d9}}
+ {Tk} {}
+ {Light} {set ::COMMON_BG_COLOR {#f8f8f8}}
+ {Dark} {set ::COMMON_BG_COLOR {#cccccc}}
+ default {
+ set ::GLOBAL_CONFIG(background) {Default}
+ set ::COMMON_BG_COLOR {#eeeeee}
+ }
+ }
+ }
+ if {[lsearch -ascii -exact [ttk::style theme names] ${::GLOBAL_CONFIG(wstyle)}] == -1} {
+ set ::GLOBAL_CONFIG(wstyle) {clam}
+ }
# Check if the cpecified translation is valid
set tmp [list]
catch { ;# For Microsoft Windows it has to be enclosed by catch
set tmp [glob -nocomplain -types f -tails \
- -directory "${LIB_DIRNAME}/../translations" *.msg \
+ -directory "${::INSTALLATION_DIR}/translations" *.msg \
]
}
set translations {en}
foreach translation $tmp {
lappend translations [file rootname $translation]
}
+
if {[lsearch $translations ${GLOBAL_CONFIG(language)}] == -1} {
set GLOBAL_CONFIG(language) {en}
}
}
+
# Load translation
# -----------------------------
+# Load list of language names
+set ::LANGUAGE_CODES [list]
+namespace eval ::configDialogues::global {
+ if {[catch {
+ set file [open "${::INSTALLATION_DIR}/translations/languages.txt" r]
+ set languages [read $file]
+ close $file
+
+ regsub -all -line {\s*#.*$} $languages {} languages
+ set ::LANGUAGE_CODES $languages
+ lindex $languages 0
+ } e]} {
+ puts stderr "Error while loading list of laguages: $e"
+ }
+}
+
# Load language specific translation file
if {!${::CLI_OPTION(notranslation)} && ${GLOBAL_CONFIG(language)} != {en}} {
if {[catch {
- mclocale ${GLOBAL_CONFIG(language)}
- mcload "${LIB_DIRNAME}/../translations/"
+ ::msgcat::mclocale ${GLOBAL_CONFIG(language)}
+ incr T [lindex [time {
+ source "${::INSTALLATION_DIR}/translations/${GLOBAL_CONFIG(language)}.msg"
+ }] 0]
} result]} then {
puts stderr "Unable to load translation"
- puts stderr "\tFile: '${LIB_DIRNAME}/../translations/${GLOBAL_CONFIG(language)}.msg'"
- puts "\n"
- puts $result
+ puts stderr "\tFile: '${::INSTALLATION_DIR}/translations/${GLOBAL_CONFIG(language)}.msg'"
} else {
set ::TRANSLATION_LOADED 1
@@ -329,14 +462,24 @@ if {!${::CLI_OPTION(notranslation)} && ${GLOBAL_CONFIG(language)} != {en}} {
# -----------------------------
if {!$::CLI_OPTION(nosplash) && ${::GLOBAL_CONFIG(splash)}} {
+ # Workaround for multiple monitors
+ toplevel .splash_aux
+ wm attributes .splash_aux -fullscreen 1
+ update
+ set sw [winfo width .splash_aux]
+ set sh [winfo height .splash_aux]
+ destroy .splash_aux
+ update
+
# Crete toplevel window
- toplevel .splash -class {Splash creen} -bg {#EEEEEE}
+ toplevel .splash -class {Splash creen} -bg ${::COMMON_BG_COLOR}
# Show image of splash creen
place [label .splash.bg \
+ -bg {#FFFFFF} \
-image [ \
image create photo -format png \
- -file "${::LIB_DIRNAME}/../icons/other/splash.png" \
+ -file "${::ROOT_DIRNAME}/icons/other/splash.png" \
] \
] -x 0 -y 0 -width 400 -height 199
@@ -347,8 +490,9 @@ if {!$::CLI_OPTION(nosplash) && ${::GLOBAL_CONFIG(splash)}} {
] -x 200 -y 180 -anchor center
# Set window parameters
- wm geometry .splash "=400x199+[expr {[winfo screenwidth .] / 2 - 200}]+[expr {[winfo screenheight .] / 2 - 100}]"
+ wm geometry .splash "=400x199+[expr {$sw / 2 - 200}]+[expr {$sh / 2 - 100}]"
wm overrideredirect .splash 1
+ wm attributes .splash -alpha 0.8
# Click on splash creen destroys it
bind .splash <1> {wm withdraw .splash}
@@ -374,7 +518,7 @@ proc time_in_msec {} {
if {!$::CLI_OPTION(quiet)} {
if {$::CLI_OPTION(nocolor)} {
puts "... $msec ms"
- } {
+ } else {
puts "... \033\[33m$msec ms\033\[m"
}
}
@@ -397,7 +541,7 @@ proc showInitMessage {message} {
if {!${::CLI_OPTION(quiet)}} {
if {${::CLI_OPTION(nocolor)}} {
puts -nonewline $message
- } {
+ } else {
puts -nonewline "\033\[37m$message\033\[m"
}
@@ -489,7 +633,7 @@ proc setStatusTip args {
if {!$CLI_OPTION(quiet)} {
if {$CLI_OPTION(nocolor)} {
puts [mc "\nInitializing MCU 8051 IDE %s" $VERSION]
- } {
+ } else {
puts [mc "\nInitializing \033\[1mMCU 8051 IDE \033\[32m%s\033\[m" $VERSION]
}
}
@@ -503,7 +647,7 @@ incr T [lindex [time {
if {[catch {package require [lindex $library 0] [lindex $library 1]}]} {
libraryLoadFailed [lindex $library 0]
# Loading failed
- } {
+ } else {
if {!$::CLI_OPTION(nosplash)} update
}
}
@@ -520,12 +664,14 @@ incr T [lindex [time {
foreach program {
urxvt vim emacs kwrite gedit nano dav
le sdcc indent doxygen asl asem doxywizard
- as31 sdcc-sdcc gvim
- } {
+ as31 sdcc-sdcc gvim hunspell d52
+ make
+ } \
+{
if {[auto_execok $program] == {}} {
- set ::PROGRAM_AVALIABLE($program) 0
- } {
- set ::PROGRAM_AVALIABLE($program) 1
+ set ::PROGRAM_AVAILABLE($program) 0
+ } else {
+ set ::PROGRAM_AVAILABLE($program) 1
}
}
time_in_msec ;# Print time info
@@ -533,18 +679,20 @@ time_in_msec ;# Print time info
## Load program sources
showInitMessage [mc "\tLoading program sources"]
set T [time {
+ source "${::LIB_DIRNAME}/lib/modern_notebook.tcl" ;# NoteBook widget with a modern look (modern in 2011)
+ source "${::LIB_DIRNAME}/lib/FSnotifications.tcl" ;# Filesystem watcher
source "${::LIB_DIRNAME}/lib/innerwindow.tcl" ;# Tool for creating inner windows
- source "${::LIB_DIRNAME}/dialogs/errorhandler.tcl" ;# Background error handler
- source "${::LIB_DIRNAME}/dialogs/my_tk_messageBox.tcl" ;# A replacement for tk_messageBox
+ source "${::LIB_DIRNAME}/dialogues/errorhandler.tcl" ;# Background error handler
+ source "${::LIB_DIRNAME}/dialogues/my_tk_messageBox.tcl";# A replacement for tk_messageBox
source "${::LIB_DIRNAME}/lib/settings.tcl" ;# Settings management
source "${::LIB_DIRNAME}/project.tcl" ;# Project management
- source "${::LIB_DIRNAME}/dialogs/fsd.tcl" ;# File selection dialog
+ source "${::LIB_DIRNAME}/dialogues/fsd.tcl" ;# File selection dialog
source "${::LIB_DIRNAME}/X.tcl" ;# GUI <==> Implementation Interface
- source "${::LIB_DIRNAME}/configdialogs/configdialogs.tcl";# Configuration dialogs
+ source "${::LIB_DIRNAME}/configdialogues/configdialogues.tcl";# Configuration dialogues
source "${::LIB_DIRNAME}/editor/editor.tcl" ;# Source code editor
source "${::LIB_DIRNAME}/lib/Math.tcl" ;# Special mathematical operations
source "${::LIB_DIRNAME}/compiler/compiler.tcl" ;# 8051 Assemly language compiler
- source "${::LIB_DIRNAME}/dialogs/tips.tcl" ;# Tips on startup
+ source "${::LIB_DIRNAME}/dialogues/tips.tcl" ;# Tips on start-up
source "${::LIB_DIRNAME}/lib/hexeditor.tcl" ;# Hexadecimal editor
source "${::LIB_DIRNAME}/utilities/hexeditdlg.tcl" ;# Hexadecimal editor dialog
source "${::LIB_DIRNAME}/environment.tcl" ;# Main window "trappings" (menu and such)
@@ -555,40 +703,47 @@ set T [time {
source "${::LIB_DIRNAME}/maintab.tcl" ;# Central widget
source "${::LIB_DIRNAME}/lib/ihextools.tcl" ;# Tools for manipulating Intel 8 HEX
source "${::LIB_DIRNAME}/utilities/symbol_viewer.tcl" ;# Assembly symbols viewer
- source "${::LIB_DIRNAME}/utilities/eightsegment.tcl" ;# 8-segment LED display editor
+ source "${::LIB_DIRNAME}/utilities/eightsegment.tcl" ;# 8-Segment LED display editor
source "${::LIB_DIRNAME}/utilities/asciichart.tcl" ;# ASCII chart
+ source "${::LIB_DIRNAME}/utilities/table_of_instructions.tcl";# 8051 Instruction Table
source "${::LIB_DIRNAME}/utilities/notes.tcl" ;# Scribble notepad
- source "${::LIB_DIRNAME}/utilities/baseconvertor.tcl" ;# Base convertor
+ source "${::LIB_DIRNAME}/utilities/baseconverter.tcl" ;# Base converter
source "${::LIB_DIRNAME}/utilities/speccalc.tcl" ;# Special calculator for x51 MCU's
source "${::LIB_DIRNAME}/utilities/rs232debugger.tcl" ;# UART/RS232 applications debugger
}]
time_in_msec ;# Print time info
# CHECK FOR VALIDITY OF THE MCU DATABASE
-if {${::X::avaliable_processors} == {}} {
+if {${::X::available_processors} == {}} {
destroy .splash
bell
tk_messageBox \
-icon error \
-type ok \
-title [mc "FATAL ERROR"] \
- -message [mc "MCUs database file is currupted,\nthis program cannot run without it.\nPlease reinstall MCU 8051 IDE."]
+ -message [mc "MCUs database file is corrupted,\nthis program cannot run without it.\nPlease reinstall MCU 8051 IDE."]
exit 1
}
# Load global configuration
loadApplicationConfiguration
+# Start spell checker process and wait until it is started
+::Editor::restart_spellchecker_process
+::Editor::adjust_spell_checker_config_button
+
# Initialize GUI environment
-iconbar_redraw ;# Main toolbar
mainmenu_redraw ;# Main menu
+iconbar_redraw ;# Main toolbar
shortcuts_reevaluate ;# Key shortcuts
## Remove splash screen
-destroy .splash
+if {[winfo exists .splash]} {
+ destroy .splash
+}
if {$CLI_OPTION(minimalized)} {
wm state . iconic
-} {
+} else {
wm deiconify .
}
@@ -596,10 +751,12 @@ if {$CLI_OPTION(minimalized)} {
if {$::TCLX_AVAILABLE} {
proc signal_handler {signal_name} {
global cntrlc_flag
- puts stdout [mc "\nExiting on signal %s" $signal_name]
- if {[catch {::X::__exit 1}]} {
- exit 1
+ puts stderr [mc "\nExiting on signal %s" $signal_name]
+ catch {
+ ::X::__exit 1 1
}
+ puts stderr [mc "\nERROR: Unable to exit the program correctly -- TERMINATING NOW!" $signal_name]
+ exit 1
}
signal trap SIGINT {signal_handler SIGINT}
@@ -608,14 +765,14 @@ if {$::TCLX_AVAILABLE} {
# ---------------------------------------------------------
-# Ugly job ... dirty workarounds and such a shit ... :(
+# Ugly job ... dirty workarounds and such things ... :(
# ---------------------------------------------------------
catch {
NoteBook .foo
proc NoteBook::_getoption {path page option} {
if {$option == {-background}} {
- return {#eeeeee}
+ return ${::COMMON_BG_COLOR}
}
set value [Widget::cget $path.f$page $option]
@@ -630,7 +787,6 @@ catch {
# ---------------------------------------------------------
-
## Open the last session
# Print message
showInitMessage [mc "\tOpening last session"]
@@ -638,6 +794,10 @@ flush stdout
# Evaluate new geometry of the main window
update
evaluate_new_window_geometry
+if {![winfo viewable .mainMenu]} {
+ wm geometry . $::CONFIG(WINDOW_GEOMETRY)
+ update
+}
# Open projects of last session
set T [time {
foreach project_file $::CONFIG(OPENED_PROJECTS) {
@@ -651,12 +811,12 @@ set T [time {
}
}]
-# Reopen base convertors
-foreach cfg $::CONFIG(BASE_CONVERTORS) {
+# Reopen base converters
+foreach cfg $::CONFIG(BASE_CONVERTERS) {
if {[catch {
- set obj [::X::__base_convertor]
+ set obj [::X::__base_converter]
::X::$obj set_config $cfg
- }]} {
+ }]} then {
puts stderr {}
puts stderr $::errorInfo
}
@@ -664,8 +824,36 @@ foreach cfg $::CONFIG(BASE_CONVERTORS) {
time_in_msec ;# Print time info
+# Without this "help windows" won't work properly on MS Windows
+if {$::MICROSOFT_WINDOWS} {
+ if {[wm state .] == {zoomed}} {
+ set ::LATS_KNOWN_WM_STATE_IS_ZOOMED 1
+ } else {
+ set ::LATS_KNOWN_WM_STATE_IS_ZOOMED 0
+ }
+}
# Create binding for panes management
-bind . <Configure> {X::redraw_panes}
+bind . <Configure> {
+ X::redraw_panes
+
+ # Without this "help windows" won't work properly on MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ if {[wm state .] == {zoomed}} {
+ set now_zoomed 1
+ } else {
+ set now_zoomed 0
+ }
+
+ if {!${::LATS_KNOWN_WM_STATE_IS_ZOOMED} && $now_zoomed} {
+ after idle {
+ update
+ regsub {[\+\-].*$} [wm geometry .] {+0+0} geometry
+ wm geometry . $geometry
+ }
+ }
+ set ::LATS_KNOWN_WM_STATE_IS_ZOOMED $now_zoomed
+ }
+}
# Print final message
if {!$CLI_OPTION(quiet)} {
puts [mc "%s is now operational\n" $APPNAME]
@@ -675,9 +863,11 @@ if {!$CLI_OPTION(quiet)} {
set ::Compiler::in_IDE 1
set APPLICATION_LOADED 1
set X::critical_procedure_in_progress 0
-update idle
+update
X::redraw_panes
+update
foreach project ${::X::openedProjects} {
+ $project bottomNB_redraw_pane
$project filelist_adjust_size_of_tabbar
$project ensure_that_both_editors_are_properly_initialized
}
@@ -689,11 +879,15 @@ if {${::X::actualProject} != {}} {
focus [${::X::actualProject} editor_procedure {} highlight_visible_area {}]
}
-# Just workaround for disapearing main menu
-raise .
-
# Correct strange behavior concerning restoration of the last window size and position
if {$::MICROSOFT_WINDOWS} {
update
wm geometry . $::CONFIG(WINDOW_GEOMETRY)
}
+
+# Initialize file change notifications mechanism
+FSnotifications::init
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/maintab.tcl b/lib/maintab.tcl
index 57f0351..b0159ab 100755..100644
--- a/lib/maintab.tcl
+++ b/lib/maintab.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 _MAINTAB_TCL ] } {
+set _MAINTAB_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Manages central widget of this program, each instance of this class
@@ -41,7 +46,7 @@ class MainTab {
public variable projectPath ;# Path to directory where the project file is located
public variable projectFile ;# Name of the project file
public variable procData ;# Processor definition list
- public variable avaliable_SFR ;# List of SFR and SFB which are avaliable on the choosen MCU
+ public variable available_SFR ;# List of SFR and SFB which are available on the choosen MCU
# Compiler configuration related variables
private variable PCC_native_assembler ;# --> ::Compiler::Settings::*
@@ -58,19 +63,20 @@ class MainTab {
private variable PCC_sdcc_scs_str_opt ;# --> ::ExternalCompiler::sdcc_scs_string_options
## Project information variables
- # (P - project; G - general)
+ # (P - project; G - general; S - Special)
public variable P_information_version ;# Project version
public variable P_information_date ;# Date of last project update
public variable G_information_authors ;# List of project authors
public variable G_information_copyright ;# Project copyright information
- public variable G_information_licence ;# Project licence information
+ public variable G_information_license ;# Project license information
+ public variable S_flag_read_only ;# Project is for reading only (e.g. "Demo project")
public variable P_option_mcu_type ;# Processor type (e.g. AT89C51RC)
public variable P_option_clock ;# Project default simulator clock rate
public variable P_option_mcu_xdata ;# Size of external data memory
public variable P_option_mcu_xcode ;# Size of external program memory
public variable P_option_main_file ;# Project main source file
- public variable project_description ;# Project decription text
+ public variable project_description ;# Project description text
public variable todoText ;# Content of TODO list
public variable calculatorList ;# List of values for calculator (see class Calculator)
public variable other_options ;# Other options
@@ -84,9 +90,10 @@ class MainTab {
# @parm List dataList - Data extracted from project file (see NS Project)
constructor {ProjectName projectpath projectfile dataList} {
set projectName $ProjectName
+ set S_flag_read_only 0
#
- ## PARSE PROJECT DATA
+ ## PROCESS PROJECT SPECIFICATION DATA
#
set i 0
@@ -96,7 +103,7 @@ class MainTab {
}
set i 0
- foreach info {authors copyright licence} {
+ foreach info {authors copyright license} {
regsub -all {\\\}} [regsub -all {\\\{} [lindex $dataList "1 $i"] "{"] "}" G_information_$info
incr i
}
@@ -138,37 +145,41 @@ class MainTab {
array set PCC_AS31_config [lindex $dataList {8 10}]
array set PCC_AS31_addcfg [lindex $dataList {8 11}]
}
- } {
+ } else {
retrieve_compiler_settings
}
set projectFiles [lindex $dataList 9]
# Load default values if the given values is not valid
- if {[lsearch ${::X::avaliable_processors} $P_option_mcu_type] == -1} {
+ if {[lsearch ${::X::available_processors} $P_option_mcu_type] == -1} {
set P_option_mcu_type [lindex ${X::project_edit_defaults} {0 1}]
puts stderr "Unsupported processor type -- setting to [lindex ${X::project_edit_defaults} {0 1}]"
}
set procData [SelectMCU::get_processor_details $P_option_mcu_type]
+
+ # set MCU type in status bar, kdb -- Are you sure Kara that this line does anathing??
+ .statusbarMCU configure -text $P_option_mcu_type
+
if {$procData == {}} {
wm withdraw .
tk_messageBox \
-icon error \
-type ok \
-title [mc "FATAL ERROR"] \
- -message [mc "MCUs database file is currupted,\nthis program cannot run without it.\nPlease reinstall MCU 8051 IDE."]
+ -message [mc "MCUs database file is corrupted,\nthis program cannot run without it.\nPlease reinstall MCU 8051 IDE."]
exit 1
}
- refresh_project_avaliable_SFR
- if {![string is digit -strict $P_option_mcu_xdata] || $P_option_mcu_xdata > 0xFFFF} {
+ refresh_project_available_SFR
+ if {![string is digit -strict $P_option_mcu_xdata] || $P_option_mcu_xdata > 0x10000} {
set P_option_mcu_xdata 0
puts "Invalid XDATA capacity -- setting to 0"
}
if {
![string is digit -strict $P_option_mcu_xcode]
||
- $P_option_mcu_xcode > [expr {0xFFFF - ([lindex $procData 2] * 1024)}]
- } {
+ $P_option_mcu_xcode > [expr {0x10000 - ([lindex $procData 2] * 1024)}]
+ } then {
set P_option_mcu_xcode 0
puts "Invalid XCODE capacity -- setting to 0"
}
@@ -178,12 +189,12 @@ class MainTab {
if {[lindex $procData 1] != {yes}} {
set P_option_mcu_xcode 0
}
- if {[regexp {^\d+$} $P_option_clock]} {
+ if {[regexp {^\d+(\.\d+)?$} $P_option_clock]} {
if {$P_option_clock > 99999} {
set P_option_clock [lindex ${X::project_edit_defaults} {1 1}]
puts stderr "Clock value must be below 99999 -- setting to [lindex ${X::project_edit_defaults} {1 1}]"
}
- } {
+ } else {
set P_option_clock [lindex ${X::project_edit_defaults} {1 1}]
puts stderr "Invalid clock value -- setting to [lindex ${X::project_edit_defaults} {1 1}]"
}
@@ -197,32 +208,46 @@ class MainTab {
set projectFile $projectfile
# create higher-level container
- set mainTab [.mainFrame.mainNB insert end \
- [string trimleft $this {:}] \
- -text $projectName \
- -image ::ICONS::16::kcmdevices \
- -raisecmd "X::switch_project $this" \
+ set mainTab [${::main_nb} insert end \
+ [string trimleft $this {:}] \
+ -text $projectName \
+ -image ::ICONS::16::kcmdevices \
+ -raisecmd [list X::switch_project $this] \
]
-
- # Some workaround -- only a "cosmetic" matter
- catch {
- .mainFrame.mainNB.c bind p:[string trimleft $this {:}] <Enter> {}
+ after idle {
+ update
+ foreach project ${::X::openedProjects} {
+ $project bottomNB_redraw_pane
+ }
}
+ # Invoke progress dialog
+ set ::FileList::open_files_cur_file [mc "Initializing ..."]
+ create_progress_bar .prgDl \
+ . \
+ ::FileList::open_files_cur_file \
+ {} \
+ ::FileList::open_files_progress \
+ 0 \
+ [mc "Opening project files"] \
+ ::ICONS::16::fileopen \
+ [mc "Abort"] \
+ {set ::FileList::open_files_abort 1}
+
# create paned windows
set main_Pane [panedwindow $mainTab.main_Pane \
-orient vertical \
- -sashwidth 2 \
+ -sashwidth 4 \
-showhandle 0 \
-opaqueresize 1 \
- -sashrelief flat \
+ -sashrelief raised \
]
set top_Pane [panedwindow $main_Pane.top_Pane \
-orient horizontal \
-sashwidth 2 \
-showhandle 0 \
-opaqueresize 1 \
- -sashrelief flat \
+ -sashrelief raised \
]
set fileList_Pane [panedwindow $top_Pane.fileList_Pane \
-orient horizontal \
@@ -244,19 +269,19 @@ class MainTab {
# Intialize all panels
simulator_initialize_mcu
- Initialize_rightPanel $rightPanel $top_Pane $watches_file
- initiate_BottomNoteBook $bottom_pane $main_Pane $todoText $calculatorList $graphList
- initiate_FileList $fileList_Pane $projectPath $projectFiles $editor_sw_lock
+ initialize_rightPanel $rightPanel $top_Pane $watches_file
+ initalize_BottomNoteBook $bottom_pane $main_Pane $todoText $calculatorList $graphList
+ initalize_FileList $fileList_Pane $projectPath $projectFiles $editor_sw_lock
- # Adjust progress dialog invoked from procedure initiate_FileList
+ # Adjust progress dialog
catch {.prgDl configure -command {puts stderr "Unable to abort at this stage !"}}
- set ::FileList::open_files_cur_file {Finishing ...}
+ set ::FileList::open_files_cur_file [mc "Finishing ..."]
# Pack main pane
pack $main_Pane -expand 1 -fill both
# Raise last tab in mainNB
- .mainFrame.mainNB raise [string trimleft $this {:}]
+ ${::main_nb} raise [string trimleft $this {:}]
# Take care of proper geometry management
bottomNB_redraw_pane
@@ -272,6 +297,7 @@ class MainTab {
# Load scenario file
if {[pale_open_scenario $scenario_file] == 1} {
tk_messageBox \
+ -parent . \
-type ok \
-icon error \
-title [mc "IO Error"] \
@@ -287,7 +313,7 @@ class MainTab {
## Object destructor
destructor {
- .mainFrame.mainNB delete [string trimleft $this {:}]
+ ${::main_nb} delete [string trimleft $this {:}]
}
## Kill all child processes
@@ -298,10 +324,10 @@ class MainTab {
$this hw_man_kill_childern
}
- ## Refresh list of avaliable SFR and SFB
+ ## Refresh list of available SFR and SFB
# @return void
- public method refresh_project_avaliable_SFR {} {
- set avaliable_SFR [concat [lindex $procData 43] {
+ public method refresh_project_available_SFR {} {
+ set available_SFR [concat [lindex $procData 43] {
R0 R1 R2 R3 R4 R5 R6 R7
B ACC A TMOD TH0 TH1 SP DPL DPH PCON
TL0 TL1 AB DPTR
@@ -314,7 +340,7 @@ class MainTab {
}] ;# REGISTER BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0
foreach editor [$this cget -editors] {
- $editor refresh_avaliable_SFR
+ $editor refresh_available_SFR
}
}
@@ -362,9 +388,9 @@ class MainTab {
# @return void
public method retrieve_compiler_settings {} {
# Native assembler
- foreach key ${::configDialogs::compiler::defaults} {
+ foreach key ${::configDialogues::compiler::defaults} {
set key [lindex $key 0]
- set PCC_native_assembler($key) [subst "\$::Compiler::Settings::$key"]
+ set PCC_native_assembler($key) [subst -nocommands "\$::Compiler::Settings::$key"]
}
set PCC_native_assembler(WARNING_LEVEL) \
${::Compiler::Settings::WARNING_LEVEL}
@@ -422,4 +448,16 @@ class MainTab {
[array get PCC_AS31_addcfg] \
]
}
+
+ ## Set project read only flag
+ #
+ # The flag inhibits proc ::X::__proj_save.
+ # @return void
+ public method set_read_only {} {
+ set S_flag_read_only 1
+ }
+}
+
+# >>> File inclusion guard
}
+# <<< File inclusion guard
diff --git a/lib/pale/ds1620.tcl b/lib/pale/ds1620.tcl
new file mode 100644
index 0000000..7c1df63
--- /dev/null
+++ b/lib/pale/ds1620.tcl
@@ -0,0 +1,1730 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# 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 #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _DS1620_TCL ] } {
+set _DS1620_TCL _
+# <<< File inclusion guard
+
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+#
+# Consists of:
+# INTERNAL APPLICATION LOGIC
+# VIRTUAL HW COMMON INTERFACE -- CALLED FROM PALE ENGINE
+# VIRTUAL HW COMMON INTERFACE -- CALLED FROM THE BASE CLASS
+# --------------------------------------------------------------------------
+
+class Ds1620 {
+ inherit VirtualHWComponent
+
+ # Font: Font to be used in the panel -- bold
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
+ ]
+ # Font: Font to be used in the panel -- bold
+ common small_font [font create \
+ -size [expr {int(-9 * $::font_size_factor)}] \
+ -family {helvetica} \
+ ]
+
+ common COMPONENT_NAME "DS1620 temperature sensor" ;# Name of this component
+ common CLASS_NAME "Ds1620" ;# Name of this class
+ common COMPONENT_ICON {ds1620} ;# Icon for this panel (16x16)
+
+ # Configuration menu
+ common CONFMENU {
+ {checkbutton "Disable delays" {} {::Ds1620::_no_delays}
+ 1 0 0 {no_delays_changed}
+ ""}
+ {command {Show DS1620 log} {} 5 "show_log" {bar5}
+ "Display the log of events which are currently happening in the simulated DS1620 chip"}
+ {separator}
+ {command {Show help} {} 5 "show_help" {help}
+ "Show brief help"}
+ {separator}
+ {command {Save configuration} {} 0 "save_as" {filesave}
+ "Save configuration into a file"}
+ {command {Load configuration} {} 0 "load_from" {fileopen}
+ "Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::Ds1620::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
+ }
+
+ #
+ common STATUS_BITS {DONE THF TLF NVB 1 0 CPU 1SHOT}
+ common MAX_LOG_LENGTH 100 ;# Int: Maximum number of row in the log window
+ common SIGNAL_NAMES {DQ CLK RST TH TL TCOM}
+ common EEPROM_WRITE_CYCLE_TIME 10000
+ common T_CONVERSION_TIME_MS 750
+ common _no_delays 0
+
+ private variable input_error
+ private variable input_error_desc
+
+ private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
+ private variable connection_pin ;# Array of Int: Index is key number, value is bit number or {-}
+
+ private variable wires ;# Array of CanvasObject (line): Wire connection between the IC and the MCU
+ private variable temp_ind_y_offset
+ private variable temp_ind_x_offset
+ private variable temperature 22
+ private variable temp_point_y 0
+ private variable enaged ;# Array of Bool: enaged(port_num,bit_num) --> Is connected to this device ?
+ private variable ds1620_reg ;# Array of
+ private variable entrybox ;# Array of
+ private variable reg_bit ;# Array of
+ private variable status ;# Array of
+ private variable no_delays 0
+ private variable log_win_text {}
+ private variable warning_indicator {}
+ private variable time_mark 0 ;# Int: Time mark pointing to this point of time according to the MCU simulator engine
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
+ private variable log_time_mark 0
+ private variable log_window_geometry {}
+ private variable signal
+ private variable log_enabled 1 ;# Bool: Logging of events enabled (slower simulation)
+ private variable log_on_off_chbut ;# Widget: Checkbox for enabling and disabling the logging of events
+
+ private variable bit_number 0
+ private variable byte_received
+ private variable command_received 0
+ private variable reception_or_transmission 1
+ private variable receive_command_or_data 1
+ private variable number_of_bits
+ private variable data_to_send 0
+ private variable conversion_running 0
+ private variable delay_transmission 1
+ private variable communication_disabled 0
+ private variable write_to_NVM 0
+ private variable t_conversion_time_mark 0
+ private variable time_of
+ private variable pending_communication 0
+
+
+ # ------------------------------------------------------------------
+ # INTERNAL APPLICATION LOGIC
+ # ------------------------------------------------------------------
+
+ ## Object constructor
+ # @parm Object _project - Project object
+ constructor {_project} {
+ # Set object variables identifing this component (see the base class)
+ set component_name $COMPONENT_NAME
+ set class_name $CLASS_NAME
+ set component_icon $COMPONENT_ICON
+
+ # Set other object variables
+ set project $_project
+ array set connection_port {0 - 1 - 2 - 3 - 4 - 5 -}
+ array set connection_pin {0 - 1 - 2 - 3 - 4 - 5 -}
+ array set ds1620_reg {
+ TH 30 TL 20
+ TEMP 392 PER_C 100
+ REMAIN 0 STATUS 136
+ }
+ array set signal {
+ CLK 0 CLK_prev 0
+ RST 0 RST_prev 0
+ DQ 0 DQ_prev 0
+ TH 0 TL 0
+ TCOM 0
+ }
+ array set time_of {
+ CLK_up 0 CLK_down 0
+ RST_up 0 RST_down 0
+ DQ_up 0 DQ_down 0
+ }
+ for {set port 0} {$port < 5} {incr port} {
+ for {set bit 0} {$bit < 8} {incr bit} {
+ set enaged($port,$bit) 0
+ }
+ }
+
+ # Inform PALE
+ $project pale_register_input_device $this
+ $project pale_set_modified
+
+ # Create panel GUI
+ create_gui
+ mcu_changed
+ on_off [$project pale_is_enabled]
+ reset_ds1620
+ create_log
+
+ # ComboBoxes to default state
+ for {set i 0} {$i < 6} {incr i} {
+ $canvas_widget.cb_b$i current 0
+ $canvas_widget.cb_p$i current 0
+ }
+ }
+
+ ## Object destructor
+ destructor {
+ # Inform PALE
+ $project pale_unregister_input_device $this
+
+ # Destroy GUI
+ destroy $win
+ }
+
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $Ds1620::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
+ ## Reconnect the specified line to another port pin
+ # @parm Int i - line number (0..5)
+ # @return void
+ public method reconnect {i} {
+ # Adjust connections
+ set connection_port($i) [$canvas_widget.cb_p$i get]
+ set connection_pin($i) [$canvas_widget.cb_b$i get]
+ if {$connection_pin($i) != {-}} {
+ set connection_pin($i) [expr {7 - $connection_pin($i)}]
+ }
+
+ # Reevaluate array of MCU port pins engaged by this device
+ evaluete_enaged_pins
+
+ # Change state of the device
+ if {$drawing_on} {
+ $project pale_reevaluate_IO
+ }
+
+ # Set flag modified
+ set_modified
+ }
+
+ ## Reevaluate array of MCU port pins engaged by this device
+ # @return void
+ private method evaluete_enaged_pins {} {
+ # Mark all as disengaged and infrom PALE
+ for {set port 0} {$port < 5} {incr port} {
+ for {set bit 0} {$bit < 8} {incr bit} {
+ if {$enaged($port,$bit)} {
+ $project pale_disengage_pin_by_input_device $port $bit $this
+ set enaged($port,$bit) 0
+ }
+ }
+ }
+
+ # Find the engaged ones and infrom PALE
+ for {set i 0} {$i < 6} {incr i} {
+ if {$i == 1 || $i == 2} {
+ continue
+ }
+
+ set port $connection_port($i)
+ set bit $connection_pin($i)
+
+ if {$port == {-} || $bit == {-}} {
+ continue
+ }
+
+ set enaged($port,$bit) 1
+ $project pale_engage_pin_by_input_device $port $bit $this
+ }
+ }
+
+ ## Create GUI of this panel
+ # @return void
+ private method create_gui {} {
+ # Create panel window and canvas widget
+ set win [toplevel .ledpanel$count -class $component_name -bg ${::COMMON_BG_COLOR}]
+ set canvas_widget [canvas $win.canvas \
+ -bg white -width 0 -height 0 \
+ -highlightthickness 0 \
+ ]
+
+ $canvas_widget create text 85 145 \
+ -text [mc "Note"] \
+ -font $cb_font \
+ -anchor e
+ $canvas_widget create window 90 145 \
+ -window [ttk::entry $canvas_widget.usr_note \
+ -validate key \
+ -validatecommand "$this set_modified" \
+ ] \
+ -width 405 -anchor w
+ bindtags $canvas_widget.usr_note \
+ [list $canvas_widget.usr_note TEntry $win all .]
+
+
+ draw_ic_package 73 10
+ draw_combo_boxes 35 10
+ draw_temperature_indicator 245 20
+ draw_registers 280 30
+
+ adjust_temp_ind
+
+ # Create "ON/OFF" button
+ set start_stop_button [ttk::button $canvas_widget.start_stop_button \
+ -command "$this on_off_button_press" \
+ -style Flat.TButton \
+ -width 3 \
+ ]
+ DynamicHelp::add $canvas_widget.start_stop_button \
+ -text [mc "Turn HW simulation on/off"]
+ setStatusTip -widget $start_stop_button -text [mc "Turn HW simulation on/off"]
+ bind $start_stop_button <Button-3> "$this on_off_button_press; break"
+ $canvas_widget create window 30 135 -window $start_stop_button -anchor nw
+ bindtags $start_stop_button [list $start_stop_button TButton all .]
+
+ # Create configuration menu button
+ set conf_button [ttk::button $canvas_widget.conf_but \
+ -image ::ICONS::16::configure \
+ -style FlatWhite.TButton \
+ -command "$this config_menu" \
+ ]
+ setStatusTip -widget $conf_button -text [mc "Configure"]
+ $canvas_widget create window 28 135 -window $conf_button -anchor ne
+ bindtags $conf_button [list $conf_button TButton all .]
+
+ # Pack canvas
+ pack $canvas_widget -fill both -expand 1
+
+ # Set window parameters
+ wm minsize $win 500 160
+ wm iconphoto $win ::ICONS::16::$component_icon
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
+ wm resizable $win 0 0
+ wm protocol $win WM_DELETE_WINDOW "$this close_window"
+ bindtags $win [list $win Toplevel all .]
+ }
+
+ public method reg_bit_event {type reg bit_no} {
+ switch -- $type {
+ 1 {
+ set ds1620_reg($reg) [expr {$ds1620_reg($reg) ^ (1 << $bit_no)}]
+ update_reg $reg
+ }
+ {E} { ;# Enter
+ set bit [expr {$ds1620_reg($reg) & (1 << $bit_no)}]
+ if {$bit} {
+ set fill ${::BitMap::one_a_fill}
+ set outline ${::BitMap::one_a_outline}
+ } else {
+ set fill ${::BitMap::zero_a_fill}
+ set outline ${::BitMap::zero_a_outline}
+ }
+ $canvas_widget itemconfigure $reg_bit($reg,$bit_no) -outline $outline -fill $fill
+ $canvas_widget configure -cursor hand2
+ }
+ {L} { ;# Leave
+ set bit [expr {$ds1620_reg($reg) & (1 << $bit_no)}]
+ if {$bit} {
+ set fill ${::BitMap::one_fill}
+ set outline ${::BitMap::one_outline}
+ } else {
+ set fill ${::BitMap::zero_fill}
+ set outline ${::BitMap::zero_outline}
+ }
+ $canvas_widget itemconfigure $reg_bit($reg,$bit_no) -outline $outline -fill $fill
+ $canvas_widget configure -cursor left_ptr
+ }
+ }
+ }
+
+ private method draw_registers {x_offset y_offset} {
+ set labels [list {TH} {TL} {TEMP}]
+ for {set i 0} {$i < 3} {incr i} {
+ set reg_name [lindex $labels $i]
+
+ $canvas_widget create text \
+ [expr {$x_offset + 0}] [expr {$y_offset + ($i * 20)}] \
+ -text $reg_name \
+ -font $cb_font \
+ -anchor w
+
+ set sep 0
+ for {set j 0} {$j < 9} {incr j} {
+ set k [expr {8 - $j}]
+ set reg_bit($reg_name,$k) [$canvas_widget create rectangle \
+ [expr {$x_offset + 38 + ($j * 13) + $sep}] [expr {$y_offset + ($i * 20) - 7}] \
+ [expr {$x_offset + 38 + ($j * 13) + 10 + $sep}] [expr {$y_offset + ($i * 20) - 7 + 10}] \
+ -width 1 \
+ ]
+ switch -- $j {
+ 0 -
+ 4 {
+ incr sep 3
+ }
+ }
+
+ $canvas_widget bind $reg_bit($reg_name,$k) <Button-1> [list $this reg_bit_event 1 $reg_name $k]
+ $canvas_widget bind $reg_bit($reg_name,$k) <Enter> [list $this reg_bit_event E $reg_name $k]
+ $canvas_widget bind $reg_bit($reg_name,$k) <Leave> [list $this reg_bit_event L $reg_name $k]
+ }
+ set entrybox($reg_name) [ttk::entry $canvas_widget.reg_$reg_name \
+ -validate key \
+ -validatecommand [list $this validate_reg_entry $reg_name %P] \
+ -width 5 \
+ -font $cb_font \
+ ]
+ $canvas_widget create window \
+ [expr {$x_offset + 163}] [expr {$y_offset + ($i * 20) - 10}] \
+ -window $entrybox($reg_name) \
+ -anchor nw
+
+ $canvas_widget create text \
+ [expr {$x_offset + 202}] [expr {$y_offset + ($i * 20)}] \
+ -text {°C} \
+ -font $cb_font \
+ -anchor w
+ }
+
+ set i 7
+ set sep 0
+ foreach bit_name $STATUS_BITS {
+ set status($bit_name) [$canvas_widget create text \
+ [expr {$x_offset - 0 + $sep}] [expr {$y_offset + 70}] \
+ -text $bit_name \
+ -font $::Simulator_GUI::bitfont \
+ -anchor w
+ ]
+
+ if {$i != 3 && $i != 2} {
+ $canvas_widget bind $status($bit_name) <Enter> [list $this status_bit_event E $bit_name $i]
+ $canvas_widget bind $status($bit_name) <Leave> [list $this status_bit_event L $bit_name $i]
+ $canvas_widget bind $status($bit_name) <Button-1> [list $this status_bit_event 1 $bit_name $i]
+ } elseif {$i == 2} {
+ $canvas_widget itemconfigure $status($bit_name) -fill ${::Simulator_GUI::off_color}
+ } elseif {$i == 3} {
+ $canvas_widget itemconfigure $status($bit_name) -fill ${::Simulator_GUI::on_color}
+ }
+
+ incr i -1
+ incr sep 2
+ incr sep [expr {9 * [string length $bit_name]}]
+ }
+ }
+
+ public method validate_reg_entry {reg_name content} {
+ if {![string length $content]} {
+ return 1
+ }
+ if {[string index $content 0] == {-} && [string length $content] == 1} {
+ return 1
+ }
+ if {[regexp {^\-?\d+\.$} $content]} {
+ return 1
+ }
+
+ if {![regexp {^\-?(\d+(\.\d)?)?$} $content]} {
+ return 0
+ }
+
+ if {$content > 127.5 || $content < -128.0} {
+ return 0
+ }
+
+ if {$reg_name == {STATUS}} {
+ set ds1620_reg($reg_name) $content
+ } else {
+ set content [expr {int($content * 2)}]
+ if {$content < 0} {
+ set content [expr {$content & 0x1ff}]
+ }
+ set ds1620_reg($reg_name) $content
+ }
+ update_reg $reg_name 1
+
+ return 1
+ }
+
+ private method update_reg {reg_name {do_not_affect_entrybox 0}} {
+ if {$reg_name == {STATUS}} {
+ set i 7
+ foreach bit_name $STATUS_BITS {
+ if {$ds1620_reg(STATUS) & (1 << $i)} {
+ set color ${::Simulator_GUI::on_color}
+ } else {
+ set color ${::Simulator_GUI::off_color}
+ }
+ $canvas_widget itemconfigure $status($bit_name) -fill $color
+
+ incr i -1
+ }
+ } else {
+ for {set bit_no 0} {$bit_no < 9} {incr bit_no} {
+ set bit [expr {$ds1620_reg($reg_name) & (1 << $bit_no)}]
+ if {$bit} {
+ set outline ${::BitMap::one_outline}
+ set fill ${::BitMap::one_fill}
+ } else {
+ set outline ${::BitMap::zero_outline}
+ set fill ${::BitMap::zero_fill}
+ }
+ $canvas_widget itemconfigure $reg_bit($reg_name,$bit_no) -outline $outline -fill $fill
+ }
+
+ if {!$do_not_affect_entrybox} {
+ set dec_val [expr {$ds1620_reg($reg_name) & 0xff}]
+ if {$ds1620_reg($reg_name) & 0x100} {
+ set dec_val [expr {$dec_val - 256}]
+ }
+ set dec_val [expr {$dec_val / 2.0}]
+ $entrybox($reg_name) delete 0 end
+ $entrybox($reg_name) insert 0 $dec_val
+ }
+ }
+
+ if {$reg_name == {TEMP}} {
+ update_outputs_Th_Tl_Tcom
+ }
+ }
+
+ public method status_bit_event {type bit_name bit_no} {
+ switch -- $type {
+ {1} {
+ set ds1620_reg(STATUS) [expr {$ds1620_reg(STATUS) ^ (1 << $bit_no)}]
+ update_reg STATUS
+ }
+ {E} {
+ $canvas_widget configure -cursor hand2
+ $canvas_widget itemconfigure $status($bit_name) -font $::Simulator_GUI::bitfont_under
+ }
+ {L} {
+ $canvas_widget configure -cursor left_ptr
+ $canvas_widget itemconfigure $status($bit_name) -font $::Simulator_GUI::bitfont
+ }
+ }
+ }
+
+ private method draw_temperature_indicator {x_offset y_offset} {
+ set x $x_offset
+ set y $y_offset
+
+ set temp_ind_x_offset $x_offset
+ set temp_ind_y_offset $y_offset
+
+ for {set i 0} {$i <= 100} {incr i} {
+ $canvas_widget create line \
+ [expr {$x + 0}] [expr {$y + $i}] \
+ [expr {$x + 10}] [expr {$y + $i}] \
+ -fill [format {#%02x33%02x} [expr {255 - int($i * 2.55)}] [expr {int($i * 2.55)}]] \
+ -tags temperature_indicator
+ }
+
+ $canvas_widget create line \
+ [expr {$x - 0}] [expr {$y + 0}] \
+ [expr {$x - 15}] [expr {$y + 0}] \
+ [expr {$x + 25}] [expr {$y + 0}] \
+ [expr {$x + 10}] [expr {$y + 0}] \
+ -fill {#000000} -arrow both \
+ -tags {temperature_pointer temperature_indicator}
+
+ $canvas_widget create text [expr {$x - 40}] [expr {$y - 8}] \
+ -text {°C} \
+ -font $cb_font \
+ -anchor w \
+ -tags temperature_C
+ $canvas_widget create text [expr {$x + 50}] [expr {$y - 8}] \
+ -text {°F} \
+ -font $cb_font \
+ -anchor e \
+ -tags temperature_F
+
+
+ $canvas_widget bind temperature_indicator <Button-1> [list $this temp_ind_event 1 %y]
+ $canvas_widget bind temperature_indicator <Button-5> [list $this temp_ind_event 5]
+ $canvas_widget bind temperature_indicator <Button-4> [list $this temp_ind_event 4]
+ $canvas_widget bind temperature_indicator <B1-Motion> [list $this temp_ind_event 1 %y]
+ }
+
+ private method adjust_temp_ind {} {
+ set y [expr {100 - int(($temperature + 55) / 1.8)}]
+
+ $canvas_widget move temperature_pointer 0 [expr {$y - $temp_point_y}]
+ set temp_point_y $y
+
+ $canvas_widget itemconfigure temperature_C -text [format {%s%3.1f°C} [expr {$temperature > 0 ? "" : "-"}] $temperature]
+ $canvas_widget itemconfigure temperature_F -text [format {%s%3.1f°F} [expr {($temperature * (9.0/5) + 32) > 0 ? "" : "-"}] [expr {($temperature * (9.0/5) + 32)}]]
+ }
+
+ public method temp_ind_event {type {y 0}} {
+ switch -- $type {
+ 1 {
+ incr y -$temp_ind_y_offset
+ set temperature [expr {180 - int($y * 1.8) - 55}]
+ }
+ 4 { ;# Wheel up
+ set temperature [expr {$temperature + 0.5}]
+ }
+ 5 { ;# Wheel down
+ set temperature [expr {$temperature - 0.5}]
+ }
+ }
+
+ if {$temperature < -55} {
+ set temperature -55
+ } elseif {$temperature > 125} {
+ set temperature 125
+ }
+
+ adjust_temp_ind
+ }
+
+ private method draw_combo_boxes {x_offset y_offset} {
+ set x $x_offset
+ set y $y_offset
+
+ incr y 12
+
+ for {set i 0} {$i < 6} {incr i} {
+ $canvas_widget create window $x $y -anchor e \
+ -window [ttk::combobox $canvas_widget.cb_p$i \
+ -width 1 \
+ -font $cb_font \
+ -state readonly \
+ ]
+ bind $canvas_widget.cb_p$i <<ComboboxSelected>> "$this reconnect $i"
+
+ $canvas_widget create window $x $y -anchor w \
+ -window [ttk::combobox $canvas_widget.cb_b$i \
+ -width 1 \
+ -font $cb_font \
+ -values {- 0 1 2 3 4 5 6 7} \
+ -state readonly \
+ ]
+ bind $canvas_widget.cb_b$i <<ComboboxSelected>> "$this reconnect $i"
+
+ bindtags $canvas_widget.cb_p$i \
+ [list $canvas_widget.cb_p$i TCombobox all .]
+ bindtags $canvas_widget.cb_b$i \
+ [list $canvas_widget.cb_b$i TCombobox all .]
+
+ if {$i == 2} {
+ incr x 160
+ incr y -25
+ } else {
+ incr y 25
+ }
+ }
+
+ $canvas_widget create text \
+ [expr {$x_offset + 0}] \
+ [expr {$y_offset + 5 + 3*25}] \
+ -text [mc "PORT"] \
+ -font $cb_font \
+ -anchor e
+ $canvas_widget create text \
+ [expr {$x_offset + 5}] \
+ [expr {$y_offset + 5 + 3*25}] \
+ -text [mc "BIT"] \
+ -font $cb_font \
+ -anchor w
+
+ $canvas_widget create text \
+ [expr {$x_offset + 160}] \
+ [expr {$y_offset + 21}] \
+ -text [mc "PORT"] \
+ -font $cb_font \
+ -anchor e
+ $canvas_widget create text \
+ [expr {$x_offset + 165}] \
+ [expr {$y_offset + 21}] \
+ -text [mc "BIT"] \
+ -font $cb_font \
+ -anchor w
+ }
+
+ private method draw_ic_package {x_offset y_offset} {
+ $canvas_widget create line \
+ [expr {$x_offset + 15}] [expr {$y_offset + 0}] \
+ [expr {$x_offset + 70}] [expr {$y_offset + 0}] \
+ [expr {$x_offset + 70}] [expr {$y_offset + 100}] \
+ [expr {$x_offset + 15}] [expr {$y_offset + 100}] \
+ [expr {$x_offset + 15}] [expr {$y_offset + 0}] \
+ -fill {#000000}
+
+ $canvas_widget create text \
+ [expr {$x_offset + 42}] [expr {$y_offset + 102}] \
+ -text {DS1620} \
+ -anchor n \
+ -font [font create -family $::DEFAULT_FIXED_FONT -size -13]
+
+ set i 0
+ for {set x 0} {$x < 2} {incr x} {
+ for {set y 0} {$y < 4} {incr y} {
+ $canvas_widget create rectangle \
+ [expr {$x_offset + ($x * 70) + 0}] [expr {$y_offset + ($y * 25) + 5}] \
+ [expr {$x_offset + ($x * 70) + 15}] [expr {$y_offset + ($y * 25) + 20}] \
+ -fill {#ffffff}
+ $canvas_widget create text \
+ [expr {$x_offset + ($x * 70) + 7}] [expr {$y_offset + ($y * 25) + 13}] \
+ -text [lindex {1 2 3 4 8 7 6 5} $i] \
+ -font $cb_font
+ $canvas_widget create text \
+ [expr {$x_offset + ($x ? 39 : 10) + 7}] [expr {$y_offset + ($y * 25) + 13}] \
+ -text [lindex {DQ CLK RST GND V T T T} $i] \
+ -font $small_font \
+ -anchor w
+ if {$i > 3} {
+ $canvas_widget create text \
+ [expr {$x_offset + 45 + 7}] [expr {$y_offset + ($y * 25) + 18}] \
+ -text [lindex {{} {} {} {} dd high low com} $i] \
+ -font $small_font \
+ -anchor w
+ }
+
+ set line [$canvas_widget create line \
+ [expr {$x_offset + ($x ? 85 : -15)}] [expr {$y_offset + ($y * 25) + 12}] \
+ [expr {$x_offset + ($x ? 100 : 0)}] [expr {$y_offset + ($y * 25) + 12}] \
+ ]
+ if {$i < 3 || $i > 4} {
+ if {$i < 3} {
+ set j $i
+ } else {
+ set j [expr {$i - 2}]
+ }
+ set wires($j) $line
+
+ # GND
+ } elseif {$i == 3} {
+ $canvas_widget itemconfigure $line -fill {#00ff00}
+ $canvas_widget create line \
+ [expr {$x_offset - 15}] [expr {$y_offset + ($y * 25) + 12}] \
+ [expr {$x_offset - 15}] [expr {$y_offset + ($y * 25) + 27}] \
+ [expr {$x_offset - 7}] [expr {$y_offset + ($y * 25) + 27}] \
+ [expr {$x_offset - 23}] [expr {$y_offset + ($y * 25) + 27}] \
+ -fill {#00ff00}
+
+ # Vdd
+ } elseif {$i == 4} {
+ $canvas_widget itemconfigure $line -fill {#ff0000}
+ $canvas_widget create line \
+ [expr {$x_offset + 100}] [expr {$y_offset + ($y * 25) + 12}] \
+ [expr {$x_offset + 100}] [expr {$y_offset + ($y * 25) - 3}] \
+ -fill {#ff0000} -arrow last
+ }
+
+ incr i
+ }
+ }
+
+ $canvas_widget create arc \
+ [expr {$x_offset + 37}] [expr {$y_offset - 5}] \
+ [expr {$x_offset + 47}] [expr {$y_offset + 5}] \
+ -start 0 \
+ -extent -180
+ }
+
+ ## Determinate which port pin is connected to the specified LED
+ # @parm Int i - LED number
+ # @return List - {port_number bit_number}
+ private method which_port_pin {i} {
+ return [list $connection_port($i) $connection_pin($i)]
+ }
+
+ ## Handle "ON/OFF" button press
+ # Turn whole PALE system on or off
+ # @return void
+ public method on_off_button_press {} {
+ $project pale_all_on_off
+ }
+
+ ## Show the log window
+ # The log window must have been once created by method create_log prior to
+ #+ the call to this method
+ # @return void
+ public method show_log {} {
+ if {$warning_indicator != {}} {
+ $canvas_widget delete $warning_indicator
+ set warning_indicator {}
+ }
+
+ set dialog $win.log_window
+ if {[wm state $dialog] == {normal}} {
+ raise $dialog
+ return
+ }
+ if {![winfo exists $dialog]} {
+ return
+ }
+ wm deiconify $dialog
+ if {$log_window_geometry != {}} {
+ wm geometry $dialog $log_window_geometry
+ }
+ }
+
+ ## Create the log dialog window, but do not show it until method show_log is called
+ # @return void
+ public method create_log {} {
+ # Create the dialog window (hidden for now)
+ set dialog $win.log_window
+ toplevel $dialog
+ wm withdraw $dialog
+
+ ## Create main frame (text and scrollbar)
+ set main_frame [frame $dialog.main_frame]
+ # Text widget
+ set text_widget [text $main_frame.text \
+ -width 0 -height 0 -font $hlp_normal_font \
+ -yscrollcommand [list $main_frame.scrollbar set] \
+ -wrap word -padx 5 -pady 5 -state disabled \
+ ]
+ set log_win_text $text_widget
+ bindtags $text_widget [list $text_widget Text $win all .]
+ pack $text_widget -side left -fill both -expand 1
+ # Create text tag in the text widget
+ $text_widget tag configure tag_info -foreground {#FFFFFF} -background {#0000EE}
+ $text_widget tag configure tag_warning -foreground {#FFFFFF} -background {#EE8800}
+ $text_widget tag configure tag_error -foreground {#FFFFFF} -background {#DD0000}
+ $text_widget tag configure tag_line \
+ -background {#DDDDDD} \
+ -font [font create \
+ -family ${::DEFAULT_FIXED_FONT} \
+ -size -1 \
+ ]
+
+ # Scrollbar
+ pack [ttk::scrollbar $main_frame.scrollbar \
+ -orient vertical \
+ -command [list $text_widget yview] \
+ ] -side right -fill y
+ # Finalize ...
+ pack $main_frame -fill both -expand 1 -padx 2
+
+ # Create bottom frame
+ set bottom_frame [frame $dialog.bottom_frame]
+ # Button "Close"
+ pack [ttk::button $bottom_frame.close_button \
+ -text [mc "Close"] \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command [list $this close_log_win] \
+ ] -side right
+ pack [ttk::button $bottom_frame.clear_button \
+ -text [mc "Clear log"] \
+ -compound left \
+ -image ::ICONS::16::editdelete \
+ -command "
+ $text_widget configure -state normal
+ $text_widget delete 0.0 end
+ $text_widget configure -state disabled
+ " \
+ ] -side left
+ # CheckBox: "Enable log"
+ set log_on_off_chbut [checkbutton $bottom_frame.on_off_chbut \
+ -command [list $this log_on_off] \
+ -text [mc "Enable log"] \
+ ]
+ if {$log_enabled} {
+ $log_on_off_chbut select
+ } else {
+ $log_on_off_chbut deselect
+ }
+ setStatusTip -widget $log_on_off_chbut -text [mc "Disabled logging may notably improve simulation speed"]
+ DynamicHelp::add $log_on_off_chbut -text [mc "Disabled logging may notably improve simulation speed"]
+ pack $log_on_off_chbut -side left -padx 5
+ pack $bottom_frame -pady 2 -padx 5 -fill x
+
+ # Set window parameters
+ wm minsize $dialog [expr {int(300 * $::font_size_factor)}] [expr {int(150 * $::font_size_factor)}]
+ wm iconphoto $dialog ::ICONS::16::bar5
+ wm title $dialog [mc "DS1620 log - MCU 8051 IDE"]
+ wm protocol $dialog WM_DELETE_WINDOW [list $this close_log_win]
+ bindtags $dialog [list $dialog Toplevel $win all .]
+ }
+
+ ## Enable or disable logging of events
+ # @return void
+ public method log_on_off {} {
+ set log_enabled [expr {!$log_enabled}]
+
+ # Set flag modified
+ set_modified
+ }
+
+ ## Close the DS1620 log window
+ # @return void
+ public method close_log_win {} {
+ set dialog $win.log_window
+ if {![winfo exists $dialog]} {
+ return
+ }
+
+ set log_window_geometry [wm geometry $dialog]
+ wm withdraw $dialog
+ }
+
+ ## Informs the DS1620 simulator about change of _no_delays flag (used by configuration menu)
+ # @return void
+ public method no_delays_changed {} {
+ set no_delays ${::Ds1620::_no_delays}
+ }
+
+ ## Write a message to the log
+ # @parm Char type - Message type "I" == Information; "W" == Warning; "E" == Error
+ # @parm String string - Text of the message
+ # @return void
+ private method write_to_log {type string} {
+ # Do not do anything if the log is not available at all
+ if {!$log_enabled || $log_win_text == {}} {
+ return
+ }
+
+ # Enable the text widget
+ $log_win_text configure -state normal
+
+ # Manage the log length, the number of row in the log must not exceed the specified maximum
+ if {int([$log_win_text index end]) > ($MAX_LOG_LENGTH + 1)} {
+ set diff [expr {int([$log_win_text index end]) - $MAX_LOG_LENGTH}]
+ $log_win_text delete 1.0 $diff.0
+ }
+ $log_win_text mark set insert {end -1l lineend}
+
+ # Insert separators (horizontal lines) between events with the same time mark
+ if {$time_mark && $log_time_mark != $time_mark} {
+ set log_time_mark $time_mark
+ $log_win_text insert insert "\n"
+ $log_win_text tag add tag_line insert-1l insert
+ }
+
+ # Insert the information about the message type
+ switch -- $type {
+ {I} { ;# Information
+ $log_win_text insert insert [mc "\[INFO\] "]
+ $log_win_text tag add tag_info {insert linestart} insert-1c
+ }
+ {W} { ;# Warning
+ $log_win_text insert insert [mc "\[WARNING\] "]
+ $log_win_text tag add tag_warning {insert linestart} insert-1c
+ }
+ {E} { ;# Error
+ $log_win_text insert insert [mc "\[ERROR\] "]
+ $log_win_text tag add tag_error {insert linestart} insert-1c
+ }
+ }
+
+ # Insert the message itself
+ $log_win_text insert insert $string
+ $log_win_text insert insert "\n"
+ $log_win_text see insert
+
+ # Disable the text widget
+ $log_win_text configure -state disabled
+
+ #
+ if {$type == {E} && $warning_indicator == {}} {
+ set warning_indicator [$canvas_widget create image 35 105 -anchor ne -image ::ICONS::16::status_unknown]
+ $canvas_widget bind $warning_indicator <Button-1> [list $this show_log]
+ $canvas_widget bind $warning_indicator <Enter> {%W configure -cursor hand2}
+ $canvas_widget bind $warning_indicator <Leave> {%W configure -cursor left_ptr}
+ }
+ }
+
+
+ # ------------------------------------------------------------------
+ # DS1620 INTERNAL FUNCTIONS
+ # ------------------------------------------------------------------
+
+ private method update_outputs_Th_Tl_Tcom {} {
+ set temp_dec $ds1620_reg(TEMP)
+ set th_dec $ds1620_reg(TH)
+ set tl_dec $ds1620_reg(TL)
+
+ if {$temp_dec & 0x100} {
+ incr temp_dec -512
+ }
+ if {$th_dec & 0x100} {
+ incr th_dec -512
+ }
+ if {$tl_dec & 0x100} {
+ incr tl_dec -512
+ }
+
+ if {$temp_dec > $th_dec} {
+ if {!$signal(TH)} {
+ write_to_log I [mc "Current temperature exceeds TH temperature"]
+ }
+
+ set signal(TH) 1
+ set signal(TCOM) 1
+
+ set ds1620_reg(STATUS) [expr {$ds1620_reg(STATUS) | 0x40}]
+ update_reg STATUS
+ } else {
+ set signal(TH) 0
+ }
+ if {$temp_dec < $tl_dec} {
+ if {!$signal(TL)} {
+ write_to_log I [mc "Current temperature is below TL temperature"]
+ }
+
+ set signal(TL) 1
+ set signal(TCOM) 0
+
+ set ds1620_reg(STATUS) [expr {$ds1620_reg(STATUS) | 0x20}]
+ update_reg STATUS
+ } else {
+ set signal(TL) 0
+ }
+ }
+
+ private method finalize_conversion {} {
+ # One-shot conversion mode
+ if {$ds1620_reg(STATUS) & 0x01} {
+ set conversion_running 0
+ }
+
+ if {$temperature < 0} {
+ set ds1620_reg(TEMP) [expr {512 - int($temperature * -2)}]
+ } else {
+ set ds1620_reg(TEMP) [expr {int($temperature * 2)}]
+ }
+ set ds1620_reg(STATUS) [expr {$ds1620_reg(STATUS) | 0x80}]
+ set ds1620_reg(REMAIN) [expr {int(rand() * 0x1ff)}]
+ update_reg TEMP
+ update_reg STATUS
+
+ if {!$no_delays} {
+ write_to_log I [mc "Temperature conversion finished"]
+ }
+ }
+
+ private method proceed_with_t_conversion {} {
+ if {!$t_conversion_time_mark} {
+ restart_t_conversion
+ }
+ if {$no_delays || $t_conversion_time_mark <= $time_mark} {
+ if {!$no_delays} {
+ restart_t_conversion
+ }
+ finalize_conversion
+ }
+ }
+
+ private method restart_t_conversion {} {
+ write_to_log I [mc "Temperature conversion will be completed when MCU time reach %dns" [expr {$time_mark + $T_CONVERSION_TIME_MS * 1000000}]]
+ set t_conversion_time_mark [expr {$time_mark + $T_CONVERSION_TIME_MS * 1000000}]
+ }
+
+ private method transmit_data {} {
+ if {0 && $delay_transmission} {
+ set delay_transmission 0
+ return 0
+ } else {
+ set signal(DQ) [expr {($data_to_send & (1 << $bit_number)) ? 1 : 0}]
+ incr bit_number
+
+ if {$bit_number == $number_of_bits} {
+ set communication_disabled 1
+ set pending_communication 0
+ }
+ return 1
+ }
+ }
+
+ private method receive_data {} {
+ if {!$bit_number} {
+ set byte_received 0
+ }
+ set byte_received [expr {$byte_received | ($signal(DQ) << $bit_number)}]
+ incr bit_number
+
+ if {$receive_command_or_data && $bit_number == 8} {
+ set bit_number 0
+ set command_received $byte_received
+
+ switch -- $command_received {
+ {170} { ;# Read Temperature [AAh]
+ write_to_log I [mc "Received command: Read Temperature \[AAh\] -- sending 9 data bits"]
+ set delay_transmission 1
+ set reception_or_transmission 0
+ set number_of_bits 9
+ set data_to_send $ds1620_reg(TEMP)
+ }
+ {1} { ;# Write TH [01h]
+ write_to_log I [mc "Received command: Write TH \[01h\] -- expecting 9 data bits"]
+ set receive_command_or_data 0
+ set number_of_bits 9
+ }
+ {2} { ;# Write TL [02h]
+ write_to_log I [mc "Received command: Write TL \[02h\] -- expecting 9 data bits"]
+ set receive_command_or_data 0
+ set number_of_bits 9
+ }
+ {161} { ;# Read TH [A1h]
+ write_to_log I [mc "Received command: Read TH \[A1h\] -- sending 9 data bits"]
+ set delay_transmission 1
+ set reception_or_transmission 0
+ set number_of_bits 9
+ set data_to_send $ds1620_reg(TH)
+ }
+ {162} { ;# Read TL [A2h]
+ write_to_log I [mc "Received command: Read TL \[A2h\] -- sending 9 data bits"]
+ set delay_transmission 1
+ set reception_or_transmission 0
+ set number_of_bits 9
+ set data_to_send $ds1620_reg(TL)
+ }
+ {160} { ;# Read Counter [A0h]
+ write_to_log I [mc "Received command: Read Counter \[A0h\] -- sending 9 data bits"]
+ set delay_transmission 1
+ set reception_or_transmission 0
+ set number_of_bits 9
+ set data_to_send $ds1620_reg(REMAIN)
+ }
+ {169} { ;# Read Slope [A9h]
+ write_to_log I [mc "Received command: Read Slope \[A9h\] -- sending 9 data bits"]
+ set delay_transmission 1
+ set reception_or_transmission 0
+ set number_of_bits 9
+ set data_to_send $ds1620_reg(PER_C)
+ }
+ {238} { ;# Start Convert T [EEh]
+ if {$ds1620_reg(STATUS) & 0x01} {
+ if {$conversion_running} {
+ write_to_log I [mc "Received command: Start Convert T \[EEh\] -- Starting T conversion on demand"]
+ } else {
+ write_to_log I [mc "Received command: Start Convert T \[EEh\] -- Restarting T conversion on demand"]
+ }
+ } else {
+ if {$conversion_running} {
+ write_to_log I [mc "Received command: Start Convert T \[EEh\] -- Starting continuous T conversion"]
+ } else {
+ write_to_log I [mc "Received command: Start Convert T \[EEh\] -- Restarting continuous T conversion"]
+ }
+ }
+
+ restart_t_conversion
+
+ set conversion_running 1
+ set communication_disabled 1
+ set pending_communication 0
+ }
+ {34} { ;# Stop Convert T [22h]
+ if {$conversion_running} {
+ if {$ds1620_reg(STATUS) & 0x01} {
+ write_to_log I [mc "Received command: Stop Convert T \[22h\] -- Stopping T conversion which is currently in progress"]
+ } else {
+ write_to_log I [mc "Received command: Stop Convert T \[22h\] -- Stopping continuous T conversion"]
+ }
+ restart_t_conversion
+ } else {
+ write_to_log W [mc "Received command: Stop Convert T \[22h\] -- No T conversion in progress -- command has no effect"]
+ }
+ set conversion_running 0
+ set communication_disabled 1
+ set pending_communication 0
+ }
+ {12} { ;# Write Config [0Ch]
+ write_to_log I [mc "Received command: Write Config \[0Ch\] -- expecting 8 data bits"]
+ set receive_command_or_data 0
+ set number_of_bits 8
+ }
+ {172} { ;# Read Config [ACh]
+ write_to_log I [mc "Received command: Read Config \[ACh\] -- sending 8 data bits"]
+ set delay_transmission 1
+ set reception_or_transmission 0
+ set number_of_bits 8
+ set data_to_send $ds1620_reg(STATUS)
+
+ }
+ default {
+ write_to_log E [mc "Received unknown command: %02Xh" $command_received]
+ }
+ }
+
+ } elseif {!$receive_command_or_data && $bit_number == $number_of_bits} {
+ set communication_disabled 1
+ set pending_communication 0
+
+ write_to_log I [mc "Received data: %03Xh -- finishing command" $byte_received]
+
+ switch -- $command_received {
+ {1} { ;# Write TH [01h]
+ if {$ds1620_reg(STATUS) & 0x10} {
+ write_to_log E [mc "Nonvolatile memory is still busy -- command ignored"]
+ } else {
+ set write_to_NVM [expr {[$project get_run_statistics 0] + $EEPROM_WRITE_CYCLE_TIME * 1000}]
+ set ds1620_reg(TH) $byte_received
+ update_reg TH
+
+ write_to_log I [mc "Commencing write to nonvolatile memory: TH := %02Xh" $byte_received]
+ }
+ }
+ {2} { ;# Write TL [02h]
+ if {$ds1620_reg(STATUS) & 0x10} {
+ write_to_log E [mc "Nonvolatile memory is still busy -- command ignored"]
+ } else {
+ set write_to_NVM [expr {[$project get_run_statistics 0] + $EEPROM_WRITE_CYCLE_TIME * 1000}]
+ set ds1620_reg(TL) $byte_received
+ update_reg TL
+
+ write_to_log I [mc "Commencing write to nonvolatile memory: TL := %02Xh" $byte_received]
+ }
+ }
+ {12} { ;# Write Config [0Ch]
+ if {$ds1620_reg(STATUS) & 0x10} {
+ write_to_log E [mc "Nonvolatile memory is still busy -- command ignored"]
+ } else {
+ set write_to_NVM [expr {[$project get_run_statistics 0] + $EEPROM_WRITE_CYCLE_TIME * 1000}]
+ set ds1620_reg(STATUS) [expr {($ds1620_reg(STATUS) & 0x9C) | ($byte_received & 0x63) | 0x10}]
+ update_reg STATUS
+
+ write_to_log I [mc "Commencing write to nonvolatile memory: STATUS/CONFIG := %02Xh" $byte_received]
+ }
+ }
+ }
+ }
+ }
+
+ private method check_proper_timing {event} {
+ set time_of($event) $time_mark
+ if {$no_delays} {
+ return
+ }
+
+ switch -- $event {
+ {DQ_up} {
+ # Check for valid t_CDH (CLK to Data Hold) >= 40
+ if {($time_mark < ($time_of(CLK_up) + 40)) || ($time_mark < ($time_of(CLK_down) + 40))} {
+ write_to_log E [mc "Bad timing: t_CDH (CLK to Data Hold) too low, must be at least 40ns"]
+ }
+ }
+ {DQ_down} {
+ # Check for valid t_CDH (CLK to Data Hold) >= 40
+ if {($time_mark < ($time_of(CLK_up) + 40)) || ($time_mark < ($time_of(CLK_down) + 40))} {
+ write_to_log E [mc "Bad timing: t_CDH (CLK to Data Hold) too low, must be at least 40ns"]
+ }
+ }
+ {RST_up} {
+ # Check for valid t_CWH (RST Inactive Time) >= 125
+ if {$command_received == 0x01 || $command_received == 0x02 || $command_received == 0x0C} {
+ set min_time [expr {$EEPROM_WRITE_CYCLE_TIME * 1000}]
+ } else {
+ set min_time 125
+ }
+ if {$time_mark < ($time_of(RST_down) + $min_time)} {
+ write_to_log E [mc "Bad timing: t_CWH (RST Inactive Time) too low, must be at least %dns" ${min_time}]
+ }
+ }
+ {RST_down} {
+ if {$signal(RST)} {
+ # Check for valid t_CCH (CLK to RST Hold) >= 40
+ if {$time_mark < ($time_of(CLK_up) + 40)} {
+ write_to_log E [mc "Bad timing: t_CCH (CLK to RST Hold too low, must be at least 40ns"]
+ }
+ }
+ }
+ {CLK_up} {
+ if {$signal(RST)} {
+ # Check for valid t_DC (Data to CLK Setup) >= 35
+ if {($time_mark < ($time_of(DQ_up) + 35)) || $time_mark < ($time_of(DQ_down) + 35)} {
+ write_to_log E [mc "Bad timing: t_DC (Data to CLK Setup) too low, must be at least 35ns"]
+ }
+ # Check for valid t_CL (CLK Low Time) >= 285ns
+ if {$time_mark < ($time_of(CLK_down) + 285)} {
+ write_to_log E [mc "Bad timing: t_CL (CLK Low Time) too low, must be at least 285ns"]
+ }
+ } else {
+ # Check for valid t_CNV (Convert Pulse Width) >= 250ns & <= 500ms
+ if {($time_mark < ($time_of(CLK_down) + 250)) || ($time_mark > ($time_of(CLK_down) + 500000000))} {
+ write_to_log E [mc "Bad timing: t_CNV (Convert Pulse Width) too low or too high, must be at least 250ns and at most 500ms"]
+ }
+
+ }
+ }
+ {CLK_down} {
+ # Check for valid t_CC (RST To CLK Setup) >= 100ns
+ if {$time_mark < ($time_of(RST_up) + 100)} {
+ write_to_log E [mc "Bad timing: t_CC (RST To CLK Setup) too low, must be at least 100ns"]
+ }
+ # Check for valid t_CH (CLK High Time) >= 285ns
+ if {$time_mark < ($time_of(CLK_up) + 285)} {
+ write_to_log E [mc "Bad timing: t_CH (CLK High Time) too low, must be at least 285ns"]
+ }
+ }
+ }
+ }
+
+ private method ds1620_core__evaluate {} {
+ # Continuous conversion mode or One-shot conversion mode
+ if {$conversion_running} {
+ proceed_with_t_conversion
+ # Stand-alone mode
+ } elseif {!($ds1620_reg(STATUS) & 0x02) && !$signal(RST) && !$signal(CLK)} {
+ proceed_with_t_conversion
+ }
+
+ if {$ds1620_reg(STATUS) & 0x10} {
+ if {$no_delays || $write_to_NVM <= $time_mark} {
+ write_to_log I [mc "Write to nonvolatile memory is complete"]
+ set ds1620_reg(STATUS) [expr {$ds1620_reg(STATUS) ^ 0x10}]
+ }
+ }
+
+ # RESET signal is high -- Communicate with MCU
+ if {$signal(RST)} {
+ # Detect raising edge on the DQ signal
+ # ____
+ # /
+ # ____/
+ if {!$signal(DQ_prev) && $signal(DQ)} {
+ check_proper_timing DQ_up
+ # Detect falling edge on the DQ signal
+ # ____
+ # \
+ # \____
+ } elseif {$signal(DQ_prev) && !$signal(DQ)} {
+ check_proper_timing DQ_down
+ }
+
+ # Detect raising edge on the RST signal
+ # ____
+ # /
+ # ____/
+ if {!$signal(RST_prev)} {
+ check_proper_timing RST_up
+ set pending_communication 1
+ write_to_log I [mc "RESET signal was driven high -- commencing communication over 3-wire protocol"]
+ }
+
+ # Detect falling edge on the CLOCK signal - output bit to DQ
+ # ____
+ # \
+ # \____
+ if {$signal(CLK_prev) && !$signal(CLK) && !$reception_or_transmission} {
+ check_proper_timing CLK_down
+ if {$communication_disabled} {
+ write_to_log W [mc "Transmission is no longer relevant"]
+ } else {
+ if {[transmit_data]} {
+ write_to_log I [mc "Transmitting bit #%d = %d" [expr {$bit_number - 1}] $signal(DQ)]
+ }
+ }
+
+ # Detect raising edge on the CLOCK signal - read bit from DQ
+ # ____
+ # /
+ # ____/
+ } elseif {!$signal(CLK_prev) && $signal(CLK) && $reception_or_transmission} {
+ check_proper_timing CLK_up
+ if {$communication_disabled} {
+ write_to_log W [mc "Reception is no longer relevant"]
+ } else {
+ write_to_log I [mc "Receiving bit #%d = %d" $bit_number $signal(DQ)]
+ receive_data
+ }
+ }
+
+ # RESET signal is low -- Terminate all communications and commence stand-alone operation
+ } else {
+ # Detect falling edge on the RST signal
+ # ____
+ # \
+ # \____
+ if {$signal(RST_prev)} {
+ check_proper_timing RST_down
+ write_to_log I [mc "Received RESET signal -- commencing stand-alone operation"]
+ }
+
+ # Detect raising edge on the CLOCK signal
+ # ____
+ # /
+ # ____/
+ if {!$signal(CLK_prev) && $signal(CLK)} {
+ check_proper_timing CLK_up
+ # Detect falling edge on the CLOCK signal - output bit to DQ
+ # ____
+ # \
+ # \____
+ } elseif {$signal(CLK_prev) && !$signal(CLK)} {
+ check_proper_timing CLK_down
+ }
+
+ if {$pending_communication} {
+ set pending_communication 0
+ write_to_log W [mc "Data communication over 3-wire protocol was terminated by RESET signal!"]
+ }
+
+ set bit_number 0
+ set reception_or_transmission 1
+ set receive_command_or_data 1
+ set communication_disabled 0
+ }
+ }
+
+ public method reset_ds1620 {} {
+ set ds1620_reg(TEMP) 392
+ set ds1620_reg(REMAIN) 0
+ set ds1620_reg(STATUS) [expr {($ds1620_reg(STATUS) & 0x03) | 0x88}]
+
+ foreach reg {TH TL TEMP STATUS} {
+ update_reg $reg
+ }
+ }
+
+ # ------------------------------------------------------------------
+ # VIRTUAL HW COMMON INTERFACE
+ # ------------------------------------------------------------------
+
+ ## Simulated MCU has been changed
+ # @return void
+ public method mcu_changed {} {
+ # Refresh lists of possible values in port selection ComboBoxes
+ set available_ports [concat - [$project pale_get_available_ports]]
+
+ for {set i 0} {$i < 6} {incr i} {
+ $canvas_widget.cb_p$i configure -values $available_ports
+
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
+ $canvas_widget.cb_p$i current 0
+ set connection_port($i) {-}
+ }
+ }
+ }
+
+ ## Accept new state of ports
+ # @parm List state - Port states ( 5 x {8 x bit} -- {bit0 bit1 bit2 ... bit7} )
+ # @return void
+ #
+ # Possible bit values:
+ # '|' - High frequency
+ # 'X' - Access to external memory
+ # '?' - No volatge
+ # '-' - Indeterminable value (some noise)
+ # '=' - High forced to low
+ # '0' - Logical 0
+ # '1' - Logical 1
+ public method new_state {_state} {
+ upvar $_state state
+
+ read_inputs state
+
+ if {!$time_mark} {
+ set signal(CLK_prev) $signal(CLK)
+ set signal(RST_prev) $signal(RST)
+ if {$signal(DQ) != {}} {
+ set signal(DQ_prev) $signal(DQ)
+ }
+ }
+
+ if {$time_mark != [$project get_run_statistics 0]} {
+ set time_mark [$project get_run_statistics 0]
+ if {$input_error} {
+ write_to_log E $input_error_desc
+
+ set input_error 0
+ set input_error_desc {}
+ }
+
+ ds1620_core__evaluate
+ process_outputs state
+
+ set signal(CLK_prev) $signal(CLK)
+ set signal(RST_prev) $signal(RST)
+ if {$signal(DQ) != {}} {
+ set signal(DQ_prev) $signal(DQ)
+ }
+ }
+
+ # Reset last I/O error
+ set input_error 0
+ set input_error_desc {}
+
+ adjust_wire_colors state
+ }
+
+ private method process_outputs {_state} {
+ upvar $_state state
+
+ set lines_to_update [list 3 4 5]
+ if {!$signal(CLK) && $signal(RST)} {
+ lappend lines_to_update 0
+ }
+ foreach i $lines_to_update {
+ # Determinate index in the list of port states
+ set pp [which_port_pin $i]
+
+ # Not connected
+ if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
+ continue
+ }
+
+ lset state $pp $signal([lindex $SIGNAL_NAMES $i])
+ }
+ }
+
+ private method read_inputs {_state} {
+ upvar $_state state
+
+ foreach i {2 1 0} {
+ # Determinate index in the list of port states
+ set pp [which_port_pin $i]
+
+ # Not connected
+ if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
+ set signal_value {}
+ } else {
+ set signal_value [lindex $state $pp]
+ }
+
+ # Convert any possible I/O signal value to Boolean value
+ switch -- $signal_value {
+ {0} -
+ {1} {}
+ {=} {
+ set signal_value 0
+ }
+ default {
+ if {($i == 2) || ($i == 1) || ($i == 0 && $signal(RST))} {
+ set input_error 1
+ set input_error_desc [mc \
+ "Received an invalid input on signal %s" \
+ [lindex $SIGNAL_NAMES $i]
+ ]
+ set signal_value [expr {rand() > 0.5 ? 1 : 0}]
+ }
+ }
+ }
+ set signal([lindex $SIGNAL_NAMES $i]) $signal_value
+ }
+ }
+
+ private method adjust_wire_colors {_state} {
+ upvar $_state state
+
+ for {set i 0} {$i < 6} {incr i} {
+ # Determinate index in the list of port states
+ set pp [which_port_pin $i]
+
+ # Not connected
+ if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
+ $canvas_widget itemconfigure $wires($i) -fill {#000000}
+ continue
+ }
+
+ # Determinate wire and LED color
+ switch -- [lindex $state $pp] {
+ {0} { ;# Logical 0
+ set wire_color {#00FF00}
+ }
+ {1} { ;# Logical 1
+ set wire_color {#FF0000}
+ }
+ {=} { ;# High forced to low
+ set wire_color {#FF00AA}
+ }
+ {} { ;# Not connected
+ set wire_color {#000000}
+ }
+ {?} { ;# No volatge
+ set wire_color {#888888}
+ }
+ default {
+ set wire_color {#FF8800}
+ }
+ }
+
+ $canvas_widget itemconfigure $wires($i) -fill $wire_color
+ }
+ }
+
+ ## Withdraw panel window from the screen
+ # @return void
+ public method withdraw_window {} {
+ wm withdraw $win
+ }
+
+ ## Get panel configuration list (usable with method "set_config")
+ # @return List - configuration list
+ public method get_config {} {
+ return [list \
+ $class_name \
+ [list \
+ [array get connection_port] \
+ [array get connection_pin] \
+ [wm geometry $win] \
+ [$canvas_widget.usr_note get] \
+ $ds1620_reg(TH) \
+ $ds1620_reg(TL) \
+ $no_delays \
+ [wm geometry $win.log_window] \
+ [wm state $win.log_window] \
+ $temperature \
+ [expr {$ds1620_reg(STATUS) & 0x03}] \
+ $log_enabled \
+ $keep_win_on_top \
+ ] \
+ ]
+ }
+
+ ## Set panel configuration from list gained from method "get_config"
+ # @parm List state - Configuration list
+ # @return void
+ public method set_config {state} {
+ if {[catch {
+ # Load connections to the MCU
+ array set connection_port [lindex $state 0]
+ array set connection_pin [lindex $state 1]
+
+ # Restore window geometry
+ if {[string length [lindex $state 2]]} {
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm minsize $win] {x}]]
+ }
+
+ # Load user note
+ $canvas_widget.usr_note delete 0
+ $canvas_widget.usr_note insert 0 [lindex $state 3]
+
+ set ds1620_reg(TH) [lindex $state 4]
+ set ds1620_reg(TL) [lindex $state 5]
+
+ set no_delays [lindex $state 6]
+
+ # Display the log window
+ set log_window_geometry [lindex $state 7]
+ if {[lindex $state 8] == {normal}} {
+ show_log
+ }
+
+ set temperature [lindex $state 9]
+ set ds1620_reg(STATUS) [expr {($ds1620_reg(STATUS) & 0xFC) | ([lindex $state 10] & 0x03)}]
+
+ set log_enabled [lindex $state 11]
+ if {$log_enabled} {
+ $log_on_off_chbut select
+ } else {
+ $log_on_off_chbut deselect
+ }
+
+ if {[lindex $state 12] != {}} {
+ set keep_win_on_top [lindex $state 12]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
+ # Restore state of ComboBoxes
+ for {set i 0} {$i < 6} {incr i} {
+ ## PIN
+ set pin $connection_pin($i)
+ if {$pin != {-}} {
+ set pin [expr {7 - $pin}]
+ }
+ set idx [lsearch -ascii -exact \
+ [$canvas_widget.cb_b$i cget -values] \
+ $pin \
+ ]
+ if {$idx == -1} {
+ set idx 0
+ }
+ $canvas_widget.cb_b$i current $idx
+
+ ## PORT
+ set idx [lsearch -ascii -exact \
+ [$canvas_widget.cb_p$i cget -values] \
+ $connection_port($i) \
+ ]
+ if {$idx == -1} {
+ set idx 0
+ }
+ $canvas_widget.cb_p$i current $idx
+ }
+
+ # Adjust internal logic and the rest of PALE
+ foreach reg {TH TL TEMP STATUS} {
+ update_reg $reg
+ }
+ adjust_temp_ind
+ evaluete_enaged_pins
+ $project pale_reevaluate_IO
+ update
+
+ # Fail
+ }]} then {
+ puts "Unable to load configuration for $class_name"
+ return 0
+
+ # Success
+ } else {
+ clear_modified
+ return 1
+ }
+ }
+
+ ## Simulated MCU has been reseted
+ # @return void
+ public method reset {} {
+ set state [$project pale_get_true_state]
+ new_state state
+ }
+
+
+ # ------------------------------------------------------------------
+ # VIRTUAL HW COMMON INTERFACE -- CALLED FROM THE BASE CLASS
+ # ------------------------------------------------------------------
+
+ ## This method is called before configuration menu invocation
+ # @return void
+ public method config_menu_special {} {
+ set ::${class_name}::_no_delays $no_delays
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
+ }
+
+ ## This method is called after configuration menu has beed created
+ # @return void
+ public method create_config_menu_special {} {
+ }
+
+ ## This method is called to fill in the help dialog
+ # @parm Widget text_widget - Target text widget
+ # @return void
+ #
+ # Note: There is defined text tag "tag_bold" in the text widget
+ public method show_help_special {text_widget} {
+ }
+
+ ## This method is called before panel window closure
+ # @return void
+ public method close_window_special {} {
+ }
+
+ ## Commit new on/off state
+ # @return void
+ public method on_off_special {} {
+ if {[$project pale_is_enabled]} {
+ reset_ds1620
+ }
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/file_interface.tcl b/lib/pale/file_interface.tcl
new file mode 100644
index 0000000..58f7293
--- /dev/null
+++ b/lib/pale/file_interface.tcl
@@ -0,0 +1,983 @@
+
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# Copyright (C) 2011 by Martin Ošmera #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _FILE_INTERFACE_TCL ] } {
+set _FILE_INTERFACE_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+# File interface for the PALE subsystem, allow to read files as input for
+# GPIO for simulated MCU and record changes in GPIO to a file
+# -------------------------------------------------------------------------
+
+class PaleFileInterface {
+ inherit VirtualHWComponent
+
+ # Font: Font to be used in the panel -- bold
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
+ ]
+ common text_font [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family ${::DEFAULT_FIXED_FONT} \
+ ]
+ common text_font_bold [font create \
+ -weight bold \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family ${::DEFAULT_FIXED_FONT} \
+ ]
+
+ common COMPONENT_NAME "VHW File Interface" ;# Name of this component
+ common CLASS_NAME "PaleFileInterface" ;# Name of this class
+ common COMPONENT_ICON {compfile1} ;# Icon for this panel (16x16)
+
+ # Configuration menu
+ common CONFMENU {
+ {command {Sync. files now} {} 1 "sync" {filesave}
+ "Flush output file buffer"}
+ {checkbutton "Keep files synchronized" {} {::PaleFileInterface::_keep_sync}
+ 1 0 0 {keep_sync_changed}
+ ""}
+ {separator}
+ {command {Show help} {} 5 "show_help" {help}
+ "Show brief help"}
+ {separator}
+ {command {Save configuration} {} 0 "save_as" {filesave}
+ "Save configuration into a file"}
+ {command {Load configuration} {} 0 "load_from" {fileopen}
+ "Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::PaleFileInterface::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
+ }
+
+ common _keep_sync 0
+
+ private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
+ private variable connection_pin ;# Array of Int: Index is key number, value is bit number or {-}
+ private variable enaged ;# Array of Bool: enaged(port_num,bit_num) --> Is connected to this device ?
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
+ private variable cb
+ private variable usr_note
+
+ private variable read_text_widget
+ private variable read_file_entry
+ private variable read_select_file_but
+ private variable read_start_stop_but
+
+ private variable write_file_entry
+ private variable write_select_file_but
+ private variable write_start_stop_but
+ private variable write_trunc_but
+ private variable write_status_lbl
+
+ private variable file_to_read_is_opened 0
+ private variable file_to_write_to_is_opened 0
+
+ private variable file_to_read_channel {}
+ private variable file_to_write_to_channel {}
+
+ private variable current_input {}
+ private variable last_read_line {}
+ private variable last_written_line {}
+
+ private variable keep_sync 0
+ private variable write_counter
+
+
+ # ------------------------------------------------------------------
+ # INTERNAL APPLICATION LOGIC
+ # ------------------------------------------------------------------
+
+ ## Object constructor
+ # @parm Object _project - Project object
+ constructor {_project} {
+ # Configure local ttk styles
+ ttk::style configure PaleFileInterface_FileInUse.TEntry \
+ -fieldbackground {#DDFFDD}
+ ttk::style map PaleFileInterface_FileInUse.TEntry \
+ -fieldbackground [list {readonly !readonly} {#DDFFDD}]
+
+ ttk::style configure PaleFileInterface_FileFound.TEntry \
+ -fieldbackground {#FFFFAA}
+ ttk::style map PaleFileInterface_FileFound.TEntry \
+ -fieldbackground [list {readonly !readonly} {#FFFFAA}]
+
+ ttk::style configure PaleFileInterface_FileNotFound.TEntry \
+ -fieldbackground {#FFDDDD}
+ ttk::style map PaleFileInterface_FileNotFound.TEntry \
+ -fieldbackground [list {readonly !readonly} {#FFDDDD}]
+
+ # Set object variables identifing this component (see the base class)
+ set component_name $COMPONENT_NAME
+ set class_name $CLASS_NAME
+ set component_icon $COMPONENT_ICON
+
+ # Set other object variables
+ set project $_project
+ set radio_buttons 1
+ array set connection_port {0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 -}
+ array set connection_pin {0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 -}
+ for {set port 0} {$port < 5} {incr port} {
+ for {set bit 0} {$bit < 8} {incr bit} {
+ set enaged($port,$bit) 0
+ }
+ }
+
+ # Inform PALE
+ $project pale_register_input_device $this
+ $project pale_set_modified
+
+ # Create panel GUI
+ create_gui
+ mcu_changed
+ on_off [$project pale_is_enabled]
+
+ # ComboBoxes to default state
+ for {set i 0} {$i < 16} {incr i} {
+ $cb(b$i) current 0
+ $cb(p$i) current 0
+ }
+ }
+
+ ## Object destructor
+ destructor {
+ # Inform PALE
+ $project pale_unregister_input_device $this
+
+ # Destroy GUI
+ destroy $win
+ }
+
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $PaleFileInterface::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
+ ## Reevaluate array of MCU port pins engaged by this device
+ # @return void
+ private method evaluete_enaged_pins {} {
+ # Mark all as disengaged and infrom PALE
+ for {set port 0} {$port < 5} {incr port} {
+ for {set bit 0} {$bit < 8} {incr bit} {
+ if {$enaged($port,$bit)} {
+ $project pale_disengage_pin_by_input_device $port $bit $this
+ set enaged($port,$bit) 0
+ }
+ }
+ }
+
+ # Find the engaged ones and infrom PALE
+ for {set i 8} {$i < 16} {incr i} {
+ set port $connection_port($i)
+ set bit $connection_pin($i)
+
+ if {$port == {-} || $bit == {-}} {
+ continue
+ }
+
+ set enaged($port,$bit) 1
+ $project pale_engage_pin_by_input_device $port $bit $this
+ }
+ }
+
+ ## Reconnect the specified key to another port pin
+ # @parm Int i - Key number (0..7)
+ # @return void
+ public method reconnect {i} {
+ # Adjust connections
+ set connection_port($i) [$cb(p$i) get]
+ set connection_pin($i) [$cb(b$i) get]
+ if {$connection_pin($i) != {-}} {
+ set connection_pin($i) [expr {7 - $connection_pin($i)}]
+ }
+
+ # Reevaluate array of MCU port pins engaged by this device
+ evaluete_enaged_pins
+
+ # Inform PALE system about the change in order
+ #+ to make immediate change in device states
+ if {$drawing_on} {
+ $project pale_reevaluate_IO
+ }
+
+ # Set flag modified
+ set_modified
+ }
+
+ public method keep_sync_changed {} {
+ set keep_sync ${::PaleFileInterface::_keep_sync}
+ }
+
+ public method sync {} {
+ if {$file_to_write_to_is_opened} {
+ flush $file_to_write_to_channel
+ }
+ }
+
+ ## Create GUI of this panel
+ # @return void
+ private method create_gui {} {
+ #
+ set win [toplevel .pale_file_interface$count -class $component_name -bg ${::COMMON_BG_COLOR}]
+
+
+ set top_frame [frame $win.top_frame]
+ # Create "ON/OFF" button
+ set start_stop_button [ttk::button $top_frame.start_stop_button \
+ -command "$this on_off_button_press" \
+ -style Flat.TButton \
+ -width 3 \
+ ]
+ DynamicHelp::add $start_stop_button -text [mc "Turn HW simulation on/off"]
+ setStatusTip -widget $start_stop_button -text [mc "Turn HW simulation on/off"]
+ bind $start_stop_button <Button-3> "$this on_off_button_press; break"
+ pack $start_stop_button -side left
+ bindtags $start_stop_button [list $start_stop_button TButton all .]
+ # Create configuration menu button
+ set conf_button [ttk::button $top_frame.conf_but \
+ -image ::ICONS::16::configure \
+ -style Flat.TButton \
+ -command "$this config_menu" \
+ ]
+ setStatusTip -widget $conf_button -text [mc "Configure"]
+ pack $conf_button -side left
+ bindtags $conf_button [list $conf_button TButton all .]
+ #
+ pack [label $top_frame.note_lbl -text [mc "Note: "]] -side left
+ set usr_note [ttk::entry $top_frame.usr_note \
+ -validate key \
+ -validatecommand [list $this set_modified] \
+ -width 0 \
+ ]
+ pack $usr_note -side left -fill x -expand 1
+ bindtags $top_frame.usr_note [list $top_frame.usr_note TEntry $win all .]
+
+ set write_labelframe [ttk::labelframe $win.write_labelframe -text [mc "Write"] -padding 5]
+ for {set i 0} {$i < 8} {incr i} {
+ set j $i
+
+ set cb(p$j) [ttk::combobox $write_labelframe.cb_p$i \
+ -width 1 \
+ -font $cb_font \
+ -state readonly \
+ ]
+
+ set cb(b$j) [ttk::combobox $write_labelframe.cb_b$i \
+ -width 1 \
+ -font $cb_font \
+ -values {- 0 1 2 3 4 5 6 7} \
+ -state readonly \
+ ]
+
+ grid $cb(p$j) -row 2 -column [expr {$i + 1}]
+ grid $cb(b$j) -row 3 -column [expr {$i + 1}]
+
+ bind $cb(p$j) <<ComboboxSelected>> [list $this reconnect $i]
+ bind $cb(b$j) <<ComboboxSelected>> [list $this reconnect $i]
+
+ bindtags $cb(p$j) [list $cb(p$j) TCombobox all .]
+ bindtags $cb(b$j) [list $cb(b$j) TCombobox all .]
+ }
+ grid [label $write_labelframe.port_lbl \
+ -text [mc "PORT"] \
+ ] -row 2 -column 0 -sticky w
+ grid [label $write_labelframe.pin_lbl \
+ -text [mc "PIN"] \
+ ] -row 3 -column 0 -sticky w
+ grid [label $write_labelframe.file_lbl \
+ -text [mc "File: "] \
+ ] -row 0 -column 0 -sticky w
+ set write_file_entry [ttk::entry $write_labelframe.entry \
+ -width 0 \
+ -validate key \
+ -validatecommand [list $this vcmd_write_file_entry %P] \
+ ]
+ DynamicHelp::add $write_file_entry -text [mc "Name of output file"]
+ setStatusTip -widget $write_file_entry -text [mc "Name of output file"]
+ bindtags $write_file_entry [list $write_file_entry TEntry $win all .]
+ grid $write_file_entry -row 0 -column 1 -columnspan 5 -sticky we
+ set write_select_file_but [ttk::button $write_labelframe.write_select_file_but \
+ -image ::ICONS::16::fileopen \
+ -style Flat.TButton \
+ -command [list $this write_select_file] \
+ ]
+ DynamicHelp::add $write_select_file_but -text [mc "Select file"]
+ setStatusTip -widget $write_select_file_but -text [mc "Select file"]
+ bindtags $write_select_file_but [list $write_select_file_but TButton all .]
+ grid $write_select_file_but -row 0 -column 6 -sticky we
+ set write_start_stop_but [ttk::button $write_labelframe.start_stop_but \
+ -image ::ICONS::16::player_play \
+ -style Flat.TButton \
+ -command [list $this write_start_stop] \
+ -state disabled \
+ ]
+ DynamicHelp::add $write_start_stop_but -text [mc "Open or close the file"]
+ setStatusTip -widget $write_start_stop_but -text [mc "Open or close the file"]
+ bindtags $write_start_stop_but [list $write_start_stop_but TButton all .]
+ grid $write_start_stop_but -row 0 -column 7 -sticky we
+ set write_trunc_but [ttk::button $write_labelframe.trunc_but \
+ -image ::ICONS::16::editdelete \
+ -style Flat.TButton \
+ -command [list $this write_trunc] \
+ -state disabled \
+ ]
+ DynamicHelp::add $write_trunc_but -text [mc "Truncate the file"]
+ setStatusTip -widget $write_trunc_but -text [mc "Truncate the file"]
+ bindtags $write_trunc_but [list $write_trunc_but TButton all .]
+ grid $write_trunc_but -row 0 -column 8 -sticky we
+ set write_status_lbl [label $write_labelframe.write_status_lbl \
+ -justify right -anchor e \
+ ]
+ grid $write_status_lbl -row 4 -column 0 -columnspan 9 -sticky e
+ grid rowconfigure $write_labelframe 1 -minsize 5
+
+ set read_labelframe [ttk::labelframe $win.read_labelframe -text [mc "Read"] -padding 5]
+ for {set i 0} {$i < 8} {incr i} {
+ set j [expr {$i + 8}]
+
+ set cb(p$j) [ttk::combobox $read_labelframe.cb_p$i \
+ -width 1 \
+ -font $cb_font \
+ -state readonly \
+ ]
+
+ set cb(b$j) [ttk::combobox $read_labelframe.cb_b$i \
+ -width 1 \
+ -font $cb_font \
+ -values {- 0 1 2 3 4 5 6 7} \
+ -state readonly \
+ ]
+
+ grid $cb(p$j) -row 2 -column [expr {$i + 1}]
+ grid $cb(b$j) -row 3 -column [expr {$i + 1}]
+
+ bind $cb(p$j) <<ComboboxSelected>> [list $this reconnect $j]
+ bind $cb(b$j) <<ComboboxSelected>> [list $this reconnect $j]
+
+ bindtags $cb(p$j) [list $cb(p$j) TCombobox all .]
+ bindtags $cb(b$j) [list $cb(b$j) TCombobox all .]
+ }
+ grid [label $read_labelframe.port_lbl \
+ -text [mc "PORT"] \
+ ] -row 2 -column 0 -sticky w
+ grid [label $read_labelframe.pin_lbl \
+ -text [mc "PIN"] \
+ ] -row 3 -column 0 -sticky w
+ set read_text_widget [text $read_labelframe.text \
+ -height 3 \
+ -width 0 \
+ -state disabled \
+ -font $text_font \
+ -tabstyle wordprocessor \
+ -undo 0 \
+ -exportselection 1 \
+ -wrap word \
+ ]
+ $read_text_widget tag configure tag_current_line -font $text_font_bold
+ $read_text_widget tag configure tag_log_0 -foreground {#00FF00}
+ $read_text_widget tag configure tag_log_1 -foreground {#FF0000}
+ $read_text_widget tag configure tag_hfl -foreground {#FF00AA}
+ $read_text_widget tag configure tag_nv -foreground {#888888}
+ $read_text_widget tag configure tag_noice -foreground {#FF8800}
+ DynamicHelp::add $read_text_widget -text [mc "View on the file"]
+ setStatusTip -widget $read_text_widget -text [mc "View on the file"]
+ bindtags $read_text_widget [list $read_text_widget Ttext $win all .]
+ grid $read_text_widget -row 4 -column 0 -columnspan 9 -sticky we
+ grid [label $read_labelframe.file_lbl \
+ -text [mc "File: "] \
+ ] -row 0 -column 0 -sticky w
+ set read_file_entry [ttk::entry $read_labelframe.entry \
+ -width 0 \
+ -validate key \
+ -validatecommand [list $this vcmd_read_file_entry %P] \
+ ]
+ DynamicHelp::add $read_file_entry -text [mc "Name of input file"]
+ setStatusTip -widget $read_file_entry -text [mc "Name of input file"]
+ bindtags $read_file_entry [list $read_file_entry TEntry $win all .]
+ grid $read_file_entry -row 0 -column 1 -columnspan 5 -sticky we
+ set read_select_file_but [ttk::button $read_labelframe.read_select_file_but \
+ -image ::ICONS::16::fileopen \
+ -style Flat.TButton \
+ -command [list $this read_select_file] \
+ ]
+ DynamicHelp::add $read_select_file_but -text [mc "Select file"]
+ setStatusTip -widget $read_select_file_but -text [mc "Select file"]
+ bindtags $read_select_file_but [list $read_select_file_but TButton all .]
+ grid $read_select_file_but -row 0 -column 6 -sticky we
+ set read_start_stop_but [ttk::button $read_labelframe.start_stop_but \
+ -image ::ICONS::16::player_play \
+ -style Flat.TButton \
+ -command [list $this read_start_stop] \
+ -state disabled \
+ ]
+ DynamicHelp::add $read_start_stop_but -text [mc "Open or close the file"]
+ setStatusTip -widget $read_start_stop_but -text [mc "Open or close the file"]
+ bindtags $read_start_stop_but [list $read_start_stop_but TButton all .]
+ grid $read_start_stop_but -row 0 -column 7 -sticky we
+ grid rowconfigure $read_labelframe 1 -minsize 5
+
+
+ pack $read_labelframe -fill x -pady 3 -padx 5 -side right
+ pack $top_frame -fill x -padx 5 -pady 2 -side bottom
+ pack $write_labelframe -fill x -pady 3 -padx 5
+
+ # Set window parameters
+ wm iconphoto $win ::ICONS::16::$component_icon
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
+ wm resizable $win 0 0
+ wm protocol $win WM_DELETE_WINDOW "$this close_window"
+ bindtags $win [list $win Toplevel all .]
+ }
+
+ ## Determinate which port pin is connected to the specified key
+ # @parm Int i - Key number
+ # @return List - {port_number bit_number}
+ private method which_port_pin {i} {
+ return [list $connection_port($i) $connection_pin($i)]
+ }
+
+ ## Handle "ON/OFF" button press
+ # Turn whole PALE system on or off
+ # @return void
+ public method on_off_button_press {} {
+ $project pale_all_on_off
+ }
+
+ # ------------------------------------------------------------------
+ # VIRTUAL HW COMMON INTERFACE -- CALLED FROM PALE ENGINE
+ # ------------------------------------------------------------------
+
+ ## Simulated MCU has been changed
+ # @return void
+ public method mcu_changed {} {
+ # Refresh lists of possible values in port selection ComboBoxes
+ set available_ports [concat - [$project pale_get_available_ports]]
+
+ for {set i 0} {$i < 16} {incr i} {
+ $cb(p$i) configure -values $available_ports
+
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
+ $cb(p$i) current 0
+ set connection_port($i) {-}
+ }
+ }
+ }
+
+ ## Evaluate new state of ports
+ # @parm List state - Port states ( 5 x {8 x bit} -- {bit0 bit1 bit2 ... bit7} )
+ # @return state - New port states modified by this device
+ # format is the same as parameter $state
+ #
+ # Possible bit values:
+ # '|' - High frequency
+ # 'X' - Access to external memory
+ # '?' - No volatge
+ # '-' - Indeterminable value (some noise)
+ # '=' - High forced to low
+ # '0' - Logical 0
+ # '1' - Logical 1
+ public method new_state {_state} {
+ upvar $_state state
+
+ if {$file_to_write_to_is_opened} {
+ set line [list]
+ for {set i 0} {$i < 8} {incr i} {
+ set pp [which_port_pin $i]
+
+ if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
+ lappend line {-}
+ } else {
+ lappend line [lindex $state $pp]
+ }
+ }
+ if {$last_written_line != $line} {
+ set last_written_line $line
+
+ puts -nonewline $file_to_write_to_channel [$project get_run_statistics 0]
+ puts -nonewline $file_to_write_to_channel "\t"
+ puts $file_to_write_to_channel $line
+ if {$keep_sync} {
+ flush $file_to_write_to_channel
+ }
+ incr write_counter
+ $write_status_lbl configure -text [mc "%d changes recorded" $write_counter]
+ }
+ }
+
+ if {[catch {
+ if {$file_to_read_is_opened} {
+ if {$last_read_line == {}} {
+ set last_read_line [gets $file_to_read_channel]
+ }
+
+ while {![eof $file_to_read_channel]} {
+ if {
+ ($current_input == {})
+ ||
+ ([lindex $last_read_line 0] <= [$project get_run_statistics 0])
+ } then {
+ $read_text_widget configure -state normal
+ $read_text_widget delete 0.0 end
+ $read_text_widget insert 1.0 "\n\n"
+
+ $read_text_widget insert 1.0 $current_input
+ insert_last_read_line
+
+ set current_input $last_read_line
+ set flag 0
+ while {![eof $file_to_read_channel]} {
+ set last_read_line [gets $file_to_read_channel]
+ regsub -all {\s*#.*$} $last_read_line {} last_read_line
+ if {[string length $last_read_line]} {
+ set flag 1
+ break
+ }
+ }
+
+ if {$flag} {
+ $read_text_widget insert 3.0 $last_read_line
+ }
+ $read_text_widget configure -state disabled
+ } else {
+ break
+ }
+ }
+
+ if {[llength $current_input] != 9} {
+ error
+ }
+ for {set i 0} {$i < 0} {incr i} {
+ if {[lsearch -ascii -exact {| X ? - = 0 1} [lindex $current_input $i]] == -1} {
+ error
+ }
+ }
+
+ for {set i 8; set j 1} {$i < 16} {incr i; incr j} {
+ set pp [which_port_pin $i]
+
+ if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
+ # nothing
+ } else {
+ lset state $pp [lindex $current_input $j]
+ }
+ }
+ }
+ }]} then {
+ tk_messageBox \
+ -parent $win \
+ -icon warning \
+ -title [mc "I/O Error"] \
+ -message [mc "File corrupted:\n\"%s\"." [$read_file_entry get]] \
+ -type ok
+ read_start_stop
+ }
+ }
+
+ private method insert_last_read_line {} {
+ $read_text_widget insert 2.0 $last_read_line
+ $read_text_widget tag add tag_current_line 2.0 3.0
+
+ set j 1
+ set k 0
+ for {set i 8} {$i > 0} {incr i -1} {
+ switch -- [lindex $last_read_line $i] {
+ {0} { ;# Logical 0
+ set tag {tag_log_0}
+ }
+ {1} { ;# Logical 1
+ set tag {tag_log_1}
+ }
+ {=} { ;# High forced to low
+ set tag {tag_hfl}
+ }
+ {?} { ;# No volatge
+ set tag {tag_nv}
+ }
+ default {
+ set tag {tag_noice}
+ }
+ }
+ $read_text_widget tag add $tag [list 2.0 lineend - ${j}c] [list 2.0 lineend - ${k}c]
+
+ incr j 2
+ incr k 2
+ }
+ }
+
+ ## Withdraw panel window from the screen
+ # @return void
+ public method withdraw_window {} {
+ wm withdraw $win
+ }
+
+ ## Get panel configuration list (usable with method "set_config")
+ # @return List - configuration list
+ public method get_config {} {
+ return [list \
+ $class_name \
+ [list \
+ [array get connection_port] \
+ [array get connection_pin] \
+ [wm geometry $win] \
+ [$usr_note get] \
+ [$read_file_entry get] \
+ [$write_file_entry get] \
+ $keep_sync \
+ $keep_win_on_top \
+ ] \
+ ]
+ }
+
+ ## Set panel configuration from list gained from method "get_config"
+ # @parm List state - Configuration list
+ # @return void
+ public method set_config {state} {
+ if {[catch {
+ # Load connections to the MCU
+ array set connection_port [lindex $state 0]
+ array set connection_pin [lindex $state 1]
+
+ # Restore window geometry
+ if {[string length [lindex $state 2]]} {
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm size $win] {x}]]
+ }
+
+ # Load user note
+ $usr_note delete 0
+ $usr_note insert 0 [lindex $state 3]
+
+ $read_file_entry delete 0
+ $read_file_entry insert 0 [lindex $state 4]
+
+ $write_file_entry delete 0
+ $write_file_entry insert 0 [lindex $state 5]
+
+ set keep_sync [lindex $state 6]
+
+ if {[lindex $state 7] != {}} {
+ set keep_win_on_top [lindex $state 7]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
+ after 0 [subst {
+ update
+ $read_file_entry xview [$read_file_entry index end]
+ $write_file_entry xview [$write_file_entry index end]
+ }]
+
+ # Restore state of ComboBoxes
+ for {set i 0} {$i < 16} {incr i} {
+ ## PIN
+ set pin $connection_pin($i)
+ if {$pin != {-}} {
+ set pin [expr {7 - $pin}]
+ }
+ set idx [lsearch -ascii -exact \
+ [$cb(b$i) cget -values] \
+ $pin \
+ ]
+ if {$idx == -1} {
+ set idx 0
+ }
+ $cb(b$i) current $idx
+
+ ## PORT
+ set idx [lsearch -ascii -exact \
+ [$cb(p$i) cget -values] \
+ $connection_port($i) \
+ ]
+ if {$idx == -1} {
+ set idx 0
+ }
+ $cb(p$i) current $idx
+ }
+
+ # Adjust internal logic and the rest of PALE
+ evaluete_enaged_pins
+ $project pale_reevaluate_IO
+ update
+
+ # Fail
+ }]} then {
+ puts "Unable to load configuration for $class_name"
+ return 0
+
+ # Success
+ } else {
+ clear_modified
+ return 1
+ }
+ }
+
+ ## Simulated MCU has been reseted
+ # @return void
+ public method reset {} {
+ set state [$project pale_get_true_state]
+ new_state state
+ }
+
+ public method read_select_file {{filename {}}} {
+ if {$filename != {}} {
+ $read_file_entry delete 0 end
+ $read_file_entry insert 0 [lindex $filename 1]
+
+ after 0 [subst {
+ update
+ $read_file_entry xview [$read_file_entry index end]
+ }]
+ } else {
+ select_file [mc "Select file for reading"] [$read_file_entry get] read_select_file
+ }
+ }
+
+ public method write_select_file {{filename {}}} {
+ if {$filename != {}} {
+ set filename [lindex $filename 1]
+ if {[file extension $filename] == {}} {
+ append filename {.gpio}
+ }
+ $write_file_entry delete 0 end
+ $write_file_entry insert 0 $filename
+ after 0 [subst {
+ update
+ $write_file_entry xview [$write_file_entry index end]
+ }]
+ } else {
+ select_file [mc "Select file for writing"] [$write_file_entry get] write_select_file
+ }
+ }
+
+ private method select_file {title initialfile cmd} {
+ if {$initialfile == {}} {
+ set directory [$project cget -projectPath]
+ } else {
+ set directory [file dirname $initialfile]
+ }
+
+ catch {delete object ::fsd}
+ KIFSD::FSD ::fsd \
+ -title $title \
+ -directory $directory \
+ -defaultmask 0 \
+ -multiple 0 \
+ -initialfile $initialfile \
+ -master $win \
+ -filetypes [list \
+ [list [mc "General Purpose Input Output"] {*.gpio}] \
+ [list [mc "All files"] {*}] \
+ ]
+
+ ::fsd setokcmd "$this $cmd \[list 1 \[::fsd get\]\]"
+ ::fsd activate
+ }
+
+ public method write_start_stop {{truncate 0}} {
+ # Stop
+ if {$file_to_write_to_is_opened} {
+ if {[catch {
+ close $file_to_write_to_channel
+ }]} then {
+ tk_messageBox \
+ -parent $win \
+ -icon warning \
+ -title [mc "I/O Error"] \
+ -message [mc "Unknown error occurred while closing file:\n\"%s\"." [$write_file_entry get]] \
+ -type ok
+ }
+ set last_written_line {}
+ set file_to_write_to_is_opened 0
+ $write_start_stop_but configure -image ::ICONS::16::player_play
+ $write_trunc_but configure -state disabled
+ $write_select_file_but configure -state normal
+ $write_file_entry configure -state normal
+ $write_file_entry configure -style PaleFileInterface_FileFound.TEntry
+ $write_status_lbl configure -text {}
+ set write_counter 0
+ # Start
+ } else {
+ if {[catch {
+ if {$truncate} {
+ set mode {w}
+ } else {
+ set mode {a}
+ }
+ set file_to_write_to_channel [open [$write_file_entry get] $mode]
+ }]} then {
+ tk_messageBox \
+ -parent $win \
+ -icon warning \
+ -title [mc "Unable to open file"] \
+ -message [mc "Unable to open file:\n\"%s\" for writing, please check your permissions." [$write_file_entry get]] \
+ -type ok
+ } else {
+ set file_to_write_to_is_opened 1
+ $write_start_stop_but configure -image ::ICONS::16::_player_pause
+ $write_trunc_but configure -state normal
+ $write_select_file_but configure -state disabled
+ $write_file_entry configure -state readonly
+ $write_file_entry configure -style PaleFileInterface_FileInUse.TEntry
+ }
+ }
+ }
+ public method write_trunc {} {
+ if {!$file_to_write_to_is_opened} {
+ return
+ }
+
+ write_start_stop
+ write_start_stop 1
+ }
+ public method read_start_stop {} {
+ # Stop
+ if {$file_to_read_is_opened} {
+ if {[catch {
+ close $file_to_read_channel
+ }]} then {
+ tk_messageBox \
+ -parent $win \
+ -icon warning \
+ -title [mc "I/O Error"] \
+ -message [mc "Unknown error occurred while closing file:\n\"%s\"." [$read_file_entry get]] \
+ -type ok
+ }
+ set file_to_read_is_opened 0
+ $read_start_stop_but configure -image ::ICONS::16::player_play
+ $read_select_file_but configure -state normal
+ $read_file_entry configure -state normal
+ $read_file_entry configure -style PaleFileInterface_FileFound.TEntry
+
+ $read_text_widget configure -state normal
+ $read_text_widget delete 0.0 end
+ $read_text_widget configure -state disabled
+ # Start
+ } else {
+ if {[catch {
+ set file_to_read_channel [open [$read_file_entry get] {r}]
+ }]} then {
+ tk_messageBox \
+ -parent $win \
+ -icon warning \
+ -title [mc "Unable to open file"] \
+ -message [mc "Unable to open file:\n\"%s\" for reading, please check your permissions." [$read_file_entry get]] \
+ -type ok
+ } else {
+ set file_to_read_is_opened 1
+ $read_start_stop_but configure -image ::ICONS::16::_player_pause
+ $read_select_file_but configure -state disabled
+ $read_file_entry configure -state readonly
+ $read_file_entry configure -style PaleFileInterface_FileInUse.TEntry
+ }
+ }
+ }
+ public method vcmd_read_file_entry {filename} {
+ if {![string length $filename]} {
+ $read_file_entry configure -style TEntry
+ $read_start_stop_but configure -state disabled
+ } elseif {[file exists $filename] && [file isfile $filename] && [file readable $filename]} {
+ if {!$file_to_read_is_opened} {
+ $read_file_entry configure -style PaleFileInterface_FileFound.TEntry
+ } else {
+ $read_file_entry configure -style PaleFileInterface_FileInUse.TEntry
+ }
+ $read_start_stop_but configure -state normal
+ } else {
+ $read_file_entry configure -style PaleFileInterface_FileNotFound.TEntry
+ $read_start_stop_but configure -state disabled
+ }
+
+ return 1
+ }
+ public method vcmd_write_file_entry {filename} {
+ if {![string length $filename]} {
+ $write_file_entry configure -style TEntry
+ $write_start_stop_but configure -state disabled
+ } elseif {[file exists $filename] && [file isfile $filename] && [file readable $filename]} {
+ if {!$file_to_write_to_is_opened} {
+ $write_file_entry configure -style PaleFileInterface_FileFound.TEntry
+ } else {
+ $write_file_entry configure -style PaleFileInterface_FileInUse.TEntry
+ }
+ $write_start_stop_but configure -state normal
+ } else {
+ $write_file_entry configure -style PaleFileInterface_FileNotFound.TEntry
+ $write_start_stop_but configure -state normal
+ }
+
+ return 1
+ }
+
+ # ------------------------------------------------------------------
+ # VIRTUAL HW COMMON INTERFACE -- CALLED FROM THE BASE CLASS
+ # ------------------------------------------------------------------
+
+ ## This method is called before configuration menu invocation
+ # @return void
+ public method config_menu_special {} {
+ set ::${class_name}::_keep_sync $keep_sync
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
+ }
+
+ ## This method is called after configuration menu has beed created
+ # @return void
+ public method create_config_menu_special {} {
+ }
+
+ ## This method is called to fill in the help dialog
+ # @parm Widget text_widget - Target text widget
+ # @return void
+ #
+ # Note: There is defined text tag "tag_bold" in the text widget
+ public method show_help_special {text_widget} {
+ }
+
+ ## This method is called before panel window closure
+ # @return void
+ public method close_window_special {} {
+ }
+
+ ## Commit new on/off state
+ # @return void
+ public method on_off_special {} {
+ set state [$project pale_get_true_state]
+ new_state state
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/hd44780_cgrom.tcl b/lib/pale/hd44780_cgrom.tcl
new file mode 100644
index 0000000..0ce00c7
--- /dev/null
+++ b/lib/pale/hd44780_cgrom.tcl
@@ -0,0 +1,1624 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+
+############################################################################
+# Copyright (C) 2011 by Martin Ošmera and Monika Říhová (so far) #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# ------------------------------------------------------------------------------
+#
+# This file contains font definitions for HD44780 display driver simulator,
+# which is a part of MCU 8051 IDE project.
+#
+# ------------------------------------------------------------------------------
+#
+# Format:
+# { <-- Start all font definitions
+# n × { <-- Start one font definitions
+# 240 × { <-- Start of one character definition (addr: [0x10,0xff])
+# 10 × { <-- Start of one row on the character patter (starting from the top)
+# 5 × {0|1} <-- Dots in the patter (0 == blank; 1 == filled)
+# } <-- End of one row on the character patter
+# } <-- End of one character definition
+# } <-- End one font definitions
+# } <-- End all font definitions
+#
+# ------------------------------------------------------------------------------
+#
+# An example of a character definition:
+#
+# { PATTERN: CHARACTER:
+# {1 1 1 1 0} | # # # #
+# {1 0 0 0 1} | # #
+# {1 0 0 0 1} | # #
+# {1 1 1 1 0} | # # # #
+# {1 0 0 0 1} | # #
+# {1 0 0 0 1} | # #
+# {1 1 1 1 0} | # # # #
+# {0 0 0 0 0} |
+# {0 0 0 0 0} |
+# {0 0 0 0 0} |
+# }
+#
+# ------------------------------------------------------------------------------
+
+common CGROM {
+{
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 1 0 1 0} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 1 0 1 0} {1 1 1 1 1} {0 1 0 1 0} {1 1 1 1 1}
+ {0 1 0 1 0} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 1 1 1} {1 0 1 0 0} {0 1 1 1 0} {0 0 1 0 1}
+ {1 1 1 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 0 0 0} {1 1 0 0 1} {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0}
+ {1 0 0 1 1} {0 0 0 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 0} {1 0 0 1 0} {1 0 1 0 0} {0 1 0 0 0} {1 0 1 0 1}
+ {1 0 0 1 0} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0} {0 1 0 0 0} {0 1 0 0 0}
+ {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {1 0 1 0 1} {0 1 1 1 0} {1 0 1 0 1}
+ {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {1 1 1 1 1} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 0 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 1 1 0 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0}
+ {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 1 1} {1 0 1 0 1} {1 1 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0}
+ {0 1 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {0 0 0 1 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 1 0} {0 1 0 1 0} {1 0 0 1 0} {1 1 1 1 1}
+ {0 0 0 1 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {1 0 0 0 0} {1 1 1 1 0} {0 0 0 0 1} {0 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 1 0} {0 1 0 0 0} {1 0 0 0 0} {1 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {1 0 0 0 1} {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 0 0} {0 1 1 0 0} {0 0 0 0 0} {0 1 1 0 0}
+ {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 0 0} {0 1 1 0 0} {0 0 0 0 0} {0 1 1 0 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0} {1 0 0 0 0} {0 1 0 0 0}
+ {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {1 1 1 1 1}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 1} {0 0 0 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0}
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 1 1 1 0} {1 0 0 0 1} {0 0 0 0 1} {0 1 1 0 1} {1 0 1 0 1}
+ {1 0 1 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 0 0} {1 0 0 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 1 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {1 0 0 0 0} {1 0 0 0 0} {1 1 1 1 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {1 0 0 0 0} {1 0 0 0 0} {1 1 1 1 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 0} {1 0 1 1 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 1 1} {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0}
+ {1 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 0 0 1 0} {1 0 1 0 0} {1 1 0 0 0} {1 0 1 0 0}
+ {1 0 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 1 0 1 1} {1 0 1 0 1} {1 0 1 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 0 0 0 1} {1 1 0 0 1} {1 0 1 0 1} {1 0 0 1 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {1 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 1 0 1}
+ {1 0 0 1 0} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0} {1 0 1 0 0}
+ {1 0 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 1} {1 0 0 0 0} {1 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1}
+ {0 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 1 0 1} {1 0 1 0 1}
+ {1 0 1 0 1} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0} {0 1 0 1 0}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0}
+ {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {0 1 0 1 0} {1 1 1 1 1} {0 0 1 0 0} {1 1 1 1 1}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 0 1} {0 0 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1} {0 1 1 1 1}
+ {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 0} {1 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 0} {1 0 0 0 0}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 1} {0 0 0 0 1} {0 1 1 0 1} {1 0 0 1 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 1 1 1 1}
+ {1 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 1 0} {0 1 0 0 1} {0 1 0 0 0} {1 1 1 0 0} {0 1 0 0 0}
+ {0 1 0 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 1}
+ {0 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {1 0 0 0 0} {1 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 0 0 0 0} {0 1 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 0 0 0} {0 0 1 1 0} {0 0 0 1 0} {0 0 0 1 0}
+ {1 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 0} {1 0 0 0 0} {1 0 0 1 0} {1 0 1 0 0} {1 1 0 0 0}
+ {1 0 1 0 0} {1 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 0 1 0} {1 0 1 0 1} {1 0 1 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 0} {1 0 0 0 1} {1 1 1 1 0}
+ {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 0 1} {1 0 0 1 1} {0 1 1 1 1}
+ {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1} {1 0 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 0} {0 1 1 1 0}
+ {0 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 1 0 0 0} {1 1 1 0 0} {0 1 0 0 0} {0 1 0 0 0}
+ {0 1 0 0 1} {0 0 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 1 1} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 1 0 1} {1 0 1 0 1}
+ {1 0 1 0 1} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0}
+ {0 1 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 1}
+ {0 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 1 0} {0 0 1 0 0}
+ {0 1 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {1 1 1 1 1} {0 0 0 1 0}
+ {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 0 0 0} {1 1 1 1 1} {0 1 0 0 0}
+ {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0}
+ {0 1 0 1 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 1 1} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 0}
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 0 0} {0 1 1 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {1 1 1 1 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 1 0} {0 0 1 0 0} {0 1 1 0 0}
+ {1 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {0 0 1 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {1 1 1 1 1} {1 0 0 0 1}
+ {0 0 0 0 1} {0 0 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 1 0} {1 1 1 1 1} {0 0 1 1 0}
+ {0 1 0 1 0} {1 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 0 0 0} {1 1 1 1 1} {0 1 0 0 1}
+ {0 1 0 1 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 1 0}
+ {0 0 0 1 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 0} {0 0 0 1 0} {1 1 1 1 0}
+ {0 0 0 1 0} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 1 0 1} {1 0 1 0 1}
+ {0 0 0 0 1} {0 0 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {0 0 0 0 1} {0 0 1 0 1} {0 0 1 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0} {0 1 1 0 0} {1 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {1 1 1 1 1} {0 0 0 1 0} {0 0 1 1 0} {0 1 0 1 0}
+ {1 0 0 1 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {1 1 1 1 1} {0 1 0 0 1} {0 1 0 0 1} {0 1 0 0 1}
+ {0 1 0 0 1} {1 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {1 1 1 1 1} {0 0 1 0 0} {1 1 1 1 1} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 1 1 1 1} {0 1 0 0 1} {1 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 1 1 1 1} {1 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0}
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 0 1} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {1 1 1 1 1} {0 1 0 1 0} {0 1 0 1 0} {0 0 0 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 0 0 0} {0 0 0 0 1} {1 1 0 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0}
+ {0 1 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {1 1 1 1 1} {0 1 0 0 1} {0 1 0 1 0} {0 1 0 0 0}
+ {0 1 0 0 0} {0 0 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {0 1 0 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 1 1 1 1} {0 1 0 0 1} {1 0 1 0 1} {0 0 0 1 1}
+ {0 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {1 1 1 0 0} {0 0 1 0 0} {1 1 1 1 1} {0 0 1 0 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 1 0 1} {1 0 1 0 1} {1 0 1 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 1 0 0 0} {0 1 0 0 0} {0 1 1 0 0} {0 1 0 1 0}
+ {0 1 0 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 0 1 0 0} {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0}
+ {0 1 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0}
+ {0 1 0 1 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 1 0 0} {1 1 1 1 1} {0 0 0 1 0} {0 0 1 0 0} {0 1 1 1 0}
+ {1 0 1 0 1} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 1 0 0 0} {1 1 1 1 1} {0 1 0 0 0} {0 1 0 0 0}
+ {0 1 0 0 0} {0 0 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 0 0} {1 0 1 0 0} {0 0 0 1 0} {0 0 0 1 0}
+ {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0} {1 0 1 0 1}
+ {1 0 1 0 1} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 1 0 1 0}
+ {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0}
+ {0 1 1 1 0} {0 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 0 0 0} {1 0 0 0 0} {1 0 0 0 1}
+ {1 1 1 1 1} {0 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 1} {0 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0}
+ {0 1 0 1 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 1 0 0 0} {1 1 1 1 1} {0 1 0 0 0}
+ {0 1 0 0 0} {0 0 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 1 0 0 0} {1 1 1 1 1} {0 1 0 0 1} {0 1 0 1 0}
+ {0 1 0 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0}
+ {0 0 0 1 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {1 1 1 1 1} {0 0 0 0 1}
+ {0 0 0 0 1} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {1 0 0 1 0} {1 0 0 1 0} {1 0 0 1 0} {1 0 0 1 0} {0 0 0 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {1 0 1 0 0} {1 0 1 0 0} {1 0 1 0 1}
+ {1 0 1 0 1} {1 0 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 1} {1 0 0 1 0}
+ {1 0 1 0 0} {1 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 1 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {1 0 0 1 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 0 0} {1 0 1 0 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 0 0 1} {1 0 1 0 1} {1 0 0 1 0}
+ {1 0 0 1 0} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1} {0 1 1 1 1}
+ {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 1 1 1 0}
+ {1 0 0 0 1} {1 1 1 1 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 0} {0 1 1 0 0}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 1 1} {1 1 1 0 1} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 1} {1 0 1 0 0} {1 0 0 1 0}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 1 0} {0 1 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 1 1 1 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 1 1 1 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 1 1} {0 0 1 0 0} {0 0 1 0 0}
+ {1 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 1 0} {1 1 0 1 0} {0 0 0 1 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 0 0 0} {0 0 1 1 0} {0 0 0 1 0} {0 0 0 1 0}
+ {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0} {1 0 0 1 0} {0 1 1 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 1 1 0} {1 0 1 0 0} {1 0 1 0 1}
+ {0 1 1 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 1 0 0 0} {1 1 1 0 0} {0 1 0 0 0} {1 1 1 0 0}
+ {0 1 0 0 0} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {0 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 1 1 1 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 0 1} {1 0 0 1 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 1}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 0 1 1} {1 0 1 0 1}
+ {1 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 0 1 0} {1 1 0 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 1 1} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {1 0 0 0 0} {0 1 0 0 0} {0 0 1 0 0} {0 1 0 0 0}
+ {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 1 0 1 0} {0 1 0 1 0}
+ {0 1 0 1 0} {1 0 0 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {1 1 1 1 1} {0 0 0 0 0} {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0}
+ {0 1 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 1 1 1 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 1} {1 1 1 1 0} {0 0 1 0 0} {1 1 1 1 1}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 1 0 0 0} {0 1 1 1 1}
+ {0 1 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {1 0 1 0 1} {1 1 1 1 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0}
+ {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 1 1} {1 1 1 1 1} {1 1 1 1 1} {1 1 1 1 1} {1 1 1 1 1}
+ {1 1 1 1 1} {1 1 1 1 1} {1 1 1 1 1} {1 1 1 1 1} {1 1 1 1 1}
+ }
+} {
+} {
+ {
+ {0 0 0 0 0} {0 1 0 0 0} {0 1 1 0 0} {0 1 1 1 0} {0 1 1 1 1}
+ {0 1 1 1 0} {0 1 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 1 0} {0 1 1 1 0} {1 1 1 1 0}
+ {0 1 1 1 0} {0 0 1 1 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 0 1} {1 0 0 1 0} {1 1 0 1 1} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 0 1 1} {0 1 0 0 1} {1 0 0 1 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 1 1 0} {1 1 1 1 1} {0 0 0 0 0}
+ {0 0 1 0 0} {0 1 1 1 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 1 1 1 0} {0 0 1 0 0} {0 0 0 0 0}
+ {1 1 1 1 1} {0 1 1 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 1 1 1 1} {1 1 1 1 1}
+ {1 1 1 1 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 1} {0 0 0 0 1} {0 0 1 0 1} {0 1 0 0 1}
+ {1 1 1 1 1} {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 1 1 0} {1 0 1 0 1} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {1 0 1 0 1} {0 1 1 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {1 1 1 1 1}
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 1 0 0 0} {1 1 1 1 1}
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 1 0 0}
+ {0 0 0 1 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 1 0 0}
+ {0 1 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0}
+ {0 1 1 1 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 1 1 1 0} {0 1 1 1 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 1 0 1 0} {0 1 0 1 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 1 0 1 0} {1 1 1 1 1} {0 1 0 1 0}
+ {1 1 1 1 1} {0 1 0 1 0} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 1 1 1} {1 0 1 0 0} {0 1 1 1 0}
+ {0 0 1 0 1} {1 1 1 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 0 0 0} {1 1 0 0 1} {0 0 0 1 0} {0 0 1 0 0}
+ {0 1 0 0 0} {1 0 0 1 1} {0 0 0 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 0 0} {1 0 0 1 0} {1 0 1 0 0} {0 1 0 0 0}
+ {1 0 1 0 1} {1 0 0 1 0} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 0 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0} {0 1 0 0 0}
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 1 0}
+ {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {1 0 1 0 1} {0 1 1 1 0}
+ {1 0 1 0 1} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {1 1 1 1 1}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 1 1 0 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 1 1 0 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0}
+ {0 1 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 1 1} {1 0 1 0 1}
+ {1 1 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {0 0 0 0 1} {0 0 0 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 1 0} {0 0 1 0 0} {0 0 0 1 0}
+ {0 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 1 0} {0 1 0 1 0} {1 0 0 1 0}
+ {1 1 1 1 1} {0 0 0 1 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 0} {1 1 1 1 0} {0 0 0 0 1}
+ {0 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 0} {0 1 0 0 0} {1 0 0 0 0} {1 1 1 1 0}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 1} {0 0 0 0 1} {0 0 0 1 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 1}
+ {0 0 0 0 1} {0 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 0 0} {0 1 1 0 0} {0 0 0 0 0}
+ {0 1 1 0 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 0 0} {0 1 1 0 0} {0 0 0 0 0}
+ {0 1 1 0 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0} {1 0 0 0 0}
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0}
+ {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 1}
+ {0 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {0 0 0 0 1} {0 0 0 1 0}
+ {0 0 1 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {0 0 0 0 1} {0 1 1 0 1}
+ {1 0 1 0 1} {1 0 1 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0}
+ {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 0 0} {1 0 0 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 1 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 0} {1 0 0 0 0} {1 1 1 1 0}
+ {1 0 0 0 0} {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 0} {1 0 0 0 0} {1 1 1 1 0}
+ {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 0} {1 0 1 1 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 1}
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 1} {0 0 0 1 0} {0 0 0 1 0} {0 0 0 1 0}
+ {0 0 0 1 0} {1 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 1 0} {1 0 1 0 0} {1 1 0 0 0}
+ {1 0 1 0 0} {1 0 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 1 0 1 1} {1 0 1 0 1} {1 0 1 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 1 0 0 1} {1 0 1 0 1}
+ {1 0 0 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {1 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0}
+ {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 1 0 1} {1 0 0 1 0} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0}
+ {1 0 1 0 0} {1 0 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 1} {1 0 0 0 0} {1 0 0 0 0} {0 1 1 1 0}
+ {0 0 0 0 1} {0 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 1 0 1}
+ {1 0 1 0 1} {1 0 1 0 1} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0}
+ {0 1 0 1 0} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 1 0 1 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 1} {0 0 0 1 0} {0 0 1 0 0}
+ {0 1 0 0 0} {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {0 1 0 1 0} {1 1 1 1 1} {0 0 1 0 0}
+ {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 1}
+ {0 0 0 0 1} {0 0 0 0 1} {0 0 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 0 1 0} {1 0 0 0 1} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 1 0 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1}
+ {0 1 1 1 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 1} {0 0 0 0 1} {0 1 1 0 1} {1 0 0 1 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 0} {0 1 0 0 1} {0 1 0 0 0} {1 1 1 0 0}
+ {0 1 0 0 0} {0 1 0 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 1 1 1} {0 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 1 1 0} {0 0 0 1 0}
+ {0 0 0 1 0} {1 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 1 0} {1 0 1 0 0}
+ {1 1 0 0 0} {1 0 1 0 0} {1 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 1 0 1 0} {1 0 1 0 1}
+ {1 0 1 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 0} {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 0 1} {1 0 0 1 1}
+ {0 1 1 1 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1}
+ {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 0}
+ {0 1 1 1 0} {0 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 0 0} {0 1 0 0 0} {1 1 1 0 0} {0 1 0 0 0}
+ {0 1 0 0 0} {0 1 0 0 1} {0 0 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 1 1} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 1 0 1}
+ {1 0 1 0 1} {1 0 1 0 1} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {0 1 0 1 0}
+ {0 0 1 0 0} {0 1 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 1 1 1} {0 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 0 0} {0 0 1 0 0} {0 1 0 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 1 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ {0 1 1 0 1} {1 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 0 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 0} {1 1 1 1 0}
+ {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 1} {0 0 1 0 1} {0 0 1 0 1} {0 1 0 0 1} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 1 0 1} {1 0 1 0 1} {1 0 1 0 1} {0 1 1 1 0}
+ {1 0 1 0 1} {1 0 1 0 1} {1 0 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 0} {0 0 0 0 1} {0 0 0 0 1} {0 0 1 1 0}
+ {0 0 0 0 1} {0 0 0 0 1} {1 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 1 1} {1 0 1 0 1}
+ {1 1 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 0 1 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 1 1}
+ {1 0 1 0 1} {1 1 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 1} {0 0 1 0 1} {0 0 1 0 1} {0 0 1 0 1}
+ {0 0 1 0 1} {1 0 1 0 1} {0 1 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 1 0 1 0}
+ {0 0 1 0 0} {0 1 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 1 1 1 1} {0 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 1}
+ {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 1 0 1} {1 0 1 0 1} {1 0 1 0 1}
+ {1 0 1 0 1} {1 0 1 0 1} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 1 0 1} {1 0 1 0 1} {1 0 1 0 1} {1 0 1 0 1}
+ {1 0 1 0 1} {1 1 1 1 1} {0 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 0 0 0} {0 1 0 0 0} {0 1 0 0 0} {0 1 1 1 0}
+ {0 1 0 0 1} {0 1 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 1 0 0 1}
+ {1 0 1 0 1} {1 0 1 0 1} {1 1 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {0 0 1 0 1} {0 1 0 1 1}
+ {0 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 0 0 1} {1 0 1 0 1}
+ {1 0 0 1 0} {1 0 0 1 0} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 1 1 0} {0 0 1 0 1} {0 0 1 0 1}
+ {0 0 1 0 0} {1 1 1 0 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 0} {1 0 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 1 0 1 0}
+ {0 1 0 1 0} {0 1 0 1 0} {1 0 0 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 0} {0 1 0 0 0} {0 0 1 0 0}
+ {0 1 0 0 0} {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 1} {1 0 0 1 0}
+ {1 0 0 1 0} {1 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 1 0} {0 0 1 0 1} {0 0 1 1 1} {0 0 1 0 1} {0 0 1 0 1}
+ {1 1 1 0 1} {1 1 0 1 1} {0 0 0 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 1} {0 1 1 1 0} {1 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 1 1 1 0} {0 1 1 1 0}
+ {1 1 1 1 1} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 1 1 1 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {0 1 0 1 0} {1 1 0 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 0} {0 1 0 0 1} {0 0 1 0 0} {0 1 0 1 0}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 0 1 1} {1 0 1 0 1}
+ {1 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 0 1 0} {1 1 1 1 1} {1 1 1 1 1}
+ {1 1 1 1 1} {0 1 1 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 0}
+ {0 1 1 0 0} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {1 1 0 1 1} {1 1 0 1 1} {1 1 0 1 1} {1 1 0 1 1}
+ {1 1 0 1 1} {1 1 0 1 1} {1 1 0 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 1 1 0} {1 0 1 0 0} {1 0 1 0 0}
+ {1 0 1 0 1} {0 1 1 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 0} {0 1 0 0 0} {0 1 0 0 0} {1 1 1 0 0}
+ {0 1 0 0 0} {0 1 0 0 1} {1 0 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {0 1 1 1 0} {0 1 0 1 0}
+ {0 1 1 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {0 1 0 1 0} {1 1 1 1 1} {0 0 1 0 0}
+ {1 1 1 1 1} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 0} {0 1 0 0 1} {0 0 1 0 0} {0 1 0 1 0}
+ {0 0 1 0 0} {1 0 0 1 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 0 1} {0 0 1 0 0} {1 1 1 1 1}
+ {0 0 1 0 0} {1 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 1} {1 0 1 0 1} {1 0 1 1 1}
+ {1 0 1 0 1} {1 0 0 0 1} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1} {0 1 1 1 1} {1 0 0 0 1}
+ {0 1 1 1 1} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 1} {0 1 0 1 0} {1 0 1 0 0} {0 1 0 1 0}
+ {0 0 1 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 1 0} {1 0 1 0 1} {1 0 1 0 1} {1 1 1 0 1}
+ {1 0 1 0 1} {1 0 1 0 1} {1 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 1}
+ {0 0 1 0 1} {0 1 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 1} {1 0 1 0 1} {1 0 0 0 1}
+ {1 0 0 1 1} {1 0 1 0 1} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 0 0 0} {0 1 1 0 0} {0 0 0 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 1 1 0 0} {1 0 0 1 0} {1 0 0 1 0} {1 0 0 1 0} {0 1 1 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {1 1 1 1 1} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 0} {1 0 0 1 0} {0 0 1 0 0} {0 1 0 0 0} {1 1 1 1 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 0 0} {0 0 0 1 0} {0 1 1 0 0} {0 0 0 1 0} {1 1 1 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 1 0 0} {1 0 0 1 0} {1 1 1 0 0} {1 0 0 0 0} {1 0 0 1 0}
+ {1 0 1 1 1} {1 0 0 1 0} {0 0 0 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 1 1}
+ {1 1 1 0 1} {1 0 0 0 0} {1 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 1} {1 0 0 1 1} {1 0 0 1 1} {0 1 1 1 1}
+ {0 0 0 1 1} {0 0 0 1 1} {0 0 0 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 1 0 0}
+ {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 1 0 1 0} {1 0 0 0 1}
+ {1 0 1 0 1} {1 0 1 0 1} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {1 1 0 0 0} {0 1 0 0 0} {0 1 0 0 0} {1 1 1 0 0}
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 1 1 0} {0 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 1 0 0} {0 1 0 1 0} {0 0 1 0 1}
+ {0 1 0 1 0} {1 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 0 0 1 0} {1 0 1 0 0} {0 1 0 1 0} {1 0 1 1 0}
+ {0 1 0 1 0} {0 1 1 1 1} {0 0 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 0 0 0 1} {1 0 0 1 0} {1 0 1 0 0} {0 1 0 1 0} {1 0 1 0 1}
+ {0 0 0 0 1} {0 0 0 1 0} {0 0 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 0 0 0} {0 1 0 0 0} {1 1 0 0 0} {0 1 0 0 1} {1 1 0 1 1}
+ {0 0 1 0 1} {0 0 1 1 1} {0 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 1 0 0 0}
+ {1 0 0 0 0} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 1 0 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 1 0 0} {0 1 0 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 1} {1 0 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 0 0 0 0} {0 0 1 0 0} {0 1 0 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 1 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 1} {0 1 1 0 0} {1 0 1 0 0} {1 0 1 1 1}
+ {1 1 1 0 0} {1 0 1 0 0} {1 0 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 0} {1 0 0 0 0} {1 0 0 0 1}
+ {0 1 1 1 0} {0 0 0 1 0} {0 0 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 0}
+ {1 1 1 1 0} {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 0}
+ {1 1 1 1 0} {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 0}
+ {1 1 1 1 0} {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 0 0 0} {1 1 1 1 1} {1 0 0 0 0}
+ {1 1 1 1 0} {1 0 0 0 0} {1 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {0 1 1 1 0} {0 1 0 0 1} {0 1 0 0 1} {1 1 1 0 1}
+ {0 1 0 0 1} {0 1 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 1} {1 0 0 1 0} {0 0 0 0 0} {1 0 0 0 1} {1 1 0 0 1}
+ {1 0 1 0 1} {1 0 0 1 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 1} {1 0 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0}
+ {0 1 0 1 0} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 1 1 1 0} {0 0 1 0 0} {0 1 1 1 0} {1 0 1 0 1} {0 1 1 1 0}
+ {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 1 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {1 0 0 0 1} {0 1 0 1 0} {0 0 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {1 1 0 0 0} {0 1 0 0 0} {0 1 1 1 0} {0 1 0 0 1} {0 1 0 0 1}
+ {0 1 1 1 0} {0 1 0 0 0} {1 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 1 0} {0 1 0 0 1} {0 1 0 0 1} {0 1 1 1 0}
+ {0 1 0 0 1} {0 1 0 0 1} {1 0 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1}
+ {0 1 1 1 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1}
+ {0 1 1 1 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 1} {1 0 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1}
+ {0 1 1 1 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1}
+ {0 1 1 1 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {0 0 0 0 1}
+ {0 1 1 1 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 1}
+ {0 1 1 1 1} {1 0 0 0 1} {0 1 1 1 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {1 1 0 1 0} {0 0 1 0 1} {0 1 1 1 1}
+ {1 0 1 0 0} {1 0 1 0 1} {0 1 0 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 0} {1 0 0 0 1}
+ {0 1 1 1 0} {0 0 1 0 0} {0 1 1 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 1 1 1 1} {1 0 0 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 1 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 1 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 0 1 0 0} {0 1 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 0 1 0 0} {0 1 1 0 0}
+ {0 0 1 0 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+
+
+ {
+ {0 0 0 0 0} {1 0 1 0 0} {0 1 0 0 0} {1 0 1 0 0} {0 0 0 1 0}
+ {0 1 1 1 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 1 0 1} {1 0 0 1 0} {0 0 0 0 0} {1 0 1 1 0} {1 1 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {1 0 0 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 0 1} {1 0 0 1 0} {0 0 0 0 0} {0 1 1 1 0}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 0 0 0} {0 1 1 1 0} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {1 1 1 1 1}
+ {0 0 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+ {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 0 0} {0 1 1 1 0} {1 0 1 0 1}
+ {0 1 1 1 0} {0 0 1 0 0} {0 1 0 0 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 1 0 0 0} {0 0 1 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 1 1} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 1 0} {0 0 1 0 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 1 1} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 1 0 0} {0 1 0 1 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 1 1} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {1 0 0 0 1} {1 0 0 1 1} {0 1 1 0 1} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 0 0 1 0} {0 0 1 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 1 1 1} {0 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 1 0 0} {0 0 1 0 0} {0 0 1 1 0} {0 0 1 0 1}
+ {0 0 1 1 0} {0 0 1 0 0} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ } {
+ {0 0 0 0 0} {0 1 0 1 0} {0 0 0 0 0} {1 0 0 0 1} {1 0 0 0 1}
+ {0 1 1 1 1} {0 0 0 0 1} {0 1 1 1 0} {0 0 0 0 0} {0 0 0 0 0}
+ }
+}
+
+}
diff --git a/lib/pale/lcd_hd44780.tcl b/lib/pale/lcd_hd44780.tcl
new file mode 100644
index 0000000..58484b5
--- /dev/null
+++ b/lib/pale/lcd_hd44780.tcl
@@ -0,0 +1,2954 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# 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 #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# --------------------------------------------------------------------------
+# Thanks to Trevor Spiteri <trevor.spiteri@um.edu.mt> there are 2 bugs less:
+#
+# - [PATCH 1/2] Fix 4-bit instructions for HD44780
+# - [PATCH 2/2] Start 2nd row at 0x40 not at 40 for HD44780
+# --------------------------------------------------------------------------
+
+# >>> File inclusion guard
+if { ! [ info exists _LCD_HD44780_TCL ] } {
+set _LCD_HD44780_TCL _
+# <<< File inclusion guard
+
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+#
+# Simulator of LCD character display controlled by HD44780.
+# --------------------------------------------------------------------------
+
+class LcdHD44780 {
+ inherit VirtualHWComponent
+
+ common COMPONENT_NAME "LCD display" ;# Name of this component
+ common CLASS_NAME "LcdHD44780" ;# Name of this class
+ common COMPONENT_ICON {hd44780} ;# Icon for this panel (16x16)
+
+ # Configuration menu
+ common CONFMENU {
+ {cascade "Set font" 0 "hd44780" .set_rom_code false 1 {
+ {radiobutton "ROM code A00" {}
+ ::LcdHD44780::font_id {0}
+ "font_changed" 3 ""}
+ {radiobutton "ROM code A02" {}
+ ::LcdHD44780::font_id {2}
+ "font_changed" 3 ""}
+ }}
+ {cascade "Set character size" 0 "hd44780" .set_char_size false 1 {
+ {radiobutton "5 × 8" {}
+ ::LcdHD44780::char_size {0}
+ "char_size_changed" 5 ""}
+ {radiobutton "5 × 10" {}
+ ::LcdHD44780::char_size {1}
+ "char_size_changed" 5 ""}
+ }}
+ {separator}
+ {checkbutton "Disable delays" {} {::LcdHD44780::_no_delays}
+ 1 0 0 {no_delays_changed}
+ ""}
+ {checkbutton "Ignore errors" {} {::LcdHD44780::_ignore_errors}
+ 1 0 0 {ignore_errors_changed}
+ ""}
+ {separator}
+ {command {Show HD44780 log} {} 5 "show_log" {bar5}
+ "Display the log of events which are currently happening in the simulated HD44780 chip"}
+ {command {Show CGROM} {} 5 "show_cgrom" {kcmmemory}
+ "Display content of HD44780 Character Generator ROM"}
+ {command {Show CGRAM} {} 5 "show_cgram" {kcmmemory}
+ "Display content of HD44780 Character Generator RAM"}
+ {command {Show DDRAM} {} 5 "show_ddram" {kcmmemory}
+ "Display content of HD44780 Display data RAM"}
+ {separator}
+ {command {Reset HD44780} {} 6 "reset_hd44780" {rebuild}
+ "Reinitialize the simulated HD44780, but do not affect DDRAM and CGRAM"}
+ {command {Clear DDRAM & CGRAM} {} 6 "clear_xxRAM" {editdelete}
+ "Clear the entire Display Data RAM and Character Generator RAM"}
+ {separator}
+ {command {Show help} {} 5 "show_help 1" {help}
+ "Show brief help"}
+ {separator}
+ {command {Save configuration} {} 0 "save_as" {filesave}
+ "Save configuration into a file"}
+ {command {Load configuration} {} 0 "load_from" {fileopen}
+ "Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::LcdHD44780::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
+ }
+
+ # Font: Font to be used in the panel -- bold
+ common common_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * ($::font_size_factor > 1.2 ? 1.2 : $font_size_factor))}] \
+ -family {helvetica} \
+ ]
+ # Font: Font to be used in the panel -- bold, underline
+ common common_font_u [font create \
+ -weight bold \
+ -size [expr {int(-10 * ($::font_size_factor > 1.2 ? 1.2 : $font_size_factor))}] \
+ -family {helvetica} \
+ -underline 1 \
+ ]
+
+ common ON_COLOR {#000000} ;# RGB: Color for darken pixels
+ common OFF_COLOR {#DDDDDD} ;# RGB: Color for blank pixels
+ common USER_DEF_COLOR {#AAAAFF} ;# RGB: Color used in CGROM table for user defined characters
+
+ # List: Names of IO signals of the simulated LCD display controller
+ common SIGNAL_NAMES [list {RS} {R/W} {E} {D7} {D6} {D5} {D4} {D3} {D2} {D1} {D0}]
+
+ # List: Keys for the array (status_led) of status LEDs
+ common STATUS_LEDS_NAMES [list {B} {S} {D} {C} {N} {F} {ID} {DL} {OMN} {BF}]
+
+ # List: Labels displayed beside of the status LEDs
+ common STATUS_LEDS_TEXTS [list {B} {S} {D} {C} {N} {F} {I/D} {DL} {OMN} {BF}]
+
+ # List: Help texts for the labels of the status LEDs
+ common STATUS_LEDS_HELPTEXTS [list \
+ [mc "Cursor blinking"] \
+ [mc "Accompanies display shift"] \
+ [mc "Display ON/OFF"] \
+ [mc "Cursor ON/OFF"] \
+ [mc "2 lines display / 1 line display"] \
+ [mc "5 × 10 dots / 5 × 8 dots"] \
+ [mc "Increment AC / Decrement AC"] \
+ [mc "8-bit data transfer / 4-bit data transfer"] \
+ [mc "One More Nibble to transfer / data transfer complete"] \
+ [mc "Internally operating / Instructions acceptable"] \
+ ]
+ common MAX_LOG_LENGTH 100 ;# Int: Maximum number of row in the log window
+ common CURSOR_BLINK_FREQUENCY 3 ;# Int: Frequency (in Hz) of cursor blinking
+
+ # Values used by the configuration menu
+ common _no_delays 0 ;# Bool: Disable delays (simulated execution times)
+ common _ignore_errors 0 ;# Bool: Do not display special error message dialog in cases when an error occurs
+ common font_id 0 ;# Int: Font ID to be used for addressing the CGROM
+ common char_size 0 ;# Bool: Character height from the HW point of view, 0 == 5x8; 1==5x10
+
+ # Load CGROM
+ source "${::LIB_DIRNAME}/pale/hd44780_cgrom.tcl"
+
+ private variable conf_color {red} ;# Color: Selected color for LED's
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
+ private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
+ private variable connection_pin ;# Array of Int: Index is key number, value is bit number or {-}
+ private variable enaged ;# Array of Bool: enaged(port_num,bit_num) --> Is connected to this device ?
+
+ private variable ddram_hexeditor {} ;# Object: Hexadecimal editor for editing content of DDRAM
+ private variable cgram_hexeditor {} ;# Object: Hexadecimal editor for editing content of CGRAM
+
+ private variable ddram_window_params {0 {}} ;# List: Parameters of DDRAM hex. editor window, format: {IS_VISIBLE GEOMETRY}
+ private variable cgram_window_params {0 {}} ;# List: Parameters of CGRAM hex. editor window, format: {IS_VISIBLE GEOMETRY}
+
+ private variable display_width ;# Int: LCD dot matrix width in number of characters which it is able to display on one line
+ private variable display_height ;# Int: LCD dot matrix height in number of text rows, it can be 1 one 2
+ private variable win_minwidth ;# Int: Minimum allowed width of the main window of this LCD display simulator in number of pixels
+
+ private variable input_error 0 ;# Bool: I/O error has occurred
+ private variable input_error_desc {} ;# String: Description of the last I/O error
+
+ private variable es_but_left_right ;# Widget: Button "Show/Hide right part of the window"
+ private variable es_but_up_down ;# Widget: Button "Show/Hide bottom part of the window"
+ private variable visible_lr 1 ;# Bool: Is the right part of the window currently visible
+ private variable visible_ud 1 ;# Bool: Is the bottom part of the window currently visible
+
+ private variable log_win_text {} ;# Widget: Text widget fro the log of events
+ private variable ignore_errors 0 ;# Bool: Do not display special error message dialog in cases when an error occurs
+ private variable time_mark 0 ;# Int: Time mark pointing to this point of time according to the MCU simulator engine
+ private variable log_time_mark 0 ;# Int: Time mark used to separate events in the log which happened during the same evaluation iteration
+ private variable no_delays 0 ;# Bool: Disable delays (simulated execution times)
+ private variable log_enabled 1 ;# Bool: Logging of events enabled (slower simulation)
+ private variable log_on_off_chbut ;# Widget: Checkbox for enabling and disabling the logging of events
+
+ private variable disp_frame ;# Widget: The black frame around the LCD dot matrix
+ private variable signal_label ;# Array of canvas objects: Labels above ComboBoxes for GPIO signal selection
+ private variable lcd_pixel ;# Array of canvas objects: Segments of LCD dot matrix
+ private variable cgram_pixel ;# Array of canvas objects: Same as lcd_pixel but for CGRAM
+ private variable entrybox ;# Array of Widgets: Entryboxes showing HD44780 registers, key is name of the register diaplyed the CGRAM viewer
+ private variable status_led ;# Array of Widgets: LEDs showing status of HD44780 flags like: S, F, D, B, etc.
+ private variable inhibit_vcmd 1 ;# Bool: Disable validation function for entryboxes like "IR:" or "AC:"
+
+ private variable ddram ;# Array: Display Data RAM
+ private variable cgram ;# List: Character Generator RAM, format: { 8× (char) { 8× (row) { 5× (column) {0|1} } } }
+ private variable inst_reg ;# Int: Instruction register (IR) as specified in the HD44780 manual
+ private variable data_reg ;# Int: Data register (DR) as specified in the HD44780 manual
+ private variable time_of_completion 0 ;# Int: Time (according to the MCU simulator engine) when the current operation will be finished
+ private variable address_counter 0 ;# Int: Address Counter (AC) as specified in the HD44780 manual, interval [0;0x7F]
+ private variable address_counter_old 0 ;# Int: The same as AC, but this one might contain an outdated information (incr./decr. delay)
+ private variable cursor_address 0 ;# Int: Current address (not position) of the cursor, interval [0;0x7F]
+ private variable cursor_timer {} ;# Timer: Timer for LCD cursor blinking
+ private variable return_value -1 ;# Int: Result of an READ operation, this value is supposed to be send to the data bus
+ private variable display_shift 0 ;# Int: Current display shift, this value suppose to be added to the AC, interval [0;0x7F]
+ private variable signal_E_prev 0 ;# Bool: Signal Enable, value from the last VHW evaluation iteration before this one
+ private variable signal_E 0 ;# Bool: Signal Enable
+ private variable signal_RS 0 ;# Bool: Signal Register Select
+ private variable signal_RW 0 ;# Bool: Signal Read/Write
+ private variable signal_D 0 ;# int: Value taken from the data bus
+
+ ## Array of HD44780 configuration flags
+ # KEY MEANING WHEN 0 MEANING WHEN 1
+ # --- ------------ ------------
+ # ID 0 == Decrement 1 == Increment
+ # S 0 == (Normal) 1 == Accompanies display shift
+ # D 0 == Display OFF 1 == Display ON
+ # C 0 == Cursor OFF 1 == Cursor ON
+ # B 0 == Cursor blinking OFF 1 == Cursor blinking ON
+ # DL 0 == 4-bit data transfer 1 == 8-bit data transfer
+ # N 0 == 1 line display 1 == 2 lines display
+ # F 0 == 5 × 8 dots 1 == 5 × 10 dots
+ # BF 0 == Instructions acceptable 1 == Internally operating
+ # OMN 0 == Transfer completed 1 == One More Nibble to transfer
+ # B_pre backup for ``B'' used by method clear_cursor in order to ensure correct erase of the cursor
+ # F_pre backup for ``F'' used by method clear_cursor in order to ensure correct erase of the cursor
+ private variable diver_cfg
+
+ private variable rom_code 0 ;# Int: Font ID, this is used for addressing the CGROM
+ private variable lcd_char_size 0 ;# Bool: Character height from the HW point of view, 0 == 5x8; 1==5x10
+
+ # ------------------------------------------------------------------
+ # GUI RELATED FUNCTIONS AND SO ON
+ # ------------------------------------------------------------------
+
+ ## Object constructor
+ # @parm Object _project - Project object
+ constructor {_project} {
+ # Set object variables identifing this component (see the base class)
+ set component_name $COMPONENT_NAME
+ set class_name $CLASS_NAME
+ set component_icon $COMPONENT_ICON
+
+ # Reset the array of MCU GPIO lines engaged by this device, for internal purposes only
+ for {set port 0} {$port < 5} {incr port} {
+ for {set bit 0} {$bit < 8} {incr bit} {
+ set enaged($port,$bit) 0
+ }
+ }
+
+ # Initialize array of HD44780 configuration flags
+ array set diver_cfg {
+ ID 1 S 0 D 0
+ C 0 B 0 DL 1
+ N 0 F 0 BF 0
+ OMN 0 B_pre 0 F_pre 0
+ }
+
+ # Set other object variables
+ set project $_project
+
+ # Inform PALE
+ $project pale_register_input_device $this
+ $project pale_set_modified
+ }
+
+ ## Object destructor
+ destructor {
+ # Inform PALE
+ $project pale_unregister_input_device $this
+
+ # Dispose the timer for cursor blinking
+ catch {
+ after cancel $cursor_timer
+ }
+
+ # Destroy GUI
+ if {[winfo exists $win]} {
+ destroy $win
+ }
+ }
+
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $LcdHD44780::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
+ ## Reevaluate array of MCU port pins engaged by this device
+ # @return void
+ private method evaluete_enaged_pins {} {
+ # Mark all as disengaged and infrom PALE
+ for {set port 0} {$port < 5} {incr port} {
+ for {set bit 0} {$bit < 8} {incr bit} {
+ if {$enaged($port,$bit)} {
+ $project pale_disengage_pin_by_input_device $port $bit $this
+ set enaged($port,$bit) 0
+ }
+ }
+ }
+
+ # Find the engaged ones and infrom PALE
+ for {set i 3} {$i < 11} {incr i} {
+ set port $connection_port($i)
+ set bit $connection_pin($i)
+
+ if {$port == {-} || $bit == {-}} {
+ continue
+ }
+
+ set enaged($port,$bit) 1
+ $project pale_engage_pin_by_input_device $port $bit $this
+ }
+ }
+
+ ## Reconnect the specified key to another port pin
+ # @parm Int i - Connection wire number ({0..3} => Row; {4..7} => Column)
+ # @return void
+ public method reconnect {i} {
+ # Adjust connections
+ set connection_port($i) [$canvas_widget.cb_p$i get]
+ set connection_pin($i) [$canvas_widget.cb_b$i get]
+ if {$connection_pin($i) != {-}} {
+ set connection_pin($i) [expr {7 - $connection_pin($i)}]
+ }
+
+ # Reevaluate array of MCU port pins engaged by this device
+ evaluete_enaged_pins
+
+ # Inform PALE system about the change in order
+ #+ to make immediate change in device states
+ if {$drawing_on} {
+ $project pale_reevaluate_IO
+ }
+
+ # Set flag modified
+ set_modified
+ }
+
+ ## Create GUI of this panel
+ # @return void
+ private method create_gui {} {
+ # Create panel window and canvas widget
+ set win [toplevel .lcd_display$count -class $component_name -bg ${::COMMON_BG_COLOR}]
+
+ # Create the canvas widget which contains everything else visible in the window
+ set canvas_widget [canvas $win.canvas \
+ -bg {#FFFFFF} \
+ -width 0 \
+ -height 0 \
+ -highlightthickness 0 \
+ ]
+
+ # Draw LEDs showing status of HD44780 flags like: S, F, D, B, etc.
+ draw_status_leds
+
+ # Draw the LCD dot matrix
+ draw_display
+
+ # Create ComboBoxes for specifying the connections between this device and the MCU simulator
+ draw_comboboxes 3 [expr {$display_height * 35 + 10}]
+
+ # Draw CGRAM viewer/editor
+ draw_cgram 400 [expr {$display_height * 35 + 38}]
+
+ # Create the entryboxes showing the most important HD44780 registers in the panel above the CGRAM viewer
+ draw_entyboxes 400 [expr {$display_height * 35 + 20}]
+
+ # Create "ON/OFF" button
+ create_on_off_button 5 [expr {$display_height * 35 + ($display_height == 1 ? 15 : 12)}]
+
+ # Create configuration menu button
+ create_configuration_menu_button 370 [expr {$display_height * 35 + 63}] ;#[expr {$display_height * 35 + 40}]
+
+ # Create "Show/Hide" buttons
+ create_enlarge_shirnk_buttons 370 [expr {$display_height * 35 + 13}]
+
+ # Pack canvas
+ pack $canvas_widget -fill both -expand 1
+
+ # Set window parameters
+ configure_win
+
+ # Disable or enable the "Show/Hide" buttons according to configuration of the window
+ disena_es_buttons
+ }
+
+ ## Show or Hide the bottom part of the window
+ # @return void
+ public method show_hide0 {} {
+ # Hide
+ if {$visible_ud} {
+ set new_height [expr {$display_height * 35 + 38}]
+ set image {_1downarrow}
+
+ $canvas_widget move connections_configuration 0 100
+ $canvas_widget move config_menu_button -330 -50
+ $canvas_widget move show_hide_but -300 0
+ $canvas_widget move right_bottom_panel 0 100
+
+ if {$visible_lr} {
+ show_hide1 1
+ set visible_lr 1
+ }
+
+ # Show
+ } else {
+ set new_height [expr {$display_height * 35 + 102}]
+ set image {_1uparrow}
+
+ $canvas_widget move connections_configuration 0 -100
+ $canvas_widget move config_menu_button 330 50
+ $canvas_widget move show_hide_but 300 0
+ $canvas_widget move right_bottom_panel 0 -100
+
+ if {$visible_lr} {
+ set visible_lr 0
+ show_hide1
+ }
+ }
+
+ # Set new window geometry
+ set geometry [split [wm geometry $win] {=x+}]
+ lset geometry 1 $new_height
+ wm minsize $win 0 0
+ wm geometry $win "=[lindex $geometry 0]x[lindex $geometry 1]+[lindex $geometry 2]+[lindex $geometry 3]"
+
+ # Set other values
+ set visible_ud [expr {!$visible_ud}]
+ $es_but_up_down configure -image ::ICONS::16::$image
+ update idletasks
+ }
+
+ ## Show or Hide the right part of the window
+ # @parm Bool allow_even_smaller=0 - Allow the window to be even smaller than $win_minwidth, see the code for details
+ # @return void
+ public method show_hide1 {{allow_even_smaller 0}} {
+ # Hide
+ if {$visible_lr} {
+ if {$allow_even_smaller} {
+ # Set window width just to contain the LCD dot matrix, CGRAM and so on can be omitted here
+ set new_width [expr {8 + 23 * $display_width}]
+ if {$display_height == 1} {
+ incr new_width 123
+ } else {
+ incr new_width 73
+ }
+ } else {
+ set new_width [expr {$win_minwidth - 226}]
+ }
+ set image {_1rightarrow}
+
+ # Show
+ } else {
+ set new_width $win_minwidth
+ set image {_1leftarrow}
+ }
+
+ # Set new window geometry
+ set geometry [split [wm geometry $win] {=x+}]
+ lset geometry 0 $new_width
+ wm minsize $win 0 0
+ wm geometry $win "=[lindex $geometry 0]x[lindex $geometry 1]+[lindex $geometry 2]+[lindex $geometry 3]"
+
+ # Set other values
+ set visible_lr [expr {!$visible_lr}]
+ $es_but_left_right configure -image ::ICONS::16::$image
+
+ update idletasks
+ }
+
+ ## Disable or enable the "Show/Hide" buttons according to configuration of the window
+ # @return void
+ private method disena_es_buttons {} {
+ if {$display_width > 18} {
+ $es_but_left_right configure -state disabled
+ }
+ }
+
+ ## Create "Show/Hide" buttons at the specified coordinates
+ # @parm Int x - X coordinate
+ # @parm Int y - Y coordinate
+ # @return void
+ private method create_enlarge_shirnk_buttons {x y} {
+ # Button "Show/Hide the bottom part"
+ set but [ttk::button $canvas_widget.show_hide0 \
+ -style FlatWhite.TButton \
+ -command [list $this show_hide0] \
+ -image ::ICONS::16::_1uparrow \
+ ]
+ setStatusTip -widget $but -text [mc "Show or hide the bottom part"]
+ DynamicHelp::add $but -text [mc "Show or hide the bottom part"]
+ $canvas_widget create window $x $y -window $but -anchor nw -tags show_hide_but
+ bindtags $but [list $but TButton all .]
+ set es_but_up_down $but
+
+ # Button "Show/Hide the right part"
+ set but [ttk::button $canvas_widget.show_hide1 \
+ -style FlatWhite.TButton \
+ -command [list $this show_hide1] \
+ -image ::ICONS::16::_1leftarrow \
+ ]
+ setStatusTip -widget $but -text [mc "Show or hide the right part"]
+ DynamicHelp::add $but -text [mc "Show or hide the right part"]
+ $canvas_widget create window $x [expr {$y + 25}] -window $but -anchor nw
+ bindtags $but [list $but TButton all .]
+ set es_but_left_right $but
+ }
+
+ ## Create "ON/OFF" button at the specified coordinates
+ # @parm Int x - X coordinate
+ # @parm Int y - Y coordinate
+ # @return void
+ private method create_on_off_button {x y} {
+ # Create "ON/OFF" button
+ set start_stop_button [ttk::button $canvas_widget.start_stop_button \
+ -command [list $this on_off_button_press] \
+ -style Flat.TButton \
+ -width 3 \
+ ]
+ DynamicHelp::add $start_stop_button \
+ -text [mc "Turn HW simulation on/off"]
+ setStatusTip -widget $start_stop_button -text [mc "Turn HW simulation on/off"]
+ bind $start_stop_button <Button-3> "$this on_off_button_press; break"
+ $canvas_widget create window $x $y -window $start_stop_button -anchor nw
+ bindtags $start_stop_button [list $start_stop_button TButton all .]
+ }
+
+ ## Create menu button for the configuration menu at the specified coordinates
+ # @parm Int x - X coordinate
+ # @parm Int y - Y coordinate
+ # @return void
+ private method create_configuration_menu_button {x y} {
+ # Create configuration menu button
+ set conf_button [ttk::button $canvas_widget.conf_but \
+ -image ::ICONS::16::configure \
+ -style FlatWhite.TButton \
+ -command [list $this config_menu] \
+ ]
+ setStatusTip -widget $conf_button -text [mc "Configure"]
+ $canvas_widget create window $x $y -window $conf_button -anchor nw -tags config_menu_button
+ bindtags $conf_button [list $conf_button TButton all .]
+ }
+
+ ## Set main window parameters
+ # @return void
+ private method configure_win {} {
+ # Decide minum allowable window width
+ set win_minwidth [expr {8 + 23 * $display_width}]
+ if {$display_height == 1} {
+ incr win_minwidth 123
+ } {
+ incr win_minwidth 73
+ }
+ if {$win_minwidth < 625} {
+ set win_minwidth 625
+ }
+
+ # Set window parameters
+ wm minsize $win $win_minwidth [expr {$display_height * 35 + 102}]
+ wm iconphoto $win ::ICONS::16::$component_icon
+ wm title $win "$display_height × $display_width [mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
+ wm resizable $win 0 0
+ wm protocol $win WM_DELETE_WINDOW [list $this close_window]
+ bindtags $win [list $win Toplevel all .]
+ }
+
+ ## Determinate which port pin is connected to the specified HD44780 wire
+ # @parm Int i - HD44780 signal, see SIGNAL_NAMES for the numbers of the signals
+ # @return List - {port_number bit_number}
+ private method which_port_pin {i} {
+ return [list $connection_port($i) $connection_pin($i)]
+ }
+
+ ## Handle "ON/OFF" button press
+ # Turn whole PALE system on or off
+ # @return void
+ public method on_off_button_press {} {
+ $project pale_all_on_off
+ }
+
+ ## Create ComboBoxes for specifying the connections between this device and the MCU simulator
+ # @parm Int x_offset - X coordinate where this suppose to be drawn
+ # @parm Int y_offset - Y coordinate where this suppose to be drawn
+ # @return void
+ private method draw_comboboxes {x_offset y_offset} {
+ set cb_l_y [expr {$y_offset + 13}]
+ set cb_p_y [expr {$y_offset + 33}]
+ set cb_b_y [expr {$y_offset + 53}]
+ set note_y [expr {$y_offset + 75}]
+
+ # Print labels and the user note entrybox
+ set x [expr {$x_offset + 30}]
+ $canvas_widget create text $x $cb_p_y \
+ -tags connections_configuration \
+ -text [mc "PORT"] \
+ -font $common_font \
+ -anchor e
+ $canvas_widget create text $x $cb_b_y \
+ -tags connections_configuration \
+ -text [mc "BIT"] \
+ -font $common_font \
+ -anchor e
+ $canvas_widget create text $x $note_y \
+ -tags connections_configuration \
+ -text [mc "NOTE"] \
+ -font $common_font \
+ -anchor e
+ incr x 5
+ $canvas_widget create window $x $note_y \
+ -tags connections_configuration \
+ -window [ttk::entry $canvas_widget.usr_note \
+ -validate key \
+ -validatecommand "$this set_modified" \
+ ] \
+ -width 325 -anchor w
+ bindtags $canvas_widget.usr_note \
+ [list $canvas_widget.usr_note TEntry $win all .]
+
+ # Create LES's and ComboBoxes
+ for {set i 0} {$i < 11} {incr i} {
+ # Label with name of the HD44780 pin
+ set signal_label($i) [$canvas_widget create text \
+ [expr {$x + 12}] $cb_l_y \
+ -tags connections_configuration \
+ -text [lindex $SIGNAL_NAMES $i] \
+ -font $common_font \
+ -anchor center \
+ -fill {#000000} \
+ ]
+
+ # MCU port selection ComboBoxe
+ $canvas_widget create window $x $cb_p_y \
+ -anchor w \
+ -tags connections_configuration \
+ -window [ttk::combobox $canvas_widget.cb_p$i \
+ -width 1 \
+ -font $common_font \
+ -state readonly \
+ ]
+ bind $canvas_widget.cb_p$i <<ComboboxSelected>> "$this reconnect $i"
+
+ # MCU port bit selection ComboBoxe
+ $canvas_widget create window $x $cb_b_y \
+ -anchor w \
+ -tags connections_configuration \
+ -window [ttk::combobox $canvas_widget.cb_b$i \
+ -width 1 \
+ -font $common_font \
+ -values {- 0 1 2 3 4 5 6 7} \
+ -state readonly \
+ ]
+ bind $canvas_widget.cb_b$i <<ComboboxSelected>> "$this reconnect $i"
+
+ # Finalize ...
+ bindtags $canvas_widget.cb_p$i \
+ [list $canvas_widget.cb_p$i TCombobox all .]
+ bindtags $canvas_widget.cb_b$i \
+ [list $canvas_widget.cb_b$i TCombobox all .]
+
+ incr x 30
+ }
+ }
+
+ ## Validator function for entryboxes with the most important HD44780 registers in the panel above the CGRAM viewer
+ # @parm String type - Entryboxes purpose; watched HD44780 register
+ # @parm String content - String to validate
+ # @return Bool - 1 == Passed; 0 == Incorrect input
+ public method vcmd {type content} {
+ if {$inhibit_vcmd} {
+ set inhibit_vcmd 1
+ return 1
+ }
+
+ # Allow empty strings
+ if {![string length $content]} {
+ set inhibit_vcmd 0
+ return 1
+ }
+
+ # Allow only hexadecimal digits up to length of two
+ if {![string is xdigit -strict $content] || [string length $content] > 2} {
+ set inhibit_vcmd 0
+ return 0
+ }
+
+ # Update the actual HD44780 register
+ set dec_value [expr "0x$content"]
+ switch -- $type {
+ {IR} { ;# Instruction Register
+ set inst_reg $dec_value
+ }
+ {DR} { ;# Data register
+ set data_reg $dec_value
+ }
+ {AC} { ;# Address counter
+ if {$dec_value > 0x7f} {
+ return 0
+ }
+ set address_counter $dec_value
+ set address_counter_old $dec_value
+ refresh_display
+ }
+ {SHIFT} { ;# Display Shift
+ if {$dec_value > 0x7f} {
+ return 0
+ }
+ set display_shift $dec_value
+ refresh_display
+ }
+ }
+
+ # Successfully done
+ set inhibit_vcmd 0
+ return 1
+ }
+
+ ## Update content of all entryboxes with the most important HD44780 registers in the panel above the CGRAM viewer
+ # @return void
+ private method update_entry_boxes {} {
+ set inhibit_vcmd 1
+
+ # Instruction Register
+ $entrybox(IR) delete 0 end
+ $entrybox(IR) insert 0 [format {%02X} $inst_reg]
+
+ # Data register
+ $entrybox(DR) delete 0 end
+ $entrybox(DR) insert 0 [format {%02X} $data_reg]
+
+ # Address counter
+ $entrybox(AC) delete 0 end
+ $entrybox(AC) insert 0 [format {%02X} $address_counter]
+
+ # Display Shift
+ $entrybox(SHIFT) delete 0 end
+ $entrybox(SHIFT) insert 0 [format {%02X} $display_shift]
+
+ set inhibit_vcmd 0
+ }
+
+ ## Create the entryboxes showing the most important HD44780 registers in the panel above the CGRAM viewer
+ # @parm Int x_offset - X coordinate where this suppose to be drawn
+ # @parm Int y_offset - Y coordinate where this suppose to be drawn
+ # @return void
+ private method draw_entyboxes {x_offset y_offset} {
+ set x $x_offset
+ set y $y_offset
+
+ incr x 15
+
+ # Instruction Register
+ $canvas_widget create text \
+ $x $y \
+ -text {IR:} \
+ -font $common_font \
+ -anchor e \
+ -tags right_bottom_panel
+ incr x 5
+ set entrybox(IR) [ttk::entry $canvas_widget.ir_ent \
+ -width 2 \
+ -font $common_font \
+ -validate key \
+ -validatecommand [list $this vcmd {IR} {%P}] \
+ ]
+ $canvas_widget create window $x $y \
+ -window $entrybox(IR) \
+ -anchor w \
+ -tags right_bottom_panel
+ incr x 50
+
+ # Data register
+ $canvas_widget create text \
+ $x $y \
+ -text {DR:} \
+ -font $common_font \
+ -anchor e \
+ -tags right_bottom_panel
+ incr x 5
+
+ set entrybox(DR) [ttk::entry $canvas_widget.dr_ent \
+ -width 2 \
+ -font $common_font \
+ -validate key \
+ -validatecommand [list $this vcmd {DR} {%P}] \
+ ]
+ $canvas_widget create window $x $y \
+ -window $entrybox(DR) \
+ -anchor w \
+ -tags right_bottom_panel
+ incr x 50
+
+ # Address counter
+ $canvas_widget create text \
+ $x $y \
+ -text {AC:} \
+ -font $common_font \
+ -anchor e \
+ -tags right_bottom_panel
+ incr x 5
+ set entrybox(AC) [ttk::entry $canvas_widget.ac_ent \
+ -width 2 \
+ -font $common_font \
+ -validate key \
+ -validatecommand [list $this vcmd {AC} {%P}] \
+ ]
+ $canvas_widget create window $x $y \
+ -window $entrybox(AC) \
+ -anchor w \
+ -tags right_bottom_panel
+ incr x 55
+
+ # Display Shift
+ $canvas_widget create text \
+ $x $y \
+ -text [mc "Shift:"] \
+ -font $common_font \
+ -anchor e \
+ -tags right_bottom_panel
+ incr x 5
+ set entrybox(SHIFT) [ttk::entry $canvas_widget.sh_ent \
+ -width 2 \
+ -font $common_font \
+ -validate key \
+ -validatecommand [list $this vcmd {SHIFT} {%P}] \
+ ]
+ $canvas_widget create window $x $y \
+ -window $entrybox(SHIFT) \
+ -anchor w \
+ -tags right_bottom_panel
+
+ # Configure binding tags
+ foreach key [array names entrybox] {
+ bindtags $entrybox($key) [list $entrybox($key) TEntry $win all .]
+ }
+ }
+
+ ## Draw CGRAM viewer/editor
+ # @parm Int x_offset - X coordinate where this suppose to be drawn
+ # @parm Int y_offset - Y coordinate where this suppose to be drawn
+ # @return void
+ private method draw_cgram {x_offset y_offset} {
+ $canvas_widget create text \
+ $x_offset [expr {$y_offset + 3}] \
+ -text {CGRAM:} \
+ -font $common_font \
+ -anchor w \
+ -tags right_bottom_panel
+ incr y_offset 10
+
+ set square_size 4
+ set sep 1
+ set sep2 3
+
+ set x $x_offset
+ set y [expr {$y_offset + 0}]
+ for {set k 0} {$k < 8} {incr k} {
+
+ for {set i 0} {$i < 8} {incr i} {
+ for {set j 0} {$j < 5} {incr j} {
+ set cgram_pixel($k,$j,$i) [$canvas_widget \
+ create rectangle $x $y \
+ [expr {$x + $square_size}] \
+ [expr {$y + $square_size}] \
+ -fill $OFF_COLOR \
+ -outline {#000000} \
+ -width 0
+ ]
+
+ foreach event {Enter Leave Button-1} {
+ $canvas_widget bind $cgram_pixel($k,$j,$i) <$event> \
+ [list $this cgram_pixel_event $event $k $j $i]
+ }
+
+ incr x $square_size
+ incr x $sep
+ }
+ incr x [expr {-5 * ($square_size + $sep)}]
+ incr y [expr {$square_size + $sep}]
+ }
+ $canvas_widget create text [expr {$x + (5 * $square_size) / 2}] [expr {$y + 8}] -text $k -font $common_font
+
+ incr x [expr {$sep2 + 5 * ($square_size + $sep)}]
+ incr y [expr {-8 * ($square_size + $sep)}]
+ }
+ }
+
+ ## Handle events on CGRAM viewer character points
+ # @parm String event - Event type (e.g. "Leave")
+ # @parm Int char - Number of character where it occurred
+ # @parm Int col - Column in the character
+ # @parm Int row - Row in the character
+ # @return void
+ public method cgram_pixel_event {event char col row} {
+ switch -- $event {
+ {Enter} { ;# Highlight the cell
+ $canvas_widget itemconfigure $cgram_pixel($char,$col,$row) -width 1
+ }
+ {Leave} { ;# "Unhighlight" cell
+ $canvas_widget itemconfigure $cgram_pixel($char,$col,$row) -width 0
+ }
+ {Button-1} { ;# Invert the cell and also adjust the CGRAM accordingly
+ set value [lindex $cgram [list $char $row $col]]
+ set value [expr {!$value}]
+
+ lset cgram [list $char $row $col] $value
+
+ if {$value} {
+ $canvas_widget itemconfigure $cgram_pixel($char,$col,$row) -fill $ON_COLOR
+ } else {
+ $canvas_widget itemconfigure $cgram_pixel($char,$col,$row) -fill $OFF_COLOR
+ }
+
+ if {$cgram_hexeditor != {}} {
+ set val 0
+ for {set j 0} {$j < 5} {incr j} {
+ set val [expr {$val | (([lindex $cgram [list $char $row $j]] ? 1 : 0) << $j)}]
+ }
+
+ set addr [expr {($char << 3) | $row}]
+ $cgram_hexeditor setValue $addr $val
+ $cgram_hexeditor setHighlighted $addr 1
+ }
+ }
+ }
+ }
+
+ ## Synchronize all of the status LEDs with current state of the HD44780 core
+ # @return void
+ private method adjust_status_leds {} {
+ foreach key $STATUS_LEDS_NAMES {
+ if {$diver_cfg($key)} {
+ set image {dot}
+ } else {
+ set image {dot_gray}
+ }
+ $canvas_widget itemconfigure $status_led($key) -image ::ICONS::16::$image
+ }
+ }
+
+ ## Invert the specified HD44780 configuration flag (e.g. F, S, D, B)
+ # This method suppose to be called from the status LEDs panel
+ # @parm String config_param_name - HD44780 flag, like B (Blink) or C (Cursor)
+ # @return void
+ public method change_config {config_param_name} {
+ set diver_cfg($config_param_name) [expr {$diver_cfg($config_param_name) ? 0 : 1}]
+ refresh_display
+ adjust_status_leds
+ }
+
+ ## Draw LEDs showing status of HD44780 flags like: S, F, D, B, etc.
+ # @parm Int x_offset - X coordinate where this suppose to be drawn
+ # @parm Int y_offset - Y coordinate where this suppose to be drawn
+ # @return void
+ private method draw_status_leds {{x_offset 6} {y_offset 5}} {
+ # Determinate dimensions of matrix of status LEDs
+ if {$display_height == 1} {
+ set rows 3
+ set cols 4
+ } {
+ set rows 5
+ set cols 2
+ }
+ set items_total 10
+
+ set k 0
+ for {set i 0} {$i < $cols} {incr i} {
+ for {set j 0} {$j < $rows} {incr j} {
+ # Create the LED
+ set status_led([lindex $STATUS_LEDS_NAMES $k]) \
+ [$canvas_widget create image $x_offset $y_offset -anchor nw -image ::ICONS::16::dot_gray]
+
+ # Create label for the LED
+ set label [label $canvas_widget.status_lbl_${k} \
+ -text [lindex $STATUS_LEDS_TEXTS $k] \
+ -fg {#000000} \
+ -bg {#FFFFFF} \
+ -font $common_font \
+ ]
+
+ # Set event some handlers for the label widget in order to make it work
+ #+ also as a button which changes value of the watched flag
+ bind $label <Enter> {+
+ %W configure \
+ -fg {#0000FF} \
+ -cursor hand2 \
+ -font ${::LcdHD44780::common_font_u}
+ }
+ bind $label <Leave> {+
+ %W configure \
+ -fg {#000000} \
+ -cursor left_ptr \
+ -font ${::LcdHD44780::common_font}
+ }
+ bind $label <Button-1> [list $this change_config [lindex $STATUS_LEDS_NAMES $k]]
+ ::DynamicHelp::add $label -text [lindex $STATUS_LEDS_HELPTEXTS $k]
+
+ # Show the label widget
+ $canvas_widget create window [expr {$x_offset + 10}] [expr {$y_offset - 3}] \
+ -anchor nw \
+ -window $label
+
+ incr y_offset 14
+ incr k
+
+ if {$k >= $items_total} {
+ break
+ }
+ }
+
+ incr y_offset [expr {$rows * -14}]
+ incr x_offset 25
+ }
+ }
+
+ ## Draw the LCD dot matrix
+ # @parm Int x_offset - X coordinate where this suppose to be drawn
+ # @parm Int y_offset - Y coordinate where this suppose to be drawn
+ # @return void
+ private method draw_display {{x_offset 73} {y_offset 3}} {
+ set square_size 3
+ set sep 1
+ set sep2 3
+
+ if {$display_height == 1} {
+ incr x_offset 50
+ }
+
+ set disp_frame [$canvas_widget create rectangle $x_offset $y_offset \
+ [expr {$x_offset + $sep2 - $sep + $display_width * ($sep2 + 5 * ($square_size + $sep))}] \
+ [expr {$y_offset + $sep2 - $sep + $display_height * ($sep2 + 8 * ($square_size + $sep)) + 2 * $lcd_char_size * ($square_size + $sep)}] \
+ -outline {#000000} -width 1 \
+ ]
+
+ incr x_offset $sep2
+ incr y_offset $sep2
+
+ set x $x_offset
+ set y $y_offset
+ for {set row 0} {$row < $display_height} {incr row} {
+ for {set col 0} {$col < $display_width} {incr col} {
+ for {set i 0} {$i < (8 + 2 * $lcd_char_size)} {incr i} {
+ for {set j 0} {$j < 5} {incr j} {
+ set lcd_pixel($col,$row,$j,$i) [$canvas_widget \
+ create rectangle $x $y \
+ [expr {$x + $square_size}] \
+ [expr {$y + $square_size}] \
+ -fill $OFF_COLOR \
+ -width 0
+ ]
+ incr x $square_size
+ incr x $sep
+ }
+ incr x [expr {-5 * ($square_size + $sep)}]
+ incr y [expr {$square_size + $sep}]
+ }
+ incr x [expr {$sep2 + 5 * ($square_size + $sep)}]
+ incr y [expr {(-8 - 2 * $lcd_char_size) * ($square_size + $sep)}]
+ }
+ set x $x_offset
+ incr y [expr {$sep2 + (8 + 2 * $lcd_char_size) * ($square_size + $sep)}]
+ }
+ }
+
+ ## Create and show CGRAM hex. editor window
+ # @return void
+ public method show_cgram {} {
+ if {[winfo exists $win.cgram_window]} {
+ raise $win.cgram_window
+ return
+ }
+
+ # Create dialog window
+ set dialog [toplevel $win.cgram_window -class {CGRAM (HD44780)} -bg ${::COMMON_BG_COLOR}]
+
+ # Create bottom frame
+ set bottom_frame [frame $dialog.bottom_frame]
+ pack [ttk::button $bottom_frame.close_but \
+ -text [mc "Close"] \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command [list $this close_cgram_window] \
+ ] -side left -anchor w -padx 2 -pady 2
+ set cursor_lbl [label $bottom_frame.cur_val \
+ -text { } -fg {#0000FF} \
+ -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
+ ]
+ pack $cursor_lbl -side right -anchor e -padx 5
+ pack [label $bottom_frame.cur_lbl \
+ -text [mc "Cursor: "] \
+ ] -side right -anchor e
+
+ # Create middle frame (hexeditor)
+ set hexeditor_frame $dialog.hexeditor_frame
+ set hexeditor [HexEditor #auto \
+ $hexeditor_frame 8 8 2 hex 1 0 3 64 \
+ ]
+ set cgram_hexeditor $hexeditor
+ $hexeditor showHideScrollbar 1
+ $hexeditor bindCellValueChanged [list $this write_to_cgram_from_hex_editor]
+ $hexeditor bindCellEnter [list $this show_address_in_hex_label $cursor_lbl]
+ $hexeditor bindCellLeave [list $cursor_lbl configure -text { }]
+ for {set i 0} {$i < 64} {incr i} {
+ set val 0
+ set pattern [lindex $cgram [expr {$i / 8}] [expr {$i % 8}]]
+ for {set j 0} {$j < 5} {incr j} {
+ set val [expr {$val | (([lindex $pattern $j] ? 1 : 0) << $j)}]
+ }
+ $hexeditor setValue $i $val
+ }
+ $hexeditor focus_left_view
+
+ pack $hexeditor_frame -fill both -expand 1
+ pack $bottom_frame -side bottom -fill x
+
+ # Configure dialog window
+ wm iconphoto $dialog ::ICONS::16::kcmmemory
+ wm title $dialog "CGRAM (HD44780) - [$::X::actualProject cget -projectName] - MCU 8051 IDE"
+ wm resizable $dialog 0 1
+ wm minsize $dialog 0 120
+ wm protocol $dialog WM_DELETE_WINDOW [list $this close_cgram_window]
+ if {[lindex $cgram_window_params 1] != {}} {
+ wm geometry $dialog [lindex $cgram_window_params 1]
+ }
+ }
+
+ ## Write a value to CGRAM (suppose to be used as a callback for CGRAM hex. editor window)
+ # @parm Int address - Address to CGRAM
+ # @parm Int data - New value to store in CGRAM (character pattern fragment -- one row)
+ public method write_to_cgram_from_hex_editor {address pattern} {
+ set char [expr {($address & 0x38) >> 3}]
+ set row [expr {$address & 0x07}]
+ set pattern [expr {$pattern & 0x1F}]
+
+ write_to_cgram $char $row $pattern 1
+ }
+
+ ## Close CGRAM hex. editor window if it is opened
+ # @return void
+ public method close_cgram_window {} {
+ if {$cgram_hexeditor == {}} {
+ return
+ }
+ set cgram_window_params [list 0 [wm geometry $win.cgram_window]]
+ destroy $win.cgram_window
+ set cgram_hexeditor {}
+ }
+
+ ## Create and show DDRAM hex. editor window
+ # @return void
+ public method show_ddram {} {
+ if {[winfo exists $win.ddram_window]} {
+ raise $win.ddram_window
+ return
+ }
+
+ # Create dialog window
+ set dialog [toplevel $win.ddram_window -class {DDRAM (HD44780)} -bg ${::COMMON_BG_COLOR}]
+
+ # Create bottom frame
+ set bottom_frame [frame $dialog.bottom_frame]
+ pack [ttk::button $bottom_frame.close_but \
+ -text [mc "Close"] \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command [list $this close_ddram_window] \
+ ] -side left -anchor w -padx 2 -pady 2
+ set cursor_lbl [label $bottom_frame.cur_val \
+ -text { } -fg {#0000FF} \
+ -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
+ ]
+ pack $cursor_lbl -side right -anchor e -padx 5
+ pack [label $bottom_frame.cur_lbl \
+ -text [mc "Cursor: "] \
+ ] -side right -anchor e
+
+ # Create middle frame (hexeditor)
+ set hexeditor_frame $dialog.hexeditor_frame
+ set hexeditor [HexEditor #auto \
+ $hexeditor_frame 8 10 2 hex 1 0 3 0x80 \
+ ]
+ set ddram_hexeditor $hexeditor
+ $hexeditor showHideScrollbar 1
+ $hexeditor bindCellValueChanged [list $this write_to_ddram_from_hex_editor]
+ $hexeditor bindCellEnter [list $this show_address_in_hex_label $cursor_lbl]
+ $hexeditor bindCellLeave [list $cursor_lbl configure -text { }]
+ for {set i 0} {$i < 0x80} {incr i} {
+ $hexeditor setValue $i $ddram($i)
+ }
+ $hexeditor focus_left_view
+
+ pack $hexeditor_frame -fill both -expand 1
+ pack $bottom_frame -side bottom -fill x
+
+ # Configure dialog window
+ wm iconphoto $dialog ::ICONS::16::kcmmemory
+ wm title $dialog "DDRAM (HD44780) - [$::X::actualProject cget -projectName] - MCU 8051 IDE"
+ wm resizable $dialog 0 1
+ wm minsize $dialog 0 120
+ wm protocol $dialog WM_DELETE_WINDOW [list $this close_ddram_window]
+ if {[lindex $ddram_window_params 1] != {}} {
+ wm geometry $dialog [lindex $ddram_window_params 1]
+ }
+ }
+
+ ## Write a value to DDRAM (suppose to be used as a callback for DDRAM hex. editor window)
+ # @parm Int address - Address to DDRAM
+ # @parm Int data - New value to store in DDRAM
+ # @return void
+ public method write_to_ddram_from_hex_editor {address data} {
+ write_to_ddram $address $data 1
+ }
+
+ ## Update cursor address label in xxRAM hex. editor window
+ # @parm Widget cursor_lbl - Cursor address label to update
+ # @parm Int dec_address - Decimal address to be shown in hexadecimal format
+ # @parm ... - Any other arguments are discarded
+ # @return void
+ public method show_address_in_hex_label {cursor_lbl dec_address args} {
+ $cursor_lbl configure -text "0x[format {%02X} $dec_address]"
+ }
+
+ ## Close DDRAM hex. editor window if it is opened
+ # @return void
+ public method close_ddram_window {} {
+ if {$ddram_hexeditor == {}} {
+ return
+ }
+ set ddram_window_params [list 0 [wm geometry $win.ddram_window]]
+ destroy $win.ddram_window
+ set ddram_hexeditor {}
+ }
+
+ ## Show Character Generator ROM, concrete table depends on variable $rom_code
+ # @return void
+ public method show_cgrom {} {
+ # Create the dialog window
+ set dialog "${win}_cgrom_${rom_code}"
+ if {[winfo exists $dialog]} {
+ raise $dialog
+ return
+ }
+ toplevel $dialog -class {HD44780 CGROM}
+ set cgrom_canvas [canvas $dialog.canvas \
+ -bg {#FFFFFF} \
+ ]
+
+ # Some parameters of the matrix where characters will be displayed
+ set sep 1 ;# LCD segment separator
+ set sep2 1 ;# Character column separator
+ set sep3 13 ;# Character row separator
+ set square_size 3 ;# LCD segment square size
+
+ set header_x_offset 15 ;# Position of the header
+ set header_y_offset 15 ;# Position of the header
+ set matrix_x_offset 30 ;# Position of the matrix
+ set matrix_y_offset 30 ;# Position of the matrix
+
+ # Create horizontal header
+ set x [expr {$matrix_x_offset + int(2.5 * ($square_size + $sep))}]
+ set y $header_y_offset
+ for {set i 0} {$i < 16} {incr i} {
+ $cgrom_canvas create text $x $y -text "[format {%X} $i]_" -font $common_font -fill {#FF0000}
+ incr x [expr {$sep3 + 5 * ($square_size + $sep)}]
+ }
+
+ # Create vertical header
+ set x $header_x_offset
+ set y [expr {$matrix_y_offset + 4 * ($square_size + $sep)}]
+ for {set i 0} {$i < 16} {incr i} {
+ $cgrom_canvas create text $x $y -text "_[format {%X} $i]" -font $common_font -fill {#FF0000}
+ incr y [expr {$sep2 + 10 * ($square_size + $sep)}]
+ }
+
+ # Create the matrix of characters
+ set x $matrix_x_offset
+ set y $matrix_y_offset
+ set char_code 0
+ for {set row 0} {$row < 16} {incr row} {
+ for {set col 0} {$col < 16} {incr col} {
+
+ # Draw character
+ set char_code [expr {16 * $col + $row}]
+ for {set i 0} {$i < 10} {incr i} {
+ for {set j 0} {$j < 5} {incr j} {
+ if {$col < 14 && $i > 7} {
+ set color {#FFFFFF}
+ } elseif {$char_code < 16} {
+ set color $USER_DEF_COLOR
+ } elseif {[lindex $CGROM [list $rom_code [expr {$char_code - 16}] $i $j]]} {
+ set color $ON_COLOR
+ } else {
+ set color $OFF_COLOR
+ }
+
+ $cgrom_canvas create rectangle $x $y \
+ [expr {$x + $square_size}] \
+ [expr {$y + $square_size}] \
+ -fill $color \
+ -width 0
+
+ incr x $square_size
+ incr x $sep
+ }
+ incr x [expr {-5 * ($square_size + $sep)}]
+ incr y [expr {$square_size + $sep}]
+ }
+ incr x [expr {$sep3 + 5 * ($square_size + $sep)}]
+ incr y [expr {-10 * ($square_size + $sep)}]
+
+ }
+ set x $matrix_x_offset
+ incr y [expr {$sep2 + 10 * ($square_size + $sep)}]
+ }
+
+ pack $cgrom_canvas -fill both -expand 1
+
+ # Set window parameters
+ wm minsize $dialog 555 690
+ wm iconphoto $dialog ::ICONS::16::kcmmemory
+ wm title $dialog [mc "HD44780 Character Generator ROM (ROM Code: A0%d) - MCU 8051 IDE" ${rom_code}]
+ wm resizable $dialog 0 0
+ bindtags $dialog [list $dialog Toplevel $win all .]
+ }
+
+ ## Show the log window
+ # The log window must have been once created by method create_log prior to
+ #+ the call to this method
+ # @return void
+ public method show_log {} {
+ set dialog $win.log_window
+ if {[wm state $dialog] == {normal}} {
+ raise $dialog
+ return
+ }
+ if {![winfo exists $dialog]} {
+ return
+ }
+ wm deiconify $dialog
+ raise $dialog
+ }
+
+ ## Create the log dialog window, but do not show it until method show_log is called
+ # @parm String geometry={} - Desired geometry of the window, {} means default geometry
+ # @return void
+ public method create_log {{geometry {}}} {
+ # Create the dialog window (hidden for now)
+ set dialog $win.log_window
+ toplevel $dialog
+ wm withdraw $dialog
+
+ ## Create main frame (text and scrollbar)
+ set main_frame [frame $dialog.main_frame]
+ # Text widget
+ set text_widget [text $main_frame.text \
+ -width 0 -height 0 -font $hlp_normal_font \
+ -yscrollcommand [list $main_frame.scrollbar set] \
+ -wrap word -padx 5 -pady 5 -state disabled \
+ ]
+ set log_win_text $text_widget
+ bindtags $text_widget [list $text_widget Text $win all .]
+ pack $text_widget -side left -fill both -expand 1
+ # Create text tag in the text widget
+ $text_widget tag configure tag_info -foreground {#FFFFFF} -background {#0000EE}
+ $text_widget tag configure tag_warning -foreground {#FFFFFF} -background {#EE8800}
+ $text_widget tag configure tag_error -foreground {#FFFFFF} -background {#DD0000}
+ $text_widget tag configure tag_line \
+ -background {#DDDDDD} \
+ -font [font create \
+ -family ${::DEFAULT_FIXED_FONT} \
+ -size -1 \
+ ]
+
+ # Scrollbar
+ pack [ttk::scrollbar $main_frame.scrollbar \
+ -orient vertical \
+ -command [list $text_widget yview] \
+ ] -side right -fill y
+ # Finalize ...
+ pack $main_frame -fill both -expand 1 -padx 2
+
+ # Create bottom frame
+ set bottom_frame [frame $dialog.bottom_frame]
+ # Button "Close"
+ pack [ttk::button $bottom_frame.close_button \
+ -text [mc "Close"] \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command [list $this close_log_win] \
+ ] -side right
+ # Button "Clear log"
+ pack [ttk::button $bottom_frame.clear_button \
+ -text [mc "Clear log"] \
+ -compound left \
+ -image ::ICONS::16::editdelete \
+ -command "
+ $text_widget configure -state normal
+ $text_widget delete 0.0 end
+ $text_widget configure -state disabled
+ " \
+ ] -side left
+ # CheckBox: "Enable log"
+ set log_on_off_chbut [checkbutton $bottom_frame.on_off_chbut \
+ -command [list $this log_on_off] \
+ -text [mc "Enable log"] \
+ ]
+ if {$log_enabled} {
+ $log_on_off_chbut select
+ } {
+ $log_on_off_chbut deselect
+ }
+ setStatusTip -widget $log_on_off_chbut -text [mc "Disabled logging may notably improve simulation speed"]
+ DynamicHelp::add $log_on_off_chbut -text [mc "Disabled logging may notably improve simulation speed"]
+ pack $log_on_off_chbut -side left -padx 5
+ pack $bottom_frame -pady 2 -padx 5 -fill x
+
+ # Set window parameters
+ wm minsize $dialog [expr {int(300 * $::font_size_factor)}] [expr {int(150 * $::font_size_factor)}]
+ wm iconphoto $dialog ::ICONS::16::bar5
+ wm title $dialog [mc "HD44780 log - MCU 8051 IDE"]
+ wm protocol $dialog WM_DELETE_WINDOW [list $this close_log_win]
+ bindtags $dialog [list $dialog Toplevel $win all .]
+
+ if {$geometry != {}} {
+ wm geometry $dialog $geometry
+ }
+ }
+
+ ## Enable or disable logging of events
+ # @return void
+ public method log_on_off {} {
+ set log_enabled [expr {!$log_enabled}]
+
+ # Set flag modified
+ set_modified
+ }
+
+ ## Close the HD44780 log window
+ # @return void
+ public method close_log_win {} {
+ set dialog $win.log_window
+ if {![winfo exists $dialog]} {
+ return
+ }
+
+ wm withdraw $dialog
+ }
+
+ ## Informs the HD44780 simulator about change of _no_delays flag (used by configuration menu)
+ # @return void
+ public method no_delays_changed {} {
+ set no_delays ${::LcdHD44780::_no_delays}
+ }
+
+ ## Informs the HD44780 simulator about change of _ignore_errors flag (used by configuration menu)
+ # @return void
+ public method ignore_errors_changed {} {
+ set ignore_errors ${::LcdHD44780::_ignore_errors}
+ }
+
+ ## Informs the HD44780 simulator about change of character size (used by configuration menu)
+ # @return void
+ public method char_size_changed {} {
+ set lcd_char_size ${::LcdHD44780::char_size}
+ if {$display_height == 2 && $lcd_char_size == 1} {
+ set lcd_char_size 0
+ return
+ }
+ accept_new_character_size
+ }
+
+ ## Informs the HD44780 simulator about change of font (used by configuration menu)
+ # @return void
+ public method font_changed {} {
+ set rom_code ${::LcdHD44780::font_id}
+ refresh_display
+ }
+
+ ## Adapt the LCD dot matrix to a new character size value, that means create additional
+ #+ dots and get rid of some of the dots currently displayed
+ # @return void
+ private method accept_new_character_size {} {
+ if {$display_height == 2} {
+ return
+ }
+
+ $canvas_widget delete $disp_frame
+ foreach key [array names lcd_pixel] {
+ $canvas_widget delete $lcd_pixel($key)
+ }
+ draw_display
+ refresh_display
+ }
+
+ ## Write a message to the log
+ # @parm Char type - Message type "I" == Information; "W" == Warning; "E" == Error
+ # @parm String string - Text of the message
+ # @return void
+ private method write_to_log {type string} {
+ # Do not do anything if the log is not available at all
+ if {!$log_enabled || $log_win_text == {}} {
+ return
+ }
+
+ # Enable the text widget
+ $log_win_text configure -state normal
+
+ # Manage the log length, the number of row in the log must not exceed the specified maximum
+ if {int([$log_win_text index end]) > ($MAX_LOG_LENGTH + 1)} {
+ set diff [expr {int([$log_win_text index end]) - $MAX_LOG_LENGTH}]
+ $log_win_text delete 1.0 $diff.0
+ }
+ $log_win_text mark set insert {end -1l lineend}
+
+ # Insert separators (horizontal lines) between events with the same time mark
+ if {$time_mark && $log_time_mark != $time_mark} {
+ set log_time_mark $time_mark
+ $log_win_text insert insert "\n"
+ $log_win_text tag add tag_line insert-1l insert
+ }
+
+ # Insert the information about the message type
+ switch -- $type {
+ {I} { ;# Information
+ $log_win_text insert insert [mc "\[INFO\] "]
+ $log_win_text tag add tag_info {insert linestart} insert-1c
+ }
+ {W} { ;# Warning
+ $log_win_text insert insert [mc "\[WARNING\] "]
+ $log_win_text tag add tag_warning {insert linestart} insert-1c
+ }
+ {E} { ;# Error
+ $log_win_text insert insert [mc "\[ERROR\] "]
+ $log_win_text tag add tag_error {insert linestart} insert-1c
+ }
+ }
+
+ # Insert the message itself
+ $log_win_text insert insert $string
+ $log_win_text insert insert "\n"
+ $log_win_text see insert
+
+ # Disable the text widget
+ $log_win_text configure -state disabled
+
+ # Show also a special erro message dialog if this is a case of an error and if it is allowed
+ if {$type == {E} && !$ignore_errors} {
+ if {[$project sim_run_in_progress]} {
+ $project sim_run
+ } elseif {[$project sim_anim_in_progress]} {
+ $project sim_animate
+ }
+ tk_messageBox \
+ -parent $win \
+ -title [mc "HD44780 ERROR"] \
+ -icon error \
+ -type ok \
+ -message $string
+ }
+ }
+
+ # ------------------------------------------------------------------
+ # HD44780 CORE FUNCTIONS
+ # ------------------------------------------------------------------
+
+ ## HD44780 instruction: Clear Display
+ # Clears entire display and sets DDRAM address 0 in address counter.
+ # @return void
+ private method inst_ClearDisplay {} {
+ write_to_log I [mc "Received instruction: %s" "Clear Display"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 1700
+
+ set address_counter 0
+ for {set i 0} {$i < 0x80} {incr i} {
+ write_to_ddram $i 20
+ }
+
+ update_entry_boxes
+ }
+
+ ## HD44780 instruction: Return Home
+ # Sets DDRAM address 0 in address counter. Also returns display from
+ #+ being shifted to original position. DDRAM contents remain unchanged.
+ # @return void
+ private method inst_ReturnHome {} {
+ write_to_log I [mc "Received instruction: %s" "Return Home"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 1700
+
+ set address_counter 0
+ set display_shift 0
+
+ update_entry_boxes
+ refresh_display
+ }
+
+ ## HD44780 instruction: Entry Mode Set
+ # Sets cursor move direction and specifies display shift. These
+ #+ operations are performed during data write and read.
+ # @return void
+ private method inst_EntryModeSet {} {
+ write_to_log I [mc "Received instruction: %s" "Entry Mode Set"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 40
+
+ set diver_cfg(ID) [expr {($inst_reg & 0x02) ? 1 : 0}]
+ set diver_cfg(S) [expr {($inst_reg & 0x01) ? 1 : 0}]
+
+ write_to_log I "I/D = $diver_cfg(ID), S = $diver_cfg(S)"
+
+ update_entry_boxes
+ adjust_status_leds
+ refresh_display
+ }
+
+ ## HD44780 instruction: Display On Off Control
+ # Sets entire display (D) on/off, cursor on/off (C), and blinking of
+ #+ cursor position character (B).
+ # @return void
+ private method inst_DisplayOnOffControl {} {
+ write_to_log I [mc "Received instruction: %s" "Display On Off Control"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 40
+
+ set diver_cfg(D) [expr {($inst_reg & 0x04) ? 1 : 0}]
+ set diver_cfg(C) [expr {($inst_reg & 0x02) ? 1 : 0}]
+ set diver_cfg(B) [expr {($inst_reg & 0x01) ? 1 : 0}]
+
+ write_to_log I "D = $diver_cfg(D), C = $diver_cfg(C), B = $diver_cfg(B)"
+
+ update_entry_boxes
+ adjust_status_leds
+ refresh_display
+ }
+
+ ## HD44780 instruction: Cursor Or Display Shift
+ # Sets entire display (D) on/off, cursor on/off (C), and blinking of
+ #+ cursor position character (B).
+ # @return void
+ private method inst_CursorOrDisplayShift {} {
+
+ write_to_log I [mc "Received instruction: %s" "Cursor Or Display Shift"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 40
+
+ set sc [expr {($inst_reg & 0x08) ? 1 : 0}]
+ set rl [expr {($inst_reg & 0x04) ? 1 : 0}]
+
+ write_to_log I "S/C = $sc, R/L = $rl"
+
+ # Shift display
+ if {$sc} {
+ # Right
+ if {$rl} {
+ incr display_shift -1
+ # Left
+ } else {
+ incr display_shift
+ }
+ # Move cursor
+ } else {
+ set address_counter_old $address_counter
+ # Right
+ if {$rl} {
+ incr address_counter
+ # Left
+ } else {
+ incr address_counter -1
+ }
+ move_cursor $address_counter
+ }
+
+ update_entry_boxes
+ refresh_display
+ }
+
+ ## HD44780 instruction: Function Set
+ # Sets interface data length (DL), number of display lines (N), and
+ #+ character font (F).
+ # @return void
+ private method inst_FunctionSet {} {
+ write_to_log I [mc "Received instruction: %s" "Function Set"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 40
+
+ set diver_cfg(DL) [expr {($inst_reg & 0x10) ? 1 : 0}]
+ set diver_cfg(N) [expr {($inst_reg & 0x08) ? 1 : 0}]
+ set diver_cfg(F) [expr {($inst_reg & 0x04) ? 1 : 0}]
+
+ write_to_log I "DL = $diver_cfg(DL), N = $diver_cfg(N), F =$diver_cfg(F)"
+
+ update_entry_boxes
+ adjust_status_leds
+ refresh_display
+ }
+
+ ## HD44780 instruction: Set CGRAM Address
+ # Sets CGRAM address. CGRAM data is sent and received after this setting.
+ # @return void
+ private method inst_SetCGRAMAddress {} {
+ write_to_log I [mc "Received instruction: %s" "Set CGRAM Address"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 40
+
+ set address_counter [expr {0x3F & $inst_reg}]
+
+ write_to_log I "ACG = $address_counter"
+
+ update_entry_boxes
+ }
+
+ ## HD44780 instruction: Set DDRAM Address
+ # Sets DDRAM address. DDRAM data is sent and received after this setting.
+ # @return void
+ private method inst_SetDDRAMAddress {} {
+ write_to_log I [mc "Received instruction: %s" "Set DDRAM Address"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 40
+
+ set address_counter [expr {0x7F & $inst_reg}]
+ move_cursor $address_counter
+
+ write_to_log I "ADD = $address_counter"
+
+ update_entry_boxes
+ }
+
+ ## HD44780 instruction: Read Busy Flag & Address
+ # Reads busy flag (BF) indicating internal operation is being performed
+ #+ and reads address counter contents.
+ # @return void
+ private method inst_ReadBusyFlagAndAddress {} {
+ write_to_log I [mc "Received instruction: %s" "Read Busy Flag & Address"]
+
+ ## Simulate address counter update delay (approx. 6 us)
+ if {$diver_cfg(BF)} {
+ set return_value [expr {(($diver_cfg(BF) ? 1 : 0) << 7) + ($address_counter_old & 0x7f)}]
+ return
+ } elseif {($time_of_completion + 6) > [lindex [$project get_run_statistics] 0]} {
+ set return_value [expr {(($diver_cfg(BF) ? 1 : 0) << 7) + ($address_counter_old & 0x7f)}]
+ return
+ }
+
+ set return_value [expr {(($diver_cfg(BF) ? 1 : 0) << 7) + ($address_counter & 0x7f)}]
+ }
+
+ ## HD44780 instruction: Write Data To CG Or DDRAM
+ # Writes data into DDRAM or CGRAM.
+ # @return void
+ private method inst_WriteDataToCGOrDDRAM {} {
+ write_to_log I [mc "Received instruction: %s" "Write Data To CG Or DDRAM"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 40
+
+ # Write to the Display Data RAM (DDRAM)
+ if {0x80 & $inst_reg} {
+ write_to_ddram $address_counter $data_reg
+ # Write to the Character Generator RAM (CGRAM)
+ } elseif {0x40 & $inst_reg} {
+ write_to_cgram [expr {($address_counter & 0xf8) >> 3}] [expr {$address_counter & 0x07}] $data_reg
+ # Write to nowhere -- Error condition, abort
+ } else {
+ write_to_log E [mc "Neither \"Set DDRAM Address\" nor \"Set CGRAM Address\" instruction was issued prior to the write instruction"]
+ return
+ }
+
+ # Perform automatic Address Counter (AC) update and display shift as described in the HD44780 manual
+ set address_counter_old $address_counter
+ if {$diver_cfg(ID)} {
+ incr address_counter
+ if {$diver_cfg(S)} {
+ incr display_shift -1
+ }
+ } else {
+ incr address_counter -1
+ if {$diver_cfg(S)} {
+ incr display_shift
+ }
+ }
+ set address_counter [expr {$address_counter % 0x80}]
+ set display_shift [expr {$display_shift % 0x80}]
+
+ # Synchronize with the LCD cursor
+ if {0x80 & $inst_reg} {
+ move_cursor $address_counter
+ }
+
+ # Update entry boxes showing content of some HD44780 registers
+ update_entry_boxes
+ }
+
+ ## HD44780 instruction: Read Data From CG Or DDRAM
+ # Reads data from DDRAM or CGRAM.
+ # @return void
+ private method inst_ReadDataFromCGOrDDRAM {} {
+ write_to_log I [mc "Received instruction: %s" "Read Data From CG Or DDRAM"]
+ if {[must_not_be_enaged]} {return}
+ engage_core 40
+
+ # Read from the Display Data RAM (DDRAM)
+ if {0x80 & $inst_reg} {
+ set return_value $ddram($address_counter)
+
+ # Read from the Character Generator RAM (CGRAM)
+ } elseif {0x40 & $inst_reg} {
+ set return_value 0
+ for {set i 4} {$i >= 0} {incr i -1} {
+ set return_value [expr {$return_value | ([lindex $cgram \
+ [expr {($address_counter & 0x38) >> 3}] \
+ [expr {$address_counter & 0x07}] \
+ [expr {4 - $i}]] << $i
+ )}]
+ }
+
+ # Read from nowhere -- Error condition, abort
+ } else {
+ write_to_log E [mc "Neither \"Set DDRAM Address\" nor \"Set CGRAM Address\" instruction was issued prior to the read instruction"]
+ return
+ }
+
+ # Perform automatic Address Counter (AC) update and display shift as described in the HD44780 manual
+ set address_counter_old $address_counter
+ if {$diver_cfg(ID)} {
+ incr address_counter
+ if {$diver_cfg(S)} {
+ incr display_shift -1
+ }
+ } else {
+ incr address_counter -1
+ if {$diver_cfg(S)} {
+ incr display_shift
+ }
+ }
+ set address_counter [expr {$address_counter % 0x80}]
+ set display_shift [expr {$display_shift % 0x80}]
+
+ # Synchronize with the LCD cursor
+ if {0x80 & $inst_reg} {
+ move_cursor $address_counter
+ }
+
+ # Update entry boxes showing content of some HD44780 registers
+ update_entry_boxes
+ }
+
+ ## Raise an error message if the core is engaged by some operation
+ # @return Bool - 0 == Not egaged; 1 == Is engaged
+ private method must_not_be_enaged {} {
+ if {$diver_cfg(BF)} {
+ if {$no_delays} {
+ set diver_cfg(BF) 0
+ } else {
+ write_to_log W [mc "Controller is busy, unable to execute requested instruction."]
+ return 1
+ }
+ } else {
+ return 0
+ }
+ }
+
+ ## Simulate the execution time of an operation
+ # @parm int time_us - Time for how long the HD44780 will be engaged by the operation in micro-seconds
+ # @return void
+ private method engage_core {time_us} {
+ # Mention it in the log
+ write_to_log I [mc "Commencing execution, this action will take %d micro-seonds to comply." $time_us]
+
+ # Skip delay if the simulator has been configure this way
+ if {$no_delays} {
+ set time_us 0
+ write_to_log I [mc "Skipping delay"]
+ }
+
+ # Set time when the execution will be completed (time is taken from the MCU simulator engine)
+ set time_of_completion [lindex [$project get_run_statistics] 0]
+ incr time_of_completion [expr {$time_us * 1000}]
+
+ # Set the Busy Flag
+ if {$no_delays} {
+ set diver_cfg(BF) 0
+ } else {
+ set diver_cfg(BF) 1
+ }
+
+ # Synchronize with the status LEDs
+ adjust_status_leds
+ }
+
+ ## Reset the simulated HD44780 controller
+ # @return void
+ public method reset_hd44780 {} {
+ set inhibit_vcmd 1 ;# Disable validation function for entryboxes like "IR:" or "AC:"
+
+ # Fill the DDRAM with 0x20 (SPACE) characters
+ clear_ddram
+
+ # Reset some object variables containing LCD display configuration
+ set display_shift 0 ;# Current display shift, this value suppose to be added to the AC
+ set address_counter 0 ;# Address Counter (AC) as specified in the HD44780 manual
+ set inst_reg 0 ;# Instruction register (IR) as specified in the HD44780 manual
+ set data_reg 0 ;# Data register (DR) as specified in the HD44780 manual
+
+ # Array of HD44780 configuration flags
+ set diver_cfg(ID) 1 ;# 0 == Decrement ; 1 == Increment
+ set diver_cfg(S) 0 ;# 0 == (Normal) ; 1 == Accompanies display shift
+ set diver_cfg(D) 0 ;# 0 == Display OFF ; 1 == Display ON
+ set diver_cfg(C) 0 ;# 0 == Cursor OFF ; 1 == Cursor ON
+ set diver_cfg(B) 0 ;# 0 == Cursor blinking OFF ; 1 == Cursor blinking ON
+ set diver_cfg(DL) 1 ;# 0 == 4-bit data transfer ; 1 == 8-bit data transfer
+ set diver_cfg(N) 0 ;# 0 == 1 line display ; 1 == 2 lines display
+ set diver_cfg(F) 0 ;# 0 == 5 × 8 dots ; 1 == 5 × 10 dots
+ set diver_cfg(BF) 0 ;# 0 == Instructions acceptable ; 1 == Internally operating
+ set diver_cfg(OMN) 0 ;# 0 == Transfer completed ; 1 == One More Nibble to transfer
+
+ clear_display ;# Ensure that that the LCD dot matrix is clear
+ clear_cursor ;# Make the LCD cursor disappear
+ adjust_status_leds ;# Synchronize with the status LEDs (right from the LCD dot matrix)
+ update_entry_boxes ;# Update entryboxes like "IR:" or "AC:"
+
+ # Mention this in the log
+ write_to_log I [mc "Device reset"]
+
+ set inhibit_vcmd 0 ;# Enable validation function for entryboxes like "IR:" or "AC:"
+ }
+
+ ## Write octet into Display Data RAM (DDRAM)
+ # @parm Int address - Address in DDRAM [0;7f]
+ # @parm Int char_code - Octet to write
+ # @parm Bool do_not_affect_hexeditor=0 - Do not synchronize wit the DDRAM hex editor window
+ # @return void
+ public method write_to_ddram {address char_code {do_not_affect_hexeditor 0}} {
+ # Validate the given address
+ if {$address > 0x7f} {
+ write_to_log W [mc "DDRAM address is too high: %d" $address]
+ }
+
+ # Write to the actual DDRAM
+ set ddram($address) $char_code
+
+ # Synchronize the DDRAM hex editor window if it is allowed and possible
+ if {$ddram_hexeditor != {} && !$do_not_affect_hexeditor} {
+ $ddram_hexeditor setValue $address $char_code
+ $ddram_hexeditor setHighlighted $address 1
+ }
+
+ # Determinate target position
+ set position [address_to_position $address]
+
+ # ABORT! if the target position is out of visible range
+ if {![is_position_visible $position]} {
+
+ return
+ }
+
+ ## Convert position into row and column
+ # Two lines display
+ if {$diver_cfg(N) && $display_height == 2 && $position >= 0x40} {
+ set col [expr {$position - 0x40}]
+ set row 1
+ # One line display
+ } else {
+ set col $position
+ set row 0
+ }
+
+ ## Get character bitmap image
+ # Access to CGRAM (Character Generator RAM)
+ if {$char_code < 16} {
+ set char_pattern [lindex $cgram $char_code]
+ # Access to CGROM (Character Generator ROM)
+ } else {
+ incr char_code -16
+ set char_pattern [lindex $CGROM [list $rom_code $char_code]]
+ }
+
+ # Determinate actual character height
+ if {$display_height == 1 && $diver_cfg(F)} {
+ set max_char_row [expr {8 + 2 * $lcd_char_size}]
+ } else {
+ set max_char_row 8
+ }
+
+ ## Adjust the LCD dot matrix
+ # Iterate over rows
+ for {set y 0} {$y < $max_char_row} {incr y} {
+ # Iterate over columns
+ for {set x 0} {$x < 5} {incr x} {
+ if {$diver_cfg(D) && [lindex $char_pattern [list $y $x]]} {
+ set color $ON_COLOR
+ } else {
+ set color $OFF_COLOR
+ }
+ $canvas_widget itemconfigure $lcd_pixel($col,$row,$x,$y) -fill $color
+ }
+ }
+ }
+
+ ## Write one row of character patter into the Character Generator RAM (CGRAM)
+ # @parm Int char_code - Number of the user defined character [0;7]
+ # @parm Int row - Row in the patter [0;7] (0 - top; 7 - bottom)
+ # @parm List data - Pattern fragment in decimal representation (e.g. 0x15 means {1 0 1 0 1} or 0x03 means {0 0 1 1 1})
+ # @parm Bool do_not_affect_hexeditor=0 - Do not synchronize wit the CGRAM hex editor window
+ # @return void
+ private method write_to_cgram {char_code row data {do_not_affect_hexeditor 0}} {
+
+ # Validate input data
+ if {$char_code > 7} {
+ write_to_log W [mc "CGRAM address is too high: %d" $char_code]
+ }
+ if {$data > 31} {
+ write_to_log W [mc "Value is too high: 0x%X" $data]
+ set data [expr {$data & 0x1f}]
+ }
+ set char_code [expr {$char_code % 8}]
+
+ # Convert the given pattern fragment to this format:
+ #+ {B B B B B}, where B is 0 or 1, 0 == blank dot, 1 == black dot
+ set char_pattern [list]
+ for {set i 4} {$i >= 0} {incr i -1} {
+ lappend char_pattern [expr {($data & (1 << $i)) ? 1 : 0}]
+ }
+
+ # Write to the CGRAM
+ lset cgram [list $char_code $row] $char_pattern
+
+ # Synchronize the CGRAM viewer
+ for {set col 0} {$col < 5} {incr col} {
+ if {[lindex $char_pattern $col]} {
+ set color $ON_COLOR
+ } else {
+ set color $OFF_COLOR
+ }
+ $canvas_widget itemconfigure $cgram_pixel($char_code,$col,$row) -fill $color
+ }
+
+ # Synchronize the CGRAM hex editor window if it is allowed and possible
+ if {$cgram_hexeditor != {} && !$do_not_affect_hexeditor} {
+ set addr [expr {($char_code << 3) | $row}]
+ $cgram_hexeditor setValue $addr $data
+ $cgram_hexeditor setHighlighted $addr 1
+ }
+ }
+
+ ## Fill the entire Character Generator RAM (CGRAM) with zeros
+ # @return void
+ private method clear_cgram {} {
+ # Dispose the CGRAM memory
+ set cgram [list]
+
+ # Generate an empty character pattern
+ set char [list]
+ for {set i 0} {$i < 8} {incr i} {
+ lappend char [list 0 0 0 0 0]
+ }
+
+ # Refill the CGRAM memory
+ for {set i 0} {$i < 16} {incr i} {
+ lappend cgram $char
+ }
+
+ # Synchronize the CGRAM viewer
+ if {$canvas_widget != {}} {
+ for {set i 0} {$i < 8} {incr i} {
+ for {set y 0} {$y < 8} {incr y} {
+ for {set x 0} {$x < 5} {incr x} {
+ $canvas_widget itemconfigure $cgram_pixel($i,$x,$y) -fill $OFF_COLOR
+ }
+ }
+ }
+ }
+
+ # Synchronize the CGRAM hex editor window if possible
+ if {$cgram_hexeditor != {}} {
+ for {set i 0} {$i < 64} {incr i} {
+ $cgram_hexeditor setValue $i 0
+ }
+ }
+ }
+
+ ## Fill the entire Display Data RAM (DDRAM) with 0x20 characters (SPACE), but do not refresh the display
+ # @return void
+ private method clear_ddram {} {
+ # Fill the DDRAM
+ for {set i 0} {$i < 0x80} {incr i} {
+ set ddram($i) 32 ;# 0x20 (SPACE) character
+ }
+
+ # Synchronize the DDRAM hex editor window is possible
+ if {$ddram_hexeditor != {}} {
+ for {set i 0} {$i < 0x80} {incr i} {
+ $ddram_hexeditor setValue $i $ddram($i)
+ }
+ }
+ }
+
+ ## Clear the entire Display Data RAM and Character Generator RAM
+ # @return void
+ public method clear_xxRAM {} {
+ clear_ddram
+ clear_cgram
+ refresh_display
+ }
+
+ ## Determinate whether the specified position is visible or not
+ # @parm Int position - Position address [0,7f]
+ # @return Bool - 1 == Visible; 0 == Not visible
+ private method is_position_visible {position} {
+ if {$position < 0} {
+ return 0
+ }
+
+ if {$position >= 0x80} {
+ return 0
+ }
+
+ if {$position >= $display_width} {
+ if {$display_height == 1} {
+ return 0
+ } else {
+ if {!$diver_cfg(N)} {
+ return 0
+ } elseif {$position < 0x40 || $position >= ($display_width + 0x40)} {
+ return 0
+ }
+ }
+ }
+
+ return 1
+ }
+
+ ## Refresh display according to the DDRAM content and (new) HD44780 configuration
+ # @return void
+ private method refresh_display {} {
+ for {set i 0} {$i < 0x80} {incr i} {
+ write_to_ddram $i $ddram($i) 1
+ }
+ move_cursor $address_counter
+ }
+
+ ## Ensure that that the LCD dot matrix is clear
+ # @return void
+ private method clear_display {} {
+ for {set row 0} {$row < $display_height} {incr row} {
+ for {set col 0} {$col < $display_width} {incr col} {
+ for {set i 0} {$i < (8 + 2 * $lcd_char_size)} {incr i} {
+ for {set j 0} {$j < 5} {incr j} {
+ $canvas_widget itemconfigure $lcd_pixel($col,$row,$j,$i) -fill $OFF_COLOR
+ }
+ }
+ }
+ }
+ }
+
+
+ ## Make the LCD cursor disappear
+ # @return void
+ private method clear_cursor {} {
+ # Determinate target position
+ set position [address_to_position $cursor_address]
+
+ # ABORT! if the target position is out of visible range
+ if {![is_position_visible $position]} {
+ return
+ }
+
+ ## Convert position into row and column
+ # Two lines display
+ if {$diver_cfg(N) && $display_height == 2 && $position >= 0x40} {
+ set col [expr {$position - 0x40}]
+ set row 1
+ # One line display
+ } else {
+ set col $position
+ set row 0
+ }
+
+ # Blinking cursor
+ if {$diver_cfg(B_pre)} {
+ if {$cursor_timer != {}} {
+ after cancel $cursor_timer
+ set cursor_timer {}
+ }
+
+ # Overwrite the cursor with actual character at its position
+ write_to_ddram $cursor_address $ddram($cursor_address) 1
+
+ # Normal cursor
+ } else {
+ if {$diver_cfg(F_pre)} {
+ if {$lcd_char_size} {
+ set max_char_row 9
+ } {
+ set max_char_row -1
+ }
+ } else {
+ set max_char_row 7
+ }
+ if {$max_char_row != -1} {
+ for {set x 0} {$x < 5} {incr x} {
+ $canvas_widget itemconfigure $lcd_pixel($col,$row,$x,$max_char_row) -fill $OFF_COLOR
+ }
+ }
+ }
+ }
+
+ ## Draw LCD cursor according to current HD44780 settings and at position given by variable $cursor_address
+ # @return void
+ private method draw_cursor {} {
+ # Cursor is disabled -- abort
+ if {!$diver_cfg(C)} {
+ return
+ }
+
+ # Determinate target position
+ set position [address_to_position $cursor_address]
+
+ # Abort if the target position is out of visible range
+ if {![is_position_visible $position]} {
+ return
+ }
+
+ ## Convert position into row and column
+ # Two lines display
+ if {$diver_cfg(N) && $display_height == 2 && $position >= 0x40} {
+ set col [expr {$position - 0x40}]
+ set row 1
+ # One line display
+ } else {
+ set col $position
+ set row 0
+ }
+
+ # Cursor appearance is affected also by the font size
+ if {$diver_cfg(F)} {
+ if {$lcd_char_size} {
+ set max_char_row 10
+ } else {
+ set max_char_row -1
+ }
+ } {
+ set max_char_row 8
+ }
+
+ set diver_cfg(B_pre) $diver_cfg(B)
+ set diver_cfg(F_pre) $diver_cfg(F)
+
+ # Draw blinking cursor
+ if {$diver_cfg(B)} {
+ # Stop the LCD cursor blinking timer
+ if {$cursor_timer != {}} {
+ after cancel $cursor_timer
+ }
+ # Normalize number of rows of the cursor rectangle
+ if {$max_char_row == -1} {
+ set max_char_row 8
+ }
+ # Draw the black cursor rectangle
+ for {set y 0} {$y < $max_char_row} {incr y} {
+ for {set x 0} {$x < 5} {incr x} {
+ $canvas_widget itemconfigure $lcd_pixel($col,$row,$x,$y) -fill $ON_COLOR
+ }
+ }
+ # Start the LCD cursor blinking timer
+ set cursor_timer [after [expr {int(1000 / $CURSOR_BLINK_FREQUENCY)}] [list $this cursor_timer_callback 1]]
+
+ # Draw normal cursor (a sort of underscore)
+ } else {
+ if {$max_char_row != -1} {
+ incr max_char_row -1
+ for {set x 0} {$x < 5} {incr x} {
+ $canvas_widget itemconfigure $lcd_pixel($col,$row,$x,$max_char_row) -fill $ON_COLOR
+ }
+ }
+ }
+ }
+
+ ## Move the LCD cursor to a new location
+ # @parm Int new_address - Address in DDRAM
+ # @return void
+ #
+ # Note: This function could be also used to refresh the cursor
+ private method move_cursor {new_address} {
+ clear_cursor
+ set cursor_address $new_address
+ draw_cursor
+ }
+
+ ## Callback function fo the LCD cursor blinking timer
+ # @parm Bool clear - 1 == Clear the cursor rectangle; 0 == Draw the cursor rectangle
+ # @return void
+ public method cursor_timer_callback {clear} {
+ if {$clear} {
+ clear_cursor
+
+ # Reset the LCD cursor blinking timer
+ if {$diver_cfg(B) && $diver_cfg(C)} {
+ set cursor_timer [after [expr {int(1000 / $CURSOR_BLINK_FREQUENCY)}] [list $this cursor_timer_callback 0]]
+ }
+
+ } elseif {$diver_cfg(B) && $diver_cfg(C)} {
+ draw_cursor
+ }
+ }
+
+ ## Convert the specified DDRAM address into position in the LCD dot matrix
+ # @parm int ddram_address - Address to convert, must be be in interval [0;7f]!
+ # @return Int - The position [0;7f]
+ private method address_to_position {ddram_address} {
+ # Two lines display
+ if {$diver_cfg(N)} {
+ set position [expr {($ddram_address + $display_shift) % 0x40}]
+ if {$ddram_address >= 0x40} {
+ incr position 0x40
+ }
+
+ # One line display
+ } else {
+ set position [expr {($ddram_address + $display_shift) % 0x80}]
+ }
+
+ return $position
+ }
+
+ ## Start execution of the requested instruction
+ # @see new_state
+ # @parm List state - Port states ( 5 x {8 x bit} -- {bit0 bit1 bit2 ... bit7} )
+ # @return state - New port states modified by this device
+ # format is the same as parameter $state
+ private method commence_operations {_state} {
+ upvar $_state state
+
+ # Detect falling edge on signal E (Enable) & Completed data transfer (in case of 4-bit mode)
+ #+ --> Input instruction or data
+ if {$signal_E_prev && !$signal_E && !$diver_cfg(OMN)} {
+ # Manage Busy Flag
+ if {$diver_cfg(BF)} {
+ # Simulated execution times are disabled
+ if {$no_delays} {
+ # Clear the Busy Flag unconditionally
+ set diver_cfg(BF) 0
+ adjust_status_leds
+ write_to_log I [mc "Operation finished"]
+
+ # Simulated execution times are enabled
+ } else {
+ # Clear the Busy Flag if the execution time already passed
+ set current_time [$project get_run_statistics 0]
+ if {$current_time >= $time_of_completion} {
+ set diver_cfg(BF) 0
+ adjust_status_leds
+ write_to_log I [mc "Operation finished"]
+ }
+ }
+ }
+
+ # Write to log the last I/O error if there is one
+ if {$input_error} {
+ write_to_log E [mc "Input is corrupted: %s" $input_error_desc]
+ }
+
+ # Input an "regular" instruction (write to the IR)
+ if {!$signal_RS && !$signal_RW} {
+ set return_value -1
+
+ # Update the IR (Instruction Register)
+ set inst_reg $signal_D
+ update_entry_boxes
+
+ # Instruction: Set DDRAM Address (1 ADD ADD ADD | ADD ADD ADD ADD)
+ if {0x80 & $signal_D} {
+ inst_SetDDRAMAddress
+
+ # Instruction: Set CGRAM Address (0 1 ACG ACG | ACG ACG ACG ACG)
+ } elseif {0x40 & $signal_D} {
+ inst_SetCGRAMAddress
+
+ # Instruction: Function Set (0 0 1 DL | N F - -)
+ } elseif {0x20 & $signal_D} {
+ inst_FunctionSet
+
+ # Instruction: Cursor Or Display Shift (0 0 0 1 | S/C R/L - -)
+ } elseif {0x10 & $signal_D} {
+ inst_CursorOrDisplayShift
+
+ # Instruction: Display On Off Control (0 0 0 0 | 1 D C B)
+ } elseif {0x08 & $signal_D} {
+ inst_DisplayOnOffControl
+
+ # Instruction: Entry Mode Set (0 0 0 0 | 0 1 I/D S)
+ } elseif {0x04 & $signal_D} {
+ inst_EntryModeSet
+
+ # Instruction: Return Home (0 0 0 0 | 0 0 1 -)
+ } elseif {0x02 & $signal_D} {
+ inst_ReturnHome
+
+ # Instruction: Clear Display (0 0 0 0 | 0 0 0 1)
+ } elseif {0x01 & $signal_D} {
+ inst_ClearDisplay
+
+ # Code 0 -- Invalid instruction
+ } else {
+ write_to_log W [mc "Invalid instruction: %2Xh" $signal_D]
+ }
+
+ # Read Busy Flag And Address
+ } elseif {!$signal_RS && $signal_RW} {
+ set data_reg $signal_D
+ update_entry_boxes
+ inst_ReadBusyFlagAndAddress
+
+ # Write Data To CG Or DDRAM
+ } elseif {$signal_RS && !$signal_RW} {
+ set return_value -1
+
+ set data_reg $signal_D
+ update_entry_boxes
+ inst_WriteDataToCGOrDDRAM
+
+ # Read Data From CG Or DDRAM
+ } elseif {$signal_RS && $signal_RW} {
+ set data_reg $signal_D
+ update_entry_boxes
+ inst_ReadDataFromCGOrDDRAM
+ }
+ }
+
+ # Detect signal Enable & Read request & Ready state (not busy) & Data waiting to be send ($return_value)
+ #+ --> Output data
+ if {$signal_E && $signal_RW && !$diver_cfg(BF) && $return_value != -1} {
+
+ # 8-bit transfer mode
+ if {$diver_cfg(DL)} {
+ for {set i 3} {$i < 11} {incr i} {
+ set pp [which_port_pin $i]
+ if {[lindex $pp 0] != {-} && [lindex $pp 1] != {-}} {
+ lset state $pp [expr {($return_value & (1 << (10 - $i))) ? 1 : 0}]
+ }
+ }
+
+ # 4-bit transfer mode
+ } else {
+ if {$diver_cfg(OMN)} {
+ set bus_offset 10
+ } else {
+ set bus_offset 14
+ }
+ for {set i 7} {$i < 11} {incr i} {
+ set pp [which_port_pin $i]
+ if {[lindex $pp 0] != {-} && [lindex $pp 1] != {-}} {
+ lset state $pp [expr {($return_value & (1 << ($bus_offset - $i))) ? 1 : 0}]
+ }
+ }
+
+ # Invert flag "One More Nibble"
+ set diver_cfg(OMN) [expr {$diver_cfg(OMN) ? 0 : 1}]
+ adjust_status_leds
+ }
+ }
+ }
+
+
+ # ------------------------------------------------------------------
+ # VIRTUAL HW COMMON INTERFACE
+ # ------------------------------------------------------------------
+
+ ## Simulated MCU has been changed
+ # @return void
+ public method mcu_changed {} {
+ # Refresh lists of possible values in port selection ComboBoxes
+ set available_ports [concat - [$project pale_get_available_ports]]
+
+ # Configure the ComboBoxes
+ for {set i 0} {$i < 11} {incr i} {
+ $canvas_widget.cb_p$i configure -values $available_ports
+
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
+ $canvas_widget.cb_p$i current 0
+ set connection_port($i) {-}
+ }
+ }
+ }
+
+ ## Accept new state of ports
+ # @parm List state - Port states ( 5 x {8 x bit} -- {bit0 bit1 bit2 ... bit7} )
+ # @return state - New port states modified by this device
+ # format is the same as parameter $state
+ #
+ # Possible bit values:
+ # '|' - High frequency
+ # 'X' - Access to external memory
+ # '?' - No volatge
+ # '-' - Indeterminable value (some noise)
+ # '=' - High forced to low
+ # '0' - Logical 0
+ # '1' - Logical 1
+ public method new_state {_state} {
+ upvar $_state state
+
+ # Start execution of the last requested instruction. It's done this way in order to cope with
+ #+ multiple new_state invocations during the Virtual HW evaluation loop
+ if {$time_mark != [$project get_run_statistics 2]} {
+ commence_operations state
+ set time_mark [$project get_run_statistics 2]
+ set signal_E_prev $signal_E
+ }
+
+ # Reset last I/O error
+ set input_error 0
+ set input_error_desc {}
+
+ # Iterate over all I/O lines
+ for {set i 0} {$i < 11} {incr i} {
+ # Determinate index in the list of port states
+ set pp [which_port_pin $i]
+
+ # Not connected
+ if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
+ $canvas_widget itemconfigure $signal_label($i) -fill {#000000}
+ set signal_value {}
+ } else {
+ set signal_value [lindex $state $pp]
+ }
+
+ # Determinate the color for the PIN label
+ switch -- $signal_value {
+ {0} { ;# Logical 0
+ set label_color {#00FF00}
+ }
+ {1} { ;# Logical 1
+ set label_color {#FF0000}
+ }
+ {=} { ;# High forced to low
+ set label_color {#00FF00}
+ }
+ {?} { ;# No volatge
+ set label_color {#888888}
+ }
+ {} { ;# Not connected
+ set label_color {#000000}
+ }
+ default {
+ set label_color {#FF8800}
+ }
+ }
+
+ # Change color of the PIN label
+ $canvas_widget itemconfigure $signal_label($i) -fill $label_color
+
+ # Convert any possible I/O signal value to Boolean value
+ switch -- $signal_value {
+ {0} -
+ {1} {}
+ {=} {
+ set signal_value 0
+ }
+ default {
+ if {$diver_cfg(DL) || $i >= 7} {
+ set input_error 1
+ set input_error_desc [mc \
+ "Received an invalid input on signal %s" \
+ [lindex $SIGNAL_NAMES $i]
+ ]
+ set signal_value [expr {rand() > 0.5 ? 1 : 0}]
+ }
+ }
+ }
+
+ # Process the input
+ switch -- $i {
+ {0} {
+ # Signal Register Select
+ set signal_RS $signal_value
+ }
+ {1} {
+ # Signal Read/Write
+ set signal_RW $signal_value
+ }
+ {2} {
+ # Signal Enable
+ set signal_E $signal_value
+ }
+ {3} -
+ {4} -
+ {5} -
+ {6} -
+ {7} -
+ {8} -
+ {9} -
+ {10} { ;# 8-bit data bus
+
+ # Set received data to zero when the first bit is received
+ if {$i == 3 && !$diver_cfg(OMN)} {
+ set signal_D 0
+ }
+
+ # 8-bit transfer mode
+ if {$diver_cfg(DL) && !$signal_RW} {
+ set signal_D [expr {$signal_D | ($signal_value << (10 - $i))}]
+
+ # 4-bit transfer mode -- accept data on rising edge of signal E (Enable) from DB4..DB7
+ } elseif {!$signal_RW && $signal_E_prev && !$signal_E && $i < 7} {
+ if {$diver_cfg(OMN)} {
+ set signal_D [expr {$signal_D | ($signal_value << (6 - $i))}]
+ } else {
+ set signal_D [expr {$signal_D | ($signal_value << (10 - $i))}]
+ }
+
+ if {$i == 6} {
+ if {$diver_cfg(OMN)} {
+ set diver_cfg(OMN) 0
+ write_to_log I [mc "Receiving the Less Significant Nibble (%02Xh)" [expr {$signal_D & 0x0F}]]
+ } else {
+ set diver_cfg(OMN) 1
+ write_to_log I [mc "Receiving the More Significant Nibble (%02Xh)" [expr {$signal_D & 0xF0}]]
+ }
+ adjust_status_leds
+ }
+ }
+ }
+ }
+ }
+ }
+
+ ## Withdraw panel window from the screen
+ # @return void
+ public method withdraw_window {} {
+ wm withdraw $win
+ }
+
+ ## Get panel configuration list (usable with method "set_config")
+ # @return List - configuration list
+ public method get_config {} {
+ # Get DDRAM hex editor windows parameters is it's visible
+ if {$ddram_hexeditor != {}} {
+ set ddram_window_params [list 1 [wm geometry $win.ddram_window]]
+ }
+ # Get CGRAM hex editor windows parameters is it's visible
+ if {$cgram_hexeditor != {}} {
+ set cgram_window_params [list 1 [wm geometry $win.cgram_window]]
+ }
+
+ # Formulate the result
+ return [list \
+ $class_name \
+ [list \
+ $display_height \
+ $display_width \
+ [wm geometry $win] \
+ [array get connection_port] \
+ [array get connection_pin] \
+ [$canvas_widget.usr_note get] \
+ $visible_lr \
+ $visible_ud \
+ $rom_code \
+ $lcd_char_size \
+ $ignore_errors \
+ $no_delays \
+ [wm geometry $win.log_window] \
+ [wm state $win.log_window] \
+ $ddram_window_params \
+ $cgram_window_params \
+ $log_enabled \
+ $keep_win_on_top \
+ ] \
+ ]
+ }
+
+ ## Set panel configuration from list gained from method "get_config"
+ # @parm List state - Configuration list
+ # @return void
+ public method set_config {state} {
+ if {[catch {
+ # Determinate whether we are re-configuring already operating
+ #+ HD44780 simulator or creating a new one from scratch
+ set new_instance [expr {![winfo exists $win]}]
+
+ # Set display width (number of columns) and height (number of rows)
+ if {$new_instance} {
+ set display_height [lindex $state 0]
+ set display_width [lindex $state 1]
+ }
+
+ # Load connections to the MCU (port numbers)
+ if {[llength [lindex $state 3]]} {
+ array set connection_port [lindex $state 3]
+ } else {
+ array set connection_port {0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 -}
+ }
+
+ # Load connections to the MCU (port pin numbers)
+ if {[llength [lindex $state 4]]} {
+ array set connection_pin [lindex $state 4]
+ } else {
+ array set connection_pin {0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 -}
+ }
+
+ # Set flags: "Right part visible" and "Bottom part visible"
+ if {[string length [lindex $state 6]]} {
+ set visible_lr [lindex $state 6]
+ }
+ if {[string length [lindex $state 7]]} {
+ set visible_ud [lindex $state 7]
+ }
+
+ # Set font to use (specification of character patterns not their size)
+ if {[string length [lindex $state 8]]} {
+ set rom_code [lindex $state 8]
+ }
+
+ # Set font size to use (could be 5×8 or 5×10)
+ if {[string length [lindex $state 9]]} {
+ set lcd_char_size [lindex $state 9]
+
+ # Validate value of character size parameter
+ if {$display_height == 2 && $lcd_char_size == 1} {
+ set lcd_char_size 0
+ }
+ }
+
+ # Flags: "Ignore errors" and "Disable delays"
+ if {[string length [lindex $state 10]]} {
+ set ignore_errors [lindex $state 10]
+ }
+ if {[string length [lindex $state 11]]} {
+ set no_delays [lindex $state 11]
+ }
+
+ # Log window parameters
+ set log_window_geometry [lindex $state 12]
+ set log_window_state [lindex $state 13]
+
+ # DDRAM and CGRAM hex editor windows parameters
+ if {[string length [lindex $state 14]]} {
+ set ddram_window_params [lindex $state 14]
+ }
+ if {[string length [lindex $state 15]]} {
+ set cgram_window_params [lindex $state 15]
+ }
+
+ # Enable or disable logging of events
+ if {[string length [lindex $state 16]]} {
+ set log_enabled [lindex $state 16]
+ }
+
+ if {[lindex $state 17] != {}} {
+ set keep_win_on_top [lindex $state 17]
+ }
+
+ # Fail
+ }]} then {
+ puts stderr "Unable to load configuration for $class_name"
+ return 0
+
+ # Success
+ } else {
+ if {$new_instance} {
+ # Create panel GUI
+ create_gui
+ create_log $log_window_geometry
+ reset_hd44780
+ mcu_changed
+
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1
+ }
+
+ # Display the log window
+ if {$log_window_state == {normal}} {
+ show_log
+ }
+
+ # Initialize HD44780 simulator
+ clear_cgram
+ on_off [$project pale_is_enabled]
+ }
+
+ # Restore window geometry
+ if {[string length [lindex $state 2]]} {
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [regsub {\+\d+\+\d+} [wm geometry $win] {}]]
+ }
+
+ # Load user note
+ if {[string length [lindex $state 5]]} {
+ $canvas_widget.usr_note delete 0
+ $canvas_widget.usr_note insert 0 [lindex $state 5]
+ }
+
+ # Hide some parts of the window accordingly to the settings
+ if {!$visible_lr} {
+ set visible_lr 1
+ show_hide1
+ }
+ if {!$visible_ud} {
+ set visible_ud 1
+ show_hide0
+ }
+
+ # Adjust log enable/disable checkbox
+ if {$log_enabled} {
+ $log_on_off_chbut select
+ } else {
+ $log_on_off_chbut deselect
+ }
+
+ # Restore/Set state of ComboBoxes
+ for {set i 0} {$i < 11} {incr i} {
+ ## PIN
+ set pin $connection_pin($i)
+ if {$pin != {-}} {
+ set pin [expr {7 - $pin}]
+ }
+ set idx [lsearch -ascii -exact \
+ [$canvas_widget.cb_b$i cget -values] \
+ $pin \
+ ]
+ if {$idx == -1} {
+ set idx 0
+ }
+ $canvas_widget.cb_b$i current $idx
+
+ ## PORT
+ set idx [lsearch -ascii -exact \
+ [$canvas_widget.cb_p$i cget -values] \
+ $connection_port($i) \
+ ]
+ if {$idx == -1} {
+ set idx 0
+ }
+ if {[llength [$canvas_widget.cb_p$i cget -values]]} {
+ $canvas_widget.cb_p$i current $idx
+ }
+ }
+
+ # Adjust display appearance to fit the current character size
+ accept_new_character_size
+
+ # Adjust internal logic and the rest of PALE
+ evaluete_enaged_pins
+ $project pale_reevaluate_IO
+
+ # Display the DDRAM and CGRAM hex editor windows
+ if {$new_instance} {
+ if {[lindex $ddram_window_params 0]} {
+ show_ddram
+ }
+ if {[lindex $cgram_window_params 0]} {
+ show_cgram
+ }
+ }
+
+ # Accept new state of ports
+ if {$new_instance} {
+ set state [$project pale_get_true_state]
+ new_state state
+ }
+
+ # Finalize ...
+ clear_modified
+ update
+
+ return 1
+ }
+ }
+
+ ## Simulated MCU has been reset
+ # @return void
+ public method reset {} {
+ # There is nothing special what has to be done here, the
+ #+ controller, HD44780, has its own reset mechanism independent
+ #+ on the simulated MCU
+ }
+
+
+ # ------------------------------------------------------------------
+ # VIRTUAL HW COMMON INTERFACE -- CALLED FROM THE BASE CLASS
+ # ------------------------------------------------------------------
+
+ ## This method is called before configuration menu invocation
+ # @return void
+ public method config_menu_special {} {
+ set ::${class_name}::font_id $rom_code
+ set ::${class_name}::char_size $lcd_char_size
+ set ::${class_name}::_ignore_errors $ignore_errors
+ set ::${class_name}::_no_delays $no_delays
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
+ }
+
+ ## This method is called after configuration menu is created
+ # @return void
+ public method create_config_menu_special {} {
+ # Changing character size is allowed only for 1 line displays
+ if {$display_height == 2} {
+ set state {disabled}
+ } else {
+ set state {normal}
+ }
+ $conf_menu entryconfigure [mc "Set character size"] -state $state
+ }
+
+ ## This method is called to fill in the help dialog
+ # @parm Widget text_widget - Target text widget
+ # @return void
+ #
+ # Note: There is defined text tag "tag_bold" in the text widget
+ public method show_help_special {text_widget} {
+ $text_widget insert insert [mc "LCD display controled by HD44780 driver\n\n"]
+
+ $text_widget insert insert [mc "This tool simulates a HD44780 character LCD of any size up to 2 rows and 64 columns. There are 11 lines serving as interface for the MCU, ``E'', ``RS'', ``R/W'' and ``D0''..``D7''. User can view end modify content of display data RAM (DDRAM), character generator RAM (CGRAM) and certain HD44780 registers: instruction register (IR), data register (DR), address counter (AC) and display shift, these registers are shown hexadecimal. User can also view content of character generator ROM (CGROM) and set font to use. All of the driver command are fully supported, all important events occurring in the simulated driver (HD44780) are recorded in the log. User can also see and modify certain HD44780 configuration flags like ``B'', ``S'', ``D'' and so on."]
+ }
+
+ ## This method is called before panel window closure
+ # @return void
+ public method close_window_special {} {
+ }
+
+ ## Commit new on/off state
+ # @return void
+ public method on_off_special {} {
+ # Boot-up the controller, it takes 10ms according to manual
+ if {[$project pale_is_enabled]} {
+ # Clear CGRAM and reset the code
+ clear_cgram
+ reset_hd44780
+
+ # Update log
+ write_to_log I [mc "Starting the HD44780 boot-up sequence."]
+
+ # Ensure that that the LCD dot matrix is clear
+ clear_display
+
+ # On a real HW would take about 10 ms
+ engage_core 10000
+ }
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/leddisplay.tcl b/lib/pale/leddisplay.tcl
index 55b13a5..44cc7ad 100755..100644
--- a/lib/pale/leddisplay.tcl
+++ b/lib/pale/leddisplay.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 _LEDDISPLAY_TCL ] } {
+set _LEDDISPLAY_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -36,7 +41,11 @@ class LedDisplay {
inherit VirtualHWComponent
# Font: Font to be used in the panel -- bold
- common cb_font [font create -weight bold -size -10 -family {helvetica}]
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
+ ]
common COMPONENT_NAME "LED Display" ;# Name of this component
common CLASS_NAME "LedDisplay" ;# Name of this class
common COMPONENT_ICON {leddisplay} ;# Icon for this panel (16x16)
@@ -53,16 +62,17 @@ class LedDisplay {
{#5555AA #0000FF}
{#AA55AA #8800FF}
}
+ common DIMMED_COLOR {#BBBBBB}
# Configuration menu
common CONFMENU {
{cascade {Common electrode} 7 "diode" .ca false 1 {
{radiobutton "Common anode" {}
::LedDisplay::cfg_common_anode 1
- "common_electrode_chanded" 7 ""}
- {radiobutton "Common catode" {}
+ "common_electrode_changed" 7 ""}
+ {radiobutton "Common cathode" {}
::LedDisplay::cfg_common_anode 0
- "common_electrode_chanded" 7 ""}
+ "common_electrode_changed" 7 ""}
}}
{cascade {Color} 0 "colorize" .color false 1 {
{radiobutton "Red" {}
@@ -92,15 +102,20 @@ class LedDisplay {
"Save configuration into a file"}
{command {Load configuration} {} 0 "load_from" {fileopen}
"Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::LedDisplay::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
}
private variable conf_led_color {red} ;# Color: Selected color for LED's
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
private variable leds ;# Array of CanvasObject (polygon): leds(segment_num) --> LED polygon
private variable wires ;# Array of CanvasObject (line): Wire connection LED with uC
private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
private variable connection_pin ;# Array of Int: Index is key number, value is bit number or {-}
- private variable common_anode 1 ;# Bool: 1 == common anode; 0 == common catode
+ private variable common_anode 1 ;# Bool: 1 == common anode; 0 == common cathode
# ------------------------------------------------------------------
# INTERNAL APPLICATION LOGIC
@@ -148,7 +163,7 @@ class LedDisplay {
# @return void
private method create_gui {} {
# Create panel window and canvas widget
- set win [toplevel .leddisplay$count -class $component_name -bg {#EEEEEE}]
+ set win [toplevel .leddisplay$count -class $component_name -bg ${::COMMON_BG_COLOR}]
set canvas_widget [canvas $win.canvas \
-bg white -width 0 -height 0 \
-highlightthickness 0 \
@@ -231,7 +246,7 @@ class LedDisplay {
-text [mc "PORT"] \
-font $cb_font \
-anchor ne
- $canvas_widget create text 50 5 \
+ $canvas_widget create text 42 5 \
-text [mc "BIT"] \
-font $cb_font \
-anchor nw
@@ -239,18 +254,18 @@ class LedDisplay {
-text [mc "PORT"] \
-font $cb_font \
-anchor ne
- $canvas_widget create text 210 5\
+ $canvas_widget create text 202 5\
-text [mc "BIT"] \
-font $cb_font \
-anchor nw
- $canvas_widget create text 5 155\
- -text [mc "Note"] \
- -font $cb_font \
- -anchor w
- $canvas_widget create window 40 155 \
+ $canvas_widget create text 35 160 \
+ -text [mc "Note"] \
+ -font $cb_font \
+ -anchor e
+ $canvas_widget create window 40 160 \
-window [ttk::entry $canvas_widget.usr_note \
- -validate all \
+ -validate key \
-validatecommand "$this set_modified" \
] \
-width 180 -anchor w
@@ -261,14 +276,25 @@ class LedDisplay {
pack $canvas_widget -fill both -expand 1
# Set window parameters
- wm geometry $win =230x170
+ wm minsize $win 230 175
wm iconphoto $win ::ICONS::16::$component_icon
- wm title $win "[mc $component_name] - [string trim $project {:}] - MCU 8051 IDE"
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this close_window"
bindtags $win [list $win Toplevel all .]
}
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $LedDisplay::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
## Reconnect the specified LED to another port pin
# @parm Int i - LED number (0..7)
# @return void
@@ -282,20 +308,22 @@ class LedDisplay {
# Change state of the device
if {$drawing_on} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
# Set flag modified
set_modified
}
- ## LED's common electrode chanded
+ ## LED's common electrode changed
# @return void
- public method common_electrode_chanded {} {
+ public method common_electrode_changed {} {
set common_anode ${::LedDisplay::cfg_common_anode}
if {$drawing_on} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
set_modified
}
@@ -306,7 +334,8 @@ class LedDisplay {
set conf_led_color ${::LedDisplay::color}
if {$drawing_on} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
set_modified
}
@@ -404,8 +433,8 @@ class LedDisplay {
}
# Draw
- set leds($i) [$canvas_widget create polygon \
- $coordinates -width 0 -fill #888888 \
+ set leds($i) [$canvas_widget create polygon \
+ $coordinates -width 0 -fill $DIMMED_COLOR \
]
}
@@ -414,7 +443,7 @@ class LedDisplay {
set leds(7) [$canvas_widget create oval \
[expr {49 + $x}] [expr {77 + $y}] \
[expr {58 + $x}] [expr {86 + $y}] \
- -width 0 -fill #888888 \
+ -width 0 -fill $DIMMED_COLOR \
]
# Print segment labels
@@ -452,12 +481,12 @@ class LedDisplay {
# @return void
public method mcu_changed {} {
# Refresh lists of possible values in port selection ComboBoxes
- set avaliable_ports [concat - [$project pale_get_avaliable_ports]]
+ set available_ports [concat - [$project pale_get_available_ports]]
for {set i 0} {$i < 8} {incr i} {
- $canvas_widget.cb_p$i configure -values $avaliable_ports
+ $canvas_widget.cb_p$i configure -values $available_ports
- if {[lsearch -ascii -exact $avaliable_ports $connection_port($i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
$canvas_widget.cb_p$i current 0
set connection_port($i) {-}
}
@@ -472,11 +501,13 @@ class LedDisplay {
# '|' - High frequency
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
# '0' - Logical 0
# '1' - Logical 1
- public method new_state {state} {
+ public method new_state {_state} {
+ upvar $_state state
+
# Determinate index of LED color in list COLORS
set color_idx [lsearch -ascii -exact \
{red orange yellow green blue purple} \
@@ -490,7 +521,7 @@ class LedDisplay {
# Not connected
if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
- $canvas_widget itemconfigure $leds($i) -fill {#888888}
+ $canvas_widget itemconfigure $leds($i) -fill $DIMMED_COLOR
$canvas_widget itemconfigure $wires($i) -fill {#000000}
continue
}
@@ -500,7 +531,7 @@ class LedDisplay {
{0} { ;# Logical 0
if {$common_anode} {
set segment_color {2}
- } {
+ } else {
set segment_color {0}
}
set wire_color {#00FF00}
@@ -508,7 +539,7 @@ class LedDisplay {
{1} { ;# Logical 1
if {$common_anode} {
set segment_color {0}
- } {
+ } else {
set segment_color {2}
}
set wire_color {#FF0000}
@@ -533,8 +564,8 @@ class LedDisplay {
# Determinate segment color (true color, not just number)
if {!$segment_color} {
- set segment_color {#888888}
- } {
+ set segment_color $DIMMED_COLOR
+ } else {
incr segment_color -1
set segment_color [lindex $COLORS [list $color_idx $segment_color]]
}
@@ -563,6 +594,7 @@ class LedDisplay {
[$canvas_widget.usr_note get] \
$conf_led_color \
$common_anode \
+ $keep_win_on_top \
] \
]
}
@@ -578,7 +610,7 @@ class LedDisplay {
# Restore window geometry
if {[string length [lindex $state 2]]} {
- wm geometry $win [lindex $state 2]
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm minsize $win] {x}]]
}
# Load user note
@@ -592,6 +624,13 @@ class LedDisplay {
set common_anode 1
}
+ if {[lindex $state 6] != {}} {
+ set keep_win_on_top [lindex $state 6]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
# Restore state of ComboBoxes
for {set i 0} {$i < 8} {incr i} {
## PIN
@@ -620,12 +659,13 @@ class LedDisplay {
}
# Accept new state of ports
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
update
# Fail
}]} then {
- puts "Unable to load config for $class_name"
+ puts "Unable to load configuration for $class_name"
return 0
# Success
@@ -638,7 +678,8 @@ class LedDisplay {
## Simulated MCU has been reseted
# @return void
public method reset {} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
@@ -651,6 +692,7 @@ class LedDisplay {
public method config_menu_special {} {
set ::${class_name}::color $conf_led_color
set ::${class_name}::cfg_common_anode $common_anode
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
}
## This method is called after configuration menu has beed created
@@ -669,7 +711,7 @@ class LedDisplay {
#
# Note: There is defined text tag "tag_bold" in the text widget
public method show_help_special {text_widget} {
- $text_widget insert insert [mc "Virtual LED display with common anode (default) or catode. Each segment can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes on the bottom of the panel. Panel configuration can be saved to a file (with extension vhc). And can be loaded from that file later.\n\n"]
+ $text_widget insert insert [mc "Virtual LED display with common anode (default) or cathode. Each segment can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes on the bottom of the panel. Panel configuration can be saved to a file with extension vhc, and can be loaded from that file later.\n\n"]
set color_idx [lsearch -ascii -exact \
{red orange yellow green blue purple} \
@@ -679,7 +721,7 @@ class LedDisplay {
$text_widget insert insert [mc "LED states:"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
$text_widget insert insert [mc "\n "]
- $text_widget window create insert -pady 1 -create "frame $text_widget.f0 -bd 1 -width 14 -height 16 -bg #888888"
+ $text_widget window create insert -pady 1 -create "frame $text_widget.f0 -bd 1 -width 14 -height 16 -bg $DIMMED_COLOR"
$text_widget insert insert [mc " Off\n "]
$text_widget window create insert -pady 1 -create "frame $text_widget.f1 -bd 1 -width 14 -height 16 -bg [lindex $COLORS [list $color_idx 0]]"
$text_widget insert insert [mc " Fast blinking\n "]
@@ -700,8 +742,13 @@ class LedDisplay {
$canvas_widget itemconfigure $leds($i) -fill {#888888}
$canvas_widget itemconfigure $wires($i) -fill {#000000}
}
- } {
- new_state [$project pale_get_true_state]
+ } else {
+ set state [$project pale_get_true_state]
+ new_state state
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/ledmatrix.tcl b/lib/pale/ledmatrix.tcl
index b739f53..1be1718 100755..100644
--- a/lib/pale/ledmatrix.tcl
+++ b/lib/pale/ledmatrix.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 _LEDMATRIX_TCL ] } {
+set _LEDMATRIX_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -36,8 +41,12 @@ class LedMatrix {
inherit VirtualHWComponent
# Font: Font to be used in the panel -- bold
- common cb_font [font create -weight bold -size -10 -family {helvetica}]
- common COMPONENT_NAME "LED matrix" ;# Name of this component
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
+ ]
+ common COMPONENT_NAME "LED Matrix" ;# Name of this component
common CLASS_NAME "LedMatrix" ;# Name of this class
common COMPONENT_ICON {ledmatrix} ;# Icon for this panel (16x16)
@@ -135,7 +144,7 @@ class LedMatrix {
}}
{separator}
{command {All fade out} {} 0 "dim_all" {ledgray}
- "Dim all leds"}
+ "Dim all LEDs"}
{command {Show help} {} 5 "show_help" {help}
"Show brief help"}
{separator}
@@ -143,14 +152,19 @@ class LedMatrix {
"Save configuration into a file"}
{command {Load configuration} {} 0 "load_from" {fileopen}
"Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::LedMatrix::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
}
private variable conf_dim_interval 50 ;# Int: Interval to dim LED's in instruction cycles
private variable conf_matrix_mapping 0 ;# Int: Type of matrix mapping: 0 == Random; 1 == Row; 2 == Column
private variable conf_led_color {red} ;# Color: Selected color for LED's
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
## List of Bool: LED light up condition
- # Index 0 - Row must be in: 1 == log. 1; 0 = log. 0
- # Index 1 - Column must be in: 1 == log. 1; 0 = log. 0
+ # Index 0 - Row must be in: 1 == log. 1; 0 == log. 0
+ # Index 1 - Column must be in: 1 == log. 1; 0 == log. 0
private variable conf_led_cond {0 0}
private variable leds ;# Array of CanvasObject (image): LED's, leds(row,column)
private variable col ;# Array of CanvasObject (line): Column wires
@@ -216,6 +230,17 @@ class LedMatrix {
destroy $win
}
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $LedMatrix::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
## Reconnect the specified wire to another port pin
# @parm Char col_or_row - 'C' => Column; 'R' => Row
# @parm Int i - Wire number (0..7)
@@ -229,7 +254,7 @@ class LedMatrix {
set connection_pin(R$i) [expr {7 - $connection_pin(R$i)}]
}
# Column
- } {
+ } else {
set connection_port(C$i) [$canvas_widget.cb_c_p$i get]
set connection_pin(C$i) [$canvas_widget.cb_c_b$i get]
if {$connection_pin(C$i) != {-}} {
@@ -239,7 +264,8 @@ class LedMatrix {
# Change state of the device
if {$drawing_on} {
- new_state [$project pale_get_true_state] 1
+ set state [$project pale_get_true_state]
+ new_state state 1
}
# Set flag modified
@@ -272,7 +298,8 @@ class LedMatrix {
# Change state of the device
if {$drawing_on} {
- new_state [$project pale_get_true_state] 1
+ set state [$project pale_get_true_state]
+ new_state state 1
}
# Set flag modified
@@ -285,12 +312,13 @@ class LedMatrix {
set conf_led_cond ${::LedMatrix::cond}
if {$drawing_on} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
set_modified
}
- ## Dim all LED's and reset their prevoius states
+ ## Dim all LED's and reset their previous states
# @return void
public method dim_all {} {
for {set i 0} {$i < 8} {incr i} {
@@ -308,7 +336,7 @@ class LedMatrix {
# @return void
private method create_gui {} {
# Create panel window and canvas widget
- set win [toplevel .ledmatrix$count -class $component_name -bg {#EEEEEE}]
+ set win [toplevel .ledmatrix$count -class $component_name -bg ${::COMMON_BG_COLOR}]
set canvas_widget [canvas $win.canvas \
-bg white -width 0 -height 0 \
-highlightthickness 0 \
@@ -318,7 +346,7 @@ class LedMatrix {
set led_sep 15
set sep 25
set y_0 100
- set x_0 85
+ set x_0 90
set y_1 [expr {$y_0 + 10}]
set x_1 [expr {$x_0 + 35}]
@@ -466,13 +494,13 @@ class LedMatrix {
-font $cb_font \
-anchor nw
- $canvas_widget create text 5 273 \
+ $canvas_widget create text 35 278 \
-text [mc "Note"] \
-font $cb_font \
- -anchor w
- $canvas_widget create window 40 273 \
+ -anchor e
+ $canvas_widget create window 40 278 \
-window [ttk::entry $canvas_widget.usr_note \
- -validate all \
+ -validate key \
-validatecommand "$this set_modified" \
] \
-width 230 -anchor w
@@ -490,7 +518,7 @@ class LedMatrix {
-text [mc "Turn HW simulation on/off"]
setStatusTip -widget $start_stop_button -text [mc "Turn HW simulation on/off"]
bind $start_stop_button <Button-3> "$this on_off_button_press; break"
- $canvas_widget create window 2 20 -window $start_stop_button -anchor sw
+ $canvas_widget create window 2 22 -window $start_stop_button -anchor sw
bindtags $start_stop_button [list $start_stop_button TButton all .]
# Create configuration menu button
@@ -500,16 +528,16 @@ class LedMatrix {
-command "$this config_menu" \
]
setStatusTip -widget $conf_button -text [mc "Configure"]
- $canvas_widget create window 2 20 -window $conf_button -anchor nw
+ $canvas_widget create window 2 22 -window $conf_button -anchor nw
bindtags $conf_button [list $conf_button TButton all .]
# Pack canvas
pack $canvas_widget -fill both -expand 1
# Set window parameters
- wm geometry $win =275x285
+ wm minsize $win 280 295
wm iconphoto $win ::ICONS::16::$component_icon
- wm title $win "[mc $component_name] - [string trim $project {:}] - MCU 8051 IDE"
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this close_window"
bindtags $win [list $win Toplevel all .]
@@ -538,17 +566,17 @@ class LedMatrix {
# @return void
public method mcu_changed {} {
# Refresh lists of possible values in port selection ComboBoxes
- set avaliable_ports [concat - [$project pale_get_avaliable_ports]]
+ set available_ports [concat - [$project pale_get_available_ports]]
for {set i 0} {$i < 8} {incr i} {
- $canvas_widget.cb_r_p$i configure -values $avaliable_ports
- $canvas_widget.cb_c_p$i configure -values $avaliable_ports
+ $canvas_widget.cb_r_p$i configure -values $available_ports
+ $canvas_widget.cb_c_p$i configure -values $available_ports
- if {[lsearch -ascii -exact $avaliable_ports $connection_port(R$i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port(R$i)] == -1} {
$canvas_widget.cb_r_p$i current 0
set connection_port(R$i) {-}
}
- if {[lsearch -ascii -exact $avaliable_ports $connection_port(C$i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port(C$i)] == -1} {
$canvas_widget.cb_c_p$i current 0
set connection_port(C$i) {-}
}
@@ -557,18 +585,20 @@ class LedMatrix {
## Accept new state of ports
# @parm List state - Port states ( 5 x {8 x bit} -- {bit0 bit1 bit2 ... bit7} )
- # @parm Bool preserve_prvious_state = 0 - Preserve previous state of component
+ # @parm Bool preserve_prvious_state=0 - Preserve previous state of component
# @return void
#
# Possible bit values:
# '|' - High frequency
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
# '0' - Logical 0
# '1' - Logical 1
- public method new_state {state {preserve_prvious_state 0}} {
+ public method new_state {_state {preserve_prvious_state 0}} {
+ upvar $_state state
+
# Change column wire colors
for {set i 0} {$i < 8} {incr i} {
# Determinate index in the list of port states
@@ -668,22 +698,22 @@ class LedMatrix {
}
# Determinate row state in this way:
- #+ row_state = 0 => Dim
- #+ row_state = 1 => Half dim
- #+ row_state = 2 => Brighten
+ #+ row_state == 0 => Dim
+ #+ row_state == 1 => Half dim
+ #+ row_state == 2 => Brighten
set row_state [lindex $state $pp]
switch -- $row_state {
{0} { ;# Logical 0
if {[lindex $conf_led_cond 0]} {
set row_state 0
- } {
+ } else {
set row_state 2
}
}
{1} { ;# Logical 1
if {[lindex $conf_led_cond 0]} {
set row_state 2
- } {
+ } else {
set row_state 0
}
}
@@ -717,14 +747,14 @@ class LedMatrix {
{0} { ;# Logical 0
if {[lindex $conf_led_cond 1]} {
set image 0 ;# ledgray
- } {
+ } else {
set image 1 ;# shining LED
}
}
{1} { ;# Logical 1
if {[lindex $conf_led_cond 1]} {
set image 1 ;# shining LED
- } {
+ } else {
set image 0 ;# ledgray
}
}
@@ -831,6 +861,7 @@ class LedMatrix {
$conf_dim_interval \
$conf_led_cond \
$conf_matrix_mapping \
+ $keep_win_on_top \
] \
]
}
@@ -846,7 +877,7 @@ class LedMatrix {
# Restore window geometry
if {[string length [lindex $state 2]]} {
- wm geometry $win [lindex $state 2]
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm minsize $win] {x}]]
}
# Load user note
@@ -863,6 +894,13 @@ class LedMatrix {
set conf_matrix_mapping 0
}
+ if {[lindex $state 8] != {}} {
+ set keep_win_on_top [lindex $state 8]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
# Restore state of ComboBoxes
foreach foo {R C} bar {r c} {
for {set i 0} {$i < 8} {incr i} {
@@ -893,12 +931,13 @@ class LedMatrix {
}
# Accept new state of ports
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
update
# Fail
}]} then {
- puts "Unable to load config for $class_name"
+ puts "Unable to load configuration for $class_name"
return 0
# Success
@@ -912,7 +951,8 @@ class LedMatrix {
# @return void
public method reset {} {
dim_all
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
@@ -927,6 +967,7 @@ class LedMatrix {
set ::${class_name}::matrix_mapping $conf_matrix_mapping
set ::${class_name}::color $conf_led_color
set ::${class_name}::cond $conf_led_cond
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
}
## This method is called after configuration menu has beed created
@@ -945,7 +986,7 @@ class LedMatrix {
#
# Note: There is defined text tag "tag_bold" in the text widget
public method show_help_special {text_widget} {
- $text_widget insert insert [mc "This tool consists of 64 LED's. Each of them can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes. Panel configuration can be saved to a file (with extension vhc). And can be loaded from that file later. Condition on which a LED lights up and LED colors are configurable. Also fade out interval is configurable.\n\n"]
+ $text_widget insert insert [mc "This tool consists of 64 LED's. Each of them can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes. Panel configuration can be saved to a file with extension vhc, and can be loaded from that file later. Condition on which a LED lights up and LED colors are configurable. Also fade out interval is configurable.\n\n"]
$text_widget insert insert [mc "LED states:"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
@@ -975,8 +1016,13 @@ class LedMatrix {
-image ::ICONS::16::ledgray
}
}
- } {
- new_state [$project pale_get_true_state] 1
+ } else {
+ set state [$project pale_get_true_state]
+ new_state state 1
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/ledpanel.tcl b/lib/pale/ledpanel.tcl
index a05bb79..a39799f 100755..100644
--- a/lib/pale/ledpanel.tcl
+++ b/lib/pale/ledpanel.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 _LEDPANEL_TCL ] } {
+set _LEDPANEL_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -36,8 +41,12 @@ class LedPanel {
inherit VirtualHWComponent
# Font: Font to be used in the panel -- bold
- common cb_font [font create -weight bold -size -10 -family {helvetica}]
- common COMPONENT_NAME "LED panel" ;# Name of this component
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
+ ]
+ common COMPONENT_NAME "LED Panel" ;# Name of this component
common CLASS_NAME "LedPanel" ;# Name of this class
common COMPONENT_ICON {ledpanel} ;# Icon for this panel (16x16)
@@ -71,9 +80,14 @@ class LedPanel {
"Save configuration into a file"}
{command {Load configuration} {} 0 "load_from" {fileopen}
"Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::LedPanel::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
}
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
private variable conf_led_color {red} ;# Color: Selected color for LED's
private variable leds ;# Array of CanvasObject (image): LED's
private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
@@ -122,6 +136,17 @@ class LedPanel {
destroy $win
}
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $LedPanel::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
## Reconnect the specified LED to another port pin
# @parm Int i - LED number (0..7)
# @return void
@@ -135,7 +160,8 @@ class LedPanel {
# Change state of the device
if {$drawing_on} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
# Set flag modified
@@ -148,7 +174,8 @@ class LedPanel {
set conf_led_color ${::LedPanel::color}
if {$drawing_on} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
set_modified
}
@@ -157,7 +184,7 @@ class LedPanel {
# @return void
private method create_gui {} {
# Create panel window and canvas widget
- set win [toplevel .ledpanel$count -class $component_name -bg {#EEEEEE}]
+ set win [toplevel .ledpanel$count -class $component_name -bg ${::COMMON_BG_COLOR}]
set canvas_widget [canvas $win.canvas \
-bg white -width 0 -height 0 \
-highlightthickness 0 \
@@ -167,7 +194,7 @@ class LedPanel {
set led_y 35
set cb_p_y 65
set cb_b_y 85
- set usr_n_y 105
+ set usr_n_y 110
set x 50
$canvas_widget create text 5 $cb_p_y \
-text [mc "PORT"] \
@@ -177,16 +204,16 @@ class LedPanel {
-text [mc "BIT"] \
-font $cb_font \
-anchor w
- $canvas_widget create text 5 $usr_n_y \
+ $canvas_widget create text 30 $usr_n_y \
-text [mc "Note"] \
-font $cb_font \
- -anchor w
- $canvas_widget create window 208 $usr_n_y \
+ -anchor e
+ $canvas_widget create window 35 $usr_n_y \
-window [ttk::entry $canvas_widget.usr_note \
- -validate all \
+ -validate key \
-validatecommand "$this set_modified" \
] \
- -width 330
+ -width 330 -anchor w
bindtags $canvas_widget.usr_note \
[list $canvas_widget.usr_note TEntry $win all .]
@@ -253,9 +280,9 @@ class LedPanel {
pack $canvas_widget -fill both -expand 1
# Set window parameters
- wm geometry $win =380x120
+ wm minsize $win 380 130
wm iconphoto $win ::ICONS::16::$component_icon
- wm title $win "[mc $component_name] - [string trim $project {:}] - MCU 8051 IDE"
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this close_window"
bindtags $win [list $win Toplevel all .]
@@ -332,12 +359,12 @@ class LedPanel {
# @return void
public method mcu_changed {} {
# Refresh lists of possible values in port selection ComboBoxes
- set avaliable_ports [concat - [$project pale_get_avaliable_ports]]
+ set available_ports [concat - [$project pale_get_available_ports]]
for {set i 0} {$i < 8} {incr i} {
- $canvas_widget.cb_p$i configure -values $avaliable_ports
+ $canvas_widget.cb_p$i configure -values $available_ports
- if {[lsearch -ascii -exact $avaliable_ports $connection_port($i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
$canvas_widget.cb_p$i current 0
set connection_port($i) {-}
}
@@ -352,11 +379,13 @@ class LedPanel {
# '|' - High frequency
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
# '0' - Logical 0
# '1' - Logical 1
- public method new_state {state} {
+ public method new_state {_state} {
+ upvar $_state state
+
for {set i 0} {$i < 8} {incr i} {
# Determinate index in the list of port states
set pp [which_port_pin $i]
@@ -409,6 +438,7 @@ class LedPanel {
[wm geometry $win] \
[$canvas_widget.usr_note get] \
$conf_led_color \
+ $keep_win_on_top \
] \
]
}
@@ -424,7 +454,7 @@ class LedPanel {
# Restore window geometry
if {[string length [lindex $state 2]]} {
- wm geometry $win [lindex $state 2]
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm minsize $win] {x}]]
}
# Load user note
@@ -434,6 +464,13 @@ class LedPanel {
# Restore LED's configuration
set conf_led_color [lindex $state 4]
+ if {[lindex $state 5] != {}} {
+ set keep_win_on_top [lindex $state 5]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
# Restore state of ComboBoxes
for {set i 0} {$i < 8} {incr i} {
## PIN
@@ -462,12 +499,13 @@ class LedPanel {
}
# Accept new state of ports
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
update
# Fail
}]} then {
- puts "Unable to load config for $class_name"
+ puts "Unable to load configuration for $class_name"
return 0
# Success
@@ -480,7 +518,8 @@ class LedPanel {
## Simulated MCU has been reseted
# @return void
public method reset {} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
@@ -492,6 +531,7 @@ class LedPanel {
# @return void
public method config_menu_special {} {
set ::${class_name}::color $conf_led_color
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
}
## This method is called after configuration menu has beed created
@@ -510,7 +550,7 @@ class LedPanel {
#
# Note: There is defined text tag "tag_bold" in the text widget
public method show_help_special {text_widget} {
- $text_widget insert insert [mc "This tool consists of 8 LED's. Each of them can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes on the bottom of the panel. Panel configuration can be saved to a file (with extension vhc). And can be loaded from that file later. LED colors are configurable.\n\n"]
+ $text_widget insert insert [mc "This tool consists of 8 LED's. Each of them can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes on the bottom of the panel. Panel configuration can be saved to a file with extension vhc, and can be loaded from that file later. LED colors are configurable.\n\n"]
$text_widget insert insert [mc "LED states:"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
@@ -536,8 +576,13 @@ class LedPanel {
$canvas_widget itemconfigure $leds($i) \
-image ::ICONS::16::ledgray
}
- } {
- new_state [$project pale_get_true_state]
+ } else {
+ set state [$project pale_get_true_state]
+ new_state state
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/matrixkeypad.tcl b/lib/pale/matrixkeypad.tcl
index 186ead0..9400741 100755..100644
--- a/lib/pale/matrixkeypad.tcl
+++ b/lib/pale/matrixkeypad.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 _MATRIXKEYPAD_TCL ] } {
+set _MATRIXKEYPAD_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -36,15 +41,15 @@ class MatrixKeyPad {
inherit VirtualHWComponent
# Font: Font to be used in the panel -- bold
- common cb_font [font create \
- -weight bold \
- -size -10 \
- -family {helvetica} \
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
]
# Font: Font to be used in the panel -- normal weight
- common cb_font_n [font create \
- -size -10 \
- -family {helvetica} \
+ common cb_font_n [font create \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
]
common COMPONENT_NAME "Matrix Keypad" ;# Name of this component
@@ -64,9 +69,14 @@ class MatrixKeyPad {
"Save configuration into a file"}
{command {Load configuration} {} 0 "load_from" {fileopen}
"Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::MatrixKeyPad::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
}
- private variable radio_buttons ;# Bool: Disallow key combinations
+ private variable radio_buttons 0 ;# Bool: Disallow key combinations
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
private variable keys ;# Array of Bool: Indicates key press
private variable wire
private variable wire_o
@@ -138,6 +148,17 @@ class MatrixKeyPad {
destroy $win
}
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $MatrixKeyPad::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
## Reevaluate array of MCU port pins engaged by this device
# @return void
private method evaluete_enaged_pins {} {
@@ -193,18 +214,18 @@ class MatrixKeyPad {
# @return void
private method create_gui {} {
# Create panel window and canvas widget
- set win [toplevel .matrixkeypad$count -class $component_name -bg {#EEEEEE}]
+ set win [toplevel .matrixkeypad$count -class $component_name -bg ${::COMMON_BG_COLOR}]
set canvas_widget [canvas $win.canvas \
-bg white -width 0 -height 0 \
-highlightthickness 0 \
]
# Create labels
- $canvas_widget create text 33 20 \
+ $canvas_widget create text 36 20 \
-text [mc "PORT"] \
-font $cb_font \
-anchor e
- $canvas_widget create text 35 20 \
+ $canvas_widget create text 38 20 \
-text [mc "BIT"] \
-font $cb_font \
-anchor w
@@ -218,13 +239,13 @@ class MatrixKeyPad {
-font $cb_font \
-anchor e
- $canvas_widget create text 5 220 \
+ $canvas_widget create text 35 220 \
-text [mc "Note"] \
-font $cb_font \
- -anchor w
- $canvas_widget create window 35 220 \
+ -anchor e
+ $canvas_widget create window 40 220 \
-window [ttk::entry $canvas_widget.usr_note \
- -validate all \
+ -validate key \
-validatecommand "$this set_modified" \
] \
-width 180 -anchor w
@@ -259,7 +280,7 @@ class MatrixKeyPad {
-state readonly \
]
bind $canvas_widget.cb_p$i <<ComboboxSelected>> "$this reconnect $i"
-
+
$canvas_widget create window $x $y -anchor w \
-window [ttk::combobox $canvas_widget.cb_b$i \
-width 1 \
@@ -289,7 +310,7 @@ class MatrixKeyPad {
-state readonly \
]
bind $canvas_widget.cb_p$i <<ComboboxSelected>> "$this reconnect $i"
-
+
$canvas_widget create window $x $cb_b_y -anchor center \
-window [ttk::combobox $canvas_widget.cb_b$i \
-width 1 \
@@ -334,9 +355,9 @@ class MatrixKeyPad {
pack $canvas_widget -fill both -expand 1
# Set window parameters
- wm geometry $win =225x235
+ wm minsize $win 225 240
wm iconphoto $win ::ICONS::16::$component_icon
- wm title $win "[mc $component_name] - [string trim $project {:}] - MCU 8051 IDE"
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this close_window"
bindtags $win [list $win Toplevel all .]
@@ -455,7 +476,7 @@ class MatrixKeyPad {
$canvas_widget itemconfigure $rect($i) -outline #333333 -width 2
# Key released
- } {
+ } else {
$canvas_widget itemconfigure $lever(0$i) -fill #000000
$canvas_widget itemconfigure $lever(1$i) -fill #FFFFFF
$canvas_widget itemconfigure $text($i) -font $cb_font_n
@@ -469,7 +490,7 @@ class MatrixKeyPad {
public method key_leave {i} {
if {$keys($i)} {
set color {#333333}
- } {
+ } else {
set color {#CCCCCC}
}
$canvas_widget itemconfigure $rect($i) -outline $color
@@ -606,12 +627,12 @@ class MatrixKeyPad {
# @return void
public method mcu_changed {} {
# Refresh lists of possible values in port selection ComboBoxes
- set avaliable_ports [concat - [$project pale_get_avaliable_ports]]
+ set available_ports [concat - [$project pale_get_available_ports]]
for {set i 0} {$i < 8} {incr i} {
- $canvas_widget.cb_p$i configure -values $avaliable_ports
+ $canvas_widget.cb_p$i configure -values $available_ports
- if {[lsearch -ascii -exact $avaliable_ports $connection_port($i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
$canvas_widget.cb_p$i current 0
set connection_port($i) {-}
}
@@ -627,11 +648,13 @@ class MatrixKeyPad {
# '|' - High frequency
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
# '0' - Logical 0
# '1' - Logical 1
- public method new_state {state} {
+ public method new_state {_state} {
+ upvar $_state state
+
# Local variables
set row_state [list {} {} {} {}] ;# State of rows
set col_state [list {} {} {} {}] ;# State of columns
@@ -650,7 +673,7 @@ class MatrixKeyPad {
if {$i < 4} {
lset row_state $i [lindex $state $pp]
# Columns
- } {
+ } else {
lset col_state [expr {$i - 4}] [lindex $state $pp]
}
}
@@ -718,7 +741,7 @@ class MatrixKeyPad {
if {$i < 4} {
lset state $pp [lindex $row_state $i]
# Columns
- } {
+ } else {
lset state $pp [lindex $col_state [expr {$i - 4}]]
}
}
@@ -738,9 +761,6 @@ class MatrixKeyPad {
$canvas_widget itemconfigure $item -fill $color
}
}
-
- # Return new port states
- return $state
}
## Withdraw panel window from the screen
@@ -761,6 +781,7 @@ class MatrixKeyPad {
[$canvas_widget.usr_note get] \
[array get keys] \
$radio_buttons \
+ $keep_win_on_top \
] \
]
}
@@ -776,7 +797,7 @@ class MatrixKeyPad {
# Restore window geometry
if {[string length [lindex $state 2]]} {
- wm geometry $win [lindex $state 2]
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm minsize $win] {x}]]
}
# Load user note
@@ -787,6 +808,13 @@ class MatrixKeyPad {
array set keys [lindex $state 4]
set radio_buttons [lindex $state 5]
+ if {[lindex $state 6] != {}} {
+ set keep_win_on_top [lindex $state 6]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
# Restore state of ComboBoxes
for {set i 0} {$i < 8} {incr i} {
## PIN
@@ -826,7 +854,7 @@ class MatrixKeyPad {
# Fail
}]} then {
- puts "Unable to load config for $class_name"
+ puts "Unable to load configuration for $class_name"
return 0
# Success
@@ -850,7 +878,8 @@ class MatrixKeyPad {
## This method is called before configuration menu invocation
# @return void
public method config_menu_special {} {
- set ::MatrixKeyPad::menu_radio_buttons $radio_buttons
+ set ::${class_name}::menu_radio_buttons $radio_buttons
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
}
## This method is called after configuration menu has beed created
@@ -864,7 +893,7 @@ class MatrixKeyPad {
#
# Note: There is defined text tag "tag_bold" in the text widget
public method show_help_special {text_widget} {
- $text_widget insert insert [mc "This tool consists of 16 switches connected in matrix. Connections with the uC are made with ComboBoxes. Panel configuration can be saved to a file (with extension vhc). And can be loaded from that file later. Wire colors are identical to colors used in graph representing IO ports.\n\n"]
+ $text_widget insert insert [mc "This tool consists of 16 switches connected in matrix. Connections with the uC are made with ComboBoxes. Panel configuration can be saved to a file with extension vhc, and can be loaded from that file later. Wire colors are identical to colors used in graph representing IO ports.\n\n"]
$text_widget insert insert [mc "Keypad can be configured in two ways:"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
$text_widget insert insert [mc "\n "]
@@ -873,7 +902,7 @@ class MatrixKeyPad {
$text_widget insert insert [mc " To allow key combinations\n Menu -> Check \"Radio buttons\"\n "]
$text_widget insert insert [mc "2)"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
- $text_widget insert insert [mc " To do not allow key combinations\n Menu -> Uncheck \"Radio buttons\""]
+ $text_widget insert insert [mc " To not allow key combinations\n Menu -> Uncheck \"Radio buttons\""]
}
## This method is called before panel window closure
@@ -884,6 +913,11 @@ class MatrixKeyPad {
## Commit new on/off state
# @return void
public method on_off_special {} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/multiplexedleddisplay.tcl b/lib/pale/multiplexedleddisplay.tcl
index 78976ad..8fcf042 100755..100644
--- a/lib/pale/multiplexedleddisplay.tcl
+++ b/lib/pale/multiplexedleddisplay.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 _MULTIPLEXEDLEDDISPLAY_TCL ] } {
+set _MULTIPLEXEDLEDDISPLAY_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements PALE VHW component "Multiplexed LED display"
@@ -35,11 +40,12 @@ class MultiplexedLedDisplay {
inherit VirtualHWComponent
# Font: Font to be used in the panel -- bold
- common cb_font [font create \
- -weight bold -size -10 \
- -family {helvetica} \
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
]
- common COMPONENT_NAME "Multiplexed LED display" ;# Name of this component
+ common COMPONENT_NAME "Multiplexed LED Display" ;# Name of this component
common CLASS_NAME "MultiplexedLedDisplay" ;# Name of this class
common COMPONENT_ICON {mleddisplay} ;# Icon for this panel (16x16)
@@ -55,16 +61,17 @@ class MultiplexedLedDisplay {
{#5555AA #0000FF #5555FF}
{#AA55AA #8800FF #CC55FF}
}
+ common DIMMED_COLOR {#BBBBBB}
# Configuration menu
common CONFMENU {
{cascade {Common electrode} 7 "diode" .ca false 1 {
{radiobutton "Common anode" {}
::MultiplexedLedDisplay::cfg_common_anode 1
- "common_electrode_chanded" 7 ""}
- {radiobutton "Common catode" {}
+ "common_electrode_changed" 7 ""}
+ {radiobutton "Common cathode" {}
::MultiplexedLedDisplay::cfg_common_anode 0
- "common_electrode_chanded" 7 ""}
+ "common_electrode_changed" 7 ""}
}}
{cascade {Fade out interval} 5 "player_time" .dim false 1 {
{radiobutton "0" {}
@@ -126,7 +133,7 @@ class MultiplexedLedDisplay {
}}
{separator}
{command {All fade out} {} 0 "dim_all" {ledgray}
- "Dim all leds"}
+ "Dim all LEDs"}
{command {Show help} {} 5 "show_help" {help}
"Show brief help"}
{separator}
@@ -134,10 +141,15 @@ class MultiplexedLedDisplay {
"Save configuration into a file"}
{command {Load configuration} {} 0 "load_from" {fileopen}
"Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::MultiplexedLedDisplay::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
}
private variable conf_dim_interval 50 ;# Int: Interval to dim LED's in instruction cycles
private variable conf_led_color {red} ;# Color: Selected color for display segments
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
private variable leds ;# Array of CanvasObject (polygon): leds(display_num,segment_num) --> LED polygon
## Array of CanvasObject (line):
@@ -147,7 +159,7 @@ class MultiplexedLedDisplay {
private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
private variable connection_pin ;# Array of Int: Index is key number, value is bit number or {-}
private variable prev_state ;# List: Previous port states
- private variable common_anode 1 ;# Bool: 1 == common anode; 0 == common catode
+ private variable common_anode 1 ;# Bool: 1 == common anode; 0 == common cathode
private variable t_state ;# List: Transistor states
@@ -213,7 +225,7 @@ class MultiplexedLedDisplay {
# @return void
private method create_gui {} {
# Create panel window and canvas widget
- set win [toplevel .multiplexedleddisplay$count -class {Mult. LED Display} -bg {#EEEEEE}]
+ set win [toplevel .multiplexedleddisplay$count -class {Mult. LED Display} -bg ${::COMMON_BG_COLOR}]
set canvas_widget [canvas $win.canvas \
-bg white -width 0 -height 0 \
-highlightthickness 0 \
@@ -396,12 +408,12 @@ class MultiplexedLedDisplay {
# Create EntryBox for user note
$canvas_widget create text 40 210 \
- -text {Note} \
+ -text [mc "Note"] \
-font $cb_font \
-anchor e
- $canvas_widget create window 40 210 \
+ $canvas_widget create window 45 210 \
-window [ttk::entry $canvas_widget.usr_note \
- -validate all \
+ -validate key \
-validatecommand "$this set_modified" \
] \
-width 380 -anchor w
@@ -412,14 +424,25 @@ class MultiplexedLedDisplay {
pack $canvas_widget -fill both -expand 1
# Set window parameters
- wm geometry $win =425x225
+ wm minsize $win 430 225
wm iconphoto $win ::ICONS::16::$component_icon
- wm title $win "[mc $component_name] - [string trim $project {:}] - MCU 8051 IDE"
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this close_window"
bindtags $win [list $win Toplevel all .]
}
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $MultiplexedLedDisplay::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
## LED dim interval changed (meaningfull for multiplexed mode)
# @return void
public method dim_interval_changed {} {
@@ -427,14 +450,15 @@ class MultiplexedLedDisplay {
set_modified
}
- ## LED's common electrode chanded
+ ## LED's common electrode changed
# @return void
- public method common_electrode_chanded {} {
+ public method common_electrode_changed {} {
set common_anode ${::MultiplexedLedDisplay::cfg_common_anode}
if {$drawing_on} {
dim_all
- new_state [$project pale_get_true_state] 1
+ set state [$project pale_get_true_state]
+ new_state state 1
}
set_modified
}
@@ -445,12 +469,13 @@ class MultiplexedLedDisplay {
set conf_led_color ${::MultiplexedLedDisplay::color}
if {$drawing_on} {
- new_state [$project pale_get_true_state] 1
+ set state [$project pale_get_true_state]
+ new_state state 1
}
set_modified
}
- ## Dim all LED's and reset their prevoius states
+ ## Dim all LED's and reset their previous states
# @return void
public method dim_all {} {
for {set i 0} {$i < 8} {incr i} {
@@ -476,7 +501,7 @@ class MultiplexedLedDisplay {
if {$connection_pin($i) != {-}} {
set connection_pin($i) [expr {7 - $connection_pin($i)}]
}
- } {
+ } else {
set connection_port(T$i) [$canvas_widget.cb_t_p$i get]
set connection_pin(T$i) [$canvas_widget.cb_t_b$i get]
if {$connection_pin(T$i) != {-}} {
@@ -486,7 +511,8 @@ class MultiplexedLedDisplay {
# Change state of the device
if {$drawing_on} {
- new_state [$project pale_get_true_state] 1
+ set state [$project pale_get_true_state]
+ new_state state 1
}
# Set flag modified
@@ -711,7 +737,7 @@ class MultiplexedLedDisplay {
private method which_port_pin {type i} {
if {$type == {S}} {
return [list $connection_port($i) $connection_pin($i)]
- } {
+ } else {
return [list $connection_port(T$i) $connection_pin(T$i)]
}
}
@@ -732,13 +758,13 @@ class MultiplexedLedDisplay {
# @return void
public method mcu_changed {} {
# Refresh lists of possible values in port selection ComboBoxes
- set avaliable_ports [concat - [$project pale_get_avaliable_ports]]
+ set available_ports [concat - [$project pale_get_available_ports]]
# For segments ...
for {set i 0} {$i < 8} {incr i} {
- $canvas_widget.cb_p$i configure -values $avaliable_ports
+ $canvas_widget.cb_p$i configure -values $available_ports
- if {[lsearch -ascii -exact $avaliable_ports $connection_port($i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
$canvas_widget.cb_p$i current 0
set connection_port($i) {-}
}
@@ -746,9 +772,9 @@ class MultiplexedLedDisplay {
# For transistors ...
for {set i 0} {$i < 4} {incr i} {
- $canvas_widget.cb_t_p$i configure -values $avaliable_ports
+ $canvas_widget.cb_t_p$i configure -values $available_ports
- if {[lsearch -ascii -exact $avaliable_ports $connection_port(T$i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port(T$i)] == -1} {
$canvas_widget.cb_t_p$i current 0
set connection_port(T$i) {-}
}
@@ -757,18 +783,20 @@ class MultiplexedLedDisplay {
## Accept new state of ports
# @parm List state - Port states ( 5 x {8 x bit} -- {bit0 bit1 bit2 ... bit7} )
- # @parm Bool preserve_prvious_state = 0 - Preserve previous state of component
+ # @parm Bool preserve_prvious_state=0 - Preserve previous state of component
# @return void
#
# Possible bit values:
# '|' - High frequency
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
# '0' - Logical 0
# '1' - Logical 1
- public method new_state {state {preserve_prvious_state 0}} {
+ public method new_state {_state {preserve_prvious_state 0}} {
+ upvar $_state state
+
# Determinate index of LED color in list COLORS
set color_idx [lsearch -ascii -exact \
{red orange yellow green blue purple} \
@@ -784,7 +812,7 @@ class MultiplexedLedDisplay {
if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
set t_state($i) {}
# Connected
- } {
+ } else {
set t_state($i) [lindex $state $pp]
}
@@ -793,7 +821,7 @@ class MultiplexedLedDisplay {
{0} { ;# Logical 0
if {$common_anode} {
set t_state($i) 2
- } {
+ } else {
set t_state($i) 0
}
set wire_color {#FF0000}
@@ -801,7 +829,7 @@ class MultiplexedLedDisplay {
{1} { ;# Logical 1
if {$common_anode} {
set t_state($i) 0
- } {
+ } else {
set t_state($i) 2
}
set wire_color {#00FF00}
@@ -809,7 +837,7 @@ class MultiplexedLedDisplay {
{=} { ;# High forced to low
if {$common_anode} {
set t_state($i) 2
- } {
+ } else {
set t_state($i) 0
}
set wire_color {#00FF00}
@@ -842,7 +870,7 @@ class MultiplexedLedDisplay {
# Not connected
if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-}} {
for {set j 0} {$j < 4} {incr j} {
- $canvas_widget itemconfigure $leds($j,$i) -fill {#555555}
+ $canvas_widget itemconfigure $leds($j,$i) -fill $DIMMED_COLOR -outline {#FFFFFF}
}
foreach item $wires($i) {
$canvas_widget itemconfigure $item -fill {#000000}
@@ -896,14 +924,14 @@ class MultiplexedLedDisplay {
set segment_color {0}
}
}
- } {
+ } else {
set segment_color {0}
}
}
{1} { ;# Logical 1
if {$common_anode} {
set segment_color {0}
- } {
+ } else {
switch -- $t_state($j) {
{2} {
set segment_color {2}
@@ -966,8 +994,8 @@ class MultiplexedLedDisplay {
# Determinate segment color (true color, not just number)
if {!$segment_color} {
- set segment_color {#555555}
- } {
+ set segment_color $DIMMED_COLOR
+ } else {
incr segment_color -1
set segment_color [lindex $COLORS [list $color_idx $segment_color]]
}
@@ -998,6 +1026,7 @@ class MultiplexedLedDisplay {
$conf_led_color \
$conf_dim_interval \
$common_anode \
+ $keep_win_on_top \
] \
]
}
@@ -1013,7 +1042,7 @@ class MultiplexedLedDisplay {
# Restore window geometry
if {[string length [lindex $state 2]]} {
- wm geometry $win [lindex $state 2]
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm minsize $win] {x}]]
}
# Load user note
@@ -1028,6 +1057,13 @@ class MultiplexedLedDisplay {
set common_anode 1
}
+ if {[lindex $state 7] != {}} {
+ set keep_win_on_top [lindex $state 7]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
## Restore state of ComboBoxes
# For segments ...
for {set i 0} {$i < 8} {incr i} {
@@ -1083,12 +1119,13 @@ class MultiplexedLedDisplay {
}
# Accept new state of ports
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
update
# Fail
}]} then {
- puts stderr "Unable to load config for $class_name"
+ puts stderr "Unable to load configuration for $class_name"
puts stderr $::errorInfo
return 0
@@ -1103,7 +1140,8 @@ class MultiplexedLedDisplay {
# @return void
public method reset {} {
dim_all
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
@@ -1117,6 +1155,7 @@ class MultiplexedLedDisplay {
set ::${class_name}::dim_interval $conf_dim_interval
set ::${class_name}::color $conf_led_color
set ::${class_name}::cfg_common_anode $common_anode
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
}
## This method is called after configuration menu has beed created
@@ -1135,7 +1174,7 @@ class MultiplexedLedDisplay {
#
# Note: There is defined text tag "tag_bold" in the text widget
public method show_help_special {text_widget} {
- $text_widget insert insert [mc "Virtual multiplexed LED display with common anode (default) or catode. Each segment can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes. Panel configuration can be saved to a file (with extension vhc). And can be loaded from that file later. LED fade out interval and LED colors are configurable\n\n"]
+ $text_widget insert insert [mc "Virtual Multiplexed LED Display with common anode (default) or cathode. Each segment can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes. Panel configuration can be saved to a file with extension vhc, and can be loaded from that file later. LED fade out interval and LED colors are configurable.\n\n"]
set color_idx [lsearch -ascii -exact \
{red orange yellow green blue purple} \
@@ -1145,7 +1184,7 @@ class MultiplexedLedDisplay {
$text_widget insert insert [mc "LED states:"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
$text_widget insert insert [mc "\n "]
- $text_widget window create insert -pady 1 -create "frame $text_widget.f0 -bd 1 -width 14 -height 16 -bg #888888"
+ $text_widget window create insert -pady 1 -create "frame $text_widget.f0 -bd 1 -width 14 -height 16 -bg $DIMMED_COLOR"
$text_widget insert insert [mc " Off\n "]
$text_widget window create insert -pady 1 -create "frame $text_widget.f1 -bd 1 -width 14 -height 16 -bg [lindex $COLORS [list $color_idx 0]]"
$text_widget insert insert [mc " Fast blinking\n "]
@@ -1172,8 +1211,13 @@ class MultiplexedLedDisplay {
}
}
}
- } {
- new_state [$project pale_get_true_state] 1
+ } else {
+ set state [$project pale_get_true_state]
+ new_state state 1
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/pale.tcl b/lib/pale/pale.tcl
index 3b4b61c..37a3fe1 100755..100644
--- a/lib/pale/pale.tcl
+++ b/lib/pale/pale.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,22 +21,33 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _PALE_TCL ] } {
+set _PALE_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# PALE (Peripheral Abstraction Layer Engine) - simulates virtual hardware
# --------------------------------------------------------------------------
-# Load base class for Virtual HW components
-source "${::LIB_DIRNAME}/pale/virtual_hw_component.tcl"
-
-# Load Virtual HW components
-source "${::LIB_DIRNAME}/pale/ledpanel.tcl"
-source "${::LIB_DIRNAME}/pale/leddisplay.tcl"
-source "${::LIB_DIRNAME}/pale/ledmatrix.tcl"
-source "${::LIB_DIRNAME}/pale/multiplexedleddisplay.tcl"
-source "${::LIB_DIRNAME}/pale/simplekeypad.tcl"
-source "${::LIB_DIRNAME}/pale/matrixkeypad.tcl"
+if {$::GUI_AVAILABLE} {
+ # Load base class for Virtual HW components
+ source "${::LIB_DIRNAME}/pale/virtual_hw_component.tcl"
+
+ # Load Virtual HW components
+ source "${::LIB_DIRNAME}/pale/ledpanel.tcl"
+ source "${::LIB_DIRNAME}/pale/leddisplay.tcl"
+ source "${::LIB_DIRNAME}/pale/ledmatrix.tcl"
+ source "${::LIB_DIRNAME}/pale/multiplexedleddisplay.tcl"
+ source "${::LIB_DIRNAME}/pale/simplekeypad.tcl"
+ source "${::LIB_DIRNAME}/pale/matrixkeypad.tcl"
+ source "${::LIB_DIRNAME}/pale/lcd_hd44780.tcl"
+ source "${::LIB_DIRNAME}/pale/ds1620.tcl"
+ source "${::LIB_DIRNAME}/pale/virtual_uart_term.tcl"
+ source "${::LIB_DIRNAME}/pale/file_interface.tcl"
+}
class Pale {
private variable scenario_file {} ;# String: Name of PALE scenario file
@@ -49,7 +60,7 @@ class Pale {
private variable portConfig ;# Array of Int: Index 0..4, defines port pin functions
private variable portConfig_mod 0 ;# Bool: $portConfig contain special configuration
- private variable instruction_cycles 0 ;# Int: Nummber of instruction cycles performed during this simulation cycle
+ private variable instruction_cycles 0 ;# Int: Number of instruction cycles performed during this simulation cycle
private variable last_output {} ;# List: 5x{8x{...}} Last port outputs
private variable last_input {} ;# List: 5x{8x{...}} Last port inputs
@@ -130,7 +141,7 @@ class Pale {
# Try to open the file
if {[catch {
- set file [open $scenario_file "w" 420]
+ set file [open $scenario_file "w" 0640]
}]} then {
puts stderr "Unable to save to file: \"$scenario_file\""
return 0
@@ -138,8 +149,7 @@ class Pale {
# Save data to the file
puts $file "# MCU 8051 IDE: Virtual HW configuration file"
- puts $file "# Date: [clock format [clock seconds] -format {%D}]"
- puts $file "# Project: [string trim $this {:}]\n"
+ puts $file "# Project: [$this cget -projectName]\n"
foreach dev [concat $output_devices $input_devices] {
puts $file [$dev get_config]
}
@@ -177,7 +187,7 @@ class Pale {
if {![string first $prj_path $scenario_file]} {
return [string range $scenario_file [string length $prj_path] end]
# Return absolute directory location
- } {
+ } else {
return $scenario_file
}
}
@@ -210,7 +220,7 @@ class Pale {
![file exists $filename] ||
![file isfile $filename] ||
(!$::MICROSOFT_WINDOWS && ![file readable $filename])
- } {
+ } then {
return 0
}
@@ -259,7 +269,7 @@ class Pale {
$obj set_config $conf
# Error detected
}]} then {
- puts stderr "Unable to create PALE object: \"$obj\", maybe you are using old version of MCU 8051 IDE\n"
+ puts stderr "Unable to create PALE object: \"$obj\", maybe you are using an old version of MCU 8051 IDE.\n"
puts stderr $::errorInfo
catch {
@@ -387,7 +397,7 @@ class Pale {
{X} { ;# Access to external memory
append result [expr {rand() < 0.5}]
}
- {-} { ;# Undeterminable value (some noise)
+ {-} { ;# Indeterminable value (some noise)
append result [expr {rand() < 0.5}]
}
{|} { ;# High frequency
@@ -406,21 +416,18 @@ class Pale {
}
## Read Real Port Pin Voltage - 1 bit value (0 or 1)
- # @parm List - {port_number bit_number}
- # @parm Int = 0 - Position in history (positive number)
+ # @parm List pn_bn - {port_number bit_number}
+ # @parm Int position=0 - Position in history (positive number)
# @return Bool - Boolean value
- public method pale_RRPPV args {
+ public method pale_RRPPV {pn_bn {position 0}} {
if {!$is_enabled} {return 1}
# Parse input arguments
- set port [lindex $args {0 0}]
- set bit [lindex $args {0 1}]
- set position [lindex $args 1]
+ set port [lindex $pn_bn 0]
+ set bit [lindex $pn_bn 1]
# Adjust arguments
- if {![string length $position]} {
- set position 0
- } elseif {$position < 0} {
+ if {$position < 0} {
set position [expr {[llength $portState] + $position}]
}
set bit [expr {7 - $bit}]
@@ -453,30 +460,20 @@ class Pale {
}
## Write to port with bypassed latch (takes effect on next simulation cycle)
- # @parm Int - Port number
- # @parm List - New value -- list of 8 values {bit0 bit1 bit2 ... bit7}
+ # @parm Int port - Port number
+ # @parm List value - New value -- list of 8 values {bit0 bit1 bit2 ... bit7}
# '0' - Logical 0
# '1' - Logical 1
# '|' - High frequency pulse
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
- # @parm Int = 0 - Position in history (zero or negative number)
+ # @parm Int position=0 - Position in history (zero or negative number)
# @return void
- public method pale_WPBL args {
+ public method pale_WPBL {port value {position 0}} {
if {!$is_enabled} {return}
- # Parse input arguments
- set port [lindex $args 0]
- set value [lindex $args 1]
- set position [lindex $args 2]
-
- # Adjust arguments
- if {![string length $position]} {
- set position 0
- }
-
# Set value
for {set bit 0} {$bit < 8} {incr bit} {
lappend special_func [list $port $bit $value $position]
@@ -484,30 +481,24 @@ class Pale {
}
## Write to port bit with bypassed latch
- # @parm List - {port_number bit_number}
- # @parm Char - New value
+ # @parm List pn_bn - {port_number bit_number}
+ # @parm Char value - New value
# '0' - Logical 0
# '1' - Logical 1
# '|' - High frequency pulse
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
- # @parm Int = 0 - Position in history (zero or negative number)
+ # @parm Int position=0 - Position in history (zero or negative number)
# @return void
- public method pale_WPBBL args {
+ public method pale_WPBBL {pn_bn value {position 0}} {
if {!$is_enabled} {return}
# Parse input arguments
- set port [lindex $args {0 0}]
- set bit [lindex $args {0 1}]
- set value [lindex $args 1]
- set position [lindex $args 2]
+ set port [lindex $pn_bn 0]
+ set bit [lindex $pn_bn 1]
- # Adjust arguments
- if {![string length $position]} {
- set position 0
- }
set bit [expr {7 - $bit}]
# Set value
@@ -583,7 +574,7 @@ class Pale {
for {set i -1; set j 0} {$j < $instruction_cycles} {incr i; incr j} {
if {$i < 0} {
set previous_output_state $last_output
- } {
+ } else {
set previous_output_state [lindex $portOutput $i]
}
foreach prev $previous_output_state new [lindex $portOutput $j] port {0 1 2 3 4} {
@@ -638,16 +629,16 @@ class Pale {
set last_output [lindex $portOutput end]
set last_input [lindex $portInput end]
set last_state [lindex $portState end]
- set portLatch [list]
- set portOutput [list]
- set portInput [list]
+ set portLatch [list]
+ set portOutput [list]
+ set portInput [list]
set special_func [list]
# Inform output devices about the new port outputs
foreach dev $output_devices {
- $dev new_state $last_state
- update
+ $dev new_state last_state
}
+ update
}
## Determinate resulting value when two values clash on one wire
@@ -678,7 +669,7 @@ class Pale {
{?} { ;# No volatge
return $in1
}
- {-} { ;# Undeterminable value (some noise)
+ {-} { ;# Indeterminable value (some noise)
return {-}
}
{=} { ;# High forced to low
@@ -690,7 +681,7 @@ class Pale {
{1} { ;# Logical 1
if {$in1 == {?}} {
return 1
- } {
+ } else {
return $in1
}
}
@@ -712,8 +703,10 @@ class Pale {
# Call all input devices
foreach dev $input_devices {
# Call device to change the current state
- set input [$dev new_state $input]
- update
+ $dev new_state input
+
+ # Clear list of devices already confronted with the new state
+ set already_evaluated [list]
# Inform all other devices interconnected with this one
for {set p 0} {$p < 5} {incr p} {
@@ -729,17 +722,22 @@ class Pale {
# Call all affected devices
foreach affected_dev $engaged_pins($p,$b) {
+ # Do not confront the device with itself
if {$affected_dev == $dev} {
continue
}
- set input [$affected_dev new_state $input]
- update
+ # Do not confront the device with another device more than once per ``foreach dev ...'' iteration
+ if {[lsearch -ascii -exact $already_evaluated $affected_dev] != -1} {
+ continue
+ }
+
+ lappend already_evaluated $affected_dev
+ $affected_dev new_state input
}
# Again call the current device
- set input [$dev new_state $input]
- update
+ $dev new_state input
}
}
}
@@ -762,9 +760,9 @@ class Pale {
# Inform output devices about the new port outputs
foreach dev $output_devices {
- $dev new_state $last_state
- update
+ $dev new_state last_state
}
+ update
}
## Call input devices to evaluate input values
@@ -776,8 +774,10 @@ class Pale {
# Call all input devices
foreach dev $input_devices {
# Call device to change the current state
- set input [$dev new_state $input]
- update
+ $dev new_state input
+
+ # Clear list of devices already confronted with the new state
+ set already_evaluated [list]
# Inform all other devices interconnected with this one
for {set p 0} {$p < 5} {incr p} {
@@ -793,17 +793,21 @@ class Pale {
# Call all affected devices
foreach affected_dev $engaged_pins($p,$b) {
+ # Do not confront the device with itself
if {$affected_dev == $dev} {
continue
}
- set input [$affected_dev new_state $input]
- update
+ # Do not confront the device with another device more than once per ``foreach dev ...'' iteration
+ if {[lsearch -ascii -exact $already_evaluated $affected_dev] != -1} {
+ continue
+ }
+
+ $affected_dev new_state input
}
# Again call the current device
- set input [$dev new_state $input]
- update
+ $dev new_state input
}
}
}
@@ -890,6 +894,9 @@ class Pale {
pale_disengage_pin_by_input_device $p $b $object
}
}
+
+ # Make this change in the environment visible right away
+ pale_reevaluate_IO
}
## Inform PALE system about that than some input device is
@@ -907,6 +914,9 @@ class Pale {
# * PALE VHW component must extend class "VirtualHWComponent"
# * Input devices CAN affect port inputs, output cannot
public method pale_engage_pin_by_input_device {port pin dev} {
+ if {[lsearch -ascii -exact $engaged_pins($port,$pin) $dev] != -1} {
+ return
+ }
lappend engaged_pins($port,$pin) $dev
}
@@ -928,6 +938,7 @@ class Pale {
# * Input devices CAN affect port inputs, output cannot
public method pale_disengage_pin_by_input_device {port pin dev} {
set idx [lsearch -ascii -exact $engaged_pins($port,$pin) $dev]
+
if {$idx == -1} {
return
}
@@ -955,7 +966,7 @@ class Pale {
# '|' - High frequency pulse
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
public method pale_get_output_state {} {
return $last_output
@@ -969,15 +980,15 @@ class Pale {
# '|' - High frequency pulse
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
public method pale_get_true_state {} {
return $last_state
}
- ## Get list of avaliable port number on the current MCU
+ ## Get list of available port number on the current MCU
# @return List of Int - e.g. {1 3}
- public method pale_get_avaliable_ports {} {
+ public method pale_get_available_ports {} {
return [lindex [$this get_ports_info] 1]
}
@@ -988,4 +999,14 @@ class Pale {
$dev mcu_changed
}
}
+
+ ## Get number of instruction cycles performed during this simulation cycle
+ # @return Int - Number of instruction cycles
+ public method pale_get_number_of_instruction_cycles {} {
+ return $instruction_cycles
+ }
+}
+
+# >>> File inclusion guard
}
+# <<< File inclusion guard
diff --git a/lib/pale/simplekeypad.tcl b/lib/pale/simplekeypad.tcl
index d7baa83..0889106 100755..100644
--- a/lib/pale/simplekeypad.tcl
+++ b/lib/pale/simplekeypad.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 _SIMPLEKEYPAD_TCL ] } {
+set _SIMPLEKEYPAD_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -36,15 +41,15 @@ class SimpleKeyPad {
inherit VirtualHWComponent
# Font: Font to be used in the panel -- bold
- common cb_font [font create \
- -weight bold \
- -size -10 \
- -family {helvetica} \
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
]
# Font: Font to be used in the panel -- normal weight
- common cb_font_n [font create \
- -size -10 \
- -family {helvetica} \
+ common cb_font_n [font create \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
]
common COMPONENT_NAME "Simple Keypad" ;# Name of this component
@@ -63,9 +68,14 @@ class SimpleKeyPad {
"Save configuration into a file"}
{command {Load configuration} {} 0 "load_from" {fileopen}
"Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::SimpleKeyPad::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
}
- private variable radio_buttons ;# Bool: Disallow key combinations
+ private variable radio_buttons 0 ;# Bool: Disallow key combinations
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
private variable keys ;# Array of Bool: Indicates key press
private variable wire ;# Array of CanvasObject (line): Wires connected to MCU pins
private variable wire_o ;# Array of CanvasObject (oval): Wires connected to MCU pins
@@ -74,7 +84,7 @@ class SimpleKeyPad {
private variable text ;# Array of CanvasObject (text): Key descriptions
private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
private variable connection_pin ;# Array of Int: Index is key number, value is bit number or {-}
- private variable enaged ;# Array of Bool: enaged(port_num,bit_num) --> Is connected to this device ?
+ private variable enaged ;# Array of Bool: enaged(port_num,bit_num) --> Is connected to this device?
# ------------------------------------------------------------------
@@ -181,12 +191,12 @@ class SimpleKeyPad {
# @return void
private method create_gui {} {
# Create panel window and canvas widget
- set win [toplevel .simplekeypad$count -class $component_name -bg {#EEEEEE}]
+ set win [toplevel .simplekeypad$count -class $component_name -bg ${::COMMON_BG_COLOR}]
set canvas_widget [canvas $win.canvas -bg white -width 0 -height 0]
set cb_p_y 65
set cb_b_y 85
- set usr_n_y 105
+ set usr_n_y 110
set x 50
# Create labels
@@ -198,13 +208,13 @@ class SimpleKeyPad {
-text [mc "BIT"] \
-font $cb_font \
-anchor w
- $canvas_widget create text 5 $usr_n_y \
+ $canvas_widget create text 32 $usr_n_y \
-text [mc "Note"] \
-font $cb_font \
- -anchor w
+ -anchor e
$canvas_widget create window 37 $usr_n_y \
-window [ttk::entry $canvas_widget.usr_note \
- -validate all \
+ -validate key \
-validatecommand "$this set_modified" \
] \
-width 220 -anchor w
@@ -251,7 +261,7 @@ class SimpleKeyPad {
-text [mc "Turn HW simulation on/off"]
setStatusTip -widget $start_stop_button -text [mc "Turn HW simulation on/off"]
bind $start_stop_button <Button-3> "$this on_off_button_press; break"
- $canvas_widget create window 2 20 -window $start_stop_button -anchor sw
+ $canvas_widget create window 2 22 -window $start_stop_button -anchor sw
bindtags $start_stop_button [list $start_stop_button TButton all .]
# Create configuration menu button
@@ -261,16 +271,16 @@ class SimpleKeyPad {
-command "$this config_menu" \
]
setStatusTip -widget $conf_button -text [mc "Configure"]
- $canvas_widget create window 2 20 -window $conf_button -anchor nw
+ $canvas_widget create window 2 22 -window $conf_button -anchor nw
bindtags $conf_button [list $conf_button TButton all .]
# Pack canvas
pack $canvas_widget -fill both -expand 1
# Set window parameters
- wm geometry $win =260x120
+ wm minsize $win 265 125
wm iconphoto $win ::ICONS::16::$component_icon
- wm title $win "[mc $component_name] - [string trim $project {:}] - MCU 8051 IDE"
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this close_window"
bindtags $win [list $win Toplevel all .]
@@ -319,7 +329,7 @@ class SimpleKeyPad {
$canvas_widget itemconfigure $rect($i) -outline #333333 -width 2
# Key released
- } {
+ } else {
$canvas_widget itemconfigure $lever(0$i) -fill #000000
$canvas_widget itemconfigure $lever(1$i) -fill #FFFFFF
$canvas_widget itemconfigure $text($i) -font $cb_font_n
@@ -333,7 +343,7 @@ class SimpleKeyPad {
public method key_leave {i} {
if {$keys($i)} {
set color {#333333}
- } {
+ } else {
set color {#CCCCCC}
}
$canvas_widget itemconfigure $rect($i) -outline $color
@@ -436,6 +446,17 @@ class SimpleKeyPad {
set radio_buttons $::SimpleKeyPad::menu_radio_buttons
}
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $SimpleKeyPad::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
# ------------------------------------------------------------------
# VIRTUAL HW COMMON INTERFACE -- CALLED FROM PALE ENGINE
# ------------------------------------------------------------------
@@ -444,12 +465,12 @@ class SimpleKeyPad {
# @return void
public method mcu_changed {} {
# Refresh lists of possible values in port selection ComboBoxes
- set avaliable_ports [concat - [$project pale_get_avaliable_ports]]
+ set available_ports [concat - [$project pale_get_available_ports]]
for {set i 0} {$i < 8} {incr i} {
- $canvas_widget.cb_p$i configure -values $avaliable_ports
+ $canvas_widget.cb_p$i configure -values $available_ports
- if {[lsearch -ascii -exact $avaliable_ports $connection_port($i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
$canvas_widget.cb_p$i current 0
set connection_port($i) {-}
}
@@ -465,11 +486,13 @@ class SimpleKeyPad {
# '|' - High frequency
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
# '0' - Logical 0
# '1' - Logical 1
- public method new_state {state} {
+ public method new_state {_state} {
+ upvar $_state state
+
# Iterate over keys
for {set i 0} {$i < 8} {incr i} {
# Determinate index in the list of port states
@@ -479,7 +502,7 @@ class SimpleKeyPad {
if {[lindex $pp 0] == {-} || [lindex $pp 1] == {-} || !$drawing_on} {
if {$keys($i)} {
set wire_color {#00DD00}
- } {
+ } else {
set wire_color {#000000}
}
@@ -522,9 +545,6 @@ class SimpleKeyPad {
$canvas_widget itemconfigure $lever($keys(${i})${i}) -fill $wire_color
$canvas_widget itemconfigure $wire_o($i) -outline $wire_color
}
-
- # Return new port states
- return $state
}
## Withdraw panel window from the screen
@@ -545,6 +565,7 @@ class SimpleKeyPad {
[$canvas_widget.usr_note get] \
[array get keys] \
$radio_buttons \
+ $keep_win_on_top \
] \
]
}
@@ -560,7 +581,7 @@ class SimpleKeyPad {
# Restore window geometry
if {[string length [lindex $state 2]]} {
- wm geometry $win [lindex $state 2]
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm minsize $win] {x}]]
}
# Load user note
@@ -570,6 +591,12 @@ class SimpleKeyPad {
# Restore keys configuration and states
array set keys [lindex $state 4]
set radio_buttons [lindex $state 5]
+ if {[lindex $state 6] != {}} {
+ set keep_win_on_top [lindex $state 6]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1
+ }
+ }
# Restore state of ComboBoxes
for {set i 0} {$i < 8} {incr i} {
@@ -608,7 +635,7 @@ class SimpleKeyPad {
# Fail
}]} then {
- puts "Unable to load config for $class_name"
+ puts "Unable to load configuration for $class_name"
return 0
# Success
@@ -621,7 +648,8 @@ class SimpleKeyPad {
## Simulated MCU has been reseted
# @return void
public method reset {} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
# ------------------------------------------------------------------
@@ -631,7 +659,8 @@ class SimpleKeyPad {
## This method is called before configuration menu invocation
# @return void
public method config_menu_special {} {
- set ::SimpleKeyPad::menu_radio_buttons $radio_buttons
+ set ::${class_name}::menu_radio_buttons $radio_buttons
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
}
## This method is called after configuration menu has beed created
@@ -645,7 +674,7 @@ class SimpleKeyPad {
#
# Note: There is defined text tag "tag_bold" in the text widget
public method show_help_special {text_widget} {
- $text_widget insert insert [mc "This tool consists of 8 switches. Each of them can connect any port pin of the simulated uC to the ground. Connections with the uC are made with ComboBoxes on the bottom of the panel. Panel configuration can be saved to a file (with extension vhc). And can be loaded from that file later. Wire colors are identical to colors used in graph representing IO ports.\n\n"]
+ $text_widget insert insert [mc "This tool consists of 8 switches. Each of them can connect any port pin of the simulated uC to ground. Connections with the uC are made with ComboBoxes on the bottom of the panel. Panel configuration can be saved to a file with extension vhc, and can be loaded from that file later. Wire colors are identical to colors used in graph representing IO ports.\n\n"]
$text_widget insert insert [mc "Keypad can be configured in two ways:"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
$text_widget insert insert [mc "\n "]
@@ -654,7 +683,7 @@ class SimpleKeyPad {
$text_widget insert insert [mc " To allow key combinations\n Menu -> Check \"Radio buttons\"\n "]
$text_widget insert insert [mc "2)"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
- $text_widget insert insert [mc " To do not allow key combinations\n Menu -> Uncheck \"Radio buttons\""]
+ $text_widget insert insert [mc " To not allow key combinations\n Menu -> Uncheck \"Radio buttons\""]
}
## This method is called before panel window closure
@@ -665,6 +694,11 @@ class SimpleKeyPad {
## Commit new on/off state
# @return void
public method on_off_special {} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/virtual_hw_component.tcl b/lib/pale/virtual_hw_component.tcl
index e0fb00b..c7a637d 100755..100644
--- a/lib/pale/virtual_hw_component.tcl
+++ b/lib/pale/virtual_hw_component.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 _VIRTUAL_HW_COMPONENT_TCL ] } {
+set _VIRTUAL_HW_COMPONENT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -32,13 +37,15 @@ class VirtualHWComponent {
common hlp_dlg_count 0 ;# Int: Counter of help dialog instances
# Create fonts used in the text
- common hlp_normal_font [font create \
- -family {helvetica} \
- -size -14 -weight {normal} \
+ common hlp_normal_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight {normal} \
]
- common hlp_bold_font [font create \
- -family {helvetica} \
- -size -14 -weight {bold} \
+ common hlp_bold_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight {bold} \
]
protected variable config_menu_created 0 ;# Bool: COnfiguration menu created
@@ -47,9 +54,9 @@ class VirtualHWComponent {
protected variable modified 0 ;# Bool: Flag modified
protected variable project ;# Object: Project object
- protected variable win ;# Widget: Dialog window
+ protected variable win {} ;# Widget: Dialog window
protected variable drawing_on 1 ;# Bool: Flag panel enabled
- protected variable canvas_widget ;# Widget: Canvas widget - crucial part of the window
+ protected variable canvas_widget {} ;# Widget: Canvas widget - crucial part of the window
protected variable start_stop_button ;# Widget: Button "ON/OFF"
protected variable conf_button ;# Widget: Button to invoke configuration menu
@@ -78,7 +85,7 @@ class VirtualHWComponent {
-icon question \
-parent $win \
-title [mc "Component modified"] \
- -message [mc "Do you want to save configuration of this panel before closing ?"] \
+ -message [mc "Do you want to save the configuration of this panel before closing?"] \
] {
{yes} {
save_as
@@ -105,6 +112,10 @@ class VirtualHWComponent {
set modified 1
$project pale_set_modified
+ if {[winfo exists $win]} {
+ wm title $win "\[modified\] [regsub {^\[modified\] } [wm title $win] {}]"
+ }
+
return 1
}
@@ -112,6 +123,10 @@ class VirtualHWComponent {
# @return void
public method clear_modified {} {
set modified 0
+
+ if {[winfo exists $win]} {
+ wm title $win [regsub {^\[modified\] } [wm title $win] {}]
+ }
}
## Invoke configuration menu
@@ -136,9 +151,9 @@ class VirtualHWComponent {
# @return void
protected method create_config_menu {} {
set config_menu_created 1
- set conf_menu $canvas_widget.conf_menu
- menuFactory [subst "\${${class_name}::CONFMENU}"] \
- $conf_menu 0 "$this " 0 {}
+ set conf_menu $win.conf_menu
+ menuFactory [subst -nocommands "\${${class_name}::CONFMENU}"] \
+ $conf_menu 0 "$this " 0 {} [$this info class]
$this create_config_menu_special
}
@@ -149,14 +164,14 @@ class VirtualHWComponent {
# Create file selection dialog
catch {delete object ::fsd}
KIFSD::FSD ::fsd \
- -title "[mc {Save configuration}] - [mc $component_name] - [string trim $project {:}] - MCU 8051 IDE" \
+ -title "[mc {Save configuration}] - [mc $component_name] - [$project cget -projectName] - MCU 8051 IDE" \
-master $win \
-directory [$project cget -projectPath] \
-initialfile [file tail $current_filename] \
- -defaultmask 0 -multiple 0 -filetypes {
- {{VH component} {*.vhc} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "VH component"] {*.vhc} ] \
+ [list [mc "All files"] {*} ] \
+ ]
# Open file after press of OK button
::fsd setokcmd "$this save_config_to_file \[::fsd get\]"
@@ -171,14 +186,14 @@ class VirtualHWComponent {
# Create file selection dialog
catch {delete object ::fsd}
KIFSD::FSD ::fsd \
- -title "[mc {Load configuration}] - [mc $component_name] - [string trim $project {:}] - MCU 8051 IDE" \
+ -title "[mc {Load configuration}] - [mc $component_name] - [$project cget -projectName] - MCU 8051 IDE" \
-master $win \
-directory [$project cget -projectPath] \
-initialfile [file tail $current_filename] \
- -defaultmask 0 -multiple 0 -filetypes {
- {{VH component} {*.vhc} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "VH component"] {*.vhc} ] \
+ [list [mc "All files"] {*} ] \
+ ]
# Open file after press of OK button
::fsd setokcmd "$this load_config_from_file \[::fsd get\]"
@@ -208,9 +223,9 @@ class VirtualHWComponent {
-icon question \
-parent $win \
-title [mc "Overwrite file"] \
- -message [mc "A file with name '%s' already exists. Do you want to overwrite it ?" [file tail $filename]]
+ -message [mc "A file with name '%s' already exists. Do you want to overwrite it?" [file tail $filename]]
] != {yes}
- } {
+ } then {
return 0
}
}
@@ -224,7 +239,7 @@ class VirtualHWComponent {
# Try to open the file
if {[catch {
- set file [open $filename {w} 420]
+ set file [open $filename {w} 0640]
}]} then {
tk_messageBox \
-type ok \
@@ -241,15 +256,14 @@ class VirtualHWComponent {
# Save configuration to the file
puts $file "# MCU 8051 IDE: Virtual HW component configuration file"
- puts $file "# Date: [clock format [clock seconds] -format {%D}]"
- puts $file "# Project: [string trim $project {:}]"
+ puts $file "# Project: [$project cget -projectName]"
puts $file "# Component: $component_name\n"
puts $file $config
# Finalize
set current_filename $filename
close $file
- set modified 0
+ clear_modified
return 1
}
@@ -310,18 +324,19 @@ class VirtualHWComponent {
# Finalize ...
set current_filename $filename
close $file
- set modified 0
+ clear_modified
return 1
}
## Show help dialog
+ # @parm Bool leave_empty=0 - Do not write implicitly anything into the help window
# @return void
- public method show_help {} {
+ public method show_help {{leave_empty 0}} {
# Increment counter of help dialog instances
incr hlp_dlg_count
# Create toplevel window
- set dialog [toplevel .help_dialog_${class_name}_${hlp_dlg_count} -class {Help} -bg {#EEEEEE}]
+ set dialog [toplevel .help_dialog_${class_name}_${hlp_dlg_count} -class {Help} -bg ${::COMMON_BG_COLOR}]
## Create top frame (header and icon)
set top_frame [frame $dialog.top_frame]
@@ -332,7 +347,7 @@ class VirtualHWComponent {
# Header text
pack [label $top_frame.header_label \
-anchor w -justify left \
- -text $component_name \
+ -text [namespace eval ::$class_name "mc {$component_name}"] \
] -side left
pack $top_frame -anchor n -pady 2
@@ -351,20 +366,15 @@ class VirtualHWComponent {
-command "$text_widget yview" \
] -side right -fill y
# Finalize ...
- pack $main_frame -fill both -expand 1
+ pack $main_frame -fill both -expand 1 -padx 2
- ## Create bottom frame (button close)
- # Separator
- pack [ttk::separator $dialog.sep \
- -orient horizontal \
- ] -fill x
# Button "Close"
pack [ttk::button $dialog.close_button \
-text [mc "Close"] \
-compound left \
-image ::ICONS::16::button_cancel \
-command "destroy $dialog" \
- ] -ipady 0
+ ] -ipady 0 -pady 2
# Create text tags in the text widget
@@ -373,30 +383,32 @@ class VirtualHWComponent {
# Fill in the text widget with the help message
$this show_help_special $text_widget
- ## Display section "Wire colors"
- $text_widget insert insert "\n\n"
- $text_widget insert insert [mc "Wire colors:"]
- $text_widget tag add tag_bold {insert linestart} {insert lineend}
- $text_widget insert insert "\n"
- # Create canvas widget
- set cw [canvas $text_widget.canvas\
- -bg {#FFFFFF} \
- -takefocus 0 \
- -cursor left_ptr \
- -bd 0 -relief flat \
- -width 170 -height 110 \
- ]
- bind $cw <Button-5> "$text_widget yview scroll +5 units; break"
- bind $cw <Button-4> "$text_widget yview scroll -5 units; break"
- # Fill in the canvas widget
- $project Graph_create_legend $cw 1
- # Show the canvas widget
- $text_widget window create insert -window $cw
+ if {!$leave_empty} {
+ ## Display section "Wire colors"
+ $text_widget insert insert "\n\n"
+ $text_widget insert insert [mc "Wire colors:"]
+ $text_widget tag add tag_bold {insert linestart} {insert lineend}
+ $text_widget insert insert "\n"
+ # Create canvas widget
+ set cw [canvas $text_widget.canvas\
+ -bg {#FFFFFF} \
+ -takefocus 0 \
+ -cursor left_ptr \
+ -bd 0 -relief flat \
+ -width 170 -height 110 \
+ ]
+ bind $cw <Button-5> "$text_widget yview scroll +5 units; break"
+ bind $cw <Button-4> "$text_widget yview scroll -5 units; break"
+ # Fill in the canvas widget
+ $project Graph_create_legend $cw 1
+ # Show the canvas widget
+ $text_widget window create insert -window $cw
+ }
# Finalize ...
$text_widget configure -state disabled
- wm minsize $dialog 300 300
- wm title $dialog $component_name
+ wm minsize $dialog [expr {int(300 * $::font_size_factor)}] [expr {int(300 * $::font_size_factor)}]
+ wm title $dialog [namespace eval ::$class_name "mc {$component_name}"]
wm iconphoto $dialog ::ICONS::16::help
focus -force $dialog.close_button
}
@@ -411,13 +423,17 @@ class VirtualHWComponent {
## Adjust apparence of "ON/OFF" button
# Turn ON
if {$state} {
- $start_stop_button configure -style GreenBg.TButton -text "ON"
+ $start_stop_button configure -style GreenBg.TButton -text [mc "ON"]
# Turn OFF
} else {
- $start_stop_button configure -style RedBg.TButton -text "OFF"
+ $start_stop_button configure -style RedBg.TButton -text [mc "OFF"]
}
# Call component specific procedure
$this on_off_special
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/pale/virtual_uart_term.tcl b/lib/pale/virtual_uart_term.tcl
new file mode 100644
index 0000000..f78b803
--- /dev/null
+++ b/lib/pale/virtual_uart_term.tcl
@@ -0,0 +1,1682 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# Copyright (C) 2011 by Martin Ošmera #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _VIRTUAL_UART_TERM_TCL ] } {
+set _VIRTUAL_UART_TERM_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+#
+# -------------------------------------------------------------------------
+
+class VirtualUARTTerminal {
+ inherit VirtualHWComponent
+
+ # Font: Big bold font
+ common bold_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] -weight {bold} \
+ ]
+ # Font: Tiny normal font
+ common tiny_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-9 * $::font_size_factor)}] -weight {normal} \
+ ]
+ # Font: Tiny bold font
+ common tiny_font_bold [font create \
+ -family {helvetica} \
+ -size [expr {int(-9 * $::font_size_factor)}] -weight {bold} \
+ ]
+ # Font: Normal font
+ common normal_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-11 * $::font_size_factor)}] -weight {normal} \
+ ]
+ # Font: Also normal font, but a bit larger
+ common big_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] -weight {normal} \
+ ]
+ # Font: Font to be used in the panel -- bold
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
+ ]
+
+ # List of Int: Available baud rates for RS232
+ common available_baud_rates {
+ 50 75 110 134 150 200
+ 300 600 1200 1800 2400 4800
+ 9600 19200 38400 57600 115200 230400
+ 460800
+ }
+
+ common COMPONENT_NAME "Virtual UART Terminal" ;# Name of this component
+ common CLASS_NAME "VirtualUARTTerminal" ;# Name of this class
+ common COMPONENT_ICON {chardevice} ;# Icon for this panel (16x16)
+
+ # Configuration menu
+ common CONFMENU {
+ {command {Show log window} {} 5 "show_log" {bar5}
+ "Display the log of events which are currently happening in the simulated UART driver"}
+ {separator}
+ {command {Show help} {} 5 "show_help 1" {help}
+ "Show brief help"}
+ {separator}
+ {command {Save configuration} {} 0 "save_as" {filesave}
+ "Save configuration into a file"}
+ {command {Load configuration} {} 0 "load_from" {fileopen}
+ "Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::VirtualUARTTerminal::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
+ }
+
+ common rect_size 12
+ common empty_fill {#888888}
+ common empty_outline {#AAAAAA}
+
+ common MAX_LOG_LENGTH 100 ;# Int: Maximum number of row in the log window
+
+ ## PRIVATE
+ private variable status_bar_label ;# Widget: Status bar
+
+ private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
+ private variable connection_pin ;# Array of Int: Index is key number, value is bit number or {-}
+
+ private variable baud_conf {9600} ;# Int: Selected baud rate for communication
+ private variable parity_conf {n} ;# Char: Selected type of parity
+ private variable data_conf {8} ;# Int: Number of data bits
+ private variable stop_conf {1} ;# Int: Number of stop bits
+
+ private variable baud_cb ;#
+ private variable parity_cb ;#
+ private variable data_cb ;#
+ private variable stop_cb ;#
+
+ private variable send_selected_button
+ private variable clear_selected_snd_button
+ private variable clear_selected_rec_button
+
+ private variable enaged ;# Array of Bool: enaged(port_num,bit_num) --> Is connected to this device ?
+ private variable usr_note
+ private variable cb
+ private variable sbuf_r_canvas
+ private variable sbuf_t_canvas
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
+
+ private variable controls_frame
+
+ private variable log_win_text {}
+ private variable warning_indicator {}
+ private variable log_time_mark 0
+ private variable log_window_geometry {}
+ private variable log_enabled 1 ;# Bool: Logging of events enabled (slower simulation)
+ private variable log_on_off_chbut ;# Widget: Checkbox for enabling and disabling the logging of events
+
+ private variable time_mark 0 ;# Int: Time mark pointing to this point of time according to the MCU simulator engine
+ private variable bit_time 104166.666
+ private variable bit_rect
+ private variable arrow
+ private variable reg_val
+
+ private variable graph_position
+ private variable graph_prev_state
+ private variable graph_elements
+
+ private variable send_hexeditor
+ private variable receive_hexeditor
+ private variable reception_address 0
+
+ private variable rxd_signal 1 ;# Bool:
+ private variable rxd_signal_prev 1
+ private variable reception_in_progress 0
+ private variable reception_bit_no
+ private variable reception_sample_time
+ private variable reception_data 0
+
+ private variable output_buffer {}
+ private variable transmission_in_prog 0
+ private variable byte_to_send -1
+ private variable transmission_bit_no -1
+ private variable transmission_sample_time
+ private variable last_txd 1
+
+
+ ## Object constructor
+ # @parm Object _project - Project object
+ constructor {_project} {
+ # Set object variables identifing this component (see the base class)
+ set component_name $COMPONENT_NAME
+ set class_name $CLASS_NAME
+ set component_icon $COMPONENT_ICON
+
+ # Set other object variables
+ set project $_project
+ array set connection_port {0 - 1 - 2 - 3 - 4 - 5 -}
+ array set connection_pin {0 - 1 - 2 - 3 - 4 - 5 -}
+ array set arrow {
+ r {}
+ r8 {}
+ t {}
+ t8 {}
+ }
+ array set reg_val {
+ rxd {}
+ txd {}
+ }
+ array set graph_position {
+ t 0 r 0
+ }
+ array set graph_prev_state {
+ t 1 r 1
+ }
+ array set graph_elements {
+ t {} r {}
+ }
+
+ for {set port 0} {$port < 5} {incr port} {
+ for {set bit 0} {$bit < 8} {incr bit} {
+ set enaged($port,$bit) 0
+ }
+ }
+
+ # Inform PALE
+ $project pale_register_input_device $this
+ $project pale_set_modified
+
+ # Create panel GUI
+ create_gui
+ mcu_changed
+ on_off [$project pale_is_enabled]
+ create_log
+
+ # ComboBoxes to default state
+ for {set i 0} {$i < 2} {incr i} {
+ $cb(b$i) current 0
+ $cb(p$i) current 0
+ }
+ }
+
+ ## Object destructor
+ destructor {
+ # Inform PALE
+ $project pale_unregister_input_device $this
+
+ # Destroy GUI
+ destroy $win
+ }
+
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $VirtualUARTTerminal::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
+ ## Reconnect the specified line to another port pin
+ # @parm Int i - line number (0..1)
+ # @return void
+ public method reconnect {i} {
+ # Adjust connections
+ set connection_port($i) [$cb(p$i) get]
+ set connection_pin($i) [$cb(b$i) get]
+ if {$connection_pin($i) != {-}} {
+ set connection_pin($i) [expr {7 - $connection_pin($i)}]
+ }
+
+ # Reevaluate array of MCU port pins engaged by this device
+ evaluete_enaged_pins
+
+ # Change state of the device
+ if {$drawing_on} {
+ $project pale_reevaluate_IO
+ }
+
+ # Set flag modified
+ set_modified
+ }
+
+ ## Reevaluate array of MCU port pins engaged by this device
+ # @return void
+ private method evaluete_enaged_pins {} {
+ # Mark all as disengaged and infrom PALE
+ for {set port 0} {$port < 5} {incr port} {
+ for {set bit 0} {$bit < 8} {incr bit} {
+ if {$enaged($port,$bit)} {
+ $project pale_disengage_pin_by_input_device $port $bit $this
+ set enaged($port,$bit) 0
+ }
+ }
+ }
+
+ # Find the engaged ones and infrom PALE
+ for {set i 0} {$i < 1} {incr i} {
+ set port $connection_port($i)
+ set bit $connection_pin($i)
+
+ if {$port == {-} || $bit == {-}} {
+ continue
+ }
+
+ set enaged($port,$bit) 1
+ $project pale_engage_pin_by_input_device $port $bit $this
+ }
+ }
+
+ ## Invoke interrupt monitor window
+ # @return void
+ private method create_gui {} {
+ set dialog_opened 1
+
+ # Create window
+ set win [toplevel .virtual_uart_term$count -class [mc "UART Monitor"] -bg ${::COMMON_BG_COLOR}]
+ incr count
+
+ # Create status bar
+ set status_bar_label [label $win.status_bar_label -justify left -pady 0 -anchor w]
+ pack $status_bar_label -side bottom -fill x
+
+ set main_frame [frame $win.main_frame]
+ create_top_frame $main_frame ;# Create top frame
+ create_bottom_frame $main_frame ;# Create bottom frame
+ pack $main_frame -fill both -expand 1
+
+ # Configure window
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
+ wm iconphoto $win ::ICONS::16::_chardevice
+ wm resizable $win 0 0
+ wm protocol $win WM_DELETE_WINDOW [list $this close_window]
+ bindtags $win [list $win Toplevel all .]
+ }
+
+ ## Create the log dialog window, but do not show it until method show_log is called
+ # @return void
+ public method create_log {} {
+ # Create the dialog window (hidden for now)
+ set dialog $win.log_window
+ toplevel $dialog
+ wm withdraw $dialog
+
+ ## Create main frame (text and scrollbar)
+ set main_frame [frame $dialog.main_frame]
+ # Text widget
+ set text_widget [text $main_frame.text \
+ -width 0 -height 0 -font $hlp_normal_font \
+ -yscrollcommand [list $main_frame.scrollbar set] \
+ -wrap word -padx 5 -pady 5 -state disabled \
+ ]
+ set log_win_text $text_widget
+ bindtags $text_widget [list $text_widget Text $win all .]
+ pack $text_widget -side left -fill both -expand 1
+ # Create text tag in the text widget
+ $text_widget tag configure tag_info -foreground {#FFFFFF} -background {#0000EE}
+ $text_widget tag configure tag_warning -foreground {#FFFFFF} -background {#EE8800}
+ $text_widget tag configure tag_error -foreground {#FFFFFF} -background {#DD0000}
+ $text_widget tag configure tag_line \
+ -background {#DDDDDD} \
+ -font [font create \
+ -family ${::DEFAULT_FIXED_FONT} \
+ -size -1 \
+ ]
+
+ # Scrollbar
+ pack [ttk::scrollbar $main_frame.scrollbar \
+ -orient vertical \
+ -command [list $text_widget yview] \
+ ] -side right -fill y
+ # Finalize ...
+ pack $main_frame -fill both -expand 1 -padx 2
+
+ # Create bottom frame
+ set bottom_frame [frame $dialog.bottom_frame]
+ # Button "Close"
+ pack [ttk::button $bottom_frame.close_button \
+ -text [mc "Close"] \
+ -compound left \
+ -image ::ICONS::16::button_cancel \
+ -command [list $this close_log_win] \
+ ] -side right
+ pack [ttk::button $bottom_frame.clear_button \
+ -text [mc "Clear log"] \
+ -compound left \
+ -image ::ICONS::16::editdelete \
+ -command "
+ $text_widget configure -state normal
+ $text_widget delete 0.0 end
+ $text_widget configure -state disabled
+ " \
+ ] -side left
+ # CheckBox: "Enable log"
+ set log_on_off_chbut [checkbutton $bottom_frame.on_off_chbut \
+ -command [list $this log_on_off] \
+ -text [mc "Enable log"] \
+ ]
+ if {$log_enabled} {
+ $log_on_off_chbut select
+ } else {
+ $log_on_off_chbut deselect
+ }
+ setStatusTip -widget $log_on_off_chbut -text [mc "Disabled logging may notably improve simulation speed"]
+ DynamicHelp::add $log_on_off_chbut -text [mc "Disabled logging may notably improve simulation speed"]
+ pack $log_on_off_chbut -side left -padx 5
+ pack $bottom_frame -pady 2 -padx 5 -fill x
+
+ # Set window parameters
+ wm minsize $dialog [expr {int(300 * $::font_size_factor)}] [expr {int(150 * $::font_size_factor)}]
+ wm iconphoto $dialog ::ICONS::16::bar5
+ wm title $dialog [mc "UART simulator log - MCU 8051 IDE"]
+ wm protocol $dialog WM_DELETE_WINDOW [list $this close_log_win]
+ bindtags $dialog [list $dialog Toplevel $win all .]
+ }
+
+ ## Show the log window
+ # The log window must have been once created by method create_log prior to
+ #+ the call to this method
+ # @return void
+ public method show_log {} {
+ if {$warning_indicator != {}} {
+ destroy $warning_indicator
+ set warning_indicator {}
+ }
+
+ set dialog $win.log_window
+ if {[wm state $dialog] == {normal}} {
+ raise $dialog
+ return
+ }
+ if {![winfo exists $dialog]} {
+ return
+ }
+ wm deiconify $dialog
+ if {$log_window_geometry != {}} {
+ wm geometry $dialog $log_window_geometry
+ }
+ }
+
+ ## Enable or disable logging of events
+ # @return void
+ public method log_on_off {} {
+ set log_enabled [expr {!$log_enabled}]
+
+ # Set flag modified
+ set_modified
+ }
+
+ ## Close the DS1620 log window
+ # @return void
+ public method close_log_win {} {
+ set dialog $win.log_window
+ if {![winfo exists $dialog]} {
+ return
+ }
+
+ set log_window_geometry [wm geometry $dialog]
+ wm withdraw $dialog
+ }
+
+ ## Set status bar tip for specified widget
+ # @parm Widget widget - Target widget
+ # @parm String text - Text of the stutus tip
+ # @return void
+ private method termial_set_status_tip {widget text} {
+ bind $widget <Enter> "$status_bar_label configure -text {$text}"
+ bind $widget <Leave> "$status_bar_label configure -text {}"
+ }
+
+ private method create_top_top_frame {target_frame} {
+ set target_frame [frame $target_frame.target_frame -pady 5 -padx 5]
+ set controls_frame $target_frame
+
+ # - Baud rate
+ grid [label $target_frame.baud_lbl \
+ -text [mc "Baud rate"] \
+ ] -row 1 -column 5 -sticky w
+ set baud_cb [ttk::combobox $target_frame.baud_cb \
+ -state readonly \
+ -width 6 \
+ -exportselection 0 \
+ -values $available_baud_rates \
+ ]
+ bind $baud_cb <<ComboboxSelected>> \
+ "$this change_port_config b \[$target_frame.baud_cb get\]"
+ termial_set_status_tip $baud_cb [mc "Connection speed in bps"]
+ grid $baud_cb -row 1 -column 6 -sticky w
+ $target_frame.baud_cb current [lsearch [$target_frame.baud_cb cget -values] $baud_conf]
+ # - Parity
+ grid [label $target_frame.parity_lbl \
+ -text [mc "Parity"] \
+ ] -row 2 -column 5 -sticky w
+ set parity_cb [ttk::combobox $target_frame.parity_cb \
+ -values {none odd even} \
+ -state readonly \
+ -width 6 \
+ -exportselection 0 \
+ ]
+ bind $parity_cb <<ComboboxSelected>> \
+ "$this change_port_config p \[$target_frame.parity_cb get\]"
+ termial_set_status_tip $parity_cb [mc "Parity"]
+ grid $parity_cb -row 2 -column 6 -sticky w
+ $target_frame.parity_cb current [lsearch {n o e m s} $parity_conf]
+ # - Data bits
+ grid [label $target_frame.data_lbl \
+ -text [mc "Data bits"] \
+ ] -row 1 -column 8 -sticky w
+ set data_cb [ttk::combobox $target_frame.data_cb \
+ -state readonly \
+ -width 1 \
+ -values {5 6 7 8} \
+ -exportselection 0 \
+ ]
+ bind $data_cb <<ComboboxSelected>> \
+ "$this change_port_config d \[$target_frame.data_cb get\]"
+ termial_set_status_tip $data_cb [mc "Number of data bits"]
+ grid $data_cb -row 1 -column 9 -sticky w
+ $target_frame.data_cb current [lsearch [$target_frame.data_cb cget -values] $data_conf]
+ # - Stop bits
+ grid [label $target_frame.stop_lbl \
+ -text [mc "Stop bits"] \
+ ] -row 2 -column 8 -sticky w
+ set stop_cb [ttk::combobox $target_frame.stop_cb \
+ -state readonly \
+ -width 1 \
+ -values {1 2} \
+ -exportselection 0 \
+ ]
+ bind $stop_cb <<ComboboxSelected>> \
+ "$this change_port_config s \[$target_frame.stop_cb get\]"
+ termial_set_status_tip $stop_cb [mc "Number of stop bits"]
+ grid $stop_cb -row 2 -column 9 -sticky w
+ $target_frame.stop_cb current [lsearch [$target_frame.stop_cb cget -values] $stop_conf]
+
+ # Create "ON/OFF" button
+ set start_stop_button [ttk::button $target_frame.start_stop_button \
+ -command [list $this on_off_button_press] \
+ -style Flat.TButton \
+ -width 3 \
+ ]
+ DynamicHelp::add $target_frame.start_stop_button \
+ -text [mc "Turn HW simulation on/off"]
+ setStatusTip -widget $start_stop_button -text [mc "Turn HW simulation on/off"]
+ bind $start_stop_button <Button-3> "$this on_off_button_press; break"
+ bindtags $start_stop_button [list $start_stop_button TButton all .]
+ grid $start_stop_button -row 1 -column 1 -sticky w
+
+ # Create configuration menu button
+ set conf_button [ttk::button $target_frame.conf_but \
+ -image ::ICONS::16::configure \
+ -style Flat.TButton \
+ -command [list $this config_menu] \
+ ]
+ setStatusTip -widget $conf_button -text [mc "Configure"]
+ bindtags $conf_button [list $conf_button TButton all .]
+ grid $conf_button -row 1 -column 2 -sticky w
+
+ grid [label $target_frame.note_lbl \
+ -text [mc "Note:"] \
+ ] -row 2 -column 1 -sticky w
+ set usr_note [ttk::entry $target_frame.usr_note \
+ -validate key \
+ -validatecommand [list $this set_modified] \
+ -width 30 \
+ ]
+ bindtags $usr_note [list $usr_note TEntry all .]
+ grid $usr_note -row 2 -column 2 -sticky w
+
+ grid columnconfigure $target_frame 4 -weight 1
+ grid columnconfigure $target_frame 7 -minsize 10
+
+ return $target_frame
+ }
+
+ ##
+ # @parm Widget target_frame - Parent frame
+ # @return Widget - Created frame
+ private method create_sbuf_t_frame {target_frame} {
+ set sbuf_t_frame [frame $target_frame.sbuf_t_frame]
+ set sbuf_t_canvas [canvas $sbuf_t_frame.sbuf_t_canvas \
+ -bg $::COMMON_BG_COLOR \
+ -width 250 \
+ -height 60 \
+ -highlightthickness 0 \
+ ]
+ set canvas $sbuf_t_canvas
+
+ set cb(p0) [ttk::combobox $canvas.cb_p0 \
+ -width 1 \
+ -font $cb_font \
+ -state readonly \
+ ]
+ bind $cb(p0) <<ComboboxSelected>> [list $this reconnect 0]
+ bindtags $cb(p0) [list $cb(p0) TCombobox all .]
+
+ set cb(b0) [ttk::combobox $canvas.cb_b0 \
+ -width 1 \
+ -font $cb_font \
+ -values {- 0 1 2 3 4 5 6 7} \
+ -state readonly \
+ ]
+ bind $cb(b0) <<ComboboxSelected>> [list $this reconnect 0]
+ bindtags $cb(b0) [list $cb(b0) TCombobox all .]
+
+ $canvas create text 45 0 \
+ -text {TxD} \
+ -font ${::Simulator_GUI::bitfont} \
+ -anchor ne
+ $canvas create window 30 40 \
+ -window $cb(p0) \
+ -anchor ne
+ $canvas create window 30 40 \
+ -window $cb(b0) \
+ -anchor nw
+ $canvas create text 45 20 \
+ -text {SBUF-T} \
+ -font ${::Simulator_GUI::bitfont} \
+ -anchor ne
+ $canvas create text 210 0 \
+ -text {Parity} \
+ -font ${::Simulator_GUI::bitfont} \
+ -anchor nw
+ set reg_val(txd) [$canvas create text 210 20 \
+ -text { -- } \
+ -font ${::Simulator_GUI::bitfont} \
+ -anchor nw \
+ ]
+
+ set labels [list S 0 1 2 3 4 5 6 7 P S]
+
+ set x 50
+ set y 20
+ for {set i 0} {$i < 11} {incr i} {
+ if {$i == 1 || $i == 9 || $i == 10} {
+ incr x 3
+ } else {
+ incr x 1
+ }
+
+ set bit_rect(t,$i) [$canvas create rectangle $x $y \
+ [expr {$x + $rect_size}] [expr {$y + $rect_size}] \
+ -fill $empty_fill -outline $empty_outline \
+ ]
+ $canvas create text \
+ [expr {$x + ($rect_size / 2)}] \
+ [expr {$y + ($rect_size / 2)}] \
+ -text [lindex $labels $i] \
+ -font $tiny_font
+
+ incr x $rect_size
+ }
+
+ # Create dash line pointing to parity bit
+ set pos [expr {55 + $rect_size + 9 * ($rect_size + 1) - ($rect_size + 1) / 2}]
+ $canvas create line 210 6 $pos 6 $pos 20 -arrow none -dash {,}
+
+ # Draw graph grid
+ for {set x 65} {$x < 250} {incr x 5} {
+ $canvas create line $x 43 $x 58 -fill {#AAAAAA} -tags grid -dash .
+ }
+
+ pack $sbuf_t_canvas -padx 5 -pady 5 -fill x
+ return $sbuf_t_frame
+ }
+
+ ##
+ # @parm Widget target_frame - Parent frame
+ # @return Widget - Created frame
+ private method create_sbuf_r_frame {target_frame} {
+ set sbuf_r_frame [frame $target_frame.sbuf_r_frame]
+ set sbuf_r_canvas [canvas $sbuf_r_frame.sbuf_r_canvas \
+ -bg $::COMMON_BG_COLOR \
+ -width 250 \
+ -height 60 \
+ -highlightthickness 0 \
+ ]
+ set canvas $sbuf_r_canvas
+
+ set cb(p1) [ttk::combobox $canvas.cb_p1 \
+ -width 1 \
+ -font $cb_font \
+ -state readonly \
+ ]
+ bind $cb(p1) <<ComboboxSelected>> [list $this reconnect 1]
+ bindtags $cb(p1) [list $cb(p1) TCombobox all .]
+
+ set cb(b1) [ttk::combobox $canvas.cb_b1 \
+ -width 1 \
+ -font $cb_font \
+ -values {- 0 1 2 3 4 5 6 7} \
+ -state readonly \
+ ]
+ bind $cb(b1) <<ComboboxSelected>> [list $this reconnect 1]
+ bindtags $cb(b1) [list $cb(b1) TCombobox all .]
+
+ $canvas create text 45 0 \
+ -text {RxD} \
+ -font ${::Simulator_GUI::bitfont} \
+ -anchor ne
+ $canvas create window 30 40 \
+ -window $cb(p1) \
+ -anchor ne
+ $canvas create window 30 40 \
+ -window $cb(b1) \
+ -anchor nw
+ $canvas create text 45 20 \
+ -text {SBUF-R} \
+ -font ${::Simulator_GUI::bitfont} \
+ -anchor ne
+ $canvas create text 210 0 \
+ -text {Parity} \
+ -font ${::Simulator_GUI::bitfont} \
+ -anchor nw
+ set reg_val(rxd) [$canvas create text 210 20 \
+ -text { -- } \
+ -font ${::Simulator_GUI::bitfont} \
+ -anchor nw \
+ ]
+
+ set labels [list S 0 1 2 3 4 5 6 7 P S]
+
+ set x 50
+ set y 20
+ for {set i 0} {$i < 11} {incr i} {
+ if {$i == 1 || $i == 9 || $i == 10} {
+ incr x 3
+ } else {
+ incr x 1
+ }
+
+ set bit_rect(r,$i) [$canvas create rectangle $x $y \
+ [expr {$x + $rect_size}] [expr {$y + $rect_size}] \
+ -fill $empty_fill -outline $empty_outline \
+ ]
+ $canvas create text \
+ [expr {$x + ($rect_size / 2)}] \
+ [expr {$y + ($rect_size / 2)}] \
+ -font $tiny_font \
+ -text [lindex $labels $i]
+
+ incr x $rect_size
+ }
+
+ set_bit_arrow r 0
+
+ set pos [expr {55 + $rect_size + 9 * ($rect_size + 1) - ($rect_size + 1) / 2}]
+ $canvas create line 210 6 $pos 6 $pos 20 -arrow none -dash {,}
+
+ # Draw graph grid
+ for {set x 65} {$x < 250} {incr x 5} {
+ $canvas create line $x 43 $x 58 -fill {#AAAAAA} -tags grid -dash .
+ }
+
+ pack $sbuf_r_canvas -padx 5 -pady 5 -fill x
+ return $sbuf_r_frame
+ }
+
+ ## Create top frame in the dialog window (connector_canvas (left) and configuration (right))
+ # @parm Widget target_frame - Parent frame
+ # @return void
+ private method create_top_frame {target_frame} {
+ grid [create_top_top_frame $target_frame] -row 1 -column 1 -sticky nwes -columnspan 4 -padx 1
+ grid [create_sbuf_t_frame $target_frame] -row 2 -column 1 -sticky nwes -columnspan 2 -padx 1
+ grid [create_sbuf_r_frame $target_frame] -row 2 -column 3 -sticky nwes -columnspan 2 -padx 1
+ }
+
+ ## Create bottom frame (hexadecimal editors)
+ # @parm Widget target_frame - Parent frame
+ # @return void
+ private method create_bottom_frame {target_frame} {
+ # Create headers ("Data to send", "Received data")
+ grid [label $target_frame.lbl_a \
+ -text [mc "Data to send"] \
+ -compound right \
+ -image ::ICONS::16::forward \
+ -padx 15 -font $bold_font \
+ ] -row 4 -column 1 -columnspan 2
+ grid [label $target_frame.lbl_b \
+ -text [mc "Received data"] \
+ -compound left \
+ -image ::ICONS::16::forward \
+ -padx 15 -font $bold_font \
+ ] -row 4 -column 3 -columnspan 2
+
+ # Create hexadecimal editors
+ set send_hexeditor [HexEditor #auto \
+ $target_frame.send_hexeditor 8 32 2 \
+ hex 1 1 5 256 \
+ ]
+ [$send_hexeditor getLeftView] configure -exportselection 0
+ $send_hexeditor bindSelectionAction [list $this hexeditor_selection s]
+ grid $target_frame.send_hexeditor -row 5 -column 1 -columnspan 2
+
+ set receive_hexeditor [HexEditor #auto \
+ $target_frame.receive_hexeditor 8 32 2 \
+ hex 1 1 5 256 \
+ ]
+ [$send_hexeditor getLeftView] configure -exportselection 0
+ $receive_hexeditor bindSelectionAction [list $this hexeditor_selection r]
+ $receive_hexeditor set_bg_hg $reception_address 1 0
+ grid $target_frame.receive_hexeditor -row 5 -column 3 -columnspan 2
+
+ # Create buttons "Send selected" and "Clear selected" in send part
+ set send_selected_button [ttk::button \
+ $target_frame.send_selected_button \
+ -text [mc "Send selected"] \
+ -image ::ICONS::16::forward \
+ -command [list $this send_selected] \
+ -compound left \
+ -state disabled \
+ ]
+ set clear_selected_snd_button [ttk::button \
+ $target_frame.clear_selected_snd_button \
+ -text [mc "Clear selected"] \
+ -image ::ICONS::16::eraser \
+ -command [list $this clear_selected_snd]\
+ -compound left \
+ -state disabled \
+ ]
+ termial_set_status_tip $send_selected_button [mc "Send selected data"]
+ termial_set_status_tip $clear_selected_snd_button [mc "Remove selected data"]
+ grid $send_selected_button -row 6 -column 1 -sticky we
+ grid $clear_selected_snd_button -row 6 -column 2 -sticky we
+
+ # Create buttons "Receive here" and "Clear selected" in reception part
+ set receive_here_button [ttk::button \
+ $target_frame.receive_here_button \
+ -text [mc "Receive here"] \
+ -image ::ICONS::16::down0 \
+ -command [list $this receive_here] \
+ -compound left \
+ ]
+ set clear_selected_rec_button [ttk::button \
+ $target_frame.clear_selected_rec_button \
+ -text [mc "Clear selected"] \
+ -image ::ICONS::16::eraser \
+ -command [list $this clear_selected_rec]\
+ -compound left \
+ -state disabled \
+ ]
+ termial_set_status_tip $receive_here_button [mc "Receive data on current cursor position"]
+ termial_set_status_tip $clear_selected_rec_button [mc "Remove selected data"]
+ grid $receive_here_button -row 6 -column 3 -sticky we
+ grid $clear_selected_rec_button -row 6 -column 4 -sticky we
+ }
+
+ ## Determinate which port pin is connected to the specified LED
+ # @parm Int i - LED number
+ # @return List - {port_number bit_number}
+ private method which_port_pin {i} {
+ return [list $connection_port($i) $connection_pin($i)]
+ }
+
+ ## Handle "ON/OFF" button press
+ # Turn whole PALE system on or off
+ # @return void
+ public method on_off_button_press {} {
+ $project pale_all_on_off
+ }
+
+ public method clear_selected_rec {} {
+ set rangeofselection [$receive_hexeditor getRangeOfSelection]
+ if {$rangeofselection == {}} {
+ return
+ }
+
+ set start_cell [lindex $rangeofselection 0]
+ set end_cell [lindex $rangeofselection 1]
+
+ for {set i $start_cell} {$i <= $end_cell} {incr i} {
+ $receive_hexeditor setValue $i {}
+ }
+ }
+
+ public method clear_selected_snd {} {
+ # Get range of text indexes determinating the selection
+ set rangeofselection [$send_hexeditor getRangeOfSelection]
+ if {$rangeofselection == {}} {
+ return
+ }
+
+ # Determinate index of the start and end cell
+ set start_cell [lindex $rangeofselection 0]
+ set end_cell [lindex $rangeofselection 1]
+
+ # Clear all selected cell one by one
+ for {set i $start_cell} {$i <= $end_cell} {incr i} {
+ $send_hexeditor setValue $i {}
+ }
+ }
+
+ public method send_selected {} {
+ # Get range of text indexes determinating the selection
+ set rangeofselection [$send_hexeditor getRangeOfSelection]
+ if {$rangeofselection == {}} {
+ return
+ }
+
+ if {$transmission_in_prog} {
+ return
+ }
+
+ set transmission_in_prog 1
+ set byte_to_send -1
+ set output_buffer [list]
+ set start_cell [lindex $rangeofselection 0]
+ set end_cell [lindex $rangeofselection 1]
+ foreach value [$send_hexeditor get_values $start_cell $end_cell] {
+ if {$value == {}} {
+ continue
+ }
+ lappend output_buffer [expr "0x$value"]
+ }
+
+ write_to_log I [mc "TxD: Starting transmission of block"]
+
+ $send_selected_button configure \
+ -text [mc "Stop transmission"] \
+ -image ::ICONS::16::fileclose \
+ -command [$this stop_transmission]
+ }
+
+ public method hexeditor_selection {source anything_selected} {
+ if {$anything_selected} {
+ set state {normal}
+ } else {
+ set state {disabled}
+ }
+
+ if {$source == {s}} {
+ if {!$transmission_in_prog} {
+ $send_selected_button configure -state $state
+ }
+ $clear_selected_snd_button configure -state $state
+ } else {
+ $clear_selected_rec_button configure -state $state
+ }
+ }
+
+ public method change_port_config {what new_value} {
+ switch -- $what {
+ b {
+ set baud_conf $new_value
+ set bit_time [expr {1000000000.0 / $baud_conf}]
+ }
+ p {
+ switch -- $new_value {
+ {none} {
+ set new_value {n}
+ }
+ {odd} {
+ set new_value {o}
+ }
+ {even} {
+ set new_value {e}
+ }
+ }
+
+ set parity_conf $new_value
+ }
+ d {
+ set data_conf $new_value
+ }
+ s {
+ set stop_conf $new_value
+ }
+ }
+ }
+
+ ## Change reception adddress to address of the current cell
+ # @return void
+ public method receive_here {} {
+ set cell [$receive_hexeditor getCurrentCell]
+ set reception_address $cell
+
+ $receive_hexeditor clearBgHighlighting 0
+ $receive_hexeditor set_bg_hg $cell 1 0
+ }
+
+ private method set_bit_color {interface bit state} {
+ if {$interface == {r}} {
+ set canvas $sbuf_r_canvas
+ } else {
+ set canvas $sbuf_t_canvas
+ }
+
+ if {$state == 1} {
+ set fill ${::BitMap::one_fill}
+ set outline ${::BitMap::one_outline}
+ } elseif {$state == 0} {
+ set fill ${::BitMap::zero_fill}
+ set outline ${::BitMap::zero_outline}
+ } elseif {$state == -1} {
+ set fill {#888888}
+ set outline {#AAAAAA}
+ }
+
+ $canvas itemconfigure $bit_rect($interface,$bit) \
+ -fill $fill \
+ -outline $outline
+ }
+
+ private method set_bit_arrow {interface position} {
+ if {$interface == {r}} {
+ set canvas $sbuf_r_canvas
+ } else {
+ set canvas $sbuf_t_canvas
+ }
+
+ if {$arrow($interface) != {}} {
+ $canvas delete $arrow($interface)
+ }
+ if {$position != -1} {
+ if {!$position} {
+ set corr 0
+ } elseif {$position >= 1 && $position <= 8} {
+ set corr 2
+ } elseif {$position == 9} {
+ set corr 4
+ } else {
+ set corr 6
+ }
+
+ set pos [expr {51 + $rect_size + $position * ($rect_size + 1) - ($rect_size + 1) / 2 + $corr}]
+ set arrow($interface) [$canvas create line 50 6 $pos 6 $pos 20 -arrow last]
+ }
+ }
+
+ private method highlight_arrow {interface highlight} {
+ if {$interface == {r}} {
+ set canvas $sbuf_r_canvas
+ } else {
+ set canvas $sbuf_t_canvas
+ }
+
+ $canvas itemconfigure $arrow($interface) -width [expr {($highlight ? 1 : 0) + 1}]
+ }
+
+ private method graph_clear {interface} {
+ if {$interface == {r}} {
+ set canvas $sbuf_r_canvas
+ } else {
+ set canvas $sbuf_t_canvas
+ }
+
+ $canvas delete graph
+
+ set graph_position($interface) 0
+ set graph_prev_state($interface) 1
+ set graph_elements($interface) [list]
+ }
+
+ private method graph_draw {interface state} {
+ if {$interface == {r}} {
+ set canvas $sbuf_r_canvas
+ } else {
+ set canvas $sbuf_t_canvas
+ }
+
+ if {$graph_position($interface) == 185} {
+ $canvas move graph -1 0
+ foreach item [lindex $graph_elements($interface) 0] {
+ $canvas delete $item
+ }
+ set graph_elements($interface) [lreplace $graph_elements($interface) 0 0]
+ incr graph_position($interface) -1
+ }
+
+ set x_0 [expr {65 + $graph_position($interface)}]
+ set x_1 [expr {$x_0 + 1}]
+
+ switch -- $graph_prev_state($interface) {
+ 0 {
+ switch -- $state {
+ 0 { ;# 0 --> 0
+ lappend graph_elements($interface) [list \
+ [$canvas create line $x_0 58 $x_1 58 -tags graph -fill {#00FF00}] \
+ ]
+ }
+ 1 { ;# 0 --> 1
+ lappend graph_elements($interface) [list \
+ [$canvas create line $x_0 43 $x_0 50 -tags graph -fill {#FF0000}] \
+ [$canvas create line $x_0 50 $x_0 58 -tags graph -fill {#00FF00}] \
+ ]
+ }
+ default {
+ lappend graph_elements($interface) [list \
+ [$canvas create line $x_0 43 $x_0 58 -tags graph -fill {#0000FF}] \
+ ]
+ }
+ }
+ }
+ 1 {
+ switch -- $state {
+ 0 { ;# 1 --> 0
+ lappend graph_elements($interface) [list \
+ [$canvas create line $x_0 43 $x_0 50 -tags graph -fill {#FF0000}] \
+ [$canvas create line $x_0 50 $x_0 58 -tags graph -fill {#00FF00}] \
+ ]
+ }
+ 1 { ;# 1 --> 1
+ lappend graph_elements($interface) [list \
+ [$canvas create line $x_0 43 $x_1 43 -tags graph -fill {#FF0000}] \
+ ]
+ }
+ default {
+ lappend graph_elements($interface) [list \
+ [$canvas create line $x_0 43 $x_0 58 -tags graph -fill {#0000FF}] \
+ ]
+ }
+ }
+ }
+ default {
+ lappend graph_elements($interface) [list \
+ [$canvas create line $x_0 43 $x_0 58 -tags graph -fill {#0055FF}] \
+ ]
+ }
+ }
+
+ incr graph_position($interface)
+ set graph_prev_state($interface) $state
+ }
+
+ ## Write a message to the log
+ # @parm Char type - Message type "I" == Information; "W" == Warning; "E" == Error
+ # @parm String string - Text of the message
+ # @return void
+ private method write_to_log {type string} {
+ # Do not do anything if the log is not available at all
+ if {!$log_enabled || $log_win_text == {}} {
+ return
+ }
+
+ # Enable the text widget
+ $log_win_text configure -state normal
+
+ # Manage the log length, the number of row in the log must not exceed the specified maximum
+ if {int([$log_win_text index end]) > ($MAX_LOG_LENGTH + 1)} {
+ set diff [expr {int([$log_win_text index end]) - $MAX_LOG_LENGTH}]
+ $log_win_text delete 1.0 $diff.0
+ }
+ $log_win_text mark set insert {end -1l lineend}
+
+ # Insert separators (horizontal lines) between events with the same time mark
+ if {$time_mark && $log_time_mark != $time_mark} {
+ set log_time_mark $time_mark
+ $log_win_text insert insert "\n"
+ $log_win_text tag add tag_line insert-1l insert
+ }
+
+ # Insert the information about the message type
+ switch -- $type {
+ {I} { ;# Information
+ $log_win_text insert insert [mc "\[INFO\] "]
+ $log_win_text tag add tag_info {insert linestart} insert-1c
+ }
+ {W} { ;# Warning
+ $log_win_text insert insert [mc "\[WARNING\] "]
+ $log_win_text tag add tag_warning {insert linestart} insert-1c
+ }
+ {E} { ;# Error
+ $log_win_text insert insert [mc "\[ERROR\] "]
+ $log_win_text tag add tag_error {insert linestart} insert-1c
+ }
+ }
+
+ # Insert the message itself
+ $log_win_text insert insert $string
+ $log_win_text insert insert "\n"
+ $log_win_text see insert
+
+ # Disable the text widget
+ $log_win_text configure -state disabled
+
+ #
+ if {$type == {E} && $warning_indicator == {}} {
+ set warning_indicator [label $controls_frame.w_lbl \
+ -image ::ICONS::16::status_unknown \
+ -cursor hand2 \
+ ]
+ grid $warning_indicator -row 2 -column 4
+ bind $warning_indicator <Button-1> [list $this show_log]
+ }
+ }
+
+ # ------------------------------------------------------------------
+ # UART SIMULATOR CORE
+ # ------------------------------------------------------------------
+
+ private method transmission_control {{txd {}}} {
+ if {!$transmission_in_prog} {
+ return $txd
+ }
+
+ if {$byte_to_send == -1} {
+ if {[manage_output_buffer $txd]} {
+ return $txd
+ }
+ }
+
+ if {$time_mark >= $transmission_sample_time} {
+ if {$time_mark >= ($transmission_sample_time + $bit_time)} {
+ write_to_log E [mc "Simulated MCU has clock frequency set too low to even receive the transmitted data!"]
+ } else {
+ stop_transmission 1
+ update_last_txd $txd
+ }
+ }
+
+ return $last_txd
+ }
+
+ private method manage_output_buffer {txd} {
+ if {![llength $output_buffer]} {
+ set transmission_in_prog 0
+
+ $sbuf_t_canvas itemconfigure $reg_val(txd) -text { -- }
+ for {set i 0} {$i < 11} {incr i} {
+ set_bit_color t $i -1
+ }
+
+ highlight_arrow t 0
+ set_bit_arrow t -1
+
+ write_to_log I [mc "TxD: Transmission of block finished"]
+
+ return 1
+ }
+
+ set byte_to_send [lindex $output_buffer 0]
+ set output_buffer [lreplace $output_buffer 0 0]
+ set transmission_bit_no -1
+ set transmission_sample_time 0
+
+ $sbuf_t_canvas itemconfigure $reg_val(txd) -text [format {0x%02X} $byte_to_send]
+
+ set_bit_color t 0 0
+ for {set i 1} {$i <= $data_conf} {incr i} {
+ set_bit_color t $i [expr {$byte_to_send & (1 << ($i - 1))}]
+ }
+ for {set i $data_conf} {$i < 8} {incr i} {
+ set_bit_color t $i -1
+ }
+ if {$parity_conf != {n}} {
+ set_bit_color t 9 [compute_parity $byte_to_send]
+ } else {
+ set_bit_color t 9 -1
+ }
+ set_bit_color t 10 1
+ set_bit_arrow t 0
+ highlight_arrow t 1
+
+ write_to_log I [mc "TxD: Starting transmission of byte: 0x%02X" $byte_to_send]
+
+ return 0
+ }
+
+ private method update_last_txd {txd} {
+ if {$transmission_bit_no == -1} {
+ set transmission_sample_time [expr {$time_mark + $bit_time}]
+ } else {
+ set transmission_sample_time [expr {$transmission_sample_time + $bit_time}]
+ }
+
+ # Send START bit
+ if {$transmission_bit_no == -1} {
+ set txd 0
+ set transmission_bit_no 0
+
+ # Send DATA bit
+ } elseif {$transmission_bit_no < $data_conf} {
+ set txd [expr {($byte_to_send & (1 << $transmission_bit_no)) ? 1 : 0}]
+ incr transmission_bit_no
+
+ # Send PARITY or STOP bit
+ } elseif {$transmission_bit_no == $data_conf} {
+ if {$parity_conf != {n}} {
+ set txd [compute_parity $byte_to_send]
+ set transmission_bit_no 9
+ } else {
+ set txd 1
+ set transmission_bit_no 10
+ }
+
+ # Send STOP bit
+ } elseif {$transmission_bit_no == 9} {
+ set txd 1
+ set transmission_bit_no 10
+
+ # Send STOP bit / End of transmission
+ } elseif {$transmission_bit_no == 10} {
+ set txd 1
+ if {$stop_conf == 1} {
+ write_to_log I [mc "TxD: Transmission of byte: 0x%02X complete" $byte_to_send]
+ set byte_to_send -1
+ } else {
+ set transmission_bit_no 11
+ }
+
+ # End of transmission
+ } elseif {$transmission_bit_no == 11} {
+ write_to_log I [mc "TxD: Transmission of byte: 0x%02X complete" $byte_to_send]
+ set byte_to_send -1
+ }
+
+ if {$transmission_bit_no < 11} {
+ set_bit_arrow t $transmission_bit_no
+ }
+
+ set last_txd $txd
+ }
+
+ public method stop_transmission {{internal_error 0}} {
+ set output_buffer {}
+ set byte_to_send -1
+
+ $sbuf_t_canvas itemconfigure $reg_val(txd) -text { -- }
+ $send_selected_button configure \
+ -text [mc "Send selected"] \
+ -image ::ICONS::16::forward \
+ -command [list $this send_selected]
+
+ if {$internal_error} {
+ write_to_log I [mc "TxD: Transmission TERMINATED on user request"]
+ } else {
+ write_to_log W [mc "TxD: Transmission TERMINATED due to an error"]
+ }
+ }
+
+ private method reception_control {} {
+ if {$reception_in_progress} {
+ if {$time_mark >= $reception_sample_time} {
+ set reception_data [expr {$reception_data | (($rxd_signal ? 1 : 0) << $reception_bit_no)}]
+ set reception_sample_time [expr {$reception_sample_time + $bit_time}]
+ $sbuf_r_canvas itemconfigure $reg_val(rxd) -text [format {0x%02X} [expr {($reception_data & 0x1fe) >> 1}]]
+
+ if {$reception_bit_no < 11} {
+ set_bit_color r $reception_bit_no $rxd_signal
+ }
+
+ incr reception_bit_no
+
+ if {$reception_bit_no == ($data_conf + 1)} {
+ set reception_bit_no 9
+
+ if {$parity_conf == {n}} {
+ incr reception_bit_no
+
+ }
+ } elseif {$reception_bit_no == 10 && $stop_conf == 1} {
+ incr reception_bit_no
+ }
+
+ if {$reception_bit_no < 11} {
+ set_bit_arrow r $reception_bit_no
+ }
+ highlight_arrow r 1
+
+ if {$reception_bit_no == 12} {
+ set_bit_arrow r 0
+ highlight_arrow r 0
+ $sbuf_r_canvas itemconfigure $reg_val(rxd) -text { -- }
+ for {set i 0} {$i < 11} {incr i} {
+ set_bit_color r $i -1
+ }
+ reception_complete
+ }
+ } else {
+ highlight_arrow r 0
+ }
+ } else {
+ if {$rxd_signal_prev && !$rxd_signal} {
+ set reception_in_progress 1
+ set reception_bit_no 1
+ set reception_data 0
+ set reception_sample_time [expr {$time_mark + $bit_time * 1.5}]
+
+ set_bit_color r 0 0
+ set_bit_arrow r 1
+
+ write_to_log I [mc "RxD: Receiving byte, address = 0x%02X" $reception_address]
+ }
+ }
+ }
+
+ private method reception_complete {} {
+ set reception_in_progress 0
+
+ if {$reception_address >= 255} {
+ set reception_address 0
+ write_to_log W [mc "RxD: Reception buffer overflow"]
+ }
+
+ set data [expr {($reception_data & 0x1fe) >> 1}]
+ $receive_hexeditor setValue $reception_address $data
+ $receive_hexeditor set_bg_hg $reception_address 1 1
+
+ # Verify rceived byte
+ if {$parity_conf != {n}} {
+ if {[compute_parity $data] != (($data & 0x20) ? 1 : 0)} {
+ write_to_log E [mc "RxD: Parity flag doesn't match"]
+ }
+ }
+ if {!(($data & 0x80) ? 1 : 0) || (($stop_conf > 1) && !(($data & 0x40) ? 1 : 0))} {
+ write_to_log E [mc "RxD: Invalid STOP bit(s)"]
+ }
+
+ write_to_log I [mc "RxD: Byte received, address = 0x%02X, data = 0x%02X" $reception_address $data]
+
+ incr reception_address
+ $receive_hexeditor seeCell $reception_address
+ }
+
+ private method compute_parity {data} {
+ set count 0
+ set mask 1
+ for {set i 0} {$i < 8} {incr i} {
+ if {$data & $mask} {
+ incr count
+ }
+ set mask [expr {$mask << 1}]
+ }
+
+ set data [expr {($count % 2) ? 1 : 0}]
+ if {$parity_conf == {o}} {
+ set data [expr {!$data}]
+ }
+
+ return $data
+ }
+
+ # ------------------------------------------------------------------
+ # VIRTUAL HW COMMON INTERFACE
+ # ------------------------------------------------------------------
+
+ ## Simulated MCU has been changed
+ # @return void
+ public method mcu_changed {} {
+ # Refresh lists of possible values in port selection ComboBoxes
+ set available_ports [concat - [$project pale_get_available_ports]]
+
+ for {set i 0} {$i < 2} {incr i} {
+ $cb(p$i) configure -values $available_ports
+
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
+ $cb(p$i) current 0
+ set connection_port($i) {-}
+ }
+ }
+ }
+
+ ## Accept new state of ports
+ # @parm List state - Port states ( 5 x {8 x bit} -- {bit0 bit1 bit2 ... bit7} )
+ # @return void
+ #
+ # Possible bit values:
+ # '|' - High frequency
+ # 'X' - Access to external memory
+ # '?' - No volatge
+ # '-' - Indeterminable value (some noise)
+ # '=' - High forced to low
+ # '0' - Logical 0
+ # '1' - Logical 1
+ public method new_state {_state} {
+ upvar $_state state
+
+ if {$time_mark == [$project get_run_statistics 0]} {
+ return
+ }
+ set time_mark [$project get_run_statistics 0]
+ set cycles [$project pale_get_number_of_instruction_cycles]
+
+ # --------------------------------------------------------------
+ # TxD part
+ # --------------------------------------------------------------
+ set pp [which_port_pin 0]
+
+ if {[lindex $pp 0] != {-} && [lindex $pp 1] != {-}} {
+ lset state $pp [transmission_control [lindex $state $pp]]
+ } else {
+ transmission_control
+ }
+ for {set i 0} {$i < $cycles} {incr i} {
+ graph_draw t $last_txd
+ }
+
+ # --------------------------------------------------------------
+ # RxD part
+ # --------------------------------------------------------------
+ set pp [which_port_pin 1]
+
+ if {[lindex $pp 0] != {-} && [lindex $pp 1] != {-}} {
+ reception_control
+
+ set rxd_signal_prev $rxd_signal
+ set rxd_signal [lindex $state $pp]
+
+ # Convert any possible I/O signal value to Boolean value
+ switch -- $rxd_signal {
+ {0} -
+ {1} {}
+ {=} {
+ set rxd_signal 0
+ }
+ default {
+ write_to_log E [mc "RxD: Input corrupted!"]
+ }
+ }
+
+ for {set i 0} {$i < $cycles} {incr i} {
+ graph_draw r [$project pale_RRPPV $pp $i]
+ }
+ }
+ }
+
+ ## Withdraw panel window from the screen
+ # @return void
+ public method withdraw_window {} {
+ wm withdraw $win
+ }
+
+ ## Get panel configuration list (usable with method "set_config")
+ # @return List - configuration list
+ public method get_config {} {
+ return [list \
+ $class_name \
+ [list \
+ [array get connection_port] \
+ [array get connection_pin] \
+ [wm geometry $win] \
+ [$usr_note get] \
+ $baud_conf \
+ $parity_conf \
+ $data_conf \
+ $stop_conf \
+ [$send_hexeditor get_values 0 255] \
+ [$send_hexeditor getCurrentCell] \
+ [$receive_hexeditor get_values 0 255] \
+ [$receive_hexeditor getCurrentCell] \
+ $reception_address \
+ [wm geometry $win.log_window] \
+ [wm state $win.log_window] \
+ $keep_win_on_top \
+ ] \
+ ]
+ }
+
+ ## Set panel configuration from list gained from method "get_config"
+ # @parm List state - Configuration list
+ # @return void
+ public method set_config {state} {
+ # Load connections to the MCU
+ array set connection_port [lindex $state 0]
+ array set connection_pin [lindex $state 1]
+
+ # Restore window geometry
+ if {[string length [lindex $state 2]]} {
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm size $win] {x}]]
+ }
+
+ # Load user note
+ $usr_note delete 0
+ $usr_note insert 0 [lindex $state 3]
+
+ set baud_conf [lindex $state 4]
+ set bit_time [expr {1000000000.0 / $baud_conf}]
+ set parity_conf [lindex $state 5]
+ set data_conf [lindex $state 6]
+ set stop_conf [lindex $state 7]
+
+ $baud_cb current [lsearch [$baud_cb cget -values] $baud_conf]
+ $parity_cb current [lsearch {n o e} $parity_conf]
+ $data_cb current [lsearch [$data_cb cget -values] $data_conf]
+ $stop_cb current [lsearch [$stop_cb cget -values] $stop_conf]
+
+ for {set i 0} {$i < 0x100} {incr i} {
+ $send_hexeditor setValue $i [lindex $state [list 8 $i]]
+ }
+ $send_hexeditor setCurrentCell [lindex $state 9]
+ for {set i 0} {$i < 0x100} {incr i} {
+ $receive_hexeditor setValue $i [lindex $state [list 10 $i]]
+ }
+ $receive_hexeditor setCurrentCell [lindex $state 11]
+ set reception_address [lindex $state 12]
+ $receive_hexeditor clearBgHighlighting 0
+ $receive_hexeditor set_bg_hg $reception_address 1 0
+
+ # Display the log window
+ set log_window_geometry [lindex $state 13]
+ if {[lindex $state 14] == {normal}} {
+ show_log
+ }
+
+ if {[lindex $state 15] != {}} {
+ set keep_win_on_top [lindex $state 15]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
+ # Restore state of ComboBoxes
+ for {set i 0} {$i < 2} {incr i} {
+ ## PIN
+ set pin $connection_pin($i)
+ if {$pin != {-}} {
+ set pin [expr {7 - $pin}]
+ }
+ set idx [lsearch -ascii -exact \
+ [$cb(b$i) cget -values] \
+ $pin \
+ ]
+ if {$idx == -1} {
+ set idx 0
+ }
+ $cb(b$i) current $idx
+
+ ## PORT
+ set idx [lsearch -ascii -exact \
+ [$cb(p$i) cget -values] \
+ $connection_port($i) \
+ ]
+ if {$idx == -1} {
+ set idx 0
+ }
+ $cb(p$i) current $idx
+ }
+
+ # Adjust internal logic and the rest of PALE
+ evaluete_enaged_pins
+ $project pale_reevaluate_IO
+ update
+
+ if {[catch {
+ # Fail
+ }]} then {
+ puts "Unable to load configuration for $class_name"
+ return 0
+
+ # Success
+ } else {
+ clear_modified
+ return 1
+ }
+ }
+
+ ## Simulated MCU has been reseted
+ # @return void
+ public method reset {} {
+ set state [$project pale_get_true_state]
+ new_state state
+
+ graph_clear t
+ graph_clear r
+ }
+
+
+ # ------------------------------------------------------------------
+ # VIRTUAL HW COMMON INTERFACE -- CALLED FROM THE BASE CLASS
+ # ------------------------------------------------------------------
+
+ ## This method is called before configuration menu invocation
+ # @return void
+ public method config_menu_special {} {
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
+ }
+
+ ## This method is called after configuration menu has beed created
+ # @return void
+ public method create_config_menu_special {} {
+ }
+
+ ## This method is called to fill in the help dialog
+ # @parm Widget text_widget - Target text widget
+ # @return void
+ #
+ # Note: There is defined text tag "tag_bold" in the text widget
+ public method show_help_special {text_widget} {
+ }
+
+ ## This method is called before panel window closure
+ # @return void
+ public method close_window_special {} {
+ }
+
+ ## Commit new on/off state
+ # @return void
+ public method on_off_special {} {
+ if {[$project pale_is_enabled]} {
+ graph_clear t
+ graph_clear r
+ }
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/project.tcl b/lib/project.tcl
index 3c4571b..bdab27a 100755..100644
--- a/lib/project.tcl
+++ b/lib/project.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 _PROJECT_TCL ] } {
+set _PROJECT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements project files management
@@ -31,7 +36,7 @@ namespace eval Project {
variable xml_data_tk_mcuide_project {} ;# Attributes of <tk_mcuide_project>
variable xml_data_authors {} ;# Content of <authors>
variable xml_data_copyright {} ;# Content of <copyright>
- variable xml_data_licence {} ;# Content of <licence>
+ variable xml_data_license {} ;# Content of <license>
variable xml_data_processor {} ;# Attributes of <processor>
variable xml_data_options {} ;# Attributes of <options>
variable xml_data_graph {} ;# Attributes of <graph>
@@ -50,16 +55,17 @@ namespace eval Project {
variable xml_curTag {} ;# Currenly parsed XML tag
variable xml_start {} ;# Bool: True at start of parsing
variable expect_data_part 1 ;# Bool: True if on the next comes data
- variable xml_warning 0 ;# Bool: True if an error occured during parsing process
-
+ variable xml_warning 0 ;# Bool: True if an error occurred during parsing process
## Create string which can be saved as a project definition file (format: XML)
# @parm List inputData - requested format: {
# {version date creator_ver} # tag: tk_mcuide_project
- # {authors copyright licence} # tag: authors copyright licence
+ # {authors copyright license} # tag: authors copyright license
# {type clock xdata xcode} # tag: processor
# {watches_file scheme main_file auto_sw_enabled} # tag: options
- # {grid_mode magnification drawing_on mark_flags} # tag: graph
+ # {grid_mode magnification drawing_on
+ # mark_flags_true_state mark_flags_latched
+ # mark_flags_output active_page} # tag: graph
# {description todo} # tag: descriptin todo
# {radix angle_unit # tag: calculator
# display0 display1 display2
@@ -78,7 +84,7 @@ namespace eval Project {
# ...
# }
# }
- # @return String - outpud data (formated as XML)
+ # @return String - outpud data (formatted as XML)
proc create_project_file_as_string {inputData} {
# Initialize variables related to content of the file
@@ -87,7 +93,7 @@ namespace eval Project {
# Definition of file structure (except of <files>)
set dataPartStructure {
{version date creator_ver}
- {authors copyright licence}
+ {authors copyright license}
{mcu_type clock xdata xcode}
{watches_file scheme main_file auto_sw_enabled}
{graph_grid_mode graph_magnification graph_drawing_on graph_mark_flags_s graph_mark_flags_l graph_mark_flags_o active_page}
@@ -121,15 +127,16 @@ namespace eval Project {
} else {
foreach var {
version date creator_ver authors copyright
- licence other_options files_count mcu_type xdata
+ license other_options files_count mcu_type xdata
watches_file files description todo calc_radix
angle_unit display0 display1 display2 memory0
memory1 memory2 clock freq time
mode graph_grid_mode graph_magnification graph_drawing_on
- graph_mark_flags_s graph_mark_flags_l graph_mark_flags_o active_page
- xcode scheme graph_mark_flags current_file2
- pwin_sash main_file compiler_options
- } {
+ auto_sw_enabled current_file2 graph_mark_flags_o active_page
+ xcode scheme graph_mark_flags graph_mark_flags_l
+ pwin_sash main_file compiler_options graph_mark_flags_s
+ } \
+ {
set $var {}
}
}
@@ -142,14 +149,14 @@ namespace eval Project {
## Create XML string
append result "<?xml version='1.0' encoding='utf-8'?>\n"
- if {[file exists "${::LIB_DIRNAME}/../data/project.dtd"]} {
+ if {[file exists "${::ROOT_DIRNAME}/data/project.dtd"]} {
if {[catch {
- set dtd [open "${::LIB_DIRNAME}/../data/project.dtd" r]
+ set dtd [open "${::ROOT_DIRNAME}/data/project.dtd" r]
}]} then {
puts stderr "Unable to open project DTD, please check your installation."
} else {
append result "<!DOCTYPE tk_mcuide_project \[\n\n"
- while 1 {
+ while {1} {
if {[eof $dtd]} {
close $dtd
break
@@ -169,7 +176,7 @@ namespace eval Project {
append result "\t\t<authors><!\[CDATA\[[adjust_to_xml $authors]\]\]></authors>\n"
append result "\t\t<copyright><!\[CDATA\["
append result "[adjust_to_xml $copyright]\]\]></copyright>\n"
- append result "\t\t<licence><!\[CDATA\[[adjust_to_xml $licence]\]\]></licence>\n"
+ append result "\t\t<license><!\[CDATA\[[adjust_to_xml $license]\]\]></license>\n"
append result "\t\t<processor type=\"[adjust_to_xml $mcu_type]\" clock=\"[adjust_to_xml $clock]\""
append result " xdata=\"[adjust_to_xml $xdata]\" xcode=\"[adjust_to_xml $xcode]\"/>\n"
append result "\t\t<options\n"
@@ -219,8 +226,9 @@ namespace eval Project {
file_index read_only actual_line md5_hash
path bookmarks breakpoints eol
enc highlight notes
- } {
- set $var $value
+ } \
+ {
+ set $var $value
}
append result "\t\t<file name=\"[adjust_to_xml $name]\" active=\"[adjust_to_xml $active]\" "
append result "o_bookmark=\"$o_bookmark\" p_bookmark=\"$p_bookmark\" "
@@ -238,7 +246,7 @@ namespace eval Project {
append result "\t\t</file>\n\n"
}
append result "\t</files>\n"
- append result "</tk_mcuide_project>"
+ append result "</tk_mcuide_project>\n"
# Return resulting XML String
return $result
@@ -258,7 +266,7 @@ namespace eval Project {
set projectFile [open $filename r]
set dataList [create_list_from_project_string [read $projectFile]]
close $projectFile
- }]} {
+ }]} then {
return 0
}
@@ -276,12 +284,12 @@ namespace eval Project {
$projectDescriptor {_} projectDescriptor
# Take care of opening multiple instances of the same project
- if {[lsearch ${X::openedProjects} $projectDescriptor] != -1} {
+ if {[lsearch ${::X::openedProjects} $projectDescriptor] != -1} {
append project_new_name "(0)"
append projectDescriptor "_0"
- while 1 {
- if {[lsearch ${X::openedProjects} $projectDescriptor] == -1} {break}
+ while {1} {
+ if {[lsearch ${::X::openedProjects} $projectDescriptor] == -1} {break}
regexp {\d+$} $projectDescriptor index
regsub {_\d+$} $projectDescriptor {} projectDescriptor
@@ -297,7 +305,7 @@ namespace eval Project {
}
# Show project notebook
- if {${X::project_menu_locked}} {
+ if {${::X::project_menu_locked}} {
pack .mainFrame.mainNB -expand 1 -fill both
}
@@ -308,7 +316,7 @@ namespace eval Project {
MainTab ::$projectDescriptor $project_new_name $projectPath $projectFileName $dataList
# Unlock all menu items
- if {${X::project_menu_locked}} {
+ if {${::X::project_menu_locked}} {
::X::Unlock_project_menu
}
::X::disaena_menu_toolbar_for_current_project
@@ -324,7 +332,7 @@ namespace eval Project {
variable xml_data_tk_mcuide_project ;# Attributes of <tk_mcuide_project>
variable xml_data_authors ;# Content of <authors>
variable xml_data_copyright ;# Content of <copyright>
- variable xml_data_licence ;# Content of <licence>
+ variable xml_data_license ;# Content of <license>
variable xml_data_processor ;# Attributes of <processor>
variable xml_data_options ;# Attributes of <options>
variable xml_data_graph ;# Attributes of <graph>
@@ -339,7 +347,7 @@ namespace eval Project {
variable xml_expect ;# XML tag expected to be the next
variable xml_curTag ;# Currenly parsed XML tag
variable xml_data_file ;# Auxiliary variable for xml_data_files
- variable xml_warning ;# Bool: True if an error occured during parsing process
+ variable xml_warning ;# Bool: True if an error occurred during parsing process
variable xml_start ;# Bool: True at start of parsing
# Setup XML parser
@@ -356,7 +364,7 @@ namespace eval Project {
# Start XML parser
if {[catch {
$parser parse $inputData
- } result]} {
+ } result]} then {
puts stderr "XML parse error: $result"
report_project_loading_error
return {}
@@ -375,7 +383,7 @@ namespace eval Project {
lappend result [list \
[unescape_tags $xml_data_authors ] \
[unescape_tags $xml_data_copyright ] \
- [unescape_tags $xml_data_licence ] \
+ [unescape_tags $xml_data_license ] \
]
lappend result $xml_data_processor
lappend result [unescape_tags $xml_data_options]
@@ -388,7 +396,7 @@ namespace eval Project {
lappend result [unescape_tags $xml_data_other_options ]
lappend result [unescape_curlies [unescape_tags $xml_data_compiler_options]]
- lappend__xml_data_files__xml_data_file ;# Note that this is important function
+ lappend__xml_data_files__xml_data_file ;# Note that this is an important function
lappend result [concat \
$xml_data_files_count \
[unescape_tags $xml_data_files] \
@@ -408,7 +416,7 @@ namespace eval Project {
variable xml_data_tk_mcuide_project ;# Attributes of <tk_mcuide_project>
variable xml_data_authors ;# Content of <authors>
variable xml_data_copyright ;# Content of <copyright>
- variable xml_data_licence ;# Content of <licence>
+ variable xml_data_license ;# Content of <license>
variable xml_data_processor ;# Attributes of <processor>
variable xml_data_options ;# Attributes of <options>
variable xml_data_graph ;# Attributes of <graph>
@@ -428,14 +436,15 @@ namespace eval Project {
# Set all listed variables to empty string
foreach var {
- xml_data_tk_mcuide_project xml_data_authors xml_data_copyright
- xml_data_licence xml_curTag xml_data_processor
- xml_data_options xml_data_description xml_data_todo
- xml_data_files xml_data_calculator xml_data_other_options
- xml_data_files_count xml_data_current_file xml_data_file
- xml_expect xml_data_graph xml_data_compiler_options
- xml_data_file_notes
- } {
+ xml_data_tk_mcuide_project xml_data_authors xml_data_copyright
+ xml_data_license xml_curTag xml_data_processor
+ xml_data_options xml_data_description xml_data_todo
+ xml_data_files xml_data_calculator xml_data_other_options
+ xml_data_files_count xml_data_current_file xml_data_file
+ xml_expect xml_data_graph xml_data_compiler_options
+ xml_data_file_notes
+ } \
+ {
set $var {}
}
}
@@ -443,14 +452,18 @@ namespace eval Project {
## Invoke dialog to report error occcured while parsing data
# @return void
proc report_project_loading_error {} {
- variable xml_warning ;# Bool: True if an error occured during parsing process
+ variable xml_warning ;# Bool: True if an error occurred during parsing process
# Ensure than there is only one error message dialog
if {$xml_warning} {return}
# Invoke dialog
- tk_messageBox -icon error -type ok -title [mc "Project loading error"] \
- -message [mc "ERROR:\nThe project file cannot be loaded correctly due to a xml parsing error. The file is eighter corrupted or it is not a project file acceptable by this environment."]
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -parent . \
+ -title [mc "Project loading error"] \
+ -message [mc "ERROR:\nThe project file cannot be loaded correctly due to a xml parsing error. The file is either corrupted or it is not a project file acceptable by this environment."]
set xml_warning 1
}
@@ -572,12 +585,12 @@ namespace eval Project {
variable xml_curTag ;# Currenly parsed XML tag
variable xml_start ;# Bool: True at start of parsing
variable xml_attlist ;# Auxiliary variable - List of current tag attributes
- variable xml_warning ;# Bool: True if an error occured during parsing process
+ variable xml_warning ;# Bool: True if an error occurred during parsing process
variable xml_data_tk_mcuide_project ;# Attributes of <tk_mcuide_project>
variable xml_data_authors ;# Content of <authors>
variable xml_data_copyright ;# Content of <copyright>
- variable xml_data_licence ;# Content of <licence>
+ variable xml_data_license ;# Content of <license>
variable xml_data_processor ;# Attributes of <processor>
variable xml_data_options ;# Attributes of <options>
variable xml_data_graph ;# Attributes of <graph>
@@ -619,8 +632,8 @@ namespace eval Project {
{copyright} {
set xml_data_copyright $data
}
- {licence} {
- set xml_data_licence $data
+ {license} {
+ set xml_data_license $data
}
{description} {
append xml_data_description $data "\n"
@@ -639,11 +652,15 @@ namespace eval Project {
if {[llength $xml_data_file] == 9} {
lappend xml_data_file {}
}
- regsub -all {[ \t\n\r]+} $data {} data
+ regsub -all {[ \t\n\r]+} $data { } data
+ regsub {^ } $data { } data
+ regsub { $} $data { } data
lappend xml_data_file $data
}
{breakpoints} {
- regsub -all {[ \t\n\r]+} $data {} data
+ regsub -all {[ \t\n\r]+} $data { } data
+ regsub {^ } $data { } data
+ regsub { $} $data { } data
lappend xml_data_file $data
}
{path} {
@@ -665,12 +682,12 @@ namespace eval Project {
variable xml_curTag ;# Currenly parsed XML tag
variable xml_start ;# Bool: True at start of parsing
variable xml_attlist ;# Auxiliary variable - List of current tag attributes
- variable xml_warning ;# Bool: True if an error occured during parsing process
+ variable xml_warning ;# Bool: True if an error occurred during parsing process
variable xml_data_tk_mcuide_project ;# Attributes of <tk_mcuide_project>
variable xml_data_authors ;# Content of <authors>
variable xml_data_copyright ;# Content of <copyright>
- variable xml_data_licence ;# Content of <licence>
+ variable xml_data_license ;# Content of <license>
variable xml_data_processor ;# Attributes of <processor>
variable xml_data_options ;# Attributes of <options>
variable xml_data_graph ;# Attributes of <graph>
@@ -718,10 +735,14 @@ namespace eval Project {
}
{copyright} {
set xml_curTag "copyright"
- project_xml_expect "licence"
+ project_xml_expect "licence license"
+ }
+ {license} {
+ set xml_curTag "license"
+ project_xml_expect "processor"
}
{licence} {
- set xml_curTag "licence"
+ set xml_curTag "license"
project_xml_expect "processor"
}
{processor} {
@@ -848,10 +869,10 @@ namespace eval Project {
}
if {[llength $xml_data_file] == 12} {
- puts stderr [mc "Conveting old project file to new version"]
+ puts stderr [mc "Converting old project file to new version"]
- # eol enc
- lappend xml_data_file {} {}
+ # eol enc
+ lappend xml_data_file {} {}
}
# Move attribute "highlight" from index 6 to 13
@@ -866,3 +887,7 @@ namespace eval Project {
lappend xml_data_files $xml_data_file
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/receive_and_print.tcl b/lib/receive_and_print.tcl
new file mode 100644
index 0000000..1d082f3
--- /dev/null
+++ b/lib/receive_and_print.tcl
@@ -0,0 +1,102 @@
+#!/bin/sh
+# the next line restarts using wish \
+exec tclsh "$0" "$@"
+
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# Copyright (C) 2011 by Martin Ošmera #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _RECEIVE_AND_PRINT_TCL ] } {
+set _RECEIVE_AND_PRINT_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+# Send input read the send command to stdout
+#
+# USAGE:
+# set pid [exec -- tclsh receive_and_print.tcl [tk appname] final_cmd | some_command ?args? &]
+# * pid - Process identifier of $some_command
+# * args - Arguments for $some_command
+# * final_cmd - Command in local Tcl program to execute once when the script exits
+#
+# Once the receive_and_print (RAP) is started you can invoke ``print_line'' command available in it
+# to print any string to stdout. The command takes any number of arguments and prints them all into
+# the standard output.
+# --------------------------------------------------------------------------
+
+# Initialize
+encoding system {utf-8}
+package require Tk
+wm withdraw .
+wm command . "$argv0 $argv"
+wm client . [info hostname]
+
+# Parse agruments
+set source_app [lindex $argv 0]
+set final_cmd [lindex $argv 1]
+unset argv
+
+## Determinate the host OS
+set ::MICROSOFT_WINDOWS 0
+if {[string first {Windows} ${tcl_platform(os)}] != -1} {
+ # Note:
+ # Microsoft Windows is NOT a POSIX system and because of that we need
+ # to do some workarounds here in order to make the IDE functional there.
+ set ::MICROSOFT_WINDOWS 1
+}
+
+# Load dde - Dynamic Data Exchange on Microsoft Windows
+if {$::MICROSOFT_WINDOWS} {
+ package require dde
+}
+
+## Perform secure send command
+ # Secure means that it will not crash or something like that in case of any errors.
+ # But instead it will pop-up an error message to the user (Tk dialog).
+ # @parm List args - Arguments for the send command
+ # @return void
+proc secure_send args {
+ if {[catch {
+ eval "send $args"
+ } result]} then {
+ puts stderr "Unknown IO Error :: $result"
+ return 1
+
+ } else {
+ return 1
+ }
+}
+
+proc print_line {args} {
+ puts $args
+}
+
+if {!${::MICROSOFT_WINDOWS}} {
+ secure_send $source_app $final_cmd "{[tk appname]}"
+} else {
+ dde eval $source_app $final_cmd "{[tk appname]}"
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/rightpanel/hwmanager.tcl b/lib/rightpanel/hwmanager.tcl
index 0e27941..133d821 100755..100644
--- a/lib/rightpanel/hwmanager.tcl
+++ b/lib/rightpanel/hwmanager.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 _HWMANAGER_TCL ] } {
+set _HWMANAGER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides panel for managing hardware plugins (e.g. Programmer, ICD, etc.)
@@ -29,24 +34,26 @@
class HwManager {
## COMMON
common PLUGIN_SEARCH_PATHS {
- ../hwplugins
/usr/share/mcu8051ide/hwplugins
/usr/local/share/mcu8051ide/hwplugins
}
+ if {$::MICROSOFT_WINDOWS} {
+ set PLUGIN_SEARCH_PATHS ${::INSTALLATION_DIR}/hwplugins
+ }
common inst_plg_count 0 ;# Int: Number of installed plugins
## PRIVATE
private variable parent ;# Widget: parent widget
- private variable gui_initialized 0 ;# Bool: GUI initialized
+ private variable hwman_gui_initialized 0 ;# Bool: GUI initialized
private variable main_frame ;# Widget: Main frame
private variable pagesmanager ;# Widget: Pages manager for plugins GUI
private variable plg_combobox ;# Widget: Plugin selection combobox
- private variable plg_refresh_but ;# Widget: Button "Refresh avaliable plugins"
+ private variable plg_refresh_but ;# Widget: Button "Refresh available plugins"
private variable ins_plugin_namespaces {} ;# List of Strings: Namespaces of installed (initialized) plugins
private variable ins_plugin_names {} ;# List of Strings: Names of installed (initialized) plugins
- private variable avl_plugin_files {} ;# List of Strings: Full filenames of avaliable plugins
- private variable avl_plugin_names {} ;# List of Strings: Names of avaliable plugins
+ private variable avl_plugin_files {} ;# List of Strings: Full filenames of available plugins
+ private variable avl_plugin_names {} ;# List of Strings: Names of available plugins
# List: Configuraion list of this panel (for session management)
private variable local_config [lindex $::CONFIG(HW_MANAGER_CONFIG) 0]
@@ -71,7 +78,7 @@ class HwManager {
if {[catch {
${ns}::dispose
- }]} {
+ }]} then {
plugin_error $name $ns
}
}
@@ -83,35 +90,35 @@ class HwManager {
# @return void
public method PrepareHwManager {_parent} {
set parent $_parent
- set gui_initialized 0
+ set hwman_gui_initialized 0
}
## Finalize initialization of this panel
# @return void
public method CreateHwManagerGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$hwman_gui_initialized} {return}
+ set hwman_gui_initialized 1
# Create main GUI parts
set main_frame [frame $parent.main_frame]
set top_frame [frame $main_frame.top]
- set pagesmanager [PagesManager $main_frame.pagesmanager -background {#eeeeee}]
+ set pagesmanager [PagesManager $main_frame.pagesmanager -background ${::COMMON_BG_COLOR}]
## Create parts of top panel
# Label "HW"
pack [label $top_frame.plg_label \
-text [mc "HW:"] \
] -side left
- # Combobox of avaliable/installed plugins
+ # Combobox of available/installed plugins
set plg_combobox [ttk::combobox $top_frame.plg_cbbox \
-exportselection 1 \
-width 0 \
-state readonly \
]
- DynamicHelp::add $plg_combobox -text [mc "List avaliable or installed HW plugins"]
+ DynamicHelp::add $plg_combobox -text [mc "List available or installed HW plugins"]
bind $plg_combobox <<ComboboxSelected>> "$this hw_manager_plg_cbs"
pack $plg_combobox -fill x -expand 1 -side left
- setStatusTip -widget $plg_combobox -text [mc "Avaliable/installed plugins"]
+ setStatusTip -widget $plg_combobox -text [mc "available/installed plugins"]
# Button "Refresh"
set plg_refresh_but [ttk::button $top_frame.plg_refresh_but \
-image ::ICONS::16::reload \
@@ -119,7 +126,7 @@ class HwManager {
-style Flat.TButton \
]
DynamicHelp::add $top_frame.plg_refresh_but \
- -text [mc "Refresh list avaliable or installed HW plugins"]
+ -text [mc "Refresh list available or installed HW plugins"]
pack $plg_refresh_but -side left
setStatusTip -widget $plg_refresh_but -text [mc "Refresh"]
# Fill in the combobox
@@ -141,16 +148,16 @@ class HwManager {
pack $main_frame -fill both -expand 1
}
- ## Refresh list avaliable or installed HW plugins
+ ## Refresh list available or installed HW plugins
# @return void
public method hw_manager_refresh_plugins {} {
- if {!$gui_initialized} {CreateHwManagerGUI}
+ if {!$hwman_gui_initialized} {CreateHwManagerGUI}
if {${::CLI_OPTION(no-plugins)}} {return}
set avl_plugin_files [list]
set avl_plugin_names [list]
- # Search for avaliable plugins
+ # Search for available plugins
foreach dir $PLUGIN_SEARCH_PATHS {
set dir [file join ${::LIB_DIRNAME} $dir]
catch { ;# For Microsoft Windows it has to be enclosed by catch
@@ -158,6 +165,7 @@ class HwManager {
if {[lsearch -ascii -exact $avl_plugin_names [file tail [file rootname $file]]] != -1} {
continue
}
+
lappend avl_plugin_files $file
lappend avl_plugin_names [regsub -all {_} [file tail [file rootname $file]] { }]
}
@@ -172,12 +180,12 @@ class HwManager {
# @parm String plugin_name - Plugin to switch to
# @return void
public method hw_manager_switch_plugin {plugin_name} {
- if {!$gui_initialized} {CreateHwManagerGUI}
+ if {!$hwman_gui_initialized} {CreateHwManagerGUI}
if {${::CLI_OPTION(no-plugins)}} {return}
# Install the plugin if it wasn't installed yet
if {[lsearch -ascii -exact $ins_plugin_names $plugin_name] == -1} {
- # Check if the selected plugin is really avaliable
+ # Check if the selected plugin is really available
if {[lsearch -ascii -exact $avl_plugin_names $plugin_name] == -1} {
return
}
@@ -192,15 +200,15 @@ class HwManager {
]
}
- # Adjust the combobox of avaliable/installed plugins
- $pagesmanager raise [regsub -all {\s} $plugin_name {_}]
+ # Adjust the combobox of available/installed plugins
+ $pagesmanager raise [regsub -all {[\s\.]} $plugin_name {_}]
}
- ## "Change command" for the combobox of avaliable/installed plugins
+ ## "Change command" for the combobox of available/installed plugins
# Switches the selected plugin
# @return void
public method hw_manager_plg_cbs {} {
- if {!$gui_initialized} {CreateHwManagerGUI}
+ if {!$hwman_gui_initialized} {CreateHwManagerGUI}
hw_manager_switch_plugin [$plg_combobox get]
}
@@ -209,22 +217,24 @@ class HwManager {
# @parm String file_path - Full path to the plugin main file
# @return String - Plugin namespace
public method hw_manager_install_plugin {plugin_name file_path} {
- if {!$gui_initialized} {CreateHwManagerGUI}
+ if {!$hwman_gui_initialized} {CreateHwManagerGUI}
if {${::CLI_OPTION(no-plugins)}} {return}
set plg_ns {}
if {[catch {
- set frame [$pagesmanager add [regsub -all {\s} $plugin_name {_}]]
+ set frame [$pagesmanager add [regsub -all {[\s\.]} $plugin_name {_}]]
set plg_ns "::HwManager::plugin_ns::$inst_plg_count"
incr inst_plg_count
namespace eval $plg_ns "source {$file_path}"
- set min_ide_ver [subst "\$${plg_ns}::MIN_IDE_VER"]
+ set min_ide_ver [subst -nocommands "\$${plg_ns}::MIN_IDE_VER"]
if {[package vcompare $min_ide_ver $::VERSION] == 1} {
tk_messageBox \
+ -parent . \
-title [mc "Too old version"] \
- -type ok -icon warning \
+ -type ok \
+ -icon warning \
-message [mc "Plugin %s requires MCU 8051 IDE version %s and above, please upgrade your MCU 8051 IDE" $plugin_name $min_ide_ver]
}
@@ -234,7 +244,7 @@ class HwManager {
if {$idx != -1} {
${plg_ns}::restore_session [lindex $plugin_config_1 $idx]
}
- }]} {
+ }]} then {
plugin_error $plugin_name $plg_ns
}
@@ -252,9 +262,9 @@ class HwManager {
set plugin_author {not defined}
set authors_email {not defined}
set err_info $::errorInfo
- catch {set plugin_ver [subst "\$${plugin_ns}::P_VERSION"]}
- catch {set plugin_author [subst "\$${plugin_ns}::AUTHOR"]}
- catch {set authors_email [subst "\$${plugin_ns}::EMAIL"]}
+ catch {set plugin_ver [subst -nocommands "\$${plugin_ns}::P_VERSION"]}
+ catch {set plugin_author [subst -nocommands "\$${plugin_ns}::AUTHOR"]}
+ catch {set authors_email [subst -nocommands "\$${plugin_ns}::EMAIL"]}
# Print error message to stadrad error output
puts stderr "\n\n"
@@ -285,85 +295,87 @@ class HwManager {
close $log_file
}
- # Display GUI error message
- set dialog [toplevel .plugin_error -bg {#EEEEEE}]
-
- # Create window frames
- set main_dlg_frame [frame $dialog.main_frame]
- set top_frame [frame $main_dlg_frame.top_frame -bg {#EE0000}]
- set middle_frame [frame $main_dlg_frame.middle_frame]
- set bottom_frame [frame $main_dlg_frame.bottom_frame]
-
- # Create window header
- pack [label $top_frame.header_lbl \
- -text [mc "PLUGIN ERROR"] \
- -bg {#EE0000} -fg {#FFFFFF} \
- -font [font create \
- -family helvetica \
- -size -24 \
- -weight bold \
- ] \
- ] -side left -fill x -expand 1
-
- # Create error message text and scrollbar
- pack [text $middle_frame.text \
- -bg {white} -bd 0 \
- -yscrollcommand "$middle_frame.scrollbar set" \
- -width 0 -height 0 -relief flat -wrap word \
- ] -side left -fill both -expand 1 -padx 5 -pady 5
- bind $middle_frame.text <Button-1> {focus %W}
- pack [ttk::scrollbar $middle_frame.scrollbar \
- -orient vertical \
- -command "$middle_frame.text yview" \
- ] -fill y -side right
-
- # Create button "Close"
- pack [ttk::button $bottom_frame.ok \
- -text [mc "Close"] \
- -style GreenBg.TButton \
- -command "
+ # Display GUI error message (only if the main window is still visible)
+ if {[wm state .] != {withdrawn}} {
+ set dialog [toplevel .plugin_error -bg ${::COMMON_BG_COLOR}]
+
+ # Create window frames
+ set main_dlg_frame [frame $dialog.main_frame]
+ set top_frame [frame $main_dlg_frame.top_frame -bg {#EE0000}]
+ set middle_frame [frame $main_dlg_frame.middle_frame]
+ set bottom_frame [frame $main_dlg_frame.bottom_frame]
+
+ # Create window header
+ pack [label $top_frame.header_lbl \
+ -text [mc "PLUGIN ERROR"] \
+ -bg {#EE0000} -fg {#FFFFFF} \
+ -font [font create \
+ -family helvetica \
+ -size [expr {int(-24 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
+ ] -side left -fill x -expand 1
+
+ # Create error message text and scrollbar
+ pack [text $middle_frame.text \
+ -bg {white} -bd 0 \
+ -yscrollcommand "$middle_frame.scrollbar set" \
+ -width 0 -height 0 -relief flat -wrap word \
+ ] -side left -fill both -expand 1 -padx 5 -pady 5
+ bind $middle_frame.text <Button-1> {focus %W}
+ pack [ttk::scrollbar $middle_frame.scrollbar \
+ -orient vertical \
+ -command "$middle_frame.text yview" \
+ ] -fill y -side right
+
+ # Create button "Close"
+ pack [ttk::button $bottom_frame.ok \
+ -text [mc "Close"] \
+ -style GreenBg.TButton \
+ -command "
+ grab release $dialog
+ destroy $dialog
+ " \
+ ] -side right
+ focus -force $bottom_frame.ok
+
+ # Display error message
+ $middle_frame.text insert insert [mc "Plugin name:\t%s\n" $plugin_name]
+ $middle_frame.text insert insert [mc "Plugin version:\t%s\n" $plugin_ver]
+ $middle_frame.text insert insert [mc "Author:\t\t%s <%s>\n" $plugin_author $authors_email]
+ $middle_frame.text insert insert "\n"
+ $middle_frame.text insert insert $err_info
+ $middle_frame.text insert insert "\n"
+ $middle_frame.text configure -state disabled
+
+ # Pack window frames
+ pack $top_frame -fill x -anchor n
+ pack $middle_frame -fill both -expand 1
+ pack $bottom_frame -fill x
+ pack $main_dlg_frame -fill both -expand 1 -padx 5 -pady 5
+
+ # Configure dialog window
+ set x [expr {[winfo screenwidth $dialog] / 2 - 225}]
+ set y [expr {[winfo screenheight $dialog] / 2 - 125}]
+ wm iconphoto $dialog ::ICONS::16::bug
+ wm title $dialog [mc "PLUGIN ERROR - MCU 8051 IDE"]
+ wm minsize $dialog 450 250
+ wm geometry $dialog =550x250+$x+$y
+ wm protocol $dialog WM_DELETE_WINDOW "
grab release $dialog
- destroy $dialog
- " \
- ] -side right
- focus -force $bottom_frame.ok
-
- # Display error message
- $middle_frame.text insert insert [mc "Plugin name:\t%s\n" $plugin_name]
- $middle_frame.text insert insert [mc "Plugin version:\t%s\n" $plugin_ver]
- $middle_frame.text insert insert [mc "Author:\t\t%s <%s>\n" $plugin_author $authors_email]
- $middle_frame.text insert insert "\n"
- $middle_frame.text insert insert $err_info
- $middle_frame.text insert insert "\n"
- $middle_frame.text configure -state disabled
-
- # Pack window frames
- pack $top_frame -fill x -anchor n
- pack $middle_frame -fill both -expand 1
- pack $bottom_frame -fill x
- pack $main_dlg_frame -fill both -expand 1 -padx 5 -pady 5
-
- # Configure dialog window
- set x [expr {[winfo screenwidth $dialog] / 2 - 225}]
- set y [expr {[winfo screenheight $dialog] / 2 - 125}]
- wm iconphoto $dialog ::ICONS::16::bug
- wm title $dialog [mc "PLUGIN ERROR - MCU 8051 IDE"]
- wm minsize $dialog 450 250
- wm geometry $dialog =550x250+$x+$y
- wm protocol $dialog WM_DELETE_WINDOW "
- grab release $dialog
- destroy $dialog"
- update
- raise $dialog
- grab $dialog
- wm transient $dialog .
- tkwait window $dialog
+ destroy $dialog"
+ update
+ raise $dialog
+ grab $dialog
+ wm transient $dialog .
+ tkwait window $dialog
+ }
}
## Ask all plugins wheather they are ready for exit
# @return Bool - 1 == Exit allowed; 0 == Exit DENIED
public method hw_manager_comfirm_exit {} {
- if {!$gui_initialized} {return 1}
+ if {!$hwman_gui_initialized} {return 1}
foreach plg_name $ins_plugin_names plg_ns $ins_plugin_namespaces {
set busy_flag 0
@@ -389,7 +401,7 @@ class HwManager {
## Get configuration list for this panel (intented for sessions management)
# @return void
public method hw_manager_get_cfg {} {
- if {!$gui_initialized} {
+ if {!$hwman_gui_initialized} {
return [list $local_config $plugin_config_0 $plugin_config_1]
}
@@ -409,11 +421,125 @@ class HwManager {
if {$idx == -1} {
lappend plugin_config_0 $plg_name
lappend plugin_config_1 $config
- } {
+ } else {
lset plugin_config_1 $idx $config
}
}
return [list $local_config $plugin_config_0 $plugin_config_1]
}
+
+ # ---------------------------------------------------------------------
+ # Functions mend to be accessed from HW control plug-ins
+ # ---------------------------------------------------------------------
+
+ ## Check whether there is some project opened in the IDE
+ # @return Bool - 1 == Yes, there is; 0 == No there is not
+ proc is_project_opened {} {
+ return [expr {!${::X::project_menu_locked}}]
+ }
+
+ ## Check whether MCU simulator is engaged
+ # @return Bool - 0 == 1 == Yes, it is; No it is not (or no project is opened)
+ proc is_simulator_engaged {} {
+ if {[lindex ${::X::simulator_enabled} ${::X::actualProjectIdx}] == 1} {
+ return 1
+ } else {
+ return 0
+ }
+ }
+
+ ## Get full name of file which is currently displayed in the source code editor
+ # @return String - Full file name including path or empty string in case there is no project opened
+ proc get_current_file {} {
+ if {![is_project_opened]} {
+ return {}
+ } else {
+ return [${::X::actualProject} editor_procedure {} getFileName {}]
+ }
+ }
+
+ ## Get full name of file which has been chosen as the project main file
+ # @return String - Full file name or empty string
+ proc get_project_main_file {} {
+ if {![is_project_opened]} {
+ return {}
+ } else {
+ return [${::X::actualProject} cget -P_option_main_file]
+ }
+ }
+
+ ## Get path the directory of currently active project
+ # @return String - Directory path or empty string in case there is no project opened
+ proc get_project_dir {} {
+ if {![is_project_opened]} {
+ return {}
+ } else {
+ return [${::X::actualProject} cget -projectPath]
+ }
+ }
+
+ ## Get name of the current project
+ # @return String - Name of the current project or empty string in case there is no project opened
+ proc get_project_name {} {
+ if {![is_project_opened]} {
+ return {}
+ } else {
+ return [${::X::actualProject} cget -projectName]
+ }
+ }
+
+ ## Initiate compilation if at least one of the source files was modified
+ # @parm String success_callback - Any command to execute after successful compilation
+ # @parm String failure_callback - Any command to execute after unsuccessful compilation
+ # @return Bool - 1 == Process successfully started; 0 == Unable to comply (no project is opened)
+ proc compile_if_nessesary_and_callback {success_callback failure_callback} {
+ if {![is_project_opened]} {
+ return 0
+ }
+
+ ::X::compile_if_nessesary_and_callback $success_callback $failure_callback
+ return 1
+ }
+
+ ## Open the specified Intel® 8 hex file in hexadecimal editor
+ # @parm String filename - Name of file to open (including path)
+ # @return Bool - 1 == Success; 0 == Failure
+ proc open_in_hexeditor {filename} {
+ return [[::X::__hexeditor] open_file $filename hex]
+ }
+
+ ## Start MCU simulator if possible
+ # @return Bool - 1 == Success; 0 == Unable to comply
+ proc start_simulator {} {
+ if {![is_project_opened]} {
+ return 0
+ }
+
+ if {[is_simulator_engaged]} {
+ return 0
+ }
+
+ ::X::__initiate_sim
+ return 1
+ }
+
+ ## Shutdown MCU simulator if possible
+ # @return Bool - 1 == Success; 0 == Unable to comply
+ proc shutdown_simulator {} {
+ if {![is_project_opened]} {
+ return 0
+ }
+
+ if {![is_simulator_engaged]} {
+ return 0
+ }
+
+ ::X::__initiate_sim
+ return 1
+ }
+}
+
+# >>> File inclusion guard
}
+# <<< File inclusion guard
diff --git a/lib/rightpanel/instructiondetails.tcl b/lib/rightpanel/instructiondetails.tcl
index 0c7efaf..88f0206 100755..100644
--- a/lib/rightpanel/instructiondetails.tcl
+++ b/lib/rightpanel/instructiondetails.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 _INSTRUCTIONDETAILS_TCL ] } {
+set _INSTRUCTIONDETAILS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements tab "Instruction details" on the Right Panel
@@ -30,9 +35,12 @@ class InstructionDetails {
## COMMON
# Conter of instances
- common count 0
+ common instd_count 0
# Font for instruction details
- common instruction_font [font create -size -12 -family $::DEFAULT_FIXED_FONT]
+ common instruction_font [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family $::DEFAULT_FIXED_FONT \
+ ]
## Highlighting tags for instruction details
# {
# {tag_name foreground_color ?bold_or_italic?}
@@ -69,13 +77,13 @@ class InstructionDetails {
# }
common HELP_FOR_DIRECTIVES {}
common HELP_FOR_DIRECTIVES_RAW {
- elseif {Conditional assembly\n\nSyntax:\n ELSEIF <expr>\n\nExample:\n IF(2 * 4 - CND)\n MOV A, #20h\n ELSEIF SOMETHING_ELSE\n MOV A, #40h\n ENDIF\n\nNote:\n Supported by ASEM-51 only}
+ elseif {Conditional assembly\n\nSyntax:\n ELSEIF <expr>\n\nExample:\n IF(2 * 4 - CND)\n MOV A, #20h\n ELSEIF SOMETHING_ELSE\n MOV A, #40h\n ENDIF\n\n}
ifn {IF Not, conditional assembly\n\nSyntax:\n IFN <expr>\n\nExample:\n IF(2 * 4 - CND)\n MOV A, #20h\n ELSE\n MOV A, #40h\n ENDIF\n\n}
- elseifn {ELSE IF Not\n\nSyntax:\n ELSEIFN <expr>\n\nExample:\n IF(2 * 4 - CND)\n MOV A, #20h\n ELSEIFN SOMETHING_ELSE\n MOV A, #40h\n ENDIF\n\nNote:\n Supported by ASEM-51 only}
+ elseifn {ELSE IF Not\n\nSyntax:\n ELSEIFN <expr>\n\nExample:\n IF(2 * 4 - CND)\n MOV A, #20h\n ELSEIFN SOMETHING_ELSE\n MOV A, #40h\n ENDIF\n\n}
ifdef {IF DEFined\n\nSyntax:\n IFDEF <symbol>\n\nExample:\n IFDEF CND\n MOV A, #20h\n ELSE\n MOV A, #40h\n ENDIF\n\n}
- elseifdef {ELSE IF DEFined\n\nSyntax:\n ELSEIFDEF <symbol>\n\nExample:\n IFDEF(2 * 4 - CND)\n MOV A, #20h\n ELSEIFDEF SOMETHING_ELSE\n MOV A, #40h\n ENDIF\n\nNote:\n Supported by ASEM-51 only}
+ elseifdef {ELSE IF DEFined\n\nSyntax:\n ELSEIFDEF <symbol>\n\nExample:\n IFDEF(2 * 4 - CND)\n MOV A, #20h\n ELSEIFDEF SOMETHING_ELSE\n MOV A, #40h\n ENDIF\n\n}
ifndef {IF Not DEFined\n\nSyntax:\n IFNDEF <symbol>\n\nExample:\n IFNDEF CND\n MOV A, #20h\n ELSE\n MOV A, #40h\n ENDIF\n\n}
- elseifndef {ELSE IF Not DEFined\n\nSyntax:\n ELSEIFNDEF <symbol>\n\nExample:\n IFDEF CND\n MOV A, #20h\n ELSEIFNDEF SOMETHING_ELSE\n MOV A, #40h\n ENDIF\n\nNote:\n Supported by ASEM-51 only}
+ elseifndef {ELSE IF Not DEFined\n\nSyntax:\n ELSEIFNDEF <symbol>\n\nExample:\n IFDEF CND\n MOV A, #20h\n ELSEIFNDEF SOMETHING_ELSE\n MOV A, #40h\n ENDIF\n\n}
ifb {IF Black\n\nSyntax:\n IFB <literal>\n\nExample:\n IFB <CND>\n MOV A, #20h\n ELSE\n MOV A, #40h\n ENDIF\n\nNote:\n Supported by ASEM-51 only}
elseifb {ELSE IF Black\n\nSyntax:\n ELSEIFB <literal>\n\nExample:\n IFB <CND>\n MOV A, #20h\n ELSEIFB <SOMETHING_ELSE>\n MOV A, #40h\n ENDIF\n\literal:\n Supported by ASEM-51 only}
ifnb {IF Not Black\n\nSyntax:\n IFNB <literal>\n\nExample:\n IFNB <CND>\n MOV A, #20h\n ELSE\n MOV A, #40h\n ENDIF\n\nNote:\n Supported by ASEM-51 only}
@@ -96,11 +104,12 @@ class InstructionDetails {
bseg {switch to BIT segment \[at address\]\n\nSyntax:\n BSEG \[AT <expr>\]\n\nExample:\n BSEG at 5d\n\n}
xseg {switch to XDATA segment \[at address\]\n\nSyntax:\n XSEG \[AT <expr>\]\n\nExample:\n XSEG at 30d\n\n}
cseg {switch to CODE segment \[at address\]\n\nSyntax:\n CSEG \[AT <expr>\]\n\nExample:\n CSEG at 40d\n\n}
+ local {define a local label inside a macro\n\nSyntax:\n LOCAL <symbol>\n\nExample:\n ABC MACRO\n LOCAL xyz\n xyz: MOV B, #12d\n EXITM\n NOP\n ENDM\n\n}
flag {define a FLAG bit\n\nSyntax:\n <symbol> FLAG <expr>\n\nExample:\n F4 FLAG 16h\n\nNote:\n Deprecated directive. Consider directive BIT instead.}
skip {SKIP bytes in the code memory\n\nSyntax:\n SKIP <expr>\n\nExample:\n SKIP 5\n\n}
equ {EQUivalent\n\nSyntax:\n <symbol> EQU <expr>\n\nExample:\n ABC EQU R0\n XYZ EQU 4Eh+12\n\n}
bit {define BIT address\n\nSyntax:\n <symbol> BIT <expr>\n\nExample:\n ABC BIT P4.5\n\n}
- set {SET numeric variable or variable register\n\nSyntax:\n <symbol> SET <expr>\n <symbol> SET <register>\n\nExample:\n ALPHA SET R0\N ALPHA SET 42*BETA\n\n}
+ set {SET numeric variable or variable register\n\nSyntax:\n <symbol> SET <expr>\n <symbol> SET <register>\n\nExample:\n ALPHA SET R0\n ALPHA SET 42*BETA\n\n}
code {define address in the CODE memory\n\nSyntax:\n <symbol> CODE <expr>\n\nExample:\n TBL CODE 600h\n\n}
data {define address in the DATA memory\n\nSyntax:\n <symbol> DATA <expr>\n\nExample:\n UIV DATA 20h\n\n}
idata {define address in the Internal DATA memory\n\nSyntax:\n <symbol> IDATA <expr>\n\nExample:\n UIV IDATA 20h\n\n}
@@ -111,7 +120,7 @@ class InstructionDetails {
db {Define Bytes\n\nSyntax:\n DB <expr1> \[,<expr2> ... \]\n\nExample:\n DB 24,'August',09,(2*8+24)/8\n\n}
dbit {Define BITs\n\nSyntax:\n DBIT <expr>\n\nExample:\n DBIT 4+2\n\n}
include {INCLUDE an external source code\n\nSyntax:\n INCLUDE <filename>\n\nExample:\n INCLUDE 'my file.asm'\n\n}
- org {ORiGin of segment location\n\nSyntax:\n ORG <expr>\n\nExample:\n ORG 0Bh\n\n}
+ org {ORiGin of code segment location\n\nSyntax:\n ORG <expr>\n\nExample:\n ORG 0Bh\n\n}
using {USING register banks\n\nSyntax:\n USING <expr>\n\nExample:\n USING 2\n\n}
byte {define BYTE address in the data memory\n\nSyntax:\n <symbol> BYTE <expr>\n\nExample:\n UIV BYTE 20h\n\nNote:\n Deprecated directive. Consider directive DATA instead.}
@@ -875,7 +884,7 @@ class InstructionDetails {
private variable header_text ;# Widget: Text header
private variable instruction_last {} ;# String: Last instruction shown in details window
private variable parent {} ;# Widget: GUI parent
- private variable gui_initialized 0 ;# Bool: GUI initialized
+ private variable instd_gui_initialized 0 ;# Bool: GUI initialized
private variable gui_preparing 0 ;# Bool: Prearing panel GUI
private variable enabled 0 ;# Bool: enable procedures which are needless while loading project
@@ -886,11 +895,11 @@ class InstructionDetails {
private variable ins_help_window {} ;# Widget: Help window itself
private variable help_win_title ;# Widget: Title label (should contain instruction name and operands)
## Array of Widgets: Labels containing certain information
- # Avaliable keys are: description, length, execution_time, opcode, note and class
+ # available keys are: description, length, execution_time, opcode, note and class
private variable help_win_labels
constructor {} {
- incr count
+ incr instd_count
}
destructor {
@@ -901,13 +910,13 @@ class InstructionDetails {
# @return void
public method PrepareInstructionDetails {_parent} {
set parent $_parent
- set gui_initialized 0
+ set instd_gui_initialized 0
}
## Create GUI of tab "Instruction details"
# @return void
public method CreateInstructionDetailsGUI {} {
- if {$gui_initialized || $gui_preparing || ${::Editor::editor_to_use}} {return}
+ if {$instd_gui_initialized || $gui_preparing || ${::Editor::editor_to_use}} {return}
set gui_preparing 1
# Create frames
@@ -929,10 +938,14 @@ class InstructionDetails {
# Tab header (instruction name)
set instruction_label [label $header_frame.lbl_rightPanel_instruction_header \
- -fg {#0000FF} \
- -anchor w \
- -padx {20px} \
- -font [font create -weight {bold} -size -17 -family $::DEFAULT_FIXED_FONT] \
+ -fg {#0000FF} \
+ -anchor w \
+ -padx {20px} \
+ -font [font create \
+ -weight {bold} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -family $::DEFAULT_FIXED_FONT \
+ ] \
]
pack $instruction_label -side left -fill x -expand 1
setStatusTip -widget $instruction_label -text [mc "Instruction name"]
@@ -940,7 +953,7 @@ class InstructionDetails {
# Create popup menu for instruction text and its header
set instruction_menu [menu $text_frame.popup_menu -tearoff 0]
$instruction_menu add command -label "Configure" -compound left \
- -command {::configDialogs::rightPanel::mkDialog 1} \
+ -command {::configDialogues::rightPanel::mkDialog 1} \
-underline 0 -image ::ICONS::16::configure
# Text header
@@ -951,6 +964,7 @@ class InstructionDetails {
-height 1 \
-bd 0 \
-exportselection 0 \
+ -wrap none \
]
bind $header_text <ButtonRelease-3> "tk_popup $instruction_menu %X %Y; break"
bind $header_text <Key-Menu> "tk_popup $instruction_menu %X %Y; break"
@@ -959,7 +973,7 @@ class InstructionDetails {
# Instruction details text
set instruction_text [text $text_frame.txt_rightPanel_instruction \
-yscrollcommand "$body_frame.src_rightPanel_instruction set" \
- -cursor left_ptr -state disabled -wrap word \
+ -cursor left_ptr -state disabled -wrap none \
-font $instruction_font -bd 0 -exportselection 0 \
]
# Create scrollbar
@@ -979,7 +993,10 @@ class InstructionDetails {
$instruction_text tag configure tag_sel0 -background #E0FFE0
rightPanel_refresh_instruction_highlighting
$instruction_text tag configure tag_bold -font [font create \
- -size -12 -family $::DEFAULT_FIXED_FONT -weight {bold}]
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family $::DEFAULT_FIXED_FONT \
+ -weight {bold} \
+ ]
# Pack parts of text frame (Instruction details text, Text header)
pack $header_text -side top -fill x
@@ -990,7 +1007,7 @@ class InstructionDetails {
pack $header_frame -side top -fill x
pack $body_frame -side bottom -fill both -expand 1
- set gui_initialized 1
+ set instd_gui_initialized 1
}
## Invoke legend window for "Instruction details"
@@ -1006,7 +1023,7 @@ class InstructionDetails {
set y [winfo pointery .]
# Create legend window
- set win [toplevel .rightPanel_legend -class {Help} -bg {#EEEEEE}]
+ set win [toplevel .rightPanel_legend -class {Help} -bg ${::COMMON_BG_COLOR}]
set frame [frame $win.f -bg {#555555} -bd 0 -padx 1 -pady 1]
wm overrideredirect $win 1
@@ -1152,7 +1169,8 @@ class InstructionDetails {
# @return void
public method rightPanel_ins_clear {} {
if {!$enabled || ${::Editor::editor_to_use}} {return}
- if {!$gui_initialized} {CreateInstructionDetailsGUI}
+ if {!$instd_gui_initialized} {CreateInstructionDetailsGUI}
+
$instruction_text configure -state normal
$instruction_text delete 1.0 end
$instruction_text configure -state disabled
@@ -1167,7 +1185,7 @@ class InstructionDetails {
# @return void
public method rightPanel_refresh_instruction_highlighting {} {
if {${::Editor::editor_to_use}} {return}
- if {!$gui_initialized && !$gui_preparing} {return}
+ if {!$instd_gui_initialized && !$gui_preparing} {return}
$this right_panel_create_highlighting_tags \
$instruction_text $instruction_tags 0
}
@@ -1176,12 +1194,12 @@ class InstructionDetails {
# @return void
public method rightPanel_ins_unselect {} {
if {!$enabled || ${::Editor::editor_to_use}} {return}
- if {!$gui_initialized} {return}
+ if {!$instd_gui_initialized} {return}
$instruction_text tag remove tag_sel 1.0 end
if {$::CONFIG(VALIDATION_LEVEL) == 2} {
$instruction_label configure -fg {#FF0000}
- } {
+ } else {
$instruction_label configure -fg {#0000FF}
}
}
@@ -1192,12 +1210,12 @@ class InstructionDetails {
# @return void
public method rightPanel_ins_select {perfect_match list_of_indexes} {
if {!$enabled || ${::Editor::editor_to_use}} {return}
- if {!$gui_initialized} {return}
+ if {!$instd_gui_initialized} {return}
if {[$instruction_label cget -text] == {}} {return}
$instruction_label configure -fg {#0000FF}
if {$perfect_match} {
set tag tag_sel
- } {
+ } else {
set tag tag_sel0
}
foreach line $list_of_indexes {
@@ -1213,7 +1231,7 @@ class InstructionDetails {
# @return void
public method rightPanel_dir_change {type directive} {
if {!$enabled || ${::Editor::editor_to_use}} {return}
- if {!$gui_initialized} {return}
+ if {!$instd_gui_initialized} {return}
regsub {^\.} $directive {} directive
set directive [string tolower $directive]
@@ -1225,7 +1243,7 @@ class InstructionDetails {
# Change content of tab header
if {$type == {D}} {
set clr {#00AADD}
- } {
+ } else {
set clr {#00AADD}
}
set dir_up [string toupper $directive]
@@ -1239,7 +1257,7 @@ class InstructionDetails {
set idx [lsearch -ascii -exact $HELP_FOR_DIRECTIVES $directive]
if {$idx == -1} {
$instruction_text insert end [mc "no help available for this directive"]
- } {
+ } else {
incr idx
$instruction_text insert end [lindex $HELP_FOR_DIRECTIVES $idx]
}
@@ -1259,7 +1277,7 @@ class InstructionDetails {
# @return void
public method rightPanel_ins_change {instruction} {
if {!$enabled || ${::Editor::editor_to_use}} {return}
- if {!$gui_initialized} {return}
+ if {!$instd_gui_initialized} {return}
set instruction [string tolower $instruction]
if {$instruction_last == $instruction} {return}
@@ -1333,7 +1351,7 @@ class InstructionDetails {
if {[string index $opr 0] == {@}} {
$instruction_text tag add tag_indr $startIndex insert-1c
# SFR
- } {
+ } else {
$instruction_text tag add tag_SFR $startIndex insert-1c
}
}
@@ -1580,15 +1598,19 @@ class InstructionDetails {
## Create instruciton help window
# @return void
private method create_ins_help_window {} {
+ if {$ins_help_win_created} {
+ return
+ }
set ins_help_win_created 1
# Create main parts of the window
- set ins_help_window [frame .ins_help_window${count} -bd 0 -bg {#BBBBFF} -padx 2 -pady 2]
+ incr instd_count
+ set ins_help_window [frame .ins_help_window${instd_count} -bd 0 -bg {#BBBBFF} -padx 2 -pady 2]
pack [frame $ins_help_window.top -bg {#BBBBFF}] -fill x -expand 1
pack [label $ins_help_window.top.img -bg {#BBBBFF} -image ::ICONS::16::info] -side left
pack [label $ins_help_window.top.tit -bg {#BBBBFF} -justify left -anchor w] -side left -fill x -expand 1
pack [frame $ins_help_window.msg -bg {#FFFFFF} -padx 10 -pady 5] -fill both -expand 1
- set help_win_title "$ins_help_window.top.tit"
+ set help_win_title "${ins_help_window}.top.tit"
## Create other parts of the window
# Descripton
@@ -1753,3 +1775,7 @@ class InstructionDetails {
# Initialize
::InstructionDetails::initialize
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/rightpanel/regwatches.tcl b/lib/rightpanel/regwatches.tcl
index ad5e433..6760cab 100755..100644
--- a/lib/rightpanel/regwatches.tcl
+++ b/lib/rightpanel/regwatches.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 _REGWATCHES_TCL ] } {
+set _REGWATCHES_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements register watches (part of Right Panel)
@@ -34,7 +39,7 @@ class RegWatches {
# Counter of embedded entry widgets in register watches
common watch_entry_count 0
# Conter of instances
- common count 0
+ common regw_count 0
## Highlighting tags for register watches
# {
# {tag_name foreground_color ?bold_or_italic?}
@@ -47,7 +52,7 @@ class RegWatches {
{tag_addr #0000DD 1}
{tag_name #8888DD {}}
}
- common regfont [font create -family $::DEFAULT_FIXED_FONT -size -14]
+ common regfont [font create -family $::DEFAULT_FIXED_FONT -size [expr {int(-14 * $::font_size_factor)}]]
# Popup menu for register watches
common WATCHMENU {
{command {Move top} {$watches:top} 0 "rightPanel_watch_move_top"
@@ -72,12 +77,12 @@ class RegWatches {
}
# Configuration menu
common CONFMENU {
- {cascade {Sort by} 0 "" .sort false 1 {
- {command {Name} {} 0 "rightPanel_watch_sort_by N" {}
+ {cascade "Sort by" 0 "" .sort false 1 {
+ {command "Name" {} 0 "rightPanel_watch_sort_by N" {}
""}
- {command {Address} {} 0 "rightPanel_watch_sort_by A" {}
+ {command "Address" {} 0 "rightPanel_watch_sort_by A" {}
""}
- {command {Type} {} 0 "rightPanel_watch_sort_by T" {}
+ {command "Type" {} 0 "rightPanel_watch_sort_by T" {}
""}
{separator}
{radiobutton "Incremental" {} ::RegWatches::sorting_order 1
@@ -85,18 +90,20 @@ class RegWatches {
{radiobutton "Decremental" {} ::RegWatches::sorting_order 0
{} 0 ""}
}}
- {command {Remove all} {} 0 "rightPanel_watch_clear" {editdelete}
+ {command "Remove all" {} 0 "rightPanel_watch_clear" {editdelete}
""}
{separator}
- {checkbutton {Autoload from code listing} {} {::RegWatches::menu_autoload} 1 0 0
+ {checkbutton "Autoload from code listing" {} {::RegWatches::menu_autoload} 1 0 0
{rightPanel_watch_toggle_autoload_flag}}
+ {checkbutton "Clear on auto-load" {} {::RegWatches::menu_autoclear} 1 0 0
+ {rightPanel_watch_toggle_autoclear_flag}}
}
## PRIVATE
private variable enabled 0 ;# Bool: enable procedures which are needless while loading project
private variable obj_idx ;# Number of this object
private variable parent ;# Widget: parent widget
- private variable gui_initialized 0 ;# Bool: GUI initialized
+ private variable regw_gui_initialized 0 ;# Bool: GUI initialized
private variable conf_button ;# Widget: Configuration button
private variable conf_menu {} ;# Configuration menu
@@ -111,6 +118,7 @@ class RegWatches {
# Bool: Autoload from LST file
private variable autoload_flag [lindex $::CONFIG(REGWATCHES_CONFIG) 0]
+ private variable autoclear_flag [lindex $::CONFIG(REGWATCHES_CONFIG) 2]
private variable watches_modified 0 ;# Bool: Register watches definition modified
private variable search_val_in_progress 0 ;# Bool: Search entry validation in porgress
private variable watch_file_name {} ;# Name of file currently loaded in register watches
@@ -128,13 +136,13 @@ class RegWatches {
## Object constructor
constructor {} {
- incr count
- set obj_idx $count
+ incr regw_count
+ set obj_idx $regw_count
}
## Object destructor
destructor {
- if {$gui_initialized} {
+ if {$regw_gui_initialized} {
# Remove status bar tips for popup menus
menu_Sbar_remove $watch_menu
@@ -151,14 +159,14 @@ class RegWatches {
public method PrepareRegWatches {_parent filename} {
set parent $_parent
set watch_file_name $filename
- set gui_initialized 0
+ set regw_gui_initialized 0
}
## Create GUI of register watches
# @return void
public method CreateRegWatchesGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$regw_gui_initialized} {return}
+ set regw_gui_initialized 1
# Top frame
set icon_bar [frame $parent.frm_rightPanel_watch_iconBar]
@@ -196,9 +204,9 @@ class RegWatches {
-style Flat.TButton \
]
pack $button -side left -padx 3
- DynamicHelp::add $button -text [mc "Save under a different filename"]
+ DynamicHelp::add $button -text [mc "Save under a different file name"]
setStatusTip -widget $button \
- -text [mc "Save under a different filename"]
+ -text [mc "Save under a different file name"]
# Separator
pack [ttk::separator $icon_bar.sep_rightPanel_watch_ib_sep0 \
-orient vertical \
@@ -248,10 +256,10 @@ class RegWatches {
# Entry "Address"
set entry [ttk::entry $tool_bar.ent_rightPanel_watch_addr \
- -textvariable RightPanel::watch_addr$count \
+ -textvariable RightPanel::watch_addr${regw_count} \
-validatecommand "$this rightPanel_watch_addr_validate %P" \
-validate key \
- -width 4 \
+ -width 5 \
]
DynamicHelp::add $entry \
-text [mc "Register address:\n 1 or 2 digits\tinternal RAM (not SFR)\n 3 digits\t\texpanded RAM\n 4 digits\t\texternal RAM\n dot and 2 digits\tBit"]
@@ -263,7 +271,7 @@ class RegWatches {
# Entry "Name"
set entry [ttk::entry $tool_bar.ent_rightPanel_watch_name \
- -textvariable RightPanel::watch_name$count \
+ -textvariable RightPanel::watch_name${regw_count} \
-validatecommand "$this rightPanel_watch_name_validate %P" \
-validate key \
-width 20 \
@@ -378,7 +386,7 @@ class RegWatches {
3 {
if {[string index $addr 0] == {.}} {
set type {B}
- } {
+ } else {
set type {E}
}
}
@@ -394,7 +402,7 @@ class RegWatches {
if {$::RegWatches::sorting_order} {
set order {-increasing}
# Decremental sorting order
- } {
+ } else {
set order {-decreasing}
}
@@ -430,6 +438,9 @@ class RegWatches {
if {!$autoload_flag} {return}
if {![file exists $filename]} {return}
+ if {$autoclear_flag} {
+ rightPanel_watch_clear 1
+ }
rightPanel_watch_import_file $filename .
}
@@ -439,10 +450,20 @@ class RegWatches {
set autoload_flag $::RegWatches::menu_autoload
}
+ ## Autoclear flag toggled (this function should be invoked from configuration menu)
+ # @return void
+ public method rightPanel_watch_toggle_autoclear_flag {} {
+ set autoclear_flag $::RegWatches::menu_autoclear
+ }
+
## Get configuration list
# @return void
public method rightPanel_watch_get_config {} {
- return [list $::RegWatches::menu_autoload $::RegWatches::sorting_order]
+ return [list \
+ $autoload_flag \
+ $::RegWatches::sorting_order \
+ $autoclear_flag \
+ ]
}
## Create configuration menu
@@ -452,7 +473,7 @@ class RegWatches {
return
}
set conf_menu $parent.conf_menu
- menuFactory $CONFMENU $conf_menu 0 "$this " 0 {}
+ menuFactory $CONFMENU $conf_menu 0 "$this " 0 {} [namespace current]
watch_disEna_buttons
}
@@ -467,22 +488,23 @@ class RegWatches {
incr y [winfo height $conf_button]
set ::RegWatches::menu_autoload $autoload_flag
+ set ::RegWatches::menu_autoclear $autoclear_flag
tk_popup $conf_menu $x $y
}
## Refresh highlighting tags
# @return void
public method rightPanel_refresh_regwatches_highlighting {} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
$this right_panel_create_highlighting_tags $watch_text $watch_text_tags -1
}
## Recreate popup menu
# @return void
public method regwatches_makePopupMenu {} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
if {[winfo exists $watch_menu]} {destroy $watch_menu}
- menuFactory $WATCHMENU $watch_menu 0 "$this " 0 {}
+ menuFactory $WATCHMENU $watch_menu 0 "$this " 0 {} [namespace current]
}
@@ -497,7 +519,7 @@ class RegWatches {
if {![string first $prj_path $watch_file_name]} {
return [string range $watch_file_name [string length $prj_path] end]
# Return absolute directory location
- } {
+ } else {
return $watch_file_name
}
}
@@ -506,7 +528,7 @@ class RegWatches {
# @parm Widget entry - Target entry widget
# @return void
private method watch_entry_shortcuts_reset {entry} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
# Unset previous configuration
foreach key $watches_set_shortcuts {
@@ -554,13 +576,13 @@ class RegWatches {
return { .00}
}
if {$string == "\n"} {
- set string [subst "\$::RightPanel::watch_addr${obj_idx}"]
+ set string [subst -nocommands "\$::RightPanel::watch_addr${obj_idx}"]
regsub {^\s+} $string {} string
}
if {[string index $string 0] == {.}} {
set string [string replace $string 0 0]
set bit_addr 1
- } {
+ } else {
set bit_addr 0
}
@@ -570,7 +592,7 @@ class RegWatches {
if {$len != 4} {
set string " $string"
}
- } {
+ } else {
if {$len == 1} {
set string "0$string"
}
@@ -580,7 +602,7 @@ class RegWatches {
# Resturn result
if {$bit_addr} {
return [string replace $string 1 1 {.}]
- } {
+ } else {
return [string toupper $string]
}
}
@@ -591,7 +613,7 @@ class RegWatches {
private method get_watchName {string} {
# Conditionaly get value from entry widget
if {$string == "\n"} {
- set string [subst "\$::RightPanel::watch_name${obj_idx}"]
+ set string [subst -nocommands "\$::RightPanel::watch_name${obj_idx}"]
regsub {\t+$} $string {} string
}
@@ -770,7 +792,7 @@ class RegWatches {
if {[string index $addr 0] == {.}} {
set addr [string replace $addr 0 0]
set bit_addr 1
- } {
+ } else {
set bit_addr 0
}
set dec_addr [expr "0x$addr"]
@@ -820,7 +842,7 @@ class RegWatches {
# AFFECT ALL ENTRIES (not only valid ones) !!!
# @return void
public method rightPanel_watch_force_enable {} {
- if {!$gui_initialized} {CreateRegWatchesGUI}
+ if {!$regw_gui_initialized} {CreateRegWatchesGUI}
set watches_enabled 1
foreach addr $watch_addrs {
@@ -832,14 +854,14 @@ class RegWatches {
# Affect only entries with valid address (implemented on current MCU)
# @return void
public method rightPanel_watch_enable {} {
- if {!$gui_initialized} {CreateRegWatchesGUI}
+ if {!$regw_gui_initialized} {CreateRegWatchesGUI}
set watches_enabled 1
foreach addr $watch_addrs {
if {[string index $addr 0] == {.}} {
set addr [string replace $addr 0 0]
set bit_addr 1
- } {
+ } else {
set bit_addr 0
}
set dec_addr [expr "0x$addr"]
@@ -848,7 +870,7 @@ class RegWatches {
# Bit
if {$bit_addr} {
if {$dec_addr > 0x7F} {
- if {![$this simulator_is_sfr_avaliable [$this getRegOfBit $dec_addr]]} {
+ if {![$this simulator_is_sfr_available [$this getRegOfBit $dec_addr]]} {
continue
}
}
@@ -880,7 +902,7 @@ class RegWatches {
## Disable all entry widgets in register watches
# @return void
public method rightPanel_watch_disable {} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
set watches_enabled 0
foreach addr $watch_addrs {
@@ -900,7 +922,7 @@ class RegWatches {
# @parm Int row - target line
# @return void
public method rightPanel_watch_switch_line {row} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
set watch_AN_valid_ena 0
# Determinate number of the last row
@@ -928,7 +950,7 @@ class RegWatches {
set ::RightPanel::watch_addr${obj_idx} {}
set watch_AN_valid_ena 1
return 0
- } {
+ } else {
set watch_curLine $row
$watch_remove_button configure -state normal
$watch_new_button configure -state normal
@@ -982,7 +1004,7 @@ class RegWatches {
set addr [get_watchAddr "\n"]
set name [get_watchName "\n"]
set no_sbar 0
- } {
+ } else {
set addr [get_watchAddr $addr]
set name [get_watchName $name]
set no_sbar 1
@@ -1061,7 +1083,7 @@ class RegWatches {
private method watch_create_entry {addr row var} {
if {[string index $addr 0] == {.}} {
set width 1
- } {
+ } else {
set width 2
}
@@ -1096,7 +1118,7 @@ class RegWatches {
## Clear highlight for all registers
# @return void
public method rightPanel_watch_clear_highlight {} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
foreach addr $watch_addrs {
$watch_text.[lindex $watch_data($addr) 1] configure -fg ${Simulator::normal_color}
@@ -1106,7 +1128,7 @@ class RegWatches {
## Clear highlight for the given register
# @return void
public method rightPanel_watch_unhighlight {addr} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
if {[lsearch $watch_addrs $addr] == -1} {
return
@@ -1187,7 +1209,7 @@ class RegWatches {
set addr_tag {tag_Baddr}
} elseif {$len == 3} {
set addr_tag {tag_Eaddr}
- } {
+ } else {
set addr_tag {tag_addr}
}
# Restore text tags
@@ -1277,18 +1299,20 @@ class RegWatches {
public method rightPanel_watch_remove {} {
# Determinate register address
set addr [lindex $watch_addrs [expr {$watch_curLine - 1}]]
- # Destroy value entry
- set var [lindex $watch_data($addr) 1]
- destroy $watch_text.$var
- # Unregister watch
- unset watch_data($addr)
- set idx [lsearch $watch_addrs $addr]
- set watch_addrs [lreplace $watch_addrs $idx $idx]
+ if {$addr != {}} {
+ # Destroy value entry
+ set var [lindex $watch_data($addr) 1]
+ destroy $watch_text.$var
+ # Unregister watch
+ unset watch_data($addr)
+ set idx [lsearch $watch_addrs $addr]
+ set watch_addrs [lreplace $watch_addrs $idx $idx]
- # Remove watch from the text widget
- $watch_text configure -state normal
- $watch_text delete $watch_curLine.0 "$watch_curLine.0 + 1 line"
- $watch_text configure -state disabled
+ # Remove watch from the text widget
+ $watch_text configure -state normal
+ $watch_text delete $watch_curLine.0 "$watch_curLine.0 + 1 line"
+ $watch_text configure -state disabled
+ }
# Change current line
if {$watch_curLine > [llength $watch_addrs]} {
@@ -1296,6 +1320,8 @@ class RegWatches {
}
if {$watch_curLine} {
rightPanel_watch_switch_line $watch_curLine
+ } else {
+ rightPanel_watch_switch_line 1
}
# Reevaluate button states
@@ -1308,33 +1334,28 @@ class RegWatches {
## Save watches definition to a file
# @parm String filename - Target filename or an empty string
- # @parm Bool force = 0 - Do not ask for overwrite
+ # @parm Bool force=0 - Do not ask for overwrite
# @return void
- public method rightPanel_watch_save args {
- if {!$gui_initialized} {CreateRegWatchesGUI}
+ public method rightPanel_watch_save {filename {force 0}} {
+ if {!$regw_gui_initialized} {CreateRegWatchesGUI}
- set filename [lindex $args 0]
- set force [lindex $args 1]
if {$filename != {}} {
set watch_file_name $filename
}
- if {$force != {1}} {
- set force 0
- }
# If no filename specified -> invoke dislog "Save as"
if {$watch_file_name == {}} {
rightPanel_watch_saveas
# Save file
- } {
+ } else {
# Set new filename
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $watch_file_name]} {
set filename "[$this cget -ProjectDir]/$watch_file_name"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $watch_file_name]} {
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $watch_file_name]} {
set filename [file join [$this cget -ProjectDir] $watch_file_name]
}
}
@@ -1354,7 +1375,7 @@ class RegWatches {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $watch_file_name]]
] != {yes}
- } {
+ } then {
return
}
# Create a backup file
@@ -1363,11 +1384,11 @@ class RegWatches {
}
}
if {[catch {
- set file [open $watch_file_name w 420]
- }]} {
+ set file [open $watch_file_name w 0640]
+ }]} then {
if {[winfo exists .fsd]} {
set parent .fsd
- } {
+ } else {
set parent .
}
tk_messageBox -type ok \
@@ -1379,7 +1400,6 @@ class RegWatches {
# Write file header
puts $file "# Watches definition file -- ${::APPNAME}"
- puts $file "# Date: [clock format [clock seconds] -format {%D}]"
# Write watches definition
puts -nonewline $file [regsub -all -line {\s+$} [$watch_text get 1.0 end] {}]
@@ -1404,10 +1424,10 @@ class RegWatches {
KIFSD::FSD ::fsd \
-title [mc "Save watches - MCU 8051 IDE"] \
-directory [$this cget -ProjectDir] \
- -defaultmask 0 -multiple 0 -filetypes {
- {{MCU 8051 IDE watch definition} {*.wtc} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "MCU 8051 IDE watches definition"] {*.wtc}] \
+ [list [mc "All files"] {*}] \
+ ]
# Save file after press of OK button
::fsd setokcmd {
set ::filename [::fsd get]
@@ -1421,19 +1441,19 @@ class RegWatches {
## Open and process watches definition file
# @parm String filename - name of source file
- # @parm Widget parent - GUI parent (for error dialogs)
+ # @parm Widget parent - GUI parent (for error dialogues)
# @parm Bool clear - Clear watches before loading
# @return Bool - result
public method rightPanel_watch_openfile {filename parent clear} {
- if {!$gui_initialized} {CreateRegWatchesGUI}
+ if {!$regw_gui_initialized} {CreateRegWatchesGUI}
# Normalize filename
if {!$::MICROSOFT_WINDOWS} { ;# POSIX way
if {![regexp "^(~|/)" $filename]} {
set filename "[$this cget -projectPath]/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
set filename [file join [$this cget -projectPath] $filename]
}
}
@@ -1446,7 +1466,10 @@ class RegWatches {
if {[catch {
set file [open $filename r]
}]} then {
- tk_messageBox -parent $parent -icon warning -type ok \
+ tk_messageBox \
+ -parent $parent \
+ -icon warning \
+ -type ok \
-title [mc "File access error"] \
-message [mc "Unable to read file '%s'" $filename]
set watch_file_name {}
@@ -1471,11 +1494,11 @@ class RegWatches {
![regexp {^\s*\.?[A-Fa-f0-9]+$} $addr] ||
[string length $addr] > 4 ||
[string length $name] > 23
- } {
+ } then {
tk_messageBox \
-title [mc "Corrupted file"] \
-icon error -type ok -parent $parent \
- -message [mc "file: %s is eighter corrupted or it is not a file in expected format." $filename]
+ -message [mc "file: %s is either corrupted or it is not a file in expected format." $filename]
return 0
}
}
@@ -1524,16 +1547,16 @@ class RegWatches {
KIFSD::FSD ::fsd \
-title [mc "Load watches from file - MCU 8051 IDE"] \
-directory [$this cget -ProjectDir] -autoclose 0 \
- -defaultmask 0 -multiple 0 -filetypes {
- {{MCU 8051 IDE watches definition} {*.wtc} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "MCU 8051 IDE watches definition"] {*.wtc}] \
+ [list [mc "All files"] {*}] \
+ ]
# Open file after press of OK button
fsd setokcmd {
# Get chosen file name
set filename [::fsd get]
- if {[${X::actualProject} rightPanel_watch_openfile $filename [::fsd get_window_name] 1]} {
+ if {[${::X::actualProject} rightPanel_watch_openfile $filename [::fsd get_window_name] 1]} {
::fsd deactivate
delete object fsd
}
@@ -1550,17 +1573,17 @@ class RegWatches {
KIFSD::FSD ::fsd \
-title [mc "Import file - MCU 8051 IDE"] \
-directory [$this cget -ProjectDir] -autoclose 0 \
- -defaultmask 0 -multiple 0 -filetypes {
- {{Code listing} {*.lst} }
- {{MCU 8051 IDE watches definition} {*.wtc} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Code listing"] {*.lst}] \
+ [list [mc "MCU 8051 IDE watches definition"] {*.wtc}] \
+ [list [mc "All files"] {*}] \
+ ]
# Open file after press of OK button
fsd setokcmd {
# Get chosen file name
set filename [::fsd get]
- if {[${X::actualProject} rightPanel_watch_import_file $filename [::fsd get_window_name]]} {
+ if {[${::X::actualProject} rightPanel_watch_import_file $filename [::fsd get_window_name]]} {
::fsd deactivate
delete object fsd
}
@@ -1572,15 +1595,15 @@ class RegWatches {
## Import file
# @parm String filename - Name of source file (*.lst or *.wtc)
- # @parm Widget parent - GUI parent (for error dialogs)
+ # @parm Widget parent - GUI parent (for error dialogues)
# @return Bool - result
public method rightPanel_watch_import_file {filename parent} {
- if {!$gui_initialized} {CreateRegWatchesGUI}
+ if {!$regw_gui_initialized} {CreateRegWatchesGUI}
# Determinate file type
set filename [file normalize [file join [$this cget -ProjectDir] $filename]]
set file_type 0
- switch -- [file extension $filename] {
+ switch -nocase -- [file extension $filename] {
{.wtc} { ;# Watches definition file
set file_type 1
}
@@ -1624,7 +1647,7 @@ class RegWatches {
# Try to open file
if {[catch {
set file [open $filename r]
- }]} {
+ }]} then {
tk_messageBox \
-parent . \
-type ok \
@@ -1757,16 +1780,10 @@ class RegWatches {
}
## Remove all register watches
- # Bool force = 0 - Don't ask user for comfirmation
+ # Bool force=0 - Don't ask for user comfirmation
# @return void
- public method rightPanel_watch_clear args {
- if {!$gui_initialized} {CreateRegWatchesGUI}
-
- # Parse arguments
- set force [lindex $args 0]
- if {$force == {}} {
- set force 0
- }
+ public method rightPanel_watch_clear {{force 0}} {
+ if {!$regw_gui_initialized} {CreateRegWatchesGUI}
# Ask user for comfirmation
if {!$force} {
@@ -1819,7 +1836,7 @@ class RegWatches {
# Enable/Disable button "Clear search entry"
if {$content == {}} {
$watch_search_clear configure -state disabled
- } {
+ } else {
$watch_search_clear configure -state normal
}
@@ -1858,7 +1875,7 @@ class RegWatches {
## Syncronize all register watches
# @return void
public method rightPanel_watch_sync_all {} {
- if {!$gui_initialized} {CreateRegWatchesGUI}
+ if {!$regw_gui_initialized} {CreateRegWatchesGUI}
# Iterate over addresses
foreach addr $watch_addrs {
@@ -1881,7 +1898,7 @@ class RegWatches {
return {--}
}
set bit_addr 1
- } {
+ } else {
set bit_addr 0
}
set len [string length $addr]
@@ -1891,10 +1908,10 @@ class RegWatches {
# Bit
if {$bit_addr} {
if {$addr_dec > 0x7F} {
- if {[$this simulator_is_sfr_avaliable [$this getRegOfBit $addr_dec]]} {
+ if {[$this simulator_is_sfr_available [$this getRegOfBit $addr_dec]]} {
set val [$this getBit $addr_dec]
}
- } {
+ } else {
set val [$this getBit $addr_dec]
}
@@ -1929,6 +1946,7 @@ class RegWatches {
# @parm Int dec_addr - SFR register address
# @return void
public method rightPanel_watch_sync_sfr {dec_addr} {
+
if {$validator_engaged} {
return
}
@@ -1947,12 +1965,12 @@ class RegWatches {
# @return Bool - result
public method rightPanel_watch_sync {addr} {
if {$validator_engaged} {return 1}
- if {!$gui_initialized} {CreateRegWatchesGUI}
+ if {!$regw_gui_initialized} {CreateRegWatchesGUI}
# Detect bit address
if {[string index $addr 0] == {.}} {
set bit_addr 1
- } {
+ } else {
set bit_addr 0
}
@@ -1961,6 +1979,7 @@ class RegWatches {
# Synchronize bits in the given register
if {!$validator_engaged && [string length $addr] == 2} {
+
set dec_addr [expr "0x$addr"]
if {$dec_addr >= 0x20 && $dec_addr <= 0x2F} {
@@ -1971,6 +1990,7 @@ class RegWatches {
if {[string length $hex_addr] == 1} {
set hex_addr "0$hex_addr"
}
+
rightPanel_watch_sync .$hex_addr
incr dec_addr
}
@@ -2014,11 +2034,11 @@ class RegWatches {
## Enable/Disable buttons on watches icon bar
# @return void
private method watch_disEna_buttons {} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
if {[$watch_text index end] == {2.0}} {
set state {disabled}
- } {
+ } else {
set state {normal}
}
@@ -2047,10 +2067,10 @@ class RegWatches {
## Enable/Disable menu items
# If address entry is not empty -> disable all
- set addr [subst "\$::RightPanel::watch_addr${obj_idx}"]
+ set addr [subst -nocommands "\$::RightPanel::watch_addr${obj_idx}"]
if {$addr != {}} {
set end [$watch_text index end]
- } {
+ } else {
set end {2.0}
}
# Empty list
@@ -2102,7 +2122,7 @@ class RegWatches {
## Create bindings for defined key shortcuts -- register watches
# @return void
public method rightPanel_watch_shortcuts_reevaluate {} {
- if {!$gui_initialized} {return}
+ if {!$regw_gui_initialized} {return}
foreach addr $watch_addrs {
watch_entry_shortcuts_reset watch_text.[lindex $watch_data($addr) 1]
}
@@ -2116,5 +2136,10 @@ class RegWatches {
}
}
-set ::RegWatches::menu_autoload [lindex $::CONFIG(REGWATCHES_CONFIG) 0]
-set ::RegWatches::sorting_order [lindex $::CONFIG(REGWATCHES_CONFIG) 1]
+set ::RegWatches::menu_autoload [lindex $::CONFIG(REGWATCHES_CONFIG) 0]
+set ::RegWatches::sorting_order [lindex $::CONFIG(REGWATCHES_CONFIG) 1]
+set ::RegWatches::menu_autoclear [lindex $::CONFIG(REGWATCHES_CONFIG) 2]
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/rightpanel/rightpanel.tcl b/lib/rightpanel/rightpanel.tcl
index 061f1f5..81bbb37 100755..100644
--- a/lib/rightpanel/rightpanel.tcl
+++ b/lib/rightpanel/rightpanel.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 _RIGHTPANEL_TCL ] } {
+set _RIGHTPANEL_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements Right Panel
@@ -42,8 +47,6 @@ class RightPanel {
inherit RegWatches InstructionDetails SubPrograms HwManager
## COMMON
- # Conter of instances
- common count 0
# Background color for selected rows -- light
common selection_color {#EEFFDD}
# Background color for selected rows -- dark
@@ -60,9 +63,9 @@ class RightPanel {
{button_cancel} "Add/Remove editor bookmark to/from current line"}
{separator}
{command {Previous} {} 0 "rightPanel_bm_up" {1uparrow}
- "Goto previous bookmark"}
+ "Go to previous bookmark"}
{command {Next} {} 0 "rightPanel_bm_up" {1downarrow}
- "Goto next bookmark"}
+ "Go to next bookmark"}
{separator}
{command {Remove all} {} 0 "editor_procedure {} clear_all_bookmarks {}"
{editdelete} "Remove all bookmarks from the editor"}
@@ -73,9 +76,9 @@ class RightPanel {
{button_cancel} "Add/Remove editor breakpoint to/from current line"}
{separator}
{command {Previous} {} 0 "rightPanel_bp_up" {1uparrow}
- "Goto previous breakpoint"}
+ "Go to previous breakpoint"}
{command {Next} {} 0 "rightPanel_bp_up" {1downarrow}
- "Goto next breakpoint"}
+ "Go to next breakpoint"}
{separator}
{command {Remove all} {} 0 "editor_procedure {} clear_all_breakpoints {}"
{editdelete} "Remove all breakpoints from the editor"}
@@ -95,8 +98,8 @@ class RightPanel {
private variable table_of_symbols ;# ID of tab "Table of symbols"
private variable obj_idx ;# Number of this object
- private variable bookmarks_menu ;# ID of popup menu for "Bookmarks"
- private variable breakpoints_menu ;# ID of popup menu for "Breakpoints"
+ private variable bookmarks_menu {} ;# ID of popup menu for "Bookmarks"
+ private variable breakpoints_menu {} ;# ID of popup menu for "Breakpoints"
private variable symbols_menu ;# ID of popup menu for "Symbol list"
private variable bm_pagesManager ;# ID of pages manager for tab "Bookmarks"
@@ -148,8 +151,6 @@ class RightPanel {
## Object constructor
constructor {} {
- incr count
- set obj_idx $count
}
## Object destructor
@@ -167,7 +168,7 @@ class RightPanel {
# @parm Widget ParentPane - parent paned window
# @parm String watches_file - definition file for register watches
# @return void
- public method Initialize_rightPanel {notebookframe ParentPane watches_file} {
+ public method initialize_rightPanel {notebookframe ParentPane watches_file} {
# Object variables
set parentPane $ParentPane ;# Parent container (some frame)
@@ -175,10 +176,7 @@ class RightPanel {
set notebook_frame $notebookframe
## Create NoteBook
- set notebook [NoteBook $notebook_frame.ntb_rightPanel \
- -side top -bg {#EEEEEE} \
- -arcradius 4 \
- ]
+ set notebook [ModernNoteBook $notebook_frame.ntb_rightPanel]
# Register notebook status bar tips
notebook_Sbar_set {rightpanel} [list \
@@ -200,57 +198,57 @@ class RightPanel {
if {!${::Editor::editor_to_use}} {
# Tab "Bookmarks"
- set bookmarks [$notebook insert end [mc "Bookmarks"] \
- -image ::ICONS::16::bookmark_toolbar \
- -raisecmd "$this rightPanel_set_active_page Bookmarks" \
- -helptext [mc "List of bookmarks in editor (Ctrl+6)"] \
+ set bookmarks [$notebook insert end {Bookmarks} \
+ -image ::ICONS::16::bookmark_toolbar \
+ -raisecmd [list $this rightPanel_set_active_page Bookmarks] \
+ -helptext [mc "List of bookmarks in editor (Ctrl+6)"] \
]
# Tab "Breakpoints"
- set breakpoints [$notebook insert end [mc "Breakpoints"] \
+ set breakpoints [$notebook insert end {Breakpoints} \
-image ::ICONS::16::flag \
- -raisecmd "$this rightPanel_set_active_page Breakpoints" \
+ -raisecmd [list $this rightPanel_set_active_page Breakpoints] \
-helptext [mc "List of breakpoints in editor (Ctrl+7)"] \
]
# Tab "Symbols"
- set table_of_symbols [$notebook insert end [mc "Symbols"] \
- -image ::ICONS::16::_blockdevice \
- -raisecmd "$this rightPanel_set_active_page Symbols" \
- -helptext [mc "Symbol List"] \
+ set table_of_symbols [$notebook insert end {Symbols} \
+ -image ::ICONS::16::_blockdevice \
+ -raisecmd [list $this rightPanel_set_active_page Symbols] \
+ -helptext [mc "Symbol List"] \
]
# Tab "Instruction"
- set instruction [$notebook insert end [mc "Instruction"] \
- -image ::ICONS::16::info \
- -raisecmd "$this rightPanel_set_active_page Instruction" \
- -helptext [mc "Instruction details (Ctrl+8)"] \
- -createcmd [list $this CreateInstructionDetailsGUI] \
+ set instruction [$notebook insert end {Instruction} \
+ -image ::ICONS::16::info \
+ -raisecmd [list $this rightPanel_set_active_page Instruction] \
+ -helptext [mc "Instruction details (Ctrl+8)"] \
+ -createcmd [list $this CreateInstructionDetailsGUI] \
]
}
# Tab "Watches"
- set watches [$notebook insert end [mc "Watches"] \
- -image ::ICONS::16::player_playlist \
- -raisecmd "$this rightPanel_set_active_page Watches" \
- -helptext [mc "Register watches (Ctrl+9)"] \
- -createcmd [list $this CreateRegWatchesGUI] \
+ set watches [$notebook insert end {Watches} \
+ -image ::ICONS::16::player_playlist \
+ -raisecmd [list $this rightPanel_set_active_page Watches] \
+ -helptext [mc "Register watches (Ctrl+9)"] \
+ -createcmd [list $this CreateRegWatchesGUI] \
]
# Tab "Subprograms"
- set subprograms [$notebook insert end [mc "Subprograms"] \
- -image ::ICONS::16::queue \
- -raisecmd "$this rightPanel_set_active_page Subprograms"\
- -helptext [mc "Active subprograms (Ctrl+0)"] \
- -createcmd [list $this CreateSubProgramsGUI] \
+ set subprograms [$notebook insert end {Subprograms} \
+ -image ::ICONS::16::queue \
+ -raisecmd [list $this rightPanel_set_active_page Subprograms] \
+ -helptext [mc "Active subprograms (Ctrl+0)"] \
+ -createcmd [list $this CreateSubProgramsGUI] \
]
# Tab "Hardware manager"
- set hwmanager [$notebook insert end [mc "Hardware"] \
- -image ::ICONS::16::kcmpci \
- -raisecmd "$this rightPanel_set_active_page Hardware" \
- -helptext [mc "Hardware manager"] \
- -createcmd [list $this CreateHwManagerGUI] \
+ set hwmanager [$notebook insert end {Hardware} \
+ -image ::ICONS::16::kcmpci \
+ -raisecmd [list $this rightPanel_set_active_page Hardware] \
+ -helptext [mc "Hardware manager"] \
+ -createcmd [list $this CreateHwManagerGUI] \
]
# Tab "Hide"
- $notebook insert end [mc "Hide"] \
- -image ::ICONS::16::2rightarrow \
- -raisecmd "$this right_panel_show_hide" \
+ $notebook insert end {Hide} \
+ -image ::ICONS::16::2rightarrow \
+ -raisecmd [list $this right_panel_show_hide] \
-helptext [mc "Hide the panel"]
# Prepare panel componenets but do not create GUI elements
@@ -262,7 +260,6 @@ class RightPanel {
PrepareInstructionDetails $instruction
}
-
## Create Button bar
# Button "Show"
set button_bar [frame $notebook_frame.button_bar]
@@ -347,15 +344,15 @@ class RightPanel {
if {!${::Editor::editor_to_use}} {
# Pack pages managers
- set bm_pagesManager [PagesManager $bookmarks.pgm_rightPanel_bm -background {#eeeeee}]
+ set bm_pagesManager [PagesManager $bookmarks.pgm_rightPanel_bm -background ${::COMMON_BG_COLOR}]
pack $bm_pagesManager -expand 1 -fill both
$bm_pagesManager compute_size
- set bp_pagesManager [PagesManager $breakpoints.pgm_rightPanel_pm -background {#eeeeee}]
+ set bp_pagesManager [PagesManager $breakpoints.pgm_rightPanel_pm -background ${::COMMON_BG_COLOR}]
pack $bp_pagesManager -expand 1 -fill both
$bp_pagesManager compute_size
- set sm_pagesManager [PagesManager $table_of_symbols.sm_pagesManager -background {#eeeeee}]
+ set sm_pagesManager [PagesManager $table_of_symbols.sm_pagesManager -background ${::COMMON_BG_COLOR}]
pack $sm_pagesManager -expand 1 -fill both
$sm_pagesManager compute_size
@@ -363,9 +360,9 @@ class RightPanel {
set bookmarks_menu $notebook_frame.menu_rightPanel_bookmarks
set breakpoints_menu $notebook_frame.menu_rightPanel_breakpoints
set symbols_menu $notebook_frame.menu_rightPanel_symbols
- menuFactory $BREAKPOINTMENU $breakpoints_menu 0 "$this " 0 {}
- menuFactory $BOOKMARKMENU $bookmarks_menu 0 "$this " 0 {}
- menuFactory $SYMBOLSKMENU $symbols_menu 0 "$this " 0 {}
+ menuFactory $BREAKPOINTMENU $breakpoints_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $BOOKMARKMENU $bookmarks_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $SYMBOLSKMENU $symbols_menu 0 "$this " 0 {} [namespace current]
}
@@ -379,7 +376,7 @@ class RightPanel {
if {$PanelVisible} {
# Show NoteBook
$parentPane paneconfigure $notebook_frame -minsize 295
- pack $notebook -expand 1 -fill both
+ pack [$notebook get_nb] -expand 1 -fill both -padx 5 -pady 5
$parentPane configure -sashwidth 2
if {[catch {
@@ -387,15 +384,15 @@ class RightPanel {
if {
${::Editor::editor_to_use} &&
([lsearch {Bookmarks Breakpoints Instruction Symbols} $active_page] != -1)
- } {
+ } then {
set active_page {Watches}
$notebook raise {Watches}
}
- }]} {
+ }]} then {
set active_page {Watches}
$notebook raise {Watches}
}
- } {
+ } else {
# Show button bar
$parentPane paneconfigure $notebook_frame -minsize 0
pack $button_bar -anchor nw
@@ -413,7 +410,7 @@ class RightPanel {
# @return void
public method rightPanel_scroll args {
# Local variables
- set what [lindex $args 0]
+ set what [lindex $args 0] ;# m == Bookmarks; p == Breakpoints; s == Symbols
set cmd [lindex $args 1] ;# Scroll command (moveto, scroll and such)
set frac [lindex $args 2] ;# Fraction where to move
set units [lindex $args 3] ;# Units (optonal)
@@ -436,7 +433,7 @@ class RightPanel {
if {$units == {}} {
$lnb yview $cmd $frac
$txt yview $cmd $frac
- } {
+ } else {
$lnb yview $cmd $frac $units
$txt yview $cmd $frac $units
}
@@ -470,7 +467,7 @@ class RightPanel {
if {[winfo ismapped $scrollbar]} {
pack forget $scrollbar
}
- } {
+ } else {
if {![winfo ismapped $scrollbar]} {
pack $scrollbar -side right -fill y -after $txt
}
@@ -490,11 +487,11 @@ class RightPanel {
public method rightPanel_refresh_font_settings {for_all} {
if {${::Editor::editor_to_use}} {return}
if {$for_all} {
- foreach widget $LIST_bookmarks_lineNumbers {
+ foreach widget $LIST_bookmarks_lineNumbers {
$widget configure -font ${Editor::defaultFont_bold}
}
- foreach widget $LIST_breakpoints_lineNumbers {
+ foreach widget $LIST_breakpoints_lineNumbers {
$widget configure -font ${Editor::defaultFont_bold}
}
@@ -527,7 +524,7 @@ class RightPanel {
}
incr i
}
- } {
+ } else {
$bookmarks_lineNumbers configure -font ${Editor::defaultFont_bold}
$bookmarks_text configure -font ${Editor::defaultFont_bold}
$breakpoints_lineNumbers configure -font ${Editor::defaultFont_bold}
@@ -574,7 +571,7 @@ class RightPanel {
# @return void
private method create_tags_in_symbol_list {} {
set tags_to_define [list tag_label tag_constant tag_normal tag_macro]
- foreach tag_def [concat ${::ASMsyntaxHighlight::hightlight_tags} ${::CsyntaxHighlight::hightlight_tags}] {
+ foreach tag_def [concat ${::ASMsyntaxHighlight::highlight_tags} ${::CsyntaxHighlight::highlight_tags}] {
if {[lsearch -ascii -exact $tags_to_define [lindex $tag_def 0]] == -1} {
continue
}
@@ -591,13 +588,13 @@ class RightPanel {
# Fonr slant
if {$tag_def_item(3) == 1} {
set tag_def_item(3) italic
- } {
+ } else {
set tag_def_item(3) roman
}
# Font weight
if {$tag_def_item(4) == 1} {
set tag_def_item(4) bold
- } {
+ } else {
set tag_def_item(4) normal
}
@@ -667,7 +664,7 @@ class RightPanel {
pack $bm_up_button -side left
DynamicHelp::add $bm_up_button -text [mc "Move to previous bookmark"]
setStatusTip -widget $bm_up_button \
- -text [mc "Goto to line of previous bookmark"]
+ -text [mc "Go to to line of previous bookmark"]
# Button "Down"
set bm_down_button [ttk::button $button_frame.but_rightPanel_bm_down \
-image ::ICONS::16::1downarrow \
@@ -678,7 +675,7 @@ class RightPanel {
pack $bm_down_button -side left
DynamicHelp::add $bm_down_button -text [mc "Move to the next bookmark"]
setStatusTip -widget $bm_down_button \
- -text [mc "Goto to line of next bookmark"]
+ -text [mc "Go to to line of next bookmark"]
# Separator
pack [ttk::separator $button_frame.but_rightPanel_bm_sep \
-orient vertical \
@@ -773,7 +770,7 @@ class RightPanel {
pack $bp_up_button -side left
DynamicHelp::add $bp_up_button -text [mc "Move to previous breakpoint"]
setStatusTip -widget $bp_up_button \
- -text [mc "Goto to line of previous breakpoint"]
+ -text [mc "Go to to line of previous breakpoint"]
# Button "Down"
set bp_down_button [ttk::button $button_frame.but_rightPanel_bp_down \
-image ::ICONS::16::1downarrow \
@@ -784,7 +781,7 @@ class RightPanel {
pack $bp_down_button -side left
DynamicHelp::add $bp_down_button -text [mc "Move to next breakpoint"]
setStatusTip -widget $bp_down_button \
- -text [mc "Goto to line of next breakpoint"]
+ -text [mc "Go to to line of next breakpoint"]
# Separator
pack [ttk::separator $button_frame.but_rightPanel_bp_sep \
-orient vertical \
@@ -1021,8 +1018,8 @@ class RightPanel {
if {[winfo exists $breakpoints_menu]} {destroy $breakpoints_menu}
if {[winfo exists $bookmarks_menu]} {destroy $bookmarks_menu}
- menuFactory $BREAKPOINTMENU $breakpoints_menu 0 "$this " 0 {}
- menuFactory $BOOKMARKMENU $bookmarks_menu 0 "$this " 0 {}
+ menuFactory $BREAKPOINTMENU $breakpoints_menu 0 "$this " 0 {} [namespace current]
+ menuFactory $BOOKMARKMENU $bookmarks_menu 0 "$this " 0 {} [namespace current]
}
## Invoke bookmarks popup menu
@@ -1208,7 +1205,7 @@ class RightPanel {
# Change current line in the editor
set block_select 1
$this editor_procedure {} goto $lineNum
- update idle
+ update idletasks
set block_select 0
return 1
@@ -1236,8 +1233,32 @@ class RightPanel {
return $lineNum
}
+ ## If the given line contain symbol declaration then select it in the list
+ # This function should be called after change on the line in the editor
+ # @parm Int lineNum - line number
+ # @return Bool - result
+ public method rightPanel_sm_select {lineNum} {
+ if {!$enabled || $block_select} {return}
+ if {![info exists sm_text]} {return}
+
+ # Unset selection in the list
+ $sm_text tag remove curLine 1.0 end
+
+ # Check for bookmark presence
+ set idx0 [lsearch -ascii -exact [$sm_lineNumbers get 1.0 end] $lineNum]
+ if {$idx0 == -1} {return 0}
+
+ # Select the line
+ incr idx0
+ set idx1 $idx0
+ incr idx1
+ $sm_text tag add curLine $idx0.0 $idx1.0
+ $sm_text see $idx0.0
+ return 1
+ }
+
## If the given line contain bookmark then select it in the list
- # This function should be called after change line in the editor
+ # This function should be called after change on the line in the editor
# @parm Int lineNum - line number
# @return Bool - result
public method rightPanel_bm_select {lineNum} {
@@ -1259,7 +1280,7 @@ class RightPanel {
}
## If the given line contain bookmark then select it in the list
- # This function should be called after change line in the editor
+ # This function should be called after change on the line in the editor
# @parm Int lineNum - line number
# @return Bool - result
public method rightPanel_bp_select {lineNum} {
@@ -1267,7 +1288,7 @@ class RightPanel {
if {![info exists breakpoints_text]} {return}
# Check for bookmark presence
- set idx0 [lsearch [$breakpoints_lineNumbers get 1.0 end] $lineNum]
+ set idx0 [lsearch -ascii -exact [$breakpoints_lineNumbers get 1.0 end] $lineNum]
if {$idx0 == -1} {return 0}
# Select the line
@@ -1316,7 +1337,7 @@ class RightPanel {
if {$idx == {end}} {
set row [$target_widget index end]
set row [expr {int($row) - 2}]
- } {
+ } else {
set row [expr {int($idx)}]
}
# Iterate over source text tags and add them to target widget
@@ -1363,7 +1384,7 @@ class RightPanel {
if {$idx == -1} {
set idx {end}
- } {
+ } else {
append idx {.0}
}
@@ -1439,7 +1460,7 @@ class RightPanel {
if {$idx == -1} {
set idx {end}
- } {
+ } else {
append idx {.0}
}
@@ -1690,7 +1711,7 @@ class RightPanel {
if {$start_idx == {}} {
if {[lindex $lineNumbers end] != $end_line} {
return
- } {
+ } else {
set start_idx 1.0
}
}
@@ -1764,7 +1785,7 @@ class RightPanel {
if {$start_idx == {}} {
if {[lindex $lineNumbers end] != $end_line} {
return
- } {
+ } else {
set start_idx 1.0
}
}
@@ -1842,7 +1863,7 @@ class RightPanel {
return 1
# Not empty string
- } {
+ } else {
$clr_b configure -state normal
}
@@ -1850,15 +1871,16 @@ class RightPanel {
set content [string toupper $content]
set e [expr {int([$sm_text index insert])}]
for {set i 1} {$i < $e} {incr i} {
- if {![string first $content [string toupper [$sm_text get $i.0 [list $i.0 lineend]]]]} {
+ if {![string first $content [string toupper [$sm_text get $i.2 [list $i.0 lineend]]]]} {
$widget configure -style StringFound.TEntry
$sm_text tag remove curLine 1.0 end
- $sm_text tag add curLine [list $i.0 linestart] [list $i.0+1l linestart]
+ $sm_text tag add curLine $i.0 [list $i.0+1l linestart]
+ $sm_text see $i.0
set block_select 1
- $this editor_procedure {} goto $i
- update idle
+ $this editor_procedure {} goto [$sm_lineNumbers get $i.0 [list $i.0 lineend]]
+ update idletasks
set block_select 0
set search_val_in_progress 0
return 1
@@ -1880,7 +1902,15 @@ class RightPanel {
# 3 - Macro
# @parm Bool add__remove - 1 == Add; 0 == Remove
# @return void
- public method rightPanel_adjust_symbol_list {lineNum symbol_name symbol_type add__remove} {
+ public method rightPanel_adjust_symbol_list {lineNum symbol_name symbol_type add__remove {editor_object {}}} {
+ if {[$this is_splitted] && $editor_object != {}} {
+ set idx [lsearch -ascii -exact [$this cget -editors] $editor_object]
+
+ if {$idx != $current_editor_idx} {
+ rightPanel_switch_editor_vars $idx
+ }
+ }
+
$sm_lineNumbers configure -state normal
$sm_text configure -state normal
@@ -1900,47 +1930,59 @@ class RightPanel {
if {$idx == -1} {
set idx [$sm_text index {end-1l}]
- } {
+ } else {
append idx {.0}
}
- $sm_lineNumbers insert $idx "$lineNum\n"
- $sm_text insert $idx "$symbol_name\n"
-
switch -- $symbol_type {
0 { ;# Label
set tag {tag_label}
+ set icon {symbol1}
}
1 { ;# Constant
set tag {tag_constant}
+ set icon {symbol3}
}
2 { ;# C variable
set tag {tag_normal}
+ set icon {symbol4}
}
3 { ;# Macro
set tag {tag_macro}
+ set icon {symbol2}
}
7 { ;# C function
set tag {tag_c_func}
+ set icon {symbol0}
}
default {
set tag {}
+ set icon {symbol5}
}
}
+ $sm_lineNumbers insert $idx "$lineNum\n"
+
+ if {${::Editor::defaultCharHeight} < 16} {
+ $sm_text insert ${idx} { }
+ } else {
+ $sm_text image create $idx -image ::ICONS::16::$icon
+ }
+ $sm_text insert ${idx}+1c " $symbol_name\n"
+
if {$tag != {}} {
$sm_text tag add $tag $idx [list $idx lineend]
}
# Remove symbol
- } {
+ } else {
if {$lineNum == {all}} {
set idx [list]
set e [expr {int([$sm_lineNumbers index end]) - 1}]
for {set i 0} {$i < $e} {incr i} {
lappend idx $i
}
- } {
+ } else {
set idx [lsearch -all [$sm_lineNumbers get 1.0 end] $lineNum]
}
@@ -1949,7 +1991,7 @@ class RightPanel {
}
foreach i $idx {
incr i
- if {[string equal [$sm_text get $i.0 [list $i.0 lineend]] $symbol_name]} {
+ if {[string equal [$sm_text get $i.2 [list $i.0 lineend]] $symbol_name]} {
$sm_text delete $i.0 $i.0+1l
$sm_lineNumbers delete $i.0 $i.0+1l
break
@@ -2080,7 +2122,7 @@ class RightPanel {
# This function takes any list of arguments
# @return void
public method rightPanel_configure args {
- ::configDialogs::rightPanel::mkDialog $args
+ ::configDialogues::rightPanel::mkDialog $args
}
## Return true if this panel is in visible state
@@ -2092,7 +2134,7 @@ class RightPanel {
public method getRightPanelSize {} {
if {$PanelVisible} {
return $PanelSize
- } {
+ } else {
return $last_PanelSize
}
}
@@ -2108,7 +2150,7 @@ class RightPanel {
if {$PanelVisible} {
$parentPane paneconfigure $notebook_frame -minsize 0
- pack forget $notebook ;# Hide notebook
+ pack forget [$notebook get_nb] ;# Hide notebook
set last_PanelSize $PanelSize ;# Save current panel width
set PanelSize 60 ;# Change panel width
right_panel_redraw_pane ;# Redraw panel
@@ -2122,7 +2164,7 @@ class RightPanel {
set PanelVisible 0
# Show the panel
- } {
+ } else {
$parentPane paneconfigure $notebook_frame -minsize 295
# Hide button bar
@@ -2131,7 +2173,7 @@ class RightPanel {
set PanelSize $last_PanelSize
right_panel_redraw_pane
$notebook raise $active_page
- pack $notebook -expand 1 -fill both
+ pack [$notebook get_nb] -expand 1 -fill both
# Show pane sash
$parentPane configure -sashwidth 2
bind $parentPane <Button> {}
@@ -2180,7 +2222,7 @@ class RightPanel {
}
}
- ## Set panel width acording to current sash position
+ ## Set panel width according to current sash position
# @return void
public method right_panel_set_size {} {
set PanelSize [lindex [$parentPane sash coord 0] 0]
@@ -2214,10 +2256,10 @@ class RightPanel {
set size $fontSize
} elseif {$use_editor_font == -1} {
set font $::DEFAULT_FIXED_FONT
- set size -14
- } {
+ set size [expr {int(-14 * $::font_size_factor)}]
+ } else {
set font $::DEFAULT_FIXED_FONT
- set size -12
+ set size [expr {int(-12 * $::font_size_factor)}]
}
# Iterate over tags definition
@@ -2234,7 +2276,7 @@ class RightPanel {
-weight {bold} \
-slant {roman}]
# Italic font
- } {
+ } else {
$widget tag configure [lindex $tag 0] \
-foreground [lindex $tag 1] \
-font [font create -size $size \
@@ -2244,7 +2286,7 @@ class RightPanel {
}
# No bold, no italic
- } {
+ } else {
$widget tag configure [lindex $tag 0] \
-foreground [lindex $tag 1] \
-font [font create -size $size \
@@ -2271,3 +2313,7 @@ class RightPanel {
$this right_panel_instruction_details_set_enabled $enabled
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/rightpanel/subprograms.tcl b/lib/rightpanel/subprograms.tcl
index 6385266..c8380cb 100755..100644
--- a/lib/rightpanel/subprograms.tcl
+++ b/lib/rightpanel/subprograms.tcl
@@ -2,7 +2,7 @@
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2007-2009 by Martin Ošmera #
+# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
# This program is free software; you can redistribute it and#or modify #
@@ -21,6 +21,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _SUBPROGRAMS_TCL ] } {
+set _SUBPROGRAMS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides panel for watching subprogram calls
@@ -30,29 +35,31 @@ class SubPrograms {
## COMMON
common fsd_filename {} ;# Filename choosen by FSD
# Main font for the text widget
- common main_font [font create \
- -family {helvetica} \
- -size -14 \
+ common main_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
]
# Bold font for the text widget
- common bold_font [font create \
- -family {helvetica} \
- -size -14 -weight {bold} \
+ common bold_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight {bold} \
]
# Font for status bar below the text box
- common large_font [font create \
- -family {helvetica} \
- -size -14 \
+ common large_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
]
# Bold font for status bar below the text box
- common large_bold_font [font create \
- -family {helvetica} \
- -size -14 -weight {bold} \
+ common large_bold_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight {bold} \
]
## PRIVATE
private variable parent ;# Widget: parent widget
- private variable gui_initialized 0 ;# Bool: GUI initialized
+ private variable subp_gui_initialized 0 ;# Bool: GUI initialized
private variable text_widget ;# Widget: Text widget containg almost all the information
private variable scrollbar ;# Widget: Scrollbar for the text widget
@@ -73,7 +80,7 @@ class SubPrograms {
}
destructor {
- if {$gui_initialized} {
+ if {$subp_gui_initialized} {
menu_Sbar_remove $menu
}
}
@@ -84,7 +91,7 @@ class SubPrograms {
# @return void
public method PrepareSubPrograms {_parent} {
set parent $_parent
- set gui_initialized 0
+ set subp_gui_initialized 0
load_config $::CONFIG(SUBP_MON_CONFIG)
}
@@ -117,8 +124,8 @@ class SubPrograms {
## Create all widgets which this panel consist of
# @return void
private method create_gui {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$subp_gui_initialized} {return}
+ set subp_gui_initialized 1
# Create top frame (checkbuttons)
set top_frame [frame $parent.top]
@@ -136,12 +143,12 @@ class SubPrograms {
# Adjust check buttons
if {$enabled} {
$enable_chbut select
- } {
+ } else {
$enable_chbut deselect
}
if {$ena_intr} {
$intr_chbut select
- } {
+ } else {
$intr_chbut deselect
}
@@ -153,7 +160,7 @@ class SubPrograms {
-image ::ICONS::16::button_cancel \
-command "$this subprograms_force_return" \
-state disabled \
- -width 6 \
+ -width 7 \
]
set clear_but [ttk::button $button_frame.clear_but \
-text [mc "Clear"] \
@@ -244,7 +251,7 @@ class SubPrograms {
{separator}
{command {Remove this} {} 0 "subprograms_menu_action 4"
{editdelete} "Remove this entry"}
- } $menu 0 "$this " 0 {}
+ } $menu 0 "$this " 0 {} [namespace current]
}
## Create highlighting tags for the text widget
@@ -365,7 +372,7 @@ class SubPrograms {
$this Simulator_sync_PC_etc
$this move_simulator_line $line
# Simulator is not running
- } {
+ } else {
set filename [$this simulator_get_filename [lindex $line 1]]
set filename [file tail $filename]
if {[$this fucus_specific_editor $filename 0]} {
@@ -373,7 +380,7 @@ class SubPrograms {
}
}
# Line unresolved
- } {
+ } else {
tk_messageBox \
-parent . \
-title [mc "Line not found"] \
@@ -397,10 +404,10 @@ class SubPrograms {
set line [expr {$line / 3}]
if {$line >= $count} {
set state {disabled}
- } {
+ } else {
set state {normal}
}
- } {
+ } else {
set state {disabled}
}
@@ -426,7 +433,7 @@ class SubPrograms {
# @return void
public method subprograms_call {type from to} {
if {!$enabled} {return}
- if {!$gui_initialized} CreateSubProgramsGUI
+ if {!$subp_gui_initialized} CreateSubProgramsGUI
# Determinate string to print as an instruction
switch -- $type {
@@ -444,7 +451,7 @@ class SubPrograms {
# Convert value of source address to hexadecimal representation
if {$from < 0} {
set from {-----}
- } {
+ } else {
set from [format %X $from]
set len [string length $from]
if {$len < 4} {
@@ -456,7 +463,7 @@ class SubPrograms {
# Convert value of target address to hexadecimal representation
if {$to < 0} {
set to {-----}
- } {
+ } else {
set to [format %X $to]
set len [string length $to]
if {$len < 4} {
@@ -504,7 +511,7 @@ class SubPrograms {
private method disena_buttonbar {bool} {
if {$bool} {
set state {normal}
- } {
+ } else {
set state {disabled}
}
$return_but configure -state $state
@@ -519,7 +526,7 @@ class SubPrograms {
if {!$enabled} {return}
if {!$count} {return}
if {$intr__sub && !$ena_intr} {return}
- if {!$gui_initialized} CreateSubProgramsGUI
+ if {!$subp_gui_initialized} CreateSubProgramsGUI
$text_widget configure -state normal
$text_widget delete 1.0 4.0
@@ -536,7 +543,7 @@ class SubPrograms {
## Clear the text widget
# @return void
public method subprograms_clear {} {
- if {!$gui_initialized} {return}
+ if {!$subp_gui_initialized} {return}
set count 0
$total_val_lbl configure -text 0
$text_widget configure -state normal
@@ -549,7 +556,7 @@ class SubPrograms {
# @parm Bool bool - 1 == Enable; 0 == Disbale
# @return void
public method subprograms_setEnabled {bool} {
- if {!$gui_initialized} {return}
+ if {!$subp_gui_initialized} {return}
if {!$bool} {
$return_but configure -state disabled
}
@@ -565,7 +572,7 @@ class SubPrograms {
set word [string trim $word]
if {$word == {Interrupt}} {
set word 1
- } {
+ } else {
set word 0
}
$this simulator_return_from_SP $word
@@ -581,10 +588,10 @@ class SubPrograms {
KIFSD::FSD fsd \
-title [mc "Save file - MCU 8051 IDE"] \
-directory [$this cget -projectPath] \
- -defaultmask 0 -multiple 0 -filetypes {
- {{Plain text} {*.txt} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Plain text"] {*.txt} ] \
+ [list [mc "All files"] {*} ] \
+ ]
# Ok button
fsd setokcmd {
@@ -593,12 +600,12 @@ class SubPrograms {
if {![regexp "^(~|/)" $fsd_filename]} {
set filename "[${::X::actualProject} cget -ProjectDir]/$fsd_filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $fsd_filename]} {
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $fsd_filename]} {
set filename [file join [${::X::actualProject} cget -ProjectDir] $fsd_filename]
}
}
-
+
set ::SubPrograms::fsd_filename [file normalize $fsd_filename]
}
@@ -627,7 +634,7 @@ class SubPrograms {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $filename]]
] != {yes}
- } {
+ } then {
return
}
# Create a backup file
@@ -637,8 +644,8 @@ class SubPrograms {
}
# Try to open the file
if {[catch {
- set file [open $filename w 420]
- }]} {
+ set file [open $filename w 0640]
+ }]} then {
tk_messageBox \
-parent . \
-icon warning \
@@ -655,14 +662,14 @@ class SubPrograms {
## Get number of recorder active subprograms
# @return Int - Count
public method subprograms_get_count {} {
- if {!$gui_initialized} {return 0}
+ if {!$subp_gui_initialized} {return 0}
return $count
}
## Get content for purpose of program hibernation
# @return String - Text
- public method subprograms_get_formated_content {} {
- if {!$gui_initialized} {return {}}
+ public method subprograms_get_formatted_content {} {
+ if {!$subp_gui_initialized} {return {}}
set result {}
set source {}
set target {}
@@ -684,7 +691,7 @@ class SubPrograms {
regexp {\w+\s*$} $line source
set source [string range $source 0 3]
set source [expr "0x$source"]
- } {
+ } else {
regexp {\w+\s*$} $line target
set target [string range $target 0 3]
set target [expr "0x$target"]
@@ -702,3 +709,7 @@ class SubPrograms {
return $result
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/bitmap.tcl b/lib/simulator/bitmap.tcl
index 6ed43e0..c2b4623 100755..100644
--- a/lib/simulator/bitmap.tcl
+++ b/lib/simulator/bitmap.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,14 +21,19 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _BITMAP_TCL ] } {
+set _BITMAP_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# Provides graphical view on bit addressable area in simulated MCU
+# Provides graphical view on bit addressable area in simulated MCU.
# --------------------------------------------------------------------------
class BitMap {
## COMMON
- common count 0 ;# Int: Counter of object instances
+ common btmap_count 0 ;# Int: Counter of object instances
# Last window geometry
common win_geometry [lindex $::CONFIG(BITMAP_CONFIG) 0]
@@ -52,15 +57,15 @@ class BitMap {
common one_a_outline #DDFFDD ;# Color: Bit outline color for log. 1 (Selected bit)
# Font: Normal font for canvas widget
- common bitmap_n_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
+ common bitmap_n_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
]
# Font: Bold font for canvas widget
- common bitmap_b_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ common bitmap_b_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
@@ -117,8 +122,8 @@ class BitMap {
}
# Create dialog window
- set win [toplevel .bitmap_$count -class {Bitmap} -bg {#EEEEEE}]
- incr count
+ set win [toplevel .bitmap_${btmap_count} -class {Bitmap} -bg ${::COMMON_BG_COLOR}]
+ incr btmap_count
# ----------------------------------------------------------------
# Create main frame and canvas widget
@@ -340,7 +345,7 @@ class BitMap {
# Set window parameters
wm protocol $win WM_DELETE_WINDOW "$this bitmap_close_dialog"
wm resizable $win 0 0
- wm title $win [mc "Bit addressable area - %s - %s" [string trim $this {:}] "MCU 8051 IDE"]
+ wm title $win [mc "Bit addressable area - %s - %s - %s" [$this cget -P_option_mcu_type] [$this cget -projectName] "MCU 8051 IDE"]
wm iconphoto $win ::ICONS::16::kcmmemory_BA
catch {
wm geometry $win $win_geometry
@@ -365,14 +370,14 @@ class BitMap {
if {$bits_states($addr)} {
set outline $one_a_outline
set fill $one_a_fill
- } {
+ } else {
set outline $zero_a_outline
set fill $zero_a_fill
}
# Set new rectangle colors and changle cursor
if {$enabled} {
$bitmap_canvas itemconfigure $bits($addr) -outline $outline -fill $fill
- $bitmap_canvas configure -cursor hand1
+ $bitmap_canvas configure -cursor hand2
}
## Adjust address meters
@@ -400,7 +405,7 @@ class BitMap {
if {$bits_states($addr)} {
set outline $one_outline
set fill $one_fill
- } {
+ } else {
set outline $zero_outline
set fill $zero_fill
}
@@ -479,7 +484,7 @@ class BitMap {
if {$original_val != $bits_states($bit_addr)} {
if {$bits_states($bit_addr)} {
set fill $one_fill
- } {
+ } else {
set fill $zero_fill
}
@@ -500,7 +505,7 @@ class BitMap {
for {set i 0} {$i < 128} {incr i} {
if {$bits_states($i)} {
set outline $one_outline
- } {
+ } else {
set outline $zero_outline
}
$bitmap_canvas itemconfigure $bits($i) -outline $outline
@@ -508,3 +513,7 @@ class BitMap {
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_auxiliary_alo_functions.tcl b/lib/simulator/engine/engine_auxiliary_alo_functions.tcl
index d73b57e..8929268 100755..100644
--- a/lib/simulator/engine/engine_auxiliary_alo_functions.tcl
+++ b/lib/simulator/engine/engine_auxiliary_alo_functions.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 _ENGINE_AUXILIARY_ALO_FUNCTIONS_TCL ] } {
+set _ENGINE_AUXILIARY_ALO_FUNCTIONS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -71,7 +76,7 @@ private method alo_add {val} {
incr val_h
incr result -16
setBit $symbol(AC) 1
- } {
+ } else {
setBit $symbol(AC) 0
}
@@ -82,7 +87,7 @@ private method alo_add {val} {
if {$result > 255} {
incr result -256
setBit $symbol(C) 1
- } {
+ } else {
setBit $symbol(C) 0
}
@@ -91,7 +96,7 @@ private method alo_add {val} {
setBit $symbol(OV) 1
} elseif {($val > 127) && ($sfr(224) > 127) && ($result < 128)} {
setBit $symbol(OV) 1
- } {
+ } else {
setBit $symbol(OV) 0
}
@@ -139,7 +144,7 @@ private method alo_subb {val} {
incr result_l 16
incr val_h
setBit $symbol(AC) 1
- } {
+ } else {
setBit $symbol(AC) 0
}
@@ -150,7 +155,7 @@ private method alo_subb {val} {
if {$result_h < 0} {
incr result_h 16
setBit $symbol(C) 1
- } {
+ } else {
setBit $symbol(C) 0
}
@@ -162,10 +167,14 @@ private method alo_subb {val} {
setBit $symbol(OV) 1
} elseif {($val < 128) && ($sfr(224) > 127) && ($result < 128)} {
setBit $symbol(OV) 1
- } {
+ } else {
setBit $symbol(OV) 0
}
# Set Acc
set sfr(224) $result
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_backward_stepping.tcl b/lib/simulator/engine/engine_backward_stepping.tcl
index f7e1b66..7914c9b 100755..100644
--- a/lib/simulator/engine/engine_backward_stepping.tcl
+++ b/lib/simulator/engine/engine_backward_stepping.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 _ENGINE_BACKWARD_STEPPING_TCL ] } {
+set _ENGINE_BACKWARD_STEPPING_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -113,7 +118,7 @@ public method stepback_discard_stack {} {
public method simulator_get_SBS_len {} {
if {${::Simulator::reverse_run_steps}} {
return $stepback_length
- } {
+ } else {
return 0
}
}
@@ -124,3 +129,7 @@ public method simulator_get_SBS_len {} {
public method simulator_set_SBS_len {value} {
set stepback_length $value
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_control.tcl b/lib/simulator/engine/engine_control.tcl
index efa00c9..6b76b5a 100755..100644
--- a/lib/simulator/engine/engine_control.tcl
+++ b/lib/simulator/engine/engine_control.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 _ENGINE_CONTROL_TCL ] } {
+set _ENGINE_CONTROL_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -36,7 +41,7 @@
public method simulator_return_from_SP {intr__sub} {
if {$intr__sub} {
simulator_cancel_interrupt [lindex $inter_in_p_flags end]
- } {
+ } else {
ins_ret
$this move_simulator_line $Line($pc)
}
@@ -88,17 +93,17 @@ public method simulator_resize_code_memory {new_size} {
## Get list of decimal address of implemented SFR
# @return List - Implemented special function registers
-public method simulator_get_avaliable_sfr {} {
- return $avaliable_sfr
+public method simulator_get_available_sfr {} {
+ return $available_sfr
}
-## Determinate whether the specified SFR is avaliable on the target MCU or not
+## Determinate whether the specified SFR is available on the target MCU or not
# @parm Int sfr_addr - Address of SFR register
- # @return Bool - 1 == Avaliable; 0 == Not avaliable
-public method simulator_is_sfr_avaliable {sfr_addr} {
- if {[lsearch -ascii -exact $avaliable_sfr $sfr_addr] == -1} {
+ # @return Bool - 1 == available; 0 == Not available
+public method simulator_is_sfr_available {sfr_addr} {
+ if {[lsearch -ascii -exact $available_sfr $sfr_addr] == -1} {
return 0
- } {
+ } else {
return 1
}
}
@@ -146,8 +151,9 @@ public method master_reset {mode} {
set wdt_prescaler_val 0 ;# Int: Value of Watchdog prescaler
set watchdog_value 0 ;# Int: Value of watchdog timer
set eeprom_WR 0 ;# Bool: Data EEPROM write cycle in progress
-
- simulator_Sbar {} 0 $this ;# Clear simulator status bar
+ if {$::GUI_AVAILABLE} {
+ simulator_Sbar {} 0 $this ;# Clear simulator status bar
+ }
set interrupt_on_next 0 ;# Bool: Engage interrupt routine on the next instruction cycle
set interrupts_in_progress {} ;# Priority flags of interrupts which are in progress
set inter_in_p_flags {} ;# Interrupt flags of interrupts which are in progress
@@ -208,44 +214,44 @@ public method master_reset {mode} {
foreach item $reset_reg_values_1 {
set reg [lindex $item 0]
switch -- $reg {
- {T2CON} {if {!$feature_avaliable(t2)} {continue}}
- {RCAP2L} {if {!$feature_avaliable(t2)} {continue}}
- {RCAP2H} {if {!$feature_avaliable(t2)} {continue}}
- {TL2} {if {!$feature_avaliable(t2)} {continue}}
- {TH2} {if {!$feature_avaliable(t2)} {continue}}
- {T2MOD} {if {!$feature_avaliable(t2mod)} {continue}}
- {AUXR} {if {!$feature_avaliable(auxr)} {continue}}
- {SCON} {if {!$feature_avaliable(uart)} {continue}}
- {P0} {if {!$feature_avaliable(p0)} {continue}}
- {P1} {if {!$feature_avaliable(p1)} {continue}}
- {P2} {if {!$feature_avaliable(p2)} {continue}}
- {P3} {if {!$feature_avaliable(p3)} {continue}}
- {P4} {if {!$feature_avaliable(p4)} {continue}}
- {ACSR} {if {!$feature_avaliable(acomparator)} {continue}}
- {SADEN} {if {!$feature_avaliable(euart)} {continue}}
- {SADDR} {if {!$feature_avaliable(euart)} {continue}}
- {IPH} {if {!$feature_avaliable(iph)} {continue}}
- {WDTCON} {if {!$feature_avaliable(wdtcon)} {continue}}
+ {T2CON} {if {!$feature_available(t2)} {continue}}
+ {RCAP2L} {if {!$feature_available(t2)} {continue}}
+ {RCAP2H} {if {!$feature_available(t2)} {continue}}
+ {TL2} {if {!$feature_available(t2)} {continue}}
+ {TH2} {if {!$feature_available(t2)} {continue}}
+ {T2MOD} {if {!$feature_available(t2mod)} {continue}}
+ {AUXR} {if {!$feature_available(auxr)} {continue}}
+ {SCON} {if {!$feature_available(uart)} {continue}}
+ {P0} {if {!$feature_available(p0)} {continue}}
+ {P1} {if {!$feature_available(p1)} {continue}}
+ {P2} {if {!$feature_available(p2)} {continue}}
+ {P3} {if {!$feature_available(p3)} {continue}}
+ {P4} {if {!$feature_available(p4)} {continue}}
+ {ACSR} {if {!$feature_available(acomparator)} {continue}}
+ {SADEN} {if {!$feature_available(euart)} {continue}}
+ {SADDR} {if {!$feature_available(euart)} {continue}}
+ {IPH} {if {!$feature_available(iph)} {continue}}
+ {WDTCON} {if {!$feature_available(wdtcon)} {continue}}
{EECON} {if {!$eeprom_size} {continue}}
- {SPCR} {if {!$feature_avaliable(spi)} {continue}}
- {SPSR} {if {!$feature_avaliable(spi)} {continue}}
+ {SPCR} {if {!$feature_available(spi)} {continue}}
+ {SPSR} {if {!$feature_available(spi)} {continue}}
{DP1H} {
- if {!$feature_avaliable(ddp) || $feature_avaliable(hddptr)} {
+ if {!$feature_available(ddp) || $feature_available(hddptr)} {
continue
}
}
{DP1L} {
- if {!$feature_avaliable(ddp) || $feature_avaliable(hddptr)} {
+ if {!$feature_available(ddp) || $feature_available(hddptr)} {
continue
}
}
{CLKREG} {
- if {!$feature_avaliable(clkreg) && !$feature_avaliable(ckcon)} {
+ if {!$feature_available(clkreg) && !$feature_available(ckcon)} {
continue
}
}
{AUXR1} {
- if {!$feature_avaliable(ddp) || $feature_avaliable(wdtcon)} {
+ if {!$feature_available(ddp) || $feature_available(wdtcon)} {
continue
}
}
@@ -256,10 +262,10 @@ public method master_reset {mode} {
}
# Restore bits which are not affected by reset
- if {$feature_avaliable(pof) && $controllers_conf(POF)} {
+ if {$feature_available(pof) && $controllers_conf(POF)} {
set sfr($symbol(PCON)) [expr {$sfr($symbol(PCON)) | 16}]
}
- if {$feature_avaliable(x2reset) && $controllers_conf(X2)} {
+ if {$feature_available(x2reset) && $controllers_conf(X2)} {
set sfr($symbol(CLKREG)) [expr {$sfr($symbol(CLKREG)) | 1}]
}
@@ -275,17 +281,19 @@ public method master_reset {mode} {
}
# Synchronize with special GUI controls
- $this simulator_GUI_cancel_write_to_eeprom ;# Abort data EEPROM write cycle
- $this interrupt_monitor_reset ;# Reset interrupt monitor
- $this subprograms_clear ;# Clear list subprograms
- $this stopwatch_refresh ;# Stopwatch
- $this stack_monitor_reset ;# clear stack monitor
+ if {$::GUI_AVAILABLE} {
+ $this simulator_GUI_cancel_write_to_eeprom ;# Abort data EEPROM write cycle
+ $this interrupt_monitor_reset ;# Reset interrupt monitor
+ $this subprograms_clear ;# Clear list subprograms
+ $this stopwatch_refresh ;# Stopwatch
+ $this stack_monitor_reset ;# clear stack monitor
+ }
# Reset PALE (Peripheral Astraction Layer Engine)
$this pale_reset
for {set i 0} {$i < 5} {incr i} {
set j 0
- foreach bit [split $feature_avaliable(port$i) {}] {
+ foreach bit [split $feature_available(port$i) {}] {
if {$bit == 0} {
$this pale_SLSF [list $i $j] 6
}
@@ -344,10 +352,10 @@ public method stepback {} {
simulator_set_special [lindex $stepback_spec $stepback_length]
set opcode [getCode $pc]
- if {[lsearch ${CompilerConsts::defined_OPCODE} $opcode] == -1} {
+ if {[lsearch ${::CompilerConsts::defined_OPCODE} $opcode] == -1} {
incr run_statistics(4) -1
- } {
- incr run_statistics(4) -[lindex $CompilerConsts::Opcode($opcode) 2]
+ } else {
+ incr run_statistics(4) -[lindex $::CompilerConsts::Opcode($opcode) 2]
}
incr run_statistics(0) [expr {int(($overall_time - $overall_time_org) * (12000000.0 / $clock_kHz))}]
@@ -394,14 +402,17 @@ public method stepback {} {
$this stack_monitor_pop
}
}
- if {[llength $interrupts_in_progress]} {
- simulator_Sbar [mc "Interrupt at vector 0x%s " [format %X [intr2vector [lindex $interrupts_in_progress end]]]] 1 $this
- } {
- simulator_Sbar {} 0 $this
+ if {$::GUI_AVAILABLE} {
+ if {[llength $interrupts_in_progress]} {
+ simulator_Sbar [mc "Interrupt at vector 0x%s " [format %X [intr2vector [lindex $interrupts_in_progress end]]]] 1 $this
+ } else {
+ simulator_Sbar {} 0 $this
+ }
+
+ $this graph_stepback [expr {int(($overall_time_org - $overall_time) * 2)}]
+ $this interrupt_monitor_reevaluate
+ $this stopwatch_refresh
}
- $this graph_stepback [expr {int(($overall_time_org - $overall_time) * 2)}]
- $this interrupt_monitor_reevaluate
- $this stopwatch_refresh
if {$eeprom_size} {
for {set i 0} {$i < 32} {incr i} {
::X::sync_eeprom_write_buffer $i $this
@@ -411,11 +422,13 @@ public method stepback {} {
if {$eeprom_WR} {
eeprom_controller [expr {int(($overall_time_org - $overall_time) * (-2))}]
- } {
- foreach reg $eeprom_prev {
- ::X::sync_eeprom_clear_bg_hg [lindex $reg 0] $this
+ } else {
+ if {$::GUI_AVAILABLE} {
+ foreach reg $eeprom_prev {
+ ::X::sync_eeprom_clear_bg_hg [lindex $reg 0] $this
+ }
+ $this simulator_GUI_cancel_write_to_eeprom
}
- $this simulator_GUI_cancel_write_to_eeprom
}
$this Simulator_sync_PC_etc
@@ -426,7 +439,7 @@ public method stepback {} {
$this Simulator_GUI_sync S 224
if {!$stepback_length} {
return 0
- } {
+ } else {
return 1
}
}
@@ -449,7 +462,7 @@ public method step {} {
return $Line($pc)
# Invalid OP code
- } {
+ } else {
bell
$this sim_txt_output [mc "No instruction found at 0x%s" [NumSystem::dec2hex $pc]]
incr_pc 1
@@ -469,7 +482,7 @@ public method sim_stepover {} {
set stepover_in_progress 0
# Engage
- } {
+ } else {
# Local variables
set current_line 0 ;# Current line in source code
set stepover_in_progress 1 ;# Bool: "Step over" mode flag
@@ -486,7 +499,7 @@ public method sim_stepover {} {
if {$code($pc) != {}} {
set sync_ena 1 ;# Enable synchronization
- while 1 {
+ while {1} {
# Conditionaly abort simulation
if {$break} {
set break 0
@@ -536,7 +549,7 @@ public method sim_stepover {} {
return $Line($pc)
# No OP code
- } {
+ } else {
incr_pc 1
bell
$this sim_txt_output [mc "No instruction found at 0x%s" [NumSystem::dec2hex $pc]]
@@ -562,7 +575,7 @@ public method sim_run {} {
set run_in_progress 0 ;# Bool: "Run" mode flag
# Engage
- } {
+ } else {
set sync_ena 0 ;# Disabled synchronizations
# Local variables
@@ -570,9 +583,10 @@ public method sim_run {} {
set simulation_in_progress 1 ;# Bool: Simulator engaged
set idx 0 ;# Instruction index (GUI is updated after each 1000)
set ::X::critical_procedure_in_progress 0
+ set time_ms [clock milliseconds] ;# Int: High res. system timer, used here for regular GUI updates
# Infinitely execute program instructions until break
- while 1 {
+ while {1} {
incr idx
# Conditionaly abort simulation
if {$break} {
@@ -600,15 +614,19 @@ public method sim_run {} {
# Execute instruction
instruction_cycle
- # Run update command after each 25 instructions
- if {!($idx % 25)} {
- update
- }
- # Update GUI after each 100 instructions
- if {$idx >= 100} {
- set idx 0
- $this Simulator_sync_PC_etc
- update
+ if {$::GUI_AVAILABLE} {
+ if {([clock milliseconds] - $time_ms) > $GUI_UPDATE_INT} {
+ set idx 0
+ $this Simulator_sync_PC_etc
+ update
+ set time_ms [clock milliseconds]
+ }
+ } else {
+ # Stop after 1000 instructions
+ if {$idx >= 1000} {
+ set idx 0
+ set break 1
+ }
}
# Handle breakpoints
@@ -648,13 +666,13 @@ public method sim_animate {} {
set animation_in_progress 0 ;# Bool: "Animation" mode flag
# Engage
- } {
+ } else {
set animation_in_progress 1 ;# Bool: "Animation" mode flag
set simulation_in_progress 1 ;# Bool: Simulator engaged
set ::X::critical_procedure_in_progress 0
# Infinitely execute program instructions until break
- while 1 {
+ while {1} {
# Conditionaly abort simulation
if {$break} {
set simulation_in_progress 0
@@ -748,8 +766,8 @@ public method Simulator_shutdown {} {
# @return void
public method Simulator_initiate {} {
set sync_ena 1
- simulator_system_power_on
master_reset -
+ simulator_system_power_on
# Reset watchdog
set watchdog_value 0
@@ -757,3 +775,7 @@ public method Simulator_initiate {} {
set break 0
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_core.tcl b/lib/simulator/engine/engine_core.tcl
index e974656..0c78129 100755..100644
--- a/lib/simulator/engine/engine_core.tcl
+++ b/lib/simulator/engine/engine_core.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 _ENGINE_CORE_TCL ] } {
+set _ENGINE_CORE_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements virtual 8051 processor. This class is a part 8051 simulator.
@@ -54,9 +59,9 @@ class Simulator_ENGINE {
## COMMON
common symbol ;# Array of SFR symbolic names (eg. $symbol(P0) == "80")
- common DEBUG 1 ;# Turn on debugging
common PIN ;# Array describing pins with some special function
common PORT_LATCHES ;# List: Port latch registers
+ common GUI_UPDATE_INT 66;# Int: Time interval [ms] in which the GUI is regulary updated in the run mode
# Default values for SFR (values to set after reset)
common reset_reg_values {
@@ -77,10 +82,10 @@ class Simulator_ENGINE {
}
## PUBLIC
- public variable programming_language 0 ;# Int: ID of used programing language (0 == Assembler; 1 == C language)
+ public variable programming_language 0 ;# Int: ID of used programming language (0 == Assembler; 1 == C language)
## PRIVATE
- private variable breakpoints ;# Array of Lists of breakpoints (by line numbers) -- (eg '{1 45 399}')
+ private variable breakpoints ;# Array of Lists of breakpoints -- (eg '$breakpoints($file_number) == {1 45 399}')
private variable ram ;# Array of internal RAM; addr: 0..255; val: 0..255
private variable eram ;# Array of expanded RAM; addr: 0..4096; val: 0..255
@@ -102,13 +107,13 @@ class Simulator_ENGINE {
private variable Line ;# $Line($PC) == {line in source code} {filenumber} {level} {block}
private variable list_of_filenames ;# List of filenames for [lindex $Line($pc) 1]
- private variable line2PC ;# $line2PC($line) == PC
+ private variable line2PC ;# $line2PC($line_number,$file_number) == PC
private variable bank 0 ;# Current register bank (0..3)
private variable pc 0 ;# Program counter
private variable clock_kHz 0 ;# MCU clock in kHz
private variable time 0 ;# Number of instruction cycles consumed by current instruction
private variable sync_ena 0 ;# Bool: Enabled synchronization with an external interface
- private variable address_error 0 ;# Bool: Addressing error occured
+ private variable address_error 0 ;# Bool: Addressing error occurred
private variable break 0 ;# Bool: Immediately terminate the loaded program
private variable simulation_in_progress 0 ;# Bool: Engine is running
@@ -118,19 +123,19 @@ class Simulator_ENGINE {
private variable ports_previous_state {} ;# List: {P0_hex P1_hex P2_hex P3_hex P4_hex}
private variable rmw_instruction 0 ;# Bool: This instruction is one of READ-MODIFY-WRITE ones
- private variable avaliable_sfr {} ;# List: Addresses of implemented SFR
- private variable feature_avaliable ;# Array: Avaliable features
+ private variable available_sfr {} ;# List: Addresses of implemented SFR
+ private variable feature_available ;# Array: available features
private variable restricted_bits {} ;# List: Decimal addresses of unimplemented bits
private variable write_only_regs {} ;# List: Decimal addresses of write only registers
- private variable incomplite_regs {} ;# List: Decimal addresses of not fully implemented registers
- private variable incomplite_regs_mask ;# Array: key == dec. addr.; val == mask of implemented bits
+ private variable incomplete_regs {} ;# List: Decimal addresses of not fully implemented registers
+ private variable incomplete_regs_mask ;# Array: key == dec. addr.; val == mask of implemented bits
private variable DPL {DP0L} ;# Address of current DPL register (DTPR)
private variable DPH {DP0H} ;# Address of current DPH register (DTPR)
private variable hidden_DPTR0 {0 0} ;# Value of DPTR0 (if dual DPTR is hidden)
private variable hidden_DPTR1 {0 0} ;# Value of DPTR1 (if dual DPTR is hidden)
- private variable watchdog_value 0 ;# Int: Current value of watchdog timer (if avaliable)
+ private variable watchdog_value 0 ;# Int: Current value of watchdog timer (if available)
private variable wdtrst_prev_val 0 ;# Int: Previous value of register WDTRST
private variable wdt_prescaler_val 0 ;# Int: Watchdog prescaler value (content)
@@ -272,3 +277,7 @@ class Simulator_ENGINE {
# Initialize NS variables
Simulator_ENGINE::InitializeNS
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_external_interface_management.tcl b/lib/simulator/engine/engine_external_interface_management.tcl
index 30a5aed..5a1f220 100755..100644
--- a/lib/simulator/engine/engine_external_interface_management.tcl
+++ b/lib/simulator/engine/engine_external_interface_management.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 _ENGINE_EXTERNAL_INTERFACE_MANAGEMENT_TCL ] } {
+set _ENGINE_EXTERNAL_INTERFACE_MANAGEMENT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -29,20 +34,25 @@
# EXTERNAL INTERFACE MANAGEMENT PROCEDURES
# --------------------------------------------------------------------------
+## Get value of bit X2 in CLKREG/CKCON if available
+ # @return Bool - X2 value (if unavailable then 0)
+public method get_X2 {} {
+ return $controllers_conf(X2)
+}
-## Get value of bit SMOD0 in PCON if avaliable
- # @return Bool - SMOD0 value (if unavaliable then 0)
+## Get value of bit SMOD0 in PCON if available
+ # @return Bool - SMOD0 value (if unavailable then 0)
public method get_SMOD0 {} {
return $controllers_conf(SMOD0)
}
-## Set value of bit FE in SCON if avaliable
- # @param Bool value - New value for SCON.FE (or SCON.SM0 if FE is not avaliable)
+## Set value of bit FE in SCON if available
+ # @param Bool value - New value for SCON.FE (or SCON.SM0 if FE is not available)
# @return void
public method sim_engine_set_FE {value} {
- if {$feature_avaliable(smod0)} {
+ if {$feature_available(smod0)} {
set controllers_conf(FE) $value
- } {
+ } else {
sim_engine_set_SM0 $value
}
}
@@ -54,12 +64,12 @@ public method sim_engine_set_SM0 {value} {
set controllers_conf(SM0) $value
}
-## Get value of bit FE in SCON if avaliable
- # @return Bool - FE value (if unavaliable then {})
+## Get value of bit FE in SCON if available
+ # @return Bool - FE value (if unavailable then {})
public method sim_engine_get_FE {} {
- if {!$feature_avaliable(smod0)} {
+ if {!$feature_available(smod0)} {
return {}
- } {
+ } else {
return $controllers_conf(FE)
}
}
@@ -71,9 +81,14 @@ public method sim_engine_get_SM0 {} {
}
## Get program run statistics
- # @return List - Array run_statistics converted to list
-public method get_run_statistics {} {
- return [array get run_statistics]
+ # @parm Int idx = {} - Index to the array ``run_statistics'', empty string means entire array
+ # @return List/Int - Array run_statistics converted to list or Int
+public method get_run_statistics {{idx {}}} {
+ if {$idx == {}} {
+ return [array get run_statistics]
+ } else {
+ return $run_statistics($idx)
+ }
}
## Retrieve filename from list of files from which this program has been compiled
@@ -97,9 +112,9 @@ public method simulator_get_filenumber {filename} {
## Get maximum valid interrupt priority level
# @return Int - 0..3
public method simulator_get_max_intr_priority {} {
- if {$feature_avaliable(iph)} {
+ if {$feature_available(iph)} {
return 3
- } {
+ } else {
return 1
}
}
@@ -185,7 +200,7 @@ private method set_interrupt_priority_flag {flag level} {
}
# Adjust register IPH
- if {$feature_avaliable(iph)} {
+ if {$feature_available(iph)} {
if {${::Simulator::reverse_run_steps}} {
stepback_reg_change S $symbol(IPH)
}
@@ -194,7 +209,7 @@ private method set_interrupt_priority_flag {flag level} {
if {$level / 2} {
set sfr($symbol(IPH)) [expr $sfr($symbol(IPH)) | $bit_mask]
# Clear priority bit
- } {
+ } else {
set sfr($symbol(IPH)) [expr $sfr($symbol(IPH)) & ($bit_mask ^ 255)]
}
@@ -210,7 +225,7 @@ private method set_interrupt_priority_flag {flag level} {
if {$level % 2} {
set sfr($symbol(IP)) [expr $sfr($symbol(IP)) | $bit_mask]
# Clear priority bit
- } {
+ } else {
set sfr($symbol(IP)) [expr $sfr($symbol(IP)) & ($bit_mask ^ 255)]
}
# Adjust internal engine configuration
@@ -277,7 +292,10 @@ public method simulator_clear_intr_flag {flag} {
# Adjust internal engine configuration
evaluate_sfr $addr
- $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ }
}
## Force return from certain interrupt
@@ -299,11 +317,13 @@ public method simulator_cancel_interrupt {flag} {
incr run_statistics(8)
$this subprograms_return 1
- if {[llength $interrupts_in_progress]} {
- set vector [format %X [intr2vector [lindex $interrupts_in_progress end]]]
- simulator_Sbar [mc "Interrupt at vector 0x%s " $vector] 1 $this
- } {
- simulator_Sbar {} 0 $this
+ if {$::GUI_AVAILABLE} {
+ if {[llength $interrupts_in_progress]} {
+ set vector [format %X [intr2vector [lindex $interrupts_in_progress end]]]
+ simulator_Sbar [mc "Interrupt at vector 0x%s " $vector] 1 $this
+ } else {
+ simulator_Sbar {} 0 $this
+ }
}
set pch [stack_pop]
@@ -348,10 +368,10 @@ public method simulator_get_interrupts_in_progress_pb {} {
# @return List - Something like {IE0 TF0 IE1 TF1 RI TI CF}
public method simulator_get_intr_flags {} {
set result {IE0 TF0 IE1 TF1}
- if {$feature_avaliable(uart)} {lappend result RI TI}
- if {$feature_avaliable(spi)} {lappend result SPIF}
- if {$feature_avaliable(t2)} {lappend result TF2 EXF2}
- if {$feature_avaliable(acomparator)} {lappend result CF}
+ if {$feature_available(uart)} {lappend result RI TI}
+ if {$feature_available(spi)} {lappend result SPIF}
+ if {$feature_available(t2)} {lappend result TF2 EXF2}
+ if {$feature_available(acomparator)} {lappend result CF}
return $result
}
@@ -384,13 +404,15 @@ public method simulator_cancel_write_to_eeprom {} {
public method simulator_finalize_write_to_eeprom {} {
if {!$eeprom_size || !$eeprom_WR} {return}
- # Clear background highlight in EEPROM hexeditor
+ # Clear background highlight in EEPROM hex editor
foreach reg $eeprom_prev {
::X::sync_eeprom_clear_bg_hg [lindex $reg 0] $this
}
# Adjust engine configuration
- $this simulator_GUI_cancel_write_to_eeprom
+ if {$::GUI_AVAILABLE} {
+ $this simulator_GUI_cancel_write_to_eeprom
+ }
set eeprom_WR 0
set eeprom_WR_time 0
set eeprom_WR_ofs {}
@@ -419,17 +441,47 @@ public method simulator_line2address {line file} {
set line [expr $line]
if {[llength [array names line2PC -exact "$line,$file"]]} {
return $line2PC($line,$file)
- } {
+ } else {
return {}
}
}
+## Determinate list of all unreachable breakpoints in the code
+ # @return List - { { file_number line_number } ... }
+public method simulator_getInvalidBreakpoints {} {
+ # Local variables
+ set ln 0 ;# Int: Line number
+ set fn 0 ;# Int: File number
+ set idx 0 ;# Index in list of breakpoints
+
+ set list_of_breakpoints [list]
+ foreach {f b} [array get breakpoints] {
+ foreach l $b {
+ lappend list_of_breakpoints [list $f $l]
+ }
+ }
+
+ foreach ln_fn [array names line2PC] {
+ scan $ln_fn {%d,%d} ln fn
+
+ set idx [lsearch -ascii -exact $list_of_breakpoints [list $fn $ln]]
+
+ if {$idx != -1} {
+ set list_of_breakpoints [lreplace $list_of_breakpoints $idx $idx]
+ }
+ }
+
+ set list_of_breakpoints [lsort -integer -index 0 $list_of_breakpoints]
+ set list_of_breakpoints [lsort -integer -index 1 $list_of_breakpoints]
+ return $list_of_breakpoints
+}
+
## Set watchdog timer value
# This procedure does nothing on MCUs without watchdog timer
# @parm Int value - new value (0..8192)
# @return void
public method simulator_setWatchDogTimer {value} {
- if {!$feature_avaliable(wtd)} {return}
+ if {!$feature_available(wtd)} {return}
set watchdog_value $value
}
@@ -463,7 +515,7 @@ public method simulator_setWatchDogPrescalerValue {value} {
# @parm Bool bool - 0 == STOP; 1 == START
# @return void
public method simulator_startStopWatchDogTimer {bool} {
- if {!$feature_avaliable(wtd)} {return}
+ if {!$feature_available(wtd)} {return}
set controllers_conf(WatchDogTimer) $bool
}
@@ -481,8 +533,10 @@ public method simulator_subprog_call {value} {
stack_push [expr {($value & 0xFF00) >> 8}]
incr run_statistics(6)
$this subprograms_call 3 $pc $value
- $this stack_monitor_set_last_values_as 1 2
- $this stopwatch_refresh
+ if {$::GUI_AVAILABLE} {
+ $this stack_monitor_set_last_values_as 1 2
+ $this stopwatch_refresh
+ }
set pc $value
}
@@ -511,7 +565,7 @@ public method simulator_get_line_number {} {
return [lindex $Line($pc) 0]
}
-## Translate adress in program memory to line info
+## Translate address in program memory to line info
# @parm Int addr - Address to translate
# @return List - Line information list
public method simulator_address2line {addr} {
@@ -567,7 +621,7 @@ public method setSfr {addr val} {
{150} { ;# EECON
if {$sfr(150) & 1} {
set controllers_conf(WRTINH) 1
- } {
+ } else {
set controllers_conf(WRTINH) 0
}
}
@@ -577,7 +631,7 @@ public method setSfr {addr val} {
evaluate_sfr $addr 0
set stepback_ena $foo
- # If adress points to Primary Accumulator (Acc) -> reevaluate PSW
+ # If address points to Primary Accumulator (Acc) -> reevaluate PSW
if {$addr == 224} {
$this Simulator_GUI_sync S 208
}
@@ -690,8 +744,10 @@ public method getData {addr} {
# @parm Int addr - register address
# @return String - register value (2 hexadecimal digits)
public method getSfr {addr} {
+
# Get hexadecimal value
set result [format "%X" $sfr($addr)]
+
# Adjust the value
if {[string length $result] == 1} {
set result "0$result"
@@ -861,7 +917,7 @@ public method load_program_from_adf {adf_file} {
-icon warning \
-type ok \
-title [mc "Out of memory"] \
- -message [mc "%s has not enought program memory to load this program. Simulator will work but the loaded code is incomplite" [$this cget -P_option_mcu_type]]
+ -message [mc "%s has not enough program memory to load this program. Simulator will work but the loaded code is incomplete" [$this cget -P_option_mcu_type]]
return 0
}
set Line($addr) [list $lineNum $fileNum 0 0] ;# Set line number
@@ -875,7 +931,7 @@ public method load_program_from_adf {adf_file} {
# @parm File filename - Full name of source file from which SIM file was generaded
# @parm File cdb_file - CDB file ID (content of *.cdb file)
# @parm File ihx_file - HEX file ID (content of *.ihx or *.hex file)
- # @return void
+ # @return Bool - 1 == Success; 0 == Failure
public method load_program_from_cdb {filename cdb_file ihx_file} {
unload_program ;# Clear current content of the program memory
@@ -1023,6 +1079,12 @@ public method setEngineClock {clockkHz} {
set clock_kHz $clockkHz
}
+## Get MCU clock frequency
+ # @return - clock frequency in kHz
+public method getEngineClock {} {
+ return $clock_kHz
+}
+
## Get program uptime as human readable string
# @return String - the time (eg. '2 s 42 ms 987 us')
public method getTime {} {
@@ -1031,7 +1093,7 @@ public method getTime {} {
set s 0
set ms 0
set ns 0
- } {
+ } else {
set s [expr {int($overall_time * (0.012 / $clock_kHz))}]
set ms [expr {int($overall_time * (12000.0 / $clock_kHz)) % 1000000}]
set ns [expr {int($overall_time * (12000000.0 / $clock_kHz)) % 1000}]
@@ -1050,7 +1112,7 @@ public method getTime {} {
set len [string length $ns]
if {$len < 3} {
set ns_s "[string repeat { } [expr {3 - $len}]]$ns"
- } {
+ } else {
set ns_s $ns
}
@@ -1058,7 +1120,7 @@ public method getTime {} {
set len [string length $us]
if {$len < 3} {
set us_s "[string repeat { } [expr {3 - $len}]]$us"
- } {
+ } else {
set us_s $us
}
@@ -1066,19 +1128,19 @@ public method getTime {} {
set len [string length $ms]
if {$len < 3} {
set ms_s "[string repeat { } [expr {3 - $len}]]$ms"
- } {
+ } else {
set ms_s $ms
}
# Adjust seconds and minutes strings
if {[string length $s] == 1} {
set s_s " $s"
- } {
+ } else {
set s_s $s
}
if {[string length $m] == 1} {
set m_s " $m"
- } {
+ } else {
set m_s $m
}
@@ -1103,7 +1165,7 @@ public method getTime {} {
}
# Append micro-seconds
if {$us > 0 || $result != {}} {
- append result " ${us_s}us"
+ append result " ${us_s}µs"
}
# Append nano-seconds
if {$ns > 0 || $result != {}} {
@@ -1113,3 +1175,7 @@ public method getTime {} {
# Done ...
return [string trim $result]
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_hibernation.tcl b/lib/simulator/engine/engine_hibernation.tcl
index 24d3adf..d5a5faa 100755..100644
--- a/lib/simulator/engine/engine_hibernation.tcl
+++ b/lib/simulator/engine/engine_hibernation.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 _ENGINE_HIBERNATION_TCL ] } {
+set _ENGINE_HIBERNATION_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -39,16 +44,16 @@ public method simulator_get_special {} {
$timer_0_running $timer_1_running $overall_time \
$overall_instructions $inter_in_p_flags $timer1_overflow
- if {$feature_avaliable(t2)} {
+ if {$feature_available(t2)} {
lappend result $timer_2_running $timer2_overflow
}
- if {$feature_avaliable(wtd)} {
+ if {$feature_available(wtd)} {
lappend result $watchdog_value $wdtrst_prev_val
}
- if {$feature_avaliable(wdtcon)} {
+ if {$feature_available(wdtcon)} {
lappend result $wdt_prescaler_val $controllers_conf(WatchDogPrescaler)
}
- if {$feature_avaliable(pwm)} {
+ if {$feature_available(pwm)} {
lappend result $pwm_running $pwm_OCR
}
if {$eeprom_size} {
@@ -64,13 +69,13 @@ public method simulator_get_special {} {
lappend result $eeprom_WR_buff($i)
}
}
- if {$feature_avaliable(hddptr)} {
+ if {$feature_available(hddptr)} {
lappend result $hidden_DPTR0 $hidden_DPTR1
}
- if {$feature_avaliable(acomparator)} {
+ if {$feature_available(acomparator)} {
lappend result $anlcmp_running $anlcmp_output $anlcpm_db_timer
}
- if {$feature_avaliable(uart)} {
+ if {$feature_available(uart)} {
lappend result \
$uart_clock_prescaler \
$uart_RX_clock \
@@ -100,25 +105,25 @@ public method simulator_set_special {list} {
incr i
}
- if {$feature_avaliable(t2)} {
+ if {$feature_available(t2)} {
set timer_2_running [lindex $list $i]
incr i
set timer2_overflow [lindex $list $i]
incr i
}
- if {$feature_avaliable(wtd)} {
+ if {$feature_available(wtd)} {
set watchdog_value [lindex $list $i]
incr i
set wdtrst_prev_val [lindex $list $i]
incr i
}
- if {$feature_avaliable(wdtcon)} {
+ if {$feature_available(wdtcon)} {
set wdt_prescaler_val [lindex $list $i]
incr i
set controllers_conf(WatchDogPrescaler) [lindex $list $i]
incr i
}
- if {$feature_avaliable(pwm)} {
+ if {$feature_available(pwm)} {
set pwm_running [lindex $list $i]
incr i
set pwm_OCR [lindex $list $i]
@@ -142,13 +147,13 @@ public method simulator_set_special {list} {
set eeprom_WR_buff($j) [lindex $list $i]
}
}
- if {$feature_avaliable(hddptr)} {
+ if {$feature_available(hddptr)} {
set hidden_DPTR0 [lindex $list $i]
incr i
set hidden_DPTR1 [lindex $list $i]
incr i
}
- if {$feature_avaliable(acomparator)} {
+ if {$feature_available(acomparator)} {
set anlcmp_running [lindex $list $i]
incr i
set anlcmp_output [lindex $list $i]
@@ -156,7 +161,7 @@ public method simulator_set_special {list} {
set anlcpm_db_timer [lindex $list $i]
incr i
}
- if {$feature_avaliable(uart)} {
+ if {$feature_available(uart)} {
set uart_clock_prescaler [lindex $list $i]
incr i
set uart_RX_clock [lindex $list $i]
@@ -203,3 +208,7 @@ public method simulator_hib_append_SB_spec {list} {
public method simulator_hib_append_SB_norm {list} {
lappend stepback_normal $list
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_initialization_cleanup.tcl b/lib/simulator/engine/engine_initialization_cleanup.tcl
index e8a1ffa..8865dd2 100755..100644
--- a/lib/simulator/engine/engine_initialization_cleanup.tcl
+++ b/lib/simulator/engine/engine_initialization_cleanup.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 _ENGINE_INITIALIZATION_CLEANUP_TCL ] } {
+set _ENGINE_INITIALIZATION_CLEANUP_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -52,7 +57,7 @@ destructor {
# This function is called after each simulator start
# @return void
private method simulator_system_power_on {} {
- if {$feature_avaliable(wtd)} {
+ if {$feature_available(wtd)} {
set sfr($symbol(WDTRST)) [undefined_octet]
set wdtrst_prev_val $sfr($symbol(WDTRST))
if {$sync_ena} {
@@ -60,7 +65,7 @@ private method simulator_system_power_on {} {
}
}
- if {$feature_avaliable(uart)} {
+ if {$feature_available(uart)} {
set sfr($symbol(SBUFR)) [undefined_octet]
set sfr($symbol(SBUFT)) [undefined_octet]
set controllers_conf(UART_M) 0
@@ -70,7 +75,7 @@ private method simulator_system_power_on {} {
}
}
- if {$feature_avaliable(pof)} {
+ if {$feature_available(pof)} {
set controllers_conf(POF) 1
set sfr($symbol(PCON)) 16
if {$sync_ena} {
@@ -78,7 +83,7 @@ private method simulator_system_power_on {} {
}
}
- if {$feature_avaliable(spi)} {
+ if {$feature_available(spi)} {
set sfr($symbol(SPDR)) 0
if {$sync_ena} {
catch {$this Simulator_GUI_sync S $symbol(SPDR)}
@@ -103,7 +108,7 @@ public method simulator_initialize_mcu {} {
+
[$this cget -P_option_mcu_xcode])}]
- # Parse processor definition and set array feature_avaliable
+ # Parse processor definition and set array feature_available
foreach index {
5 6 7 9 10 11 17
20 21 22 23 24 25 26
@@ -118,24 +123,24 @@ public method simulator_initialize_mcu {} {
auxrwdidle auxrdisrto xram xcode
} {
if {[lindex $proc_data $index] == {yes}} {
- set feature_avaliable($name) 1
- } {
- set feature_avaliable($name) 0
+ set feature_available($name) 1
+ } else {
+ set feature_available($name) 0
}
}
for {set i 12; set j 0} {$i < 17} {incr i; incr j} {
set port_mask [lindex $proc_data $i]
if {$port_mask != {} && $port_mask != {00000000}} {
- set feature_avaliable(p$j) 1
- set feature_avaliable(port$j) $port_mask
- } {
- set feature_avaliable(p$j) 0
- set feature_avaliable(port$j) {00000000}
+ set feature_available(p$j) 1
+ set feature_available(port$j) $port_mask
+ } else {
+ set feature_available(p$j) 0
+ set feature_available(port$j) {00000000}
}
}
- # Set incomplite_regs_mask, restricted_bits and incomplite_regs
- array unset incomplite_regs_mask
+ # Set incomplete_regs_mask, restricted_bits and incomplete_regs
+ array unset incomplete_regs_mask
set restricted_bits {}
foreach reg_mask [lindex $proc_data 18] {
set addr [string range $reg_mask 0 1]
@@ -143,7 +148,7 @@ public method simulator_initialize_mcu {} {
set addr [expr "0x$addr"]
set mask [expr "0x$mask"]
- set incomplite_regs_mask($addr) $mask
+ set incomplete_regs_mask($addr) $mask
if {$addr > 127 && !($addr % 8)} {
for {set i 1} {$i <= 128} {set i [expr {$i * 2}]; incr addr} {
@@ -153,7 +158,7 @@ public method simulator_initialize_mcu {} {
}
}
}
- set incomplite_regs [array names incomplite_regs_mask]
+ set incomplete_regs [array names incomplete_regs_mask]
# Determiate list of write-only registers
set write_only_regs {}
@@ -186,7 +191,7 @@ public method simulator_initialize_mcu {} {
# Power on virtual uC and derminate list of implemented SFR
simulator_system_power_on
master_reset 0
- set avaliable_sfr [array names sfr]
+ set available_sfr [array names sfr]
# Initialize/Clear code memory and data EEPROM
simulator_clear_memory code
@@ -312,18 +317,18 @@ proc InitializeNS {} {
set PORT_LATCHES [list $symbol(P0) $symbol(P1) $symbol(P2) $symbol(P3) $symbol(P4)]
}
-## Shutdown simulator engine
+## Stop simulator engine
# @return void
private method internal_shutdown {} {
set break 1
$this Simulator_sync_clock
}
-## Determinate if the specified feature is avaliable on this MCU
+## Determinate if the specified feature is available on this MCU
# @parm String key - feature name (e.g. 'p0')
# @return Bool - result (1 == yes; 0 == no)
-public method get_feature_avaliable {key} {
- return $feature_avaliable($key)
+public method get_feature_available {key} {
+ return $feature_available($key)
}
## Get number of implemented ports and list of port indexes
@@ -331,10 +336,14 @@ public method get_feature_avaliable {key} {
public method get_ports_info {} {
set sum 0
for {set i 0} {$i < 5} {incr i} {
- if {$feature_avaliable(p$i)} {
+ if {$feature_available(p$i)} {
incr sum
lappend lst $i
}
}
return [list $sum $lst]
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_instructions.tcl b/lib/simulator/engine/engine_instructions.tcl
index d732414..19c45af 100755..100644
--- a/lib/simulator/engine/engine_instructions.tcl
+++ b/lib/simulator/engine/engine_instructions.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 _ENGINE_INSTRUCTIONS_TCL ] } {
+set _ENGINE_INSTRUCTIONS_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -41,7 +46,7 @@ private method ins_acall {haddr laddr} {
stack_push [expr {($pc & 255)}]
stack_push [expr {($pc & 0xFF00) >> 8}]
- incr laddr [expr {$haddr << 8}]
+ incr laddr [expr {($haddr << 8) | $pc & 0x0f800}]
incr run_statistics(6)
$this subprograms_call 1 $pc $laddr
$this stack_monitor_set_last_values_as 1 2
@@ -70,7 +75,7 @@ private method ins_add_D {addr} {
}
if {$addr < 128} {
ins_add $ram($addr)
- } {
+ } else {
ins_add [read_sfr $addr]
}
}
@@ -83,7 +88,7 @@ private method ins_add_ID {addr} {
incr_pc 1
if {[check_address_validity I $addr]} {
alo_add [undefined_octet]
- } {
+ } else {
alo_add $ram($addr)
}
evaluate_sfr 224
@@ -111,7 +116,7 @@ private method ins_addc_D {addr} {
}
if {$addr < 128} {
ins_addc $ram($addr)
- } {
+ } else {
ins_addc [read_sfr $addr]
}
}
@@ -125,7 +130,7 @@ private method ins_addc_ID {addr} {
if {[check_address_validity I $addr]} {
alo_addc [undefined_octet]
return
- } {
+ } else {
alo_addc $ram($addr)
}
}
@@ -136,7 +141,7 @@ private method ins_addc_ID {addr} {
# @return void
private method ins_ajmp {haddr laddr} {
set time 2
- incr laddr [expr {$haddr << 8}]
+ incr laddr [expr {($haddr << 8) | $pc & 0x0f800}]
set pc $laddr
}
@@ -155,7 +160,7 @@ private method ins_anl {addr val} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
set rmw_instruction 1
write_sfr $addr [expr {[read_sfr $addr] & $val}]
evaluate_sfr $addr
@@ -185,7 +190,7 @@ private method ins_anl_A_D {addr} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
ins_anl_A [read_sfr $addr]
evaluate_sfr $addr
}
@@ -222,7 +227,7 @@ private method ins_anl_C_N {addr} {
set time 2
if {[check_address_validity B $addr]} {
setBit $symbol(C) [expr {rand() > 0.5}]
- } {
+ } else {
if {[getBit $addr]} {setBit $symbol(C) 0}
}
evaluate_bit $symbol(C)
@@ -235,10 +240,10 @@ private method ins_anl_C_N {addr} {
private method ins_cjne_AD {addr roff} {
if {[check_address_validity D $addr]} {
set val [undefined_octet]
- } {
+ } else {
if {$addr < 128} {
set val $ram($addr)
- } {
+ } else {
set val $sfr($addr)
}
}
@@ -254,15 +259,14 @@ private method ins_cjne {val0 val1 roff} {
set time 2
if {$val0 != $val1} {
- if {$val0 < $val1} {
- setBit $symbol(C) 1
- } {
- setBit $symbol(C) 0
- }
-
if {$roff > 127} {incr roff -256}
incr_pc $roff
}
+ if {$val0 < $val1} {
+ setBit $symbol(C) 1
+ } else {
+ setBit $symbol(C) 0
+ }
}
## Instruction: CJNE @Ri, ...
@@ -275,19 +279,18 @@ private method ins_cjne_ID {addr val1 roff} {
if {[check_address_validity I $addr]} {
set val0 [undefined_octet]
- } {
+ } else {
set val0 $ram($addr)
}
if {$val0 != $val1} {
- if {$val0 < $val1} {
- setBit $symbol(C) 1
- } {
- setBit $symbol(C) 0
- }
-
if {$roff > 127} {incr roff -256}
incr_pc $roff
}
+ if {$val0 < $val1} {
+ setBit $symbol(C) 1
+ } else {
+ setBit $symbol(C) 0
+ }
}
## Instruction: CLR
@@ -309,7 +312,7 @@ private method ins_clr {opr} {
setBit $symbol(C) 0
evaluate_bit $symbol(C)
# Some bit
- } {
+ } else {
if {[check_address_validity B $opr]} {return}
set rmw_instruction 1
setBit $opr 0
@@ -335,17 +338,17 @@ private method ins_cpl {opr} {
} elseif {$opr == {C}} {
if {[getBit $symbol(C)]} {
setBit $symbol(C) 0
- } {
+ } else {
setBit $symbol(C) 1
}
evaluate_bit $symbol(C)
# Some bit
- } {
+ } else {
if {[check_address_validity B $opr]} {return}
set rmw_instruction 1
if {[getBit $opr]} {
setBit $opr 0
- } {
+ } else {
setBit $opr 1
}
evaluate_bit $opr
@@ -423,7 +426,7 @@ private method ins_div {} {
setBit $symbol(OV) 1
set sfr(224) 0
set sfr($symbol(B)) 0
- } {
+ } else {
setBit $symbol(OV) 0
set A $sfr(224)
set sfr(224) [expr {$A / $sfr($symbol(B))}]
@@ -449,7 +452,7 @@ private method ins_djnz {addr roff} {
incr_pc $roff
}
evaluate_sfr $addr
- } {
+ } else {
if {$ram($addr) != 0} {
if {$roff > 127} {incr roff -256}
incr_pc $roff
@@ -517,7 +520,7 @@ private method ins_jb {addr roff} {
set time 2
if {[check_address_validity B $addr]} {
set val [expr {rand() > 0.5}]
- } {
+ } else {
set val [getBit $addr]
}
if {$val} {
@@ -534,7 +537,7 @@ private method ins_jnb {addr roff} {
set time 2
if {[check_address_validity B $addr]} {
set val [expr {rand() > 0.5}]
- } {
+ } else {
set val [getBit $addr]
}
if {!$val} {
@@ -552,7 +555,7 @@ private method ins_jbc {addr roff} {
set time 2
if {[check_address_validity B $addr]} {
set val [expr {rand() > 0.5}]
- } {
+ } else {
set val [getBit $addr]
}
if {$val} {
@@ -653,7 +656,7 @@ private method ins_mov {addr val} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
write_sfr $addr $val
evaluate_sfr $addr
}
@@ -670,7 +673,7 @@ private method ins_mov_D {addr1 addr0} {
if {[check_address_validity D $addr0]} {return}
if {[check_address_validity D $addr1]} {
set val [undefined_octet]
- } {
+ } else {
if {$addr1 < 128} {
set val $ram($addr1)
} {
@@ -686,7 +689,7 @@ private method ins_mov_D {addr1 addr0} {
if {$sync_ena} {
$this Simulator_sync_reg $addr0
}
- } {
+ } else {
write_sfr $addr0 $val
evaluate_sfr $addr0
}
@@ -699,10 +702,10 @@ private method ins_mov_D {addr1 addr0} {
private method ins_mov_ID2 {addr0 addr1} {
if {[check_address_validity D $addr1]} {
ins_mov_ID0 $addr0 [undefined_octet]
- } {
+ } else {
if {$addr1 < 128} {
ins_mov_ID0 $addr0 $ram($addr1)
- } {
+ } else {
ins_mov_ID0 $addr0 [read_sfr $addr1]
}
}
@@ -720,7 +723,7 @@ private method ins_mov_ID1 {addr addr_id} {
if {[check_address_validity D $addr]} {return}
if {[check_address_validity I $addr_id]} {
set val [undefined_octet]
- } {
+ } else {
set val $ram($addr_id)
}
if {$addr < 128} {
@@ -731,7 +734,7 @@ private method ins_mov_ID1 {addr addr_id} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
write_sfr $addr $val
evaluate_sfr $addr
}
@@ -788,7 +791,7 @@ private method ins_mov_Rx_ADDR {idx addr} {
}
if {$addr < 128} {
set ram($t_addr) $ram($addr)
- } {
+ } else {
set ram($t_addr) [read_sfr $addr]
}
@@ -806,21 +809,21 @@ private method ins_mov_bit {dest source} {
if {$dest == {C}} {
if {[check_address_validity B $source]} {
set val [expr {rand() < 0.5}]
- } {
+ } else {
set val [getBit $source]
}
if {$val} {
setBit $symbol(C) 1
- } {
+ } else {
setBit $symbol(C) 0
}
- } {
+ } else {
set rmw_instruction 1
incr time
if {[check_address_validity B $dest]} {return}
if {[getBit $symbol(C)]} {
setBit $dest 1
- } {
+ } else {
setBit $dest 0
}
}
@@ -837,7 +840,7 @@ private method ins_movc {arg} {
if {$arg == {DPTR}} {
set addr [expr {($sfr(224) + $sfr($symbol($DPL))) + ($sfr($symbol($DPH)) << 8)}]
# MOVC A, @A+PC
- } {
+ } else {
set addr $pc
incr addr $sfr(224)
}
@@ -853,7 +856,7 @@ private method ins_movc {arg} {
set sfr(224) [undefined_octet]
} elseif {$code($addr) != {}} {
set sfr(224) $code($addr)
- } {
+ } else {
set sfr(224) [undefined_octet]
}
@@ -885,14 +888,14 @@ private method ins_movx {opr0 opr1} {
if {$Saddr < $eram_size && !$controllers_conf(EXTRAM)} {
if {[check_address_validity E $Saddr]} {
set sfr(224) [undefined_octet]
- } {
+ } else {
set sfr(224) $eram($Saddr)
}
# Read from data EEPROM
} elseif {$Saddr < $eeprom_size && $controllers_conf(EEMEN)} {
if {[check_address_validity P $Saddr]} {
set sfr(224) [undefined_octet]
- } {
+ } else {
set complement_MSB 0
foreach reg $eeprom_prev {
if {$Saddr == [lindex $reg 0]} {
@@ -902,13 +905,13 @@ private method ins_movx {opr0 opr1} {
}
if {$complement_MSB} {
set sfr(224) [expr {$eeprom($Saddr) ^ 0x80}]
- } {
+ } else {
set sfr(224) $eeprom($Saddr)
}
}
# Read from external data memory
} else {
- if {$feature_avaliable(xram) && [$this pale_is_enabled]} {
+ if {$feature_available(xram) && [$this pale_is_enabled]} {
for {set i -3} {$i < 0} {incr i} {
if {!$controllers_conf(X2)} {
$this pale_WPBBL $PIN(RD) {X} $i
@@ -918,7 +921,7 @@ private method ins_movx {opr0 opr1} {
$this pale_WPBBL $PIN(RD) {X} $i
$this pale_WPBL 0 X $i
$this pale_WPBL 2 X $i
- } {
+ } else {
incr i
$this pale_WPBL 0 X [expr {int($i / 2)}]
$this pale_WPBL 2 X [expr {int($i / 2)}]
@@ -928,7 +931,7 @@ private method ins_movx {opr0 opr1} {
}
if {[check_address_validity X $Saddr]} {
set sfr(224) [undefined_octet]
- } {
+ } else {
set sfr(224) $xram($Saddr)
}
}
@@ -978,7 +981,7 @@ private method ins_movx {opr0 opr1} {
set eeprom_WR_ofs "0x$offset"
::X::eeprom_write_buffer_set_offset $eeprom_WR_ofs $this
- # Start EEPROM programing cycle
+ # Start EEPROM programming cycle
if {!$controllers_conf(EELD)} {
# Write data to data EEPROM
set eeprom_prev {}
@@ -993,7 +996,7 @@ private method ins_movx {opr0 opr1} {
set eeprom_WR_buff($i) {}
}
- # Clear write buffer hexeditor
+ # Clear write buffer hex editor
::X::eeprom_write_buffer_set_offset {} $this
::X::clear_eeprom_write_buffer $this
@@ -1017,7 +1020,7 @@ private method ins_movx {opr0 opr1} {
# Write to external data memory
} else {
- if {$feature_avaliable(xram) && [$this pale_is_enabled]} {
+ if {$feature_available(xram) && [$this pale_is_enabled]} {
for {set i -3} {$i < 0} {incr i} {
if {!$controllers_conf(X2)} {
$this pale_WPBBL $PIN(WR) {X} $i
@@ -1027,7 +1030,7 @@ private method ins_movx {opr0 opr1} {
$this pale_WPBBL $PIN(WR) {X} $i
$this pale_WPBL 0 X $i
$this pale_WPBL 2 X $i
- } {
+ } else {
incr i
$this pale_WPBL 0 X [expr {int($i / 2)}]
$this pale_WPBL 2 X [expr {int($i / 2)}]
@@ -1037,6 +1040,7 @@ private method ins_movx {opr0 opr1} {
}
if {[check_address_validity X $Daddr]} {return}
+ stepback_reg_change X $Daddr
set xram($Daddr) $sfr(224)
}
@@ -1062,7 +1066,7 @@ private method ins_mul {} {
if {$result > 255} {
set sfr(240) [expr {($result & 0xFF00) >> 8}]
setBit $symbol(OV) 1
- } {
+ } else {
set sfr(240) 0
setBit $symbol(OV) 0
}
@@ -1096,7 +1100,7 @@ private method ins_orl {addr val} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
set rmw_instruction 1
write_sfr $addr [expr {[read_sfr $addr] | $val}]
evaluate_sfr $addr
@@ -1113,7 +1117,7 @@ private method ins_orl_D {addr0 addr1} {
ins_orl $addr0 [undefined_octet]
} elseif {$addr1 < 128} {
ins_orl $addr0 $ram($addr1)
- } {
+ } else {
ins_orl $addr0 [read_sfr $addr1]
}
}
@@ -1129,7 +1133,7 @@ private method ins_orl_ID {addr addr_id} {
if {[check_address_validity D $addr]} {return}
if {[check_address_validity I $addr_id]} {
set val [undefined_octet]
- } {
+ } else {
set val $ram($addr_id)
}
if {$addr < 128} {
@@ -1140,7 +1144,7 @@ private method ins_orl_ID {addr addr_id} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
set rmw_instruction 1
write_sfr $addr [expr {[read_sfr $addr] | $val}]
evaluate_sfr $addr
@@ -1157,7 +1161,7 @@ private method ins_orl_not_bit {addr} {
setBit $symbol(C) [expr {rand() < 0.5}]
} elseif {[getBit $symbol(C)] || ![getBit $addr]} {
setBit $symbol(C) 1
- } {
+ } else {
setBit $symbol(C) 0
}
}
@@ -1172,7 +1176,7 @@ private method ins_orl_bit {addr} {
setBit $symbol(C) [expr {rand() < 0.5}]
} elseif {[getBit $symbol(C)] || [getBit $addr]} {
setBit $symbol(C) 1
- } {
+ } else {
setBit $symbol(C) 0
}
}
@@ -1193,7 +1197,7 @@ private method ins_pop {addr} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
write_sfr $addr [stack_pop]
evaluate_sfr $addr
}
@@ -1243,13 +1247,15 @@ private method ins_reti {} {
$this interrupt_monitor_reti [lindex $inter_in_p_flags end]
set interrupts_in_progress [lreplace $interrupts_in_progress end end]
set inter_in_p_flags [lreplace $inter_in_p_flags end end]
- if {[llength $interrupts_in_progress]} {
- set vector [format %X [intr2vector [lindex $interrupts_in_progress end]]]
- simulator_Sbar [mc "Interrupt at vector 0x%s " $vector] 1 $this
- } {
- simulator_Sbar {} 0 $this
+ if {$::GUI_AVAILABLE} {
+ if {[llength $interrupts_in_progress]} {
+ set vector [format %X [intr2vector [lindex $interrupts_in_progress end]]]
+ simulator_Sbar [mc "Interrupt at vector 0x%s " $vector] 1 $this
+ } else {
+ simulator_Sbar {} 0 $this
+ }
}
- } {
+ } else {
$this simulator_invalid_reti_dlg $pc $Line($pc)
}
@@ -1295,7 +1301,7 @@ private method ins_rlc {} {
if {$sfr(224) > 255} {
incr sfr(224) -256
setBit $symbol(C) 1
- } {
+ } else {
setBit $symbol(C) 0
}
@@ -1313,7 +1319,7 @@ private method ins_rr {} {
}
if {[expr {$sfr(224) % 2}]} {
set C 1
- } {
+ } else {
set C 0
}
@@ -1335,7 +1341,7 @@ private method ins_rrc {} {
}
if {[expr {$sfr(224) % 2}]} {
set C 1
- } {
+ } else {
set C 0
}
@@ -1347,7 +1353,7 @@ private method ins_rrc {} {
if {$C} {
setBit $symbol(C) 1
- } {
+ } else {
setBit $symbol(C) 0
}
@@ -1363,7 +1369,7 @@ private method ins_setb {opr} {
if {$opr == {C}} {
setBit $symbol(C) 1
- } {
+ } else {
if {[check_address_validity B $opr]} {return}
set rmw_instruction 1
setBit $opr 1
@@ -1399,7 +1405,7 @@ private method ins_subb_D {addr} {
ins_subb [undefined_octet]
} elseif {$addr < 128} {
ins_subb $ram($addr)
- } {
+ } else {
ins_subb $sfr($addr)
}
}
@@ -1412,7 +1418,7 @@ private method ins_subb_ID {addr} {
incr_pc 1
if {[check_address_validity I $addr]} {
ins_subb [undefined_octet]
- } {
+ } else {
alo_subb $ram($addr)
}
evaluate_sfr 224
@@ -1457,7 +1463,7 @@ private method ins_xch {addr} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
set sfr(224) [read_sfr $addr]
write_sfr $addr $A
evaluate_sfr $addr
@@ -1499,14 +1505,14 @@ private method ins_xchd {addr} {
set val [undefined_octet]
} elseif {$addr < 128} {
set val $ram($addr)
- } {
+ } else {
set val $sfr($addr)
}
if {${::Simulator::reverse_run_steps}} {
stepback_reg_change S 224
if {$addr < 128} {
stepback_reg_change I $addr
- } {
+ } else {
stepback_reg_change S $addr
}
}
@@ -1518,7 +1524,7 @@ private method ins_xchd {addr} {
set val [expr {($val & 240) + $nibble0}]
if {$addr < 128} {
set ram($addr) $val
- } {
+ } else {
set sfr($addr) $val
}
@@ -1545,7 +1551,7 @@ private method ins_xrl {addr val} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
set rmw_instruction 1
write_sfr $addr [expr {[read_sfr $addr] ^ $val}]
evaluate_sfr $addr
@@ -1561,7 +1567,7 @@ private method ins_xrl_D {addr0 addr1} {
ins_xrl $addr0 [undefined_octet]
} elseif {$addr1 < 128} {
ins_xrl $addr0 $ram($addr1)
- } {
+ } else {
ins_xrl $addr0 [read_sfr $addr1]
}
}
@@ -1577,7 +1583,7 @@ private method ins_xrl_ID {addr addr_id} {
if {[check_address_validity I $addr_id]} {
set val [undefined_octet]
- } {
+ } else {
set val $ram($addr_id)
}
if {$addr < 128} {
@@ -1588,9 +1594,13 @@ private method ins_xrl_ID {addr addr_id} {
if {$sync_ena} {
$this Simulator_sync_reg $addr
}
- } {
+ } else {
set rmw_instruction 1
write_sfr $addr [expr {[read_sfr $addr] ^ $val}]
evaluate_sfr $addr
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_mcu_configuration.tcl b/lib/simulator/engine/engine_mcu_configuration.tcl
index 7701583..2226a7d 100755..100644
--- a/lib/simulator/engine/engine_mcu_configuration.tcl
+++ b/lib/simulator/engine/engine_mcu_configuration.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 _ENGINE_MCU_CONFIGURATION_TCL ] } {
+set _ENGINE_MCU_CONFIGURATION_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -53,7 +58,7 @@ private method increment_program_time {num} {
return [watchdog_controller]
}
-## Adjust configuration acording to new value of the given bit
+## Adjust configuration according to new value of the given bit
# @parm Int addr - Bit address
# @return void
private method evaluate_bit {addr} {
@@ -61,18 +66,18 @@ private method evaluate_bit {addr} {
if {$sync_ena} {
$this Simulator_sync_reg [getRegOfBit $addr]
}
- } {
+ } else {
evaluate_sfr [getRegOfBit $addr]
}
}
-## Evaluate list of interrupt priorities acording to values of IP and IPH
+## Evaluate list of interrupt priorities according to values of IP and IPH
# @return void
private method evaluate_interrupt_priorities {} {
# Determinate value of Interrupt Priority High register
- if {$feature_avaliable(iph)} {
+ if {$feature_available(iph)} {
set iph $sfr(183)
- } {
+ } else {
set iph 0
}
@@ -115,17 +120,17 @@ private method evaluate_interrupt_priorities {} {
foreach flag $controllers_conf(IP) ip $controllers_conf(IP_level) {
switch -- $flag {
PS {
- if {$feature_avaliable(uart)} {
+ if {$feature_available(uart)} {
lappend interrupt_pri_flg RI TI
lappend interrupt_pri_num $ip $ip
}
- if {$feature_avaliable(spi)} {
+ if {$feature_available(spi)} {
lappend interrupt_pri_flg SPIF
lappend interrupt_pri_num $ip
}
}
PT2 {
- if {!$feature_avaliable(t2)} {continue}
+ if {!$feature_available(t2)} {continue}
lappend interrupt_pri_flg EXF2 TF2
lappend interrupt_pri_num $ip $ip
}
@@ -146,7 +151,7 @@ private method evaluate_interrupt_priorities {} {
lappend interrupt_pri_num $ip
}
PC {
- if {!$feature_avaliable(acomparator)} {continue}
+ if {!$feature_available(acomparator)} {continue}
lappend interrupt_pri_flg CF
lappend interrupt_pri_num $ip
}
@@ -154,17 +159,16 @@ private method evaluate_interrupt_priorities {} {
}
# Adjust interrup monitor
- $this interrupt_monitor_intr_prior $interrupt_pri_flg
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_prior $interrupt_pri_flg
+ }
}
-## Adjust configuration acording to new value of the given SFR
- # @parm Int - Register address
- # @parm Bool = 1 - Synchronize this SFR with external interface
+## Adjust configuration according to new value of the given SFR
+ # @parm Int addr - Register address
+ # @parm Bool sync=1 - Synchronize this SFR with external interface
# @return void
-private method evaluate_sfr args {
- set addr [lindex $args 0]
- set sync [lindex $args 1]
-
+private method evaluate_sfr {addr {sync 1}} {
switch -- $addr {
135 { ;# PCON 0x87
set SMOD0_prev $controllers_conf(SMOD0)
@@ -179,7 +183,9 @@ private method evaluate_sfr args {
write_conf 168 {EA EC ET2 ES ET1 EX1 ET0 EX0}
# Inform interrupt monitor
- $this interrupt_monitor_intr_ena_dis
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_ena_dis
+ }
}
184 { ;# IP 0xB8
evaluate_interrupt_priorities
@@ -190,7 +196,7 @@ private method evaluate_sfr args {
# Determinate SM0 and FE
if {$controllers_conf(SMOD0)} {
set controllers_conf(FE) [expr {($sfr(152) & 0x80) ? 1 : 0}]
- } {
+ } else {
set controllers_conf(SM0) [expr {($sfr(152) & 0x80) ? 1 : 0}]
}
@@ -203,13 +209,17 @@ private method evaluate_sfr args {
}
# Inform interrupt monitor
- $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ }
}
136 { ;# TCON 0x88
write_conf 136 {TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0}
# Inform interrupt monitor
- $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ }
}
137 { ;# TMOD 0x89
write_conf 137 {GATE1 CT1 M11 M01 GATE0 CT0 M10 M00}
@@ -234,19 +244,18 @@ private method evaluate_sfr args {
set bank [expr {($sfr(208) & 24) >> 3}]
}
224 { ;# A 0xE0
- set A 0
set count 0
set mask 1
for {set i 0} {$i < 8} {incr i} {
- if {[expr {$sfr(224) & $mask}] > 0} {
+ if {$sfr(224) & $mask} {
incr count
}
set mask [expr {$mask << 1}]
}
- if {[expr {$count % 2}] == 1} {
+ if {$count % 2} {
setBit $symbol(P) 1
- } {
+ } else {
setBit $symbol(P) 0
}
}
@@ -256,11 +265,11 @@ private method evaluate_sfr args {
write_conf 162 {- - - - - - - DPS}
# Switch visible dual DPTR
- if {!$feature_avaliable(hddptr)} {
+ if {!$feature_available(hddptr)} {
if {$controllers_conf(DPS)} {
set DPL {DP1L}
set DPH {DP1H}
- } {
+ } else {
set DPL {DP0L}
set DPH {DP0H}
}
@@ -269,13 +278,13 @@ private method evaluate_sfr args {
} elseif {$DPS_org != $controllers_conf(DPS)} {
if {$DPS_org} {
set hidden_DPTR1 [list $sfr($symbol(DP0L)) $sfr($symbol(DP0H))]
- } {
+ } else {
set hidden_DPTR0 [list $sfr($symbol(DP0L)) $sfr($symbol(DP0H))]
}
if {$controllers_conf(DPS)} {
set sfr($symbol(DP0L)) [lindex $hidden_DPTR1 0]
set sfr($symbol(DP0H)) [lindex $hidden_DPTR1 1]
- } {
+ } else {
set sfr($symbol(DP0L)) [lindex $hidden_DPTR0 0]
set sfr($symbol(DP0H)) [lindex $hidden_DPTR0 1]
}
@@ -290,13 +299,13 @@ private method evaluate_sfr args {
}
}
142 { ;# AUXR 0x8E
- if {$feature_avaliable(wdtcon)} {
- if {$feature_avaliable(intelpe)} {
+ if {$feature_available(wdtcon)} {
+ if {$feature_available(intelpe)} {
write_conf 142 {- - - - - - IPE DISALE}
- } {
+ } else {
write_conf 142 {- - - - - - EXTRAM DISALE}
}
- } {
+ } else {
write_conf 142 {- - - WDIDLE DISRTO - EXTRAM DISALE}
}
}
@@ -306,7 +315,7 @@ private method evaluate_sfr args {
set controllers_conf(WatchDogTimer) 1
set watchdog_value -$time
- if {$feature_avaliable(wdtcon)} {
+ if {$feature_available(wdtcon)} {
set controllers_conf(WDTEN) 1
set sfr(167) [expr {$sfr(167) | 1}]
if {${::Simulator::reverse_run_steps}} {
@@ -324,7 +333,9 @@ private method evaluate_sfr args {
write_conf 200 {TF2 EXF2 RCLK TCLK EXEN2 TR2 CT2 CPRL2}
# Inform interrupt monitor
- $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ }
}
201 { ;# T2MOD 0xC9
write_conf 201 {- - - - - - T2OE DCEN}
@@ -342,7 +353,9 @@ private method evaluate_sfr args {
}]
# Inform interrupt monitor
- $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ }
}
183 { ;# IPH 0xB7
evaluate_interrupt_priorities
@@ -354,12 +367,14 @@ private method evaluate_sfr args {
write_conf 170 {SPIF WCOL LDEN - - - DISSO ENH}
# Inform interrupt monitor
- $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ }
}
167 { ;# WDTCON/WDTPRG 0xA7
- if {$feature_avaliable(wdtprg)} {
+ if {$feature_available(wdtprg)} {
write_conf 167 {- - - - - PS2 PS1 PS0}
- } {
+ } else {
write_conf 167 {PS2 PS1 PS0 WDIDLE DISRTO HWDT WSWRST WDTEN}
}
set controllers_conf(WatchDogPrescaler) 0
@@ -395,7 +410,7 @@ private method evaluate_sfr args {
if {$controllers_conf(DPS)} {
set DPL {DP1L}
set DPH {DP1H}
- } {
+ } else {
set DPL {DP0L}
set DPH {DP0H}
}
@@ -423,7 +438,7 @@ private method write_conf {addr key_list} {
if {[expr {$sfr($addr) & $mask}] == 0} {
set controllers_conf($key) 0
- } {
+ } else {
set controllers_conf($key) 1
}
}
@@ -499,7 +514,7 @@ private method incr_8b {type addr val} {
private method stack_pop {} {
if {[check_address_validity I $sfr(129)]} {
set result [undefined_octet]
- } {
+ } else {
if {${::Simulator::reverse_run_steps}} {
stepback_reg_change I $sfr(129)
}
@@ -540,7 +555,7 @@ public method stack_push {val} {
}
if {[check_address_validity I $sfr(129)]} {
return
- } {
+ } else {
if {${::Simulator::reverse_run_steps}} {
stepback_reg_change I $sfr(129)
}
@@ -553,3 +568,7 @@ public method stack_push {val} {
evaluate_sfr 129
$this stack_monitor_push $sfr(129) $val
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_memory_management.tcl b/lib/simulator/engine/engine_memory_management.tcl
index acf2978..e3a5828 100755..100644
--- a/lib/simulator/engine/engine_memory_management.tcl
+++ b/lib/simulator/engine/engine_memory_management.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 _ENGINE_MEMORY_MANAGEMENT_TCL ] } {
+set _ENGINE_MEMORY_MANAGEMENT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -40,11 +45,11 @@ private method getNextOperand {} {
bell
$this sim_txt_output [mc "Incomplete instruction (undefined operand/value missing in memory) at 0x%s" [NumSystem::dec2hex $pc]]
return [undefined_octet]
- } {
+ } else {
if {$code($pc) == {}} {
$this sim_txt_output [mc "Incomplete instruction (undefined operand/value missing in memory) at 0x%s. Using 0FFh as operand !" [NumSystem::dec2hex $pc]]
return 255
- } {
+ } else {
return $code($pc)
}
}
@@ -59,11 +64,11 @@ private method getLastOperand {} {
bell
$this sim_txt_output [mc "Incomplete instruction (undefined operand/value missing in memory) at 0x%s" [NumSystem::dec2hex $pc]]
set result [undefined_octet]
- } {
+ } else {
if {$code($pc) == {}} {
$this sim_txt_output [mc "Incomplete instruction (undefined operand/value missing in memory) at 0x%s. Using 0FFh as operand !" [NumSystem::dec2hex $pc]]
set result 255
- } {
+ } else {
set result $code($pc)
}
}
@@ -92,7 +97,7 @@ public method setBit {addr value} {
if {${::Simulator::reverse_run_steps}} {
if {$regAddr < 128} {
stepback_reg_change I $regAddr
- } {
+ } else {
stepback_reg_change S $regAddr
}
}
@@ -114,7 +119,7 @@ public method setBit {addr value} {
} elseif {([expr {$ram($regAddr) & $mask}] == 0) && $value} {
set ram($regAddr) [expr {$ram($regAddr) ^ $mask}]
}
- } {
+ } else {
set sfr_val [read_sfr $regAddr]
if {([expr {$sfr_val & $mask}] > 0) && !$value} {
write_sfr $regAddr [expr {$sfr_val ^ $mask}]
@@ -125,7 +130,7 @@ public method setBit {addr value} {
if {$regAddr > 127} {
evaluate_sfr $regAddr
- } {
+ } else {
if {$sync_ena} {
$this Simulator_sync_reg $regAddr
}
@@ -161,19 +166,19 @@ public method getBitByReg {regAddr bitNumber} {
if {$regAddr < 0x80} {
if {[expr {$ram($regAddr) & $mask}] == 0} {
return 0
- } {
+ } else {
return 1
}
- } {
- if {[lsearch -ascii -exact $PORT_LATCHES $regAddr] != -1} {
+ } else {
+ if {[lsearch -ascii -exact $PORT_LATCHES $regAddr] != -1} {
set byte [read_sfr $regAddr]
- } {
- set byte $sfr($regAddr)
- }
+ } else {
+ set byte $sfr($regAddr)
+ }
if {[expr {$byte & $mask}] == 0} {
return 0
- } {
+ } else {
return 1
}
}
@@ -187,7 +192,7 @@ public method getRegOfBit {addr} {
if {$addr > 127} {
set reg [expr {$reg * 8}]
- } {
+ } else {
incr reg 32
}
@@ -247,7 +252,9 @@ private method check_address_validity {location address} {
}
internal_shutdown
- $this invalid_addressing_dialog $location $address
+ if {$::GUI_AVAILABLE} {
+ $this invalid_addressing_dialog $location $address
+ }
set address_error 1
return 1
}
@@ -255,8 +262,10 @@ private method check_address_validity {location address} {
## Check if the specified address at the given location is implemented in this MCU
# @parm Char location - Memory type
# D == IDATA direct addressing or SFR
+ # S == SFR only
# I == IDATA indirect addressing (or operations on stack)
# B == Bit area
+ # J == Special Function Bits only
# X == XDATA
# C == CODE
# E == ERAM
@@ -269,7 +278,12 @@ public method simulator_address_range {location address} {
if {$address < 128 && $address < $iram_size} {
return 1
}
- if {[lsearch $avaliable_sfr $address] != -1} {
+ if {[lsearch $available_sfr $address] != -1} {
+ return 1
+ }
+ }
+ {S} { ;# SFR only
+ if {[lsearch $available_sfr $address] != -1} {
return 1
}
}
@@ -286,7 +300,15 @@ public method simulator_address_range {location address} {
if {$reg_addr < 128 && $reg_addr < $iram_size} {
return 1
}
- if {[lsearch $avaliable_sfr $reg_addr] != -1} {
+ if {[lsearch $available_sfr $reg_addr] != -1} {
+ return 1
+ }
+ }
+ {J} { ;# Special Function Bits only
+ if {[lsearch $restricted_bits $address] != -1} {
+ return 0
+ }
+ if {[lsearch $available_sfr [getRegOfBit $address]] != -1} {
return 1
}
}
@@ -316,7 +338,8 @@ public method simulator_address_range {location address} {
## Write value to SFR
# - It does not check address validity !
- # - Purpose is to write zero to unimplemented bits
+ # - Purpose is to write zero to unimplemented bits and handle special funtions
+ # triggered by write to specific SFR
# @parm Int addr - Target address (128..255)
# @parm Int value - New value (0.255)
# @return void
@@ -341,15 +364,15 @@ private method write_sfr {addr value} {
# Interrupts configuration related SFR -- skip next interrupt
if {$addr == $symbol(IP) || $addr == $symbol(IE) || $addr == $symbol(IPH)} {
set skip_interrupt 1
- } {
+ } else {
set skip_interrupt 0
}
# Write specified value into the SFR
- if {[lsearch $incomplite_regs $addr] == -1} {
+ if {[lsearch $incomplete_regs $addr] == -1} {
set sfr($addr) $value
- } {
- set sfr($addr) [expr {$value & $incomplite_regs_mask($addr)}]
+ } else {
+ set sfr($addr) [expr {$value & $incomplete_regs_mask($addr)}]
}
}
@@ -361,7 +384,7 @@ private method write_sfr {addr value} {
private method read_sfr {addr} {
# Port latch
set port_number [lsearch -ascii -exact $PORT_LATCHES $addr]
- if {!$rmw_instruction && $port_number != -1} {
+ if {!$rmw_instruction && $port_number != -1 && [$this pale_is_enabled]} {
set result [$this pale_RRPV $port_number]
# Write only register
@@ -373,15 +396,19 @@ private method read_sfr {addr} {
return [undefined_octet]
# Fully implemeneted register
- } elseif {[lsearch $incomplite_regs $addr] == -1} {
+ } elseif {[lsearch $incomplete_regs $addr] == -1} {
return $sfr($addr)
# Partialy implemented register
- } {
+ } else {
return [expr {
- ($incomplite_regs_mask($addr) & $sfr($addr))
+ ($incomplete_regs_mask($addr) & $sfr($addr))
+
- (($incomplite_regs_mask($addr) ^ 0x0FF) & [undefined_octet])
+ (($incomplete_regs_mask($addr) ^ 0x0FF) & [undefined_octet])
}]
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_opcodes.tcl b/lib/simulator/engine/engine_opcodes.tcl
index 6d43158..e06dc12 100755..100644
--- a/lib/simulator/engine/engine_opcodes.tcl
+++ b/lib/simulator/engine/engine_opcodes.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 _ENGINE_OPCODES_TCL ] } {
+set _ENGINE_OPCODES_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -433,3 +438,7 @@ private method 108 {} {ins_xrl 224 $ram([R 4])} ;# 0x6C :: xrl A, R4
private method 109 {} {ins_xrl 224 $ram([R 5])} ;# 0x6D :: xrl A, R5
private method 110 {} {ins_xrl 224 $ram([R 6])} ;# 0x6E :: xrl A, R6
private method 111 {} {ins_xrl 224 $ram([R 7])} ;# 0x6F :: xrl A, R7
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_text_based_interface.tcl b/lib/simulator/engine/engine_text_based_interface.tcl
new file mode 100644
index 0000000..0b6448c
--- /dev/null
+++ b/lib/simulator/engine/engine_text_based_interface.tcl
@@ -0,0 +1,1087 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# Copyright (C) 2011-2011 by Martin Ošmera #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _ENGINE_TEXT_BASED_INTERFACE_TCL ] } {
+set _ENGINE_TEXT_BASED_INTERFACE_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+#
+# Command line interface for the simulator engine. Listens to simple commands,
+# like `read-sfr-by-name PCON'. Each command must be on separate line, empty
+# lines and everything after `#' characater are ignored. Response to every
+# command is either `DONE' or
+# `ERROR (line: <line_number>; command: <command>): <error_info>'. Some commands
+# returns some values, in that case these values are printed before the `DONE'
+# string. Commands are case insensitive, but the same may not apply for their
+# arguments.
+#
+# Note: This interface is supposed to be available via main.tcl invoked with
+# --simulator option. That means that to access this inteface it should be
+# sufficient to run `mcu8051ide --simulator' command.
+#
+# List of commands:
+# ================
+#
+# COMMAND DESCRIPTION
+# ------- -----------
+# echo-on
+# echo-off
+# set-mcu
+# set-clock
+# set-xcode
+# set-xdata
+# load-code
+# load-code-adf
+# load-code-cdb
+# load-idata
+# load-xdata
+# load-eeprom
+# load-eram
+# dump-code
+# dump-idata
+# dump-xdata
+# dump-eeprom
+# dump-eram
+# write-code
+# write-idata
+# write-xdata
+# write-eeprom
+# write-eram
+# write-sfr
+# write-sfr
+# write-bit
+# read-code
+# read-idata
+# read-xdata
+# read-eeprom
+# read-eram
+# read-sfr
+# read-sfr-by-name
+# read-bit
+# step
+# step-back
+# list-changes
+# read-pc
+# write-pc
+# read-position
+# reset
+# run
+# input
+# output
+# hibernate
+# resume
+# core-dump
+# core-alter
+# exit
+# --------------------------------------------------------------------------
+
+namespace eval SimulatorEngineCLI {
+ variable command_line
+ variable cmd_line_idx
+ variable simulator
+ variable line_counter
+ variable echo
+ variable error_reported
+
+ class SimEngineWrapper {
+ inherit Simulator_ENGINE Pale
+
+ common changed_registers [list]
+
+ # TODO: get rid of these variables:
+ public variable procData {}
+ public variable P_option_mcu_type {}
+ public variable P_option_mcu_xdata 0
+ public variable P_option_mcu_xcode 0
+ public variable projectPath {.}
+
+ public method is_ready {} {
+ if {[llength $procData]} {
+ return 1
+ } else {
+ return 0
+ }
+ }
+
+ public method Simulator_GUI_sync args {
+ lappend changed_registers $args
+ }
+
+ public method Simulator_sync_PC_etc {} {
+ }
+
+ public method get_changed_registers {} {
+ return $changed_registers
+ }
+
+ public method clear_changed_registers {} {
+ set changed_registers [list]
+ }
+ }
+
+ proc enter_main_loop {} {
+ variable command_line
+ variable cmd_line_idx
+ variable simulator
+ variable line_counter 0
+ variable echo 0
+ variable error_reported
+
+ set simulator [SimEngineWrapper #auto]
+
+ namespace eval ::Simulator {
+ variable undefined_value 2
+ variable reverse_run_steps 100
+ }
+
+ namespace eval ::X {
+ variable critical_procedure_in_progress 0
+ }
+
+ puts "READY"
+
+ while {![eof stdin]} {
+ incr line_counter
+ set command_line [gets stdin]
+ set command_line [regsub {#.*$} $command_line {}]
+ set command_line [string trim $command_line]
+ set cmd_line_idx 1
+ set error_reported 0
+
+ if {[catch {
+ set command [string tolower [lindex $command_line 0]]
+ }]} then {
+ set tmp $command_line
+ set command_line {<unknown>}
+ abort_now "Unable to understand line: \"$tmp\""
+ }
+
+ # Do nothing with an empty line
+ if {![string length $command_line]} {
+ continue
+ }
+
+ if {$echo} {
+ puts "> $command_line"
+ }
+ if {[lsearch -ascii -exact {set-mcu echo-on echo-off} $command] == -1 && ![$simulator is_ready]} {
+ report_error "Processor type has to be specified first"
+ continue
+ }
+ if {[command_switch $command]} {
+ break
+ }
+
+ if {!$error_reported} {
+ puts "OK"
+ }
+ }
+ puts "EXITING"
+ }
+
+ proc command_switch {command} {
+ variable echo
+ switch -- $command {
+ {echo-on} {
+ expect_no_more_arguments
+ command__echo_on
+ }
+ {echo-off} {
+ expect_no_more_arguments
+ command__echo_off
+ }
+ {set-mcu} {
+ expect_string
+ expect_no_more_arguments
+
+ command__set_mcu
+ }
+ {set-clock} {
+ expect_integer 1 99999
+ expect_no_more_arguments
+
+ command__set_clock
+ }
+ {set-xcode} {
+ expect_integer 0 65536
+ expect_no_more_arguments
+
+ command__set_xcode
+ }
+ {set-xdata} {
+ expect_integer 0 65536
+ expect_no_more_arguments
+
+ command__set_xdata
+ }
+
+ {load-code} {
+ expect_no_more_arguments
+ command__load_code
+ }
+ {load-code-adf} {
+ expect_string
+ expect_no_more_arguments
+
+ command__load_code_adf
+ }
+ {load-code-cdb} {
+ expect_string
+ expect_string
+ expect_string
+ expect_no_more_arguments
+ command__load_code_cdb
+ }
+ {load-idata} {
+ expect_no_more_arguments
+ command__load_idata
+ }
+ {load-xdata} {
+ expect_no_more_arguments
+ command__load_xdata
+ }
+ {load-eeprom} {
+ expect_no_more_arguments
+ command__load_eeprom
+ }
+ {load-eram} {
+ expect_no_more_arguments
+ command__load_eram
+ }
+
+ {dump-code} {
+ expect_no_more_arguments
+ command__dump_code
+ }
+ {dump-idata} {
+ expect_no_more_arguments
+ command__dump_idata
+ }
+ {dump-xdata} {
+ expect_no_more_arguments
+ command__dump_xdata
+ }
+ {dump-eeprom} {
+ expect_no_more_arguments
+ command__dump_eeprom
+ }
+ {dump-eram} {
+ expect_no_more_arguments
+ command__dump_eram
+ }
+
+ {write-code} {
+ expect_integer 0 65536
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__write_code
+ }
+ {write-idata} {
+ expect_integer 0 256
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__write_idata
+ }
+ {write-xdata} {
+ expect_integer 0 65536
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__write_xdata
+ }
+ {write-eeprom} {
+ expect_integer 0 65536
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__write_eeprom
+ }
+ {write-eram} {
+ expect_integer 0 65536
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__write_eram
+ }
+ {write-sfr} {
+ expect_integer 128 256
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__write_sfr
+ }
+ {write-sfr} {
+ expect_string
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__write_sfr_by_name
+ }
+ {write-bit} {
+ expect_integer 0 256
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__write_bit
+ }
+
+ {read-code} {
+ expect_integer 0 65536
+ expect_no_more_arguments
+
+ command__read_code
+ }
+ {read-idata} {
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__read_idata
+ }
+ {read-xdata} {
+ expect_integer 0 65536
+ expect_no_more_arguments
+
+ command__read_xdata
+ }
+ {read-eeprom} {
+ expect_integer 0 65536
+ expect_no_more_arguments
+
+ command__read_eeprom
+ }
+ {read-eram} {
+ expect_integer 0 65536
+ expect_no_more_arguments
+
+ command__read_eram
+ }
+ {read-sfr} {
+ expect_integer 128 256
+ expect_no_more_arguments
+
+ command__read_sfr
+ }
+ {read-sfr-by-name} {
+ expect_string
+ expect_no_more_arguments
+
+ command__read_sfr_by_name
+ }
+ {read-bit} {
+ expect_integer 0 256
+ expect_no_more_arguments
+
+ command__read_bit
+ }
+
+ {step} {
+ expect_no_more_arguments
+ command__step
+ }
+ {step-back} {
+ expect_no_more_arguments
+ command__step_back
+ }
+
+ {list-changes} {
+ expect_no_more_arguments
+ command__list_changes
+ }
+ {read-pc} {
+ expect_no_more_arguments
+ command__read_pc
+ }
+ {write-pc} {
+ expect_integer 0 65536
+ expect_no_more_arguments
+
+ command__write_pc
+ }
+ {read-position} {
+ expect_no_more_arguments
+ command__read_position
+ }
+ {reset} {
+ expect_no_more_arguments
+ command__reset
+ }
+ {run} {
+ expect_no_more_arguments
+ command__run
+ }
+
+ {input} {
+ expect_integer 0 4
+ expect_no_more_arguments
+
+ command__input
+ }
+ {output} {
+ expect_integer 0 4
+ expect_no_more_arguments
+
+ command__output
+ }
+
+ {hibernate} {
+ expect_string
+ expect_no_more_arguments
+
+ command__hibernate
+ }
+ {resume} {
+ expect_string
+ expect_no_more_arguments
+
+ command__resume
+ }
+
+ {core-dump} {
+ expect_no_more_arguments
+ command__core_dump
+ }
+ {core-alter} {
+ expect_string
+ expect_no_more_arguments
+
+ command__core_alter
+ }
+
+ {exit} {
+ expect_no_more_arguments
+ return 1
+ }
+ default {
+ report_error "Unrecognised command: \"$command\""
+ }
+ }
+ return 0
+ }
+
+ proc abort_now {info} {
+ report_error $info
+ puts "ABORTING"
+ exit 1
+ }
+
+ proc report_error {info} {
+ variable error_reported
+ variable line_counter
+ variable command_line
+
+ set error_reported 1
+ puts stderr "ERROR (line: $line_counter; command: [lindex $command_line 0]): $info"
+ }
+
+ proc expect_no_more_arguments {} {
+ variable command_line
+ variable cmd_line_idx
+
+ if {[llength $command_line] > $cmd_line_idx} {
+ abort_now "Too many aguments given to to command [lindex $command_line 0]"
+ }
+ }
+
+ proc expect_string {{max_length {}}} {
+ variable command_line
+ variable cmd_line_idx
+
+ set arg [lindex $command_line $cmd_line_idx]
+ if {![string length $arg]} {
+ abort_now "Argument missing for command [lindex $command_line 0] at index $cmd_line_idx"
+ } elseif {$max_length != {} && [string length $arg] > $max_length} {
+ abort_now "Agrument given to command [lindex $command_line 0] at index $cmd_line_idx is too long, mimum allowed length is $max_length"
+ }
+ incr cmd_line_idx
+ }
+
+ proc expect_integer {{min {}} {max {}}} {
+ variable command_line
+ variable cmd_line_idx
+
+ set arg [lindex $command_line $cmd_line_idx]
+ if {![string is digit -strict $arg]} {
+ abort_now "Non integer agrument given to command [lindex $command_line 0] at index $cmd_line_idx"
+ } elseif {($min != {} && $arg < $min) || ($max != {} && $arg > $max)} {
+ abort_now "Integer agrument given to command [lindex $command_line 0] at index $cmd_line_idx is out of its allowed range \[$min;$max\]"
+ }
+ incr cmd_line_idx
+ }
+
+ proc load_hex {set_command memory_size} {
+ variable simulator
+
+ set hex_data {}
+
+ while {![eof stdin]} {
+ set line [gets stdin]
+ append hex_data $line "\n"
+
+ # Stop when EOF sequnce is found
+ if {[string range $line 7 8] == {01}} {
+ break
+ }
+ }
+
+ ::IHexTools::free_resources
+ ::IHexTools::load_hex_data $hex_data
+ if {${::IHexTools::error_count}} {
+ report_error ${::IHexTools::error_string}
+ return
+ }
+
+ if {${::IHexTools::highest_addr} >= $memory_size} {
+ report_error "You are attempting to load more data than the memory capacity allows. Capacity: $memory_size; Required: [expr {${::IHexTools::highest_addr} + 1}]"
+ }
+
+ set val {}
+ for {set i 0} {$i < ${::IHexTools::highest_addr}} {incr i} {
+ set val [::IHexTools::get_value $i]
+ if {$val == -1} {
+ set val {}
+ }
+ $simulator $set_command $i $val
+ }
+ for {} {$i < $memory_size} {incr i} {
+ $simulator $set_command $i {}
+ }
+ }
+
+ # ----------------------------------------------------------------------
+ # COMMANDS
+ # ----------------------------------------------------------------------
+
+ proc command__echo_on {} {
+ variable echo 1
+ }
+ proc command__echo_off {} {
+ variable echo 0
+ }
+ proc command__set_mcu {} {
+ variable simulator
+ variable command_line
+
+ set new_processor [string toupper [lindex $command_line 1]]
+
+ if {[lsearch -ascii -exact [SelectMCU::get_available_processors] $new_processor] == -1} {
+ abort_now "Unsupported processor: [lindex $command_line 1]"
+ }
+
+ $simulator configure -P_option_mcu_type $new_processor
+ set proc_data [SelectMCU::get_processor_details $new_processor]
+ if {$proc_data == {}} {
+ abort_now "Internal error"
+ }
+ $simulator configure -procData $proc_data
+
+ $simulator simulator_initialize_mcu
+ }
+ proc command__set_clock {} {
+ variable simulator
+ variable command_line
+
+ $simulator setEngineClock [lindex $command_line 1]
+ }
+ proc command__set_xcode {} {
+ variable simulator
+ variable command_line
+
+ set arg [lindex $command_line 1]
+
+ set icode [expr {[lindex [$simulator cget -procData] 2] * 1024}]
+ if {$arg > (0xFFFF - $icode)} {
+ abort_now "This MCU has CODE memory limit 0x10000 B (65536)"
+ }
+
+ if {[lindex [$simulator cget -procData] 1] != {yes}} {
+ abort_now "This MCU cannot have connected external program memory"
+ } else {
+ $simulator configure -P_option_mcu_xcode $arg
+ $simulator simulator_resize_code_memory $arg
+ }
+ }
+ proc command__set_xdata {} {
+ variable simulator
+ variable command_line
+
+ set arg [lindex $command_line 1]
+ if {[lindex [$simulator cget -procData] 0] != {yes}} {
+ abort_now "This MCU cannot have connected external data memory"
+ } else {
+ $simulator configure -P_option_mcu_xdata $arg
+ $simulator simulator_resize_xdata_memory $arg
+ }
+ }
+ proc command__reset {} {
+ variable simulator
+ $simulator master_reset -
+ }
+
+ proc command__load_code {} {
+ variable simulator
+ variable command_line
+
+ load_hex setCodeDEC [expr {[$simulator cget -P_option_mcu_xcode] + ([lindex [$simulator cget -procData] 2] * 1024)}]
+ }
+
+ proc command__load_code_adf {} {
+ variable simulator
+ variable command_line
+
+ if {[catch {
+ set file [open [lindex $command_line 1] {r}]
+ }]} then {
+ abort_now "Unable to open file: [lindex $command_line 1]"
+ }
+
+ $simulator load_program_from_adf $file
+ foreach filename [$simulator simulator_get_list_of_filenames] {
+ $simulator Simulator_import_breakpoints $filename [list]
+ }
+
+ catch {
+ close $file
+ }
+ }
+ proc command__load_code_cdb {} {
+ variable simulator
+ variable command_line
+
+ set filename [lindex $command_line 1]
+ set cdb_flnm [lindex $command_line 2]
+ set ihx_flnm [lindex $command_line 3]
+
+ set cdb_file {}
+ set ihx_file {}
+
+ if {![file exists $filename]} {
+ report_error "File does not exist: \"$filename\""
+ return
+ }
+
+ if {[catch {
+ set cdb_file [open $cdb_flnm {r}]
+ }]} then {
+ report_error "Cannot open file: \"$cdb_flnm\""
+ return
+ }
+ if {[catch {
+ set ihx_file [open $ihx_flnm {r}]
+ }]} then {
+ catch {close $cdb_file}
+ report_error "Cannot open file: \"$ihx_flnm\""
+ return
+ }
+
+ if {![$simulator load_program_from_cdb $filename $cdb_file $ihx_file]} {
+ report_error ${::IHexTools::error_string}
+ } else {
+ foreach filename [$simulator simulator_get_list_of_filenames] {
+ $simulator Simulator_import_breakpoints $filename [list]
+ }
+ }
+
+ catch {close $cdb_file}
+ catch {close $ihx_file}
+ }
+ proc command__load_idata {} {
+ variable simulator
+ variable command_line
+
+ load_hex setDataDEC [lindex [$simulator cget -procData] 3]
+ }
+ proc command__load_xdata {} {
+ variable simulator
+ variable command_line
+
+ load_hex setXdataDEC [$simulator cget -P_option_mcu_xdata]
+ }
+ proc command__load_eeprom {} {
+ variable simulator
+ variable command_line
+
+ load_hex setEepromDEC [lindex [$simulator cget -procData] 32]
+ }
+ proc command__load_eram {} {
+ variable simulator
+ variable command_line
+
+ load_hex setEramDEC [lindex [$simulator cget -procData] 8]
+ }
+ proc command__dump_code {} {
+ variable simulator
+ variable command_line
+
+ set capacity [expr {[$simulator cget -P_option_mcu_xcode] + ([lindex [$simulator cget -procData] 2] * 1024)}]
+ ::IHexTools::free_resources
+ for {set addr 0} {$addr < $capacity} {incr addr} {
+ ::IHexTools::content [$simulator getCode $addr]
+ }
+ puts -nonewline [::IHexTools::get_hex_data]
+ }
+ proc command__dump_idata {} {
+ variable simulator
+ variable command_line
+
+ set capacity [lindex [$simulator cget -procData] 3]
+ ::IHexTools::free_resources
+ for {set addr 0} {$addr < $capacity} {incr addr} {
+ ::IHexTools::content [$simulator getData $addr]
+ }
+ puts -nonewline [::IHexTools::get_hex_data]
+ }
+ proc command__dump_xdata {} {
+ variable simulator
+ variable command_line
+
+ set capacity [$simulator cget -P_option_mcu_xdata]
+ ::IHexTools::free_resources
+ for {set addr 0} {$addr < $capacity} {incr addr} {
+ ::IHexTools::content [$simulator getXdata $addr]
+ }
+ puts -nonewline [::IHexTools::get_hex_data]
+ }
+ proc command__dump_eeprom {} {
+ variable simulator
+ variable command_line
+
+ set capacity [lindex [$simulator cget -procData] 32]
+ ::IHexTools::free_resources
+ for {set addr 0} {$addr < $capacity} {incr addr} {
+ ::IHexTools::content [$simulator getEeprom $addr]
+ }
+ puts -nonewline [::IHexTools::get_hex_data]
+ }
+ proc command__dump_eram {} {
+ variable simulator
+ variable command_line
+
+ set capacity [lindex [$simulator cget -procData] 8]
+ ::IHexTools::free_resources
+ for {set addr 0} {$addr < $capacity} {incr addr} {
+ ::IHexTools::content [$simulator getEram $addr]
+ }
+ puts -nonewline [::IHexTools::get_hex_data]
+ }
+ proc command__write_code {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {![$simulator simulator_address_range C $addr]} {
+ report_error "Invalid address: $addr"
+ } else {
+ $simulator setCodeDEC $addr $val
+ }
+ }
+ proc command__write_idata {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {![$simulator simulator_address_range I $addr]} {
+ report_error "Invalid I-DATA address: $addr"
+ } else {
+ $simulator setDataDEC $addr $val
+ }
+ }
+ proc command__write_xdata {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {![$simulator simulator_address_range X $addr]} {
+ report_error "Invalid X-DATA address: $addr"
+ } else {
+ $simulator setXdataDEC $addr $val
+ }
+ }
+ proc command__write_eeprom {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {![$simulator simulator_address_range P $addr]} {
+ report_error "Invalid EEPROM address: $addr"
+ } else {
+ $simulator setEepromDEC $addr $val
+ }
+ }
+ proc command__write_eram {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {![$simulator simulator_address_range E $addr]} {
+ report_error "Invalid ERAM address: $addr"
+ } else {
+ $simulator setEramDEC $addr $val
+ }
+ }
+ proc command__write_sfr {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {![$simulator simulator_address_range S $addr]} {
+ report_error "Invalid SFR address: $addr"
+ } else {
+ if {$addr == $::Simulator_ENGINE::symbol(SBUFR)} {
+ set addr $::Simulator_ENGINE::symbol(SBUFT)
+ }
+ $simulator setSfrDEC $addr $val
+ }
+ }
+ proc command__write_sfr_by_name {} {
+ variable simulator
+ variable command_line
+
+ set name [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {[lsearch -ascii -exact [array names ::Simulator_ENGINE::symbol] [string toupper $name]] == -1} {
+ report_error "Invalid SFR name: $name"
+ } else {
+ set addr $::Simulator_ENGINE::symbol([string toupper $name])
+
+ if {![$simulator simulator_address_range S $addr]} {
+ report_error "Invalid SFR address: $addr"
+ } else {
+ if {$addr == $::Simulator_ENGINE::symbol(SBUFR)} {
+ set addr $::Simulator_ENGINE::symbol(SBUFT)
+ }
+ $simulator setSfrDEC $addr $val
+ }
+ }
+ }
+ proc command__write_bit {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {![$simulator simulator_address_range B $addr]} {
+ report_error "Invalid BIT address: $addr"
+ } else {
+ $simulator setBit $addr
+ }
+ }
+ proc command__read_code {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+
+ if {![$simulator simulator_address_range C $addr]} {
+ report_error "Invalid address: $addr"
+ } else {
+ puts [$simulator getCodeDEC $addr]
+ }
+ }
+ proc command__read_idata {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+
+ if {![$simulator simulator_address_range I $addr]} {
+ report_error "Invalid I-DATA address: $addr"
+ } else {
+ puts [$simulator getDataDEC $addr]
+ }
+ }
+ proc command__read_xdata {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+
+ if {![$simulator simulator_address_range X $addr]} {
+ report_error "Invalid X-DATA address: $addr"
+ } else {
+ puts [$simulator getXdataDEC $addr]
+ }
+ }
+ proc command__read_eeprom {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+
+ if {![$simulator simulator_address_range P $addr]} {
+ report_error "Invalid EEPROM address: $addr"
+ } else {
+ puts [$simulator getEepromDEC $addr]
+ }
+ }
+ proc command__read_eram {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+
+ if {![$simulator simulator_address_range E $addr]} {
+ report_error "Invalid ERAM address: $addr"
+ } else {
+ puts [$simulator getEramDEC $addr]
+ }
+ }
+ proc command__read_sfr {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+
+ if {![$simulator simulator_address_range S $addr]} {
+ report_error "Invalid SFR address: $addr"
+ } else {
+ puts [$simulator getSfrDEC $addr]
+ }
+ }
+ proc command__read_sfr_by_name {} {
+ variable simulator
+ variable command_line
+
+ set name [lindex $command_line 1]
+ set val [lindex $command_line 2]
+
+ if {[lsearch -ascii -exact [array names ::Simulator_ENGINE::symbol] [string toupper $name]] == -1} {
+ report_error "Invalid SFR name: $name"
+ } else {
+ set addr $::Simulator_ENGINE::symbol([string toupper $name])
+
+ if {![$simulator simulator_address_range S $addr]} {
+ report_error "Invalid SFR address: $addr"
+ } else {
+ puts [$simulator getSfrDEC $addr]
+ }
+ }
+ }
+ proc command__read_bit {} {
+ variable simulator
+ variable command_line
+
+ set addr [lindex $command_line 1]
+
+ if {![$simulator simulator_address_range B $addr]} {
+ report_error "Invalid BIT address: $addr"
+ } else {
+ puts [$simulator getBit $addr]
+ }
+ }
+ proc command__step {} {
+ variable simulator
+
+ $simulator clear_changed_registers
+ $simulator step
+ }
+ proc command__step_back {} {
+ variable simulator
+
+ $simulator clear_changed_registers
+ puts [$simulator stepback]
+ }
+ proc command__list_changes {} {
+ variable simulator
+ variable command_line
+
+ puts [$simulator get_changed_registers]
+ }
+ proc command__read_pc {} {
+ variable simulator
+
+ puts [$simulator getPC]
+ }
+ proc command__write_pc {} {
+ variable simulator
+ variable command_line
+
+ $simulator setPC [lindex $command_line 1]
+ }
+ proc command__read_position {} {
+ variable simulator
+ variable command_line
+
+ set pos [$simulator simulator_getCurrentLine]
+ puts "F: \"[$simulator simulator_get_filename [lindex $pos 1]]\""
+ puts "L: [lindex $pos 0]"
+ puts "V: [lindex $pos 2]"
+ puts "B: [lindex $pos 3]"
+ }
+ proc command__run {} {
+ variable simulator
+ $simulator sim_run
+ }
+ proc command__input {} {
+ variable simulator
+ variable command_line
+ # TODO: Complete it
+ }
+ proc command__output {} {
+ variable simulator
+ variable command_line
+ # TODO: Complete it
+ }
+ proc command__hibernate {} {
+ variable simulator
+ variable command_line
+ # TODO: Complete it
+ }
+ proc command__resume {} {
+ variable simulator
+ variable command_line
+ # TODO: Complete it
+ }
+ proc command__core_dump {} {
+ variable simulator
+ variable command_line
+ # TODO: Complete it
+ }
+ proc command__core_alter {} {
+ variable simulator
+ variable command_line
+ # TODO: Complete it
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/engine/engine_virtual_hw_controller.tcl b/lib/simulator/engine/engine_virtual_hw_controller.tcl
index a597e27..a13c9b9 100755..100644
--- a/lib/simulator/engine/engine_virtual_hw_controller.tcl
+++ b/lib/simulator/engine/engine_virtual_hw_controller.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 _ENGINE_VIRTUAL_HW_CONTROLLER_TCL ] } {
+set _ENGINE_VIRTUAL_HW_CONTROLLER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Part of simulator engine functionality.
@@ -39,9 +44,9 @@ private method instruction_cycle {} {
stepback_save_spec
# Execute instruction
- if {$DEBUG} {
+ if {${::DEBUG}} {
$code($pc)
- } {
+ } else {
if {[catch {
$code($pc)
} result]} then {
@@ -50,7 +55,10 @@ private method instruction_cycle {} {
internal_shutdown
incr_pc 1
}
- puts stderr $result
+ # OP code 165d is invalid on 8051
+ if {$code($pc) != 165} {
+ puts stderr ${::errorInfo}
+ }
}
}
@@ -100,9 +108,9 @@ private method instruction_cycle {} {
set rmw_instruction 1
set ports_previous_state [list]
for {set i 0; set addr 128} {$i < 5} {incr i; incr addr 16} {
- if {$feature_avaliable(p$i)} {
+ if {$feature_available(p$i)} {
lappend ports_previous_state $sfr($addr)
- } {
+ } else {
lappend ports_previous_state 0
}
}
@@ -112,7 +120,7 @@ private method instruction_cycle {} {
if {[$this pale_is_enabled]} {
if {$controllers_conf(CEN)} {
anlcmp_controller
- } {
+ } else {
set anlcmp_running 0
$this pale_SLSF $PIN(ANL0) 0
$this pale_SLSF $PIN(ANL1) 0
@@ -120,7 +128,7 @@ private method instruction_cycle {} {
}
# UART controller
- if {$feature_avaliable(uart)} {
+ if {$feature_available(uart)} {
if {($uart_RX_in_progress || $uart_TX_in_progress) && ${::Simulator::reverse_run_steps}} {
stepback_reg_change S $symbol(SBUFR)
stepback_reg_change S $symbol(SBUFT)
@@ -134,9 +142,9 @@ private method instruction_cycle {} {
set intx 1 ;# State of pin INTx
set ext_int 0 ;# Local external interrupt flag
- # Analyze port state
+ # Anylize port state
for {set i -$time} {$i < 0} {incr i} {
- # Determinate value of input pin INTx
+ # Determinate value of input pin INTX
set intx [$this pale_RRPPV $PIN(INT${int_src}) $i]
# Detect falling edge on INTx
@@ -149,7 +157,7 @@ private method instruction_cycle {} {
}
# Just copy inverted value from INTx to IEx
- } {
+ } else {
set ext_int [expr {!$intx}]
}
}
@@ -170,7 +178,7 @@ private method instruction_cycle {} {
if {!$pwm_running} {
set pwm_running 1
$this pale_SLSF $PIN(T1) 3
- } {
+ } else {
# Make backup for affected SFR
if {${::Simulator::reverse_run_steps}} {
stepback_reg_change S $symbol(TL0)
@@ -181,7 +189,7 @@ private method instruction_cycle {} {
# Timer 0 is forced into mode 2 (8-bit autoreload)
# TL1 is incremented after each T0 overflow
incr sfr($symbol(TL0)) $time
- while 1 {
+ while {1} {
if {$sfr($symbol(TL0)) > 255} {
set sfr($symbol(TL0)) [expr {$sfr($symbol(TL0)) - 256 + $sfr($symbol(TH0))}]
# Increment TL1
@@ -199,11 +207,11 @@ private method instruction_cycle {} {
set time_back [expr {256 - $sfr($symbol(TL0))}]
if {$time_back >= 0} {
$this pale_WPBBL $PIN(T1) 0
- } {
+ } else {
$this pale_WPBBL $PIN(T1) $time_back
}
}
- } {
+ } else {
break
}
}
@@ -241,7 +249,7 @@ private method instruction_cycle {} {
$this Simulator_GUI_sync S $symbol(TH0)
}
# Shutdown timer 0
- } {
+ } else {
set timer_0_running 0
}
@@ -263,7 +271,7 @@ private method instruction_cycle {} {
}
}
# Shutdown timer 1
- } {
+ } else {
set timer_1_running 0
}
@@ -282,7 +290,7 @@ private method instruction_cycle {} {
}
# Increment timer 2
- if {$feature_avaliable(t2)} {
+ if {$feature_available(t2)} {
if {$controllers_conf(TR2)} {
if {${::Simulator::reverse_run_steps}} {
stepback_reg_change S $symbol(TL2)
@@ -299,17 +307,21 @@ private method instruction_cycle {} {
$this Simulator_GUI_sync S $symbol(RCAP2H)
}
# Shutdown timer 2
- } {
+ } else {
set timer_2_running 0
}
}
# Manage interrupt monitor
- $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ if {$::GUI_AVAILABLE} {
+ $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags]
+ }
# Adjust stopwatch timer
incr run_statistics(3)
- $this stopwatch_refresh
+ if {$::GUI_AVAILABLE} {
+ $this stopwatch_refresh
+ }
# Manage stack for stepback stack
stepback_save_norm
@@ -343,7 +355,7 @@ private method anlcmp_controller {} {
set sample 1
}
# Normal mode (sample every S4)
- } {
+ } else {
set sample 1
}
# Sample port pins ANL0 and ANL1
@@ -418,7 +430,7 @@ private method timer_controller_2 {} {
}
# Timer 16-bit
- } {
+ } else {
set increment $time
}
@@ -431,11 +443,11 @@ private method timer_controller_2 {} {
# 16-bit timer
if {$timer_2_running && !$controllers_conf(CT2)} {
set increment [expr {$time * 6}]
- } {
+ } else {
set increment 0
}
if {[increment_timer2 $increment 1]} {
- while 1 {
+ while {1} {
set sfr($symbol(TH2)) $sfr($symbol(RCAP2H))
if {![increment_timer2 $sfr($symbol(RCAP2L)) 1]} {
break
@@ -444,7 +456,6 @@ private method timer_controller_2 {} {
}
# Detect transition on external input
- puts "set controllers_conf(T2) [expr {!$controllers_conf(T2)}]"
set controllers_conf(T2) [expr {!$controllers_conf(T2)}]
}
@@ -466,7 +477,7 @@ private method timer_controller_2 {} {
set increment [expr {$increment * 6}]
}
if {[increment_timer2 $increment 1]} {
- while 1 {
+ while {1} {
set sfr($symbol(TH2)) $sfr($symbol(RCAP2H))
if {![increment_timer2 $sfr($symbol(RCAP2L)) 1]} {
break
@@ -518,7 +529,7 @@ private method timer_controller_2 {} {
# Overflow
if {$result == 1} {
- while 1 {
+ while {1} {
set sfr($symbol(TH2)) $sfr($symbol(RCAP2H))
if {![increment_timer2 $sfr($symbol(RCAP2L)) $updown]} {
break
@@ -531,7 +542,7 @@ private method timer_controller_2 {} {
# Underflow
if {!$updown || $result == -1} {
- while 1 {
+ while {1} {
set cur_val [expr {$sfr($symbol(TL2)) + ($sfr($symbol(TH2)) << 8)}]
set min_val [expr {$sfr($symbol(RCAP2L)) + ($sfr($symbol(RCAP2H)) << 8)}]
@@ -559,7 +570,7 @@ private method timer_controller_2 {} {
# 16-bit Auto-reload (DCEN == 0)
} elseif {$timer_2_running} {
if {[increment_timer2 $increment 1]} {
- while 1 {
+ while {1} {
set sfr($symbol(TH2)) $sfr($symbol(RCAP2H))
if {![increment_timer2 $sfr($symbol(RCAP2L)) 1]} {
break
@@ -584,7 +595,7 @@ private method timer_controller_2 {} {
private method increment_timer2 {increment_by updown} {
if {$updown} {
incr sfr($symbol(TL2)) $increment_by
- } {
+ } else {
incr sfr($symbol(TL2)) -$increment_by
}
@@ -637,7 +648,7 @@ private method uart_start_transmission {} {
if {$controllers_conf(UART_M) == 0} {
$this pale_SLSF $PIN(TXD) 2
$this pale_SLSF $PIN(RXD) 1
- } {
+ } else {
$this pale_SLSF $PIN(TXD) 1
}
}
@@ -694,18 +705,18 @@ private method uart_controller {num} {
if {$controllers_conf(UART_M) == 2} {
if {$controllers_conf(SMOD)} {
incr uart_RX_clock [expr {$uart_clock_prescaler / 2}]
- } {
+ } else {
incr uart_RX_clock [expr {$uart_clock_prescaler / 4}]
}
- } {
+ } else {
# Timer 2 overflow
if {$controllers_conf(RCLK)} {
incr uart_RX_clock $timer2_overflow
# Timer 1 overflow
- } {
+ } else {
if {$controllers_conf(SMOD)} {
incr uart_RX_clock $timer1_overflow
- } {
+ } else {
incr uart_RX_clock [expr {$uart_clock_prescaler / 2}]
}
}
@@ -741,7 +752,7 @@ private method uart_controller {num} {
}
# Frame error detection
- if {$feature_avaliable(smod0) && !($uart_RX_shift_reg & 1)} {
+ if {$feature_available(smod0) && !($uart_RX_shift_reg & 1)} {
set controllers_conf(FE) 1
if {$sync_ena} {
$this Simulator_GUI_sync S $symbol(SCON)
@@ -758,7 +769,7 @@ private method uart_controller {num} {
setBit $symbol(RB8) [expr {$uart_RX_shift_reg & 2}]
set sfr($symbol(SBUFR)) [expr {($uart_RX_shift_reg & 0x3FC) >> 2}]
if {$controllers_conf(SM2)} {
- if {$feature_avaliable(euart)} {
+ if {$feature_available(euart)} {
# Check for broadcast address
if {$sfr($symbol(SBUFR)) == ($sfr($symbol(SADEN)) | $sfr($symbol(SADDR)))} {
setBit $symbol(RI) $controllers_conf(RB8)
@@ -766,15 +777,15 @@ private method uart_controller {num} {
} elseif {($sfr($symbol(SBUFR)) & $sfr($symbol(SADEN))) == ($sfr($symbol(SADDR)) & $sfr($symbol(SADEN)))} {
setBit $symbol(RI) $controllers_conf(RB8)
}
- } {
+ } else {
setBit $symbol(RI) $controllers_conf(RB8)
}
- } {
+ } else {
setBit $symbol(RI) 1
}
# Frame error
- if {$feature_avaliable(smod0) && !($uart_RX_shift_reg & 1)} {
+ if {$feature_available(smod0) && !($uart_RX_shift_reg & 1)} {
set controllers_conf(FE) 1
if {$sync_ena} {
$this Simulator_GUI_sync S $symbol(SCON)
@@ -801,7 +812,7 @@ private method uart_controller {num} {
set uart_RX_shift_reg 0x1FE
}
# Mode 1, 2, 3 - Start bit starts reception
- } {
+ } else {
if {![$this pale_RRPPV $PIN(RXD)]} {
set uart_RX_clock 0
set uart_RX_in_progress 1
@@ -845,7 +856,7 @@ private method uart_controller {num} {
incr i
$this pale_WPBBL $PIN(RXD) $bit_to_send $i
$this pale_WPBBL $PIN(TXD) 1 $i
- } {
+ } else {
incr i
$this pale_WPBBL $PIN(TXD) {|} [expr {int($i / 2)}]
$this pale_WPBBL $PIN(RXD) $bit_to_send [expr {int($i / 2)}]
@@ -874,18 +885,18 @@ private method uart_controller {num} {
if {$controllers_conf(UART_M) == 2} {
if {$controllers_conf(SMOD)} {
incr uart_TX_clock [expr {$uart_clock_prescaler / 2}]
- } {
+ } else {
incr uart_TX_clock [expr {$uart_clock_prescaler / 4}]
}
- } {
+ } else {
# Timer 2 overflow
if {$controllers_conf(TCLK)} {
incr uart_TX_clock $timer2_overflow
# Timer 1 overflow
- } {
+ } else {
if {$controllers_conf(SMOD)} {
incr uart_TX_clock $timer1_overflow
- } {
+ } else {
incr uart_TX_clock [expr {$uart_clock_prescaler / 2}]
}
}
@@ -920,7 +931,7 @@ private method uart_controller {num} {
if {$uart_clock_prescaler && $controllers_conf(UART_M)} {
if {$controllers_conf(SMOD)} {
set uart_clock_prescaler [expr {$uart_clock_prescaler % 2}]
- } {
+ } else {
set uart_clock_prescaler [expr {$uart_clock_prescaler % 4}]
}
}
@@ -960,11 +971,11 @@ private method special_timer1_controller_T0_MOD_3 {} {
}
2 { ;# Mode 2 - 8 bit auto-reload counter
incr sfr($TL1) $time
- while 1 {
+ while {1} {
if {$sfr($TL1) > 255} {
set sfr($TL1) [expr {$sfr($TL1) - 256 + $sfr($TH1)}]
incr timer1_overflow
- } {
+ } else {
break
}
}
@@ -988,7 +999,7 @@ private method timer_controller_01 {timer_num} {
set timer_1_running 1
return
}
- } {
+ } else {
if {!$timer_0_running} {
set timer_0_running 1
return
@@ -1014,7 +1025,7 @@ private method timer_controller_01 {timer_num} {
set increment 0
}
}
- } {
+ } else {
set increment $time
# Trigered timer
@@ -1036,7 +1047,7 @@ private method timer_controller_01 {timer_num} {
setBit $symbol(TF1) 1
}
# Increment TL0
- } {
+ } else {
incr sfr($symbol(TL0)) $increment
if {$sfr($symbol(TL0)) > 255} {
set sfr($symbol(TL0)) [expr {$sfr($symbol(TL0)) - 256}]
@@ -1088,14 +1099,14 @@ private method timer_controller_01 {timer_num} {
}
2 { ;# Mode 2 - 8 bit auto-reload counter
incr sfr($TL_addr) $increment
- while 1 {
+ while {1} {
if {$sfr($TL_addr) > 255} {
set sfr($TL_addr) [expr {$sfr($TL_addr) - 256 + $sfr($TH_addr)}]
setBit $symbol(TF${timer_num}) 1
if {$timer_num} {
incr timer1_overflow
}
- } {
+ } else {
break
}
}
@@ -1118,7 +1129,7 @@ private method eeprom_controller {num} {
internal_shutdown
}
- # Fill incomplite bytes with random values
+ # Fill incomplete bytes with random values
set eeprom_prev_new [list]
foreach reg $eeprom_prev {
lappend eeprom_prev_new [lindex $reg 0] [undefined_octet]
@@ -1177,7 +1188,7 @@ private method watchdog_controller {} {
}
if {$controllers_conf(WDTEN)} {
set sfr(167) [expr {$sfr(167) | 1}]
- } {
+ } else {
set sfr(167) [expr {$sfr(167) - 1}]
}
if {$sync_ena} {
@@ -1194,15 +1205,15 @@ private method watchdog_controller {} {
set increment 0
if {$controllers_conf(WatchDogPrescaler)} {
incr wdt_prescaler_val $time
- while 1 {
+ while {1} {
if {$wdt_prescaler_val >= $controllers_conf(WatchDogPrescaler)} {
incr wdt_prescaler_val -$controllers_conf(WatchDogPrescaler)
incr increment
- } {
+ } else {
break
}
}
- } {
+ } else {
set increment $time
}
@@ -1285,7 +1296,9 @@ private method interrupt_handler {IntName vector flag_bit immediately} {
lappend inter_in_p_flags $flag_bit ;# List: Interrupt flags of interrupts which are in progress
# Adjust status bar
- simulator_Sbar [mc "Interrupt PC: 0x%s; line: %s; vector 0x%s " [format %X $pc] [lindex $Line($pc) 0] [format %X $vector]] 1 $this
+ if {$::GUI_AVAILABLE} {
+ simulator_Sbar [mc "Interrupt PC: 0x%s; line: %s; vector 0x%s " [format %X $pc] [lindex $Line($pc) 0] [format %X $vector]] 1 $this
+ }
$this pale_interrupt $vector
# Invoke LCALL to interrupt vector
@@ -1378,14 +1391,14 @@ private method isInterruptActive {IntName} {
}
{PS} { ;# UART & SPI
if {!$controllers_conf(ES)} {return 0}
- if {$feature_avaliable(uart)} {
+ if {$feature_available(uart)} {
if {$controllers_conf(TI)} {
return {35 TI}
} elseif {$controllers_conf(RI)} {
return {35 RI}
}
}
- if {$feature_avaliable(spi) && $controllers_conf(SPIE) && $controllers_conf(SPIF)} {
+ if {$feature_available(spi) && $controllers_conf(SPIE) && $controllers_conf(SPIF)} {
return {35 SPIE}
}
}
@@ -1411,3 +1424,7 @@ private method isInterruptActive {IntName} {
}
return 0
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/hibernate.tcl b/lib/simulator/hibernate.tcl
index c35f4f8..0cd090e 100755..100644
--- a/lib/simulator/hibernate.tcl
+++ b/lib/simulator/hibernate.tcl
@@ -2,7 +2,7 @@
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2007-2009 by Martin Ošmera #
+# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
# This program is free software; you can redistribute it and#or modify #
@@ -21,6 +21,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _HIBERNATE_TCL ] } {
+set _HIBERNATE_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Provides program hibernation capability. It ohter words it can save
@@ -59,16 +64,21 @@ class Hibernate {
common mcu_variable ;# Bool: Checkbox variable for "Different processor"
common xdata_variable ;# Int: RadioButton variable for "Different XDATA size"
common md5_variable ;# Bool: Checkbox variable for "Different MD5 hash"
- # Big font for dialog "Program resumption"
- common big_font [font create \
- -family {helvetica} \
- -weight bold -size -35 \
- ]
- # Normal font for dialog "Program resumption"
- common text_font [font create \
- -family {helvetica} \
- -weight bold -size -14 \
- ]
+
+ if {$::GUI_AVAILABLE} {
+ # Big font for dialog "Program resumption"
+ common big_font [font create \
+ -family {helvetica} \
+ -weight bold \
+ -size [expr {int(-35 * $::font_size_factor)}] \
+ ]
+ # Normal font for dialog "Program resumption"
+ common text_font [font create \
+ -family {helvetica} \
+ -weight bold \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ ]
+ }
## PRIVATE
private variable parser ;# Object: Reference to active XML parser
@@ -102,7 +112,7 @@ class Hibernate {
}
if {$for_what == {data}} {
$mem_prg_bar configure -maximum $value
- } {
+ } else {
$stb_prg_bar configure -maximum $value
}
}
@@ -128,15 +138,16 @@ class Hibernate {
}
# Create dialog window
- set win [toplevel .hibernation_progress_dialog -class {Progress dialog} -bg {#EEEEEE}]
+ set win [toplevel .hibernation_progress_dialog -class {Progress dialog} -bg ${::COMMON_BG_COLOR}]
# Create dialog header
- pack [label $win.header \
- -text $header \
- -font [font create \
- -size -17 -weight {bold} \
- -family {helvetica} \
- ] \
+ pack [label $win.header \
+ -text $header \
+ -font [font create \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight {bold} \
+ -family {helvetica} \
+ ] \
] -fill x
# Create progress bar "Memory"
@@ -167,7 +178,7 @@ class Hibernate {
-compound left \
-image ::ICONS::16::button_cancel \
-command {set ::Hibernate::hib_abort 1} \
- ] -padx 10 -fill x
+ ] -pady 5
# Configure dialog window
wm iconphoto $win ::ICONS::16::bar5
@@ -191,15 +202,15 @@ class Hibernate {
public method hibernate_hibernate {filename sourcefile md5 exclude_stepback} {
# Try to open the destination file
if {[catch {
- set file [open $filename w 420]
- }]} {
+ set file [open $filename w 0640]
+ }]} then {
return 0
}
# Determinate depth of stepback stack and size of XDATA memory
if {$exclude_stepback} {
set stacklength 0
- } {
+ } else {
set stacklength [$this simulator_get_SBS_len]
}
set xdata_size [$this cget -P_option_mcu_xdata]
@@ -217,18 +228,18 @@ class Hibernate {
puts -nonewline $file "\tThis is MCU 8051 IDE hibernation data file.\n"
puts -nonewline $file "\tIt does not contain program code, only data.\n\n"
puts -nonewline $file "\tPLEASE DO NOT EDIT THIS FILE MANUALY, BECAUSE\n"
- puts -nonewline $file "\tBAD FORMATING OF THIS FILE WILL LEAD MCU 8051 IDE TO CRASH !\n"
+ puts -nonewline $file "\tBAD FORMATTING OF THIS FILE WILL LEAD MCU 8051 IDE TO CRASH !\n"
puts -nonewline $file "-->\n"
# Write DTD (Document Type Declaration) to the destination file
- if {[file exists "${::LIB_DIRNAME}/../data/m5ihib.dtd"]} {
+ if {[file exists "${::ROOT_DIRNAME}/data/m5ihib.dtd"]} {
if {[catch {
- set dtd [open "${::LIB_DIRNAME}/../data/m5ihib.dtd" r]
- }]} {
+ set dtd [open "${::ROOT_DIRNAME}/data/m5ihib.dtd" r]
+ }]} then {
puts stderr "Unable to open m5ihib.dtd, please check your installation."
} else {
puts -nonewline $file "<!DOCTYPE m5ihib \[\n\n"
- while 1 {
+ while {1} {
if {[eof $dtd]} {
close $dtd
break
@@ -333,7 +344,7 @@ class Hibernate {
# Special function registers
puts -nonewline $file "\t\t<sfr>\n"
puts -nonewline $file "\t\t\t<addresses>\n\t\t\t\t"
- set sfr [$this simulator_get_avaliable_sfr]
+ set sfr [$this simulator_get_available_sfr]
set j 0
foreach addr $sfr {
if {$j > 6} {
@@ -366,7 +377,7 @@ class Hibernate {
## Write content of list of active interrupts
puts -nonewline $file "\t<subprograms count=\"[$this subprograms_get_count]\">\n"
- foreach sub [$this subprograms_get_formated_content] {
+ foreach sub [$this subprograms_get_formatted_content] {
set source [lindex $sub 0]
set target [lindex $sub 1]
set type [lindex $sub 2]
@@ -414,7 +425,7 @@ class Hibernate {
hibernate_close_progress_dialog
if {[catch {close $file}]} {
return 0
- } {
+ } else {
return 1
}
}
@@ -442,12 +453,12 @@ class Hibernate {
# Open hibernation data file
if {[catch {
set file [open $filename {r}]
- }]} {
+ }]} then {
return 1
}
# Show progress dialog
- show_progress_dialog {Resuming hibernated program} 1 1
+ show_progress_dialog [mc "Resuming hibernated program"] 1 1
# Create XML parser object
if {[catch {
@@ -455,12 +466,12 @@ class Hibernate {
-elementstartcommand [list $this hibernate_xml_parser_element] \
-characterdatacommand [list $this hibernate_xml_parser_data] \
]
- }]} {
+ }]} then {
hibernate_close_progress_dialog
tk_messageBox \
-type ok -icon error -parent . \
-title "::xml::parser error" \
- -message "Unknown error occured in XML parser library,\nplease try to reinstall package \"tdom\"."
+ -message "Unknown error occurred in XML parser library,\nplease try to reinstall package \"tdom\"."
return 2
}
@@ -485,7 +496,7 @@ class Hibernate {
# Close the file and free the parser
if {[catch {
close $file
- }]} {
+ }]} then {
set exit_code 1
}
catch {
@@ -500,13 +511,13 @@ class Hibernate {
set interrupts_in_progress [$this simulator_get_interrupts_in_progress_pb]
if {[llength $interrupts_in_progress]} {
simulator_Sbar [mc "Interrupt at vector 0x%s " [format %X [$this intr2vector [lindex $interrupts_in_progress end]]]] 1 $this
- } {
+ } else {
simulator_Sbar {} 0 $this
}
set lineNum [$this simulator_getCurrentLine]
if {$lineNum != {}} {
$this move_simulator_line $lineNum
- } {
+ } else {
$this editor_procedure {} unset_simulator_line {}
}
::X::stepback_button_set_ena [$this simulator_get_SBS_len]
@@ -663,7 +674,7 @@ class Hibernate {
}
if {$source != {} && $target != {} && $type != {}} {
$this subprograms_call $type $source $target
- } {
+ } else {
error "Invalid argument set in tag <step>"
}
}
@@ -680,7 +691,7 @@ class Hibernate {
$this simulator_set_SBS_len $stacklength
progress_dialog_set_max stepback [expr {$stacklength / 10}]
break
- } {
+ } else {
incr i
}
}
@@ -861,7 +872,7 @@ class Hibernate {
set xdata_variable 1
set md5_variable 1
- set win [toplevel .hibernation_bad_file_dialog -class {Error dialog} -bg {#EEEEEE}]
+ set win [toplevel .hibernation_bad_file_dialog -class {Error dialog} -bg ${::COMMON_BG_COLOR}]
set dlg_result 1
set dlg_bits $differences
@@ -931,13 +942,13 @@ class Hibernate {
-compound left \
-image ::ICONS::16::ok \
]
- pack $dlg_ok_but -side left
+ pack $dlg_ok_but -side left -padx 2
pack [ttk::button $button_frame.button_cancel \
-text [mc "Cancel"] \
-command "$this hibernation_cls_dlg 1" \
-compound left \
-image ::ICONS::16::button_cancel \
- ] -side left
+ ] -side left -padx 2
pack $button_frame -side bottom -anchor e -padx 10 -pady 5
# Configure dialog window
@@ -980,7 +991,7 @@ class Hibernate {
# Create text widget for the given message
set text_wdg [text $right_frame.top_text \
-width 0 -height 3 -wrap word -bd 0 \
- -relief flat -bg {#EEEEEE} \
+ -relief flat -bg ${::COMMON_BG_COLOR} \
-font $text_font -cursor left_ptr \
]
$text_wdg insert end $text
@@ -1004,7 +1015,7 @@ class Hibernate {
public method hibernation_chbut_rabut_command {} {
if {$file_variable && $mcu_variable && $xdata_variable && $md5_variable} {
$dlg_ok_but configure -state normal
- } {
+ } else {
$dlg_ok_but configure -state disabled
}
}
@@ -1027,7 +1038,7 @@ class Hibernate {
$this configure -P_option_mcu_xdata $xdata_size
::X::close_hexedit xdata $this
$this simulator_resize_xdata_memory $xdata_size
- } {
+ } else {
set xdata_size 0
}
@@ -1049,3 +1060,7 @@ class Hibernate {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/interruptmonitor.tcl b/lib/simulator/interruptmonitor.tcl
index 5156382..510b070 100755..100644
--- a/lib/simulator/interruptmonitor.tcl
+++ b/lib/simulator/interruptmonitor.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 _INTERRUPTMONITOR_TCL ] } {
+set _INTERRUPTMONITOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements interrupt monitor
@@ -29,33 +34,37 @@
class InterruptMonitor {
## COMMON
common geometry ${::CONFIG(INTR_MON_GEOMETRY)} ;# Last window geometry
- common count 0 ;# Counter of intances
+ common intr_mon_count 0 ;# Counter of intances
common bg_color {#0088FF} ;# Color for highlighted background
# Small header font
- common header_font [font create \
- -size -17 -weight bold \
- -family {helvetica} \
+ common header_font [font create \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica} \
]
# Big header font
- common header_font_big [font create \
- -size -21 -weight bold \
- -family {helvetica} \
+ common header_font_big [font create \
+ -size [expr {int(-21 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica} \
]
# Common label font
- common lbl_font [font create \
- -size -12 \
- -family {helvetica} \
+ common lbl_font [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family {helvetica} \
]
# Font for value labels
- common val_font [font create \
- -size -12 -weight bold \
- -family {helvetica} \
+ common val_font [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica} \
]
# Font for value labels - underline
- common val_font_under [font create \
- -size -12 -weight bold \
- -family {helvetica} \
- -underline 1 \
+ common val_font_under [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
+ -family {helvetica} \
+ -underline 1 \
]
@@ -74,7 +83,7 @@ class InterruptMonitor {
private variable in_progress_flg {} ;# List: Flags of interrupts which are in progress
private variable intr_priorities {} ;# List: Interrupt flags in order of their priorities (decremental)
private variable pending_flg {} ;# List: Flags of pending interrupts
- private variable avaliable_interrs {} ;# List: Avaliable interrupt flags
+ private variable available_interrs {} ;# List: available interrupt flags
private variable maximum_priority 0 ;# Int: Maximum valid priority
@@ -106,7 +115,7 @@ class InterruptMonitor {
set in_progress_flg {}
set pending_flg {}
set intr_priorities {}
- set avaliable_interrs {}
+ set available_interrs {}
if {[winfo exists $win]} {
destroy $win
@@ -120,22 +129,22 @@ class InterruptMonitor {
set dialog_opened 1
# Create dialog window, main frame and status bar
- set win [toplevel .interrupt_monitor$count -class {Interrupt monitor} -bg {#EEEEEE}]
- incr count
+ set win [toplevel .interrupt_monitor${intr_mon_count} -class {Interrupt monitor} -bg ${::COMMON_BG_COLOR}]
+ incr intr_mon_count
set main_frame [frame $win.main_frame]
set status_bar [label $win.status_bar]
# Create scrollable frames
set in_progress_frame_f [ScrollableFrame $main_frame.in_p \
- -width 300 -areawidth 300 \
+ -width 280 -areawidth 280 \
-yscrollcommand "$main_frame.in_p_scrl set" \
]
set pending_frame_f [ScrollableFrame $main_frame.pending \
- -width 230 -areawidth 230 \
+ -width 250 -areawidth 250 \
-yscrollcommand "$main_frame.pend_scrl set" \
]
set priorities_frame_f [ScrollableFrame $main_frame.prior \
- -width 230 -areawidth 230 \
+ -width 250 -areawidth 250 \
-yscrollcommand "$main_frame.prior_scrl set" \
]
@@ -144,11 +153,11 @@ class InterruptMonitor {
set top_frame_1 [frame $main_frame.top_frame_1]
set top_frame_2 [frame $main_frame.top_frame_2]
foreach num {0 1 2} text {
- {Interrupts in progress}
- {Pending interrupts}
- {Interrupt priorities}
+ "Interrupts in progress"
+ "Pending interrupts"
+ "Interrupt priorities"
} {
- set frame [subst "\$top_frame_${num}"]
+ set frame [subst -nocommands "\$top_frame_${num}"]
pack [ttk::button $frame.expand \
-image ::ICONS::16::add \
-style Flat.TButton \
@@ -163,7 +172,7 @@ class InterruptMonitor {
set_status_tip $frame.collapse [mc "Collapse all"]
pack [label $frame.in_p_lbl \
-font $header_font \
- -text $text \
+ -text [mc $text] \
] -side left -fill x -expand 1
}
@@ -203,7 +212,7 @@ class InterruptMonitor {
# Fill GUI
set maximum_priority [$this simulator_get_max_intr_priority]
- interrupt_monitor_set_avaliable [$this simulator_get_intr_flags]
+ interrupt_monitor_set_available [$this simulator_get_intr_flags]
interrupt_monitor_reevaluate
# Pack main frame and create bottom frame
@@ -217,17 +226,18 @@ class InterruptMonitor {
-command "$this interrupt_monitor_close" \
-image ::ICONS::16::button_cancel \
] -side right -pady 5 -padx 10
- set_status_tip $win.close_but {Close this dialog window}
+ set_status_tip $win.close_but [mc "Close this dialog window"]
# Set window attributes
wm iconphoto $win ::ICONS::16::kcmdf
- wm title $win "[mc {Interrupt monitor}] - [string trim $this {:}] - MCU 8051 IDE"
- wm minsize $win 840 270
+ wm title $win "[mc {Interrupt monitor}] - [$this cget -projectName] - MCU 8051 IDE"
+ wm minsize $win 850 270
if {$geometry != {}} {
+ regsub {\+\d+\+} $geometry {+850+} geometry
wm geometry $win $geometry
}
wm resizable $win 0 1
- wm protocol $win WM_DELETE_WINDOW "$this interrupt_monitor_close"
+ wm protocol $win WM_DELETE_WINDOW [list $this interrupt_monitor_close]
bindtags $win [list $win Toplevel all .]
}
@@ -256,7 +266,7 @@ class InterruptMonitor {
# Enable/Disabled buttons "Invoke this interrupt"
set state [expr {([$this is_frozen]) ? "normal" : "disabled"}]
- foreach flag $avaliable_interrs {
+ foreach flag $available_interrs {
$priorities_frame.[string tolower $flag].secondary.exec_but configure -state $state
}
@@ -291,8 +301,8 @@ class InterruptMonitor {
set in_progress_wdg {}
set in_progress_flg {}
set pending_flg {}
- set intr_priorities $avaliable_interrs
- foreach flag $avaliable_interrs {
+ set intr_priorities $available_interrs
+ foreach flag $available_interrs {
set flag [string tolower $flag]
$priorities_frame.$flag.secondary.exec_but configure -state normal
}
@@ -342,18 +352,18 @@ class InterruptMonitor {
public method interrupt_monitor_collapse_expand {widget} {
if {[winfo ismapped $widget]} {
pack forget $widget
- } {
+ } else {
pack $widget -fill both -padx 2 -pady 2
}
update
}
- ## Set avaliable interrupt flags
+ ## Set available interrupt flags
# @parm List flags - Interrupt flags (e.g. {TF2 CF RI IE0})
# @return void
- private method interrupt_monitor_set_avaliable {flags} {
- # Set avaliable interrupts
- set avaliable_interrs $flags
+ private method interrupt_monitor_set_available {flags} {
+ # Set available interrupts
+ set available_interrs $flags
# Create sub windows in frame "Priorities"
foreach flag_bit $flags {
@@ -374,7 +384,7 @@ class InterruptMonitor {
pack [label $secondary_frame.name \
-text [lindex $intr 3] -pady 0 \
-bg $bg_color -fg white \
- -cursor hand1 -anchor w \
+ -cursor hand2 -anchor w \
] -side left -anchor w -fill x -expand 1
bind $secondary_frame.name <Button-1> \
"$this interrupt_monitor_collapse_expand $primary_frame.tertiary"
@@ -405,7 +415,7 @@ class InterruptMonitor {
set row 2
set col 0
set pri_bits [lindex $intr 2]
- if {[$this get_feature_avaliable iph]} {
+ if {[$this get_feature_available iph]} {
set pri_bits [linsert $pri_bits 0 "[lindex $intr 2]H"]
}
foreach lbl {
@@ -441,7 +451,7 @@ class InterruptMonitor {
e_bit -
p_bit -
f_bit {
- set cursor {hand1}
+ set cursor {hand2}
set is_bit 1
}
}
@@ -514,11 +524,11 @@ class InterruptMonitor {
}
# Adjust value of priority level in each subwindow
- foreach flag_bit $avaliable_interrs {
+ foreach flag_bit $available_interrs {
set pri__clr [get_priority_and_color $flag_bit]
set pri_bits [lindex [get_interrupt_details $flag_bit] 2]
set flag_bit [string tolower $flag_bit]
- if {[$this get_feature_avaliable iph]} {
+ if {[$this get_feature_available iph]} {
lappend pri_bits "${pri_bits}H"
}
@@ -529,14 +539,14 @@ class InterruptMonitor {
if {[lindex $pri__clr 0] == $maximum_priority} {
$priorities_frame.$flag_bit.secondary.up_but \
configure -state disabled
- } {
+ } else {
$priorities_frame.$flag_bit.secondary.up_but \
configure -state normal
}
if {[lindex $pri__clr 0]} {
$priorities_frame.$flag_bit.secondary.down_but \
configure -state normal
- } {
+ } else {
$priorities_frame.$flag_bit.secondary.down_but \
configure -state disabled
}
@@ -556,7 +566,7 @@ class InterruptMonitor {
# Determinate new color
if {[intr_mon_getBit $pri_bit]} {
set color $::Simulator_GUI::on_color
- } {
+ } else {
set color $::Simulator_GUI::off_color
}
@@ -610,7 +620,7 @@ class InterruptMonitor {
foreach flag $new_flag {
if {[winfo exists $pending_frame.[string tolower $flag]]} {
pack forget $pending_frame.[string tolower $flag]
- } {
+ } else {
create_pending_interrupt $flag
}
}
@@ -626,11 +636,11 @@ class InterruptMonitor {
}
# Adjust colors of flag bits
- foreach flag_bit $avaliable_interrs {
+ foreach flag_bit $available_interrs {
# Determinate new color
if {[intr_mon_getBit $flag_bit]} {
set color $::Simulator_GUI::on_color
- } {
+ } else {
set color $::Simulator_GUI::off_color
}
set flag [string tolower $flag_bit]
@@ -654,13 +664,13 @@ class InterruptMonitor {
if {!$dialog_opened} {return}
# Adjust colors of flag bits
- foreach flag_bit $avaliable_interrs {
+ foreach flag_bit $available_interrs {
set ena_bit [lindex [get_interrupt_details $flag_bit] 1]
# Determinate new color
if {[intr_mon_getBit $ena_bit]} {
set color $::Simulator_GUI::on_color
- } {
+ } else {
set color $::Simulator_GUI::off_color
}
@@ -709,7 +719,7 @@ class InterruptMonitor {
pack [label $secondary_frame.name \
-text [lindex $intr 3] -pady 0 \
-bg $bg_color -fg white \
- -cursor hand1 -anchor w \
+ -cursor hand2 -anchor w \
] -side left -anchor w -fill x -padx 3 -expand 1
bind $secondary_frame.name <Button-1> \
"$this interrupt_monitor_collapse_expand $primary_frame.tertiary"
@@ -725,7 +735,7 @@ class InterruptMonitor {
set tertiary_frame [frame $primary_frame.tertiary -bg {#FFFFFF}]
# Priority:
grid [label $tertiary_frame.priority_lbl \
- -pady 0 -text "Priority:" \
+ -pady 0 -text [mc "Priority:"] \
-bg white -font $lbl_font \
] -sticky w -pady 0 -row 0 -column 0
set pri__clr [get_priority_and_color $flag_bit]
@@ -742,7 +752,7 @@ class InterruptMonitor {
set row 2
set col 0
set pri_bits [lindex $intr 2]
- if {[$this get_feature_avaliable iph]} {
+ if {[$this get_feature_available iph]} {
set pri_bits [linsert $pri_bits 0 "[lindex $intr 2]H"]
}
foreach lbl {
@@ -778,7 +788,7 @@ class InterruptMonitor {
e_bit -
p_bit -
f_bit {
- set cursor {hand1}
+ set cursor {hand2}
set is_bit 1
}
}
@@ -864,7 +874,7 @@ class InterruptMonitor {
pack [label $secondary_frame.name \
-text [lindex $intr 3] -pady 0 \
-bg $bg_color -fg white \
- -cursor hand1 -anchor w \
+ -cursor hand2 -anchor w \
] -side left -anchor w -fill x -padx 3 -expand 1
bind $secondary_frame.name <Button-1> \
"$this interrupt_monitor_collapse_expand $primary_frame.tertiary"
@@ -880,7 +890,7 @@ class InterruptMonitor {
set tertiary_frame [frame $primary_frame.tertiary -bg {#FFFFFF}]
# Priority
grid [label $tertiary_frame.priority_lbl \
- -pady 0 -text "Priority:" \
+ -pady 0 -text [mc "Priority:"] \
-bg white -font $lbl_font \
] -sticky w -pady 0 -row 0 -column 0
set pri__clr [get_priority_and_color $flag_bit]
@@ -897,7 +907,7 @@ class InterruptMonitor {
# Vector, Flag bit, Enable bit, Priority bits
set row 2
set pri_bits [lindex $intr 2]
- if {[$this get_feature_avaliable iph]} {
+ if {[$this get_feature_available iph]} {
set pri_bits [linsert $pri_bits 0 "[lindex $intr 2]H"]
}
foreach lbl {
@@ -932,7 +942,7 @@ class InterruptMonitor {
e_bit -
p_bit -
f_bit {
- set cursor {hand1}
+ set cursor {hand2}
set is_bit 1
}
}
@@ -977,13 +987,13 @@ class InterruptMonitor {
# Invoked from:
set row 2
grid [label $tertiary_frame.lbl__$row \
- -text {Invoked from:} -pady 0 \
+ -text [mc "Invoked from:"] -pady 0 \
-bg white -font $lbl_font \
] -sticky w -row $row -column 3 -pady 0 -columnspan 2
incr row
# PC:
grid [label $tertiary_frame.lbl__$row \
- -pady 0 -text { PC:} \
+ -pady 0 -text [mc " PC:"] \
-bg white -font $lbl_font \
] -sticky w -row $row -column 3 -pady 0
grid [label $tertiary_frame.val__$row \
@@ -993,13 +1003,13 @@ class InterruptMonitor {
incr row
# File:
grid [label $tertiary_frame.lbl__$row \
- -pady 0 -text [mc { File:}] \
+ -pady 0 -text [mc " File:"] \
-bg white -font $lbl_font \
] -sticky w -row $row -column 3 -pady 0
set filename [$this filelist_get_simulator_editor_obj]
if {$filename != {}} {
set filename [$filename cget -fullFileName]
- } {
+ } else {
set filename [lindex [$this simulator_get_list_of_filenames] 0]
}
grid [label $tertiary_frame.val__$row \
@@ -1009,7 +1019,7 @@ class InterruptMonitor {
incr row
# Line:
grid [label $tertiary_frame.lbl__$row \
- -pady 0 -text [mc { Line:}] \
+ -pady 0 -text [mc " Line:"] \
-bg white -font $lbl_font \
] -sticky w -row $row -column 3 -pady 0
grid [label $tertiary_frame.val__$row \
@@ -1024,7 +1034,7 @@ class InterruptMonitor {
set wdg [lindex $in_progress_wdg end]
if {$wdg != {}} {
pack $primary_frame -fill x -before $wdg -pady 2
- } {
+ } else {
pack $primary_frame -fill x -pady 2
}
@@ -1244,3 +1254,7 @@ class InterruptMonitor {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/sfrmap.tcl b/lib/simulator/sfrmap.tcl
index d6d16d2..65e5806 100755..100644
--- a/lib/simulator/sfrmap.tcl
+++ b/lib/simulator/sfrmap.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,14 +21,19 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _SFRMAP_TCL ] } {
+set _SFRMAP_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# Implements window showing the map of avaliable special function register
+# Implements window showing the map of available special function register
# --------------------------------------------------------------------------
class SFRMap {
## COMMON
- common count 0 ;# Int: Counter of object instances
+ common sfrmap_count 0 ;# Int: Counter of object instances
## PRIVATE
private variable dialog_opened 0 ;# Bool: Dialog window opened
@@ -46,7 +51,7 @@ class SFRMap {
private variable selected_entry -1 ;# Int: Address of selected entry box in the map
constructor {} {
- incr count
+ incr sfrmap_count
}
destructor {
@@ -63,14 +68,14 @@ class SFRMap {
# Create dialog window
set enabled [$this is_frozen]
- set win [toplevel .sfr_map$count -bg {#FFFFFF} -class {SFR map} -bg {#EEEEEE}]
+ set win [toplevel .sfr_map${sfrmap_count} -bg {#FFFFFF} -class {SFR map} -bg ${::COMMON_BG_COLOR}]
# Create other widgets
create_win_gui
# Configure the window
wm iconphoto $win ::ICONS::16::kcmmemory_S
- wm title $win "Map of SFR area - [string trim $this {:}] - MCU 8051 IDE"
+ wm title $win "[mc {Map of SFR area}] - [$this cget -P_option_mcu_type] - [$this cget -projectName] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this sfrmap_close_dialog"
bindtags $win [list $win Toplevel all .]
@@ -146,34 +151,29 @@ class SFRMap {
set name [lindex $reg 1]
set row 0
- lappend defined_sfr $addr
-
- switch -- $name {
- {SBUFR} {
- set name_d {SBUF R}
- }
- {SBUFT} {
- set name_d {SBUF T}
- }
- default {
- set name_d $name
- }
+ if {$addr > 255} {
+ continue
}
-
- set n_addr [expr {$addr & 0x0FF}]
- if {$addr > 0xFF} {
- set row 1
+ if {$name == {SBUFR} || $name == {SBUFT}} {
+ set name {SBUF}
}
if {!($addr % 8)} {
set fg {#00DDDD}
- } {
+ } else {
set fg {#0000DD}
}
- $main_frame.cell_$n_addr configure -bg {#FFFFFF}
- grid [label $main_frame.lbl_${addr} \
- -text $name_d -bg {#FFFFFF} -fg $fg \
- ] -in $main_frame.cell_$n_addr -sticky nsw -row $row -column 0
+ $main_frame.cell_$addr configure -bg {#FFFFFF}
+ pack [label $main_frame.lbl_${addr} \
+ -text $name -bg {#FFFFFF} -fg $fg \
+ ] -in $main_frame.cell_$addr -side left
+
+ grid columnconfigure $main_frame.cell_$addr 0 -weight 1
+ if {$name == {SBUF}} {
+ continue
+ }
+ lappend defined_sfr $addr
+
set entry [ttk::entry $main_frame.ent_${addr} \
-validatecommand "$this sfrmap_validate $addr h %P m" \
-style Simulator_WhiteBg.TEntry \
@@ -182,30 +182,11 @@ class SFRMap {
-width 3 \
-font ${::Simulator_GUI::entry_font} \
]
- grid $entry -in $main_frame.cell_$n_addr -padx 1 -pady 1 -row $row -column 1 -sticky nse
+ pack $entry -in $main_frame.cell_$addr -side right
$entry insert end [$this getSfr $addr]
if {!$enabled} {
$entry configure -state disabled
}
- if {$row} {
- foreach widget [list \
- $main_frame.lbl_${addr} $main_frame.lbl_${n_addr} \
- $main_frame.ent_${addr} $main_frame.ent_${n_addr} \
- ] {
- catch {$widget configure -highlightthickness 0}
- catch {$widget configure -pady 0}
- catch {$widget configure -bd 0}
-
- $widget configure -font [font create -family $::DEFAULT_FIXED_FONT -size -3]
- grid configure $widget -pady 0 -ipady 0
- }
- foreach widget [list $main_frame.lbl_${addr} $main_frame.lbl_${n_addr}] {
- $widget configure -pady 0
- }
- grid rowconfigure $main_frame.cell_$n_addr 0 -pad 0
- grid rowconfigure $main_frame.cell_$n_addr 1 -pad 0
- }
- grid columnconfigure $main_frame.cell_$n_addr 0 -weight 1
bindtags $entry [list $entry TEntry $win all .]
bind $entry <Motion> {help_window_show %X %Y+30}
@@ -500,13 +481,13 @@ class SFRMap {
set enabled $bool
if {$bool} {
set bool {normal}
- } {
+ } else {
set bool {disabled}
}
foreach entry [list $det_hex $det_oct $det_bin $det_dec] {
$entry configure -state $bool
}
- foreach addr [$this simulator_get_avaliable_sfr] {
+ foreach addr $defined_sfr {
$main_frame.ent_${addr} configure -state $bool
}
}
@@ -521,3 +502,7 @@ class SFRMap {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/simulator.tcl b/lib/simulator/simulator.tcl
index 06ce985..8804022 100755..100644
--- a/lib/simulator/simulator.tcl
+++ b/lib/simulator/simulator.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 _SIMULATOR_TCL ] } {
+set _SIMULATOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements 8051 Simulator environment.
@@ -38,14 +43,14 @@
source "${::LIB_DIRNAME}/simulator/engine/engine_core.tcl" ;# Simulator engine
source "${::LIB_DIRNAME}/simulator/simulator_gui.tcl" ;# Simulator panel
source "${::LIB_DIRNAME}/simulator/interruptmonitor.tcl" ;# Interrupt monitor
-source "${::LIB_DIRNAME}/simulator/virtual_uart_term.tcl" ;# Virtual UART Terminal
+source "${::LIB_DIRNAME}/simulator/uart_monitor.tcl" ;# UART monitor
source "${::LIB_DIRNAME}/simulator/sfrmap.tcl" ;# SFR Map monitor
source "${::LIB_DIRNAME}/simulator/stopwatch.tcl" ;# Stopwatch
source "${::LIB_DIRNAME}/simulator/bitmap.tcl" ;# Map of bit addressable area
source "${::LIB_DIRNAME}/simulator/stackmonitor.tcl" ;# Stack monitor
class Simulator {
- inherit Simulator_GUI Simulator_ENGINE InterruptMonitor SFRMap Stopwatch BitMap StackMonitor VirtualUartTerminal
+ inherit Simulator_GUI Simulator_ENGINE InterruptMonitor SFRMap Stopwatch BitMap StackMonitor UARTMonitor
## COMMON
common highlight_color {#DD8800} ;# Foreground color for changed registers
@@ -68,6 +73,7 @@ class Simulator {
common ignore_invalid_USB 0 ;# Bool: Ignore "UART: Frame discarded"
common ignore_invalid_UMC 0 ;# Bool: Ignore "UART mode has been changed while UART was engaged"
common ignore_invalid_TMC 0 ;# Bool: Ignore "Timer mode has been changed while timer was running"
+ common ignore_invalid_brkpoints 0 ;# Bool: Do not warn user about invalid (unreachable) breakpoints
common ignore_EEPROM_WR_fail 0 ;# Bool: Ignore EEPROM write failure (due to EECON.WRTINH, EECON.RDYBSY or EECON.EEMWE)
common ignore_EEPROM_WR_abort 0 ;# Bool: Ignore EEPROM write cycle abort
@@ -75,21 +81,26 @@ class Simulator {
# Normal font for error dialog
common error_normal_font [font create \
- -family {helvetica} -size -14 \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
]
# Bold font for error dialog
common error_bold_font [font create \
-family $::DEFAULT_FIXED_FONT \
- -size -14 \
+ -size [expr {int(-14 * $::font_size_factor)}] \
-weight bold \
]
# Header font for error dialog
common error_header_font [font create \
- -family {helvetica} -size -17 -weight bold \
+ -family {helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
]
# Main header font
common error_main_header [font create \
- -family {helvetica} -size -20 -weight bold \
+ -family {helvetica} \
+ -size [expr {int(-20 * $::font_size_factor)}] \
+ -weight bold \
]
## PRIVATE
@@ -98,7 +109,7 @@ class Simulator {
private variable error_dialog_textwdg ;# Widget: Text widget used in error dialog
private variable addr_error_save_type ;# Type of file to save
- # Bool: Related to warnings dialogs
+ # Bool: Related to warnings dialogues
private variable ignore_warnings_related_to_changes_in_SFR 0
## Obejct constructor
@@ -113,20 +124,22 @@ class Simulator {
# Get new and old value of Program Counter
set new_val [getPC]
- set original_val [subst "\$::Simulator_GUI::ENV${obj_idx}_PC_dec"]
+ set original_val [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_PC_dec"]
# Display new value of PC and highlight it if it has changed
set ::Simulator_GUI::ENV${obj_idx}_PC_dec $new_val
- if {$highlight_ena && ($original_val != $new_val)} {
- mark_entry PC
+ if {$original_val != $new_val} {
+ if {$highlight_ena} {
+ mark_entry PC
+ }
$this sim_eval_PC dec $new_val
}
- # Mode program pointer in code mememory hexeditor
+ # Mode program pointer in code mememory hex editor
::X::program_counter_changed $this $new_val
# Synchronize Watchdog
- if {[$this get_feature_avaliable wtd]} {
+ if {[$this get_feature_available wtd]} {
set val [format %X [$this simulator_getWatchDogTimerValue]]
set len [string length $val]
if {$len != 4} {
@@ -136,7 +149,7 @@ class Simulator {
$this simulator_evaluate_wtd_onoff_switch
$this watchdog_validate $val
- if {[$this get_feature_avaliable wdtcon] || [$this get_feature_avaliable wdtprg]} {
+ if {[$this get_feature_available wdtcon] || [$this get_feature_available wdtprg]} {
set val [format %X [$this simulator_getWatchDogPrescalerValue]]
if {[string length $val] == 1} {
set val "0$val"
@@ -206,7 +219,6 @@ class Simulator {
# @parm Int addr - address of register to synchronize
# @return void
public method Simulator_GUI_sync {type addr} {
-
# Internal RAM
if {$type == {I}} {
# Get new and old value
@@ -247,7 +259,7 @@ class Simulator {
# Synchronize with C variables view
if {$addr < 128} {
$this cvarsview_sync E $addr
- } {
+ } else {
$this cvarsview_sync G $addr
}
@@ -279,10 +291,10 @@ class Simulator {
# Determinate boolean value of the bit
if {$psw == 0} {
set bool 0
- } {
+ } else {
if {[expr {$psw & $mask}] > 0} {
set bool 1
- } {
+ } else {
set bool 0
}
}
@@ -293,7 +305,7 @@ class Simulator {
# Take care of bit color
if {$bool} {
$Simulator_panel_parent._PSW_$bit configure -fg $on_color
- } {
+ } else {
$Simulator_panel_parent._PSW_$bit configure -fg $off_color
}
}
@@ -364,16 +376,16 @@ class Simulator {
134 {set regName {SPDR} }
150 {set regName {EECON} }
143 {
- if {[$this get_feature_avaliable ckcon]} {
+ if {[$this get_feature_available ckcon]} {
set regName {CKCON}
- } {
+ } else {
set regName {CLKREG}
}
}
167 {
- if {[$this get_feature_avaliable wdtprg]} {
+ if {[$this get_feature_available wdtprg]} {
set regName {WDTPRG}
- } {
+ } else {
set regName {WDTCON}
}
}
@@ -393,7 +405,7 @@ class Simulator {
# Synchronize with simulator control panel
if {$name_resolved} {
- set original_val [subst "\$::Simulator_GUI::ENV${obj_idx}_${regName}"]
+ set original_val [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_${regName}"]
set ::Simulator_GUI::ENV${obj_idx}_${regName} $new_val
if {$highlight_ena && ($original_val != $new_val)} {
@@ -410,7 +422,7 @@ class Simulator {
set ::Simulator_GUI::ENV${obj_idx}_SFR(FE) $bit_FE
if {$bit_FE} {
$Simulator_panel_parent._SCON_FE configure -fg $::Simulator_GUI::on_color
- } {
+ } else {
$Simulator_panel_parent._SCON_FE configure -fg $::Simulator_GUI::off_color
}
}
@@ -418,7 +430,7 @@ class Simulator {
if {[$this sim_engine_get_SM0]} {
$Simulator_panel_parent._SCON_SM0 configure -fg $::Simulator_GUI::on_color
set ::Simulator_GUI::ENV${obj_idx}_SFR(SM0) 1
- } {
+ } else {
$Simulator_panel_parent._SCON_SM0 configure -fg $::Simulator_GUI::off_color
set ::Simulator_GUI::ENV${obj_idx}_SFR(SM0) 0
}
@@ -477,7 +489,7 @@ class Simulator {
}
# Synchronize SFR
- foreach addr [simulator_get_avaliable_sfr] {
+ foreach addr [simulator_get_available_sfr] {
Simulator_GUI_sync S $addr
}
}
@@ -517,7 +529,7 @@ class Simulator {
# @return void
public method simulator_clear_highlight {} {
simulator_hexeditor clearHighlighting
- foreach addr [simulator_get_avaliable_sfr] {
+ foreach addr [simulator_get_available_sfr] {
unmark_entry $addr
}
foreach addr {R0 R1 R2 R3 R4 R5 R6 R7} {
@@ -551,7 +563,7 @@ class Simulator {
foreach wdg $widgets($addr) {
if {[winfo class $wdg] == {TEntry}} {
$wdg configure -style Simulator_HG.TEntry
- } {
+ } else {
$wdg configure -fg $highlight_color
}
}
@@ -567,7 +579,7 @@ class Simulator {
foreach wdg $widgets($addr) {
if {[winfo class $wdg] == {TEntry}} {
$wdg configure -style Simulator.TEntry
- } {
+ } else {
$wdg configure -fg $normal_color
}
}
@@ -599,7 +611,7 @@ class Simulator {
if {$addr_dec > 127} {
set memory {special function registers area}
set mem {SFR}
- } {
+ } else {
set mem {IDATA}
set memory {internal data memory}
}
@@ -631,7 +643,7 @@ class Simulator {
}
# Create dialog window
- set win [toplevel .undefined_result -class {Error dialog} -bg {#EEEEEE}]
+ set win [toplevel .undefined_result -class {Error dialog} -bg ${::COMMON_BG_COLOR}]
# Create dialog header
set top_frame [frame $win.top_frame]
@@ -648,7 +660,7 @@ class Simulator {
set text_wdg [text $middle_frame.text \
-height 0 -width 0 -font $error_normal_font \
-yscrollcommand "$middle_frame.scrollbar set" \
- -wrap word -relief flat -bg {#EEEEEE} \
+ -wrap word -relief flat -bg ${::COMMON_BG_COLOR} \
-tabstyle wordprocessor \
]
set error_dialog_textwdg $text_wdg
@@ -665,13 +677,13 @@ class Simulator {
-compound left \
-text [mc "Save as plain text"] \
-command "$this simulator_addr_error_save T" \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $bottom_frame.save_as_xhtml \
-image ::ICONS::16::html \
-compound left \
-text [mc "Save as XHTML"] \
-command "$this simulator_addr_error_save X" \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $bottom_frame.ok \
-image ::ICONS::16::ok \
-compound left \
@@ -712,7 +724,7 @@ class Simulator {
$text_wdg insert end [$this editor_procedure {} cget -filename]
$text_wdg insert end [mc "\n\tProject:\t\t"]
$text_wdg tag add tag_bold {insert linestart} insert
- $text_wdg insert end [string trim $this {:}]
+ $text_wdg insert end [$this cget -projectName]
# Processor details
$text_wdg insert end [mc "\n\nProcessor details:"]
@@ -742,7 +754,7 @@ class Simulator {
pack [checkbutton $win.not_again_checkbutton \
-text [mc "Do not show this dialog again"] \
-variable ::Simulator::not_again_val \
- -command "::configDialogs::simulator::set_variable $conf_variable \$::Simulator::not_again_val" \
+ -command "::configDialogues::simulator::set_variable $conf_variable \$::Simulator::not_again_val" \
] -anchor w -padx 15 -pady 5
DynamicHelp::add $win.not_again_checkbutton \
-text [mc "See simulator configuration dialog\nMain Menu -> Configure -> Simulator"]
@@ -753,7 +765,7 @@ class Simulator {
focus -force $bottom_frame.ok
wm title $win [mc "Undefined result - MCU 8051 IDE"]
wm iconphoto $win ::ICONS::16::no
- wm minsize $win 450 400
+ wm minsize $win 470 400
wm protocol $win WM_DELETE_WINDOW "
grab release $win
destroy $win
@@ -775,16 +787,16 @@ class Simulator {
set error_dialog_project $this
if {$type == {T}} {
set init {error.log}
- set filetypes {
- {{Log files} {*.log} }
- {{All files} {*} }
- }
- } {
+ set filetypes [list \
+ [list [::mc "Log files"] {*.log}] \
+ [list [::mc "All files"] {*}] \
+ ]
+ } else {
set init {error.html}
- set filetypes {
- {{XHTML files} {*.html}}
- {{All files} {*} }
- }
+ set filetypes [list \
+ [list [::mc "HTML files"] {*.html}] \
+ [list [::mc "All files"] {*}] \
+ ]
}
# Invoke the file selection dialog
@@ -803,8 +815,8 @@ class Simulator {
if {![regexp "^(~|/)" $filename]} {
set filename "[${::Simulator::error_dialog_project} cget -ProjectDir]/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
set filename [file join [${::Simulator::error_dialog_project} cget -ProjectDir] $filename]
}
}
@@ -875,7 +887,7 @@ class Simulator {
puts -nonewline $file [line_wrap 70 [$error_dialog_textwdg get 1.0 end]]
## SAVE AS XHTML
- } {
+ } else {
# Local variables
set end [$error_dialog_textwdg index end] ;# Widget end index
set last_index 0 ;# Current position (by characters)
@@ -949,7 +961,7 @@ class Simulator {
# Deterinate string to insert
if {[lindex $range 2]} {
set tag [lindex $range 1]
- } {
+ } else {
set tag "/[lindex $range 1]"
}
@@ -978,7 +990,7 @@ class Simulator {
## Invoke simulator warning dialog "UART: Frame discarded"
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_uart_invalid_stop_bit {pc line} {
if {$ignore_warnings_related_to_changes_in_SFR || ![$this sim_is_busy]} {
@@ -990,12 +1002,12 @@ class Simulator {
simulator_warning_dialog \
ignore_invalid_USB \
- [mc "UART: Frame discarded (acording to MCS-51 manual)\n"] $pc $line
+ [mc "UART: Frame discarded (according to MCS-51 manual)\n"] $pc $line
}
## Invoke simulator warning dialog "UART mode has been changed while UART was engaged"
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_invalid_uart_mode_change {pc line} {
if {$ignore_warnings_related_to_changes_in_SFR || ![$this sim_is_busy]} {
@@ -1012,7 +1024,7 @@ class Simulator {
## Invoke simulator warning dialog "Timer mode has been changed while timer was running"
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @parm Int timer - Timer number (0/1/2)
# @return void
public method simulator_invalid_timer_mode_change {timer pc line} {
@@ -1030,7 +1042,7 @@ class Simulator {
## Invoke watchdog reset dialog
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_watchdog_reset {pc line} {
if {$line == {}} {
@@ -1045,7 +1057,7 @@ class Simulator {
## Invokes dialog "Stack Overflow" / "Stack underflow"
# @parm String type - {over} == overflow; {under} == underflow
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_stack_warning {type pc line} {
if {$line == {}} {
@@ -1054,7 +1066,7 @@ class Simulator {
if {$type == {over}} {
set foo {overflow}
set conf_variable {ignore_stack_overflow}
- } {
+ } else {
set foo {underflow}
set conf_variable {ignore_stack_underflow}
}
@@ -1066,7 +1078,7 @@ class Simulator {
## Invoke dialog "Invalid instruction OP code"
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_invalid_instruction {pc line} {
$this simulator_warning_dialog \
@@ -1078,7 +1090,7 @@ class Simulator {
## Invoke dialog "Reading from write-only register"
# @parm Int addr - Register address
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_reading_wr_only {addr pc line} {
if {$line == {}} {
@@ -1090,9 +1102,9 @@ class Simulator {
[mc "Unable to read write-only register.\nRandom value returned.\n\nRegister:\t\t0x%s" [format %X $addr]] $pc $line
}
- ## Invoke dialog "EEPROM programing cycle abort"
+ ## Invoke dialog "EEPROM programming cycle abort"
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_EEPROM_WR_abort {pc line} {
if {$line == {}} {
@@ -1106,7 +1118,7 @@ class Simulator {
## Invoke dialog "EEPROM write failed"
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_EEPROM_WR_fail {pc line} {
if {$line == {}} {
@@ -1115,12 +1127,12 @@ class Simulator {
simulator_warning_dialog \
ignore_EEPROM_WR_fail \
- [mc "Unable to initialize EEPROM programing cycle\nbecause EEMWE, RDYBSY and WRTINH must be set\n"] $pc $line
+ [mc "Unable to initialize EEPROM programming cycle\nbecause EEMWE, RDYBSY and WRTINH must be set\n"] $pc $line
}
## Invoke dialog "Invalid return from interrupt"
# @parm Int pc - Value of program counter
- # @parm Int line - Line in source code where this error occured
+ # @parm Int line - Line in source code where this error occurred
# @return void
public method simulator_invalid_reti_dlg {pc line} {
if {$line == {}} {
@@ -1136,7 +1148,7 @@ class Simulator {
# @parm String conf_variable - Configuration variable for disabling this dialog
# @parm String text - Text to show
# @parm Int pc - Value of program counter
- # @parm List line - Line in source code where this error occured
+ # @parm List line - Line in source code where this error occurred
# @return void
public method simulator_warning_dialog {conf_variable text pc line} {
@@ -1145,7 +1157,7 @@ class Simulator {
if {[winfo exists $win]} {
destroy $win
}
- toplevel $win -class {Error dialog} -bg {#EEEEEE}
+ toplevel $win -class {Error dialog} -bg ${::COMMON_BG_COLOR}
## Create dialog icon and text
set top_frame [frame $win.top_frame]
@@ -1166,7 +1178,7 @@ class Simulator {
pack [checkbutton $bottom_frame.not_again_checkbutton \
-text [mc "Do not show this dialog again"] \
-variable ::Simulator::not_again_val \
- -command "::configDialogs::simulator::set_variable $conf_variable \$::Simulator::not_again_val" \
+ -command "::configDialogues::simulator::set_variable $conf_variable \$::Simulator::not_again_val" \
] -anchor w -side left -anchor w
DynamicHelp::add $bottom_frame.not_again_checkbutton \
-text [mc "See simulator configuration dialog\nMain Menu -> Configure -> Simulator"]
@@ -1199,4 +1211,21 @@ class Simulator {
}
tkwait window $win
}
+
+ ## Detect all invalid breakpoints (breakpoints at unreachable locations) and report them via messages panel
+ # @return void
+ public method report_invalid_breakpoints {} {
+ if {$ignore_invalid_brkpoints} {
+ return
+ }
+
+ $this messages_text_append "\n"
+ foreach fn_ln [$this simulator_getInvalidBreakpoints] {
+ $this messages_text_append "[file tail [$this simulator_get_filename [lindex $fn_ln 0]]]:[lindex $fn_ln 1]: warning: Invalid breakpoint"
+ }
+ }
+}
+
+# >>> File inclusion guard
}
+# <<< File inclusion guard
diff --git a/lib/simulator/simulator_gui.tcl b/lib/simulator/simulator_gui.tcl
index ddaba65..9ae70b9 100755..100644
--- a/lib/simulator/simulator_gui.tcl
+++ b/lib/simulator/simulator_gui.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,9 +21,14 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _SIMULATOR_GUI_TCL ] } {
+set _SIMULATOR_GUI_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# Provides graphical frontend for simulator engine (intended to be
+# Provides graphical front-end for simulator engine (intended to be
# used at the bottom panel). This class is part of class Simulator.
# --------------------------------------------------------------------------
@@ -35,33 +40,47 @@
class Simulator_GUI {
## COMMON
- common count 0 ;# Counter of instances
+ common sim_gui_count 0 ;# Counter of instances
common name_color {#0000DD} ;# Color for register name labels (eg. 'SP')
common name_nr_color {#8800DD} ;# Color for not-register name labels (eg. 'Clock')
- common on_color {green} ;# Foreground color for bits in state 1 (for bit maps)
- common off_color {red} ;# Foreground color for bits in state 0 (for bit maps)
+ common on_color {#00CC00} ;# Foreground color for bits in state 1 (for bit maps)
+ common off_color {#DD0000} ;# Foreground color for bits in state 0 (for bit maps)
# Font for bit labels (eg. 'EA')
- common bitfont [font create \
- -family {helvetica} \
- -size -11 \
- -weight bold]
+ common bitfont [font create \
+ -family {helvetica} \
+ -size [expr {int(-11 * $::font_size_factor)}] \
+ -weight [expr {$::MICROSOFT_WINDOWS ? "normal" : "bold"}] \
+ ]
# Same as $bitfont but underlined
- common bitfont_under [font create \
- -family {helvetica} \
- -size -11 -underline 1 \
- -weight bold]
+ common bitfont_under [font create \
+ -family {helvetica} \
+ -size [expr {int(-11 * $::font_size_factor)}] \
+ -underline 1 \
+ -weight [expr {$::MICROSOFT_WINDOWS ? "normal" : "bold"}] \
+ ]
# Color for small labels (eg. 'HEX')
common small_color {#5599BB}
# Font for small labels (eg. 'OCT')
- common smallfont $::smallfont
+ common smallfont $::smallfont
+ if {$::MICROSOFT_WINDOWS} { ;# On MS Windows we need some smaller font to fit in
+ set smallfont [font create \
+ -size [expr {int(-9 * $::font_size_factor)}] \
+ -family {helvetica} \
+ -weight normal \
+ ]
+ }
common hcolor {#FFAA00} ;# Highlight foreground color for entry widgets
common hbcolor {#CCCCCC} ;# Highlight background color for entry widgets
# Font for other memory entries (eg. PCON)
- common entry_font [font create -size -12 -family $::DEFAULT_FIXED_FONT -weight bold]
+ common entry_font [font create \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -family $::DEFAULT_FIXED_FONT \
+ -weight [expr {$::MICROSOFT_WINDOWS ? "normal" : "bold"}] \
+ ]
# Postfixes for entry text variables
common entry_variables {
@@ -108,7 +127,7 @@ class Simulator_GUI {
private variable set_pc_by_line_button {} ;# Button: Set PC by line number
# Variables related to object initialization
- private variable gui_initialized 0 ;# Bool: GUI created
+ private variable sim_gui_gui_initialized 0 ;# Bool: GUI created
private variable parent ;# Parent widget
## PUBLIC
@@ -121,14 +140,14 @@ class Simulator_GUI {
## Object constructor
constructor {} {
- incr count ;# Increment instances counter
- set obj_idx $count ;# Set object index
+ incr sim_gui_count ;# Increment instances counter
+ set obj_idx $sim_gui_count ;# Set object index
}
## Object destructor
destructor {
# Unallocate entry text variables
- if {$gui_initialized} {
+ if {$sim_gui_gui_initialized} {
SimGUI_clean_up
}
}
@@ -138,19 +157,21 @@ class Simulator_GUI {
# @return void
public method PrepareSimulator {_parent} {
set parent $_parent
- set gui_initialized 0
+ set sim_gui_gui_initialized 0
}
## Inform simulator panel than it has became active
# @return void
public method SimulatorTabRaised {} {
+ update idletasks
+ $scrollable_frame yview scroll 0 units
}
## Initialize simulator GUI
# @return void
public method CreateSimulatorGUI {} {
- if {$gui_initialized} {return}
- set gui_initialized 1
+ if {$sim_gui_gui_initialized} {return}
+ set sim_gui_gui_initialized 1
# Set object variables
set disable_validation 1
@@ -196,7 +217,7 @@ class Simulator_GUI {
{up0} "Set this bit to 1"}
{command {Set to 0} {} 7 "bit_popup_menu_setto 0"
{button_cancel} "Set this bit to 0"}
- } $bitmenu 0 "$this " 0 {}
+ } $bitmenu 0 "$this " 0 {} [namespace current]
#
# Create left part
@@ -210,7 +231,12 @@ class Simulator_GUI {
if {[expr {$cap % 8}]} {
incr hg
}
- set hexeditor [HexEditor hexeditor${obj_idx} $main_top_frame.left_frame 8 $hg 2 hex 0 1 8 $cap]
+ if {!$::MICROSOFT_WINDOWS} {
+ set height_in_number_of_rows 9
+ } else {
+ set height_in_number_of_rows 11
+ }
+ set hexeditor [HexEditor hexeditor${obj_idx} $main_top_frame.left_frame 8 $hg 2 hex 0 1 $height_in_number_of_rows $cap]
$hexeditor bindCellValueChanged "$this simulator_hexedit_value_changed"
$hexeditor bindCellLeave {help_window_hide}
$hexeditor bindCellEnter "$this create_help_window_ram"
@@ -228,14 +254,14 @@ class Simulator_GUI {
set sim_gregs_f [frame $middle_f.gregs_frame]
# Pack frames of middle part
- pack $ctrl_f -fill x -padx 2
+ pack $ctrl_f -fill x
pack $sim_gregs_f
- pack $middle_f -side left -fill both -anchor w
+ pack $middle_f -side left -fill both -anchor w -padx 5
# Create controls icon bar
iconBarFactory $ctrl_f "X::" [string range $ctrl_f.controls_ 1 end] ::ICONS::16:: {
- {start_stop "Initialize simulator" {launch} {__initiate_sim}
- "Load sim file into simulator engine"}
+ {start_stop "Start/Stop simulator" {launch} {__initiate_sim}
+ "Load program into the simulator engine, or shutdown the MCU simulator."}
{separator}
{reset "Reset" {rebuild} {__reset -}
"Perform HW reset"}
@@ -250,7 +276,7 @@ class Simulator_GUI {
"Run program and show results after each instruction"}
{run "Run program" {2rightarrow} {__run}
"Run program and show results after some time"}
- }
+ } [namespace current]
foreach slave [pack slaves $ctrl_f] {
pack configure $slave -padx 0
}
@@ -258,11 +284,11 @@ class Simulator_GUI {
# Create separator under controls icon bar
pack [ttk::separator $sim_gregs_f.mid_sep \
-orient horizontal \
- ] -fill x -expand 1 -pady 2
+ ] -fill x -expand 1 -pady 2 -padx 5
## Create registers: A B
set sim_gregs_f_AB [frame $sim_gregs_f.gregs_f_AB]
- pack $sim_gregs_f_AB -anchor w
+ pack $sim_gregs_f_AB -pady 5
# Create num. base headers
set col 1
@@ -318,7 +344,7 @@ class Simulator_GUI {
-validate key \
]
- setStatusTip -widget $entry -text $stip
+ setStatusTip -widget $entry -text [mc $stip]
# Register register entry for disabling/enabling
add_entry $entry
# Register register entry for synchronizations
@@ -333,7 +359,7 @@ class Simulator_GUI {
$sim_gregs_f_AB._B_$base icursor \[$entry index insert\]
focus $sim_gregs_f_AB._B_$base
"
- } {
+ } else {
bind $entry <Key-Up> "
$sim_gregs_f_AB._A_$base icursor \[$entry index insert\]
focus $sim_gregs_f_AB._A_$base
@@ -350,7 +376,7 @@ class Simulator_GUI {
## Create register: PSW
set sim_gregs_f_PSW [frame $sim_gregs_f.gregs_f_PSW]
- pack $sim_gregs_f_PSW -anchor w
+ pack $sim_gregs_f_PSW -pady 2
set ::Simulator_GUI::ENV${obj_idx}_PSW 0
create_bitmap_register $sim_gregs_f_PSW 1 PSW {C AC F0 RS1 RS0 OV - P} 0 {
{Bit address: 0xD7 -- Carry Flag}
@@ -387,7 +413,7 @@ class Simulator_GUI {
-text "R$i" -fg $name_color -pady 0 \
-font $bitfont \
] -row 1 -column $col -sticky we
- setStatusTip -widget $sim_gregs_f_Rx._R${i}_l -text $stip
+ setStatusTip -widget $sim_gregs_f_Rx._R${i}_l -text [mc $stip]
# Create register hexadecimal entry
set ::Simulator_GUI::ENV${obj_idx}_R$i {00}
@@ -439,10 +465,10 @@ class Simulator_GUI {
pack $frame0 -side left -anchor nw
# Create timers frame (hexadecimal entries and bitmaps)
- set timers_frame [ttk::labelframe $frame0.timers_f \
- -padding 2 \
- -labelwidget [label $frame0.timers_lbl -text "TIMERS 0 & 1" -font $smallfont -pady 0]]
- pack $timers_frame -anchor nw -fill x
+ set timers_frame [labelframe $frame0.timers_f \
+ -pady 2 -padx 2 \
+ -labelwidget [label $frame0.timers_lbl -text [mc "TIMERS 0 & 1"] -font $smallfont -pady 0]]
+ pack $timers_frame -anchor nw -fill x -padx 5
# Create frame for hexadecimal entries: TH1 TL1 TH0 TL0
set timers_values_f [frame $timers_frame.timers_values_f]
@@ -633,20 +659,20 @@ class Simulator_GUI {
}
# Create frame for interrupt control registers (IE and IP)
- set interrupt_frame [ttk::labelframe $frame0.interrupt_f \
- -padding 2 \
- -labelwidget [label $frame0.int_lbl -text "INTERRUPTS" -font $smallfont -pady 0]]
- pack $interrupt_frame -anchor nw -fill x
+ set interrupt_frame [labelframe $frame0.interrupt_f \
+ -pady 2 -padx 2 \
+ -labelwidget [label $frame0.int_lbl -text [mc "INTERRUPTS"] -font $smallfont -pady 0]]
+ pack $interrupt_frame -anchor nw -fill x -pady 5 -padx 5
# Create IE, IP bitmaps
- if {[$this get_feature_avaliable t2]} {
+ if {[$this get_feature_available t2]} {
set et2 {ET2}
set pt2 {PT2}
set et2_stip {Bit address: 0xAD -- Enable or disable the Timer 2 overflow interrupt}
set pt2_stip {Bit address: 0xBD -- Defines the Timer 2 interrupt priority level}
- set et2_ttip {Timer 2 interrupt enable bit}
+ set et2_ttip {Timer 2 interrupt enable bit.}
set pt2_ttip {Timer 2 interrupt priority bit}
- } {
+ } else {
set et2 {-}
set pt2 {-}
set et2_stip {Bit address: 0xAD -- Not implemented}
@@ -654,14 +680,14 @@ class Simulator_GUI {
set et2_ttip {Not implemented}
set pt2_ttip {Not implemented}
}
- if {[$this get_feature_avaliable uart]} {
+ if {[$this get_feature_available uart]} {
set es {ES}
set ps {PS}
set es_stip {Bit address: 0xAC -- Enable or disable the serial port interrupt}
set ps_stip {Bit address: 0xBC -- Defines the Serial Port interrupt priority level}
set es_ttip {Serial Port interrupt enable bit}
set ps_ttip {Serial Port interrupt priority bit}
- } {
+ } else {
set es {-}
set ps {-}
set es_stip {Bit address: 0xAD -- Not implemented}
@@ -669,14 +695,14 @@ class Simulator_GUI {
set es_ttip {Not implemented}
set ps_ttip {Not implemented}
}
- if {[$this get_feature_avaliable acomparator]} {
+ if {[$this get_feature_available acomparator]} {
set ec {EC}
set pc {PC}
set ec_stip {Bit address: 0xAE -- Enable or disable the comparator interrupt}
set pc_stip {Bit address: 0xBE -- Defines the comparator interrupt priority level}
set ec_ttip {EC Comparator Interrupt Enable bit}
set pc_ttip {Comparator Interrupt Priority bit}
- } {
+ } else {
set ec {-}
set pc {-}
set ec_stip {Bit address: 0xAE -- Not implemented}
@@ -824,7 +850,7 @@ class Simulator_GUI {
set addrs {} ;# Register addresses
set stips {} ;# Status bar tips
foreach reg {P0 P1 P2 P3 P4} addr {128 144 160 176 192} stip {0 1 2 3 4} {
- if {[$this get_feature_avaliable [string tolower $reg]]} {
+ if {[$this get_feature_available [string tolower $reg]]} {
lappend regs $reg
lappend addrs $addr
lappend stips [mc "SFR 0x%s: Latch of port %s" [symb_name_to_hex_addr $reg] $stip]
@@ -842,7 +868,7 @@ class Simulator_GUI {
-text "$reg:" -fg $name_color -pady 0 \
-font $bitfont \
] -row $row -column 1
- setStatusTip -widget $frame1_top_left._${reg}_l -text $stip
+ setStatusTip -widget $frame1_top_left._${reg}_l -text [mc $stip]
# Create binary entry
set ::Simulator_GUI::ENV${obj_idx}_${reg}_bin {11111111}
@@ -862,7 +888,7 @@ class Simulator_GUI {
# Set entry event bindings
bind $entry0 <FocusIn> "$this unmark_entry $addr"
- setStatusTip -widget $entry0 -text $stip
+ setStatusTip -widget $entry0 -text [mc $stip]
if {$row != 1} {
bind $entry0 <Key-Up> "
$frame1_top_left._Pxx[expr {$row-1}]_bin_e icursor \[$entry0 index insert\]
@@ -914,66 +940,66 @@ class Simulator_GUI {
### Create bottom frame widgets (PCON SCON)
## Create register bitmaps
# - PCON
- if {[$this get_feature_avaliable pof]} {
+ if {[$this get_feature_available pof]} {
set POF {POF}
set pof_statusTip {Power Off Flag}
set pof_tooltip {Power-Off Flag\nCleared to recognize next reset type.\nSet by hardware when VCC rises from 0 to its nominal voltage. Can also be set by software.}
- } {
+ } else {
set POF {-}
set pof_statusTip {Not implemented}
set pof_tooltip {Not implemented}
}
- if {[$this get_feature_avaliable gf1]} {
+ if {[$this get_feature_available gf1]} {
set GF1 {GF1}
set gf1_statusTip {General purpose flag bit}
set gf1_tooltip {General purpose Flag\nCleared by user for general purpose usage.\nSet by user for general purpose usage.}
- } {
+ } else {
set GF1 {-}
set gf1_statusTip {Not implemented}
set gf1_tooltip {Not implemented}
}
- if {[$this get_feature_avaliable gf0]} {
+ if {[$this get_feature_available gf0]} {
set GF0 {GF0}
set gf0_statusTip {General purpose flag bit}
set gf0_tooltip {General purpose Flag\nCleared by user for general purpose usage.\nSet by user for general purpose usage.}
- } {
+ } else {
set GF0 {-}
set gf0_statusTip {Not implemented}
set gf0_tooltip {Not implemented}
}
- if {[$this get_feature_avaliable pd]} {
+ if {[$this get_feature_available pd]} {
set PD {PD}
set pd_statusTip {Power down bit}
set pd_tooltip {Power-Down mode bit\nCleared by hardware when reset occurs.\nSet to enter power-down mode.}
- } {
+ } else {
set PD {-}
set pd_statusTip {Not implemented}
set pd_tooltip {Not implemented}
}
- if {[$this get_feature_avaliable idl]} {
+ if {[$this get_feature_available idl]} {
set IDL {IDL}
set idl_statusTip {Idle mode bit}
set idl_tooltip {Idle mode bit\nCleared by hardware when interrupt or reset occurs.\nSet to enter idle mode.}
- } {
+ } else {
set IDL {-}
set idl_statusTip {Not implemented}
set idl_tooltip {Not implemented}
}
- if {[$this get_feature_avaliable uart]} {
+ if {[$this get_feature_available uart]} {
set SMOD1 {SMOD}
set smod1_statusTip {Double baud rate bit}
set smod1_tooltip {Serial port Mode bit 1 for UART\nSet to select double baud rate in mode 1, 2 or 3.}
- if {[$this get_feature_avaliable smod0]} {
+ if {[$this get_feature_available smod0]} {
append SMOD1 {1}
set SMOD0 {SMOD0}
set smod0_statusTip {Frame Error Select}
set smod0_tooltip {Frame Error Select. When SMOD0 = 0, SCON.7 is SM0. When SMOD0 = 1, SCON.7 is FE.\nNote that FE will be set after a frame error\nregardless of the state of SMOD0.}
- } {
+ } else {
set SMOD0 {-}
set smod0_statusTip {Not implemented}
set smod0_tooltip {Not implemented}
}
- } {
+ } else {
set SMOD1 {-}
set smod1_statusTip {Not implemented}
set smod1_tooltip {Not implemented}
@@ -981,11 +1007,11 @@ class Simulator_GUI {
set smod0_statusTip {Not implemented}
set smod0_tooltip {Not implemented}
}
- if {[$this get_feature_avaliable pwm]} {
+ if {[$this get_feature_available pwm]} {
set PWMEN {PWMEN}
set pwmen_stip {Pulse Width Modulation Enable}
set pwmen_ttip {Pulse Width Modulation Enable. When PWMEN = 1, Timer 0 and Timer 1 are\nconfigured as an 8-bit PWM counter with 8-bit auto-reload prescaler.\nThe PWM outputs on T1 (P3.5).}
- } {
+ } else {
set PWMEN {-}
set pwmen_stip {Not implemented}
set pwmen_ttip {Not implemented}
@@ -1010,7 +1036,7 @@ class Simulator_GUI {
$idl_tooltip \
]
# - SCON
- if {[$this get_feature_avaliable uart]} {
+ if {[$this get_feature_available uart]} {
create_bitmap_register $frame1_bottom 2 SCON {SM0 SM1 SM2 REN TB8 RB8 TI RI} 1 {
{Bit address: 0x9F -- Serial Port mode specifier}
{Bit address: 0x9E -- Serial Port mode specifier}
@@ -1032,7 +1058,7 @@ class Simulator_GUI {
}
# Create bit FE (Frame error)
- if {[$this get_feature_avaliable smod0]} {
+ if {[$this get_feature_available smod0]} {
set FE_frm [frame $frame1_bottom._SCON_SM0_FE_frm]
grid forget $Simulator_panel_parent._SCON_SM0
@@ -1043,7 +1069,7 @@ class Simulator_GUI {
bind $Simulator_panel_parent._SCON_SM0 <ButtonRelease-3> "$this bit_popup_menu SM0 0 SCON 1 %X %Y"
set label [label $Simulator_panel_parent._SCON_FE \
- -text {FE} -fg $off_color -cursor hand1 \
+ -text {FE} -fg $off_color -cursor hand2 \
-bd 0 -font $bitfont -pady 0 -padx 0 \
]
pack $label -in $FE_frm -side left
@@ -1053,7 +1079,7 @@ class Simulator_GUI {
pack $Simulator_panel_parent._SCON_SM0 -in $FE_frm -side left
- setStatusTip -widget $label -text {Bit address: 0x9F -- Framing Error bit}
+ setStatusTip -widget $label -text [mc "Bit address: 0x9F -- Framing Error bit"]
bind $label <Enter> {+%W configure -font $::Simulator_GUI::bitfont_under}
bind $label <Leave> {+%W configure -font $::Simulator_GUI::bitfont}
DynamicHelp::add $label -text [subst {Clear to reset the error state, not cleared by a valid stop bit.\nSet by hardware when an invalid stop bit is detected.\nSMOD0 must be set to enable access to the FE bit}]
@@ -1084,7 +1110,7 @@ class Simulator_GUI {
{SFR 0x98: Serial port control register}
} {
incr row ;# Increment grid row
- if {$reg == {SCON} && ![$this get_feature_avaliable uart]} {
+ if {$reg == {SCON} && ![$this get_feature_available uart]} {
continue
}
@@ -1094,7 +1120,7 @@ class Simulator_GUI {
# Create register name labels
grid [label $frame1_bottom._${reg}_hex_l \
- -text {HEX} -fg $small_color -font $smallfont \
+ -text {H:} -fg $small_color -font $smallfont \
] -row $row -column 12
setStatusTip -widget $frame1_bottom._${reg}_hex_l -text [mc $stip]
@@ -1137,9 +1163,9 @@ class Simulator_GUI {
# Create label "DPTR:"
if {
- [$this get_feature_avaliable {ddp}]
+ [$this get_feature_available {ddp}]
&&
- ![$this get_feature_avaliable {hddptr}]
+ ![$this get_feature_available {hddptr}]
} then {
set text {DPTR0:}
} else {
@@ -1204,7 +1230,7 @@ class Simulator_GUI {
"Simulator_GUI::sim_entry_right $frame1_top_right_0._DPH_e $frame1_top_right_0._DPL_e"
bind $frame1_top_right_0._DPL_e <Key-Left> \
"Simulator_GUI::sim_entry_left $frame1_top_right_0._DPL_e $frame1_top_right_0._DPH_e"
- if {[$this get_feature_avaliable {ddp}]} {
+ if {[$this get_feature_available {ddp}]} {
bind $frame1_top_right_0._DPH_e <Key-Down> "
$frame1_top_right_0._DP1H_e icursor \[$frame1_top_right_0._DPH_e index insert\]
focus $frame1_top_right_0._DP1H_e"
@@ -1214,7 +1240,7 @@ class Simulator_GUI {
}
# Create vertical separator (DPTR + Clock)|(SP + SBUF)
- if {[$this get_feature_avaliable {ddp}]} {set row 3} {set row 2}
+ if {[$this get_feature_available {ddp}]} {set row 3} {set row 2}
grid [ttk::separator $frame1_top_right_0._SP_sep \
-orient vertical \
] \
@@ -1229,7 +1255,7 @@ class Simulator_GUI {
-text {SP:} -fg $name_color -pady 0 \
-font $bitfont \
] -row 2 -column 4 -sticky w
- setStatusTip -widget $frame1_top_right_0._SP_l -text {SFR 0x81: Stack pointer}
+ setStatusTip -widget $frame1_top_right_0._SP_l -text [mc "SFR 0x81: Stack pointer"]
# Create hexadecimal entry for register: SP
set ::Simulator_GUI::ENV${obj_idx}_SP {07}
@@ -1243,7 +1269,7 @@ class Simulator_GUI {
]
# Show and register created memory cell (SP)
- grid $entry -row 2 -column 5 -sticky w
+ grid $entry -row 2 -column 5
add_entry $entry
$this add_sfr_entry 129 $entry
@@ -1258,7 +1284,7 @@ class Simulator_GUI {
bind $entry <Enter> "$this create_help_window_ram SP; Sbar -freeze {SFR 0x81: Stack pointer}"
# Create DPTR1
- if {[$this get_feature_avaliable {ddp}] && ![$this get_feature_avaliable {hddptr}]} {
+ if {[$this get_feature_available {ddp}] && ![$this get_feature_available {hddptr}]} {
# Create label "DPTR1:"
grid [label $frame1_top_right_0._DPTR1_l \
@@ -1315,7 +1341,7 @@ class Simulator_GUI {
focus $frame1_top_right_0._DPL_e"
set row 4
- } {
+ } else {
set row 3
}
@@ -1332,7 +1358,7 @@ class Simulator_GUI {
-style Simulator.TEntry \
-textvariable ::Simulator_GUI::ENV${obj_idx}_CLOCK \
-font $entry_font \
- -width 6 \
+ -width 7 \
-validate all \
-validatecommand "$this clock_validate %P" \
]
@@ -1359,13 +1385,13 @@ class Simulator_GUI {
incr row
# Create label "SBUF X:"
- if {[$this get_feature_avaliable uart]} {
+ if {[$this get_feature_available uart]} {
set label [label $frame1_top_right_0._${reg}_l \
-text "${regname}:" -fg $name_color \
-font $bitfont -pady 0 \
]
grid $label -row $row -column 4
- setStatusTip -widget $label -text $stip
+ setStatusTip -widget $label -text [mc $stip]
# Create hexadecimal entry for memory cell: SBUF
@@ -1404,7 +1430,7 @@ class Simulator_GUI {
-text {PC:} -fg $name_nr_color \
-font $bitfont \
] -side left
- setStatusTip -widget $pc_lbl_but_frm._PC_l -text $stip
+ setStatusTip -widget $pc_lbl_but_frm._PC_l -text [mc $stip]
set set_pc_by_line_button [ttk::button $pc_lbl_but_frm._PC_but \
-image ::ICONS::16::2_rightarrow \
-command "::X::__simulator_set_PC_by_line" \
@@ -1412,7 +1438,7 @@ class Simulator_GUI {
]
pack $set_pc_by_line_button -side right -after $pc_lbl_but_frm._PC_l
DynamicHelp::add $set_pc_by_line_button \
- -text [mc "Set PC (Program Counter) acording to\nline number in source code"]
+ -text [mc "Set PC (Program Counter) according to\nline number in source code"]
add_entry $pc_lbl_but_frm._PC_but
setStatusTip -widget $set_pc_by_line_button \
-text [mc "Set PC by line number"]
@@ -1438,7 +1464,7 @@ class Simulator_GUI {
-validatecommand "$this sim_eval_PC hex %P" \
-font $entry_font \
]
- setStatusTip -widget $frame1_top_right_0_0._PC_hex_e -text $stip
+ setStatusTip -widget $frame1_top_right_0_0._PC_hex_e -text [mc $stip]
# Show and register created entry (PC - hex)
grid $entry -row 1 -column 2
@@ -1467,7 +1493,7 @@ class Simulator_GUI {
-validatecommand "$this sim_eval_PC dec %P" \
-font $entry_font \
]
- setStatusTip -widget $frame1_top_right_0_1._PC_dec_e -text $stip
+ setStatusTip -widget $frame1_top_right_0_1._PC_dec_e -text [mc $stip]
# Show and register created entry (PC - dec)
grid $entry -row 1 -column 2
@@ -1495,7 +1521,7 @@ class Simulator_GUI {
-style TEntry \
-textvariable ::Simulator_GUI::ENV${obj_idx}_TIME \
-state readonly \
- -font [font create -size -12 -family $::DEFAULT_FIXED_FONT] \
+ -font [font create -size [expr {int(-12 * $::font_size_factor)}] -family $::DEFAULT_FIXED_FONT] \
]
setStatusTip -widget $frame1_top_right_1._TIME_e -text [mc "Overall time"]
@@ -1513,7 +1539,7 @@ class Simulator_GUI {
set bottom_left_bottom_trow 0 ;# Row in grid
# Create controls related to Timer/Couter 2
- if {[$this get_feature_avaliable t2]} {
+ if {[$this get_feature_available t2]} {
incr bottom_left_bottom_row 4
set t2_frame [frame $bottom_left_frame.timers_f]
pack $t2_frame
@@ -1598,7 +1624,7 @@ class Simulator_GUI {
-validatecommand "$this validate_Txx $reg %P" \
-font $entry_font \
]
- setStatusTip -widget $timers_values_f._Txx${col}_e -text $stip
+ setStatusTip -widget $timers_values_f._Txx${col}_e -text [mc $stip]
# Show and register created memory cell
grid $entry -row 2 -column $col
@@ -1639,7 +1665,7 @@ class Simulator_GUI {
{Timer 2 Capture/Reload bit\nIf RCLK=1 or TCLK=1, CP/RL2# is ignored and timer is forced to auto-reload on timer 2 overflow.\nClear to auto-reload on timer 2 overflows or negative transitions on T2EX pin if EXEN2=1.\nSet to capture on negative transitions on T2EX pin if EXEN2=1.}
}
- if {[$this get_feature_avaliable t2mod]} {
+ if {[$this get_feature_available t2mod]} {
create_bitmap_register $timers_frame_reg 2 T2MOD {- - - - - - T2OE DCEN} 1 {
{Reserved}
{Reserved}
@@ -1671,7 +1697,7 @@ class Simulator_GUI {
} {
incr col ;# Increment grid column
- if {$reg == {T2MOD} && ![$this get_feature_avaliable t2mod]} {
+ if {$reg == {T2MOD} && ![$this get_feature_available t2mod]} {
continue
}
@@ -1723,38 +1749,38 @@ class Simulator_GUI {
set bottom_middle_row 0 ;# Row in grid
# Registers: AUXR, AUXR1, ACSR, EECON, SPCR, SPSR, WDTCON. IPH, SPCR
- if {[$this get_feature_avaliable t2]} {
+ if {[$this get_feature_available t2]} {
set pt2h {PT2H}
set pt2h_stip {Defines the Timer 2 interrupt priority level}
set pt2h_ttip {Timer 2 interrupt priority bit}
- } {
+ } else {
set pt2h {-}
set pt2h_stip {Not implemented}
set pt2h_ttip {Not implemented}
}
- if {[$this get_feature_avaliable uart]} {
+ if {[$this get_feature_available uart]} {
set psh {PSH}
set psh_stip {Defines the Serial Port interrupt priority level}
set psh_ttip {Serial Port interrupt priority bit}
- } {
+ } else {
set psh {-}
set psh_stip {Not implemented}
set psh_ttip {Not implemented}
}
- if {[$this get_feature_avaliable acomparator]} {
+ if {[$this get_feature_available acomparator]} {
set pch {PCH}
set pch_stip {Defines the comparator interrupt priority level}
set pch_ttip {Comparator Interrupt Priority bit}
- } {
+ } else {
set pch {-}
set pch_stip {Not implemented}
set pch_ttip {Not implemented}
}
- if {[$this get_feature_avaliable pwdex]} {
+ if {[$this get_feature_available pwdex]} {
set PWDEX {PWDEX}
set pwdex_stip {Power-down Exit Mode}
set pwdex_ttip {Power-down Exit Mode. When PWDEX = 1, wake up from Power-down is externally controlled.\nWhen PWDEX = 0, wake up from Power-down is internally timed.}
- } {
+ } else {
set PWDEX {-}
set pwdex_stip {Not implemented}
set pwdex_ttip {Not implemented}
@@ -1763,7 +1789,7 @@ class Simulator_GUI {
set EXTRAM {EXTRAM}
set extram_statustip {Internal/External RAM access using MOVX}
set extram_tooltip {Internal/External RAM access using MOVX @ Ri/@DPTR\nEXTRAM\tOperating Mode\n0\tInternal ERAM (00H-FFH) access using MOVX @ Ri/@DPTR\n1\tExternal data memory access}
- } elseif {[$this get_feature_avaliable intelpe]} {
+ } elseif {[$this get_feature_available intelpe]} {
set EXTRAM {IPE}
set extram_statustip {Intel_Pwd_Exit}
set extram_tooltip {When set, this bit configures the interrupt driven exit from power-down\nto resume execution on the rising edge of the interrupt signal. When\nthis bit is cleared, the execution resumes after a self-timed interval\n(nominal 2 ms) referenced from the falling edge of the interrupt signal.}
@@ -1773,9 +1799,9 @@ class Simulator_GUI {
set extram_tooltip {Reserved\nThe value read from this bit is indeterminate. Do not set this bit.}
}
if {
- [$this get_feature_avaliable wdtcon] ||
- ![$this get_feature_avaliable wtd] ||
- ![$this get_feature_avaliable auxrdisrto]
+ [$this get_feature_available wdtcon] ||
+ ![$this get_feature_available wtd] ||
+ ![$this get_feature_available auxrdisrto]
} then {
set DISRTO {-}
set disrto_stip {Reserved for future expansion}
@@ -1786,9 +1812,9 @@ class Simulator_GUI {
set disrto_ttip {Disable/Enable Reset out\nDISRTO\tOperating Mode\n0\tReset pin is driven High after WDT times out\n1\tReset pin is input only}
}
if {
- [$this get_feature_avaliable wdtcon] ||
- ![$this get_feature_avaliable wtd] ||
- ![$this get_feature_avaliable auxrwdidle]
+ [$this get_feature_available wdtcon] ||
+ ![$this get_feature_available wtd] ||
+ ![$this get_feature_available auxrwdidle]
} then {
set WDIDLE {-}
set wdidle_stip {Reserved for future expansion}
@@ -1798,16 +1824,16 @@ class Simulator_GUI {
set wdidle_stip {Disable/Enable WDT in IDLE mode}
set wdidle_ttip {Disable/Enable WDT in IDLE mode\nWDIDLE\tOperating Mode\n0\tWDT continues to count in IDLE mode\n1\tWDT halts counting in IDLE mode}
}
- if {[$this get_feature_avaliable ao]} {
+ if {[$this get_feature_available ao]} {
set DISALE {AO}
- } {
+ } else {
set DISALE {DISALE}
}
- if {[$this get_feature_avaliable auxr1gf3]} {
+ if {[$this get_feature_available auxr1gf3]} {
set GF3 {GF3}
set gf3_ttip {General purpose user flag}
set gf3_stip {General purpose user flag}
- } {
+ } else {
set GF3 {-}
set gf3_ttip {Reserved\nThe value read from this bit is indeterminate. Do not set this bit.}
set gf3_stip {Reserved for future expansion}
@@ -1829,8 +1855,8 @@ class Simulator_GUI {
[list - $pch $pt2h $psh PT1H PX1H PT0H PX0H] \
[list - - - - - - $PWDEX X2] \
] stip {
- {SFR 0x8E: Auxillary Register}
- {SFR 0xA2: Auxillary Register 1}
+ {SFR 0x8E: Auxiliary Register}
+ {SFR 0xA2: Auxiliary Register 1}
{SFR 0x97: Analog Comparator Control and Status Register}
{SFR 0x96: Data EEPROM Control Register}
{SFR 0xD5: SPI Control Register}
@@ -1843,14 +1869,14 @@ class Simulator_GUI {
if {$cg_left && $bottom_middle_row > $bottom_left_bottom_row} {
set left__right 1
set target_frame $bottom_left_bottom_frame
- } {
+ } else {
set left__right 0
set target_frame $bottom_middle_frame
}
switch -- $reg {
{IPH} {
- if {![$this get_feature_avaliable iph]} {
+ if {![$this get_feature_available iph]} {
continue
}
create_bitmap_register $target_frame $row $reg $bits 1 [list \
@@ -1874,9 +1900,9 @@ class Simulator_GUI {
]
}
{CLKREG} {
- if {[$this get_feature_avaliable clkreg]} {
+ if {[$this get_feature_available clkreg]} {
set reg {CLKREG}
- } elseif {[$this get_feature_avaliable ckcon]} {
+ } elseif {[$this get_feature_available ckcon]} {
set reg {CKCON}
} else {
continue
@@ -1932,7 +1958,7 @@ class Simulator_GUI {
bind $Simulator_panel_parent._EECON_RDYBSY <ButtonRelease-3> {break}
}
{WDTCON} {
- if {![$this get_feature_avaliable wdtcon] || [$this get_feature_avaliable wdtprg]} {
+ if {![$this get_feature_available wdtcon] || [$this get_feature_available wdtprg]} {
continue
}
set psx_tooltip {Prescaler bits for the watchdog timer (WDT). When all three bits are cleared\nto 0, the watchdog timer has a nominal period of 16K machine cycles,\n(i.e. 16 ms at a XTAL frequency of 12 MHz in normal mode or 6 MHz in x2 mode).\nWhen all three bits are set to 1, the nominal period is 2048K machine cycles,\n(i.e. 2048 ms at 12 MHz clock frequency in normal mode or 6 MHz in x2 mode).}
@@ -1958,7 +1984,7 @@ class Simulator_GUI {
]
}
{WDTPRG} {
- if {![$this get_feature_avaliable wdtprg] || [$this get_feature_avaliable wdtcon]} {
+ if {![$this get_feature_available wdtprg] || [$this get_feature_available wdtcon]} {
continue
}
set t_stip {Reserved}
@@ -1981,7 +2007,7 @@ class Simulator_GUI {
}
}
{SPSR} {
- if {![$this get_feature_avaliable spi]} {
+ if {![$this get_feature_available spi]} {
continue
}
create_bitmap_register $target_frame $row $reg $bits 1 {
@@ -2005,7 +2031,7 @@ class Simulator_GUI {
}
}
{SPCR} {
- if {![$this get_feature_avaliable spi]} {
+ if {![$this get_feature_available spi]} {
continue
}
create_bitmap_register $target_frame $row $reg $bits 1 [list \
@@ -2029,7 +2055,7 @@ class Simulator_GUI {
]
}
{ACSR} {
- if {![$this get_feature_avaliable acomparator]} {
+ if {![$this get_feature_available acomparator]} {
continue
}
set CMx_tooltip {Comparator Interrupt Mode\n 2 1 0\tInterrupt Mode\n--- --- ---\t---------------------------------------\n 0 0 0\tNegative (Low) level\n 0 0 1\tPositive edge\n 0 1 0\tToggle with debounce\n 0 1 1\tPositive edge with debounce\n 1 0 0\tNegative edge\n 1 0 1\tToggle\n 1 1 0\tNegative edge with debounce\n 1 1 1\tPositive (High) level}
@@ -2053,8 +2079,8 @@ class Simulator_GUI {
}
{AUXR1} {
if {
- (![$this get_feature_avaliable ddp] || [$this get_feature_avaliable wdtcon])
- && ![$this get_feature_avaliable auxr1gf3]
+ (![$this get_feature_available ddp] || [$this get_feature_available wdtcon])
+ && ![$this get_feature_available auxr1gf3]
} then {
continue
}
@@ -2079,7 +2105,7 @@ class Simulator_GUI {
]
}
{AUXR} {
- if {![$this get_feature_avaliable auxr]} {
+ if {![$this get_feature_available auxr]} {
continue
}
create_bitmap_register $target_frame $row $reg $bits 1 [list \
@@ -2129,7 +2155,7 @@ class Simulator_GUI {
if {$reg != {EECON}} {
set ::Simulator_GUI::ENV${obj_idx}_${reg} {00}
- } {
+ } else {
set ::Simulator_GUI::ENV${obj_idx}_${reg} {03}
}
@@ -2149,7 +2175,7 @@ class Simulator_GUI {
if {$left__right} {
incr bottom_left_bottom_row
incr bottom_left_bottom_trow
- } {
+ } else {
incr bottom_middle_row
}
}
@@ -2174,7 +2200,7 @@ class Simulator_GUI {
pack $bottom_right_spec_frame -anchor nw -fill both
## Create watchdog timer controls
- if {[$this get_feature_avaliable wtd]} {
+ if {[$this get_feature_available wtd]} {
set bottom_right_present 1
set watchdog_frame [frame $bottom_right_frame.watchdog_frame]
pack $watchdog_frame -anchor nw -before $bottom_right_reg_frame
@@ -2188,8 +2214,8 @@ class Simulator_GUI {
# Create ON/OFF switch
set watchdog_onoff_switch [label $watchdog_frame.on_off_switch \
-text [mc "OFF"] -fg $off_color -pady 0 \
- -bd 1 -cursor hand1 -font [font create \
- -family $::DEFAULT_FIXED_FONT -size -12 \
+ -bd 1 -cursor hand2 -font [font create \
+ -family $::DEFAULT_FIXED_FONT -size [expr {int(-12 * $::font_size_factor)}] \
-weight bold \
] \
]
@@ -2198,7 +2224,7 @@ class Simulator_GUI {
pack $watchdog_onoff_switch -side left -padx 2
# Create entryBox for watchdog prescaler
- if {[$this get_feature_avaliable wdtcon] || [$this get_feature_avaliable wdtprg]} {
+ if {[$this get_feature_available wdtcon] || [$this get_feature_available wdtprg]} {
# Create hexadecimal entry for created entry: WatchDog
set ::Simulator_GUI::ENV${obj_idx}_WatchDogP {00}
set wdt_prescaler_entry [ttk::entry $watchdog_frame._WatchDogP_e\
@@ -2263,7 +2289,7 @@ class Simulator_GUI {
{SFR 0x86: SPI Data Register}
{SFR 0xA6: Watchdog reset}
} {
- if {![$this get_feature_avaliable $feature]} {
+ if {![$this get_feature_available $feature]} {
continue
}
if {$col >= 4} {
@@ -2357,7 +2383,7 @@ class Simulator_GUI {
## Show EEPROM write progress indicator
# @return void
public method simulator_GUI_invoke_write_to_eeprom {} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
# Create EEPROM indicator frame and horizonatl separator above it
set eeprom_operation_frame [frame $bottom_right_spec_frame.frame]
@@ -2409,7 +2435,7 @@ class Simulator_GUI {
## Hide EEPROM write progress indicator
# @return void
public method simulator_GUI_cancel_write_to_eeprom {} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
set ::Simulator_GUI::ENV${obj_idx}_EEPROM_prg 1
if {[winfo exists $eeprom_operation_frame]} {
@@ -2421,7 +2447,7 @@ class Simulator_GUI {
# @parm Int value - New progress value in percents minus one (1..101)
# @return void
public method simulator_WTE_prg_set {value} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
if {$value < 1} {
set value 1
@@ -2445,14 +2471,14 @@ class Simulator_GUI {
$eeprom_progressbar configure -fg $clr
}
- ## Adjust watchdog on/off switch acording to current state
+ ## Adjust watchdog on/off switch according to current state
# @return void
public method simulator_evaluate_wtd_onoff_switch {} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
if {[$this simulator_isWatchDogTimerRuning]} {
$watchdog_onoff_switch configure -text [mc "ON "] -fg $on_color
- } {
+ } else {
$watchdog_onoff_switch configure -text [mc "OFF"] -fg $off_color
}
}
@@ -2460,12 +2486,12 @@ class Simulator_GUI {
## Invert watchdog on/off flag
# @return void
public method simulator_invert_wtd_onoff_switch {} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
if {!$sim_enabled} {return}
if {[$this simulator_isWatchDogTimerRuning]} {
$this simulator_startStopWatchDogTimer 0
- } {
+ } else {
$this simulator_startStopWatchDogTimer 1
}
simulator_evaluate_wtd_onoff_switch
@@ -2512,7 +2538,7 @@ class Simulator_GUI {
catch {
if {!$dec_value || !$sim_enabled} {
$wtd_clear_button configure -state disabled
- } {
+ } else {
$wtd_clear_button configure -state normal
}
}
@@ -2541,7 +2567,7 @@ class Simulator_GUI {
# This function cannot run multithreaded
if {$sync_Txx_in_progress} {
return 1
- } {
+ } else {
set sync_Txx_in_progress 1
}
@@ -2628,7 +2654,7 @@ class Simulator_GUI {
}
# Validation of THx, TLx or RCAPxL, RCAPxH
- } {
+ } else {
# Check for corrent value
if {![entry_2_hex_validate $content]} {
set sync_Txx_in_progress 0
@@ -2638,23 +2664,23 @@ class Simulator_GUI {
## Determinate vaiable of Tx entry and low-order and high-order bytes of Tx
# TH0 or TL0
if {$registerName == {TH0} || $registerName == {TL0}} {
- set hex_h [subst "\$::Simulator_GUI::ENV${obj_idx}_TH0"]
- set hex_l [subst "\$::Simulator_GUI::ENV${obj_idx}_TL0"]
+ set hex_h [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_TH0"]
+ set hex_l [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_TL0"]
set target_var "::Simulator_GUI::ENV${obj_idx}_T0"
# TH1 or TL1
} elseif {$registerName == {TH1} || $registerName == {TL1}} {
- set hex_h [subst "\$::Simulator_GUI::ENV${obj_idx}_TH1"]
- set hex_l [subst "\$::Simulator_GUI::ENV${obj_idx}_TL1"]
+ set hex_h [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_TH1"]
+ set hex_l [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_TL1"]
set target_var "::Simulator_GUI::ENV${obj_idx}_T1"
# TH2 or TL2
} elseif {$registerName == {TH2} || $registerName == {TL2}} {
- set hex_h [subst "\$::Simulator_GUI::ENV${obj_idx}_TH2"]
- set hex_l [subst "\$::Simulator_GUI::ENV${obj_idx}_TL2"]
+ set hex_h [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_TH2"]
+ set hex_l [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_TL2"]
set target_var "::Simulator_GUI::ENV${obj_idx}_T2"
# RCAP2H or RCAP2L
} elseif {$registerName == {RCAP2H} || $registerName == {RCAP2L}} {
- set hex_h [subst "\$::Simulator_GUI::ENV${obj_idx}_RCAP2H"]
- set hex_l [subst "\$::Simulator_GUI::ENV${obj_idx}_RCAP2L"]
+ set hex_h [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_RCAP2H"]
+ set hex_l [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_RCAP2L"]
set target_var "::Simulator_GUI::ENV${obj_idx}_RCAP2"
}
@@ -2707,17 +2733,17 @@ class Simulator_GUI {
# possibly new value of bit SCON.7 (FE/SM0)
# @return void
public method simulator_gui_SMOD0_changed {} {
- set scon [subst "\$::Simulator_GUI::ENV${obj_idx}_SCON"]
+ set scon [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_SCON"]
if {$scon == {}} {
set scon 0
}
set scon [expr {"0x$scon" & 0x7F}]
if {[$this get_SMOD0]} {
- if {[subst "\$::Simulator_GUI::ENV${obj_idx}_SFR(FE)"]} {
+ if {[subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_SFR(FE)"]} {
set scon [expr {$scon | 0x80}]
}
- } {
- if {[subst "\$::Simulator_GUI::ENV${obj_idx}_SFR(SM0)"]} {
+ } else {
+ if {[subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_SFR(SM0)"]} {
set scon [expr {$scon | 0x80}]
}
}
@@ -2737,7 +2763,7 @@ class Simulator_GUI {
# This function cannot run multithreaded
if {$bitmap_hex_validation_ena} {
set bitmap_hex_validation_ena 0
- } {
+ } else {
return 1
}
@@ -2771,7 +2797,7 @@ class Simulator_GUI {
SCON {
if {[$this get_SMOD0]} {
lset bitList 0 FE
- } {
+ } else {
lset bitList 0 SM0
}
}
@@ -2789,7 +2815,7 @@ class Simulator_GUI {
set bitVal [lindex $bits $i]
if {$bitVal} {
set color $on_color
- } {
+ } else {
set color $off_color
}
@@ -2831,7 +2857,7 @@ class Simulator_GUI {
-text "[mc $name]:" -fg $name_color \
-anchor w -pady 0 -font $bitfont \
] -row $row -column 1 -in $parent -sticky w
- setStatusTip -widget $Simulator_panel_parent._${name}_l -text $stip
+ setStatusTip -widget $Simulator_panel_parent._${name}_l -text [mc $stip]
set col 1 ;# Bit label column (2..9)
set bitNum -1 ;# Bit number (0..7)
@@ -2847,9 +2873,9 @@ class Simulator_GUI {
incr Idx
set idx $Idx
set cursor {left_ptr}
- } {
+ } else {
set color $off_color
- set cursor {hand1}
+ set cursor {hand2}
set idx {}
}
@@ -2863,7 +2889,7 @@ class Simulator_GUI {
bind $label <Enter> {+%W configure -font $::Simulator_GUI::bitfont_under}
bind $label <Leave> {+%W configure -font $::Simulator_GUI::bitfont}
}
- DynamicHelp::add $label -text [subst [mc $tooltip]]
+ DynamicHelp::add $label -text [mc [subst $tooltip]]
grid $label -row $row -column $col -in $parent
# Skip registration of empty bits
@@ -2894,7 +2920,7 @@ class Simulator_GUI {
# @parm void
public method bit_popup_menu_setto {bool} {
if {!$sim_enabled} {return}
- if {$bool != [subst "\$::Simulator_GUI::ENV${obj_idx}_SFR([lindex $bit_popup_menu_args 0])"]} {
+ if {$bool != [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_SFR([lindex $bit_popup_menu_args 0])"]} {
eval "sim_invert $bit_popup_menu_args"
}
}
@@ -2908,7 +2934,7 @@ class Simulator_GUI {
# This function cannot run multithreaded
if {$sync_PC_in_progress} {
return 1
- } {
+ } else {
set sync_PC_in_progress 1
}
@@ -2972,7 +2998,7 @@ class Simulator_GUI {
set lineNum [$this simulator_getCurrentLine]
if {$lineNum != {}} {
$this move_simulator_line $lineNum
- } {
+ } else {
$this editor_procedure {} unset_simulator_line {}
}
}
@@ -2992,7 +3018,7 @@ class Simulator_GUI {
# This function cannot run multithreaded
if {$sync_Px_in_progress} {
return 1
- } {
+ } else {
set sync_Px_in_progress 1
}
@@ -3079,7 +3105,7 @@ class Simulator_GUI {
# This function cannot run multithreaded
if {$sync_AB_in_progress} {
return 1
- } {
+ } else {
set sync_AB_in_progress 1
}
@@ -3089,7 +3115,7 @@ class Simulator_GUI {
return 1
}
- # Determinate maximum length acording to numeric base
+ # Determinate maximum length according to numeric base
switch -- $num_base {
{hex} {set max_len 2}
{dec} {set max_len 3}
@@ -3174,15 +3200,15 @@ class Simulator_GUI {
}
# Determinate character representation
if {$dec > 31 && $dec < 127} {
- set char [subst "\\u00$hex"]
- } {
+ set char [subst -nocommands "\\u00$hex"]
+ } else {
set char {}
}
# Synchronize with other entries
foreach base {hex dec bin oct char} {
if {$base == $num_base} {continue}
- set ::Simulator_GUI::ENV${obj_idx}_${register}_$base [subst "\$$base"]
+ set ::Simulator_GUI::ENV${obj_idx}_${register}_$base [subst -nocommands "\$$base"]
}
# Synchronize with Right panel and Engine
@@ -3194,7 +3220,7 @@ class Simulator_GUI {
$this sfr_watches_sync 224 $dec_val
$this sfrmap_map_sync 224 $dec_val
# Register B
- } {
+ } else {
$this setSfr 240 $hex
set dec_val [expr "0x$hex"]
$this sfr_watches_sync 240 $dec_val
@@ -3212,8 +3238,8 @@ class Simulator_GUI {
# @return void
public method create_help_window_Rx {R_index} {
# Determinate true register address (decimal)
- set RS0 [subst "\$::Simulator_GUI::ENV${obj_idx}_SFR(RS0)"]
- set RS1 [subst "\$::Simulator_GUI::ENV${obj_idx}_SFR(RS1)"]
+ set RS0 [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_SFR(RS0)"]
+ set RS1 [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_SFR(RS1)"]
if {$RS0} {incr R_index 8}
if {$RS1} {incr R_index 16}
@@ -3228,11 +3254,11 @@ class Simulator_GUI {
# @parm String bit - Bit name (not address)
# @return void
public method sim_GUI_bit_set_clear {bool reg bit} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
if {$bool} {
$Simulator_panel_parent._${reg}_${bit} configure -fg $on_color
- } {
+ } else {
$Simulator_panel_parent._${reg}_${bit} configure -fg $off_color
}
}
@@ -3244,14 +3270,14 @@ class Simulator_GUI {
# @parm Bool hex_reg - Bitmap is connected to hexadecimal entry
# @return void
public method sim_invert {bitName bitNumber registerName hex_reg} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
set decVal_increment 0
# Simulator must be engaged
if {!$sim_enabled} {return}
# Determinate bit boolean value
- set bitBoolVal [subst "\$::Simulator_GUI::ENV${obj_idx}_SFR($bitName)"]
+ set bitBoolVal [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_SFR($bitName)"]
# Determinate bit decimal and hexadecimal value
set addr [symb_name_to_hex_addr $registerName]
@@ -3260,8 +3286,8 @@ class Simulator_GUI {
set bitDecVal 0
set bitmap_hex_validation_ena 0
if {$hex_reg} {
- set decVal [expr "0x[subst "\$::Simulator_GUI::ENV${obj_idx}_${registerName}"]"]
- } {
+ set decVal [expr "0x[subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_${registerName}"]"]
+ } else {
set decVal [$this getSfrDEC $addr]
}
switch -- $bitNumber {
@@ -3279,7 +3305,7 @@ class Simulator_GUI {
if {$bitBoolVal} {
$Simulator_panel_parent._${registerName}_$bitName configure -fg $off_color
set decVal_increment -$bitDecVal
- } {
+ } else {
$Simulator_panel_parent._${registerName}_$bitName configure -fg $on_color
set decVal_increment $bitDecVal
}
@@ -3434,16 +3460,16 @@ class Simulator_GUI {
{86} {return SPDR}
{96} {return EECON}
{8F} {
- if {[$this get_feature_avaliable ckcon]} {
+ if {[$this get_feature_available ckcon]} {
return {CKCON}
- } {
+ } else {
return {CLKREG}
}
}
{A7} {
- if {[$this get_feature_avaliable wdtcon]} {
+ if {[$this get_feature_available wdtcon]} {
return {WDTCON}
- } {
+ } else {
return {WDTPRG}
}
}
@@ -3453,7 +3479,7 @@ class Simulator_GUI {
## Switch active register bank (Current bank number is based on bits SFR(RS0) SFR(RS1))
# @return void
public method sim_switch_bank {} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
# Determinate bank offset
set bnk [$this getBank]
@@ -3461,7 +3487,7 @@ class Simulator_GUI {
# Synchronize active bank register entries
for {set i 0} {$i < 8} {incr i} {
- set value [subst "\$::Simulator_GUI::ENV${obj_idx}_DATA([expr {$index + $i}])"]
+ set value [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_DATA([expr {$index + $i}])"]
set ::Simulator_GUI::ENV${obj_idx}_R$i $value
}
}
@@ -3661,7 +3687,7 @@ class Simulator_GUI {
# Register name (SFR only)
} else {
- set val [subst "\$::Simulator_GUI::ENV${obj_idx}_$addr"]
+ set val [subst -nocommands "\$::Simulator_GUI::ENV${obj_idx}_$addr"]
set addr [symb_name_to_hex_addr $addr]
append addr { SFR}
}
@@ -3675,9 +3701,12 @@ class Simulator_GUI {
# @return Bool - result
public method clock_validate {number} {
# Check for allowed characters
- if {![string is digit -strict $number]} {
+ if {$number == {}} {
+ set number 0
+ } elseif {![regexp {^\d+(\.\d*)?$} $number]} {
return 0
}
+ set number [string trimright $number {.}]
# Check for allowed range
if {$number > 99999} {
@@ -3697,11 +3726,11 @@ class Simulator_GUI {
# @parm String args - any arguments
# @return void
public method simulator_hexeditor {args} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
eval "$hexeditor $args"
}
- ## Binding for event CellValueChanged in hexeditor
+ ## Binding for event CellValueChanged in hex editor
# @parm Int address - Address of changed cell
# @parm Int value - New cell value
# @return void
@@ -3716,7 +3745,7 @@ class Simulator_GUI {
if {$address < 32} {
set ::Simulator_GUI::ENV${obj_idx}_DATA($address) $value
entry_bank_reg_sync $address $value
- } {
+ } else {
entry_idata_reg_sync $address $value
}
}
@@ -3729,7 +3758,7 @@ class Simulator_GUI {
public method simulator_gui_scroll_set {orient frac0 frac1} {
if {$orient == {x}} {
set scrollbar $horizontal_scrollbar
- } {
+ } else {
set scrollbar $vertical_scrollbar
}
@@ -3740,11 +3769,11 @@ class Simulator_GUI {
update
}
# Show scrollbar
- } {
+ } else {
if {![winfo ismapped $scrollbar]} {
if {$orient == {x}} {
pack $scrollbar -fill x -side top -before $scrollable_frame
- } {
+ } else {
pack $scrollbar -fill y -side left
}
}
@@ -3761,7 +3790,7 @@ class Simulator_GUI {
unset ::Simulator_GUI::ENV${obj_idx}_${var}
}
}
- if {$gui_initialized} {
+ if {$sim_gui_gui_initialized} {
menu_Sbar_remove $bitmenu
}
}
@@ -3781,14 +3810,14 @@ class Simulator_GUI {
## Change image on button "Step over" (from "Pause" to "Goto" or backwards)
# @return void
public method invert_stepover_button {} {
- if {!$gui_initialized || !$sim_enabled} {return}
+ if {!$sim_gui_gui_initialized || !$sim_enabled} {return}
# Determinate ID of the current image
set image [$ctrl_f.controls_quick_step cget -image]
# Change image
if {$image == {::ICONS::16::goto2}} {
$ctrl_f.controls_quick_step configure -image ::ICONS::16::player_pause
- } {
+ } else {
$ctrl_f.controls_quick_step configure -image ::ICONS::16::goto2
}
}
@@ -3796,14 +3825,14 @@ class Simulator_GUI {
## Change image on button "Animate" (from "Pause" to "Right arrow" or backwards)
# @return void
public method invert_animate_button {} {
- if {!$gui_initialized || !$sim_enabled} {return}
+ if {!$sim_gui_gui_initialized || !$sim_enabled} {return}
# Determinate ID of the current image
set image [$ctrl_f.controls_animate cget -image]
# Change image
if {$image == {::ICONS::16::1rightarrow}} {
$ctrl_f.controls_animate configure -image ::ICONS::16::player_pause
- } {
+ } else {
$ctrl_f.controls_animate configure -image ::ICONS::16::1rightarrow
}
}
@@ -3811,14 +3840,14 @@ class Simulator_GUI {
## Change image on button "Run" (from "Pause" to "Double right arrow" or backwards)
# @return void
public method invert_run_button {} {
- if {!$gui_initialized || !$sim_enabled} {return}
+ if {!$sim_gui_gui_initialized || !$sim_enabled} {return}
# Determinate ID of the current image
set image [$ctrl_f.controls_run cget -image]
# Change image
if {$image == {::ICONS::16::2rightarrow}} {
$ctrl_f.controls_run configure -image ::ICONS::16::player_pause
- } {
+ } else {
$ctrl_f.controls_run configure -image ::ICONS::16::2rightarrow
}
}
@@ -3826,11 +3855,11 @@ class Simulator_GUI {
## Set state of button "StepBack" on simulator control panel
# @return void
public method stepback_button_set_ena {bool} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
if {$bool} {
set state {normal}
- } {
+ } else {
set state {disabled}
}
$ctrl_f.controls_stepback configure -state $state
@@ -3839,7 +3868,7 @@ class Simulator_GUI {
## Disable simulator control panel (shoud be called after simulator engine disengagement)
# @return void
public method sim_disable {} {
- if {!$gui_initialized} {return}
+ if {!$sim_gui_gui_initialized} {return}
set sim_enabled 0 ;# Clear enabled flag
@@ -3877,7 +3906,7 @@ class Simulator_GUI {
## Enable simulator control panel (shoud be called after simulator engine engagement)
# @return void
public method sim_enable {} {
- if {!$gui_initialized} {CreateSimulatorGUI}
+ if {!$sim_gui_gui_initialized} {CreateSimulatorGUI}
set sim_enabled 1 ;# Set enabled flag
@@ -3915,7 +3944,12 @@ class Simulator_GUI {
# @parm String text - text to display
# @return void
public method sim_txt_output {txt} {
- tk_messageBox -title [mc "Simulator"] -type ok -message $txt
+ tk_messageBox \
+ -parent . \
+ -icon info \
+ -type ok \
+ -message $txt \
+ -title [mc "Simulator"]
}
## Focus on the given target entry widget if the current insertion index is equivalent to the end index
@@ -3944,10 +3978,10 @@ class Simulator_GUI {
focus $target_entry
}
- ## Get list of avaliable SFRs
+ ## Get list of available SFRs
# @return List - {{dec_addr reg_name} ...}
public method simulator_get_sfrs {} {
- if {!$gui_initialized} {CreateSimulatorGUI}
+ if {!$sim_gui_gui_initialized} {CreateSimulatorGUI}
return $sf_registers
}
@@ -3967,15 +4001,15 @@ class Simulator_GUI {
if {$bool} {
if {[$widget cget -font] == $smallfont} {
set bg $small_color
- } {
+ } else {
set bg $name_color
}
set fg {#FFFFFF}
- } {
- set bg {#EEEEEE}
+ } else {
+ set bg ${::COMMON_BG_COLOR}
if {[$widget cget -font] == $smallfont} {
set fg $small_color
- } {
+ } else {
set fg $name_color
}
}
@@ -3984,3 +4018,7 @@ class Simulator_GUI {
$widget configure -bg $bg -fg $fg
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/stackmonitor.tcl b/lib/simulator/stackmonitor.tcl
index 8f83ab2..b51fabb 100755..100644
--- a/lib/simulator/stackmonitor.tcl
+++ b/lib/simulator/stackmonitor.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 _STACKMONITOR_TCL ] } {
+set _STACKMONITOR_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -31,20 +36,20 @@ class StackMonitor {
## COMMON
common push_value {} ;# String: Value to PUSH onto the stack by user
- common count 0 ;# Int: Counter of intances
+ common stack_mon_count 0 ;# Int: Counter of intances
common geometry ${::CONFIG(STACK_MON_GEOMETRY)} ;# Geometry: Last window geometry
common collapsed ${::CONFIG(STACK_MON_COLLAPSED)};# Bool: Bottom bar hidden
# Font for the text widget representing the stack (bold)
- common font0 [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ common font0 [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
# Font for the text widget representing the stack (normal)
- common font1 [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight normal \
+ common font1 [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight normal \
]
## PRIVATE
@@ -64,8 +69,8 @@ class StackMonitor {
constructor {} {
# Increment counter of object instances
- incr count
- set obj_idx $count
+ incr stack_mon_count
+ set obj_idx $stack_mon_count
}
destructor {
@@ -84,8 +89,8 @@ class StackMonitor {
set dialog_opened 1
# Create dialog window
- set win [toplevel .stack_monitor$count -class {Interrupt monitor} -bg {#EEEEEE}]
- incr count
+ set win [toplevel .stack_monitor${stack_mon_count} -class {Interrupt monitor} -bg ${::COMMON_BG_COLOR}]
+ incr stack_mon_count
# Create window frames (main frame and status bar, etc.)
set top_frame [frame $win.top_frame]
@@ -106,19 +111,19 @@ class StackMonitor {
-font $font0 -width 27 \
-justify left -anchor w -background {#DDDDDD} \
-bd 0 -text [mc "Addr HH Dec Binary Oct A"] \
- ]
- pack $values_txt -fill y -expand 1
+ ] -anchor w -fill x
+ pack $values_txt -fill both -expand 1
$values_txt tag configure tag_general -background {#CCCCFF}
$values_txt tag configure tag_subprog -background {#CCFFCC}
$values_txt tag configure tag_interrupt -background {#FFCCCC}
bind $values_txt <ButtonRelease-3> {break}
bind $values_txt <<Selection>> "false_selection $values_txt; break"
# Scrollbar
- pack $left_frame -side left -fill y -expand 1
+ pack $left_frame -side left -fill both -expand 1
pack [ttk::scrollbar $top_frame.scrollbar \
-command "$values_txt yview" \
-orient vertical \
- ] -side right -fill y -expand 1
+ ] -side right -fill y
## Stack pointer
@@ -166,7 +171,7 @@ class StackMonitor {
pack $col_exp_button -side right -padx 5
# Pack frames except for the bottom bar (with legend)
- pack $top_frame -fill y -expand 1
+ pack $top_frame -fill both -expand 1
pack $bottom_frame -anchor w -fill x
## Create bottom bar (with legend)
@@ -178,7 +183,7 @@ class StackMonitor {
pack [label $tool_frame.lf.sl1 -text [mc "Subprogram"] -font $font0 -bg {#CCFFCC}] -side left -fill y -padx 3
pack [label $tool_frame.lf.il1 -text [mc "Interrupt"] -font $font0 -bg {#FFCCCC}] -side left -fill y
- # Show or keep the bottom bar hidden acording to previous session
+ # Show or keep the bottom bar hidden according to previous session
if {!$collapsed} {
set collapsed [expr {!$collapsed}]
stack_monitor_col_exp
@@ -187,7 +192,8 @@ class StackMonitor {
# Set window attributes
wm iconphoto $win ::ICONS::16::kcmmemory_ST
- wm title $win [mc "Stack - %s - MCU 8051 IDE" [string trim $this {:}]]
+ wm title $win [mc "Stack - %s - MCU 8051 IDE" [$this cget -projectName]]
+ wm minsize $win 225 90
if {$geometry != {}} {
wm geometry $win $geometry
}
@@ -313,7 +319,7 @@ class StackMonitor {
if {$collapsed} {
set image 2downarrow
pack forget $tool_frame
- } {
+ } else {
set image 2uparrow
pack $tool_frame -fill y -anchor nw
}
@@ -381,7 +387,7 @@ class StackMonitor {
}
# Create toplevel window
- set dlg [toplevel .manual_push${obj_idx} -class {Push value onto stack} -bg {#EEEEEE}]
+ set dlg [toplevel .manual_push${obj_idx} -class {Push value onto stack} -bg ${::COMMON_BG_COLOR}]
# Create label, entryBox and horizontal separator
pack [label $dlg.lbl -text [mc "Push value onto stack (HEX)"]] -fill x -anchor w -padx 5
@@ -411,7 +417,7 @@ class StackMonitor {
-compound left \
-image ::ICONS::16::down0 \
-command "$this stack_monitor_manual_push_val" \
- ] -side left
+ ] -side left -padx 2
pack [ttk::button $buttonFrame.cancel \
-width 5 \
-text [mc "Close"] \
@@ -420,18 +426,19 @@ class StackMonitor {
-command "
grab release $dlg
destroy $dlg" \
- ] -side left
+ ] -side left -padx 2
pack $buttonFrame -side right -padx 5
# Set window attributes
wm iconphoto $dlg ::ICONS::16::kcmmemory_ST
wm title $dlg [mc "Push value onto stack."]
wm minsize $dlg 200 60
+ wm transient $dlg $win
wm protocol $dlg WM_DELETE_WINDOW "
grab release $dlg
destroy $dlg"
- raise $dlg
update
+ raise $dlg
focus $dlg.ent
}
@@ -472,7 +479,7 @@ class StackMonitor {
if {$enabled} {
set state {normal}
- } {
+ } else {
set state {disabled}
}
@@ -517,3 +524,7 @@ class StackMonitor {
$values_txt configure -state disabled
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/stopwatch.tcl b/lib/simulator/stopwatch.tcl
index 407cdd3..353ac41 100755..100644
--- a/lib/simulator/stopwatch.tcl
+++ b/lib/simulator/stopwatch.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 _STOPWATCH_TCL ] } {
+set _STOPWATCH_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Stopwatch timer for MCU simulator
@@ -28,7 +33,7 @@
class Stopwatch {
## Class variables
- common count 0 ;# Int: Counter of class instances
+ common stopw_count 0 ;# Int: Counter of class instances
# List: Short names of stopwatch entries
common stats_keys {
US CC IC
@@ -43,16 +48,6 @@ class Stopwatch {
{Subprogram calls} {RET} {RETI}
{Breakpoints}
}
- # Normal font (for entry boxes)
- common normal_font [font create \
- -family Helvetica \
- -size -12 -weight normal\
- ]
- # Bold font (for entry boxes)
- common bold_font [font create \
- -family Helvetica \
- -size -12 -weight bold \
- ]
## Private varibales
private variable win ;# Widget: Dialog window
@@ -68,15 +63,16 @@ class Stopwatch {
constructor {} {
# Configure ttk styles
- if {!$count} {
+ if {!$stopw_count} {
ttk::style configure Stopwatch.TEntry -fieldreadonlybackground {#F8F8F8}
ttk::style configure Stopwatch_Focused_D.TEntry -fieldbackground {#AAAAFF} -fieldreadonlybackground {#AAAAFF}
+ ttk::style configure Stopwatch_Focused_D_Invalid.TEntry -fieldbackground {#AAAAFF} -foreground {#FF0000}
ttk::style configure Stopwatch_Focused_I.TEntry -fieldbackground {#DDDDFF} -fieldreadonlybackground {#DDDDFF}
}
# Increment counter of object instances
- set obj_idx $count
- incr count
+ set obj_idx $stopw_count
+ incr stopw_count
# Restore configuration from the previous session
set i 0
@@ -116,7 +112,7 @@ class Stopwatch {
# @return void
public method stopwatch_invoke_dialog {} {
if {$dialog_opened} {return}
- set win [toplevel .stopwatch$obj_idx -class {Stopwatch} -bg {#EEEEEE}]
+ set win [toplevel .stopwatch$obj_idx -class {Stopwatch} -bg ${::COMMON_BG_COLOR}]
set dialog_opened 1
set stopwatch_on 1
@@ -126,11 +122,15 @@ class Stopwatch {
bind $win <Control-Key-q> "destroy $win; break"
bindtags $win [list $win Toplevel all .]
- wm title $win "[mc {Stopwatch}] - [string trim $this {:}] - MCU 8051 IDE"
+ wm title $win "[mc {Stopwatch}] - [$this cget -projectName] - MCU 8051 IDE"
wm iconphoto $win ::ICONS::22::history
wm protocol $win WM_DELETE_WINDOW "$this stopwatch_close"
+ wm resizable $win 0 0
+ update
catch {
- wm geometry $win $window_geometry
+ wm geometry $win [regsub {^\=?\d+x\d+} $window_geometry \
+ [regsub {\+\d+\+\d+$} [wm geometry $win] {}] \
+ ]
}
}
@@ -146,18 +146,18 @@ class Stopwatch {
set stop_a 0
foreach key $stats_keys {
# Overall
- set org_O [subst "\$::Stopwatch::text_vars${obj_idx}($key,O)"]
+ set org_O [subst -nocommands "\$::Stopwatch::text_vars${obj_idx}($key,O)"]
set ::Stopwatch::text_vars${obj_idx}($key,O) $run_statistics($i)
# Current
if {$stopwatch_on} {
incr ::Stopwatch::text_vars${obj_idx}($key,C) [expr {$run_statistics($i) - $org_O}]
- set stop_a [subst "\$::Stopwatch::text_vars${obj_idx}($key,S)"]
+ set stop_a [subst -nocommands "\$::Stopwatch::text_vars${obj_idx}($key,S)"]
# Conditional stop
- if {$stop_a && $stop_a <= [subst "\$::Stopwatch::text_vars${obj_idx}($key,C)"]} {
+ if {$stop_a && $stop_a <= [subst -nocommands "\$::Stopwatch::text_vars${obj_idx}($key,C)"]} {
stopwatch_start_stop
- if {[subst "\$::Stopwatch::text_vars${obj_idx}(stop_sim)"]} {
+ if {[subst -nocommands "\$::Stopwatch::text_vars${obj_idx}(stop_sim)"]} {
if {[$this sim_run_in_progress]} {
$this sim_run
} elseif {[$this sim_anim_in_progress]} {
@@ -232,7 +232,9 @@ class Stopwatch {
# - Label "STOPPED"
set label_stopped_lbl [label $top_frame.label_stopped_lbl \
-font [font create \
- -family {Helvetica} -size -21 -weight bold \
+ -family {Helvetica} \
+ -size -21 \
+ -weight bold \
] -text {STOPPED} -fg {#FF0000} -pady 0 \
]
@@ -299,6 +301,8 @@ class Stopwatch {
bind $entrybox <Key-Down> "$this stopwatch_entry_key $key $tp down; break"
bind $entrybox <Key-Left> "$this stopwatch_entry_key $key $tp left; break"
bind $entrybox <Key-Right> "$this stopwatch_entry_key $key $tp right; break"
+ bind $entrybox <Shift-Key-Left> "continue"
+ bind $entrybox <Shift-Key-Right> "continue"
bind $entrybox <Key-Tab> "$this stopwatch_entry_key $key $tp tab; break"
if {!$::MICROSOFT_WINDOWS} {
bind $entrybox <Key-ISO_Left_Tab> "$this stopwatch_entry_key $key $tp stab; break"
@@ -356,7 +360,7 @@ class Stopwatch {
$entryboxes($key,C) configure -style Stopwatch_Focused_I.TEntry
$entryboxes($key,S) configure -style Stopwatch_Focused_I.TEntry
$entryboxes($key,$type) configure -style Stopwatch_Focused_D.TEntry
- } {
+ } else {
$entryboxes($key,$type) selection clear
$entryboxes($key,C) configure -style TEntry
$entryboxes($key,S) configure -style TEntry
@@ -459,11 +463,11 @@ class Stopwatch {
# Adjust foreground color for entrybox in column "Current"
if {$type == {C} && $string != {}} {
- set max [subst "\$::Stopwatch::text_vars${obj_idx}($key,S)"]
- if {$max && $string >= $max} {
- $entryboxes($key,C) configure -fg {#FF0000} -font $bold_font
- } {
- $entryboxes($key,C) configure -fg {#000000} -font $normal_font
+ set max [subst -nocommands "\$::Stopwatch::text_vars${obj_idx}($key,S)"]
+ if {$max != {} && $max != 0 && $string >= $max} {
+ $entryboxes($key,C) configure -style Stopwatch_Focused_D_Invalid.TEntry
+ } else {
+ $entryboxes($key,C) configure -style Stopwatch_Focused_D.TEntry
}
}
@@ -471,7 +475,7 @@ class Stopwatch {
if {$type == {C} || $type == {S}} {
if {$string != {} && $string != 0} {
$clearbuttons($key,$type) configure -state normal
- } {
+ } else {
$clearbuttons($key,$type) configure -state disabled
}
}
@@ -500,13 +504,13 @@ class Stopwatch {
# @parm Bool text__html - File type (1 == Plain text; 0 == XHTML)
# @return void
public method stopwatch_save {text__html} {
- # Determinate list of avaliable file extensions
+ # Determinate list of available file extensions
if {$text__html} {
set filetypes [list \
[list [::mc "Text files"] {*.txt}] \
[list [::mc "All files"] {*}] \
]
- } {
+ } else {
set filetypes [list \
[list [::mc "HTML files"] {*.html}] \
[list [::mc "All files"] {*}] \
@@ -519,7 +523,7 @@ class Stopwatch {
-directory [$this cget -projectPath] \
-master $win -filetypes [mc $filetypes] \
-defaultmask 0 -multiple 0 \
- -initialfile [string trim $this {:}]
+ -initialfile [$this cget -projectName]
# Open file after press of OK button
::fsd setokcmd "
@@ -544,7 +548,7 @@ class Stopwatch {
if {![string length [file extension $filename]]} {
if {$text__html} {
append filename {.txt}
- } {
+ } else {
append filename {.html}
}
}
@@ -559,7 +563,7 @@ class Stopwatch {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $filename]]
] != {yes}
- } {
+ } then {
return
}
# Create a backup file
@@ -570,8 +574,8 @@ class Stopwatch {
# Open the specified file
if {[catch {
- set file [open $filename w 420]
- }]} {
+ set file [open $filename w 0640]
+ }]} then {
tk_messageBox \
-parent . \
-type ok \
@@ -584,34 +588,33 @@ class Stopwatch {
# Save as plain text
if {$text__html} {
set text {}
- append text [string repeat { } 33] "Current" \
- [string repeat { } 10] "Stop after" \
- [string repeat { } 13] "Overall"
+ append text [string repeat { } 37] [mc "Current"] \
+ [string repeat { } 10] [mc "Stop after"] \
+ [string repeat { } 13] [mc "Overall"]
puts $file $text
foreach text $stats_names key $stats_keys {
set text [mc $text]
- append text [string repeat { } [expr {20 - [string length $text]}]]
+ append text [string repeat { } [expr {24 - [string length $text]}]]
foreach subkey {C S O} {
- set val [subst "\$::Stopwatch::text_vars${obj_idx}($key,$subkey)"]
+ set val [subst -nocommands "\$::Stopwatch::text_vars${obj_idx}($key,$subkey)"]
append text [string repeat { } [expr {20 - [string length $val]}]] $val
}
puts $file $text
}
- puts $file "\nProject: [string trim $this {:}]"
- puts $file "Date: [clock format [clock seconds] -format {%D}]"
- puts $file "Generated by ${::APPNAME} ( http://mcu8051ide.sf.net )"
+ puts $file "\n[mc {Project:}] [$this cget -projectName]"
+ puts $file [mc "Generated by %s" "${::APPNAME} ( http://mcu8051ide.sf.net )"]
# Save as XHTML
- } {
+ } else {
puts $file "<?xml version='1.0' encoding='utf-8' standalone='no'?>"
puts $file "<!DOCTYPE html PUBLIC"
puts $file "\t'-//W3C//DTD XHTML 1.1//EN'"
puts $file "\t'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>"
puts $file "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>"
- puts $file "<!--\n\tCreator: ${::APPNAME}\n\tDate: [clock format [clock seconds] -format {%D}]\n-->"
+ puts $file "<!-- Creator: ${::APPNAME} -->"
puts $file "\t<head>"
- puts $file "\t\t<title>[string trim $this {:}] stopwatch state [clock format [clock seconds] -format {%D}]</title>"
+ puts $file "\t\t<title>[$this cget -projectName] stopwatch state [clock format [clock seconds] -format {%D}]</title>"
puts $file "\t\t<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=UTF-8\" />"
puts $file "\t\t<meta name=\"Generator\" content=\"${::APPNAME}\" />"
puts $file "\t\t<style type=\"text/css\">"
@@ -639,7 +642,7 @@ class Stopwatch {
puts $file "\t\t<table style=\"border-width: 1px\">"
puts $file "\t\t\t<col /><col /><col /><col />"
puts $file "\t\t\t<thead>"
- puts $file "\t\t\t\t<tr class=\"sw_header\"><th>&nbsp;</th><th>Current</th><th>Stop after</th><th>Overall</th></tr>"
+ puts $file "\t\t\t\t<tr class=\"sw_header\"><th>&nbsp;</th><th>[mc {Current}]</th><th>[mc {Stop after}]</th><th>[mc {Overall}]</th></tr>"
puts $file "\t\t\t</thead>"
puts $file "\t\t\t<tbody>"
foreach text $stats_names key $stats_keys {
@@ -647,7 +650,7 @@ class Stopwatch {
puts $file "\t\t\t\t\t<td class=\"sw_header\">[mc $text]</td>"
foreach subkey {C S O} {
puts -nonewline $file "\t\t\t\t\t<td class=\"sw_$subkey\">"
- puts -nonewline $file [subst "\$::Stopwatch::text_vars${obj_idx}($key,$subkey)"]
+ puts -nonewline $file [subst -nocommands "\$::Stopwatch::text_vars${obj_idx}($key,$subkey)"]
puts $file "</td>"
}
puts $file "\t\t\t\t</tr>"
@@ -656,9 +659,8 @@ class Stopwatch {
puts $file "\t\t</table>"
puts $file "\t\t<p>"
- puts $file "\t\t\tProject: <b>[string trim $this {:}]</b><br />"
- puts $file "\t\t\tDate: <b>[clock format [clock seconds] -format {%D}]</b><br />"
- puts $file "\t\t\tGenerated by ${::APPNAME} ( <a href=\"http://mcu8051ide.sf.net\">http://mcu8051ide.sf.net</a> )"
+ puts $file "\t\t\t[mc {Project:}] <b>[$this cget -projectName]</b><br />"
+ puts $file "\t\t\t[mc {Generated by %s} "${::APPNAME} ( <a href=\"http://mcu8051ide.sf.net\">http://mcu8051ide.sf.net</a> )"]"
puts $file "\t\t</p>"
puts $file "\t</body>"
@@ -680,7 +682,7 @@ class Stopwatch {
local_status_tip $start_stop_button [mc "Stop"]
pack forget $label_stopped_lbl
# Stop
- } {
+ } else {
$start_stop_button configure -image ::ICONS::22::player_play
local_status_tip $start_stop_button [mc "Start"]
pack $label_stopped_lbl -side right -pady 0 -ipady 0
@@ -691,12 +693,16 @@ class Stopwatch {
# @return void
public method stopwatch_get_config {} {
set result $window_geometry
- lappend result [subst "\$::Stopwatch::text_vars${obj_idx}(stop_sim)"]
+ lappend result [subst -nocommands "\$::Stopwatch::text_vars${obj_idx}(stop_sim)"]
foreach key $stats_keys {
- lappend result [subst "\$::Stopwatch::text_vars${obj_idx}($key,S)"]
+ lappend result [subst -nocommands "\$::Stopwatch::text_vars${obj_idx}($key,S)"]
}
return $result
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/uart_monitor.tcl b/lib/simulator/uart_monitor.tcl
new file mode 100644
index 0000000..28d3b48
--- /dev/null
+++ b/lib/simulator/uart_monitor.tcl
@@ -0,0 +1,886 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# Copyright (C) 2011 by Martin Ošmera #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _UART_MONITOR_TCL ] } {
+set _UART_MONITOR_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+# UART monitor
+# -------------------------------------------------------------------------
+
+class UARTMonitor {
+
+ common geometry ${::CONFIG(UART_MON_GEOMETRY)} ;# Last window geometry
+ common uart_mon_count 0 ;# Counter of intances
+
+ # Font: Tiny normal font
+ common tiny_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-9 * $::font_size_factor)}] \
+ -weight {normal} \
+ ]
+ # Font: Big bold font
+ common big_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight {bold} \
+ ]
+ # Font: Normal font
+ common normal_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-11 * $::font_size_factor)}] \
+ -weight {normal} \
+ ]
+ # Font:
+ common normal_fixed_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-11 * $::font_size_factor)}] \
+ -weight {normal} \
+ ]
+ # Font:
+ common bold_fixed_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-11 * $::font_size_factor)}] \
+ -weight {bold} \
+ ]
+
+ common rect_size 12
+ common empty_fill {#888888}
+ common empty_outline {#AAAAAA}
+
+ common MAX_G_LOG_LENGTH 100 ;# Int:
+ common MAX_D_LOG_LENGTH 100 ;# Int:
+
+ private variable dialog_opened 0 ;# Bool: Dialog window opened
+ private variable win ;# Widget: Dialog window
+
+ private variable status_bar 1
+ private variable rxd_frame
+ private variable txd_frame
+
+ private variable general_log
+ private variable general_log_length
+ private variable data_transfer_log
+ private variable data_transfer_log_length
+ private variable canvas
+ private variable bit_rect
+ private variable uart_value_label
+ private variable shift_reg
+ private variable shift_reg_bits_written
+ private variable bit
+
+ private variable graph_position
+ private variable graph_prev_states
+ private variable graph_elements
+
+ constructor {} {
+ array set data_transfer_log_length {
+ r 0 t 0
+ }
+ array set general_log_length {
+ r 0 t 0
+ }
+ array set shift_reg {
+ r 0 t 0
+ }
+ array set shift_reg_bits_written {
+ r 0 t 0
+ }
+ array set graph_position {
+ r 0 t 0
+ }
+ array set graph_prev_states {
+ t 1 r 1
+ }
+ array set graph_elements {
+ t {} r {}
+ }
+ array set bit {
+ fe 0 sm0 0
+ sm1 0 sm2 0
+ ren 0 ti 0
+ ri 0 smod1 0
+ tclk 0 rclk 0
+ }
+ }
+
+ destructor {
+ uart_monitor_close
+ }
+
+ ## Invoke interrupt monitor window
+ # @return void
+ public method uart_monitor_invoke_dialog {} {
+ set win [toplevel .uartmonitor${uart_mon_count}]
+ incr uart_mon_count
+
+ set main_frame [frame $win.main_frame]
+ set status_bar [label $win.status_bar]
+
+ # --------------------------------------------------------------
+ # RECEIVER PART
+ # --------------------------------------------------------------
+ grid [label $main_frame.r_header_lbl \
+ -font $big_font \
+ -text [mc "RxD line"] \
+ ] -row 0 -column 1 -sticky w -padx 0 -columnspan 2 -sticky we
+ # Mode:
+ grid [label $main_frame.r_mode_lbl \
+ -text [mc "Mode:"] \
+ ] -row 1 -column 1 -sticky w -padx 5
+ set uart_value_label(r_mode) [label $main_frame.r_mode_v_lbl]
+ grid $uart_value_label(r_mode) -row 1 -column 2 -sticky w -padx 5
+ # Line function:
+ grid [label $main_frame.r_lf_lbl \
+ -text [mc "Line function:"] \
+ ] -row 2 -column 1 -sticky w -padx 5
+ set uart_value_label(r_lf) [label $main_frame.r_lf_v_lbl]
+ grid $uart_value_label(r_lf) -row 2 -column 2 -sticky w -padx 5
+ # BR Generator:
+ grid [label $main_frame.r_brg_lbl \
+ -text [mc "BR Generator:"] \
+ ] -row 3 -column 1 -sticky w -padx 5
+ set uart_value_label(r_brg) [label $main_frame.r_brg_v_lbl]
+ grid $uart_value_label(r_brg) -row 3 -column 2 -sticky w -padx 5
+ # BRG prescaler:
+ grid [label $main_frame.r_brgp_lbl \
+ -text [mc "BRG prescaler:"] \
+ ] -row 4 -column 1 -sticky w -padx 5
+ set uart_value_label(r_brgp) [label $main_frame.r_brgp_v_lbl]
+ grid $uart_value_label(r_brgp) -row 4 -column 2 -sticky w -padx 5
+ # Resulting bdps:
+ grid [label $main_frame.r_rbdps_lbl \
+ -text [mc "Resulting bdps:"] \
+ ] -row 5 -column 1 -sticky w -padx 5
+ set uart_value_label(r_rbdps) [label $main_frame.r_rbdps_v_lbl]
+ grid $uart_value_label(r_rbdps) -row 5 -column 2 -sticky w -padx 5
+ # State:
+ grid [label $main_frame.r_state_lbl \
+ -text [mc "State:"] \
+ ] -row 6 -column 1 -sticky w -padx 5
+ set uart_value_label(r_state) [label $main_frame.r_state_v_lbl]
+ grid $uart_value_label(r_state) -row 6 -column 2 -sticky w -padx 5
+
+ set canvas(r) [canvas $main_frame.r_canvas \
+ -width 240 \
+ -height 175 \
+ -bg $::COMMON_BG_COLOR \
+ -highlightthickness 0 \
+ ]
+ fill_canvas r
+ grid $canvas(r) -row 8 -column 1 -columnspan 2 -sticky we
+
+ set data_transfer_log(r) [text $main_frame.r_data_transfer_log \
+ -height 4 \
+ -width 0 \
+ -bd 0 \
+ -bg $::COMMON_BG_COLOR \
+ -highlightthickness 0 \
+ -font $normal_fixed_font \
+ -wrap none \
+ -xscrollcommand [list $main_frame.r_stl_scrollbar set] \
+ ]
+ $data_transfer_log(r) tag configure tag_bold -font $bold_fixed_font
+ $data_transfer_log(r) insert end [mc "HEX \nDEC \nOCT \nASCII "]
+ $data_transfer_log(r) configure -state disabled
+ for {set i 1} {$i <= 4} {incr i} {
+ $data_transfer_log(r) tag add tag_bold $i.0 $i.5
+ }
+ grid $data_transfer_log(r) -row 9 -column 1 -columnspan 2 -sticky we
+ grid [ttk::scrollbar $main_frame.r_stl_scrollbar \
+ -orient horizontal \
+ -command [list $data_transfer_log(r) xview] \
+ ] -row 10 -column 1 -columnspan 2 -sticky we
+
+ set general_log_frame [frame $main_frame.r_general_log_frame]
+ set general_log(r) [text $general_log_frame.general_log \
+ -height 4 \
+ -width 0 \
+ -yscrollcommand [list $general_log_frame.scrollbar set] \
+ -state disabled \
+ ]
+ set general_log_sc_bar [ttk::scrollbar $general_log_frame.scrollbar \
+ -orient vertical \
+ -command [list $general_log(r) yview] \
+ ]
+ pack $general_log_sc_bar -side right -fill y
+ pack $general_log(r) -side left -fill both -expand 1
+ grid $general_log_frame -row 11 -column 1 -columnspan 2 -sticky wens -pady 2
+
+ # --------------------------------------------------------------
+ # TRANSMITTER PART
+ # --------------------------------------------------------------
+ grid [label $main_frame.t_header_lbl \
+ -font $big_font \
+ -text [mc "TxD line"] \
+ ] -row 0 -column 4 -sticky w -padx 0 -columnspan 2 -sticky we
+ # Mode:
+ grid [label $main_frame.t_mode_lbl \
+ -text [mc "Mode:"] \
+ ] -row 1 -column 4 -sticky w -padx 5
+ set uart_value_label(t_mode) [label $main_frame.t_mode_v_lbl]
+ grid $uart_value_label(t_mode) -row 1 -column 5 -sticky w -padx 5
+ # Line function:
+ grid [label $main_frame.t_lf_lbl \
+ -text [mc "Line function:"] \
+ ] -row 2 -column 4 -sticky w -padx 5
+ set uart_value_label(t_lf) [label $main_frame.t_lf_v_lbl]
+ grid $uart_value_label(t_lf) -row 2 -column 5 -sticky w -padx 5
+ # BR Generator:
+ grid [label $main_frame.t_brg_lbl \
+ -text [mc "BR Generator:"] \
+ ] -row 3 -column 4 -sticky w -padx 5
+ set uart_value_label(t_brg) [label $main_frame.t_brg_v_lbl]
+ grid $uart_value_label(t_brg) -row 3 -column 5 -sticky w -padx 5
+ # BRG prescaler:
+ grid [label $main_frame.t_brgp_lbl \
+ -text [mc "BRG prescaler:"] \
+ ] -row 4 -column 4 -sticky w -padx 5
+ set uart_value_label(t_brgp) [label $main_frame.t_brgp_v_lbl]
+ grid $uart_value_label(t_brgp) -row 4 -column 5 -sticky w -padx 5
+ # Resulting bdps:
+ grid [label $main_frame.t_rbdps_lbl \
+ -text [mc "Resulting bdps:"] \
+ ] -row 5 -column 4 -sticky w -padx 5
+ set uart_value_label(t_rbdps) [label $main_frame.t_rbdps_v_lbl]
+ grid $uart_value_label(t_rbdps) -row 5 -column 5 -sticky w -padx 5
+ # State:
+ grid [label $main_frame.t_state_lbl \
+ -text [mc "State:"] \
+ ] -row 6 -column 4 -sticky w -padx 5
+ set uart_value_label(t_state) [label $main_frame.t_state_v_lbl]
+ grid $uart_value_label(t_state) -row 6 -column 5 -sticky w -padx 5
+
+ set canvas(t) [canvas $main_frame.t_canvas \
+ -width 240 \
+ -height 175 \
+ -bg $::COMMON_BG_COLOR \
+ -highlightthickness 0 \
+ ]
+ fill_canvas t
+ grid $canvas(t) -row 8 -column 4 -columnspan 2 -sticky nw
+
+ set data_transfer_log(t) [text $main_frame.t_data_transfer_log \
+ -height 4 \
+ -width 0 \
+ -bd 0 \
+ -bg $::COMMON_BG_COLOR \
+ -highlightthickness 0 \
+ -font $normal_fixed_font \
+ -wrap none \
+ -xscrollcommand [list $main_frame.t_stl_scrollbar set] \
+ ]
+ $data_transfer_log(t) tag configure tag_bold -font $bold_fixed_font
+ $data_transfer_log(t) insert end [mc "HEX \nDEC \nOCT \nASCII "]
+ $data_transfer_log(t) configure -state disabled
+ for {set i 1} {$i <= 4} {incr i} {
+ $data_transfer_log(t) tag add tag_bold $i.0 $i.5
+ }
+ grid $data_transfer_log(t) -row 9 -column 4 -columnspan 2 -sticky we
+ grid [ttk::scrollbar $main_frame.t_stl_scrollbar \
+ -orient horizontal \
+ -command [list $data_transfer_log(t) xview] \
+ ] -row 10 -column 4 -columnspan 2 -sticky we
+
+ set general_log_frame [frame $main_frame.t_general_log_frame]
+ set general_log(t) [text $general_log_frame.general_log \
+ -height 4 \
+ -width 0 \
+ -yscrollcommand [list $general_log_frame.scrollbar set] \
+ -state disabled \
+ ]
+ set general_log_sc_bar [ttk::scrollbar $general_log_frame.scrollbar \
+ -orient vertical \
+ -command [list $general_log(t) yview] \
+ ]
+ pack $general_log_sc_bar -side right -fill y
+ pack $general_log(t) -side left -fill both -expand 1
+ grid $general_log_frame -row 11 -column 4 -columnspan 2 -sticky wens -pady 2
+
+ grid [ttk::separator $main_frame.sep -orient vertical] -row 0 -column 3 -rowspan 12 -padx 2 -sticky ns
+ pack $main_frame -fill y -padx 2 -pady 2 -anchor nw -expand 1
+
+ # Pack main frame and create bottom frame
+ pack $main_frame -fill both -expand 1
+ pack [ttk::separator $win.sep -orient horizontal] \
+ -fill x -pady 1
+ pack $status_bar -side left -fill x -padx 5
+ pack [ttk::button $win.close_but \
+ -text [mc "Close"] \
+ -compound left \
+ -command [list $this uart_monitor_close] \
+ -image ::ICONS::16::button_cancel \
+ ] -side right -pady 2 -padx 5
+ uart_monitor_set_status_tip $win.close_but [mc "Close this dialog window"]
+
+ # Set window attributes
+ wm iconphoto $win ::ICONS::16::__blockdevice
+ wm title $win "[mc {UART Monitor}] - [$this cget -projectName] - MCU 8051 IDE"
+ wm minsize $win 500 500
+ wm resizable $win 1 1
+ wm protocol $win WM_DELETE_WINDOW [list $this uart_monitor_close]
+ bindtags $win [list $win Toplevel all .]
+
+ update idletasks
+ if {$geometry != {}} {
+ regsub {\+\d+\+\d+} $geometry [format {+%d+%d} [winfo width $win] [winfo height $win]] geometry
+ wm geometry $win $geometry
+ }
+
+ set dialog_opened 1
+
+# #< DEBUG !!!
+# uart_monitor_byte_received 100 111 132
+# uart_monitor_byte_transmitted 101 112 122
+#
+ uart_monitor_refresh_configuration
+ uart_monitor_write_to_log r "THIS TOOL IS NOT FUNCTIONAL YET!"
+ uart_monitor_write_to_log t "THIS TOOL IS NOT FUNCTIONAL YET!"
+#
+# uart_monitor_shift_reg_input r 1 1
+# uart_monitor_shift_reg_input r 1 0
+# uart_monitor_shift_reg_input r 1 0
+# uart_monitor_shift_reg_input r 1 1
+# uart_monitor_shift_reg_input r 1 1
+#
+# uart_monitor_shift_reg_input t 0 1
+# uart_monitor_shift_reg_input t 0 0
+# uart_monitor_shift_reg_input t 0 0
+# uart_monitor_shift_reg_input t 0 1
+# uart_monitor_shift_reg_input t 0 1
+#
+# uart_monitor_update_sbuf r
+# uart_monitor_update_sbuf t
+#
+# uart_monitor_graph_draw t {1 0 1 0 1}
+# uart_monitor_graph_draw t {1 0 1 1 1}
+# uart_monitor_graph_draw t {0 1 1 1 1}
+# uart_monitor_graph_draw t {1 0 1 1 1}
+# uart_monitor_graph_draw t {1 0 1 1 0}
+# uart_monitor_graph_draw t {1 0 1 0 1}
+# uart_monitor_graph_draw t {1 0 1 1 1}
+# uart_monitor_graph_draw t {0 1 1 1 1}
+# uart_monitor_graph_draw t {1 0 1 1 1}
+# uart_monitor_graph_draw t {1 0 1 1 0}
+# #> DEBUG !!!
+ }
+
+ public method uart_monitor_close {} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ set geometry [wm geometry $win]
+ set dialog_opened 0
+
+ if {[winfo exists $win]} {
+ destroy $win
+ }
+ }
+
+ ## Set status bar tip for certain widget
+ # @parm Widget widget - Some button or label ...
+ # @parm String text - Status tip
+ # @return void
+ private method uart_monitor_set_status_tip {widget text} {
+ bind $widget <Enter> [list $status_bar configure -text $text]
+ bind $widget <Leave> [list $status_bar configure -text {}]
+ }
+
+ private method fill_canvas {side} {
+ set labels [list 8 7 6 5 4 3 2 1 0]
+
+ set x 5
+ set j 0
+ for {set i 0} {$i < 10} {incr i} {
+ set y 20
+ set bit_rect(s,$side,$i) [$canvas($side) create rectangle $x $y \
+ [expr {$x + $rect_size}] [expr {$y + $rect_size}] \
+ -fill $empty_fill -outline $empty_outline \
+ ]
+
+ if {($side == {r} && $i > 0 && $i < 10) || ($side == {t} && $i >= 0 && $i < 9)} {
+ if {$j == 1} {
+ incr x 3
+ }
+ set y 50
+ set bit_rect(b,$side,$j) [$canvas($side) create rectangle $x $y \
+ [expr {$x + $rect_size}] [expr {$y + $rect_size}] \
+ -fill $empty_fill -outline $empty_outline \
+ ]
+ $canvas($side) create text \
+ [expr {$x + ($rect_size / 2)}] \
+ [expr {$y + ($rect_size / 2)}] \
+ -text [lindex $labels $j] \
+ -font $tiny_font
+ if {$j == 1} {
+ incr x -3
+ }
+ incr j
+ }
+
+ incr x $rect_size
+ incr x 2
+ }
+
+ $canvas($side) create text 5 5 -anchor nw -font $normal_font -text [mc "The shift register:"]
+ $canvas($side) create text 5 35 -anchor nw -font $normal_font -text "SBUF [string toupper $side]:"
+
+ # --------------------------------------------------------------
+
+ if {$side == {r}} {
+ set graph_label [list \
+ [mc "RxD"] \
+ [mc "RI"] \
+ [mc "ALE"] \
+ [mc "SHIFT"] \
+ [mc "SBUF"] \
+ ]
+ } else {
+ set graph_label [list \
+ [mc "TxD"] \
+ [mc "TI"] \
+ [mc "ALE"] \
+ [mc "SHIFT"] \
+ [mc "SBUF"] \
+ ]
+ }
+ for {set y 0} {$y < 5} {incr y} {
+ set y_0 [expr {75 + $y * 20}]
+ set y_1 [expr {$y_0 + 15}]
+
+ for {set x 45} {$x <= 235} {incr x 5} {
+ $canvas($side) create line $x $y_0 $x $y_1 -fill {#AAAAAA} -tags grid -dash .
+ }
+
+ $canvas($side) create text 5 $y_0 -anchor nw -font $bold_fixed_font -text [lindex $graph_label $y]
+
+ incr y_0 -3
+ $canvas($side) create line 45 $y_0 235 $y_0 -fill {#AAAAAA} -tags grid
+ }
+ }
+
+ public method uart_monitor_refresh_configuration {} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ set pcon [$this getSfrDEC $::Simulator_ENGINE::symbol(PCON)]
+ set scon [$this getSfrDEC $::Simulator_ENGINE::symbol(SCON)]
+
+ set bit(fe) [$this sim_engine_get_FE]
+ set bit(sm0) [$this sim_engine_get_SM0]
+ set bit(sm1) [expr {$scon & 0x40}]
+ set bit(sm2) [expr {$scon & 0x20}]
+ set bit(ren) [expr {$scon & 0x10}]
+ set bit(ti) [expr {$scon & 0x02}]
+ set bit(ri) [expr {$scon & 0x01}]
+
+ set bit(smod1) [expr {$pcon & 0x80}]
+
+ if {[$this get_feature_available t2]} {
+ set bit(tclk) [$this getBit $::Simulator_ENGINE::symbol(TCLK)]
+ set bit(rclk) [$this getBit $::Simulator_ENGINE::symbol(RCLK)]
+ } else {
+ set bit(tclk) 0
+ set bit(rclk) 0
+ }
+
+ ## Determinate mode of operation
+ # Mode 0
+ if {!$bit(sm0) && !$bit(sm1)} {
+ set mode [mc "0 (8-bit Shift register)"]
+ # Mode 1
+ } elseif {!$bit(sm0) && $bit(sm1)} {
+ set mode [mc "1 (8-bit UART)"]
+ # Mode 2
+ } elseif {$bit(sm0) && !$bit(sm1)} {
+ set mode [mc "2 (9-bit UART)"]
+ # Mode 3
+ } elseif {$bit(sm0) && $bit(sm1)} {
+ set mode [mc "3 (9-bit UART)"]
+ }
+
+ ## Determinate line functions
+ if {!$bit(sm0) && !$bit(sm1)} {
+ set r_lf [mc "Data input/output"]
+ set t_lf [mc "Shift clock output"]
+ } else {
+ set r_lf [mc "Data input"]
+ set t_lf [mc "Data output"]
+ }
+
+ ## Determinate source of baud rate clock
+ if {$bit(sm1)} {
+ if {$bit(rclk)} {
+ set r_brg [mc "Timer 2"]
+ } else {
+ set r_brg [mc "Timer 1"]
+ }
+ if {$bit(tclk)} {
+ set t_brg [mc "Timer 2"]
+ } else {
+ set t_brg [mc "Timer 1"]
+ }
+ } else {
+ set r_brg [mc "Master clock"]
+ set t_brg [mc "Master clock"]
+ }
+
+ ## Determinate resulting baud rate
+ set r_rbdps [determinate_baud_rate t]
+ set t_rbdps [determinate_baud_rate t]
+
+ ## Determinate state of the interface
+ set r_state [mc "WAITING"]
+ set t_state [mc "WAITING"]
+
+ # --------------------------------------------------------------
+ # RECEIVER PART
+ # --------------------------------------------------------------
+ $uart_value_label(r_mode) configure -text $mode
+ $uart_value_label(r_lf) configure -text $r_lf
+ $uart_value_label(r_brg) configure -text $r_brg
+ $uart_value_label(r_rbdps) configure -text $r_rbdps
+ $uart_value_label(r_state) configure -text $r_state
+
+ # --------------------------------------------------------------
+ # TRANSMITTER PART
+ # --------------------------------------------------------------
+ $uart_value_label(t_mode) configure -text $mode
+ $uart_value_label(t_lf) configure -text $t_lf
+ $uart_value_label(t_brg) configure -text $t_brg
+ $uart_value_label(t_rbdps) configure -text $t_rbdps
+ $uart_value_label(t_state) configure -text $t_state
+ }
+
+ private method determinate_baud_rate {side} {
+ # RxD side
+ if {$side == {r}} {
+ # Timer 2
+ if {$bit(rclk)} {
+ return [mc "Determinated by timer 2"]
+
+ # Timer 1
+ } else {
+ set tmod [$this getSfrDEC $::Simulator_ENGINE::symbol(PCON)]
+ if {$tmod & 0x40} {
+ return [mc "Unknown"]
+ }
+ set clock_f [expr {1000 * [$this getEngineClock] * (1 + ([$this get_X2] ? 1 : 0))}]
+ set mode [expr {($tmod & 0x30) >> 4}]
+ switch -- $mode {
+ 0 {
+ return [expr {$clock_f / 8192.0}]
+ }
+ 1 {
+ return [expr {$clock_f / 65536.0}]
+ }
+ 2 {
+ set th1 [$this getSfrDEC $::Simulator_ENGINE::symbol(TH1)]
+ return [expr {$clock_f / (256.0 - $th1)}]
+ }
+ 3 {
+ return 0
+ }
+ }
+ }
+
+ # TxD side
+ } else {
+ # Timer 2
+ if {$bit(tclk)} {
+ return [mc "Determinated by timer 2"]
+
+ # Timer 1
+ } else {
+ set tmod [$this getSfrDEC $::Simulator_ENGINE::symbol(PCON)]
+ if {$tmod & 0x40} {
+ return [mc "Unknown"]
+ }
+ set clock_f [expr {1000 * [$this getEngineClock] * (1 + ([$this get_X2] ? 1 : 0))}]
+ set mode [expr {($tmod & 0x30) >> 4}]
+ switch -- $mode {
+ 0 {
+ return [expr {$clock_f / 8192.0}]
+ }
+ 1 {
+ return [expr {$clock_f / 65536.0}]
+ }
+ 2 {
+ set th1 [$this getSfrDEC $::Simulator_ENGINE::symbol(TH1)]
+ return [expr {$clock_f / (256.0 - $th1)}]
+ }
+ 3 {
+ return 0
+ }
+ }
+ }
+ }
+
+ return [mc "Unknown"]
+ }
+
+ public method uart_monitor_update_prescaler {side value} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ $uart_value_label(${side}_brgp) configure -text $value
+ }
+
+ public method uart_monitor_byte_received {args} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ foreach byte $args {
+ write_to_data_transfer_log r $byte
+ }
+ }
+
+ public method uart_monitor_byte_transmitted {args} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ foreach byte $args {
+ write_to_data_transfer_log t $byte
+ }
+ }
+
+ private method write_to_data_transfer_log {side byte} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ $data_transfer_log($side) configure -state normal
+ if {$data_transfer_log_length($side) == $MAX_D_LOG_LENGTH} {
+ for {set i 1} {$i < 5} {incr i} {
+ $data_transfer_log($side) delete $i.4 $i.6
+ }
+ incr data_transfer_log_length($side) -1
+ }
+
+ set i [expr {6 + $data_transfer_log_length($side) * 4}]
+
+ $data_transfer_log($side) insert 1.$i [format {%3X } $byte]
+ $data_transfer_log($side) insert 2.$i [format {%3d } $byte]
+ $data_transfer_log($side) insert 3.$i [format {%3o } $byte]
+ if {[string is print -strict [format {%c} $byte]]} {
+ $data_transfer_log($side) insert 4.$i [format { %c } $byte]
+ } else {
+ $data_transfer_log($side) insert 4.$i { }
+ }
+ $data_transfer_log($side) configure -state disabled
+
+ incr data_transfer_log_length($side)
+ }
+
+ public method uart_monitor_write_to_log {side text} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ $general_log($side) configure -state normal
+ if {$general_log_length($side) == $MAX_G_LOG_LENGTH} {
+ $general_log($side) delete 1.0 2.0
+ $general_log($side) mark set {end-1l lineend}
+ }
+
+ $general_log($side) insert insert $text
+ $general_log($side) insert insert "\n"
+ $general_log($side) see insert
+ $general_log($side) configure -state disabled
+ }
+
+ public method uart_monitor_shift_reg_input {side right__left bit_val} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ incr shift_reg_bits_written($side)
+ if {$right__left} {
+ set shift_reg($side) [expr {($shift_reg($side) >> 1) | (($bit_val ? 1 : 0) << 9)}]
+ set start 0
+ set end [expr {$shift_reg_bits_written($side) - 1}]
+ } else {
+ set shift_reg($side) [expr {0x3FF & (($shift_reg($side) << 1) | ($bit_val ? 1 : 0))}]
+ set start [expr {9 - $shift_reg_bits_written($side)}]
+ set end 9
+ }
+
+ for {set i $start} {$i <= $end} {incr i} {
+ if {$shift_reg($side) & (1 << (9 - $i))} {
+ set outline ${::BitMap::one_outline}
+ set fill ${::BitMap::one_fill}
+ } else {
+ set outline ${::BitMap::zero_outline}
+ set fill ${::BitMap::zero_fill}
+ }
+
+ $canvas($side) itemconfigure $bit_rect(s,$side,$i) \
+ -outline $outline \
+ -fill $fill
+ }
+ }
+ public method uart_monitor_shift_reg_clear {side} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ for {set i 0} {$i < 9} {incr i} {
+ $canvas($side) itemconfigure $bit_rect(s,$side,$i) \
+ -outline $empty_outline \
+ -fill $empty_fill
+ }
+ set shift_reg($side) 0
+ set shift_reg_bits_written($side) 0
+ }
+ public method uart_monitor_update_sbuf {side} {
+ if {!$dialog_opened} {
+ return
+ }
+
+ if {$side == {r}} {
+ set sbuf [$this getSfrDEC $::Simulator_ENGINE::symbol(SBUFR)]
+ set bit8 [$this getBit $::Simulator_ENGINE::symbol(RB8)]
+ } else {
+ set sbuf [$this getSfrDEC $::Simulator_ENGINE::symbol(SBUFT)]
+ set bit8 [$this getBit $::Simulator_ENGINE::symbol(TB8)]
+ }
+
+ for {set i 0} {$i < 9} {incr i} {
+ if {!$i} {
+ set value $bit8
+ } else {
+ set value [expr {$sbuf & (1 << (8 - $i))}]
+ }
+
+ if {$value} {
+ set outline ${::BitMap::one_outline}
+ set fill ${::BitMap::one_fill}
+ } else {
+ set outline ${::BitMap::zero_outline}
+ set fill ${::BitMap::zero_fill}
+ }
+
+ $canvas($side) itemconfigure $bit_rect(b,$side,$i) \
+ -outline $outline \
+ -fill $fill
+ }
+ }
+ public method uart_monitor_graph_clear {side} {
+ $canvas($side) delete graph
+
+ set graph_position($side) 0
+ set graph_prev_states($side) 1
+ set graph_elements($side) [list]
+ }
+
+ public method uart_monitor_graph_draw {side values} {
+ if {$graph_position($side) == 190} {
+ $canvas($side) move graph -1 0
+ foreach items [lindex $graph_elements($side) 0] {
+ foreach item $items {
+ $canvas($side) delete $item
+ }
+ }
+ set graph_elements($side) [lreplace $graph_elements($side) 0 0]
+ incr graph_position($side) -1
+ }
+
+ set x_0 [expr {45 + $graph_position($side)}]
+ set x_1 [expr {$x_0 + 1}]
+
+ set i 0
+ set prev_state [list]
+ set graph_elems [list]
+ foreach state $values {
+ set top [expr {75 + $i * 20}]
+ set mid [expr {82 + $i * 20}]
+ set bot [expr {90 + $i * 20}]
+ switch -- [lindex $graph_prev_states($side) $i] {
+ 0 {
+ switch -- $state {
+ 0 { ;# 0 --> 0
+ lappend graph_elems [list \
+ [$canvas($side) create line $x_0 $bot $x_1 $bot -tags graph -fill {#00FF00}] \
+ ]
+ }
+ 1 { ;# 0 --> 1
+ lappend graph_elems [list \
+ [$canvas($side) create line $x_0 $top $x_0 $mid -tags graph -fill {#FF0000}] \
+ [$canvas($side) create line $x_0 $mid $x_0 $bot -tags graph -fill {#00FF00}] \
+ ]
+ }
+ default {
+ lappend graph_elems [list \
+ [$canvas($side) create line $x_0 $top $x_0 $bot -tags graph -fill {#0000FF}] \
+ ]
+ }
+ }
+ }
+ 1 {
+ switch -- $state {
+ 0 { ;# 1 --> 0
+ lappend graph_elems [list \
+ [$canvas($side) create line $x_0 $top $x_0 $mid -tags graph -fill {#FF0000}] \
+ [$canvas($side) create line $x_0 $mid $x_0 $bot -tags graph -fill {#00FF00}] \
+ ]
+ }
+ 1 { ;# 1 --> 1
+ lappend graph_elems [list \
+ [$canvas($side) create line $x_0 $top $x_1 $top -tags graph -fill {#FF0000}] \
+ ]
+ }
+ default {
+ lappend graph_elems [list \
+ [$canvas($side) create line $x_0 $top $x_0 $bot -tags graph -fill {#0000FF}] \
+ ]
+ }
+ }
+ }
+ default {
+ lappend graph_elems [list \
+ [$canvas($side) create line $x_0 $top $x_0 $bot -tags graph -fill {#0055FF}] \
+ ]
+ }
+ }
+
+ incr i
+ lappend prev_state $state
+ }
+
+ incr graph_position($side)
+ set graph_prev_states($side) $prev_state
+ lappend graph_elements($side) $graph_elems
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/simulator/virtual_uart_term.tcl b/lib/simulator/virtual_uart_term.tcl
deleted file mode 100755
index 29f3199..0000000
--- a/lib/simulator/virtual_uart_term.tcl
+++ /dev/null
@@ -1,646 +0,0 @@
-#!/usr/bin/tclsh
-# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
-
-############################################################################
-# Copyright (C) 2010 by Martin Ošmera #
-# martin.osmera@gmail.com #
-# #
-# This program is free software; you can redistribute it and#or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation; either version 2 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program; if not, write to the #
-# Free Software Foundation, Inc., #
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
-############################################################################
-
-# --------------------------------------------------------------------------
-# DESCRIPTION
-# UART monitor
-# -------------------------------------------------------------------------
-
-# LOAD PROGRAM ICONS
-# -----------------------------
-if {$argv0 != {./virtual_uart_term.tcl}} {
- set D 0
-} {
- set D 1
-}
-if {$D} {
- package require Tk
- package require img::png
- package require Itcl
- namespace import -force ::itcl::*
- package require msgcat
- namespace import -force ::msgcat::*
- package require BWidget
- set ::DEFAULT_FIXED_FONT {DejaVu Sans Mono}
- set ::MICROSOFT_WINDOWS 0
-
- set LIB_DIRNAME "/media/disk/mcu8051ide/lib"
- source "$LIB_DIRNAME/lib/hexeditor.tcl"
-
- foreach directory {16x16 22x22 32x32} ns {16 22 32} {
- namespace eval ::ICONS::${ns} {}
- foreach filename [glob "${::LIB_DIRNAME}/../icons/${directory}/*.png"] {
- set filename [file normalize $filename]
- set iconname [file tail $filename]
- regexp {^\w+} $iconname iconname
- if {[catch {
- image create photo ::ICONS::${ns}::${iconname} -format png -file $filename
- } result]} then {
- puts stderr {}
- puts -nonewline stderr $result
- image create photo ::ICONS::${ns}::${iconname}
- }
- }
- }
-
- proc menuFactory {pattern path tearoff cmdPrefix shortcuts options} {
-
- # Create menu widget
- eval "menu $path -tearoff $tearoff $options"
-
- # Iterate over menu definition list
- foreach menuitem $pattern {
- # Create array of options
- for {set i 0} {$i < 9} {incr i} {
- set menu($i) [lindex $menuitem $i]
- }
- # Determinate kind of operation
- switch $menu(0) {
- {command} {
- # Item icon
- if {$menu(5) != {}} {
- set menu(5) "::ICONS::16::$menu(5)"
- }
-
- # Adjust accelerator value
- set menu(2) $menu(2)
-
- # Create menu command
- $path add command \
- -label [mc $menu(1)] \
- -accelerator $menu(2) \
- -underline $menu(3) \
- -command "$cmdPrefix$menu(4)" \
- -image $menu(5) -compound left
-
- # Status bar tip
- if {$menu(6) != {}} {
- set itemIndex [$path index end]
- menu_Sbar_add $path $itemIndex [mc $menu(6)]
- bind $path <<MenuSelect>> "menu_Sbar $path \[%W index active\]"
- bind $path <Leave> {Sbar {}}
- }
- }
- {separator} {$path add separator}
- {radiobutton} {
- # Adjust command
- if {$menu(5) != {}} {
- set menu(5) "${cmdPrefix}$menu(5)"
- }
-
- # Adjust accelerator value
- set menu(2) [adjust_menu_accelerator $menu(2)]
-
- # Create radio button item
- $path add radiobutton \
- -label [mc $menu(1)] \
- -accelerator $menu(2) \
- -variable $menu(3) \
- -value $menu(4) \
- -command $menu(5) \
- -underline $menu(6) \
- -compound left \
- -indicatoron 0 \
- -image ::ICONS::raoff \
- -selectimage ::ICONS::raon \
- -selectcolor {#EEEEEE}
-
- # Status bar tip
- if {$menu(7) != {}} {
- set itemIndex [$path index end]
- menu_Sbar_add $path $itemIndex [mc $menu(7)]
- bind $path <<MenuSelect>> "menu_Sbar $path \[%W index active\]"
- bind $path <Leave> {Sbar {}}
- }
- }
- {checkbutton} {
- # Adjust command
- if {$menu(7) != {}} {
- set menu(7) "${cmdPrefix}$menu(7)"
- }
- # Adjust accelerator value
- set menu(2) [adjust_menu_accelerator $menu(2)]
-
- # Create checkbutton item
- $path add checkbutton \
- -label [mc $menu(1)] \
- -accelerator $menu(2) \
- -variable $menu(3) \
- -onvalue $menu(4) \
- -offvalue $menu(5) \
- -underline $menu(6) \
- -command $menu(7) \
- -compound left \
- -image ::ICONS::choff \
- -indicatoron 0 \
- -selectimage ::ICONS::chon \
- -selectcolor {#EEEEEE}
- # Status bar tip
- if {$menu(8) != {}} {
- set itemIndex [$path index end]
- menu_Sbar_add $path $itemIndex [mc $menu(8)]
- bind $path <<MenuSelect>> "menu_Sbar $path \[%W index active\]"
- bind $path <Leave> {Sbar {}}
- }
- }
- {cascade} {
- # Adjust menu name
- set menu(4) "$path$menu(4)"
- # Create new menu for cascade
- if {$menu(7) != {}} {
- menuFactory $menu(7) $menu(4) $menu(5) $cmdPrefix $menu(6) $options
- }
- # Item icon
- if {$menu(3) != {}} {
- set menu(3) "::ICONS::16::$menu(3)"
- }
- # Add cascade to this menu
- $path add cascade -label [mc $menu(1)] -underline $menu(2) \
- -image $menu(3) -menu $menu(4) -compound left
- }
- {} {return}
- default {
- error "Menu creation failed -- unknown type: $menu(0)"
- return -code 1
- }
- }
- }
- }
-
- ttk::style theme use clam
- # - ttk
- set TTK_COMMON_BG {#E0E0E0}
- ttk::style configure TFrame \
- -background {#EEEEEE}
-
- ttk::style configure TNotebook \
- -background {#EEEEEE} \
- -fieldbackground {red}
- ttk::style map TNotebook \
- -background [list \
- active red \
- pressed blue \
- pressed green \
- ]
-
- font configure TkTextFont -family {helvetica} -size -12 -weight {normal}
- font configure TkDefaultFont -family {helvetica} -size -12 -weight {normal}
-
- ttk::style configure StringNotFound.TEntry \
- -fieldbackground {#FFDDDD}
- ttk::style configure StringFound.TEntry \
- -fieldbackground {#DDFFDD}
-
- ttk::style configure Simulator.TEntry
- ttk::style map Simulator.TEntry \
- -fieldbackground [list readonly {#F8F8F8}] \
- -foreground [list readonly {#888888}]
- ttk::style configure Simulator_HG.TEntry \
- -foreground {#CC8800}
- ttk::style configure Simulator_WhiteBg.TEntry \
- -fieldbackground {#FFFFFF} \
- -fielddisabledbackground {#FFFFFF}
- ttk::style configure Simulator_WhiteBg_HG.TEntry \
- -fieldbackground {#FFFFFF} \
- -fielddisabledbackground {#FFFFFF} \
- -foreground {#CC8800}
- ttk::style configure Simulator_WhiteBg_Sel.TEntry \
- -fieldbackground {#DDDDFF} \
- -fielddisabledbackground {#DDDDFF}
- ttk::style configure Simulator_WhiteBg_HG_Sel.TEntry \
- -foreground {#CC8800} \
- -fieldbackground {#DDDDFF} \
- -fielddisabledbackground {#DDDDFF}
-
- ttk::style configure Simulator_watchdogEntry_0.TEntry \
- -fieldbackground {#88FF88} \
- -fielddisabledbackground {#66DD66}
- ttk::style map Simulator_watchdogEntry_0.TEntry \
- -foreground [list readonly {#888888}]
-
- ttk::style configure Simulator_watchdogEntry_1.TEntry \
- -fieldbackground {#FFFF55} \
- -fielddisabledbackground {#DDDD33}
- ttk::style map Simulator_watchdogEntry_1.TEntry \
- -foreground [list readonly {#888888}]
-
- ttk::style configure Simulator_watchdogEntry_2.TEntry \
- -fieldbackground {#FF5555} \
- -fielddisabledbackground {#DD3333}
- ttk::style map Simulator_watchdogEntry_2.TEntry \
- -foreground [list readonly {#888888}]
-
- ttk::style configure TLabelframe \
- -background {#EEEEEE}
- ttk::style configure TLabel \
- -background {#EEEEEE}
-
- ttk::style configure TButton \
- -background $TTK_COMMON_BG \
- -padding 0
- ttk::style configure RedBg.TButton \
- -padding 0
- ttk::style map RedBg.TButton \
- -background [list \
- active {#FFBBBB} \
- !active {#FF8888} \
- ] \
- -foreground [list \
- active {#FF0000} \
- !active {#000000} \
- ]
- ttk::style configure GreenBg.TButton \
- -padding 0
- ttk::style map GreenBg.TButton \
- -background [list \
- active {#BBFFBB} \
- !active {#88FF88} \
- ] \
- -foreground [list \
- active {#00FF00} \
- !active {#000000} \
- ]
-
- ttk::style configure Flat.TButton \
- -background {#EEEEEE} \
- -padding 0 \
- -borderwidth 1 \
- -relief flat
- ttk::style map Flat.TButton \
- -relief [list active raised] \
- -background [list disabled {#EEEEEE}]
-
- ttk::style configure TMenubutton \
- -padding 0 \
- -background $TTK_COMMON_BG
- ttk::style configure Flat.TMenubutton \
- -padding 0 \
- -background {#EEEEEE} \
- -borderwidth 1 \
- -relief flat
- ttk::style map Flat.TMenubutton \
- -relief [list active raised] \
- -background [list disabled {#EEEEEE}]
-
- ttk::style configure FlatWhite.TButton \
- -padding 0 \
- -background {#FFFFFF} \
- -borderwidth 1 \
- -relief flat
- ttk::style map FlatWhite.TButton \
- -relief [list active raised] \
- -background [list disabled {#FFFFFF}]
-
- ttk::style configure ToolButton.TButton \
- -background {#EEEEEE} \
- -padding 1 \
- -borderwidth 1 \
- -relief flat
- ttk::style map ToolButton.TButton \
- -relief [list active raised] \
- -background [list disabled {#EEEEEE}]
-
- ttk::style configure TCombobox \
- -background $TTK_COMMON_BG \
- -fieldfont [font create -family {helvetica} -size -12 -weight {normal}]
- ttk::style map TCombobox \
- -foreground [list disabled {#888888}] \
- -fieldbackground [list \
- readonly $TTK_COMMON_BG \
- disabled {#EEEEEE} \
- {!readonly !disabled} {#FFFFFF} \
- ]
-
- ttk::style configure TScrollbar \
- -background $TTK_COMMON_BG \
- -troughcolor {#F8F8F8}
-
- ttk::style configure TScale \
- -background $TTK_COMMON_BG
- ttk::style map TScale \
- -troughcolor [list \
- disabled $TTK_COMMON_BG \
- !disabled {#F8F8F8} \
- ]
-
- ttk::style configure TProgressbar \
- -background $TTK_COMMON_BG \
- -troughcolor {#F8F8F8}
- wm withdraw .
-}
-
-class VirtualUartTerminal {
- ## COMMON
- common count 0 ;# Counter of intances
- # Font: Big bold font
- common bold_font [font create \
- -family {helvetica} \
- -size -12 -weight {bold} \
- ]
- # Font: Tiny normal font
- common tiny_font [font create \
- -family {helvetica} \
- -size -9 -weight {normal} \
- ]
- # Font: Tiny bold font
- common tiny_font_bold [font create \
- -family {helvetica} \
- -size -9 -weight {bold} \
- ]
- # Font: Normal font
- common normal_font [font create \
- -family {helvetica} \
- -size -11 -weight {normal} \
- ]
- # Font: Also normal font, but a bit larger
- common big_font [font create \
- -family {helvetica} \
- -size -12 -weight {normal} \
- ]
- # List of Int: Available baud rates for RS232
- common available_baud_rates {
- 50 75 110 134 150 200
- 300 600 1200 1800 2400 4800
- 9600 19200 38400 57600 115200 230400
- 460800
- }
-
- ## PRIVATE
- private variable dialog_opened 0 ;# Bool: Dialog window opened
- private variable win ;# Widget: Dialog window
- private variable status_bar_label ;# Widget: Status bar
-
- private variable too_baud_conf {9600} ;# Int: Selected baud rate for communication
- private variable too_parity_conf {n} ;# Char: Selected type of parity
- private variable too_data_conf {8} ;# Int: Number of data bits
- private variable too_stop_conf {1} ;# Int: Number of stop bits
-
- constructor {} {
- }
-
- destructor {
- }
-
- ## Close interrupt monitor window and free its resources
- # @return void
- public method virtual_uart_termial_close {} {
- if {!$dialog_opened} {
- return
- }
-
- set geometry [wm geometry $win]
- set dialog_opened 0
- set in_progress_wdg {}
- set in_progress_flg {}
- set pending_flg {}
- set intr_priorities {}
- set avaliable_interrs {}
-
- if {[winfo exists $win]} {
- destroy $win
- }
- }
-
- ## Invoke interrupt monitor window
- # @return void
- public method virtual_uart_termial_invoke_dialog {} {
- set dialog_opened 1
-
- # Create window
- set win [toplevel .virtual_uart_term$count -class [mc "UART Monitor"] -bg {#EEEEEE}]
- incr count
-
- # Create status bar
- set status_bar_label [label $win.status_bar_label -justify left -pady 0 -anchor w]
- pack $status_bar_label -side bottom -fill x
-
- # Create top frame
- set top_frame [frame $win.top_frame]
- create_top_frame $top_frame
- pack $top_frame -fill x -anchor nw
-
- # Create bottom frame
- set bottom_frame [frame $win.bottom_frame]
- create_bottom_frame $bottom_frame
- pack $bottom_frame -fill x -anchor nw
-
- # Configure window
- wm title $win [mc "Virtual UART Terminal - MCU 8051 IDE"]
- wm iconphoto $win ::ICONS::16::_blockdevice
- wm resizable $win 0 0
- wm protocol $win WM_DELETE_WINDOW "$this virtual_uart_termial_close"
- }
-
- ## Set status bar tip for specified widget
- # @parm Widget widget - Target widget
- # @parm String text - Text of the stutus tip
- # @return void
- private method virtual_uart_termial_set_status_tip {widget text} {
- bind $widget <Enter> "$status_bar_label configure -text {$text}"
- bind $widget <Leave> "$status_bar_label configure -text {}"
- }
-
- ## Create top frame in the dialog window (connector_canvas (left) and configuration (right))
- # @parm Widget target_frame - Parent frame
- # @return void
- private method create_top_frame {target_frame} {
- #
- ## FRAME: OUR MICROCONTROLLER
- #
-
- # Create labelframe
- set our_mcu_frame [ttk::labelframe $target_frame.our_mcu_frame \
- -padding 5 \
- -labelwidget [label $target_frame.our_mcu_label \
- -font $bold_font \
- -compound left \
- -text [mc "\"Our Microcontroller\""] \
- -image ::ICONS::16::configure \
- ] \
- ]
- pack [label $our_mcu_frame.l -text "AAAA"]
- pack $our_mcu_frame -side left -fill x -expand 1 -padx 5
-
-
- #
- ## FRAME: THE OTHER DEVICE
- #
-
- # Create labelframe
- set the_other_one_frame [ttk::labelframe \
- $target_frame.the_other_one_frame \
- -padding 5 \
- -labelwidget [label $target_frame.too_label \
- -font $bold_font \
- -compound left \
- -text [mc "Terminal configuration"] \
- -image ::ICONS::16::configure \
- ] \
- ]
- # - Baud rate
- grid [label $the_other_one_frame.baud_lbl \
- -text [mc "Baud rate"] \
- ] -row 3 -column 1 -sticky w
- set baud_cb [ttk::combobox $the_other_one_frame.baud_cb \
- -state readonly \
- -width 6 \
- -exportselection 0 \
- -values $available_baud_rates \
- ]
- bind $baud_cb <<ComboboxSelected>> \
- "$this change_port_config b \[$the_other_one_frame.baud_cb get\]"
- virtual_uart_termial_set_status_tip $baud_cb [mc "Connection speed in bps"]
- grid $baud_cb -row 3 -column 2 -sticky w
- $the_other_one_frame.baud_cb current [lsearch [$the_other_one_frame.baud_cb cget -values] $too_baud_conf]
- # - Parity
- grid [label $the_other_one_frame.parity_lbl \
- -text [mc "Parity"] \
- ] -row 4 -column 1 -sticky w
- set parity_cb [ttk::combobox $the_other_one_frame.parity_cb \
- -values {none odd even mark space} \
- -state readonly \
- -width 6 \
- -exportselection 0 \
- ]
- bind $parity_cb <<ComboboxSelected>> \
- "$this change_port_config p \[$the_other_one_frame.parity_cb get\]"
- virtual_uart_termial_set_status_tip $parity_cb [mc "Parity"]
- grid $parity_cb -row 4 -column 2 -sticky w
- $the_other_one_frame.parity_cb current [lsearch {n o e m s} $too_parity_conf]
- # - Data bits
- grid [label $the_other_one_frame.data_lbl \
- -text [mc "Data bits"] \
- ] -row 5 -column 1 -sticky w
- set data_cb [ttk::combobox $the_other_one_frame.data_cb \
- -state readonly \
- -width 1 \
- -values {5 6 7 8} \
- -exportselection 0 \
- ]
- bind $data_cb <<ComboboxSelected>> \
- "$this change_port_config d \[$the_other_one_frame.data_cb get\]"
- virtual_uart_termial_set_status_tip $data_cb [mc "Number of data bits"]
- grid $data_cb -row 5 -column 2 -sticky w
- $the_other_one_frame.data_cb current [lsearch [$the_other_one_frame.data_cb cget -values] $too_data_conf]
- # - Stop bits
- grid [label $the_other_one_frame.stop_lbl \
- -text [mc "Stop bits"] \
- ] -row 6 -column 1 -sticky w
- set stop_cb [ttk::combobox $the_other_one_frame.stop_cb \
- -state readonly \
- -width 1 \
- -values {1 2} \
- -exportselection 0 \
- ]
- bind $stop_cb <<ComboboxSelected>> \
- "$this change_port_config s \[$the_other_one_frame.stop_cb get\]"
- virtual_uart_termial_set_status_tip $stop_cb [mc "Number of stop bits"]
- grid $stop_cb -row 6 -column 2 -sticky w
- $the_other_one_frame.stop_cb current [lsearch [$the_other_one_frame.stop_cb cget -values] $too_stop_conf]
- pack $the_other_one_frame -side left -fill x -expand 1 -padx 5
- }
-
- ## Create bottom frame (hexadecimal editors)
- # @parm Widget target_frame - Parent frame
- # @return void
- private method create_bottom_frame {target_frame} {
- # Create headers ("Data to send", "Received data")
- grid [label $target_frame.lbl_a \
- -text [mc "Data to send"] \
- -compound right \
- -image ::ICONS::16::forward \
- -padx 15 -font $bold_font \
- ] -row 0 -column 1 -columnspan 2
- grid [label $target_frame.lbl_b \
- -text [mc "Received data"] \
- -compound left \
- -image ::ICONS::16::forward \
- -padx 15 -font $bold_font \
- ] -row 0 -column 3 -columnspan 2
-
- # Create hexadecimal editors
- set send_hexeditor [HexEditor #auto \
- $target_frame.send_hexeditor 8 32 2 \
- hex 1 1 5 256 \
- ]
- [$send_hexeditor getLeftView] configure -exportselection 0
- $send_hexeditor bindSelectionAction "$this hexeditor_selection s"
- grid $target_frame.send_hexeditor -row 1 -column 1 -columnspan 2
-
- set receive_hexeditor [HexEditor #auto \
- $target_frame.receive_hexeditor 8 32 2 \
- hex 1 1 5 256 \
- ]
- [$send_hexeditor getLeftView] configure -exportselection 0
- $receive_hexeditor bindSelectionAction "$this hexeditor_selection r"
- grid $target_frame.receive_hexeditor -row 1 -column 3 -columnspan 2
-
- # Create buttons "Send selected" and "Clear selected" in send part
- set send_selected_button [ttk::button \
- $target_frame.send_selected_button \
- -text [mc "Send selected"] \
- -image ::ICONS::16::forward \
- -command "$this send_selected" \
- -compound left \
- -state disabled \
- ]
- set clear_selected_snd_button [ttk::button \
- $target_frame.clear_selected_snd_button \
- -text [mc "Clear selected"] \
- -image ::ICONS::16::eraser \
- -command "$this clear_selected_snd" \
- -compound left \
- -state disabled \
- ]
- virtual_uart_termial_set_status_tip $send_selected_button [mc "Send selected data"]
- virtual_uart_termial_set_status_tip $clear_selected_snd_button [mc "Remove selected data"]
- grid $send_selected_button -row 2 -column 1 -sticky we
- grid $clear_selected_snd_button -row 2 -column 2 -sticky we
-
- # Create buttons "Receive here" and "Clear selected" in reception part
- set receive_here_button [ttk::button \
- $target_frame.receive_here_button \
- -text [mc "Receive here"] \
- -image ::ICONS::16::down0 \
- -command "$this receive_here" \
- -compound left \
- ]
- set clear_selected_rec_button [ttk::button \
- $target_frame.clear_selected_rec_button \
- -text [mc "Clear selected"] \
- -image ::ICONS::16::eraser \
- -command "$this clear_selected_rec" \
- -compound left \
- -state disabled \
- ]
- virtual_uart_termial_set_status_tip $receive_here_button [mc "Receive data on current cursor position"]
- virtual_uart_termial_set_status_tip $clear_selected_rec_button [mc "Remove selected data"]
- grid $receive_here_button -row 2 -column 3 -sticky we
- grid $clear_selected_rec_button -row 2 -column 4 -sticky we
- }
-}
-
-if {$D} {
- VirtualUartTerminal virtual_uart_term
- virtual_uart_term virtual_uart_termial_invoke_dialog
-}
diff --git a/lib/utilities/asciichart.tcl b/lib/utilities/asciichart.tcl
index 01ac86e..bc44f3e 100755..100644
--- a/lib/utilities/asciichart.tcl
+++ b/lib/utilities/asciichart.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,14 +21,19 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _ASCIICHART_TCL ] } {
+set _ASCIICHART_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Interactive ASCII chart
# --------------------------------------------------------------------------
class AsciiChart {
- common count 0 ;# Int: Counter of object instances
- common ASCII_TABLE ;# Array of List: ASCII table
+ common ascii_chr_count 0 ;# Int: Counter of object instances
+ common ASCII_TABLE ;# Array of List: ASCII table
array set ASCII_TABLE {
0 {NUL ^@ \\0 {Null character}}
1 {SOH ^A {} {Start of Header}}
@@ -110,25 +115,27 @@ class AsciiChart {
constructor {} {
# Configure local ttk styles
- ttk::style configure AsciiChart_BlueFg.TEntry -foreground {#0000DD}
- ttk::style configure AsciiChart_RedFg.TEntry -foreground {#DD0000}
+ ttk::style configure AsciiChart_BlueFg.TEntry -foreground {#0000DD}
+ ttk::style configure AsciiChart_RedFg.TEntry -foreground {#DD0000}
+ ttk::style configure AsciiChart_RedBg.TEntry -fieldbackground {#FFDDDD}
+ ttk::style configure AsciiChart_GreenBg.TEntry -fieldbackground {#DDFFDD}
# Create dialog window
set window_visible 1
- set win [toplevel .asciichart$count -class {ASCII chart} -bg {#EEEEEE}]
- set obj_idx $count
- incr count
+ set win [toplevel .asciichart${ascii_chr_count} -class {ASCII chart} -bg ${::COMMON_BG_COLOR}]
+ set obj_idx $ascii_chr_count
+ incr ascii_chr_count
# Create dialog GUI
create_gui
# Set window event bindings
- bind $win <Control-Key-q> "::itcl::delete object $this; break"
+ bind $win <Control-Key-q> "$this close_window; break"
bindtags $win [list $win Toplevel all .]
# Set window parameters
wm iconphoto $win ::ICONS::16::math_matrix
- wm title $win "ASCII chart - MCU 8051 IDE"
+ wm title $win "[mc {ASCII chart}] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this close_window"
}
@@ -173,7 +180,7 @@ class AsciiChart {
set status_bar_lbl [label $bottom_frame.status_bar_lbl -justify left -anchor w]
pack $status_bar_lbl -side left -fill x -in $bottom_frame
pack [ttk::button $bottom_frame.close_but \
- -text "Exit" \
+ -text [mc "Exit"] \
-command "$this close_window" \
-compound left \
-image ::ICONS::16::exit \
@@ -182,14 +189,14 @@ class AsciiChart {
## Create main frame
set main_frame [frame $win.main_frame -bg {#DDDDDD}]
# Create vertical header
- grid [frame $main_frame.top_right_lbl -bg {#EEEEEE}] -sticky wens -row 0 -column 0
+ grid [frame $main_frame.top_right_lbl -bg ${::COMMON_BG_COLOR}] -sticky wens -row 0 -column 0
set header [list {} \
{0x0_} {0x1_} {0x2_} {0x3_} \
{0x4_} {0x5_} {0x6_} {0x7_} \
]
for {set y 1} {$y < 9} {incr y} {
grid [label $main_frame.vh_lbl$y -text [lindex $header $y] -bg {#FFFFFF}] \
- -row $y -column 0 -pady [expr {$y % 2}] -sticky ns
+ -row $y -column 0 -pady [expr {$y % 2}] -sticky wens
set vh_cells([expr {$y - 1}]) $main_frame.vh_lbl$y
}
# Create horizontal header
@@ -201,7 +208,7 @@ class AsciiChart {
]
for {set x 1} {$x < 17} {incr x} {
grid [label $main_frame.hh_lbl$x -text [lindex $header $x] -bg {#FFFFFF}] \
- -row 0 -column $x -padx [expr {$x % 2}] -sticky we
+ -row 0 -column $x -padx [expr {$x % 2}] -sticky wens
set hh_cells([expr {$x - 1}]) $main_frame.hh_lbl$x
}
# Create ASCII chart matrix
@@ -225,7 +232,7 @@ class AsciiChart {
set val [lindex $ASCII_TABLE($address) 0]
if {[string length $val] > 1} {
set foreground {#DD0000}
- } {
+ } else {
set foreground {#0000DD}
}
@@ -239,23 +246,44 @@ class AsciiChart {
-bg white -pady 0 \
]
- grid $frame -row $y -column $x -padx [expr {$x % 2}] -pady [expr {$y % 2}] -sticky we
+ grid $frame -row $y -column $x -padx [expr {$x % 2}] -pady [expr {$y % 2}] -sticky wens
set cells($address) $frame
foreach wdg [list $frame $frame.val_lbl $frame.char_lbl] {
bind $wdg <Enter> "$this cell_enter $address"
bind $wdg <Leave> "$this cell_leave $address"
bind $wdg <Button-1> "$this cell_click $address"
}
+
+ if {$address < 127} {
+ bind $frame <Key-Right> [list $this cell_click [expr {$address + 1}]]
+ }
+ if {$address > 0} {
+ bind $frame <Key-Left> [list $this cell_click [expr {$address - 1}]]
+ }
+ if {$address > 16} {
+ bind $frame <Key-Up> [list $this cell_click [expr {$address - 16}]]
+ }
+ if {$address < 112} {
+ bind $frame <Key-Down> [list $this cell_click [expr {$address + 16}]]
+ }
+
incr address
}
}
+ # Ensure than all cells have the same width and heigh
+ for {set i 0} {$i < 17} {incr i} {
+ grid columnconfigure $main_frame $i -uniform ascii
+ }
+ for {set i 1} {$i < 9} {incr i} {
+ grid rowconfigure $main_frame $i -uniform ascii
+ }
# Show ASCII chart
pack $main_frame -pady 5 -side top
## Create details frame (character details)
# Create labelframe
set details_frame_header_frm [frame $win.details_frame_header_frm]
- pack [label $details_frame_header_frm.lbl -text "Character: "] -side left
+ pack [label $details_frame_header_frm.lbl -text [mc "Character: "]] -side left
set char_ent [ttk::entry $details_frame_header_frm.ent \
-validatecommand "$this char_ent_validator %P" \
-width 4 \
@@ -407,6 +435,7 @@ class AsciiChart {
set selected_cell -1
return
}
+ focus $cells($address)
select_cell $address
if {$selected_cell != -1} {
fill_entryboxes $address {}
@@ -459,7 +488,7 @@ class AsciiChart {
# Set new background color
if {$keep_current} {
sel_bg_color $selected_cell {#DDFFDD}
- } {
+ } else {
sel_bg_color $selected_cell {#FFFFFF}
}
@@ -526,7 +555,7 @@ class AsciiChart {
$char_ent insert insert $value
if {[string length $value] > 1} {
$char_ent configure -style AsciiChart_RedFg.TEntry
- } {
+ } else {
$char_ent configure -style AsciiChart_BlueFg.TEntry
}
}
@@ -569,7 +598,7 @@ class AsciiChart {
## Validator for entrybox "Character"
# @parm String string - New entrybox contents
- # @return Bool - Allways 1
+ # @return Bool - Always 1
public method char_ent_validator {string} {
if {!$validation_ena} {return 1}
set validation_ena 0
@@ -599,7 +628,7 @@ class AsciiChart {
if {$length > 1} {
$char_ent configure -style AsciiChart_RedFg.TEntry
- } {
+ } else {
$char_ent configure -style AsciiChart_BlueFg.TEntry
}
@@ -638,7 +667,7 @@ class AsciiChart {
# Empty input string
set length [string length $string]
if {!$length} {
- $widget configure -bg {#FFFFFF}
+ $widget configure -style TEntry
clear_entryboxes $type
unselect_current_cell 0 0
set validation_ena 1
@@ -684,7 +713,7 @@ class AsciiChart {
if {$string > 127 || $string < 0} {
clear_entryboxes $type
unselect_current_cell 0 0
- $widget configure -bg {#FFDDDD}
+ $widget configure -style AsciiChart_RedBg.TEntry
set validation_ena 1
return 1
}
@@ -692,7 +721,7 @@ class AsciiChart {
# Adjust GUI (ACII chart and details frame)
select_cell $string
fill_entryboxes $string $type
- $widget configure -bg {#DDFFDD}
+ $widget configure -style AsciiChart_GreenBg.TEntry
return 1
}
@@ -710,14 +739,14 @@ class AsciiChart {
if {$type == {C}} {
set widget $caret_not_ent
set index 1
- } {
+ } else {
set widget $escape_seq_ent
set index 2
}
# Empty input string
if {![string length $string]} {
- $widget configure -bg {#FFFFFF}
+ $widget configure -style TEntry
clear_entryboxes $type
unselect_current_cell 0 0
set validation_ena 1
@@ -736,7 +765,7 @@ class AsciiChart {
select_cell $i
fill_entryboxes $i $type
- $widget configure -bg {#DDFFDD}
+ $widget configure -style AsciiChart_GreenBg.TEntry
set validation_ena 1
return 1
}
@@ -745,8 +774,12 @@ class AsciiChart {
# String not found
clear_entryboxes $type
unselect_current_cell 0 0
- $widget configure -bg {#FFDDDD}
+ $widget configure -style AsciiChart_RedBg.TEntry
set validation_ena 1
return 1
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/utilities/baseconvertor.tcl b/lib/utilities/baseconverter.tcl
index ded53cb..82d656a 100755..100644
--- a/lib/utilities/baseconvertor.tcl
+++ b/lib/utilities/baseconverter.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,15 +21,36 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _BASECONVERTER_TCL ] } {
+set _BASECONVERTER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
-# Utility "Base Convertor"
+# Utility "Base Converter"
# --------------------------------------------------------------------------
-class BaseConvertor {
+class BaseConverter {
## COMMON
- common count 0 ;# Int: Counter of class instances
+ common base_c_count 0 ;# Int: Counter of class instances
+ common INITIAL_HEIGHT 130 ;# Int: Initial heightof the window in pixels
+ common INITIAL_WIDTH 150 ;# Int: Initial width of the window in pixels
+ common EXTENDED_WIDTH 340 ;# Int: Width of the window when it is in extended mode
+
+ # On MS Windows these values has to be a bit different
+ if {$::MICROSOFT_WINDOWS} {
+ set INITIAL_HEIGHT 125
+ set INITIAL_WIDTH 165
+ set EXTENDED_WIDTH 355
+ }
+ # Font entryboxes
+ common entry_font [font create \
+ -size -12 \
+ -family $::DEFAULT_FIXED_FONT \
+ -weight bold \
+ ]
## PRIVATE
private variable win ;# Widget: Window
@@ -64,12 +85,13 @@ class BaseConvertor {
## Object constructor
constructor {} {
# Configure ttk styles
- if {!$count} {
- ttk::style configure BaseConvertor_Focused_D.TEntry -fieldbackground {#AAAAFF}
- ttk::style configure BaseConvertor_Focused_I.TEntry -fieldbackground {#DDDDFF}
+ if {!$base_c_count} {
+ ttk::style configure BaseConverter_Focused_D.TEntry -fieldbackground {#AAAAFF}
+ ttk::style configure BaseConverter_Focused_I.TEntry -fieldbackground {#DDDDFF}
+ ttk::style configure BaseConverter_NotFocused.TEntry
}
- incr count
+ incr base_c_count
create_window
create_gui
@@ -125,7 +147,7 @@ class BaseConvertor {
[$entry_d(3) get] \
[$entry_d(4) get] \
[$entry_d(5) get]
- } {
+ } else {
lappend values {} {} {}
}
@@ -142,12 +164,12 @@ class BaseConvertor {
## Create window using class "InnerWindow"
# @return void
private method create_window {} {
- set win_obj [InnerWindow #auto \
- .baseconvertor_${count} \
- [list 160 130 100 100] \
- [mc "Convertor"] \
- ::ICONS::16::kaboodleloop \
- "$this close_window" \
+ set win_obj [InnerWindow #auto \
+ .baseconverter_${base_c_count} \
+ [list $INITIAL_WIDTH $INITIAL_HEIGHT 100 100] \
+ [mc "Converter"] \
+ ::ICONS::16::kaboodleloop \
+ "$this close_window" \
]
set win [$win_obj get_frame]
}
@@ -173,8 +195,9 @@ class BaseConvertor {
-image ::ICONS::16::1downarrow \
-command "$this enlarge_shrink" \
-width 7 \
+ -style Flat.TButton \
]
- pack $enlarge_shrink_button -side left
+ pack $enlarge_shrink_button -side left -padx 2 -pady 2
# Button "More"/"Less"
set less_more_button [ttk::button $bottom_frame.less_more_button\
-text [mc "More"] \
@@ -182,8 +205,9 @@ class BaseConvertor {
-image ::ICONS::16::1rightarrow \
-command "$this less_more" \
-width 5 \
+ -style Flat.TButton \
]
- pack $less_more_button -side right
+ pack $less_more_button -side right -padx 2 -pady 2
# Pack frames
pack $left_top_frame -side left -anchor nw
@@ -195,10 +219,10 @@ class BaseConvertor {
}
## Close the window and forget configuration
- # Calls proc. "::X::__base_convertor_close"
+ # Calls proc. "::X::__base_converter_close"
# @return void
public method close_window {} {
- ::X::__base_convertor_close $this
+ ::X::__base_converter_close $this
$win_obj close_window
delete object $this
}
@@ -231,7 +255,7 @@ class BaseConvertor {
# Detect zero length input string
if {[string length $content]} {
set zero_length 0
- } {
+ } else {
set zero_length 1
set content 0
}
@@ -241,7 +265,7 @@ class BaseConvertor {
{h} { ;# Hexadecimal
if {![regexp {^[[:xdigit:]]{0,2}$} $content]} {
set result 0
- } {
+ } else {
scan $content "%x" value
}
}
@@ -250,14 +274,14 @@ class BaseConvertor {
set result 0
} elseif {$content > 255} {
set result 0
- } {
+ } else {
set value $content
}
}
{b} { ;# Binary
if {![regexp {^[01]{0,8}$} $content]} {
set result 0
- } {
+ } else {
set value [NumSystem::bin2dec $content]
}
}
@@ -266,7 +290,7 @@ class BaseConvertor {
set result 0
} elseif {$content > 377} {
set result 0
- } {
+ } else {
scan $content "%o" value
}
}
@@ -275,7 +299,7 @@ class BaseConvertor {
set result 0
} elseif {$content > 15} {
set result 0
- } {
+ } else {
set value [$entry_c1($row) get]
if {![string length $value]} {
set value 0
@@ -289,7 +313,7 @@ class BaseConvertor {
set result 0
} elseif {$content > 15} {
set result 0
- } {
+ } else {
set value [$entry_c0($row) get]
if {![string length $value]} {
set value 0
@@ -306,7 +330,7 @@ class BaseConvertor {
if {[string length $content] > 1} {
set result 0
- } {
+ } else {
set value [NumSystem::ascii2dec $content]
}
@@ -399,7 +423,7 @@ class BaseConvertor {
} elseif {[expr $value & $mask]} {
set fill ${::BitMap::one_fill}
set outline ${::BitMap::one_outline}
- } {
+ } else {
set fill ${::BitMap::zero_fill}
set outline ${::BitMap::zero_outline}
}
@@ -448,7 +472,7 @@ class BaseConvertor {
# Set new rectangle fill and outline and adjust cursor
$entry_t($r) itemconfigure $bit($r,$b) \
-fill $fill -outline $outline
- $entry_t($r) configure -cursor hand1
+ $entry_t($r) configure -cursor hand2
}
## Handles event <leave> on canvas widget with bits,
@@ -564,6 +588,8 @@ class BaseConvertor {
-width $width \
-validate key \
-validatecommand "$this validate $type $row %P" \
+ -style BaseConverter_NotFocused.TEntry \
+ -font $entry_font \
]
set entry_${type}($row) $entry_wgd
grid $entry_wgd -row [expr {$row + 2}] -column $col
@@ -616,6 +642,8 @@ class BaseConvertor {
-width 2 \
-validate all \
-validatecommand "$this validate ${type} $row %P" \
+ -style BaseConverter_NotFocused.TEntry \
+ -font $entry_font \
]
set entry_${type}($row) $entry_wgd
grid $entry_wgd -row [expr {$row + 2}] -column $col
@@ -626,6 +654,8 @@ class BaseConvertor {
-width 2 \
-validate all \
-validatecommand "$this validate ${type}1 $row %P" \
+ -style BaseConverter_NotFocused.TEntry \
+ -font $entry_font \
]
set entry_${type}1($row) $entry_wgd
grid $entry_wgd -row [expr {$row + 2}] -column $col
@@ -637,6 +667,8 @@ class BaseConvertor {
-width 2 \
-validate all \
-validatecommand "$this validate ${type}0 $row %P" \
+ -style BaseConverter_NotFocused.TEntry \
+ -font $entry_font \
]
set entry_${type}0($row) $entry_wgd
grid $entry_wgd -row [expr {$row + 2}] -column $col
@@ -696,15 +728,19 @@ class BaseConvertor {
if {$large} {
create_right_frame
create_left_frame
- $win_obj geometry {} [expr {[winfo height $entry_h(0)] * 3 + 130}] {} {}
+ $win_obj geometry {} [expr {[winfo height $entry_h(0)] * 3 + $INITIAL_HEIGHT}] {} {}
$enlarge_shrink_button configure \
-image ::ICONS::16::1uparrow \
-text [mc "Shrink"]
- } {
- $win_obj geometry {} 130 {} {}
+ } else {
+ $win_obj geometry {} $INITIAL_HEIGHT {} {}
$enlarge_shrink_button configure \
-image ::ICONS::16::1downarrow \
-text [mc "Enlarge"]
+
+ for {set i 0; set j 3} {$i < 3} {incr i; incr j} {
+ lset val_to_set $i [$entry_d($j) get]
+ }
}
# Show or hide appropriate GUI elements
@@ -719,9 +755,9 @@ class BaseConvertor {
} {
for {set i 3; set r 5} {$i < 6} {incr i; incr r} {
if {$large} {
- grid [subst "\$${w}($i)"] -column $c -row $r
- } {
- grid forget [subst "\$${w}($i)"]
+ grid [subst -nocommands "\$${w}($i)"] -column $c -row $r
+ } else {
+ grid forget [subst -nocommands "\$${w}($i)"]
}
}
}
@@ -741,17 +777,17 @@ class BaseConvertor {
$less_more_button configure \
-compound left -text [mc "Less"] \
-image ::ICONS::16::1leftarrow
- $win_obj geometry 350 {} {} {}
+ $win_obj geometry $EXTENDED_WIDTH {} {} {}
for {set i 0} {$i < $right_rows_created} {incr i} {
validate {t} $i [$entry_d($i) get]
}
- } {
+ } else {
pack forget $right_top_frame
$less_more_button configure \
-compound right -text [mc "More"] \
-image ::ICONS::16::1rightarrow
- $win_obj geometry 160 {} {} {}
+ $win_obj geometry $INITIAL_WIDTH {} {} {}
}
}
@@ -770,10 +806,10 @@ class BaseConvertor {
# @return void
public method entry_focus {type row focused} {
if {$focused} {
- set style BaseConvertor_Focused_I.TEntry
+ set style BaseConverter_Focused_I.TEntry
set bg {#DDDDFF}
- } {
- set style TEntry
+ } else {
+ set style BaseConverter_NotFocused.TEntry
set bg {#FFFFFF}
}
@@ -799,9 +835,9 @@ class BaseConvertor {
}
if {$focused} {
- [subst "\$entry_${type}($row)"] configure -style BaseConvertor_Focused_D.TEntry
- } {
- [subst "\$entry_${type}($row)"] selection clear
+ [subst -nocommands "\$entry_${type}($row)"] configure -style BaseConverter_Focused_D.TEntry
+ } else {
+ [subst -nocommands "\$entry_${type}($row)"] selection clear
}
}
@@ -828,7 +864,7 @@ class BaseConvertor {
# e - Enter
# @return void
public method entry_key {type y key} {
- set entrybox [subst "\$entry_${type}($y)"]
+ set entrybox [subst -nocommands "\$entry_${type}($y)"]
set insert [$entrybox index insert]
set max_y $left_rows_created
incr max_y -1
@@ -904,9 +940,13 @@ class BaseConvertor {
{5} {set type c0}
{6} {set type a}
}
- set entrybox [subst "\$entry_${type}($y)"]
+ set entrybox [subst -nocommands "\$entry_${type}($y)"]
$entrybox selection range 0 end
$entrybox icursor [expr {[$entrybox index end] - $insert}]
focus $entrybox
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/utilities/eightsegment.tcl b/lib/utilities/eightsegment.tcl
index de1903b..601d078 100755..100644
--- a/lib/utilities/eightsegment.tcl
+++ b/lib/utilities/eightsegment.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,13 +21,18 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _EIGHTSEGMENT_TCL ] } {
+set _EIGHTSEGMENT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# 8 segment LED display configurator
# --------------------------------------------------------------------------
class EightSegment {
- common count 0 ;# Int: Counter of object instances
+ common ld_ed_count 0 ;# Int: Counter of object instances
private variable obj_idx ;# Int: Current object ID
private variable win ;# Widget: Dialog window
@@ -37,9 +42,9 @@ class EightSegment {
private variable canvas_objects ;# Array: LED segments in canvas widget
private variable validation_ena 1 ;# Bool: Entryboxs validation enabled
- private variable cc_hex_entry ;# Widget: Entrybox "Common catode - Hex"
- private variable cc_dec_entry ;# Widget: Entrybox "Common catode - Dec"
- private variable cc_bin_entry ;# Widget: Entrybox "Common catode - Bin"
+ private variable cc_hex_entry ;# Widget: Entrybox "Common cathode - Hex"
+ private variable cc_dec_entry ;# Widget: Entrybox "Common cathode - Dec"
+ private variable cc_bin_entry ;# Widget: Entrybox "Common cathode - Bin"
private variable ca_hex_entry ;# Widget: Entrybox "Common anode - Hex"
private variable ca_dec_entry ;# Widget: Entrybox "Common anode - Dec"
private variable ca_bin_entry ;# Widget: Entrybox "Common anode - Bin"
@@ -49,9 +54,9 @@ class EightSegment {
constructor {} {
# Create dialog window
- set win [toplevel .eightsegment$count -class {8 segment editor} -bg {#EEEEEE}]
- set obj_idx $count
- incr count
+ set win [toplevel .eightsegment${ld_ed_count} -class {8 segment editor} -bg ${::COMMON_BG_COLOR}]
+ set obj_idx $ld_ed_count
+ incr ld_ed_count
# Restore last session
for {set i 0} {$i < 8} {incr i} {
@@ -75,7 +80,7 @@ class EightSegment {
# Set window parameters
wm iconphoto $win ::ICONS::16::8seg
- wm title $win "8 segment editor"
+ wm title $win [mc "8 segment editor"]
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "::itcl::delete object $this"
}
@@ -100,7 +105,7 @@ class EightSegment {
# Highlight ComboBoxes related to pins which are in confict
for {set segment 0} {$segment < 8} {incr segment} {
- set pin [subst "\$::EightSegment::con_${obj_idx}_$segment"]
+ set pin [subst -nocommands "\$::EightSegment::con_${obj_idx}_$segment"]
set seg2pin($segment) $pin
for {set i 0} {$i < 8} {incr i} {
@@ -133,9 +138,9 @@ class EightSegment {
ttk::style configure EightSegment_RedFg.TCombobox -foreground {#FF0000}
## Create entryboxes
- # - Common catode
+ # - Common cathode
set left_frame [frame $main_frame.left_frame]
- grid [label $left_frame.header_CC_lbl -text [mc "Common catode"]] \
+ grid [label $left_frame.header_CC_lbl -text [mc "Common cathode"]] \
-row 0 -column 0 -columnspan 4 -sticky w
grid [label $left_frame.sub_header_CC_hex_lbl -text [mc "Hex:"]] \
-row 1 -column 1 -sticky w
@@ -297,7 +302,7 @@ class EightSegment {
-text [mc "Close"] \
-command "::itcl::delete object $this" \
-image ::ICONS::16::exit \
- ] -side right -pady 5
+ ] -side right -pady 5 -padx 5
pack $status_bar -side left -fill x
# Pack window frames
@@ -315,11 +320,11 @@ class EightSegment {
}
## Copy contents of the specified exntrybox to clipboard
- # @parm Char common_electrode - C == Catode; A == Anode
+ # @parm Char common_electrode - C == Cathode; A == Anode
# @parm Char radix - H == Hexadecimal; D == Decimal; B == Binary
# @return void
public method copy_contents {common_electrode radix} {
- # Common catode
+ # Common cathode
if {$common_electrode == {C}} {
switch -- $radix {
{H} {set widget ${cc_hex_entry}}
@@ -327,7 +332,7 @@ class EightSegment {
{B} {set widget ${cc_bin_entry}}
}
# Common anode
- } {
+ } else {
switch -- $radix {
{H} {set widget ${ca_hex_entry}}
{D} {set widget ${ca_dec_entry}}
@@ -349,7 +354,7 @@ class EightSegment {
}
## Value entrybox validator
- # @parm Char common_electrode - C == Catode; A == Anode
+ # @parm Char common_electrode - C == Cathode; A == Anode
# @parm Char radix - H == Hexadecimal; D == Decimal; B == Binary
# @parm String value - String to validate
# @return Bool - always 1
@@ -387,10 +392,19 @@ class EightSegment {
}
# Convert value to decimal
- if {$radix == {H}} {
- set value [expr "0x$value"]
- } elseif {$radix == {B}} {
- set value [::NumSystem::bin2dec $value]
+ switch -- $radix {
+ {H} {
+ set value [expr "0x$value"]
+ }
+ {B} {
+ set value [::NumSystem::bin2dec $value]
+ }
+ {D} {
+ set value [string trimleft $value 0]
+ if {$value == {}} {
+ set value 0
+ }
+ }
}
# Adjust array $led() (LED states)
@@ -400,7 +414,7 @@ class EightSegment {
set leds($i) [expr {$value & $mask}]
set mask [expr {$mask * 2}]
}
- } {
+ } else {
set mask 1
for {set i 0} {$i < 8} {incr i} {
set leds($i) [expr {!($value & $mask)}]
@@ -422,7 +436,7 @@ class EightSegment {
for {set i 0} {$i < 8} {incr i} {
if {$leds($seg2pin($i))} {
$canvas_widget itemconfigure $canvas_objects($i) -fill #FF0000
- } {
+ } else {
$canvas_widget itemconfigure $canvas_objects($i) -fill #FFFFFF
}
}
@@ -507,3 +521,7 @@ class EightSegment {
}
}
set ::EightSegment::config $::CONFIG(EIGHT_SEG_EDITOR)
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/utilities/hexeditdlg.tcl b/lib/utilities/hexeditdlg.tcl
index 42175f1..c18df59 100755..100644
--- a/lib/utilities/hexeditdlg.tcl
+++ b/lib/utilities/hexeditdlg.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 _HEXEDITDLG_TCL ] } {
+set _HEXEDITDLG_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Prodides hexadecimal editor for external data and program memory.
@@ -34,16 +39,16 @@ class HexEditDlg {
common cell {0} ;# Current cell (0 - 0xFFFF)
common current_view {left} ;# Focused view {left right}
# Font for mode combobox
- common mode_cb_font [font create \
- -family {Helvetica} \
- -size -17 \
- -weight bold \
+ common mode_cb_font [font create \
+ -family {Helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
]
# General normal size bold font
- common bold_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -12 \
- -weight bold \
+ common bold_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight bold \
]
# Status bar tips for main menu for XDATA mode
common HELPFILE_XDATA {
@@ -62,8 +67,8 @@ class HexEditDlg {
{}
{}
{Invoke dialog for searching strings in the text}
- {Find next occurence of the search string}
- {Find previous occurence of the search string}
+ {Find next occurrence of the search string}
+ {Find previous occurrence of the search string}
} {
{Switch view mode to hexadecimal}
{Switch view mode to decimal}
@@ -86,8 +91,8 @@ class HexEditDlg {
{}
{}
{Invoke dialog for searching strings in the text}
- {Find next occurence of the search string}
- {Find previous occurence of the search string}
+ {Find next occurrence of the search string}
+ {Find previous occurrence of the search string}
} {
{Switch view mode to hexadecimal}
{Switch view mode to decimal}
@@ -138,7 +143,7 @@ class HexEditDlg {
set project $_project
set type $_type
set obj_idx $count
- set win [toplevel .hexeditdlg${obj_idx} -class {Hex Editor} -bg {#EEEEEE}]
+ set win [toplevel .hexeditdlg${obj_idx} -class {Hex Editor} -bg ${::COMMON_BG_COLOR}]
set loaded_lines [string repeat [string repeat 0 0xFF] 0xFF]
incr count ;# Increment instance counter
@@ -180,7 +185,7 @@ class HexEditDlg {
if {$type == {code}} {
if {[$project is_frozen]} {
set state normal
- } {
+ } else {
set state disabled
}
@@ -199,7 +204,7 @@ class HexEditDlg {
# Fill EntryBoxes
if {$cell >= $capacity} {
set current_cell [expr {$capacity - 1}]
- } {
+ } else {
set current_cell $cell
}
set value [$hexeditor get_values $current_cell $current_cell]
@@ -208,7 +213,7 @@ class HexEditDlg {
set validation_ena 1
# Pack dialog frames
- pack $tool_bar_frame -fill x -anchor w
+ pack $tool_bar_frame -fill x -anchor w -padx 3
pack $middle_frame -anchor nw -after $tool_bar_frame -pady 10
pack $bottom_frame -anchor w -after $middle_frame
pack $statusbar_frame -side bottom -fill x -after $bottom_frame
@@ -235,7 +240,7 @@ class HexEditDlg {
wm resizable $win 0 0
if {$mode == {hex}} {
wm geometry $win ${win_pos}
- } {
+ } else {
wm geometry $win ${win_pos}
}
@@ -243,7 +248,7 @@ class HexEditDlg {
wm iconphoto $win ::ICONS::16::$window_icon
if {$type == {uni}} {
wm protocol $win WM_DELETE_WINDOW "$this quit"
- } {
+ } else {
wm protocol $win WM_DELETE_WINDOW \
[list ::X::close_hexedit $type $project]
}
@@ -289,9 +294,9 @@ class HexEditDlg {
## Create menu widgets
# Main
set mainmenu [menu $win.mainmenu \
- -bd 0 -tearoff 0 -bg {#EEEEEE} \
+ -bd 0 -tearoff 0 -bg ${::COMMON_BG_COLOR} \
-activeforeground {#6666FF} \
- -activebackground {#EEEEEE} \
+ -activebackground ${::COMMON_BG_COLOR} \
]
set file_menu [menu $mainmenu.file_menu -tearoff 0] ;# Main -> File
set edit_menu [menu $mainmenu.edit_menu -tearoff 0] ;# Main -> Edit
@@ -307,71 +312,71 @@ class HexEditDlg {
# Create File menu
if {$type == {code}} {
- $file_menu add command -label "Open ADF" -compound left \
+ $file_menu add command -label [mc "Open ADF"] -compound left \
-command "$this opensim" -underline 0 \
-image ::ICONS::16::fileopen
}
- $file_menu add command -label "Open IHEX8" -compound left \
+ $file_menu add command -label [mc "Open IHEX8"] -compound left \
-accelerator "Ctrl+O" -command "$this openhex" \
-image ::ICONS::16::fileopen -underline 1
$file_menu add separator
- $file_menu add command -label "Save" -compound left \
+ $file_menu add command -label [mc "Save"] -compound left \
-accelerator "Ctrl+S" -command "$this save" \
-image ::ICONS::16::filesave -underline 0
- $file_menu add command -label "Save as" -compound left \
+ $file_menu add command -label [mc "Save as"] -compound left \
-accelerator "Ctrl+Shift+S" -command "$this saveas" \
-image ::ICONS::16::filesaveas -underline 1
$file_menu add separator
if {$type != {code}} {
- $file_menu add command -label "Reload" -compound left \
- -accelerator "F5" -command "$this reload" \
+ $file_menu add command -label [mc "Reload"] -compound left \
+ -accelerator "F5" -command "$this reload" \
-image ::ICONS::16::reload -underline 1
$file_menu add separator
}
- $file_menu add command -label "Exit" -compound left \
- -accelerator "Ctrl+Q" -command "$this quit" \
+ $file_menu add command -label [mc "Exit"] -compound left \
+ -accelerator "Ctrl+Q" -command "$this quit" \
-image ::ICONS::16::exit -underline 1
# Create Edit menu
- $edit_menu add command -label "Copy" -compound left \
+ $edit_menu add command -label [mc "Copy"] -compound left \
-accelerator "Ctrl+C" -command "$this text_copy" \
-image ::ICONS::16::editcopy -underline 0
- $edit_menu add command -label "Paste" -compound left \
+ $edit_menu add command -label [mc "Paste"] -compound left \
-accelerator "Ctrl+V" -command "$this text_paste" \
-image ::ICONS::16::editpaste -underline 0
$edit_menu add separator
- $edit_menu add command -label "Find" -compound left \
- -accelerator "Ctrl+F" -command "$this find_string 0" \
+ $edit_menu add command -label [mc "Find"] -compound left \
+ -accelerator "Ctrl+F" -command "$this find_string 0" \
-image ::ICONS::16::find -underline 0
- $edit_menu add command -label "Find next" -compound left \
- -accelerator "F3" -command "$this find_string 1" \
+ $edit_menu add command -label [mc "Find next"] -compound left \
+ -accelerator "F3" -command "$this find_string 1" \
-image ::ICONS::16::1downarrow -underline 5
- $edit_menu add command -label "Find previous" -compound left \
- -accelerator "Shift+F3" -command "$this find_string 2" \
+ $edit_menu add command -label [mc "Find previous"] -compound left \
+ -accelerator "Shift+F3" -command "$this find_string 2" \
-image ::ICONS::16::1uparrow -underline 8
# Create Mode menu
set ::HexEditDlg::mode_${obj_idx} $mode
- $mode_menu add radiobutton -label "HEX" \
+ $mode_menu add radiobutton -label [mc "HEX"] \
-variable ::HexEditDlg::mode_${obj_idx} \
-indicatoron 0 -compound left -image ::ICONS::raoff \
-selectimage ::ICONS::raon -value {hex} -underline 0 \
-command [list $this adjust_mode]
- $mode_menu add radiobutton -label "DEC" \
+ $mode_menu add radiobutton -label [mc "DEC"] \
-variable ::HexEditDlg::mode_${obj_idx} \
-indicatoron 0 -compound left -image ::ICONS::raoff \
-selectimage ::ICONS::raon -value {dec} -underline 0 \
-command [list $this adjust_mode]
- $mode_menu add radiobutton -label "OCT" \
+ $mode_menu add radiobutton -label [mc "OCT"] \
-variable ::HexEditDlg::mode_${obj_idx} \
-indicatoron 0 -compound left -image ::ICONS::raoff \
-selectimage ::ICONS::raon -value {oct} -underline 0 \
-command [list $this adjust_mode]
# Create Main menu
- $mainmenu add cascade -label "File" -underline 0 -menu $file_menu
- $mainmenu add cascade -label "Edit" -underline 0 -menu $edit_menu
- $mainmenu add cascade -label "Mode" -underline 0 -menu $mode_menu
+ $mainmenu add cascade -label [mc "File"] -underline 0 -menu $file_menu
+ $mainmenu add cascade -label [mc "Edit"] -underline 0 -menu $edit_menu
+ $mainmenu add cascade -label [mc "Mode"] -underline 0 -menu $mode_menu
$win configure -menu $mainmenu
}
@@ -462,8 +467,8 @@ class HexEditDlg {
bind $wdg <Leave> [list $this sbar_show {}]
}
- ## Create hexeditor and entryboxes for address and value
- # @parm Widget middle_frame - Frame for hexeditor
+ ## Create hex editor and entryboxes for address and value
+ # @parm Widget middle_frame - Frame for hex editor
# @parm Widget bottom_frame - Frame for entryboxes
# @return void
private method create_middle_bottom_frame {middle_frame bottom_frame} {
@@ -475,7 +480,7 @@ class HexEditDlg {
set hexeditor [HexEditor editor${obj_idx} $middle_frame 16 $hg 4 $mode 1 0 16 $capacity]
if {$current_view == {left}} {
$hexeditor focus_left_view
- } {
+ } else {
$hexeditor focus_right_view
}
$hexeditor setCurrentCell $cell
@@ -535,7 +540,7 @@ class HexEditDlg {
if {$type == {code}} {
if {[$project is_frozen]} {
set state normal
- } {
+ } else {
set state disabled
}
@@ -624,7 +629,7 @@ class HexEditDlg {
$project rightPanel_watch_sync $hex_addr
# Code memory
- } {
+ } else {
$project setCodeDEC $addr $val
}
}
@@ -639,7 +644,7 @@ class HexEditDlg {
set modified $bool
if {$modified} {
wm title $win "\[modified\] [wm title $win]"
- } {
+ } else {
wm title $win [string range [wm title $win] 11 end]
}
}
@@ -647,7 +652,7 @@ class HexEditDlg {
## Parse given data (IHEX-8 and load it into the editor + sync with external components)
# @parm String hex_data - input data
- # @return void
+ # @return Bool - 1 == success; 0 == failure
private method readHex {hex_data} {
# Any EOL -> LF
regsub -all {\r\n?} $hex_data "\n" hex_data
@@ -657,7 +662,7 @@ class HexEditDlg {
# Local variables
set pointer 0 ;# Current address
set line_number 0 ;# Number of the current line
- set errors_count 0 ;# Number of errors occured while parsing ihex file
+ set errors_count 0 ;# Number of errors occurred while parsing ihex file
set eof 0 ;# Bool: EOF detected
set error_string {} ;# Text of error message
@@ -736,7 +741,7 @@ class HexEditDlg {
set number [string range $data $i $j]
if {$type == {uni}} {
$hexeditor setValue $pointer [expr "0x$number"]
- } {
+ } else {
write_to_simulator $pointer [expr "0x$number"]
}
incr pointer
@@ -752,7 +757,7 @@ class HexEditDlg {
# Invoke error dialog
if {$errors_count} {
# Create dialog window
- set dialog [toplevel .error_message_dialog -bg {#EEEEEE}]
+ set dialog [toplevel $win.error_message_dialog -bg ${::COMMON_BG_COLOR}]
# Create main frame (text widget and scrolbar)
set main_frame [frame $dialog.main_frame]
@@ -785,13 +790,16 @@ class HexEditDlg {
# Set window attributes
wm iconphoto $dialog ::ICONS::16::no
- wm title $dialog [mc "Error(s) occured while parsing IHEX file"]
+ wm title $dialog [mc "Error(s) occurred while parsing IHEX file"]
wm minsize $dialog 500 250
wm protocol $dialog WM_DELETE_WINDOW "grab release $dialog; destroy $dialog"
wm transient $dialog $win
grab $dialog
raise $dialog
tkwait window $dialog
+ return 0
+ } else {
+ return 1
}
}
@@ -806,7 +814,7 @@ class HexEditDlg {
set hexlen 2
set octlen 3
set binlen 8
- } {
+ } else {
set hexlen 4
set octlen 7
set binlen 16
@@ -818,7 +826,7 @@ class HexEditDlg {
set oct {}
set bin {}
# Non empty value -> convert
- } {
+ } else {
# To hexadecimal
set hex [format %X $value]
set len [string length $hex]
@@ -903,7 +911,7 @@ class HexEditDlg {
sbar_show {}
}
- ## This method should be called after value change in hexeditor
+ ## This method should be called after value change in hex editor
# This method writes new value to simulator engine, watchers and EntryBoxes
# @parm Int addr - Address of changed cell
# @parm int val - New value of the entry
@@ -917,7 +925,7 @@ class HexEditDlg {
set validation_ena 1
}
- ## This method should be called after current cell change in hexeditor
+ ## This method should be called after current cell change in hex editor
# Synchronizes EntryBoxes
# @parm Int addr - New cell address
# @return void
@@ -945,7 +953,7 @@ class HexEditDlg {
# Check for valid characters
if {$valtype == {val}} {
set m 1
- } {
+ } else {
set m 2
}
set len [string length $value]
@@ -998,7 +1006,7 @@ class HexEditDlg {
set validation_ena 1
return 0
}
- } {
+ } else {
if {$value >= $capacity} {
set validation_ena 1
return 0
@@ -1010,7 +1018,7 @@ class HexEditDlg {
if {$valtype == {val}} {
$hexeditor setValue $current_cell $value
write_to_simulator $current_cell $value
- } {
+ } else {
set current_cell $value
$hexeditor setCurrentCell $value
}
@@ -1026,11 +1034,11 @@ class HexEditDlg {
# @return void
public method prog_jump {} {
if {$type != {code}} {return}
- $project setPC [subst "\$::HexEditDlg::dec_addr_${obj_idx}"]
+ $project setPC [subst -nocommands "\$::HexEditDlg::dec_addr_${obj_idx}"]
set lineNum [$project simulator_getCurrentLine]
if {$lineNum != {}} {
$project move_simulator_line $lineNum
- } {
+ } else {
$project editor_procedure {} unset_simulator_line {}
}
$project Simulator_sync_PC_etc
@@ -1040,11 +1048,11 @@ class HexEditDlg {
# @return void
public method sub_call {} {
if {$type != {code}} {return}
- $project simulator_subprog_call [subst "\$::HexEditDlg::dec_addr_${obj_idx}"]
+ $project simulator_subprog_call [subst -nocommands "\$::HexEditDlg::dec_addr_${obj_idx}"]
set lineNum [$project simulator_getCurrentLine]
if {$lineNum != {}} {
$project move_simulator_line $lineNum
- } {
+ } else {
$project editor_procedure {} unset_simulator_line {}
}
$project Simulator_sync_PC_etc
@@ -1053,10 +1061,10 @@ class HexEditDlg {
## Adjust view mode to state of mode menu
# @return void
public method adjust_mode {} {
- $mode_combo_box current [lsearch {hex dec oct} [subst "\$::HexEditDlg::mode_${obj_idx}"]]
+ $mode_combo_box current [lsearch {hex dec oct} [subst -nocommands "\$::HexEditDlg::mode_${obj_idx}"]]
sbar_show {Working ...}
update
- $hexeditor switch_mode [subst "\$::HexEditDlg::mode_${obj_idx}"]
+ $hexeditor switch_mode [subst -nocommands "\$::HexEditDlg::mode_${obj_idx}"]
sbar_show {Working}
}
@@ -1078,7 +1086,7 @@ class HexEditDlg {
}
if {$type == {uni}} {
delete object $this
- } {
+ } else {
::X::close_hexedit $type $project
}
}
@@ -1102,7 +1110,7 @@ class HexEditDlg {
if {$type == {code}} {
$left_sbar_label configure -text \
[mc [lindex $HELPFILE_CODE [list $help_file_index $entry_index]]]
- } {
+ } else {
$left_sbar_label configure -text \
[mc [lindex $HELPFILE_XDATA [list $help_file_index $entry_index]]]
}
@@ -1189,6 +1197,19 @@ class HexEditDlg {
# Reload content of HexEditor
# @return void
public method reload {} {
+
+ if {$modified} {
+ set response [tk_messageBox \
+ -parent $win \
+ -type yesno \
+ -icon warning \
+ -title [mc "File modified"] \
+ -message [mc "Content of the hex editor has been changed.\nDo you really want to reload without saving it?"]]
+ if {$response == {no}} {
+ return
+ }
+ }
+
# Store original cursor position
set current_cursor_pos [$hexeditor getCurrentCell]
@@ -1198,7 +1219,7 @@ class HexEditDlg {
if {$ext != {} && $opened_file != {}} {
open_file $opened_file $ext
}
- } {
+ } else {
refresh
}
@@ -1209,21 +1230,21 @@ class HexEditDlg {
}
## Action for Menu/Toolbar - Save as
- # Save current content of hexeditor as IHEX8 file and ask for file name
+ # Save current content of hex editor as IHEX8 file and ask for file name
# @return void
public method saveas {} {
set directory [file dirname $opened_file]
if {$type == {uni}} {
if {${::X::project_menu_locked}} {
set project {}
- } {
+ } else {
set project ${::X::actualProject}
}
}
if {$directory == {.}} {
if {$project == {}} {
set directory ${::X::defaultDirectory}
- } {
+ } else {
set directory [$project cget -projectPath]
}
}
@@ -1232,11 +1253,11 @@ class HexEditDlg {
-title [mc "Save file - MCU 8051 IDE"] \
-master $win \
-directory $directory \
- -initialfile [$middle_sbar_label cget -text] \
- -defaultmask 0 -multiple 0 -filetypes {
- {{IHEX8} {*.{hex,ihx}} }
- {{All files} {*} }
- }
+ -initialfile [$middle_sbar_label cget -text] \
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Intel 8 HEX"] {*.{hex,ihx}} ] \
+ [list [mc "All files"] {*} ] \
+ ]
fsd setokcmd "$this save_file_proc \[::HexEditDlg::fsd get\]"
fsd activate
}
@@ -1259,14 +1280,14 @@ class HexEditDlg {
if {$type == {uni}} {
if {${::X::project_menu_locked}} {
set project {}
- } {
+ } else {
set project ${::X::actualProject}
}
}
if {$directory == {.}} {
if {$project == {}} {
set directory ${::X::defaultDirectory}
- } {
+ } else {
set directory [$project cget -projectPath]
}
}
@@ -1274,10 +1295,10 @@ class HexEditDlg {
KIFSD::FSD fsd \
-title [mc "Open file - MCU 8051 IDE"] \
-master $win -directory $directory \
- -defaultmask 0 -multiple 0 -filetypes {
- {{IHEX8} {*.{hex,ihx}} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Intel 8 HEX"] {*.{hex,ihx}} ] \
+ [list [mc "All files"] {*} ] \
+ ]
fsd setokcmd "$this open_file \[::HexEditDlg::fsd get\] hex"
fsd activate
}
@@ -1294,10 +1315,10 @@ class HexEditDlg {
KIFSD::FSD fsd \
-title [mc "Open file - MCU 8051 IDE"] \
-master $win -directory $directory \
- -defaultmask 0 -multiple 0 -filetypes {
- {{Simulator file} {*.adb} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Simulator file"] {*.adb} ] \
+ [list [mc "All files"] {*} ] \
+ ]
fsd setokcmd "$this open_file \[::HexEditDlg::fsd get\] adf"
fsd activate
}
@@ -1305,7 +1326,7 @@ class HexEditDlg {
## Open the give file and load its contents into editor
# @parm String filename - Relative or absolute filename
# @parm String extension - Fily type {adf hex}
- # @return void
+ # @return Bool - 1 == success; 0 == failure
public method open_file {filename extension} {
# Store original cursor position
set current_cursor_pos [$hexeditor getCurrentCell]
@@ -1316,14 +1337,14 @@ class HexEditDlg {
if {$type == {uni}} {
if {${::X::project_menu_locked}} {
set project {}
- } {
+ } else {
set project ${::X::actualProject}
}
}
if {$directory == {.}} {
if {$project == {}} {
set directory ${::X::defaultDirectory}
- } {
+ } else {
set directory [$project cget -projectPath]
}
}
@@ -1331,8 +1352,8 @@ class HexEditDlg {
if {![regexp "^(~|/)" $filename]} {
set filename "$directory/$filename"
}
- } { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
+ } else { ;# Microsoft windows way
+ if {![regexp {^\w:} $filename]} {
set filename [file join $directory $filename]
}
}
@@ -1347,20 +1368,20 @@ class HexEditDlg {
-icon warning \
-title [mc "Permission denied"] \
-message [mc "Unable to open file:\n%s" $filename]
- return
+ return 0
}
# Clear editor
if {$type == {uni}} {
$hexeditor fill_views
- } {
+ } else {
$project simulator_clear_memory $type
}
# Load contents
if {$extension == {adf}} {
$project load_program_from_adf $filename
- } {
+ } else {
readHex [read $file]
}
@@ -1373,6 +1394,8 @@ class HexEditDlg {
update
$hexeditor setCurrentCell $current_cursor_pos
$hexeditor seeCell $current_cursor_pos
+
+ return 1
}
## Save content of the editor into the given file in format IHEX8
@@ -1386,14 +1409,14 @@ class HexEditDlg {
if {$type == {uni}} {
if {${::X::project_menu_locked}} {
set project {}
- } {
+ } else {
set project ${::X::actualProject}
}
}
if {$directory == {.}} {
if {$project == {}} {
set directory ${::X::defaultDirectory}
- } {
+ } else {
set directory [$project cget -projectPath]
}
}
@@ -1402,7 +1425,7 @@ class HexEditDlg {
set filename "$directory/$filename"
}
} { ;# Microsoft windows way
- if {![regexp "^\w:" $filename]} {
+ if {![regexp {^\w:} $filename]} {
set filename [file join $directory $filename]
}
}
@@ -1411,7 +1434,7 @@ class HexEditDlg {
if {![regexp {\.(hex|ihx)$} $filename]} {
if {$type != {code} && $type != {uni} } {
append filename {.xdata.hex}
- } {
+ } else {
append filename {.hex}
}
}
@@ -1431,7 +1454,7 @@ class HexEditDlg {
-title [mc "Overwrite file"] \
-message [mc "A file name '%s' already exists. Are you sure you want to overwrite it ?" [file tail $filename]]
] != {yes}
- } {
+ } then {
return
}
# Create a backup file
@@ -1458,8 +1481,8 @@ class HexEditDlg {
# Open file
if {[catch {
- set file [open $filename w 420]
- }]} {
+ set file [open $filename w 0640]
+ }]} then {
tk_messageBox \
-parent $win \
-type ok \
@@ -1560,11 +1583,14 @@ class HexEditDlg {
}
# Save EOF
- puts -nonewline $file {:00000001FF}
+ puts $file {:00000001FF}
# Done ...
close $file
setModified 0
+ if {$::MICROSOFT_WINDOWS} { ;# "/" --> "\"
+ regsub -all {/} $filename "\\" filename
+ }
sbar_show [mc "File %s saved" $filename]
}
@@ -1595,7 +1621,7 @@ class HexEditDlg {
# GENERAL PUBLIC INTERFACE
# -------------------------------------------------------------------
- ## Inform hexeditor about simulator start or shutdown
+ ## Inform hex editor about simulator start or shutdown
# @parm Bool started - 1 == Simulator started; 0 == Simulator stopped
# @return void
public method simulator_stared_stopped {started} {
@@ -1605,7 +1631,7 @@ class HexEditDlg {
if {$started} {
set state {normal}
- } {
+ } else {
set state {disabled}
}
$sub_call_but configure -state $state
@@ -1614,7 +1640,8 @@ class HexEditDlg {
[$hexeditor get_popup_menu] entryconfigure [::mc "LCALL this_address"] -state $state
}
- ## Move program pointer (highlight cells) -- Avaliable only for code memory hexeditor
+ ## Move program pointer (highlight cells)
+ # -- available only for code memory hex editor
# @parm Int new_PC - New program counter
# @parm Int int_length - Instruction length
# @return void
@@ -1647,12 +1674,14 @@ class HexEditDlg {
for {set i 0} {$i < $int_length} {incr i} {
$hexeditor set_bg_hg $new_PC 1 2
+ $hexeditor set_bg_hg $new_PC 0 1
incr new_PC
}
$hexeditor seeCell $new_PC
}
- ## Directly move program pointer (do not affect previous PC pointer) -- Avaliable only for code memory hexeditor
+ ## Directly move program pointer (do not affect previous PC pointer)
+ # -- available only for code memory hex editor
# @parm Int new_PC - New program counter (-1 == unresolved)
# @parm Int int_length - Instruction length
# @return void
@@ -1697,7 +1726,7 @@ class HexEditDlg {
}
## Write value to the editor
- # - avaliable only in modes: XDATA and ERAM
+ # - available only in modes: XDATA and ERAM
# @parm String address - hexadecimal address
# @return void
public method reg_sync {address} {
@@ -1733,7 +1762,7 @@ class HexEditDlg {
set loaded_lines [string repeat [string repeat 0 0xFF] 0xFF]
load_data_to_current_view
- setModified 1
+ setModified 0
}
## Get configuration list
@@ -1752,7 +1781,7 @@ class HexEditDlg {
set cell [lindex $config 2]
set current_view [lindex $config 3]
- # load configuration for hexeditor widget
+ # load configuration for hex editor widget
::HexEditor::load_config_list [lindex $config 4]
# Validate loaded values
@@ -1785,9 +1814,13 @@ class HexEditDlg {
if {$type == {uni}} {
if {$modified} {
wm title $win "\[modified\] $filename - [mc {Hexadecimal editor}] - MCU 8051 IDE"
- } {
+ } else {
wm title $win "$filename - [mc {Hexadecimal editor}] - MCU 8051 IDE"
}
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/utilities/notes.tcl b/lib/utilities/notes.tcl
index f39312f..d74b652 100755..100644
--- a/lib/utilities/notes.tcl
+++ b/lib/utilities/notes.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 _NOTES_TCL ] } {
+set _NOTES_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION:
# Scribble notes independent on project
@@ -32,10 +37,10 @@ class Notes {
common bgcolor {#EEEE55} ;# Color: Background color for title bar and window border
common bgcolor2 {#FFFF88} ;# Color: Background color for the canvas widget
# Font: For inserted text
- common canvas_text_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- -weight bold \
+ common canvas_text_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
]
# List: Popup menu for the canvas widget
common MENU {
@@ -118,7 +123,7 @@ class Notes {
set filename $_file_name
if {$_geometry == {}} {
set geometry {50 50 300 300}
- } {
+ } else {
set geometry $_geometry
}
@@ -133,7 +138,7 @@ class Notes {
-relief flat
ttk::style map Notes_Flat.TButton \
-relief [list active raised] \
- -background [list disabled {#EEEEEE}]
+ -background [list disabled ${::COMMON_BG_COLOR}]
create_win
}
@@ -270,7 +275,7 @@ class Notes {
if {[prompt_for_text]} {
$canvas_widget configure -cursor cross
set w $mode_text_but
- } {
+ } else {
if {$drawing_mode_org == {T}} {
set drawing_mode_org {M}
}
@@ -321,7 +326,7 @@ class Notes {
pack forget $main_frame
place $win -height [expr {[winfo height $win.title_bar] + 4}]
# Unshade
- } {
+ } else {
set image _1uparrow
pack $main_frame -fill both -expand 1 -padx 2 -pady 2
place $win -height [expr {[lindex $geometry 3] + 2}]
@@ -336,7 +341,7 @@ class Notes {
set popup_menu_created 1
set menu $canvas_widget.menu
- menuFactory $MENU $menu 0 "$this " 0 {}
+ menuFactory $MENU $menu 0 "$this " 0 {} [namespace current]
}
## Popup menu
@@ -484,7 +489,7 @@ class Notes {
-image ::ICONS::16::grid1 \
]
DynamicHelp::add $bottom_frame.mode_rectangle_but -text [mc "Retangle"]
- setStatusTip -widget $mode_rectangle_but -text [mc "Draw retangles"]
+ setStatusTip -widget $mode_rectangle_but -text [mc "Draw rectangles"]
pack $mode_rectangle_but -side left -ipady 0
# - Button "Oval"
set mode_oval_but [ttk::button $bottom_frame.mode_oval_but \
@@ -523,7 +528,7 @@ class Notes {
-command "$this select_color" \
-bd 1 -relief raised -overrelief raised \
-activebackground $selected_color \
- -bg $selected_color -pady 0 \
+ -bg $selected_color -pady 0 -width 2 \
]
DynamicHelp::add $bottom_frame.select_color_but -text [mc "Select color"]
setStatusTip -widget $select_color_but -text [mc "Select color"]
@@ -597,7 +602,7 @@ class Notes {
# @return void
private method prompt_for_text {} {
set ::Notes::text_prompt_text {}
- set dialog [toplevel .notes_pd -bg {#EEEEEE}]
+ set dialog [toplevel .notes_pd -bg ${::COMMON_BG_COLOR}]
## Create top frame
set frame [frame $dialog.frm]
@@ -865,10 +870,10 @@ class Notes {
KIFSD::FSD ::fsd \
-directory $directory \
-title [mc "Insert image from file"] \
- -defaultmask 0 -multiple 0 -filetypes {
- {{PNG files} {*.png}}
- {{All files} {*}}
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Portable network graphics"] {*.png} ] \
+ [list [mc "All files"] {*} ] \
+ ]
::fsd setokcmd "$this load_image_file \[::fsd get\]"
::fsd activate
@@ -881,10 +886,12 @@ class Notes {
set loaded_image {}
if {[catch {
set loaded_image [image create photo -file $file]
- }]} {
- tk_messageBox \
+ }]} then {
+ tk_messageBox \
+ -parent . \
+ -type ok \
+ -icon warning \
-title [mc "Unable to read file"] \
- -type ok -icon warning \
-message [mc "Unable to read file:\n%s" $file]
return
}
@@ -894,3 +901,7 @@ class Notes {
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/utilities/rs232debugger.tcl b/lib/utilities/rs232debugger.tcl
index dacb8d5..af2354b 100755..100644
--- a/lib/utilities/rs232debugger.tcl
+++ b/lib/utilities/rs232debugger.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 _RS232DEBUGGER_TCL ] } {
+set _RS232DEBUGGER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -31,29 +36,34 @@ class RS232Debugger {
## COMMON
common count 0 ;# Int: Counter of class instances
# Font: Big bold font
- 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} \
]
# Font: Tiny normal font
- common tiny_font [font create \
- -family {helvetica} \
- -size -9 -weight {normal} \
+ common tiny_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-9 * $::font_size_factor)}] \
+ -weight {normal} \
]
# Font: Tiny bold font
- common tiny_font_bold [font create \
- -family {helvetica} \
- -size -9 -weight {bold} \
+ common tiny_font_bold [font create \
+ -family {helvetica} \
+ -size [expr {int(-9 * $::font_size_factor)}] \
+ -weight {bold} \
]
# Font: Normal font
- common normal_font [font create \
- -family {helvetica} \
- -size -11 -weight {normal} \
+ common normal_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-11 * $::font_size_factor)}] \
+ -weight {normal} \
]
# Font: Also normal font, but a bit larger
- common big_font [font create \
- -family {helvetica} \
- -size -12 -weight {normal} \
+ common big_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight {normal} \
]
# Int: Pool interval for selected RS232 interface
common POOL_INTERVAL 50 ;# mili-seconds
@@ -92,13 +102,13 @@ class RS232Debugger {
private variable clear_selected_rec_button ;# Widget: Button "Clear selected" in section "Receive"
private variable receive_here_button ;# Widget: Button "Receive here"
private variable clear_selected_snd_button ;# Widget: Button "Clear selected" in section "Send"
- private variable receive_hexeditor ;# Object: Hexeditor intented for reception
- private variable send_hexeditor ;# Object: Hexeditor intented for sending
+ private variable receive_hexeditor ;# Object: Hex editor intented for reception
+ private variable send_hexeditor ;# Object: Hex editor intented for sending
private variable pool_timer {} ;# Object: Pool timer object
private variable channel {} ;# Channel: Opened device file
private variable port_filename {} ;# String: Device file name
- private variable reception_address 0 ;# Int: Address in reception hexeditor where received data are stored
+ private variable reception_address 0 ;# Int: Address in reception hex editor where received data are stored
private variable reception_enabled 1 ;# Bool: Reception enabled
private variable prev_tty_status ;# List: Previous TTY status (before any action performed by this code)
@@ -130,7 +140,7 @@ class RS232Debugger {
-foreground {#000000} \
-background {#DDDDDD}
ttk::style map RS232Debugger_SignalAllDefault.TButton \
- -background [list active {#EEEEEE}]
+ -background [list active ${::COMMON_BG_COLOR}]
ttk::style configure RS232Debugger_SignalTxDTrue.TButton \
-background {#AAFFAA} \
@@ -150,7 +160,7 @@ class RS232Debugger {
-background {#DDDDDD} \
-foreground {#000000}
ttk::style map RS232Debugger_SignalTxDFalse.TButton \
- -background [list active {#EEEEEE}] \
+ -background [list active ${::COMMON_BG_COLOR}] \
-foreground [list active {#000000}]
ttk::style configure RS232Debugger_SignalNormalFalse.TButton \
@@ -216,7 +226,7 @@ class RS232Debugger {
create_gui
set_tty_controls_state 0
- # Restore data displayed in hexeditors
+ # Restore data displayed in hex editors
foreach idx {5 6} hexedit [list $receive_hexeditor $send_hexeditor] {
set data [lindex $config_list $idx]
if {![llength $data]} {
@@ -228,7 +238,7 @@ class RS232Debugger {
}
}
- # restore addresses of current cells in hexeditors
+ # restore addresses of current cells in hex editors
$receive_hexeditor setCurrentCell [lindex $config_list 7]
$send_hexeditor setCurrentCell [lindex $config_list 8]
}
@@ -249,7 +259,7 @@ class RS232Debugger {
# Cancel pool timer
catch {after cancel $pool_timer}
- # Close opended channel
+ # Close opened channel
if {$channel !={}} {
catch {fileevent $channel readable {}}
catch {close $channel}
@@ -263,7 +273,7 @@ class RS232Debugger {
# @return void
private method create_gui {} {
# Create window
- set win [toplevel .rs232debugger$count -class [mc "RS232 Debugger"] -bg {#EEEEEE}]
+ set win [toplevel .rs232debugger$count -class [mc "RS232 Debugger"] -bg ${::COMMON_BG_COLOR}]
# Create status bar
set status_bar_label [label $win.status_bar_label -justify left -pady 0 -anchor w]
@@ -381,13 +391,13 @@ class RS232Debugger {
$connector_canvas bind gnd_wire <Leave> "$this wire_leave gnd"
## Write texts
- $connector_canvas create text \
- [expr {$x + 10}] [expr {$y - 25}] \
- -anchor n -justify left \
+ $connector_canvas create text \
+ [expr {$x + 10}] [expr {$y - 30}] \
+ -anchor n -justify left \
-font $big_font -text [mc "RS-232\nDTE"]
- $connector_canvas create text \
+ $connector_canvas create text \
[expr {$x + 10}] [expr {$y + 100}] \
- -anchor n -justify left \
+ -anchor n -justify left \
-font $big_font -text [mc "DE-9"]
}
@@ -510,7 +520,7 @@ class RS232Debugger {
bind $dtr_button <Enter> "$this wire_enter dtr"
bind $dtr_button <Leave> "$this wire_leave dtr"
$connector_canvas create window \
- [expr {$x + 100}] [expr {$y + 95}] \
+ [expr {$x + 100}] [expr {$y + 90}] \
-anchor center -window $dtr_button
$connector_canvas create line \
@@ -539,7 +549,7 @@ class RS232Debugger {
bind $rts_button <Enter> "$this wire_enter rts"
bind $rts_button <Leave> "$this wire_leave rts"
$connector_canvas create window \
- [expr {$x + 135}] [expr {$y + 95}] \
+ [expr {$x + 135}] [expr {$y + 90}] \
-anchor center -window $rts_button
$connector_canvas create line \
@@ -568,7 +578,7 @@ class RS232Debugger {
bind $break_button <Enter> "$this wire_enter txd"
bind $break_button <Leave> "$this wire_leave txd"
$connector_canvas create window \
- [expr {$x + 180}] [expr {$y + 95}] \
+ [expr {$x + 180}] [expr {$y + 90}] \
-anchor center -window $break_button
$connector_canvas create line \
@@ -617,10 +627,10 @@ class RS232Debugger {
# Create canvas widget
set connector_canvas [canvas $target_frame.canvas \
- -width 280 -height 150 -bg {#EEEEEE} \
+ -width 280 -height 150 -bg ${::COMMON_BG_COLOR} \
-bd 0 -relief flat -highlightthickness 0 \
]
- pack $connector_canvas -side left -anchor sw
+ pack $connector_canvas -side left -padx 5 ;#-anchor sw
# Fill in the connector canvas
draw_connector 20 30
@@ -642,7 +652,7 @@ class RS232Debugger {
-image ::ICONS::16::configure \
] \
]
- pack $conf_frame -side left -anchor nw
+ pack $conf_frame -side right -anchor nw -padx 5
# - Physical port
grid [label $conf_frame.port_lbl \
-text [mc "Physical port"] \
@@ -687,13 +697,16 @@ class RS232Debugger {
-text [mc "Parity"] \
] -row 4 -column 1 -sticky w
set parity_cb [ttk::combobox $conf_frame.parity_cb \
- -values {none odd even mark space} \
-state readonly \
-width 6 \
-exportselection 0 \
+ -values [list [mc "none"] \
+ [mc "odd"] [mc "even"] \
+ [mc "mark"] [mc "space"] \
+ ]
]
bind $parity_cb <<ComboboxSelected>> \
- "$this change_port_config p \[$conf_frame.parity_cb get\]"
+ "$this change_port_config p \[$conf_frame.parity_cb current\]"
set_status_tip $parity_cb [mc "Parity"]
grid $parity_cb -row 4 -column 2 -sticky w
$conf_frame.parity_cb current [lsearch {n o e m s} $parity_conf]
@@ -852,7 +865,7 @@ class RS232Debugger {
if {[file exists $content]} {
if {$port_filename == $content} {
$port_combobox configure -style RS232Debugger_FileInUse.TCombobox
- } {
+ } else {
$port_combobox configure -style RS232Debugger_FileFound.TCombobox
}
# Not exiting file
@@ -924,7 +937,7 @@ class RS232Debugger {
-message \"[mc {Unable to open the specified file}]\n\n\${reason}\""
# -> Success
} else {
- # Try to configure opened channel acording to specified parameters
+ # Try to configure opened channel according to specified parameters
if {[catch {
fconfigure $channel \
-handshake none \
@@ -964,24 +977,7 @@ class RS232Debugger {
set baud_conf $value
}
{p} { ;# Parity bit
- switch -- $value {
- {none} {
- set value {n}
- }
- {odd} {
- set value {o}
- }
- {even} {
- set value {e}
- }
- {mark} {
- set value {m}
- }
- {space} {
- set value {s}
- }
- }
- set parity_conf $value
+ set parity_conf [lindex {n o e m s} $value]
}
{d} { ;# Data bits
set data_conf $value
@@ -1004,31 +1000,31 @@ class RS232Debugger {
-parent $win \
-type ok \
-icon error \
- -title [mc "Uknown failure"] \
+ -title [mc "Unknown failure"] \
-message [mc "Unable to change port configuration"]
}
}
- ## Handle selection event in hexeditor
+ ## Handle selection event in hex editor
# @parm Char editor - Editor ID
# @parm Bool anything_selected - 1 == anything selected; 0 == Nothing selected
# @return void
public method hexeditor_selection {editor anything_selected} {
if {$anything_selected} {
set state {normal}
- } {
+ } else {
set state {disabled}
}
if {$editor == {s}} {
$send_selected_button configure -state $state
$clear_selected_snd_button configure -state $state
- } {
+ } else {
$clear_selected_rec_button configure -state $state
}
}
- ## Clear selected data in send hexeditor
+ ## Clear selected data in send hex editor
# @return void
public method clear_selected_snd {} {
# Get range of text indexes determinating the selection
@@ -1142,7 +1138,7 @@ class RS232Debugger {
if {[winfo exists .data_lost_dialog]} {
return
}
- set dialog [toplevel .data_lost_dialog -class [mc "Error message"] -bg {#EEEEEE}]
+ set dialog [toplevel .data_lost_dialog -class [mc "Error message"] -bg ${::COMMON_BG_COLOR}]
pack [label $dialog.label \
-font $bold_font -compound left -padx 5 \
@@ -1181,7 +1177,7 @@ class RS232Debugger {
tkwait window $dialog
}
- ## Clear selected data in receive hexeditor
+ ## Clear selected data in receive hex editor
# @return void
public method clear_selected_rec {} {
set rangeofselection [$receive_hexeditor getRangeOfSelection]
@@ -1200,7 +1196,7 @@ class RS232Debugger {
## Enable/Disable reception
# @return void
public method reception_ena_dis {} {
- set reception_enabled [subst "\$::RS232Debugger::enable_reception${obj_idx}"]
+ set reception_enabled [subst -nocommands "\$::RS232Debugger::enable_reception${obj_idx}"]
}
## Read TTY status from the interface and update GUI accordingly
@@ -1212,15 +1208,15 @@ class RS232Debugger {
# Read TTY status
if {[catch {
set ttystatus [fconfigure $channel -ttystatus]
- }]} {
+ }]} then {
unknown_port_io_error
return
}
- # Check whether any change occured
+ # Check whether any change occurred
if {$prev_tty_status(0) == $ttystatus} {
return
- } {
+ } else {
set prev_tty_status(0) $ttystatus
}
@@ -1256,7 +1252,7 @@ class RS232Debugger {
foreach signal {cts dsr ri dcd} value $args {
if {$prev_tty_status($signal) == $value} {
continue
- } {
+ } else {
set prev_tty_status($signal) $value
}
@@ -1280,7 +1276,7 @@ class RS232Debugger {
}
}
- ## Report an unknown IO error occured on the interface
+ ## Report an unknown IO error occurred on the interface
# Plus disable reception and safely terminate connection
# @return void
private method unknown_port_io_error {} {
@@ -1326,7 +1322,7 @@ class RS232Debugger {
set state {normal}
set state2 {readonly}
set_tty_controls_to_defaults
- } {
+ } else {
set state {disabled}
set state2 {disabled}
set_tty_controls_to_unknown_state
@@ -1382,33 +1378,33 @@ class RS232Debugger {
switch -- $value {
0 { ;# Loical 0
if {$wire == {break}} {
- [subst "\${${wire}_button}"] configure -text {Break} \
+ [subst -nocommands "\${${wire}_button}"] configure -text {Break} \
-style RS232Debugger_SignalTxDFalse.TButton
$connector_canvas itemconfigure txd_wire -fill {#0000FF}
- } {
- [subst "\${${wire}_button}"] configure -text {1} \
+ } else {
+ [subst -nocommands "\${${wire}_button}"] configure -text {1} \
-style RS232Debugger_SignalNormalFalse.TButton
$connector_canvas itemconfigure ${wire}_wire -fill {#FF0000}
}
}
1 { ;# Logical 1
if {$wire == {break}} {
- [subst "\${${wire}_button}"] configure -text {BREAK} \
+ [subst -nocommands "\${${wire}_button}"] configure -text {BREAK} \
-style RS232Debugger_SignalTxDTrue.TButton
$connector_canvas itemconfigure txd_wire -fill {#00FF00}
- } {
- [subst "\${${wire}_button}"] configure -text {0} \
+ } else {
+ [subst -nocommands "\${${wire}_button}"] configure -text {0} \
-style RS232Debugger_SignalNormalTrue.TButton
$connector_canvas itemconfigure ${wire}_wire -fill {#00FF00}
}
}
default { ;# Unknown state
if {$wire == {break}} {
- [subst "\${${wire}_button}"] configure -text {Break} \
+ [subst -nocommands "\${${wire}_button}"] configure -text {Break} \
-style RS232Debugger_SignalAllDefault.TButton
$connector_canvas itemconfigure txd_wire -fill {#0000FF}
- } {
- [subst "\${${wire}_button}"] configure -text {-} \
+ } else {
+ [subst -nocommands "\${${wire}_button}"] configure -text {-} \
-style RS232Debugger_SignalAllDefault.TButton
$connector_canvas itemconfigure ${wire}_wire -fill {#888888}
}
@@ -1418,7 +1414,7 @@ class RS232Debugger {
if {[catch {
fconfigure $channel -ttycontrol [list $wire $value]
- }]} {
+ }]} then {
unknown_port_io_error
return
}
@@ -1452,9 +1448,13 @@ class RS232Debugger {
# @return void
public method wire_leave {wire} {
$connector_canvas itemconfigure ${wire}_wire -width 1
- $connector_canvas itemconfigure ${wire}_pin -fill {#EEEEEE}
+ $connector_canvas itemconfigure ${wire}_pin -fill ${::COMMON_BG_COLOR}
$connector_canvas itemconfigure ${wire}_num -font $tiny_font
$status_bar_label configure -text {}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/utilities/speccalc.tcl b/lib/utilities/speccalc.tcl
index 67a9430..49db83b 100755..100644
--- a/lib/utilities/speccalc.tcl
+++ b/lib/utilities/speccalc.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 _SPECCALC_TCL ] } {
+set _SPECCALC_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -34,7 +39,7 @@
class SpecCalc {
## COMMON
common count 0 ;# Int: Counter of class instances
- common diagram_counter 0 ;# Int: Counter of diagram dialogs instances
+ common diagram_counter 0 ;# Int: Counter of diagram dialogues instances
# List of pages descriptors for PagesManager
common page_list {
loops timer01 timer2 spi
@@ -67,10 +72,10 @@ class SpecCalc {
ttk::style configure SpecCalc_RedBg.TCombobox -fieldbackground {#FFCCCC}
ttk::style configure SpecCalc_Flat.TButton -background {#FFFFFF} -padding 0 -borderwidth 1 -relief flat
- ttk::style map SpecCalc_Flat.TButton -relief [list active raised] -background [list disabled {#EEEEEE} active {#EEEEFF}]
+ ttk::style map SpecCalc_Flat.TButton -relief [list active raised] -background [list disabled ${::COMMON_BG_COLOR} active {#EEEEFF}]
ttk::style configure SpecCalc_Spec.TButton -background {#CCCCFF} -padding 0
- ttk::style map SpecCalc_Spec.TButton -background [list disabled {#EEEEEE} active {#DDDDFF}]
+ ttk::style map SpecCalc_Spec.TButton -background [list disabled ${::COMMON_BG_COLOR} active {#DDDDFF}]
create_gui
}
@@ -86,7 +91,7 @@ class SpecCalc {
[list [$widgets(loops,time_ent) get] \
[$widgets(loops,time_cb) current] \
[$widgets(loops,clock_cb) get] \
- [$widgets(loops,clock_type_cb) current] \
+ [$widgets(loops,clock_type_cb) current] \
[$widgets(loops,reg_ent0) get] \
[$widgets(loops,reg_ent1) get] \
[$widgets(loops,reg_ent2) get] \
@@ -102,7 +107,7 @@ class SpecCalc {
[$widgets(timer01,clock_type_cb) current] \
[$widgets(timer01,mode_cb) current] \
[$widgets(timer01,psc_cb) current] \
- [subst "\${::SpecCalc::spec_chb_$obj_idx}"] \
+ [subst -nocommands "\${::SpecCalc::spec_chb_$obj_idx}"] \
] [list \
[$widgets(timer2,time_ent) get] \
[$widgets(timer2,time_cb) current] \
@@ -111,14 +116,14 @@ class SpecCalc {
[$widgets(timer2,mode_cb) current] \
] [list \
- [subst "\$::SpecCalc::timer2_clk_fosc_$obj_idx"]\
- [subst "\$::SpecCalc::timer2_clk_freq_$obj_idx"]\
- [subst "\$::SpecCalc::timer2_clk_x2_$obj_idx"] \
+ [subst -nocommands "\$::SpecCalc::timer2_clk_fosc_$obj_idx"] \
+ [subst -nocommands "\$::SpecCalc::timer2_clk_freq_$obj_idx"] \
+ [subst -nocommands "\$::SpecCalc::timer2_clk_x2_$obj_idx"] \
] [list \
[wm geometry $win] \
$active_page \
] [list \
- [subst "\${::SpecCalc::double_chb_$obj_idx}"] \
+ [subst -nocommands "\${::SpecCalc::double_chb_$obj_idx}"] \
[$widgets(spi,sck_ent00) get] \
]
]
@@ -148,7 +153,7 @@ class SpecCalc {
# @return void
private method create_gui {} {
# Create dialog window and the main frame
- set win [toplevel .spec_calc$count -class [mc "Special Calculator - MCU 8051 IDE"] -bg {#EEEEEE}]
+ set win [toplevel .spec_calc$count -class [mc "Special Calculator - MCU 8051 IDE"] -bg ${::COMMON_BG_COLOR}]
set main_frame [frame $win.main_frame]
# Create status bar
@@ -192,7 +197,7 @@ class SpecCalc {
if {[llength $config]} {
wm geometry $win [lindex $config {4 0}]
switch_page [lindex $config {4 1}]
- } {
+ } else {
wm geometry $win 400x350
switch_page loops
}
@@ -222,10 +227,10 @@ class SpecCalc {
} page $page_list \
{
set buttons($page) [ttk::button $target_frame.${page}_button \
- -image ::ICONS::22::$icon \
- -text [mc $name] -compound top \
- -command "$this switch_page $page" \
- -style Flat.TButton \
+ -image ::ICONS::22::$icon \
+ -text [mc $name] -compound top \
+ -command "$this switch_page $page" \
+ -style Flat.TButton \
]
pack $buttons($page) -anchor n
set_status_tip $buttons($page) [mc $stip]
@@ -236,7 +241,7 @@ class SpecCalc {
# @parm Widget target_frame - Frame widget in which the GUI should be created
# @return void
private method create_right_frame {target_frame} {
- set pages_manager [PagesManager $target_frame.pages_manager -background {#eeeeee}]
+ set pages_manager [PagesManager $target_frame.pages_manager -background ${::COMMON_BG_COLOR}]
pack $pages_manager -fill both -expand 1
foreach page $page_list {
@@ -363,13 +368,13 @@ class SpecCalc {
-command "$this calc loops copy_but {}" \
]
pack $widgets(loops,copy_but) -side right
- set widgets(loops,results) [text $bottom_frame_b.text \
- -state disabled -width 0 -height 0 -bg white \
- -yscrollcommand "$bottom_frame_b.scrollbar set" \
- -takefocus 1 -font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -14 \
- ] \
+ set widgets(loops,results) [text $bottom_frame_b.text \
+ -state disabled -width 0 -height 0 -bg white \
+ -yscrollcommand "$bottom_frame_b.scrollbar set" \
+ -takefocus 1 -font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ ] \
]
ASMsyntaxHighlight::create_tags $widgets(loops,results) 14 $::DEFAULT_FIXED_FONT
bind $widgets(loops,results) <Button-1> "focus %W"
@@ -394,13 +399,13 @@ class SpecCalc {
# Create page header
- pack [label $pages($page).header \
- -text [mc "Create a wait loop"] \
- -font [font create \
- -family {helvetica} \
- -size -17 \
- -weight bold \
- ] \
+ pack [label $pages($page).header \
+ -text [mc "Create a wait loop"] \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
] -pady 5
pack $top_frame -anchor nw
pack $regs_frame -anchor nw -fill x
@@ -413,15 +418,15 @@ class SpecCalc {
if {[llength $config]} {
$widgets(loops,time_ent) insert 0 [lindex $config {0 0}]
$widgets(loops,time_cb) current [lindex $config {0 1}]
- $widgets(loops,clock_cb) delete 0 end
- $widgets(loops,clock_cb) insert 0 [lindex $config {0 2}]
+ $widgets(loops,clock_cb) delete 0 end
+ $widgets(loops,clock_cb) insert 0 [lindex $config {0 2}]
$widgets(loops,clock_type_cb) current [lindex $config {0 3}]
for {set i 0; set k 4} {$i < 8} {incr i; incr k} {
$widgets(loops,reg_ent$i) insert 0 [lindex $config [list 0 $k]]
}
- } {
+ } else {
$widgets(loops,time_cb) current 1
$widgets(loops,clock_cb) current 2
$widgets(loops,clock_type_cb) current 0
@@ -569,9 +574,9 @@ class SpecCalc {
# - TH
set widgets(timer01,th) [ \
entry $bottom_frame.th_r_lbl -state readonly \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
- -fg {#888888} -bg {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer01_th_$obj_idx \
]
@@ -580,8 +585,8 @@ class SpecCalc {
# - TL
set widgets(timer01,tl) [ \
entry $bottom_frame.tl_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
- -readonlybackground {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer01_tl_$obj_idx \
@@ -591,8 +596,8 @@ class SpecCalc {
# - RH
set widgets(timer01,rh) [ \
entry $bottom_frame.rh_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
- -readonlybackground {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer01_rh_$obj_idx \
@@ -601,8 +606,8 @@ class SpecCalc {
# - RL
set widgets(timer01,rl) [ \
entry $bottom_frame.rl_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
- -readonlybackground {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer01_rl_$obj_idx \
@@ -611,8 +616,8 @@ class SpecCalc {
# - Repeats
set widgets(timer01,repeats) [ \
entry $bottom_frame.reps_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
- -readonlybackground {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer01_repeats_$obj_idx\
@@ -622,8 +627,8 @@ class SpecCalc {
# - Rest
set widgets(timer01,rest) [ \
entry $bottom_frame.rest_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
- -readonlybackground {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer01_rest_$obj_idx \
@@ -636,13 +641,13 @@ class SpecCalc {
# Create page header
- pack [label $pages($page).header \
- -text [mc "Calculate timer 0/1 preset"] \
- -font [font create \
- -family {helvetica} \
- -size -17 \
- -weight bold \
- ] \
+ pack [label $pages($page).header \
+ -text [mc "Calculate timer 0/1 preset"] \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
] -pady 5
pack $top_frame -anchor nw
pack [ttk::separator $pages($page).sep \
@@ -682,7 +687,7 @@ class SpecCalc {
private method create_page_timer2 {} {
# Create notebook
set page {timer2}
- set nb [NoteBook $pages($page).nb -side top -arcradius 4 -bg {#EEEEEE}]
+ set nb [ModernNoteBook $pages($page).nb]
# - Page "Preset"
set preset_frame [$nb insert end {Preset} \
-text [mc "Preset"] \
@@ -805,10 +810,10 @@ class SpecCalc {
# - RCAL2H
set widgets(timer2,rcal2h) [
entry $bottom_frame.rcal2h_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer2_rcal2h_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_rcal2h_$obj_idx [mc "Do not change"]
@@ -816,10 +821,10 @@ class SpecCalc {
# - RCAL2L
set widgets(timer2,rcal2l) [
entry $bottom_frame.rcal2l_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer2_rcal2l_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_rcal2l_$obj_idx [mc "Do not change"]
@@ -827,10 +832,10 @@ class SpecCalc {
# - T2H
set widgets(timer2,t2h) [
entry $bottom_frame.t2h_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer2_t2h_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_t2h_$obj_idx [mc "Do not change"]
@@ -838,21 +843,21 @@ class SpecCalc {
# - T2L
set widgets(timer2,t2l) [
entry $bottom_frame.t2l_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
-relief flat -highlightthickness 0 -bd 0 \
-textvariable ::SpecCalc::timer2_t2l_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_t2l_$obj_idx [mc "Do not change"]
grid $widgets(timer2,t2l) -row 4 -column 3 -sticky w
# - Repeats
- set widgets(timer2,repeats) [ \
- entry $bottom_frame.repeats_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
- -relief flat -highlightthickness 0 -bd 0 \
- -readonlybackground {#EEEEEE} \
- -disabledforeground {#000000} \
+ set widgets(timer2,repeats) [ \
+ entry $bottom_frame.repeats_lbl -state readonly \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
+ -relief flat -highlightthickness 0 -bd 0 \
+ -readonlybackground ${::COMMON_BG_COLOR} \
+ -disabledforeground {#000000} \
-textvariable ::SpecCalc::timer2_repeats_$obj_idx \
]
set ::SpecCalc::timer2_repeats_$obj_idx [mc "none"]
@@ -860,9 +865,9 @@ class SpecCalc {
# - Rest
set widgets(timer2,rest) [ \
entry $bottom_frame.rest_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} \
-relief flat -highlightthickness 0 -bd 0 \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
-textvariable ::SpecCalc::timer2_rest_$obj_idx \
]
@@ -874,13 +879,13 @@ class SpecCalc {
# Create page header
- pack [label $preset_frame.header \
- -text [mc "Calculate timer 2 preset"] \
- -font [font create \
- -family {helvetica} \
- -size -17 \
- -weight bold \
- ] \
+ pack [label $preset_frame.header \
+ -text [mc "Calculate timer 2 preset"] \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
] -pady 5
pack $top_frame -pady 5 -anchor nw
pack [ttk::separator $preset_frame.sep \
@@ -892,11 +897,11 @@ class SpecCalc {
if {[llength $config]} {
$widgets(timer2,time_ent) insert 0 [lindex $config {2 0}]
$widgets(timer2,time_cb) current [lindex $config {2 1}]
- $widgets(timer2,clock_cb) delete 0 end
- $widgets(timer2,clock_cb) insert 0 [lindex $config {1 2}]
+ $widgets(timer2,clock_cb) delete 0 end
+ $widgets(timer2,clock_cb) insert 0 [lindex $config {1 2}]
$widgets(timer2,clock_type_cb) current [lindex $config {2 3}]
$widgets(timer2,mode_cb) current [lindex $config {2 4}]
- } {
+ } else {
$widgets(timer2,time_cb) current 1
$widgets(timer2,clock_cb) current 2
$widgets(timer2,clock_type_cb) current 0
@@ -972,10 +977,10 @@ class SpecCalc {
# - RCAL2H
set widgets(timer2,clk_rcal2h) [
entry $bottom_frame.clk_rcal2h_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} -validate key \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} -validate key \
-relief flat -highlightthickness 0 -bd 0 -width 5 \
-textvariable ::SpecCalc::timer2_clk_rcal2h_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_clk_rcal2h_$obj_idx "--"
@@ -983,10 +988,10 @@ class SpecCalc {
# - RCAL2L
set widgets(timer2,clk_rcal2l) [
entry $bottom_frame.clk_rcal2l_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} -validate key \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} -validate key \
-relief flat -highlightthickness 0 -bd 0 -width 5 \
-textvariable ::SpecCalc::timer2_clk_rcal2l_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_clk_rcal2l_$obj_idx "--"
@@ -994,10 +999,10 @@ class SpecCalc {
# RCAL2H
set widgets(timer2,clk_rcal2h_d) [
entry $bottom_frame.clk_rcal2h_d_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} -validate key \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} -validate key \
-relief flat -highlightthickness 0 -bd 0 -width 5 \
-textvariable ::SpecCalc::timer2_clk_rcal2h_d_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_clk_rcal2h_d_$obj_idx "--"
@@ -1005,10 +1010,10 @@ class SpecCalc {
# - RCAL2L
set widgets(timer2,clk_rcal2l_d) [
entry $bottom_frame.clk_rcal2l_d_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} -validate key \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} -validate key \
-relief flat -highlightthickness 0 -bd 0 -width 5 \
-textvariable ::SpecCalc::timer2_clk_rcal2l_d_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_clk_rcal2l_d_$obj_idx "--"
@@ -1016,10 +1021,10 @@ class SpecCalc {
# - Error
set widgets(timer2,clk_error) [
entry $bottom_frame.clk_error_r_lbl -state readonly \
- -fg {#888888} -bg {#EEEEEE} -validate key \
+ -fg {#888888} -bg ${::COMMON_BG_COLOR} -validate key \
-relief flat -highlightthickness 0 -bd 0 -width 12 \
-textvariable ::SpecCalc::timer2_clk_error_$obj_idx \
- -readonlybackground {#EEEEEE} \
+ -readonlybackground ${::COMMON_BG_COLOR} \
-disabledforeground {#000000} \
]
set ::SpecCalc::timer2_clk_error_$obj_idx "--"
@@ -1033,30 +1038,30 @@ class SpecCalc {
set ::SpecCalc::timer2_clk_fosc_$obj_idx [lindex $config {3 0}]
set ::SpecCalc::timer2_clk_freq_$obj_idx [lindex $config {3 1}]
set ::SpecCalc::timer2_clk_x2_$obj_idx [lindex $config {3 2}]
- } {
+ } else {
set ::SpecCalc::timer2_clk_fosc_$obj_idx {}
set ::SpecCalc::timer2_clk_freq_$obj_idx {}
set ::SpecCalc::timer2_clk_x2_$obj_idx {0}
}
# Create page header
- pack [label $clock_out_frame.header \
- -text [mc "Calculate clock output"] \
- -font [font create \
- -family {helvetica} \
- -size -17 \
- -weight bold \
- ] \
+ pack [label $clock_out_frame.header \
+ -text [mc "Calculate clock output"] \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
] -pady 5
- pack [label $clock_out_frame.math \
- -image [image create photo \
- -format png \
- -file "${::LIB_DIRNAME}/../icons/other/math0.png" \
- ] \
+ pack [label $clock_out_frame.math \
+ -image [image create photo \
+ -format png \
+ -file "${::ROOT_DIRNAME}/icons/other/math0.png" \
+ ] \
] -pady 5
pack $bottom_frame -anchor nw
$nb raise {Preset}
- pack $nb -fill both -expand 1
+ pack [$nb get_nb] -fill both -expand 1
}
## Create page for calculating SPI related values
@@ -1102,10 +1107,10 @@ class SpecCalc {
grid $widgets(spi,sck_ent00) -row 2 -column 2
grid [label $top_frame.spr1_1_lbl \
- -text "0" \
+ -text "0" \
] -row 3 -column 0
grid [label $top_frame.spr0_1_lbl \
- -text "1" \
+ -text "1" \
] -row 3 -column 1
set widgets(spi,sck_ent01) [ttk::entry $top_frame.sck_1_ent \
-width 9 \
@@ -1115,10 +1120,10 @@ class SpecCalc {
grid $widgets(spi,sck_ent01) -row 3 -column 2
grid [label $top_frame.spr1_2_lbl \
- -text "1" \
+ -text "1" \
] -row 4 -column 0
grid [label $top_frame.spr0_2_lbl \
- -text "0" \
+ -text "0" \
] -row 4 -column 1
set widgets(spi,sck_ent10) [ttk::entry $top_frame.sck_2_ent \
-width 9 \
@@ -1128,10 +1133,10 @@ class SpecCalc {
grid $widgets(spi,sck_ent10) -row 4 -column 2
grid [label $top_frame.spr1_3_lbl \
- -text "1" \
+ -text "1" \
] -row 5 -column 0
grid [label $top_frame.spr0_3_lbl \
- -text "1" \
+ -text "1" \
] -row 5 -column 1
set widgets(spi,sck_ent11) [ttk::entry $top_frame.sck_3_ent \
-width 9 \
@@ -1144,26 +1149,26 @@ class SpecCalc {
pack [label $bottom_frame.res_lbl0 \
-text [mc "Set MCU oscillator to "] \
] -side left
- set widgets(spi,result) [ \
- entry $bottom_frame.result_ent \
- -readonlybackground {#EEEEEE} \
- -disabledforeground {#000000} \
- -bg {#EEEEEE} -width 0 -bd 1 -state readonly \
- -relief flat -highlightthickness 0 \
- -textvariable ::SpecCalc::spi_result_$obj_idx \
+ set widgets(spi,result) [ \
+ entry $bottom_frame.result_ent \
+ -readonlybackground ${::COMMON_BG_COLOR} \
+ -disabledforeground {#000000} \
+ -bg ${::COMMON_BG_COLOR} -width 0 -bd 1 -state readonly \
+ -relief flat -highlightthickness 0 \
+ -textvariable ::SpecCalc::spi_result_$obj_idx \
]
pack $widgets(spi,result) -side left
pack [label $bottom_frame.res_lbl1 \
- -text [mc " kHz"] \
+ -text [mc " kHz"] \
] -side left
- pack [label $pages($page).header \
- -text [mc "Calculate oscillator frequency"] \
- -font [font create \
- -family {helvetica} \
- -size -17 \
- -weight bold \
- ] \
+ pack [label $pages($page).header \
+ -text [mc "Calculate oscillator frequency"] \
+ -font [font create \
+ -family {helvetica} \
+ -size [expr {int(-17 * $::font_size_factor)}] \
+ -weight bold \
+ ] \
] -pady 5
pack $top_frame -pady 5 -anchor nw
pack [ttk::separator $pages($page).sep \
@@ -1205,7 +1210,7 @@ class SpecCalc {
}
}
- ## Auxiliary procedure for procedure "calculate_loops"
+ ## Auxiliary function for function "calculate_loops"
# @parm float time
# @parm float rest
# @parm Bool is_spec
@@ -1239,7 +1244,7 @@ class SpecCalc {
set time [expr {$time / $div}]
if {$res($len) == 256} {
set res($len) 0
- } {
+ } else {
set res($len) $div
}
@@ -1250,7 +1255,7 @@ class SpecCalc {
incr len
if {$len > 1} {
incr res(0) -2
- } {
+ } else {
incr res(0) -1
}
set correction 0
@@ -1266,13 +1271,13 @@ class SpecCalc {
if {$i == 1} {
if {[lindex $is_spec $i]} {
set correction 1
- } {
+ } else {
set correction 2
}
- } {
+ } else {
if {[lindex $is_spec $i]} {
set correction [expr {($correction * $res($i)) + ($res($i) * 2) + 1}]
- } {
+ } else {
set correction [expr {($correction * $res($i)) + ($res($i) * 3) + 2}]
}
}
@@ -1282,10 +1287,126 @@ class SpecCalc {
return [list $rest $len [array get res]]
}
- ## Report an error occured during evaluation of the wait loop
- # @return void
- private method calculate_loops_evaluation_error {} {
- error "Please report this bug. Method ::SpecCalc::calculate_loops --> Evaluation error. Dump: \n\$widgets(loops,time_ent) == $widgets(loops,time_ent)\n\$widgets(loops,time_cb) == $widgets(loops,time_cb)\n\$widgets(loops,clock_cb) == $widgets(loops,clock_cb)\n\$widgets(loops,clock_type_cb) == $widgets(loops,clock_type_cb)\n\$widgets(loops,reg_ent0) == $widgets(loops,reg_ent0)\n\$widgets(loops,reg_ent1) == $widgets(loops,reg_ent1)\n\$widgets(loops,reg_ent2) == $widgets(loops,reg_ent2)\n\$widgets(loops,reg_ent3) == $widgets(loops,reg_ent3)\n\$widgets(loops,reg_ent4) == $widgets(loops,reg_ent4)\n\$widgets(loops,reg_ent5) == $widgets(loops,reg_ent5)\n\$widgets(loops,reg_ent6) == $widgets(loops,reg_ent6)\n\$widgets(loops,reg_ent7) == $widgets(loops,reg_ent7)"
+ private method calculate_loops_AUX2 {time clock is_spec} {
+ set time_org $time
+ set i 0
+ set result [list]
+ set lowest_rest {}
+ set last_rest {}
+ set result_c {}
+ set result_fin_i 0
+ for {set i 0} {$i < 8} {incr i} {
+ set rest $time_org
+ set time [expr {int($time)}]
+ set rest [expr {$rest - $time}]
+
+ if {!$i && $time_org < 2.0} {
+ lappend result [list [expr {$time_org * 2.0 + 1.0}] 0 [list 0 {} 1 {} 2 {} 3 {} 4 {} 5 {} 6 {} 7 {}]]
+ break
+ }
+
+ set result_c [calculate_loops_AUX $time $rest $is_spec]
+ if {$result_c == {0}} {
+ return {}
+ }
+ lappend result $result_c
+
+ if {$lowest_rest == {}} {
+ set lowest_rest [lindex $result_c 0]
+
+ } elseif {$lowest_rest < 0} {
+ if {
+ ( [lindex $result_c 0] >= 0 )
+ ||
+ ( abs($lowest_rest) > abs([lindex $result_c 0]) )
+ } then {
+ set result_fin_i $i
+ set lowest_rest [lindex $result_c 0]
+ }
+
+ } elseif {
+ ( [lindex $result_c 0] >= 0 )
+ &&
+ ( $lowest_rest > [lindex $result_c 0] )
+ } then {
+ set result_fin_i $i
+ set lowest_rest [lindex $result_c 0]
+ }
+
+ if {$last_rest == [lindex $result_c 0] || ![lindex $result_c 0]} {
+ break
+ }
+ set last_rest [lindex $result_c 0]
+ set time [expr {$time_org + ($last_rest / 2.0)}]
+ }
+
+ return [lindex $result $result_fin_i]
+ }
+
+ private method calculate_loops_AUX3 {len is_spec res_list reg_list} {
+ set e_no_of_spaces ${::Editor::number_of_spaces}
+ if {$e_no_of_spaces == 1} {
+ set e_no_of_spaces 5
+ } elseif {$e_no_of_spaces <= 4} {
+ set e_no_of_spaces 6
+ }
+
+ array set res $res_list
+ array set reg $reg_list
+ set last_branch 0
+ set branch 0
+ for {set i 0} {$i < $len} {incr i} {
+ set branch $last_branch
+ set val $res($i)
+
+ set val [string range [format {%X} $res($i)] end-1 end]
+ set val "[string repeat {0} [expr {3 - [string length $val]}]]$val"
+
+ set cmp {}
+ if {[lindex $is_spec $i]} {
+ if {!$i} {
+ if {${::Editor::spaces_no_tabs}} {
+ set cmp "\n[string repeat { } ${::Editor::number_of_spaces}]NOP"
+ } else {
+ set cmp "\n\tNOP"
+ }
+ incr branch 1
+ }
+ } else {
+ incr branch 2
+ }
+ incr branch 4
+
+ set last_branch $branch
+ if {!$i} {
+ set branch 0
+ incr last_branch -4
+ }
+
+ if {$branch == {0}} {
+ set branch {}
+ } else {
+ set branch "-$branch"
+ }
+
+ if {${::Editor::spaces_no_tabs}} {
+ set res($i) [list \
+ "[string repeat { } ${::Editor::number_of_spaces}]DJNZ[string repeat { } [expr {$e_no_of_spaces - 4}]]$reg($i), \$$branch" \
+ "[string repeat { } ${::Editor::number_of_spaces}]MOV[string repeat { } [expr {$e_no_of_spaces - 3}]]$reg($i), #${val}h$cmp" \
+ ]
+ } else {
+ set res($i) [list \
+ "\tDJNZ\t$reg($i), \$$branch" \
+ "\tMOV\t$reg($i), #${val}h$cmp" \
+ ]
+ }
+ }
+ for {set i [expr {$len - 1}]} {$i >= 0} {incr i -1} {
+ $widgets(loops,results) insert end "[lindex $res($i) 1]\n"
+ }
+ for {set i 0} {$i < $len} {incr i} {
+ $widgets(loops,results) insert end "[lindex $res($i) 0]\n"
+ }
}
## Generate wait loop acoring to specified criteria
@@ -1302,7 +1423,7 @@ class SpecCalc {
if {[lsearch -ascii -exact {R0 R1 R2 R3 R4 R5 R6 R7 A} [string toupper $reg($i)]] != -1} {
lappend is_spec 1
- } {
+ } else {
lappend is_spec 0
}
}
@@ -1329,52 +1450,28 @@ class SpecCalc {
return 0
}
+ set e_no_of_spaces ${::Editor::number_of_spaces}
+ if {$e_no_of_spaces == 1} {
+ set e_no_of_spaces 5
+ } elseif {$e_no_of_spaces <= 4} {
+ set e_no_of_spaces 6
+ }
+
set time [expr {$time * [lindex {1.0 1000.0 1000000.0 1000000000.0} [$widgets(loops,time_cb) current]] / 2.0}]
- set clock [expr {[lindex {12.0 6.0 1.0} [$widgets(loops,clock_type_cb) current]] / $clock}]
+ set clock [expr {$clock / [lindex {12000000.0 6000000.0 1000000.0} [$widgets(loops,clock_type_cb) current]]}]
set time [expr {$time * $clock}]
- set time_org $time
- set i 0
- set result [list]
- set lowes_rest $time
- set last_rest {}
- set result_c {}
- set result_fin_i 0
- for {set i 0} {$i < 8} {incr i} {
-
- set rest $time_org
- set time [expr {int($time)}]
- set rest [expr {$rest - $time}]
-
- set result_c [calculate_loops_AUX $time $rest $is_spec]
- if {$result_c == {0}} {
- return 0
- }
- lappend result $result_c
-
- if {$lowes_rest == {}} {
- set lowes_rest [lindex $result_c 0]
-
- } elseif {($lowes_rest < 0) && ([lindex $result_c 0] >= 0)} {
- set result_fin_i $i
- set lowes_rest [lindex $result_c 0]
-
- } elseif {abs($lowes_rest) > abs([lindex $result_c 0])} {
- set result_fin_i $i
- set lowes_rest [lindex $result_c 0]
- }
-
- if {$last_rest == [lindex $result_c 0] || ![lindex $result_c 0]} {
- break
- }
- set last_rest [lindex $result_c 0]
- set time [expr {$time_org + ($last_rest / 2.0)}]
+ if {$time <= 258.5} {
+ set time [expr {$time - 0.5}]
}
- set time $time_org
- set rest [lindex $result [list $result_fin_i 0]]
- set len [lindex $result [list $result_fin_i 1]]
- array set res [lindex $result [list $result_fin_i 2]]
+ set final_results [calculate_loops_AUX2 $time $clock $is_spec]
+ if {$final_results == {}} {
+ return 0
+ }
+ set rest [lindex $final_results 0]
+ set len [lindex $final_results 1]
+ array set res [lindex $final_results 2]
for {set i 0} {$i < $len} {incr i} {
set error 0
@@ -1402,87 +1499,62 @@ class SpecCalc {
}
$widgets(loops,results) insert end "\n"
- set last_branch 0
- set branch 0
- for {set i 0} {$i < $len} {incr i} {
- set branch $last_branch
- set val $res($i)
-
- set val [string range [format {%X} $res($i)] end-1 end]
- set val "[string repeat {0} [expr {3 - [string length $val]}]]$val"
-
- set cmp {}
- if {[lindex $is_spec $i]} {
- if {!$i} {
- set cmp "\n\tNOP"
- incr branch 1
- }
- } {
- incr branch 2
- }
- incr branch 4
+ calculate_loops_AUX3 $len $is_spec [array get res] [array get reg]
- set last_branch $branch
- if {!$i} {
- set branch 0
- incr last_branch -4
- }
- if {$branch == {0}} {
- set branch {}
- } {
- set branch "-$branch"
+ while {$rest > 514} {
+ set final_results [calculate_loops_AUX2 [expr {$rest / 2.0}] $clock $is_spec]
+ if {$final_results == {}} {
+ return 0
}
-
- set res($i) [list \
- "\tDJNZ\t$reg($i), \$$branch" \
- "\tMOV\t$reg($i), #${val}h$cmp" \
- ]
- }
-
- for {set i [expr {$len - 1}]} {$i >= 0} {incr i -1} {
- $widgets(loops,results) insert end "[lindex $res($i) 1]\n"
- }
-
- for {set i 0} {$i < $len} {incr i} {
- $widgets(loops,results) insert end "[lindex $res($i) 0]\n"
+ set rest [lindex $final_results 0]
+ calculate_loops_AUX3 [lindex $final_results 1] $is_spec [lindex $final_results 2] [array get reg]
}
if {$rest <= 4} {
for {set i 0} {$i < 5} {incr i} {
- if {int(ceil($rest)) > 0.5} {
- $widgets(loops,results) insert end "\tNOP\n"
+ if {int(ceil($rest)) >= 0.5} {
+ if {${::Editor::spaces_no_tabs}} {
+ $widgets(loops,results) insert end "[string repeat { } ${::Editor::number_of_spaces}]NOP\n"
+ } else {
+ $widgets(loops,results) insert end "\tNOP\n"
+ }
set rest [expr {$rest - 1}]
}
}
- } {
+ } else {
if {[lindex $is_spec 0]} {
set rest [expr {$rest - 1}]
- } {
+ } else {
set rest [expr {$rest - 2}]
}
set val [expr {int($rest / 2)}]
set rest [expr {$rest - ($val * 2.0)}]
if {$val == 256} {
set val 0
- } elseif {$val > 256} {
- status_tip [mc "Unable to evaluate"]
- calculate_loops_clear_results
- return 0
}
+
set val [string range [format {%X} $val] end-1 end]
set val "[string repeat {0} [expr {3 - [string length $val]}]]$val"
- $widgets(loops,results) insert end "\tMOV\t$reg(0), #${val}h\n"
- $widgets(loops,results) insert end "\tDJNZ\t$reg(0), \$\n"
- if {int(ceil($rest)) > 0.5} {
- $widgets(loops,results) insert end "\tNOP\n"
- set rest [expr {$rest - 1}]
+ if {${::Editor::spaces_no_tabs}} {
+ $widgets(loops,results) insert end "[string repeat { } ${::Editor::number_of_spaces}]MOV[string repeat { } [expr {$e_no_of_spaces - 3}]]$reg(0), #${val}h\n"
+ $widgets(loops,results) insert end "[string repeat { } ${::Editor::number_of_spaces}]DJNZ[string repeat { } [expr {$e_no_of_spaces - 4}]]$reg(0), \$\n"
+ if {int(ceil($rest)) >= 0.5} {
+ $widgets(loops,results) insert end "[string repeat { } ${::Editor::number_of_spaces}]NOP\n"
+ set rest [expr {$rest - 1}]
+ }
+ } else {
+ $widgets(loops,results) insert end "\tMOV\t$reg(0), #${val}h\n"
+ $widgets(loops,results) insert end "\tDJNZ\t$reg(0), \$\n"
+ if {int(ceil($rest)) >= 0.5} {
+ $widgets(loops,results) insert end "\tNOP\n"
+ set rest [expr {$rest - 1}]
+ }
}
}
set rest [expr {$rest * 1.0 / $clock}]
$widgets(loops,results) insert end [mc "; Rest: %s\n" [adjust_rest $rest]]
-
$widgets(loops,results) insert end [mc "; END: Wait loop"]
set end [expr {int([$widgets(loops,results) index end])}]
@@ -1510,7 +1582,7 @@ class SpecCalc {
private method calculate_loops_enable_copy {enable} {
if {$enable} {
set enable {normal}
- } {
+ } else {
set enable {disabled}
}
$widgets(loops,copy_but) configure -state $enable
@@ -1521,13 +1593,11 @@ class SpecCalc {
public method calculate_timer01 {} {
set time [$widgets(timer01,time_ent) get]
if {$time == {} || $time == 0} {
- status_tip [mc "Invalid time"]
return 0
}
set clock [$widgets(timer01,clock_cb) get]
if {$clock == {} || $clock == 0} {
- status_tip [mc "Invalid clock rate"]
return 0
}
status_tip ""
@@ -1544,11 +1614,11 @@ class SpecCalc {
}
set time [expr {$time * [lindex {1.0 1000.0 1000000.0 1000000000.0} [$widgets(timer01,time_cb) current]]}]
- set clock [expr {[lindex {12.0 6.0 1.0} [$widgets(timer01,clock_type_cb) current]] / $clock}]
+ set clock [expr {$clock / [lindex {12000000.0 6000000.0 1000000.0} [$widgets(timer01,clock_type_cb) current]]}]
set time [expr {$time * $clock}]
set time_int [expr {int($time)}]
- set enhanced [subst "\$::SpecCalc::spec_chb_$obj_idx"]
+ set enhanced [subst -nocommands "\$::SpecCalc::spec_chb_$obj_idx"]
set prescaler [$widgets(timer01,psc_cb) current]
# Set default results
@@ -1561,7 +1631,7 @@ class SpecCalc {
{0} { ;# 9 -> 16 bit counter
if {$enhanced} {
set bits [expr {$prescaler + 9}]
- } {
+ } else {
set bits 13
}
set capacity [expr {1 << $bits}]
@@ -1574,7 +1644,7 @@ class SpecCalc {
if {[expr {!($time_int & $full_mask)}]} {
incr repeats -1
set stepsPerIter $full_mask
- } {
+ } else {
set stepsPerIter [expr {$time_int / $repeats}]
set tmp [expr {$capacity - $stepsPerIter}]
set low [expr {$tmp & $low_mask}]
@@ -1592,7 +1662,6 @@ class SpecCalc {
set rest [adjust_rest $rest]
if {$repeats > 1} {
- status_tip [mc "Value is too high"]
return 0
}
@@ -1619,7 +1688,7 @@ class SpecCalc {
incr repeats -1
set stepsPerIter 0xFFFF
set tmp 0
- } {
+ } else {
set stepsPerIter [expr {$time_int / $repeats}]
set tmp [expr {0x10000 - $stepsPerIter}]
set low [expr {$tmp & 0xFF}]
@@ -1637,7 +1706,7 @@ class SpecCalc {
if {$tmp < 0} {
set rest [expr {abs($tmp)}]
set tmp 0
- } {
+ } else {
set rest 0
}
set tmp [expr {$tmp & 0x0FFFF}]
@@ -1666,7 +1735,7 @@ class SpecCalc {
foreach w {rh rl tl th rest repeats} {
$widgets(timer01,$w) configure -fg {#000000}
}
- } {
+ } else {
if {$repeats > 1} {
status_tip [mc "Value is too high"]
return 0
@@ -1688,7 +1757,7 @@ class SpecCalc {
if {[expr {!($time_int & 0xFF)}]} {
incr repeats -1
set stepsPerIter 0xFF
- } {
+ } else {
set stepsPerIter [expr {$time_int / $repeats}]
set low [expr {0x100 - $stepsPerIter}]
set high $low
@@ -1705,7 +1774,7 @@ class SpecCalc {
if {$low < 0} {
set rest [expr {abs($low)}]
set low 0
- } {
+ } else {
set rest 0
}
@@ -1736,13 +1805,11 @@ class SpecCalc {
public method calculate_timer2 {} {
set time [$widgets(timer2,time_ent) get]
if {$time == {} || $time == 0} {
- status_tip [mc "Invalid time"]
return 0
}
set clock [$widgets(timer2,clock_cb) get]
if {$clock == {} || $clock == 0} {
- status_tip [mc "Invalid clock rate"]
return 0
}
status_tip ""
@@ -1759,7 +1826,7 @@ class SpecCalc {
}
set time [expr {$time * [lindex {1.0 1000.0 1000000.0 1000000000.0} [$widgets(timer2,time_cb) current]]}]
- set clock [expr {[lindex {12.0 6.0 1.0} [$widgets(timer2,clock_type_cb) current]] / $clock}]
+ set clock [expr {$clock / [lindex {12000000.0 6000000.0 1000000.0} [$widgets(timer2,clock_type_cb) current]]}]
set time [expr {$time * $clock}]
set time_int [expr {int($time)}]
set mode [$widgets(timer2,mode_cb) current]
@@ -1781,13 +1848,13 @@ class SpecCalc {
set low_p $low
set high_p $high
- } {
+ } else {
# Calculate tempotary results
if {[expr {!($time_int & 0xFFFF)}]} {
incr repeats -1
set stepsPerIter 0xFFFF
set tmp 0
- } {
+ } else {
set stepsPerIter [expr {$time_int / $repeats}]
set tmp [expr {0x10000 - $stepsPerIter}]
set rest [expr {$time_int - ((0x10000 - $tmp) * $repeats)}]
@@ -1805,7 +1872,7 @@ class SpecCalc {
if {$tmp < 0} {
set rest [expr {abs($tmp)}]
set tmp 0
- } {
+ } else {
set rest 0
}
set tmp [expr {$tmp & 0x0FFFF}]
@@ -1911,9 +1978,9 @@ class SpecCalc {
## Perform calculation intented for page "Timer 2 clock output"
# @return void
public method calculate_timer2_clk {} {
- set o [subst "\$::SpecCalc::timer2_clk_fosc_$obj_idx"]
- set f [subst "\$::SpecCalc::timer2_clk_freq_$obj_idx"]
- set x [subst "\$::SpecCalc::timer2_clk_x2_$obj_idx"]
+ set o [subst -nocommands "\$::SpecCalc::timer2_clk_fosc_$obj_idx"]
+ set f [subst -nocommands "\$::SpecCalc::timer2_clk_freq_$obj_idx"]
+ set x [subst -nocommands "\$::SpecCalc::timer2_clk_x2_$obj_idx"]
if {
![string length $o] || ![string length $f] || ![string length $x] ||
$f == 0 || $o == 0
@@ -1950,7 +2017,7 @@ class SpecCalc {
# @parm
# @return void
private method calculate_spi {type value} {
- set const [subst "\$::SpecCalc::double_chb_$obj_idx"]
+ set const [subst -nocommands "\$::SpecCalc::double_chb_$obj_idx"]
switch -- $type {
{sck_ent00} {
@@ -2085,14 +2152,10 @@ class SpecCalc {
return 1
}
{compute_but} {
- if {[catch {
- if {[calculate_loops]} {
- calculate_loops_enable_copy 1
- } {
- calculate_loops_enable_copy 0
- }
- }]} {
- calculate_loops_evaluation_error
+ if {[calculate_loops]} {
+ calculate_loops_enable_copy 1
+ } else {
+ calculate_loops_enable_copy 0
}
}
{copy_but} {
@@ -2160,7 +2223,7 @@ class SpecCalc {
grid $widgets(timer01,rl) -row 4 -column 3 -sticky w
grid $widgets(timer01,eq3) -row 3 -column 2
grid $widgets(timer01,eq4) -row 4 -column 2
- } {
+ } else {
grid forget $widgets(timer01,psc_lbl)
grid forget $widgets(timer01,psc_cb)
grid forget $widgets(timer01,rh_l)
@@ -2327,25 +2390,25 @@ class SpecCalc {
switch -- [$widgets(timer01,mode_cb) current] {
0 {
set title [mc "Timer 0/1 in mode 0"]
- if {[subst "\${::SpecCalc::spec_chb_$obj_idx}"]} {
+ if {[subst -nocommands "\${::SpecCalc::spec_chb_$obj_idx}"]} {
set image {timer_01_0e}
- } {
+ } else {
set image {timer_01_0}
}
}
1 {
set title [mc "Timer 0/1 in mode 1"]
- if {[subst "\${::SpecCalc::spec_chb_$obj_idx}"]} {
+ if {[subst -nocommands "\${::SpecCalc::spec_chb_$obj_idx}"]} {
set image {timer_01_1e}
- } {
+ } else {
set image {timer_01_1}
}
}
2 {
set title [mc "Timer 0/1 in mode 2"]
- if {[subst "\${::SpecCalc::spec_chb_$obj_idx}"]} {
+ if {[subst -nocommands "\${::SpecCalc::spec_chb_$obj_idx}"]} {
set image {timer_01_2e}
- } {
+ } else {
set image {timer_01_2}
}
}
@@ -2376,9 +2439,9 @@ class SpecCalc {
}
}
- set dlg [toplevel .spec_calc_diagram_$diagram_counter -class [mc "Diagram or formula"] -bg {#EEEEEE}]
+ set dlg [toplevel .spec_calc_diagram_$diagram_counter -class [mc "Diagram or formula"] -bg ${::COMMON_BG_COLOR}]
pack [label $dlg.image \
- -image [image create photo -format png -file "${::LIB_DIRNAME}/../icons/other/$image.png"]
+ -image [image create photo -format png -file "${::ROOT_DIRNAME}/icons/other/$image.png"]
] -fill both
wm title $dlg $title
@@ -2388,3 +2451,7 @@ class SpecCalc {
incr diagram_counter
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/utilities/symbol_viewer.tcl b/lib/utilities/symbol_viewer.tcl
index 3df57b4..c46b8ac 100755..100644
--- a/lib/utilities/symbol_viewer.tcl
+++ b/lib/utilities/symbol_viewer.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 _SYMBOL_VIEWER_TCL ] } {
+set _SYMBOL_VIEWER_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements assembly language symbols viewer (from code listing)
@@ -31,17 +36,21 @@ class SymbolViewer {
# Int: Counter of object intances
common count 0
# Font: Just normal font used in the table
- common normal_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -15 \
- -weight normal \
+ common normal_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight normal \
]
# Font: Bold font (the same size as $normal_font)
- common bold_font [font create \
- -family $::DEFAULT_FIXED_FONT \
- -size -15 \
- -weight bold \
+ common bold_font [font create \
+ -family $::DEFAULT_FIXED_FONT \
+ -size [expr {int(-14 * $::font_size_factor)}] \
+ -weight bold \
]
+ if {$::MICROSOFT_WINDOWS} {
+ # it's better to do not use bold font for this purpose on MS Windows®
+ set bold_font $normal_font
+ }
# Dialog configuration
common config_list $::CONFIG(SYMBOL_VIEWER_CONFIG)
@@ -62,7 +71,7 @@ class SymbolViewer {
constructor {} {
# Create dialog window
- set win [toplevel .symbolviewer$count -class {Defined symbols} -bg {#EEEEEE}]
+ set win [toplevel .symbolviewer$count -class {Defined symbols} -bg ${::COMMON_BG_COLOR}]
set obj_idx $count
incr count
@@ -93,16 +102,19 @@ class SymbolViewer {
# Configure dialog window
wm iconphoto $win ::ICONS::16::symbol
wm title $win [mc "Assembly symbol table - MCU 8051 IDE"]
- wm minsize $win 620 350
+ wm minsize $win 520 350
wm protocol $win WM_DELETE_WINDOW "$this close_window"
+ update
catch {
- wm geometry $win [lindex $config_list $i]
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $config_list $i] \
+ [regsub {\+\d+\+\d+$} [wm geometry $win] {}] \
+ ]
}
# Set ...
incr i
set ::SymbolViewer::display_${obj_idx}(Special) [lindex $config_list $i]
- if {[subst "\$::SymbolViewer::display_${obj_idx}(Special)"] == {}} {
+ if {[subst -nocommands "\$::SymbolViewer::display_${obj_idx}(Special)"] == {}} {
set ::SymbolViewer::display_${obj_idx}(Special) 1
}
}
@@ -114,16 +126,16 @@ class SymbolViewer {
}
set i 0
foreach name {DATA IDATA XDATA CODE BIT Number used unused} {
- lset config_list $i [subst "\$::SymbolViewer::display_${obj_idx}($name)"]
+ lset config_list $i [subst -nocommands "\$::SymbolViewer::display_${obj_idx}($name)"]
incr i
}
- lset config_list $i [subst "\$::SymbolViewer::sort_by_${obj_idx}"]
+ lset config_list $i [subst -nocommands "\$::SymbolViewer::sort_by_${obj_idx}"]
incr i
- lset config_list $i [subst "\$::SymbolViewer::sort_by_order_${obj_idx}"]
+ lset config_list $i [subst -nocommands "\$::SymbolViewer::sort_by_order_${obj_idx}"]
incr i
lset config_list $i [wm geometry $win]
incr i
- lset config_list $i [subst "\$::SymbolViewer::display_${obj_idx}(Special)"]
+ lset config_list $i [subst -nocommands "\$::SymbolViewer::display_${obj_idx}(Special)"]
# Clean up
unset ::SymbolViewer::sort_by_${obj_idx}
@@ -182,7 +194,7 @@ class SymbolViewer {
$text_widget tag configure used_YES -foreground {#00DD00}
$text_widget tag configure used_NO -foreground {#DD0000}
$text_widget tag configure tag_sel -background {#DDDDDD} -font $bold_font
- $text_widget tag configure nth_row -background {#EEEEEE}
+ $text_widget tag configure nth_row -background ${::COMMON_BG_COLOR}
$text_widget tag raise tag_sel nth_row
}
@@ -383,10 +395,10 @@ class SymbolViewer {
if {$opened_file == {}} {
if {${::X::project_menu_locked}} {
set directory {~}
- } {
+ } else {
set directory [${::X::actualProject} cget -projectPath]
}
- } {
+ } else {
set directory [file dirname $opened_file]
}
@@ -394,10 +406,10 @@ class SymbolViewer {
KIFSD::FSD ::fsd \
-title [mc "Load symbol table - MCU 8051 IDE"] \
-directory $directory -master $win \
- -defaultmask 0 -multiple 0 -filetypes {
- {{Code listing} {*.lst} }
- {{All files} {*} }
- }
+ -defaultmask 0 -multiple 0 -filetypes [list \
+ [list [mc "Code listing"] {*.lst} ] \
+ [list [mc "All files"] {*} ] \
+ ]
# Open the selected after press of OK button
::fsd setokcmd "
@@ -420,7 +432,7 @@ class SymbolViewer {
public method open_file {ignore_errors filename} {
if {[catch {
set file [open $filename r]
- }]} {
+ }]} then {
if {!$ignore_errors} {
tk_messageBox \
-parent $win \
@@ -472,7 +484,7 @@ class SymbolViewer {
set type [lindex $line 0]
if {$type == {S}} {
set addr [lindex $line end]
- } {
+ } else {
set addr [string replace [lindex $line 2] end end]
}
@@ -516,7 +528,7 @@ class SymbolViewer {
if {$type == {S} || $type == {R}} {
lappend symbol_table_data [list $name $type $addr {0} $used]
- } {
+ } else {
lappend symbol_table_data [list $name $type $addr [expr "0x$addr"] $used]
}
}
@@ -528,18 +540,18 @@ class SymbolViewer {
refresh
}
- ## Sort list of loaded symbols acording to user settings
+ ## Sort list of loaded symbols according to user settings
# @return void
private method sort_table {} {
- if {[subst "\$::SymbolViewer::sort_by_order_${obj_idx}"]} {
+ if {[subst -nocommands "\$::SymbolViewer::sort_by_order_${obj_idx}"]} {
set order {-decreasing}
- } {
+ } else {
set order {-increasing}
}
- set index [subst "\$::SymbolViewer::sort_by_${obj_idx}"]
+ set index [subst -nocommands "\$::SymbolViewer::sort_by_${obj_idx}"]
if {$index == 3} {
set type {-integer}
- } {
+ } else {
set type {-dictionary}
}
@@ -562,21 +574,21 @@ class SymbolViewer {
{S} {set type {Special}}
{R} {set type {Special}}
}
- if {![subst "\$::SymbolViewer::display_${obj_idx}($type)"]} {
+ if {![subst -nocommands "\$::SymbolViewer::display_${obj_idx}($type)"]} {
return 0
}
# Adjust flag USED
if {$used} {
- if {![subst "\$::SymbolViewer::display_${obj_idx}(used)"]} {
+ if {![subst -nocommands "\$::SymbolViewer::display_${obj_idx}(used)"]} {
return 0
}
- set used {YES}
- } {
- if {![subst "\$::SymbolViewer::display_${obj_idx}(unused)"]} {
+ set used [mc "YES"]
+ } else {
+ if {![subst -nocommands "\$::SymbolViewer::display_${obj_idx}(unused)"]} {
return 0
}
- set used {NO}
+ set used [mc "NO"]
}
return [list $type $used]
@@ -602,7 +614,7 @@ class SymbolViewer {
lset current_line 1 [string index [lindex $current_line 1] 0]
if {[lindex $current_line 4] == {YES}} {
lset current_line 4 1
- } {
+ } else {
lset current_line 4 0
}
}
@@ -646,7 +658,7 @@ class SymbolViewer {
if {$type == {Special}} {
$text_widget insert insert $hexv
$text_widget insert insert [string repeat { } [expr {16 - [string length $hexv]}]]
- } {
+ } else {
$text_widget insert insert $hexv
$text_widget insert insert { }
$text_widget insert insert $decv
@@ -673,7 +685,7 @@ class SymbolViewer {
if {$cur_found} {
$text_widget tag add tag_sel $current_line.0 $current_line.0+1l
$text_widget see $current_line.0
- } {
+ } else {
set current_line {}
}
@@ -706,7 +718,7 @@ class SymbolViewer {
set string [string tolower [string trimleft $string 0]]
$clear_but configure -state normal
# Empty string -> abort
- } {
+ } else {
$search_entry configure -style TEntry
$clear_but configure -state disabled
return 1
@@ -749,7 +761,7 @@ class SymbolViewer {
if {$found_idx == -1} {
$search_entry configure -style StringNotFound.TEntry
# String found
- } {
+ } else {
set current_line [expr {$found_idx + 1}]
$text_widget tag add tag_sel $current_line.0 $current_line.0+1l
$text_widget see $current_line.0
@@ -795,7 +807,7 @@ class SymbolViewer {
select_line $x $y
if {$current_line == {}} {
set state disabled
- } {
+ } else {
set state normal
}
foreach entry {{Copy symbol name} {Copy hex value} {Copy dec value} {Copy line}} {
@@ -835,3 +847,7 @@ class SymbolViewer {
clipboard append [string trim [$text_widget get $current_line.$s $current_line.$e]]
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard
diff --git a/lib/utilities/table_of_instructions.tcl b/lib/utilities/table_of_instructions.tcl
new file mode 100644
index 0000000..b6587b2
--- /dev/null
+++ b/lib/utilities/table_of_instructions.tcl
@@ -0,0 +1,692 @@
+#!/usr/bin/tclsh
+# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+
+############################################################################
+# Copyright (C) 2011 by Martin Ošmera #
+# martin.osmera@gmail.com #
+# #
+# This program is free software; you can redistribute it and#or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the #
+# Free Software Foundation, Inc., #
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
+############################################################################
+
+# >>> File inclusion guard
+if { ! [ info exists _TABLE_OF_INSTRUCTIONS_TCL ] } {
+set _TABLE_OF_INSTRUCTIONS_TCL _
+# <<< File inclusion guard
+
+# --------------------------------------------------------------------------
+# DESCRIPTION
+# 8051 Instruction Table
+# --------------------------------------------------------------------------
+
+class TableOfInstructions {
+ common tbl_of_inst_count 0 ;# Int: Counter of object instances
+ common oprs_color {#00DD00} ;# RGB Color: Number of operands
+ common len_color {#00AA55} ;# RGB Color: Instruction length
+ common time_color {#8800DD} ;# RGB Color: Time to execute
+ common ins_color {#0000DD} ;# RGB Color: Instruction mnemonics
+
+ # Font for instruction name
+ common instruction_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ ]
+ # Font for numbers below the instruction name
+ common number_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -weight {bold} \
+ ]
+ # Font for labels in details frame (normal)
+ common details_n_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ ]
+ # Font for labels in details frame (bold)
+ common details_b_font [font create \
+ -family {helvetica} \
+ -size [expr {int(-12 * $::font_size_factor)}] \
+ -weight {bold} \
+ ]
+
+ private variable win ;# Widget: Dialog window
+ private variable window_visible 0 ;# Bool: Visibility flag
+ private variable cells ;# Array of Widget: Chart cell frames
+ private variable vh_cells ;# Array of Widget: Vertical headers
+ private variable hh_cells ;# Array of Widget: Horizontal headers
+ private variable selected_cell -1 ;# Int: Currently selected cell
+ private variable status_bar_lbl ;# Widget: Status bar
+ private variable validation_ena 1 ;# Bool: EntryBox validation enabled
+ private variable matrix_frame ;# Widget: Frame for the chart
+ private variable vertical_scrollbar ;# Widget: Scrollbar for the scrollable frame
+ private variable scrollable_frame ;# Widget: Scrollable frame containing the chart
+
+ private variable opcode_ent ;# Widget: Entry box with the OP code
+ private variable title_v_lbl ;# Widget: Label containing instruction name along with its operands
+ private variable class_v_lbl ;# Widget: Label containing the class
+ private variable desc_v_lbl ;# Widget: Label containing the description
+ private variable length_v_lbl ;# Widget: Label containing the length
+ private variable time_v_lbl ;# Widget: Label containing the time
+ private variable flags_v_lbl ;# Widget: Label containing the flags
+ private variable note_v_lbl ;# Widget: Label containing the note
+
+ constructor {} {
+ # Configure local ttk styles
+ ttk::style configure TblOfIns_RedBg.TEntry -fieldbackground {#FFDDDD}
+ ttk::style configure TblOfIns_GreenBg.TEntry -fieldbackground {#DDFFDD}
+
+ # Create dialog window
+ set window_visible 1
+ set win [toplevel .tableofinstructions${tbl_of_inst_count} -class {8051 Instruction Table} -bg ${::COMMON_BG_COLOR}]
+ incr tbl_of_inst_count
+
+ # Create dialog GUI
+ create_gui
+
+ # Set window event bindings
+ bind $win <Control-Key-q> "$this close_window; break"
+ bindtags $win [list $win Toplevel all .]
+
+ # Set window parameters
+ wm iconphoto $win ::ICONS::16::fsview
+ wm title $win "[mc {8051 Instruction Table}] - MCU 8051 IDE"
+ wm resizable $win 0 1
+ wm protocol $win WM_DELETE_WINDOW "$this close_window"
+ update
+
+ # Compute required width of the window
+ set w [winfo width $matrix_frame.hh_lbl1]
+ incr w [winfo width $vertical_scrollbar]
+ for {set i 0} {$i < 16} {incr i} {
+ incr w [winfo width $matrix_frame.cell_$i]
+ incr w
+ }
+ wm minsize $win $w 400
+ }
+
+ destructor {
+ destroy $win
+ }
+
+ ## Determinate wheather the window is visble or not
+ # @return Bool - Visibility flag
+ public method is_visible {} {
+ return $window_visible
+ }
+
+ ## Raise dialog window (insure than it is visible)
+ # @return void
+ public method raise_window {} {
+ if {!$window_visible} {return}
+ raise $win .
+ }
+
+ ## Restore dialog window
+ # @return void
+ public method restore_window {} {
+ set window_visible 1
+ wm deiconify $win
+ raise $win .
+ }
+
+ ## Close dialog window, but keep object
+ # @return void
+ public method close_window {} {
+ set window_visible 0
+ wm withdraw $win
+ }
+
+ ## Create window GUI
+ # @return void
+ private method create_gui {} {
+ ## Create bottom frame
+ set bottom_frame [frame $win.bottom_frame]
+ set status_bar_lbl [label $bottom_frame.status_bar_lbl -justify left -anchor w]
+ pack $status_bar_lbl -side left -fill x -in $bottom_frame -padx 5
+ pack [ttk::button $bottom_frame.close_but \
+ -text [mc "Exit"] \
+ -command "$this close_window" \
+ -compound left \
+ -image ::ICONS::16::exit \
+ ] -side right -padx 5 -pady 5
+
+ ## Create main frame
+ set main_frame [frame $win.main_frame -bg ${::COMMON_BG_COLOR}]
+ set scrollable_frame [ScrollableFrame $main_frame.scrollable_frame \
+ -bg ${::COMMON_BG_COLOR} \
+ -yscrollcommand "$main_frame.vertical_scrollbar set" \
+ ]
+ set matrix_frame [$scrollable_frame getframe]
+ bind $matrix_frame <Button-5> "$scrollable_frame yview scroll +1 units; break"
+ bind $matrix_frame <Button-4> "$scrollable_frame yview scroll -1 units; break"
+ set vertical_scrollbar [ttk::scrollbar $main_frame.vertical_scrollbar \
+ -orient vertical -command "$main_frame.scrollable_frame yview" \
+ ]
+ # Create vertical header
+ set header [list {} \
+ {0x0_} {0x1_} {0x2_} {0x3_} \
+ {0x4_} {0x5_} {0x6_} {0x7_} \
+ {0x8_} {0x9_} {0xA_} {0xB_} \
+ {0xC_} {0xD_} {0xE_} {0xF_} \
+ ]
+ grid [frame $matrix_frame.top_right_lbl -bg ${::COMMON_BG_COLOR}] -sticky wens -row 0 -column 0
+ for {set y 1} {$y < 17} {incr y} {
+ grid [label $matrix_frame.vh_lbl$y -text [lindex $header $y] -bg {#FFFFFF}] \
+ -row $y -column 0 -pady [expr {$y % 2}] -sticky wens
+ set vh_cells([expr {$y - 1}]) $matrix_frame.vh_lbl$y
+ }
+ # Create horizontal header
+ set header [list {} \
+ {0x_0} {0x_1} {0x_2} {0x_3} \
+ {0x_4} {0x_5} {0x_6} {0x_7} \
+ {0x_8} {0x_9} {0x_A} {0x_B} \
+ {0x_C} {0x_D} {0x_E} {0x_F} \
+ ]
+ for {set x 1} {$x < 17} {incr x} {
+ grid [label $matrix_frame.hh_lbl$x -text [lindex $header $x] -bg {#FFFFFF}] \
+ -row 0 -column $x -padx [expr {$x % 2}] -sticky wens
+ set hh_cells([expr {$x - 1}]) $matrix_frame.hh_lbl$x
+ }
+ # Create instruction table
+ set address -1
+ for {set y 1} {$y < 17} {incr y} {
+ for {set x 1} {$x < 17} {incr x} {
+ incr address
+
+ # Create cell frame
+ set frame [frame $matrix_frame.cell_$address \
+ -bg white -bd 0 \
+ ]
+
+ # Get instruction OP code in 2-digits uppercase hexadecimal form
+ set opcode [convert_to_opcode $address]
+
+ # Handle undefined OP codes (0xA5)
+ if {[lsearch -ascii -exact ${::CompilerConsts::defined_OPCODE} $opcode] == -1} {
+ destroy $frame
+ continue
+ }
+
+ # Get some information about the instruction
+ set def $::CompilerConsts::Opcode($opcode)
+ set instruction [string toupper [lindex $def 0]]
+ set operands [llength [lindex $def 1]]
+ set length [lindex $def 2]
+ set time [lindex $def 4]
+
+ # Create label containing instruction name
+ pack [label $frame.ins_lbl \
+ -text $instruction \
+ -fg $ins_color \
+ -bg white \
+ -pady 0 \
+ -font $instruction_font \
+ ]
+
+ # Create label widgets for numbers belowe instruction name
+ set f [frame $frame.f]
+ foreach val [list $operands $length $time ] \
+ wdg [list oprs_lbl len_lbl time_lbl ] \
+ fg [list $oprs_color $len_color $time_color ] \
+ {
+ pack [label $frame.$wdg \
+ -text $val \
+ -fg $fg \
+ -bg white \
+ -pady 0 \
+ -font $number_font \
+ ] -side left
+ }
+ pack $f
+
+ grid $frame -row $y -column $x -padx [expr {$x % 2}] -pady [expr {$y % 2}] -sticky wens
+ set cells($address) $frame
+ foreach wdg [list $frame $frame.f $frame.ins_lbl $frame.oprs_lbl $frame.len_lbl $frame.time_lbl] {
+ bind $wdg <Enter> "$this cell_enter $address"
+ bind $wdg <Leave> "$this cell_leave $address"
+ bind $wdg <Button-1> "$this cell_click $address; focus $frame"
+
+ bind $wdg <Button-5> "$scrollable_frame yview scroll +1 units; break"
+ bind $wdg <Button-4> "$scrollable_frame yview scroll -1 units; break"
+ }
+
+ if {$address < 255} {
+ bind $frame <Key-Right> [list $this cell_click [expr {$address + 1}]]
+ }
+ if {$address > 0} {
+ bind $frame <Key-Left> [list $this cell_click [expr {$address - 1}]]
+ }
+ if {$address > 16} {
+ bind $frame <Key-Up> [list $this cell_click [expr {$address - 16}]]
+ }
+ if {$address < 240} {
+ bind $frame <Key-Down> [list $this cell_click [expr {$address + 16}]]
+ }
+ }
+ }
+ # Ensure than all cells have the same width and heigh
+ for {set i 0} {$i < 17} {incr i} {
+ grid columnconfigure $matrix_frame $i -uniform toi
+ }
+ for {set i 1} {$i < 17} {incr i} {
+ grid rowconfigure $matrix_frame $i -uniform toi
+ }
+
+ # Create middle frame (contains details and legend)
+ set middle_frame [frame $win.middle_frame]
+
+ ## Create legend
+ set legend_frame [frame $middle_frame.legend_frame]
+ grid [label $legend_frame.l_h \
+ -font $instruction_font \
+ -text "Legend:" \
+ ] -column 0 -row 0 -columnspan 2 -sticky w
+ # Instruction mnemonics
+ grid [label $legend_frame.l03 \
+ -fg $ins_color \
+ -bg $ins_color \
+ -text {X} \
+ -font $number_font \
+ ] -column 0 -row 1 -sticky w -padx 2
+ grid [label $legend_frame.l13 \
+ -text [mc "Mnemonics"] \
+ -font $number_font \
+ ] -column 1 -row 1 -sticky w
+ # Number of operands
+ grid [label $legend_frame.l00 \
+ -fg $oprs_color \
+ -bg $oprs_color \
+ -text {X} \
+ -font $number_font \
+ ] -column 0 -row 2 -sticky w -padx 2
+ grid [label $legend_frame.l10 \
+ -text [mc "Operands"] \
+ -font $number_font \
+ ] -column 1 -row 2 -sticky w
+ # Length
+ grid [label $legend_frame.l01 \
+ -fg $len_color \
+ -bg $len_color \
+ -text {X} \
+ -font $number_font \
+ ] -column 0 -row 3 -sticky w -padx 2
+ grid [label $legend_frame.l11 \
+ -text [mc "Length"] \
+ -font $number_font \
+ ] -column 1 -row 3 -sticky w
+ # Time
+ grid [label $legend_frame.l02 \
+ -fg $time_color \
+ -bg $time_color \
+ -text {X} \
+ -font $number_font \
+ ] -column 0 -row 4 -sticky w -padx 2
+ grid [label $legend_frame.l12 \
+ -text [mc "Time"] \
+ -font $number_font \
+ ] -column 1 -row 4 -sticky w
+
+ ## Create details frame
+ # Create labelframe
+ set details_frame_header_frm [frame $win.details_frame_header_frm]
+ pack [label $details_frame_header_frm.lbl \
+ -text [mc "OP code (hex): "] \
+ -font $details_n_font \
+ ] -side left
+ set opcode_ent [ttk::entry $details_frame_header_frm.ent \
+ -validatecommand "$this opcode_validator %P" \
+ -width 4 \
+ -validate key \
+ ]
+ pack $opcode_ent -side left
+ set title_v_lbl [label $details_frame_header_frm.title_v_lbl \
+ -fg $ins_color \
+ -font $details_b_font \
+ ]
+ pack $title_v_lbl -side left -padx 15
+ set details_frame [ttk::labelframe $middle_frame.details_frame \
+ -labelwidget $details_frame_header_frm \
+ -padding 5 \
+ ]
+ # Labels: Class & Description
+ grid [label $details_frame.class_l_lbl \
+ -text [mc "Class: "] \
+ -font $details_b_font \
+ ] -row 0 -column 0 -sticky w
+ set class_v_lbl [label $details_frame.class_v_lbl -font $details_n_font]
+ grid $class_v_lbl -row 0 -column 1 -sticky w
+ grid [label $details_frame.desc_l_lbl \
+ -text [mc "Description: "] \
+ -font $details_b_font \
+ ] -row 1 -column 0 -sticky w
+ set desc_v_lbl [label $details_frame.desc_v_lbl -font $details_n_font]
+ grid $desc_v_lbl -row 1 -column 1 -sticky w
+ # Labels: Length & Time
+ grid [label $details_frame.length_l_lbl \
+ -text [mc "Length: "] \
+ -font $details_b_font \
+ ] -row 0 -column 2 -sticky w
+ set length_v_lbl [label $details_frame.length_v_lbl -font $details_n_font]
+ grid $length_v_lbl -row 0 -column 3 -sticky w
+ grid [label $details_frame.time_l_lbl \
+ -text [mc "Time: "] \
+ -font $details_b_font \
+ ] -row 1 -column 2 -sticky w
+ set time_v_lbl [label $details_frame.time_v_lbl -font $details_n_font]
+ grid $time_v_lbl -row 1 -column 3 -sticky w
+ # Label: Note & Flags
+ grid [label $details_frame.note_l_lbl \
+ -text [mc "Note: "] \
+ -font $details_b_font \
+ ] -row 2 -column 0 -sticky w
+ set note_v_lbl [label $details_frame.note_v_lbl -font $details_n_font]
+ grid $note_v_lbl -row 2 -column 1 -sticky w
+ grid [label $details_frame.flags_l_lbl \
+ -text [mc "Flags: "] \
+ -font $details_b_font \
+ ] -row 2 -column 2 -sticky w
+ set flags_v_lbl [label $details_frame.flags_v_lbl -font $number_font -fg {#DD0000}]
+ grid $flags_v_lbl -row 2 -column 3 -sticky w
+ # Configure details frame
+ grid columnconfigure $details_frame 1 -weight 1
+ grid columnconfigure $details_frame 3 -minsize [expr {int(55 * $::font_size_factor)}]
+
+ # Finalize ...
+ pack $scrollable_frame -side left -fill both -expand 1
+ pack $vertical_scrollbar -side right -fill y
+ pack $main_frame -pady 5 -side top -fill both -expand 1
+ pack $details_frame -padx 5 -fill x -side left -expand 1
+ pack $legend_frame -padx 5 -side right -anchor nw
+ pack $middle_frame -fill x
+ pack $bottom_frame -fill x
+ }
+
+ ## Validator for entrybox "OP code"
+ # @parm String string - New entrybox contents
+ # @return Bool - Always 1
+ public method opcode_validator {string} {
+ if {!$validation_ena} {return 1}
+
+ # Handle an empty string
+ if {![string length $string]} {
+ $opcode_ent configure -style TEntry
+ return 1
+ }
+
+ # Check for maximum allowable length
+ if {[string length $string] > 2} {
+ return 0
+ }
+
+ # Normalize the length
+ if {[string length $string] == 1} {
+ set string "0$string"
+ }
+
+ # Check whether the given value is really a hexadecimal number
+ if {![string is xdigit -strict $string]} {
+ $opcode_ent configure -style TblOfIns_RedBg.TEntry
+ return 1
+ }
+
+ # Convert the string to upper case letters and to integer
+ set string [string toupper $string]
+ set address [expr "0x$string"]
+
+ # Check for existence of the given OP code
+ if {[lsearch -ascii -exact ${::CompilerConsts::defined_OPCODE} $string] == -1} {
+ $opcode_ent configure -style TblOfIns_RedBg.TEntry
+ tk_messageBox \
+ -type ok \
+ -icon info \
+ -parent $win \
+ -title [mc "OP code not defined"] \
+ -message [mc "This instruction does not exist on 8051"]
+ return 1
+ }
+
+ # Highlight the cell with the corresponding instruction
+ $opcode_ent configure -style TblOfIns_GreenBg.TEntry
+ select_cell $address
+ if {$selected_cell != -1} {
+ fill_details $address 1
+ }
+ return 1
+ }
+
+ ## Set background color for certain cell in the chart matrix
+ # @parm Int address - Cell address
+ # @parm Color color - New background color
+ # @return void
+ private method sel_bg_color {address color} {
+ set frame $cells($address)
+ foreach wdg [list $frame $frame.f $frame.ins_lbl $frame.oprs_lbl $frame.len_lbl $frame.time_lbl] {
+ $wdg configure -bg $color
+ }
+
+ $hh_cells([expr {$address & 0x0F}]) configure -bg $color
+ $vh_cells([expr {($address & 0xF0) >> 4}]) configure -bg $color
+ }
+
+ ## Handles event when mouse pointer enters certain cell in the chart
+ # @parm Int address - Cell address
+ # @return void
+ public method cell_enter {address} {
+ $status_bar_lbl configure -text {}
+ if {$selected_cell != $address} {
+ sel_bg_color $address {#DDFFDD}
+ }
+
+ set def $::CompilerConsts::Opcode([convert_to_opcode $address])
+ $status_bar_lbl configure -text "[string toupper [lindex $def 0]] [join [lindex $def 1] {, }]"
+ }
+
+ ## Handles event when mouse pointer leaves certain cell in the chart
+ # @parm Int address - Cell address
+ # @return void
+ public method cell_leave {address} {
+ if {$selected_cell == $address} {
+ return
+ }
+ sel_bg_color $address {#FFFFFF}
+ $status_bar_lbl configure -text {}
+
+ if {$selected_cell != -1} {
+ $hh_cells([expr {$selected_cell & 0x0F}]) configure -bg {#BBBBFF}
+ $vh_cells([expr {($selected_cell & 0xF0) >> 4}]) configure -bg {#BBBBFF}
+ }
+ }
+
+ ## Handles event when clicks on certain cell in the chart
+ # @parm Int address - Cell address
+ # @return void
+ public method cell_click {address} {
+ if {$selected_cell == $address} {
+ unselect_current_cell 1 1
+ set selected_cell -1
+ return
+ }
+ if {![winfo exists $matrix_frame.cell_$address]} {
+ return
+ }
+
+ focus $matrix_frame.cell_$address
+ select_cell $address
+ if {$selected_cell != -1} {
+ fill_details $address
+ }
+ }
+
+ ## Select specified cell in the chart (mark as selected and adjust details frame)
+ # @parm Int address - Cell address
+ # @return void
+ private method select_cell {address} {
+ if {$selected_cell != -1} {
+ unselect_current_cell 0 0
+ }
+ set selected_cell $address
+ sel_bg_color $address {#BBBBFF}
+ }
+
+ ## Unselect specified cell in the chart (mark as normal and clear details frame)
+ # @parm Bool keep_current - Mark cell as a cell under mouse pointer (light green bg. color)
+ # @parm Bool affect_entryboxes - Clear entryboxes in details frame
+ # @return void
+ private method unselect_current_cell {keep_current affect_entryboxes} {
+ if {$selected_cell == -1} {
+ return
+ }
+
+ # Set new background color
+ if {$keep_current} {
+ sel_bg_color $selected_cell {#DDFFDD}
+ } else {
+ sel_bg_color $selected_cell {#FFFFFF}
+ }
+
+ # Clear entryboxes in details frame
+ if {$affect_entryboxes} {
+ $title_v_lbl configure -text {}
+ $class_v_lbl configure -text {}
+ $desc_v_lbl configure -text {}
+ $length_v_lbl configure -text {}
+ $time_v_lbl configure -text {}
+ $flags_v_lbl configure -text {}
+ $note_v_lbl configure -text {}
+
+ set validation_ena 0
+ $opcode_ent delete 0 end
+ $opcode_ent configure -style TEntry
+ set validation_ena 1
+ }
+ }
+
+ ## Get instruction OP code in 2-digits uppercase hexadecimal form
+ # @parm Int int_address - OP code in decimal form
+ # @return String - 2-digits uppercase hexadecimal number (e.g. ``B9'')
+ private method convert_to_opcode {int_address} {
+ set opcode [format %X $int_address]
+ if {[string length $opcode] == 1} {
+ set opcode "0$opcode"
+ }
+ return $opcode
+ }
+
+ ## Fill the details about the instruction
+ # @parm Int address - Integer representation of the instruction OP code
+ # @parm Bool exclude_opcode - Do not affect the entry box with OP code
+ # @return void
+ public method fill_details {address {exclude_opcode 0}} {
+ $scrollable_frame see $matrix_frame.cell_$address
+
+ ## Obtain detailed informations about the instruction
+
+ set opcode [convert_to_opcode $address]
+ set def $::CompilerConsts::Opcode($opcode)
+
+ set instruction [lindex $def 0] ;# Instruction name
+ set operands [lindex $def 1] ;# Oprand types
+ set length [lindex $def 2] ;# Instruction length
+ set time [lindex $def 4] ;# Time
+
+ set operands_tmp [list]
+ foreach operand $operands {
+ switch -glob -nocase -- $operand {
+ a -
+ c -
+ ab -
+ @dptr -
+ @a+dptr -
+ @a+pc -
+ dptr {
+ set operand [string toupper $operand]
+ }
+ r? {
+ set operand {Rn}
+ }
+ @r? {
+ set operand {@Ri}
+ }
+ imm8 {
+ set operand {#data}
+ }
+ imm16 {
+ set operand {#data16}
+ }
+ code8 {
+ set operand {rel}
+ }
+ code11 {
+ set operand {addr11}
+ }
+ code16 {
+ set operand {addr16}
+ }
+ bit {
+ set operand {bit}
+ }
+ /bit {
+ set operand {/bit}
+ }
+ data {
+ set operand {direct}
+ }
+ }
+ lappend operands_tmp $operand
+ }
+
+ set operands [join $operands_tmp {, }]
+ set instruction [string toupper $instruction]
+ set title "$instruction\t$operands"
+
+ set idx [lsearch -ascii -exact ${::InstructionDetails::INSTRUCTION_DESCRIPTION} $title]
+ if {$idx == -1} {
+ set ins_class {}
+ set ins_desc {}
+ set ins_note {}
+ set flags {}
+ } else {
+ incr idx
+ set def [lindex ${::InstructionDetails::INSTRUCTION_DESCRIPTION} $idx]
+ set ins_desc [lindex $def 0]
+ set ins_class [lindex $def 1]
+ set ins_note [lindex $def 2]
+ set flags {}
+
+ foreach i {0 1 2} f {C OV AC} {
+ if {[string length [lindex $def [list 3 $i]]]} {
+ lappend flags $f
+ }
+ }
+ }
+
+ if {!$exclude_opcode} {
+ $opcode_ent delete 0 end
+ $opcode_ent insert 0 $opcode
+ }
+
+ $title_v_lbl configure -text $title
+ $class_v_lbl configure -text [namespace eval ::InstructionDetails "mc {$ins_class}"]
+ $desc_v_lbl configure -text [namespace eval ::InstructionDetails "mc {$ins_desc}"]
+ $length_v_lbl configure -text $length
+ $time_v_lbl configure -text $time
+ $flags_v_lbl configure -text [join $flags {, }]
+ $note_v_lbl configure -text [namespace eval ::InstructionDetails "mc {$ins_note}"]
+ }
+}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard