From 4a76bd5e22459381b96bd4a6e1d9241d4822bd9b Mon Sep 17 00:00:00 2001 From: svkalinin Date: Wed, 21 Sep 2022 14:38:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=80=D0=B5=D0=BA=D1=83=D1=80=D1=81=D0=B8=D0=B2?= =?UTF-8?q?=D0=BD=D0=BE=D0=B5=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=82=D0=B0=D0=BB=D0=BE=D0=B3=D0=B0=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B8.=20?= =?UTF-8?q?=D0=94=D0=B8=D0=B0=D0=BB=D0=BE=D0=B3=20=D0=BF=D0=BE=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=BE=D0=BA=D0=BD=D0=B0.=20=D0=94=D0=B8=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=20=D0=BD=D0=B0=D0=B2=D0=B8=D0=B3=D0=B0=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=20=D1=82?= =?UTF-8?q?=D0=B0=D0=BA-=D0=B6=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/editor.tcl | 111 +++++++++++++++------------------------------- lib/files.tcl | 8 +++- lib/highlight.tcl | 2 +- lib/msgs/ru.msg | 1 + lib/tree.tcl | 2 +- projman.tcl | 23 ++++------ 6 files changed, 53 insertions(+), 94 deletions(-) diff --git a/lib/editor.tcl b/lib/editor.tcl index 58fa74e..3da3f3e 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -448,8 +448,8 @@ namespace eval Editor { # #bind $txt GoToLine # bind $txt {focus .frmTool.frmGoto.entGoTo; .frmTool.frmGoto.entGoTo delete 0 end} bind $txt "Editor::FindDialog $w" - bind $txt "Editor::FindDialog $w" - bind $txt "Editor::FindDialog $w" + bind $txt "Editor::FindDialog $txt" + bind $txt "Editor::FindDialog $txt" # bind $txt {FindNext $w.text 1} # bind $txt ReplaceDialog # bind $txt ReplaceDialog @@ -495,12 +495,13 @@ namespace eval Editor { # bind $txt <> "Editor::SelectionGet $txt" bind $txt ImageBase64Encode bind $txt "Editor::SearchBrackets %W" - bind $txt "catch {Editor::GoToFunction $w}" - bind $txt "catch {Editor::GoToFunction $w}; break" + bind $txt "catch {Editor::GoToFunction $txt}" + bind $txt "catch {Editor::GoToFunction $txt}; break" bind $txt "$txt delete {insert wordstart} {insert wordend}" bind $txt "$txt delete {insert linestart} {insert lineend + 1char}" bind $txt "$txt delete {insert linestart} insert" bind $txt "$txt delete insert {insert lineend}" + bind $txt "Editor::SplitEditorH $w $fileType" } proc SearchBrackets {txt} { @@ -586,7 +587,9 @@ namespace eval Editor { if {[dict exists $lexers $fileType procRegexpCommand] != 0 } { if {[eval [dict get $lexers $fileType procRegexpCommand]]} { set procName_ [string trim $procName] - puts [Tree::InsertItem $tree $treeItemName $procName_ "procedure" "$procName_ ($params)"] + if {$treeItemName ne ""} { + puts [Tree::InsertItem $tree $treeItemName $procName_ "procedure" "$procName_ ($params)"] + } lappend procList [list $procName_ $params] unset procName_ } @@ -618,11 +621,11 @@ namespace eval Editor { dict set editors $txt variableList $varList } - proc FindFunction {findString} { + proc FindFunction {txt findString} { global nbEditor puts $findString set pos "0.0" - set txt [$nbEditor select].frmText.t + # set txt [$nbEditor select].frmText.t $txt see $pos set line [lindex [split $pos "."] 0] set x [lindex [split $pos "."] 1] @@ -691,22 +694,19 @@ namespace eval Editor { # ---------------------------------------------------------------------- # Вызов диалога со списком процедур или функций присутствующих в тексте - proc GoToFunction { w } { global tree editors - set txt $w.frmText.t - # set start_word [$txt get "insert - 1 chars wordstart" insert] + puts $w + # set txt $w.frmText.t + set txt $w set box [$txt bbox insert] set box_x [expr [lindex $box 0] + [winfo rootx $txt] ] set box_y [expr [lindex $box 1] + [winfo rooty $txt] + [lindex $box 3] ] set l "" - # bindtags $txt [list GoToFunctionBind [winfo toplevel $txt] $txt Text sysAfter all] - # bind GoToFunctionBind "bindtags $txt {[list [winfo toplevel $txt] $txt Text sysAfter all]}; catch { destroy .gotofunction; break}" - # bind GoToFunctionBind { Editor::GoToFunctionKey %W %K %A ; break} - # puts [array names editors] - + # puts "--$txt" + # puts $editors($txt) foreach item [dict get $editors $txt procedureList] { - # puts $item + puts $item lappend l [lindex $item 0] } if {$l ne ""} { @@ -715,50 +715,6 @@ namespace eval Editor { } } - # proc GoToFunctionKey { txt K A } { - # set win .gotofunction - # set ind [$win.lBox curselection] - # puts "$txt $K $A" - # switch -- $K { - # Prior { - # set up [expr [$win.lBox index active] - [$win.lBox cget -height]] - # if { $up < 0 } { set up 0 } - # $win.lBox activate $up - # $win.lBox selection clear 0 end - # $win.lBox selection set $up $up - # } - # Next { - # set down [expr [$win.lBox index active] + [$win.lBox cget -height]] - # if { $down >= [$win.lBox index end] } { set down end } - # $win.lBox activate $down - # $win.lBox selection clear 0 end - # $win.lBox selection set $down $down - # } - # Up { - # set up [expr [$win.lBox index active] - 1] - # if { $up < 0 } { set up 0 } - # $win.lBox activate $up - # $win.lBox selection clear 0 end - # $win.lBox selection set $up $up - # } - # Down { - # set down [expr [$win.lBox index active] + 1] - # if { $down >= [$win.lBox index end] } { set down end } - # $win.lBox activate $down - # $win.lBox selection clear 0 end - # $win.lBox selection set $down $down - # } - # Return { - # Editor::FindFunction "proc $values" - # eval [bind GoToFunctionBind ] - # } - # default { - # $txt insert "insert" $A - # eval [bind GoToFunctionBind ] - # } - # } - # } - #--------------------------------------------------------- # Поиск по списку по первой букве # Richard Suchenwirth 2001-03-1 @@ -785,10 +741,11 @@ namespace eval Editor { global editors lexers variable txt variable win - set txt $w.frmText.t + # set txt $w.frmText.t + set txt $w set win .gotofunction - if { [winfo exists $win] } { destroy $win } + if { [winfo exists $win] } { destroy $win } toplevel $win wm transient $win . wm overrideredirect $win 1 @@ -807,7 +764,7 @@ namespace eval Editor { if { [set height [llength $args]] > 10 } { set height 10 } $win.lBox configure -height $height - bind $win { + bind $win { destroy $Editor::win focus -force $Editor::txt.t break @@ -821,7 +778,7 @@ namespace eval Editor { set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString] set values [.gotofunction.lBox get [.gotofunction.lBox curselection]] regsub -all {PROCNAME} $findString $values str - Editor::FindFunction "$str" + Editor::FindFunction $Editor::txt "$str" destroy .gotofunction $Editor::txt tag remove sel 1.0 end # focus $Editor::txt.t @@ -839,9 +796,10 @@ namespace eval Editor { wm geom $win +$x+$y } - proc FindReplaceText {findString replaceString regexp} { + proc FindReplaceText {txt findString replaceString regexp} { global nbEditor - set txt [$nbEditor select].frmText.t + puts [focus] + # set txt [$nbEditor select].frmText.t $txt tag remove sel 1.0 end # $txt see $pos # set pos [$txt search -nocase $findString $line.$x end] @@ -919,7 +877,8 @@ namespace eval Editor { set findString "" set replaceString "" - set txt $w.frmText.t + # set txt $w.frmText.t + set txt $w set win .finddialog set regexpSet "" set searchAll "-all" @@ -936,18 +895,18 @@ namespace eval Editor { ttk::button $win.bForward -image forward_20x20 -command { - Editor::FindReplaceText "$findString" "" $regexpSet + Editor::FindReplaceText $Editor::txt "$findString" "" $regexpSet } ttk::button $win.bBackward -state disable -image backward_20x20 -command "puts $replaceString" ttk::button $win.bDone -image done_20x20 -state disable -command { puts "$findString -> $replaceString, $regexpSet" } ttk::button $win.bDoneAll -image doneall_20x20 -command { - Editor::FindReplaceText "$findString" "$replaceString" $regexpSet + Editor::FindReplaceText $Editor::txt "$findString" "$replaceString" $regexpSet } ttk::button $win.bReplace -image replace_20x20 \ -command { - puts $Editor::show($Editor::win.entryReplace) + # puts $Editor::show($Editor::win.entryReplace) if {$Editor::show($Editor::win.entryReplace) eq "false"} { grid $Editor::win.entryReplace -row 1 -column 0 -columnspan 3 -sticky nsew grid $Editor::win.bDone -row 1 -column 3 -sticky e @@ -987,11 +946,11 @@ namespace eval Editor { break } bind $win.entryFind { - Editor::FindReplaceText "$findString" "" $regexpSet + Editor::FindReplaceText $Editor::txt "$findString" "" $regexpSet break } bind $win.entryReplace { - Editor::FindReplaceText "$findString" "$replaceString" $regexpSet + Editor::FindReplaceText $Editor::txt "$findString" "$replaceString" $regexpSet break } @@ -999,6 +958,7 @@ namespace eval Editor { focus -force $win.entryFind } + # Horizontal split the Editor text widget proc SplitEditorH {w fileType} { global cfgVariables puts [$w.panelTxt panes] @@ -1015,6 +975,7 @@ namespace eval Editor { $w.panelTxt add $frmText -weight 1 $frmText.t see [$w.frmText.t index insert] + ReadStructure $frmText.t "" focus -force $frmText.t.t } @@ -1036,7 +997,7 @@ namespace eval Editor { $frmText.t see [$w.frmText.t index insert] } - + proc EditorWidget {fr fileType} { global cfgVariables editors @@ -1075,8 +1036,8 @@ namespace eval Editor { dict set editors $txt fileType $fileType dict set editors $txt procedureList [list] - # puts ">>[dict get $editors $txt fileType]" - # puts ">>[dict get $editors $txt procedureList]" + puts ">>[dict get $editors $txt fileType]" + puts ">>[dict get $editors $txt procedureList]" # puts ">>>>> $editors" if {[info procs ::Highlight::$fileType] ne ""} { diff --git a/lib/files.tcl b/lib/files.tcl index d38187b..262f22b 100644 --- a/lib/files.tcl +++ b/lib/files.tcl @@ -228,12 +228,16 @@ namespace eval FileOper { # Sort lists and insert into tree if {[info exists lstDir] && [llength $lstDir] > 0} { foreach f [lsort $lstDir] { - puts "Tree insert item: [Tree::InsertItem $tree $parent [file join $directory $f] "directory" $f]" + set i [Tree::InsertItem $tree $parent [file join $directory $f] "directory" $f] + # puts "Tree insert item: $i $f]" + ReadFolder [file join $directory $f] $i + unset i } } if {[info exists lstFiles] && [llength $lstFiles] > 0} { foreach f [lsort $lstFiles] { - puts "Tree insert item: [Tree::InsertItem $tree $parent [file join $directory $f] "file" $f]" + Tree::InsertItem $tree $parent [file join $directory $f] "file" $f + # puts "Tree insert item: " } } # Чтение структуры файлов в каталоге diff --git a/lib/highlight.tcl b/lib/highlight.tcl index bac370a..8da5811 100644 --- a/lib/highlight.tcl +++ b/lib/highlight.tcl @@ -58,7 +58,7 @@ namespace eval Highlight {} { proc PY {txt} { ctext::addHighlightClassForRegexp $txt flags orange {-+[a-zA-Z\-_]+} - ctext::addHighlightClass $txt stackControl #19a2a6 {if else: elif for while case switch def import from return make break defer continue package len print with open try: except} + ctext::addHighlightClass $txt stackControl #19a2a6 {if else: elif for while case switch def import from return make break defer continue package len print with open try: except: in} ctext::addHighlightClass $txt types #7187d5 {string int int16 int32 int64 float bool byte} ctext::addHighlightClassWithOnlyCharStart $txt vars #4471ca "\&" ctext::addHighlightClassWithOnlyCharStart $txt vars #4471ca "\*" diff --git a/lib/msgs/ru.msg b/lib/msgs/ru.msg index 665fd56..08ef08e 100644 --- a/lib/msgs/ru.msg +++ b/lib/msgs/ru.msg @@ -179,6 +179,7 @@ ::msgcat::mcset ru "Show backup files" "Показывать временные файлы" ::msgcat::mcset ru "Show the Menu" "Показывать меню" ::msgcat::mcset ru "Show dot files" "Показывать скрытые файлы" +::msgcat::mcset ru "Specify the absolute path to the directory or file" "Укажите полный путь к каталогу или файлу" ::msgcat::mcset ru "Split edit window" "Разделить окно редактора" ::msgcat::mcset ru "SQL commands" "SQL команды" ::msgcat::mcset ru "Text autoformat" "Автоформат текста" diff --git a/lib/tree.tcl b/lib/tree.tcl index 0776760..56bd85e 100644 --- a/lib/tree.tcl +++ b/lib/tree.tcl @@ -126,7 +126,7 @@ namespace eval Tree { set findString [dict get $lexers [dict get $editors $txt fileType] procFindString] regsub -all {PROCNAME} $findString $values str - Editor::FindFunction "$str" + Editor::FindFunction $txt "$str" } } } diff --git a/projman.tcl b/projman.tcl index fc80749..f4a9abb 100755 --- a/projman.tcl +++ b/projman.tcl @@ -10,7 +10,7 @@ exec wish "$0" -- "$@" ###################################################### # Version: 2.0.0 # Release: alpha -# Build: 19092022115815 +# Build: 21092022142626 ###################################################### # определим текущую версию, релиз и т.д. @@ -50,7 +50,6 @@ package require Thread # Устанавливаем текущий каталог set dir(root) [pwd] - set dir(doc) [file join $dir(root) doc] # Устанавливаем рабочий каталог, если его нет то создаём. @@ -111,38 +110,32 @@ source [file join $dir(lib) gui.tcl] # Open the PATH if command line argument has been setting if [info exists opened] { - puts ">$opened" + # puts ">$opened" foreach path $opened { + if {[file pathtype $path] ne "absolute"} { + puts "\n\t[::msgcat::mc "Specify the absolute path to the directory or file"]: $path\n" + exit + } if [file isdirectory $path] { set activeProject $path FileOper::ReadFolder $path ReadFilesFromDirectory $path $path - # puts "aaa[dict values $project "ansible*"]" } elseif [file exists $path] { ResetModifiedFlag [FileOper::Edit $path] } } } else { if {$cfgVariables(opened) ne ""} { - puts "<$cfgVariables(opened)" + # puts "<$cfgVariables(opened)" set activeProject $cfgVariables(opened) FileOper::ReadFolder $cfgVariables(opened) ReadFilesFromDirectory $cfgVariables(opened) $cfgVariables(opened) if {$cfgVariables(editedFiles) ne ""} { foreach f [split $cfgVariables(editedFiles) " "] { - puts $f + # puts $f FileOper::Edit $f } } } } -# if [info exists project] { - # foreach f [array names project] { - # puts "--$f" - # puts "----" - # foreach a [split $project($f) " "] { - # puts $variables($a) - # } - # } -#