[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs TODO.org dired.c extras.c hex.c list.c m...
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs TODO.org dired.c extras.c hex.c list.c m... |
Date: |
Tue, 25 Apr 2017 13:41:28 -0400 (EDT) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 17/04/25 13:41:27
Modified files:
. : TODO.org dired.c extras.c hex.c list.c
markdown.c mpeg.c qe.c qe.h shell.c unihex.c
Log message:
display: improve line wrap handling
- add WRAP_AUTO and WRAP_TERM (for terminal emulator)
WRAP_AUTO wraps lines if the window is more than 3/4 of the screen
width
if window is narrower, lines are truncated.
WRAP_TERM does not display the \ wrapping mark to simulate terminal
behavior
- add default_wrap member in ModeDef structure
- delegate to view pane for man, ssh and compile commands
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/TODO.org?cvsroot=qemacs&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/qemacs/dired.c?cvsroot=qemacs&r1=1.78&r2=1.79
http://cvs.savannah.gnu.org/viewcvs/qemacs/extras.c?cvsroot=qemacs&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/qemacs/hex.c?cvsroot=qemacs&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/qemacs/list.c?cvsroot=qemacs&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/qemacs/markdown.c?cvsroot=qemacs&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/qemacs/mpeg.c?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.276&r2=1.277
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.258&r2=1.259
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.128&r2=1.129
http://cvs.savannah.gnu.org/viewcvs/qemacs/unihex.c?cvsroot=qemacs&r1=1.38&r2=1.39
Patches:
Index: TODO.org
===================================================================
RCS file: /sources/qemacs/qemacs/TODO.org,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- TODO.org 21 Apr 2017 14:44:14 -0000 1.38
+++ TODO.org 25 Apr 2017 17:41:27 -0000 1.39
@@ -1,7 +1,7 @@
; TODO list for qemacs
;
; Author: Charles Gordon
-; Updated: 2017-04-21
+; Updated: 2017-04-24
* Recent bugs and ideas
@@ -17,9 +17,15 @@
** display: hex-mode and binary-mode should have an initial skip value to
align the display on any boundary
** display: optimize display for very large display-width in binary and hex
modes
** display: add screen dump command and format
+** display: toggle-full-screen should work on popups
+** display: toggle-full-screen should not put modeline on popup
+** display: colorize extra ^M and ^Z as preproc at end of line prior to
calling the syntax highlighter (same as BOM)
+** display: display bug on
~/comp/projects/fractal/fractint/ORGFORM/BAILOUT.FRM (double ^M)
+** display: colorizer bug on
/comp/projects/fractal/fractint/ORGFORM/NOEL-2.FRM (triple ^M)
** files: actually load file in find-file-noselect
** files: ignore .DS_Store in completion
** files: fix SPC / TAB distinct behaviors on ~/comp/project/gnachman/
+** modes: next-mode should include buffer default_mode in list
** shell: support ':' as alternate escape sequence argument separator
** shell: use target window for man and similar commands
** tags: remove tags for modified line
@@ -286,7 +292,7 @@
* Clean window deletion mess:
-** avoid problems with popups (kill_buffer, delete_window, split_window)
+** avoid problems with popups (kill_buffer, delete_window)
** detach window from tree and keep attached to buffer if last
** detach window from tree and put in delayed free tree otherwise
Index: dired.c
===================================================================
RCS file: /sources/qemacs/qemacs/dired.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -b -r1.78 -r1.79
--- dired.c 25 Apr 2017 17:14:30 -0000 1.78
+++ dired.c 25 Apr 2017 17:41:27 -0000 1.79
@@ -1072,9 +1072,6 @@
*/
rc = qe_load_file(e, filename, 0, BF_PREVIEW);
if (rc >= 0) {
- /* disable wrapping to get nicer display */
- /* XXX: should wrap lines unless window is narrow */
- //e->wrap = WRAP_TRUNCATE; // causes bug on very long lines
return e;
} else {
/* if file failed to load, show a scratch buffer */
@@ -1436,7 +1433,6 @@
if (!access(filename, R_OK)) {
e = dired_view_file(s, filename);
if (e) {
- e->wrap = WRAP_TRUNCATE;
if (target_line > 0)
do_goto_line(e, target_line, 0);
}
@@ -1455,6 +1451,7 @@
e = insert_window_left(s->b, qs->width / 5, WF_MODELINE | WF_FILELIST);
if (e != NULL) {
edit_set_mode(e, &filelist_mode);
+ /* XXX: should come from mode.default_wrap */
e->wrap = WRAP_TRUNCATE;
filelist_last_buf[0] = '\0';
qs->active_window = e;
@@ -1464,6 +1461,7 @@
static int filelist_mode_init(EditState *s, EditBuffer *b, int flags)
{
if (s) {
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_TRUNCATE;
}
return 0;
Index: extras.c
===================================================================
RCS file: /sources/qemacs/qemacs/extras.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- extras.c 25 Apr 2017 17:15:03 -0000 1.71
+++ extras.c 25 Apr 2017 17:41:27 -0000 1.72
@@ -1451,8 +1451,10 @@
eb_printf(b1, "%*s: %d\n", w, "bidir", s->bidir);
eb_printf(b1, "%*s: %d\n", w, "cur_rtl", s->cur_rtl);
eb_printf(b1, "%*s: %d %s\n", w, "wrap", s->wrap,
+ s->wrap == WRAP_AUTO ? "AUTO" :
s->wrap == WRAP_TRUNCATE ? "TRUNCATE" :
s->wrap == WRAP_LINE ? "LINE" :
+ s->wrap == WRAP_TERM ? "TERM" :
s->wrap == WRAP_WORD ? "WORD" : "???");
eb_printf(b1, "%*s: %d\n", w, "line_numbers", s->line_numbers);
eb_printf(b1, "%*s: %d\n", w, "indent_size", s->indent_size);
Index: hex.c
===================================================================
RCS file: /sources/qemacs/qemacs/hex.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- hex.c 25 Apr 2017 16:56:26 -0000 1.53
+++ hex.c 25 Apr 2017 17:41:27 -0000 1.54
@@ -175,6 +175,7 @@
s->hex_mode = 0;
s->unihex_mode = 0;
s->insert = 0;
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_TRUNCATE;
}
return 0;
@@ -188,6 +189,7 @@
s->hex_nibble = 0;
s->unihex_mode = 0;
s->insert = 0;
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_TRUNCATE;
}
return 0;
Index: list.c
===================================================================
RCS file: /sources/qemacs/qemacs/list.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- list.c 25 Apr 2017 16:46:41 -0000 1.25
+++ list.c 25 Apr 2017 17:41:27 -0000 1.26
@@ -95,6 +95,7 @@
static int list_mode_init(EditState *s, EditBuffer *b, int flags)
{
if (s) {
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_TRUNCATE;
s->get_colorized_line = list_get_colorized_line;
}
Index: markdown.c
===================================================================
RCS file: /sources/qemacs/qemacs/markdown.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- markdown.c 25 Apr 2017 16:46:41 -0000 1.28
+++ markdown.c 25 Apr 2017 17:41:27 -0000 1.29
@@ -836,6 +836,7 @@
if (s) {
s->b->tab_width = 4;
s->indent_tabs_mode = 0;
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_WORD;
}
return 0;
@@ -853,6 +854,7 @@
if (s) {
s->b->tab_width = 4;
s->indent_tabs_mode = 0;
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_WORD;
s->mode->colorize_flags = mkd_add_lang("coffee");
}
Index: mpeg.c
===================================================================
RCS file: /sources/qemacs/qemacs/mpeg.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- mpeg.c 23 Dec 2016 15:51:51 -0000 1.11
+++ mpeg.c 25 Apr 2017 17:41:27 -0000 1.12
@@ -143,6 +143,7 @@
if (s) {
s->hex_mode = 1;
s->hex_nibble = 0;
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_TRUNCATE;
}
return 0;
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.276
retrieving revision 1.277
diff -u -b -r1.276 -r1.277
--- qe.c 25 Apr 2017 17:15:03 -0000 1.276
+++ qe.c 25 Apr 2017 17:41:27 -0000 1.277
@@ -124,15 +124,12 @@
QEmacsState *qs = &qe_state;
ModeDef **p;
- m->flags |= flags;
-
- if (!m->mode_name)
- m->mode_name = m->name;
-
/* register mode in mode list (at end) */
for (p = &qs->first_mode;; p = &(*p)->next) {
- if (*p == m)
+ if (*p == m) {
+ /* mode is already registered, do nothing */
return;
+ }
if (*p == NULL) {
m->next = NULL;
*p = m;
@@ -140,6 +137,11 @@
}
}
+ m->flags |= flags;
+
+ if (!m->mode_name)
+ m->mode_name = m->name;
+
if (m->flags & MODEF_SYNTAX) {
/* if no syntax probing function, use extension matcher */
if (!m->mode_probe && m->extensions)
@@ -271,6 +273,7 @@
}
lp = m ? &m->first_key : &qs->first_key;
/* Bindings must be prepended to override previous bindings */
+ /* XXX: should avoid multiple redundant bindings */
#if 0
while (*lp != NULL && (*lp)->mode != NULL)
lp = &(*lp)->next;
@@ -1203,6 +1206,9 @@
DisplayState ds1, *ds = &ds1;
int adjust;
+ if (s->wrap == WRAP_TERM)
+ return;
+
/* compute space_width */
display_init(ds, s, DISP_NONE, NULL, NULL);
adjust = dir * ds->space_width;
@@ -1216,14 +1222,14 @@
s->x_disp[0] = min(s->x_disp[0] + adjust, 0);
}
} else
- if (s->wrap == WRAP_LINE) {
+ if (s->wrap == WRAP_LINE || s->wrap == WRAP_AUTO) {
s->wrap = WRAP_WORD;
}
} else {
if (s->wrap == WRAP_WORD) {
s->wrap = WRAP_LINE;
} else
- if (s->wrap == WRAP_LINE) {
+ if (s->wrap == WRAP_LINE || s->wrap == WRAP_AUTO) {
s->wrap = WRAP_TRUNCATE;
} else {
s->x_disp[0] = min(s->x_disp[0] + adjust, 0);
@@ -2271,6 +2277,7 @@
/* init mode */
generic_mode_init(s);
+ s->wrap = m->default_wrap;
m->mode_init(s, s->b, MODEF_VIEW | mode_flags);
if (m->colorize_func)
set_colorize_func(s, m->colorize_func);
@@ -2443,6 +2450,9 @@
void do_toggle_truncate_lines(EditState *s)
{
+ if (s->wrap == WRAP_TERM)
+ return;
+
if (s->wrap == WRAP_TRUNCATE) {
s->wrap = WRAP_LINE;
s->x_disp[0] = s->x_disp[1] = 0;
@@ -2453,6 +2463,9 @@
void do_word_wrap(EditState *s)
{
+ if (s->wrap == WRAP_TERM)
+ return;
+
if (s->wrap == WRAP_WORD) {
s->wrap = WRAP_LINE;
} else {
@@ -3126,16 +3139,31 @@
ds->cursor_func = cursor_func;
ds->cursor_opaque = cursor_opaque;
ds->wrap = e->wrap;
+ if (ds->wrap == WRAP_AUTO) {
+ /* XXX: check e->mode->default_wrap */
+ /* Behave as WRAP_LINE if window is not at least 75% of full width.
+ * This allows the same default behavior for full width window and
+ * the dired view pane but behaves as WRAP_TRUNCATE on split screens
+ */
+ if (e->width >= e->screen->width * 3 / 4) {
+ ds->wrap = WRAP_LINE;
+ }
+ }
/* select default values */
get_style(e, &styledef, QE_STYLE_DEFAULT);
font = select_font(e->screen, styledef.font_style, styledef.font_size);
ds->default_line_height = font->ascent + font->descent;
+ ds->space_width = glyph_width(e->screen, font, ' ');
+ ds->tab_width = ds->space_width * e->b->tab_width;
+ if (ds->wrap == WRAP_TERM) {
+ ds->eol_width = 0;
+ ds->width = e->wrap_cols * glyph_width(e->screen, font, '0');
+ } else {
ds->eol_width = max3(glyph_width(e->screen, font, '/'),
glyph_width(e->screen, font, '\\'),
glyph_width(e->screen, font, '$'));
- ds->space_width = glyph_width(e->screen, font, ' ');
- ds->tab_width = ds->space_width * e->b->tab_width;
ds->width = e->width - ds->eol_width;
+ }
ds->height = e->height;
ds->hex_mode = e->hex_mode;
ds->cur_hex_mode = 0;
@@ -3328,7 +3356,7 @@
}
}
- if (last == 0) {
+ if (last == 0 && ds->eol_width != 0) {
/* draw eol mark */
unsigned int markbuf[1];
@@ -3560,8 +3588,10 @@
switch (ds->wrap) {
case WRAP_TRUNCATE:
+ case WRAP_AUTO:
break;
case WRAP_LINE:
+ case WRAP_TERM:
while (ds->x > ds->width) {
int len1, w1, ww, n;
//printf("x=%d maxw=%d len=%d\n", ds->x, ds->width, frag->len);
@@ -4346,7 +4376,7 @@
/* update x cursor position if needed. Note that we distinguish
between rtl and ltr margins. We try to have x_disp == 0 as much
as possible */
- if (s->wrap == WRAP_TRUNCATE) {
+ if (ds->wrap == WRAP_TRUNCATE) {
#if 1 //@@@?
//put_status(s, "|xc=%d x_disp+%d", m->xc, s->x_disp[m->basec]);
if (m->xc != NO_CURSOR) {
@@ -5589,7 +5619,7 @@
s->insert = 1;
s->indent_size = s->qe_state->default_tab_width;
s->default_style = QE_STYLE_DEFAULT;
- s->wrap = WRAP_LINE;
+ s->wrap = mode ? mode->default_wrap : WRAP_AUTO;
}
}
/* validate the mode */
@@ -6292,6 +6322,7 @@
s->prompt = qe_strdup(prompt);
s->bidir = 0;
s->default_style = QE_STYLE_MINIBUF;
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_TRUNCATE;
/* add default input */
@@ -6407,6 +6438,7 @@
b->default_mode = &popup_mode;
e = edit_new(b, (w1 - w) / 2, (h1 - h) / 2, w, h, WF_POPUP);
+ /* XXX: should come from mode.default_wrap */
e->wrap = WRAP_TRUNCATE;
e->target_window = s;
qs->active_window = e;
@@ -6447,6 +6479,7 @@
e_new = edit_new(b, 0, 0, width, qs->height - qs->status_height,
flags | WF_POPLEFT | WF_RSEPARATOR);
+ /* XXX: WRAP_AUTO is a better choice? */
e_new->wrap = WRAP_TRUNCATE;
do_refresh(e_new);
return e_new;
@@ -6981,8 +7014,7 @@
/* XXX: should actually initialize SAVED_DATA area in new buffer */
s->offset = 0;
- /* XXX: Should test for full width and WRAP_TRUNCATE if not */
- s->wrap = WRAP_LINE; /* default mode may override this */
+ s->wrap = WRAP_AUTO; /* default mode may override this */
/* First we try to read the first block to determine the data type */
if (stat(filename, &st) < 0) {
@@ -7722,7 +7754,7 @@
"offset:", "offset.col:", "mark:", "mark.col:", "top:", "top.col:",
"active:",
};
- int args[] = { 0, 0, 0, 0, WF_MODELINE, WRAP_LINE, 0, 0, 0, 0, 0, 0, 0 };
+ int args[] = { 0, 0, 0, 0, WF_MODELINE, WRAP_AUTO, 0, 0, 0, 0, 0, 0, 0 };
ModeDef *m = NULL;
int i, n, x1, y1, x2, y2, flags;
enum WrapType wrap;
@@ -8292,7 +8324,7 @@
s->hex_nibble = 0;
s->unihex_mode = 0;
s->insert = 1;
- s->wrap = WRAP_LINE;
+ s->wrap = WRAP_AUTO;
/* free all callbacks or associated buffer data */
set_colorize_func(s, NULL);
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.258
retrieving revision 1.259
diff -u -b -r1.258 -r1.259
--- qe.h 25 Apr 2017 17:15:03 -0000 1.258
+++ qe.h 25 Apr 2017 17:41:27 -0000 1.259
@@ -1354,9 +1354,11 @@
} QELineShadow;
enum WrapType {
- WRAP_TRUNCATE = 0,
+ WRAP_AUTO = 0,
+ WRAP_TRUNCATE,
WRAP_LINE,
- WRAP_WORD
+ WRAP_TERM,
+ WRAP_WORD,
};
#define DIR_LTR 0
@@ -1378,6 +1380,7 @@
int bidir;
int cur_rtl; /* TRUE if the cursor on over RTL chars */
enum WrapType wrap;
+ int wrap_cols; /* number of columns in terminal emulator */
int line_numbers;
/* XXX: these should be buffer specific rather than window specific */
int indent_size;
@@ -1526,6 +1529,7 @@
ColorizeFunc colorize_func;
int colorize_flags;
int auto_indent;
+ int default_wrap;
/* common functions are defined here */
/* TODO: Should have single move function with move type and argument */
Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -b -r1.128 -r1.129
--- shell.c 21 Apr 2017 14:44:14 -0000 1.128
+++ shell.c 25 Apr 2017 17:41:27 -0000 1.129
@@ -484,10 +484,9 @@
}
/* Compute offset of the char at column x and row y (0 based).
- * Can insert spaces or rows if needed.
+ * Can insert spaces or newlines if needed.
* x and y may each be relative to the current position.
*/
-/* XXX: optimize !!!!! */
static void qe_term_goto_xy(ShellState *s, int x, int y, int relative)
{
int total_lines, cur_line, line_num, col_num, offset, offset1, c;
@@ -1908,7 +1907,7 @@
cols = QE_TERM_XSIZE;
rows = QE_TERM_YSIZE;
if (e) {
- cols = e->cols - 1;
+ cols = e->cols;
rows = e->rows;
}
s->cols = cols;
@@ -2010,6 +2009,15 @@
char cmd[128];
EditBuffer *b;
+ if (s->flags & (WF_POPUP | WF_MINIBUF))
+ return;
+
+ if (s->flags & WF_POPLEFT) {
+ /* avoid messing with the dired pane */
+ s = find_window(s, KEY_RIGHT, s);
+ s->qe_state->active_window = s;
+ }
+
/* Assume standard man command */
snprintf(cmd, sizeof(cmd), "man %s", arg);
@@ -2034,6 +2042,15 @@
char cmd[128];
EditBuffer *b;
+ if (s->flags & (WF_POPUP | WF_MINIBUF))
+ return;
+
+ if (s->flags & WF_POPLEFT) {
+ /* avoid messing with the dired pane */
+ s = find_window(s, KEY_RIGHT, s);
+ s->qe_state->active_window = s;
+ }
+
/* Use standard ssh command */
snprintf(cmd, sizeof(cmd), "ssh %s", arg);
snprintf(bufname, sizeof(bufname), "*ssh-%s*", arg);
@@ -2552,10 +2569,19 @@
edit_set_mode(e, &pager_mode);
}
-static void do_compile(EditState *e, const char *cmd)
+static void do_compile(EditState *s, const char *cmd)
{
EditBuffer *b;
+ if (s->flags & (WF_POPUP | WF_MINIBUF))
+ return;
+
+ if (s->flags & WF_POPLEFT) {
+ /* avoid messing with the dired pane */
+ s = find_window(s, KEY_RIGHT, s);
+ s->qe_state->active_window = s;
+ }
+
/* if the buffer already exists, kill it */
b = eb_find("*compilation*");
if (b) {
@@ -2566,15 +2592,15 @@
cmd = "make";
/* create new buffer */
- b = new_shell_buffer(NULL, e, "*compilation*", "Compilation", cmd,
+ b = new_shell_buffer(NULL, s, "*compilation*", "Compilation", cmd,
SF_COLOR | SF_INFINITE);
if (!b)
return;
b->data_type_name = "compile";
/* XXX: try to split window if necessary */
- switch_to_buffer(e, b);
- edit_set_mode(e, &pager_mode);
+ switch_to_buffer(s, b);
+ edit_set_mode(s, &pager_mode);
set_error_offset(b, 0);
}
@@ -2871,7 +2897,9 @@
return -1;
e->b->tab_width = 8;
- e->wrap = WRAP_TRUNCATE;
+ /* XXX: should come from mode.default_wrap */
+ e->wrap = WRAP_TERM;
+ e->wrap_cols = s->cols;
if (s->shell_flags & SF_INTERACTIVE)
e->interactive = 1;
}
@@ -2882,6 +2910,7 @@
{
if (e) {
e->b->tab_width = 8;
+ /* XXX: should come from mode.default_wrap */
e->wrap = WRAP_TRUNCATE;
}
return 0;
Index: unihex.c
===================================================================
RCS file: /sources/qemacs/qemacs/unihex.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- unihex.c 19 Mar 2017 15:39:25 -0000 1.38
+++ unihex.c 25 Apr 2017 17:41:27 -0000 1.39
@@ -47,6 +47,7 @@
s->unihex_mode = w = snprintf(NULL, 0, "%x", maxc);
s->dump_width = clamp((s->width - 8 - 2 - 2 - 1) / (w + 3), 8, 16);
s->insert = 0;
+ /* XXX: should come from mode.default_wrap */
s->wrap = WRAP_TRUNCATE;
}
return 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs TODO.org dired.c extras.c hex.c list.c m...,
Charlie Gordon <=