[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs TODO.org extras.c html.c qe.h shell.c bu...
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs TODO.org extras.c html.c qe.h shell.c bu... |
Date: |
Tue, 7 Jun 2016 08:56:40 +0000 (UTC) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 16/06/07 08:56:40
Modified files:
. : TODO.org extras.c html.c qe.h shell.c buffer.c
hex.c qe.c qeconfig.h unihex.c
Log message:
shell: improve shell editing, yank kill buffer at shell prompt
- add mode specific `delete_bytes()` method
- reorder `write_char()` and `mouse_goto()` mode methods
- pass `keep` argument to `do_kill()`
- pass `argval` to `do_kill_line()`
- add `do_kill_beginning_of_line()` command
- allow kill commands in read-only buffers, copies contents to
kill-ring and
moves point.
- change `do_kill_line()` semantics when invoked with numeric argument
- add `cur_prompt` and `last_char` in ShellState to track start of
shell input line
- C-a moves to start of shell input, exits interactive mode if there
already
- force interactive mode on shell-end-of-line and shell-end-of-buffer
- simplify shell_write_char(), remove hard coded dispatcher
- add `shell_delete_bytes()` to delete contents in shell input line
- change shell-kill-word and shell-kill-line to not rely on mode
specific
cursor movement commands because of asynchronous behavior. This is
also
a problem for macros
- make shell-yank insert data via shell input.
- pause for 1ms after each CR sent to the process
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/TODO.org?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/extras.c?cvsroot=qemacs&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/qemacs/html.c?cvsroot=qemacs&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.217&r2=1.218
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.109&r2=1.110
http://cvs.savannah.gnu.org/viewcvs/qemacs/buffer.c?cvsroot=qemacs&r1=1.101&r2=1.102
http://cvs.savannah.gnu.org/viewcvs/qemacs/hex.c?cvsroot=qemacs&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.224&r2=1.225
http://cvs.savannah.gnu.org/viewcvs/qemacs/qeconfig.h?cvsroot=qemacs&r1=1.57&r2=1.58
http://cvs.savannah.gnu.org/viewcvs/qemacs/unihex.c?cvsroot=qemacs&r1=1.30&r2=1.31
Patches:
Index: TODO.org
===================================================================
RCS file: /sources/qemacs/qemacs/TODO.org,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- TODO.org 27 May 2016 18:20:30 -0000 1.11
+++ TODO.org 7 Jun 2016 08:56:39 -0000 1.12
@@ -6,14 +6,13 @@
* Needed for release version 5
* Priority 0
-** shell: turn on interactive mode on commands that move the cursor
- to the end of buffer
** basic: reset last command when executing macro
** extra: add function to add entry in TOTO.org
** clang: indentation bug on {\nputchar(expr ? 'a' : 'b');\n}
** completion: completion behaviour on SPC
-** shell: yank at shell prompt
** edit: track file modifications and reload upon change
+** shell: turn on interactive mode on commands that move the cursor
+ to the end of buffer
* Priority 1
@@ -72,7 +71,7 @@
** shell: integrate kill/paste including multiple lines
** shell: fix crash bug when invoking qemacs recursively in the terminal
** shell: set current directory of new shell buffer to that of current window
-** shell: yank at shell prompt
+** shell: use auxiliary buffer to make process input asynchronous
** syntax: fix overlong line coloring
** syntax: support ReStructuredText (RST)
** text: \u200c -> zero width
Index: extras.c
===================================================================
RCS file: /sources/qemacs/qemacs/extras.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- extras.c 21 May 2016 15:45:19 -0000 1.39
+++ extras.c 7 Jun 2016 08:56:40 -0000 1.40
@@ -542,11 +542,8 @@
{
int start = s->offset;
- if (s->b->flags & BF_READONLY)
- return;
-
do_forward_block(s, dir);
- do_kill(s, start, s->offset, dir);
+ do_kill(s, start, s->offset, dir, 0);
}
enum {
@@ -1188,9 +1185,9 @@
CMD3( KEY_META(KEY_CTRL('f')), KEY_NONE,
"forward-block", do_forward_block, ESi, 1, "v")
CMD3( KEY_ESC, KEY_DELETE,
- "backward-kill-block", do_kill_block, ESi, -1, "*v")
+ "backward-kill-block", do_kill_block, ESi, -1, "v")
CMD3( KEY_META(KEY_CTRL('k')), KEY_NONE,
- "kill-block", do_kill_block, ESi, 1, "*v")
+ "kill-block", do_kill_block, ESi, 1, "v")
/* Should also have mark-block on C-M-@ */
CMD3( KEY_CTRL('t'), KEY_NONE,
Index: html.c
===================================================================
RCS file: /sources/qemacs/qemacs/html.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- html.c 16 Sep 2015 22:18:24 -0000 1.37
+++ html.c 7 Jun 2016 08:56:40 -0000 1.38
@@ -929,8 +929,8 @@
.move_bol = html_move_bol,
.move_eol = html_move_eol,
.scroll_up_down = html_scroll_up_down,
- .write_char = text_write_char,
.mouse_goto = html_mouse_goto,
+ .write_char = text_write_char,
};
static int html_init(void)
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -b -r1.217 -r1.218
--- qe.h 27 May 2016 18:20:30 -0000 1.217
+++ qe.h 7 Jun 2016 08:56:40 -0000 1.218
@@ -1293,18 +1293,20 @@
/* common functions are defined here */
/* TODO: Should have single move function with move type and argument */
- void (*move_up_down)(EditState *, int);
- void (*move_left_right)(EditState *, int);
- void (*move_bol)(EditState *);
- void (*move_eol)(EditState *);
- void (*move_bof)(EditState *);
- void (*move_eof)(EditState *);
- void (*move_word_left_right)(EditState *, int);
- void (*scroll_up_down)(EditState *, int);
- void (*scroll_line_up_down)(EditState *, int);
- void (*write_char)(EditState *, int);
- void (*mouse_goto)(EditState *, int x, int y);
- /* XXX: need functions to insert and delete contents */
+ void (*move_up_down)(EditState *s, int dir);
+ void (*move_left_right)(EditState *s, int dir);
+ void (*move_bol)(EditState *s);
+ void (*move_eol)(EditState *s);
+ void (*move_bof)(EditState *s);
+ void (*move_eof)(EditState *s);
+ void (*move_word_left_right)(EditState *s, int dir);
+ void (*scroll_up_down)(EditState *s, int dir);
+ void (*scroll_line_up_down)(EditState *s, int dir);
+ void (*mouse_goto)(EditState *s, int x, int y);
+
+ /* Functions to insert and delete contents: */
+ void (*write_char)(EditState *s, int c);
+ void (*delete_bytes)(EditState *s, int offset, int size);
EditBufferDataType *data_type; /* native buffer data type (NULL = raw) */
void (*get_mode_line)(EditState *s, buf_t *out);
@@ -1867,9 +1869,10 @@
void do_tab(EditState *s, int argval);
EditBuffer *new_yank_buffer(QEmacsState *qs, EditBuffer *base);
void do_append_next_kill(EditState *s);
-void do_kill(EditState *s, int p1, int p2, int dir);
-void do_kill_region(EditState *s, int killtype);
-void do_kill_line(EditState *s, int dir);
+void do_kill(EditState *s, int p1, int p2, int dir, int keep);
+void do_kill_region(EditState *s, int keep);
+void do_kill_line(EditState *s, int argval);
+void do_kill_beginning_of_line(EditState *s, int argval);
void do_kill_word(EditState *s, int dir);
void text_move_bol(EditState *s);
void text_move_eol(EditState *s);
Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- shell.c 28 May 2016 16:27:56 -0000 1.109
+++ shell.c 7 Jun 2016 08:56:40 -0000 1.110
@@ -59,6 +59,7 @@
int pid; /* -1 if not launched */
int color, attr, def_color;
int cur_offset; /* current offset at position x, y */
+ int cur_prompt; /* offset of end of prompt on current line */
int esc_params[MAX_ESC_PARAMS];
int has_params[MAX_ESC_PARAMS];
int nb_esc_params;
@@ -82,6 +83,7 @@
const char *khome, *kend, *kmous, *knp, *kpp;
const char *caption; /* process caption for exit message */
int shell_flags;
+ int last_char; /* last char sent to the process */
} ShellState;
@@ -408,6 +410,7 @@
}
}
+// XXX: should use an auxiliary buffer to make this asynchous
static void tty_write(ShellState *s, const char *buf, int len)
{
int ret;
@@ -426,6 +429,7 @@
break;
buf += ret;
len -= ret;
+ s->last_char = buf[-1];
}
}
@@ -1312,6 +1316,18 @@
s->b->flags |= save_readonly;
}
}
+ if (s->last_char == '\000' || s->last_char == '\001'
+ || s->last_char == '\003'
+ || s->last_char == '\r' || s->last_char == '\n') {
+ /* if the last char sent to the process was the enter key, C-C
+ * to kill the process, C-A to go to beginning of line, or if
+ * nothing was sent to the process yet, assume the process is
+ * prompting for input and save the current input position as
+ * the start of input.
+ */
+ s->b->mark = s->cur_prompt = s->cur_offset;
+ }
+
/* now we do some refresh */
edit_display(qs);
dpy_flush(qs->screen);
@@ -1323,6 +1339,7 @@
int status;
eb_free_callback(b, eb_offset_callback, &s->cur_offset);
+ eb_free_callback(b, eb_offset_callback, &s->cur_prompt);
if (s->pid != -1) {
kill(s->pid, SIGINT);
@@ -1458,6 +1475,7 @@
}
/* Track cursor with edge effect */
eb_add_callback(b, eb_offset_callback, &s->cur_offset, 1);
+ eb_add_callback(b, eb_offset_callback, &s->cur_prompt, 0);
}
s->b = b;
s->pty_fd = -1;
@@ -1465,7 +1483,7 @@
s->qe_state = qs;
s->caption = caption;
s->shell_flags = shell_flags;
- s->cur_offset = b->total_size;
+ s->cur_prompt = s->cur_offset = b->total_size;
tty_init(s);
/* launch shell */
@@ -1630,6 +1648,7 @@
tty_write(s, dir > 0 ? s->kcud1 : s->kcuu1, -1);
} else {
text_move_up_down(e, dir);
+ // XXX: what if beyond?
if (s && (s->shell_flags & SF_INTERACTIVE))
e->interactive = (e->offset == s->cur_offset);
}
@@ -1645,6 +1664,7 @@
} else {
/* hack: M-p silently converted to C-u C-p */
text_move_up_down(e, dir * 4);
+ // XXX: what if beyond?
if (s && (s->shell_flags & SF_INTERACTIVE))
e->interactive = (e->offset == s->cur_offset);
}
@@ -1658,6 +1678,7 @@
tty_write(s, "\030\030", 2); /* C-x C-x */
} else {
do_exchange_point_and_mark(e);
+ // XXX: what if beyond?
if (s && (s->shell_flags & SF_INTERACTIVE))
e->interactive = (e->offset == s->cur_offset);
}
@@ -1669,6 +1690,7 @@
e->interactive = 0;
text_scroll_up_down(e, dir);
+ // XXX: what if beyond?
if (s && (s->shell_flags & SF_INTERACTIVE))
e->interactive = (e->offset == s->cur_offset);
}
@@ -1677,9 +1699,8 @@
{
ShellState *s = shell_get_state(e, 1);
- /* XXX: exit shell interactive mode on home / ^A */
- /* XXX: should first perform the shell's ^A,
- * then exit interactive-mode */
+ /* exit shell interactive mode on home / ^A at start of shell input */
+ if (!s || e->offset == s->cur_prompt)
e->interactive = 0;
if (s && e->interactive) {
@@ -1698,8 +1719,12 @@
} else {
text_move_eol(e);
/* XXX: restore shell interactive mode on end / ^E */
- if (s && (s->shell_flags & SF_INTERACTIVE))
- e->interactive = (e->offset == s->cur_offset);
+ if (s && (s->shell_flags & SF_INTERACTIVE)
+ && e->offset >= s->cur_offset) {
+ e->interactive = 1;
+ if (e->offset > s->cur_offset)
+ tty_write(s, "\005", 1); /* Control-E */
+ }
}
}
@@ -1719,18 +1744,23 @@
} else {
text_move_eof(e);
/* Restore shell interactive mode on end-buffer / M-> */
- if (s && (s->shell_flags & SF_INTERACTIVE))
- e->interactive = (e->offset == s->cur_offset);
+ if (s && (s->shell_flags & SF_INTERACTIVE)
+ && e->offset >= s->cur_offset) {
+ e->interactive = 1;
+ if (e->offset != s->cur_offset)
+ tty_write(s, "\005", 1); /* Control-E */
+ }
}
}
static void shell_write_char(EditState *e, int c)
{
- char buf[10];
- int len;
ShellState *s = shell_get_state(e, 1);
if (s && e->interactive) {
+ char buf[10];
+ int len;
+
if (c >= KEY_META(0) && c <= KEY_META(0xff)) {
buf[0] = '\033';
buf[1] = c - KEY_META(0);
@@ -1740,53 +1770,71 @@
}
tty_write(s, buf, len);
} else {
- /* Should dispatch as in fundamental mode */
- switch (c) {
- case KEY_CTRL('d'):
- do_delete_char(e, NO_ARG);
- break;
- // Do not do this: it is useless and causes infinite recursion
- //case 9:
- // do_tab(e, 1);
- // break;
- case KEY_CTRL('k'):
- do_kill_line(e, 1);
- break;
- case KEY_CTRL('y'):
- do_yank(e);
- break;
- case KEY_BS:
- 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_BS):
- case KEY_META(KEY_DEL):
- do_kill_word(e, -1);
- break;
- default:
text_write_char(e, c);
- break;
+ }
+}
+
+static void shell_delete_bytes(EditState *e, int offset, int size)
+{
+ ShellState *s = shell_get_state(e, 1);
+ int start = offset;
+ int end = offset + size;
+
+ // XXX: should deal with regions spanning current input line and
+ // previous buffer contents
+ if (s && !s->grab_keys && end > s->cur_prompt) {
+ int start_char, cur_char, end_char, size;
+ if (start < s->cur_prompt) {
+ /* delete part before the interactive input */
+ size = eb_delete(e->b, start, s->cur_prompt);
+ end -= size;
+ start = s->cur_prompt;
+ }
+ start_char = eb_get_char_offset(e->b, start);
+ cur_char = eb_get_char_offset(e->b, s->cur_offset);
+ end_char = eb_get_char_offset(e->b, end);
+ while (cur_char > end_char) {
+ tty_write(s, "\002", 1); /* C-b */
+ cur_char--;
+ }
+ while (cur_char < start_char) {
+ tty_write(s, "\006", 1); /* C-f */
+ cur_char++;
+ }
+ if (start_char == cur_char && end == e->b->total_size) {
+ /* kill to end of line with control-k */
+ tty_write(s, "\013", 1);
+ } else {
+ while (cur_char < end_char) {
+ tty_write(s, "\004", 1); /* C-d */
+ end_char--;
+ }
+ while (start_char < cur_char) {
+ tty_write(s, "\010", 1); /* backspace */
+ cur_char--;
+ end_char--;
}
}
- if (c == '\r') {
- /* skip errors from previous commands */
- set_error_offset(e->b, e->offset);
+ } else {
+ eb_delete(e->b, offset, size);
}
}
static void do_shell_enter(EditState *e)
{
+ struct timespec ts;
+
if (e->interactive) {
shell_write_char(e, '\r');
+ /* give the process a chance to handle the input */
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1000000; /* 1 ms */
+ nanosleep(&ts, NULL);
} else {
do_return(e, 1);
}
+ /* reset offset to scan errors and matches from */
+ set_error_offset(e->b, e->offset);
}
static void do_shell_intr(EditState *e)
@@ -1816,28 +1864,116 @@
}
}
-static void do_shell_delete_word(EditState *e, int dir)
+static void do_shell_kill_word(EditState *e, int dir)
{
- if (e->interactive) {
+ ShellState *s = shell_get_state(e, 1);
+
+ if (s && e->interactive) {
+ /* copy word to the kill ring */
+ int start = e->offset;
+
+ text_move_word_left_right(e, dir);
+ if (e->offset < s->cur_prompt) {
+ e->offset = s->cur_prompt;
+ }
+ do_kill(e, start, e->offset, dir, 1);
+ // XXX: word pattern consistency issue
shell_write_char(e, dir > 0 ? KEY_META('d') : KEY_META(KEY_DEL));
} else {
do_kill_word(e, dir);
}
}
-static void do_shell_kill_line(EditState *e, int dir)
+static void do_shell_kill_line(EditState *e, int argval)
{
- if (e->interactive) {
- shell_write_char(e, dir > 0 ? 11 : KEY_META('k'));
+ ShellState *s = shell_get_state(e, 1);
+ int dir = (argval == NO_ARG || argval > 0) ? 1 : -1;
+ int offset, p1 = e->offset, p2 = p1;
+
+ if (s && e->interactive) {
+ /* ignore count argument in interactive mode */
+ if (dir < 0) {
+ /* kill backwards upto prompt position */
+ p2 = max(eb_goto_bol(e->b, p1), s->cur_prompt);
+ do_kill(e, p1, p2, dir, 0);
+ //shell_write_char(e, KEY_META('k'));
+ } else {
+ p2 = eb_goto_eol(e->b, p1);
+ do_kill(e, p1, p2, dir, 0);
+ //shell_write_char(e, KEY_CTRL('k'));
+ }
+ } else {
+ /* Cannot use do_kill_line() because it relies on mode specific
+ * cursor movement methods, which are handled asynchronously in
+ * shell mode.
+ */
+ if (argval == NO_ARG) {
+ /* kill to end of line */
+ if (eb_nextc(e->b, p2, &offset) == '\n') {
+ p2 = offset;
+ } else {
+ p2 = eb_goto_eol(e->b, p2);
+ }
+ } else
+ if (argval <= 0) {
+ /* kill backwards */
+ dir = -1;
+ for (;;) {
+ p2 = eb_goto_bol(e->b, p2);
+ if (p2 <= 0 || argval == 0)
+ break;
+ eb_prevc(e->b, p2, &p2);
+ argval += 1;
+ }
} else {
- do_kill_line(e, dir);
+ for (;;) {
+ p2 = eb_goto_eol(e->b, p2);
+ if (p2 >= e->b->total_size || argval == 0)
+ break;
+ eb_nextc(e->b, p2, &p2);
+ argval -= 1;
+ }
+ }
+ e->offset = p2;
+ do_kill(e, p1, p2, dir, 0);
}
}
+static void do_shell_kill_beginning_of_line(EditState *s, int argval)
+{
+ do_shell_kill_line(s, argval == NO_ARG ? 0 : -argval);
+}
+
+// XXX: need shell_set_mark, shell_kill_region...
+
static void do_shell_yank(EditState *e)
{
if (e->interactive) {
- shell_write_char(e, KEY_CTRL('y'));
+ /* yank from kill-ring and insert via shell_write_char().
+ * This will cause a deadlock if kill buffer contents is too
+ * large. Hard coded limit can be removed if shell input is
+ * made asynchronous via an auxiliary buffer.
+ */
+ int offset;
+ QEmacsState *qs = e->qe_state;
+ EditBuffer *b = qs->yank_buffers[qs->yank_current];
+
+ e->b->mark = e->offset;
+
+ if (b) {
+ if (b->total_size > 1024) {
+ put_status(e, "too much data to yank at shell prompt");
+ return;
+ }
+ for (offset = 0; offset < b->total_size;) {
+ int c = eb_nextc(b, offset, &offset);
+ if (c == '\n')
+ do_shell_enter(e);
+ else
+ shell_write_char(e, c);
+ }
+ }
+ qs->this_cmd_func = (CmdFunc)do_yank;
} else {
do_yank(e);
}
@@ -2083,21 +2219,21 @@
CMD2( KEY_CTRL('d'), KEY_DELETE,
"shell-delete-char", do_shell_delete_char, ES, "*")
CMD3( KEY_META('d'), KEY_NONE,
- "shell-delete-word", do_shell_delete_word, ESi, 1, "*v")
+ "shell-kill-word", do_shell_kill_word, ESi, 1, "v")
CMD3( KEY_META(KEY_DEL), KEY_META(KEY_BS) ,
- "shell-backward-delete-word", do_shell_delete_word, ESi, -1, "*v")
+ "shell-backward-kill-word", do_shell_kill_word, ESi, -1, "v")
CMD1( KEY_META('p'), KEY_NONE,
"shell-previous", shell_previous_next, -1)
CMD1( KEY_META('n'), KEY_NONE,
- "shell-next", shell_previous_next, -1)
+ "shell-next", shell_previous_next, 1)
CMD0( KEY_CTRLX(KEY_CTRL('x')), KEY_NONE,
"shell-exchange-point-and-mark", shell_exchange_point_and_mark)
CMD2( KEY_CTRL('i'), KEY_NONE,
"shell-tabulate", do_shell_tabulate, ES, "*")
- CMD3( KEY_CTRL('k'), KEY_NONE,
- "shell-kill-line", do_shell_kill_line, ESi, 1, "*v")
- CMD3( KEY_META('k'), KEY_NONE,
- "shell-kill-beginning-of-line", do_shell_kill_line, ESi, -1, "*v")
+ CMD2( KEY_CTRL('k'), KEY_NONE,
+ "shell-kill-line", do_shell_kill_line, ESi, "ui")
+ CMD2( KEY_META('k'), KEY_NONE,
+ "shell-kill-beginning-of-line", do_shell_kill_beginning_of_line,
ESi, "ui")
CMD2( KEY_CTRL('y'), KEY_NONE,
"shell-yank", do_shell_yank, ES, "*")
CMD_DEF_END,
@@ -2184,6 +2320,7 @@
shell_mode.move_bof = shell_move_bof;
shell_mode.move_eof = shell_move_eof;
shell_mode.write_char = shell_write_char;
+ shell_mode.delete_bytes = shell_delete_bytes;
shell_mode.get_default_path = shell_get_default_path;
qe_register_mode(&shell_mode, MODEF_NOCMD | MODEF_VIEW);
Index: buffer.c
===================================================================
RCS file: /sources/qemacs/qemacs/buffer.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -b -r1.101 -r1.102
--- buffer.c 6 Mar 2016 19:53:06 -0000 1.101
+++ buffer.c 7 Jun 2016 08:56:40 -0000 1.102
@@ -2484,15 +2484,15 @@
}
/* return offset of the end of the line containing offset */
-int eb_goto_eol(EditBuffer *b, int offset)
+int eb_goto_eol(EditBuffer *b, int offset1)
{
- int c, offset1;
+ int c, offset;
for (;;) {
+ offset = offset1;
c = eb_nextc(b, offset, &offset1);
if (c == '\n')
break;
- offset = offset1;
}
return offset;
}
Index: hex.c
===================================================================
RCS file: /sources/qemacs/qemacs/hex.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- hex.c 26 Aug 2015 22:51:24 -0000 1.45
+++ hex.c 7 Jun 2016 08:56:40 -0000 1.46
@@ -339,8 +339,8 @@
.move_bol = hex_move_bol,
.move_eol = hex_move_eol,
.scroll_up_down = text_scroll_up_down,
- .write_char = text_write_char,
.mouse_goto = text_mouse_goto,
+ .write_char = text_write_char,
.get_mode_line = hex_mode_line,
};
@@ -355,8 +355,8 @@
.move_bol = hex_move_bol,
.move_eol = hex_move_eol,
.scroll_up_down = text_scroll_up_down,
- .write_char = hex_write_char,
.mouse_goto = text_mouse_goto,
+ .write_char = hex_write_char,
.get_mode_line = hex_mode_line,
};
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -b -r1.224 -r1.225
--- qe.c 7 Jun 2016 06:50:44 -0000 1.224
+++ qe.c 7 Jun 2016 08:56:40 -0000 1.225
@@ -156,10 +156,10 @@
m->move_word_left_right = text_move_word_left_right;
if (!m->scroll_up_down)
m->scroll_up_down = text_scroll_up_down;
- if (!m->write_char)
- m->write_char = text_write_char;
if (!m->mouse_goto)
m->mouse_goto = text_mouse_goto;
+ if (!m->write_char)
+ m->write_char = text_write_char;
}
/* add missing functions */
@@ -638,15 +638,12 @@
{
int start = s->offset;
- if (s->b->flags & BF_READONLY)
- return;
-
if (dir < 0)
do_backward_paragraph(s);
else
do_forward_paragraph(s);
- do_kill(s, start, s->offset, dir);
+ do_kill(s, start, s->offset, dir, 0);
}
void do_fill_paragraph(EditState *s)
@@ -828,7 +825,7 @@
for (i = argval; i < 0 && endpos > 0; i++) {
eb_prevc(s->b, endpos, &endpos);
}
- do_kill(s, s->offset, endpos, argval);
+ do_kill(s, s->offset, endpos, argval, 0);
}
void do_backspace(EditState *s, int argval)
@@ -1725,7 +1722,7 @@
/* do nothing! */
}
-void do_kill(EditState *s, int p1, int p2, int dir)
+void do_kill(EditState *s, int p1, int p2, int dir, int keep)
{
QEmacsState *qs = s->qe_state;
int len, tmp;
@@ -1734,9 +1731,6 @@
/* deactivate region hilite */
s->region_style = 0;
- if (dir && (s->b->flags & BF_READONLY))
- return;
-
if (p1 > p2) {
tmp = p1;
p1 = p2;
@@ -1750,56 +1744,81 @@
}
/* insert at beginning or end depending on kill direction */
eb_insert_buffer_convert(b, dir < 0 ? 0 : b->total_size, s->b, p1, len);
- if (dir) {
+ if (keep) {
+ /* no message */
+ } else
+ if (!(s->b->flags & BF_READONLY)) {
+ if (s->mode->delete_bytes) {
+ s->mode->delete_bytes(s, p1, len);
+ } else {
eb_delete(s->b, p1, len);
+ }
s->offset = p1;
- qs->this_cmd_func = (CmdFunc)do_append_next_kill;
} else {
put_status(s, "Region copied");
}
+ if (dir) {
+ qs->this_cmd_func = (CmdFunc)do_append_next_kill;
+ }
selection_activate(qs->screen);
}
-void do_kill_region(EditState *s, int killtype)
+void do_kill_region(EditState *s, int keep)
{
- do_kill(s, s->b->mark, s->offset, killtype);
+ do_kill(s, s->b->mark, s->offset, 0, keep);
}
-void do_kill_line(EditState *s, int dir)
+void do_kill_line(EditState *s, int argval)
{
- int p1, p2, offset1;
-
- if (s->b->flags & BF_READONLY)
- return;
+ int p1, p2, offset1, dir = 1;
p1 = s->offset;
- if (dir < 0) {
- /* kill beginning of line */
- do_bol(s);
- p2 = s->offset;
- } else {
- /* kill line */
+ if (argval == NO_ARG) {
+ /* kill to end of line */
if (eb_nextc(s->b, p1, &offset1) == '\n') {
- p2 = offset1;
+ p2 = s->offset = offset1;
} else {
- p2 = offset1;
- while (eb_nextc(s->b, p2, &offset1) != '\n') {
- p2 = offset1;
+ do_eol(s);
+ p2 = s->offset;
}
+ } else
+ if (argval <= 0) {
+ /* kill backwards */
+ dir = -1;
+ for (;;) {
+ do_bol(s);
+ p2 = s->offset;
+ if (p2 <= 0 || argval == 0)
+ break;
+ eb_prevc(s->b, p2, &p2);
+ s->offset = p2;
+ argval += 1;
+ }
+ } else {
+ for (;;) {
+ do_eol(s);
+ p2 = s->offset;
+ if (p2 >= s->b->total_size || argval == 0)
+ break;
+ eb_nextc(s->b, p2, &p2);
+ s->offset = p2;
+ argval -= 1;
}
}
- do_kill(s, p1, p2, dir);
+ do_kill(s, p1, p2, dir, 0);
+}
+
+void do_kill_beginning_of_line(EditState *s, int argval)
+{
+ do_kill_line(s, argval == NO_ARG ? 0 : -argval);
}
void do_kill_word(EditState *s, int dir)
{
int start = s->offset;
- if (s->b->flags & BF_READONLY)
- return;
-
do_word_right(s, dir);
- do_kill(s, start, s->offset, dir);
+ do_kill(s, start, s->offset, dir, 0);
}
void do_yank(EditState *s)
@@ -7343,7 +7362,7 @@
e = motion_target;
if (!check_motion_target(e))
return;
- do_kill_region(e, 0);
+ do_kill_region(e, 1);
}
}
@@ -7636,8 +7655,8 @@
.move_eof = text_move_eof,
.move_word_left_right = text_move_word_left_right,
.scroll_up_down = text_scroll_up_down,
- .write_char = text_write_char,
.mouse_goto = text_mouse_goto,
+ .write_char = text_write_char,
};
/* find a resource file */
Index: qeconfig.h
===================================================================
RCS file: /sources/qemacs/qemacs/qeconfig.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- qeconfig.h 6 Mar 2016 19:53:06 -0000 1.57
+++ qeconfig.h 7 Jun 2016 08:56:40 -0000 1.58
@@ -111,18 +111,18 @@
"mark-whole-buffer", do_mark_whole_buffer)
CMD0( KEY_META(KEY_CTRL('w')), KEY_NONE,
"append-next-kill", do_append_next_kill)
- CMD3( KEY_CTRL('k'), KEY_NONE,
- "kill-line", do_kill_line, ESi, 1, "*v" )
- CMD3( KEY_NONE, KEY_NONE,
- "kill-beginning-of-line", do_kill_line, ESi, -1, "*v" )
+ CMD2( KEY_CTRL('k'), KEY_NONE,
+ "kill-line", do_kill_line, ESi, "ui" )
+ CMD2( KEY_NONE, KEY_NONE,
+ "kill-beginning-of-line", do_kill_beginning_of_line, ESi, "ui" )
CMD3( KEY_META(KEY_DEL), KEY_META(KEY_BS),
- "backward-kill-word", do_kill_word, ESi, -1, "*v" )
+ "backward-kill-word", do_kill_word, ESi, -1, "v" )
CMD3( KEY_META('d'), KEY_NONE,
- "kill-word", do_kill_word, ESi, 1, "*v" )
- CMD3( KEY_CTRL('w'), KEY_NONE,
- "kill-region", do_kill_region, ESi, 1, "*v" )
+ "kill-word", do_kill_word, ESi, 1, "v" )
+ CMD1( KEY_CTRL('w'), KEY_NONE,
+ "kill-region", do_kill_region, 0 )
CMD1( KEY_META('w'), KEY_NONE,
- "copy-region", do_kill_region, 0 )
+ "copy-region", do_kill_region, 1 )
CMD2( KEY_CTRL('y'), KEY_NONE,
"yank", do_yank, ES, "*")
CMD2( KEY_META('y'), KEY_NONE,
@@ -215,7 +215,7 @@
CMD2( KEY_META('q'), KEY_NONE,
"fill-paragraph", do_fill_paragraph, ES, "*")
CMD3( KEY_NONE, KEY_NONE,
- "kill-paragraph", do_kill_paragraph, ESi, 1, "*v")
+ "kill-paragraph", do_kill_paragraph, ESi, 1, "v")
CMD3( KEY_META('c'), KEY_NONE,
"capitalize-word", do_changecase_word, ESi, 2, "*v")
Index: unihex.c
===================================================================
RCS file: /sources/qemacs/qemacs/unihex.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- unihex.c 26 Aug 2015 22:51:25 -0000 1.30
+++ unihex.c 7 Jun 2016 08:56:40 -0000 1.31
@@ -228,8 +228,8 @@
.move_bol = unihex_move_bol,
.move_eol = unihex_move_eol,
.scroll_up_down = text_scroll_up_down,
- .write_char = hex_write_char,
.mouse_goto = text_mouse_goto,
+ .write_char = hex_write_char,
.get_mode_line = unihex_mode_line,
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs TODO.org extras.c html.c qe.h shell.c bu...,
Charlie Gordon <=