📄 asedmain.tcl
字号:
################################################################################
# asedmain.tcl -
#
# Copyright 1999-2002 by Andreas Sievers
#
# andreas.sievers@t-online.de
################################################################################
################################################################################
#proc delete_id
#called when a editorwindow is closed to delete the correspondend undo_id
################################################################################
proc delete_id {} {
global undo_id
delete textUndoer $Editor::current(undo_id)
return
}
proc Editor::tick {} {
global clock_var
variable mainframe
variable startTime
set seconds [expr [clock seconds] - $startTime]
set clock_var [clock format $seconds -format %H:%M:%S -gmt 1]
after 1000 Editor::tick
}
proc Editor::aboutBox {} {\
tk_messageBox -message \
[tr "ASED Tcl/Tk-IDE 2.0.9.9
(c) Andreas Sievers, 1999-2002\n\n\
This Software is distributed under the terms
of the GNU General Public License! \n
Parts of ASED are based upon
the BWidget Toolkit Demo from UNIFIX and
Tcldev from Alexey Kakunin\n
Special Thanks to Carsten Zerbst who provided
the basics of the Code Browser Window and iTcl-support\n\n
Please report any comments or bugs to
andreas.sievers@t-online.de"] \
-type ok \
-title About \
-icon info
}
proc Editor::getWindowPositions {} {
global EditorData
variable pw1
variable pw2
variable notebook
variable list_notebook
variable con_notebook
variable current
update idletasks
set EditorData(options,notebookWidth) [winfo width $notebook]
set EditorData(options,notebookHeight) [winfo height $notebook]
set EditorData(options,list_notebookWidth) [winfo width $list_notebook]
set EditorData(options,list_notebookHeight) [winfo height $list_notebook]
set EditorData(options,con_notebookWidth) [winfo width $con_notebook]
set EditorData(options,con_notebookHeight) [winfo height $con_notebook]
# get position of mainWindow
set EditorData(options,mainWinSize) [wm geom .]
}
proc Editor::restoreWindowPositions {} {
global EditorData
variable pw1
variable pw2
variable notebook
variable list_notebook
variable con_notebook
$notebook configure -width $EditorData(options,notebookWidth)
$notebook configure -height $EditorData(options,notebookHeight)
$list_notebook configure -width $EditorData(options,list_notebookWidth)
$list_notebook configure -height $EditorData(options,list_notebookHeight)
$con_notebook configure -width $EditorData(options,con_notebookWidth)
$con_notebook configure -height $EditorData(options,con_notebookHeight)
showConsole $EditorData(options,showConsole)
showProcWin $EditorData(options,showProcs)
}
################################################################################
#proc Editor::saveOptions
#called when ASED exits
#saves only "EditorData(options,...)"
#but might be easily enhanced with other options
################################################################################
proc Editor::saveOptions {} {
global EditorData
global ASEDsRootDir
Editor::getWindowPositions
set configData "#ASED Configuration File\n\n"
set configFile [file join "~" ased.cfg]
set optionlist [array names EditorData]
foreach option $optionlist {
set optiontext EditorData($option)
if {![string match "*(options*" $optiontext]} {
continue
}
set value \"[subst \$[subst {$optiontext}]]\"
append configData "set EditorData($option) $value\n"
}
set result [Editor::_saveFile $configFile $configData]
}
proc Editor::CreateFonts {} {
global EditorData
variable configError
variable Font_var
variable FontSize_var
# set editor font
if {$configError} {
set font [list -family Courier -size 10 -weight normal -slant roman -underline 0 -overstrike 0]
set EditorData(options,fonts,editorFont) $font
}
eval font create editorFont $EditorData(options,fonts,editorFont)
# set comment font
if {$configError} {
set font [list -family Courier -size 10 -weight normal -slant italic -underline 0 -overstrike 0]
set EditorData(options,fonts,commentFont) $font
}
eval font create commentFont $EditorData(options,fonts,commentFont)
# set keyword font
if {$configError} {
set font [list -family Courier -size 10 -weight bold -slant roman -underline 0 -overstrike 0]
set EditorData(options,fonts,keywordFont) $font
}
eval font create keywordFont $EditorData(options,fonts,keywordFont)
set Font_var [font configure editorFont -family]
return
}
proc Editor::changeServerPort {} {
global EditorData
set dialog [toplevel .top ]
label $dialog.l -text [tr "Enter Port Number"]
set port $EditorData(options,serverPort)
set portEntry [entry $dialog.e -width 5 -textvar EditorData(options,serverPort)]
set EditorData(oldPort) $EditorData(options,serverPort)
set f [frame $dialog.f]
button $dialog.f.ok -text [tr "Ok"] -width 8 -command {
destroy .top
}
button $dialog.f.c -text [tr "Cancel"] -width 8 -command {
global EditorData
destroy .top
set EditorData(options,serverPort) $EditorData(oldPort)
}
pack $dialog.l $portEntry -fill both -expand yes
pack $dialog.f.ok -side left -fill both -expand yes
pack $dialog.f.c -side left -fill both -expand yes
pack $f
focus $portEntry
bind $portEntry <KeyRelease-Return> {
destroy .top
break
}
wm title $dialog [tr "Enter Port"]
BWidget::place $dialog 0 0 center
}
proc Editor::newFile {{force 0}} {
variable notebook
variable current
variable newFileCount
global EditorData
set pages [NoteBook::pages $notebook]
if {([llength $pages] > 0) && ($force == 0)} {
if {[info exists current(text)]} {
set f0 [NoteBook::raise $notebook]
set text [NoteBook::itemcget $notebook $f0 -text]
set data [$current(text) get 1.0 end-1c]
if {($data == "") && ([string trimright $text 0123456789] == [tr "Untitled"])} {return}
}
}
set temp $current(hasChanged)
incr newFileCount
set f0 [EditManager::create_text $notebook [tr "Untitled"]$newFileCount]
set Editor::text_win($Editor::index_counter,undo_id) [new textUndoer [lindex $f0 2]]
set current(hasChanged) $temp
NoteBook::raise $notebook [lindex $f0 1]
set current(hasChanged) 0
set current(writable) 1
$Editor::mainframe setmenustate noFile normal
updateObjects
}
proc Editor::scanLine {} {
variable current
# is current line a proc-line?
set result [$current(text) search "proc " "insert linestart" "insert lineend"]
if {$result == ""} {
# this is not a proc-line
# was it a proc-line?
if {$current(is_procline)} {
set current(is_procline) 0
set current(procSelectionChanged) 1
} else {
set current(is_procline) 0
set current(procSelectionChanged) 0
}
} else {
# is current line really a proc-line?
set line [$current(text) get "$result linestart" "$result lineend"]
set temp [string trim $line \ \t\;]
set proc ""
set procName ""
# is it really a proc-line?
if {[scan $temp %\[proc\]%s proc procName] != 2} {
set result ""
} elseif {$proc != "proc"} {
set result ""
}
if {$result != ""} {
if {$current(procName) != $procName} {
set current(procName) $procName
set current(procSelectionChanged) 1
set current(is_procline) 1
} else {
set current(procSelectionChanged) 0
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -