[PATCH] some xconfig enhancements

From: Andrzej Krzysztofowicz (ankry@green.mif.pg.gda.pl)
Date: Thu May 18 2000 - 04:06:02 EST


Hi,
  The following patch contains some minor xconfig fixes & enhancements.
It is against 2.2.16pre, but should apply cleanly to both: 2.2.16pre
and 2.3.99pre.
  The patch contains:
- comments implemented
- increased buffer for choice list description (large choice lists almost
  hits the old limit)
- large choice menus splitted on low-resolution screens to enable choice
  of any value
- scrolling in Help windows implemented (usefulfor log helps and/or low
  display resolution)
- make Help window position dependent on current (not main) menu position
- fixed maximum width of the main menu to be able to access all buttons even
  on low resolution screens.

Tested on 640x480. Possibly should also work with lower resolution.

Any comments ?

Andrzej

*****************************************************************
diff -u --recursive linux-2.2.16pre1/Documentation/kbuild/config-language.txt linux/Documentation/kbuild/config-language.txt
--- linux-2.2.16pre1/Documentation/kbuild/config-language.txt Tue May 2 01:00:11 2000
+++ linux/Documentation/kbuild/config-language.txt Mon May 1 23:41:20 2000
@@ -193,7 +193,7 @@
 
 Configure: implemented
 Menuconfig: implemented
-Xconfig: does not display, but writes to output files
+Xconfig: implemented
 mconfig: implemented
 
 Example:
diff -u --recursive linux-2.2.16pre1/scripts/header.tk linux/scripts/header.tk
--- linux-2.2.16pre1/scripts/header.tk Tue May 2 01:00:15 2000
+++ linux/scripts/header.tk Mon May 1 23:31:59 2000
@@ -312,7 +312,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"
+ -command "dohelp .dohelp $helpidx .menu$mnum"
         pack $w.x$line.help -side right -fill y
         pack $w.x$line.l -side right -fill both -expand on
 }
@@ -325,9 +325,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 +339,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,6 +400,17 @@
         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
@@ -412,11 +423,20 @@
         pack $w.x$line -anchor w -fill both -expand on
 }
 
-proc comment {w line text } {
-#nothing done for comments now.
+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 dohelp {w var } {
+proc dohelp {w var parent} {
         catch {destroy $w}
         toplevel $w -class Dialog
 
@@ -442,45 +462,73 @@
                         " 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.m -width 750 -aspect 300 -relief flat -text \
+ message $w.f1.f.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.m -width 400 -aspect 300 -relief flat -text \
+ message $w.f1.f.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.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]
+ 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]
 
                 label $w.f1.bm -bitmap info
                 wm title $w "Configuration help"
         }
- 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
+ pack $w.f1.f.m -side left
+ pack $w.f1.bm $w.f1.f -side left -padx 10
 
- # Finish off the window
- #
         focus $w
- global winx; global winy
- set winx [expr [winfo x .]+30]; set winy [expr [winfo y .]+30]
+ set winx [expr [winfo x $parent]+20]
+ set winy [expr [winfo y $parent]+20]
         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
 }
 
 proc wrapup {w } {
diff -u --recursive linux-2.2.16pre1/scripts/tail.tk linux/scripts/tail.tk
--- linux-2.2.16pre1/scripts/tail.tk Tue May 2 01:00:15 2000
+++ linux/scripts/tail.tk Mon May 1 23:15:23 2000
@@ -55,6 +55,16 @@
 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.
 #
diff -u --recursive linux-2.2.16pre1/scripts/tkgen.c linux/scripts/tkgen.c
--- linux-2.2.16pre1/scripts/tkgen.c Tue May 2 01:00:15 2000
+++ linux/scripts/tkgen.c Mon May 1 23:23:39 2000
@@ -265,6 +265,8 @@
         || 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
     {
@@ -464,6 +466,7 @@
                 menu_num, line_num );
             break;
 
+ case token_comment:
         case token_mainmenu_option:
             if ( line_num >= 0 )
             {
@@ -1135,6 +1138,7 @@
         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:
@@ -1189,6 +1193,8 @@
     {
         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,
@@ -1210,6 +1216,21 @@
                 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",
@@ -1227,8 +1248,10 @@
                 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\n", cfg->menu_line );
+ printf( "\tmenu $w.config.f.x%d.x.menu -title \"%s\"\n",
+ cfg->menu_line, cfg->label );
                 cfg1 = cfg;
+ opt_count = 0;
                 break;
 
             case token_choice_item:
@@ -1236,6 +1259,12 @@
                 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:
diff -u --recursive linux-2.2.16pre1/scripts/tkparse.c linux/scripts/tkparse.c
--- linux-2.2.16pre1/scripts/tkparse.c Tue May 2 01:00:15 2000
+++ linux/scripts/tkparse.c Tue Apr 25 23:36:15 2000
@@ -130,7 +130,7 @@
 static const char * get_qstring( const char * pnt, char ** label )
 {
     char quote_char;
- char newlabel [1024];
+ char newlabel [2048];
     char * pnt1;
 
     /* advance to the open quote */
@@ -705,7 +705,7 @@
  */
 static void do_source( const char * filename )
 {
- char buffer [1024];
+ char buffer [2048];
     FILE * infile;
     const char * old_file;
     int old_lineno;
*****************************************************************

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Technical University of Gdansk

- 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 : Tue May 23 2000 - 21:00:14 EST