summaryrefslogtreecommitdiff
path: root/lib/main.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/main.tcl')
-rwxr-xr-xlib/main.tcl67
1 files changed, 51 insertions, 16 deletions
diff --git a/lib/main.tcl b/lib/main.tcl
index 115d9a8..e942c00 100755
--- a/lib/main.tcl
+++ b/lib/main.tcl
@@ -2,12 +2,15 @@
# the next line restarts using wish \
exec tclsh "$0" "$@"
-# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
+# Part of MCU 8051 IDE ( http://http://www.moravia-microsystems.com/mcu8051ide )
############################################################################
# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
+# Copyright (C) 2014 by Moravia Microsystems, s.r.o. #
+# martin.osmera@moravia-microsystems.com #
+# #
# This program is free software; you can redistribute it and#or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
@@ -41,8 +44,8 @@ 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 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 ROOT_DIRNAME [file normalize "$LIB_DIRNAME/.."] ;# On Linux it's the same as INSTALLATION_DIR but it's different on Windows
+set VERSION "1.4.9" ;# 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
@@ -80,9 +83,15 @@ set LIBRARIES_TO_LOAD {
{img::png 1.3}
{tdom 0.8}
{Tclx 8.0}
+ {Signal 1.4}
{Tcl 8.2}
}
+set OPTIONAL_LIBRARIES {
+ Signal
+ Tclx
+}
+
## Bool:
# 1 == Normal GUI operation
# 0 == Program GUI suppressed
@@ -97,6 +106,11 @@ set ::GUI_AVAILABLE 1
# we are not able to handle signals, but everything else works normally.
set ::TCLX_AVAILABLE 1
+## Bool:
+ # 1 == library Signal is available
+ # 0 == library Signal is NOT available
+set ::SIGNAL_AVAILABLE 1
+
## Determinate the host OS
set ::MICROSOFT_WINDOWS 0
if {[string first {Windows} ${tcl_platform(os)}] != -1} {
@@ -140,7 +154,7 @@ if {!$::CLI_OPTION(quiet)} {
puts "\tLicense: GNU General Public License version 2 or later"
puts "\tPlease report bugs at http://mcu8051ide.sf.net"
puts "Authors:"
- puts "\tMartin Osmera <martin.osmera@gmail.com>"
+ puts "\tMartin Osmera <martin.osmera@moravia-microsystems.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"
@@ -148,7 +162,7 @@ if {!$::CLI_OPTION(quiet)} {
puts "\tLicense: GNU General Public License version 2 or later"
puts "\tPlease report bugs at \033\[34;1mhttp://mcu8051ide.sf.net\033\[m"
puts "Authors:"
- puts "\tMartin Osmera \033\[33;1m<martin.osmera@gmail.com>\033\[m"
+ puts "\tMartin Osmera \033\[33;1m<martin.osmera@moravia-microsystems.com>\033\[m"
}
}
@@ -159,12 +173,18 @@ proc libraryLoadFailed {library} {
# Itcl workarond for Debian
if {$library == {Itcl}} {
+ if {[package vcompare $::tcl_version "8.6"] >= 0} {
+ if {![catch {package require Itcl}]} {
+ return
+ }
+ }
+
set library_version "3.4"
set libname "libitcl"
set ::env(ITCL_LIBRARY) ${::LIB_DIRNAME}
- puts stderr "\nERROR: Unable to load Itcl library compatible with this version of Tcl/Tk !"
+ puts stderr "\nERROR: Unable to load Itcl library compatible with this version of Tcl/Tk!"
puts stderr "Trying to workaround ..."
if {[lsearch {Linux} ${::tcl_platform(os)}] == -1} {
@@ -191,10 +211,18 @@ proc libraryLoadFailed {library} {
return
}
- # Tclx workarond for Debian
+ # Tclx workarond for Debian (1/2)
} elseif {$library == {Tclx}} {
set ::TCLX_AVAILABLE 0
- puts stderr "\nERROR: Unable to load Tclx library, functionality will be limited"
+ puts stderr "\nERROR: Unable to load library Tclx, MCU 805 1IDE functionality might be limited."
+ return
+
+ # Tclx workarond for Debian (2/2)
+ } elseif { $library == {Signal} } {
+ set ::SIGNAL_AVAILABLE 0
+ if {!$::TCLX_AVAILABLE} {
+ puts stderr "\nERROR: Unable to load library Signal, MCU 805 1IDE functionality might be limited."
+ }
return
}
@@ -748,7 +776,7 @@ if {$CLI_OPTION(minimalized)} {
}
# Configure signal handling
-if {$::TCLX_AVAILABLE} {
+if {$::TCLX_AVAILABLE || $::SIGNAL_AVAILABLE} {
proc signal_handler {signal_name} {
global cntrlc_flag
puts stderr [mc "\nExiting on signal %s" $signal_name]
@@ -759,8 +787,13 @@ if {$::TCLX_AVAILABLE} {
exit 1
}
- signal trap SIGINT {signal_handler SIGINT}
- signal trap SIGTERM {signal_handler SIGTERM}
+ if {$::TCLX_AVAILABLE} {
+ signal trap SIGINT {signal_handler SIGINT}
+ signal trap SIGTERM {signal_handler SIGTERM}
+ } else {
+ signal add SIGINT {signal_handler SIGINT}
+ signal add SIGTERM {signal_handler SIGTERM}
+ }
}
@@ -775,12 +808,14 @@ catch {
return ${::COMMON_BG_COLOR}
}
- set value [Widget::cget $path.f$page $option]
- if {![string length $value]} {
- set value [Widget::cget $path $option]
- }
+ catch {
+ set value [Widget::cget $path.f$page $option]
+ if {![string length $value]} {
+ set value [Widget::cget $path $option]
+ }
- return $value
+ return $value
+ }
}
destroy .foo
}