From f9dbdf893df9c160ebc227e0badc719ad870e8fd Mon Sep 17 00:00:00 2001 From: svk Date: Thu, 22 Jan 2026 16:55:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80?= =?UTF-8?q?=D1=8B=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D0=B8=D1=87=D0=B8=D1=8F=20=D0=BF=D0=B0=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D0=B8,=20?= =?UTF-8?q?=D0=B8=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D1=8E?= =?UTF-8?q?=20=D0=B2=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B5=20=D0=B8=D1=85?= =?UTF-8?q?=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B2=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B5=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D0=B8.=20?= =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=8F=20=D1=81=D0=B5=D0=BA=D1=86=D1=8F=20?= =?UTF-8?q?=D0=B8=20=D0=B4=D0=B2=D0=B0=20=D0=BD=D0=BE=D0=B2=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=BC=D0=B5=D1=82=D1=80=D0=B0=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3,=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=BE=D1=82=D0=BB=D0=B0?= =?UTF-8?q?=D0=B4=D0=BE=D1=87=D0=BD=D0=BE=D0=B9=20=D0=B8=D0=BD=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/config.tcl | 47 +++++++++++++++++++++++++++++++++++++++++++++++ lib/procedure.tcl | 11 +++++++++++ projman.tcl | 1 + 3 files changed, 59 insertions(+) diff --git a/lib/config.tcl b/lib/config.tcl index 4d8a42b..c4d0760 100644 --- a/lib/config.tcl +++ b/lib/config.tcl @@ -75,6 +75,9 @@ RB=ruby HTM=firefox HTML=firefox LUA=lua +\[Debug\] +debug=false +debugOut=stdout " proc Config::create {dir} { set cfgFile [open [file join $dir projman.ini] "w+"] @@ -131,3 +134,47 @@ proc Config::write {dir} { ini::commit $cfgFile ini::close $cfgFile } + +# Добавление перменной в список +# если отсутствует нужная секция то она будет добавлена. +proc Config::AddVariable {key value section} { + # Проверяем, существует ли уже такая переменная + if {[info exists ::cfgVariables($key)]} { + DebugPuts "The variable '$key' already exists: $::cfgVariables($key)" + return 0 + } + + # Добавляем в массив переменных + set ::cfgVariables($key) $value + + # Добавляем в список ключей секции + if {[info exists ::cfgINIsections($section)]} { + # Проверяем, нет ли уже такого ключа в секции + if {[lsearch -exact $::cfgINIsections($section) $key] == -1} { + lappend ::cfgINIsections($section) $key + } + } else { + set ::cfgINIsections($section) [list $key] + } + DebugPuts "Config::AddVariable: The variable '$key' has been added to the array 'cfgVariables'" + + return 1 +} + +# Проверяем наличие переменных в конфиге на основе "эталонного" списка +# и выставляем значение по умолчанию если в конфиге переменной нет +proc Config::CheckVariables {} { + set valList [split $::configDefault "\n"] + foreach item $valList { + if {[regexp -nocase -all -- {\[(\w+)\]} $item -> v1]} { + set section $v1 + } + if {[regexp {^([^=]+)=(.*)$} $item -> var value]} { + if ![info exists ::cfgVariables($var)] { + DebugPuts "Error in Config::CheckVariables: variable ::cfgVariables($var) not found" + Config::AddVariable "$var" "$value" "$section" + DebugPuts "Config::CheckVariables: The variable cfgVariables($var) setting to default value \"$value\"" + } + } + } +} diff --git a/lib/procedure.tcl b/lib/procedure.tcl index ee4c018..09e0828 100644 --- a/lib/procedure.tcl +++ b/lib/procedure.tcl @@ -1155,3 +1155,14 @@ proc Paste {} { SendEventToLatestTxtWidget <> } proc Undo {} { SendEventToLatestTxtWidget <> } proc Redo {} { SendEventToLatestTxtWidget <> } # ------------ + +proc DebugPuts {msg} { + global cfgVariables debugFlag + if ![info exists cfgVariables(debugFlag)] { + set cfgVariables(debugFlag) "true" + } + if {$cfgVariables(debugFlag) eq "true"} { + puts "$msg" + } +} + diff --git a/projman.tcl b/projman.tcl index babe817..f8cbf79 100755 --- a/projman.tcl +++ b/projman.tcl @@ -119,6 +119,7 @@ if {[file exists [file join $dir(cfg) projman.ini]] ==0} { Config::create $dir(cfg) } Config::read $dir(cfg) +Config::CheckVariables ::msgcat::mclocale $cfgVariables(locale)