summaryrefslogtreecommitdiff
path: root/lib/project.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/project.tcl
parent5b8466f7fae0e071c0f4eda13051c93313910028 (diff)
Import Upstream version 1.4.7
Diffstat (limited to 'lib/project.tcl')
-rw-r--r--[-rwxr-xr-x]lib/project.tcl137
1 files changed, 81 insertions, 56 deletions
diff --git a/lib/project.tcl b/lib/project.tcl
index 3c4571b..bdab27a 100755..100644
--- a/lib/project.tcl
+++ b/lib/project.tcl
@@ -2,7 +2,7 @@
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2007-2009 by Martin Ošmera #
+# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
# This program is free software; you can redistribute it and#or modify #
@@ -21,6 +21,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _PROJECT_TCL ] } {
+set _PROJECT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements project files management
@@ -31,7 +36,7 @@ namespace eval Project {
variable xml_data_tk_mcuide_project {} ;# Attributes of <tk_mcuide_project>
variable xml_data_authors {} ;# Content of <authors>
variable xml_data_copyright {} ;# Content of <copyright>
- variable xml_data_licence {} ;# Content of <licence>
+ variable xml_data_license {} ;# Content of <license>
variable xml_data_processor {} ;# Attributes of <processor>
variable xml_data_options {} ;# Attributes of <options>
variable xml_data_graph {} ;# Attributes of <graph>
@@ -50,16 +55,17 @@ namespace eval Project {
variable xml_curTag {} ;# Currenly parsed XML tag
variable xml_start {} ;# Bool: True at start of parsing
variable expect_data_part 1 ;# Bool: True if on the next comes data
- variable xml_warning 0 ;# Bool: True if an error occured during parsing process
-
+ variable xml_warning 0 ;# Bool: True if an error occurred during parsing process
## Create string which can be saved as a project definition file (format: XML)
# @parm List inputData - requested format: {
# {version date creator_ver} # tag: tk_mcuide_project
- # {authors copyright licence} # tag: authors copyright licence
+ # {authors copyright license} # tag: authors copyright license
# {type clock xdata xcode} # tag: processor
# {watches_file scheme main_file auto_sw_enabled} # tag: options
- # {grid_mode magnification drawing_on mark_flags} # tag: graph
+ # {grid_mode magnification drawing_on
+ # mark_flags_true_state mark_flags_latched
+ # mark_flags_output active_page} # tag: graph
# {description todo} # tag: descriptin todo
# {radix angle_unit # tag: calculator
# display0 display1 display2
@@ -78,7 +84,7 @@ namespace eval Project {
# ...
# }
# }
- # @return String - outpud data (formated as XML)
+ # @return String - outpud data (formatted as XML)
proc create_project_file_as_string {inputData} {
# Initialize variables related to content of the file
@@ -87,7 +93,7 @@ namespace eval Project {
# Definition of file structure (except of <files>)
set dataPartStructure {
{version date creator_ver}
- {authors copyright licence}
+ {authors copyright license}
{mcu_type clock xdata xcode}
{watches_file scheme main_file auto_sw_enabled}
{graph_grid_mode graph_magnification graph_drawing_on graph_mark_flags_s graph_mark_flags_l graph_mark_flags_o active_page}
@@ -121,15 +127,16 @@ namespace eval Project {
} else {
foreach var {
version date creator_ver authors copyright
- licence other_options files_count mcu_type xdata
+ license other_options files_count mcu_type xdata
watches_file files description todo calc_radix
angle_unit display0 display1 display2 memory0
memory1 memory2 clock freq time
mode graph_grid_mode graph_magnification graph_drawing_on
- graph_mark_flags_s graph_mark_flags_l graph_mark_flags_o active_page
- xcode scheme graph_mark_flags current_file2
- pwin_sash main_file compiler_options
- } {
+ auto_sw_enabled current_file2 graph_mark_flags_o active_page
+ xcode scheme graph_mark_flags graph_mark_flags_l
+ pwin_sash main_file compiler_options graph_mark_flags_s
+ } \
+ {
set $var {}
}
}
@@ -142,14 +149,14 @@ namespace eval Project {
## Create XML string
append result "<?xml version='1.0' encoding='utf-8'?>\n"
- if {[file exists "${::LIB_DIRNAME}/../data/project.dtd"]} {
+ if {[file exists "${::ROOT_DIRNAME}/data/project.dtd"]} {
if {[catch {
- set dtd [open "${::LIB_DIRNAME}/../data/project.dtd" r]
+ set dtd [open "${::ROOT_DIRNAME}/data/project.dtd" r]
}]} then {
puts stderr "Unable to open project DTD, please check your installation."
} else {
append result "<!DOCTYPE tk_mcuide_project \[\n\n"
- while 1 {
+ while {1} {
if {[eof $dtd]} {
close $dtd
break
@@ -169,7 +176,7 @@ namespace eval Project {
append result "\t\t<authors><!\[CDATA\[[adjust_to_xml $authors]\]\]></authors>\n"
append result "\t\t<copyright><!\[CDATA\["
append result "[adjust_to_xml $copyright]\]\]></copyright>\n"
- append result "\t\t<licence><!\[CDATA\[[adjust_to_xml $licence]\]\]></licence>\n"
+ append result "\t\t<license><!\[CDATA\[[adjust_to_xml $license]\]\]></license>\n"
append result "\t\t<processor type=\"[adjust_to_xml $mcu_type]\" clock=\"[adjust_to_xml $clock]\""
append result " xdata=\"[adjust_to_xml $xdata]\" xcode=\"[adjust_to_xml $xcode]\"/>\n"
append result "\t\t<options\n"
@@ -219,8 +226,9 @@ namespace eval Project {
file_index read_only actual_line md5_hash
path bookmarks breakpoints eol
enc highlight notes
- } {
- set $var $value
+ } \
+ {
+ set $var $value
}
append result "\t\t<file name=\"[adjust_to_xml $name]\" active=\"[adjust_to_xml $active]\" "
append result "o_bookmark=\"$o_bookmark\" p_bookmark=\"$p_bookmark\" "
@@ -238,7 +246,7 @@ namespace eval Project {
append result "\t\t</file>\n\n"
}
append result "\t</files>\n"
- append result "</tk_mcuide_project>"
+ append result "</tk_mcuide_project>\n"
# Return resulting XML String
return $result
@@ -258,7 +266,7 @@ namespace eval Project {
set projectFile [open $filename r]
set dataList [create_list_from_project_string [read $projectFile]]
close $projectFile
- }]} {
+ }]} then {
return 0
}
@@ -276,12 +284,12 @@ namespace eval Project {
$projectDescriptor {_} projectDescriptor
# Take care of opening multiple instances of the same project
- if {[lsearch ${X::openedProjects} $projectDescriptor] != -1} {
+ if {[lsearch ${::X::openedProjects} $projectDescriptor] != -1} {
append project_new_name "(0)"
append projectDescriptor "_0"
- while 1 {
- if {[lsearch ${X::openedProjects} $projectDescriptor] == -1} {break}
+ while {1} {
+ if {[lsearch ${::X::openedProjects} $projectDescriptor] == -1} {break}
regexp {\d+$} $projectDescriptor index
regsub {_\d+$} $projectDescriptor {} projectDescriptor
@@ -297,7 +305,7 @@ namespace eval Project {
}
# Show project notebook
- if {${X::project_menu_locked}} {
+ if {${::X::project_menu_locked}} {
pack .mainFrame.mainNB -expand 1 -fill both
}
@@ -308,7 +316,7 @@ namespace eval Project {
MainTab ::$projectDescriptor $project_new_name $projectPath $projectFileName $dataList
# Unlock all menu items
- if {${X::project_menu_locked}} {
+ if {${::X::project_menu_locked}} {
::X::Unlock_project_menu
}
::X::disaena_menu_toolbar_for_current_project
@@ -324,7 +332,7 @@ namespace eval Project {
variable xml_data_tk_mcuide_project ;# Attributes of <tk_mcuide_project>
variable xml_data_authors ;# Content of <authors>
variable xml_data_copyright ;# Content of <copyright>
- variable xml_data_licence ;# Content of <licence>
+ variable xml_data_license ;# Content of <license>
variable xml_data_processor ;# Attributes of <processor>
variable xml_data_options ;# Attributes of <options>
variable xml_data_graph ;# Attributes of <graph>
@@ -339,7 +347,7 @@ namespace eval Project {
variable xml_expect ;# XML tag expected to be the next
variable xml_curTag ;# Currenly parsed XML tag
variable xml_data_file ;# Auxiliary variable for xml_data_files
- variable xml_warning ;# Bool: True if an error occured during parsing process
+ variable xml_warning ;# Bool: True if an error occurred during parsing process
variable xml_start ;# Bool: True at start of parsing
# Setup XML parser
@@ -356,7 +364,7 @@ namespace eval Project {
# Start XML parser
if {[catch {
$parser parse $inputData
- } result]} {
+ } result]} then {
puts stderr "XML parse error: $result"
report_project_loading_error
return {}
@@ -375,7 +383,7 @@ namespace eval Project {
lappend result [list \
[unescape_tags $xml_data_authors ] \
[unescape_tags $xml_data_copyright ] \
- [unescape_tags $xml_data_licence ] \
+ [unescape_tags $xml_data_license ] \
]
lappend result $xml_data_processor
lappend result [unescape_tags $xml_data_options]
@@ -388,7 +396,7 @@ namespace eval Project {
lappend result [unescape_tags $xml_data_other_options ]
lappend result [unescape_curlies [unescape_tags $xml_data_compiler_options]]
- lappend__xml_data_files__xml_data_file ;# Note that this is important function
+ lappend__xml_data_files__xml_data_file ;# Note that this is an important function
lappend result [concat \
$xml_data_files_count \
[unescape_tags $xml_data_files] \
@@ -408,7 +416,7 @@ namespace eval Project {
variable xml_data_tk_mcuide_project ;# Attributes of <tk_mcuide_project>
variable xml_data_authors ;# Content of <authors>
variable xml_data_copyright ;# Content of <copyright>
- variable xml_data_licence ;# Content of <licence>
+ variable xml_data_license ;# Content of <license>
variable xml_data_processor ;# Attributes of <processor>
variable xml_data_options ;# Attributes of <options>
variable xml_data_graph ;# Attributes of <graph>
@@ -428,14 +436,15 @@ namespace eval Project {
# Set all listed variables to empty string
foreach var {
- xml_data_tk_mcuide_project xml_data_authors xml_data_copyright
- xml_data_licence xml_curTag xml_data_processor
- xml_data_options xml_data_description xml_data_todo
- xml_data_files xml_data_calculator xml_data_other_options
- xml_data_files_count xml_data_current_file xml_data_file
- xml_expect xml_data_graph xml_data_compiler_options
- xml_data_file_notes
- } {
+ xml_data_tk_mcuide_project xml_data_authors xml_data_copyright
+ xml_data_license xml_curTag xml_data_processor
+ xml_data_options xml_data_description xml_data_todo
+ xml_data_files xml_data_calculator xml_data_other_options
+ xml_data_files_count xml_data_current_file xml_data_file
+ xml_expect xml_data_graph xml_data_compiler_options
+ xml_data_file_notes
+ } \
+ {
set $var {}
}
}
@@ -443,14 +452,18 @@ namespace eval Project {
## Invoke dialog to report error occcured while parsing data
# @return void
proc report_project_loading_error {} {
- variable xml_warning ;# Bool: True if an error occured during parsing process
+ variable xml_warning ;# Bool: True if an error occurred during parsing process
# Ensure than there is only one error message dialog
if {$xml_warning} {return}
# Invoke dialog
- tk_messageBox -icon error -type ok -title [mc "Project loading error"] \
- -message [mc "ERROR:\nThe project file cannot be loaded correctly due to a xml parsing error. The file is eighter corrupted or it is not a project file acceptable by this environment."]
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -parent . \
+ -title [mc "Project loading error"] \
+ -message [mc "ERROR:\nThe project file cannot be loaded correctly due to a xml parsing error. The file is either corrupted or it is not a project file acceptable by this environment."]
set xml_warning 1
}
@@ -572,12 +585,12 @@ namespace eval Project {
variable xml_curTag ;# Currenly parsed XML tag
variable xml_start ;# Bool: True at start of parsing
variable xml_attlist ;# Auxiliary variable - List of current tag attributes
- variable xml_warning ;# Bool: True if an error occured during parsing process
+ variable xml_warning ;# Bool: True if an error occurred during parsing process
variable xml_data_tk_mcuide_project ;# Attributes of <tk_mcuide_project>
variable xml_data_authors ;# Content of <authors>
variable xml_data_copyright ;# Content of <copyright>
- variable xml_data_licence ;# Content of <licence>
+ variable xml_data_license ;# Content of <license>
variable xml_data_processor ;# Attributes of <processor>
variable xml_data_options ;# Attributes of <options>
variable xml_data_graph ;# Attributes of <graph>
@@ -619,8 +632,8 @@ namespace eval Project {
{copyright} {
set xml_data_copyright $data
}
- {licence} {
- set xml_data_licence $data
+ {license} {
+ set xml_data_license $data
}
{description} {
append xml_data_description $data "\n"
@@ -639,11 +652,15 @@ namespace eval Project {
if {[llength $xml_data_file] == 9} {
lappend xml_data_file {}
}
- regsub -all {[ \t\n\r]+} $data {} data
+ regsub -all {[ \t\n\r]+} $data { } data
+ regsub {^ } $data { } data
+ regsub { $} $data { } data
lappend xml_data_file $data
}
{breakpoints} {
- regsub -all {[ \t\n\r]+} $data {} data
+ regsub -all {[ \t\n\r]+} $data { } data
+ regsub {^ } $data { } data
+ regsub { $} $data { } data
lappend xml_data_file $data
}
{path} {
@@ -665,12 +682,12 @@ namespace eval Project {
variable xml_curTag ;# Currenly parsed XML tag
variable xml_start ;# Bool: True at start of parsing
variable xml_attlist ;# Auxiliary variable - List of current tag attributes
- variable xml_warning ;# Bool: True if an error occured during parsing process
+ variable xml_warning ;# Bool: True if an error occurred during parsing process
variable xml_data_tk_mcuide_project ;# Attributes of <tk_mcuide_project>
variable xml_data_authors ;# Content of <authors>
variable xml_data_copyright ;# Content of <copyright>
- variable xml_data_licence ;# Content of <licence>
+ variable xml_data_license ;# Content of <license>
variable xml_data_processor ;# Attributes of <processor>
variable xml_data_options ;# Attributes of <options>
variable xml_data_graph ;# Attributes of <graph>
@@ -718,10 +735,14 @@ namespace eval Project {
}
{copyright} {
set xml_curTag "copyright"
- project_xml_expect "licence"
+ project_xml_expect "licence license"
+ }
+ {license} {
+ set xml_curTag "license"
+ project_xml_expect "processor"
}
{licence} {
- set xml_curTag "licence"
+ set xml_curTag "license"
project_xml_expect "processor"
}
{processor} {
@@ -848,10 +869,10 @@ namespace eval Project {
}
if {[llength $xml_data_file] == 12} {
- puts stderr [mc "Conveting old project file to new version"]
+ puts stderr [mc "Converting old project file to new version"]
- # eol enc
- lappend xml_data_file {} {}
+ # eol enc
+ lappend xml_data_file {} {}
}
# Move attribute "highlight" from index 6 to 13
@@ -866,3 +887,7 @@ namespace eval Project {
lappend xml_data_files $xml_data_file
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard