beta2 #8

Merged
svk merged 49 commits from beta2 into master 2026-01-28 12:45:48 +03:00
11 changed files with 471 additions and 56 deletions
Showing only changes of commit aaa027398a - Show all commits

View File

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

View File

@@ -11,7 +11,7 @@ namespace eval Tools {} {
}
set ::toolsDefault "\[VisualRegexp\]
commandString=tkregexp %
commandString=tkregexp %s
description'A graphical front-end to write/debug regular expression
icon=
shortCut=
@@ -125,7 +125,7 @@ proc Tools::GetMenu {m} {
}
proc Tools::Execute {toolName} {
global cfgVariables toolsVariables
global cfgVariables toolsVariables tree
if ![dict exists $::toolsVariables $toolName commandString] {
DebugPuts "Tools::Execute: command for $toolName not found"
return
@@ -133,18 +133,36 @@ proc Tools::Execute {toolName} {
set command [dict get $::toolsVariables $toolName commandString]
DebugPuts "Tools::Execute: command for $toolName as $command"
}
# 1. Определять текущий файл
set fullCommand $command
# 2. Определять выделен ли текст в открытом редакторе
set selectedText [Editor::SelectionGet]
if {$selectedText ne ""} {
regsub -all "%s" $command "$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]
}
DebugPuts "Tools::Execute: $fullCommand"
}
# 5. Заменяем %s на выделенный в редакторе текст
# 6. Заменяем %d на текущий каталог(и), если он выделен в дереве,
# и если не выделено то корневой открытый в дереве
# 7. Проверять команды на доступность в системе и подставлять полный путь к команде
# если в конфиге не указан полный путь.
set pipe [open "|$command" "r"]
set pipe [open "|$fullCommand" "r"]
fileevent $pipe readable
fconfigure $pipe -buffering none -blocking no
}

View File

@@ -99,6 +99,7 @@ namespace eval Tree {
proc PressItem {tree} {
global nbEditor lexers editors activeProject
set id [$tree selection]
if {[llength $id] > 1} {return}
$tree tag remove selected
$tree item $id -tags selected
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
}
}