summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
committerAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
commit47aa8b00b2b11df13a100489e0f904a4947177ef (patch)
treeb35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib
parent5b8466f7fae0e071c0f4eda13051c93313910028 (diff)
Import Upstream version 1.4.7
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}