From 1a22ddea8d0baa25b070874d99f152c5a22f5c6a Mon Sep 17 00:00:00 2001 From: bostic Date: Wed, 11 Dec 1996 15:04:38 +0000 Subject: [PATCH] RAZ's new version, merged with my stuff -- searches aren't merged right, yet, but it compiles --- motif/m_main.c | 28 +-- motif_l/m_menu.c | 214 +++++++-------------- motif_l/m_options.c | 523 ++++++++++++++++++++++++++++++++++++++-------------- motif_l/m_prompt.c | 10 +- motif_l/m_search.c | 127 +++++-------- motif_l/m_vi.c | 50 ++++- 6 files changed, 563 insertions(+), 389 deletions(-) diff --git a/motif/m_main.c b/motif/m_main.c index 7eedafd3..64eee04a 100644 --- a/motif/m_main.c +++ b/motif/m_main.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: m_main.c,v 8.24 1996/12/11 13:34:34 bostic Exp $ (Berkeley) $Date: 1996/12/11 13:34:34 $"; +static const char sccsid[] = "$Id: m_main.c,v 8.25 1996/12/11 15:04:38 bostic Exp $ (Berkeley) $Date: 1996/12/11 15:04:38 $"; #endif /* not lint */ #include @@ -55,6 +55,9 @@ static void onexit __P((void)); String fallback_rsrcs[] = { "*font: -*-*-*-r-*--14-*-*-*-m-*-*-*", + "*text*fontList: -*-*-*-r-*--14-*-*-*-m-*-*-*", + "*Menu*fontList: -*-helvetica-bold-r-normal--14-*-*-*-*-*-*-*", + "*fontList: -*-helvetica-medium-r-normal--14-*-*-*-*-*-*-*", "*pointerShape: xterm", "*busyShape: watch", "*iconName: vi", @@ -63,12 +66,14 @@ String fallback_rsrcs[] = { "*iconForeground: XtDefaultForeground", "*iconBackground: XtDefaultBackground", - /* layout for the temporary preferences page */ - "*toggleOptions.numColumns: 6", - "*intOptions.numColumns: 4", - "*otherOptions.numColumns: 3", - "*intOptions*columns: 10", - "*otherOptions*columns: 18", + /* layout for the tag stack dialog */ + "*Tags*visibleItemCount: 5", + + /* layout for the new, temporary preferences page */ + "*toggleOptions.numColumns: 6", /* also used by Find */ + "*Preferences*tabWidthPercentage: 0", + "*Preferences*tabs.shadowThickness: 2", + "*Preferences*tabs.font: -*-helvetica-bold-r-normal--14-*-*-*-*-*-*-*", /* --------------------------------------------------------------------- * * anything below this point is only defined when we are not running CDE * @@ -78,10 +83,11 @@ String fallback_rsrcs[] = { * (e.g. VUE on HPUX). The result is that you don't look * like a normal desktop application */ - "?highlightColor: red", - "?background: gray75", - "?screen.background: wheat", - "?highlightColor: red" + "?highlightColor: red", + "?background: gray75", + "?screen.background: wheat", + "?highlightColor: red", + "?Preferences*options.background: gray90", }; static XutResource resource[] = { diff --git a/motif_l/m_menu.c b/motif_l/m_menu.c index 75850017..b68ee985 100644 --- a/motif_l/m_menu.c +++ b/motif_l/m_menu.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: m_menu.c,v 8.17 1996/12/11 13:08:45 bostic Exp $ (Berkeley) $Date: 1996/12/11 13:08:45 $"; +static const char sccsid[] = "$Id: m_menu.c,v 8.18 1996/12/11 15:04:38 bostic Exp $ (Berkeley) $Date: 1996/12/11 15:04:38 $"; #endif /* not lint */ #include @@ -31,6 +31,9 @@ static const char sccsid[] = "$Id: m_menu.c,v 8.17 1996/12/11 13:08:45 bostic Ex #include "../ip_vi/ip.h" #include "ipc_extern.h" +/* save this for creation of children */ +static Widget main_widget = NULL; + /* This module defines the menu structure for vi. Each menu * item has an action routine associated with it. For the most * part, those actions will simply call __vi_send with vi commands. @@ -192,7 +195,7 @@ static String get_file( w, prompt ) /* create one? */ if ( db == NULL ){ - db = XmCreateFileSelectionDialog( w, "file", NULL, 0 ); + db = XmCreateFileSelectionDialog( main_widget, "file", NULL, 0 ); XtAddCallback( db, XmNokCallback, ok_file_name, NULL ); XtAddCallback( db, XmNcancelCallback, __vi_cancel_cb, NULL ); } @@ -208,104 +211,6 @@ static String get_file( w, prompt ) } -/* Utility: Get a string (using standard File Selection Dialog Box) */ - -static String string_name; - - -#if defined(__STDC__) -static void ok_string( Widget w, - XtPointer client_data, - XtPointer call_data - ) -#else -static void ok_string( w, client_data, call_data ) - Widget w; - XtPointer client_data; - XtPointer call_data; -#endif -{ - XmSelectionBoxCallbackStruct *cbs; - - cbs = (XmSelectionBoxCallbackStruct *) call_data; - XmStringGetLtoR( cbs->value, XmSTRING_DEFAULT_CHARSET, &string_name ); - - have_answer = True; -} - - -#if defined(__STDC__) -static String get_string( Widget w, String prompt, String title ) -#else -static String get_string( w, prompt, title ) - Widget w; - String prompt; - String title; -#endif -{ - /* make it static so we can reuse it */ - static Widget db; - XmString xmstr; - - /* our return parameter */ - if ( string_name != NULL ) { - XtFree( string_name ); - string_name = NULL; - } - - /* create one? */ - if ( db == NULL ){ - db = XmCreatePromptDialog( w, "string", NULL, 0 ); - XtAddCallback( db, XmNokCallback, ok_string, NULL ); - XtAddCallback( db, XmNcancelCallback, __vi_cancel_cb, NULL ); - } - - /* this one has space for a prompt... */ - xmstr = XmStringCreateSimple( prompt ); - XtVaSetValues( db, XmNselectionLabelString, xmstr, 0 ); - XmStringFree( xmstr ); - - /* set the title as well */ - XtVaSetValues( XtParent(db), XmNtitle, title, 0 ); - - /* wait for a response */ - __vi_modal_dialog( db ); - - /* done */ - return string_name; -} - - -/* - * string_command -- - * Get a string and send it with the command to the core. - */ -static void -string_command(w, code, prompt, title) - Widget w; - int code; - String prompt; - String title; -{ - IP_BUF ipb; - char *str; - - if ((str = get_string(w, prompt, title)) != NULL ) { - ipb.code = code; - ipb.str = str; - /* - * XXX - * This is REALLY sleazy. We pass the nul along with the - * string so that the core editor doesn't have to copy the - * string to get a nul termination. This should be fixed - * as part of making the editor fully 8-bit clean. - */ - ipb.len = strlen(str) + 1; - __vi_send("s", &ipb); - } -} - - /* * file_command -- * Get a file name and send it with the command to the core. @@ -456,7 +361,7 @@ ma_find(w, call_data, client_data) Widget w; XtPointer call_data, client_data; { - __vi_show_search_dialog( w, "Find" ); + __vi_show_search_dialog( main_widget, "Find" ); } static void @@ -468,25 +373,11 @@ ma_find_next(w, call_data, client_data) } static void -ma_tag(w, call_data, client_data) - Widget w; - XtPointer call_data, client_data; -{ - IP_BUF ipb; - - ipb.code = VI_TAG; - (void)__vi_send(NULL, &ipb); -} - -static void -ma_tagsplit(w, call_data, client_data) +ma_tags(w, call_data, client_data) Widget w; XtPointer call_data, client_data; { - IP_BUF ipb; - - ipb.code = VI_TAGSPLIT; - (void)__vi_send(NULL, &ipb); + __vi_show_tags_dialog( main_widget, "Tag Stack" ); } static void @@ -498,11 +389,11 @@ ma_tagpop(w, call_data, client_data) } static void -ma_tagas(w, call_data, client_data) +ma_tagtop(w, call_data, client_data) Widget w; XtPointer call_data, client_data; { - string_command(w, VI_TAGAS, "Enter Tag Name:", "Tag"); + __vi_send_command_string( ":tagtop" ); } #if defined(__STDC__) @@ -517,7 +408,7 @@ static void ma_preferences( w, call_data, client_data ) XtPointer client_data; #endif { - __vi_show_options_dialog( w, "Preferences" ); + __vi_show_options_dialog( main_widget, "Preferences" ); } @@ -526,6 +417,8 @@ static void ma_preferences( w, call_data, client_data ) typedef struct { String title; void (*action)(); + String accel; /* for Motif */ + String accel_text; /* for the user */ } pull_down; typedef struct { @@ -535,48 +428,47 @@ typedef struct { } menu_bar; static pull_down file_menu[] = { - { "Edit File...", ma_edit_file }, - { "", NULL }, - { "Split Window...", ma_split }, - { "", NULL }, - { "Save ", ma_save }, - { "Save As...", ma_save_as }, - { "", NULL }, - { "Write and Quit", ma_wq }, - { "Quit", ma_quit }, - { NULL, NULL }, + { "Edit File...", ma_edit_file, "Alte", "Alt+E" }, + { "", NULL, NULL, NULL }, + { "Split Window...", ma_split, NULL, NULL }, + { "", NULL, NULL, NULL }, + { "Save ", ma_save, "Alts", "Alt+S" }, + { "Save As...", ma_save_as, "Shift Alts", "Shift+Alt+S" }, + { "", NULL, NULL, NULL }, + { "Write and Quit", ma_wq, "Shift Altq", "Shift+Alt+Q" }, + { "Quit", ma_quit, "Altq", "Alt+Q" }, + { NULL, NULL, NULL, NULL }, }; static pull_down edit_menu[] = { - { "Undo", ma_undo }, - { "", NULL }, - { "Cut", ma_cut }, - { "Copy", ma_copy }, - { "Paste", ma_paste }, - { "", NULL }, - { "Find", ma_find }, - { "Find Next", ma_find_next }, - { NULL, NULL }, + { "Undo", ma_undo, NULL, NULL }, + { "", NULL, NULL, NULL }, + { "Cut", ma_cut, "Altx", "Alt+X" }, + { "Copy", ma_copy, "Altc", "Alt+C" }, + { "Paste", ma_paste, "Altv", "Alt+V" }, + { "", NULL, NULL, NULL }, + { "Find", ma_find, "Altf", "Alt+F" }, + { "Find Next", ma_find_next, "Altg", "Alt+G" }, + { NULL, NULL, NULL, NULL }, }; static pull_down options_menu[] = { - { "Preferences", ma_preferences }, - { "Command Mode Maps", NULL }, - { "Insert Mode Maps", NULL }, - { NULL, NULL }, + { "Preferences", ma_preferences, NULL, NULL }, + { "Command Mode Maps", NULL, NULL, NULL }, + { "Insert Mode Maps", NULL, NULL, NULL }, + { NULL, NULL, NULL, NULL }, }; static pull_down tag_menu[] = { - { "Go To Tag", ma_tag }, - { "Split To Tag", ma_tagsplit }, - { "Tag As...", ma_tagas }, - { "", NULL }, - { "Pop", ma_tagpop }, - { NULL, NULL }, + { "Show Tag Stack", ma_tags, "Altt", "Alt+T" }, + { "", NULL, NULL, NULL }, + { "Pop Tag", ma_tagpop, NULL, NULL }, + { "Clear Stack", ma_tagtop, NULL, NULL }, + { NULL, NULL, NULL, NULL }, }; static pull_down help_menu[] = { - { NULL, NULL }, + { NULL, NULL, NULL, NULL }, }; static menu_bar main_menu[] = { @@ -598,18 +490,30 @@ static void add_entries( parent, actions ) #endif { Widget w; + XmString str; for ( ; actions->title != NULL; actions++ ) { /* a separator? */ if ( *actions->title != '\0' ) { w = XmCreatePushButton( parent, actions->title, NULL, 0 ); - if ( actions->action != NULL ) + if ( actions->action == NULL ) + XtSetSensitive( w, False ); + else XtAddCallback( w, XmNactivateCallback, (XtCallbackProc) actions->action, actions ); + if ( actions->accel != NULL ) { + str = XmStringCreateSimple( actions->accel_text ); + XtVaSetValues( w, + XmNaccelerator, actions->accel, + XmNacceleratorText, str, + 0 + ); + XmStringFree( str ); + } } else { w = XmCreateSeparator( parent, "separator", NULL, 0 ); @@ -632,7 +536,10 @@ vi_create_menubar(parent) Widget menu, pull, button; menu_bar *ptr; - menu = XmCreateMenuBar( parent, "menu", NULL, 0 ); + /* save this for creation of children */ + main_widget = parent; + + menu = XmCreateMenuBar( parent, "Menu", NULL, 0 ); for ( ptr=main_menu; ptr->title != NULL; ptr++ ) { @@ -644,8 +551,11 @@ vi_create_menubar(parent) if ( strcmp( ptr->title, "Help" ) == 0 ) XtVaSetValues( menu, XmNmenuHelpWidget, button, 0 ); +#if 0 + /* These screw up accelerator processing. Punt for now */ if ( ptr->mnemonic ) XtVaSetValues( button, XmNmnemonic, ptr->mnemonic, 0 ); +#endif XtManageChild( button ); } diff --git a/motif_l/m_options.c b/motif_l/m_options.c index 40611164..6cd76508 100644 --- a/motif_l/m_options.c +++ b/motif_l/m_options.c @@ -10,7 +10,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: m_options.c,v 8.4 1996/12/11 13:09:00 bostic Exp $ (Berkeley) $Date: 1996/12/11 13:09:00 $"; +static const char sccsid[] = "$Id: m_options.c,v 8.5 1996/12/11 15:04:39 bostic Exp $ (Berkeley) $Date: 1996/12/11 15:04:39 $"; #endif /* not lint */ #include @@ -33,7 +33,8 @@ typedef enum { optToggle, optInteger, optString, - optFile + optFile, + optTerminator } optKind; typedef struct { @@ -42,6 +43,14 @@ typedef struct { void *value; /* really should get this from core */ } optData; +typedef struct { + String name; + Widget holder; + optData *toggles; + optData *ints; + optData *others; +} optSheet; + /* constants */ @@ -50,108 +59,219 @@ typedef struct { /* in production, get these from the resource list */ #define toggleColumns 6 -#define intColumns 4 -#define otherColumns 3 #endif -/* in production, get these from the resource list */ - -#define intWidth 10 /* characters */ -#define otherWidth 18 /* characters */ +#define LargestSheet 0 /* file */ /* * global data */ -static optData toggles[] = { - { optToggle, "altwerase", (void *) False }, - { optToggle, "extended", (void *) False }, - { optToggle, "mesg", (void *) True }, - { optToggle, "ruler", (void *) False }, - { optToggle, "tildeop", (void *) False }, - { optToggle, "autoindent", (void *) True }, - { optToggle, "modeline", (void *) False }, - { optToggle, "timeout", (void *) True }, - { optToggle, "autoprint", (void *) True }, - { optToggle, "flash", (void *) True }, +static Widget preferences = NULL; + +static optData Search_toggles[] = { + { optToggle, "iclower", (void *) False }, { optToggle, "searchincr", (void *) True }, - { optToggle, "ttywerase", (void *) False }, + { optToggle, "wrapscan", (void *) True }, + { optToggle, "extended", (void *) False }, + { optToggle, "edcompatible", (void *) False }, + { optToggle, "ignorecase", (void *) True }, + { optToggle, "magic", (void *) True }, + { optTerminator,NULL, (void *) NULL } +}, + File_toggles[] = { + { optToggle, "readonly", (void *) False }, { optToggle, "autowrite", (void *) False }, + { optToggle, "warn", (void *) True }, + { optToggle, "lock", (void *) True }, + { optToggle, "writeany", (void *) False }, + { optTerminator,NULL, (void *) NULL } +}, + Shell_toggles[] = { { optToggle, "secure", (void *) False }, - { optToggle, "verbose", (void *) False }, - { optToggle, "iclower", (void *) False }, + { optTerminator,NULL, (void *) NULL } +}, + Ex_toggles[] = { + { optToggle, "autoprint", (void *) True }, + { optToggle, "exrc", (void *) False }, + { optToggle, "prompt", (void *) True }, + { optTerminator,NULL, (void *) NULL } +}, + Programming_toggles[] = { + { optToggle, "lisp", (void *) False }, + { optToggle, "autoindent", (void *) True }, + { optToggle, "showmatch", (void *) False }, + { optTerminator,NULL, (void *) NULL } +}, + Display_toggles[] = { + { optToggle, "list", (void *) False }, { optToggle, "number", (void *) False }, - { optToggle, "warn", (void *) True }, - { optToggle, "beautify", (void *) False }, - { optToggle, "ignorecase", (void *) True }, { optToggle, "octal", (void *) False }, - { optToggle, "showmatch", (void *) False }, - { optToggle, "open", (void *) True }, { optToggle, "showmode", (void *) False }, + { optToggle, "comment", (void *) False }, { optToggle, "windowname", (void *) False }, { optToggle, "leftright", (void *) False }, - { optToggle, "optimize", (void *) True }, - { optToggle, "slowopen", (void *) False }, - { optToggle, "comment", (void *) False }, - { optToggle, "lisp", (void *) False }, - { optToggle, "prompt", (void *) True }, - { optToggle, "sourceany", (void *) False }, - { optToggle, "wrapscan", (void *) True }, - { optToggle, "edcompatible", (void *) False }, - { optToggle, "list", (void *) False }, - { optToggle, "readonly", (void *) False }, - { optToggle, "writeany", (void *) False }, - { optToggle, "lock", (void *) True }, - { optToggle, "redraw", (void *) False }, - { optToggle, "errorbells", (void *) False }, - { optToggle, "magic", (void *) True }, + { optToggle, "ruler", (void *) False }, + { optTerminator,NULL, (void *) NULL } +}, + Insert_toggles[] = { + { optToggle, "altwerase", (void *) False }, + { optToggle, "ttywerase", (void *) False }, + { optToggle, "timeout", (void *) True }, + { optToggle, "beautify", (void *) False }, { optToggle, "remap", (void *) True }, - { optToggle, "exrc", (void *) False }, - { optToggle, "terse", (void *) False }, + { optTerminator,NULL, (void *) NULL } +}, + Command_toggles[] = { + { optToggle, "tildeop", (void *) False }, + { optTerminator,NULL, (void *) NULL } +}, + Error_toggles[] = { + { optToggle, "verbose", (void *) False }, + { optToggle, "errorbells", (void *) False }, + { optToggle, "flash", (void *) True }, + { optTerminator,NULL, (void *) NULL } }; -static optData ints[] = { - { optInteger, "scroll", (void *) "11" }, - { optInteger, "hardtabs", (void *) "0" }, +static optData Programming_ints[] = { + { optInteger, "matchtime", (void *) "7" }, { optInteger, "shiftwidth", (void *) "4" }, - { optInteger, "window", (void *) "23" }, - { optInteger, "keytime", (void *) "6" }, - { optInteger, "sidescroll", (void *) "16" }, - { optInteger, "wraplen", (void *) "0" }, - { optInteger, "columns", (void *) "80" }, - { optInteger, "lines", (void *) "24" }, - { optInteger, "wrapmargin", (void *) "0" }, - { optInteger, "tabstop", (void *) "8" }, - { optInteger, "escapetime", (void *) "1" }, { optInteger, "taglength", (void *) "0" }, - { optInteger, "matchtime", (void *) "7" }, + { optTerminator,NULL, (void *) NULL } +}, + Display_ints[] = { { optInteger, "report", (void *) "5" }, + { optInteger, "tabstop", (void *) "8" }, + { optTerminator,NULL, (void *) NULL } +}, + Insert_ints[] = { + { optInteger, "wrapmargin", (void *) "0" }, + { optInteger, "escapetime", (void *) "1" }, + { optInteger, "wraplen", (void *) "0" }, + { optTerminator,NULL, (void *) NULL } }; -static optData others[] = { - { optString, "filec", (void *) "^[" }, - { optString, "msgcat", (void *) "./" }, - { optString, "noprint", (void *) "" }, - { optString, "backup", (void *) "" }, - { optString, "cdpath", (void *) ":" }, - { optString, "cedit", (void *) "" }, - { optString, "print", (void *) "" }, - { optString, "term", (void *) "motif" }, - { optFile, "directory", (void *) "/tmp" }, +static optData Search_others[] = { { optString, "paragraphs", (void *) "IPLPPPQPP LIpplpipbp" }, + { optString, "sections", (void *) "NHSHH HUnhsh" }, + { optTerminator,NULL, (void *) NULL } +}, + File_others[] = { + { optString, "filec", (void *) "^[" }, { optString, "path", (void *) "src:include:/debugger/src:/debugger/include/" }, { optFile, "recdir", (void *) "/var/tmp/vi.recover" }, - { optString, "sections", (void *) "NHSHH HUnhsh" }, + { optFile, "directory", (void *) "/tmp" }, + { optString, "backup", (void *) "" }, + { optTerminator,NULL, (void *) NULL } +}, + Shell_others[] = { + { optString, "cdpath", (void *) ":" }, { optFile, "shell", (void *) "/bin/csh" }, { optString, "shellmeta", (void *) "~{[*?$`'\"\\" }, + { optTerminator,NULL, (void *) NULL } +}, + Ex_others[] = { + { optString, "cedit", (void *) "" }, + { optTerminator,NULL, (void *) NULL } +}, + Programming_others[] = { { optString, "tags", (void *) "tags /debugger/tmp/tags10 /debugger/tags /debugger/lib/tags" }, + { optTerminator,NULL, (void *) NULL } +}, + Display_others[] = { + { optString, "print", (void *) "" }, + { optString, "noprint", (void *) "" }, + { optTerminator,NULL, (void *) NULL } +}, + Error_others[] = { + { optString, "msgcat", (void *) "./" }, + { optTerminator,NULL, (void *) NULL } +}; + +static optSheet sheets[] = { + { "File", /* must be first because it's the largest */ + NULL, + File_toggles, + NULL, + File_others + }, + { "Search", + NULL, + Search_toggles, + NULL, + Search_others + }, + { "Shell", + NULL, + Shell_toggles, + NULL, + Shell_others + }, + { "Ex", + NULL, + Ex_toggles, + NULL, + Ex_others + }, + { "Programming", + NULL, + Programming_toggles, + Programming_ints, + Programming_others + }, + { "Display", + NULL, + Display_toggles, + Display_ints, + Display_others + }, + { "Insert", + NULL, + Insert_toggles, + Insert_ints, + NULL + }, + { "Command", + NULL, + Command_toggles, + NULL, + NULL + }, + { "Error", + NULL, + Error_toggles, + NULL, + Error_others + }, }; /* callbacks */ +#if defined(SelfTest) +void __vi_cancel_cb() +{ + puts( "cancelled" ); +} +#endif + + +static void destroyed() +{ + int i; + + puts( "destroyed" ); + + /* some window managers destroy us upon popdown */ + for (i=0; iname ); + option->value = (void *) set; #if defined(SelfTest) printf( "sending command <<%s>>\n", buffer ); @@ -189,6 +310,11 @@ static void change_string( w, option ) str = XmTextFieldGetString( w ); sprintf( buffer, ":set %s=%s", option->name, str ); + /* Note memory leak. We should free the old string, but that + * would require another bit to let us know if it had been allocated. + */ + option->value = (void *) str; + #if defined(SelfTest) printf( "sending command <<%s>>\n", buffer ); #else @@ -197,7 +323,7 @@ static void change_string( w, option ) } -/* add a control to the property sheet */ +/* add toggles to the property sheet */ #if defined(__STDC__) static void add_toggle( Widget parent, optData *option ) @@ -218,66 +344,172 @@ static void add_toggle( parent, option ) XtAddCallback( w, XmNvalueChangedCallback, change_toggle, option ); } - -/* draw a matrix of text fields and their labels - * Note that rowcolumns widgets are column major, so we - * need to go through this nonsense rather than just adding the - * darn things in order - */ -#define numRows(cols,count) ((2*(count)+(cols)-1)/(cols)) +static Widget create_toggles( outer, toggles ) + Widget outer; + optData *toggles; +{ + Widget inner; + int i; + + inner = XtVaCreateWidget( "toggleOptions", + xmRowColumnWidgetClass, + outer, + XmNpacking, XmPACK_COLUMN, +#if defined(SelfTest) + XmNnumColumns, toggleColumns, +#endif + XmNtopAttachment, XmATTACH_FORM, + XmNrightAttachment, XmATTACH_FORM, + XmNleftAttachment, XmATTACH_FORM, + 0 + ); + + /* first the booleans */ + for (i=0; toggles[i].kind != optTerminator; i++) { + add_toggle( inner, &toggles[i] ); + } + XtManageChild( inner ); + + return inner; +} + + +/* draw text fields and their labels */ #if defined(__STDC__) static void add_string_options( Widget parent, - optData *options, - int count, - int width + optData *options ) #else -static void add_string_options( parent, options, count, width ) +static void add_string_options( parent, options ) Widget parent; optData *options; - int count; - int width; #endif { - int i; - Widget f, w; + int i; + Widget f, w, l; + + for ( i=0; options[i].kind != optTerminator; i++ ) { - for ( i=0; iname, + xmFormWidgetClass, + parent, + XmNtopAttachment, XmATTACH_FORM, + XmNrightAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + XmNleftAttachment, XmATTACH_FORM, + XmNshadowType, XmSHADOW_ETCHED_IN, + XmNshadowThickness, 2, + XmNverticalSpacing, 4, + XmNhorizontalSpacing, 4, + 0 + ); + + /* add the toggles */ + inner = create_toggles( outer, sheet->toggles ); + + inner = XtVaCreateWidget( "otherOptions", + xmRowColumnWidgetClass, + outer, + XmNpacking, XmPACK_COLUMN, + XmNtopAttachment, XmATTACH_WIDGET, + XmNtopWidget, inner, + XmNrightAttachment, XmATTACH_FORM, + XmNbottomAttachment, XmATTACH_FORM, + XmNleftAttachment, XmATTACH_FORM, + 0 + ); + + /* then the ints */ + if ( sheet->ints != NULL ) { + add_string_options( inner, sheet->ints ); + } + + /* then the rest */ + if ( sheet->others != NULL ) { + add_string_options( inner, sheet->others ); + } + XtManageChild( inner ); + + /* finally, force resize of the parent */ + XtVaGetValues( outer, XmNheight, &height, 0 ); + XtVaSetValues( parent, XmNheight, height, 0 ); + + return outer; +} + + +/* change preferences to another sheet */ + +static void change_sheet( parent, current ) + Widget parent; + int current; +{ + static int current_sheet = -1; + + /* create a new one? */ + if ( sheets[current].holder == NULL ) + sheets[current].holder = create_sheet( parent, &sheets[current] ); + + /* done with the old one? */ + if ( current_sheet != -1 && sheets[current_sheet].holder != NULL ) + XtUnmanageChild( sheets[current_sheet].holder ); + + current_sheet = current; + XtManageChild( sheets[current].holder ); + XtManageChild( parent ); +} /* Draw and display a dialog the describes nvi options */ @@ -290,8 +522,12 @@ static Widget create_options_dialog( parent, title ) String title; #endif { - Widget box, form, form2; + Widget box, form, inner; int i; + char buffer[1024]; + + /* already built? */ + if ( preferences != NULL ) return preferences; box = XtVaCreatePopupShell( title, xmDialogShellWidgetClass, @@ -301,52 +537,37 @@ static Widget create_options_dialog( parent, title ) 0 ); XtAddCallback( box, XmNpopdownCallback, __vi_cancel_cb, 0 ); + XtAddCallback( box, XmNdestroyCallback, destroyed, 0 ); - form = XtVaCreateWidget( "form", - xmRowColumnWidgetClass, + form = XtVaCreateWidget( "options", + xmFormWidgetClass, box, 0 ); - form2 = XtVaCreateWidget( "toggleOptions", - xmRowColumnWidgetClass, - form, - XmNpacking, XmPACK_COLUMN, -#if defined(SelfTest) - XmNnumColumns, toggleColumns, -#endif - 0 - ); - - for (i=0; i @@ -28,6 +28,10 @@ String str; Widget db = XmCreateErrorDialog( parent, "Fatal", NULL, 0 ); XmString msg = XmStringCreateSimple( str ); + XtVaSetValues( XtParent(db), + XmNtitle, "Fatal", + 0 + ); XtVaSetValues( db, XmNmessageString, msg, 0 @@ -53,6 +57,10 @@ String str; if ( db == NULL ) db = XmCreateInformationDialog( parent, "Information", NULL, 0 ); + XtVaSetValues( XtParent(db), + XmNtitle, "Information", + 0 + ); XtVaSetValues( db, XmNmessageString, msg, 0 diff --git a/motif_l/m_search.c b/motif_l/m_search.c index bc7bd0e2..fc962e66 100644 --- a/motif_l/m_search.c +++ b/motif_l/m_search.c @@ -10,11 +10,12 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "$Id: m_search.c,v 8.4 1996/12/11 13:09:58 bostic Exp $ (Berkeley) $Date: 1996/12/11 13:09:58 $"; +static const char sccsid[] = "$Id: m_search.c,v 8.5 1996/12/11 15:04:40 bostic Exp $ (Berkeley) $Date: 1996/12/11 15:04:40 $"; #endif /* not lint */ #include +/* context */ #include #include #include @@ -49,36 +50,28 @@ typedef struct { void (*cb)(); } ButtonData; + +#if defined(SelfTest) + typedef struct { String name; - Boolean value; + Boolean *value; int flag; } ToggleData; -typedef enum { - ExprStandard, - ExprExtended, - ExprNone -} ExpressionKind; - -static String expr_image[] = { - "Standard", - "Extended", - "None" +static ToggleData toggle_data[] = { + { "Ignore Case", 0, VI_SEARCH_IC }, + { "Incremental", 0, VI_SEARCH_INCR } + { "Literal", 0, VI_SEARCH_LIT }, + { "Wrap End Of File", 0, VI_SEARCH_WR }, }; +#endif + /* globals and constants */ -static String ExpressionWidget = "option", - PatternWidget = "text"; - -static ToggleData toggle_data[] = { - { "Ignore Case", 0, VI_SEARCH_IC }, - { "Incremental", 0, VI_SEARCH_INCR }, - { "Literal", 0, VI_SEARCH_LIT }, - { "Wrap End Of File", 0, VI_SEARCH_WR }, -}; +static String PatternWidget = "text"; static void done_func __P((Widget)); static void next_func __P((Widget)); @@ -87,13 +80,11 @@ static void search __P((Widget, int)); static ButtonData button_data[] = { { "Next", True, next_func }, - { "Previous", True, prev_func }, + { "Previous", False, prev_func }, { "Cancel", False, done_func } }; -ExpressionKind expr_kind; - -static String pattern = NULL; +static String pattern = NULL; /* Xt utilities */ @@ -149,25 +140,14 @@ static void get_state( w ) /* get all the data from the root of the widget tree */ while ( ! XtIsShell(shell) ) shell = XtParent(shell); - /* which regular expression kind? */ - if (( w = get_child_widget( shell, ExpressionWidget )) != NULL ) { - w = XmOptionButtonGadget( w ); - str = get_widget_string( w, XmNlabelString ); - for (i=0; i @@ -1338,6 +1338,44 @@ __vi_set_cursor(cur_screen, is_busy) +/* hooks for the tags widget */ + +static String cur_word = NULL; + +static void set_word_at_caret( this_screen ) + xvi_screen *this_screen; +{ + char *start, *end, save; + int newx, newy; + + newx = this_screen->curx; + newy = this_screen->cury; + + /* Note that this really ought to be done by core due to wrapping issues */ + for ( end = start = CharAt( this_screen, newy, newx ); + (isalnum( *end ) || *end == '_') && (newx < this_screen->cols); + end++, newx++ + ); + save = *end; + *end = '\0'; + if ( cur_word != NULL ) free( cur_word ); + cur_word = strdup( start ); + *end = save; + + /* if the tag stack widget is active, set the text field there + * to agree with the current caret position. + */ + __vi_set_tag_text( start ); +} + + +String __vi_get_word_at_caret( this_screen ) + xvi_screen *this_screen; +{ + return (cur_word) ? cur_word : ""; +} + + /* * These routines deal with the caret. * @@ -1372,9 +1410,17 @@ __vi_move_caret(this_screen, newy, newx) xvi_screen *this_screen; int newy, newx; { - /* caret is now here */ + /* remove the old caret */ __vi_erase_caret( this_screen ); + + /* caret is now here */ this_screen->curx = newx; this_screen->cury = newy; draw_caret( this_screen ); + + /* if the tag stack widget is active, set the text field there + * to agree with the current caret position. + * Note that this really ought to be done by core due to wrapping issues + */ + set_word_at_caret( this_screen ); } -- 2.11.4.GIT