From a7b6c48a423a4602450f84e5e8dcb21506eddd08 Mon Sep 17 00:00:00 2001 From: svkalinin Date: Wed, 14 Sep 2022 16:31:50 +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=D0=B3=D0=BE=D1=80=D0=B8=D0=B7=D0=BE=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20=D1=80=D0=B0=D0=B7=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=BA=D0=BD=D0=B0?= =?UTF-8?q?=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B0.=20?= =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=D0=B8=20=D0=BF=D0=BE=20Alt+R=20-=20=D1=80?= =?UTF-8?q?=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=81=D1=82=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=83=D0=B4=D0=B0=D0=BB=D1=8F=D0=B5=D1=82=D1=81=D1=8F?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D1=81=D1=82=D1=8C=D1=8E=20?= =?UTF-8?q?=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B5=20=D1=81=20=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=D0=B2=D0=BE=D0=BB=D0=B0=D0=BC=D0=B8=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D1=81=D0=B0.=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D1=81=D0=BE=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0=20(untitled)=20?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=B2=D1=81=D0=B5=D1=80=D0=B0=D0=B2=D0=BD=D0=BE?= =?UTF-8?q?=20=D0=BA=D0=B0=D0=BA-=D1=82=D0=BE=20=D0=BA=D1=80=D0=B8=D0=B2?= =?UTF-8?q?=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 6 +++ lib/editor.tcl | 112 ++++++++++++++++++++++++++----------------------- lib/files.tcl | 42 +++++++++++++------ lib/tree.tcl | 2 +- projman.tcl | 3 +- 5 files changed, 99 insertions(+), 66 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 38ce476..da44899 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -109,3 +109,9 @@ - Added search function name into Function navigation whem press key - Added find and replace dialog - Fixed correct placement the Function dialog + +14/09/2022 + - Added procedure for the horizontal split a text window + - Fixed untitled file saved + - Fixed Alt+R (delete row), now will are deleted row with a "\n\r" symbols + diff --git a/lib/editor.tcl b/lib/editor.tcl index ac9912c..8d5d213 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -436,10 +436,10 @@ namespace eval Editor { if {$key == 63 || $key == 107 || $key == 108 || $key == 112} {return "true"} } - proc BindKeys {w fileType} { + proc BindKeys {w txt fileType} { global cfgVariables # variable txt - set txt $w.frmText.t + # set txt $w.frmText.t bind $txt "Editor::ReleaseKey %K $txt" bind $txt "Editor::PressKey %K $txt" # bind $txt "Editor::Key %k %K" @@ -496,9 +496,9 @@ namespace eval Editor { bind $txt ImageBase64Encode bind $txt "Editor::SearchBrackets %W" bind $txt "catch {Editor::GoToFunction $w}" - bind $txt "catch {Editor::GoToFunction $w}" + bind $txt "catch {Editor::GoToFunction $w}; break" bind $txt "$txt delete {insert wordstart} {insert wordend}" - bind $txt "$txt delete {insert linestart} {insert lineend}" + bind $txt "$txt delete {insert linestart} {insert lineend + 1char}" bind $txt "$txt delete {insert linestart} insert" bind $txt "$txt delete insert {insert lineend}" } @@ -692,7 +692,7 @@ proc FindFunction {findString} { # ---------------------------------------------------------------------- # Вызов диалога со списком процедур или функций присутствующих в тексте - proc GoToFunction { w } { + proc GoToFunction { w } { global tree editors set txt $w.frmText.t # set start_word [$txt get "insert - 1 chars wordstart" insert] @@ -992,57 +992,35 @@ proc FindFunction {findString} { focus -force $win.entryFind } - proc SplitEditor {w orient} { - ttk::panedwindow $w.panelTxt -orient horizontal -style TPanedwindow - pack propagate $w.panelTxt false - set frmText [ttk::frame $w.frmText2 -border 1] - - pack $frmText -side top -expand true -fill both - ctext $frmText.t2 - pack $frmText.t2 -fill both -expand 1 - $frmText.t2 insert end [$w.frmText.t get 0.0 end] + proc SplitEditor {w fileType} { + global cfgVariables + puts [$w.panelTxt panes] + if [winfo exists $w.frmText2] { + $w.panelTxt forget $w.frmText2 + destroy $w.frmText2 + return + } + set frmText [Editor::EditorWidget $w $fileType] + $frmText.t insert end [$w.frmText.t get 0.0 end] - $w.panelTxt add $w.frmText -weight 0 + # $w.panelTxt add $w.frmText -weight 0 $w.panelTxt add $w.frmText2 -weight 1 - } - proc Editor {fileFullPath nb itemName} { + proc EditorWidget {fr fileType} { global cfgVariables editors - set fr $itemName - if ![string match "*untitled*" $itemName] { - set lblText $fileFullPath + + if [winfo exists $fr.frmText] { + set frmText [ttk::frame $fr.frmText2 -border 1] } else { - set lblText "" - + set frmText [ttk::frame $fr.frmText -border 1] } - ttk::frame $fr.header - - set frmText [ttk::frame $fr.frmText -border 1] set txt $frmText.t - set lblName "lbl[string range $itemName [expr [string last "." $itemName] +1] end]" - ttk::label $fr.header.$lblName -text $lblText - # pack $fr.$lblName -side top -anchor w -fill x - - set btnSplitV "btnSplitV[string range $itemName [expr [string last "." $itemName] +1] end]" - set btnSplitH "btnSplitH[string range $itemName [expr [string last "." $itemName] +1] end]" - ttk::button $fr.header.$btnSplitH -image split_horizontal_11x11 \ - -command "Editor::SplitEditor $fr horizontal" - ttk::button $fr.header.$btnSplitV -image split_vertical_11x11 \ - -command "Editor::SplitEditor $fr vertical" -state disable - # pack $fr.$btnSplitH $fr.$btnSplitV -side right -anchor e - pack $fr.header.$lblName -side left -expand true -fill x - pack $fr.header.$btnSplitV $fr.header.$btnSplitH -side right - - pack $fr.header -side top -fill x - # set frmText [ttk::frame $fr.frmText -border 1] # set txt $frmText.t - pack $frmText -side top -expand true -fill both - pack [ttk::scrollbar $frmText.v -command "$frmText.t yview"] -side right -fill y ttk::scrollbar $frmText.h -orient horizontal -command "$frmText.t xview" @@ -1060,9 +1038,6 @@ proc FindFunction {findString} { $txt tag configure lightBracket -background $cfgVariables(selectLightBg) -foreground #00ffff $txt tag configure lightSelected -background $cfgVariables(selectLightBg) -foreground #00ffff - set fileType [string toupper [string trimleft [file extension $fileFullPath] "."]] - if {$fileType eq ""} {set fileType "Unknown"} - # puts ">$fileType<" # puts [info procs Highlight::GO] dict set editors $txt fileType $fileType @@ -1077,13 +1052,46 @@ proc FindFunction {findString} { } else { Highlight::Default $txt } + BindKeys $fr $txt $fileType + return $frmText + } + + proc Editor {fileFullPath nb itemName} { + global cfgVariables editors + set fr $itemName + if ![string match "*untitled*" $itemName] { + set lblText $fileFullPath + } else { + set lblText "" + + } + set fileType [string toupper [string trimleft [file extension $fileFullPath] "."]] + if {$fileType eq ""} {set fileType "Unknown"} - BindKeys $itemName $fileType - # bind $txt { - # regexp {^(\s*)} [%W get "insert linestart" end] -> spaceStart - # %W insert insert "\n$spaceStart" - # break - # } + ttk::frame $fr.header + set lblName "lbl[string range $itemName [expr [string last "." $itemName] +1] end]" + ttk::label $fr.header.$lblName -text $lblText + # pack $fr.$lblName -side top -anchor w -fill x + + set btnSplitV "btnSplitV[string range $itemName [expr [string last "." $itemName] +1] end]" + set btnSplitH "btnSplitH[string range $itemName [expr [string last "." $itemName] +1] end]" + ttk::button $fr.header.$btnSplitH -image split_horizontal_11x11 \ + -command "Editor::SplitEditor $fr $fileType" + ttk::button $fr.header.$btnSplitV -image split_vertical_11x11 \ + -command "Editor::SplitEditor $fr $fileType" -state disable + # pack $fr.$btnSplitH $fr.$btnSplitV -side right -anchor e + pack $fr.header.$lblName -side left -expand true -fill x + pack $fr.header.$btnSplitV $fr.header.$btnSplitH -side right + + pack $fr.header -side top -fill x + + ttk::panedwindow $fr.panelTxt -orient vertical -style TPanedwindow + pack propagate $fr.panelTxt false + pack $fr.panelTxt -side top -fill both -expand true + + set frmText [Editor::EditorWidget $fr $fileType] + + $fr.panelTxt add $frmText -weight 0 return $fr } diff --git a/lib/files.tcl b/lib/files.tcl index 6dc04b1..d6c6570 100644 --- a/lib/files.tcl +++ b/lib/files.tcl @@ -16,8 +16,12 @@ namespace eval FileOper { } proc OpenDialog {} { - global env - set dir $env(HOME) + global env project activeProject + if [info exists activeProject] { + set dir $activeProject + } else { + set dir $env(HOME) + } set fullPath [tk_getOpenFile -initialdir $dir -filetypes $::types -parent .] set file [string range $fullPath [expr [string last "/" $fullPath]+1] end] regsub -all "." $file "_" node @@ -26,7 +30,7 @@ namespace eval FileOper { set name [file rootname $file] set ext [string range [file extension $file] 1 end] if {$fullPath != ""} { - puts $fullPath + # puts $fullPath return $fullPath } else { return @@ -34,16 +38,23 @@ namespace eval FileOper { } proc OpenFolderDialog {} { - global env + global env activeProject #global tree node types dot env noteBook fontNormal fontBold fileList noteBook projDir activeProject imgDir editor rootDir # set dir $projDir - set dir $env(HOME) + if [info exists activeProject] { + set dir $activeProject + } else { + set dir $env(HOME) + } set fullPath [tk_chooseDirectory -initialdir $dir -parent .] set file [string range $fullPath [expr [string last "/" $fullPath]+1] end] regsub -all "." $file "_" node set dir [file dirname $fullPath] # EditFile .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles $node $fullPath - puts $fullPath + # puts $fullPath + if ![info exists activeProject] { + set activeProject $fullPath + } return $fullPath } @@ -75,7 +86,7 @@ namespace eval FileOper { foreach nbItem [array names modified] { if {$modified($nbItem) eq "true"} { $nbEditor select $nbItem - puts "close tab $nbItem" + # puts "close tab $nbItem" if {[Close] eq "cancel"} {return "cancel"} } } @@ -84,7 +95,7 @@ namespace eval FileOper { proc Close {} { global nbEditor modified tree set nbItem [$nbEditor select] - puts "close tab $nbItem" + # puts "close tab $nbItem" if {$nbItem == ""} {return} if {$modified($nbItem) eq "true"} { @@ -116,11 +127,18 @@ namespace eval FileOper { } proc Save {} { - global nbEditor tree env + global nbEditor tree env activeProject + + if [info exists activeProject] { + set dir $activeProject + } else { + set dir $env(HOME) + } + set nbEditorItem [$nbEditor select] puts "Saved editor text: $nbEditorItem" if [string match "*untitled*" $nbEditorItem] { - set filePath [tk_getSaveFile -initialdir $env(HOME) -filetypes $::types -parent .] + set filePath [tk_getSaveFile -initialdir $dir -filetypes $::types -parent .] if {$filePath eq ""} { return } @@ -129,7 +147,7 @@ namespace eval FileOper { $nbEditor tab $nbEditorItem -text $fileName # set treeitem [Tree::InsertItem $tree {} $filePath "file" $fileName] set lblName "lbl[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end]" - $nbEditorItem.$lblName configure -text $filePath + $nbEditorItem.header.$lblName configure -text $filePath } else { set treeItem "file::[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end ]" set filePath [Tree::GetItemID $tree $treeItem] @@ -165,7 +183,7 @@ namespace eval FileOper { } proc ReadFolder {directory {parent ""}} { - global tree dir lexers + global tree dir lexers project puts "Read the folder $directory" set rList "" if {[catch {cd $directory}] != 0} { diff --git a/lib/tree.tcl b/lib/tree.tcl index 1d008c3..7808b78 100644 --- a/lib/tree.tcl +++ b/lib/tree.tcl @@ -63,7 +63,7 @@ namespace eval Tree { } } append id $type "::" $subNode - puts "Tree ID: $id, tree item: $item" + # puts "Tree ID: $id, tree item: $item" if ![$tree exists $id] { $tree insert $parent end -id "$id" -text " $text" -values "$item" -image $image } diff --git a/projman.tcl b/projman.tcl index 2462990..62c9323 100755 --- a/projman.tcl +++ b/projman.tcl @@ -10,7 +10,7 @@ exec wish "$0" -- "$@" ###################################################### # Version: 2.0.0 # Release: alpha -# Build: 05092022090515 +# Build: 14092022145805 ###################################################### # определим текущую версию, релиз и т.д. @@ -114,6 +114,7 @@ if [info exists opened] { puts $opened foreach path $opened { if [file isdirectory $path] { + set activeProject $path FileOper::ReadFolder $path ReadFilesFromDirectory $path $path # puts "aaa[dict values $project "ansible*"]"