::alitedTop

The alited stands for "a lite editor".

The main features of alited are:

  • structured code
  • easy access to the code
  • born for Tcl/Tk development only

It satisfies most requirements of Tcl Editors, adding its own features.

Edited by alited are Tcl/Tk files. The C/C++ code is another target of alited, still for Tcl/Tk development only all the same.

The alited facilitates the development and the maintenance of Tcl/Tk code, particularly because of the unit tree being a sort of documentation.


Linksalited, Top

For a quick acquaintance of alited, a few of demo videos are available:


Inevitable blah-blahalited, Top

The alited project started 1 March 2021 and as such isn't complete, perfect etc. And in no way and in no time it will be so.

In fact, alited has been developed by its own means since v0.2. Inspite of permanent overheads of this way and a raw state of alited, it turned out to be amazingly productive, more and more in the course of time.

Below is a screenshot of alited, just to glance at it:

... and its localized and themed variant:


Commandsalited, Top




Exit [::alited]alited, Top

Closes alited application.

Exit ?w? ?res? ?ask?
Parameters
wnot used; optional, default ""
resresult of running of main window; optional, default 0
askif "yes", requests the confirmation of the exit; optional, default yes

proc ::alited::Exit {{w {}} {res 0} {ask yes}} { # Closes alited application. # w - not used # res - result of running of main window # ask - if "yes", requests the confirmation of the exit variable al variable obPav if {!$ask || !$al(INI,confirmexit) || [msg yesno ques [msgcat::mc {Quit alited?}]]} { if {[alited::file::AllSaved]} { $obPav res $al(WIN) $res alited::find::_close alited::tool::_close } } }




FgFgBold [::alited]alited, Top

Gets foregrounds of normal and colored text of current color scheme.

FgFgBold

proc ::alited::FgFgBold {} { # Gets foregrounds of normal and colored text of current color scheme. variable obPav lassign [$obPav csGet] - fg - - - - - - - fgbold return [list $fg $fgbold] }




Help [::alited]alited, Top

Reads and shows a help file.

Help win ?suff?
Parameters
wincurrently active window
suffsuffix for a help file's name; optional, default ""

proc ::alited::Help {win {suff {}}} { # Reads and shows a help file. # win - currently active window # suff - suffix for a help file's name variable DATADIR variable al variable obDlg set fname [lindex [split [dict get [info frame -1] proc] :] end-2] set fname [file join [file join $DATADIR help] $fname$suff.txt] if {[file exists $fname]} { set msg [::apave::readTextFile $fname] } else { set msg "Here should be a text of\n\"$fname\"" } if {$alited::al(DEBUG)} { after idle [list baltip::tip .alwin.diaaliteddlg1.fra.butOK $fname] } msg ok {} $msg -title Help -text 1 -geometry root=$win -scroll no -noesc 1 }




HelpAbout [::alited]alited, Top

Shows "About..." dialogue.

HelpAbout

proc ::alited::HelpAbout {} { # Shows "About..." dialogue. source [file join $alited::SRCDIR about.tcl] about::About }




HelpAlited [::alited]alited, Top

Shows a main help of alited.

HelpAlited

proc ::alited::HelpAlited {} { # Shows a main help of alited. ::apave::openDoc [file join $alited::DIR doc index.html] }




Message [::alited]alited, Top

Displays a message in statusbar.

Message msg ?mode? ?lab? ?first?
Parameters
msgmessage
mode1: simple; 2: bold; 3: bold colored; 4: bold colored bell; 5: static; optional, default 1
lablabel's name to display the message in; optional, default ""
firstserves to recursively erase the message; optional, default yes

proc ::alited::Message {msg {mode 1} {lab {}} {first yes}} { # Displays a message in statusbar. # msg - message # mode - 1: simple; 2: bold; 3: bold colored; 4: bold colored bell; 5: static # lab - label's name to display the message in # first - serves to recursively erase the message variable al variable obPav lassign [FgFgBold] fg fgbold if {$lab eq ""} {set lab [$obPav Labstat3]} set font [[$obPav Labstat2] cget -font] set fontB [list {*}$font -weight bold] set msg [string range [string map [list \n { } \r {}] $msg] 0 100] set slen [string length $msg] if {[catch {$lab configure -text $msg}] || !$slen} return $lab configure -font $font -foreground $fg if {$mode in {2 3 4 5}} { $lab configure -font $fontB if {$mode in {3 4 5}} { $lab configure -foreground $fgbold if {$mode eq {4} && $first} bell } } if {$mode eq {5}} { update return } if {$first} { set msec [expr {200*$slen}] } else { set msg [string range $msg 0 end-1] set msec 10 } catch {after cancel $al(afterID)} if {$msec>0} { set al(afterID) [after $msec [list ::alited::Message $msg $mode $lab no]] } }




Message2 [::alited]alited, Top

Displays a message in statusbar of secondary dialogue ($obDl2).

Message2 msg ?first?
Parameters
msgmessage
firstmode of Message; optional, default 1
See also

Message


proc ::alited::Message2 {msg {first 1}} { # Displays a message in statusbar of secondary dialogue ($obDl2). # msg - message # first - mode of Message # See also: Message variable obDl2 Message $msg $first [$obDl2 LabMess] }




msg [::alited]alited, Top

Shows a message and asks for an answer.

msg type icon message ?defb? ?args?
Parameters
typeok/yesno/okcancel/yesnocancel
iconinfo/warn/err
messagethe message
defbdefault button (for not "ok" dialogs); optional, default ""
argsadditional arguments (-title and font's option)
Description

For "ok" dialogue, 'defb' is omitted (being a part of args).


proc ::alited::msg {type icon message {defb {}} args} { # Shows a message and asks for an answer. # type - ok/yesno/okcancel/yesnocancel # icon - info/warn/err # message - the message # defb - default button (for not "ok" dialogs) # args - additional arguments (-title and font's option) # For "ok" dialogue, 'defb' is omitted (being a part of args). variable obDlg variable al if {$type eq {ok}} { set args [linsert $args 0 $defb] set defb {} } lassign [::apave::extractOptions args -title {} -noesc 0] title noesc if {$title eq {}} { switch $icon { warn {set title $al(MC,warning)} err {set title [msgcat::mc Error]} ques {set title [msgcat::mc Question]} default {set title $al(MC,info)} } } #TODO: if {!$noesc} {set message [string map [list \\ \\\\] $message]} set res [$obDlg $type $icon $title "\n$message\n" {*}$defb {*}$args] after idle {catch alited::main::UpdateGutter} return [lindex $res 0] }




msgcatMessages [::alited]alited, Top

Sets common localized messages.

msgcatMessages

proc ::alited::msgcatMessages {} { # Sets common localized messages. variable al ## _ common _ ## set al(MC,nofile) [msgcat::mc {No name}] set al(MC,warning) [msgcat::mc Warning] set al(MC,info) [msgcat::mc Information] set al(MC,wait) [msgcat::mc {Wait a little ...}] set al(MC,help) [msgcat::mc Help] set al(MC,select) [msgcat::mc Select] ;# verb set al(MC,notsaved) [msgcat::mc "\"%f\" wasn't saved.\n\nSave it?"] set al(MC,saving) [msgcat::mc Saving] set al(MC,files) [msgcat::mc Files] set al(MC,moving) [msgcat::mc Moving] set al(MC,run) [msgcat::mc Run] set al(MC,new) [msgcat::mc New] set al(MC,open...) [msgcat::mc Open...] set al(MC,close) [msgcat::mc Close] set al(MC,save) [msgcat::mc Save] set al(MC,saveas...) [msgcat::mc {Save as...}] set al(MC,saveall) [msgcat::mc {Save All}] set al(MC,clall) [msgcat::mc {... All}] set al(MC,clallleft) [msgcat::mc {... All at Left}] set al(MC,clallright) [msgcat::mc {... All at Right}] set al(MC,pref) [msgcat::mc Preferences] set al(MC,pref...) [msgcat::mc Preferences...] set al(MC,notrecomm) [msgcat::mc {Not recommended!}] set al(MC,restart) [msgcat::mc Restart] set al(MC,quit) [msgcat::mc Quit] set al(MC,indent) [msgcat::mc Indent] set al(MC,unindent) [msgcat::mc Unindent] set al(MC,comment) [msgcat::mc Comment] set al(MC,uncomment) [msgcat::mc Uncomment] set al(MC,findreplace) [msgcat::mc {Find / Replace}] set al(MC,findnext) [msgcat::mc {Find Next}] set al(MC,alloffile) [msgcat::mc "All of \"%f\""] set al(MC,moveupU) [msgcat::mc {Move Unit Up}] set al(MC,movedownU) [msgcat::mc {Move Unit Down}] set al(MC,moveupF) [msgcat::mc {Move File Up}] set al(MC,movedownF) [msgcat::mc {Move File Down}] set al(MC,FavLists) [msgcat::mc {Lists of Favorites}] set al(MC,swfiles) [msgcat::mc {Switch to Unit Tree}] set al(MC,swunits) [msgcat::mc {Switch to File Tree}] set al(MC,filesadd) [msgcat::mc {Create File}] set al(MC,filesadd2) [msgcat::mc "Enter a name of file to create in:\n%d\n\nIf it is a directory, check 'Directory' box.\nThe directory can include subdirectories (a/b/c)."] set al(MC,filesdel) [msgcat::mc {Delete File}] set al(MC,fileexist) [msgcat::mc "File %f already exists in\n%d"] set al(MC,unitsadd) [msgcat::mc {Add Unit by Template}] set al(MC,unitsdel) [msgcat::mc {Remove Unit(s)}] set al(MC,favoradd) [msgcat::mc {Add to Favorites}] set al(MC,favordel) [msgcat::mc {Remove from Favorites}] set al(MC,favordelall) [msgcat::mc {Remove All}] set al(MC,updtree) [msgcat::mc {Update Tree}] set al(MC,movefile) [msgcat::mc "Move %f\nto\n%d\n?"] set al(MC,introln1) [msgcat::mc {First Lines}] set al(MC,introln2) [msgcat::mc {Can't touch the first %n lines.}] set al(MC,favorites) [msgcat::mc Favorites] set al(MC,lastvisit) [msgcat::mc {Last Visited}] set al(MC,addfavor) [msgcat::mc "Add \"%n\" of %f\nto the favorites?"] set al(MC,addexist) [msgcat::mc "Item \"%n\" of %f\nis already in the favorites."] set al(MC,delfavor) [msgcat::mc "Remove \"%n\" of %f\nfrom the favorites?"] set al(MC,selfavor) [msgcat::mc "Click \"%t\""] set al(MC,copydecl) [msgcat::mc {Copy Declaration}] set al(MC,openofdir) [msgcat::mc "Open all Tcl files of \"%n\""] set al(MC,delitem) [msgcat::mc "Remove \"%n\"\nfrom \"%f\"?"] set al(MC,delfile) [msgcat::mc "Delete \"%f\"?"] set al(MC,nodelopen) [msgcat::mc {An open file can not be deleted.}] set al(MC,modiffile) [msgcat::mc "File \"%f\" was modified by some application.\n\nCancel your edition and reload the file?"] set al(MC,wasdelfile) [msgcat::mc "File \"%f\" was deleted by some application.\n\nSave the file?"] set al(MC,Row:) [msgcat::mc {Row: }] set al(MC,Col:) [msgcat::mc { Col: }] set al(MC,Item) [msgcat::mc Item] set al(MC,errmove) [msgcat::mc "\"%n\" contains unbalanced \{\}: %1!=%2"] set al(MC,beforerun) [msgcat::mc {Command before "Run"}] set al(MC,locale) [msgcat::mc "Mostly this is a country code,\nfor example: ru, ua, cz."] ## _ templates _ ## set al(MC,tpl) [msgcat::mc Templates] set al(MC,tplsel) [msgcat::mc {Click a template}] set al(MC,tplnew) [msgcat::mc {The template #%n added}] set al(MC,tplupd) [msgcat::mc {The template #%n updated}] set al(MC,tplrem) [msgcat::mc {The template #%n removed}] set al(MC,tplent1) [msgcat::mc {Enter a name of the template}] set al(MC,tplent2) [msgcat::mc {Enter a text of the template}] set al(MC,tplexists) [msgcat::mc {A template with the attribute(s) already exists.}] set al(MC,tpldelq) [msgcat::mc {Delete a template #%n ?}] ## _ projects _ ## set al(MC,projects) [msgcat::mc Projects] set al(MC,prjgoing) [msgcat::mc {You are going to %n!}] set al(MC,prjadd) [msgcat::mc {Add a project}] set al(MC,prjchg) [msgcat::mc {Change a project}] set al(MC,prjdel) [msgcat::mc {Delete a project}] set al(MC,prjcantdel) [msgcat::mc {Don't delete the current project!}] set al(MC,prjnew) [msgcat::mc "The project \"%n\" added"] set al(MC,prjupd) [msgcat::mc "The project \"%n\" updated"] set al(MC,prjrem) [msgcat::mc "The project \"%n\" removed"] set al(MC,prjOptions) [msgcat::mc Options] set al(MC,prjName) [msgcat::mc {Project name:}] set al(MC,prjsavfl) [msgcat::mc "You can\n - add the current one to\n - substitute with the current one\n - delete\n - not change\nthe file list of the project.\n"] set al(MC,prjaddfl) [msgcat::mc Add] set al(MC,prjsubstfl) [msgcat::mc Substitute] set al(MC,prjdelfl) [msgcat::mc Delete] set al(MC,prjnochfl) [msgcat::mc {Don't change}] set al(MC,prjsel) [msgcat::mc {Click a project}] set al(MC,prjdelq) [msgcat::mc "Delete a project \"%n\" ?"] set al(MC,prjexists) [msgcat::mc "A project \"%n\" already exists."] ## _ favorites _ ## set al(MC,favsel) [msgcat::mc {Click a list of favorites}] set al(MC,favnew) [msgcat::mc {The list #%n added}] set al(MC,favupd) [msgcat::mc {The list #%n updated}] set al(MC,favrem) [msgcat::mc {The list #%n removed}] set al(MC,favent1) [msgcat::mc {Enter a name of the list}] set al(MC,favent3) [msgcat::mc {The current list is empty!}] set al(MC,favexists) [msgcat::mc {This list already exists}] set al(MC,faverrsav) [msgcat::mc "This list not saved to\n\"%f\"."] set al(MC,favdelq) [msgcat::mc {Delete a favorites' list #%n ?}] ## _ find-replace dialogue _ ## set al(MC,frres1) [msgcat::mc "Found %n matches for \"%s\"."] set al(MC,frres2) [msgcat::mc "Made %n replacements of \"%s\" with \"%r\" in \"%f\"."] set al(MC,frres3) [msgcat::mc "Made %n replacements of \"%s\" with \"%r\" in all of session."] set al(MC,frdoit1) [msgcat::mc "Replace all of \"%s\"\n\nwith \"%r\"\n\nin \"%f\" ?"] set al(MC,frdoit2) [msgcat::mc "Replace all of \"%s\"\n\nwith \"%r\"\n\nin all texts?"] ## _ file & directory _ ## set al(MC,errcopy) [msgcat::mc "Can't backup \"%f\" to\n\"%d\"!\n\nDelete it anyway?"] set al(MC,removed) [msgcat::mc "\"%f\" removed to \"%d\""] set al(MC,nottoopen) [msgcat::mc "The file \"%f\" seems to be not of types\n%s.\n\nStill do you want to open it?"] ## _ checking ini directory _ ## set al(MC,chini1) [msgcat::mc {Choosing Directory for Settings}] set al(MC,chini2) [msgcat::mc "\n The \"alited\" needs a configuration directory to store its settings.\n You can pass its name to alited as an argument.\n\n The default configuration directory is \"%d\".\n It's preferable as used to run \"alited\" without arguments.\n"] set al(MC,chini3) [msgcat::mc {Choose a directory}] set al(MC,notes) [msgcat::mc "Sort of diary.\nList of TODOs etc."] set al(MC,checktcl) [msgcat::mc {Check of Tcl}] set al(MC,colorpicker) [msgcat::mc {Color Picker}] set al(MC,datepicker) [msgcat::mc {Date Picker}] set al(checkroot) [msgcat::mc {Checking %d. Wait a little...}] set al(badroot) [msgcat::mc {Too big directory for a project: %n files or more.}] set al(makeroot) [msgcat::mc "Directory \"%d\"\ndoesn't exist.\n\nCreate it?"] ## _ icons of toolbar _ ## set al(MC,icofile) [msgcat::mc "Create a file\nCtrl+N"] set al(MC,icoOpenFile) [msgcat::mc "Open a file\nCtrl+O"] set al(MC,icoSaveFile) [msgcat::mc "Save the file\nF2"] set al(MC,icosaveall) [msgcat::mc "Save all files\nCtrl+Shift+S"] set al(MC,icohelp) [msgcat::mc "Tcl/Tk help on the selection\nF1"] set al(MC,icoreplace) [msgcat::mc "Find / Replace\nCtrl+F"] set al(MC,icook) $al(MC,checktcl) set al(MC,icocolor) $al(MC,colorpicker) set al(MC,icodate) $al(MC,datepicker) set al(MC,icoother) tkcon set al(MC,icorun) [msgcat::mc "Run the file\nF5"] set al(MC,icoe_menu) [msgcat::mc "Run e_menu\nF4"] set al(MC,icoundo) [msgcat::mc "Undo changes\nCtrl+Z"] set al(MC,icoredo) [msgcat::mc "Redo changes\nCtrl+Shift+Z"] set al(MC,icobox) [msgcat::mc Projects] ## _ find units _ ## set al(MC,findunit) [msgcat::mc "Use glob patterns to find units' declarations\ne.g. \"s*rt\" would find \"start\" and \"insert\".\nThe letter case is ignored."] }




p+ [::alited]alited, Top

Sums two text positions straightforward: lines & columns separately.

p+ p1 p2
Parameters
p11st position
p22nd position
Description

The lines may be with "-".


proc ::alited::p+ {p1 p2} { # Sums two text positions straightforward: lines & columns separately. # p1 - 1st position # p2 - 2nd position # The lines may be with "-". lassign [split $p1 .] l11 c11 lassign [split $p2 .] l21 c21 foreach n {l11 c11 l21 c21} { if {![string is digit -strict [string trimleft [set $n] -]]} {set $n 0} } return "[incr l11 $l21].[incr c11 $c21]" }




raise_window [::alited]alited, Top

Raises the app's window.

raise_window

proc ::alited::raise_window {} { # Raises the app's window. variable al wm withdraw $al(WIN) wm deiconify $al(WIN) }




run_remote [::alited]alited, Top

Runs a command that was started by another process.

run_remote cmd ?args?
Parameters
cmdNot documented.
argsOptional arguments.

proc ::alited::run_remote {cmd args} { # Runs a command that was started by another process. if {[catch { $cmd {*}$args }]} { return -code error } }



::alited::barTop


Commandsbar, Top




BAR [::alited::bar]bar, Top

Runs the tab bar's method.

BAR ?args?
Parameters
argsmethod's name and its arguments

proc ::alited::bar::BAR {args} { # Runs the tab bar's method. # args - method's name and its arguments namespace upvar ::alited al al return [al(bts) $al(BID) {*}$args] }




ColorBar [::alited::bar]bar, Top

Makes the bar of tabs to have a "marked tab" color consistent with current color scheme.

ColorBar

proc ::alited::bar::ColorBar {} { # Makes the bar of tabs to have a "marked tab" color # consistent with current color scheme. namespace upvar ::alited obPav obPav set cs [$obPav csCurrent] if {$cs>-1} { lassign [$obPav csGet $cs] cfg2 cfg1 cbg2 cbg1 cfhh - - - - - - - - - - - - fgmark BAR configure -fgmark $fgmark } }




ControlTab [::alited::bar]bar, Top

Switches between last two active tabs.

ControlTab

proc ::alited::bar::ControlTab {} { # Switches between last two active tabs. variable ctrltablist set fname [CurrentControlTab] set found no while {[llength $ctrltablist]} { set fnext [lindex $ctrltablist 0] foreach tab [BAR listTab] { set TID [lindex $tab 0] if {$fnext eq [FileName $TID]} { set found yes break } } if {$found} break # if the file was closed, remove it from the ctrl-tabbed set ctrltablist [lreplace $ctrltablist 0 0] } CurrentControlTab $fname if {!$found} { # only one tab is open - return to it (possibly not visible in the bar tab) set TID [CurrentTabID] set pos [[alited::main::CurrentWTXT] index insert] after idle [list alited::main::FocusText $TID $pos] } # select the first of open files that was next to the current BAR $TID show }




CurrentControlTab [::alited::bar]bar, Top

Keeps a list of last switched files, to switch between last two.

CurrentControlTab ?fname?
Parameters
fnamefile name; optional, default ""

proc ::alited::bar::CurrentControlTab {{fname {}}} { # Keeps a list of last switched files, to switch between last two. # fname - file name variable ctrltablist if {[set ret [expr {$fname eq {}}]]} { set fname [FileName] } if {[set i [lsearch -exact $ctrltablist $fname]]>-1} { set ctrltablist [lreplace $ctrltablist $i $i] } if {$ret} {return $fname} set ctrltablist [linsert $ctrltablist 0 $fname] }




CurrentTab [::alited::bar]bar, Top

Gets an attribute of the current tab.

CurrentTab io ?TID?
Parameters
io0 to get ID, 1 - short name (tab label), 2 - full name, 3 - index
TIDtab's ID; optional, default ""

proc ::alited::bar::CurrentTab {io {TID {}}} { # Gets an attribute of the current tab. # io - 0 to get ID, 1 - short name (tab label), 2 - full name, 3 - index # TID - tab's ID if {$TID eq {}} {set TID [CurrentTabID]} switch $io { 0 {set res $TID} 1 {set res [BAR $TID cget -text]} 2 {set res [FileName $TID]} 3 {set res [lsearch -index 0 [BAR listTab] $TID]} default {set res {}} } return $res }




CurrentTabID [::alited::bar]bar, Top

Gets ID of the current tab.

CurrentTabID

proc ::alited::bar::CurrentTabID {} { # Gets ID of the current tab. return [BAR cget -tabcurrent] }




DisableTabLeft [::alited::bar]bar, Top

Checks for left tabs to disable "select all at left".

DisableTabLeft tab
Parameters
tabtab's ID
Return value

Returns 1, if no left tab exists, thus disabling the menu's item.


proc ::alited::bar::DisableTabLeft {tab} { # Checks for left tabs to disable "select all at left". # tab - tab's ID # Returns 1, if no left tab exists, thus disabling the menu's item. set i [CurrentTab 3 $tab] if {$i} {return 0} return 1 }




DisableTabRight [::alited::bar]bar, Top

Checks for right tabs to disable "select all at right".

DisableTabRight tab
Parameters
tabtab's ID
Return value

Returns 1, if no right tab exists, thus disabling the menu's item.


proc ::alited::bar::DisableTabRight {tab} { # Checks for right tabs to disable "select all at right". # tab - tab's ID # Returns 1, if no right tab exists, thus disabling the menu's item. set i [CurrentTab 3 $tab] if {$i < ([llength [BAR listTab]]-1)} {return 0} return 1 }




FileName [::alited::bar]bar, Top

Gets a file name of a tab.

FileName ?TID?
Parameters
TIDtab's ID; optional, default ""

proc ::alited::bar::FileName {{TID {}}} { # Gets a file name of a tab. # TID - tab's ID if {$TID eq {}} {set TID [CurrentTabID]} set tip [BAR $TID cget -tip] return [lindex [split $tip \n] 0] }




FileTID [::alited::bar]bar, Top

Gets a tab's ID of a file name.

FileTID fname
Parameters
fnamefile name

proc ::alited::bar::FileTID {fname} { # Gets a tab's ID of a file name. # fname - file name set TID {} foreach tab [BAR listTab] { set TID2 [lindex $tab 0] if {$fname eq [FileName $TID2]} { set TID $TID2 break } } return $TID }




FillBar [::alited::bar]bar, Top

Fills the bar of tabs.

FillBar wframe ?newproject?
Parameters
wframeframe's path to place the bar in
newprojectif yes, creates the bar from scratch; optional, default no

proc ::alited::bar::FillBar {wframe {newproject no}} { # Fills the bar of tabs. # wframe - frame's path to place the bar in # newproject - if yes, creates the bar from scratch namespace upvar ::alited al al obPav obPav set wbase [$obPav LbxInfo] set lab0 [msgcat::mc (Un)Select] set lab1 [msgcat::mc {... Visible}] set lab2 [msgcat::mc {... All at Left}] set lab3 [msgcat::mc {... All at Right}] set lab4 [msgcat::mc {... All}] set bar1Opts [list -wbar $wframe -wbase $wbase -pady 2 -scrollsel no -lifo yes -lowlist $al(FONTSIZE,small) -lablen $al(INI,barlablen) -tiplen $al(INI,bartiplen) -menu [list sep "com {$lab0} {::alited::bar::SelTab %t} {} {}" "com {$lab1} {::alited::bar::SelTabVis} {} {}" "com {$lab2} {::alited::bar::SelTabLeft %t} {} {{\[::alited::bar::DisableTabLeft %t\]}}" "com {$lab3} {::alited::bar::SelTabRight %t} {} {{\[::alited::bar::DisableTabRight %t\]}}" "com {$lab4} {::alited::bar::SelTabAll} {} {}"] -separator no -font apaveFontDefTypedsmall -csel2 {alited::bar::OnTabSelection %t} -cdel {alited::file::CloseFile %t} -cmov2 alited::bar::OnTabMove] set tabs [set files [set posis [list]]] foreach tab $al(tabs) { lassign [split $tab \t] tab pos lappend files $tab lappend posis $pos set tab [UniqueTab $tabs [file tail $tab]] lappend tabs $tab lappend bar1Opts -tab $tab } set curname [lindex $tabs $al(curtab)] if {$newproject || [catch { ::bartabs::Bars create al(bts) ;# al(bts) is Bars object set al(BID) [al(bts) create al(bt) $bar1Opts $curname] }]} then { foreach tab $tabs {BAR insertTab $tab} } set tabs [BAR listTab] foreach tab $tabs fname $files pos $posis { set tid [lindex $tab 0] SetTabState $tid --fname $fname --pos $pos BAR $tid configure -tip [alited::file::FileStat $fname] } set curname [lindex $files $al(curtab)] SetBarState -1 $curname [$obPav Text] [$obPav SbvText] ColorBar alited::file::CheckForNew }




GetBarState [::alited::bar]bar, Top

Gets attributes of a tab that are specific for alited.

GetBarState

proc ::alited::bar::GetBarState {} { # Gets attributes of a tab that are specific for alited. return [BAR cget -ALITED] }




GetTabState [::alited::bar]bar, Top

Gets attributes of a tab.

GetTabState ?TID? ?args?
Parameters
TIDtab's ID (current one by default); optional, default ""
argslist of attributes + values

proc ::alited::bar::GetTabState {{TID {}} args} { # Gets attributes of a tab. # TID - tab's ID (current one by default) # args - list of attributes + values if {$TID eq {}} {set TID [CurrentTabID]} if {![BAR isTab $TID]} {return {}} return [BAR $TID cget {*}$args] }




InsertTab [::alited::bar]bar, Top

Inserts a new tab into the beginning of bar of tabs.

InsertTab tab tip
Parameters
tabthe tab
tipthe tab's tip

proc ::alited::bar::InsertTab {tab tip} { # Inserts a new tab into the beginning of bar of tabs. # tab - the tab # tip - the tab's tip namespace upvar ::alited al al set TID [BAR insertTab $tab 0] BAR $TID configure -tip $tip SetTabState $TID --fname $tip alited::ini::SaveCurrentIni $al(INI,save_onadd) return $TID }




OnTabMove [::alited::bar]bar, Top

Handles moving a tab in the bar.

OnTabMove

proc ::alited::bar::OnTabMove {} { # Handles moving a tab in the bar. namespace upvar ::alited al al alited::ini::SaveCurrentIni $al(INI,save_onmove) }




OnTabSelection [::alited::bar]bar, Top

Handles selecting a tab in the bar.

OnTabSelection TID
Parameters
TIDtab's ID

proc ::alited::bar::OnTabSelection {TID} { # Handles selecting a tab in the bar. # TID - tab's ID namespace upvar ::alited al al alited::main::ShowText alited::find::ClearTags alited::ini::SaveCurrentIni $al(INI,save_onselect) alited::unit::CheckSaveIcons [alited::file::IsModified $TID] alited::unit::CheckUndoRedoIcons [alited::main::CurrentWTXT] $TID if {[alited::file::IsTcl [FileName]]} {set indst normal} {set indst disabled} $al(MENUEDIT) entryconfigure 5 -state $indst if {[alited::unit::CommentChar] ne {}} {set cmnst normal} {set cmnst disabled} $al(MENUEDIT) entryconfigure 7 -state $cmnst $al(MENUEDIT) entryconfigure 8 -state $cmnst set wtxt [alited::main::GetWTXT $TID] set al(wrapwords) [expr {[$wtxt cget -wrap] eq {word}}] CurrentControlTab [FileName $TID] alited::main::HighlightLine alited::tree::SeeSelection }




SelTab [::alited::bar]bar, Top

Makes a tab selected / unselected.

SelTab tab ?mode?
Parameters
tabtab's ID
modeif 1, selects the tab; optional, default -1

proc ::alited::bar::SelTab {tab {mode -1}} { # Makes a tab selected / unselected. # tab - tab's ID # mode - if 1, selects the tab set selected [BAR cget -select] if {$mode == 1 || $tab in $selected} { BAR unselectTab $tab } elseif {$mode == 0 || $tab ni $selected} { BAR selectTab $tab } }




SelTabAll [::alited::bar]bar, Top

Makes all tabs selected / unselected.

SelTabAll

proc ::alited::bar::SelTabAll {} { # Makes all tabs selected / unselected. set mode [expr {[llength [BAR cget -select]]>0}] foreach tab [BAR listTab] { SelTab [lindex $tab 0] $mode } }




SelTabLeft [::alited::bar]bar, Top

Makes all left tabs selected / unselected.

SelTabLeft tab
Parameters
tabtab's ID

proc ::alited::bar::SelTabLeft {tab} { # Makes all left tabs selected / unselected. # tab - tab's ID foreach t [BAR listTab] { set t [lindex $t 0] if {$t eq $tab} break SelTab $t } }




SelTabRight [::alited::bar]bar, Top

Makes all right tabs selected / unselected.

SelTabRight tab
Parameters
tabtab's ID

proc ::alited::bar::SelTabRight {tab} { # Makes all right tabs selected / unselected. # tab - tab's ID set cntrd no foreach t [BAR listTab] { set t [lindex $t 0] if {$t eq $tab} { set cntrd yes } elseif {$cntrd} { SelTab $t } } }




SelTabVis [::alited::bar]bar, Top

Makes visible tabs selected / unselected.

SelTabVis

proc ::alited::bar::SelTabVis {} { # Makes visible tabs selected / unselected. foreach tab [BAR listFlag v] { SelTab $tab } }




SetBarState [::alited::bar]bar, Top

Sets attributes of the tab bar that are specific for alited.

SetBarState TID ?args?
Parameters
TIDtab's ID
argslist of attributes + values

proc ::alited::bar::SetBarState {TID args} { # Sets attributes of the tab bar that are specific for alited. # TID - tab's ID # args - list of attributes + values BAR configure -ALITED [list $TID {*}$args] }




SetTabState [::alited::bar]bar, Top

Sets attributes of a tab.

SetTabState TID ?args?
Parameters
TIDtab's ID
argslist of attributes + values

proc ::alited::bar::SetTabState {TID args} { # Sets attributes of a tab. # TID - tab's ID # args - list of attributes + values if {![BAR isTab $TID]} return BAR $TID configure {*}$args }




UniqueListTab [::alited::bar]bar, Top

Returns a unique tab name for a file.

UniqueListTab fname
Parameters
fnamefile name
Return value

Returns a unique tab name for a file.


proc ::alited::bar::UniqueListTab {fname} { # Returns a unique tab name for a file. # fname - file name set tabs [alited::bar::BAR listTab] set tab [file tail $fname] return [UniqueTab $tabs $tab -index 1] }




UniqueTab [::alited::bar]bar, Top

Returns a unique name for a tab.

UniqueTab tabs tab ?args?
Parameters
tabslist of tabs
tabtab name to be checked for its duplicate
argsoptions of lsearch to find a duplicate name
Description

If some file has a tail name (tab name) equal to an existing one's, the new tab name should get "(N)" suffix to be unique. This is required by bartabs package: no duplicates allowed.

Return value

Returns a unique name for a tab.


proc ::alited::bar::UniqueTab {tabs tab args} { # Returns a unique name for a tab. # tabs - list of tabs # tab - tab name to be checked for its duplicate # args - options of lsearch to find a duplicate name # If some file has a tail name (tab name) equal to an existing one's, # the new tab name should get "(N)" suffix to be unique. # This is required by bartabs package: no duplicates allowed. set cnttab 1 set taborig $tab while {1} { if {[lsearch {*}$args $tabs $tab]==-1} break set tab "$taborig ([incr cnttab])" } return $tab }



::alited::checkTop


Commandscheck, Top




_create [::alited::check]check, Top

Creates "Checking" dialogue.

_create

proc ::alited::check::_create {} { # Creates "Checking" dialogue. namespace upvar ::alited al al obDl2 obDl2 variable win $obDl2 makeWindow $win.fra $al(MC,checktcl) $obDl2 paveWindow $win.fra { {v_ - -} {labHead v_ T 1 1 {-st w -pady 4 -padx 8} {-t "Checks available:"}} {chb1 labHead T 1 1 {-st sw -pady 1 -padx 22} {-var alited::check::chBrace -t {Consistency of {} }}} {chb2 chb1 T 1 1 {-st sw -pady 5 -padx 22} {-var alited::check::chBracket -t {Consistency of []}}} {chb3 chb2 T 1 1 {-st sw -pady 1 -padx 22} {-var alited::check::chParenthesis -t {Consistency of ()}}} {v_2 chb3 T} {fra v_2 T 1 1 {-st nsew -pady 0 -padx 3} {-padding {5 5 5 5} -relief groove}} {fra.lab - - - - {pack -side left} {-t "Check:"}} {fra.radA - - - - {pack -side left -padx 9} {-t "current file" -var ::alited::check::what -value 1}} {fra.radB - - - - {pack -side left -padx 9} {-t "all of session files" -var ::alited::check::what -value 2}} {fra2 fra T 1 1 {-st nsew -pady 3 -padx 3} {-padding {5 5 5 5} -relief groove}} {.butHelp - - - - {pack -side left} {-t "Help" -command ::alited::check::Help}} {.h_ - - - - {pack -side left -expand 1 -fill both}} {.ButOK - - - - {pack -side left -padx 2} {-t "Check" -command ::alited::check::Ok}} {.butCancel - - - - {pack -side left} {-t Cancel -command ::alited::check::Cancel}} } set res [$obDl2 showModal $win -resizable {0 0} -focus [$obDl2 ButOK] -onclose alited::check::Cancel] destroy $win return $res }




_run [::alited::check]check, Top

Runs "Checking" dialogue.

_run

proc ::alited::check::_run {} { # Runs "Checking" dialogue. if {[_create]} Check }




Cancel [::alited::check]check, Top

Handles hitting "Cancel" button.

Cancel ?args?
Parameters
argsOptional arguments.

proc ::alited::check::Cancel {args} { # Handles hitting "Cancel" button. namespace upvar ::alited obDl2 obDl2 variable win $obDl2 res $win 0 }




Check [::alited::check]check, Top

Runs checking.

Check

proc ::alited::check::Check {} { # Runs checking. namespace upvar ::alited al al variable what variable errors variable fileerrors alited::info::Clear alited::info::Put $al(MC,wait) {} yes set errors [set fileerrors 0] switch $what { 1 CheckFile 2 CheckAll } alited::info::Clear 0 ShowResults }




CheckAll [::alited::check]check, Top

Checks all files of session.

CheckAll

proc ::alited::check::CheckAll {} { # Checks all files of session. update set allfnd [list] foreach tab [alited::bar::BAR listTab] { set TID [lindex $tab 0] alited::file::ReadFileByTID $TID lassign [alited::main::GetText $TID] curfile wtxt CheckFile $curfile $wtxt $TID } }




CheckFile [::alited::check]check, Top

Checks a file.

CheckFile ?fname? ?wtxt? ?TID?
Parameters
fnamefile name; optional, default ""
wtxtthe file's text widget; optional, default ""
TIDthe file's tab ID; optional, default ""

proc ::alited::check::CheckFile {{fname {}} {wtxt {}} {TID {}}} { # Checks a file. # fname - file name # wtxt - the file's text widget # TID - the file's tab ID variable errors variable fileerrors variable errors1 variable errors2 variable errors3 if {$fname eq {}} { set fname [alited::bar::FileName] set wtxt [alited::main::CurrentWTXT] set TID [alited::bar::CurrentTabID] } if {![alited::file::IsTcl $fname]} return set curfile [file tail $fname] set textcont [$wtxt get 1.0 end] set errors1 [set errors2 [set errors3 0]] set fileerrs [CheckUnit $wtxt 1.0 end] incr fileerrors $fileerrs set und [string repeat _ 30] set pos1 [alited::bar::GetTabState $TID --pos] set info [list $TID [expr {int($pos1)}]] alited::info::Put "$und $fileerrs ($errors1/$errors2/$errors3) file errors of $curfile $und$und$und" $info set unittree [alited::unit::GetUnits $TID $textcont] foreach item $unittree { lassign $item lev leaf fl1 title l1 l2 if {!$leaf || $title eq {}} continue set title "$curfile: $title" set err [CheckUnit $wtxt $l1.0 $l2.end $TID $title] if {$err} { incr errors $err } } }




CheckUnit [::alited::check]check, Top

Checks a unit.

CheckUnit wtxt pos1 pos2 ?TID? ?title?
Parameters
wtxttext's path
pos1ending position of the unit in the text
pos2Not documented.
TIDtab's ID; optional, default ""
titletitle of the unit; optional, default ""

proc ::alited::check::CheckUnit {wtxt pos1 pos2 {TID {}} {title {}}} { # Checks a unit. # wtxt - text's path # pos1 - starting position of the unit in the text # pos1 - ending position of the unit in the text # TID - tab's ID # title - title of the unit variable chBrace 1 variable chBracket 1 variable chParenthesis 1 variable errors1 variable errors2 variable errors3 set cc1 [set cc2 [set ck1 [set ck2 [set cp1 [set cp2 0]]]]] foreach line [split [$wtxt get $pos1 $pos2] \n] { if {$chBrace} { incr cc1 [::apave::countChar $line \{] incr cc2 [::apave::countChar $line \}] } if {$chBracket} { incr ck1 [::apave::countChar $line \[] incr ck2 [::apave::countChar $line \]] } if {$chParenthesis} { incr cp1 [::apave::countChar $line (] incr cp2 [::apave::countChar $line )] } } set err 0 if {$TID ne {}} { set info [list $TID [expr {[string is double -strict $pos1] ? int($pos1) : 1}]] } if {$cc1 != $cc2} { incr err incr errors1 if {$TID ne {}} {alited::info::Put "$title: inconsistent \{\}: $cc1 != $cc2" $info} } if {$ck1 != $ck2} { incr err incr errors2 if {$TID ne {}} {alited::info::Put "$title: inconsistent \[\]: $ck1 != $ck2" $info} } if {$cp1 != $cp2} { incr err incr errors3 if {$TID ne {}} {alited::info::Put "$title: inconsistent (): $cp1 != $cp2" $info} } return $err }




Help [::alited::check]check, Top

Handles hitting "Help" button.

Help ?args?
Parameters
argsOptional arguments.

proc ::alited::check::Help {args} { # Handles hitting "Help" button. variable win alited::Help $win }




Ok [::alited::check]check, Top

Handles hitting "OK" button.

Ok ?args?
Parameters
argsOptional arguments.

proc ::alited::check::Ok {args} { # Handles hitting "OK" button. namespace upvar ::alited obDl2 obDl2 variable win $obDl2 res $win 1 return }




ShowResults [::alited::check]check, Top

Displays results of checking.

ShowResults

proc ::alited::check::ShowResults {} { # Displays results of checking. variable errors variable fileerrors if {$errors || $fileerrors} { set msg [msgcat::mc {Found %f file error(s), %u unit error(s).}] set msg [string map [list %f $fileerrors %u $errors] $msg] } else { set msg [msgcat::mc {No errors found.}] } alited::info::Put $msg {} yes }



::alited::completeTop


Commandscomplete, Top




AllSessionCommands [::alited::complete]complete, Top

Gets all commands available in Tcl/Tk and in session files.

AllSessionCommands ?currentTID?
Parameters
currentTIDID of a current tab; optional, default ""
Description

If currentTID is set, the commands of this TID are shown unqualified.


proc ::alited::complete::AllSessionCommands {{currentTID {}}} { # Gets all commands available in Tcl/Tk and in session files. # currentTID - ID of a current tab # If currentTID is set, the commands of this TID are shown unqualified. namespace upvar ::alited al al set res [list] foreach tab [alited::find::SessionList] { set TID [lindex $tab 0] alited::file::ReadFileByTID $TID foreach it $al(_unittree,$TID) { lassign $it lev leaf fl1 ttl l1 l2 if {$leaf && [llength $ttl]==1} { if {$TID eq $currentTID} { lappend res [lindex [split $ttl :] end] } else { lappend res $ttl } } } } return $res }




AutoCompleteCommand [::alited::complete]complete, Top

Runs auto completion of commands.

AutoCompleteCommand

proc ::alited::complete::AutoCompleteCommand {} { # Runs auto completion of commands. lassign [MatchedCommands] curword idx1 idx2 alited::complete::comms set wtxt [alited::main::CurrentWTXT] if {[set com [PickCommand $wtxt]] ne {}} { set TID [alited::bar::CurrentTabID] set row [expr {int([$wtxt index insert])}] $wtxt delete $row.$idx1 $row.[incr idx2] set pos $row.$idx1 $wtxt insert $pos $com ::alited::main::HighlightLine } focus -force $wtxt }




MatchedCommands [::alited::complete]complete, Top

Gets commands that are matched to a current (under cursor) word.

MatchedCommands
Return value

Returns list of current word, begin and end of it, matched commands.


proc ::alited::complete::MatchedCommands {} { # Gets commands that are matched to a current (under cursor) word. # Returns list of current word, begin and end of it, matched commands. lassign [alited::find::GetWordOfText noselect2] curword idx1 idx2 if {![namespace exists ::alited::repl]} { namespace eval ::alited { source [file join $::alited::LIBDIR repl repl.tcl] } } set allcomms [lindex [::alited::repl::complete command {}] 1] lappend allcomms {*}[AllSessionCommands [alited::bar::CurrentTabID]] set comms [list] set excluded [list {[._]*} alimg_* bts_* \$*] foreach com $allcomms { set incl 1 foreach ex $excluded { if {[string match $ex $com]} { set incl 0 break } } if {$incl && [string match "${curword}*" $com]} {lappend comms $com} } return [list $curword $idx1 $idx2 [lsort $comms]] }




PickCommand [::alited::complete]complete, Top

Shows a frame of commands for auto completion, allowing a user to select from it.

PickCommand wtxt
Parameters
wtxttext's path

proc ::alited::complete::PickCommand {wtxt} { # Shows a frame of commands for auto completion, # allowing a user to select from it. # wtxt - text's path if {![llength $alited::complete::comms]} {return {}} set win .pickcommand catch {destroy $win} if {$::tcl_platform(platform) eq {windows}} { toplevel $win } else { frame $win wm manage $win } wm withdraw $win wm overrideredirect $win 1 set obj pavedPickCommand ::apave::APaveInput create $obj $win $obj paveWindow $win { {LbxPick - - - - {pack -side left -expand 1 -fill both} {-h 16 -w 32 -lvar ::alited::complete::comms}} {sbvPick LbxPick L - - {pack -side left -fill both} {}} } set lbx [$obj LbxPick] foreach ev {ButtonPress-1 Return KP_Enter KeyPress-space} { catch {bind $lbx <$ev> "after idle {::alited::complete::SelectCommand $win $obj $lbx}"} } $lbx selection set 0 lassign [TextCursorCoordinates $wtxt] X Y if {$::tcl_platform(platform) eq {windows}} { incr X 10 incr Y 40 after 100 "wm deiconify $win" } set res [$obj showModal $win -decor 0 -focus $lbx -geometry +$X+$Y] destroy $win $obj destroy if {$res ne "0"} {return $res} return {} }




SelectCommand [::alited::complete]complete, Top

Handles a selection of command for auto completion.

SelectCommand win obj lbx
Parameters
winwindow of command list
objapave object
lbxlistbox's path

proc ::alited::complete::SelectCommand {win obj lbx} { # Handles a selection of command for auto completion. # win - window of command list # obj - apave object # lbx - listbox's path $obj res $win [lindex $alited::complete::comms [$lbx curselection]] }




TextCursorCoordinates [::alited::complete]complete, Top

Gets screen coordinates (X, Y) under cursor in a text.

TextCursorCoordinates wtxt
Parameters
wtxttext's path
Return value

Returns a list of X and Y coordinates.


proc ::alited::complete::TextCursorCoordinates {wtxt} { # Gets screen coordinates (X, Y) under cursor in a text. # wtxt - text's path # Returns a list of X and Y coordinates. set ch [$wtxt get [$wtxt index insert] [$wtxt index {insert +1c}]] if {[string trim $ch] eq {}} {set pos {insert -1c}} {set pos insert} lassign [$wtxt bbox [$wtxt index $pos]] X Y w h incr X $w incr Y $h set p [winfo parent $wtxt] while 1 { lassign [split [winfo geometry $p] x+] w h x y incr X $x incr Y $y if {[catch {set p [winfo parent $p]}] || $p in {{} {.}}} break } return [list $X $Y] }



::alited::favorTop


Commandsfavor, Top




_init [::alited::favor]favor, Top

Initializes and shows favorite / last visited units' view.

_init

proc ::alited::favor::_init {} { # Initializes and shows favorite / last visited units' view. namespace upvar ::alited al al obPav obPav set wtree [$obPav TreeFavor] alited::tree::AddTags $wtree $wtree tag bind tagNorm <Return> {::alited::favor::Select} $wtree tag bind tagNorm <ButtonRelease-1> {::alited::favor::Select} $wtree tag bind tagNorm <ButtonPress-3> {after idle {alited::favor::PopupMenu %x %y %X %Y}} $wtree tag bind tagNorm <Motion> {after idle {alited::favor::Tooltip %x %y %X %Y}} bind $wtree <Leave> {alited::favor::TooltipOff} $wtree heading #1 -text [msgcat::mc $al(MC,favorites)] SetFavorites $al(FAV,current) if {!$al(FAV,IsFavor)} Show }




Add [::alited::favor]favor, Top

Adds a unit to favorites.

Add ?undermouse?
Parameters
undermouseif yes, run by mouse click; optional, default yes

proc ::alited::favor::Add {{undermouse yes}} { # Adds a unit to favorites. # undermouse - if yes, run by mouse click namespace upvar ::alited al al obPav obPav lassign [CurrentName] itemID name l1 l2 if {$name eq {}} return if {$undermouse} {set geo {-geometry pointer+10+-100}} {set geo {}} set fname [alited::bar::FileName] set sname [file tail $fname] foreach it [alited::tree::GetTree {} TreeFavor] { lassign [lindex $it 4] name2 fname2 if {$name eq $name2 && $fname eq $fname2} { set msg [string map [list %n $name %f $sname] $al(MC,addexist)] alited::msg ok err $msg {*}$geo return } } set msg [string map [list %n $name %f $sname] $al(MC,addfavor)] if {[alited::msg yesno ques $msg YES {*}$geo]} { set wtree [$obPav Tree] set header [alited::unit::GetHeader [$obPav Tree] $itemID] set pos [[alited::main::CurrentWTXT] index insert] set line [expr {($l1 eq {} || $l2 eq {} || $l1>$pos || $l2<$pos) ? 0 : [alited::p+ $pos -$l1]}] set wt2 [$obPav TreeFavor] set ID2 [$wt2 insert {} 0 -values [list $name $fname $header $line]] $wt2 tag add tagNorm $ID2 } }




CopyDeclaration [::alited::favor]favor, Top

Copies a current unit's declaration to the clipboard.

CopyDeclaration wtree ID
Parameters
wtreetree widget's path
IDtree item's ID

proc ::alited::favor::CopyDeclaration {wtree ID} { # Copies a current unit's declaration to the clipboard. # wtree - tree widget's path # ID - tree item's ID clipboard clear clipboard append [lindex [$wtree item $ID -values] 2] }




CurrentName [::alited::favor]favor, Top

Gets data of a current unit.

CurrentName
Return value

Returns a list of the unit's data: ID, title, 1st line, last line.


proc ::alited::favor::CurrentName {} { # Gets data of a current unit. # Returns a list of the unit's data: ID, title, 1st line, last line. lassign [alited::tree::CurrentItemByLine {} 1] itemID - - - name l1 l2 set name [string trim $name] if {$name eq {}} bell return [list $itemID $name $l1 $l2] }




Delete [::alited::favor]favor, Top

Deletes an item from favorites.

Delete ?undermouse?
Parameters
undermouseif yes, run by mouse click; optional, default yes

proc ::alited::favor::Delete {{undermouse yes}} { # Deletes an item from favorites. # undermouse - if yes, run by mouse click namespace upvar ::alited al al obPav obPav if {$undermouse} { set name [lindex [CurrentName] 1] set favID {} foreach it [alited::tree::GetTree {} TreeFavor] { lassign $it - - ID2 - values lassign $values name2 fname header line if {$name2 eq $name} { set favID $ID2 break } } } else { if {![IsSelected favID name fname sname header line]} return } if {$favID eq {}} {bell; return} set sname [file tail $fname] set msg [string map [list %n $name %f $sname] $al(MC,delfavor)] if {$undermouse} {set geo {-geometry pointer+10+-100}} {set geo {}} if {[alited::msg yesno warn $msg NO {*}$geo]} { [$obPav TreeFavor] delete $favID } }




DeleteAll [::alited::favor]favor, Top

Deletes all items from favorites.

DeleteAll ?undermouse?
Parameters
undermouseif yes, run by mouse click; optional, default yes

proc ::alited::favor::DeleteAll {{undermouse yes}} { # Deletes all items from favorites. # undermouse - if yes, run by mouse click namespace upvar ::alited al al obPav obPav if {$undermouse} {set geo {-geometry pointer+10+-100}} {set geo {}} if {$al(FAV,IsFavor)} { set msg {Remove all of the favorites?} set listvar al(FAV,current) } else { set msg {Remove all of the last visited?} set listvar al(FAV,visited) } set favlist [alited::tree::GetTree {} TreeFavor] if {$favlist eq {}} {bell; return} if {[alited::msg yesno warn [msgcat::mc $msg] NO {*}$geo -title $al(MC,favordelall)]} { foreach curfav $favlist { [$obPav TreeFavor] delete [lindex $curfav 2] } set $listvar [list] } }




GoToUnit [::alited::favor]favor, Top

Enters a unit.

GoToUnit TID name header ?forfavor? ?it1? ?values?
Parameters
TIDtab's ID
namename of the unit
headerheader of the unit
forfavoryes, if Favorites list is clicked and must be updated; optional, default no
it1item selected in Favorites (for forfavor=yes); optional, default ""
valuesvalues of item selected in Favorites (for forfavor=yes); optional, default ""
Return value

Returns yes, if the unit is open successfully.

See also

tree::SaveCursorPos


proc ::alited::favor::GoToUnit {TID name header {forfavor no} {it1 {}} {values {}}} { # Enters a unit. # TID - tab's ID # name - name of the unit # header - header of the unit # forfavor - yes, if Favorites list is clicked and must be updated # it1 - item selected in Favorites (for forfavor=yes) # values - values of item selected in Favorites (for forfavor=yes) # Returns yes, if the unit is open successfully. # See also: tree::SaveCursorPos namespace upvar ::alited al al obPav obPav foreach it $al(_unittree,$TID) { set treeID [alited::tree::NewItemID [incr iit]] lassign $it lev leaf fl1 title l1 l2 if {$name eq [alited::tree::UnitTitle $title $l1 $l2]} { if {$forfavor} { set wtree [$obPav TreeFavor] $wtree delete $it1 set favID [$wtree insert {} 0 -values $values] $wtree tag add tagNorm $favID } LastVisited [list -text $name] $header set pos [lindex $it 7] ;# saved cursor position if {$pos ne {}} {set pos "$pos yes"} after idle "alited::tree::NewSelection $treeID $pos" return yes } } return no }




IsSelected [::alited::favor]favor, Top

Gets data of currently selected item of favorites.

IsSelected IDN nameN fnameN snameN headerN lineN
Parameters
IDNvariable name of item's ID
nameNvariable name of item's name
fnameNvariable name of item's file name
snameNvariable name of item's tail file name
headerNvariable name of item's header
lineNvariable name of item's 1st line

proc ::alited::favor::IsSelected {IDN nameN fnameN snameN headerN lineN} { # Gets data of currently selected item of favorites. # IDN - variable name of item's ID # nameN - variable name of item's name # fnameN - variable name of item's file name # snameN - variable name of item's tail file name # headerN - variable name of item's header # lineN - variable name of item's 1st line namespace upvar ::alited al al obPav obPav upvar 1 $IDN ID $nameN name $fnameN fname $snameN sname $headerN header $lineN line if {[set ID [alited::tree::CurrentItem TreeFavor]] eq {}} {return no} set wtree [$obPav TreeFavor] lassign [$wtree item $ID -values] name fname header line set sname [file tail $fname] return yes }




LastVisited [::alited::favor]favor, Top

Puts an item to "Last visited" list.

LastVisited item header
Parameters
itemlist of tree's item data (first two: -text {label})
headerheader of item

proc ::alited::favor::LastVisited {item header} { # Puts an item to "Last visited" list. # item - list of tree's item data (first two: -text {label}) # header - header of item namespace upvar ::alited al al obPav obPav set name [string trim [lindex $item 1]] if {[string trim $name] eq {}} return set fname [alited::bar::FileName] # search an old item set found no set i 0 foreach it $al(FAV,visited) { lassign $it - - ID - values lassign $values name2 fname2 header2 if {$fname eq $fname2 && $header eq $header2} { set found yes # if found, move it to 0th position set al(FAV,visited) [lreplace $al(FAV,visited) $i $i] break } incr i } set al(FAV,visited) [linsert $al(FAV,visited) 0 [list - - - - [list $name $fname $header]]] # delete last items if the list's limit is exceeded catch {set al(FAV,visited) [lreplace $al(FAV,visited) $al(FAV,MAXLAST) end]} # update the tree widget if {!$al(FAV,IsFavor)} { SetFavorites $al(FAV,visited) set wtree [$obPav TreeFavor] if {[set id0 [lindex [$wtree children {}] 0]] ne {}} { $wtree see $id0 } } }




Lists [::alited::favor]favor, Top

Runs "Lists of Favorites" dialogue, sets a list of favorites at a choice.

Lists

proc ::alited::favor::Lists {} { # Runs "Lists of Favorites" dialogue, sets a list of favorites at a choice. variable initialFavs if {![llength $initialFavs]} { set initialFavs [alited::tree::GetTree {} TreeFavor] } lassign [::alited::favor_ls::_run] pla cont switch $pla { 1 {SetFavorites $cont} 2 {SetAndClose $cont} 3 {SetFavorites $initialFavs} } }




OpenSelectedFile [::alited::favor]favor, Top

Opens a file from a selected item of favorites/last visited.

OpenSelectedFile fname
Parameters
fnamefile name
Return value

Returns tab's ID, if the file is open successfully.


proc ::alited::favor::OpenSelectedFile {fname} { # Opens a file from a selected item of favorites/last visited. # fname - file name # Returns tab's ID, if the file is open successfully. namespace upvar ::alited al al set al(dolastvisited) no set TID [alited::file::OpenFile $fname yes] set al(dolastvisited) yes if {$TID eq {}} { set msg [string map [list %f $fname] [msgcat::mc {File not found: %f}]] alited::Message $msg 4 } return $TID }




PopupMenu [::alited::favor]favor, Top

Prepares and runs a popup menu at clicking the favorites / last visited list.

PopupMenu x y X Y
Parameters
xx-coordinate to identify tree item
yy-coordinate to identify tree item
Xx-coordinate of the mouse pointer
Yy-coordinate of the mouse pointer

proc ::alited::favor::PopupMenu {x y X Y} { # Prepares and runs a popup menu at clicking the favorites / last visited list. # x - x-coordinate to identify tree item # y - y-coordinate to identify tree item # X - x-coordinate of the mouse pointer # Y - y-coordinate of the mouse pointer namespace upvar ::alited al al obPav obPav set wtree [$obPav TreeFavor] set ID [$wtree identify item $x $y] if {![$wtree exists $ID]} return if {[set sel [$wtree selection]] ne {}} { $wtree selection remove $sel } $wtree selection add $ID ShowPopupMenu $ID $X $Y }




Select [::alited::favor]favor, Top

Handles selecting an item of "Favorites / Last visited" treeview.

Select

proc ::alited::favor::Select {} { # Handles selecting an item of "Favorites / Last visited" treeview. namespace upvar ::alited al al obPav obPav set msec [clock milliseconds] if {[info exists al(_MSEC)] && [expr {($msec-$al(_MSEC))<800}]} { return ;# disables double click } set al(_MSEC) $msec set wtree [$obPav TreeFavor] if {![IsSelected favID name fname sname header line]} { return } set values [$wtree item $favID -values] if {[set TID [OpenSelectedFile $fname]] eq {}} return # scan the favorites/last-visited tree, to find the selected item # and remake favorites and last visits; then go to the selected unit foreach it1 [$wtree children {}] { if {$name eq [lindex [$wtree item $it1 -values] 0]} { if {[GoToUnit $TID $name $header $al(FAV,IsFavor) $it1 $values]} return break } } set msg [string map [list %u $name] [msgcat::mc {Unit not found: %u}]] alited::Message $msg 4 }




SetAndClose [::alited::favor]favor, Top

Sets favorites list, opens files from favorites list, closes other files.

SetAndClose cont
Parameters
contlist of favorites

proc ::alited::favor::SetAndClose {cont} { # Sets favorites list, opens files from favorites list, closes other files. # cont - list of favorites SetFavorites $cont set fnamecont {} foreach tab [alited::bar::BAR listTab] { set TID [lindex $tab 0] set fname [alited::bar::FileName $TID] set found no foreach fit $cont { set fnamecont [lindex $fit 4 1] if {$fname eq $fnamecont} { set found yes break } } if {!$found} { if {![alited::file::CloseFile $TID no]} break alited::bar::BAR $TID close no } } if {![llength [alited::bar::BAR listTab]]} { # no tabs open if {$fnamecont ne {}} { alited::file::OpenFile $fnamecont yes ;# open a file from favorites } else { alited::file::CheckForNew ;# ... or create "no name" tab } } }




SetFavorites [::alited::favor]favor, Top

Sets favorites/last visited list in the treeview.

SetFavorites cont
Parameters
contlist of favorites/last visited

proc ::alited::favor::SetFavorites {cont} { # Sets favorites/last visited list in the treeview. # cont - list of favorites/last visited namespace upvar ::alited al al obPav obPav set wtree [$obPav TreeFavor] foreach it [alited::tree::GetTree {} TreeFavor] { $wtree delete [lindex $it 2] } foreach curfav $cont { catch { lassign $curfav - - - - values if {$values ne {}} { set itemID [$wtree insert {} end -values $values] $wtree tag add tagNorm $itemID } } } }




Show [::alited::favor]favor, Top

Shows a list of favorites / last visited units.

Show

proc ::alited::favor::Show {} { # Shows a list of favorites / last visited units. namespace upvar ::alited al al obPav obPav set wtree [$obPav TreeFavor] if {$al(FAV,IsFavor)} { [$obPav BuTVisitF] configure -image alimg_misc set tip $alited::al(MC,lastvisit) set state normal SetFavorites $al(FAV,current) $wtree heading #1 -text [msgcat::mc $al(MC,favorites)] } else { set al(FAV,current) [list] foreach it [alited::tree::GetTree {} TreeFavor] { lappend al(FAV,current) $it } [$obPav BuTVisitF] configure -image alimg_heart set tip $al(MC,favorites) set state disable SetFavorites $al(FAV,visited) $wtree heading #1 -text [msgcat::mc $al(MC,lastvisit)] } foreach but {BuTListF BuTAddF BuTDelF} { [$obPav $but] configure -state $state } baltip::tip [$obPav BuTVisitF] $tip }




ShowPopupMenu [::alited::favor]favor, Top

Displays a popup menu at clicking the favorites / last visited list.

ShowPopupMenu ID X Y
Parameters
IDtree item's ID
Xx-coordinate of the mouse pointer
Yy-coordinate of the mouse pointer

proc ::alited::favor::ShowPopupMenu {ID X Y} { # Displays a popup menu at clicking the favorites / last visited list. # ID - tree item's ID # X - x-coordinate of the mouse pointer # Y - y-coordinate of the mouse pointer namespace upvar ::alited al al obPav obPav set wtree [$obPav TreeFavor] set popm $wtree.popup catch {destroy $popm} menu $popm -tearoff 0 set sname [lindex [$wtree item $ID -values] 0] if {[string length $sname]>25} {set sname "[string range $sname 0 21]..."} set msgsel [string map [list %t $sname] $al(MC,selfavor)] if {$al(FAV,IsFavor)} { set img alimg_misc set lab $al(MC,lastvisit) } else { set img alimg_heart set lab $al(MC,favorites) } $popm add command -label $lab {*}[$obPav iconA none] -command alited::favor::SwitchFavVisit -image $img $popm add separator if {$al(FAV,IsFavor)} { $popm add command -label $al(MC,FavLists) {*}[$obPav iconA none] -command ::alited::favor::Lists -image alimg_heart $popm add command -label $al(MC,favoradd) {*}[$obPav iconA none] -command {::alited::favor::Add no} -image alimg_add $popm add command -label $al(MC,favordel) {*}[$obPav iconA none] -command {::alited::favor::Delete no} -image alimg_delete $popm add separator } $popm add command -label $al(MC,favordelall) {*}[$obPav iconA none] -command {::alited::favor::DeleteAll no} -image alimg_trash $popm add separator $popm add command -label $al(MC,copydecl) {*}[$obPav iconA none] -command "::alited::favor::CopyDeclaration $wtree $ID" $obPav themePopup $popm tk_popup $popm $X $Y }




SwitchFavVisit [::alited::favor]favor, Top

Switches favorites / last visited units' view.

SwitchFavVisit

proc ::alited::favor::SwitchFavVisit {} { # Switches favorites / last visited units' view. namespace upvar ::alited al al obPav obPav set al(FAV,IsFavor) [expr {!$al(FAV,IsFavor)}] Show }




Tooltip [::alited::favor]favor, Top

Shows a tip of favorite / last visited unit's declaration.

Tooltip x y X Y
Parameters
xx-coordinate to identify tree item
yy-coordinate to identify tree item
Xx-coordinate of the mouse pointer
Yy-coordinate of the mouse pointer

proc ::alited::favor::Tooltip {x y X Y} { # Shows a tip of favorite / last visited unit's declaration. # x - x-coordinate to identify tree item # y - y-coordinate to identify tree item # X - x-coordinate of the mouse pointer # Y - y-coordinate of the mouse pointer namespace upvar ::alited al al obPav obPav variable tipID set wtree [$obPav TreeFavor] if {[$wtree identify region $x $y] ni {tree cell}} { TooltipOff return } set ID [$wtree identify item $x $y] if {[$wtree exists $ID] && $tipID ne $ID} { lassign [$wtree bbox $ID] x2 y2 w2 h2 incr X 10 if {[catch {incr Y [expr {$y2-$y+$h2}]}]} {incr Y 10} set decl [lindex [$wtree item $ID -values] 2] set fname [lindex [$wtree item $ID -values] 1] append tip $decl \n $fname set msec [clock milliseconds] if {![info exists al(FAVORTIP_MSEC)]} { set al(FAVORTIP_MSEC) 0 } if {($msec-$al(FAVORTIP_MSEC))>200} { ::baltip tip $al(WIN) $tip -geometry +$X+$Y -per10 4000 -pause 5 -fade 5 set tipID $ID } else { TooltipOff } set al(FAVORTIP_MSEC) $msec } }




TooltipOff [::alited::favor]favor, Top

Removes a tip of favorite / last visited unit's declaration.

TooltipOff

proc ::alited::favor::TooltipOff {} { # Removes a tip of favorite / last visited unit's declaration. namespace upvar ::alited al al obPav obPav variable tipID ::baltip hide $al(WIN) set tipID {} }



::alited::favor_lsTop


Commandsfavor_ls, Top




_create [::alited::favor_ls]favor_ls, Top

Creates "Favorites lists" dialogue.

_create

proc ::alited::favor_ls::_create {} { # Creates "Favorites lists" dialogue. namespace upvar ::alited al al obDl2 obDl2 variable win variable favlist variable fav $obDl2 makeWindow $win $al(MC,favorites) $obDl2 paveWindow $win { {fraLbxFav - - 1 2 {-st nswe -pady 4} {}} {.labFavs - - - - {pack -side top -anchor nw -padx 4} {-t "Lists of favorites:"}} {.fra - - - - {pack -side right -fill both} {}} {.fra.buTAd - - - - {pack -side top -anchor n} {-takefocus 0 -com ::alited::favor_ls::Add -tip "Add a list of favorites" -image alimg_add-big}} {.fra.buTChg - - - - {pack -side top} {-takefocus 0 -com ::alited::favor_ls::Change -tip "Change a list of favorites" -image alimg_change-big}} {.fra.buTDel - - - - {pack -side top} {-takefocus 0 -com ::alited::favor_ls::Delete -tip "Delete a list of favorites" -image alimg_delete-big}} {.LbxFav - - - - {pack -side left -expand 1 -fill both} {-h 7 -w 40 -lvar ::alited::favor_ls::favlist}} {.sbvFavs fraLbxFav.LbxFav L - - {pack -side left -fill both} {}} {fra1 fraLbxFav T 1 2 {-st nswe}} {fra1.fraEnt - - 1 1 {pack -side top -expand 1 -fill both -pady 4}} {.labFav - - 1 1 {pack -side left -padx 4} {-t "Current list of favorites:"}} {.EntFav fra1.labFav L 1 1 {pack -side left -expand 1 -fill both} {-tvar ::alited::favor_ls::fav -tip {$alited::al(MC,favent1)}}} {fra1.fratex fra1.labFav T 1 2 {pack -side bottom}} {.TexFav - - - - {pack -side left -expand 1 -fill both} {-h 7 -w 60 -tip "Favorites of the current list" -ro 1}} {.sbvFav .TexFav L - - {pack -side left}} {fra2 fra1 T 1 2 {-st nswe} {-padding {5 5 5 5} -relief groove}} {.labBA - - - - {pack -side left} {-t "Non-favorite files to be:"}} {.radA - - - - {pack -side left -padx 8} {-t kept -var ::alited::favor_ls::place -value 1 -tip "Doesn't close any tab without favorites\nat choosing the favorites' list"}} {.radB - - - - {pack -side left -padx 8} {-t closed -var ::alited::favor_ls::place -value 2 -tip "Closes all tabs without favorites\nat choosing the favorites' list"}} {LabMess fra2 T 1 2 {-st nsew -pady 0 -padx 3} {-style TLabelFS}} {fra3 labMess T 1 2 {-st nswe}} {.butHelp - - - - {pack -side left} {-t "$alited::al(MC,help)" -command ::alited::favor_ls::Help}} {.h_ - - - - {pack -side left -expand 1 -fill both -padx 4}} {.butUndo - - - - {pack -side left} {-t Back -command {::alited::favor_ls::Ok 3} -tip "Sets a list of favorites\nthat was active initially."}} {.butOK - - - - {pack -side left -padx 2} {-t "$alited::al(MC,select)" -command ::alited::favor_ls::Ok}} {.butCancel - - - - {pack -side left} {-t Cancel -command ::alited::favor_ls::Cancel}} } set fav {} set lbx [$obDl2 LbxFav] set wtxt [$obDl2 TexFav] GetCurrentList Restore_favlist bind $lbx <<ListboxSelect>> ::alited::favor_ls::Select bind $lbx <Delete> ::alited::favor_ls::Delete bind $lbx <Double-Button-1> ::alited::favor_ls::Ok bind $lbx <Return> ::alited::favor_ls::Ok if {[llength $favlist]} {set foc $lbx} {set foc [$obDl2 EntFav]} set res [$obDl2 showModal $win -resizable {0 0} -onclose ::alited::favor_ls::Cancel -focus $foc] return $res }




_run [::alited::favor_ls]favor_ls, Top

Runs "Favorites lists" dialogue.

_run

proc ::alited::favor_ls::_run {} { # Runs "Favorites lists" dialogue. variable win set res [_create] destroy $win return $res }




Add [::alited::favor_ls]favor_ls, Top

Handles hitting "Add favorites' list" button.

Add

proc ::alited::favor_ls::Add {} { # Handles hitting "Add favorites' list" button. namespace upvar ::alited al al obDl2 obDl2 variable favlist variable favcont variable favpla variable currents variable fav variable place if {[set isel [[$obDl2 LbxFav] curselection]] eq {}} { set cont $currents } else { set cont [lindex $favcont $isel] } set found no set isel 0 foreach f $favlist p $favpla c $favcont { if {$fav eq $f || ($p eq $place && $c eq $cont)} { set found yes break } incr isel } set fav [string trim $fav] if {$fav ne "" && $cont ne "" && $found} { alited::Message2 $al(MC,favexists) 4 Select $isel return } elseif {$fav eq ""} { focus [$obDl2 EntFav] alited::Message2 $al(MC,favent1) 4 return } elseif {[string trim $cont] eq ""} { alited::Message2 $al(MC,favent3) 4 return } else { set isel end lappend favlist $fav lappend favcont $cont lappend favpla $place set msg [string map [list %n [llength $favlist]] $al(MC,favnew)] alited::Message2 $msg } Focus $isel }




Cancel [::alited::favor_ls]favor_ls, Top

Handles hitting Cancel button.

Cancel ?args?
Parameters
argsOptional arguments.

proc ::alited::favor_ls::Cancel {args} { # Handles hitting Cancel button. namespace upvar ::alited obDl2 obDl2 variable win Save_favlist $obDl2 res $win 0 }




Change [::alited::favor_ls]favor_ls, Top

Handles hitting "Change favorites' list" button.

Change

proc ::alited::favor_ls::Change {} { # Handles hitting "Change favorites' list" button. namespace upvar ::alited al al obDl2 obDl2 variable favlist variable favpla variable place variable fav if {[set isel [Selected]] eq ""} return if {[set isl1 [lsearch -exact $favlist $fav]]!=$isel} { alited::Message2 $al(MC,favexists) 4 Select $isl1 } else { set favlist [lreplace $favlist $isel $isel $fav] set favpla [lreplace $favpla $isel $isel $place] set msg [string map [list %n [incr isel]] $al(MC,favupd)] alited::Message2 $msg } }




Delete [::alited::favor_ls]favor_ls, Top

Handles hitting "Delete favorites' list" button.

Delete

proc ::alited::favor_ls::Delete {} { # Handles hitting "Delete favorites' list" button. namespace upvar ::alited al al variable favlist variable favcont variable favpla if {[set isel [Selected]] eq ""} return set nsel [expr {$isel+1}] set msg [string map [list %n $nsel] $al(MC,favdelq)] if {![alited::msg yesno warn $msg NO -title $al(MC,warning)]} { return } set favlist [lreplace $favlist $isel $isel] set favcont [lreplace $favcont $isel $isel] set favpla [lreplace $favpla $isel $isel] set llen [expr {[llength $favlist]-1}] if {$isel>$llen} {set isel $llen} if {$llen>=0} {Select $isel} set msg [string map [list %n $nsel] $al(MC,favrem)] alited::Message2 $msg }




Focus [::alited::favor_ls]favor_ls, Top

Focuses on an item of the list.

Focus isel
Parameters
iselthe item to focus on

proc ::alited::favor_ls::Focus {isel} { # Focuses on an item of the list. # isel - the item to focus on namespace upvar ::alited obDl2 obDl2 set lbx [$obDl2 LbxFav] $lbx selection clear 0 end $lbx selection set $isel $isel $lbx see $isel }




GetCurrentList [::alited::favor_ls]favor_ls, Top

Gets a current list of favorites from alited's main form.

GetCurrentList ?args?
Parameters
argsa list of favorites
Description

If args is omitted, the current favorites tree's contents will be the list.


proc ::alited::favor_ls::GetCurrentList {args} { # Gets a current list of favorites from alited's main form. # args - a list of favorites # If args is omitted, the current favorites tree's contents will be the list. namespace upvar ::alited obDl2 obDl2 variable currents set text [set currents {}] if {![llength $args]} {set args [alited::tree::GetTree {} TreeFavor]} foreach it $args { if {$text ne {}} { append text \n append currents $::alited::EOL } append text [lindex $it 4 0] append currents $it } set w [$obDl2 TexFav] $obDl2 readonlyWidget $w no $obDl2 displayText $w $text $obDl2 readonlyWidget $w yes }




GetIni [::alited::favor_ls]favor_ls, Top

Reads favorites' lists data, stored in the ini file.

GetIni lines
Parameters
linesNot documented.

proc ::alited::favor_ls::GetIni {lines} { # Reads favorites' lists data, stored in the ini file. variable favlist variable favlistsaved variable favcont variable favpla variable currents variable fav variable place set lines [Split $lines] if {[llength $lines]<3} { # initialize arrays set favlist [list] set favlistsaved [list] set favcont [list] set favpla [list] set currents [list] set fav {} set place 1 } elseif {[set cont [lrange $lines 2 end]] ne {}} { lappend favlist [lindex $lines 0] lappend favpla [lindex $lines 1] lappend favcont [join $cont $::alited::EOL] } Save_favlist }




Help [::alited::favor_ls]favor_ls, Top

Handles hitting Help button.

Help ?args?
Parameters
argsOptional arguments.

proc ::alited::favor_ls::Help {args} { # Handles hitting Help button. variable win alited::Help $win }




IniFile [::alited::favor_ls]favor_ls, Top

Returns the ini file's name to store favorites' lists.

IniFile
Return value

Returns the ini file's name to store favorites' lists.


proc ::alited::favor_ls::IniFile {} { # Returns the ini file's name to store favorites' lists. return [file join $alited::INIDIR favor_ls.ini] }




Ok [::alited::favor_ls]favor_ls, Top

Handles hitting OK button.

Ok ?res?
Parameters
resif 0, sets the dialogue's result from a current favorites item; optional, default 0

proc ::alited::favor_ls::Ok {{res 0}} { # Handles hitting OK button. # res - if 0, sets the dialogue's result from a current favorites item. namespace upvar ::alited obDl2 obDl2 variable win variable favcont variable favpla if {!$res} { if {[set isel [Selected]] eq {}} { focus [$obDl2 LbxFav] return } set pla [lindex $favpla $isel] set cont [lindex $favcont $isel] set res [list $pla [Split $cont]] } Save_favlist $obDl2 res $win $res }




PutIni [::alited::favor_ls]favor_ls, Top

Makes favorites' lists data to store to the ini file.

PutIni

proc ::alited::favor_ls::PutIni {} { # Makes favorites' lists data to store to the ini file. variable favlist variable favcont variable favpla Restore_favlist set res [list] foreach fav $favlist pla $favpla cont $favcont { set r1 $fav append r1 $::alited::EOL append r1 $pla append r1 $::alited::EOL append r1 $cont lappend res $r1 } return $res }




Restore_favlist [::alited::favor_ls]favor_ls, Top

Restores favorites' list.

Restore_favlist

proc ::alited::favor_ls::Restore_favlist {} { # Restores favorites' list. variable favlist variable favlistsaved set favlist $favlistsaved }




Save_favlist [::alited::favor_ls]favor_ls, Top

Saves favorites' list.

Save_favlist

proc ::alited::favor_ls::Save_favlist {} { # Saves favorites' list. variable favlist variable favlistsaved set favlistsaved $favlist }




Select [::alited::favor_ls]favor_ls, Top

Handles a selection in the list of favorites' lists.

Select ?isel?
Parameters
isela selected item of the list; optional, default ""

proc ::alited::favor_ls::Select {{isel {}}} { # Handles a selection in the list of favorites' lists. # isel - a selected item of the list namespace upvar ::alited obDl2 obDl2 variable favlist variable favcont variable favpla variable fav variable place set lbx [$obDl2 LbxFav] if {$isel eq {}} {set isel [$lbx curselection]} if {$isel ne {}} { set fav [lindex $favlist $isel] set place [lindex $favpla $isel] set cont [Split [lindex $favcont $isel]] GetCurrentList {*}$cont Focus $isel } }




Selected [::alited::favor_ls]favor_ls, Top

Gets a selected item of favorites list.

Selected

proc ::alited::favor_ls::Selected {} { # Gets a selected item of favorites list. namespace upvar ::alited al al obDl2 obDl2 variable favlist if {[set isel [[$obDl2 LbxFav] curselection]] eq {}} { alited::Message2 $al(MC,favsel) 4 } return $isel }




Split [::alited::favor_ls]favor_ls, Top

Splits a saved list by the list's dividers.

Split lines
Parameters
linesNot documented.

proc ::alited::favor_ls::Split {lines} { # Splits a saved list by the list's dividers. return [split [string map [list $::alited::EOL \n] $lines] \n] }




Text [::alited::favor_ls]favor_ls, Top

Gets a text with a list of favorites.

Text

proc ::alited::favor_ls::Text {} { # Gets a text with a list of favorites. namespace upvar ::alited obDl2 obDl2 return [[$obDl2 TexFav] get 1.0 {end -1 char}] }



::alited::fileTop


Commandsfile, Top




Add [::alited::file]file, Top

Creates a file at the file tree.

Add ID
Parameters
IDtree item's ID

proc ::alited::file::Add {ID} { # Creates a file at the file tree. # ID - tree item's ID namespace upvar ::alited al al obPav obPav obDl2 obDl2 if {$ID eq {}} {set ID [alited::tree::CurrentItem]} set dname [lindex [[$obPav Tree] item $ID -values] 1] if {[file isdirectory $dname]} { set fname {} } else { set fname [file tail $dname] set dname [file dirname $dname] } set head [string map [list %d $dname] $al(MC,filesadd2)] while {1} { set res [$obDl2 input "" $al(MC,filesadd) [list seh {{} {-pady 10}} {} ent {{File name:} {} {-w 40}} "{$fname}" chb [list {} {-padx 5} [list -toprev 1 -t "Directory"]] {0} ] -head $head -family "{[::apave::obj basicTextFont]}"] if {[lindex $res 0] && $fname eq ""} bell else break } lassign $res res fname isdir if {$res} { set fname [file join $dname $fname] if {[catch { if {$isdir} { file mkdir $fname } else { if {[file extension $fname] eq ""} {append fname .tcl} if {![file exists $fname]} {close [open $fname w]} OpenFile $fname } alited::tree::RecreateTree } err]} then { alited::msg ok err $err } } }




AddRecent [::alited::file]file, Top

AddRecent fname
Parameters
fnameNot documented.

proc ::alited::file::AddRecent {fname} { namespace upvar ::alited al al InsertRecent $fname 0 alited::menu::FillRecent }




AllSaved [::alited::file]file, Top

Checks whether all files are saved. Saves them if not.

AllSaved

proc ::alited::file::AllSaved {} { # Checks whether all files are saved. Saves them if not. foreach tab [alited::bar::BAR listTab] { set TID [lindex $tab 0] switch [IsSaved $TID] { 0 { ;# "Cancel" chosen for a modified return no } 1 { ;# "Save" chosen for a modified set res [SaveFile $TID] } } } return yes }




CheckForNew [::alited::file]file, Top

Checks if there is a file in bar of tabs and creates "No name" tab, if no tab exists.

CheckForNew ?docheck?
Parameters
docheckif yes, does checking, if no - run itself with docheck=yes; optional, default no

proc ::alited::file::CheckForNew {{docheck no}} { # Checks if there is a file in bar of tabs and creates "No name" tab, if no tab exists. # docheck - if yes, does checking, if no - run itself with docheck=yes if {$docheck} { if {![llength [alited::bar::BAR listTab]]} { alited::file::NewFile } } else { after idle {::alited::file::CheckForNew yes} } }




ChooseRecent [::alited::file]file, Top

ChooseRecent idx
Parameters
idxNot documented.

proc ::alited::file::ChooseRecent {idx} { namespace upvar ::alited al al set fname [lindex $al(RECENTFILES) $idx] AddRecent $fname OpenFile $fname }




CloseAll [::alited::file]file, Top

Closes files.

CloseAll func ?args?
Parameters
func"1/2/3" means closing "all/to left/to right"
argsmay contain -skipsel to not close selected tabs

proc ::alited::file::CloseAll {func args} { # Closes files. # func - "1/2/3" means closing "all/to left/to right" # args - may contain -skipsel to not close selected tabs namespace upvar ::alited al al set TID [alited::bar::CurrentTabID] set al(closefunc) $func ;# disables "recent files" at closing all alited::bar::BAR closeAll $::alited::al(BID) $TID $func {*}$args set al(closefunc) 0 return [expr {[llength [alited::bar::BAR listFlag "m"]]==0}] }




CloseFile [::alited::file]file, Top

Closes a file.

CloseFile ?TID? ?checknew?
Parameters
TIDtab's ID; optional, default ""
checknewif yes, checks if new file's tab should be created; optional, default yes

proc ::alited::file::CloseFile {{TID {}} {checknew yes}} { # Closes a file. # TID - tab's ID # checknew - if yes, checks if new file's tab should be created namespace upvar ::alited al al obPav obPav set res 1 if {$TID eq ""} {set TID [alited::bar::CurrentTabID]} set fname [alited::bar::FileName $TID] lassign [alited::bar::GetTabState $TID --wtxt --wsbv] wtxt wsbv if {$TID ni {"-1" ""} && $wtxt ne ""} { switch [IsSaved $TID] { 0 { ;# "Cancel" chosen for a modified return 0 } 1 { ;# "Save" chosen for a modified set res [SaveFile $TID] } } if {$wtxt ne [$obPav Text]} { # [$obPav Text] was made by main::_open, let it be alive catch {destroy $wtxt} catch {destroy $wsbv} } if {$checknew} CheckForNew alited::ini::SaveCurrentIni $al(INI,save_onclose) alited::tree::UpdateFileTree } if {$al(closefunc) != 1} { ;# close func = 1 means "close all" alited::file::AddRecent $fname } return $res }




CloseFileMenu [::alited::file]file, Top

Closes the current file from the menu.

CloseFileMenu

proc ::alited::file::CloseFileMenu {} { # Closes the current file from the menu. if {[set TID [alited::bar::CurrentTabID]] ne ""} { alited::bar::BAR $TID close } }




Delete [::alited::file]file, Top

Deletes a file at the file tree.

Delete ID wtree
Parameters
IDtree item's ID wtree file tree widget
wtreeNot documented.

proc ::alited::file::Delete {ID wtree} { # Deletes a file at the file tree. # ID - tree item's ID # wtree file tree widget namespace upvar ::alited al al BAKDIR BAKDIR set name [$wtree item $ID -text] set fname [lindex [$wtree item $ID -values] 1] set TID [alited::bar::FileTID $fname] if {$TID ne ""} { bell alited::msg ok warn $al(MC,nodelopen) alited::bar::BAR $TID show return } set msg [string map [list %f $name] $al(MC,delfile)] if {[alited::msg yesno ques $msg NO]} { RemoveFile $fname $BAKDIR backup } }




DisplayFile [::alited::file]file, Top

Displays a file's contents.

DisplayFile TID fname wtxt doreload
Parameters
TIDID of tab
fnamefile name
wtxttext widget's path
doreloadif yes, forces reloading (at external changes of file)

proc ::alited::file::DisplayFile {TID fname wtxt doreload} { # Displays a file's contents. # TID - ID of tab # fname - file name # wtxt - text widget's path # doreload - if yes, forces reloading (at external changes of file) namespace upvar ::alited al al obPav obPav # this is most critical: displayed text should correspond to the tab if {$wtxt ne [alited::main::GetWTXT $TID]} { set errmsg "\n ERROR file::DisplayFile: \n ($TID) $wtxt != [alited::main::GetWTXT $TID] \n Please, notify alited's authors!\n" puts $errmsg return -code error $errmsg } # another critical point: read the file only at need if {$doreload || [set filecont [ReadFileByTID $TID yes]] eq {}} { # last check point: 0 bytes of the file => read it anyway set filecont [ReadFile $TID $fname] } $obPav displayText $wtxt $filecont $obPav makePopup $wtxt no yes }




DoMoveFile [::alited::file]file, Top

Asks and moves a file to a directory.

DoMoveFile fname dname f1112
Parameters
fnamefile name
dnamedirectory name
f1112yes, if run by pressing F11/F12 keys

proc ::alited::file::DoMoveFile {fname dname f1112} { # Asks and moves a file to a directory. # fname - file name # dname - directory name # f1112 - yes, if run by pressing F11/F12 keys namespace upvar ::alited al al set tailname [file tail $fname] if {$f1112} { set defb NO set geo "" } else { set defb YES set geo "-geometry pointer+10+10" } set msg [string map [list %f $tailname %d $dname] $al(MC,movefile)] if {![info exists al(_ANS_MOVE_)] || $al(_ANS_MOVE_)!=11} { set al(_ANS_MOVE_) [alited::msg yesno ques $msg $defb -title $al(MC,moving) {*}$geo -ch "Don't ask again"] if {!$al(_ANS_MOVE_)} return } RemoveFile $fname $dname move }




FileSize [::alited::file]file, Top

Formats a file's size.

FileSize bsize
Parameters
bsizefile size in bytes

proc ::alited::file::FileSize {bsize} { # Formats a file's size. # bsize - file size in bytes set res "$bsize bytes" set bsz $bsize foreach m {Kb Mb Gb Tb} { if {$bsz<1024} break set rsz [expr {$bsz/1024.0}] set res "[format %.1f $rsz] $m ($bsize bytes)" set bsz [expr {int($bsz/1024)}] } return $res }




FileStat [::alited::file]file, Top

Gets a file's attributes: times & size.

FileStat fname
Parameters
fnamefile name
Return value

Returns a string with file name and attributes divided by \n.


proc ::alited::file::FileStat {fname} { # Gets a file's attributes: times & size. # fname - file name # Returns a string with file name and attributes divided by \n. set res {} array set ares {} if {$alited::al(TREE,showinfo) && ![catch {file stat $fname ares}]} { set dtf "%D %T" set res "\n \nCreated: [clock format $ares(ctime) -format $dtf] \nModified: [clock format $ares(mtime) -format $dtf] \nAccessed: [clock format $ares(atime) -format $dtf] \nSize: [FileSize $ares(size)]" } return [append fname $res] }




InsertRecent [::alited::file]file, Top

InsertRecent fname pos
Parameters
fnameNot documented.
posNot documented.

proc ::alited::file::InsertRecent {fname pos} { namespace upvar ::alited al al if {![IsNoName $fname]} { if {[set i [lsearch $al(RECENTFILES) $fname]]>-1} { set al(RECENTFILES) [lreplace $al(RECENTFILES) $i $i] } set al(RECENTFILES) [linsert $al(RECENTFILES) $pos $fname] catch { set al(RECENTFILES) [lreplace $al(RECENTFILES) $al(INI,RECENTFILES) end] } } }




IsClang [::alited::file]file, Top

Checks if a file is of C/C++.

IsClang fname
Parameters
fnamefile name

proc ::alited::file::IsClang {fname} { # Checks if a file is of C/C++. # fname - file name if {[string tolower [file extension $fname]] in $alited::al(ClangExtensions)} { return yes } return no }




IsModified [::alited::file]file, Top

Checks if a text of tab is modified.

IsModified ?TID?
Parameters
TIDID of tab; optional, default ""

proc ::alited::file::IsModified {{TID {}}} { # Checks if a text of tab is modified. # TID - ID of tab if {$TID eq ""} {set TID [alited::bar::CurrentTabID]} return [expr {[lsearch -index 0 [alited::bar::BAR listFlag m] $TID]>-1}] }




IsNoName [::alited::file]file, Top

Checks if a file name is "No name".

IsNoName fname
Parameters
fnamefile name

proc ::alited::file::IsNoName {fname} { # Checks if a file name is "No name". # fname - file name namespace upvar ::alited al al if {[file tail $fname] in [list $al(MC,nofile) {No name} {}]} { return yes } return no }




IsSaved [::alited::file]file, Top

Checks if a file is modified and if yes, offers to save it.

IsSaved TID
Parameters
TIDID of tab
Return value

Returns 1 for "yes, needs saving", 2 for "needs no saving", 0 for "cancel".


proc ::alited::file::IsSaved {TID} { # Checks if a file is modified and if yes, offers to save it. # TID - ID of tab # Returns 1 for "yes, needs saving", 2 for "needs no saving", 0 for "cancel". namespace upvar ::alited al al if {[IsModified $TID]} { set fname [alited::bar::BAR $TID cget -text] set ans [alited::msg yesnocancel warn [string map [list %f $fname] $al(MC,notsaved)] YES -title $al(MC,saving)] return $ans } return 2 ;# as if "No" chosen }




IsTcl [::alited::file]file, Top

Checks if a file is of Tcl.

IsTcl fname
Parameters
fnamefile name

proc ::alited::file::IsTcl {fname} { # Checks if a file is of Tcl. # fname - file name if {[string tolower [file extension $fname]] in $alited::al(TclExtensions)} { return yes } return no }




MakeThemHighlighted [::alited::file]file, Top

Sets flag "highlight file(s) anyway".

MakeThemHighlighted ?tabs?
Parameters
tabslist of tabs to set the flag for; optional, default ""
Description

Useful when you need update the files' highlightings.


proc ::alited::file::MakeThemHighlighted {{tabs {}}} { # Sets flag "highlight file(s) anyway". # tabs - list of tabs to set the flag for # Useful when you need update the files' highlightings. namespace upvar ::alited al al if {$tabs eq {}} { set tabs [alited::bar::BAR listTab] } foreach tab $tabs { set wtxt [alited::main::GetWTXT [lindex $tab 0]] set al(HL,$wtxt) {..} } }




MoveExternal [::alited::file]file, Top

Moves an external file to a project's directory.

MoveExternal f1112
Parameters
f1112yes, if run by F11/F12 keys

proc ::alited::file::MoveExternal {f1112} { # Moves an external file to a project's directory. # f1112 - yes, if run by F11/F12 keys namespace upvar ::alited al al set fname [alited::bar::FileName] if {$al(prjroot) eq {} || [string first $al(prjroot) $fname]==0} { return no ;# no project directory or the file is inside it } DoMoveFile $fname $al(prjroot) $f1112 return yes }




MoveFile [::alited::file]file, Top

Moves file(s).

MoveFile wtree to itemID f1112
Parameters
wtreefile tree widget
to"move", "up" or "down" (direction of moving)
itemIDfile's tree ID to be moved
f1112yes for pressing F11/F12 or file's tree ID
Description

For to=move, f1112 is a file's ID to be moved to.


proc ::alited::file::MoveFile {wtree to itemID f1112} { # Moves file(s). # wtree - file tree widget # to - "move", "up" or "down" (direction of moving) # itemID - file's tree ID to be moved # f1112 - yes for pressing F11/F12 or file's tree ID # For to=move, f1112 is a file's ID to be moved to. set tree [alited::tree::GetTree] set idx [alited::unit::SearchInBranch $itemID $tree] if {$idx<0} return if {$to eq {move}} { MoveFile1 $wtree $itemID $f1112 return } set curfile [alited::bar::FileName] set curdir [file dirname $curfile] set selparent [$wtree parent $itemID] set dirname {} set increment [expr {$to eq {up} ? -1 : 1}] for {set i $idx} {1} {incr i $increment} { lassign [lindex $tree $i 4] files fname isfile id if {$fname eq {}} break if {$isfile} { set parent [$wtree parent $id] if {$parent ne $selparent && $parent ne {} && [file dirname $fname] ne $curdir} { lassign [$wtree item $parent -values] files fname isfile id set dirname $fname break } } elseif {$id ne $selparent || $fname ne $curdir} { set dirname $fname break } } if {$dirname eq ""} { if {$selparent ne ""} { set dirname $alited::al(prjroot) } else { bell return } } DoMoveFile $curfile $dirname $f1112 alited::main::ShowHeader yes }




MoveFile1 [::alited::file]file, Top

Moves a file from a tree position to another tree position.

MoveFile1 wtree fromID toID
Parameters
wtreefile tree widget
fromIDtree ID to move the file from
toIDtree ID to move the file to

proc ::alited::file::MoveFile1 {wtree fromID toID} { # Moves a file from a tree position to another tree position. # wtree - file tree widget # fromID - tree ID to move the file from # toID - tree ID to move the file to if {![$wtree exists $fromID] || ![$wtree exists $toID]} return set curfile [lindex [$wtree item $fromID -values] 1] set dirname [lindex [$wtree item $toID -values] 1] if {![file isdirectory $dirname]} { set dirname [file dirname $dirname] } if {[file isdirectory $curfile]} { if {$curfile ne $dirname} { alited::msg ok err [msgcat::mc "Only files are moved by alited."] -geometry pointer+10+-100 } return } if {[file dirname $curfile] ne $dirname} { DoMoveFile $curfile $dirname no alited::main::ShowHeader yes } }




NewFile [::alited::file]file, Top

Handles "New file" menu item.

NewFile

proc ::alited::file::NewFile {} { # Handles "New file" menu item. namespace upvar ::alited al al if {[set TID [alited::bar::FileTID $al(MC,nofile)]] eq {}} { set TID [alited::bar::InsertTab $al(MC,nofile) $al(MC,nofile)] } alited::bar::BAR $TID show }




OpenFile [::alited::file]file, Top

Handles "Open file" menu item.

OpenFile ?fname? ?reload?
Parameters
fnamefile name (if not set, asks for it; optional, default ""
reloadif yes, loads the file even if it has a "strange" extension; optional, default no
Return value

Returns the file's tab ID if it's loaded, or {} if not loaded.


proc ::alited::file::OpenFile {{fname {}} {reload no}} { # Handles "Open file" menu item. # fname - file name (if not set, asks for it # reload - if yes, loads the file even if it has a "strange" extension # Returns the file's tab ID if it's loaded, or {} if not loaded. namespace upvar ::alited al al obPav obPav set al(filename) {} set chosen no if {$fname eq {}} { set chosen yes set fname [$obPav chooser tk_getOpenFile alited::al(filename) -initialdir [file dirname [alited::bar::CurrentTab 2]] -parent $al(WIN)] } if {[file exists $fname]} { set exts {tcl, tm, msg, c, h, cc, cpp, hpp, html, css, md, txt, ini} set ext [string tolower [string trim [file extension $fname] .]] if {!$reload && $ext ni [split [string map {{ } {}} $exts] ,]} { set msg [string map [list %f [file tail $fname] %s $exts] $al(MC,nottoopen)] if {![alited::msg yesno warn $msg NO]} { return {} } } if {[set TID [alited::bar::FileTID $fname]] eq {}} { # close "no name" tab if it's the only one and not changed set tabs [alited::bar::BAR listTab] set tabm [alited::bar::BAR listFlag m] if {[llength $tabs]==1 && [llength $tabm]==0} { set tid [lindex $tabs 0 0] if {[alited::bar::FileName $tid] eq $al(MC,nofile)} { alited::bar::BAR $tid close } } # open new tab set tab [alited::bar::UniqueListTab $fname] set TID [alited::bar::InsertTab $tab [FileStat $fname]] alited::file::AddRecent $fname } if {$TID ne [alited::bar::CurrentTabID]} {alited::bar::BAR $TID show} return $TID } return {} }




OpenOfDir [::alited::file]file, Top

Opens all Tcl files of a directory.

OpenOfDir dname
Parameters
dnamedirectory's name

proc ::alited::file::OpenOfDir {dname} { # Opens all Tcl files of a directory. # dname - directory's name if {![catch {set flist [glob -directory $dname *]}]} { foreach fname [lsort -decreasing $flist] { if {[file isfile $fname] && [IsTcl $fname]} { OpenFile $fname } } alited::tree::UpdateFileTree } }




OutwardChange [::alited::file]file, Top

Checks for change of file by an external application.

OutwardChange TID ?docheck?
Parameters
TIDID of tab
docheckyes for "do check", no for "just save the file's mtime" optional, default yes

proc ::alited::file::OutwardChange {TID {docheck yes}} { # Checks for change of file by an external application. # TID - ID of tab # docheck - yes for "do check", no for "just save the file's mtime" namespace upvar ::alited al al set fname [alited::bar::FileName $TID] lassign [alited::bar::BAR $TID cget --mtime --mtimefile] mtime mtimefile if {[file exists $fname]} { set curtime [file mtime $fname] } elseif {$fname ne $al(MC,nofile)} { set curtime ? } else { set curtime {} } if {$docheck && $mtime ne {} && $curtime ne $mtime && $fname eq $mtimefile} { set isfile [file exists $fname] if {$isfile} { set msg [string map [list %f [file tail $fname]] $al(MC,modiffile)] } else { set msg [string map [list %f [file tail $fname]] $al(MC,wasdelfile)] } if {[alited::msg yesno warn $msg YES -title $al(MC,saving)]} { if {$isfile} { set wtxt [alited::main::GetWTXT $TID] set pos [$wtxt index insert] DisplayFile $TID $fname $wtxt yes alited::main::UpdateAll catch { ::tk::TextSetCursor $wtxt $pos ::alited::main::CursorPos $wtxt } } else { # if the answer was "no save", let the text remains for further considerations SaveFile $TID set curtime [file mtime $fname] } } } alited::bar::BAR $TID configure --mtime $curtime --mtimefile $fname -tip [FileStat $fname] }




ReadFile [::alited::file]file, Top

Reads a file, creates its unit tree.

ReadFile TID fname
Parameters
TIDID of tab
fnamefile name
Return value

Returns the file's contents.


proc ::alited::file::ReadFile {TID fname} { # Reads a file, creates its unit tree. # TID - ID of tab # fname - file name # Returns the file's contents. namespace upvar ::alited al al set filecont [::apave::readTextFile $fname] set al(_unittree,$TID) [alited::unit::GetUnits $TID $filecont] return $filecont }




ReadFileByTID [::alited::file]file, Top

Reads a file of tab, if needed.

ReadFileByTID TID ?getcont?
Parameters
TIDID of the tab
getcontif yes, returns a content of the file; optional, default no

proc ::alited::file::ReadFileByTID {TID {getcont no}} { # Reads a file of tab, if needed. # TID - ID of the tab # getcont - if yes, returns a content of the file namespace upvar ::alited al al if {![info exist al(_unittree,$TID)]} { return [ReadFile $TID [alited::bar::FileName $TID]] } if {$getcont} { set wtxt [alited::main::GetWTXT $TID] return [$wtxt get 1.0 "end - 1 chars"] } }




RecreateFileTree [::alited::file]file, Top

Creates the file tree.

RecreateFileTree

proc ::alited::file::RecreateFileTree {} { # Creates the file tree. namespace upvar ::alited al al obPav obPav if {!$al(TREE,isunits)} { catch {after cancel $al(_AFT_RECR_)} set al(_AFT_RECR_) [after 100 ::alited::tree::RecreateTree] } }




RemoveFile [::alited::file]file, Top

Removes or backups a file, trying to save it in a directory.

RemoveFile fname dname mode
Parameters
fnamefile name
dnamename of directory
modeif "move", then moves a file to a directory, otherwise backups it

proc ::alited::file::RemoveFile {fname dname mode} { # Removes or backups a file, trying to save it in a directory. # fname - file name # dname - name of directory # mode - if "move", then moves a file to a directory, otherwise backups it namespace upvar ::alited al al set ftail [file tail $fname] set dtail [file tail $dname] set fname2 [file join $dname $ftail] if {[file exists $fname2]} { if {$mode eq "move"} { set msg [string map [list %f $ftail %d $dname] $al(MC,fileexist)] alited::msg ok warn $msg return } catch {file delete $fname2} } if {[catch {file copy $fname $dname} err]} { set msg [string map [list %f $ftail %d $dname] $al(MC,errcopy)] if {![alited::msg yesno warn "$err\n\n$msg" NO]} return } catch {file mtime $fname2 [file mtime $fname]} file delete $fname alited::Message [string map [list %f $ftail %d $dtail] $al(MC,removed)] if {$mode eq "move"} { set TID [alited::bar::CurrentTabID] alited::bar::SetTabState $TID --fname $fname2 alited::bar::BAR $TID configure -tip [FileStat $fname2] } alited::tree::RecreateTree }




RenameFile [::alited::file]file, Top

Renames a file.

RenameFile TID fname
Parameters
TIDID of tab
fnamefile name

proc ::alited::file::RenameFile {TID fname} { # Renames a file. # TID - ID of tab # fname - file name alited::bar::SetTabState $TID --fname $fname alited::bar::BAR $TID configure -text {} -tip {} set tab [alited::bar::UniqueListTab $fname] alited::bar::BAR $TID configure -text $tab -tip [FileStat $fname] alited::bar::BAR $TID show }




SaveAll [::alited::file]file, Top

Saves all files.

SaveAll

proc ::alited::file::SaveAll {} { # Saves all files. foreach tab [alited::bar::BAR listTab] { set TID [lindex $tab 0] if {[IsModified $TID]} { if {![SaveFile $TID]} {return no} } } return yes }




SaveFile [::alited::file]file, Top

Saves the current file.

SaveFile ?TID?
Parameters
TIDID of tab; optional, default ""

proc ::alited::file::SaveFile {{TID {}}} { # Saves the current file. # TID - ID of tab namespace upvar ::alited al al if {$TID eq {}} {set TID [alited::bar::CurrentTabID]} set fname [alited::bar::FileName $TID] if {$fname in [list {} $al(MC,nofile)]} { return [SaveFileAs $TID] } set res [SaveFileByName $TID $fname] alited::ini::SaveCurrentIni "$res && $al(INI,save_onsave)" alited::main::ShowHeader yes alited::tree::RecreateTree return $res }




SaveFileAndClose [::alited::file]file, Top

Saves and closes the current file. This handles pressing Ctrl+W.

SaveFileAndClose

proc ::alited::file::SaveFileAndClose {} { # Saves and closes the current file. # This handles pressing Ctrl+W. if {[IsModified] && ![SaveFile]} return alited::bar::BAR [alited::bar::CurrentTabID] close }




SaveFileAs [::alited::file]file, Top

Saves the current file "as".

SaveFileAs ?TID?
Parameters
TIDID of tab; optional, default ""

proc ::alited::file::SaveFileAs {{TID {}}} { # Saves the current file "as". # TID - ID of tab namespace upvar ::alited al al obPav obPav if {$TID eq {}} {set TID [alited::bar::CurrentTabID]} set fname [alited::bar::FileName $TID] set alited::al(filename) [file tail $fname] if {$alited::al(filename) in [list {} $al(MC,nofile)]} { set alited::al(filename) {} } set fname [$obPav chooser tk_getSaveFile alited::al(filename) -title [msgcat::mc {Save as}] -initialdir [file dirname $fname] -parent $al(WIN)] if {$fname in [list {} $al(MC,nofile)]} { set res 0 } elseif {[set res [SaveFileByName $TID $fname]]} { RenameFile $TID $fname alited::main::ShowHeader yes alited::tree::RecreateTree } return $res }




SaveFileByName [::alited::file]file, Top

Saves a file.

SaveFileByName TID fname
Parameters
TIDID of tab
fnamefile name

proc ::alited::file::SaveFileByName {TID fname} { # Saves a file. # TID - ID of tab # fname - file name set wtxt [alited::main::GetWTXT $TID] set fcont [$wtxt get 1.0 "end - 1 chars"] ;# last \n excluded if {![::apave::writeTextFile $fname fcont]} { alited::msg ok err [::apave::error $fname] -w 50 -text 1 return 0 } alited::unit::BackupFile $TID $wtxt edit modified no alited::unit::Modified $TID $wtxt alited::main::HighlightText $TID $fname $wtxt OutwardChange $TID no RecreateFileTree return 1 }




ToBeHighlighted [::alited::file]file, Top

Checks flag "highlight text anyway".

ToBeHighlighted wtxt
Parameters
wtxttext's path

proc ::alited::file::ToBeHighlighted {wtxt} { # Checks flag "highlight text anyway". # wtxt - text's path namespace upvar ::alited al al return [expr {$al(HL,$wtxt) eq {..}}] }




UpdateFileStat [::alited::file]file, Top

Updates tips in tab bar (file info).

UpdateFileStat

proc ::alited::file::UpdateFileStat {} { # Updates tips in tab bar (file info). foreach tab [alited::bar::BAR listTab] { set TID [lindex $tab 0] set fname [alited::bar::FileName $TID] alited::bar::BAR $TID configure -tip [FileStat $fname] } }




WrapLines [::alited::file]file, Top

Switches wrap word mode for a current text.

WrapLines

proc ::alited::file::WrapLines {} { # Switches wrap word mode for a current text. namespace upvar ::alited al al set wtxt [alited::main::CurrentWTXT] if {[set al(wrapwords) [expr {[$wtxt cget -wrap] ne {word}}]]} { $wtxt configure -wrap word } else { $wtxt configure -wrap none } }



::alited::findTop


Commandsfind, Top




_close [::alited::find]find, Top

Closes Find/Replace dialogue.

_close

proc ::alited::find::_close {} { # Closes Find/Replace dialogue. namespace upvar ::alited obFND obFND catch {$obFND res $::alited::find::win 0} ClearTags }




_create [::alited::find]find, Top

$ Creates Find/Replace dialogue.

_create

proc ::alited::find::_create {} { #$ Creates Find/Replace dialogue. namespace upvar ::alited al al obFND obFND variable win variable geo variable minsize variable data set data(lastinvoke) 1 set res 1 set w $win.fra while {$res} { $obFND makeWindow $w $al(MC,findreplace) $obFND paveWindow $w { {labB1 - - 1 1 {-st e} {-t "Find: " -style TLabelFS}} {Cbx1 labB1 L 1 9 {-st wes} {-tvar ::alited::find::data(en1) -values {$::alited::find::data(vals1)}}} {labB2 labB1 T 1 1 {-st e} {-t "Replace: " -style TLabelFS}} {cbx2 labB2 L 1 9 {-st wes} {-tvar ::alited::find::data(en2) -values {$::alited::find::data(vals2)}}} {labBm labB2 T 1 1 {-st e} {-t "Match: " -style TLabelFS}} {radA labBm L 1 1 {-st ws -padx 0} {-t "Exact" -var ::alited::find::data(v1) -value 1 -style TRadiobuttonFS}} {radB radA L 1 1 {-st ws -padx 5} {-t "Glob" -var ::alited::find::data(v1) -value 2 -tip "Allows to use *, ?, \[ and \]\nin \"find\" string." -style TRadiobuttonFS}} {radC radB L 1 5 {-st ws -padx 0 -cw 1} {-t "RE" -var ::alited::find::data(v1) -value 3 -tip "Allows to use the regular expressions\nin \"find\" string." -style TRadiobuttonFS}} {h_2 labBm T 1 9 {-st es -rw 1}} {seh h_2 T 1 9 {-st ews}} {chb1 seh T 1 2 {-st w} {-t "Match whole word only" -var ::alited::find::data(c1) -style TCheckbuttonFS}} {chb2 chb1 T 1 2 {-st w} {-t "Match case" -var ::alited::find::data(c2) -style TCheckbuttonFS}} {chb3 chb2 T 1 2 {-st w} {-t "Replace by blank" -var ::alited::find::data(c3) -tip "Allows replacements by the empty string,\nin fact, to erase the found ones." -style TCheckbuttonFS}} {sev1 chb1 L 5 1 } {fralabB3 sev1 L 4 6 {-st nsw} {-borderwidth 0 -relief groove -padding {3 3}}} {.labB3 - - - - {pack -anchor w} {-t "Direction:" -style TLabelFS}} {.rad1 - - - - {pack -anchor w -padx 0} {-t "Up" -image alimg_up -compound left -var ::alited::find::data(v2) -value 1 -style TRadiobuttonFS}} {.rad2 - - - - {pack -anchor w -padx 0} {-t "Down" -image alimg_down -compound left -var ::alited::find::data(v2) -value 2 -style TRadiobuttonFS}} {.chb4 - - - - {pack -anchor sw} {-t "Wrap around" -var ::alited::find::data(c4) -style TCheckbuttonFS}} {sev2 cbx1 L 10 1 } {But1 sev2 L 1 1 {-st we} {-t "Find" -com "::alited::find::Find 1" -style TButtonWestBoldFS}} {But2 but1 T 1 1 {-st we} {-t "All in Text" -com "::alited::find::FindInText 2" -style TButtonWestFS}} {But3 but2 T 1 1 {-st we} {-com "::alited::find::FindInSession add 3" -style TButtonWestFS}} {h_3 but3 T 2 1} {but4 h_3 T 1 1 {-st we} {-t Replace -com "::alited::find::Replace" -style TButtonWestBoldFS}} {but5 but4 T 1 1 {-st nwe} {-t "All in Text" -com "::alited::find::ReplaceInText" -style TButtonWestFS}} {But6 but5 T 1 1 {-st nwe} {-com "::alited::find::ReplaceInSession" -style TButtonWestFS}} } SessionButtons foreach k {f F} {bind $w.cbx1 <Control-$k> {::alited::find::LastInvoke; break}} bind $w.cbx1 <Return> "$w.but1 invoke" ;# hot in comboboxes bind $w.cbx2 <Return> "$w.but4 invoke" if {$minsize eq ""} { ;# save default min.sizes after idle [list after 100 { set ::alited::find::minsize "-minsize {[winfo width $::alited::find::win] [winfo height $::alited::find::win]}" }] } after idle "$w.cbx1 selection range 0 end" set res [$obFND showModal $win -geometry $geo {*}$minsize -focus $w.cbx1 -modal no] set geo [wm geometry $win] ;# save the new geometry of the dialogue destroy $win ClearTags } focus -force [alited::main::CurrentWTXT] }




_run [::alited::find]find, Top

Runs Find/Replace dialogue.

_run

proc ::alited::find::_run {} { # Runs Find/Replace dialogue. namespace upvar ::alited obFND obFND variable win GetFindEntry if {[winfo exists $win]} { SessionButtons wm withdraw $win wm deiconify $win set cbx [$obFND Cbx1] focus $cbx $cbx selection clear after idle "$cbx selection range 0 end" } else { _create } }




CheckData [::alited::find]find, Top

Checks if the find/replace data are valid.

CheckData op
Parameters
opif "repl", checks for "Replace" operation
Description

Return "yes", if the input data are valid.


proc ::alited::find::CheckData {op} { # Checks if the find/replace data are valid. # op - if "repl", checks for "Replace" operation # Return "yes", if the input data are valid. namespace upvar ::alited al al variable win variable data # this means "no checks when used outside of the dialogue": if {!$data(docheck)} {return yes} # search input data in arrays of combobox values: # if not found, save the data to the arrays set w $win.fra set foc {} foreach i {2 1} { if {[set data(en$i)] ne {}} { if {[set f [lsearch -exact [set data(vals$i)] [set data(en$i)]]]>-1} { set data(vals$i) [lreplace [set data(vals$i)] $f $f] } set data(vals$i) [linsert [set data(vals$i)] 0 [set data(en$i)]] catch {set data(vals$i) [lreplace [set data(vals$i)] $al(INI,maxfind) end]} $w.cbx$i configure -values [set data(vals$i)] } elseif {$i==1 || ($op eq "repl" && !$data(c3))} { set foc $w.cbx$i } } if {$foc ne {}} { # if find/replace field is empty, let the bell tolls for him bell focus $foc return no } return yes }




CheckWord [::alited::find]find, Top

Check if the found string is a word, at searching by words,

CheckWord wtxt index1 index2
Parameters
wtxttext widget's path
index1first index of the found string
index2last index of the found string
Return value

Returns "yes" if the found string is a word.


proc ::alited::find::CheckWord {wtxt index1 index2} { # Check if the found string is a word, at searching by words, # wtxt - text widget's path # index1 - first index of the found string # index2 - last index of the found string # Returns "yes" if the found string is a word. variable adelim variable data if {$data(c1)} { set index10 [$wtxt index "$index1 - 1c"] set index20 [$wtxt index "$index2 + 1c"] if {[$wtxt get $index10 $index1] ni $adelim} {return no} if {[$wtxt get $index2 $index20] ni $adelim} {return no} } return yes }




ClearTags [::alited::find]find, Top

Clears all find tags in a current text, if Find/Replace dialogue was closed.

ClearTags

proc ::alited::find::ClearTags {} { # Clears all find tags in a current text, if Find/Replace dialogue was closed. variable win catch { if {![winfo exists $win]} { [alited::main::CurrentWTXT] tag remove fndTag 1.0 end } } }




DoFindUnit [::alited::find]find, Top

Runs searching units in current text / all texts.

DoFindUnit

proc ::alited::find::DoFindUnit {} { # Runs searching units in current text / all texts. namespace upvar ::alited al al obPav obPav set ent [$obPav EntFindSTD] set what [string trim [$ent get]] if {$what eq {}} { bell return } InitShowResults set n 0 if {$alited::main::findunits==1} { set tabs [SessionList] } else { set tabs [alited::bar::CurrentTabID] } foreach tab $tabs { set TID [lindex $tab 0] alited::file::ReadFileByTID $TID foreach it $al(_unittree,$TID) { lassign $it lev leaf fl1 title l1 l2 set ttl [string range $title [string last : $title]+1 end] ;# pure name, no NS if {[string match -nocase "*$what*" $ttl]} { set fname [alited::bar::BAR $TID cget -text] alited::info::Put "$fname:$l1: $title" [list $TID $l1] incr n } } } alited::info::Clear 0 ShowResults [string map [list %n $n %s $what] $al(MC,frres1)] 3 }




Find [::alited::find]find, Top

Searches one string in a current text.

Find ?inv?
Parameters
invindex of a button that was hit (1 means "Find" button); optional, default -1

proc ::alited::find::Find {{inv -1}} { # Searches one string in a current text. # inv - index of a button that was hit (1 means "Find" button) namespace upvar ::alited obFND obFND variable data if {$inv>-1} {set data(lastinvoke) $inv} ;# save the hit button's index set wtxt [alited::main::CurrentWTXT] $wtxt tag remove sel 1.0 end set fndlist [Search $wtxt] if {![llength $fndlist]} { bell focus [$obFND Cbx1] return } set indexprev [set indexnext 0] set index [$wtxt index insert] foreach idx12 $fndlist { lassign $idx12 index1 index2 $wtxt tag add fndTag $index1 $index2 if {[$wtxt compare $index1 < $index]} { set indexprev $index1 set indp2 $index2 } if {[$wtxt compare $index < $index1] && $indexnext==0} { set indexnext $index1 set indn2 $index2 } } if {$data(c4) && $data(v2)==1} { ;# search backward & wrap around if {!$indexprev} {lassign [lindex $fndlist end] indexprev indp2} ::tk::TextSetCursor $wtxt $indexprev $wtxt tag add sel $indexprev $indp2 } elseif {$data(c4) && $data(v2)==2} { ;# search forward & wrap around if {!$indexnext || ([lindex $fndlist end 0]==$indexnext && [$wtxt compare $indexnext == $index])} { lassign [lindex $fndlist 0] indexnext indn2 } ::tk::TextSetCursor $wtxt $indexnext $wtxt tag add sel $indexnext $indn2 } elseif {!$data(c4) &&$data(v2)==1} { ;# search backward & not wrap around if {$indexprev} { ::tk::TextSetCursor $wtxt $indexprev $wtxt tag add sel $indexprev $indp2 } else { bell } } elseif {!$data(c4) && $data(v2)==2} { ;# search forward & not wrap around if {$indexnext} { ::tk::TextSetCursor $wtxt $indexnext $wtxt tag add sel $indexnext $indn2 } else { bell } } ::alited::main::CursorPos $wtxt if {$inv>-1} alited::main::HighlightLine }




FindAll [::alited::find]find, Top

Searches all strings in a text.

FindAll wtxt TID ?tagme?
Parameters
wtxttext widget's path
TIDtab's ID
tagmeif "add", means "add find tag to the found strings of the text" optional, default add

proc ::alited::find::FindAll {wtxt TID {tagme add}} { # Searches all strings in a text. # wtxt - text widget's path # TID - tab's ID # tagme - if "add", means "add find tag to the found strings of the text" set fname [alited::bar::BAR $TID cget -text] set l1 -1 set allfnd [Search $wtxt] foreach idx12 $allfnd { lassign $idx12 index1 index2 if {$tagme eq {add}} {$wtxt tag add fndTag $index1 $index2} set l2 [expr {int($index1)}] if {$l1 != $l2} { set line [$wtxt get "$index1 linestart" "$index1 lineend"] alited::info::Put "$fname:$l2: [string trim $line]" [list $TID $l2] set l1 $l2 } } return $allfnd }




FindInSession [::alited::find]find, Top

Searches all strings in a session.

FindInSession ?tagme? ?inv?
Parameters
tagmeif "add", means "add find tag to the found strings of the text" optional, default add
invindex of a button that was hit (3 means "All in Session" button); optional, default -1

proc ::alited::find::FindInSession {{tagme add} {inv -1}} { # Searches all strings in a session. # tagme - if "add", means "add find tag to the found strings of the text" # inv - index of a button that was hit (3 means "All in Session" button) variable data if {$inv>-1} {set data(lastinvoke) $inv} InitShowResults set allfnd [list] set data(_ERR_) no foreach tab [SessionList] { set TID [lindex $tab 0] # alited::file::ReadFileByTID $TID lassign [alited::main::GetText $TID] curfile wtxt lappend allfnd {*}[FindAll $wtxt $TID $tagme] if {$data(_ERR_)} break } alited::info::Clear 0 ShowResults1 $allfnd }




FindInText [::alited::find]find, Top

Searches all strings in a current text.

FindInText ?inv?
Parameters
invindex of a button that was hit (2 means "All in Text" button); optional, default -1

proc ::alited::find::FindInText {{inv -1}} { # Searches all strings in a current text. # inv - index of a button that was hit (2 means "All in Text" button) variable data if {$inv>-1} {set data(lastinvoke) $inv} alited::info::Clear set wtxt [alited::main::CurrentWTXT] set TID [alited::bar::CurrentTabID] ShowResults1 [FindAll $wtxt $TID] }




FindOptions [::alited::find]find, Top

Gets options of search, according to the dialogue's fields.

FindOptions wtxt
Parameters
wtxttext widget's path

proc ::alited::find::FindOptions {wtxt} { # Gets options of search, according to the dialogue's fields. # wtxt - text widget's path variable data $wtxt tag remove fndTag 1.0 end ;# clear the text off the find tag set options [set stopidx {}] set findstr $data(en1) if {!$data(c2)} {append options {-nocase }} # glob search - through its regexp switch $data(v1) { 2 { append options {-regexp } set findstr [string map {* .* ? . . \\. \{ \\\{ \} \\\} ( \\( ) \\) ^ \\^ \$ \\\$ - \\- + \\+} $findstr] } 3 { append options {-regexp }} default { append options {-exact }} } return [list $findstr [string trim $options] $stopidx] }




FindReplStr [::alited::find]find, Top

Prepares a string to find/replace for messages.

FindReplStr str
Parameters
strstring to prepare

proc ::alited::find::FindReplStr {str} { # Prepares a string to find/replace for messages. # str - string to prepare set res [string range $str 0 50] if {$res ne $str} {append res { ...}} return $res }




FindUnit [::alited::find]find, Top

Displays "Find unit" frame.

FindUnit

proc ::alited::find::FindUnit {} { # Displays "Find unit" frame. namespace upvar ::alited al al obPav obPav set ent [$obPav EntFindSTD] if {[set word [GetWordOfText]] ne {}} { set alited::al(findunit) $word } if {![info exist al(isfindunit)] || !$al(isfindunit)} { set al(isfindunit) true pack [$obPav FraHead] -side bottom -fill x -pady 3 -after [$obPav GutText] foreach k {f F} {bind $ent <Shift-Control-$k> {alited::find::DoFindUnit; break}} bind $ent <Return> alited::find::DoFindUnit bind $ent <Escape> {::alited::find::HideFindUnit; break} } focus $ent after idle "$ent selection range 0 end" }




GetCommandOfLine [::alited::find]find, Top

Gets a command from a line.

GetCommandOfLine line idx ?delim? ?mode?
Parameters
linethe line
idxa column of the line
delimlist of word delimiters; optional, default ""
modeif it ends with "2", the result includes a range of found string; optional, default ""

proc ::alited::find::GetCommandOfLine {line idx {delim {}} {mode {}}} { # Gets a command from a line. # line - the line # idx - a column of the line # delim - list of word delimiters # mode - if it ends with "2", the result includes a range of found string. variable ldelim variable rdelim if {$delim ne {}} { set delim1 $delim set delim2 $delim } else { set delim1 $ldelim set delim2 $rdelim } set i1 [set i2 [string range $idx [string first . $idx]+1 end]] for {set i $i1} {1} {} { incr i -1 if {[string index $line $i] in $delim1} { set i1 [expr {$i+1}] break } } for {set i $i1} {1} {} { incr i if {[string index $line $i] in $delim2} { set i2 [expr {$i-1}] break } } set res [string trim [string range $line $i1 $i2]] if {[string index $mode end] eq "2"} { set res [list $res $i1 $i2] } return $res }




GetCommandOfText [::alited::find]find, Top

Gets a command of text under the cursor.

GetCommandOfText wtxt ?mode?
Parameters
wtxttext widget's path
modeif it ends with "2", the result includes a range of found string; optional, default ""

proc ::alited::find::GetCommandOfText {wtxt {mode {}}} { # Gets a command of text under the cursor. # wtxt - text widget's path # mode - if it ends with "2", the result includes a range of found string. set idx [$wtxt index insert] set line [$wtxt get "$idx linestart" "$idx lineend"] return [list [GetCommandOfLine $line $idx "" $mode] $idx] }




GetFindEntry [::alited::find]find, Top

Puts a current selection of text to the "Find:" field

GetFindEntry

proc ::alited::find::GetFindEntry {} { # Puts a current selection of text to the "Find:" field variable data set wtxt [alited::main::CurrentWTXT] if {[catch {set sel [$wtxt get sel.first sel.last]}]} { set idx [$wtxt index insert] set line [$wtxt get "$idx linestart" "$idx lineend"] set sel [GetWordOfLine $line $idx] } if {$sel ne {}} {set data(en1) $sel} }




GetWordOfLine [::alited::find]find, Top

Gets a word from a line.

GetWordOfLine line idx ?mode?
Parameters
linethe line
idxa column of the line
modeif it ends with "2", the result includes a range of found string; optional, default ""

proc ::alited::find::GetWordOfLine {line idx {mode {}}} { # Gets a word from a line. # line - the line # idx - a column of the line # mode - if it ends with "2", the result includes a range of found string. variable adelim return [GetCommandOfLine $line $idx $adelim $mode] }




GetWordOfText [::alited::find]find, Top

Gets a word of text under the cursor.

GetWordOfText ?mode?
Parameters
modeif "select", try to get the word from a line with a selection; optional, default ""
Description

If 'mode' ends with "2", the result includes a range of found string.


proc ::alited::find::GetWordOfText {{mode {}}} { # Gets a word of text under the cursor. # mode - if "select", try to get the word from a line with a selection # If 'mode' ends with "2", the result includes a range of found string. set wtxt [alited::main::CurrentWTXT] if {$mode in {noselect noselect2} || [catch {set sel [$wtxt get sel.first sel.last]}]} { set idx [$wtxt index insert] set line [$wtxt get "$idx linestart" "$idx lineend"] set sel [GetWordOfLine $line $idx $mode] } elseif {[string index $mode end] eq "2"} { set sel [list $sel] } return $sel }




HideFindUnit [::alited::find]find, Top

Hides "Find unit" frame.

HideFindUnit

proc ::alited::find::HideFindUnit {} { # Hides "Find unit" frame. namespace upvar ::alited al al obPav obPav set al(isfindunit) no pack forget [$obPav FraHead] focus [alited::main::CurrentWTXT] }




InitShowResults [::alited::find]find, Top

Clears the info list before any search.

InitShowResults

proc ::alited::find::InitShowResults {} { # Clears the info list before any search. namespace upvar ::alited al al alited::info::Clear alited::info::Put $al(MC,wait) "" yes update }




LastInvoke [::alited::find]find, Top

Invokes last Find button that was pressed. If Ctrl-F is pressed inside Find/Replace dialogue, the last pressed Find button will be invoked.

LastInvoke

proc ::alited::find::LastInvoke {} { # Invokes last Find button that was pressed. # If Ctrl-F is pressed inside Find/Replace dialogue, the last # pressed Find button will be invoked. namespace upvar ::alited obFND obFND variable data [$obFND But$data(lastinvoke)] invoke }




Next [::alited::find]find, Top

Generate F3 key pressing event.

Next

proc ::alited::find::Next {} { # Generate F3 key pressing event. catch {event generate [alited::main::CurrentWTXT] <[alited::pref::BindKey 12 - F3]>} }




Replace [::alited::find]find, Top

Replaces one string and finds next.

Replace

proc ::alited::find::Replace {} { # Replaces one string and finds next. namespace upvar ::alited al al variable data if {![CheckData repl]} return set wtxt [alited::main::CurrentWTXT] set pos [$wtxt index insert] set isset no lassign [$wtxt tag ranges sel] idx1 idx2 if {$pos eq $idx1} { lassign [Search1 $wtxt $pos] err fnd if {$err} return foreach index1 $fnd { if {$index1 eq $pos} { set isset yes break } } } if {!$isset} Find lassign [$wtxt tag ranges sel] idx1 idx2 if {$idx1 ne {} && $idx2 ne {}} { $wtxt replace $idx1 $idx2 $data(en2) SetCursor $wtxt $idx1 set msg [string map [list %n 1 %s $data(en1) %r $data(en2)] $alited::al(MC,frres2)] ShowResults $msg 3 alited::main::UpdateTextAndGutter } Find }




ReplaceAll [::alited::find]find, Top

Replaces all found strings in a text.

ReplaceAll TID wtxt allfnd
Parameters
TIDtab's ID
wtxttext's path
allfndlist of found strings data (index1, index2)

proc ::alited::find::ReplaceAll {TID wtxt allfnd} { # Replaces all found strings in a text. # TID - tab's ID # wtxt - text's path # allfnd - list of found strings data (index1, index2) variable data set rn 0 for {set i [llength $allfnd]} {$i} {} { if {!$rn} { if {$TID ni [alited::bar::BAR listFlag m]} { alited::unit::BackupFile $TID orig } } incr i -1 lassign [lindex $allfnd $i] idx1 idx2 $wtxt replace $idx1 $idx2 $data(en2) incr rn } if {$rn} {SetCursor $wtxt [lindex $allfnd end 0]} return $rn }




ReplaceInSession [::alited::find]find, Top

Handles hitting "Replace in Session" button.

ReplaceInSession

proc ::alited::find::ReplaceInSession {} { # Handles hitting "Replace in Session" button. namespace upvar ::alited al al variable data if {![CheckData repl]} return set msg [string map [list %s [FindReplStr $data(en1)] %r [FindReplStr $data(en2)]] $al(MC,frdoit2)] if {![alited::msg yesno warn $msg NO -ontop $data(c5)]} { return {} } set currTID [alited::bar::CurrentTabID] set rn 0 set data(_ERR_) no foreach tab [SessionList] { set TID [lindex $tab 0] # if {![info exist al(_unittree,$TID)]} { # alited::file::ReadFile $TID [alited::bar::FileName $TID] # } lassign [alited::main::GetText $TID] curfile wtxt if {[set rdone [ReplaceAll $TID $wtxt [Search $wtxt]]]} { ShowResults2 $rdone $alited::al(MC,frres2) $TID incr rn $rdone } alited::file::MakeThemHighlighted $TID if {$data(_ERR_)} break } ShowResults2 $rn $alited::al(MC,frres3) alited::main::UpdateTextAndGutter }




ReplaceInText [::alited::find]find, Top

Handles hitting "Replace in Text" button.

ReplaceInText

proc ::alited::find::ReplaceInText {} { # Handles hitting "Replace in Text" button. namespace upvar ::alited al al variable data if {![CheckData repl]} return set fname [file tail [alited::bar::FileName]] set msg [string map [list %f $fname %s [FindReplStr $data(en1)] %r [FindReplStr $data(en2)]] $al(MC,frdoit1)] if {![alited::msg yesno warn $msg NO -ontop $data(c5)]} { return {} } set wtxt [alited::main::CurrentWTXT] set TID [alited::bar::CurrentTabID] set rn [ReplaceAll $TID $wtxt [Search $wtxt]] ShowResults2 $rn $alited::al(MC,frres2) alited::main::UpdateTextAndGutter }




Search [::alited::find]find, Top

Searches a text for a string to find.

Search wtxt
Parameters
wtxttext widget's path

proc ::alited::find::Search {wtxt} { # Searches a text for a string to find. # wtxt - text widget's path namespace upvar ::alited obPav obPav variable data variable counts variable win set idx [$wtxt index insert] lassign [FindOptions $wtxt] findstr options if {![CheckData find]} {return {}} $obPav set_HighlightedString $findstr if {[$obPav csDarkEdit]} { set fg white set bg #1c1cff } else { set fg black set bg #8fc7ff } $wtxt tag configure fndTag -borderwidth 1 -relief raised -foreground $fg -background $bg $wtxt tag lower fndTag lassign [Search1 $wtxt 1.0] err fnd if {$err} {return {}} set i 0 set res [list] foreach index1 $fnd { set index2 [$wtxt index "$index1 + [lindex $counts $i]c"] if {[CheckWord $wtxt $index1 $index2]} { lappend res [list $index1 $index2] } incr i } return $res }




Search1 [::alited::find]find, Top

Searches a text from a position for a string to find.

Search1 wtxt pos
Parameters
wtxttext widget's path
posposition to start searching from

proc ::alited::find::Search1 {wtxt pos} { # Searches a text from a position for a string to find. # wtxt - text widget's path # pos - position to start searching from variable win variable data lassign [FindOptions $wtxt] findstr options if {[catch {set fnd [$wtxt search {*}$options -count alited::find::counts -all -- $findstr $pos]} err]} { alited::msg ok err $err -ontop yes -parent $win set data(_ERR_) yes return [list 1 {}] } return [list 0 $fnd] }




SearchUnit [::alited::find]find, Top

Prepares and runs searching units in a text.

SearchUnit ?wtxt?
Parameters
wtxtthe text's path; optional, default ""

proc ::alited::find::SearchUnit {{wtxt {}}} { # Prepares and runs searching units in a text. # wtxt - the text's path namespace upvar ::alited al al obPav obPav # switch to the unit tree: 1st to enable the search, 2nd to show units found & selected if {!$al(TREE,isunits)} alited::tree::SwitchTree lassign [SearchUnit1 $wtxt yes] found TID if {$found eq {}} { # if the qualified not found, try to find the non-qualified (first encountered) lassign [SearchUnit1 $wtxt no] found TID } if {$found ne {}} { alited::bar::BAR $TID show after idle " alited::main::FocusText $TID $found.0 ; alited::tree::NewSelection {} $found.0 yes" } else { bell } }




SearchUnit1 [::alited::find]find, Top

Searches units in a text.

SearchUnit1 wtxt isNS
Parameters
wtxtthe text's path
isNSflag "search a qualified unit name"

proc ::alited::find::SearchUnit1 {wtxt isNS} { # Searches units in a text. # wtxt - the text's path # isNS - flag "search a qualified unit name" namespace upvar ::alited al al if {$wtxt eq ""} {set wtxt [alited::main::CurrentWTXT]} lassign [GetCommandOfText $wtxt] com1 idx if {$com1 eq {}} {bell; return {}} set com2 $com1 set withNS [expr {[set i [string last ":" $com1]]>-1}] if {!$isNS} { # try to find the pure (not qualified) name set com2 [string range $com1 $i+1 end] } elseif {!$withNS} { # try to get the current unit's namespace set curr [lindex [alited::tree::CurrentItemByLine $idx yes] 4] set com2 [string cat [string range $curr 0 [string last ":" $curr]] $com1] } if {$isNS} { set tabs [SessionList] set what "*$com2" } else { set what "*::$com2" set tabs [alited::bar::CurrentTabID] ;# not qualified } foreach tab $tabs { set TID [lindex $tab 0] alited::file::ReadFileByTID $TID foreach it $al(_unittree,$TID) { lassign $it lev leaf fl1 ttl l1 l2 if {[string match $what $ttl] || [string match "*::$ttl" $com2] || $com2 eq $ttl} { return [list $l1 $TID] } } } return {} }




SearchWordInSession [::alited::find]find, Top

SearchWordInSession

proc ::alited::find::SearchWordInSession {} { variable data set saven1 $data(en1) ;# field "Find" set savv1 $data(v1) ;# rad "Exact" set savc1 $data(c1) ;# chb "Word only" set savc2 $data(c2) ;# chb "Case Sensitive" if {[set data(en1) [GetWordOfText select]] eq ""} { bell } else { set wtxt [alited::main::CurrentWTXT] if {[catch {set sel [$wtxt get sel.first sel.last]}] || $sel eq ""} { set data(c1) 1 } else { set data(c1) 0 ;# if selected, let it be looked for (at "not word only") } set data(v1) 1 set data(c2) 1 set data(docheck) no ;# no checks - no usage of the dialogue's widgets FindInSession notag set data(docheck) yes } set data(en1) $saven1 set data(v1) $savv1 set data(c1) $savc1 set data(c2) $savc2 }




SessionButtons [::alited::find]find, Top

Prepares buttons' label ("in all/selected tabs").

SessionButtons

proc ::alited::find::SessionButtons {} { # Prepares buttons' label ("in all/selected tabs"). namespace upvar ::alited al al obFND obFND if {[set llen [llength [alited::bar::BAR listFlag s]]]>1} { set btext [string map [list %n $llen] [msgcat::mc {All in %n Files}]] } else { set btext [msgcat::mc {All in Session}] } [$obFND But3] configure -text $btext [$obFND But6] configure -text $btext }




SessionList [::alited::find]find, Top

Returns a list of all tabs or selected tabs (if set).

SessionList
Return value

Returns a list of all tabs or selected tabs (if set).


proc ::alited::find::SessionList {} { # Returns a list of all tabs or selected tabs (if set). set res [alited::bar::BAR listFlag s] if {[llength $res]==1} {set res [alited::bar::BAR listTab]} return $res }




SetCursor [::alited::find]find, Top

Sets the cursor in a text after a replacement made.

SetCursor wtxt idx1
Parameters
wtxttext's path
idx1starting index of the replacement

proc ::alited::find::SetCursor {wtxt idx1} { # Sets the cursor in a text after a replacement made. # wtxt - text's path # idx1 - starting index of the replacement variable data set len [string length $data(en2)] ::tk::TextSetCursor $wtxt [$wtxt index "$idx1 + ${len}c"] ::alited::main::CursorPos $wtxt }




ShowResults [::alited::find]find, Top

Display a message containing results of a search.

ShowResults msg ?mode? ?TID?
Parameters
msgthe message
modemode for alited::Message; optional, default 2
TIDtab's ID where the searches were performed in; optional, default ""

proc ::alited::find::ShowResults {msg {mode 2} {TID {}}} { # Display a message containing results of a search. # msg - the message # mode - mode for alited::Message # TID - tab's ID where the searches were performed in if {$TID eq {}} {set TID [alited::bar::CurrentTabID]} set fname [alited::bar::BAR $TID cget -text] set msg [string map [list %f $fname] $msg] # results in info list: alited::info::Put $msg {} yes # results in status bar: alited::Message "$msg [string repeat { } 40]" $mode # update line numbers of current file, as they are gone after the search after idle " alited::main::CursorPos [alited::main::CurrentWTXT] ; alited::main::UpdateGutter" }




ShowResults1 [::alited::find]find, Top

Shows a message of all found strings.

ShowResults1 allfnd
Parameters
allfndlist of search results

proc ::alited::find::ShowResults1 {allfnd} { # Shows a message of all found strings. # allfnd - list of search results namespace upvar ::alited al al variable data ShowResults [string map [list %n [llength $allfnd] %s $data(en1)] $alited::al(MC,frres1)] }




ShowResults2 [::alited::find]find, Top

Shows a message of number of found strings.

ShowResults2 rn msg ?TID?
Parameters
rnnumber of found strings
msgmesssage's template
TIDtab's ID where the searches were performed in; optional, default ""

proc ::alited::find::ShowResults2 {rn msg {TID {}}} { # Shows a message of number of found strings. # rn - number of found strings # msg - messsage's template # TID - tab's ID where the searches were performed in namespace upvar ::alited al al variable data ShowResults [string map [list %n $rn %s $data(en1) %r $data(en2)] $msg] 3 $TID }



::alited::imgTop



::alited::infoTop


Commandsinfo, Top




Clear [::alited::info]info, Top

Clears the info listbox widget and the related data.

Clear ?i?
Parameters
iindex of message (if omitted, clears all messages); optional, default -1

proc ::alited::info::Clear {{i -1}} { # Clears the info listbox widget and the related data. # i - index of message (if omitted, clears all messages) variable list variable info if {$i == -1} { set list [list] set info [list] } else { set list [lreplace $list $i $i] set info [lreplace $info $i $i] namespace upvar ::alited obPav obPav lassign [alited::FgFgBold] fg catch {[$obPav LbxInfo] itemconfigure 0 -foreground $fg} } }




FocusIn [::alited::info]info, Top

At focusing in the info listbox, shows its scrollbar.

FocusIn sbhi lbxi
Parameters
sbhiscrollbar's path
lbxilistbox's path

proc ::alited::info::FocusIn {sbhi lbxi} { # At focusing in the info listbox, shows its scrollbar. # sbhi - scrollbar's path # lbxi - listbox's path if {![winfo ismapped $sbhi]} { pack $sbhi -side bottom -before $lbxi -fill both } }




FocusOut [::alited::info]info, Top

At focusing out of the info listbox, hides its scrollbar.

FocusOut sbhi
Parameters
sbhiscrollbar's path

proc ::alited::info::FocusOut {sbhi} { # At focusing out of the info listbox, hides its scrollbar. # sbhi - scrollbar's path variable focustext if {$focustext} { pack forget $sbhi } }




Get [::alited::info]info, Top

Gets a message of the info listbox widget by its index.

Get i
Parameters
iindex of message

proc ::alited::info::Get {i} { # Gets a message of the info listbox widget by its index. # i - index of message variable list variable info return list [[lindex $list $i] [lindex $info $i]] }




ListboxSelect [::alited::info]info, Top

Handles a selection event of the info listbox.

ListboxSelect w ?checkit?
Parameters
wlistbox's path
checkitflag to check for the repeated calls of this procedure; optional, default no

proc ::alited::info::ListboxSelect {w {checkit no}} { # Handles a selection event of the info listbox. # w - listbox's path # checkit - flag to check for the repeated calls of this procedure variable info variable focustext variable selectmsec variable selectafter set msec [clock milliseconds] if {($msec-$selectmsec)<500 && $checkit} { # this disables updating at key pressing, let a user release the key catch {after cancel $selectafter} set selectafter [after idle "alited::info::ListboxSelect $w yes"] } else { set sel [lindex [$w curselection] 0] if {[string is digit -strict $sel]} { update lassign [lindex $info $sel] TID line if {[alited::bar::BAR isTab $TID]} { if {$TID ne [alited::bar::CurrentTabID]} { alited::bar::BAR $TID show } after idle "catch { alited::main::FocusText $TID $line.0 ; alited::tree::NewSelection {} $line.0 yes ; alited::main::HighlightLine}" if {!$focustext} {after 100 "focus $w"} } } } set selectmsec $msec }




PopupMenu [::alited::info]info, Top

Runs a popup menu on the info listbox.

PopupMenu X Y
Parameters
Xx-coordinate of mouse pointer
Yy-coordinate of mouse pointer

proc ::alited::info::PopupMenu {X Y} { # Runs a popup menu on the info listbox. # X - x-coordinate of mouse pointer # Y - y-coordinate of mouse pointer namespace upvar ::alited al al obPav obPav variable focustext set popm $al(WIN).popupInfo catch {destroy $popm} menu $popm -tearoff 0 if {$focustext} { set msg [msgcat::mc {Don't focus a text after selecting in infobar}] } else { set msg [msgcat::mc {Focus a text after selecting in infobar}] } $popm add command -label $msg -command "alited::info::SwitchFocustext" $obPav themePopup $popm tk_popup $popm $X $Y }




Put [::alited::info]info, Top

Puts a message to the info listbox widget.

Put msg ?inf? ?bold?
Parameters
msgthe message
infadditional data for the message (1st line of unit etc.); optional, default ""
boldif yes, displays the message bolded; optional, default no

proc ::alited::info::Put {msg {inf {}} {bold no}} { # Puts a message to the info listbox widget. # msg - the message # inf - additional data for the message (1st line of unit etc.) # bold - if yes, displays the message bolded variable list variable info lappend list $msg lappend info $inf if {$bold} { namespace upvar ::alited obPav obPav lassign [alited::FgFgBold] -> fgbold [$obPav LbxInfo] itemconfigure end -foreground $fgbold } }




SwitchFocustext [::alited::info]info, Top

Switches a variable of flag "listbox is focused".

SwitchFocustext

proc ::alited::info::SwitchFocustext {} { # Switches a variable of flag "listbox is focused". variable focustext if {$focustext} {set focustext 0} {set focustext 1} }



::alited::iniTop


Commandsini, Top




_init [::alited::ini]ini, Top

Initializes alited app.

_init

proc ::alited::ini::_init {} { # Initializes alited app. namespace upvar ::alited al al obPav obPav obDlg obDlg obDl2 obDl2 obDl3 obDl3 obFND obFND namespace upvar ::alited::pref em_Num em_Num em_sep em_sep em_ico em_ico em_inf em_inf em_mnu em_mnu GetUserDirs ReadIni InitFonts lassign [InitTheme] theme lbd ::apave::initWM -cursorwidth $al(CURSORWIDTH) -theme $theme -labelborder $lbd ::apave::iconImage -init $al(INI,ICONS) set ::apave::MC_NS ::alited InitGUI CheckIni GetUserDirs # get hotkeys alited::pref::IniKeys alited::pref::RegisterKeys alited::pref::KeyAccelerators # create main apave objects ::apave::APaveInput create $obPav $al(WIN) ::apave::APaveInput create $obDlg $al(WIN) ::apave::APaveInput create $obDl2 $al(WIN) ::apave::APaveInput create $obDl3 $al(WIN) ::apave::APaveInput create $obFND $al(WIN) # here, the order of icons defines their order in the toolbar set listIcons [::apave::iconImage] # the below icons' order defines their order in the toolbar foreach {icon} {none gulls heart add change delete up down plus minus retry misc previous next folder file OpenFile box SaveFile saveall undo redo help replace ok color date run other e_menu trash} { set img [CreateIcon $icon] if {$icon in {"file" OpenFile box SaveFile saveall help ok color date other replace e_menu run undo redo}} { append al(atools) " $img-big \{{} -tip {$alited::al(MC,ico$icon)@@ -under 4} " switch $icon { "file" { append al(atools) "-com alited::file::NewFile\}" } OpenFile { append al(atools) "-com alited::file::OpenFile\}" } box { append al(atools) "-com alited::project::_run\} sev 6" } SaveFile { append al(atools) "-com alited::file::SaveFile -state disabled\}" } saveall { append al(atools) "-com alited::file::SaveAll -state disabled\} sev 6" } undo { append al(atools) "-com alited::tool::Undo -state disabled\}" } redo { append al(atools) "-com alited::tool::Redo -state disabled\} sev 6" } help { append al(atools) "-com alited::tool::Help\}" } replace { append al(atools) "-com alited::find::_run\}" } ok { append al(atools) "-com alited::check::_run\}" } color { append al(atools) "-command alited::tool::ColorPicker\}" } date { append al(atools) "-command alited::tool::DatePicker\} sev 6" } run { append al(atools) "-com alited::tool::_run\}" } other { append al(atools) "-command alited::tool::tkcon\}" } e_menu { image create photo $img-big -data $alited::img::_AL_IMG(e_menu) append al(atools) "-com alited::tool::e_menu\}" } } } } for {set i [set was 0]} {$i<$em_Num} {incr i} { if {[info exists em_ico($i)] && ($em_ico($i) ni {none {}} || $em_sep($i))} { if {[incr was]==1 && !$em_sep($i)} { append al(atools) { sev 6} } if {$em_sep($i)} { append al(atools) { sev 6} } else { if {[string length $em_ico($i)]==1} { set img _$em_ico($i) set txt "-t $em_ico($i)" } else { set img [CreateIcon $em_ico($i)]-big set txt {} } set tip [string map {% %%} $em_mnu($i)] append al(atools) " $img \{{} -tip {$tip@@ -under 4} $txt " append al(atools) "-com {[alited::tool::EM_command $i]}\}" } } } for {set i 0} {$i<8} {incr i} { image create photo alimg_pro$i -data [set alited::img::_AL_IMG($i)] } image create photo alimg_tclfile -data [set alited::img::_AL_IMG(Tcl)] image create photo alimg_kbd -data [set alited::img::_AL_IMG(kbd)] # new find/repl. geometry if {$al(FONTSIZE,small) ne $al(FONTSIZE,small)} { set ::alited::find::geo [set ::alited::find::minsize ""] } # styles & fonts used in "small" dialogues ::apave::initStylesFS -size $al(FONTSIZE,small) lassign [::apave::obj create_FontsType small -size $al(FONTSIZE,small)] al(FONT,defsmall) al(FONT,monosmall) }




CheckIni [::alited::ini]ini, Top

Checks if the configuration directory exists and if not asks for it.

CheckIni

proc ::alited::ini::CheckIni {} { # Checks if the configuration directory exists and if not asks for it. namespace upvar ::alited al al if {[file exists $::alited::INIDIR] && [file exists $::alited::PRJDIR]} { return } ::apave::APaveInput create pobj set head [string map [list %d $::alited::USERDIRSTD] $al(MC,chini2)] set res [pobj input info $al(MC,chini1) [list dir1 [list $al(MC,chini3) {} [list -title $al(MC,chini3) -w 50]] "{$::alited::USERDIRSTD}" ] -size 14 -weight bold -head $head] pobj destroy lassign $res ok ::alited::USERDIRROOT if {!$ok} exit CreateUserDirs }




CreateIcon [::alited::ini]ini, Top

Create an icon (of normal and big size).

CreateIcon icon
Parameters
iconname of icon

proc ::alited::ini::CreateIcon {icon} { # Create an icon (of normal and big size). # icon - name of icon set img alimg_$icon catch {image create photo $img-big -data [::apave::iconData $icon]} catch {image create photo $img -data [::apave::iconData $icon small]} return $img }




CreateUserDirs [::alited::ini]ini, Top

Creates main directories for settings.

CreateUserDirs

proc ::alited::ini::CreateUserDirs {} { # Creates main directories for settings. namespace upvar ::alited al al DATADIR DATADIR USERDIR USERDIR INIDIR INIDIR PRJDIR PRJDIR MNUDIR MNUDIR BAKDIR BAKDIR GetUserDirs foreach dir {USERDIR INIDIR PRJDIR} { catch {file mkdir [set $dir]} } if {![file exists $al(INI)]} { file copy [file join $DATADIR user ini alited.ini] $al(INI) file copy [file join $DATADIR user prj default.ale] [file join $PRJDIR default.ale] file copy [file join $DATADIR user notes.txt] [file join $USERDIR notes.txt] ReadIni InitGUI } set emdir [file dirname $al(EM,menudir)] if {![file exists $emdir]} { file mkdir $emdir file copy $MNUDIR $emdir file copy [file join [file dirname $MNUDIR] em_projects] $emdir } }




EditSettings [::alited::ini]ini, Top

Displays the settings file, just to look behind the wall.

EditSettings

proc ::alited::ini::EditSettings {} { # Displays the settings file, just to look behind the wall. namespace upvar ::alited al al obPav obPav set filecont [::apave::readTextFile $al(INI)] $obPav vieweditFile $al(INI) {} -rotext 1 -h 25 }




GetUserDirs [::alited::ini]ini, Top

Gets names of main directories for settings.

GetUserDirs

proc ::alited::ini::GetUserDirs {} { # Gets names of main directories for settings. namespace upvar ::alited al al set ::alited::USERDIR [file join $::alited::USERDIRROOT alited] set ::alited::INIDIR [file join $::alited::USERDIR ini] set ::alited::PRJDIR [file join $::alited::USERDIR prj] if {$al(prjroot) eq ""} { set ::alited::BAKDIR [file join $::alited::USERDIR .bak] } else { set ::alited::BAKDIR [file join $al(prjroot) .bak] } if {![file exists $::alited::BAKDIR]} { catch {file mkdir $::alited::BAKDIR} } if {$al(EM,menudir) eq ""} { set al(EM,menudir) [file join $::alited::USERDIR e_menu menus] } set al(INI) [file join $::alited::INIDIR alited.ini] }




InitFonts [::alited::ini]ini, Top

Loads main fonts for alited to use as default and mono.

InitFonts

proc ::alited::ini::InitFonts {} { # Loads main fonts for alited to use as default and mono. namespace upvar ::alited al al # if {[catch { # package require extrafont # set ttflist [glob [file join $alited::DATADIR fonts *]] # }]} { # set ttflist [list] # } # foreach ttf $ttflist { # catch {extrafont::load $ttf} #puts "[incr ::-ALE-] ini::InitFonts $ttf" # } #puts "[incr ::-ALE-] ini::InitFonts ....[font families]" if {$al(FONT) ne {}} { catch { ::apave::obj basicDefFont [dict get $al(FONT) -family] } set smallfont $al(FONT) catch { set smallfont [dict set smallfont -size $al(FONTSIZE,small)] } foreach font {TkDefaultFont TkMenuFont TkHeadingFont TkCaptionFont} { font configure $font {*}$al(FONT) } foreach font {TkSmallCaptionFont TkIconFont TkTooltipFont} { font configure $font {*}$smallfont } ::baltip::configure -font $smallfont } ::apave::obj basicFontSize $al(FONTSIZE,std) set gl [file join $alited::MSGSDIR $al(LOCAL)] if {[catch {glob "$gl.msg"}]} {set al(LOCAL) en} if {$al(LOCAL) ni {en {}}} { # load localized messages msgcat::mcload $alited::MSGSDIR alited::msgcatMessages } }




InitGUI [::alited::ini]ini, Top

Initializes GUI.

InitGUI

proc ::alited::ini::InitGUI {} { # Initializes GUI. namespace upvar ::alited al al ::apave::obj basicFontSize $al(FONTSIZE,std) ::apave::obj csSet $al(INI,CS) . -doit if {$al(INI,HUE)} {::apave::obj csToned $al(INI,CS) $al(INI,HUE)} set Dark [::apave::obj csDarkEdit] if {![info exists al(ED,clrCOM)] || ![info exists al(ED,CclrCOM)] || ![info exists al(ED,Dark)] || $al(ED,Dark) != $Dark} { alited::pref::TclSyntax_Default yes alited::pref::CSyntax_Default yes } set clrnams [::hl_tcl::hl_colorNames] set clrvals [list] foreach clr $clrnams { if {[info exists al(ED,$clr)]} { lappend clrvals [set al(ED,$clr)] } } if {[llength $clrvals]==[llength $clrnams]} { ::hl_tcl::hl_colors {-AddTags} $Dark {*}$clrvals } }




InitTheme [::alited::ini]ini, Top

Initializes alited's theme.

InitTheme
Return value

Returns a list of theme name and label's border (for status bar).


proc ::alited::ini::InitTheme {} { # Initializes alited's theme. # Returns a list of theme name and label's border (for status bar). namespace upvar ::alited al al switch -glob -- $al(THEME) { azure* - sun-valley* { set i [string last - $al(THEME)] set name [string range $al(THEME) 0 $i-1] set type [string range $al(THEME) $i+1 end] source [file join $::alited::LIBDIR theme $name $name.tcl] set_theme $type set theme {} set lbd 0 } forest* { set i [string last - $al(THEME)] set name [string range $al(THEME) 0 $i-1] set type [string range $al(THEME) $i+1 end] source [file join $::alited::LIBDIR theme $name $al(THEME).tcl] set theme $al(THEME) set lbd 0 } awdark - awlight { global auto_path lappend auto_path [file join $alited::LIBDIR theme awthemes-10.4.0] package require awthemes package require ttk::theme::awdark package require ttk::theme::awlight set theme $al(THEME) set lbd 1 } default { set theme $al(THEME) set lbd 1 } } return [list $theme $lbd] }




ReadIni [::alited::ini]ini, Top

Reads alited application's and project's settings.

ReadIni ?projectfile?
Parameters
projectfileproject file's name; optional, default ""

proc ::alited::ini::ReadIni {{projectfile {}}} { # Reads alited application's and project's settings. # projectfile - project file's name namespace upvar ::alited al al namespace upvar ::alited::project prjlist prjlist prjinfo prjinfo alited::pref::Tkcon_Default set prjlist [list] set al(TPL,list) [list] set al(KEYS,bind) [list] set al(FAV,current) [list] set al(FAV,visited) [list] set em_i 0 set fontsize [expr {$al(FONTSIZE,std)+1}] set al(FONT,txt) "-family {[::apave::obj basicTextFont]} -size $fontsize" lassign "" ::alited::Pan_wh ::alited::PanL_wh ::alited::PanR_wh ::alited::PanBM_wh ::alited::PanTop_wh ::alited::al(GEOM) catch { puts "alited pwd : [pwd]" puts "alited reading: $al(INI)" set chan [open $::alited::al(INI)] set mode "" while {![eof $chan]} { set stini [string trim [gets $chan]] switch -exact $stini { {[Geometry]} - {[Options]} - {[Projects]} - {[Templates]} - {[Keys]} - {[EM]} - {[Tkcon]} - {[Misc]} { set mode $stini continue } } if {[set i [string first = $stini]]>0} { set nam [string range $stini 0 $i-1] set val [string range $stini $i+1 end] switch -exact $mode { {[Geometry]} {ReadIniGeometry $nam $val} {[Options]} {ReadIniOptions $nam $val} {[Templates]} {ReadIniTemplates $nam $val} {[Keys]} {ReadIniKeys $nam $val} {[EM]} {ReadIniEM $nam $val em_i} {[Tkcon]} {ReadIniTkcon $nam $val} {[Misc]} {ReadIniMisc $nam $val} } } } } catch {close $chan} # some options may be active outside of any project; they are set by default values if {$projectfile eq {} && $al(prjfile) eq {}} { set al(prjmultiline) $al(ED,multiline) set al(prjindent) $al(ED,indent) set al(prjEOL) $al(ED,EOL) } else { if {$projectfile eq {}} { set projectfile $al(prjfile) } else { set al(prjfile) $projectfile } ReadIniOptions project $projectfile } ReadIniPrj set al(TEXT,opts) "-padx 3 -spacing1 $al(ED,sp1) -spacing2 $al(ED,sp2) -spacing3 $al(ED,sp3)" if {!$al(INI,belltoll)} { proc ::bell args {} ;# no bells } }




ReadIniEM [::alited::ini]ini, Top

Gets e_menu options of alited.

ReadIniEM nam val emiName
Parameters
namname of option
valvalue of option
emiNamename of em_i (index in arrays of e_menu data)

proc ::alited::ini::ReadIniEM {nam val emiName} { # Gets e_menu options of alited. # nam - name of option # val - value of option # emiName - name of em_i (index in arrays of e_menu data) namespace upvar ::alited al al namespace upvar ::alited::pref em_Num em_Num em_sep em_sep em_ico em_ico em_inf em_inf em_mnu em_mnu upvar $emiName em_i switch -exact $nam { emgeometry {set al(EM,geometry) $val} emsave {set al(EM,save) $val} emPD {set al(EM,PD=) $val} emh {set al(EM,h=) $val} emtt {set al(EM,tt=) $val} emmenu {set al(EM,menu) $val} emmenudir {set al(EM,menudir) $val} emcs {set al(EM,CS) $val} emexec {set al(EM,exec) $val} emdiff {set al(EM,DiffTool) $val} em_run { if {$em_i < $em_Num} { lassign [split $val \t] em_sep($em_i) em_ico($em_i) em_inf($em_i) set em_mnu($em_i) [lindex $em_inf($em_i) end] } incr em_i } } }




ReadIniGeometry [::alited::ini]ini, Top

Gets the geometry options of alited.

ReadIniGeometry nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadIniGeometry {nam val} { # Gets the geometry options of alited. # nam - name of option # val - value of option namespace upvar ::alited al al switch -glob -- $nam { Pan* { lassign [split $val x+] w h set ::alited::${nam}_wh "-w $w -h $h" } GEOM { lassign [split $val x+] - - x y set ::alited::al(GEOM) "-geometry +$x+$y" } geomfind {set ::alited::find::geo $val} minsizefind {set ::alited::find::minsize $val} geomproject {set ::alited::project::geo $val} minsizeproject {set ::alited::project::minsize $val} geompref {set ::alited::pref::geo $val} minsizepref {set ::alited::pref::minsize $val} dirgeometry {set ::alited::DirGeometry $val} filgeometry {set ::alited::FilGeometry $val} treecw0 {set al(TREE,cw0) $val} treecw1 {set al(TREE,cw1) $val} } }




ReadIniKeys [::alited::ini]ini, Top

Gets keys options of alited.

ReadIniKeys nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadIniKeys {nam val} { # Gets keys options of alited. # nam - name of option # val - value of option namespace upvar ::alited al al switch -exact -- $nam { key {lappend al(KEYS,bind) $val} } }




ReadIniMisc [::alited::ini]ini, Top

Gets miscellaneous options of alited.

ReadIniMisc nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadIniMisc {nam val} { # Gets miscellaneous options of alited. # nam - name of option # val - value of option namespace upvar ::alited al al switch -exact -- $nam { isfavor {set al(FAV,IsFavor) $val} chosencolor {set alited::al(chosencolor) $val} showinfo {set alited::al(TREE,showinfo) $val} } }




ReadIniOptions [::alited::ini]ini, Top

Gets various options of alited.

ReadIniOptions nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadIniOptions {nam val} { # Gets various options of alited. # nam - name of option # val - value of option namespace upvar ::alited al al set clrnames [::hl_tcl::hl_colorNames] foreach lng {{} C} { set nam1 [string range $nam [string length $lng] end] if {[lsearch $clrnames $nam1]>-1} { set al(ED,$nam) $val return } } switch -glob -- $nam { project { set al(prjfile) $val set al(prjname) [file tail [file rootname $val]] } theme {set al(THEME) $val} cs {set al(INI,CS) $val} hue {set al(INI,HUE) $val} local {set al(LOCAL) $val} deffont {set al(FONT) $val} smallfontsize {set al(FONTSIZE,small) $val} stdfontsize {set al(FONTSIZE,std) $val} txtfont {set al(FONT,txt) $val} multiline {set al(ED,multiline) $val} indent {set al(ED,indent) $val} EOL {set al(ED,EOL) $val} maxfind {set al(INI,maxfind) $val} confirmexit {set al(INI,confirmexit) $val} belltoll {set al(INI,belltoll) $val} spacing1 {set al(ED,sp1) $val} spacing2 {set al(ED,sp2) $val} spacing3 {set al(ED,sp3) $val} CKeyWords {set al(ED,CKeyWords) $val} clrDark {set al(ED,Dark) $val} save_onadd - save_onclose - save_onsave {set al(INI,$nam) $val} TclExts {set al(TclExtensions) $val} ClangExts {set al(ClangExtensions) $val} REbranch {set al(RE,branch) $val} REproc {set al(RE,proc) $val} REproc2 {set al(RE,proc2) $val} REleaf {set al(RE,leaf) $val} REleaf2 {set al(RE,leaf2) $val} UseLeaf {set al(INI,LEAF) $val} Lines1 {set al(INI,LINES1) $val} RecentFiles {set al(INI,RECENTFILES) $val} MaxLast {set al(FAV,MAXLAST) $val} MaxFiles {set al(MAXFILES) $val} barlablen {set al(INI,barlablen) $val} bartiplen {set al(INI,bartiplen) $val} backup { if {$val ne {.bak}} {set val {}} set al(BACKUP) $val } maxbackup {set al(MAXBACKUP) $val} gutterwidth {set al(ED,gutterwidth) $val} guttershift {set al(ED,guttershift) $val} cursorwidth {set al(CURSORWIDTH) $val} prjdefault {set al(PRJDEFAULT) $val} DEFAULT,* {set al($nam) $val} } }




ReadIniPrj [::alited::ini]ini, Top

Reads a project's settings.

ReadIniPrj

proc ::alited::ini::ReadIniPrj {} { # Reads a project's settings. namespace upvar ::alited al al set al(tabs) [list] set al(curtab) "" alited::favor_ls::GetIni "" ;# initializes favorites' lists set al(prjdirign) ".git .bak" if {![file exists $al(prjfile)]} { set al(prjfile) [file join $alited::PRJDIR [file tail $al(prjfile)]] } if {[catch { puts "alited project: $al(prjfile)" set chan [open $::alited::al(prjfile) r] set mode "" while {![eof $chan]} { set stini [string trim [gets $chan]] switch -exact $stini { {[Tabs]} - {[Options]} - {[Favorites]} - {[Misc]} { set mode $stini continue } } set i [string first = $stini] set nam [string range $stini 0 $i-1] set val [string range $stini $i+1 end] switch -exact $mode { {[Tabs]} {ReadPrjTabs $nam $val} {[Options]} {ReadPrjOptions $nam $val} {[Favorites]} {ReadPrjFavorites $nam $val} {[Misc]} {ReadPrjMisc $nam $val} } } if {$al(prjroot) eq ""} {set al(prjroot) $alited::DIR} }]} then { puts "Not open: $al(prjfile)" set al(prjname) "" set al(prjfile) "" set al(prjroot) "" } catch {close $chan} catch {cd $al(prjroot)} if {![string is digit -strict $al(curtab)] || $al(curtab)<0 || $al(curtab)>=[llength $al(tabs)]} { set al(curtab) 0 } ::apave::setTextIndent $al(prjindent) ::apave::textEOL $al(prjEOL) }




ReadIniTemplates [::alited::ini]ini, Top

Gets templates options of alited.

ReadIniTemplates nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadIniTemplates {nam val} { # Gets templates options of alited. # nam - name of option # val - value of option namespace upvar ::alited al al switch -exact -- $nam { tpl { lappend al(TPL,list) $val # key bindings lassign $val tplname tplkey if {$tplkey ne {}} { set kbval "template {$tplname} $tplkey {[lrange $val 2 end]}" lappend al(KEYS,bind) $kbval } } } foreach n {%d %t %u %U %m %w %a} { if {$n eq $nam} { if {$val ne ""} {set al(TPL,$n) $val} break } } }




ReadIniTkcon [::alited::ini]ini, Top

Gets tkcon options of alited.

ReadIniTkcon nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadIniTkcon {nam val} { # Gets tkcon options of alited. # nam - name of option # val - value of option namespace upvar ::alited al al set al(tkcon,$nam) $val }




ReadPrjFavorites [::alited::ini]ini, Top

Gets favorites of project.

ReadPrjFavorites nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadPrjFavorites {nam val} { # Gets favorites of project. # nam - name of option # val - value of option namespace upvar ::alited al al switch -exact -- $nam { current - visited {lappend al(FAV,$nam) $val} saved {alited::favor_ls::GetIni $val} } }




ReadPrjMisc [::alited::ini]ini, Top

Gets favorites of project.

ReadPrjMisc nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadPrjMisc {nam val} { # Gets favorites of project. # nam - name of option # val - value of option namespace upvar ::alited al al switch -exact -- $nam { datafind { catch { array set ::alited::find::data $val set ::alited::find::data(en1) "" set ::alited::find::data(en2) "" } } } }




ReadPrjOptions [::alited::ini]ini, Top

Gets options of project.

ReadPrjOptions nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadPrjOptions {nam val} { # Gets options of project. # nam - name of option # val - value of option if {$nam in {"" "prjfile"}} return ;# to avoid resetting the current project file name namespace upvar ::alited al al set al($nam) $val }




ReadPrjTabs [::alited::ini]ini, Top

Gets tabs of project.

ReadPrjTabs nam val
Parameters
namname of option
valvalue of option

proc ::alited::ini::ReadPrjTabs {nam val} { # Gets tabs of project. # nam - name of option # val - value of option namespace upvar ::alited al al if {[string trim $val] ne ""} { switch -exact -- $nam { tab {lappend al(tabs) $val} recent {alited::file::InsertRecent $val end} } } }




SaveCurrentIni [::alited::ini]ini, Top

Saves a current configuration of alited on various events.

SaveCurrentIni ?saveon? ?doit?
Parameters
saveonflag "save on event" optional, default yes
doitserves to run this procedure after idle; optional, default no

proc ::alited::ini::SaveCurrentIni {{saveon yes} {doit no}} { # Saves a current configuration of alited on various events. # saveon - flag "save on event" # doit - serves to run this procedure after idle # for sessions to come if {![expr $saveon]} return variable afterID # run this code after updating GUI catch {after cancel $afterID} if {$doit} { SaveIni } else { set afterID [after idle ::alited::ini::SaveCurrentIni yes yes] } }




SaveIni [::alited::ini]ini, Top

Saves a current configuration of alited.

SaveIni ?newproject?
Parameters
newprojectflag "for a new project" optional, default no

proc ::alited::ini::SaveIni {{newproject no}} { # Saves a current configuration of alited. # newproject - flag "for a new project" namespace upvar ::alited al al obPav obPav namespace upvar ::alited::pref em_Num em_Num em_sep em_sep em_ico em_ico em_inf em_inf namespace upvar ::alited::project prjlist prjlist prjinfo prjinfo OPTS OPTS puts "alited storing: $al(INI)" set chan [open $::alited::al(INI) w] puts $chan {[Options]} puts $chan "project=$al(prjfile)" puts $chan "theme=$al(THEME)" puts $chan "cs=$al(INI,CS)" puts $chan "hue=$al(INI,HUE)" puts $chan "local=$al(LOCAL)" puts $chan "deffont=$al(FONT)" puts $chan "smallfontsize=$al(FONTSIZE,small)" puts $chan "stdfontsize=$al(FONTSIZE,std)" puts $chan "txtfont=$al(FONT,txt)" puts $chan "multiline=$al(ED,multiline)" puts $chan "indent=$al(ED,indent)" puts $chan "EOL=$al(ED,EOL)" puts $chan "maxfind=$al(INI,maxfind)" puts $chan "confirmexit=$al(INI,confirmexit)" puts $chan "belltoll=$al(INI,belltoll)" puts $chan "spacing1=$al(ED,sp1)" puts $chan "spacing2=$al(ED,sp2)" puts $chan "spacing3=$al(ED,sp3)" puts $chan "CKeyWords=$al(ED,CKeyWords)" puts $chan "cursorwidth=$al(CURSORWIDTH)" set clrnams [::hl_tcl::hl_colorNames] foreach lng {{} C} { foreach nam $clrnams {puts $chan "$lng$nam=$al(ED,$lng$nam)"} } puts $chan "clrDark=$al(ED,Dark)" puts $chan "save_onadd=$al(INI,save_onadd)" puts $chan "save_onclose=$al(INI,save_onclose)" puts $chan "save_onsave=$al(INI,save_onsave)" puts $chan "TclExts=$al(TclExtensions)" puts $chan "ClangExts=$al(ClangExtensions)" puts $chan "REbranch=$al(RE,branch)" puts $chan "REproc=$al(RE,proc)" puts $chan "REproc2=$al(RE,proc2)" puts $chan "REleaf=$al(RE,leaf)" puts $chan "REleaf2=$al(RE,leaf2)" puts $chan "UseLeaf=$al(INI,LEAF)" puts $chan "Lines1=$al(INI,LINES1)" puts $chan "RecentFiles=$al(INI,RECENTFILES)" puts $chan "MaxLast=$al(FAV,MAXLAST)" puts $chan "MaxFiles=$al(MAXFILES)" puts $chan "barlablen=$al(INI,barlablen)" puts $chan "bartiplen=$al(INI,bartiplen)" puts $chan "backup=$al(BACKUP)" puts $chan "maxbackup=$al(MAXBACKUP)" puts $chan "gutterwidth=$al(ED,gutterwidth)" puts $chan "guttershift=$al(ED,guttershift)" puts $chan "prjdefault=$al(PRJDEFAULT)" foreach k [array names al DEFAULT,*] { puts $chan "$k=$al($k)" } puts $chan "" puts $chan {[Templates]} foreach t $al(TPL,list) { puts $chan "tpl=$t" } foreach n {%d %t %u %U %m %w %a} { puts $chan "$n=$al(TPL,$n)" } puts $chan "" puts $chan {[Keys]} foreach k $al(KEYS,bind) { if {![string match template* $k] && ![string match action* $k]} { puts $chan "key=$k" } } puts $chan "" puts $chan {[EM]} puts $chan "emsave=$al(EM,save)" puts $chan "emPD=$al(EM,PD=)" puts $chan "emh=$al(EM,h=)" puts $chan "emtt=$al(EM,tt=)" puts $chan "emmenu=$al(EM,menu)" puts $chan "emmenudir=$al(EM,menudir)" puts $chan "emcs=$al(EM,CS)" puts $chan "emgeometry=$al(EM,geometry)" puts $chan "emexec=$al(EM,exec)" puts $chan "emdiff=$al(EM,DiffTool)" for {set i 0} {$i<$em_Num} {incr i} { if {[info exists em_sep($i)]} { set em_run $em_sep($i) append em_run \t $em_ico($i) \t $em_inf($i) puts $chan "em_run=$em_run" } } puts $chan "" puts $chan {[Tkcon]} foreach k [array names al tkcon,*] { puts $chan "[string range $k 6 end]=$al($k)" } # save the geometry options puts $chan "" puts $chan {[Geometry]} foreach v {Pan PanL PanR PanBM PanTop} { if {[info exists al(width$v)]} { set w $al(width$v) } else { set w [winfo geometry [$::alited::obPav $v]] } puts $chan $v=$w } puts $chan "GEOM=[wm geometry $al(WIN)]" puts $chan "geomfind=$::alited::find::geo" puts $chan "minsizefind=$::alited::find::minsize" puts $chan "geomproject=$::alited::project::geo" puts $chan "minsizeproject=$::alited::project::minsize" puts $chan "geompref=$::alited::pref::geo" puts $chan "minsizepref=$::alited::pref::minsize" puts $chan "treecw0=[[$obPav Tree] column #0 -width]" puts $chan "treecw1=[[$obPav Tree] column #1 -width]" puts $chan "dirgeometry=$::alited::DirGeometry" puts $chan "filgeometry=$::alited::FilGeometry" # save other options puts $chan "" puts $chan {[Misc]} puts $chan "isfavor=$al(FAV,IsFavor)" puts $chan "chosencolor=$alited::al(chosencolor)" puts $chan "showinfo=$alited::al(TREE,showinfo)" close $chan SaveIniPrj $newproject }




SaveIniPrj [::alited::ini]ini, Top

Saves settings of project.

SaveIniPrj newproject
Parameters
newprojectflag "for a new project"

proc ::alited::ini::SaveIniPrj {newproject} { # Saves settings of project. # newproject - flag "for a new project" namespace upvar ::alited al al obPav obPav set tabs $al(tabs) set al(tabs) [list] if {$al(prjroot) eq ""} return set chan [open $al(prjfile) w] puts $chan {[Tabs]} lassign [alited::bar::GetBarState] TIDcur - wtxt if {!$newproject} { set tabs [alited::bar::BAR listTab] } foreach tab $tabs { if {!$newproject} { set TID [lindex $tab 0] set tab [alited::bar::FileName $TID] if {[alited::file::IsNoName $tab]} continue if {$TID eq $TIDcur} { set pos [$wtxt index insert] } else { set pos [alited::bar::GetTabState $TID --pos] } append tab \t $pos } lappend al(tabs) $tab puts $chan "tab=$tab" } foreach rf $al(RECENTFILES) { if {![alited::file::IsNoName $rf]} { puts $chan "recent=$rf" } } puts $chan "" puts $chan {[Options]} puts $chan "curtab=[alited::bar::CurrentTab 3]" foreach {opt val} [array get al prj*] { puts $chan "$opt=$val" } if {!$newproject} { puts $chan "" puts $chan {[Favorites]} if {$al(FAV,IsFavor)} { set favlist [alited::tree::GetTree {} TreeFavor] } else { set favlist $al(FAV,current) } foreach curfav $favlist { puts $chan "current=$curfav" } foreach savfav [::alited::favor_ls::PutIni] { puts $chan "saved=$savfav" } foreach visited $al(FAV,visited) { puts $chan "visited=$visited" } puts $chan "" puts $chan {[Misc]} puts $chan "datafind=[array get ::alited::find::data]" } close $chan }



::alited::keysTop


Commandskeys, Top




Add [::alited::keys]keys, Top

Adds an item to a list of keys data.

Add type name keys cont
Parameters
typetype of key
namename of item
keyskey combination
contcontents (data of binding)

proc ::alited::keys::Add {type name keys cont} { # Adds an item to a list of keys data. # type - type of key # name - name of item # keys - key combination # cont - contents (data of binding) namespace upvar ::alited al al if {[string trim $keys] ne {}} { set item [list $type $name $keys $cont] if {[set i [Search $type $name]]>-1} { set al(KEYS,bind) [lreplace $al(KEYS,bind) $i $i $item] } else { lappend al(KEYS,bind) $item } } }




BindKeys [::alited::keys]keys, Top

Binds keys to appropriate events of text.

BindKeys wtxt type
Parameters
wtxttext's path
typetype of keys (template etc.)

proc ::alited::keys::BindKeys {wtxt type} { # Binds keys to appropriate events of text. # wtxt - text's path # type - type of keys (template etc.) foreach kb [alited::keys::EngagedList $type all] { lassign $kb -> tpl keys tpldata if {[catch { if {[set i [string last - $keys]]>0} { set lt [string range $keys $i+1 end] if {[string length $lt]==1} { ;# for lower case of letters lappend keys "[string range $keys 0 $i][string tolower $lt]" } } foreach k $keys { if {$type eq "template"} { lassign $tpldata tex pos place set tex [string map [list $::alited::EOL \n % %%] $tex] bind $wtxt "<$k>" [list ::alited::unit::InsertTemplate [list $tex $pos $place]] } elseif {$type eq "preference"} { set tpldata [string map [list %k $keys] $tpldata] {*}$tpldata } else { bind $wtxt "<$k>" $tpldata } } } err]} then { puts "Error of binding: $tpl <$keys> - $err" } } }




Delete [::alited::keys]keys, Top

Deletes an item from a list of keys data.

Delete type ?name?
Parameters
typetype of key
namename of item; optional, default ""

proc ::alited::keys::Delete {type {name {}}} { # Deletes an item from a list of keys data. # type - type of key # name - name of item namespace upvar ::alited al al set deleted 0 while {[set i [Search $type $name]]>-1} { set al(KEYS,bind) [lreplace $al(KEYS,bind) $i $i] incr deleted } return $deleted }




EngagedList [::alited::keys]keys, Top

Returns a list of keys engaged by a user.

EngagedList ?type? ?mode?
Parameters
typea type of keys ("template" etc.); optional, default ""
modeif "all", returns full info of keys; if "keysonly" - only key names; if "keyscont" - only key contents; optional, default keyscont
Return value

Returns a list of keys engaged by a user.


proc ::alited::keys::EngagedList {{type {}} {mode keyscont}} { # Returns a list of keys engaged by a user. # type - a type of keys ("template" etc.) # mode - if "all", returns full info of keys; if "keysonly" - only key names; if "keyscont" - only key contents namespace upvar ::alited al al set res [list] foreach kb $al(KEYS,bind) { if {$type eq "" || $type eq [lindex $kb 0]} { switch $mode { all {lappend res $kb} keysonly {lappend res [lindex $kb 2]} keyscont {lappend res [lrange $kb 2 3]} } } } return $res }




ReservedAdd [::alited::keys]keys, Top

Saves reserved ("action") keys to a list of keys data.

ReservedAdd wtxt
Parameters
wtxtNot documented.

proc ::alited::keys::ReservedAdd {wtxt} { # Saves reserved ("action") keys to a list of keys data. namespace upvar ::alited obPav obPav Add action find-replace Control-F {alited::find::_run; break} Add action find-unit Shift-Control-F {::alited::find::FindUnit; break} Add action new-file Control-N {::alited::file::NewFile; break} Add action open-file Control-O {::alited::file::OpenFile; break} Add action save-all Shift-Control-S {::alited::file::SaveAll; break} Add action save-close Control-W {::alited::file::SaveFileAndClose; break} Add action help F1 {alited::tool::Help} # other keys are customized in Preferences Add action save-file [alited::pref::BindKey 0 - F2] {::alited::file::SaveFile} Add action save-as [alited::pref::BindKey 1 - Control-S] {::alited::file::SaveFileAs; break} Add action e_menu [alited::pref::BindKey 2 - F4] {alited::tool::e_menu} Add action run [alited::pref::BindKey 3 - F5] {alited::tool::_run} Add action indent [alited::pref::BindKey 6 - Control-I] {::alited::unit::Indent; break} Add action unindent [alited::pref::BindKey 7 - Control-U] {::alited::unit::UnIndent; break} Add action comment [alited::pref::BindKey 8 - Control-bracketleft] {::alited::unit::Comment; break} Add action uncomment [alited::pref::BindKey 9 - Control-bracketright] {::alited::unit::UnComment; break} Add action find-next [alited::pref::BindKey 12 - F3] "$obPav findInText 1 $wtxt" Add action look-declaration [alited::pref::BindKey 13 - Control-L] "::alited::find::SearchUnit $wtxt ; break" Add action look-word [alited::pref::BindKey 14 - Control-Shift-L] "::alited::find::SearchWordInSession ; break" Add action item-up [alited::pref::BindKey 15 - F11] {+ ::alited::tree::MoveItem up yes} Add action item-down [alited::pref::BindKey 16 - F12] {+ ::alited::tree::MoveItem down yes} Add action goto-line [alited::pref::BindKey 17 - Control-G] {alited::main::GotoLine; break} Add action insert-line [alited::pref::BindKey 18 - Control-P] {alited::main::InsertLine; break} Add action autocomplete [alited::pref::BindKey 19 - Tab] {alited::complete::AutoCompleteCommand; break} }




ReservedList [::alited::keys]keys, Top

Returns a list of keys reserved by alited.

ReservedList
Return value

Returns a list of keys reserved by alited.


proc ::alited::keys::ReservedList {} { # Returns a list of keys reserved by alited. return [list F1 F10 Control-A Control-C Control-F Control-M Control-N Control-O Control-R Control-V Control-W Control-X Control-Z Control-Shift-Z Control-Shift-F Alt-Up Alt-Down Alt-Left Alt-Right Alt-F4 ] }




Search [::alited::keys]keys, Top

Searches an item in a list of keys data.

Search type name
Parameters
typetype of key
namename of item

proc ::alited::keys::Search {type name} { # Searches an item in a list of keys data. # type - type of key # name - name of item namespace upvar ::alited al al set i 0 foreach kb $al(KEYS,bind) { lassign $kb t n n2 if {($type eq "" || $t eq $type) && ($name eq "" || $name eq $n || $name eq $n2)} { return $i } incr i } return -1 }




Test [::alited::keys]keys, Top

It's just for testing keys.

Test klist
Parameters
klistlist of key combinations

proc ::alited::keys::Test {klist} { # It's just for testing keys. # klist - list of key combinations foreach k $klist { if {[catch {bind . "<$k>" "puts $k"} err]} { puts $err } else { puts "Valid key combination: $k" } catch {bind . "<$k>" {}} } }




UnBindKeys [::alited::keys]keys, Top

Clears key bindings of text.

UnBindKeys wtxt type
Parameters
wtxttext's path
typetype of keys (template etc.)

proc ::alited::keys::UnBindKeys {wtxt type} { # Clears key bindings of text. # wtxt - text's path # type - type of keys (template etc.) foreach kb [alited::keys::EngagedList $type all] { lassign $kb -> tpl keys tpldata if {[catch { set tpldata [string map [list $::alited::EOL \n] $tpldata] bind $wtxt "<$keys>" {} } err]} then { puts "Error of unbinding: $tpl <$keys> - $err" } } }




UserList [::alited::keys]keys, Top

Returns a list of keys avalable to a user.

UserList
Return value

Returns a list of keys avalable to a user.


proc ::alited::keys::UserList {} { # Returns a list of keys avalable to a user. set reserved [ReservedList] foreach mod {"" Control- Alt- Shift- Control-Shift- Control-Alt-} { if {$mod ni {Control- Control-Alt-}} { foreach k {F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12} { set key "$mod$k" if {$key ni $reserved} {lappend res $key} } } if {$mod ni {"" "Shift-"}} { foreach k {0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} { set key "$mod$k" if {$key ni $reserved} {lappend res $key} } } } lappend res Control-bracketleft lappend res Control-bracketright lappend res Tab return $res }




VacantList [::alited::keys]keys, Top

Returns a list of keys not yet engaged.

VacantList
Return value

Returns a list of keys not yet engaged.


proc ::alited::keys::VacantList {} { # Returns a list of keys not yet engaged. set userlist [UserList] set englist [EngagedList {} keysonly] set res [list] foreach k $userlist { if {$k ni $englist} {lappend res $k} } return $res }



::alited::mainTop


Commandsmain, Top




_create [::alited::main]main, Top

Creates a main form of the alited.

_create

proc ::alited::main::_create {} { # Creates a main form of the alited. namespace upvar ::alited al al obPav obPav lassign [$obPav csGet] - - ::alited::FRABG - - - - - bclr ttk::style configure TreeNoHL {*}[ttk::style configure Treeview] -borderwidth 0 ttk::style map TreeNoHL {*}[ttk::style map Treeview] -bordercolor [list focus $bclr active $bclr] -lightcolor [list focus $::alited::FRABG active $::alited::FRABG] -darkcolor [list focus $::alited::FRABG active $::alited::FRABG] ttk::style layout TreeNoHL [ttk::style layout Treeview] $obPav untouchWidgets *.frAText *.fraBot.fra.lbxInfo *.entFind # make the main apave object and populate it $obPav makeWindow $al(WIN).fra alited $obPav paveWindow $al(WIN).fra { {Menu - - - - - {-array { file File edit Edit tool Tools setup Setup help Help }} alited::menu::FillMenu} {frat - - - - {pack -fill both}} {frat.ToolTop - - - - {pack -side top} {-relief flat -borderwidth 0 -array {$alited::al(atools)}}} {fra - - - - {pack -side top -fill both -expand 1 -pady 0}} {fra.Pan - - - - {pack -side top -fill both -expand 1} {-orient horizontal $alited::Pan_wh}} {fra.pan.PanL - - - - {add} {-orient vertical $alited::PanL_wh}} {.fraBot - - - - {add}} {.fraBot.PanBM - - - - {pack -fill both -expand 1} {$alited::PanBM_wh}} {.fraBot.panBM.FraTree - - - - {pack -side top -fill both -expand 1}} {.fraBot.panBM.fraTree.fra1 - - - - {pack -side top -fill x}} {.fraBot.panBM.fraTree.fra1.BuTswitch - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_gulls -command alited::tree::SwitchTree}} {.fraBot.panBM.fraTree.fra1.BuTUpdT - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_retry -tip {$alited::al(MC,updtree)} -command alited::main::UpdateAll}} {.fraBot.panBM.fraTree.fra1.sev1 - - - - {pack -side left -fill y -padx 5}} {.fraBot.panBM.fraTree.fra1.BuTUp - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_up -command {alited::tree::MoveItem up}}} {.fraBot.panBM.fraTree.fra1.BuTDown - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_down -command {alited::tree::MoveItem down}}} {.fraBot.panBM.fraTree.fra1.sev2 - - - - {pack -side left -fill y -padx 5}} {.fraBot.panBM.fraTree.fra1.BuTAddT - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_add -command alited::tree::AddItem}} {.fraBot.panBM.fraTree.fra1.BuTDelT - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_delete -command alited::tree::DelItem}} {.fraBot.panBM.fraTree.fra1.h_ - - - - {pack -anchor center -side left -fill both -expand 1}} {.fraBot.panBM.fraTree.fra1.buTCtr - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_minus -command {alited::tree::ExpandContractTree Tree no} -tip "Contract All"}} {.fraBot.panBM.fraTree.fra1.buTExp - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_plus -command {alited::tree::ExpandContractTree Tree} -tip "Expand All"}} {.fraBot.panBM.fraTree.fra1.sev3 - - - - {pack -side right -fill y -padx 0}} {.fraBot.panBM.fraTree.fra - - - - {pack -side bottom -fill both -expand 1} {}} {.fraBot.panBM.fraTree.fra.Tree - - - - {pack -side left -fill both -expand 1} {-columns {L1 L2 PRL ID LEV LEAF FL1} -displaycolumns {L1} -columnoptions "#0 {-width $::alited::al(TREE,cw0)} L1 {-width $::alited::al(TREE,cw1) -anchor e}" -style TreeNoHL -takefocus 0}} {.fraBot.panBM.fraTree.fra.SbvTree .fraBot.panBM.fraTree.fra.Tree L - - {pack -side right -fill both}} {.FraFV - - - - {add}} {.fraFV.v_ - - - - {pack -side top -fill x} {-h 5}} {.fraFV.fra1 - - - - {pack -side top -fill x}} {.fraFV.fra1.seh - - - - {pack -side top -fill x -expand 1 -pady 0}} {.fraFV.fra1.BuTVisitF - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_misc -tip {$alited::al(MC,lastvisit)} -com alited::favor::SwitchFavVisit}} {.fraFV.fra1.sev0 - - - - {pack -side left -fill y -padx 5}} {.fraFV.fra1.BuTListF - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_heart -tip {$alited::al(MC,FavLists)} -com alited::favor::Lists}} {.fraFV.fra1.sev1 - - - - {pack -side left -fill y -padx 5}} {.fraFV.fra1.BuTAddF - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_add -tip {$alited::al(MC,favoradd)} -com alited::favor::Add}} {.fraFV.fra1.BuTDelF - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_delete -tip {$alited::al(MC,favordel)} -com alited::favor::Delete}} {.fraFV.fra1.BuTDelAllF - - - - {pack -side left -fill x} {-relief flat -highlightthickness 0 -takefocus 0 -image alimg_trash -tip {$alited::al(MC,favordelall)} -com alited::favor::DeleteAll}} {.fraFV.fra1.h_2 - - - - {pack -anchor center -side left -fill both -expand 1}} {.fraFV.fra1.sev2 - - - - {pack -side right -fill y -padx 0}} {.fraFV.fra - - - - {pack -fill both -expand 1} {}} {.fraFV.fra.TreeFavor - - - - {pack -side left -fill both -expand 1} {-h 5 -style TreeNoHL -columns {C1 C2 C3 C4} -displaycolumns C1 -show headings -takefocus 0}} {.fraFV.fra.SbvFavor .fraFV.fra.TreeFavor L - - {pack -side left}} {fra.pan.PanR - - - - {add} {-orient vertical $alited::PanR_wh}} {.fraTop - - - - {add}} {.fraTop.PanTop - - - - {pack -fill both -expand 1} {$alited::PanTop_wh}} {.fraTop.panTop.BtsBar - - - - {pack -side top -fill x -pady 3} {after 100 {alited::bar::FillBar %w}}} {.fraTop.panTop.GutText - - - - {pack -side left -expand 0 -fill both}} {#.fraTop.panTop.CanDiff - - - - {pack -side left -expand 0 -fill y} {-w 4}} {.fraTop.panTop.FrAText - - - - {pack -side left -expand 1 -fill both} {-background $::alited::FRABG}} {.fraTop.panTop.frAText.Text - - - - {pack forget -side left -expand 1 -fill both} {-borderwidth 1 -w 2 -h 20 -gutter GutText -gutterwidth $::alited::al(ED,gutterwidth) -guttershift $::alited::al(ED,guttershift) $alited::al(TEXT,opts)}} {.fraTop.panTop.fraSbv - - - - {pack -side right -fill y}} {.fraTop.panTop.fraSbv.SbvText .fraTop.panTop.frAText.text L - - {pack -fill y}} {.fraTop.FraHead - - - - {pack forget -side bottom -fill x} {-padding {4 4 4 4} -relief groove}} {.fraTop.fraHead.labFind - - - - {pack -side left} {-t " Unit: "}} {.fraTop.fraHead.EntFindSTD - - - - {pack -side left} {-tvar alited::al(findunit) -w 30 -tip {$al(MC,findunit)}}} {.fraTop.fraHead.buT - - - - {pack -side left -padx 4} {-t "Find: " -relief flat -com alited::find::DoFindUnit -takefocus 0 -bd 0 -highlightthickness 0 -w 8 -anchor e}} {.fraTop.fraHead.rad1 - - - - {pack -side left -padx 4} {-takefocus 0 -var alited::main::findunits -t {in all} -value 1}} {.fraTop.fraHead.rad2 - - - - {pack -side left -padx 4} {-takefocus 0 -var alited::main::findunits -t {in current} -value 2}} {.fraTop.fraHead.h_ - - - - {pack -side left -fill x -expand 1}} {.fraTop.fraHead.buTno - - - - {pack -side left} {-relief flat -highlightthickness 0 -takefocus 0 -command {alited::find::HideFindUnit}}} {.fraBot - - - - {add}} {.fraBot.fra - - - - {pack -fill both -expand 1}} {.fraBot.fra.LbxInfo - - - - {pack -side left -fill both -expand 1} {-h 1 -w 40 -lvar ::alited::info::list -font $alited::al(FONT,defsmall) -highlightthickness 0}} {.fraBot.fra.sbv .fraBot.fra.LbxInfo L - - {pack}} {.fraBot.fra.SbhInfo .fraBot.fra.LbxInfo T - - {pack -side bottom -before %w}} {.fraBot.stat - - - - {pack -side bottom} {-array { {{$alited::al(MC,Row:)}} 12 {{$alited::al(MC,Col:)}} 5 {{} -anchor w -expand 1} 50 {{} -anchor e} 18 }}} } UpdateProjectInfo bind [$obPav Pan] <ButtonRelease> ::alited::tree::AdjustWidth set sbhi [$obPav SbhInfo] set lbxi [$obPav LbxInfo] pack forget $sbhi bind $lbxi <FocusIn> "alited::info::FocusIn $sbhi $lbxi" bind $lbxi <FocusOut> "alited::info::FocusOut $sbhi" bind $lbxi <<ListboxSelect>> {alited::info::ListboxSelect %W} bind $lbxi <ButtonPress-3> {alited::info::PopupMenu %X %Y} bind [$obPav ToolTop] <ButtonPress-3> {::alited::tool::PopupBar %X %Y} }




_run [::alited::main]main, Top

Runs the alited, displaying its main form with attributes 'modal', 'not closed by Esc', 'decorated with Contract/Expand buttons', 'minimal sizes' and 'saved geometry'.

_run
Description

After closing the alited, saves its settings (geometry etc.).


proc ::alited::main::_run {} { # Runs the alited, displaying its main form with attributes # 'modal', 'not closed by Esc', 'decorated with Contract/Expand buttons', # 'minimal sizes' and 'saved geometry'. # # After closing the alited, saves its settings (geometry etc.). namespace upvar ::alited al al obPav obPav ::apave::setAppIcon $al(WIN) $::alited::img::_AL_IMG(ale) ::apave::setProperty DirFilGeoVars [list ::alited::DirGeometry ::alited::FilGeometry] set ans [$obPav showModal $al(WIN) -decor 1 -minsize {500 500} -escape no -onclose alited::Exit {*}$al(GEOM)] # ans==2 means 'no saves of settings' (imaginary mode) if {$ans ne {2}} {alited::ini::SaveIni} destroy $al(WIN) $obPav destroy return $ans }




BindsForText [::alited::main]main, Top

Sets bindings for a text.

BindsForText TID wtxt
Parameters
TIDtab's ID
wtxttext widget's path

proc ::alited::main::BindsForText {TID wtxt} { # Sets bindings for a text. # TID - tab's ID # wtxt - text widget's path if {[alited::bar::BAR isTab $TID]} { bind $wtxt <FocusIn> [list after 200 "::alited::main::FocusInText $TID $wtxt"] } bind $wtxt <Control-ButtonRelease-1> "::alited::find::SearchUnit $wtxt ; break" bind $wtxt <Control-Shift-ButtonRelease-1> {::alited::find::SearchWordInSession ; break} bind $wtxt <Control-Tab> {::alited::bar::ControlTab ; break} bind $wtxt <Alt-BackSpace> {::alited::unit::SwitchUnits ; break} bind $wtxt <<Undo>> {after idle alited::main::HighlightLine} alited::keys::ReservedAdd $wtxt alited::keys::BindKeys $wtxt action alited::keys::BindKeys $wtxt template alited::keys::BindKeys $wtxt preference }




CurrentWTXT [::alited::main]main, Top

Gets a current text widget's path.

CurrentWTXT

proc ::alited::main::CurrentWTXT {} { # Gets a current text widget's path. return [lindex [alited::bar::GetBarState] 2] }




CursorPos [::alited::main]main, Top

Displays a current text's row and column in the status bar.

CursorPos wtxt ?args?
Parameters
wtxttext widget's path
argscontains a cursor position,

proc ::alited::main::CursorPos {wtxt args} { # Displays a current text's row and column in the status bar. # wtxt - text widget's path # args - contains a cursor position, namespace upvar ::alited obPav obPav if {$args eq {}} {set args [$wtxt index {end -1 char}]} lassign [split [$wtxt index insert] .] r c [$obPav Labstat1] configure -text "$r / [expr {int([lindex $args 0])}]" [$obPav Labstat2] configure -text [incr c] alited::tree::SaveCursorPos }




FocusInText [::alited::main]main, Top

Processes event on the text.

FocusInText TID wtxt
Parameters
TIDtab's ID
wtxttext widget's path

proc ::alited::main::FocusInText {TID wtxt} { # Processes <FocusIn> event on the text. # TID - tab's ID # wtxt - text widget's path namespace upvar ::alited obPav obPav if {![alited::bar::BAR isTab $TID]} return ::alited::main::CursorPos $wtxt [$obPav TreeFavor] selection set {} alited::file::OutwardChange $TID }




FocusText [::alited::main]main, Top

Sets a focus on a current text.

FocusText ?args?
Parameters
argscontains tab's ID and a cursor positition.

proc ::alited::main::FocusText {args} { # Sets a focus on a current text. # args - contains tab's ID and a cursor positition. namespace upvar ::alited al al obPav obPav lassign $args TID pos if {$pos eq {}} { set wtxt [CurrentWTXT] set TID [alited::bar::CurrentTabID] set pos [$wtxt index insert] } else { set wtxt [GetWTXT $TID] } # find a current unit/file in the tree set alited::tree::doFocus no set wtree [$obPav Tree] catch { if {$al(TREE,isunits)} { # search the tree for a unit with current line of text set itemID [alited::tree::CurrentItemByLine $pos] } else { # search the tree for a current file set fname [alited::bar::FileName] set wtree [$obPav Tree] while {1} { incr iit set ID [alited::tree::NewItemID $iit] if {![$wtree exists $ID]} break lassign [$wtree item $ID -values] -> tip isfile if {$tip eq $fname} { set itemID $ID break } } } } # display a current item of the tree catch { if {$itemID ni [$wtree selection]} {$wtree selection set $itemID} after 10 alited::tree::SeeSelection } # focus on the text catch {focus -force $wtxt} catch {::tk::TextSetCursor $wtxt $pos} after idle {set ::alited::tree::doFocus yes} }




GetText [::alited::main]main, Top

Creates or gets a text widget for a tab.

GetText TID ?doshow?
Parameters
TIDtab's ID
doshowflag "this widget should be displayed" optional, default no
Return value

Returns a list of: curfile (current file name), wtxt (text's path), wsbv (scrollbar's path), pos (cursor's position), doinit (flag "initialized") dopack (flag "packed")


proc ::alited::main::GetText {TID {doshow no}} { # Creates or gets a text widget for a tab. # TID - tab's ID # doshow - flag "this widget should be displayed" # Returns a list of: curfile (current file name), # wtxt (text's path), wsbv (scrollbar's path), # pos (cursor's position), doinit (flag "initialized") # dopack (flag "packed") namespace upvar ::alited al al obPav obPav set curfile [alited::bar::FileName $TID] # initial text and its scrollbar: set wtxt [$obPav Text] set wsbv [$obPav SbvText] # get data of the current tab lassign [alited::bar::GetBarState] TIDold fileold wold1 wold2 lassign [alited::bar::GetTabState $TID --pos] pos set doreload no ;# obsolete set doinit yes if {$TIDold eq "-1"} { ;# first text to edit in original Text widget: create its scrollbar BindsForText $TID $wtxt ::apave::logMessage "first $curfile" } elseif {[GetWTXT $TID] ne {}} { # edited text: get its widgets' data lassign [alited::bar::GetTabState $TID --wtxt --wsbv] wtxt wsbv set doinit no } else { # till now, not edited text: create its own Text/SbvText widgets append wtxt "_$TID" ;# new text append wsbv "_$TID" ;# new scrollbar } if {![string is double -strict $pos]} {set pos 1.0} # check for previous text and hide it, if it's not the selected one set dopack [expr {$TID ne $TIDold}] alited::bar::SetTabState $TID --fname $curfile --wtxt $wtxt --wsbv $wsbv # create the text and the scrollbar if new if {![winfo exists $wtxt]} { lassign [GutterAttrs] canvas width shift set texopts [lindex [$obPav defaultAttrs tex] 1] lassign [::apave::extractOptions texopts -selborderwidth 1] selbw text $wtxt {*}$texopts {*}$al(TEXT,opts) $wtxt tag configure sel -borderwidth $selbw $obPav themeNonThemed [winfo parent $wtxt] set bind [list $obPav fillGutter $wtxt $canvas $width $shift] bind $wtxt <Configure> $bind if {[trace info execution $wtxt] eq {}} { trace add execution $wtxt leave $bind } ttk::scrollbar $wsbv -orient vertical -takefocus 0 $wtxt configure -yscrollcommand "$wsbv set" $wsbv configure -command "$wtxt yview" BindsForText $TID $wtxt } # show the selected text if {$doshow} { alited::bar::SetBarState [alited::bar::CurrentTabID] $curfile $wtxt $wsbv } if {$doinit} { # if the file isn't read yet, read it and initialize its highlighting alited::file::DisplayFile $TID $curfile $wtxt $doreload HighlightText $TID $curfile $wtxt } elseif {[alited::file::ToBeHighlighted $wtxt]} { HighlightText $TID $curfile $wtxt if {$al(TREE,isunits)} alited::tree::RecreateTree } if {[winfo exists $wold1]} { # previous text: save its state alited::bar::SetTabState $TIDold --pos [$wold1 index insert] if {$dopack && $doshow} { # hide both previous pack forget $wold1 ;# a text pack forget $wold2 ;# a scrollbar } } return [list $curfile $wtxt $wsbv $pos $doinit $dopack] }




GetWTXT [::alited::main]main, Top

Gets a text widget's path of a tab.

GetWTXT TID
Parameters
TIDID of the tab

proc ::alited::main::GetWTXT {TID} { # Gets a text widget's path of a tab. # TID - ID of the tab return [alited::bar::GetTabState $TID --wtxt] }




GotoLine [::alited::main]main, Top

Processes Ctrl+G keypressing: "go to a line".

GotoLine

proc ::alited::main::GotoLine {} { # Processes Ctrl+G keypressing: "go to a line". namespace upvar ::alited al al obDl2 obDl2 set head [msgcat::mc "Go to Line"] set prompt1 [msgcat::mc "Line number:"] set prompt2 [msgcat::mc " In unit:"] set wtxt [CurrentWTXT] set ln 1 ;#[expr {int([$wtxt index insert])}] set lmax [expr {int([$wtxt index "end -1c"])}] set units [list] set TID [alited::bar::CurrentTabID] foreach it $al(_unittree,$TID) { lassign $it lev leaf fl1 title l1 l2 if {$leaf && [set title [string trim $title]] ne {}} { lappend units $title } } set ::alited::main::gotoline2 [linsert [lsort -nocase $units] 0 {}] if {$::alited::main::gotolineTID ne $TID} { set ::alited::main::gotoline1 {} set ::alited::main::gotolineTID $TID } lassign [$obDl2 input {} $head [list spx "{$prompt1} {} {-w 6 -justify center -from 1 -to $lmax -selected yes}" "{$ln}" cbx "{$prompt2} {} {-tvar ::alited::main::gotoline1 -state readonly -h 16 -w 20}" "{$::alited::main::gotoline1} $::alited::main::gotoline2" ]] res ln unit if {$res} { set ::alited::main::gotoline1 $unit if {$unit ne {}} { # for a chosen unit - a relative line number if {[set it [lsearch -index 3 $al(_unittree,$TID) $unit]] >- 1} { lassign [lindex $al(_unittree,$TID) $it] lev leaf fl1 title l1 l2 set l $l1 set fst 1 foreach line [split [$wtxt get $l1.0 $l2.end] \n] { # gentlemen, use \ for continuation of long lines & strings! set continued [expr {[string index $line end] eq "\\"}] if {!$continued || $fst} { if {$fst} { set l $l1 if {[incr ln -1]<1} break } set fst [expr {!$continued}] } incr l1 } set ln $l } } after idle " alited::main::FocusText $TID $ln.0 ; alited::tree::NewSelection {} $ln.0 yes" } }




GutterAttrs [::alited::main]main, Top

Returns list of gutter's data (canvas widget, width, shift)

GutterAttrs
Return value

Returns list of gutter's data (canvas widget, width, shift)


proc ::alited::main::GutterAttrs {} { # Returns list of gutter's data (canvas widget, width, shift) namespace upvar ::alited al al obPav obPav return [list [$obPav GutText] $al(ED,gutterwidth) $al(ED,guttershift)] }




HighlightLine [::alited::main]main, Top

Highlights a current line of a current text.

HighlightLine

proc ::alited::main::HighlightLine {} { # Highlights a current line of a current text. set wtxt [alited::main::CurrentWTXT] if {[alited::file::IsClang [alited::bar::FileName]]} { ::hl_c::hl_line $wtxt } else { ::hl_tcl::hl_line $wtxt } }




HighlightText [::alited::main]main, Top

Highlights a file's syntax constructs.

HighlightText TID curfile wtxt
Parameters
TIDtab's ID
curfilefile name
wtxttext widget's path
Description

Depending on a file name, Tcl or C highlighter is called.


proc ::alited::main::HighlightText {TID curfile wtxt} { # Highlights a file's syntax constructs. # TID - tab's ID # curfile - file name # wtxt - text widget's path # Depending on a file name, Tcl or C highlighter is called. namespace upvar ::alited al al obPav obPav # the language (Tcl or C) is defined by the file's extension set ext [string tolower [file extension $curfile]] if {![info exists al(HL,$wtxt)] || $al(HL,$wtxt) ne $ext} { set clrnams [::hl_tcl::hl_colorNames] set clrCURL [lindex [$obPav csGet] 16] # get a color list for the highlighting Tcl and C foreach lng {{} C} { foreach nam $clrnams { lappend "${lng}colors" $al(ED,${lng}$nam) } lappend "${lng}colors" $clrCURL } if {[alited::file::IsClang $curfile]} { ::hl_c::hl_init $wtxt -dark [$obPav csDarkEdit] -multiline 1 -keywords $al(ED,CKeyWords) -cmd "::alited::unit::Modified $TID" -cmdpos ::alited::main::CursorPos -font $al(FONT,txt) -colors $Ccolors -insertwidth $al(CURSORWIDTH) } else { ::hl_tcl::hl_init $wtxt -dark [$obPav csDarkEdit] -multiline $al(prjmultiline) -cmd "::alited::unit::Modified $TID" -cmdpos ::alited::main::CursorPos -plaintext [expr {![alited::file::IsTcl $curfile]}] -font $al(FONT,txt) -colors $colors -insertwidth $al(CURSORWIDTH) } UpdateText $wtxt $curfile } set al(HL,$wtxt) $ext }




InsertLine [::alited::main]main, Top

Puts a new line into a text, attentive to a previous line's indentation.

InsertLine

proc ::alited::main::InsertLine {} { # Puts a new line into a text, attentive to a previous line's indentation. set wtxt [CurrentWTXT] set ln [expr {int([$wtxt index insert])}] if {$ln==1} { $wtxt insert $ln.0 \n set pos 1.0 } else { set ln0 [expr {$ln-1}] set line [$wtxt get $ln0.0 $ln0.end] set leadsp [::apave::obj leadingSpaces $line] $wtxt insert $ln.0 "[string repeat { } $leadsp]\n" set pos $ln.$leadsp } ::tk::TextSetCursor $wtxt $pos }




PackTextWidgets [::alited::main]main, Top

Packs a text and its scrollbar.

PackTextWidgets wtxt wsbv
Parameters
wtxttext widget's path
wsbvscrollbar widget's path

proc ::alited::main::PackTextWidgets {wtxt wsbv} { # Packs a text and its scrollbar. # wtxt - text widget's path # wsbv - scrollbar widget's path namespace upvar ::alited al al obPav obPav lassign [GutterAttrs] canvas width shift # widgets created outside apave require the theming: $obPav csSet [$obPav csCurrent] $al(WIN) -doit pack $wtxt -side left -expand 1 -fill both pack $wsbv -fill y -expand 1 set bind [list $obPav fillGutter $wtxt $canvas $width $shift] {*}$bind }




ShowHeader [::alited::main]main, Top

Displays a file's name and modification flag (*) in alited's title.

ShowHeader ?doit?
Parameters
doitif yes, displays unconditionally; optional, default no
Description

If doit is no, displays only at changing a file name or a flag.


proc ::alited::main::ShowHeader {{doit no}} { # Displays a file's name and modification flag (*) in alited's title. # doit - if yes, displays unconditionally. # If *doit* is *no*, displays only at changing a file name or a flag. namespace upvar ::alited al al if {[alited::file::IsModified]} {set modif "*"} {set modif " "} set TID [alited::bar::CurrentTabID] if {$doit || "$modif$TID" ne [alited::bar::BAR cget -ALmodif]} { alited::bar::BAR configure -ALmodif "$modif$TID" set f [alited::bar::CurrentTab 1] set d [file normalize [file dirname [alited::bar::CurrentTab 2]]] set ttl [string map [list %f $f %d $d %p $al(prjname)] $al(TITLE)] wm title $al(WIN) [string trim "$modif$ttl"] } }




ShowText [::alited::main]main, Top

Displays a current text.

ShowText

proc ::alited::main::ShowText {} { # Displays a current text. namespace upvar ::alited al al obPav obPav set TID [alited::bar::CurrentTabID] lassign [GetText $TID yes] curfile wtxt wsbv pos doinit dopack if {$dopack} { PackTextWidgets $wtxt $wsbv } if {$doinit || $dopack} { # for newly displayed text: create also its unit tree set al(TREE,units) no alited::tree::Create } FocusText $TID $pos if {[set itemID [alited::tree::NewSelection]] ne {}} { # if a new unit is selected, show it in the unit tree [$obPav Tree] see $itemID } focus $wtxt # update "File" menu and app's header alited::menu::CheckMenuItems ShowHeader }




UpdateAll [::alited::main]main, Top

Updates tree, text and gutter.

UpdateAll

proc ::alited::main::UpdateAll {} { # Updates tree, text and gutter. alited::tree::RecreateTree UpdateTextAndGutter HighlightLine }




UpdateGutter [::alited::main]main, Top

Redraws the gutter.

UpdateGutter

proc ::alited::main::UpdateGutter {} { # Redraws the gutter. namespace upvar ::alited obPav obPav set wtxt [CurrentWTXT] after idle "$obPav fillGutter $wtxt" }




UpdateProjectInfo [::alited::main]main, Top

Displays a project settings in the status bar.

UpdateProjectInfo

proc ::alited::main::UpdateProjectInfo {} { # Displays a project settings in the status bar. namespace upvar ::alited al al obPav obPav if {$al(prjroot) ne {}} {set stsw normal} {set stsw disabled} [$obPav BuTswitch] configure -state $stsw if {[set eol $al(prjEOL)] eq {}} {set eol auto} [$obPav Labstat4] configure -text "eol=$eol, [msgcat::mc ind]=$al(prjindent)" }




UpdateText [::alited::main]main, Top

Redraws a text.

UpdateText ?wtxt? ?curfile?
Parameters
wtxtthe text widget's path; optional, default ""
curfilefile name of the text; optional, default ""

proc ::alited::main::UpdateText {{wtxt {}} {curfile {}}} { # Redraws a text. # wtxt - the text widget's path # curfile - file name of the text namespace upvar ::alited obPav obPav if {$wtxt eq {}} {set wtxt [CurrentWTXT]} if {$curfile eq {}} {set curfile [alited::bar::FileName]} if {[alited::file::IsClang $curfile]} { ::hl_c::hl_text $wtxt } else { ::hl_tcl::hl_text $wtxt } }




UpdateTextAndGutter [::alited::main]main, Top

Redraws both a text and a gutter.

UpdateTextAndGutter

proc ::alited::main::UpdateTextAndGutter {} { # Redraws both a text and a gutter. UpdateGutter UpdateText }



::alited::menuTop


Commandsmenu, Top




CheckMenuItems [::alited::menu]menu, Top

Disables/enables "File/Close All..." menu items.

CheckMenuItems

proc ::alited::menu::CheckMenuItems {} { # Disables/enables "File/Close All..." menu items. namespace upvar ::alited al al set TID [alited::bar::CurrentTabID] foreach idx {9 10 11} { if {[alited::bar::BAR isTab $TID]} { set dsbl [alited::bar::BAR checkDisabledMenu $al(BID) $TID [incr item]] } else { set dsbl yes } if {$dsbl} { set state "-state disabled" } else { set state "-state normal" } $al(MENUFILE) entryconfigure $idx {*}$state } }




FillMenu [::alited::menu]menu, Top

Populates alited's main menu.

FillMenu

proc ::alited::menu::FillMenu {} { # Populates alited's main menu. namespace upvar ::alited al al namespace upvar ::alited::pref em_Num em_Num em_sep em_sep em_ico em_ico em_inf em_inf em_mnu em_mnu ## ________________________ File _________________________ ## set m [set al(MENUFILE) $al(WIN).menu.file] $m add command -label $al(MC,new) -command alited::file::NewFile -accelerator Ctrl+N $m add command -label $al(MC,open...) -command alited::file::OpenFile -accelerator Ctrl+O menu $m.recentfiles -tearoff 0 $m add cascade -label [msgcat::mc "Recent Files"] -menu $m.recentfiles $m add separator $m add command -label $al(MC,save) -command alited::file::SaveFile -accelerator $al(acc_0) $m add command -label $al(MC,saveas...) -command alited::file::SaveFileAs -accelerator $al(acc_1) $m add command -label $al(MC,saveall) -command alited::file::SaveAll -accelerator Ctrl+Shift+S $m add separator $m add command -label $al(MC,close) -command alited::file::CloseFileMenu $m add command -label $al(MC,clall) -command {alited::file::CloseAll 1} $m add command -label $al(MC,clallleft) -command {alited::file::CloseAll 2} $m add command -label $al(MC,clallright) -command {alited::file::CloseAll 3} $m add separator $m add command -label $al(MC,restart) -command {alited::Exit - 1 no} $m add separator $m add command -label $al(MC,quit) -command {alited::Exit - 0 no} ## ________________________ Edit _________________________ ## set m [set al(MENUEDIT) $al(WIN).menu.edit] $m add command -label $al(MC,moveupU) -command {alited::tree::MoveItem up yes} -accelerator $al(acc_15) $m add command -label $al(MC,movedownU) -command {alited::tree::MoveItem down yes} -accelerator $al(acc_16) $m add separator $m add command -label $al(MC,indent) -command alited::unit::Indent -accelerator $al(acc_6) $m add command -label $al(MC,unindent) -command alited::unit::UnIndent -accelerator $al(acc_7) $m add command -label [msgcat::mc {Correct Indentation}] -command alited::unit::NormIndent $m add separator $m add command -label $al(MC,comment) -command alited::unit::Comment -accelerator $al(acc_8) $m add command -label $al(MC,uncomment) -command alited::unit::UnComment -accelerator $al(acc_9) $m add separator $m add command -label [msgcat::mc {Put New Line}] -command alited::main::InsertLine -accelerator $al(acc_18) $m add separator $m add command -label $al(MC,findreplace) -command alited::find::_run -accelerator Ctrl+F $m add command -label $al(MC,findnext) -command alited::find::Next -accelerator $al(acc_12) $m add command -label [msgcat::mc {Look for Declaration}] -command alited::find::SearchUnit -accelerator $al(acc_13) $m add command -label [msgcat::mc {Look for Word}] -command alited::find::SearchWordInSession -accelerator $al(acc_14) $m add command -label [msgcat::mc {Find Unit}] -command alited::find::FindUnit -accelerator Ctrl+Shift+F $m add separator $m add command -label [msgcat::mc {Go to Line}] -command alited::main::GotoLine -accelerator $al(acc_17) ## ________________________ Tools _________________________ ## set m [set al(TOOLS) $al(WIN).menu.tool] $m add command -label $al(MC,run) -command alited::tool::_run -accelerator $al(acc_3) $m add command -label e_menu -command alited::tool::e_menu -accelerator $al(acc_2) $m add command -label tkcon -command alited::tool::tkcon ### ________________________ Runs _________________________ ### for {set i [set emwas 0]} {$i<$em_Num} {incr i} { if {[info exists em_ico($i)] && ($em_mnu($i) ne {} || $em_sep($i))} { if {[incr emwas]==1} { menu $m.runs -tearoff 0 $m add cascade -label bar/menu -menu $m.runs } if {$em_sep($i)} { $m.runs add separator } else { set txt $em_mnu($i) $m.runs add command -label $txt -command [alited::tool::EM_command $i] } } } ### ________________________ Other tools _________________________ ### $m add separator $m add command -label $al(MC,checktcl) -command alited::check::_run $m add separator $m add command -label $al(MC,colorpicker) -command alited::tool::ColorPicker $m add command -label [msgcat::mc {Screen Loupe}] -command alited::tool::Loupe $m add command -label $al(MC,datepicker) -command alited::tool::DatePicker ## ________________________ Setup _________________________ ## set m [set al(SETUP) $al(WIN).menu.setup] $m add command -label $al(MC,projects) -command alited::project::_run $m add command -label $al(MC,tpl) -command alited::unit::Add $m add command -label $alited::al(MC,FavLists) -command alited::favor::Lists $m add separator menu $m.tint -tearoff 0 if {[::apave::obj apaveTheme]} {set state normal} {set state disabled} $m add cascade -label [msgcat::mc Tint] -menu $m.tint -state $state foreach ti {50 45 40 35 30 25 20 15 10 5 0 -5 -10 -15 -20 -25 -30 -35 -40 -45 -50} { set ti1 [string range " $ti" end-2 end] if {$ti<0} { set ti2 "[msgcat::mc Darker:] $ti1" } elseif {$ti>0} { set ti2 "[msgcat::mc Lighter:]$ti1" } else { set ti3 [::apave::obj csGetName $al(INI,CS)] set ti2 [msgcat::mc {Color scheme:}] append ti2 { } [string range $ti3 [string first { } $ti3] end] } $m.tint add command -label $ti2 -command "alited::menu::SetTint $ti" } $m add checkbutton -label [msgcat::mc {Wrap Lines}] -variable alited::al(wrapwords) -command alited::file::WrapLines $m add checkbutton -label [msgcat::mc {Tip File Info}] -variable alited::al(TREE,showinfo) -command alited::file::UpdateFileStat $m add command -label [msgcat::mc {Before Run...}] -command alited::tool::BeforeRunDlg $m add separator $m add command -label $al(MC,pref...) -command alited::pref::_run ## ________________________ Help _________________________ ## set m [set al(MENUHELP) $al(WIN).menu.help] $m add command -label "$al(MC,help) Tcl/Tk" -command alited::tool::Help -accelerator F1 $m add separator $m add command -label [msgcat::mc "Help of alited"] -command alited::HelpAlited $m add command -label [msgcat::mc "About..."] -command alited::HelpAbout FillRecent }




FillRecent [::alited::menu]menu, Top

Creates "Recent Files" menu items.

FillRecent

proc ::alited::menu::FillRecent {} { # Creates "Recent Files" menu items. namespace upvar ::alited al al set m $al(MENUFILE).recentfiles $m delete 0 end if {[llength $al(RECENTFILES)]} { $al(MENUFILE) entryconfigure 2 -state normal set i 0 foreach rf $al(RECENTFILES) { $m add command -label $rf -command "alited::file::ChooseRecent $i" incr i } } else { $al(MENUFILE) entryconfigure 2 -state disabled } }




SetTint [::alited::menu]menu, Top

Sets a tint of a current color scheme.

SetTint tint
Parameters
tintvalue of the tint

proc ::alited::menu::SetTint {tint} { # Sets a tint of a current color scheme. # tint - value of the tint namespace upvar ::alited al al obPav obPav $obPav csToned $al(INI,CS) $tint }



::alited::prefTop


Commandspref, Top




_create [::alited::pref]pref, Top

Creates "Preferences" dialogue.

_create tab
Parameters
taba tab to open (saved at previous session) or {}

proc ::alited::pref::_create {tab} { # Creates "Preferences" dialogue. # tab - a tab to open (saved at previous session) or {} fetchVars $obDl2 makeWindow $win "$al(MC,pref) :: $::alited::USERDIR" $obDl2 paveWindow $win [MainFrame] $win.fraR.nbk.f1 [General_Tab1] $win.fraR.nbk.f2 [General_Tab2] $win.fraR.nbk.f3 [General_Tab3] $win.fraR.nbk2.f1 [Edit_Tab1] $win.fraR.nbk2.f2 [Edit_Tab2] $win.fraR.nbk2.f3 [Edit_Tab3] $win.fraR.nbk3.f1 [Units_Tab] $win.fraR.nbk4.f1 [Template_Tab] $win.fraR.nbk5.f1 [Keys_Tab1] $win.fraR.nbk6.f1 [Emenu_Tab] $win.fraR.nbk6.f2 [Tkcon_Tab] $win.fraR.nbk6.f3 [Runs_Tab] if {$minsize eq ""} { ;# save default min.sizes after idle [list after 100 { set ::alited::pref::minsize "-minsize {[winfo width $::alited::pref::win] [winfo height $::alited::pref::win]}" }] } set fnotes [file join $::alited::USERDIR notes.txt] if {[file exists $fnotes]} { [$obDl2 TexNotes] insert end [::apave::readTextFile $fnotes] } [$obDl2 TexCKeys] insert end $al(ED,CKeyWords) if {$tab ne {}} { switch -exact $tab { Emenu_Tab { set nbk nbk6 set nt $win.fraR.nbk6.f3 } } Tab $nbk $nt yes } elseif {$oldTab ne {}} { Tab $oldTab $arrayTab($oldTab) yes } bind $win <Control-o> alited::ini::EditSettings set res [$obDl2 showModal $win -geometry $geo {*}$minsize -onclose ::alited::pref::Cancel] set fcont [[$obDl2 TexNotes] get 1.0 {end -1c}] ::apave::writeTextFile $fnotes fcont if {[llength $res] < 2} {set res ""} set geo [wm geometry $win] ;# save the new geometry of the dialogue set oldTab $curTab set arrayTab($curTab) [$win.fraR.$curTab select] destroy $win return $res }




_init [::alited::pref]pref, Top

Initializes "Preferences" dialogue.

_init

proc ::alited::pref::_init {} { # Initializes "Preferences" dialogue. fetchVars SaveSettings set curTab "nbk" IniKeys }




_run [::alited::pref]pref, Top

Runs "Preferences" dialogue.

_run ?tab?
Parameters
tabNot documented; optional, default ""
Return value

Returns "true", if settings were saved.


proc ::alited::pref::_run {{tab {}}} { # Runs "Preferences" dialogue. # Returns "true", if settings were saved. _init set res [_create $tab] return $res }




BindKey [::alited::pref]pref, Top

Binds a key event to a key combination.

BindKey nk ?key? ?defk?
Parameters
nkindex of combobox corresponding to the event
keykey combination or "-" (for not engaged keys); optional, default ""
defkdefault key combination; optional, default ""
Return value

Returns a bound keys for not engaged keys or {} for others.


proc ::alited::pref::BindKey {nk {key {}} {defk {}}} { # Binds a key event to a key combination. # nk - index of combobox corresponding to the event # key - key combination or "-" (for not engaged keys) # defk - default key combination # Returns a bound keys for not engaged keys or {} for others. fetchVars if {$key eq {-}} { # not engaged event: bind to a new combination if defined if {[info exists keys($nk)]} { return $keys($nk) } # otherwise bind to the default return $defk } switch $nk { 4 { ;# "Double Selection" ::apave::setTextHotkeys CtrlD $keys($nk) } 5 { ;# "Delete Line" ::apave::setTextHotkeys CtrlY $keys($nk) } 10 { ;# "Highlight First" ::apave::setTextHotkeys AltQ $keys($nk) } 11 { ;# "Highlight Last" ::apave::setTextHotkeys AltW $keys($nk) } } return {} }




Cancel [::alited::pref]pref, Top

Handler of "Cancel" button.

Cancel ?args?
Parameters
argsOptional arguments.

proc ::alited::pref::Cancel {args} { # Handler of "Cancel" button. fetchVars RestoreSettings GetEmSave out $obDl2 res $win 0 }




CbxBackup [::alited::pref]pref, Top

Check for access to SpxMaxBak field. If CbxBackup is empty (no backup), SpxMaxBak should be disabled.

CbxBackup

proc ::alited::pref::CbxBackup {} { # Check for access to SpxMaxBak field. # If CbxBackup is empty (no backup), SpxMaxBak should be disabled. fetchVars if {$alited::al(BACKUP) eq {}} {set state disabled} {set state normal} [$obDl2 SpxMaxBak] configure -state $state }




CbxTheme [::alited::pref]pref, Top

Check for access to "Tint" field. If CbxTheme is not "clam", "Tint" should be disabled.

CbxTheme

proc ::alited::pref::CbxTheme {} { # Check for access to "Tint" field. # If CbxTheme is not "clam", "Tint" should be disabled. fetchVars if {[GetCS]>-2 && [::apave::obj apaveTheme $alited::al(THEME)]} { set state normal } else { set state disabled set alited::al(INI,HUE) 0 } [$obDl2 SpxHue] configure -state $state }




CheckUseDef [::alited::pref]pref, Top

Enables/disables the project default fields.

CheckUseDef

proc ::alited::pref::CheckUseDef {} { # Enables/disables the project default fields. fetchVars if {$al(PRJDEFAULT)} { set state normal [$obDl2 CbxEOL] configure -state readonly } else { set state disabled [$obDl2 CbxEOL] configure -state $state } foreach w {EntIgn SpxIndent SpxRedunit ChbMult} { [$obDl2 $w] configure -state $state } }




CheckUseLeaf [::alited::pref]pref, Top

Enables/disables the "Regexp of a leaf" field.

CheckUseLeaf

proc ::alited::pref::CheckUseLeaf {} { # Enables/disables the "Regexp of a leaf" field. fetchVars if {$al(INI,LEAF)} {set state normal} {set state disabled} [$obDl2 EntLf] configure -state $state }




CSyntax_Default [::alited::pref]pref, Top

Sets default colors to highlight C.

CSyntax_Default ?init?
Parameters
inityes, if only variables should be initialized; optional, default no

proc ::alited::pref::CSyntax_Default {{init no}} { # Sets default colors to highlight C. # init - yes, if only variables should be initialized. fetchVars set Dark [::apave::obj csDarkEdit] set clrnams [::hl_tcl::hl_colorNames] set clrvals [::hl_c::hl_colors {} $Dark] foreach nam $clrnams val $clrvals { set al(ED,C$nam) $val } if {!$init} {UpdateColors 2} }




Edit_Tab1 [::alited::pref]pref, Top

Serves to layout "Editor" tab.

Edit_Tab1

proc ::alited::pref::Edit_Tab1 {} { # Serves to layout "Editor" tab. return { {v_ - - 1 1} {fra v_ T 1 1 {-st nsew -cw 1 -rw 1}} {fra.scf - - 1 1 {pack -fill both -expand 1} {-mode y}} {.labFon - - 1 1 {-st w -pady 8 -padx 3} {-t "Font:"}} {.fonTxt .labFon L 1 9 {-st sw -pady 5 -padx 3} {-tvar alited::al(FONT,txt) -w 40}} {.labSp1 .labFon T 1 1 {-st w -pady 1 -padx 3} {-t "Space above lines:"}} {.spxSp1 .labSp1 L 1 1 {-st sw -pady 5 -padx 3} {-tvar alited::al(ED,sp1) -from 0 -to 16 -justify center -w 9}} {.labSp3 .labSp1 T 1 1 {-st w -pady 1 -padx 3} {-t "Space below lines:"}} {.spxSp3 .labSp3 L 1 1 {-st sw -pady 5 -padx 3} {-tvar alited::al(ED,sp3) -from 0 -to 16 -justify center -w 9}} {.labSp2 .labSp3 T 1 1 {-st w -pady 1 -padx 3} {-t "Space between wraps:"}} {.spxSp2 .labSp2 L 1 1 {-st sw -pady 5 -padx 3} {-tvar alited::al(ED,sp2) -from 0 -to 16 -justify center -w 9}} {.seh .labSp2 T 1 2 {-pady 3}} {.labLl .seh T 1 1 {-st w -pady 1 -padx 3} {-t "Tab bar label's length:"}} {.spxLl .labLl L 1 1 {-st sw -pady 5 -padx 3} {-tvar alited::al(INI,barlablen) -from 10 -to 100 -justify center -w 9}} {.labTl .labLl T 1 1 {-st w -pady 1 -padx 3} {-t "Tab bar tip's length:"}} {.spxTl .labTl L 1 1 {-st sw -pady 5 -padx 3} {-tvar alited::al(INI,bartiplen) -from 10 -to 100 -justify center -w 9}} {.seh2 .labTl T 1 2 {-pady 3}} {.labGW .seh2 T 1 1 {-st w -pady 1 -padx 3} {-t "Gutter's width:"}} {.spxGW .labGW L 1 1 {-st sw -pady 5 -padx 3} {-tvar alited::al(ED,gutterwidth) -from 3 -to 7 -justify center -w 9}} {.labGS .labGW T 1 1 {-st w -pady 1 -padx 3} {-t "Gutter's shift from text:"}} {.spxGS .labGS L 1 1 {-st sw -pady 5 -padx 3} {-tvar alited::al(ED,guttershift) -from 0 -to 10 -justify center -w 9}} } }




Edit_Tab2 [::alited::pref]pref, Top

Serves to layout "Tcl syntax" tab.

Edit_Tab2

proc ::alited::pref::Edit_Tab2 {} { # Serves to layout "Tcl syntax" tab. return { {v_ - - 1 1} {FraTab2 v_ T 1 1 {-st nsew -cw 1 -rw 1}} {fraTab2.scf - - 1 1 {pack -fill both -expand 1} {-mode y}} {.labExt - - 1 1 {-st w -pady 3 -padx 3} {-t "Tcl files' extensions:"}} {.entExt .labExt L 1 1 {-st sw -pady 3} {-tvar alited::al(TclExtensions) -w 30}} {.LabCOM .labExt T 1 1 {-st w -pady 3 -padx 3} {-t "Color of Tcl commands:"}} {.clrCOM .labCOM L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,clrCOM) -w 20}} {.labCOMTK .labCOM T 1 1 {-st w -pady 3 -padx 3} {-t "Color of Tk commands:"}} {.clrCOMTK .labCOMTK L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,clrCOMTK) -w 20}} {.labSTR .labCOMTK T 1 1 {-st w -pady 3 -padx 3} {-t "Color of strings:"}} {.clrSTR .labSTR L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,clrSTR) -w 20}} {.labVAR .labSTR T 1 1 {-st w -pady 3 -padx 3} {-t "Color of variables:"}} {.clrVAR .labVAR L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,clrVAR) -w 20}} {.labCMN .labVAR T 1 1 {-st w -pady 3 -padx 3} {-t "Color of comments:"}} {.clrCMN .labCMN L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,clrCMN) -w 20}} {.labPROC .labCMN T 1 1 {-st w -pady 3 -padx 3} {-t "Color of proc/methods:"}} {.clrPROC .labPROC L 1 1 {-st sw -pady } {-tvar alited::al(ED,clrPROC) -w 20}} {.labOPT .labPROC T 1 1 {-st w -pady 3 -padx 3} {-t "Color of options:"}} {.clrOPT .labOPT L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,clrOPT) -w 20}} {.labBRA .labOPT T 1 1 {-st w -pady 3 -padx 3} {-t "Color of brackets:"}} {.clrBRA .labBRA L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,clrBRA) -w 20}} {.seh .labBRA T 1 2 {-pady 3}} {.but .seh T 1 1 {-st w} {-t Default -com alited::pref::TclSyntax_Default}} } }




Edit_Tab3 [::alited::pref]pref, Top

Serves to layout "C/C++ syntax" tab.

Edit_Tab3

proc ::alited::pref::Edit_Tab3 {} { # Serves to layout "C/C++ syntax" tab. return { {v_ - - 1 1} {FraTab3 v_ T 1 1 {-st nsew -cw 1 -rw 1}} {fraTab3.scf - - 1 1 {pack -fill both -expand 1} {-mode y}} {.labExt - - 1 1 {-st w -pady 3 -padx 3} {-t "C/C++ files' extensions:"}} {.entExt .labExt L 1 2 {-st sw -pady 3} {-tvar alited::al(ClangExtensions) -w 30}} {.LabCOM2 .labExt T 1 1 {-st w -pady 3 -padx 3} {-t "Color of C key words:"}} {.clrCOM2 .labCOM2 L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,CclrCOM) -w 20}} {.labCOMTK2 .labCOM2 T 1 1 {-st w -pady 3 -padx 3} {-t "Color of C++ key words:"}} {.clrCOMTK2 .labCOMTK2 L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,CclrCOMTK) -w 20}} {.labSTR2 .labCOMTK2 T 1 1 {-st w -pady 3 -padx 3} {-t "Color of strings:"}} {.clrSTR2 .labSTR2 L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,CclrSTR) -w 20}} {.labVAR2 .labSTR2 T 1 1 {-st w -pady 3 -padx 3} {-t "Color of punctuation:"}} {.clrVAR2 .labVAR2 L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,CclrVAR) -w 20}} {.labCMN2 .labVAR2 T 1 1 {-st w -pady 3 -padx 3} {-t "Color of comments:"}} {.clrCMN2 .labCMN2 L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,CclrCMN) -w 20}} {.labPROC2 .labCMN2 T 1 1 {-st w -pady 3 -padx 3} {-t "Color of return/goto:"}} {.clrPROC2 .labPROC2 L 1 1 {-st sw -pady } {-tvar alited::al(ED,CclrPROC) -w 20}} {.labOPT2 .labPROC2 T 1 1 {-st w -pady 3 -padx 3} {-t "Color of your key words:"}} {.clrOPT2 .labOPT2 L 1 1 {-st sw -pady } {-tvar alited::al(ED,CclrOPT) -w 20}} {.labBRA2 .labOPT2 T 1 1 {-st w -pady 3 -padx 3} {-t "Color of brackets:"}} {.clrBRA2 .labBRA2 L 1 1 {-st sw -pady 3} {-tvar alited::al(ED,CclrBRA) -w 20}} {.seh .labBRA2 T 1 2 {-pady 3}} {.but .seh T 1 1 {-st w} {-t Default -com alited::pref::CSyntax_Default}} {.seh2 .but T 1 2 {-pady 10}} {fraTab3.scf.fra2 .seh2 T 1 2 {-st nsew}} {.labAddKeys - - 1 1 {-st nw -pady 3} {-t "Your key words:"}} {.TexCKeys .labAddKeys L 1 1 {-st new} {-h 7 -w 36 -wrap word -tabnext $alited::pref::win.fraB.butOK}} } }




EmAddLine [::alited::pref]pref, Top

Inserts a new "bar/menu" action before a current one.

EmAddLine idx
Parameters
idxindex of a current action

proc ::alited::pref::EmAddLine {idx} { # Inserts a new "bar/menu" action before a current one. # idx - index of a current action fetchVars for {set i $em_Num} {$i>$idx} {} { incr i -1 if {$i==$idx} { lassign {} em_mnu($i) em_ico($i) em_inf($i) set em_sep($i) 0 } else { # lower all the rest actions set ip [expr {$i-1}] set em_sep($i) $em_sep($ip) set em_ico($i) $em_ico($ip) set em_mnu($i) $em_mnu($ip) set em_inf($i) $em_inf($ip) } } EmSeparators yes }




EmDelLine [::alited::pref]pref, Top

Deletes a current "bar/menu" action.

EmDelLine idx
Parameters
idxindex of a current action

proc ::alited::pref::EmDelLine {idx} { # Deletes a current "bar/menu" action. # idx - index of a current action fetchVars for {set i $idx} {$i<$em_Num} {incr i} { if {$i==($em_Num-1)} { lassign {} em_mnu($i) em_ico($i) em_inf($i) set em_sep($i) 0 } else { # make upper all the rest actions set ip [expr {$i+1}] set em_sep($i) $em_sep($ip) set em_ico($i) $em_ico($ip) set em_mnu($i) $em_mnu($ip) set em_inf($i) $em_inf($ip) } } EmSeparators yes ScrollRuns }




Emenu_Tab [::alited::pref]pref, Top

Serves to layout "Tools" tab.

Emenu_Tab

proc ::alited::pref::Emenu_Tab {} { # Serves to layout "Tools" tab. set alited::al(EM,menu) [file join $alited::al(EM,menudir) [file tail $alited::al(EM,menu)]] return { {v_ - - 1 1} {fra v_ T 1 1 {-st nsew -cw 1 -rw 1}} {fra.scf - - 1 1 {pack -fill both -expand 1} {-mode x}} {.labExe - - 1 1 {-st w -pady 1 -padx 3} {-t "Run as external app:"}} {.chbExe .labExe L 1 1 {-st sw -pady 5} {-var alited::al(EM,exec) -onvalue yes -offvalue no}} {.labCS .labExe T 1 1 {-st w -pady 1 -padx 3} {-t "Color scheme:"}} {.opc .labCS L 1 1 {-st sw -pady 5} {::alited::pref::opcc2 alited::pref::opcColors {-width 20} {alited::pref::opcToolPre %a}}} {.labGeo .labCS T 1 1 {-st w -pady 1 -padx 3} {-t "Geometry:"}} {.entGeo .labGeo L 1 1 {-st sw -pady 5} {-tvar alited::al(EM,geometry) -w 40}} {.labDir .labGeo T 1 1 {-st w -pady 1 -padx 3} {-t "Directory of menus:"}} {.dirEM .labDir L 1 1 {-st sw -pady 5} {-tvar alited::al(EM,menudir) -w 40}} {.labMenu .labDir T 1 1 {-st w -pady 1 -padx 3} {-t "Main menu:"}} {.filMenu .labMenu L 1 1 {-st sw -pady 5} {-tvar alited::al(EM,menu) -w 40 -filetypes {{{Menus} .mnu} {{All files} .* }}}} {.labPD .labMenu T 1 1 {-st w -pady 1 -padx 3} {-t "Projects (%PD wildcard):"}} {.filPD .labPD L 1 1 {-st sw -pady 5} {-tvar alited::al(EM,PD=) -w 40}} {.labDoc .labPD T 1 1 {-st w -pady 1 -padx 3} {-t "Path to man/tcl8.6:"}} {.dirDoc .labDoc L 1 1 {-st sw -pady 5} {-tvar alited::al(EM,h=) -w 40}} {.labTT .labDoc T 1 1 {-st w -pady 1 -padx 3} {-t "Linux terminal:"}} {.entTT .labTT L 1 1 {-st sw -pady 5} {-tvar alited::al(EM,tt=) -w 40}} {.labDF .labTT T 1 1 {-st w -pady 1 -padx 3} {-t "Diff tool:"}} {.entDF .labDF L 1 1 {-st sw -pady 1} {-tvar alited::al(EM,DiffTool) -w 40}} } }




EmSeparators [::alited::pref]pref, Top

Handles separators of bar/menu.

EmSeparators upd
Parameters
updif yes, displays the widgets of bar/menu settings.

proc ::alited::pref::EmSeparators {upd} { # Handles separators of bar/menu. # upd - if yes, displays the widgets of bar/menu settings. fetchVars for {set i 0} {$i<$em_Num} {incr i} { if {![info exists em_sep($i)]} { lassign {} em_inf($i) em_mnu($i) em_ico($i) em_sep($i) } set em_sep($i) [string is true -strict $em_sep($i)] if {$em_sep($i)} { lassign {} em_inf($i) em_mnu($i) em_ico($i) } if {$upd} { if {$em_sep($i)} {set state disabled} {set state normal} [$obDl2 ButMnu$i] configure -text $em_mnu($i) -state $state [$obDl2 OpcIco$i] configure -state $state } } if {$upd} ScrollRuns }




fetchVars [::alited::pref]pref, Top

Delivers namespace variables to a caller.

fetchVars

proc ::alited::pref::fetchVars {} { # Delivers namespace variables to a caller. uplevel 1 { namespace upvar ::alited al al obDl2 obDl2 variable win variable geo variable minsize variable data variable keys variable prevkeys variable savekeys variable arrayTab variable curTab variable oldTab variable opcThemes variable opc1 variable opcColors variable opcc variable opcc2 variable em_Num variable em_mnu variable em_ico variable em_sep variable em_inf variable em_Menus variable em_Icons variable listIcons variable listMenus variable stdkeys variable stdkeysSize } }




General_Tab1 [::alited::pref]pref, Top

Serves to layout "General" tab.

General_Tab1

proc ::alited::pref::General_Tab1 {} { # Serves to layout "General" tab. fetchVars set opcc [set opcc2 [msgcat::mc {-2: Default}]] set opcColors [list "{$opcc}"] for {set i -1; set n [apave::cs_MaxBasic]} {$i<=$n} {incr i} { if {(($i+2) % ($n/2+2)) == 0} {lappend opcColors |} set csname [::apave::obj csGetName $i] lappend opcColors [list $csname] if {$i == $al(INI,CS)} {set opcc $csname} if {$i == $al(EM,CS)} {set opcc2 $csname} } set opcThemes [list default clam classic alt awlight awdark -- {experimental azure-light azure-dark forest-light forest-dark sun-valley-light sun-valley-dark}] if {[string first $alited::al(THEME) $opcThemes]<0} { set opc1 [lindex $opcThemes 0] } else { set opc1 $alited::al(THEME) } return { {v_ - - 1 1} {fra1 v_ T 1 2 {-st nsew -cw 1}} {.labTheme - - 1 1 {-st w -pady 1 -padx 3} {-t "Ttk theme:"}} {.opc1 .labTheme L 1 1 {-st sw -pady 1} {::alited::pref::opc1 alited::pref::opcThemes {-width 20 -com alited::pref::CbxTheme} {}}} {.labCS .labTheme T 1 1 {-st w -pady 1 -padx 3} {-t "Color scheme:"}} {.opc2 .labCS L 1 1 {-st sw -pady 1} {::alited::pref::opcc alited::pref::opcColors {-width 20 -com alited::pref::CbxTheme} {alited::pref::opcToolPre %a}}} {.labHue .labCS T 1 1 {-st w -pady 1 -padx 3} {-t "Tint:"}} {.SpxHue .labHue L 1 1 {-st sw -pady 1} {-tvar alited::al(INI,HUE) -from -50 -to 50 -justify center -w 9}} {seh_ .labHue T 1 2 {-pady 4}} {fra2 seh_ T 1 2 {-st nsew -cw 1}} {.labLocal - - 1 1 {-st w -pady 1 -padx 3} {-t "Preferable locale:" -tip {$alited::al(MC,locale)}}} {.entLocal .labLocal L 1 1 {-st sw -pady 1 -padx 3} {-tvar alited::al(LOCAL) -w 8 -tip {$alited::al(MC,locale)}}} {.labFon .labLocal T 1 1 {-st w -pady 1 -padx 3} {-t "Font:"}} {.fonTxt .labFon L 1 9 {-st sw -pady 1 -padx 3} {-tvar alited::al(FONT) -w 40}} {.labFsz1 .labFon T 1 1 {-st w -pady 1 -padx 3} {-t "Small font size:"}} {.spxFsz1 .labFsz1 L 1 9 {-st sw -pady 1 -padx 3} {-tvar alited::al(FONTSIZE,small) -from 8 -to 14 -justify center -w 9}} {.labFsz2 .labFsz1 T 1 1 {-st w -pady 1 -padx 3} {-t "Middle font size:"}} {.spxFsz2 .labFsz2 L 1 9 {-st sw -pady 1 -padx 3} {-tvar alited::al(FONTSIZE,std) -from 9 -to 18 -justify center -w 9}} {.labCurw .labFsz2 T 1 1 {-st w -pady 1 -padx 3} {-t "Cursor width:"}} {.spxCurw .labCurw L 1 9 {-st sw -pady 1 -padx 3} {-tvar alited::al(CURSORWIDTH) -from 1 -to 3 -justify center -w 9}} {seh_2 fra2 T 1 2 {-pady 4}} {lab seh_2 T 1 2 {-st w -pady 4 -padx 3} {-t "Notes:"}} {fra3 lab T 1 2 {-st nsew -rw 1 -cw 1}} {.TexNotes - - - - {pack -side left -expand 1 -fill both -padx 3} {-h 20 -w 90 -wrap word -tabnext $alited::pref::win.fraB.butHelp -tip {$alited::al(MC,notes)}}} {.sbv .TexNotes L - - {pack -side left}} } }




General_Tab2 [::alited::pref]pref, Top

Serves to layout "General/Saving" tab.

General_Tab2

proc ::alited::pref::General_Tab2 {} { # Serves to layout "General/Saving" tab. GetEmSave in return { {v_ - - 1 1} {fra v_ T 1 1 {-st nsew -cw 1 -rw 1}} {fra.scf - - 1 1 {pack -fill both -expand 1} {-mode y}} {.labConf - - 1 1 {-st w -pady 1 -padx 3} {-t "Confirm exit:"}} {.chbConf .labConf L 1 1 {-st sw -pady 1 -padx 3} {-var alited::al(INI,confirmexit)}} {.seh1 .labConf T 1 4 {-st ew -pady 5}} {.labS .seh1 T 1 1 {-st w -pady 1 -padx 3} {-t "Save configuration on"}} {.labSonadd .labS T 1 1 {-st e -pady 1 -padx 3} {-t "opening a file:"}} {.chbOnadd .labSonadd L 1 1 {-st sw -pady 1 -padx 3} {-var alited::al(INI,save_onadd)}} {.labSonclose .labSonadd T 1 1 {-st e -pady 1 -padx 3} {-t "closing a file:"}} {.chbOnclose .labSonclose L 1 1 {-st sw -pady 1 -padx 3} {-var alited::al(INI,save_onclose)}} {.labSonsave .labSonclose T 1 1 {-st e -pady 1 -padx 3} {-t "saving a file:"}} {.chbOnsave .labSonsave L 1 1 {-st sw -pady 1 -padx 3} {-var alited::al(INI,save_onsave)}} {.seh2 .labSonsave T 1 4 {-st ew -pady 5}} {.labSave .seh2 T 1 1 {-st w -pady 1 -padx 3} {-t "Save before bar/menu runs:"}} {.cbxSave .labSave L 1 2 {-st sw -pady 1} {-values {$alited::al(pref,saveonrun)} -tvar alited::al(EM,save) -state readonly -w 20}} {.seh3 .labSave T 1 4 {-st ew -pady 5}} {.labRecnt .seh3 T 1 1 {-st w -pady 1 -padx 3} {-t "'Recent Files' length:"}} {.spxRecnt .labRecnt L 1 1 {-st sw -pady 1} {-tvar alited::al(INI,RECENTFILES) -from 10 -to 50 -justify center -w 9}} {.labMaxLast .labRecnt T 1 1 {-st w -pady 1 -padx 3} {-t "'Last Visited' length:"}} {.spxMaxLast .labMaxLast L 1 1 {-st sw -pady 1} {-tvar alited::al(FAV,MAXLAST) -from 10 -to 100 -justify center -w 9}} {.labMaxFiles .labMaxLast T 1 1 {-st w -pady 1 -padx 3} {-t "Maximum of project files:"}} {.spxMaxFiles .labMaxFiles L 1 1 {-st sw -pady 1} {-tvar alited::al(MAXFILES) -from 1000 -to 9999 -justify center -w 9}} {.seh4 .labMaxFiles T 1 4 {-st ew -pady 5}} {.labBackup .seh4 T 1 1 {-st w -pady 1 -padx 3} {-t "Back up files to a project's subdirectory:"}} {.CbxBackup .labBackup L 1 1 {-st sw -pady 1} {-tvar alited::al(BACKUP) -values {{} .bak} -state readonly -w 6 -tip "A subdirectory of projects where backup copies of files will be saved to.\nSet the field blank to cancel the backup." -afteridle alited::pref::CbxBackup -selcombobox alited::pref::CbxBackup}} {.labMaxBak .CbxBackup L 1 1 {-st w -pady 1 -padx 1} {-t " Maximum:"}} {.SpxMaxBak .labMaxBak L 1 1 {-st sw -pady 1 -padx 1} {-tvar alited::al(MAXBACKUP) -from 1 -to 99 -justify center -w 9 -tip "Maximum of backup copies per a file"}} {.labBell .labBackup T 1 1 {-st w -pady 1 -padx 3} {-t "Bell at warnings:"}} {.chbBell .labBell L 1 1 {-st sw -pady 1 -padx 3} {-var alited::al(INI,belltoll)}} } }




General_Tab3 [::alited::pref]pref, Top

Serves to layout "General/Defaults" tab.

General_Tab3

proc ::alited::pref::General_Tab3 {} { # Serves to layout "General/Defaults" tab. return { {v_ - - 1 10} {fra2 v_ T 1 2 {-st nsew -cw 1}} {.labDef - - 1 1 {-st w -pady 1 -padx 3} {-t {Default values for new projects:}}} {.chbDef .labDef L 1 1 {-st sw -pady 3 -padx 3} {-var alited::al(PRJDEFAULT) -com alited::pref::CheckUseDef -afteridle alited::pref::CheckUseDef}} {.h_ .labDef T 1 2 {-st w -pady 8 -padx 3}} {.labIgn .h_ T 1 1 {-st w -pady 8 -padx 3} {-t "Skip subdirectories:"}} {.EntIgn .labIgn L 1 9 {-st sw -pady 5 -padx 3} {-tvar alited::al(DEFAULT,prjdirign) -w 50}} {.labEOL .labIgn T 1 1 {-st w -pady 1 -padx 3} {-t "End of line:"}} {.CbxEOL .labEOL L 1 1 {-st sw -pady 3 -padx 3} {-tvar alited::al(DEFAULT,prjEOL) -values {{} LF CR CRLF} -state readonly -w 9}} {.labIndent .labEOL T 1 1 {-st w -pady 1 -padx 3} {-t "Indentation:"}} {.SpxIndent .labIndent L 1 1 {-st sw -pady 3 -padx 3} {-tvar alited::al(DEFAULT,prjindent) -w 9 -from 2 -to 8 -justify center}} {.labRedunit .labIndent T 1 1 {-st w -pady 1 -padx 3} {-t "Unit lines per 1 red bar:"}} {.SpxRedunit .labRedunit L 1 1 {-st sw -pady 3 -padx 3} {-tvar alited::al(DEFAULT,prjredunit) -w 9 -from 10 -to 100 -justify center}} {.labMult .labRedunit T 1 1 {-st w -pady 1 -padx 3} {-t "Multi-line strings:" -tip {$alited::al(MC,notrecomm)}}} {.ChbMult .labMult L 1 1 {-st sw -pady 3 -padx 3} {-var alited::al(DEFAULT,prjmultiline) -tip {$alited::al(MC,notrecomm)}}} } }




GetCS [::alited::pref]pref, Top

Gets a color scheme's index from opcc / opcc2 variable.

GetCS ?ncc?
Parameters
ncc{} for opcc, {2} for opcc2; optional, default ""

proc ::alited::pref::GetCS {{ncc {}}} { # Gets a color scheme's index from *opcc* / *opcc2* variable. # ncc - {} for opcc, {2} for opcc2 fetchVars return [scan [set opcc$ncc] %d:] }




GetEmSave [::alited::pref]pref, Top

Gets a name of setting "Save before run".

GetEmSave to
Parameters
toif "in", gets a localized name; if "out", gets English name

proc ::alited::pref::GetEmSave {to} { # Gets a name of setting "Save before run". # to - if "in", gets a localized name; if "out", gets English name fetchVars set savcur [msgcat::mc {Current file}] set savall [msgcat::mc {All files}] set al(pref,saveonrun) [list {} $savcur $savall] if {$to eq {in}} { switch -exact $al(EM,save) { Current {set al(EM,save) $savcur} All {set al(EM,save) $savall} } } elseif {$al(EM,save) eq $savcur} { set al(EM,save) Current } elseif {$al(EM,save) eq $savall} { set al(EM,save) All } }




GetKeyList [::alited::pref]pref, Top

Gets a list of available (not engaged) key combinations.

GetKeyList nk
Parameters
nkindex of combobox that will get the list as -values option

proc ::alited::pref::GetKeyList {nk} { # Gets a list of available (not engaged) key combinations. # nk - index of combobox that will get the list as -values option fetchVars RegisterKeys [$obDl2 CbxKey$nk] configure -values [alited::keys::VacantList] }




Help [::alited::pref]pref, Top

Shows a help on a current tab.

Help

proc ::alited::pref::Help {} { # Shows a help on a current tab. fetchVars set sel [lindex [split [$win.fraR.$curTab select] .] end] alited::Help $win "-${curTab}-$sel" }




IniKeys [::alited::pref]pref, Top

Gets key settings at opening "Preferences" dialogue.

IniKeys

proc ::alited::pref::IniKeys {} { # Gets key settings at opening "Preferences" dialogue. fetchVars # default settings dict for {k info} $stdkeys { set keys($k) [set prevkeys($k) [set savekeys($k) [lindex $info 1]]] } # new settings foreach kitem [alited::keys::EngagedList preference] { lassign $kitem key comi lassign $comi com k set keys($k) [set prevkeys($k) [set savekeys($k) $key]] } }




KeyAccelerator [::alited::pref]pref, Top

Gets a key accelerator for a combobox of keys, bound to an action.

KeyAccelerator nk defk
Parameters
nkindex of combobox
defkdefault key combination

proc ::alited::pref::KeyAccelerator {nk defk} { # Gets a key accelerator for a combobox of keys, bound to an action. # nk - index of combobox # defk - default key combination set acc [BindKey $nk - $defk] return [::apave::KeyAccelerator $acc] }




KeyAccelerators [::alited::pref]pref, Top

Gets a full list of key accelerators,

KeyAccelerators

proc ::alited::pref::KeyAccelerators {} { # Gets a full list of key accelerators, fetchVars dict for {k info} $stdkeys { set al(acc_$k) [KeyAccelerator $k [lindex $info 1]] } }




Keys_Tab1 [::alited::pref]pref, Top

Serves to layout "Keys" tab.

Keys_Tab1

proc ::alited::pref::Keys_Tab1 {} { # Serves to layout "Keys" tab. return { {v_ - - 1 1} {fra v_ T 1 1 {-st nsew -cw 1 -rw 1}} {fra.scf - - 1 1 {pack -fill both -expand 1} {-mode y}} {tcl { set pr - for {set i 0} {$i<$alited::pref::stdkeysSize} {incr i} { set lab "lab$i" set cbx "CbxKey$i" lassign [dict get $alited::pref::stdkeys $i] text key set lwid ".$lab $pr T 1 1 {-st w -pady 1 -padx 3} {-t \"$text\"}" %C $lwid set lwid ".$cbx .$lab L 1 1 {-st we} {-tvar ::alited::pref::keys($i) -postcommand {::alited::pref::GetKeyList $i} -selcombobox {::alited::pref::SelectKey $i} -state readonly -h 16 -w 20}" %C $lwid set pr .$lab } }} } }




MainFrame [::alited::pref]pref, Top

Creates a main frame of the dialogue.

MainFrame

proc ::alited::pref::MainFrame {} { # Creates a main frame of the dialogue. return { {fraL - - 1 1 {-st nws -rw 2}} {.ButHome - - 1 1 {-st we} {-t "General" -com "alited::pref::Tab nbk" -style TButtonWest}} {.butChange .butHome T 1 1 {-st we} {-t "Editor" -com "alited::pref::Tab nbk2" -style TButtonWest}} {.butCategories .butChange T 1 1 {-st we} {-t "Units" -com "alited::pref::Tab nbk3" -style TButtonWest}} {.butActions .butCategories T 1 1 {-st we} {-t "Templates" -com "alited::pref::Tab nbk4" -style TButtonWest}} {.butKeys .butActions T 1 1 {-st we} {-image alimg_kbd -compound left -t "Keys" -com "alited::pref::Tab nbk5" -style TButtonWest}} {.butTools .butKeys T 1 1 {-st we} {-t "Tools" -com "alited::pref::Tab nbk6" -style TButtonWest}} {.v_ .butTools T 1 1 {-st ns} {-h 30}} {fraR fraL L 1 1 {-st nsew -cw 1}} {fraR.Nbk - - - - {pack -side top -expand 1 -fill both} { f1 {-t View} f2 {-t Saving} f3 {-t Projects} }} {fraR.nbk2 - - - - {pack forget -side top} { f1 {-t Editor} f2 {-t "Tcl syntax"} f3 {-t "C/C++ syntax"} }} {fraR.nbk3 - - - - {pack forget -side top} { f1 {-t Units} }} {fraR.nbk4 - - - - {pack forget -side top} { f1 {-t Templates} }} {fraR.nbk5 - - - - {pack forget -side top} { f1 {-t Keys} }} {fraR.nbk6 - - - - {pack forget -side top} { f1 {-t e_menu} f2 {-t tkcon} f3 {-t bar/menu} }} {#LabMess fraL T 1 2 {-st nsew -pady 0 -padx 3} {-style TLabelFS}} {fraB fraL T 1 2 {-st nsew} {-padding {5 5 5 5} -relief groove}} {.butHelp - - - - {pack -side left} {-t "Help" -com ::alited::pref::Help}} {.LabMess - - - - {pack -side left -expand 1 -fill both -padx 8} {-w 50}} {.butOK - - - - {pack -side left -anchor s -padx 2} {-t Save -command ::alited::pref::Ok}} {.butCancel - - - - {pack -side left -anchor s} {-t Cancel -command ::alited::pref::Cancel}} } }




Ok [::alited::pref]pref, Top

Handler of "OK" button.

Ok ?args?
Parameters
argsOptional arguments.

proc ::alited::pref::Ok {args} { # Handler of "OK" button. fetchVars set ans [alited::msg yesnocancel info [msgcat::mc "For the settings to be active\nthe application should be restarted.\n\nRestart it just now?"] YES -geometry root=$win] if {$ans in {1 2}} { GetEmSave out # check options that can make alited unusable if {$al(INI,HUE)<-50 || $al(INI,HUE)>50} {set al(INI,HUE) 0} if {$al(FONTSIZE,small)<8 || $al(FONTSIZE,small)>14} {set al(FONTSIZE,small) 10} if {$al(FONTSIZE,std)<9 || $al(FONTSIZE,std)>18} {set al(FONTSIZE,std) 11} if {$al(INI,RECENTFILES)<10 || $al(INI,RECENTFILES)>50} {set al(INI,RECENTFILES) 16} if {$al(FAV,MAXLAST)<10 || $al(FAV,MAXLAST)>100} {set al(FAV,MAXLAST) 100} if {$al(MAXFILES)<1000 || $al(MAXFILES)>9999} {set al(MAXFILES) 2000} if {$al(INI,barlablen)<10 || $al(INI,barlablen)>100} {set al(INI,barlablen) 16} if {$al(INI,bartiplen)<10 || $al(INI,bartiplen)>100} {set al(INI,bartiplen) 32} if {$al(CURSORWIDTH)<1 || $al(CURSORWIDTH)>3} {set al(CURSORWIDTH) 2} set al(THEME) $opc1 set al(INI,CS) [GetCS] if {![string is integer -strict $al(INI,CS)]} {set al(INI,CS) -1} set al(EM,CS) [GetCS 2] if {![string is integer -strict $al(EM,CS)]} {set al(EM,CS) -1} set al(ED,CKeyWords) [[$obDl2 TexCKeys] get 1.0 {end -1c}] set al(ED,CKeyWords) [string map [list \n { }] $al(ED,CKeyWords)] set al(BACKUP) [string trim $al(BACKUP)] $obDl2 res $win 1 if {$ans == 1} {alited::Exit - 1 no} } }




opcIcoPre [::alited::pref]pref, Top

Gets an item for icon list of a bar/menu action.

opcIcoPre ?args?
Parameters
argscontains a name of current icon

proc ::alited::pref::opcIcoPre {args} { # Gets an item for icon list of a bar/menu action. # args - contains a name of current icon fetchVars lassign $args a if {[set i [lsearch $listIcons $a]]>-1} { set img [::apave::iconImage [lindex $listIcons $i]] set res "-image $img" } else { set res "-image alimg_none" } append res " -compound left -label $a" }




opcToolPre [::alited::pref]pref, Top

Gets colors for "Color schemes" items.

opcToolPre ?args?
Parameters
argsa color scheme's index and name, separated by ":"

proc ::alited::pref::opcToolPre {args} { # Gets colors for "Color schemes" items. # args - a color scheme's index and name, separated by ":" lassign $args a set a [string trim $a :] if {[string is integer $a]} { lassign [::apave::obj csGet $a] - fg - bg return "-background $bg -foreground $fg" } else { return {} } }




PickMenuItem [::alited::pref]pref, Top

Selects e_menu's action for a "bar/menu" item.

PickMenuItem it
Parameters
itindex of "bar/menu" item

proc ::alited::pref::PickMenuItem {it} { # Selects e_menu's action for a "bar/menu" item. # it - index of "bar/menu" item fetchVars if {![info exists ::em::geometry]} { source [file join $::e_menu_dir e_menu.tcl] } set w [$obDl2 ButMnu$it] set X [winfo rootx $w] set Y [winfo rooty $w] set res [::em::main -prior 1 -modal 1 -remain 0 -noCS 1 {*}[alited::tool::EM_Options "pk=yes dk=dock o=0 t=1 g=+[incr X 5]+[incr Y 25]"]] lassign $res menu idx item if {$item ne {}} { set i [lindex [alited::tool::EM_Structure $menu] $idx-1 1] set item2 [string range $i [string first - $i]+1 end] if {$item2 ne $item && [string match *.mnu $item2]} { append item2 ": $item" ;# it's a menu call title set idx - ;# to open the whole menu } $w configure -text $item2 set em_mnu($it) $item2 set em_inf($it) [list [file tail $menu] $idx $item2] ScrollRuns } }




RegisterKeys [::alited::pref]pref, Top

Adds key bindings to keys array.

RegisterKeys

proc ::alited::pref::RegisterKeys {} { # Adds key bindings to keys array. fetchVars alited::keys::Delete preference for {set k 0} {$k<$stdkeysSize} {incr k} { alited::keys::Add preference $k [set keys($k)] "alited::pref::BindKey $k {%k}" } }




ReservedIcons [::alited::pref]pref, Top

Returns a list of icons already engaged by alited.

ReservedIcons
Return value

Returns a list of icons already engaged by alited.


proc ::alited::pref::ReservedIcons {} { # Returns a list of icons already engaged by alited. return [list file OpenFile box SaveFile saveall undo redo help replace run other ok color] }




RestoreSettings [::alited::pref]pref, Top

Restores original settings.

RestoreSettings

proc ::alited::pref::RestoreSettings {} { # Restores original settings. fetchVars foreach o [SavedOptions] { catch {set al($o) $data($o)} } dict for {k info} $stdkeys { set keys($k) $savekeys($k) SelectKey $k } for {set i 0} {$i<$em_Num} {incr i} { catch { set em_mnu($i) $data(em_mnu,$i) set em_ico($i) $data(em_ico,$i) set em_sep($i) $data(em_sep,$i) set em_inf($i) $data(em_inf,$i) } } }




Runs_Tab [::alited::pref]pref, Top

Prepares and layouts "bar/menu" tab.

Runs_Tab

proc ::alited::pref::Runs_Tab {} { # Prepares and layouts "bar/menu" tab. fetchVars # get a list of all available icons for "bar/menu" actions set listIcons [::apave::iconImage] set em_Icons [list] set n [llength $listIcons] set icr 0 set ncr 0 for {set i 0} {$i<($n+43)} {incr i} { if {$icr && ($icr % 13) == 0} {lappend em_Icons |} set ii [expr {$icr-$ncr}] if {$i<$n} { set ico [lindex $listIcons $i] if {$ico in [ReservedIcons]} continue lappend em_Icons $ico incr ncr } elseif {$ii<10} { lappend em_Icons $ii } else { lappend em_Icons [string index [TextIcons] [expr {$ii -10}]] } incr icr } EmSeparators no # get a full list of actions contained in all e_menu's menus set em_Menus {} set curmenu menu.mnu set curlev 0 set listMenus [alited::tool::EM_AllStructure $curmenu] foreach mit $listMenus { lassign $mit lev mnu hk item set item [string map [list \{ \\\{ \} \\\} \" \\\" \$ \\\$] $item] if {$lev>$curlev} { append em_Menus " \{$mnu" } elseif {$lev<$curlev} { append em_Menus "\} \"$item\"" } else { append em_Menus " \"$item\"" } set curlev $lev } append em_Menus [string repeat \} $curlev] # get a layout of "bar/menu" tab return { {v_ - - 1 1} {fra v_ T 1 1 {-st nsew -cw 1 -rw 1} {-afteridle {::alited::pref::EmSeparators yes}}} {fra.ScfRuns - - 1 1 {pack -fill both -expand 1}} {tcl { set prt "- -" for {set i 0} {$i<$::alited::pref::em_Num} {incr i} { set nit [expr {$i+1}] set lwid ".buTAdd$i $prt 1 1 {-padx 0} {-tip {Inserts a new line.} -com {::alited::pref::EmAddLine $i} -takefocus 0 -relief flat -image alimg_add}" %C $lwid set lwid ".buTDel$i .buTAdd$i L 1 1 {-padx 1} {-tip {Deletes a line.} -com {::alited::pref::EmDelLine $i} -takefocus 0 -relief flat -image alimg_delete}" %C $lwid set lwid ".lab$i .buTDel$i L 1 1 {-st w -padx 3} {-t {$alited::al(MC,Item)$nit}}" %C $lwid set lwid ".ChbMT$i .lab$i L 1 1 {-padx 10} {-t separator -var ::alited::pref::em_sep($i) -tip {If 'yes', means a separator of the toolbar/menu.} -com {::alited::pref::EmSeparators yes}}" %C $lwid set lwid ".OpcIco$i .ChbMT$i L 1 1 {-st nsw} {::alited::pref::em_ico($i) alited::pref::em_Icons {-width 10 -tooltip {{An icon puts the run into the toolbar.\nBlank or 'none' excludes it from the toolbar.}}} {alited::pref::opcIcoPre %a}}" %C $lwid set lwid ".ButMnu$i .OpcIco$i L 1 1 {-st sw -pady 1 -padx 10} {-t {$::alited::pref::em_mnu($i)} -com {alited::pref::PickMenuItem $i} -style TButtonWest -tip {{The run item for the menu and/or the toolbar.\nSelect it from the e_menu items.}}}" %C $lwid set prt ".buTAdd$i T" }} } } }




SavedOptions [::alited::pref]pref, Top

Returns a list of names of main settings.

SavedOptions
Return value

Returns a list of names of main settings.


proc ::alited::pref::SavedOptions {} { # Returns a list of names of main settings. fetchVars return [array name al] }




SaveSettings [::alited::pref]pref, Top

Saves original settings.

SaveSettings

proc ::alited::pref::SaveSettings {} { # Saves original settings. fetchVars foreach o [SavedOptions] { set data($o) $al($o) } for {set i 0} {$i<$em_Num} {incr i} { catch { set data(em_mnu,$i) $em_mnu($i) set data(em_ico,$i) $em_ico($i) set data(em_sep,$i) $em_sep($i) set data(em_inf,$i) $em_inf($i) } } }




ScrollRuns [::alited::pref]pref, Top

Updates scrollbars of bar/menu tab because its contents may have various length.

ScrollRuns

proc ::alited::pref::ScrollRuns {} { # Updates scrollbars of bar/menu tab because its contents may have various length. fetchVars update ::apave::sframe resize [$obDl2 ScfRuns] }




SelectKey [::alited::pref]pref, Top

Handles <> event on a combobox of keys.

SelectKey nk
Parameters
nkindex of combobox

proc ::alited::pref::SelectKey {nk} { # Handles <<ComboboxSelected>> event on a combobox of keys. # nk - index of combobox fetchVars alited::keys::Delete {} $prevkeys($nk) set prevkeys($nk) $keys($nk) GetKeyList $nk }




Tab [::alited::pref]pref, Top

Handles changing tabs of notebooks.

Tab tab ?nt? ?doit?
Parameters
tabname of notebook
nttab of notebook; optional, default ""
doitif yes, forces changing tabs; optional, default no
Description

At changing the current notebook: we need to save the old selection in order to restore the selection at returning to the notebook.


proc ::alited::pref::Tab {tab {nt {}} {doit no}} { # Handles changing tabs of notebooks. # tab - name of notebook # nt - tab of notebook # doit - if yes, forces changing tabs. # At changing the current notebook: we need to save the old selection # in order to restore the selection at returning to the notebook. fetchVars if {$tab ne $curTab || $doit} { if {$curTab ne {}} { set arrayTab($curTab) [$win.fraR.$curTab select] pack forget $win.fraR.$curTab } set curTab $tab pack $win.fraR.$curTab -expand yes -fill both catch { if {$nt eq {}} {set nt $arrayTab($curTab)} $win.fraR.$curTab select $nt } } if {$tab eq {nbk2}} { # check if a color scheme is switched light/dark - if yes, disable colors set light1 [::apave::obj csDarkEdit $data(INI,CS)] set light2 [::apave::obj csDarkEdit [GetCS]] if { $light1 != $light2} { set msg [msgcat::mc {Color scheme's light changed. Color fields disabled.}] alited::Message $msg 3 [$obDl2 LabMess] set state disabled } else { set state normal } foreach fra {FraTab2 FraTab3} { foreach a [winfo children [$obDl2 $fra]] { foreach b [winfo children $a] { foreach c [winfo children $b] { foreach d [winfo children $c] { foreach e [winfo children $d] { if {[string first clr $e]>0 || [string first but $e]>0} { catch {$e configure -state $state} } } } } } } } } }




TclSyntax_Default [::alited::pref]pref, Top

Sets default colors to highlight Tcl.

TclSyntax_Default ?init?
Parameters
inityes, if only variables should be initialized; optional, default no

proc ::alited::pref::TclSyntax_Default {{init no}} { # Sets default colors to highlight Tcl. # init - yes, if only variables should be initialized. fetchVars set Dark [::apave::obj csDarkEdit] set clrnams [::hl_tcl::hl_colorNames] set clrvals [::hl_tcl::hl_colors {} $Dark] foreach nam $clrnams val $clrvals { set al(ED,$nam) $val } set al(ED,Dark) $Dark if {!$init} {UpdateColors {}} }




Template_Tab [::alited::pref]pref, Top

Serves to layout "Template" tab.

Template_Tab

proc ::alited::pref::Template_Tab {} { # Serves to layout "Template" tab. return { {v_ - - 1 1} {fra v_ T 1 2 {-st nsew -cw 1}} {.labH - - 1 2 {-st w -pady 5 -padx 3} {-t "Enter %U, %u, %m, %w, %d, %t wildcards of templates:"}} {.labU .labH T 1 1 {-st w -pady 1 -padx 3} {-t "User name:"}} {.entU .labU L 1 1 {-st sw -pady 5} {-tvar alited::al(TPL,%U) -w 40}} {.labu .labU T 1 1 {-st w -pady 1 -padx 3} {-anc e -t "Login:"}} {.entu .labu L 1 1 {-st sw -pady 5} {-tvar alited::al(TPL,%u) -w 30}} {.labm .labu T 1 1 {-st w -pady 1 -padx 3} {-t "E-mail:"}} {.entm .labm L 1 1 {-st sw -pady 5} {-tvar alited::al(TPL,%m) -w 40}} {.labw .labm T 1 1 {-st w -pady 1 -padx 3} {-t "WWW:"}} {.entw .labw L 1 1 {-st sw -pady 5} {-tvar alited::al(TPL,%w) -w 40}} {.labd .labw T 1 1 {-st w -pady 1 -padx 3} {-t "Date format:"}} {.entd .labd L 1 1 {-st sw -pady 5} {-tvar alited::al(TPL,%d) -w 30}} {.labt .labd T 1 1 {-st w -pady 1 -padx 3} {-t "Time format:"}} {.entt .labt L 1 1 {-st sw -pady 5} {-tvar alited::al(TPL,%t) -w 30}} } }




TextIcons [::alited::pref]pref, Top

Returns a list of letters to be toolbar "icons".

TextIcons
Return value

Returns a list of letters to be toolbar "icons".


proc ::alited::pref::TextIcons {} { # Returns a list of letters to be toolbar "icons". return ABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%&*= }




Tkcon_Default [::alited::pref]pref, Top

Sets defaults for "Tkcon" tab.

Tkcon_Default

proc ::alited::pref::Tkcon_Default {} { # Sets defaults for "Tkcon" tab. fetchVars set al(tkcon,clrbg) #25292b set al(tkcon,clrblink) #929281 set al(tkcon,clrcursor) #FFFFFF set al(tkcon,clrdisabled) #999797 set al(tkcon,clrproc) #FF6600 set al(tkcon,clrvar) #602B06 set al(tkcon,clrprompt) #66FF10 set al(tkcon,clrstdin) #FFFFFF set al(tkcon,clrstdout) #CECECE set al(tkcon,clrstderr) #FB44C0 set al(tkcon,rows) 10 set al(tkcon,cols) 80 set al(tkcon,fsize) 13 set al(tkcon,geo) +300+100 set al(tkcon,topmost) 1 }




Tkcon_Tab [::alited::pref]pref, Top

Serves to layout "Tkcon" tab.

Tkcon_Tab

proc ::alited::pref::Tkcon_Tab {} { # Serves to layout "Tkcon" tab. if {![info exists alited::al(tkcon,clrbg)]} Tkcon_Default return { {v_ - - 1 1} {fra v_ T 1 1 {-st nsew -cw 1 -rw 1}} {fra.scf - - 1 1 {pack -fill both -expand 1} {-mode y}} {fra.scf.lfr - - 1 1 {pack -fill x} {-t Colors}} {.labbg - - 1 1 {-st w -pady 1 -padx 3} {-t "bg:"}} {.clrbg .labbg L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrbg) -w 20}} {.labblink .labbg T 1 1 {-st w -pady 1 -padx 3} {-t "blink:"}} {.clrblink .labblink L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrblink) -w 20}} {.labcursor .labblink T 1 1 {-st w -pady 1 -padx 3} {-t "cursor:"}} {.clrcursor .labcursor L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrcursor) -w 20}} {.labdisabled .labcursor T 1 1 {-st w -pady 1 -padx 3} {-t "disabled:"}} {.clrdisabled .labdisabled L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrdisabled) -w 20}} {.labproc .labdisabled T 1 1 {-st w -pady 1 -padx 3} {-t "proc:"}} {.clrproc .labproc L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrproc) -w 20}} {.labvar .labproc T 1 1 {-st w -pady 1 -padx 3} {-t "var:"}} {.clrvar .labvar L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrvar) -w 20}} {.labprompt .labvar T 1 1 {-st w -pady 1 -padx 3} {-t "prompt:"}} {.clrprompt .labprompt L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrprompt) -w 20}} {.labstdin .labprompt T 1 1 {-st w -pady 1 -padx 3} {-t "stdin:"}} {.clrstdin .labstdin L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrstdin) -w 20}} {.labstdout .labstdin T 1 1 {-st w -pady 1 -padx 3} {-t "stdout:"}} {.clrstdout .labstdout L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrstdout) -w 20}} {.labstderr .labstdout T 1 1 {-st w -pady 1 -padx 3} {-t "stderr:"}} {.clrstderr .labstderr L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,clrstderr) -w 20}} {fra.scf.v_ fra.scf.lfr T 1 1 {pack} {-h 10}} {fra.scf.lfr2 fra.scf.v_ T 1 1 {pack -fill x} {-t Options}} {.labRows - - 1 1 {-st w -pady 1 -padx 3} {-t "Rows:"}} {.spxRows .labRows L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,rows) -from 4 -to 40 -w 9}} {.labCols .labRows T 1 1 {-st w -pady 1 -padx 3} {-t "Columns:"}} {.spxCols .labCols L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,cols) -from 15 -to 150 -w 9}} {.labFsize .labCols T 1 1 {-st w -pady 1 -padx 3} {-t "Font size:"}} {.spxFS .labFsize L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,fsize) -from 8 -to 20 -w 9}} {.labGeo .labFsize T 1 1 {-st w -pady 1 -padx 3} {-t "Geometry:"}} {.entGeo .labGeo L 1 1 {-st sw -pady 1} {-tvar alited::al(tkcon,geo) -w 20}} {.labTopmost .labGeo T 1 1 {-st w -pady 1 -padx 3} {-t "Stay on top:"}} {.chbTopmost .labTopmost L 1 1 {-st sw -pady 1} {-var alited::al(tkcon,topmost)}} {fra.scf.but - - - - {pack -side left -pady 5} {-t Default -com alited::pref::Tkcon_Default -w 20}} {fra.scf.but2 - - - - {pack -side left -padx 5 -pady 5} {-t Test -com alited::tool::tkcon -w 20}} } }




Units_Default [::alited::pref]pref, Top

Sets the default settings of units.

Units_Default

proc ::alited::pref::Units_Default {} { # Sets the default settings of units. fetchVars set al(INI,LINES1) 10 set al(INI,LEAF) 0 set al(RE,branch) $al(RE,branchDEF) set al(RE,leaf) $al(RE,leafDEF) set al(RE,proc) $al(RE,procDEF) set al(RE,leaf2) $al(RE,leaf2DEF) set al(RE,proc2) $al(RE,proc2DEF) }




Units_Tab [::alited::pref]pref, Top

Serves to layout "Units" tab.

Units_Tab

proc ::alited::pref::Units_Tab {} { # Serves to layout "Units" tab. return { {v_ - - 1 1} {fra v_ T 1 1 {-st nsew -cw 1 -rw 1}} {fra.scf - - 1 1 {pack -fill both -expand 1} {-mode x}} {.labBr - - 1 1 {-st w -pady 1 -padx 3} {-t "Branch's regexp:"}} {.entBr .labBr L 1 1 {-st sw -pady 1} {-tvar alited::al(RE,branch) -w 70}} {.labPr .labBr T 1 1 {-st w -pady 1 -padx 3} {-t "Proc's regexp:"}} {.entPr .labPr L 1 1 {-st sw -pady 1} {-tvar alited::al(RE,proc) -w 70}} {.seh_0 .labPr T 1 2 {-pady 5}} {.labLf2 .seh_0 T 1 1 {-st w -pady 1 -padx 3} {-t "Check branch's regexp:"}} {.entLf2 .labLf2 L 1 1 {-st sw -pady 1} {-tvar alited::al(RE,leaf2) -w 70}} {.labPr2 .labLf2 T 1 1 {-st w -pady 1 -padx 3} {-t "Check proc's regexp:"}} {.entPr2 .labPr2 L 1 1 {-st sw -pady 1} {-tvar alited::al(RE,proc2) -w 70}} {.seh_1 .labPr2 T 1 2 {-pady 5}} {.labUself .seh_1 T 1 1 {-st w -pady 1 -padx 3} {-t "Use leaf's regexp:"}} {.chbUself .labUself L 1 1 {-st sw -pady 1} {-var alited::al(INI,LEAF) -onvalue yes -offvalue no -com alited::pref::CheckUseLeaf -afteridle alited::pref::CheckUseLeaf}} {.labLf .labUself T 1 1 {-st w -pady 1 -padx 3} {-t "Leaf's regexp:"}} {.EntLf .labLf L 1 1 {-st sw -pady 1} {-tvar alited::al(RE,leaf) -w 70}} {.seh_2 .labLf T 1 2 {-pady 5}} {.labUnt .seh_2 T 1 1 {-st w -pady 1 -padx 3} {-t "Untouched top lines:"}} {.spxUnt .labUnt L 1 1 {-st sw -pady 1} {-tvar alited::al(INI,LINES1) -from 2 -to 200 -w 9}} {.seh_3 .labUnt T 1 2 {-pady 5}} {.but .seh_3 T 1 1 {-st w} {-t Default -com alited::pref::Units_Default}} } }




UpdateColors [::alited::pref]pref, Top

Updates color labels at clicking "Default" button.

UpdateColors lng
Parameters
lng{} for Tcl, {2} for C/C++

proc ::alited::pref::UpdateColors {lng} { # Updates color labels at clicking "Default" button. # lng - {} for Tcl, {2} for C/C++ fetchVars set lab1 [$obDl2 LabCOM$lng] foreach nam {COM COMTK STR VAR CMN PROC OPT BRA} { set lab [string map [list labCOM labclr$nam] $lab1] set ent [string map [list labCOM entclr$nam] $lab1] $lab configure -background [$ent get] } }



::alited::projectTop


Commandsproject, Top




_create [::alited::project]project, Top

Creates and opens "Projects" dialogue.

_create

proc ::alited::project::_create {} { # Creates and opens "Projects" dialogue. namespace upvar ::alited al al obDl2 obDl2 variable win variable geo variable minsize variable prjlist variable oldTab variable ilast $obDl2 makeWindow $win "$al(MC,projects) :: $::alited::PRJDIR" $obDl2 paveWindow $win [MainFrame] $win.fraR.nbk.f1 [Tab1] $win.fraR.nbk.f2 [Tab2] set tree [$obDl2 TreePrj] $tree heading C1 -text $al(MC,projects) if {$oldTab ne ""} { $win.fraR.nbk select $oldTab } UpdateTree bind $tree <<TreeviewSelect>> "::alited::project::Select" bind $tree <Delete> "::alited::project::Delete" bind $tree <Double-Button-1> "::alited::project::Ok" bind $tree <Return> "::alited::project::Ok" if {$ilast>-1} {Select $ilast} if {$minsize eq ""} { ;# save default min.sizes after idle [list after 100 { set ::alited::project::minsize "-minsize {[winfo width $::alited::project::win] [winfo height $::alited::project::win]}" }] } bind [$obDl2 TexPrj] <FocusOut> "alited::project::SaveNotes" set res [$obDl2 showModal $win -geometry $geo {*}$minsize -onclose ::alited::project::Cancel -focus [$obDl2 TreePrj]] set oldTab [$win.fraR.nbk select] if {[llength $res] < 2} {set res ""} set geo [wm geometry $win] ;# save the new geometry of the dialogue destroy $win return $res }




_run [::alited::project]project, Top

Runs "Projects" dialogue.

_run

proc ::alited::project::_run {} { # Runs "Projects" dialogue. SaveSettings GetProjects set res [_create] return $res }




Add [::alited::project]project, Top

"Add project" button's handler.

Add

proc ::alited::project::Add {} { # "Add project" button's handler. namespace upvar ::alited al al obDl2 obDl2 variable prjlist variable prjinfo variable OPTS if {![ValidProject]} return set pname $al(prjname) if {[lsearch -exact $prjlist $pname]>-1} { focus [$obDl2 EntName] set msg [string map [list %n $pname] $al(MC,prjexists)] alited::Message2 $msg 4 return } if {![SaveCurrFileList $al(MC,prjadd) yes]} return set al(tabs) $al(tablist) set al(prjfile) [ProjectFileName $pname] set al(prjbeforerun) {} if {$al(PRJDEFAULT)} { # use project defaults from "Setup/Common/Projects" foreach opt $OPTS { catch {set al($opt) $al(DEFAULT,$opt)} } } alited::ini::SaveIni yes ;# to initialize ini-file foreach opt $OPTS { set prjinfo($pname,$opt) $al($opt) } PutProjectOpts $al(prjfile) $al(prjfile) GetProjects UpdateTree Select $prjinfo($pname,ID) alited::Message2 [string map [list %n $pname] $al(MC,prjnew)] }




Cancel [::alited::project]project, Top

'Cancel' button handler.

Cancel ?args?
Parameters
argspossible arguments

proc ::alited::project::Cancel {args} { # 'Cancel' button handler. # args - possible arguments namespace upvar ::alited obDl2 obDl2 variable win SaveData RestoreSettings $obDl2 res $win 0 }




Change [::alited::project]project, Top

"Change project" button's handler.

Change ?askappend? ?isel?
Parameters
askappendNot documented; optional, default yes
iselNot documented; optional, default -1

proc ::alited::project::Change {{askappend yes} {isel -1}} { # "Change project" button's handler. namespace upvar ::alited al al obDl2 obDl2 variable data variable prjlist variable prjinfo if {$isel==-1 && [set isel [Selected index]] eq ""} return if {![ValidProject]} return for {set i 0} {$i<[llength $prjlist]} {incr i} { if {$i!=$isel && [lindex $prjlist $i] eq $al(prjname)} { set msg [string map [list %n $al(prjname)] $al(MC,prjexists)] alited::Message2 $msg 4 return } } if {$askappend && ![SaveCurrFileList $al(MC,prjchg)]} return set oldprj [lindex $prjlist $isel] set newprj $al(prjname) catch {unset prjinfo($oldprj,tablist)} set prjinfo($newprj,tablist) $al(tablist) set oldname [ProjectFileName $oldprj] set prjlist [lreplace $prjlist $isel $isel $newprj] set fname [ProjectFileName $newprj] if {$newprj eq $data(prjname)} SaveSettings PutProjectOpts $fname $oldname GetProjects UpdateTree Select $prjinfo($newprj,ID) alited::Message2 [string map [list %n [lindex $prjlist $isel]] $al(MC,prjupd)] }




CheckProjectName [::alited::project]project, Top

Removes spec.characters from a project name (sort of normalizing it).

CheckProjectName

proc ::alited::project::CheckProjectName {} { # Removes spec.characters from a project name (sort of normalizing it). namespace upvar ::alited al al set oldname $al(prjname) set al(prjname) [string map [list * _ ? _ ~ _ . _ / _ \\ _ \{ _ \} _ \[ _ \] _ \t _ \n _ \r _ | _ < _ > _ & _ , _ : _ \; _ \" _ ' _ ` _] $al(prjname)] return [expr {$oldname eq $al(prjname)}] }




Delete [::alited::project]project, Top

"Delete project" button's handler.

Delete

proc ::alited::project::Delete {} { # "Delete project" button's handler. namespace upvar ::alited al al obDl2 obDl2 variable prjlist variable prjinfo variable win variable data if {[set isel [Selected index]] eq ""} return set geo "-geometry root=$win" set nametodel [lindex $prjlist $isel] if {$nametodel eq $data(prjname)} { alited::msg ok err $al(MC,prjcantdel) {*}$geo return } set msg [string map [list %n $nametodel] $al(MC,prjdelq)] if {![alited::msg yesno ques $msg NO {*}$geo]} { return } if {[catch {file delete [ProjectFileName $nametodel]} err]} { alited::msg ok err $err {*}$geo return } if {[set llen [llength $prjlist]] && $isel>=$llen} { set isel [incr llen -1] } GetProjects UpdateTree Select $isel alited::Message2 [string map [list %n $nametodel] $al(MC,prjrem)] }




GetOptVal [::alited::project]project, Top

Gets a name and a value from a line of form "name=value".

GetOptVal line
Parameters
linethe line

proc ::alited::project::GetOptVal {line} { # Gets a name and a value from a line of form "name=value". # line - the line if {[set i [string first = $line]]>-1} { return [list [string range $line 0 $i-1] [string range $line $i+1 end]] } return [list] }




GetProjectOpts [::alited::project]project, Top

Reads a project's settings from a project settings file.

GetProjectOpts fname
Parameters
fnamethe project settings file's name

proc ::alited::project::GetProjectOpts {fname} { # Reads a project's settings from a project settings file. # fname - the project settings file's name namespace upvar ::alited al al variable prjlist variable prjinfo variable OPTS variable data set pname [ProjectName $fname] # save project names to 'prjlist' variable to display it by treeview widget lappend prjlist $pname # save project files' settings in prjinfo array set filecont [::apave::readTextFile $fname] foreach opt $OPTS { catch {set prjinfo($pname,$opt) $al($opt)} ;#defaults } set prjinfo($pname,prjfile) $fname set prjinfo($pname,prjname) $pname set prjinfo($pname,prjdirign) ".git .bak" set prjinfo($pname,tablist) [list] if {[set currentprj [expr {$data(prjname) eq $pname}]]} { foreach tab [alited::bar::BAR listTab] { set tid [lindex $tab 0] lappend prjinfo($pname,tablist) [alited::bar::FileName $tid] } } foreach line [::apave::textsplit $filecont] { lassign [GetOptVal $line] opt val if {[lsearch $OPTS $opt]>-1} { set prjinfo($pname,$opt) [ProcEOL $val in] } elseif {$opt eq "tab" && !$currentprj} { lappend prjinfo($pname,tablist) $val } } set al(tablist) $prjinfo($pname,tablist) return $pname }




GetProjects [::alited::project]project, Top

Reads settings of all projects.

GetProjects

proc ::alited::project::GetProjects {} { # Reads settings of all projects. namespace upvar ::alited al al PRJEXT PRJEXT variable prjlist variable ilast set prjlist [list] set i [set ilast 0] foreach finfo [alited::tree::GetDirectoryContents $::alited::PRJDIR] { set fname [lindex $finfo 2] if {[file extension $fname] eq $PRJEXT} { if {[GetProjectOpts $fname] eq $al(prjname)} { set ilast $i } incr i } } }




Help [::alited::project]project, Top

'Help' button handler.

Help

proc ::alited::project::Help {} { # 'Help' button handler. variable win alited::Help $win }




MainFrame [::alited::project]project, Top

Creates a main frame of "Project" dialogue.

MainFrame

proc ::alited::project::MainFrame {} { # Creates a main frame of "Project" dialogue. namespace upvar ::alited al al obDl2 obDl2 variable win return { {fraTreePrj - - 10 1 {-st nswe -pady 4 -rw 1} {}} {.TreePrj - - - - {pack -side left -expand 1 -fill both} {-h 16 -show headings -columns {C1} -displaycolumns {C1}}} {.sbvPrjs .TreePrj L - - {pack -side left -fill both}} {fraR fraTreePrj L 10 1 {-st nsew -cw 1 -pady 4}} {fraR.Nbk - - - - {pack -side top -expand 1 -fill both} { f1 {-text {$al(MC,info)}} f2 {-text {$al(MC,prjOptions)}} -traverse yes -select f1 }} {fraB1 fraTreePrj T 1 1 {-st nsew} {}} {.buTad - - - - {pack -side left -anchor n} {-takefocus 0 -com ::alited::project::Add -tip {$alited::al(MC,prjadd)} -image alimg_add-big}} {.buTch - - - - {pack -side left} {-takefocus 0 -com ::alited::project::Change -tip {$alited::al(MC,prjchg)} -image alimg_change-big}} {.buTdel - - - - {pack -side left} {-takefocus 0 -com ::alited::project::Delete -tip {$alited::al(MC,prjdel)} -image alimg_delete-big}} {LabMess fraB1 L 1 1 {-st nsew -pady 0 -padx 3} {-style TLabelFS}} {fraB2 fraB1 T 1 2 {-st nsew} {-padding {5 5 5 5} -relief groove}} {.butHelp - - - - {pack -side left -anchor s -padx 2} {-t {$alited::al(MC,help)} -command ::alited::project::Help}} {.h_ - - - - {pack -side left -expand 1 -fill both -padx 8} {-w 50}} {.butOK - - - - {pack -side left -anchor s -padx 2} {-t {$alited::al(MC,select)} -command ::alited::project::Ok}} {.butCancel - - - - {pack -side left -anchor s} {-t Cancel -command ::alited::project::Cancel}} } }




Ok [::alited::project]project, Top

'OK' button handler.

Ok ?args?
Parameters
argspossible arguments

proc ::alited::project::Ok {args} { # 'OK' button handler. # args - possible arguments namespace upvar ::alited al al obDl2 obDl2 obPav obPav variable win variable prjlist variable prjinfo variable data if {[set isel [Selected index]] eq {} || ![ValidProject]} { focus [$obDl2 TreePrj] return } if {[set N [llength [alited::bar::BAR listFlag m]]]} { set msg [msgcat::mc "All modified files (%n) will be saved.\n\nDo you agree?"] set msg [string map [list %n $N] $msg] if {![alited::msg yesno ques $msg NO -geometry root=$win]} return } if {![alited::file::SaveAll]} { $obDl2 res $win 0 return } if {[set N [llength [alited::bar::BAR cget -select]]]} { set msg [msgcat::mc "All selected files (%n) will remain open\nin the project you are switching to.\n\nDo you agree?"] set msg [string map [list %n $N] $msg] if {![alited::msg yesno ques $msg NO -geometry root=$win]} return } set pname [string trim $al(prjname)] set fname [ProjectFileName $pname] RestoreSettings alited::ini::SaveIni alited::file::CloseAll 1 -skipsel ;# the selected tabs aren't closed set selfiles [list] ;# -> get their file names to reopen afterwards foreach tid [alited::bar::BAR listFlag s] { lappend selfiles [alited::bar::FileName $tid] } alited::file::CloseAll 1 ;# close all tabs set al(prjname) $pname set al(prjfile) $fname alited::ini::ReadIni $fname alited::bar::FillBar [$obPav BtsBar] for {set i [llength $selfiles]} {$i} {} { ;# reopen selected files of previous project incr i -1 set fname [lindex $selfiles $i] if {[alited::bar::FileTID $fname] eq {}} { alited::file::OpenFile $fname yes } } set TID [lindex [alited::bar::BAR listTab] $al(curtab) 0] catch {alited::bar::BAR $TID show} alited::main::UpdateProjectInfo alited::ini::GetUserDirs $obDl2 res $win 1 alited::file::MakeThemHighlighted after idle alited::main::ShowText return }




ProcEOL [::alited::project]project, Top

Transforms \n to "EOL chars" and vise versa.

ProcEOL val mode
Parameters
valstring to transform
modeif "in", gets \n-value; if "out", gets EOL-value.

proc ::alited::project::ProcEOL {val mode} { # Transforms \n to "EOL chars" and vise versa. # val - string to transform # mode - if "in", gets \n-value; if "out", gets EOL-value. if {$mode eq {in}} { return [string map [list $::alited::EOL \n] $val] } else { return [string map [list \n $::alited::EOL] $val] } }




ProjectFileName [::alited::project]project, Top

Gets a project file name from a project's name.

ProjectFileName name
Parameters
nameNot documented.

proc ::alited::project::ProjectFileName {name} { # Gets a project file name from a project's name. namespace upvar ::alited al al PRJDIR PRJDIR PRJEXT PRJEXT set name [ProjectName [string trim $name]] return [file normalize [file join $PRJDIR "$name$PRJEXT"]] }




ProjectName [::alited::project]project, Top

Gets a project name from its file name.

ProjectName fname
Parameters
fnameNot documented.

proc ::alited::project::ProjectName {fname} { # Gets a project name from its file name. return [file rootname [file tail $fname]] }




PutProjectOpts [::alited::project]project, Top

Writes a project's settings to a project settings file.

PutProjectOpts fname oldname
Parameters
fnamethe project settings file's name
oldnameold name of the project file

proc ::alited::project::PutProjectOpts {fname oldname} { # Writes a project's settings to a project settings file. # fname - the project settings file's name # oldname - old name of the project file namespace upvar ::alited al al obDl2 obDl2 variable prjinfo variable OPTS set filecont [::apave::readTextFile $oldname] set newcont {} foreach line [::apave::textsplit $filecont] { lassign [GetOptVal $line] opt val if {$line eq {[Tabs]}} { foreach tab $al(tablist) { append line \n "tab=$tab" } } elseif {$opt in [list tab {*}$OPTS]} { continue } elseif {$opt in {curtab}} { # } elseif {$line eq {[Options]}} { foreach opt $OPTS { if {$opt ni {prjname tablist}} { set val [set alited::al($opt)] append line \n $opt= $val set prjinfo($al(prjname),$opt) [ProcEOL $val in] } } } append newcont $line \n } ::apave::writeTextFile $fname newcont if {$oldname ne $fname} {catch {file delete $oldname}} }




RestoreSettings [::alited::project]project, Top

Restores project settings from a data array.

RestoreSettings

proc ::alited::project::RestoreSettings {} { # Restores project settings from a data array. namespace upvar ::alited al al variable data variable OPTS foreach v $OPTS { set al($v) $data($v) } set al(prjfile) $data(prjfile) TabFileInfo }




SaveCurrFileList [::alited::project]project, Top

Actions with a file list of project.

SaveCurrFileList title ?isnew?
Parameters
titletitle of the message box "What to do"
isnewyes, if it's a new project to be added; optional, default no
Description

A result of action is saved to al(tablist).

Return value

Returns yes, if an action is chosen, no - if canceled.


proc ::alited::project::SaveCurrFileList {title {isnew no}} { # Actions with a file list of project. # title - title of the message box "What to do" # isnew - yes, if it's a new project to be added # A result of action is saved to al(tablist). # Returns yes, if an action is chosen, no - if canceled. namespace upvar ::alited al al obDl3 obDl3 variable win set asks [list $al(MC,prjaddfl) add $al(MC,prjsubstfl) change $al(MC,prjdelfl) delete $al(MC,prjnochfl) file Cancel cancel] set msg [string map [list %n [string toupper $title]] $al(MC,prjgoing)] append msg \n\n $al(MC,prjsavfl) set ans [$obDl3 misc ques $title $msg $asks file] switch $ans { "delete" { set al(tablist) [list] TabFileInfo } "add" - "change" { if {$ans eq "change" || $isnew} { set al(tablist) [list] } lassign [alited::bar::GetBarState] TIDcur - wtxt foreach tab [alited::bar::BAR listTab] { set TID [lindex $tab 0] if {$TID eq $TIDcur} { set pos [$wtxt index insert] } else { set pos [alited::bar::GetTabState $TID --pos] } set fname [set fn [alited::bar::FileName $TID]] append fn \t $pos if {$fname ne $al(MC,nofile) && [lsearch -exact $al(tablist) $fn]<0} { lappend al(tablist) $fn } } TabFileInfo } "file" { if {$isnew} { set al(tablist) [list] TabFileInfo } } default { return no } } return yes }




SaveData [::alited::project]project, Top

Saves some data.

SaveData

proc ::alited::project::SaveData {} { # Saves some data. variable ilast set ilast [Selected index no] }




SaveNotes [::alited::project]project, Top

Saves a file of notes.

SaveNotes

proc ::alited::project::SaveNotes {} { # Saves a file of notes. namespace upvar ::alited obDl2 obDl2 variable fnotes if {$fnotes ne {}} { set fcont [[$obDl2 TexPrj] get 1.0 {end -1c}] ::apave::writeTextFile $fnotes fcont } }




SaveSettings [::alited::project]project, Top

Saves project settings to a data array.

SaveSettings

proc ::alited::project::SaveSettings {} { # Saves project settings to a data array. namespace upvar ::alited al al variable data variable OPTS foreach v $OPTS { set data($v) $al($v) } set data(prjfile) $al(prjfile) }




Select [::alited::project]project, Top

Handles a selection in a list of projects.

Select ?item?
Parameters
itemNot documented; optional, default ""

proc ::alited::project::Select {{item {}}} { # Handles a selection in a list of projects. namespace upvar ::alited al al obDl2 obDl2 variable prjlist variable prjinfo variable OPTS variable fnotes if {$item eq {}} {set item [Selected item no]} if {$item ne {}} { set tree [$obDl2 TreePrj] if {[string is digit $item]} { ;# the item is an index if {$item<0 || $item>=[llength $prjlist]} return set prj [lindex $prjlist $item] set item $prjinfo($prj,ID) } elseif {![$tree exists $item]} { return } set isel [$tree index $item] set prj [lindex $prjlist $isel] set fnotes [file join $::alited::PRJDIR $prj-notes.txt] set wtxt [$obDl2 TexPrj] $wtxt delete 1.0 end if {[file exists $fnotes]} { $wtxt insert end [::apave::readTextFile $fnotes] } foreach opt $OPTS { set al($opt) $prjinfo($prj,$opt) } set al(tablist) $prjinfo($prj,tablist) TabFileInfo if {[$tree selection] ne $item} { $tree selection set $item } $tree see $item } }




Selected [::alited::project]project, Top

Gets a currently selected project's index.

Selected what ?domsg?
Parameters
whatif "index", selected item's index is returned
domsgif "no", no message displayed if there is no selected project; optional, default yes

proc ::alited::project::Selected {what {domsg yes}} { # Gets a currently selected project's index. # what - if "index", selected item's index is returned # domsg - if "no", no message displayed if there is no selected project namespace upvar ::alited al al obDl2 obDl2 variable prjlist set tree [$obDl2 TreePrj] if {[set isel [$tree selection]] eq {} && [set isel [$tree focus]] eq "" && $domsg} { alited::Message2 $al(MC,prjsel) 4 } if {$isel ne {} && $what eq {index}} { set isel [$tree index $isel] } return $isel }




Tab1 [::alited::project]project, Top

Creates a main tab of "Project".

Tab1

proc ::alited::project::Tab1 {} { # Creates a main tab of "Project". return { {v_ - - 1 1} {fra1 v_ T 1 2 {-st nsew -cw 1}} {.labName - - 1 1 {-st w -pady 1 -padx 3} {-t {$al(MC,prjName)}}} {.EntName .labName L 1 1 {-st sw -pady 5} {-tvar alited::al(prjname) -w 50}} {.labDir .labName T 1 1 {-st w -pady 8 -padx 3} {-t "Root directory:"}} {.Dir .labDir L 1 9 {-st sw -pady 5 -padx 3} {-tvar alited::al(prjroot) -w 50}} {.labIgn .labDir T 1 1 {-st w -pady 8 -padx 3} {-t "Skip subdirectories:"}} {.entIgn .labIgn L 1 9 {-st sw -pady 5 -padx 3} {-tvar alited::al(prjdirign) -w 50}} {lab fra1 T 1 2 {-st w -pady 4 -padx 3} {-t "Notes:"}} {fra2 lab T 1 2 {-st nsew -rw 1 -cw 1}} {.TexPrj - - - - {pack -side left -expand 1 -fill both -padx 3} {-h 20 -w 40 -wrap word -tabnext $alited::project::win.fraB2.butHelp -tip {$alited::al(MC,notes)}}} {.sbv .TexPrj L - - {pack -side left}} } }




Tab2 [::alited::project]project, Top

Creates Options tab of "Project".

Tab2

proc ::alited::project::Tab2 {} { # Creates Options tab of "Project". return { {v_ - - 1 10} {fra2 v_ T 1 2 {-st nsew -cw 1}} {.labEOL - - 1 1 {-st w -pady 1 -padx 3} {-t "End of line:"}} {.cbxEOL .labEOL L 1 1 {-st sw -pady 3 -padx 3} {-tvar alited::al(prjEOL) -values {{} LF CR CRLF} -w 5 -state readonly}} {.labIndent .labEOL T 1 1 {-st w -pady 1 -padx 3} {-t "Indentation:"}} {.spxIndent .labIndent L 1 1 {-st sw -pady 3 -padx 3} {-tvar alited::al(prjindent) -w 9 -from 2 -to 8 -justify center}} {.labRedunit .labIndent T 1 1 {-st w -pady 1 -padx 3} {-t "Unit lines per 1 red bar:"}} {.spxRedunit .labRedunit L 1 1 {-st sw -pady 3 -padx 3} {-tvar alited::al(prjredunit) -w 9 -from 10 -to 100 -justify center}} {.labMult .labRedunit T 1 1 {-st w -pady 1 -padx 3} {-t "Multi-line strings:" -tip {$alited::al(MC,notrecomm)}}} {.chbMult .labMult L 1 1 {-st sw -pady 3 -padx 3} {-var alited::al(prjmultiline) -tip {$alited::al(MC,notrecomm)}}} {.labFlist .labMult T 1 1 {-pady 3 -padx 3} {-t "List of files:"}} {fraFlist .labFlist T 1 2 {-st nswe -padx 3 -cw 1 -rw 1}} {.LbxFlist - - - - {pack -side left -fill both -expand 1}} {.sbvFlist .lbxFlist L - - {pack -side left}} } }




TabFileInfo [::alited::project]project, Top

Fills a listbox with a list of project files.

TabFileInfo

proc ::alited::project::TabFileInfo {} { # Fills a listbox with a list of project files. namespace upvar ::alited al al obDl2 obDl2 set lbx [$obDl2 LbxFlist] $lbx delete 0 end foreach tab $al(tablist) { set fname [lindex [split $tab \t] 0] $lbx insert end $fname } }




UpdateTree [::alited::project]project, Top

Fills a list of projects.

UpdateTree

proc ::alited::project::UpdateTree {} { # Fills a list of projects. namespace upvar ::alited al al obDl2 obDl2 variable prjlist variable prjinfo set tree [$obDl2 TreePrj] $tree delete [$tree children {}] foreach prj $prjlist { set prjinfo($prj,ID) [$tree insert {} end -values [list $prj]] } }




ValidProject [::alited::project]project, Top

Checks if a project's options are valid.

ValidProject

proc ::alited::project::ValidProject {} { # Checks if a project's options are valid. namespace upvar ::alited al al obDl2 obDl2 variable win if {[string trim $al(prjname)] eq {} || ![CheckProjectName]} { bell focus [$obDl2 EntName] return no } set al(prjroot) [file nativename $al(prjroot)] if {![file exists $al(prjroot)]} { set msg [string map [list %d $al(prjroot)] $al(makeroot)] if {![alited::msg yesno ques $msg NO -geometry root=$win]} { return no } file mkdir $al(prjroot) } if {$al(prjindent)<2 || $al(prjindent)>8} {set al(prjindent) 2} if {$al(prjredunit)<10 || $al(prjredunit)>100} {set al(prjredunit) 20} set msg [string map [list %d $al(prjroot)] $al(checkroot)] alited::Message2 $msg 5 if {[llength [alited::tree::GetDirectoryContents $al(prjroot)]] >= $al(MAXFILES)} { set msg [string map [list %n $al(MAXFILES)] $al(badroot)] alited::Message2 $msg 4 set res no } else { alited::Message2 {} 5 set res yes } return $res }



::alited::toolTop


Commandstool, Top




_close [::alited::tool]tool, Top

Closes e_menu (being an internal procedure) by force.

_close ?fname?
Parameters
fnameNot documented; optional, default ""

proc ::alited::tool::_close {{fname {}}} { # Closes e_menu (being an internal procedure) by force. catch {destroy .em} }




_run [::alited::tool]tool, Top

Runs e_menu's item of menu.mnu.

_run ?what?
Parameters
whatthe item (by default, "Run me"); optional, default ""

proc ::alited::tool::_run {{what {}}} { # Runs e_menu's item of menu.mnu. # what - the item (by default, "Run me") namespace upvar ::alited al al if {[winfo exists .em] && [winfo ismapped .em]} { bell } set opts "EX=$what" if {$what eq {}} { # it is 'Run me' e_menu item set fpid [file join $al(EM,menudir) .pid~] if {!$al(DEBUG) && [file exists $fpid]} { catch { set pid [::apave::readTextFile $fpid] exec kill -s SIGINT $pid } } set opts {EX=1 PI=1} BeforeRun } e_menu {*}$opts }




BeforeRun [::alited::tool]tool, Top

Runs a command before running "Tools/Run"

BeforeRun

proc ::alited::tool::BeforeRun {} { # Runs a command before running "Tools/Run" namespace upvar ::alited al al set runs [string map [list $alited::EOL \n] $al(prjbeforerun)] foreach run [split $runs \n] { if {[set run [string trim $run]] ne {}} { catch {exec {*}$run} e alited::info::Put "$al(MC,beforerun): \"$run\" -> $e" } } }




BeforeRunDlg [::alited::tool]tool, Top

Dialogue to enter a command before running "Tools/Run"

BeforeRunDlg

proc ::alited::tool::BeforeRunDlg {} { # Dialogue to enter a command before running "Tools/Run" namespace upvar ::alited al al obDl2 obDl2 set head [msgcat::mc "\n Enter commands to be run before running a current file with \"Tools/Run\".\n It can be necessary for a specific project. Something like an initialization before \"Run\". \n"] set run [string map [list $alited::EOL \n] $al(prjbeforerun)] lassign [$obDl2 input {} $al(MC,beforerun) [list tex "{[msgcat::mc Commands:]} {} {-w 60 -h 8}" "$run" ] -head $head] res run if {$res} { set al(prjbeforerun) [string map [list \n $alited::EOL] [string trim $run]] } }




ColorPicker [::alited::tool]tool, Top

Calls a color picker passing to it and getting from it a color.

ColorPicker

proc ::alited::tool::ColorPicker {} { # Calls a color picker passing to it and getting from it a color. lassign [alited::find::GetWordOfText 2] color pos1 pos2 if {$color ne {}} { set alited::al(chosencolor) $color } set res [::apave::obj chooser colorChooser alited::al(chosencolor)] if {$res ne {}} { set alited::al(chosencolor) $res InsertInText $res $pos1 $pos2 } }




CtrlC [::alited::tool]tool, Top

CtrlC

proc ::alited::tool::CtrlC {} { catch {event generate [alited::main::CurrentWTXT] <<Copy>>} }




CtrlV [::alited::tool]tool, Top

CtrlV

proc ::alited::tool::CtrlV {} { catch {event generate [alited::main::CurrentWTXT] <<Paste>>} }




CtrlX [::alited::tool]tool, Top

CtrlX

proc ::alited::tool::CtrlX {} { catch {event generate [alited::main::CurrentWTXT] <<Cut>>} }




DatePicker [::alited::tool]tool, Top

Calls a calendar to pick a date.

DatePicker

proc ::alited::tool::DatePicker {} { # Calls a calendar to pick a date. namespace upvar ::alited al al lassign [alited::find::GetWordOfText 2] date pos1 pos2 if {$date ne {} && ![catch {clock scan $date -format $al(TPL,%d)}]} { set al(klnddate) $date } elseif {![info exists al(klnddate)]} { set al(klnddate) [clock format [clock seconds] -format $al(TPL,%d)] } set res [::apave::obj chooser dateChooser alited::al(klnddate) -parent $al(WIN) -dateformat $al(TPL,%d)] if {$res ne {}} { set al(klnddate) $res InsertInText $res $pos1 $pos2 } }




e_menu [::alited::tool]tool, Top

Runs e_menu.

e_menu ?args?
Parameters
argsarguments of e_menu
Description

The e_menu is run as an external application or an internal procedure, depending on e_menu's preferences.


proc ::alited::tool::e_menu {args} { # Runs e_menu. # args - arguments of e_menu # The e_menu is run as an external application or an internal procedure, # depending on e_menu's preferences. namespace upvar ::alited al al if {{ex=Help} ni $args} { EM_SaveFiles if {![is_submenu $args]} { append args " g=" ;# should be last, to override previous settings } } if {{m=menu.mnu} in $args && {ex=d} in $args && $al(BACKUP) ne {}} { # Differences of a file & its backup: get the backup's name set TID [alited::bar::CurrentTabID] lassign [alited::unit::BackupDirFileNames $TID] dir fname fname2 #set fname2 [alited::unit::BackupFileName $fname2 0] append args " \"BF=$fname2\"" ;# version before 1st change } if {$alited::al(EM,exec)} { e_menu1 $args } else { e_menu2 $args } }




e_menu1 [::alited::tool]tool, Top

Runs e_menu.

e_menu1 opts
Parameters
optsoptions of e_menu
Description

The e_menu is run as an external application.


proc ::alited::tool::e_menu1 {opts} { # Runs e_menu. # opts - options of e_menu # The e_menu is run as an external application. exec tclsh [file join $::e_menu_dir e_menu.tcl] {*}[EM_Options $opts] c=$alited::al(EM,CS) & }




e_menu2 [::alited::tool]tool, Top

Runs e_menu.

e_menu2 opts
Parameters
optsoptions of e_menu
Description

The e_menu is run as an internal procedure.


proc ::alited::tool::e_menu2 {opts} { # Runs e_menu. # opts - options of e_menu # The e_menu is run as an internal procedure. if {![info exists ::em::geometry]} { source [file join $::e_menu_dir e_menu.tcl] } set options [EM_Options $opts] ::em::main -prior 1 -modal 0 -remain 0 -noCS 1 {*}$options if {[is_submenu $options]} { set alited::al(EM,geometry) $::em::geometry } }




EM_AllStructure [::alited::tool]tool, Top

Gets all items of all menus.

EM_AllStructure mnu
Parameters
mnua root menu's file name

proc ::alited::tool::EM_AllStructure {mnu} { # Gets all items of all menus. # mnu - a root menu's file name set alited::al(EM_STRUCTURE) [list] EM_AllStructure1 $mnu 0 return $alited::al(EM_STRUCTURE) }




EM_AllStructure1 [::alited::tool]tool, Top

Gets recursively all items of all menus.

EM_AllStructure1 mnu lev
Parameters
mnua current menu's file name
leva current level of menu

proc ::alited::tool::EM_AllStructure1 {mnu lev} { # Gets recursively all items of all menus. # mnu - a current menu's file name # lev - a current level of menu foreach mit [EM_Structure $mnu] { incr i lassign $mit mnu item h if {[string match {M-*} $item]} { if {[lsearch -exact -index end $alited::al(EM_STRUCTURE) $item]>-1} { continue ;# to avoid infinite cycle } set lev [EM_AllStructure1 [string range $item 2 end] [incr lev]] } else { lappend alited::al(EM_STRUCTURE) [list $lev $mnu $h[EM_HotKey $i] $item] } } return [incr lev -1] }




EM_command [::alited::tool]tool, Top

Gets e_menu command.

EM_command im
Parameters
imindex of the command in em_inf array

proc ::alited::tool::EM_command {im} { # Gets e_menu command. # im - index of the command in em_inf array namespace upvar ::alited::pref em_inf em_inf lassign $em_inf($im) mnu idx item if {$idx eq {-} || [regexp {^[^[:blank:].]+[.]mnu: } $item]} { # open a menu set mnu [string range $item 0 [string first : $item]-1] set ex {ex= o=0} } else { # call a command set ex "ex=[alited::tool::EM_HotKey $idx]" } return "alited::tool::e_menu \"m=$mnu\" $ex" }




EM_dir [::alited::tool]tool, Top

Returns a directory of e_menu's menus.

EM_dir
Return value

Returns a directory of e_menu's menus.


proc ::alited::tool::EM_dir {} { # Returns a directory of e_menu's menus. namespace upvar ::alited al al if {$al(EM,menudir) eq {}} { return $::e_menu_dir } return [file dirname $al(EM,menudir)] }




EM_HotKey [::alited::tool]tool, Top

Returns e_menu's hotkeys which numerate menu items.

EM_HotKey idx
Parameters
idxNot documented.
Return value

Returns e_menu's hotkeys which numerate menu items.


proc ::alited::tool::EM_HotKey {idx} { # Returns e_menu's hotkeys which numerate menu items. set hk {0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,./} return [string index $hk $idx] }




EM_Options [::alited::tool]tool, Top

Returns e_menu's general options.

EM_Options opts
Parameters
optsNot documented.
Return value

Returns e_menu's general options.


proc ::alited::tool::EM_Options {opts} { # Returns e_menu's general options. namespace upvar ::alited al al set sel [alited::find::GetWordOfText] set f [alited::bar::FileName] set d [file dirname $f] # get a list of selected tabs (i.e. their file names): # it's used as %ls wildcard in grep.mnu ("SEARCH EXACT LS=") set tabs [alited::bar::BAR listFlag s] if {[llength $tabs]>1} { foreach tab $tabs { append ls [alited::bar::FileName $tab] " " } set ls "\"ls=$ls\"" } else { set ls "ls=" } if {$al(EM,DiffTool) ne {}} {append ls " DF=$al(EM,DiffTool)"} set l [[alited::main::CurrentWTXT] index insert] set l [expr {int($l)}] return [list "md=$al(EM,menudir)" "m=$al(EM,menu)" "f=$f" "d=$d" "l=$l" "PD=$al(EM,PD=)" "pd=$al(prjroot)" "h=$al(EM,h=)" "tt=$al(EM,tt=)" "s=$sel" o=-1 om=0 g=$al(EM,geometry) {*}$ls {*}$opts] }




EM_SaveFiles [::alited::tool]tool, Top

Saves all files before running e_menu, if this mode is set in "Preferences".

EM_SaveFiles

proc ::alited::tool::EM_SaveFiles {} { # Saves all files before running e_menu, if this mode is set in "Preferences". namespace upvar ::alited al al if {$al(EM,save) in {All yes}} { alited::file::SaveAll } elseif {$al(EM,save) eq {Current}} { if {[alited::file::IsModified]} { alited::file::SaveFile } } }




EM_Structure [::alited::tool]tool, Top

Gets a menu's items.

EM_Structure mnu
Parameters
mnuthe menu's file name

proc ::alited::tool::EM_Structure {mnu} { # Gets a menu's items. # mnu - the menu's file name namespace upvar ::alited al al set mnu [string trim $mnu "\" "] set fname [file join [EM_dir] menus [file tail $mnu]] if {[catch {set fcont [::apave::readTextFile $fname {} 1]}]} { return [list] } set res [list] set prname {} set mmarks [list S: R: M: S/ R/ M/ SE: RE: ME: SE/ RE/ ME/ SW: RW: MW: SW/ RW/ MW/ I:] set ismenu yes set ishidden [set isoptions no] foreach line [::apave::textsplit $fcont] { set line [string trimleft $line] switch $line { {[MENU]} { set ismenu yes set ishidden [set isoptions no] continue } {[HIDDEN]} { set ishidden yes set ismenu [set isoptions no] continue } {[OPTIONS]} { set isoptions yes set ismenu [set ishidden no] } } if {$isoptions} continue foreach mark $mmarks { if {[string match "${mark}*${mark}*" $line]} { set i1 [string length $mark] set i2 [string first $mark $line 2] set typ [string index $mark 0] if {$typ eq {M}} { set line [string range $line $i2 end] lassign [regexp -inline {.+m=([^[:blank:]]+)} $line] -> itemname } else { set itemname [string trim [string range $line $i1 $i2-1]] } if {$itemname ni {{} -} && $itemname ne $prname} { set prname $itemname if {$ishidden} {set h h} {set h {}} lappend res [list $mnu "$typ-$itemname" $h] } } } } return $res }




Help [::alited::tool]tool, Top

Calls a help on alited.

Help

proc ::alited::tool::Help {} { # Calls a help on alited. _run Help }




InsertInText [::alited::tool]tool, Top

Insert a string into a text possibly instead of its selection.

InsertInText str ?pos1? ?pos2?
Parameters
strthe string
pos1starting position in a current line; optional, default ""
pos2ending position in a current line; optional, default ""

proc ::alited::tool::InsertInText {str {pos1 {}} {pos2 {}}} { # Insert a string into a text possibly instead of its selection. # str - the string # pos1 - starting position in a current line # pos2 - ending position in a current line set wtxt [alited::main::CurrentWTXT] if {$pos1 eq {}} { lassign [$wtxt tag ranges sel] pos1 pos2 } else { set line [expr {int([$wtxt index insert])}] set prevch [$wtxt get $line.[expr {$pos1-1}] $line.$pos1] if {$prevch eq [string index $str 0]} { incr pos1 -1 } set pos1 $line.$pos1 set pos2 $line.[incr pos2] } if {$pos1 ne {}} { $wtxt delete $pos1 $pos2 } $wtxt insert [$wtxt index insert] $str }




is_submenu [::alited::tool]tool, Top

Checks if e_menu's arguments are for submenu

is_submenu opts
Parameters
optse_menu's arguments

proc ::alited::tool::is_submenu {opts} { # Checks if e_menu's arguments are for submenu # opts - e_menu's arguments return [expr {[lsearch -glob -nocase $opts EX=*] == -1}] }




Loupe [::alited::tool]tool, Top

Calls a screen loupe.

Loupe

proc ::alited::tool::Loupe {} { # Calls a screen loupe. exec tclsh [file join $::alited::PAVEDIR pickers color aloupe aloupe.tcl] & }




PopupBar [::alited::tool]tool, Top

Opens a popup menu in the tool bar, to enter e_menu's preferences.

PopupBar X Y
Parameters
Xx-coordinate of clicking on the tool bar
Yy-coordinate of clicking on the tool bar

proc ::alited::tool::PopupBar {X Y} { # Opens a popup menu in the tool bar, to enter e_menu's preferences. # X - x-coordinate of clicking on the tool bar # Y - y-coordinate of clicking on the tool bar namespace upvar ::alited al al obPav obPav set popm $al(WIN).popupBar catch {destroy $popm} menu $popm -tearoff 0 $popm add command -label [msgcat::mc {Open bar/menu settings}] -command "alited::pref::_run Emenu_Tab" $obPav themePopup $popm tk_popup $popm $X $Y }




Redo [::alited::tool]tool, Top

Redo

proc ::alited::tool::Redo {} { catch {event generate [alited::main::CurrentWTXT] <<Redo>>} }




tkcon [::alited::tool]tool, Top

Calls Tkcon application.

tkcon

proc ::alited::tool::tkcon {} { # Calls Tkcon application. namespace upvar ::alited al al foreach opt [array names al tkcon,clr*] { lappend opts -color-[string range $opt 9 end] $al($opt) } foreach opt {rows cols fsize geo topmost} { lappend opts -apl-$opt $al(tkcon,$opt) } exec tclsh [file join $::alited::LIBDIR util tkcon.tcl] {*}$opts & }




ToolButName [::alited::tool]tool, Top

Helper procedure to get a name of toolbar button.

ToolButName img
Parameters
imgname of icon

proc ::alited::tool::ToolButName {img} { # Helper procedure to get a name of toolbar button. # img - name of icon namespace upvar ::alited obPav obPav return [$obPav ToolTop].buT_alimg_$img-big }




Undo [::alited::tool]tool, Top

Undo

proc ::alited::tool::Undo {} { catch {event generate [alited::main::CurrentWTXT] <<Undo>>} }



::alited::treeTop


Commandstree, Top




AddItem [::alited::tree]tree, Top

Adds a new item to the tree.

AddItem ?ID?
Parameters
IDan item's ID where the new item will be added (for the file tree); optional, default ""

proc ::alited::tree::AddItem {{ID {}}} { # Adds a new item to the tree. # ID - an item's ID where the new item will be added (for the file tree). namespace upvar ::alited al al if {$al(TREE,isunits)} { alited::unit::Add } else { alited::file::Add $ID } }




AddTags [::alited::tree]tree, Top

Creates tags for the tree.

AddTags wtree
Parameters
wtreethe tree's path

proc ::alited::tree::AddTags {wtree} { # Creates tags for the tree. # wtree - the tree's path namespace upvar ::alited al al lassign [::hl_tcl::hl_colors {-AddTags} [::apave::obj csDarkEdit]] - fgred fgbr set fontN "-font $alited::al(FONT,defsmall)" append fontB $fontN " -foreground $fgred" $wtree tag configure tagNorm {*}$fontN $wtree tag configure tagBold {*}$fontB $wtree tag configure tagBranch -foreground $fgbr }




AddToDirContents [::alited::tree]tree, Top

Adds an item to a list of directory's contents.

AddToDirContents lev isfile fname iroot
Parameters
levlevel in the directory hierarchy
isfilea flag "file" (if yes) or "directory" (if no)
fnamea file name to be added
irootindex of the directory's parent or -1

proc ::alited::tree::AddToDirContents {lev isfile fname iroot} { # Adds an item to a list of directory's contents. # lev - level in the directory hierarchy # isfile - a flag "file" (if yes) or "directory" (if no) # fname - a file name to be added # iroot - index of the directory's parent or -1 namespace upvar ::alited al al set dllen [llength $al(_dirtree)] if {$dllen < $al(MAXFILES)} { lappend al(_dirtree) [list $lev $isfile $fname 0 $iroot] if {$iroot>-1} { lassign [lindex $al(_dirtree) $iroot] lev isfile fname fcount sroot set al(_dirtree) [lreplace $al(_dirtree) $iroot $iroot [list $lev $isfile $fname [incr fcount] $sroot]] } } return $dllen }




AdjustWidth [::alited::tree]tree, Top

Fixes a problem with the tree scrollbar's width at resizing the panes. The problem occurs if Frame's width is less than Tree's + Scrollbar's, as then the scrollbar is squeezed. Thus the Tree's width should be adjusted. The restart of alited will fully repair this.

AdjustWidth

proc ::alited::tree::AdjustWidth {} { # Fixes a problem with the tree scrollbar's width at resizing the panes. # The problem occurs if Frame's width is less than Tree's + Scrollbar's, as # then the scrollbar is squeezed. Thus the Tree's width should be adjusted. # The restart of alited will fully repair this. namespace upvar ::alited al al obPav obPav set wpf [winfo width [$obPav FraTree]] set ws1 [winfo width [$obPav SbvTree]] set ws2 [winfo width [$obPav SbvFavor]] set w2 [[$obPav Tree] column #1 -width] [$obPav Tree] column #0 -width [expr {$wpf-$w2-$ws2-4}] }




ButtonMotion [::alited::tree]tree, Top

Starts moving an item of the tree.

ButtonMotion but x y X Y
Parameters
butmouse button
xx-coordinate to identify an item
yy-coordinate to identify an item
Xx-coordinate of the click
Yx-coordinate of the click

proc ::alited::tree::ButtonMotion {but x y X Y} { # Starts moving an item of the tree. # but - mouse button # x - x-coordinate to identify an item # y - y-coordinate to identify an item # X - x-coordinate of the click # Y - x-coordinate of the click namespace upvar ::alited al al obPav obPav if {![info exists al(movWin)] || $al(movWin) eq {}} { alited::tree::Tooltip $x $y $X $Y return } set wtree [$obPav Tree] # dragging the tab if {![winfo exists $al(movWin)]} { # make the tab's replica to be dragged toplevel $al(movWin) if {$::tcl_platform(platform) eq {windows}} { wm attributes $al(movWin) -alpha 0.0 } else { wm withdraw $al(movWin) } if {[tk windowingsystem] eq {aqua}} { ::tk::unsupported::MacWindowStyle style $al(movWin) help none } else { wm overrideredirect $al(movWin) 1 } label $al(movWin).label -text [$wtree item $al(movID) -text] -relief solid -foreground black -background #7eeeee pack $al(movWin).label -expand 1 -fill both -ipadx 1 } set ID [$wtree identify item $x $y] wm geometry $al(movWin) +[expr {$X+10}]+[expr {$Y+10}] if {$::tcl_platform(platform) eq {windows}} { if {[wm attributes $al(movWin) -alpha] < 0.1} {wm attributes $al(movWin) -alpha 1.0} } else { catch {wm deiconify $al(movWin) ; raise $al(movWin)} } }




ButtonPress [::alited::tree]tree, Top

Handles a mouse clicking the tree.

ButtonPress but x y X Y
Parameters
butmouse button
xx-coordinate to identify an item
yy-coordinate to identify an item
Xx-coordinate of the click
Yx-coordinate of the click

proc ::alited::tree::ButtonPress {but x y X Y} { # Handles a mouse clicking the tree. # but - mouse button # x - x-coordinate to identify an item # y - y-coordinate to identify an item # X - x-coordinate of the click # Y - x-coordinate of the click namespace upvar ::alited al al obPav obPav TooltipOff set wtree [$obPav Tree] set ID [$wtree identify item $x $y] set region [$wtree identify region $x $y] set al(movID) [set al(movWin) {}] if {![$wtree exists $ID] || $region ne {tree}} { return ;# only tree items are processed } switch $but { {3} { if {[llength [$wtree selection]]<2} { $wtree selection set $ID } ShowPopupMenu $ID $X $Y } {1} { set al(movID) $ID set al(movWin) .tritem_move if {$al(TREE,isunits)} { NewSelection $ID } else { set msec [clock milliseconds] if {[info exists al(_MSEC)] && [expr {($msec-$al(_MSEC))<400}]} { OpenFile $ID } $wtree selection set $ID set al(_MSEC) $msec } } } }




ButtonRelease [::alited::tree]tree, Top

Handles a mouse button releasing on the tree, at moving an item.

ButtonRelease but x y X Y
Parameters
butmouse button
xx-coordinate to identify an item
yy-coordinate to identify an item
Xx-coordinate of the click
Yx-coordinate of the click

proc ::alited::tree::ButtonRelease {but x y X Y} { # Handles a mouse button releasing on the tree, at moving an item. # but - mouse button # x - x-coordinate to identify an item # y - y-coordinate to identify an item # X - x-coordinate of the click # Y - x-coordinate of the click namespace upvar ::alited al al obPav obPav set wtree [$obPav Tree] set ID [$wtree identify item $x $y] DestroyMoveWindow no if {[$wtree exists $ID] && [info exists al(movID)] && $al(movID) ne {} && $ID ne {} && $al(movID) ne $ID && [$wtree identify region $x $y] eq {tree}} { if {$al(TREE,isunits)} { alited::unit::MoveUnits $wtree move $al(movID) $ID } else { alited::file::MoveFile $wtree move $al(movID) $ID } } DestroyMoveWindow yes }




Create [::alited::tree]tree, Top

Creates a tree of units/files, at need.

Create

proc ::alited::tree::Create {} { # Creates a tree of units/files, at need. namespace upvar ::alited al al obPav obPav if {$al(TREE,isunits) && $al(TREE,units) || !$al(TREE,isunits) && $al(TREE,files)} return ;# no need set TID [alited::bar::CurrentTabID] set wtree [$obPav Tree] Delete $wtree {} $TID AddTags $wtree $wtree tag bind tagNorm <ButtonPress> {after idle {alited::tree::ButtonPress %b %x %y %X %Y}} $wtree tag bind tagNorm <ButtonRelease> {after idle {alited::tree::ButtonRelease %b %x %y %X %Y}} $wtree tag bind tagNorm <Motion> {after idle {alited::tree::ButtonMotion %b %x %y %X %Y}} bind $wtree <ButtonRelease> {alited::tree::DestroyMoveWindow no} bind $wtree <Leave> { alited::tree::TooltipOff alited::tree::DestroyMoveWindow yes } if {$al(TREE,isunits)} { CreateUnitsTree $TID $wtree } else { CreateFilesTree $wtree } }




CreateFilesTree [::alited::tree]tree, Top

Creates a file tree.

CreateFilesTree wtree
Parameters
wtreethe tree's path

proc ::alited::tree::CreateFilesTree {wtree} { # Creates a file tree. # wtree - the tree's path namespace upvar ::alited al al obPav obPav set al(TREE,files) yes [$obPav BuTswitch] configure -image alimg_gulls baltip::tip [$obPav BuTswitch] $al(MC,swfiles) baltip::tip [$obPav BuTAddT] $al(MC,filesadd) baltip::tip [$obPav BuTDelT] $al(MC,filesdel) baltip::tip [$obPav BuTUp] $al(MC,moveupF) baltip::tip [$obPav BuTDown] $al(MC,movedownF) $al(MENUEDIT) entryconfigure 0 -label $al(MC,moveupF) $al(MENUEDIT) entryconfigure 1 -label $al(MC,movedownF) $wtree heading #0 -text ":: [file tail $al(prjroot)] ::" $wtree heading #1 -text $al(MC,files) bind $wtree <Return> {::alited::tree::OpenFile} set selID "" if {[catch {set selfile [alited::bar::FileName]}]} { set selfile {} ;# at closing by Ctrl+W with file tree open: no current file } foreach item [GetDirectoryContents $al(prjroot)] { set itemID [alited::tree::NewItemID [incr iit]] lassign $item lev isfile fname fcount iroot if {$selfile eq $fname} {set selID $itemID} set title [file tail $fname] if {$iroot<0} { set parent {} } else { set parent [alited::tree::NewItemID [incr iroot]] } if {$isfile} { if {[alited::file::IsTcl $fname]} { set imgopt {-image alimg_tclfile} } else { set imgopt {-image alimg_file} } } else { set imgopt {-image alimg_folder} } if {$fcount} {set fc $fcount} {set fc {}} $wtree insert $parent end -id $itemID -text "$title" -values [list $fc $fname $isfile $itemID] -open yes {*}$imgopt $wtree tag add tagNorm $itemID if {!$isfile} { $wtree tag add tagBranch $itemID } elseif {[alited::bar::FileTID $fname] ne ""} { $wtree tag add tagBold $itemID } } if {$selID ne {}} { $wtree see $selID $wtree selection set $selID } }




CreateUnitsTree [::alited::tree]tree, Top

Creates a unit tree for a tab.

CreateUnitsTree TID wtree
Parameters
TIDa current tab's ID
wtreethe tree's path

proc ::alited::tree::CreateUnitsTree {TID wtree} { # Creates a unit tree for a tab. # TID - a current tab's ID # wtree - the tree's path namespace upvar ::alited al al obPav obPav set al(TREE,units) yes [$obPav BuTswitch] configure -image alimg_folder baltip::tip [$obPav BuTswitch] $al(MC,swunits) baltip::tip [$obPav BuTAddT] $al(MC,unitsadd) baltip::tip [$obPav BuTDelT] $al(MC,unitsdel) baltip::tip [$obPav BuTUp] $al(MC,moveupU) baltip::tip [$obPav BuTDown] $al(MC,movedownU) $al(MENUEDIT) entryconfigure 0 -label $al(MC,moveupU) $al(MENUEDIT) entryconfigure 1 -label $al(MC,movedownU) $wtree heading #0 -text [alited::bar::CurrentTab 1] $wtree heading #1 -text [msgcat::mc Row] set ctab [alited::bar::CurrentTabID] set parents [list {}] set parent {} set levprev -1 foreach item $al(_unittree,$TID) { if {[llength $item]<3} continue set itemID [alited::tree::NewItemID [incr iit]] lassign $item lev leaf fl1 title l1 l2 set title [UnitTitle $title $l1 $l2] set lev [expr {min($lev,[llength $parents])}] set parent [lindex $parents [expr {$lev-1}]] if {$leaf} { set title " $title" set pr [expr {max(0,min(7,($l2-$l1)/$al(prjredunit)))}] set imgopt "-image alimg_pro$pr" } else { set imgopt "-image alimg_gulls" } $wtree insert $parent end -id $itemID -text "$title" -values [list $l1 $l2 {} $itemID $lev $leaf $fl1] -open yes {*}$imgopt $wtree tag add tagNorm $itemID catch { if {$leaf && [info exists al(CPOS,$ctab,[alited::unit::GetHeader $wtree $itemID])]} { $wtree tag add tagBold $itemID } } if {!$leaf} { $wtree tag add tagBranch $itemID set parent $itemID set parents [lreplace $parents $lev end $parent] } set levprev $lev } }




CurrentItem [::alited::tree]tree, Top

Gets ID of selected item of the tree.

CurrentItem ?Tree?
Parameters
Treethe tree widget's name; optional, default Tree

proc ::alited::tree::CurrentItem {{Tree Tree}} { # Gets ID of selected item of the tree. # Tree - the tree widget's name namespace upvar ::alited obPav obPav set wtree [$obPav $Tree] set it [$wtree focus] if {$it eq {}} {set it [lindex [$wtree selection] 0]} return $it }




CurrentItemByLine [::alited::tree]tree, Top

Gets item ID of unit tree for a current text position.

CurrentItemByLine ?pos? ?fullinfo?
Parameters
posthe current text position; optional, default ""
fullinfoif yes, returns a full info for the found ID; optional, default no

proc ::alited::tree::CurrentItemByLine {{pos {}} {fullinfo no}} { # Gets item ID of unit tree for a current text position. # pos - the current text position # fullinfo - if yes, returns a full info for the found ID. namespace upvar ::alited al al if {$pos eq {}} { set pos [[alited::main::CurrentWTXT] index insert] } set l [expr {int($pos)}] set TID [alited::bar::CurrentTabID] foreach it $al(_unittree,$TID) { set ID [NewItemID [incr iit]] lassign $it lev leaf fl1 title l1 l2 if {$l1<=$l && $l<=$l2} { if {$fullinfo} { return [list $ID $lev $leaf $fl1 $title $l1 $l2] } return $ID } } return {} }




Delete [::alited::tree]tree, Top

Removes recursively an item and its children from the tree.

Delete wtree item TID
Parameters
wtreethe tree widget's path
itemID of the item to be deleted.
TIDNot documented.

proc ::alited::tree::Delete {wtree item TID} { # Removes recursively an item and its children from the tree. # wtree - the tree widget's path # item - ID of the item to be deleted. foreach child [$wtree children $item] { alited::tree::Delete $wtree $child $TID } if {$item ne {}} {$wtree delete $item} }




DelItem [::alited::tree]tree, Top

Removes an item from the tree.

DelItem ?ID?
Parameters
IDan item's ID to be deleted; optional, default ""

proc ::alited::tree::DelItem {{ID {}}} { # Removes an item from the tree. # ID - an item's ID to be deleted. namespace upvar ::alited al al obPav obPav if {$ID eq {} && [set ID [alited::tree::CurrentItem]] eq {}} { bell return } set wtree [$obPav Tree] set fname [alited::bar::FileName] if {$al(TREE,isunits)} { alited::unit::Delete $wtree $fname } else { alited::file::Delete $ID $wtree } }




DestroyMoveWindow [::alited::tree]tree, Top

Destroys an item moving window.

DestroyMoveWindow cancel
Parameters
cancelif yes, clears also the related variables.

proc ::alited::tree::DestroyMoveWindow {cancel} { # Destroys an item moving window. # cancel - if yes, clears also the related variables. namespace upvar ::alited al al catch {destroy $al(movWin)} if {$cancel} {lassign {} al(movWin) al(movID)} }




DirContents [::alited::tree]tree, Top

Reads a directory's contents.

DirContents dirname ?lev? ?iroot? ?globs?
Parameters
dirnamea dirtectory's name
levlevel in the directory hierarchy; optional, default 0
irootindex of the directory's parent or -1; optional, default -1
globslist of globs to filter files; optional, default *
See also

GetDirectoryContents, AddToDirContents


proc ::alited::tree::DirContents {dirname {lev 0} {iroot -1} {globs *}} { # Reads a directory's contents. # dirname - a dirtectory's name # lev - level in the directory hierarchy # iroot - index of the directory's parent or -1 # globs - list of globs to filter files. # See also: # GetDirectoryContents # AddToDirContents namespace upvar ::alited al al incr lev if {[catch {set dcont [lsort -dictionary [glob [file join $dirname *]]]}]} { set dcont [list] } # firstly directories: # 1. skip the ignored ones for {set i [llength $dcont]} {$i} {} { incr i -1 if {[IgnoredDir [lindex $dcont $i]]} { set dcont [lreplace $dcont $i $i] } } # 2. put the directories to the beginning of the file list set i 0 foreach fname $dcont { if {[file isdirectory $fname]} { set dcont [lreplace $dcont $i $i [list $fname "y"]] set nroot [AddToDirContents $lev 0 $fname $iroot] if {[llength $al(_dirtree)] < $al(MAXFILES)} { DirContents $fname $lev $nroot $globs } else { break } } else { set dcont [lreplace $dcont $i $i [list $fname]] } incr i } # then files if {[llength $al(_dirtree)] < $al(MAXFILES)} { foreach fname $dcont { lassign $fname fname d if {$d ne "y"} { foreach gl [split $globs ","] { if {[string match $gl $fname]} { AddToDirContents $lev 1 $fname $iroot break } } } } } }




ExpandContractTree [::alited::tree]tree, Top

Expands or contracts the tree.

ExpandContractTree Tree ?isexp?
Parameters
Treethe tree's name
isexpyes, if to expand; no, if to contract; optional, default yes

proc ::alited::tree::ExpandContractTree {Tree {isexp yes}} { # Expands or contracts the tree. # Tree - the tree's name # isexp - yes, if to expand; no, if to contract namespace upvar ::alited al al obPav obPav set wtree [$obPav $Tree] foreach item [GetTree {} $Tree] { lassign $item lev cnt ID if {[llength [$wtree children $ID]]} { $wtree item $ID -open $isexp } } }




ForEach [::alited::tree]tree, Top

Scans all items of the tree.

ForEach wtree aproc ?lev? ?branch?
Parameters
wtreethe tree's path
aproca procedure to run at scanning
levlevel of the tree; optional, default 0
branchID of the branch to be scanned; optional, default ""
Description

The 'aproc' argument can include wildcards to be replaced appropriate data:

%levelcurrent tree level
%childrenchildren of a current item
%itemID of a current item
%texttext of a current item
%valuesvalues of a current item

proc ::alited::tree::ForEach {wtree aproc {lev 0} {branch {}}} { # Scans all items of the tree. # wtree - the tree's path # aproc - a procedure to run at scanning # lev - level of the tree # branch - ID of the branch to be scanned # The 'aproc' argument can include wildcards to be replaced # appropriate data: # %level - current tree level # %children - children of a current item # %item - ID of a current item # %text - text of a current item # %values - values of a current item set children [$wtree children $branch] if {$lev} { set proc [string map [list %level $lev %children [llength $children] %item $branch %text [$wtree item $branch -text] %values [$wtree item $branch -values]] $aproc] uplevel [expr {$lev+1}] "$proc" } incr lev foreach child $children { ForEach $wtree $aproc $lev $child } }




GetDirectoryContents [::alited::tree]tree, Top

Gets a directory's contents.

GetDirectoryContents dirname
Parameters
dirnameNot documented.
Return value

Returns a list containing the directory's contents.

See also

DirContents


proc ::alited::tree::GetDirectoryContents {dirname} { # Gets a directory's contents. # Returns a list containing the directory's contents. # See also: # DirContents namespace upvar ::alited al al set al(_dirtree) [list] DirContents $dirname return $al(_dirtree) }




GetTree [::alited::tree]tree, Top

Gets a tree or its branch.

GetTree ?parent? ?Tree?
Parameters
parentID of the branch; optional, default ""
Treename of the tree widget; optional, default Tree

proc ::alited::tree::GetTree {{parent {}} {Tree Tree}} { # Gets a tree or its branch. # parent - ID of the branch # Tree - name of the tree widget namespace upvar ::alited obPav obPav set wtree [$obPav $Tree] set tree [list] set levp -1 ForEach $wtree { set item "%item" set lev %level if {$levp>-1 || $item eq $parent} { if {$lev<=$levp} {return -code break} ;# all of branch fetched if {$item eq $parent} {set levp $lev} } if {$parent eq {} || $levp>-1} { lappend tree [list $lev %children $item {%text} {%values}] } } return $tree }




IgnoredDir [::alited::tree]tree, Top

Checks if a directory is in the list of the ignored ones.

IgnoredDir