[PATCH] keybindings for xconfig,2.4.0-test1

From: Kip Macy (kip@eventdriven.org)
Date: Wed May 31 2000 - 00:57:19 EST


Sorry if this is mail is received twice - I got a 450 DNS Error
the first time I sent this message because I had misset the
relay to be a machine name for which there is no reverse lookup.
My bad.

This patch adds a few keybindings that I felt to be missing from
xconfig.

The PageDown, PageUp, Home, End, Down, and Up keys now work. I
also added the following mnemonic keybindings: Alt-q for "Quit
without Saving", Alt-s for "Save and Exit", Alt-n for Next,
Alt-p for Prev, and Esc to leave a submenu. Suggestions welcome.

                                        -Kip

diff -Naur linux-2.4.0-test1/scripts/header.tk linux/scripts/header.tk
--- linux-2.4.0-test1/scripts/header.tk Sun May 21 20:18:08 2000
+++ linux/scripts/header.tk Tue May 30 21:51:54 2000
@@ -110,6 +110,8 @@
         wm geometry $w +$winx+$winy
 }
 
+bind all <Alt-q> {maybe_exit .maybe}
+
 proc maybe_exit { w } {
         catch {destroy $w}
         toplevel $w -class Dialog
@@ -128,6 +130,8 @@
                 -width 20 -command "destroy $w; focus $oldFocus"
         pack $w.f.back $w.f.canc -side left -pady 10 -padx 45
         pack $w.f -pady 10 -side bottom -padx 10 -anchor w
+ bind $w <Return> "exit"
+ bind $w <Escape> "destroy $w; focus $oldFocus"
         focus $w
         global winx; global winy
         set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
@@ -312,7 +316,7 @@
         $w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
                                 -activeback [cget $w.x$line.l -bg]
         button $w.x$line.help -text "Help" -relief raised \
- -command "dohelp .dohelp $helpidx .menu$mnum"
+ -command "dohelp .dohelp $helpidx"
         pack $w.x$line.help -side right -fill y
         pack $w.x$line.l -side right -fill both -expand on
 }
@@ -325,9 +329,9 @@
                 -relief groove -width 2 -command "update_active"
         radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \
                 -relief groove -width 2 -command "update_active"
-
+
         option_name $w $mnum $line $text $variable
-
+
         pack $w.x$line.n $w.x$line.m $w.x$line.y -side right -fill y
 }
 
@@ -339,9 +343,9 @@
                 -relief groove -width 2 -command "update_active"
         radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \
                 -relief groove -width 2 -command "update_active"
-
+
         option_name $w $mnum $line $text $variable
-
+
         global CONFIG_MODULES
         if {($CONFIG_MODULES == 0)} then {
                 $w.x$line.m configure -state disabled
@@ -400,17 +404,6 @@
         pack $w.x$line -anchor w -fill both -expand on
 }
 
-proc menusplit {w m n} {
- if { $n > 2 } then {
- set menuoptsize [expr [$m yposition 2] - [$m yposition 1]]
- set maxsize [winfo screenheight $w]
- set splitpoint [expr $maxsize * 4 / 5 / $menuoptsize - 1]
- for {set i [expr $splitpoint + 1]} {$i <= $n} {incr i $splitpoint} {
- $m entryconfigure $i -columnbreak 1
- }
- }
-}
-
 proc submenu { w mnum line text subnum } {
         frame $w.x$line
         button $w.x$line.l -text "" -width 15 -relief groove
@@ -423,20 +416,11 @@
         pack $w.x$line -anchor w -fill both -expand on
 }
 
