From 3b52b9af348df356e633ca82332bfbecdaf513ec Mon Sep 17 00:00:00 2001 From: svkalinin Date: Thu, 1 Dec 2022 12:37:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=20=D0=B4=D0=B2=D1=83=D1=85=D0=BF=D0=B0=D0=BD?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=80=D0=B5=D0=B6=D0=B8?= =?UTF-8?q?=D0=BC=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20(=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D1=82=D0=B8=D0=B8=D0=BA=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE?= =?UTF-8?q?=D0=B5=20=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/editor.tcl | 57 +++++++++++++++++++++++++++-------------------- lib/files.tcl | 18 ++++++++++----- lib/gui.tcl | 11 ++++++++- lib/procedure.tcl | 8 +++---- lib/tree.tcl | 4 ++-- projman.tcl | 2 +- 6 files changed, 62 insertions(+), 38 deletions(-) diff --git a/lib/editor.tcl b/lib/editor.tcl index 59af511..a10a97b 100644 --- a/lib/editor.tcl +++ b/lib/editor.tcl @@ -729,7 +729,7 @@ namespace eval Editor { $txt tag remove sel {insert linestart} {insert lineend + 1char} return } - proc BindKeys {w txt fileType} { + proc BindKeys {w txt fileType nb} { global cfgVariables # variable txt # set txt $w.frmText.t @@ -747,7 +747,7 @@ namespace eval Editor { bind $txt {OverWrite} bind $txt "Editor::SearchBrackets $txt" bind $txt "Editor::SelectionHighlight $txt" - bind $txt <> "SetModifiedFlag $w" + bind $txt <> "SetModifiedFlag $w $nb" bind $txt ImageBase64Encode bind $txt "Editor::SearchBrackets %W" bind $txt "catch {Editor::GoToFunction $txt}" @@ -1272,7 +1272,7 @@ namespace eval Editor { } # Horizontal split the Editor text widget - proc SplitEditorH {w fileType} { + proc SplitEditorH {w fileType nb} { global cfgVariables puts [$w.panelTxt panes] if [winfo exists $w.frmText2] { @@ -1281,7 +1281,7 @@ namespace eval Editor { focus -force $w.frmText.t.t return } - set frmText [Editor::EditorWidget $w $fileType] + set frmText [Editor::EditorWidget $w $fileType $nb] $frmText.t insert end [$w.frmText.t get 0.0 end] # $w.panelTxt add $w.frmText -weight 0 @@ -1291,25 +1291,34 @@ namespace eval Editor { ReadStructure $frmText.t "" focus -force $frmText.t.t } - - proc SplitEditorV {w fileType} { + + proc SplitEditorV {fileFullPath} { global cfgVariables - .frmBody.panel add $frmTree -weight 0 - - puts [$w.panelTxt panes] - if [winfo exists $w.frmText2] { - $w.panelTxt forget $w.frmText2 - destroy $w.frmText2 + regsub -all {\.|/|\\|\s} $fileFullPath "_" itemName + set itemName ".frmWork.nbEditor2.$itemName" + # puts $itemName + if {[winfo exists $itemName] == 1} { + .frmWork.nbEditor2 forget $itemName + destroy $itemName + if {[llength [.frmWork.nbEditor2 tabs]] == 0} { + if [lsearch -exact [.frmWork.panelNB panes] .frmWork.nbEditor2] { + grid forget .frmWork.nbEditor2 + .frmWork.panelNB forget .frmWork.nbEditor2 + } + } return } - set frmText [Editor::EditorWidget $w $fileType] - $frmText.t insert end [$w.frmText.t get 0.0 end] + pack .frmWork.nbEditor2 -side left -fill both -expand true + pack propagate .frmWork.nbEditor2 false + # grid .frmWork.nbEditor2 -row 0 -column 1 -sticky nsew + # grid columnconfigure .frmWork .frmWork.nbEditor -weight 1 + # grid rowconfigure .frmWork .frmWork.nbEditor -weight 1 + # grid columnconfigure .frmWork .frmWork.nbEditor2 -weight 1 + # grid rowconfigure .frmWork .frmWork.nbEditor2 -weight 1 + .frmWork.panelNB add .frmWork.nbEditor2 -weight 0 + puts [FileOper::Edit $fileFullPath .frmWork.nbEditor2] + - # $w.panelTxt add $w.frmText -weight 0 - $w.panelTxt add $frmText -weight 1 - - $frmText.t see [$w.frmText.t index insert] - # $frmText.t mark set insert [$w.frmText.t index insert] } proc GoToLineNumber {text lineNumber} { @@ -1369,7 +1378,7 @@ namespace eval Editor { focus $win.ent } - proc EditorWidget {fr fileType} { + proc EditorWidget {fr fileType nb} { global cfgVariables editors if [winfo exists $fr.frmText] { @@ -1416,7 +1425,7 @@ namespace eval Editor { } else { Highlight::Default $txt } - BindKeys $fr $txt $fileType + BindKeys $fr $txt $fileType $nb return $frmText } @@ -1451,9 +1460,9 @@ namespace eval Editor { 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::SplitEditorH $fr $fileType" + -command "Editor::SplitEditorH $fr $fileType $nb" ttk::button $fr.header.$btnSplitV -image split_vertical_11x11 \ - -command "Editor::SplitEditorV $fr $fileType" -state disable + -command "Editor::SplitEditorV $fileFullPath" # 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 @@ -1467,7 +1476,7 @@ namespace eval Editor { if {[lsearch -exact $imageType $fileType] != -1} { ImageViewer $fileFullPath $itemName $fr } else { - set frmText [Editor::EditorWidget $fr $fileType] + set frmText [Editor::EditorWidget $fr $fileType $nb] } $fr.panelTxt add $frmText -weight 0 diff --git a/lib/files.tcl b/lib/files.tcl index d063670..925ffba 100644 --- a/lib/files.tcl +++ b/lib/files.tcl @@ -195,9 +195,15 @@ namespace eval FileOper { proc CloseAll {} { global nbEditor modified + foreach nb2Item [.frmWork.nbEditor2 tabs] { + .frmWork.nbEditor2 forget $nb2Item + } + if {[lsearch -exact [.frmWork.panelNB panes] .frmWork.nbEditor2] != -1} { + .frmWork.panelNB forget .frmWork.nbEditor2 + } foreach nbItem [array names modified] { - if {$modified($nbItem) eq "true"} { - $nbEditor select $nbItem + if {[info exists modified($nbItem)] == 1 && $modified($nbItem) eq "true"} { + catch {$nbEditor select $nbItem} # puts "close tab $nbItem" if {[Close] eq "cancel"} {return "cancel"} } @@ -277,7 +283,7 @@ namespace eval FileOper { puts -nonewline $f $editedText puts "$f was saved" close $f - ResetModifiedFlag $nbEditorItem + ResetModifiedFlag $nbEditorItem $nbEditor } proc SaveAll {} { @@ -381,8 +387,8 @@ namespace eval FileOper { $txt see 1.0 } - proc Edit {fileFullPath} { - global nbEditor tree + proc Edit {fileFullPath {nbEditor .frmWork.nbEditor}} { + global tree if {[file exists $fileFullPath] == 0} { return false } else { @@ -414,7 +420,7 @@ namespace eval FileOper { Editor::Editor $fileFullPath $nbEditor $itemName ReadFile $fileFullPath $itemName $itemName.frmText.t highlight 1.0 end - ResetModifiedFlag $itemName + ResetModifiedFlag $itemName $nbEditor $itemName.frmText.t see 1.1 } $nbEditor select $itemName diff --git a/lib/gui.tcl b/lib/gui.tcl index 0f359bb..f859d24 100644 --- a/lib/gui.tcl +++ b/lib/gui.tcl @@ -168,10 +168,19 @@ grid rowconfigure $frmTree 0 -weight 1 set frmWork [ttk::frame .frmWork -border 0 -relief flat] +ttk::panedwindow $frmWork.panelNB -orient horizontal -style TPanedwindow +# grid $frmWork.panelNB -row 0 -column 0 -sticky nesw +pack $frmWork.panelNB -side left -fill both -expand true + set nbEditor [ttk::notebook $frmWork.nbEditor] pack $nbEditor -side left -fill both -expand true +# grid $nbEditor -row 0 -column 0 -sticky nsew +# grid columnconfigure $frmWork $nbEditor -weight 1 +# grid rowconfigure $frmWork $nbEditor -weight 1 -# set nbEditor2 [ttk::notebook $frmWork.nbEditor2] +set nbEditor2 [ttk::notebook $frmWork.nbEditor2] + +$frmWork.panelNB add $nbEditor -weight 10 # pack $nbEditor2 -side left -fill both -expand true # # Create an image CLOSE for tab diff --git a/lib/procedure.tcl b/lib/procedure.tcl index 3b9a574..4e080da 100644 --- a/lib/procedure.tcl +++ b/lib/procedure.tcl @@ -187,16 +187,16 @@ proc YScrollCommand {txt canv} { $canv yview" } -proc ResetModifiedFlag {w} { - global modified nbEditor +proc ResetModifiedFlag {w nbEditor} { + global modified $w.frmText.t edit modified false set modified($w) "false" set lbl [string trimleft [$nbEditor tab $w -text] "* "] # puts "ResetModifiedFlag: $lbl" $nbEditor tab $w -text $lbl } -proc SetModifiedFlag {w} { - global modified nbEditor +proc SetModifiedFlag {w nbEditor} { + global modified #$w.frmText.t edit modified false set modified($w) "true" set lbl [$nbEditor tab $w -text] diff --git a/lib/tree.tcl b/lib/tree.tcl index cb94424..8fb9eae 100644 --- a/lib/tree.tcl +++ b/lib/tree.tcl @@ -107,7 +107,7 @@ namespace eval Tree { # $tree item $id -open false } file { - set v [FileOper::Edit $values] + set v [FileOper::Edit $values $nbEditor] if {$v eq false} { $tree delete $id } @@ -115,7 +115,7 @@ namespace eval Tree { } I[0-9]*? { destroy .findVariables - FileOper::Edit [lindex $values 2] + FileOper::Edit [lindex $values 2] $nbEditor } default { set parentItem [$tree parent $id] diff --git a/projman.tcl b/projman.tcl index dbcdb99..4a3efe7 100755 --- a/projman.tcl +++ b/projman.tcl @@ -10,7 +10,7 @@ exec wish "$0" -- "$@" ###################################################### # Version: 2.0.0 # Release: alpha -# Build: 28112022163633 +# Build: 01122022113755 ###################################################### # определим текущую версию, релиз и т.д.