[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs clang.c qe.c qe.h qeconfig.h shell.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs clang.c qe.c qe.h qeconfig.h shell.c |
Date: |
Tue, 08 Apr 2008 09:25:16 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 08/04/08 09:25:16
Modified files:
. : clang.c qe.c qe.h qeconfig.h shell.c
Log message:
pass key to exec_command and call_func
added intrinsic command argument ki for last key pressed
simplified C electric keys: : ; { } invoke the same command
c-electric-key
pass actual key to self-insert-command
handle M-d, M-DEL, M-p, M-n in shell mode
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/qemacs/qeconfig.h?cvsroot=qemacs&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.47&r2=1.48
Patches:
Index: clang.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/clang.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- clang.c 31 Mar 2008 20:35:31 -0000 1.34
+++ clang.c 8 Apr 2008 09:25:16 -0000 1.35
@@ -631,15 +631,11 @@
"c-backward-preprocessor", do_c_forward_preprocessor, ESi, -1, "*v")
CMDV( KEY_META(']'), KEY_NONE,
"c-forward-preprocessor", do_c_forward_preprocessor, ESi, 1, "*v")
- /* CG: should use 'k' intrinsic argument */
- CMDV( ';', KEY_NONE,
- "c-electric-semi&comma", do_c_electric, ESi, ';', "*v")
- CMDV( ':', KEY_NONE,
- "c-electric-colon", do_c_electric, ESi, ':', "*v")
- CMDV( '{', KEY_NONE,
- "c-electric-obrace", do_c_electric, ESi, '{', "*v")
- CMDV( '}', KEY_NONE,
- "c-electric-cbrace", do_c_electric, ESi, '}', "*v")
+ /* CG: should add more electric keys */
+ CMD_( ';', ':',
+ "c-electric-key", do_c_electric, ESi, "*ki")
+ CMD_( '{', '}',
+ "c-electric-key", do_c_electric, ESi, "*ki")
CMD_DEF_END,
};
Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- qe.c 8 Apr 2008 09:14:48 -0000 1.79
+++ qe.c 8 Apr 2008 09:25:16 -0000 1.80
@@ -3493,6 +3493,7 @@
CmdDef *d;
int nb_args;
int argval;
+ int key;
const char *ptype;
CmdArg args[MAX_CMD_ARGS];
unsigned char args_type[MAX_CMD_ARGS];
@@ -3585,6 +3586,10 @@
p = *pp;
type = 0;
+ if (*p == 'k') {
+ p++;
+ type = CMD_ARG_USE_KEY;
+ }
if (*p == 'u') {
p++;
type = CMD_ARG_USE_ARGVAL;
@@ -3620,7 +3625,7 @@
static void parse_args(ExecCmdState *es);
static void free_cmd(ExecCmdState *es);
-void exec_command(EditState *s, CmdDef *d, int argval)
+void exec_command(EditState *s, CmdDef *d, int argval, int key)
{
ExecCmdState *es;
const char *argdesc;
@@ -3640,7 +3645,8 @@
es->s = s;
es->d = d;
- es->argval= argval;
+ es->argval = argval;
+ es->key = key;
es->nb_args = 0;
/* first argument is always the window */
@@ -3663,7 +3669,7 @@
char completion_name[64];
char history[32];
unsigned char arg_type;
- int ret, rep_count, get_arg, type, use_argval;
+ int ret, rep_count, get_arg, type, use_argval, use_key;
for (;;) {
ret = parse_arg(&es->ptype, &arg_type,
@@ -3677,6 +3683,7 @@
if (es->nb_args >= MAX_CMD_ARGS)
goto fail;
use_argval = arg_type & CMD_ARG_USE_ARGVAL;
+ use_key = arg_type & CMD_ARG_USE_KEY;
type = arg_type & CMD_ARG_TYPE_MASK;
es->args_type[es->nb_args] = type;
get_arg = 0;
@@ -3688,6 +3695,9 @@
es->args[es->nb_args].p = prompt;
break;
case CMD_ARG_INT:
+ if (use_key) {
+ es->args[es->nb_args].n = es->key;
+ } else
if (use_argval && es->argval != NO_ARG) {
es->args[es->nb_args].n = es->argval;
es->argval = NO_ARG;
@@ -3845,7 +3855,7 @@
d = qe_find_cmd(cmd);
if (d) {
- exec_command(s, d, argval);
+ exec_command(s, d, argval, 0);
} else {
put_status(s, "No match");
}
@@ -4077,6 +4087,9 @@
void qe_grab_keys(void (*cb)(void *opaque, int key), void *opaque)
{
QEKeyContext *c = &key_ctx;
+
+ /* CG: Should free previous grab? */
+ /* CG: Should grabing be window dependent ? */
c->grab_key_cb = cb;
c->grab_key_opaque = opaque;
}
@@ -4087,6 +4100,8 @@
void qe_ungrab_keys(void)
{
QEKeyContext *c = &key_ctx;
+
+ /* CG: Should free previous grab? */
c->grab_key_cb = NULL;
c->grab_key_opaque = NULL;
}
@@ -4119,6 +4134,7 @@
again:
if (c->grab_key_cb) {
+ /* grabber should return codes for quit / fall thru / ungrab */
c->grab_key_cb(c->grab_key_opaque, key);
/* allow key_grabber to quit and unget last key */
if (c->grab_key_cb || qs->ungot_key == -1)
@@ -4150,6 +4166,7 @@
if (c->is_escape) {
compose_keys(c->keys, &c->nb_keys);
c->is_escape = 0;
+ key = c->keys[c->nb_keys - 1];
}
/* see if one command is found */
@@ -4239,7 +4256,7 @@
* dispatching the command
*/
qe_key_init(c);
- exec_command(s, d, argval);
+ exec_command(s, d, argval, key);
}
qe_key_init(c);
edit_display(qs);
Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- qe.h 8 Apr 2008 09:14:47 -0000 1.77
+++ qe.h 8 Apr 2008 09:25:16 -0000 1.78
@@ -619,6 +619,8 @@
} QEEvent;
void qe_handle_event(QEEvent *ev);
+/* CG: Should optionally attach grab to a window */
+/* CG: Should deal with opaque object life cycle */
void qe_grab_keys(void (*cb)(void *opaque, int key), void *opaque);
void qe_ungrab_keys(void);
@@ -1223,7 +1225,8 @@
CMD_ARG_STRING,
CMD_ARG_STRINGVAL,
CMD_ARG_WINDOW,
- CMD_ARG_TYPE_MASK = 0x7f,
+ CMD_ARG_TYPE_MASK = 0x3f,
+ CMD_ARG_USE_KEY = 0x40,
CMD_ARG_USE_ARGVAL = 0x80,
};
@@ -1648,7 +1651,7 @@
const char *system_fonts);
void call_func(CmdSig sig, CmdProto func, int nb_args, CmdArg *args,
unsigned char *args_type);
-void exec_command(EditState *s, CmdDef *d, int argval);
+void exec_command(EditState *s, CmdDef *d, int argval, int key);
void do_execute_command(EditState *s, const char *cmd, int argval);
void window_display(EditState *s);
void do_universal_argument(EditState *s);
Index: qeconfig.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qeconfig.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- qeconfig.h 4 Apr 2008 12:06:08 -0000 1.32
+++ qeconfig.h 8 Apr 2008 09:25:16 -0000 1.33
@@ -26,9 +26,9 @@
/*---------------- Simple commands ----------------*/
- CMDV( KEY_DEFAULT, KEY_NONE,
- "self-insert-command", do_char, ESii, ' ',
- "*" "v" "ui")
+ CMD_( KEY_DEFAULT, KEY_NONE,
+ "self-insert-command", do_char, ESii,
+ "*" "kiui")
CMD_( KEY_META('#'), KEY_NONE,
"insert-char", do_char, ESii,
"*" "i{Insert char: }" "ui")
Index: shell.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/shell.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- shell.c 4 Apr 2008 13:16:09 -0000 1.47
+++ shell.c 8 Apr 2008 09:25:16 -0000 1.48
@@ -603,8 +603,9 @@
}
break;
}
- if (p)
+ if (p) {
tty_write(s, p, len);
+ }
}
static unsigned char const sco_color[16] = {
@@ -1334,14 +1335,18 @@
static void shell_write_char(EditState *e, int c)
{
- char ch;
+ char buf[2], *p;
if (e->interactive) {
ShellState *s = e->b->priv_data;
- ch = c;
- /* TODO: convert to tty escape sequences? */
- tty_write(s, &ch, 1);
+ p = buf;
+ *p++ = c;
+ if (c >= KEY_META(0) && c <= KEY_META(0xff)) {
+ p[-1] = '\033';
+ *p++ = c - KEY_META(0);
+ }
+ tty_write(s, buf, p - buf);
} else {
/* Should dispatch as in fundamental mode */
switch (c) {
@@ -1355,12 +1360,18 @@
case 11:
do_kill_line(e, 1);
break;
- case 127:
+ case KEY_DEL:
do_backspace(e, NO_ARG);
break;
case '\r':
do_return(e, 1);
break;
+ case KEY_META('d'):
+ do_kill_word(e, 1);
+ break;
+ case KEY_META(KEY_DEL):
+ do_kill_word(e, -1);
+ break;
default:
text_write_char(e, c);
break;
@@ -1521,19 +1532,24 @@
CMD1( '\r', KEY_NONE,
"shell-return", shell_write_char, '\r')
/* CG: should send s->kbs */
- CMD1( 127, KEY_NONE,
- "shell-backward-delete-char", shell_write_char, 127)
+ CMD1( KEY_DEL, KEY_NONE,
+ "shell-backward-delete-char", shell_write_char, KEY_DEL)
CMD1( KEY_CTRL('c'), KEY_NONE,
"shell-intr", shell_write_char, 3)
CMD1( KEY_CTRL('d'), KEY_DELETE,
"shell-delete-char", shell_write_char, 4)
+ CMD1( KEY_META('d'), KEY_NONE,
+ "shell-delete-word", shell_write_char, KEY_META('d'))
+ CMD1( KEY_META(KEY_DEL), KEY_NONE,
+ "shell-backward-delete-word", shell_write_char, KEY_META(KEY_DEL))
+ CMD_( KEY_META('p'), KEY_META('n'),
+ "shell-history-search", shell_write_char, ESi, "*ki")
CMD1( KEY_CTRL('i'), KEY_NONE,
"shell-tabulate", shell_write_char, 9)
CMD1( KEY_CTRL('k'), KEY_NONE,
"shell-kill-line", shell_write_char, 11)
CMD1( KEY_CTRL('y'), KEY_NONE,
"shell-yank", shell_write_char, 25)
- /* Should have KEY_CTRL('c') -> shell_kill */
CMD_DEF_END,
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs clang.c qe.c qe.h qeconfig.h shell.c,
Charlie Gordon <=