-proc comment {w mnum line text } {
- frame $w.x$line
- button $w.x$line.l -text "" -width 15 -relief groove
- $w.x$line.l configure -activefore [cget $w.x$line.l -fg] \
- -activeback [cget $w.x$line.l -bg] -state disabled
- button $w.x$line.m -text "$text" -relief groove -anchor w
- $w.x$line.m configure -activefore [cget $w.x$line.m -fg] \
- -activeback [cget $w.x$line.m -bg]
- pack $w.x$line.l -side left -fill both
- pack $w.x$line.m -anchor w -side right -fill both -expand on
- pack $w.x$line -anchor w -fill both -expand on
+proc comment {w line text } {
+#nothing done for comments now.
 }
 
-proc dohelp {w var parent} {
+proc dohelp {w var } {
         catch {destroy $w}
         toplevel $w -class Dialog
 
@@ -462,75 +446,51 @@
                         " Documentation/Configure.help]
                 set found [expr [string length "$message"] > 0]
         }
-
+
         frame $w.f1
- pack $w.f1 -fill both -expand on
-
- # Do the OK button
- #
- set oldFocus [focus]
- frame $w.f2
- button $w.f2.ok -text "OK" \
- -width 10 -command "destroy $w; catch {focus $oldFocus}"
- pack $w.f2.ok -side bottom -pady 6 -anchor n
- pack $w.f2 -side bottom -padx 10 -anchor s
-
- scrollbar $w.f1.vscroll -command "$w.f1.canvas yview"
- pack $w.f1.vscroll -side right -fill y
-
- canvas $w.f1.canvas -relief flat -borderwidth 0 \
- -yscrollcommand "$w.f1.vscroll set"
- frame $w.f1.f
- pack $w.f1.canvas -side right -fill y -expand on
 
         if { $found == 0 } then {
                 if { $filefound == 0 } then {
- message $w.f1.f.m -width 750 -aspect 300 -relief flat -text \
+ message $w.f1.m -width 750 -aspect 300 -relief flat -text \
                         "No help available - unable to open file Documentation/Configure.help. This file should have come with your kernel."
                 } else {
- message $w.f1.f.m -width 400 -aspect 300 -relief flat -text \
+ message $w.f1.m -width 400 -aspect 300 -relief flat -text \
                         "No help available for $var"
                 }
                 label $w.f1.bm -bitmap error
                 wm title $w "RTFM"
         } else {
- text $w.f1.f.m -width 73 -relief flat -wrap word
- $w.f1.f.m insert 0.0 $message
- $w.f1.f.m conf -state disabled -height [$w.f1.f.m index end]
+ text $w.f1.m -width 73 -relief flat -wrap word
+ $w.f1.m insert 0.0 $message
+ $w.f1.m conf -state disabled -height [$w.f1.m index end]
 
                 label $w.f1.bm -bitmap info
                 wm title $w "Configuration help"
         }
- pack $w.f1.f.m -side left
- pack $w.f1.bm $w.f1.f -side left -padx 10
+ pack $w.f1.bm $w.f1.m -side left -padx 10
+ pack $w.f1 -side top
+ set oldFocus [focus]
+
+ # Do the OK button
+ #
+ frame $w.f2
+ button $w.f2.ok -text "OK" \
+ -width 10 -command "destroy $w; catch {focus $oldFocus}"
+ pack $w.f2.ok -side bottom -pady 6 -anchor n
+ pack $w.f2 -side bottom -padx 10 -anchor s
 
+ # Finish off the window
+ #
         focus $w
- set winx [expr [winfo x $parent]+20]
- set winy [expr [winfo y $parent]+20]
+ global winx; global winy
+ set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
         wm geometry $w +$winx+$winy
- set sizok [expr [winfo reqheight $w.f2.ok] + 12]
- set maxy [expr [winfo screenheight .] * 3 / 4]
- set canvtotal [winfo reqheight $w.f1.f.m]
- if [expr $sizok + $canvtotal < $maxy] {
- set sizy $canvtotal
- } else {
- set sizy [expr $maxy - $sizok]
- }
- $w.f1.canvas configure -height $sizy -width [winfo reqwidth $w.f1.f.m] \
- -scrollregion "0 0 [winfo reqwidth $w.f1.f.m] \
- [winfo reqheight $w.f1.f.m]"
- $w.f1.canvas create window 0 0 -anchor nw -window $w.f1.f
- update idletasks
-
- set maxy [winfo screenheight .]
- if [expr $sizok + $canvtotal < $maxy] {
- set sizy [expr $sizok + $canvtotal]
- } else {
- set sizy $maxy
- }
- wm maxsize $w [winfo width $w] $sizy
 }
 
+
+bind all <Alt-s> { catch {exec cp -f .config .config.old}; \
+ writeconfig .config include/linux/autoconf.h; wrapup .wrap }
+
 proc wrapup {w } {
         catch {destroy $w}
         toplevel $w -class Dialog
@@ -554,6 +514,7 @@
         pack $w.f.back -side bottom -pady 10 -anchor s
         pack $w.f -pady 10 -side top -padx 10 -anchor s
         focus $w
+ bind $w <Return> "exit"
         global winx; global winy
         set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
         wm geometry $w +$winx+$winy
@@ -621,3 +582,4 @@
 
 set active_menus [list]
 set processed_top_level 0
+
diff -Naur linux-2.4.0-test1/scripts/tail.tk linux/scripts/tail.tk
--- linux-2.4.0-test1/scripts/tail.tk Sun May 21 20:18:08 2000
+++ linux/scripts/tail.tk Tue May 30 21:51:56 2000
@@ -32,11 +32,11 @@
 update_define 1 $total_menus 0
 update_mainmenu
 
-button .f0.right.save -anchor w -text "Save and Exit" \
+button .f0.right.save -anchor w -text "Save and Exit" -underline 0\
     -command { catch {exec cp -f .config .config.old}; \
                 writeconfig .config include/linux/autoconf.h; wrapup .wrap }
 
-button .f0.right.quit -anchor w -text "Quit Without Saving" \
+button .f0.right.quit -anchor w -text "Quit Without Saving" -underline 0\
     -command { maybe_exit .maybe }
 
 button .f0.right.load -anchor w -text "Load Configuration from File" \
@@ -55,16 +55,6 @@
 pack .f0.left .f0.middle .f0.right -side left -padx 5 -pady 0 -fill y
 pack .f0 -padx 5 -pady 5
 
-update idletasks
-set winy [expr 10 + [winfo reqheight .f0]]
-set scry [lindex [wm maxsize .] 1]
-set winx [expr 10 + [winfo reqwidth .f0]]
-set scrx [lindex [wm maxsize .] 0]
-if {$winx < $scrx} then {set maxx -1} else {set maxx $winx}
-if {$winy < $scry} then {set maxy -1} else {set maxy $winy}
-.f0 configure -width $winx -height $winy
-wm maxsize . $maxx $maxy
-
 #
 # If we cannot write our config files, disable the write button.
 #
@@ -87,3 +77,4 @@
                         .f0.right.save configure -state disabled
                 }
         }
+
diff -Naur linux-2.4.0-test1/scripts/tkgen.c linux/scripts/tkgen.c
--- linux-2.4.0-test1/scripts/tkgen.c Sun May 21 20:18:08 2000
+++ linux/scripts/tkgen.c Tue May 30 21:47:49 2000
@@ -149,49 +149,80 @@
     printf( "\tpack $w.m -pady 10 -side top -padx 10\n" );
     printf( "\twm title $w \"%s\" \n\n", label );
 
+
+ printf( "\tbind $w <Escape> \"catch {focus $oldFocus}; destroy $w; unregister_active %d; break\"\n", menu_num);
+
     /*
      * Attach the "Prev", "Next" and "OK" buttons at the end of the window.
      */
     printf( "\tframe $w.f\n" );
     if ( toplevel )
- printf( "\tbutton $w.f.back -text \"Main Menu\" \\\n" );
+ printf( "\tbutton $w.f.back -text \"Main Menu\" \\\n" );
     else
- printf( "\tbutton $w.f.back -text \"OK\" \\\n" );
+ printf( "\tbutton $w.f.back -text \"OK\" \\\n" );
     printf( "\t\t-width 15 -command \"catch {focus $oldFocus}; destroy $w; unregister_active %d\"\n",
- menu_num );
- printf( "\tbutton $w.f.next -text \"Next\" \\\n" );
- printf( "\t\t-width 15 -command \"catch {focus $oldFocus}; " );
+ menu_num );
+ /*
+ * move functionality into separate block so that it can be reused
+ * for key binding
+ */
+ printf("\tset nextscript ");
     /*
      * We are checking which windows should be destroyed and which are
      * common parrents with the next one. Remember that menu_num field
      * in mainmenu_option record reports number of its *parent* menu.
      */
