[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.h qe.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.h qe.c |
Date: |
Fri, 29 Jul 2016 11:04:31 +0000 (UTC) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 16/07/29 11:04:31
Modified files:
. : qe.h qe.c
Log message:
edit: delete or kill the highlighted region automatically
- typing now first deletes the highlighted region
- delete-char and backward-delete-char delete the highlighted region if
any.
- kill-line kills the highlighted region if any.
- yank first deletes the highlighted region
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.220&r2=1.221
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.227&r2=1.228
Patches:
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -b -r1.220 -r1.221
--- qe.h 26 Jun 2016 08:35:26 -0000 1.220
+++ qe.h 29 Jul 2016 11:04:31 -0000 1.221
@@ -1857,6 +1857,7 @@
int generic_get_colorized_line(EditState *s, unsigned int *buf, int buf_size,
int *offsetp, int line_num);
+int do_delete_selection(EditState *s);
void do_char(EditState *s, int key, int argval);
void do_combine_char(EditState *s, int accent);
void do_set_mode(EditState *s, const char *name);
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.227
retrieving revision 1.228
diff -u -b -r1.227 -r1.228
--- qe.c 26 Jun 2016 08:35:25 -0000 1.227
+++ qe.c 29 Jul 2016 11:04:31 -0000 1.228
@@ -808,6 +808,12 @@
if (s->b->flags & BF_READONLY)
return;
+ /* Delete hilighted region, if any.
+ * do_append_next_kill silently ignored.
+ */
+ if (do_delete_selection(s))
+ return;
+
if (argval == NO_ARG) {
if (s->qe_state->last_cmd_func != (CmdFunc)do_append_next_kill) {
eb_delete_uchar(s->b, s->offset);
@@ -843,10 +849,11 @@
return;
}
- /* XXX: Should delete hilighted region */
-
- /* deactivate region hilite */
- s->region_style = 0;
+ /* Delete hilighted region, if any.
+ * do_append_next_kill silently ignored.
+ */
+ if (do_delete_selection(s))
+ return;
if (argval == NO_ARG) {
if (s->qe_state->last_cmd_func == (CmdFunc)do_tab
@@ -1400,6 +1407,21 @@
}
#endif
+int do_delete_selection(EditState *s)
+{
+ int res = 0;
+
+ if (s->region_style && s->b->mark != s->offset) {
+ /* Delete hilighted region */
+ // XXX: make it optional?
+ res = eb_delete_range(s->b, s->b->mark, s->offset);
+ }
+ /* deactivate region hilite */
+ s->region_style = 0;
+
+ return res;
+}
+
void do_char(EditState *s, int key, int argval)
{
#ifndef CONFIG_TINY
@@ -1416,10 +1438,8 @@
if (s->b->flags & BF_READONLY)
return;
- /* XXX: Should delete hilighted region */
-
- /* deactivate region hilite */
- s->region_style = 0;
+ /* Delete hilighted region */
+ do_delete_selection(s);
for (;;) {
if (s->mode->write_char)
@@ -1773,10 +1793,16 @@
p1 = s->offset;
if (argval == NO_ARG) {
- /* kill to end of line */
+ if (s->region_style && s->b->mark != s->offset) {
+ /* kill highlighted region */
+ p1 = s->b->mark;
+ p2 = s->offset;
+ } else
if (eb_nextc(s->b, p1, &offset1) == '\n') {
+ /* kill end of line marker */
p2 = s->offset = offset1;
} else {
+ /* kill to end of line */
do_eol(s);
p2 = s->offset;
}
@@ -1829,6 +1855,9 @@
if (s->b->flags & BF_READONLY)
return;
+ /* First delete any highlighted range */
+ do_delete_selection(s);
+
/* if the GUI selection is used, it will be handled in the GUI code */
selection_request(qs->screen);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs qe.h qe.c,
Charlie Gordon <=