Допилдивание процедуры автоввода имен переменных

This commit is contained in:
svkalinin 2022-11-03 15:58:07 +03:00
parent c379f6d70b
commit 654819d192
5 changed files with 99 additions and 64 deletions

View File

@ -366,6 +366,51 @@ namespace eval Editor {
}
}
proc VarHelperKey { widget K A } {
set win .varhelper
set ind [$win.lBox curselection]
puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
switch -- $K {
Prior {
set up [expr [$win.lBox index active] - [$win.lBox cget -height]]
if { $up < 0 } { set up 0 }
$win.lBox activate $up
$win.lBox selection clear 0 end
$win.lBox selection set $up $up
}
Next {
set down [expr [$win.lBox index active] + [$win.lBox cget -height]]
if { $down >= [$win.lBox index end] } { set down end }
$win.lBox activate $down
$win.lBox selection clear 0 end
$win.lBox selection set $down $down
}
Up {
set up [expr [$win.lBox index active] - 1]
if { $up < 0 } { set up 0 }
$win.lBox activate $up
$win.lBox selection clear 0 end
$win.lBox selection set $up $up
}
Down {
set down [expr [$win.lBox index active] + 1]
if { $down >= [$win.lBox index end] } { set down end }
$win.lBox activate $down
$win.lBox selection clear 0 end
$win.lBox selection set $down $down
}
Return {
$widget delete "insert - 1 chars wordstart" "insert wordend - 1 chars"
$widget insert "insert" [$win.lBox get [$win.lBox curselection]]
eval [bind VarHelperBind <Escape>]
}
default {
$widget insert "insert" $A
eval [bind VarHelperBind <Escape>]
}
}
} ;# proc auto_completition_key
proc VarHelper {x y w word} {
global editors lexers variables
@ -375,7 +420,16 @@ namespace eval Editor {
set txt $w
set win .varhelper
# puts "$x $y $w $word"
set varList [dict get $editors $txt variableList]
if {[dict exists $editors $txt variableList] != 0} {
set varList [dict get $editors $txt variableList]
}
if {[dict exists $editors $txt procedureList] != 0} {
set procList [dict get $editors $txt procedureList]
}
if {[dict exists $editors $txt variableList] == 0 && [dict exists $editors $txt procedureList] == 0} {
return
}
set findedVars ""
foreach i [lsearch -all $varList $word*] {
# puts [lindex $varList $i]
@ -385,6 +439,11 @@ namespace eval Editor {
lappend findedVars $item
}
}
bindtags $txt [list VarHelperBind [winfo toplevel $txt] $txt Text sysAfter all]
bind VarHelperBind <Escape> "bindtags $txt {[list [winfo toplevel $txt] $txt Text sysAfter all]}; catch { destroy .varhelper }"
bind VarHelperBind <Key> {Editor::VarHelperKey %W %K %A ; break}
if { [winfo exists $win] } { destroy $win }
if {$findedVars eq ""} {
return
@ -394,11 +453,8 @@ namespace eval Editor {
wm transient $win .
wm overrideredirect $win 1
# listbox $win.lBox -width 30 -border 2 -yscrollcommand "$win.yscroll set" -border 1
# ttk::scrollbar $win.yscroll -orient vertical -command "$win.lBox yview"
listbox $win.lBox -width 30 -border 2 -border 1
pack $win.lBox -expand true -fill y -side left
# pack $win.yscroll -side left -expand false -fill y
foreach { word } $findedVars {
$win.lBox insert end $word
@ -408,16 +464,8 @@ namespace eval Editor {
if { [set height [llength $findedVars]] > 10 } { set height 10 }
$win.lBox configure -height $height
# bindtags $win.lBox [list VarHelperBind [winfo toplevel $win.lBox] $win.lBox Text sysAfter all]
# bind VarHelperBind <Escape> "bindtags $win.lBox {[list [winfo toplevel $win.lBox] $win.lBox Text sysAfter all]}; catch { destroy .varhelper }"
bind $txt <Escape> {
bind $Editor::txt <Escape> {}
destroy $Editor::win
focus -force $Editor::txt.t
break
}
bind $win <Escape> {
bind $txt <Escape> {}
destroy $Editor::win
focus -force $Editor::txt.t
break
@ -427,51 +475,15 @@ namespace eval Editor {
focus -force $Editor::txt.t
break
}
bind $win.lBox <Return> {
set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString]
set values [.varhelper.lBox get [.varhelper.lBox curselection]]
regsub -all {PROCNAME} $findString $values str
Editor::FindFunction $Editor::txt "$str"
destroy .varhelper.lBox
# focus $Editor::txt.t
# bind $Editor::txt <KeyRelease> "Editor::ReleaseKey %K $txt"
# bind $Editor::txt <KeyPress> "Editor::PressKey %K $txt"
# bind $Editor::txt <Up> ""
# bind $Editor::txt <Down> ""
break
}
# bind $txt <KeyRelease> ""
# bind $txt <KeyPress> ""
# bind $txt <Down> {
# set index [.varhelper.lBox index active]
# .varhelper.lBox selection clear $index $index
# set index [expr $index + 1]
# puts $index
# .varhelper.lBox activate $index
# .varhelper.lBox selection set $index $index
# bind $win.lBox <Return> {
# set findString [dict get $lexers [dict get $editors $Editor::txt fileType] procFindString]
# set values [.varhelper.lBox get [.varhelper.lBox curselection]]
# regsub -all {PROCNAME} $findString $values str
# Editor::FindFunction $Editor::txt "$str"
# destroy .varhelper.lBox
# # focus $Editor::txt.t
# break
# }
# bind $txt <Up> {
# set index [.varhelper.lBox index active]
# .varhelper.lBox selection clear $index $index
# if {$index eq "0" } {
# set index [.varhelper.lBox size]
# } else {
# set index [expr $index - 1]
# }
# puts $index
# .varhelper.lBox activate $index
# .varhelper.lBox selection set $index $index
# break
# }
# bind $win.lBox <Down> {
# set index [.varhelper.lBox curselection]
# puts $index
# # .varhelper.lBox selection set [incr index] 0
# .varhelper.lBox activate $index
# }
# # bind $win.lBox <Any-Key> {Editor::ListBoxSearch %W %A}
# Определям расстояние до края экрана (основного окна) и если
# оно меньше размера окна со списком то сдвигаем его вверх

View File

@ -81,12 +81,24 @@ proc GetViewMenu {m} {
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)"
$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)"
$m add separator
menu $m.editorHelper
$m add cascade -label [::msgcat::mc "Editor helpers"] -menu $m.editorHelper
$m.editorHelper add checkbutton -label [::msgcat::mc "Variables"] \
-variable cfgVariables(variableHelper) -onvalue true -offvalue false
# -command "ViewHelper variableHelper"
$m.editorHelper add checkbutton -label [::msgcat::mc "Procedures"] \
-variable cfgVariables(procedureHelper) -onvalue true -offvalue false
# -command "ViewHelper procedureHelper"
}
proc GetHelpMenu {m} {

View File

@ -74,6 +74,7 @@
::msgcat::mcset ru "Editor font" "Шрифт редактора"
::msgcat::mcset ru "Editor font bold" "Шрифт редактора жирный"
::msgcat::mcset ru "Editor settings" "Настройки редактора"
::msgcat::mcset ru "Editor helpers" "Подсказки при вводе"
::msgcat::mcset ru "Encode" "Перекодировка"
::msgcat::mcset ru "Authorisation required" "Требуется авторизация"
::msgcat::mcset ru "Error open URL" "Ошибка открытия URL"
@ -140,7 +141,6 @@
::msgcat::mcset ru "Operators" "Операторы"
::msgcat::mcset ru "Overwrite" "Замена"
::msgcat::mcset ru "Parameters" "Параметры"
::msgcat::mcset ru "Subparameters" "Субпараметры"
::msgcat::mcset ru "Password" "Пароль"
::msgcat::mcset ru "Paste" "Вставить"
::msgcat::mcset ru "Paste from clipboard" "Вставить из буфера"
@ -149,6 +149,7 @@
::msgcat::mcset ru "Print" "Печать"
::msgcat::mcset ru "Print command" "Команда печати"
::msgcat::mcset ru "Print selected text" "Печатать выделенный текст"
::msgcat::mcset ru "Procedures" "Процедуры"
::msgcat::mcset ru "Procedure name" "Имя процедуры"
::msgcat::mcset ru "Procedure name complit" "Автодобивка процедуры"
::msgcat::mcset ru "Program finished successfully" "Выполнение завершено"
@ -198,6 +199,7 @@
::msgcat::mcset ru "Specify the absolute path to the directory or file" "Укажите полный путь к каталогу или файлу"
::msgcat::mcset ru "Split edit window" "Разделить окно редактора"
::msgcat::mcset ru "SQL commands" "SQL команды"
::msgcat::mcset ru "Subparameters" "Субпараметры"
::msgcat::mcset ru "Text autoformat" "Автоформат текста"
::msgcat::mcset ru "Thanks" "Благодарности"
::msgcat::mcset ru "Title normal" "Файл нормальный"

View File

@ -55,6 +55,15 @@ proc ViewLineNumbers {} {
}
}
proc ViewHelper {helper} {
global cfgVariables
# Changed global settigs
if {$cfgVariables($helper) eq "true"} {
set cfgVariables($helper) false
} else {
set cfgVariables($helper) true
}
}
proc Del {} {
return
}

View File

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