+ printf(" \"catch {focus $oldFocus}; " );
     if ( menu_num < tot_menu_num
- && menu_first[menu_num + 1]->menu_number != menu_num )
+ && menu_first[menu_num + 1]->menu_number != menu_num )
     {
- int to_destr;
-
- printf( "destroy $w; unregister_active %d; ", menu_num );
- to_destr = menu_first[menu_num]->menu_number;
- while ( to_destr > 0 && menu_first[menu_num + 1]->menu_number != to_destr )
- {
- printf( "catch {destroy .menu%d}; unregister_active %d; ",
- to_destr, to_destr );
- to_destr = menu_first[to_destr]->menu_number;
- }
+ int to_destr;
+
+ printf( "destroy $w; unregister_active %d; ", menu_num );
+ to_destr = menu_first[menu_num]->menu_number;
+ while ( to_destr > 0 && menu_first[menu_num + 1]->menu_number != to_destr )
+ {
+ printf( "catch {destroy .menu%d}; unregister_active %d; ",
+ to_destr, to_destr );
+ to_destr = menu_first[to_destr]->menu_number;
+ }
     }
     printf( "menu%d .menu%d \\\"$title\\\"\"\n",
         menu_num+1, menu_num+1 );
- if ( menu_num == tot_menu_num )
- printf( "\t$w.f.next configure -state disabled\n" );
- printf( "\tbutton $w.f.prev -text \"Prev\" \\\n" );
+
+ printf( "\tbutton $w.f.next -text \"Next\" -underline 0\\\n" );
+ printf( "\t\t-width 15 -command $nextscript\n");
+
+ if ( menu_num == tot_menu_num ){
+ printf( "\t$w.f.next configure -state disabled\n" );
+ /*
+ * this is a bit hackish but Alt-n must be rebound
+ * otherwise if the user press Alt-n on the last menu
+ * it will give him/her the next menu of one of the
+ * previous options
+ */
+ printf( "\tbind all <Alt-n> \"puts \\\"no more menus\\\" \"\n");
+ }
+ else
+ {
+ /*
+ * I should be binding to $w not all - but if I do that I get the error "unknown path"
+ */
+ printf( "\tbind all <Alt-n> $nextscript\n");
+ }
+ printf( "\tbutton $w.f.prev -text \"Prev\" -underline 0\\\n" );
     printf( "\t\t-width 15 -command \"catch {focus $oldFocus}; destroy $w; unregister_active %d; menu%d .menu%d \\\"$title\\\"\"\n",
- menu_num, menu_num-1, menu_num-1 );
- if ( menu_num == 1 )
- printf( "\t$w.f.prev configure -state disabled\n" );
+ menu_num, menu_num-1, menu_num-1 );
+ if ( menu_num == 1 ){
+ printf( "\t$w.f.prev configure -state disabled\n" );
+ }
+ else
+ {
+ printf( "\tbind $w <Alt-p> \"catch {focus $oldFocus}; destroy $w; unregister_active %d; menu%d .menu%d \\\"$title\\\";break\"\n",
+ menu_num, menu_num-1, menu_num-1 );
+ }
     printf( "\tpack $w.f.back $w.f.next $w.f.prev -side left -expand on\n" );
     printf( "\tpack $w.f -pady 10 -side bottom -anchor w -fill x\n" );
-
     /*
      * Lines between canvas and other areas of the window.
      */
@@ -215,6 +246,12 @@
     printf( "\t\t-relief flat -borderwidth 0 -yscrollcommand \"$w.config.vscroll set\" \\\n" );
     printf( "\t\t-width [expr [winfo screenwidth .] * 1 / 2] \n" );
     printf( "\tframe $w.config.f\n" );
