Beispiel #1
0
static gboolean
cmdline_key_pressed(GtkWidget *widget, GdkEventKey *event,
		    gpointer user_data)
{
	bool is_shift	= event->state & GDK_SHIFT_MASK;
	bool is_ctl	= event->state & GDK_CONTROL_MASK;

#ifdef DEBUG
	g_printf("KEY \"%s\" (%d) SHIFT=%d CNTRL=%d\n",
		 event->string, *event->string,
		 event->state & GDK_SHIFT_MASK, event->state & GDK_CONTROL_MASK);
#endif

	switch (event->keyval) {
	case GDK_BackSpace:
		cmdline_keypress('\b');
		break;
	case GDK_Tab:
		cmdline_keypress('\t');
		break;
	case GDK_Return:
		cmdline_keypress(get_eol());
		break;

	/*
	 * Function key macros
	 */
#define FN(KEY, MACRO) \
	case GDK_##KEY: cmdline_fnmacro(#MACRO); break
#define FNS(KEY, MACRO) \
	case GDK_##KEY: cmdline_fnmacro(is_shift ? "S" #MACRO : #MACRO); break
	FN(Down, DOWN); FN(Up, UP);
	FNS(Left, LEFT); FNS(Right, RIGHT);
	FN(KP_Down, DOWN); FN(KP_Up, UP);
	FNS(KP_Left, LEFT); FNS(KP_Right, RIGHT);
	FNS(Home, HOME);
	case GDK_F1...GDK_F35: {
		gchar macro_name[3+1];

		g_snprintf(macro_name, sizeof(macro_name),
			   "F%d", event->keyval - GDK_F1 + 1);
		cmdline_fnmacro(macro_name);
		break;
	}
	FNS(Delete, DC);
	FNS(Insert, IC);
	FN(Page_Down, NPAGE); FN(Page_Up, PPAGE);
	FNS(Print, PRINT);
	FN(KP_Home, A1); FN(KP_Prior, A3);
	FN(KP_Begin, B2);
	FN(KP_End, C1); FN(KP_Next, C3);
	FNS(End, END);
	FNS(Help, HELP);
#undef FNS
#undef FN

	/*
	 * Control keys and keys with printable representation
	 */
	default:
		gunichar u = gdk_keyval_to_unicode(event->keyval);

		if (u && g_unichar_to_utf8(u, NULL) == 1) {
			gchar key;

			g_unichar_to_utf8(u, &key);
			if (key > 0x7F)
				break;
			if (is_ctl)
				key = CTL_KEY(g_ascii_toupper(key));

			cmdline_keypress(key);
		}
	}

	return TRUE;
}
Beispiel #2
0
/********************************************************************* 
     Main processing loop.
     get a key record from the input queue.
     if a key was input from keyboard (owner == TRUE), then look at
     the key record and try to call a function. If no function, then
     just input it into the sheet.

     if input was from clipboard (owner == FALSE), then don't try to 
     call a function, just put it in the sheet.

     v 3.0  9-12-94
            still needs work. sigh..

************************************************************************/
static void  edit_loop (void)
{
USHORT key;
bool ok = FALSE;        // temp for load_key
USHORT cmd_result = 0x0000;      // returned from do_command
UCHAR lokey, hikey;     // low and high byte of KEY USHORT
USHORT keystate;
struct key_rec edit_key_rec;

#ifndef NO_COMMANDO
//char commando_cwd[FNAME_LEN];
//strcpy (commando_cwd, cwd);
#endif

#ifndef NO_HELP
DEF_HELP(EDIT_HELP,1,-1,-1);
init_help (Help);
NEW_HELP;
#endif

for (;;) {
get_next:
   edit_key_rec = view_getkey();
   key = edit_key_rec.value;
   keystate = edit_key_rec.state;
   lokey = LOUCHAR(key);
   hikey = HIUCHAR(key);

//  DBG_INI(dout<<"edit.cpp line "<<__LINE__<<" shell_command.s = °"<<settings.shell_command.s<<"°"<<endl);
   switch (key) {
      case kESC:   
             if (pulldown_menu() && tryquit ()) {
                  return;
             }
             else {
                lokey = 0x00;     // "eat" the ESC key
             }
             break;
      default:
         DBG_KEY(dout<<'\n'<<"edit key =  "<<hex<<key<<"  high = "<<hikey);
         DBG_KEY(dout<<" low = "<< lokey<<" keystate = "<<keystate<<dec<<endl);
         if(edit_key_rec.owner == TRUE) {                // keyboard key
            if((CTL_KEY(keystate)) || ((lokey == 0x00)||(lokey == 0xE0))) {
               if(key != 0x0000) {
                  cmd_result = do_command(mykey_rec);
                  DBG_KEY(dout<<" edit_key after do_command() "<<endl);        
               }
               if(cmd_result == CMD_QUIT) {
                  DBG_KEY(dout<<" edit key QUIT cmd_result = "<<hex<<cmd_result<<dec<<endl);
                  return;
               }
               if(cmd_result == CMD_HANDLED) {
                  DBG_KEY(dout<<" edit key ignoring cmd_result = "<<hex<<cmd_result<<dec<<endl);
                  goto get_next;
               }
            }
            if((lokey != 0xE0) && (lokey >0)) { // ignore any ext key not handled
               DBG_KEY(dout<<" edit_key calling view_addkey() "<<endl);        
               view_addkey(lokey);
               break;
           }
         }
         else {
           DBG_KEY(dout<<" edit key not owner"<<endl);
           if((lokey < 255) && (lokey >0)) { // ignore any ext key not handled
//            DBG_KEY(dout<<" edit_loop addkey  key = "<<hex<<lokey<<dec<<endl);
              view_addkey(lokey);
              break;
           }
         }
   }                               // end switch/case
}                                  // end for(;;)
#pragma warn -aus        // eliminate 'OLD_HELP'assigned but not used
}