Compare commits

9 Commits

Author SHA1 Message Date
svk
e21995d13e Сборка бета2 2026-01-27 17:37:10 +03:00
svk
26546dfe27 Добавлена динамическая генерация меню 'Инструменты'. Теперь новые внешние инструменты доступны сразу после сохранения файла настроек tools.ini в редакторе. 2026-01-27 17:31:39 +03:00
svk
a974068883 2-я бета 2026-01-27 16:44:48 +03:00
svk
d13a4adba5 Исправлена ошибка с некорректным определением виджета в процедуре получения выделенного текста. 2026-01-27 16:40:24 +03:00
svk
2dd7b7239e Добавлено редактирование настроек внешних инструментов. И пункт в меню 'Инструменты'->'Настройки' 2026-01-27 16:25:22 +03:00
svk
4b09b1e97d Исправление ошибки с запуском внешних программ. 2026-01-27 16:16:53 +03:00
svk
807131eee2 Добавлено определение путей до внешних программ при подключении к редактору. 2026-01-27 15:26:59 +03:00
svk
aaa027398a Сделана обработка шаблонов командной строки и запуск внешних инструментов. 2026-01-27 14:22:55 +03:00
svk
bc2808c3e4 Добавлен tkregexp для установки в /usr/bin 2026-01-27 14:22:12 +03:00
9 changed files with 149 additions and 15 deletions

View File

@@ -158,6 +158,29 @@ Or type "projman" into terminal, Or choose the name of the program "Projman" on
- Alt-S - Split the edited window horizontally - Alt-S - Split the edited window horizontally
- Alt-K - Open folder - Alt-K - Open folder
### Work with external tools
ProjMan allows you to connect any external tools to the editor. To do this, you need to add an entry to the file ~/.config/projman/tools.ini.
Calling an external program is available through the main and pop-up menus. To transfer the parameters, write the appropriate template in the file.
- %s - template for substituting selected text in the editor
- %f - template for substituting selected file\(s\) in the file tree
When adding multiple %f templates, the corresponding number of files allocated in the tree will be substituted.
```
[TkDIFF]
commandString=tkdiff %f %f
description=TkDiff is a Tcl/Tk front-end to diff
icon=
shortCut=
[VisualRegexp]
commandString=tkregexp "%s"
description=A graphical front-end to write/debug regular expression
icon=
shortCut=
```
## Credits ## Credits
Sergey Kalinin - author Sergey Kalinin - author

View File

@@ -11,6 +11,7 @@ sed -i "/# Build:.*/c$TXT" projman.tcl
cp projman.tcl projman cp projman.tcl projman
cp changelog-gen.tcl changelog-gen cp changelog-gen.tcl changelog-gen
cp tkregexp.tcl tkregexp
./changelog-gen.tcl --project-name projman --project-version ${VERSION} --project-release ${RELEASE} --out-file debian/changelog --deb --last ./changelog-gen.tcl --project-name projman --project-version ${VERSION} --project-release ${RELEASE} --out-file debian/changelog --deb --last
@@ -25,5 +26,5 @@ dpkg-buildpackage -d
#cp ../projman_${VERSION}-${RELEASE}_amd64.deb /files/ #cp ../projman_${VERSION}-${RELEASE}_amd64.deb /files/
rm -v projman changelog-gen rm -v projman changelog-gen tkregexp
rm -r -v debian/{projman,.debhelper} rm -r -v debian/{projman,.debhelper}

17
debian/changelog vendored
View File

