new symbol browser: add Update button to refresh list of dirs and files; fix Alt-s (Reload) incorrectly moved in r keybind after handle_key_press() refactoring
This commit is contained in:
parent
abfa38b1e4
commit
b348451160
|
|
@ -3434,19 +3434,6 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
|
|||
tcleval("[xschem get top_path].menubar invoke Simulate");
|
||||
}
|
||||
}
|
||||
else if(SET_MODMASK) { /* reload */
|
||||
if(xctx->semaphore >= 2) break;
|
||||
tcleval("tk_messageBox -type okcancel -parent [xschem get topwindow] "
|
||||
"-message {Are you sure you want to reload from disk?}");
|
||||
if(strcmp(tclresult(),"ok")==0) {
|
||||
char filename[PATH_MAX];
|
||||
unselect_all(1);
|
||||
remove_symbols();
|
||||
my_strncpy(filename, abs_sym_path(xctx->sch[xctx->currsch], ""), S(filename));
|
||||
load_schematic(1, filename, 1, 1);
|
||||
draw();
|
||||
}
|
||||
}
|
||||
else if(EQUAL_MODMASK) { /* rotate objects around their anchor points 20171208 */
|
||||
if(xctx->ui_state & STARTMOVE) move_objects(ROTATE|ROTATELOCAL,0,0,0);
|
||||
else if(xctx->ui_state & STARTCOPY) copy_objects(ROTATE|ROTATELOCAL);
|
||||
|
|
@ -3490,7 +3477,8 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
|
|||
tcleval("[xschem get top_path].menubar invoke Simulate");
|
||||
}
|
||||
}
|
||||
else if(/* !xctx->ui_state && */ (rstate == 0) && cadence_compat) { /* create wire snapping to closest instance pin (cadence keybind) */
|
||||
/* create wire snapping to closest instance pin (cadence keybind) */
|
||||
else if(/* !xctx->ui_state && */ (rstate == 0) && cadence_compat) {
|
||||
if(xctx->semaphore >= 2) break;
|
||||
snapped_wire(c_snap);
|
||||
}
|
||||
|
|
@ -3507,6 +3495,21 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
|
|||
save(1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
else if(SET_MODMASK) { /* reload */
|
||||
if(xctx->semaphore >= 2) break;
|
||||
tcleval("tk_messageBox -type okcancel -parent [xschem get topwindow] "
|
||||
"-message {Are you sure you want to reload from disk?}");
|
||||
if(strcmp(tclresult(),"ok")==0) {
|
||||
char filename[PATH_MAX];
|
||||
unselect_all(1);
|
||||
remove_symbols();
|
||||
my_strncpy(filename, abs_sym_path(xctx->sch[xctx->currsch], ""), S(filename));
|
||||
load_schematic(1, filename, 1, 1);
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
else if(SET_MODMASK && (state & ControlMask) ) { /* save as symbol */
|
||||
if(xctx->semaphore >= 2) break;
|
||||
saveas(NULL, SYMBOL);
|
||||
|
|
|
|||
|
|
@ -4878,9 +4878,34 @@ proc insert_symbol_preview {} {
|
|||
}
|
||||
}
|
||||
|
||||
proc insert_symbol_update_dirs {paths {maxdepth -1}} {
|
||||
global insert_symbol new_symbol_browser_ext
|
||||
# regenerate list of dirs
|
||||
set insert_symbol(dirs) [get_list_of_dirs_with_symbols $paths $maxdepth $new_symbol_browser_ext]
|
||||
set insert_symbol(dirtails) {}
|
||||
foreach i $insert_symbol(dirs) {
|
||||
lappend insert_symbol(dirtails) [file tail $i]
|
||||
}
|
||||
# sort dirs using dirtails as key
|
||||
set files {}
|
||||
foreach f $insert_symbol(dirtails) ff $insert_symbol(dirs) {
|
||||
lappend files [list $f $ff]
|
||||
}
|
||||
set files [lsort -dictionary -index 0 $files]
|
||||
set insert_symbol(dirtails) {}
|
||||
set insert_symbol(dirs) {}
|
||||
|
||||
foreach f $files {
|
||||
lassign $f ff fff
|
||||
lappend insert_symbol(dirtails) $ff
|
||||
lappend insert_symbol(dirs) $fff
|
||||
}
|
||||
}
|
||||
|
||||
#### fill list of files matching pattern
|
||||
proc insert_symbol_filelist {paths {maxdepth -1}} {
|
||||
global insert_symbol new_symbol_browser_ext
|
||||
|
||||
set sel [.ins.center.leftdir.l curselection]
|
||||
if {![info exists insert_symbol(dirs)]} {return}
|
||||
if {$sel eq {}} {
|
||||
|
|
@ -5012,7 +5037,10 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} {
|
|||
-readonlybackground [option get . background {}] -takefocus 0
|
||||
label .ins.top.ext_l -text Ext:
|
||||
entry .ins.top.ext_e -width 15 -takefocus 0 -state normal -textvariable new_symbol_browser_ext
|
||||
|
||||
button .ins.top.upd -takefocus 0 -text Update -command "
|
||||
insert_symbol_update_dirs [list $paths] [list $maxdepth]
|
||||
insert_symbol_filelist [list $paths] [list $maxdepth]
|
||||
"
|
||||
bind .ins <KeyPress-Escape> {.ins.bottom.dismiss invoke}
|
||||
bind .ins <KeyRelease> "
|
||||
if {{%K} eq {Tab} && {%W} eq {.ins.center.left.l}} {
|
||||
|
|
@ -5048,33 +5076,12 @@ proc insert_symbol {{paths {}} {maxdepth -1} {ext {.*}}} {
|
|||
pack .ins.top.pat_e -side left
|
||||
pack .ins.top.dir_l -side left
|
||||
pack .ins.top.dir_e -side left
|
||||
pack .ins.top.upd -side left
|
||||
pack .ins.top.ext_l -side left
|
||||
pack .ins.top.ext_e -side left
|
||||
|
||||
set insert_symbol(dirs) [get_list_of_dirs_with_symbols $paths $maxdepth $new_symbol_browser_ext]
|
||||
set insert_symbol(dirtails) {}
|
||||
foreach i $insert_symbol(dirs) {
|
||||
lappend insert_symbol(dirtails) [file tail $i]
|
||||
}
|
||||
insert_symbol_update_dirs $paths $maxdepth
|
||||
|
||||
# sort dirs using dirtails as key
|
||||
set files {}
|
||||
foreach f $insert_symbol(dirtails) ff $insert_symbol(dirs) {
|
||||
lappend files [list $f $ff]
|
||||
}
|
||||
set files [lsort -dictionary -index 0 $files]
|
||||
set insert_symbol(dirtails) {}
|
||||
set insert_symbol(dirs) {}
|
||||
|
||||
foreach f $files {
|
||||
lassign $f ff fff
|
||||
lappend insert_symbol(dirtails) $ff
|
||||
lappend insert_symbol(dirs) $fff
|
||||
}
|
||||
|
||||
# insert_symbol_filelist $paths $maxdepth
|
||||
# tkwait window .ins
|
||||
# xschem set semaphore [expr {[xschem get semaphore] -1}]
|
||||
if {[info exists insert_symbol(dirindex)]} {.ins.center.leftdir.l selection set $insert_symbol(dirindex)}
|
||||
if {[info exists insert_symbol(fileindex)]} {.ins.center.left.l selection set $insert_symbol(fileindex)}
|
||||
return {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue