Compare commits

15 Commits

Author SHA1 Message Date
svk
dee9141e91 Merge pull request 'beta2' (#8) from beta2 into master
All checks were successful
Build and Release / build (push) Successful in 24s
Reviewed-on: #8
2026-01-28 12:45:47 +03:00
svk
1b6493d3a8 Новая сборка 2026-01-28 12:43:25 +03:00
svk
36d1940c7b Небольшая правка 2026-01-28 12:42:05 +03:00
svk
c69db69c69 Сборка beta2 2026-01-28 12:35:44 +03:00
svk
c74fa5b113 Добавлено подключение (bind) сочетания клавишь указанных в настройках инструментов. 2026-01-28 12:26:53 +03:00
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
svk
1758afd100 Начало работы с внешними инструментами:
- Добавлено создание и работа (проверка параметров, сохранение) с файлом настроек tools.ini
- Добавлено создание меню 'Инструменты' как основного так и контекстного (всплывающего) на основе  tools.ini.
2026-01-26 19:46:01 +03:00
12 changed files with 314 additions and 11 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}

18
debian/changelog vendored
View File

@@ -1,3 +1,19 @@
projman (2.0.0-beta2) stable; urgency=medium
* Добавлено подключение (bind) сочетания клавиш указанных в настройках инструментов.
* Добавлена динамическая генерация меню 'Инструменты'. Теперь новые внешние инструменты доступны сразу после сохранения файла настроек 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 +484,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,15 +363,24 @@ 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} {
variable selectionText variable selectionText
$txt tag remove lightSelected 1.0 end $txt tag remove lightSelected 1.0 end

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

@@ -135,7 +135,11 @@ GetEditMenu [menu .frmMenu.mnuEdit.m]
ttk::menubutton .frmMenu.mnuView -text [::msgcat::mc "View"] -menu .frmMenu.mnuView.m ttk::menubutton .frmMenu.mnuView -text [::msgcat::mc "View"] -menu .frmMenu.mnuView.m
GetViewMenu [menu .frmMenu.mnuView.m] GetViewMenu [menu .frmMenu.mnuView.m]
pack .frmMenu.mnuFile .frmMenu.mnuEdit .frmMenu.mnuView -side left ttk::menubutton .frmMenu.mnuTools -text [::msgcat::mc "Tools"] -menu .frmMenu.mnuTools.m
Tools::GetMenu [menu .frmMenu.mnuTools.m]
pack .frmMenu.mnuFile .frmMenu.mnuEdit .frmMenu.mnuView .frmMenu.mnuTools -side left
ttk::menubutton .frmMenu.mnuHelp -text [::msgcat::mc "Help"] -menu .frmMenu.mnuHelp.m ttk::menubutton .frmMenu.mnuHelp -text [::msgcat::mc "Help"] -menu .frmMenu.mnuHelp.m
GetHelpMenu [menu .frmMenu.mnuHelp.m] GetHelpMenu [menu .frmMenu.mnuHelp.m]
@@ -151,6 +155,9 @@ GetFileMenu .popup.file
menu .popup.view menu .popup.view
.popup add cascade -label [::msgcat::mc "View"] -menu .popup.view .popup add cascade -label [::msgcat::mc "View"] -menu .popup.view
GetViewMenu .popup.view GetViewMenu .popup.view
menu .popup.tools
.popup add cascade -label [::msgcat::mc "Tools"] -menu .popup.tools
Tools::GetMenu .popup.tools
set frmTool [ttk::frame .frmBody.frmTool] set frmTool [ttk::frame .frmBody.frmTool]
ttk::panedwindow .frmBody.panel -orient horizontal -style TPanedwindow ttk::panedwindow .frmBody.panel -orient horizontal -style TPanedwindow

View File

@@ -174,6 +174,7 @@
::msgcat::mcset en "Title normal" ::msgcat::mcset en "Title normal"
::msgcat::mcset en "Title modify" ::msgcat::mcset en "Title modify"
::msgcat::mcset en "Toolbar" ::msgcat::mcset en "Toolbar"
::msgcat::mcset en "Tools"
::msgcat::mcset en "Undo" ::msgcat::mcset en "Undo"
::msgcat::mcset en "Update" ::msgcat::mcset en "Update"
::msgcat::mcset en "Variables" ::msgcat::mcset en "Variables"
@@ -185,4 +186,3 @@
::msgcat::mcset en "Work dir" ::msgcat::mcset en "Work dir"

View File

@@ -214,6 +214,7 @@
::msgcat::mcset ru "Title normal" "Файл нормальный" ::msgcat::mcset ru "Title normal" "Файл нормальный"
::msgcat::mcset ru "Title modify" "Файл изменен" ::msgcat::mcset ru "Title modify" "Файл изменен"
::msgcat::mcset ru "Toolbar" "Панель инструментов" ::msgcat::mcset ru "Toolbar" "Панель инструментов"
::msgcat::mcset ru "Tools" "Инструменты"
::msgcat::mcset ru "User name" "Имя пользователя" ::msgcat::mcset ru "User name" "Имя пользователя"
::msgcat::mcset ru "Undo" "Отменить" ::msgcat::mcset ru "Undo" "Отменить"
::msgcat::mcset ru "Update" "Обновить" ::msgcat::mcset ru "Update" "Обновить"

220
lib/tools.tcl Normal file
View File

@@ -0,0 +1,220 @@
##################################################################
# tools.tcl - this file implements the logic of working
# with external tools.
##################################################################
# svk, 01/2026
##################################################################
namespace eval Tools {} {
variable toolsINISections
variable toolsVariables
}
set ::toolsDefault "\[VisualRegexp\]
commandString=tkregexp \"%s\"
description=A graphical front-end to write/debug regular expression
icon=
shortCut=
\[TkDIFF\]
commandString=tkdiff %f %f
description=TkDiff is a Tcl/Tk front-end to diff
icon=
shortCut=
"
# Создание файла настроек внешних инструментов
proc Tools::Create {dir} {
set toolsFile [open [file join $dir tools.ini] "w+"]
puts $toolsFile $::toolsDefault
close $toolsFile
}
proc Tools::Read {dir} {
set ::toolsVariables ""
set toolsFile [ini::open [file join $dir tools.ini] "r"]
foreach section [ini::sections $toolsFile] {
foreach key [ini::keys $toolsFile $section] {
lappend ::toolsINIsections($section) $key
dict set ::toolsVariables $section $key [ini::value $toolsFile $section $key]
DebugPuts "Tools::Read: $toolsFile $section $key = [ini::value $toolsFile $section $key]"
}
}
ini::close $toolsFile
}
proc Tools::Write {dir} {
set toolsFile [ini::open [file join $dir tools.ini] "w"]
foreach section [array names ::toolsINIsections] {
dict for {key value} [dict get $::toolsVariables $section] {
DebugPuts "Tools::write: $section $key = $value"
# ini::set $toolsFile $section $key [dict get $::toolsVariables $section $key]
ini::set $toolsFile $section $key $value
}
}
ini::commit $toolsFile
ini::close $toolsFile
}
# Добавление перменной в список
# если отсутствует нужная секция то она будет добавлена.
proc Tools::AddVariable {key value section} {
# Проверяем, существует ли уже такая переменная
if {[info exists ::toolsVariables($key)]} {
DebugPuts "The variable '$key' already exists: "
return 0
}
# Добавляем в массив переменных
# set ::toolsVariables($key) $value
dict set ::toolsVariables $section $key $value
# Добавляем в список ключей секции
if {[dict exists $::toolsVariables $key]} {
# Проверяем, нет ли уже такого ключа в секции
if {[lsearch -exact $::toolsINIsections($section) $key] == -1} {
lappend ::toolsINIsections($section) $key
}
} else {
set ::toolsINIsections($section) [list $key]
}
DebugPuts "Tools::AddVariable: The variable '$key' has been added to the '$section' array 'toolsVariables' with value '$value'"
return 1
}
# Проверяем наличие переменных в tools.ini на основе "эталонного" списка
# и выставляем значение по умолчанию если в конфиге переменной нет
proc Tools::CheckVariables {} {
set valList [split $::toolsDefault "\n"]
foreach item $valList {
if {[regexp -nocase -all -- {\[(\w+)\]} $item -> v1]} {
set section $v1
}
if {[regexp {^([^=]+)=(.*)$} $item -> key value]} {
# puts "$section $key $value >> [dict get $::toolsVariables $section $key]"
# if {[dict get $::toolsVariables $section $key] eq ""}
if ![dict exists $::toolsVariables $section $key] {
DebugPuts "Error in Tools::CheckVariables: variable $section $key not found"
Tools::AddVariable "$key" "$value" "$section"
# DebugPuts "Tools::CheckVariables: The variable toolsVariables $key setting to default value \"$value\""
}
}
}
foreach id [dict keys $::toolsVariables] {
DebugPuts "Tools::CheckVariables: config parameters for $id [dict get $::toolsVariables $id]!"
}
# DebugPuts "toolsVariables dict keys: [dict keys $::toolsVariables]"
}
proc Tools::GetMenu {m} {
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] {
dict for {key value} [dict get $toolsVariables $toolName] {
DebugPuts "GetToolsMenu $key $value"
if {$key eq "commandString"} {
set cmd "$value"
}
if {$key eq "shortCut"} {
set shortCut "$value"
}
}
if {[info exists cmd] == 1 && $cmd ne ""} {
if {[info exists shortCut] == 1 && $shortCut ne ""} {
$m add command -label $toolName -accelerator $shortCut -command [list Tools::Execute "$toolName"]
bind . <$shortCut> "[list Tools::Execute "$toolName"]; break"
} else {
$m add command -label $toolName -command [list Tools::Execute "$toolName"]
}
}
}
$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} {
global cfgVariables toolsVariables tree
if ![dict exists $::toolsVariables $toolName commandString] {
DebugPuts "Tools::Execute: command for $toolName not found"
return
} else {
set command [dict get $::toolsVariables $toolName commandString]
DebugPuts "Tools::Execute: command for $toolName as $command"
}
# 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. Определять выделен ли текст в открытом редакторе
# 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. Опеределять сколько файлов выделено в дереве
# 4. Заменяем знак %f на имя текущего файла (файлов)
# regsub -all "%f" $command "$filePath" fullCommand
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 на текущий каталог(и), если он выделен в дереве,
# и если не выделено то корневой открытый в дереве
DebugPuts "Tools::Execute: $fullCommand"
set pipe [open "|$fullCommand" "r"]
fileevent $pipe readable
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]]
@@ -160,5 +161,12 @@ namespace eval Tree {
GetUpperItem $tree $parent GetUpperItem $tree $parent
} }
} }
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: 28012026124210
###################################################### ######################################################
# определим текущую версию, релиз и т.д. # определим текущую версию, релиз и т.д.
@@ -114,13 +114,22 @@ foreach modFile [lsort [glob -nocomplain [file join $dir(theme) *]]] {
} }
# загружаем пользовательский конфиг, если он отсутствует, то копируем дефолтный # загружаем пользовательский конфиг, если он отсутствует или пустой, то копируем дефолтный
if {[file exists [file join $dir(cfg) projman.ini]] ==0} { if {[file exists [file join $dir(cfg) projman.ini]] == 0 || [file size [file join $dir(cfg) projman.ini]] == 0} {
Config::create $dir(cfg) Config::create $dir(cfg)
} }
Config::read $dir(cfg) Config::read $dir(cfg)
Config::CheckVariables Config::CheckVariables
# загружаем пользовательский конфиг для инстурментов, если он отсутствует или пустой, то копируем дефолтный
if {[file exists [file join $dir(cfg) tools.ini]] == 0 || [file size [file join $dir(cfg) tools.ini]] == 0} {
Tools::Create $dir(cfg)
}
# Читаем настройки для внешних инструментов
Tools::Read $dir(cfg)
Tools::CheckVariables
Tools::Write $dir(cfg)
::msgcat::mclocale $cfgVariables(locale) ::msgcat::mclocale $cfgVariables(locale)
if [::msgcat::mcload [file join $dir(lib) msgs]] { if [::msgcat::mcload [file join $dir(lib) msgs]] {