@@ -1,3 +1,18 @@
projman (2.0.0-beta2) stable; urgency=medium
* Добавлена динамическая генерация меню 'Инструменты'. Теперь новые внешние инструменты доступны сразу после сохранения файла настроек tools.ini в редакторе.
* Исправлена ошибка с некорректным определением виджета в процедуре получения выделенного текста.
* Добавлено редактирование настроек внешних инструментов. И пункт в меню 'Инструменты'->'Настройки'
* Исправление ошибки с запуском внешних программ.
* Добавлено определение путей до внешних программ при подключении к редактору.
* Сделана обработка шаблонов командной строки и запуск внешних инструментов.
* Добавлен tkregexp для установки в /usr/bin
* Начало работы с внешними инструментами: - Добавлено создание и работа (проверка параметров
* Исправлен скрипт сборки бсд-пакета
* Добавлена сборка пакетов для openbsd
-- svk <svk@nuk-svk.ru> Tue, 27 Jan 2026 16:44:48 +0300
projman (2.0.0-beta1) stable; urgency=medium projman (2.0.0-beta1) stable; urgency=medium
* Сделан вывод отладочной информации по запросу. * Сделан вывод отладочной информации по запросу.
@@ -468,3 +483,5 @@ projman (2.0.0-alfa0) stable; urgency=medium

1
debian/install vendored
View File

@@ -1,5 +1,6 @@
projman /usr/bin/ projman /usr/bin/
changelog-gen /usr/bin/ changelog-gen /usr/bin/
tkregexp /usr/bin
lib/*.tcl /usr/share/projman/lib lib/*.tcl /usr/share/projman/lib
lib/msgs/* /usr/share/projman/lib/msgs lib/msgs/* /usr/share/projman/lib/msgs
theme /usr/share/projman/ theme /usr/share/projman/

View File

@@ -363,13 +363,22 @@ namespace eval Editor {
} }
} }
proc SelectionGet {txt} { proc SelectionGet {{txt ""}} {
variable selectionText global nbEditor
variable selectionText ""
if {$txt eq ""} {
DebugPuts "Editor::SelectionGet: [focus]"
set txt [focus]
if {![string match -nocase "*text*" $txt]} {
return ""
}
}
set selBegin [lindex [$txt tag ranges sel] 0] set selBegin [lindex [$txt tag ranges sel] 0]
set selEnd [lindex [$txt tag ranges sel] 1] set selEnd [lindex [$txt tag ranges sel] 1]
if {$selBegin ne "" && $selEnd ne ""} { if {$selBegin ne "" && $selEnd ne ""} {
set selectionText [$txt get $selBegin $selEnd] set selectionText [$txt get $selBegin $selEnd]
} }
return $selectionText
} }
proc SelectionHighlight {txt} { proc SelectionHighlight {txt} {

View File

@@ -391,6 +391,12 @@ namespace eval FileOper {
if {[file tail $filePath] eq "projman.ini"} { if {[file tail $filePath] eq "projman.ini"} {
Config::read $dir(cfg) Config::read $dir(cfg)
} }
if {[file tail $filePath] eq "tools.ini"} {
Tools::Read $dir(cfg)
Tools::CheckVariables
Tools::GetMenu .popup.tools
Tools::GetMenu .frmMenu.mnuTools.m
}
if [string match "*untitled*" $nbEditorItem] { if [string match "*untitled*" $nbEditorItem] {
FileOper::Close FileOper::Close
if {$type ne "close"} { if {$type ne "close"} {

View File

@@ -11,8 +11,8 @@ namespace eval Tools {} {
} }
set ::toolsDefault "\[VisualRegexp\] set ::toolsDefault "\[VisualRegexp\]
commandString=tkregexp % commandString=tkregexp \"%s\"
description'A graphical front-end to write/debug regular expression description=A graphical front-end to write/debug regular expression
icon= icon=
shortCut= shortCut=
\[TkDIFF\] \[TkDIFF\]
@@ -29,6 +29,7 @@ proc Tools::Create {dir} {
} }
proc Tools::Read {dir} { proc Tools::Read {dir} {
set ::toolsVariables ""
set toolsFile [ini::open [file join $dir tools.ini] "r"] set toolsFile [ini::open [file join $dir tools.ini] "r"]
foreach section [ini::sections $toolsFile] { foreach section [ini::sections $toolsFile] {
foreach key [ini::keys $toolsFile $section] { foreach key [ini::keys $toolsFile $section] {
@@ -104,6 +105,12 @@ proc Tools::CheckVariables {} {
proc Tools::GetMenu {m} { proc Tools::GetMenu {m} {
global cfgVariables toolsVariables global cfgVariables toolsVariables
set count [$m index end]
if {$count != "none"} {
for {set i $count} {$i >= 0} {incr i -1} {
$m delete $i
}
}
foreach toolName [dict keys $toolsVariables] { foreach toolName [dict keys $toolsVariables] {
dict for {key value} [dict get $toolsVariables $toolName] { dict for {key value} [dict get $toolsVariables $toolName] {
DebugPuts "GetToolsMenu $key $value" DebugPuts "GetToolsMenu $key $value"
@@ -122,10 +129,34 @@ proc Tools::GetMenu {m} {
} }
} }
} }
$m add separator
$m add command -label "[::msgcat::mc "Settings"]" -command Tools::Settings
}
proc Tools::CommandPathSettings {command} {
global tcl_platform
if [file exists $command] {return $command}
if {$tcl_platform(platform) eq "windows"} {
set cmd "where $command)"
} else {
set cmd "which $command"
}
DebugPuts [catch {exec {*}$cmd} toolsPath]
DebugPuts "executor_path $toolsPath"
if {[catch {exec {*}$cmd} toolsPath]} {
DebugPuts "Tools::CommandPathSettings: Программа $command не найдена в системе"
return ""
}
set fullPath [string trim $toolsPath]
set firstPath [lindex [split $toolsPath "\n"] 0]
DebugPuts "Tools::CommandPathSettings: executable path $fullPath"
return $fullPath
} }
proc Tools::Execute {toolName} { proc Tools::Execute {toolName} {
global cfgVariables toolsVariables global cfgVariables toolsVariables tree
if ![dict exists $::toolsVariables $toolName commandString] { if ![dict exists $::toolsVariables $toolName commandString] {
DebugPuts "Tools::Execute: command for $toolName not found" DebugPuts "Tools::Execute: command for $toolName not found"
return return
@@ -133,18 +164,56 @@ proc Tools::Execute {toolName} {
set command [dict get $::toolsVariables $toolName commandString] set command [dict get $::toolsVariables $toolName commandString]
DebugPuts "Tools::Execute: command for $toolName as $command" DebugPuts "Tools::Execute: command for $toolName as $command"
} }
# 1. Определять текущий файл # 7. Проверять команды на доступность в системе и подставлять полный путь к команде
# если в конфиге не указан полный путь.
# Проверем наличие внешгних программ в системе
set cmd [lindex [split $command " "] 0]
if [file exists $cmd] {
set fullCommand $command
} else {
set fullPathToExec [Tools::CommandPathSettings "$cmd"]
set fullCommand [lreplace [split $command " "] 0 0 $fullPathToExec]
}
if {$fullPathToExec eq ""} {
DebugPuts "Tools::Execute: $command not found"
return
} else {
DebugPuts "Tools::Execute: $fullPathToExec, $fullCommand"
}
# 2. Определять выделен ли текст в открытом редакторе # 2. Определять выделен ли текст в открытом редакторе
# 5. Заменяем %s на выделенный в редакторе текст
set selectedText [Editor::SelectionGet]
if {$selectedText ne ""} {
regsub -all "%s" $fullCommand "$selectedText" fullCommand
DebugPuts "Tools::Execute: selected text \"$selectedText\", command \"$fullCommand\""
}
# 1. Определять текущий файл
# 3. Опеределять сколько файлов выделено в дереве # 3. Опеределять сколько файлов выделено в дереве
# 4. Заменяем знак %f на имя текущего файла (файлов) # 4. Заменяем знак %f на имя текущего файла (файлов)
# regsub -all "%f" $command "$filePath" fullCommand # regsub -all "%f" $command "$filePath" fullCommand
# 5. Заменяем %s на выделенный в редакторе текст set filesList [Tree::GetSelectedItemValues $tree]
if {$filesList ne ""} {
foreach file $filesList {
# Если больше нет %f для замены, выходим из цикла
if {![string match "*%f*" $fullCommand]} break
set fullCommand [regsub {%f} $fullCommand $file]
}
}
# 6. Заменяем %d на текущий каталог(и), если он выделен в дереве, # 6. Заменяем %d на текущий каталог(и), если он выделен в дереве,
# и если не выделено то корневой открытый в дереве # и если не выделено то корневой открытый в дереве
# 7. Проверять команды на доступность в системе и подставлять полный путь к команде DebugPuts "Tools::Execute: $fullCommand"
# если в конфиге не указан полный путь.
set pipe [open "|$command" "r"] set pipe [open "|$fullCommand" "r"]
fileevent $pipe readable fileevent $pipe readable
fconfigure $pipe -buffering none -blocking no fconfigure $pipe -buffering none -blocking no
} }
# Правка файла настроек
proc Tools::Settings {} {
global dir
FileOper::Edit [file join $dir(cfg) tools.ini]
# Config::read $dir(cfg)
}

View File

@@ -99,6 +99,7 @@ namespace eval Tree {
proc PressItem {tree} { proc PressItem {tree} {
global nbEditor lexers editors activeProject global nbEditor lexers editors activeProject
set id [$tree selection] set id [$tree selection]
if {[llength $id] > 1} {return}
$tree tag remove selected $tree tag remove selected
$tree item $id -tags selected $tree item $id -tags selected
SetActiveProject [GetItemID $tree [GetUpperItem $tree $id]] SetActiveProject [GetItemID $tree [GetUpperItem $tree $id]]
@@ -161,4 +162,11 @@ namespace eval Tree {
} }
} }
proc GetSelectedItemValues {tree} {
set valuesList ""
foreach itemID [$tree selection] {
lappend valuesList [GetItemID $tree $itemID]
}
return $valuesList
}
} }

View File

@@ -9,8 +9,8 @@ exec wish8.6 "$0" -- "$@"
# Home page: https://nuk-svk.ru # Home page: https://nuk-svk.ru
###################################################### ######################################################
# Version: 2.0.0 # Version: 2.0.0
# Release: beta1 # Release: beta2
# Build: 22012026174911 # Build: 27012026173153
###################################################### ######################################################
# определим текущую версию, релиз и т.д. # определим текущую версию, релиз и т.д.