improvements in tcl command console (added "=" keybind)

This commit is contained in:
stefan schippers 2025-10-23 15:11:19 +02:00
parent afefb18ee2
commit d16cbf94c0
5 changed files with 40 additions and 15 deletions

View File

@ -273,6 +273,7 @@ alt '-' Set line width
ctrl '+' Increase line width ctrl '+' Increase line width
- '_' Toggle change line width - '_' Toggle change line width
- '%' Toggle draw grid - '%' Toggle draw grid
- '=' Tclcommand console
ctrl '=' Toggle fill rectangles ctrl '=' Toggle fill rectangles
- '$' Toggle pixmap saving - '$' Toggle pixmap saving
ctrl '$' Toggle use XCopyArea vs drawing primitives for drawing the screen ctrl '$' Toggle use XCopyArea vs drawing primitives for drawing the screen

View File

@ -3768,7 +3768,9 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
break; break;
case '=': case '=':
if(state & ControlMask) { /* toggle fill rectangles */ if(state == 0) { /* tcl command console */
tcleval("tclcmd");
} else if(state & ControlMask) { /* toggle fill rectangles */
int x; int x;
xctx->fill_pattern++; xctx->fill_pattern++;
if(xctx->fill_pattern==2) xctx->fill_pattern=0; if(xctx->fill_pattern==2) xctx->fill_pattern=0;

View File

@ -214,6 +214,7 @@ alt '-' Set line width
ctrl '+' Increase line width ctrl '+' Increase line width
- '_' Toggle change line width - '_' Toggle change line width
- '%' Toggle draw grid - '%' Toggle draw grid
- '=' Tclcommand console
ctrl '=' Toggle fill rectangles ctrl '=' Toggle fill rectangles
- '$' Toggle pixmap saving - '$' Toggle pixmap saving
ctrl '$' Toggle use XCopyArea vs drawing primitives for drawing the screen ctrl '$' Toggle use XCopyArea vs drawing primitives for drawing the screen

View File

@ -664,6 +664,10 @@ proc to_eng {args} {
return $s return $s
} }
proc = {args} {
ev7 $args
}
## evaluate expression with 7 significant digits. ## evaluate expression with 7 significant digits.
## if expression has errors or does not evaluate return expression as is ## if expression has errors or does not evaluate return expression as is
proc ev7 {args} { proc ev7 {args} {
@ -6300,11 +6304,11 @@ proc return_release {window} {
$window delete "$curs - 1 chars" $curs $window delete "$curs - 1 chars" $curs
} }
proc tclcmd_ok_button {} { proc tclcmd_ok_button {} {
global tclcmd_txt tclcmd_puts global tclcmd_txt tclcmd_puts
set tclcmd_txt [.tclcmd.t get 1.0 end] set tclcmd_txt [.tclcmd.t get 1.0 end]
regsub {^ *= *} $tclcmd_txt {= } tclcmd_txt
redef_puts redef_puts
catch {uplevel #0 $tclcmd_txt} tclcmd_puts catch {uplevel #0 $tclcmd_txt} tclcmd_puts
rename puts {} rename puts {}
@ -6318,40 +6322,57 @@ proc tclcmd_ok_button {} {
# evaluate a tcl command from GUI # evaluate a tcl command from GUI
proc tclcmd {} { proc tclcmd {} {
global tclcmd_txt global tclcmd_txt tclcmd_default_geometry
set_ne tclcmd_default_geometry {}
if {[winfo exists .tclcmd]} { if {[winfo exists .tclcmd]} {
destroy .tclcmd destroy .tclcmd
} }
toplevel .tclcmd -class Dialog toplevel .tclcmd -class dialog
# wm transient .tclcmd [xschem get topwindow]
label .tclcmd.txtlab -text {Enter TCL expression. Shift-Return will evaluate} label .tclcmd.txtlab -text {Enter TCL expression. Shift-Return will evaluate}
panedwindow .tclcmd.p -orient vert panedwindow .tclcmd.p -orient vert
text .tclcmd.t -undo 1 -width 100 -height 3
bind .tclcmd <Configure> {
set tclcmd_default_geometry [wm geometry .tclcmd]
}
frame .tclcmd.t
text .tclcmd.t.t -width 60 -height 4 -font {Monospace 12} -yscrollcommand ".tclcmd.t.yscroll set"
scrollbar .tclcmd.t.yscroll -command ".tclcmd.t.t yview"
frame .tclcmd.r frame .tclcmd.r
text .tclcmd.r.r -undo 1 -width 100 -height 8 -yscrollcommand ".tclcmd.r.yscroll set" text .tclcmd.r.r -width 60 -height 5 -font {Monospace 12} -yscrollcommand ".tclcmd.r.yscroll set"
scrollbar .tclcmd.r.yscroll -command ".tclcmd.r.r yview" scrollbar .tclcmd.r.yscroll -command ".tclcmd.r.r yview"
.tclcmd.p add .tclcmd.t .tclcmd.r .tclcmd.p add .tclcmd.t .tclcmd.r
.tclcmd.t insert 1.0 $tclcmd_txt .tclcmd.t.t insert 1.0 $tclcmd_txt
frame .tclcmd.b frame .tclcmd.b
button .tclcmd.b.clear -text Clear -command { button .tclcmd.b.cleari -text {Clear Input} -command {
.tclcmd.t.t delete 1.0 end
}
button .tclcmd.b.clear -text {Clear Results} -command {
.tclcmd.r.r delete 1.0 end .tclcmd.r.r delete 1.0 end
} }
button .tclcmd.b.close -text Close -command { button .tclcmd.b.close -text Close -command {
set tclcmd_txt [.tclcmd.t get 1.0 {end - 1 chars}] set tclcmd_txt [.tclcmd.t.t get 1.0 {end - 1 chars}]
destroy .tclcmd destroy .tclcmd
} }
button .tclcmd.b.ok -text Evaluate -command {tclcmd_ok_button} button .tclcmd.b.ok -text Evaluate -command {tclcmd_ok_button}
# bind .tclcmd.t <Shift-KeyPress-Return> { .tclcmd.b.ok invoke } # bind .tclcmd.t <Shift-KeyPress-Return> { .tclcmd.b.ok invoke }
bind .tclcmd.t <Shift-KeyRelease-Return> {return_release %W; .tclcmd.b.ok invoke } bind .tclcmd.t.t <Shift-KeyRelease-Return> {return_release %W; .tclcmd.b.ok invoke }
bind .tclcmd <Escape> {.tclcmd.b.close invoke}
pack .tclcmd.txtlab -side top -fill x pack .tclcmd.txtlab -side top -fill x
pack .tclcmd.b -side bottom -fill x pack .tclcmd.b -side bottom -fill x
pack .tclcmd.p -side top -fill both -expand yes pack .tclcmd.p -side top -fill both -expand yes
pack .tclcmd.r.yscroll -side right -fill y pack .tclcmd.r.yscroll -side right -fill y
pack .tclcmd.r.r -side top -fill both -expand yes pack .tclcmd.r.r -side top -fill both -expand yes
pack .tclcmd.t.yscroll -side right -fill y
pack .tclcmd.t.t -side top -fill both -expand yes
pack .tclcmd.b.ok -side left -expand yes -fill x pack .tclcmd.b.ok -side left -expand yes -fill x
pack .tclcmd.b.close -side left -expand yes -fill x
pack .tclcmd.b.clear -side left -expand yes -fill x pack .tclcmd.b.clear -side left -expand yes -fill x
pack .tclcmd.b.cleari -side left -expand yes -fill x
pack .tclcmd.b.close -side left -expand yes -fill x
if { $tclcmd_default_geometry ne {}} {wm geometry .tclcmd $tclcmd_default_geometry}
} }
proc select_layers {} { proc select_layers {} {
@ -9324,7 +9345,7 @@ set tctx::global_list {
tctx::colors tctx::delay_flag tctx::hsize tctx::recentfile tctx::colors tctx::delay_flag tctx::hsize tctx::recentfile
tctx::selected_mode tctx::old_selected_mode tctx::old_selected_tok tctx::selected_tok tctx::selected_mode tctx::old_selected_mode tctx::old_selected_tok tctx::selected_tok
tctx::rcode tctx::vsize tctx::tctx::retval tctx::retval_orig tctx::rcode tctx::vsize tctx::tctx::retval tctx::retval_orig
text_line_default_geometry text_replace_selection text_tabs_setting tclcmd_default_geometry text_line_default_geometry text_replace_selection text_tabs_setting
textwindow_fileid textwindow_filename textwindow_w toolbar_horiz toolbar_list toolbar_visible textwindow_fileid textwindow_filename textwindow_w toolbar_horiz toolbar_list toolbar_visible
top_is_subckt transparent_svg undo_type unselect_partial_sel_wires uppercase_subckt top_is_subckt transparent_svg undo_type unselect_partial_sel_wires uppercase_subckt
use_cursor_for_selection use_lab_wire use_label_prefix use_tclreadline user_wants_copy_cell use_cursor_for_selection use_lab_wire use_label_prefix use_tclreadline user_wants_copy_cell
@ -10243,7 +10264,7 @@ proc build_widgets { {topwin {} } } {
-accelerator {Print Scrn} -accelerator {Print Scrn}
$topwin.menubar.tools add command -label "Search" -accelerator Ctrl+F -command property_search $topwin.menubar.tools add command -label "Search" -accelerator Ctrl+F -command property_search
$topwin.menubar.tools add command -label "Align to Grid" -accelerator Alt+U -command "xschem align" $topwin.menubar.tools add command -label "Align to Grid" -accelerator Alt+U -command "xschem align"
$topwin.menubar.tools add command -label "Execute TCL command" -command "tclcmd" $topwin.menubar.tools add command -label "Execute TCL command" -command "tclcmd" -accelerator {=}
$topwin.menubar.tools add command -label "Join/Trim wires" \ $topwin.menubar.tools add command -label "Join/Trim wires" \
-command "xschem trim_wires" -accelerator {&} -command "xschem trim_wires" -accelerator {&}
$topwin.menubar.tools add command -label "Break wires at selected instance pins" \ $topwin.menubar.tools add command -label "Break wires at selected instance pins" \

View File

@ -414,7 +414,7 @@ T {Flat netlist} 882.5 -183.75 0 0 0.18 0.18 {layer=12}
T {Reserved} 882.5 -172.5 0 0 0.18 0.18 {} T {Reserved} 882.5 -172.5 0 0 0.18 0.18 {}
T {Toggle fill style} 962.5 -355 0 0 0.18 0.18 {layer=4} T {Toggle fill style} 962.5 -355 0 0 0.18 0.18 {layer=4}
T {-} 962.5 -343.75 0 0 0.18 0.18 {layer=12} T {-} 962.5 -343.75 0 0 0.18 0.18 {layer=12}
T {-} 962.5 -332.5 0 0 0.18 0.18 {} T {Tcl console} 962.5 -332.5 0 0 0.18 0.18 {}
T {Decr line width} 882.5 -355 0 0 0.18 0.18 {layer=4} T {Decr line width} 882.5 -355 0 0 0.18 0.18 {layer=4}
T {Variab. line w.} 882.5 -343.75 0 0 0.18 0.18 {layer=12} T {Variab. line w.} 882.5 -343.75 0 0 0.18 0.18 {layer=12}
T {-} 882.5 -332.5 0 0 0.18 0.18 {} T {-} 882.5 -332.5 0 0 0.18 0.18 {}