Добавлено горизонтальное разделение окна редактора.
Исправлено удаление строки по 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 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
|
||||
|
||||
|
|
112
lib/editor.tcl
112
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 <KeyRelease> "Editor::ReleaseKey %K $txt"
|
||||
bind $txt <KeyPress> "Editor::PressKey %K $txt"
|
||||
# bind $txt <KeyRelease> "Editor::Key %k %K"
|
||||
|
@ -496,9 +496,9 @@ namespace eval Editor {
|
|||
bind $txt <Control-i> ImageBase64Encode
|
||||
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}; break"
|
||||
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-e> "$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 <Return> {
|
||||
# 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
|
||||
}
|
||||
|
|
|
@ -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} {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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*"]"
|
||||
|
|
Loading…
Reference in New Issue
Block a user