2018-02-13 13:23:40 +03:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
# Tcl ignores the next line -*- tcl -*- \
|
|
|
|
|
exec wish "$0" -- "$@"
|
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
######################################################
|
|
|
|
|
# Tcl/Tk Project manager 2.0
|
|
|
|
|
# Distributed under GNU Public License
|
2022-08-12 15:22:07 +03:00
|
|
|
|
# Author: Sergey Kalinin svk@nuk-svk.ru
|
2022-07-21 10:56:46 +03:00
|
|
|
|
# Home page: https://nuk-svk.ru
|
|
|
|
|
######################################################
|
|
|
|
|
# Version: 2.0.0
|
|
|
|
|
# Release: alpha
|
2022-12-08 15:31:31 +03:00
|
|
|
|
# Build: 08122022143741
|
2022-07-21 10:56:46 +03:00
|
|
|
|
######################################################
|
|
|
|
|
|
2022-08-12 15:22:07 +03:00
|
|
|
|
# определим текущую версию, релиз и т.д.
|
2022-07-21 10:56:46 +03:00
|
|
|
|
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] {
|
2022-08-12 15:22:07 +03:00
|
|
|
|
set projman(Version) $v1
|
2015-10-19 13:27:31 +03:00
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
if [regexp -nocase -all -- {release:\s+([a-z0-9]+?)} $line match v1] {
|
2022-08-12 15:22:07 +03:00
|
|
|
|
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
|
2015-10-19 13:27:31 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
close $f
|
2015-10-19 13:27:31 +03:00
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
if { $::argc > 0 } {
|
|
|
|
|
foreach arg $::argv {
|
|
|
|
|
lappend opened $arg
|
2018-03-06 12:55:04 +03:00
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
puts $opened
|
2018-03-06 12:55:04 +03:00
|
|
|
|
}
|
2022-08-01 16:24:42 +03:00
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
package require msgcat
|
|
|
|
|
package require inifile
|
|
|
|
|
package require ctext
|
2022-08-01 16:24:42 +03:00
|
|
|
|
package require base64
|
2022-08-12 15:22:07 +03:00
|
|
|
|
package require fileutil
|
|
|
|
|
package require Thread
|
2022-11-10 14:53:58 +03:00
|
|
|
|
package require fileutil::magic::filetype
|
2018-03-06 12:55:04 +03:00
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
# Устанавливаем текущий каталог
|
2022-07-21 16:00:05 +03:00
|
|
|
|
set dir(root) [pwd]
|
2022-07-21 10:56:46 +03:00
|
|
|
|
set dir(doc) [file join $dir(root) doc]
|
2015-10-19 13:27:31 +03:00
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
# Устанавливаем рабочий каталог, если его нет то создаём.
|
|
|
|
|
# Согласно спецификации 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]
|
2015-10-19 13:27:31 +03:00
|
|
|
|
} else {
|
2022-07-21 10:56:46 +03:00
|
|
|
|
set dir(cfg) [file join $env(HOME) .projman]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if {[file exists $dir(cfg)] == 0} {
|
2022-08-17 16:52:22 +03:00
|
|
|
|
file mkdir $dir(cfg)
|
2015-10-19 13:27:31 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-12 15:22:07 +03:00
|
|
|
|
# puts "Config dir is $dir(cfg)"
|
2022-07-21 10:56:46 +03:00
|
|
|
|
|
|
|
|
|
# каталог с модулями
|
2022-07-21 13:09:09 +03:00
|
|
|
|
set dir(lib) "[file join $dir(root) lib]"
|
2015-10-19 13:27:31 +03:00
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
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"} {
|
2018-02-05 11:24:14 +03:00
|
|
|
|
source $modFile
|
2022-07-21 10:56:46 +03:00
|
|
|
|
puts "Loading module $modFile"
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
}
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
2015-10-19 13:27:31 +03:00
|
|
|
|
|
2018-07-05 08:41:18 +03:00
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
# загружаем пользовательский конфиг, если он отсутствует, то копируем дефолтный
|
|
|
|
|
if {[file exists [file join $dir(cfg) projman.ini]] ==0} {
|
|
|
|
|
Config::create $dir(cfg)
|
2022-08-17 16:52:22 +03:00
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
Config::read $dir(cfg)
|
2018-07-05 08:41:18 +03:00
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
::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] {
|
2022-09-21 14:38:31 +03:00
|
|
|
|
# puts ">$opened"
|
2022-07-21 10:56:46 +03:00
|
|
|
|
foreach path $opened {
|
2022-09-21 14:38:31 +03:00
|
|
|
|
if {[file pathtype $path] ne "absolute"} {
|
|
|
|
|
puts "\n\t[::msgcat::mc "Specify the absolute path to the directory or file"]: $path\n"
|
|
|
|
|
exit
|
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
if [file isdirectory $path] {
|
2022-11-24 13:28:11 +03:00
|
|
|
|
# set activeProject $path
|
|
|
|
|
SetActiveProject $path
|
2022-10-19 09:05:55 +03:00
|
|
|
|
.frmStatus.lblGitLogo configure -image git_logo_20x20
|
|
|
|
|
.frmStatus.lblGit configure -text "[::msgcat::mc "Branch"]: [Git::Branches current]"
|
2022-07-21 10:56:46 +03:00
|
|
|
|
FileOper::ReadFolder $path
|
2022-09-02 17:01:53 +03:00
|
|
|
|
ReadFilesFromDirectory $path $path
|
2022-07-21 10:56:46 +03:00
|
|
|
|
} elseif [file exists $path] {
|
2022-12-07 14:27:08 +03:00
|
|
|
|
# ResetModifiedFlag [FileOper::Edit $path]
|
|
|
|
|
FileOper::Edit $path
|
2022-07-21 10:56:46 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-15 16:51:11 +03:00
|
|
|
|
} else {
|
|
|
|
|
if {$cfgVariables(opened) ne ""} {
|
2022-09-21 14:38:31 +03:00
|
|
|
|
# puts "<$cfgVariables(opened)"
|
2022-11-24 13:28:11 +03:00
|
|
|
|
SetActiveProject $cfgVariables(opened)
|
2022-10-19 09:05:55 +03:00
|
|
|
|
.frmStatus.lblGitLogo configure -image git_logo_20x20
|
|
|
|
|
.frmStatus.lblGit configure -text "[::msgcat::mc "Branch"]: [Git::Branches current]"
|
2022-09-15 16:51:11 +03:00
|
|
|
|
FileOper::ReadFolder $cfgVariables(opened)
|
|
|
|
|
ReadFilesFromDirectory $cfgVariables(opened) $cfgVariables(opened)
|
|
|
|
|
if {$cfgVariables(editedFiles) ne ""} {
|
|
|
|
|
foreach f [split $cfgVariables(editedFiles) " "] {
|
2022-09-21 14:38:31 +03:00
|
|
|
|
# puts $f
|
2022-09-15 16:51:11 +03:00
|
|
|
|
FileOper::Edit $f
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
}
|