summaryrefslogtreecommitdiff
path: root/lib/main.tcl
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
committerAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
commit47aa8b00b2b11df13a100489e0f904a4947177ef (patch)
treeb35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib/main.tcl
parent5b8466f7fae0e071c0f4eda13051c93313910028 (diff)
Import Upstream version 1.4.7
Diffstat (limited to 'lib/main.tcl')
-rwxr-xr-xlib/main.tcl390
1 files changed, 292 insertions, 98 deletions
diff --git a/lib/main.tcl b/lib/main.tcl
index 6a0f033..115d9a8 100755
--- a/lib/main.tcl
+++ b/lib/main.tcl
@@ -1,8 +1,11 @@
-#!/usr/bin/tclsh
+#!/bin/sh
+# the next line restarts using wish \
+exec tclsh "$0" "$@"
+
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2007-2009 by Martin Ošmera #
+# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
# This program is free software; you can redistribute it and#or modify #
@@ -21,6 +24,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _MAIN_TCL ] } {
+set _MAIN_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -29,15 +37,18 @@
# GENERAL CONSTANTS
# -----------------------------
+set DEBUG 0 ;# Turn on debugging
encoding system {utf-8} ;# System encoding
set LIB_DIRNAME [file normalize [file dirname $argv0]] ;# Path to directory where the *.tcl file are located
-set VERSION "1.3.7" ;# Program version
-set SHORTNAME "MCU8051IDE" ;# Program short name (without white space)
-set APPNAME "MCU 8051 IDE v$VERSION" ;# Full program name
-set MIN_TCL_VER "8.5" ;# Minimum required Tcl version
+set INSTALLATION_DIR [file normalize "$LIB_DIRNAME/.."] ;# Path to the main executable (this file)
+set ROOT_DIRNAME [file normalize "$LIB_DIRNAME/.."] ;# On Linux it's the same as INSTALLATION_DIR, but it's different on MS Windows
+set VERSION "1.4.7" ;# Version of this IDE
+set SHORTNAME "MCU8051IDE" ;# Program short name (without white space)
+set APPNAME "MCU 8051 IDE v$VERSION" ;# Full program name
+set MIN_TCL_VER "8.5" ;# Minimum required Tcl version
set APPLICATION_LOADED 0 ;# True if program is loaded
set TRANSLATION_LOADED 0 ;# Bool: Translation loaded
-set MICROSOFT_WINDOWS {} ;# Bool: Windows OS running on the host computer
+set MICROSOFT_WINDOWS 0 ;# Bool: Windows OS running on the host computer
set CONFIG_DIR {} ;# Directory containing configuration files
# Check for correct Tcl version
@@ -48,25 +59,38 @@ if {[package vcompare $::tcl_version $::MIN_TCL_VER] < 0} {
exit 1
}
-## Tcl packages used by this prgram
+# Make sure that there is "ttk::spinbox" even when Tk version is lower than 8.5.9
+namespace eval ttk {
+ proc spinbox {args} {
+ eval "set result \[::spinbox $args\]"
+ return $result
+ }
+}
+
+## Tcl packages used by this software
# Format: {
# {pkg_name pkg_verison}
# ...
# }
set LIBRARIES_TO_LOAD {
- {BWidget 1.7}
+ {BWidget 1.8}
{Itcl 3.4}
- {Tcl 8.2}
{md5 2.0}
{Tk 8.5}
{img::png 1.3}
{tdom 0.8}
{Tclx 8.0}
+ {Tcl 8.2}
}
## Bool:
- # 1 == library TclX is avaliable
- # 0 == library TclX is NOT avaliable
+ # 1 == Normal GUI operation
+ # 0 == Program GUI suppressed
+set ::GUI_AVAILABLE 1
+
+## Bool:
+ # 1 == library TclX is available
+ # 0 == library TclX is NOT available
#
# TclX is used here only to handle signals (e.g. SIGINT), so the IDE can run
# without it, that's the reason for this variable. If TCLX_AVAILABLE is 0 then
@@ -77,15 +101,26 @@ set ::TCLX_AVAILABLE 1
set ::MICROSOFT_WINDOWS 0
if {[string first {Windows} ${tcl_platform(os)}] != -1} {
# Note:
- # Microsoft Windows is NOT a POSIX system and because of that we need
- # to do some workarounds here in order to make the IDE functional there.
+ # Microsoft Windows is NOT a POSIX system, and because of that, we need
+ # to do some workarounds here in order to make the IDE functional.
set ::MICROSOFT_WINDOWS 1
+
+ set LIB_DIRNAME_SPECIFIC_FOR_MS_WINDOWS "<AIPCS:LIB_DIRNAME_SPECIFIC_FOR_MS_WINDOWS>" ;# <-- The auto. inst. pkg. creation script will fill this in
+ set AUTO_PATH_FOR_MS_WINDOWS "<AIPCS:AUTO_PATH_FOR_MS_WINDOWS>" ;# <-- The auto. inst. pkg. creation script will fill this in
+ set INSTALLATION_DIR $LIB_DIRNAME
+ set LIB_DIRNAME $LIB_DIRNAME_SPECIFIC_FOR_MS_WINDOWS
+ set ROOT_DIRNAME [regsub {\/\w+\/?$} $LIB_DIRNAME {}]
+
+ foreach dir $AUTO_PATH_FOR_MS_WINDOWS {
+ lappend ::auto_path "${::ROOT_DIRNAME}/${dir}"
+ }
+ set env(ITCL_LIBRARY) "${::ROOT_DIRNAME}/libraries/itcl"
}
# Set directory containing configuration files according to the host OS
if {!$::MICROSOFT_WINDOWS} {
- set CONFIG_DIR [file join $::env(HOME) .[string tolower ${::SHORTNAME}]]
-} {
+ set CONFIG_DIR [file join ${::env(HOME)} .[string tolower ${::SHORTNAME}]]
+} else {
set CONFIG_DIR [file join ${::env(USERPROFILE)} ".[string tolower ${::SHORTNAME}]"]
}
@@ -99,15 +134,21 @@ source "${::LIB_DIRNAME}/cli.tcl"
if {!$::CLI_OPTION(quiet)} {
if {$::CLI_OPTION(nocolor)} {
- puts "WARNING:"
- puts "\tThis program is distributed with ABSOLUTELY NO WARRANTY !"
+ puts "IMPORTANT INFORMATION:"
+ puts "\tThis program is distributed in the hope that it will be useful, but with ABSOLUTELY NO WARRANTY !"
+ puts "\tThis is free software, so you are free to change and redistribute it."
+ puts "\tLicense: GNU General Public License version 2 or later"
puts "\tPlease report bugs at http://mcu8051ide.sf.net"
- puts "\tAuthor: Martin Osmera <martin.osmera@gmail.com>"
- } {
- puts "WARNING:"
- puts "\tThis program is distributed with ABSOLUTELY NO WARRANTY !"
+ puts "Authors:"
+ puts "\tMartin Osmera <martin.osmera@gmail.com>"
+ } else {
+ puts "IMPORTANT INFORMATION :"
+ puts "\tThis program is distributed in the hope that it will be useful, but with \033\[31;1mABSOLUTELY NO WARRANTY !\033\[m"
+ puts "\tThis is free software, so you are free to change and redistribute it."
+ puts "\tLicense: GNU General Public License version 2 or later"
puts "\tPlease report bugs at \033\[34;1mhttp://mcu8051ide.sf.net\033\[m"
- puts "\tAuthor: Martin Osmera \033\[33;1m<martin.osmera@gmail.com>\033\[m"
+ puts "Authors:"
+ puts "\tMartin Osmera \033\[33;1m<martin.osmera@gmail.com>\033\[m"
}
}
@@ -128,13 +169,13 @@ proc libraryLoadFailed {library} {
if {[lsearch {Linux} ${::tcl_platform(os)}] == -1} {
puts stderr "FATAL ERROR: Unsupported operating system. ${::tcl_platform(os)}"
- puts stderr "You can contact author of the project at <martin.osmera@gmail.com> if you want to get you OS supported."
+ puts stderr "You can contact authors of the project at <martin.osmera@gmail.com> if you want to get you OS supported."
exit 1
}
if {[lsearch {x86_64 i386 i486 i586 i686 x86} ${::tcl_platform(machine)}] == -1} {
puts stderr "FATAL ERROR: Unsupported system architecture. ${::tcl_platform(machine)}"
- puts stderr "You can contact author of the project at <martin.osmera@gmail.com> if you want to get you OS supported."
+ puts stderr "You can contact authors of the project at <martin.osmera@gmail.com> if you want to get you OS supported."
exit 1
}
@@ -145,8 +186,8 @@ proc libraryLoadFailed {library} {
puts "\nPlease try to run mcu8051ide with --check-libraries to see what's wrong."
exit 1
- } {
- puts stderr "WORKAROUND SUCCESSFULL ... \n(But don't be much happy about this, it is still serious failure. And please don't forget to comply to developers of your Linux distribution. Missing library is: ${library} version ${library_version})"
+ } else {
+ puts stderr "WORKAROUND SUCCESSFUL ... \n(But don't be much happy about this, it is still serious failure. And please don't forget to comply to developers of your Linux distribution. Missing library is: ${library} version ${library_version})"
return
}
@@ -160,7 +201,7 @@ proc libraryLoadFailed {library} {
# Print error message
if {$::CLI_OPTION(nocolor)} {
puts stderr "\n\nERROR: Unable to load library $library"
- } {
+ } else {
puts stderr "\n\n\033\[31mERROR:\033\[m Unable to load library \033\[32m$library\033\[m"
}
@@ -175,7 +216,7 @@ proc libraryLoadFailed {library} {
# -----------------------------
# Load Tk ToolKit
set T [lindex [time {
- if {[catch {package require img::png 1.3}]} {
+ if {[catch {package require img::png 1.3} e]} {
libraryLoadFailed "img::png"
}
if {[catch {package require Tk $::MIN_TCL_VER} errinfo]} {
@@ -187,50 +228,92 @@ wm withdraw .
update
# Determinate default Fixed font
-set ::DEFAULT_FIXED_FONT {DejaVu Sans Mono}
-if {[lsearch -ascii -exact [font families] {DejaVu Sans Mono}] == -1} {
- set ::DEFAULT_FIXED_FONT {Courier}
+set ::DEFAULT_FIXED_FONT {Courier}
+if {!$::MICROSOFT_WINDOWS} {
+ if {[lsearch -ascii -exact [font families] {DejaVu Sans Mono}] != -1} {
+ set ::DEFAULT_FIXED_FONT {DejaVu Sans Mono}
+ }
}
+# Set default background color
+set ::COMMON_BG_COLOR [. cget -bg]
+
# ------------------------------------------------------------------------------
# Microsoft Windows OS specific code
# ------------------------------------------------------------------------------
if {$::MICROSOFT_WINDOWS} {
# Print windows related warning
puts ""
- puts " THE IDE WAS ORIGINALY DESIGNED FOR POSIX, SO IT IS POSSIBLE THAT SOME"
- puts " FUNCTIONALITY WILL BE LIMITED ON YOUR OS DUE TO ABSENCE OF CERTAIN"
- puts " POSIX FUNCTIONALITY !"
+ puts " THE IDE WAS ORIGINALY WRITTEN FOR POSIX, SO IT IS POSSIBLE THAT SOME"
+ puts " FUNCTIONALITY WILL BE LIMITED ON MS WINDOWS DUE TO ABSENCE OF CERTAIN"
+ puts " POSIX FUNCTIONALITY!"
puts ""
+}
+# ------------------------------------------------------------------------------
- # Redefine the "bind" command, because on Windows binding a callback to
- # event, which does not exist on Windows would cause program crash
- rename bind original_command_bind
- proc microsoft_windows_specific_bind args {
+
+# ------------------------------------------------------------------------------
+# Make key shortcuts independent on Caps Lock.
+# ------------------------------------------------------------------------------
+rename bind original_command_bind
+proc mcu8051ide_bind args {
+ set widget [lindex $args 0]
+ set event_str [lindex $args 1]
+ set command [lindex $args 2]
+
+ if {[llength $args] > 3} {
+ error "Too many arguments to bind command."
+ } elseif {[llength $args] == 2} {
+ return [original_command_bind $widget $event_str]
+ }
+
+ # MS Windows doesn't recognize ISO and XFree86 codes
+ if {$::MICROSOFT_WINDOWS} {
if {
- [string first {ISO_} [lindex $args 1]] != -1 ||
- [string first {XF86_} [lindex $args 1]] != -1
- } {
+ [string first {ISO} $event_str] != -1 ||
+ [string first {XF86} $event_str] != -1
+ } then {
return
}
+ }
+
+ if {
+ [string index $event_str end-2] == {-}
+ &&
+ [string is alpha [string index $event_str end-1]]
+ &&
+ [string index $event_str end] == {>}
+ } then {
+ set letter [string index $event_str end-1]
+ set event_str [string range $event_str 1 end-2]
+ if {[string is upper $letter]} {
+ set event_str "Shift-${event_str}"
+ }
- eval "original_command_bind $args"
+ original_command_bind $widget "<${event_str}[string toupper $letter]>" $command
+ original_command_bind $widget "<${event_str}[string tolower $letter]>" $command
+ } else {
+ original_command_bind $widget $event_str $command
}
- rename microsoft_windows_specific_bind bind
}
+rename mcu8051ide_bind bind
# ------------------------------------------------------------------------------
-
# Load base config file
# -----------------------------
+# Initialize variable containing the font size factor
+set font_size_factor 1.0
+
# Load i18n library
# (It must be loaded here because ::msgcat::mclocale must be available when
# base config file is being loaded)
incr T [lindex [time {
if {[catch {package require msgcat 1.3.4}]} {
libraryLoadFailed "msgcat"
- } {
+ } else {
+ namespace import -force ::msgcat::mc
+ namespace import -force ::msgcat::mcset
namespace import -force ::msgcat::*
}
}] 0]
@@ -240,7 +323,7 @@ if {![file exists ${::CONFIG_DIR}]} {
puts "\nCreating program configuration files in directory: \"[file normalize ${::CONFIG_DIR}]\""
if {!$::MICROSOFT_WINDOWS} {
puts "Welcome in this IDE, [file tail [file normalize ~]] !"
- } {
+ } else {
catch { ;# Make the configuration directory in Microsoft Windows hidden
file attributes $::CONFIG_DIR -hidden 1
}
@@ -253,10 +336,16 @@ if {[catch {
# File doesn't exits -> create it with default configuration
}]} then {
# Default settings
+ set detected_lang [string tolower [lindex [split [::msgcat::mclocale] {_}] 0]]
+ if {{} != [lindex [split [::msgcat::mclocale] {_}] 1]} {
+ append detected_lang {_} [string toupper [lindex [split [::msgcat::mclocale] {_}] 1]]
+ }
array set GLOBAL_CONFIG [list \
splash 1 \
tips 1 \
- language [::msgcat::mclocale] \
+ language $detected_lang \
+ background {Default} \
+ wstyle {clam} \
]
# Create the file
@@ -264,11 +353,14 @@ if {[catch {
set conf_file [open "${::CONFIG_DIR}/base.conf" w]
puts -nonewline $conf_file [list \
$GLOBAL_CONFIG(splash) \
- $GLOBAL_CONFIG(splash) \
+ $GLOBAL_CONFIG(tips) \
$GLOBAL_CONFIG(language) \
+ ${::font_size_factor} \
+ $GLOBAL_CONFIG(background) \
+ $GLOBAL_CONFIG(wstyle) \
]
close $conf_file
- }]} {
+ }]} then {
puts stderr "Unable to create base configuration file"
}
# File exits -> read configuration from it
@@ -277,48 +369,89 @@ if {[catch {
set data [read $conf_file]
close $conf_file
- # Set configuration acording to the file contents
+ # Set configuration according to the file contents
set GLOBAL_CONFIG(splash) [lindex $data 0]
set GLOBAL_CONFIG(tips) [lindex $data 1]
set GLOBAL_CONFIG(language) [lindex $data 2]
+ set ::font_size_factor [lindex $data 3]
+ set GLOBAL_CONFIG(background) [lindex $data 4]
+ set GLOBAL_CONFIG(wstyle) [lindex $data 5]
## Validate read values
- if {![string is boolean -strict ${GLOBAL_CONFIG(splash)}]} {
+ if {![regexp {^1\.\d+$} $::font_size_factor] || $::font_size_factor < 1.0 || $::font_size_factor >= 2.0} {
+ set ::font_size_factor 1.0
+ }
+ if {![string is boolean -strict ${::GLOBAL_CONFIG(splash)}]} {
set GLOBAL_CONFIG(splash) 1
}
- if {![string is boolean -strict ${GLOBAL_CONFIG(tips)}]} {
+ if {![string is boolean -strict ${::GLOBAL_CONFIG(tips)}]} {
set GLOBAL_CONFIG(tips) 1
}
+ # This feature is not supported on MS Windows due to BWidget
+ if {!$::MICROSOFT_WINDOWS} {
+ switch -- ${::GLOBAL_CONFIG(background)} {
+ {Default} {set ::COMMON_BG_COLOR {#eeeeee}}
+ {Windows} {set ::COMMON_BG_COLOR {#ece9d9}}
+ {Tk} {}
+ {Light} {set ::COMMON_BG_COLOR {#f8f8f8}}
+ {Dark} {set ::COMMON_BG_COLOR {#cccccc}}
+ default {
+ set ::GLOBAL_CONFIG(background) {Default}
+ set ::COMMON_BG_COLOR {#eeeeee}
+ }
+ }
+ }
+ if {[lsearch -ascii -exact [ttk::style theme names] ${::GLOBAL_CONFIG(wstyle)}] == -1} {
+ set ::GLOBAL_CONFIG(wstyle) {clam}
+ }
# Check if the cpecified translation is valid
set tmp [list]
catch { ;# For Microsoft Windows it has to be enclosed by catch
set tmp [glob -nocomplain -types f -tails \
- -directory "${LIB_DIRNAME}/../translations" *.msg \
+ -directory "${::INSTALLATION_DIR}/translations" *.msg \
]
}
set translations {en}
foreach translation $tmp {
lappend translations [file rootname $translation]
}
+
if {[lsearch $translations ${GLOBAL_CONFIG(language)}] == -1} {
set GLOBAL_CONFIG(language) {en}
}
}
+
# Load translation
# -----------------------------
+# Load list of language names
+set ::LANGUAGE_CODES [list]
+namespace eval ::configDialogues::global {
+ if {[catch {
+ set file [open "${::INSTALLATION_DIR}/translations/languages.txt" r]
+ set languages [read $file]
+ close $file
+
+ regsub -all -line {\s*#.*$} $languages {} languages
+ set ::LANGUAGE_CODES $languages
+ lindex $languages 0
+ } e]} {
+ puts stderr "Error while loading list of laguages: $e"
+ }
+}
+
# Load language specific translation file
if {!${::CLI_OPTION(notranslation)} && ${GLOBAL_CONFIG(language)} != {en}} {
if {[catch {
- mclocale ${GLOBAL_CONFIG(language)}
- mcload "${LIB_DIRNAME}/../translations/"
+ ::msgcat::mclocale ${GLOBAL_CONFIG(language)}
+ incr T [lindex [time {
+ source "${::INSTALLATION_DIR}/translations/${GLOBAL_CONFIG(language)}.msg"
+ }] 0]
} result]} then {
puts stderr "Unable to load translation"
- puts stderr "\tFile: '${LIB_DIRNAME}/../translations/${GLOBAL_CONFIG(language)}.msg'"
- puts "\n"
- puts $result
+ puts stderr "\tFile: '${::INSTALLATION_DIR}/translations/${GLOBAL_CONFIG(language)}.msg'"
} else {
set ::TRANSLATION_LOADED 1
@@ -329,14 +462,24 @@ if {!${::CLI_OPTION(notranslation)} && ${GLOBAL_CONFIG(language)} != {en}} {
# -----------------------------
if {!$::CLI_OPTION(nosplash) && ${::GLOBAL_CONFIG(splash)}} {
+ # Workaround for multiple monitors
+ toplevel .splash_aux
+ wm attributes .splash_aux -fullscreen 1
+ update
+ set sw [winfo width .splash_aux]
+ set sh [winfo height .splash_aux]
+ destroy .splash_aux
+ update
+
# Crete toplevel window
- toplevel .splash -class {Splash creen} -bg {#EEEEEE}
+ toplevel .splash -class {Splash creen} -bg ${::COMMON_BG_COLOR}
# Show image of splash creen
place [label .splash.bg \
+ -bg {#FFFFFF} \
-image [ \
image create photo -format png \
- -file "${::LIB_DIRNAME}/../icons/other/splash.png" \
+ -file "${::ROOT_DIRNAME}/icons/other/splash.png" \
] \
] -x 0 -y 0 -width 400 -height 199
@@ -347,8 +490,9 @@ if {!$::CLI_OPTION(nosplash) && ${::GLOBAL_CONFIG(splash)}} {
] -x 200 -y 180 -anchor center
# Set window parameters
- wm geometry .splash "=400x199+[expr {[winfo screenwidth .] / 2 - 200}]+[expr {[winfo screenheight .] / 2 - 100}]"
+ wm geometry .splash "=400x199+[expr {$sw / 2 - 200}]+[expr {$sh / 2 - 100}]"
wm overrideredirect .splash 1
+ wm attributes .splash -alpha 0.8
# Click on splash creen destroys it
bind .splash <1> {wm withdraw .splash}
@@ -374,7 +518,7 @@ proc time_in_msec {} {
if {!$::CLI_OPTION(quiet)} {
if {$::CLI_OPTION(nocolor)} {
puts "... $msec ms"
- } {
+ } else {
puts "... \033\[33m$msec ms\033\[m"
}
}
@@ -397,7 +541,7 @@ proc showInitMessage {message} {
if {!${::CLI_OPTION(quiet)}} {
if {${::CLI_OPTION(nocolor)}} {
puts -nonewline $message
- } {
+ } else {
puts -nonewline "\033\[37m$message\033\[m"
}
@@ -489,7 +633,7 @@ proc setStatusTip args {
if {!$CLI_OPTION(quiet)} {
if {$CLI_OPTION(nocolor)} {
puts [mc "\nInitializing MCU 8051 IDE %s" $VERSION]
- } {
+ } else {
puts [mc "\nInitializing \033\[1mMCU 8051 IDE \033\[32m%s\033\[m" $VERSION]
}
}
@@ -503,7 +647,7 @@ incr T [lindex [time {
if {[catch {package require [lindex $library 0] [lindex $library 1]}]} {
libraryLoadFailed [lindex $library 0]
# Loading failed
- } {
+ } else {
if {!$::CLI_OPTION(nosplash)} update
}
}
@@ -520,12 +664,14 @@ incr T [lindex [time {
foreach program {
urxvt vim emacs kwrite gedit nano dav
le sdcc indent doxygen asl asem doxywizard
- as31 sdcc-sdcc gvim
- } {
+ as31 sdcc-sdcc gvim hunspell d52
+ make
+ } \
+{
if {[auto_execok $program] == {}} {
- set ::PROGRAM_AVALIABLE($program) 0
- } {
- set ::PROGRAM_AVALIABLE($program) 1
+ set ::PROGRAM_AVAILABLE($program) 0
+ } else {
+ set ::PROGRAM_AVAILABLE($program) 1
}
}
time_in_msec ;# Print time info
@@ -533,18 +679,20 @@ time_in_msec ;# Print time info
## Load program sources
showInitMessage [mc "\tLoading program sources"]
set T [time {
+ source "${::LIB_DIRNAME}/lib/modern_notebook.tcl" ;# NoteBook widget with a modern look (modern in 2011)
+ source "${::LIB_DIRNAME}/lib/FSnotifications.tcl" ;# Filesystem watcher
source "${::LIB_DIRNAME}/lib/innerwindow.tcl" ;# Tool for creating inner windows
- source "${::LIB_DIRNAME}/dialogs/errorhandler.tcl" ;# Background error handler
- source "${::LIB_DIRNAME}/dialogs/my_tk_messageBox.tcl" ;# A replacement for tk_messageBox
+ source "${::LIB_DIRNAME}/dialogues/errorhandler.tcl" ;# Background error handler
+ source "${::LIB_DIRNAME}/dialogues/my_tk_messageBox.tcl";# A replacement for tk_messageBox
source "${::LIB_DIRNAME}/lib/settings.tcl" ;# Settings management
source "${::LIB_DIRNAME}/project.tcl" ;# Project management
- source "${::LIB_DIRNAME}/dialogs/fsd.tcl" ;# File selection dialog
+ source "${::LIB_DIRNAME}/dialogues/fsd.tcl" ;# File selection dialog
source "${::LIB_DIRNAME}/X.tcl" ;# GUI <==> Implementation Interface
- source "${::LIB_DIRNAME}/configdialogs/configdialogs.tcl";# Configuration dialogs
+ source "${::LIB_DIRNAME}/configdialogues/configdialogues.tcl";# Configuration dialogues
source "${::LIB_DIRNAME}/editor/editor.tcl" ;# Source code editor
source "${::LIB_DIRNAME}/lib/Math.tcl" ;# Special mathematical operations
source "${::LIB_DIRNAME}/compiler/compiler.tcl" ;# 8051 Assemly language compiler
- source "${::LIB_DIRNAME}/dialogs/tips.tcl" ;# Tips on startup
+ source "${::LIB_DIRNAME}/dialogues/tips.tcl" ;# Tips on start-up
source "${::LIB_DIRNAME}/lib/hexeditor.tcl" ;# Hexadecimal editor
source "${::LIB_DIRNAME}/utilities/hexeditdlg.tcl" ;# Hexadecimal editor dialog
source "${::LIB_DIRNAME}/environment.tcl" ;# Main window "trappings" (menu and such)
@@ -555,40 +703,47 @@ set T [time {
source "${::LIB_DIRNAME}/maintab.tcl" ;# Central widget
source "${::LIB_DIRNAME}/lib/ihextools.tcl" ;# Tools for manipulating Intel 8 HEX
source "${::LIB_DIRNAME}/utilities/symbol_viewer.tcl" ;# Assembly symbols viewer
- source "${::LIB_DIRNAME}/utilities/eightsegment.tcl" ;# 8-segment LED display editor
+ source "${::LIB_DIRNAME}/utilities/eightsegment.tcl" ;# 8-Segment LED display editor
source "${::LIB_DIRNAME}/utilities/asciichart.tcl" ;# ASCII chart
+ source "${::LIB_DIRNAME}/utilities/table_of_instructions.tcl";# 8051 Instruction Table
source "${::LIB_DIRNAME}/utilities/notes.tcl" ;# Scribble notepad
- source "${::LIB_DIRNAME}/utilities/baseconvertor.tcl" ;# Base convertor
+ source "${::LIB_DIRNAME}/utilities/baseconverter.tcl" ;# Base converter
source "${::LIB_DIRNAME}/utilities/speccalc.tcl" ;# Special calculator for x51 MCU's
source "${::LIB_DIRNAME}/utilities/rs232debugger.tcl" ;# UART/RS232 applications debugger
}]
time_in_msec ;# Print time info
# CHECK FOR VALIDITY OF THE MCU DATABASE
-if {${::X::avaliable_processors} == {}} {
+if {${::X::available_processors} == {}} {
destroy .splash
bell
tk_messageBox \
-icon error \
-type ok \
-title [mc "FATAL ERROR"] \
- -message [mc "MCUs database file is currupted,\nthis program cannot run without it.\nPlease reinstall MCU 8051 IDE."]
+ -message [mc "MCUs database file is corrupted,\nthis program cannot run without it.\nPlease reinstall MCU 8051 IDE."]
exit 1
}
# Load global configuration
loadApplicationConfiguration
+# Start spell checker process and wait until it is started
+::Editor::restart_spellchecker_process
+::Editor::adjust_spell_checker_config_button
+
# Initialize GUI environment
-iconbar_redraw ;# Main toolbar
mainmenu_redraw ;# Main menu
+iconbar_redraw ;# Main toolbar
shortcuts_reevaluate ;# Key shortcuts
## Remove splash screen
-destroy .splash
+if {[winfo exists .splash]} {
+ destroy .splash
+}
if {$CLI_OPTION(minimalized)} {
wm state . iconic
-} {
+} else {
wm deiconify .
}
@@ -596,10 +751,12 @@ if {$CLI_OPTION(minimalized)} {
if {$::TCLX_AVAILABLE} {
proc signal_handler {signal_name} {
global cntrlc_flag
- puts stdout [mc "\nExiting on signal %s" $signal_name]
- if {[catch {::X::__exit 1}]} {
- exit 1
+ puts stderr [mc "\nExiting on signal %s" $signal_name]
+ catch {
+ ::X::__exit 1 1
}
+ puts stderr [mc "\nERROR: Unable to exit the program correctly -- TERMINATING NOW!" $signal_name]
+ exit 1
}
signal trap SIGINT {signal_handler SIGINT}
@@ -608,14 +765,14 @@ if {$::TCLX_AVAILABLE} {
# ---------------------------------------------------------
-# Ugly job ... dirty workarounds and such a shit ... :(
+# Ugly job ... dirty workarounds and such things ... :(
# ---------------------------------------------------------
catch {
NoteBook .foo
proc NoteBook::_getoption {path page option} {
if {$option == {-background}} {
- return {#eeeeee}
+ return ${::COMMON_BG_COLOR}
}
set value [Widget::cget $path.f$page $option]
@@ -630,7 +787,6 @@ catch {
# ---------------------------------------------------------
-
## Open the last session
# Print message
showInitMessage [mc "\tOpening last session"]
@@ -638,6 +794,10 @@ flush stdout
# Evaluate new geometry of the main window
update
evaluate_new_window_geometry
+if {![winfo viewable .mainMenu]} {
+ wm geometry . $::CONFIG(WINDOW_GEOMETRY)
+ update
+}
# Open projects of last session
set T [time {
foreach project_file $::CONFIG(OPENED_PROJECTS) {
@@ -651,12 +811,12 @@ set T [time {
}
}]
-# Reopen base convertors
-foreach cfg $::CONFIG(BASE_CONVERTORS) {
+# Reopen base converters
+foreach cfg $::CONFIG(BASE_CONVERTERS) {
if {[catch {
- set obj [::X::__base_convertor]
+ set obj [::X::__base_converter]
::X::$obj set_config $cfg
- }]} {
+ }]} then {
puts stderr {}
puts stderr $::errorInfo
}
@@ -664,8 +824,36 @@ foreach cfg $::CONFIG(BASE_CONVERTORS) {
time_in_msec ;# Print time info
+# Without this "help windows" won't work properly on MS Windows
+if {$::MICROSOFT_WINDOWS} {
+ if {[wm state .] == {zoomed}} {
+ set ::LATS_KNOWN_WM_STATE_IS_ZOOMED 1
+ } else {
+ set ::LATS_KNOWN_WM_STATE_IS_ZOOMED 0
+ }
+}
# Create binding for panes management
-bind . <Configure> {X::redraw_panes}
+bind . <Configure> {
+ X::redraw_panes
+
+ # Without this "help windows" won't work properly on MS Windows
+ if {$::MICROSOFT_WINDOWS} {
+ if {[wm state .] == {zoomed}} {
+ set now_zoomed 1
+ } else {
+ set now_zoomed 0
+ }
+
+ if {!${::LATS_KNOWN_WM_STATE_IS_ZOOMED} && $now_zoomed} {
+ after idle {
+ update
+ regsub {[\+\-].*$} [wm geometry .] {+0+0} geometry
+ wm geometry . $geometry
+ }
+ }
+ set ::LATS_KNOWN_WM_STATE_IS_ZOOMED $now_zoomed
+ }
+}
# Print final message
if {!$CLI_OPTION(quiet)} {
puts [mc "%s is now operational\n" $APPNAME]
@@ -675,9 +863,11 @@ if {!$CLI_OPTION(quiet)} {
set ::Compiler::in_IDE 1
set APPLICATION_LOADED 1
set X::critical_procedure_in_progress 0
-update idle
+update
X::redraw_panes
+update
foreach project ${::X::openedProjects} {
+ $project bottomNB_redraw_pane
$project filelist_adjust_size_of_tabbar
$project ensure_that_both_editors_are_properly_initialized
}
@@ -689,11 +879,15 @@ if {${::X::actualProject} != {}} {
focus [${::X::actualProject} editor_procedure {} highlight_visible_area {}]
}
-# Just workaround for disapearing main menu
-raise .
-
# Correct strange behavior concerning restoration of the last window size and position
if {$::MICROSOFT_WINDOWS} {
update
wm geometry . $::CONFIG(WINDOW_GEOMETRY)
}
+
+# Initialize file change notifications mechanism
+FSnotifications::init
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard