[comp.windows.x.motif] Problems with adding XmText translations

jerryl@is.Morgan.COM (Jerry Liebelson) (05/15/91)

Hi --

Below is a simple program that has an ApplicationShell containing 
a BulletinBoard widget which contains a single ScrolledText. I'm trying
to add additional, somewhat emacs-like, keyboard translations to
the XmText widget.

I'm using the following resources:

   basic*text.editMode: MULTI_LINE_EDIT
   basic*text.wordWrap: true
   basic*text.columns:	40
   basic*text.rows: 5
   basic*text.maxLength: 3000
   basic*text.scrollBarDisplayPolicy:	AS_NEEDED
   basic*text.scrollHorizontal:	false
   basic*text.autoShowCursorPosition:	true
   basic*text.translations:	#override \
     Ctrl<Key>a:    beginning-of-line() \n\ 
     Ctrl<Key>e:    end-of-line() \n\ 
     Ctrl<Key>f:    forward-character() \n\ 
     Ctrl<Key>b:    backward-character() \n\ 
     Ctrl<Key>v:  next-page() move-destination() \n\
     Alt Meta<Key>f:  forward-word() \n\ 
     Alt Meta<Key>b:  backward-word() \n\ 
     Ctrl<Key>d:    delete-next-character() \n\ 
     Alt Meta<Key>d:  delete-next-word() \n\ 
     Ctrl<Key>k:    kill-to-end-of-line() \n\ 
     Alt Meta<Key>k:  kill-to-start-of-line() \n\
     Ctrl<Key>n:    next-line() \n\ 
     Ctrl<Key>p:    previous-line() \n\
     Ctrl<Key>l:    redraw-display() \n\ 
     Ctrl<Key>w:    cut-clipboard() \n\
     Alt Meta<Key>w:  copy-clipboard() \n\
     Ctrl<Key>u:    unkill() \n\
     Ctrl<Key>y:    paste-clipboard() \n\
     <Key>R9:    previous-page() move-destination() \n\
     <Key>R15:    next-page() move-destination() \n\
     Alt Meta<Key>v:  previous-page() move-destination() \n\
     Shift<Key>R9:  beginning-of-file() \n\  
     Shift<Key>R15:  end-of-file()

  PROBLEM: It seems only the first translation (Ctrl-a or whatever one specifiesfirst) takes affect.  The others are ignored. Does anybody see what I'm 
doing wrong?  Thanks.

  ENVIRONMENT: Motif 1.1  X11R4/18 SunOS 4.11 Sparc2, IPC, SLC.
  
-- 
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
|        Jerry Liebelson         |      EMAIL: jerryl@is.morgan.com          |
|      Information Systems       |             uunet!is.morgan.com!jerryl    |
|      Morgan Stanley, Inc.      |      VOICE: (212) 703-2409                |
|      1633 Broadway 36th Floor  |      FAX:   (212) 703-2371                |
|      New York, NY 10019        |                                           |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------- cut here  -------------------------------------

#include <stdio.h>
#include <Intrinsic.h>
#include <StringDefs.h>
#include <keysym.h>
#include <Xm/BulletinB.h>
#include <Xm/Text.h>

Widget AppShell;
	
/***************************************************************************/
int main(argc, argv)
int argc;
char **argv;
{

	Widget board, text;
	Arg argList[10];
	int i;
	XtAppContext appContext;
	Display *displayPtr;
	char appClass[64];
	

	strcpy(appClass,argv[0]);

    if (islower(appClass[0]))
		appClass[0] = toupper(appClass[0]);
    else if (islower(appClass[1]))
        appClass[1] = toupper(appClass[1]);
    
	AppShell = XtAppInitialize ( 
		&appContext, appClass, NULL, 0,
		&argc, argv,
		NULL, NULL, 0		
    );


	board = XtCreateManagedWidget("board", xmBulletinBoardWidgetClass, AppShell,
		NULL, 0);

	text = XmCreateScrolledText(board, "text", NULL, 0);
	XtManageChild(text);

	XtRealizeWidget(AppShell);
    XtAppMainLoop(appContext);

    exit(-1);
}

------------------------------- cut here  -------------------------------------

tjhorton@vis.toronto.edu ("Timothy J. Horton") (05/16/91)

jerryl@is.Morgan.COM (Jerry Liebelson) writes:
>I'm trying to add additional, somewhat emacs-like, keyboard translations to
>the XmText widget.
>
>   basic*text.translations:	#override \
>     Ctrl<Key>a:    beginning-of-line() \n\ 
>     Ctrl<Key>e:    end-of-line() \n\ 
[...]

>  PROBLEM: It seems only the first translation (Ctrl-a or whatever one
>specifies first) takes affect.  The others are ignored. Does anybody see
>what I'm doing wrong?  Thanks.

Straightforward.  As you included it, there was a space after the "\"
at the end of the first line of the translation:

>     Ctrl<Key>a:    beginning-of-line() \n\ 
                                            ^ you have a space here

That "\" character escapes the next character.  If it were a newline,
the usual meaning of the newline would be ignored (ie normal meaning is
"end of this resource") and it would be included as whitespace in the
resource definition.  In your translations, you escaped the following
space, and the newline after that ended the resource definition.
Thus, nothing else of your translations should have had effect.

I've seen this problem before; it should be in the FAQs if it isn't.