Реализован двухпанельный режим работы (вертиикальное разделение)

This commit is contained in:
svkalinin 2022-12-01 12:37:13 +03:00
parent 47f6cc436a
commit 3b52b9af34
6 changed files with 62 additions and 38 deletions

View File

@ -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 <Insert> {OverWrite}
bind $txt <ButtonRelease-1> "Editor::SearchBrackets $txt"
bind $txt <Button-1><ButtonRelease-1> "Editor::SelectionHighlight $txt"
bind $txt <<Modified>> "SetModifiedFlag $w"
bind $txt <<Modified>> "SetModifiedFlag $w $nb"
bind $txt <Control-i> ImageBase64Encode
bind $txt <Control-u> "Editor::SearchBrackets %W"
bind $txt <Control-J> "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
@ -1292,24 +1292,33 @@ namespace eval Editor {
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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
######################################################
# Version: 2.0.0
# Release: alpha
# Build: 28112022163633
# Build: 01122022113755
######################################################
# определим текущую версию, релиз и т.д.