+ printf( "\tbind $w <Key-Down> \"$w.config.canvas yview scroll 1 unit;break;\"\n");
+ printf( "\tbind $w <Key-Up> \"$w.config.canvas yview scroll -1 unit;break;\"\n");
+ printf( "\tbind $w <Key-Next> \"$w.config.canvas yview scroll 1 page;break;\"\n");
+ printf( "\tbind $w <Key-Prior> \"$w.config.canvas yview scroll -1 page;break;\"\n");
+ printf( "\tbind $w <Key-Home> \"$w.config.canvas yview moveto 0;break;\"\n");
+ printf( "\tbind $w <Key-End> \"$w.config.canvas yview moveto 1 ;break;\"\n");
     printf( "\tpack $w.config.canvas -side right -fill y\n" );
     printf("\n\n");
 }
@@ -265,8 +302,6 @@
         || cfg->token == token_define_int || cfg->token == token_define_string
         || cfg->token == token_define_tristate || cfg->token == token_unset )
             return;
- if ( cfg->token == token_comment && line_num == -1 )
- return;
     }
     else
     {
@@ -466,7 +501,6 @@
                 menu_num, line_num );
             break;
 
- case token_comment:
         case token_mainmenu_option:
             if ( line_num >= 0 )
             {
@@ -1138,7 +1172,6 @@
         case token_bool:
         case token_choice_header:
         case token_choice_item:
- case token_comment:
         case token_dep_bool:
         case token_dep_tristate:
         case token_dep_mbool:
@@ -1193,8 +1226,6 @@
     {
         int menu_line = 0;
         int nr_submenu = imenu;
- int menu_name_omitted = 0;
- int opt_count = 0;
 
         clear_globalflags();
         start_proc( menu_first[imenu]->label, imenu,
@@ -1216,21 +1247,6 @@
                 cfg = menu_last[nr_submenu];
                 break;
 
- case token_comment:
- if ( !cfg->menu_line && !menu_name_omitted )
- {
- cfg->menu_line = -1;
- menu_name_omitted = 1;
- }
- else
- {
- menu_name_omitted = 1;
- cfg->menu_line = menu_line++;
- printf( "\tcomment $w.config.f %d %d \"%s\"\n",
- cfg->menu_number, cfg->menu_line, cfg->label );
- }
- break;
-
             case token_bool:
                 cfg->menu_line = menu_line++;
                 printf( "\tbool $w.config.f %d %d \"%s\" %s\n",
@@ -1248,10 +1264,8 @@
                 printf( "\tminimenu $w.config.f %d %d \"%s\" tmpvar_%d %s\n",
                     cfg->menu_number, cfg->menu_line, cfg->label,
                     -(cfg->nameindex), vartable[cfg->next->nameindex].name );
- printf( "\tmenu $w.config.f.x%d.x.menu -title \"%s\"\n",
- cfg->menu_line, cfg->label );
+ printf( "\tmenu $w.config.f.x%d.x.menu\n", cfg->menu_line );
                 cfg1 = cfg;
- opt_count = 0;
                 break;
 
             case token_choice_item:
@@ -1259,12 +1273,6 @@
                 printf( "\t$w.config.f.x%d.x.menu add radiobutton -label \"%s\" -variable tmpvar_%d -value \"%s\" -command \"update_active\"\n",
                     cfg1->menu_line, cfg->label, -(cfg1->nameindex),
                     cfg->label );
- opt_count++;
- if ( cfg->next && cfg->next->token != token_choice_item ) {
- /* last option in the menu */
- printf( "\tmenusplit $w $w.config.f.x%d.x.menu %d\n",
- cfg1->menu_line, opt_count );
- }
                 break;
 
             case token_dep_bool:
@@ -1486,3 +1494,4 @@
      * prepended and tail.tk appended to create an executable wish script.
      */
 }
+

Adds sensible keybindings to xconfig e.g. PageDown, PageUp, Alt-S for Save,
Esc for leaving a submenu, etc.
Kip Macy, kip@eventdriven.org

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:26 EST