Добавлено горизонтальное разделение окна редактора.
Исправлено удаление строки по Alt+R - реперь строка удаляется полностью вместе с символами переноса. Исправлено сохранение нового файла (untitled) но всеравно как-то криво.
This commit is contained in:
parent
4b4f15a5fc
commit
a7b6c48a42
|
@ -109,3 +109,9 @@
|
||||||
- Added search function name into Function navigation whem press key
|
- Added search function name into Function navigation whem press key
|
||||||
- Added find and replace dialog
|
- Added find and replace dialog
|
||||||
- Fixed correct placement the Function 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
|
||||||
|
|
||||||
|
|
110
lib/editor.tcl
110
lib/editor.tcl
|
@ -436,10 +436,10 @@ namespace eval Editor {
|
||||||
if {$key == 63 || $key == 107 || $key == 108 || $key == 112} {return "true"}
|
if {$key == 63 || $key == 107 || $key == 108 || $key == 112} {return "true"}
|
||||||
}
|
}
|
||||||
|
|
||||||
proc BindKeys {w fileType} {
|
proc BindKeys {w txt fileType} {
|
||||||
global cfgVariables
|
global cfgVariables
|
||||||
# variable txt
|
# variable txt
|
||||||
set txt $w.frmText.t
|
# set txt $w.frmText.t
|
||||||
bind $txt <KeyRelease> "Editor::ReleaseKey %K $txt"
|
bind $txt <KeyRelease> "Editor::ReleaseKey %K $txt"
|
||||||
bind $txt <KeyPress> "Editor::PressKey %K $txt"
|
bind $txt <KeyPress> "Editor::PressKey %K $txt"
|
||||||
# bind $txt <KeyRelease> "Editor::Key %k %K"
|
# bind $txt <KeyRelease> "Editor::Key %k %K"
|
||||||
|
@ -496,9 +496,9 @@ namespace eval Editor {
|
||||||
bind $txt <Control-i> ImageBase64Encode
|
bind $txt <Control-i> ImageBase64Encode
|
||||||
bind $txt <Control-u> "Editor::SearchBrackets %W"
|
bind $txt <Control-u> "Editor::SearchBrackets %W"
|
||||||
bind $txt <Control-J> "catch {Editor::GoToFunction $w}"
|
bind $txt <Control-J> "catch {Editor::GoToFunction $w}"
|
||||||
bind $txt <Control-j> "catch {Editor::GoToFunction $w}"
|
bind $txt <Control-j> "catch {Editor::GoToFunction $w}; break"
|
||||||
bind $txt <Alt-w> "$txt delete {insert wordstart} {insert wordend}"
|
bind $txt <Alt-w> "$txt delete {insert wordstart} {insert wordend}"
|
||||||
bind $txt <Alt-r> "$txt delete {insert linestart} {insert lineend}"
|
bind $txt <Alt-r> "$txt delete {insert linestart} {insert lineend + 1char}"
|
||||||
bind $txt <Alt-b> "$txt delete {insert linestart} insert"
|
bind $txt <Alt-b> "$txt delete {insert linestart} insert"
|
||||||
bind $txt <Alt-e> "$txt delete insert {insert lineend}"
|
bind $txt <Alt-e> "$txt delete insert {insert lineend}"
|
||||||
}
|
}
|
||||||
|
@ -992,58 +992,36 @@ proc FindFunction {findString} {
|
||||||
focus -force $win.entryFind
|
focus -force $win.entryFind
|
||||||
}
|
}
|
||||||
|
|
||||||
proc SplitEditor {w orient} {
|
proc SplitEditor {w fileType} {
|
||||||
ttk::panedwindow $w.panelTxt -orient horizontal -style TPanedwindow
|
global cfgVariables
|
||||||
pack propagate $w.panelTxt false
|
puts [$w.panelTxt panes]
|
||||||
set frmText [ttk::frame $w.frmText2 -border 1]
|
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]
|
||||||
|
|
||||||
pack $frmText -side top -expand true -fill both
|
# $w.panelTxt add $w.frmText -weight 0
|
||||||
ctext $frmText.t2
|
|
||||||
pack $frmText.t2 -fill both -expand 1
|
|
||||||
$frmText.t2 insert end [$w.frmText.t get 0.0 end]
|
|
||||||
|
|
||||||
$w.panelTxt add $w.frmText -weight 0
|
|
||||||
$w.panelTxt add $w.frmText2 -weight 1
|
$w.panelTxt add $w.frmText2 -weight 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proc Editor {fileFullPath nb itemName} {
|
proc EditorWidget {fr fileType} {
|
||||||
global cfgVariables editors
|
global cfgVariables editors
|
||||||
set fr $itemName
|
|
||||||
if ![string match "*untitled*" $itemName] {
|
if [winfo exists $fr.frmText] {
|
||||||
set lblText $fileFullPath
|
set frmText [ttk::frame $fr.frmText2 -border 1]
|
||||||
} else {
|
} else {
|
||||||
set lblText ""
|
|
||||||
|
|
||||||
}
|
|
||||||
ttk::frame $fr.header
|
|
||||||
|
|
||||||
set frmText [ttk::frame $fr.frmText -border 1]
|
set frmText [ttk::frame $fr.frmText -border 1]
|
||||||
|
}
|
||||||
set txt $frmText.t
|
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 frmText [ttk::frame $fr.frmText -border 1]
|
||||||
# set txt $frmText.t
|
# set txt $frmText.t
|
||||||
|
|
||||||
|
|
||||||
pack $frmText -side top -expand true -fill both
|
pack $frmText -side top -expand true -fill both
|
||||||
|
|
||||||
|
|
||||||
pack [ttk::scrollbar $frmText.v -command "$frmText.t yview"] -side right -fill y
|
pack [ttk::scrollbar $frmText.v -command "$frmText.t yview"] -side right -fill y
|
||||||
ttk::scrollbar $frmText.h -orient horizontal -command "$frmText.t xview"
|
ttk::scrollbar $frmText.h -orient horizontal -command "$frmText.t xview"
|
||||||
ctext $txt -xscrollcommand "$frmText.h set" -yscrollcommand "$frmText.v set" \
|
ctext $txt -xscrollcommand "$frmText.h set" -yscrollcommand "$frmText.v set" \
|
||||||
|
@ -1060,9 +1038,6 @@ proc FindFunction {findString} {
|
||||||
$txt tag configure lightBracket -background $cfgVariables(selectLightBg) -foreground #00ffff
|
$txt tag configure lightBracket -background $cfgVariables(selectLightBg) -foreground #00ffff
|
||||||
$txt tag configure lightSelected -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 ">$fileType<"
|
||||||
# puts [info procs Highlight::GO]
|
# puts [info procs Highlight::GO]
|
||||||
dict set editors $txt fileType $fileType
|
dict set editors $txt fileType $fileType
|
||||||
|
@ -1077,13 +1052,46 @@ proc FindFunction {findString} {
|
||||||
} else {
|
} else {
|
||||||
Highlight::Default $txt
|
Highlight::Default $txt
|
||||||
}
|
}
|
||||||
|
BindKeys $fr $txt $fileType
|
||||||
|
return $frmText
|
||||||
|
}
|
||||||
|
|
||||||
BindKeys $itemName $fileType
|
proc Editor {fileFullPath nb itemName} {
|
||||||
# bind $txt <Return> {
|
global cfgVariables editors
|
||||||
# regexp {^(\s*)} [%W get "insert linestart" end] -> spaceStart
|
set fr $itemName
|
||||||
# %W insert insert "\n$spaceStart"
|
if ![string match "*untitled*" $itemName] {
|
||||||
# break
|
set lblText $fileFullPath
|
||||||
# }
|
} else {
|
||||||
|
set lblText ""
|
||||||
|
|
||||||
|
}
|
||||||
|
set fileType [string toupper [string trimleft [file extension $fileFullPath] "."]]
|
||||||
|
if {$fileType eq ""} {set fileType "Unknown"}
|
||||||
|
|
||||||
|
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
|
return $fr
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,12 @@ namespace eval FileOper {
|
||||||
}
|
}
|
||||||
|
|
||||||
proc OpenDialog {} {
|
proc OpenDialog {} {
|
||||||
global env
|
global env project activeProject
|
||||||
|
if [info exists activeProject] {
|
||||||
|
set dir $activeProject
|
||||||
|
} else {
|
||||||
set dir $env(HOME)
|
set dir $env(HOME)
|
||||||
|
}
|
||||||
set fullPath [tk_getOpenFile -initialdir $dir -filetypes $::types -parent .]
|
set fullPath [tk_getOpenFile -initialdir $dir -filetypes $::types -parent .]
|
||||||
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
|
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
|
||||||
regsub -all "." $file "_" node
|
regsub -all "." $file "_" node
|
||||||
|
@ -26,7 +30,7 @@ namespace eval FileOper {
|
||||||
set name [file rootname $file]
|
set name [file rootname $file]
|
||||||
set ext [string range [file extension $file] 1 end]
|
set ext [string range [file extension $file] 1 end]
|
||||||
if {$fullPath != ""} {
|
if {$fullPath != ""} {
|
||||||
puts $fullPath
|
# puts $fullPath
|
||||||
return $fullPath
|
return $fullPath
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
|
@ -34,16 +38,23 @@ namespace eval FileOper {
|
||||||
}
|
}
|
||||||
|
|
||||||
proc OpenFolderDialog {} {
|
proc OpenFolderDialog {} {
|
||||||
global env
|
global env activeProject
|
||||||
#global tree node types dot env noteBook fontNormal fontBold fileList noteBook projDir activeProject imgDir editor rootDir
|
#global tree node types dot env noteBook fontNormal fontBold fileList noteBook projDir activeProject imgDir editor rootDir
|
||||||
# set dir $projDir
|
# set dir $projDir
|
||||||
|
if [info exists activeProject] {
|
||||||
|
set dir $activeProject
|
||||||
|
} else {
|
||||||
set dir $env(HOME)
|
set dir $env(HOME)
|
||||||
|
}
|
||||||
set fullPath [tk_chooseDirectory -initialdir $dir -parent .]
|
set fullPath [tk_chooseDirectory -initialdir $dir -parent .]
|
||||||
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
|
set file [string range $fullPath [expr [string last "/" $fullPath]+1] end]
|
||||||
regsub -all "." $file "_" node
|
regsub -all "." $file "_" node
|
||||||
set dir [file dirname $fullPath]
|
set dir [file dirname $fullPath]
|
||||||
# EditFile .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles $node $fullPath
|
# EditFile .frmBody.frmCat.noteBook.ffiles.frmTreeFiles.treeFiles $node $fullPath
|
||||||
puts $fullPath
|
# puts $fullPath
|
||||||
|
if ![info exists activeProject] {
|
||||||
|
set activeProject $fullPath
|
||||||
|
}
|
||||||
|
|
||||||
return $fullPath
|
return $fullPath
|
||||||
}
|
}
|
||||||
|
@ -75,7 +86,7 @@ namespace eval FileOper {
|
||||||
foreach nbItem [array names modified] {
|
foreach nbItem [array names modified] {
|
||||||
if {$modified($nbItem) eq "true"} {
|
if {$modified($nbItem) eq "true"} {
|
||||||
$nbEditor select $nbItem
|
$nbEditor select $nbItem
|
||||||
puts "close tab $nbItem"
|
# puts "close tab $nbItem"
|
||||||
if {[Close] eq "cancel"} {return "cancel"}
|
if {[Close] eq "cancel"} {return "cancel"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +95,7 @@ namespace eval FileOper {
|
||||||
proc Close {} {
|
proc Close {} {
|
||||||
global nbEditor modified tree
|
global nbEditor modified tree
|
||||||
set nbItem [$nbEditor select]
|
set nbItem [$nbEditor select]
|
||||||
puts "close tab $nbItem"
|
# puts "close tab $nbItem"
|
||||||
|
|
||||||
if {$nbItem == ""} {return}
|
if {$nbItem == ""} {return}
|
||||||
if {$modified($nbItem) eq "true"} {
|
if {$modified($nbItem) eq "true"} {
|
||||||
|
@ -116,11 +127,18 @@ namespace eval FileOper {
|
||||||
}
|
}
|
||||||
|
|
||||||
proc Save {} {
|
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]
|
set nbEditorItem [$nbEditor select]
|
||||||
puts "Saved editor text: $nbEditorItem"
|
puts "Saved editor text: $nbEditorItem"
|
||||||
if [string match "*untitled*" $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 ""} {
|
if {$filePath eq ""} {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -129,7 +147,7 @@ namespace eval FileOper {
|
||||||
$nbEditor tab $nbEditorItem -text $fileName
|
$nbEditor tab $nbEditorItem -text $fileName
|
||||||
# set treeitem [Tree::InsertItem $tree {} $filePath "file" $fileName]
|
# set treeitem [Tree::InsertItem $tree {} $filePath "file" $fileName]
|
||||||
set lblName "lbl[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end]"
|
set lblName "lbl[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end]"
|
||||||
$nbEditorItem.$lblName configure -text $filePath
|
$nbEditorItem.header.$lblName configure -text $filePath
|
||||||
} else {
|
} else {
|
||||||
set treeItem "file::[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end ]"
|
set treeItem "file::[string range $nbEditorItem [expr [string last "." $nbEditorItem] +1] end ]"
|
||||||
set filePath [Tree::GetItemID $tree $treeItem]
|
set filePath [Tree::GetItemID $tree $treeItem]
|
||||||
|
@ -165,7 +183,7 @@ namespace eval FileOper {
|
||||||
}
|
}
|
||||||
|
|
||||||
proc ReadFolder {directory {parent ""}} {
|
proc ReadFolder {directory {parent ""}} {
|
||||||
global tree dir lexers
|
global tree dir lexers project
|
||||||
puts "Read the folder $directory"
|
puts "Read the folder $directory"
|
||||||
set rList ""
|
set rList ""
|
||||||
if {[catch {cd $directory}] != 0} {
|
if {[catch {cd $directory}] != 0} {
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace eval Tree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
append id $type "::" $subNode
|
append id $type "::" $subNode
|
||||||
puts "Tree ID: $id, tree item: $item"
|
# puts "Tree ID: $id, tree item: $item"
|
||||||
if ![$tree exists $id] {
|
if ![$tree exists $id] {
|
||||||
$tree insert $parent end -id "$id" -text " $text" -values "$item" -image $image
|
$tree insert $parent end -id "$id" -text " $text" -values "$item" -image $image
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ exec wish "$0" -- "$@"
|
||||||
######################################################
|
######################################################
|
||||||
# Version: 2.0.0
|
# Version: 2.0.0
|
||||||
# Release: alpha
|
# Release: alpha
|
||||||
# Build: 05092022090515
|
# Build: 14092022145805
|
||||||
######################################################
|
######################################################
|
||||||
|
|
||||||
# определим текущую версию, релиз и т.д.
|
# определим текущую версию, релиз и т.д.
|
||||||
|
@ -114,6 +114,7 @@ if [info exists opened] {
|
||||||
puts $opened
|
puts $opened
|
||||||
foreach path $opened {
|
foreach path $opened {
|
||||||
if [file isdirectory $path] {
|
if [file isdirectory $path] {
|
||||||
|
set activeProject $path
|
||||||
FileOper::ReadFolder $path
|
FileOper::ReadFolder $path
|
||||||
ReadFilesFromDirectory $path $path
|
ReadFilesFromDirectory $path $path
|
||||||
# puts "aaa[dict values $project "ansible*"]"
|
# puts "aaa[dict values $project "ansible*"]"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user