-
Notifications
You must be signed in to change notification settings - Fork 0
/
projman.tcl
executable file
·134 lines (114 loc) · 3.89 KB
/
projman.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/sh
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@"
######################################################
# Tcl/Tk Project manager 2.0
# Distributed under GNU Public License
# Author: Sergey Kalinin [email protected]
# Home page: https://nuk-svk.ru
######################################################
# Version: 2.0.0
# Release: alpha
# Build: 02092022214055
######################################################
# определим текущую версию, релиз и т.д.
set f [open [info script] "RDONLY"]
while {[gets $f line] >=0} {
if [regexp -nocase -all -- {version:\s+([0-9]+?.[0-9]+?.[0-9]+?)} $line match v1] {
set projman(Version) $v1
}
if [regexp -nocase -all -- {release:\s+([a-z0-9]+?)} $line match v1] {
set projman(Release) $v1
}
if [regexp -nocase -all -- {build:\s+([a-z0-9]+?)} $line match v1] {
set projman(Build) $v1
}
if [regexp -nocase -all -- {author:\s+(.+?)} $line match v1] {
set projman(Author) $v1
}
if [regexp -nocase -all -- {home page:\s+(.+?)} $line match v1] {
set projman(Homepage) $v1
}
}
close $f
if { $::argc > 0 } {
foreach arg $::argv {
lappend opened $arg
}
puts $opened
}
package require msgcat
package require inifile
package require ctext
package require base64
package require fileutil
package require Thread
# Устанавливаем текущий каталог
set dir(root) [pwd]
set dir(doc) [file join $dir(root) doc]
# Устанавливаем рабочий каталог, если его нет то создаём.
# Согласно спецификации XDG проверяем наличие переменных и каталогов
if [info exists env(XDG_CONFIG_HOME)] {
set dir(cfg) [file join $env(XDG_CONFIG_HOME) projman]
} elseif [file exists [file join $env(HOME) .config]] {
set dir(cfg) [file join $env(HOME) .config projman]
} else {
set dir(cfg) [file join $env(HOME) .projman]
}
if {[file exists $dir(cfg)] == 0} {
file mkdir $dir(cfg)
}
# puts "Config dir is $dir(cfg)"
# каталог с модулями
set dir(lib) "[file join $dir(root) lib]"
source [file join $dir(lib) config.tcl]
foreach modFile [lsort [glob -nocomplain [file join $dir(lib) *.tcl]]] {
if {[file tail $modFile] ne "gui.tcl" && [file tail $modFile] ne "config.tcl"} {
source $modFile
puts "Loading module $modFile"
}
}
# TTK Theme loading
set dir(theme) "[file join $dir(root) theme]"
foreach modFile [lsort [glob -nocomplain [file join $dir(theme) *]]] {
if [file isdirectory $modFile] {
source $modFile/[file tail $modFile].tcl
puts "Loading theme $modFile.tcl"
} elseif {[file extension $modFile] eq ".tcl"} {
source $modFile
puts "Loading theme $modFile"
}
}
# загружаем пользовательский конфиг, если он отсутствует, то копируем дефолтный
if {[file exists [file join $dir(cfg) projman.ini]] ==0} {
Config::create $dir(cfg)
}
Config::read $dir(cfg)
::msgcat::mclocale $cfgVariables(locale)
if [::msgcat::mcload [file join $dir(lib) msgs]] {
puts "Load locale messages... OK"
}
puts "Setting the locale... [::msgcat::mclocale]"
source [file join $dir(lib) gui.tcl]
# Open the PATH if command line argument has been setting
if [info exists opened] {
puts $opened
foreach path $opened {
if [file isdirectory $path] {
FileOper::ReadFolder $path
ReadFilesFromDirectory $path $path
# puts "aaa[dict values $project "ansible*"]"
} elseif [file exists $path] {
ResetModifiedFlag [FileOper::Edit $path]
}
}
}
# if [info exists project] {
# foreach f [array names project] {
# puts "--$f"
# puts "----"
# foreach a [split $project($f) " "] {
# puts $variables($a)
# }
# }
#