Исправлено закерытие вкладки по щелчку мыши.

Добавлена настройка переноса строк в редакторе.
Добавлены сочетания клавиш ctrl+pgup cntrl+pgdown  для переключения  между вкладками редактора.
Добавлен диалог закрытия папки (каталога)
This commit is contained in:
svkalinin 2022-08-30 16:44:28 +03:00
parent 1142324008
commit ec3e4ac12e
8 changed files with 102 additions and 30 deletions

View File

@ -99,3 +99,9 @@
- Alt+e - delete text between cursor and line End - Alt+e - delete text between cursor and line End
- Fix close braces indent - Fix close braces indent
30/08/2022
- Fix the clicked by the close button on a tab
- Added "View"->"Editors word wrap" menu and procedure
- Added bindings "Ctrl+PgUp" and "Ctrl+PgDown" for next or prior tab selecting
- Added "Close file" dialog

View File

@ -9,26 +9,23 @@
namespace eval Editor { namespace eval Editor {
variable selectionTex variable selectionTex
# Set the editor option
proc SetOption {optionName value} {
global cfgVariables nbEditor
# apply changes for opened tabs
foreach node [$nbEditor tabs] {
$node.frmText.t configure -$optionName $value
}
}
# Comment one string or selected string
proc Comment {txt fileType} { proc Comment {txt fileType} {
global lexers global lexers
set selIndex [$txt tag ranges sel] set selIndex [$txt tag ranges sel]
set pos [$txt index insert] set pos [$txt index insert]
set lineNum [lindex [split $pos "."] 0] set lineNum [lindex [split $pos "."] 0]
set PosNum [lindex [split $pos "."] 1] set PosNum [lindex [split $pos "."] 1]
# switch $fileType {
# TCL {
# set symbol "#"
# }
# GO {
# set symbol "//"
# }
# Unknown {
# set symbol "#"
# }
# default {
# set symbol "#"
# }
# }
if [dict exists $lexers $fileType commentSymbol] { if [dict exists $lexers $fileType commentSymbol] {
set symbol [dict get $lexers $fileType commentSymbol] set symbol [dict get $lexers $fileType commentSymbol]
} else { } else {
@ -57,6 +54,8 @@ namespace eval Editor {
$txt tag raise comments $txt tag raise comments
} }
} }
# Uncomment one string selected strings
proc Uncomment {txt fileType} { proc Uncomment {txt fileType} {
set selIndex [$txt tag ranges sel] set selIndex [$txt tag ranges sel]
set pos [$txt index insert] set pos [$txt index insert]
@ -456,8 +455,8 @@ namespace eval Editor {
# bind $txt <Control-j> "" # bind $txt <Control-j> ""
bind $txt <Control-i> "ImageBase64Encode $txt" bind $txt <Control-i> "ImageBase64Encode $txt"
# bind $txt <Control-bracketleft> "Editor::InsertTabular $txt" bind $txt <Control-bracketleft> "Editor::InsertTabular $txt"
# bind $txt <Control-bracketright> "Editor::DeleteTabular $txt" bind $txt <Control-bracketright> "Editor::DeleteTabular $txt"
bind $txt <Control-comma> "Editor::Comment $txt $fileType" bind $txt <Control-comma> "Editor::Comment $txt $fileType"
bind $txt <Control-period> "Editor::Uncomment $txt $fileType" bind $txt <Control-period> "Editor::Uncomment $txt $fileType"
@ -785,13 +784,15 @@ namespace eval Editor {
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.s -command "$frmText.t yview"] -side right -fill y pack [ttk::scrollbar $frmText.v -command "$frmText.t yview"] -side right -fill y
ctext $txt -yscrollcommand "$frmText.s set" -font $cfgVariables(font) \ ttk::scrollbar $frmText.h -orient horizontal -command "$frmText.t xview"
ctext $txt -xscrollcommand "$frmText.h set" -yscrollcommand "$frmText.v set" \
-font $cfgVariables(font) -relief flat -wrap $cfgVariables(editorWrap) \
-linemapfg $cfgVariables(lineNumberFG) -linemapbg $cfgVariables(lineNumberBG) \ -linemapfg $cfgVariables(lineNumberFG) -linemapbg $cfgVariables(lineNumberBG) \
-tabs "[expr {4 * [font measure $cfgVariables(font) 0]}] left" -tabstyle tabular -undo true \ -tabs "[expr {4 * [font measure $cfgVariables(font) 0]}] left" -tabstyle tabular -undo true
-relief flat
pack $txt -fill both -expand 1 pack $txt -fill both -expand 1
pack $frmText.h -side bottom -fill x
# puts ">>>>>>> [bindtags $txt]" # puts ">>>>>>> [bindtags $txt]"
if {$cfgVariables(lineNumberShow) eq "false"} { if {$cfgVariables(lineNumberShow) eq "false"} {
$txt configure -linemap 0 $txt configure -linemap 0

View File

@ -48,6 +48,28 @@ namespace eval FileOper {
return $fullPath return $fullPath
} }
proc CloseFolder {} {
global tree nbEditor
set treeItem [$tree selection]
set parent [$tree parent $treeItem]
while {$parent ne ""} {
set treeItem $parent
set parent [$tree parent $treeItem]
}
if {$parent eq "" && [string match "directory::*" $treeItem] == 1} {
# puts "tree root item: $treeItem"
foreach nbItem [$nbEditor tabs] {
set item [string trimleft [file extension $nbItem] "."]
# puts $item
if [$tree exists "file::$item"] {
$nbEditor select $nbItem
Close
}
}
$tree delete $treeItem
}
}
proc CloseAll {} { proc CloseAll {} {
global nbEditor modified global nbEditor modified
foreach nbItem [array names modified] { foreach nbItem [array names modified] {
@ -150,6 +172,7 @@ namespace eval FileOper {
return "" return ""
} }
set parent [Tree::InsertItem $tree {} $directory "directory" [file tail $directory]] set parent [Tree::InsertItem $tree {} $directory "directory" [file tail $directory]]
$tree selection set $parent
# if {[ $tree item $parent -open] eq "false"} { # if {[ $tree item $parent -open] eq "false"} {
# $tree item $parent -open true # $tree item $parent -open true
# } else { # } else {

View File

@ -56,7 +56,9 @@ bind . <Control-K> {
} }
bind . <Control-s> {FileOper::Save} bind . <Control-s> {FileOper::Save}
bind . <Control-S> {FileOper::Save} bind . <Control-S> {FileOper::Save}
bind . <Alt-t> ViewFilesTree bind . <Alt-p> ViewFilesTree
#ttk::style configure TPanedwindow -background blue #ttk::style configure TPanedwindow -background blue
#ttk::style configure Sash -sashthickness 5 #ttk::style configure Sash -sashthickness 5
#ttk::style configure TButton -padding 60 -relief flat -bg black #ttk::style configure TButton -padding 60 -relief flat -bg black
@ -149,9 +151,12 @@ ttk::style layout TNotebook.Tab {
} }
} }
} }
bind TNotebook <Button-1> "catch {NB::PressTab %W %x %y}\;[bind TNotebook <Button-1>];break"
# bind <<NotebookTabChanged>> "NB::PressTab %W %x %y"
bind TNotebook <Button-1> "NB::CloseTab %W %x %y\;[bind TNotebook <Button-1>]" # bind . <Control-Tab> "NB::NextTab $nbEditor"
bind . <Control-Next> "NB::NextTab $nbEditor 1"
bind . <Control-Prior> "NB::NextTab $nbEditor -1"
# ttk::scrollbar $nbEditor.hsb1 -orient horizontal -command [list $frm_tree.work xview] # ttk::scrollbar $nbEditor.hsb1 -orient horizontal -command [list $frm_tree.work xview]
# ttk::scrollbar $fbEditor.vsb1 -orient vertical -command [list $frm_tree.work yview] # ttk::scrollbar $fbEditor.vsb1 -orient vertical -command [list $frm_tree.work yview]
# set tree [ttk::treeview $frm_tree.tree -show tree \ # set tree [ttk::treeview $frm_tree.tree -show tree \

View File

@ -17,14 +17,18 @@ proc GetFileMenu {m} {
FileOper::Edit $filePath FileOper::Edit $filePath
} }
} }
$m add command -label [::msgcat::mc "Save file"] -command {FileOper::Save}\
-accelerator "Ctrl+S"
$m add command -label [::msgcat::mc "Close file"] -command {FileOper::Close}\
-accelerator "Ctrl+w"
$m add command -label [::msgcat::mc "Open folder"] -accelerator "Ctrl+K" -command { $m add command -label [::msgcat::mc "Open folder"] -accelerator "Ctrl+K" -command {
set folderPath [FileOper::OpenFolderDialog] set folderPath [FileOper::OpenFolderDialog]
if {$folderPath != ""} { if {$folderPath != ""} {
FileOper::ReadFolder $folderPath FileOper::ReadFolder $folderPath
} }
} }
$m add command -label [::msgcat::mc "Save file"] -command {FileOper::Save}\ $m add command -label [::msgcat::mc "Close folder"] -command {FileOper::CloseFolder}
-accelerator "Ctrl+S"
#$m add command -label [::msgcat::mc "Open"] -command {FileDialog $tree open}\ #$m add command -label [::msgcat::mc "Open"] -command {FileDialog $tree open}\
#-font $fontNormal -accelerator "Ctrl+O" -state disable #-font $fontNormal -accelerator "Ctrl+O" -state disable
$m add separator $m add separator
@ -68,8 +72,18 @@ proc GetViewMenu {m} {
$m.panelSide add radiobutton -label [::msgcat::mc "Left"] -variable cfgVariables(filesPanelPlace) -value left $m.panelSide add radiobutton -label [::msgcat::mc "Left"] -variable cfgVariables(filesPanelPlace) -value left
$m.panelSide add radiobutton -label [::msgcat::mc "Right"] -variable cfgVariables(filesPanelPlace) -value right $m.panelSide add radiobutton -label [::msgcat::mc "Right"] -variable cfgVariables(filesPanelPlace) -value right
$m add separator
$m add command -label [::msgcat::mc "View line numbers"] -command ViewLineNumbers $m add command -label [::msgcat::mc "View line numbers"] -command ViewLineNumbers
menu $m.editorWrap
$m add cascade -label [::msgcat::mc "Editors word wrapping"] -menu $m.editorWrap
$m.editorWrap add radiobutton -label [::msgcat::mc "None"] -variable cfgVariables(editorWrap) -value none \
-command "Editor::SetOption wrap $cfgVariables(editorWrap)"
$m.editorWrap add radiobutton -label [::msgcat::mc "Char"] -variable cfgVariables(editorWrap) -value char \
-command "Editor::SetOption wrap $cfgVariables(editorWrap)"
$m.editorWrap add radiobutton -label [::msgcat::mc "Word"] -variable cfgVariables(editorWrap) -value word \
-command "Editor::SetOption wrap $cfgVariables(editorWrap)"
} }
proc GetHelpMenu {m} { proc GetHelpMenu {m} {

View File

@ -19,8 +19,11 @@
::msgcat::mcset ru "Braces foreground" "Цвет скобки" ::msgcat::mcset ru "Braces foreground" "Цвет скобки"
::msgcat::mcset ru "Cancel" "Отмена" ::msgcat::mcset ru "Cancel" "Отмена"
::msgcat::mcset ru "Can't found file:" "Не найден файл:" ::msgcat::mcset ru "Can't found file:" "Не найден файл:"
::msgcat::mcset ru "Char" "Символ"
::msgcat::mcset ru "Close" "Закрыть" ::msgcat::mcset ru "Close" "Закрыть"
::msgcat::mcset ru "Close all" "Закрыть все" ::msgcat::mcset ru "Close all" "Закрыть все"
::msgcat::mcset ru "Close file" "Закрыть файл"
::msgcat::mcset ru "Close folder" "Закрыть папку"
::msgcat::mcset ru "Close Project Manager?" "Выйти из программы?" ::msgcat::mcset ru "Close Project Manager?" "Выйти из программы?"
::msgcat::mcset ru "Comments" "Коментарии" ::msgcat::mcset ru "Comments" "Коментарии"
::msgcat::mcset ru "Comment selected" "Закоментировать" ::msgcat::mcset ru "Comment selected" "Закоментировать"
@ -113,6 +116,7 @@
::msgcat::mcset ru "New project" "Новый проект" ::msgcat::mcset ru "New project" "Новый проект"
::msgcat::mcset ru "Not implemented yet" "Данная функция пока не реализована" ::msgcat::mcset ru "Not implemented yet" "Данная функция пока не реализована"
::msgcat::mcset ru "Not found active project" "Не определен активный проект" ::msgcat::mcset ru "Not found active project" "Не определен активный проект"
::msgcat::mcset ru "None" "Нет"
::msgcat::mcset ru "No" "Нет" ::msgcat::mcset ru "No" "Нет"
::msgcat::mcset ru "Open" "Открыть" ::msgcat::mcset ru "Open" "Открыть"
::msgcat::mcset ru "Open file" "Открыть файл" ::msgcat::mcset ru "Open file" "Открыть файл"
@ -193,6 +197,7 @@
::msgcat::mcset ru "View line numbers" "Показывать номера строк" ::msgcat::mcset ru "View line numbers" "Показывать номера строк"
::msgcat::mcset ru "Warning" "Внимание" ::msgcat::mcset ru "Warning" "Внимание"
::msgcat::mcset ru "Was replacement" "Было заменено" ::msgcat::mcset ru "Was replacement" "Было заменено"
::msgcat::mcset ru "Word wrapping" "Перенос слов" ::msgcat::mcset ru "Word" "Слово"
::msgcat::mcset ru "Editors word wrapping" "Перенос слов в редакторе"
::msgcat::mcset ru "Work dir" "Рабочий каталог" ::msgcat::mcset ru "Work dir" "Рабочий каталог"
::msgcat::mcset ru "Yes" "Да" ::msgcat::mcset ru "Yes" "Да"

View File

@ -24,13 +24,31 @@ namespace eval NB {
} }
} }
} }
puts "NB item - $fm" # puts "NB item - $fm"
return $fm return $fm
} }
proc CloseTab {w x y} { proc PressTab {w x y} {
$w select [$w identify tab $x $y]
if {[$w identify $x $y] == "close_button"} { if {[$w identify $x $y] == "close_button"} {
FileOper::Close FileOper::Close
} else {
set txt [$w select].frmText.t
focus -force $txt.t
} }
} }
proc NextTab {w step} {
set i [expr [$w index end] - 1]
set nbItemIndex [$w index [$w select]]
if {$nbItemIndex eq 0 && $step eq "-1"} {
$w select $i
} elseif {$nbItemIndex eq $i && $step eq "1"} {
$w select 0
} else {
$w select [expr $nbItemIndex + $step]
}
set txt [$w select].frmText.t
focus -force $txt.t
}
} }

View File

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