2022-07-21 10:56:46 +03:00
|
|
|
|
######################################################
|
|
|
|
|
# ProjMan 2
|
|
|
|
|
# Distributed under GNU Public License
|
|
|
|
|
# Author: Sergey Kalinin svk@nuk-svk.ru
|
|
|
|
|
# Copyright (c) "", 2022, https://nuk-svk.ru
|
|
|
|
|
######################################################
|
|
|
|
|
#
|
|
|
|
|
# All procedures module
|
|
|
|
|
#
|
|
|
|
|
######################################################
|
2018-02-05 11:24:14 +03:00
|
|
|
|
|
|
|
|
|
proc Quit {} {
|
2022-07-21 10:56:46 +03:00
|
|
|
|
global dir
|
|
|
|
|
Config::write $dir(cfg)
|
2022-07-21 16:01:28 +03:00
|
|
|
|
if {[FileOper::CloseAll] eq "cancel"} {
|
|
|
|
|
return "cancel"
|
|
|
|
|
} else {
|
|
|
|
|
exit
|
|
|
|
|
}
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
proc ViewFilesTree {} {
|
|
|
|
|
global cfgVariables
|
2022-08-17 16:52:22 +03:00
|
|
|
|
if {$cfgVariables(filesPanelShow) eq "true"} {
|
2022-07-21 10:56:46 +03:00
|
|
|
|
.frmBody.panel forget .frmBody.frmTree
|
2022-08-17 16:52:22 +03:00
|
|
|
|
set cfgVariables(filesPanelShow) false
|
2018-02-05 11:24:14 +03:00
|
|
|
|
} else {
|
2022-08-17 16:52:22 +03:00
|
|
|
|
switch $cfgVariables(filesPanelPlace) {
|
|
|
|
|
"left" {
|
|
|
|
|
.frmBody.panel insert 0 .frmBody.frmTree
|
|
|
|
|
}
|
|
|
|
|
"right" {
|
|
|
|
|
.frmBody.panel add .frmBody.frmTree
|
|
|
|
|
}
|
|
|
|
|
default {
|
|
|
|
|
.frmBody.panel insert 0 .frmBody.frmTree
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set cfgVariables(filesPanelShow) true
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
# Enable/Disabled line numbers in editor
|
|
|
|
|
proc ViewLineNumbers {} {
|
|
|
|
|
global cfgVariables nbEditor
|
|
|
|
|
# Changed global settigs
|
|
|
|
|
if {$cfgVariables(lineNumberShow) eq "true"} {
|
|
|
|
|
set cfgVariables(lineNumberShow) false
|
|
|
|
|
} else {
|
|
|
|
|
set cfgVariables(lineNumberShow) true
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
# apply changes for opened tabs
|
|
|
|
|
foreach node [$nbEditor tabs] {
|
|
|
|
|
$node.frmText.t configure -linemap $cfgVariables(lineNumberShow)
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
proc Del {} {
|
|
|
|
|
return
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
proc YScrollCommand {txt canv} {
|
|
|
|
|
$txt yview
|
|
|
|
|
$canv yview"
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-21 10:56:46 +03:00
|
|
|
|
proc ResetModifiedFlag {w} {
|
|
|
|
|
global modified nbEditor
|
|
|
|
|
$w.frmText.t edit modified false
|
|
|
|
|
set modified($w) "false"
|
|
|
|
|
set lbl [string trimleft [$nbEditor tab $w -text] "* "]
|
|
|
|
|
puts "ResetModifiedFlag: $lbl"
|
|
|
|
|
$nbEditor tab $w -text $lbl
|
2018-02-05 11:24:14 +03:00
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
proc SetModifiedFlag {w} {
|
|
|
|
|
global modified nbEditor
|
|
|
|
|
#$w.frmText.t edit modified false
|
|
|
|
|
set modified($w) "true"
|
|
|
|
|
set lbl [$nbEditor tab $w -text]
|
|
|
|
|
puts "SetModifiedFlag: $w; $modified($w); >$lbl<"
|
|
|
|
|
if {[regexp -nocase -all -- {^\*} $lbl match] == 0} {
|
|
|
|
|
set lbl "* $lbl"
|
2022-07-21 10:37:19 +03:00
|
|
|
|
}
|
2022-07-21 10:56:46 +03:00
|
|
|
|
$nbEditor tab $w -text $lbl
|
2022-07-21 10:37:19 +03:00
|
|
|
|
}
|
2022-08-01 16:24:42 +03:00
|
|
|
|
|
|
|
|
|
proc ImageBase64Encode {} {
|
|
|
|
|
global env nbEditor
|
|
|
|
|
set types {
|
|
|
|
|
{"PNG" {.png}}
|
|
|
|
|
{"GIF" {.gif}}
|
|
|
|
|
{"JPEG" {.jpg}}
|
|
|
|
|
{"BMP" {.bmp}}
|
|
|
|
|
{"All files" *}
|
|
|
|
|
}
|
|
|
|
|
set txt "[$nbEditor select].frmText.t"
|
|
|
|
|
set img [tk_getOpenFile -initialdir $env(HOME) -filetypes $types -parent .]
|
|
|
|
|
if {$img ne ""} {
|
|
|
|
|
set f [open $img]
|
|
|
|
|
fconfigure $f -translation binary
|
|
|
|
|
set data [base64::encode [read $f]]
|
|
|
|
|
close $f
|
|
|
|
|
# base name on root name of the image file
|
|
|
|
|
set name [file root [file tail $img]]
|
|
|
|
|
$txt insert insert "image create photo $name -data {\n$data\n}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
proc FindImage {ext} {
|
|
|
|
|
foreach img [image names] {
|
|
|
|
|
if [regexp -nocase -all -- "^($ext)(_)" $img match v1 v2] {
|
2022-08-03 12:21:28 +03:00
|
|
|
|
# puts "\nFindinig images: $img \n"
|
2022-08-01 16:24:42 +03:00
|
|
|
|
return $img
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-12 15:19:57 +03:00
|
|
|
|
namespace eval Help {
|
|
|
|
|
proc About {} {
|
|
|
|
|
global projman
|
|
|
|
|
set msg "Tcl/Tk project Manager\n\n"
|
|
|
|
|
append msg "Version: " $projman(Version) "\n" \
|
|
|
|
|
"Release: " $projman(Release) "\n" \
|
|
|
|
|
"Build: " $projman(Build) "\n\n" \
|
|
|
|
|
"Author: " $projman(Author) "\n" \
|
|
|
|
|
"Home page: " $projman(Homepage)
|
|
|
|
|
# foreach name [array names projman] {
|
|
|
|
|
# append msg $name ": " $projman($name) "\n"
|
|
|
|
|
# }
|
|
|
|
|
set answer [
|
|
|
|
|
tk_messageBox -message "[::msgcat::mc "About ..."] ProjMan" \
|
|
|
|
|
-icon info -type ok -detail $msg
|
|
|
|
|
]
|
|
|
|
|
switch $answer {
|
|
|
|
|
ok {return}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-02 17:01:53 +03:00
|
|
|
|
|
2022-09-02 21:42:40 +03:00
|
|
|
|
proc SearchVariable {txt} {
|
2022-09-02 17:01:53 +03:00
|
|
|
|
global fileStructure project variables
|
2022-09-02 21:42:40 +03:00
|
|
|
|
set varName [$txt get {insert wordstart} {insert wordend}]
|
|
|
|
|
puts ">>>$varName<<<"
|
|
|
|
|
if {[info exists project] == 0} {return}
|
|
|
|
|
foreach f [array names project] {
|
|
|
|
|
puts "--$f"
|
|
|
|
|
puts "----"
|
|
|
|
|
foreach a $project($f) {
|
|
|
|
|
puts "-----$variables($a)"
|
|
|
|
|
foreach b $variables($a) {
|
|
|
|
|
puts "------$b -- [lindex $b 0]"
|
|
|
|
|
if {$varName eq [lindex $b 0]} {
|
|
|
|
|
puts "УРААААААА $varName = $b в файле $a \n\t [lindex $b 0]"
|
|
|
|
|
FindVariablesDialog $txt "$varName: $a"
|
|
|
|
|
}
|
2022-09-02 17:01:53 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-02 21:42:40 +03:00
|
|
|
|
proc FindVariablesDialog {txt args} {
|
|
|
|
|
global editors lexers
|
|
|
|
|
# variable txt
|
|
|
|
|
variable win
|
|
|
|
|
# set txt $w.frmText.t
|
|
|
|
|
set box [$txt bbox insert]
|
|
|
|
|
set x [expr [lindex $box 0] + [winfo rootx $txt] ]
|
|
|
|
|
set y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ]
|
|
|
|
|
|
|
|
|
|
set win .findVariables
|
|
|
|
|
|
|
|
|
|
if { [winfo exists $win] } { destroy $win }
|
|
|
|
|
toplevel $win
|
|
|
|
|
wm transient $win .
|
|
|
|
|
wm overrideredirect $win 1
|
|
|
|
|
|
|
|
|
|
listbox $win.lBox -width 50 -border 2 -yscrollcommand "$win.yscroll set" -border 1
|
|
|
|
|
ttk::scrollbar $win.yscroll -orient vertical -command "$win.lBox yview"
|
|
|
|
|
pack $win.lBox -expand true -fill y -side left
|
|
|
|
|
pack $win.yscroll -side left -expand false -fill y
|
|
|
|
|
|
|
|
|
|
foreach { word } $args {
|
|
|
|
|
$win.lBox insert end $word
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch { $win.lBox activate 0 ; $win.lBox selection set 0 0 }
|
|
|
|
|
|
|
|
|
|
if { [set height [llength $args]] > 10 } { set height 10 }
|
|
|
|
|
$win.lBox configure -height $height
|
|
|
|
|
|
|
|
|
|
bind $win <Escape> {
|
|
|
|
|
destroy $win
|
|
|
|
|
# focus -force $txt.t
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
bind $win.lBox <Escape> {
|
|
|
|
|
destroy $win
|
|
|
|
|
# focus -force $txt.t
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
bind $win.lBox <Return> {
|
|
|
|
|
# set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString]
|
|
|
|
|
set values [.findVariables.lBox get [.findVariables.lBox curselection]]
|
|
|
|
|
# regsub -all {PROCNAME} $findString $values str
|
|
|
|
|
# Editor::FindFunction "$str"
|
|
|
|
|
destroy .findVariables
|
|
|
|
|
# $txt tag remove sel 1.0 end
|
|
|
|
|
# focus $Editor::txt.t
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
bind $win.lBox <Any-Key> {Editor::ListBoxSearch %W %A}
|
|
|
|
|
# Определям расстояние до края экрана (основного окна) и если
|
|
|
|
|
# оно меньше размера окна со списком то сдвигаем его вверх
|
|
|
|
|
set winGeom [winfo reqheight $win]
|
|
|
|
|
set topHeight [winfo height .]
|
|
|
|
|
# puts "$x, $y, $winGeom, $topHeight"
|
|
|
|
|
if [expr [expr $topHeight - $y] < $winGeom] {
|
|
|
|
|
set y [expr $topHeight - $winGeom]
|
|
|
|
|
}
|
|
|
|
|
wm geom $win +$x+$y
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|