[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.h qe.c qeconfig.h search.c dired.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.h qe.c qeconfig.h search.c dired.c |
Date: |
Fri, 23 Dec 2016 08:00:55 -0500 (EST) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 16/12/23 08:00:55
Modified files:
. : qe.h qe.c qeconfig.h search.c dired.c
Log message:
display: cursor handling
- merge do_center_cursor and do_center_cursor_maybe:
do_center_cursor takes an `int force` argument
- add set-window-style command to change `e->default_style`
- change argument sign for do_scroll_left_right() for consistency
scroll window by increments of space_width
toggle WRAP_LINE, WRAP_WORD and WRAP_TRUNCATE in
do_scroll_left_right()
- do not force WRAP_TRUNCATE in dired view pane to avoid problems on
files
with extremely long lines
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.224&r2=1.225
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.231&r2=1.232
http://cvs.savannah.gnu.org/viewcvs/qemacs/qeconfig.h?cvsroot=qemacs&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/qemacs/search.c?cvsroot=qemacs&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.69&r2=1.70
Patches:
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -b -r1.224 -r1.225
--- qe.h 13 Dec 2016 17:20:51 -0000 1.224
+++ qe.h 23 Dec 2016 13:00:55 -0000 1.225
@@ -498,6 +498,10 @@
return b;
}
+static inline int max3(int a, int b, int c) {
+ return max(max(a, b), c);
+}
+
static inline int min(int a, int b) {
if (a < b)
return a;
@@ -505,6 +509,10 @@
return b;
}
+static inline int min3(int a, int b, int c) {
+ return min(min(a, b), c);
+}
+
static inline int clamp(int a, int b, int c) {
if (a < b)
return b;
@@ -1932,8 +1940,7 @@
void do_scroll_left_right(EditState *s, int dir);
void do_scroll_up_down(EditState *s, int dir);
void perform_scroll_up_down(EditState *s, int h);
-void do_center_cursor_maybe(EditState *s);
-void do_center_cursor(EditState *s);
+void do_center_cursor(EditState *s, int force);
void do_quote(EditState *s, int argval);
void do_overwrite_mode(EditState *s, int argval);
// should take argval
@@ -1959,6 +1966,7 @@
void do_set_indent_width(EditState *s, int indent_width);
void do_set_indent_tabs_mode(EditState *s, int val);
void display_window_borders(EditState *e);
+int find_style_index(const char *name);
QEStyleDef *find_style(const char *name);
void style_completion(CompleteState *cp);
void get_style(EditState *e, QEStyleDef *style, int style_index);
@@ -1971,6 +1979,7 @@
void do_toggle_mode_line(EditState *s);
void do_set_system_font(EditState *s, const char *qe_font_name,
const char *system_fonts);
+void do_set_window_style(EditState *s, const char *stylestr);
void call_func(CmdSig sig, CmdProto func, int nb_args, CmdArg *args,
unsigned char *args_type);
int parse_arg(const char **pp, unsigned char *argtype,
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.231
retrieving revision 1.232
diff -u -b -r1.231 -r1.232
--- qe.c 13 Dec 2016 17:20:51 -0000 1.231
+++ qe.c 23 Dec 2016 13:00:55 -0000 1.232
@@ -1089,19 +1089,32 @@
void do_scroll_left_right(EditState *s, int dir)
{
- if (dir < 0) {
+ DisplayState ds1, *ds = &ds1;
+ int adjust;
+
+ /* compute space_width */
+ display_init(ds, s, DISP_CURSOR);
+ adjust = dir * ds->space_width;
+
+ if (dir > 0) {
+ if (s->wrap == WRAP_TRUNCATE) {
if (s->x_disp[0] == 0) {
s->wrap = WRAP_LINE;
} else {
- /* XXX: should change x_disp by space_width increments */
- s->x_disp[0] += dir;
+ s->x_disp[0] = min(s->x_disp[0] + adjust, 0);
+ }
+ } else
+ if (s->wrap == WRAP_LINE) {
+ s->wrap = WRAP_WORD;
}
} else {
+ if (s->wrap == WRAP_WORD) {
+ s->wrap = WRAP_LINE;
+ } else
if (s->wrap == WRAP_LINE) {
s->wrap = WRAP_TRUNCATE;
} else {
- /* XXX: should change x_disp by space_width increments */
- s->x_disp[0] += dir;
+ s->x_disp[0] = min(s->x_disp[0] + adjust, 0);
}
}
}
@@ -1181,7 +1194,7 @@
/* center the cursor in the window */
/* XXX: make it generic to all modes */
-void do_center_cursor(EditState *s)
+void do_center_cursor(EditState *s, int force)
{
CursorContext cm;
@@ -1199,6 +1212,9 @@
int offset_top = s->offset;
eb_prevc(s->b, offset_top, &offset_top);
s->offset_top = s->mode->text_backward_offset(s, offset_top);
+ } else {
+ if (!force)
+ return;
}
get_cursor_pos(s, &cm);
@@ -1209,15 +1225,6 @@
perform_scroll_up_down(s, -((s->height / 2) - cm.yc));
}
-/* center window if offset is not currently visible */
-void do_center_cursor_maybe(EditState *s)
-{
- if (s->offset < s->offset_top
- || (s->offset_bottom >= 0 && s->offset >= s->offset_bottom)) {
- do_center_cursor(s);
- }
-}
-
/* called each time the cursor could be displayed */
typedef struct {
int yd;
@@ -2696,7 +2703,7 @@
}
}
-QEStyleDef *find_style(const char *name)
+int find_style_index(const char *name)
{
int i;
QEStyleDef *style;
@@ -2704,13 +2711,23 @@
style = qe_styles;
for (i = 0; i < QE_STYLE_NB; i++, style++) {
if (strequal(style->name, name))
- return style;
+ return i;
}
if (qe_isdigit(*name)) {
i = strtol(name, NULL, 0);
if (i < QE_STYLE_NB)
- return qe_styles + i;
+ return i;
}
+ return -1;
+}
+
+QEStyleDef *find_style(const char *name)
+{
+ int i = find_style_index(name);
+
+ if (i >= 0 && i < QE_STYLE_NB)
+ return qe_styles + i;
+ else
return NULL;
}
@@ -2866,6 +2883,17 @@
do_refresh(s);
}
+void do_set_window_style(EditState *s, const char *stylestr)
+{
+ int style = find_style_index(stylestr);
+
+ if (style < 0) {
+ put_status(s, "Unknown style '%s'", stylestr);
+ return;
+ }
+ s->default_style = style;
+}
+
void do_set_system_font(EditState *s, const char *qe_font_name,
const char *system_fonts)
{
@@ -2881,7 +2909,6 @@
system_fonts);
}
-
void display_init(DisplayState *s, EditState *e, enum DisplayType do_disp)
{
QEFont *font;
Index: qeconfig.h
===================================================================
RCS file: /sources/qemacs/qemacs/qeconfig.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- qeconfig.h 29 Jul 2016 11:20:08 -0000 1.59
+++ qeconfig.h 23 Dec 2016 13:00:55 -0000 1.60
@@ -274,8 +274,8 @@
CMD0( KEY_CTRLX('p'), KEY_NONE,
"previous-window", do_previous_window)
#ifndef CONFIG_TINY
- CMD0( KEY_META(KEY_CTRL('l')), KEY_NONE,
- "center-cursor", do_center_cursor)
+ CMD1( KEY_META(KEY_CTRL('l')), KEY_NONE,
+ "center-cursor", do_center_cursor, 1)
CMD1( KEY_CTRL('x'), KEY_UP,
"find-window-up", do_find_window, KEY_UP)
CMD1( KEY_CTRL('x'), KEY_DOWN,
@@ -285,9 +285,9 @@
CMD1( KEY_CTRL('x'), KEY_RIGHT,
"find-window-right", do_find_window, KEY_RIGHT)
CMD1( KEY_META('('), KEY_NONE,
- "scroll-left", do_scroll_left_right, 1)
+ "scroll-left", do_scroll_left_right, -1)
CMD1( KEY_META(')'), KEY_NONE,
- "scroll-right", do_scroll_left_right, -1)
+ "scroll-right", do_scroll_left_right, 1)
CMD1( KEY_NONE, KEY_NONE,
"preview-mode", do_preview_mode, 1)
#endif
@@ -357,6 +357,9 @@
"set-system-font", do_set_system_font, ESss,
"s{Font family: }|fontfamily|"
"s{System fonts: }|fontnames|")
+ CMD2( KEY_NONE, KEY_NONE,
+ "set-window-style", do_set_window_style, ESs,
+ "s{Style: }[style]|style|")
/*---------------- Miscellaneous ----------------*/
Index: search.c
===================================================================
RCS file: /sources/qemacs/qemacs/search.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- search.c 6 Mar 2016 19:53:06 -0000 1.7
+++ search.c 23 Dec 2016 13:00:55 -0000 1.8
@@ -322,7 +322,7 @@
buf_puts(out, "^Q-");
/* display text */
- do_center_cursor_maybe(s);
+ do_center_cursor(s, 0);
edit_display(s->qe_state);
put_status(NULL, "%s", out->buf); /* XXX: why NULL? */
elapsed_time = get_clock_ms() - start_time;
@@ -470,7 +470,7 @@
is->search_flags &= ~SEARCH_FLAG_SMARTCASE;
break;
case KEY_CTRL('l'):
- do_center_cursor(s);
+ do_center_cursor(s, 1);
break;
default:
if ((KEY_IS_SPECIAL(ch) || KEY_IS_CONTROL(ch)) && ch != '\t') {
@@ -708,7 +708,7 @@
s->offset = is->found_end;
s->b->mark = is->found_offset;
s->region_style = QE_STYLE_SEARCH_MATCH;
- do_center_cursor_maybe(s);
+ do_center_cursor(s, 0);
edit_display(s->qe_state);
put_status(NULL, "%s", out->buf);
dpy_flush(s->screen);
@@ -773,7 +773,7 @@
query_replace_abort(is);
return;
case KEY_CTRL('l'):
- do_center_cursor(s);
+ do_center_cursor(s, 1);
break;
case '.':
query_replace_replace(is);
@@ -864,7 +864,7 @@
continue;
} else {
s->offset = (dir < 0) ? found_offset : found_end;
- do_center_cursor_maybe(s);
+ do_center_cursor(s, 0);
return;
}
} else {
Index: dired.c
===================================================================
RCS file: /sources/qemacs/qemacs/dired.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- dired.c 26 Nov 2016 11:30:29 -0000 1.69
+++ dired.c 23 Dec 2016 13:00:55 -0000 1.70
@@ -1074,11 +1074,12 @@
if (rc >= 0) {
/* disable wrapping to get nicer display */
/* XXX: should wrap lines unless window is narrow */
- e->wrap = WRAP_TRUNCATE;
- }
- if (rc < 0) {
+ //e->wrap = WRAP_TRUNCATE; // causes bug on very long lines
+ } else {
/* if file failed to load, show a scratch buffer */
- switch_to_buffer(e, eb_new("*scratch*", BF_SAVELOG | BF_UTF8 |
BF_PREVIEW));
+ b = eb_new("*scratch*", BF_SAVELOG | BF_UTF8 | BF_PREVIEW);
+ eb_printf(b, "Cannot load file %s", filename);
+ switch_to_buffer(e, b);
}
}
@@ -1196,6 +1197,12 @@
append_slash(buf, buf_size);
return buf;
} else {
+ //// unused because buffer filename has been changed upon navigation
+ //// should deal with file view from multiple directories
+ //DiredState *ds = qe_get_buffer_mode_data(b, &dired_mode, NULL);
+ //if (ds) {
+ // return makepath(buf, buf_size, ds->path, "");
+ //}
return NULL;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs qe.h qe.c qeconfig.h search.c dired.c,
Charlie Gordon <=