diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e0894b..f35e003 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-12, macos-14] + os: [macos-13, macos-14] steps: - uses: actions/checkout@v4 - name: build diff --git a/Makefile b/Makefile index e3e2a15..2c4432f 100644 --- a/Makefile +++ b/Makefile @@ -586,7 +586,8 @@ clean: rm -rf *.dSYM *.gch .objs* .tobjs* .xobjs* bin rm -f *~ *.o *.a *.exe *_g *_debug TAGS gmon.out core *.exe.stackdump \ qe tqe tqe1 xqe kmaptoqe ligtoqe html2png cptoqe jistoqe \ - fbftoqe fbffonts.c allmodules.txt basemodules.txt '.#'*[0-9] + fbftoqe fbffonts.c allmodules.txt basemodules.txt '.#'*[0-9] \ + qe_asan qe_msan qe_ubsan distclean: clean $(MAKE) -C libqhtml distclean diff --git a/buffer.c b/buffer.c index 757d9aa..d8e3ae5 100644 --- a/buffer.c +++ b/buffer.c @@ -1226,7 +1226,7 @@ void do_undo(EditState *s) LogBuffer lb; if (!b->log_buffer) { - put_status(s, "No undo information"); + put_error(s, "No undo information"); return; } @@ -1246,14 +1246,14 @@ void do_undo(EditState *s) log_index = b->log_current - 1; } if (log_index == 0) { - put_status(s, "No further undo information"); + put_error(s, "No further undo information"); return; } else { put_status(s, "Undo!"); } if (!qs->first_transient_key && (qs->last_key == 'u' || qs->last_key == 'u')) { - put_status(s, "repeat with 'u', 'r'"); + put_status(s, "Repeat with 'u', 'r'"); qe_register_transient_binding(qs, "undo", "u"); qe_register_transient_binding(qs, "redo", "r"); } @@ -1311,7 +1311,7 @@ void do_redo(EditState *s) LogBuffer lb; if (!b->log_buffer) { - put_status(s, "No undo information"); + put_error(s, "No undo information"); return; } @@ -1325,7 +1325,7 @@ void do_redo(EditState *s) } if (!b->log_current || !b->log_new_index) { - put_status(s, "Nothing to redo"); + put_error(s, "Nothing to redo"); return; } put_status(s, "Redo!"); @@ -2019,7 +2019,7 @@ int eb_raw_buffer_load1(EditBuffer *b, FILE *f, int offset) unsigned char buf[IOBUF_SIZE]; int len, size, inserted; - //put_status(b->qs->active_window, "loading %s", filename); + //put_status(b->qs->active_window, "Loading %s", filename); size = inserted = 0; for (;;) { len = fread(buf, 1, IOBUF_SIZE, f); @@ -2058,7 +2058,7 @@ int eb_mmap_buffer(EditBuffer *b, const char *filename) if (fd < 0) return -1; file_size = lseek(fd, 0, SEEK_END); - //put_status(b->qs->active_window, "mapping %s", filename); + //put_status(b->qs->active_window, "Mapping %s", filename); file_ptr = mmap(NULL, file_size, PROT_READ, MAP_SHARED, fd, 0); if ((void*)file_ptr == MAP_FAILED) { close(fd); @@ -2130,7 +2130,7 @@ static int raw_buffer_save(EditBuffer *b, int start, int end, if (fd < 0) return -1; - //put_status(b->qs->active_window, "writing %s", filename); + //put_status(b->qs->active_window, "Writing %s", filename); if (end < start) { int tmp = start; start = end; diff --git a/charset.c b/charset.c index 11067db..45e2072 100644 --- a/charset.c +++ b/charset.c @@ -23,7 +23,6 @@ * THE SOFTWARE. */ -#include "util.h" #include "charset.h" /* XXX: Should move this to QEmacsState, and find a way for html2png */ diff --git a/display.h b/display.h index d2178d2..7094156 100644 --- a/display.h +++ b/display.h @@ -124,7 +124,7 @@ struct QEDisplay { void (*dpy_describe)(QEditScreen *s, struct EditBuffer *b); void (*dpy_sound_bell)(QEditScreen *s); void (*dpy_suspend)(QEditScreen *s); - void (*dpy_error)(QEditScreen *s, const char *fmt, ...); + void (*dpy_error)(QEditScreen *s, const char *fmt, ...) qe__attr_printf(2,3); QEDisplay *next; }; diff --git a/extras.c b/extras.c index 8afdf46..0bb2cff 100644 --- a/extras.c +++ b/extras.c @@ -388,11 +388,11 @@ void do_compare_files(EditState *s, const char *filename, int bflags) snprintf(buf, sizeof(buf), "../%s", filename); } else if (pathlen == 1) { - put_status(s, "Reference file is in root directory: %s", filename); + put_error(s, "Reference file is in root directory: %s", filename); return; } else if (pathlen >= MAX_FILENAME_SIZE) { - put_status(s, "Filename too long: %s", filename); + put_error(s, "Filename too long: %s", filename); return; } else { pstrcpy(buf, sizeof(buf), filename); @@ -403,13 +403,11 @@ void do_compare_files(EditState *s, const char *filename, int bflags) // XXX: should check for regular file if (access(filename, R_OK)) { - put_status(s, "Cannot access file %s: %s", - filename, strerror(errno)); + put_error(s, "Cannot access file %s: %s", filename, strerror(errno)); return; } if (access(buf, R_OK)) { - put_status(s, "Cannot access file %s: %s", - buf, strerror(errno)); + put_error(s, "Cannot access file %s: %s", buf, strerror(errno)); return; } @@ -443,7 +441,7 @@ static void do_adjust_window(EditState *s, int argval, int flags) argval = -argval; if (!qs->first_transient_key) { - put_status(s, "adjusting window, repeat with ^, }, {, v"); + put_status(s, "Adjusting window, repeat with ^, }, {, v"); qe_register_transient_binding(qs, "enlarge-window", "^, up"); qe_register_transient_binding(qs, "shrink-window", "v, down"); qe_register_transient_binding(qs, "enlarge-window-horizontally", "}, right"); @@ -748,7 +746,7 @@ static void do_indent_rigidly(EditState *s, int start, int end, int argval) QEmacsState *qs = s->qs; if (!qs->first_transient_key) { s->region_style = QE_STYLE_REGION_HILITE; - put_status(s, "indent the region interactively with TAB, left, right, S-left, S-right"); + put_status(s, "Indent the region interactively with TAB, left, right, S-left, S-right"); qe_register_transient_binding(qs, "indent-rigidly-left", "left"); qe_register_transient_binding(qs, "indent-rigidly-right", "right"); qe_register_transient_binding(qs, "indent-rigidly-left-to-tab-stop", "S-left, S-TAB"); @@ -924,8 +922,8 @@ static void forward_block(EditState *s, int dir) --level; if (level < MAX_LEVEL && balance[level] != c) { /* XXX: should set mark and offset */ - put_status(s, "Unmatched delimiter %c <> %c", - c, balance[level]); + put_error(s, "Unmatched delimiter %c <> %c", + c, balance[level]); goto done; } if (level == 0) { @@ -1008,8 +1006,8 @@ static void forward_block(EditState *s, int dir) --level; if (level < MAX_LEVEL && balance[level] != c) { /* XXX: should set mark and offset */ - put_status(s, "Unmatched delimiter %c <> %c", - c, balance[level]); + put_error(s, "Unmatched delimiter %c <> %c", + c, balance[level]); goto done; } if (level == 0) { @@ -1025,7 +1023,7 @@ static void forward_block(EditState *s, int dir) } if (level != 0) { /* XXX: should set mark and offset */ - put_status(s, "Unmatched delimiter"); + put_error(s, "Unmatched delimiter"); } else { s->offset = offset; } @@ -1220,7 +1218,7 @@ void do_show_bindings(EditState *s, const char *cmd_name) const CmdDef *d; if ((d = qe_find_cmd(qs, cmd_name)) == NULL) { - put_status(s, "No command %s", cmd_name); + put_error(s, "No command %s", cmd_name); return; } if (qe_list_bindings(qs, d, s->mode, 1, buf, sizeof(buf))) { @@ -1236,7 +1234,7 @@ static void do_describe_function(EditState *s, const char *cmd_name) { const char *desc; if ((d = qe_find_cmd(s->qs, cmd_name)) == NULL) { - put_status(s, "No command %s", cmd_name); + put_error(s, "No command %s", cmd_name); return; } b = new_help_buffer(s); @@ -1374,7 +1372,7 @@ void do_apropos(EditState *s, const char *str) show_popup(s, b, buf); } else { eb_free(&b); - put_status(s, "No apropos matches for `%s'", str); + put_error(s, "No apropos matches for `%s'", str); } } @@ -1573,7 +1571,7 @@ static void do_set_style_color(EditState *e, const char *stylestr, const char *v stp = find_style(stylestr); if (!stp) { - put_status(e, "Unknown style '%s'", stylestr); + put_error(e, "Unknown style '%s'", stylestr); return; } @@ -1582,7 +1580,7 @@ static void do_set_style_color(EditState *e, const char *stylestr, const char *v if (p > value) { pstrncpy(buf, sizeof buf, value, p - value); if (css_get_color(&stp->fg_color, buf)) { - put_status(e, "Unknown fgcolor '%s'", buf); + put_error(e, "Unknown fgcolor '%s'", buf); return; } } @@ -1595,7 +1593,7 @@ static void do_set_style_color(EditState *e, const char *stylestr, const char *v qe_skip_spaces(&p); if (*p) { if (css_get_color(&stp->bg_color, p)) { - put_status(e, "Unknown bgcolor '%s'", p); + put_error(e, "Unknown bgcolor '%s'", p); return; } } @@ -1611,7 +1609,7 @@ static void do_set_region_color(EditState *s, const char *str) s->region_style = 0; if (qe_term_get_style(str, &style)) { - put_status(s, "Invalid color '%s'", str); + put_error(s, "Invalid color '%s'", str); return; } @@ -1656,7 +1654,7 @@ static void do_set_region_style(EditState *s, const char *str) st = find_style(str); if (!st) { - put_status(s, "Invalid style '%s'", str); + put_error(s, "Invalid style '%s'", str); return; } style = st - qe_styles; @@ -2023,8 +2021,7 @@ static int chunk_cmp(void *vp0, const void *vp1, const void *vp2) { if ((++cp->ncmp & 8191) == 8191) { QEmacsState *qs = cp->b->qs; - put_status(qs->active_window, "Sorting: %d%%", (int)((cp->ncmp * 90LL) / cp->total_cmp)); - dpy_flush(qs->screen); + put_status(qs->active_window, "&Sorting: %d%%", (int)((cp->ncmp * 90LL) / cp->total_cmp)); } if (cp->flags & SF_REVERSE) { p1 = vp2; @@ -2217,8 +2214,7 @@ static int eb_sort_span(EditBuffer *b, int *pp1, int *pp2, int cur_offset, int f // XXX: style issue. Should include newline from source buffer eb_putc(b1, '\n'); if ((i & 8191) == 8191 && !(flags & SF_SILENT)) { - put_status(b->qs->active_window, "Sorting: %d%%", (int)(90 + i * 10LL / lines)); - dpy_flush(b->qs->screen); + put_status(b->qs->active_window, "&Sorting: %d%%", (int)(90 + i * 10LL / lines)); } } eb_delete_range(b, p1, p2); @@ -2235,7 +2231,7 @@ done: static void do_sort_span(EditState *s, int p1, int p2, int argval, int flags) { s->region_style = 0; if (eb_sort_span(s->b, &p1, &p2, s->offset, flags | argval) < 0) { - put_status(s, "Out of memory"); + put_error(s, "Out of memory"); return; } s->b->mark = p1; @@ -2339,7 +2335,7 @@ static void do_find_tag(EditState *s, const char *str) { s->offset = offset; return; } - put_status(s, "Tag not found: %s", str); + put_error(s, "Tag not found: %s", str); } static void do_goto_tag(EditState *s) { @@ -2348,11 +2344,11 @@ static void do_goto_tag(EditState *s) { len = qe_get_word(s, buf, sizeof buf, s->offset, NULL); if (len >= sizeof(buf)) { - put_status(s, "Tag too large"); + put_error(s, "Tag too large"); return; } else if (len == 0) { - put_status(s, "No tag"); + put_error(s, "No tag"); return; } else { do_find_tag(s, buf); @@ -2443,7 +2439,7 @@ static void charname_complete(CompleteState *cp, CompleteFunc enumerate) { } fclose(fp); } else { - put_status(cp->s, "cannot find DerivedName.txt or UnicodeData.txt in QEPATH"); + put_error(cp->s, "Cannot find DerivedName.txt or UnicodeData.txt in QEPATH"); } } diff --git a/input.c b/input.c index 0f17233..13fb862 100644 --- a/input.c +++ b/input.c @@ -111,7 +111,7 @@ void do_set_input_method(EditState *s, const char *name) s->input_method = m; s->selected_input_method = m; } else { - put_status(s, "'%s' not found", name); + put_error(s, "'%s' not found", name); } } diff --git a/lang/clang.c b/lang/clang.c index 9c9e73d..4311d18 100644 --- a/lang/clang.c +++ b/lang/clang.c @@ -1304,7 +1304,7 @@ static void do_c_list_conditionals(EditState *s) show_popup(s, b, "Preprocessor conditionals"); } else { eb_free(&b); - put_status(s, "Not in a #if conditional"); + put_error(s, "Not in a #if conditional"); } cp_destroy(cp); } diff --git a/modes/dired.c b/modes/dired.c index d2eccb3..3e40f41 100644 --- a/modes/dired.c +++ b/modes/dired.c @@ -1438,7 +1438,7 @@ static EditState *dired_view_file(EditState *s, const char *filename) static void dired_execute(EditState *s) { /* Actually delete, copy, or move the marked items */ - put_status(s, "Not yet implemented"); + put_error(s, "Not yet implemented"); } static void dired_parent(EditState *s, int collapse) @@ -1527,7 +1527,7 @@ static void dired_toggle_dot_files(EditState *s, int val) dired_show_dot_files = val; if (ds) dired_update_buffer(ds, s->b, s, DIRED_UPDATE_FILTER); - put_status(s, "dot files are %s", val ? "visible" : "hidden"); + put_status(s, "Dot files are %s", val ? "visible" : "hidden"); } } @@ -2017,7 +2017,7 @@ static void filelist_display_hook(EditState *s) } put_status(e, "Previewing %s", filename); } else { - put_status(s, "No access to %s", filename); + put_error(s, "No access to %s", filename); } } } diff --git a/modes/fractal.c b/modes/fractal.c index 2e94029..293b704 100644 --- a/modes/fractal.c +++ b/modes/fractal.c @@ -659,7 +659,7 @@ static void fractal_set_parameters(EditState *s, FractalState *ms, const char *p } else if (strstart(p, "colors=", &p)) { if (!fractal_set_colors(ms, p, &p)) { - put_status(s, "invalid colors: %s", p); + put_error(s, "Invalid colors: %s", p); p += strcspn(p, ", "); } } else @@ -687,7 +687,7 @@ static void fractal_set_parameters(EditState *s, FractalState *ms, const char *p if (strstart(p, "y=", &p)) { ms->y = strtold_c(p, &p); } else { - put_status(s, "invalid parameter: %s", p); + put_error(s, "Invalid parameter: %s", p); break; } } diff --git a/modes/image.c b/modes/image.c index 69ec0c0..853071f 100644 --- a/modes/image.c +++ b/modes/image.c @@ -231,7 +231,7 @@ static void image_set_size(EditState *s, int w, int h) ib = is->ibs->ib; if (w < 1 || h < 1) { - put_status(s, "Invalid image size"); + put_error(s, "Invalid image size"); return; } @@ -737,8 +737,8 @@ static void image_rotate(EditState *e) if (ret < 0) { /* remove temporary image */ image_free(ib1); - put_status(e, "Format '%s' not supported yet in rotate", - avcodec_get_pix_fmt_name(pix_fmt)); + put_error(e, "Format '%s' not supported yet in rotate", + avcodec_get_pix_fmt_name(pix_fmt)); return; } ib1->alpha_info = ib->alpha_info; @@ -779,7 +779,7 @@ static void image_convert(EditState *e, const char *pix_fmt_str) if (strequal(name, pix_fmt_str)) goto found; } - put_status(e, "Unknown pixel format"); + put_error(e, "Unknown pixel format"); return; found: new_pix_fmt = i; @@ -791,9 +791,9 @@ static void image_convert(EditState *e, const char *pix_fmt_str) if (ret < 0) { /* remove temporary image */ image_free(ib1); - put_status(e, "Conversion from '%s' to '%s' not supported yet", - avcodec_get_pix_fmt_name(ib->pix_fmt), - avcodec_get_pix_fmt_name(new_pix_fmt)); + put_error(e, "Conversion from '%s' to '%s' not supported yet", + avcodec_get_pix_fmt_name(ib->pix_fmt), + avcodec_get_pix_fmt_name(new_pix_fmt)); return; } else { char buf[128]; diff --git a/modes/latex-mode.c b/modes/latex-mode.c index aeca537..af56720 100644 --- a/modes/latex-mode.c +++ b/modes/latex-mode.c @@ -245,7 +245,7 @@ static void latex_cmd_run(void *opaque, char *cmd, QEmacsState *qs = s->qs; if (cmd == NULL) { - put_status(s, "Aborted"); + put_error(s, "Aborted"); return; } @@ -313,7 +313,7 @@ static void do_latex(EditState *e, const char *cmd) latex_cmd_run(func, buf, NULL); } } else { - put_status(e, "%s: No match", buf); + put_error(e, "%s: No match", buf); } } diff --git a/modes/markdown.c b/modes/markdown.c index c51d1af..6927427 100644 --- a/modes/markdown.c +++ b/modes/markdown.c @@ -494,7 +494,7 @@ static int mkd_find_heading(EditState *s, int offset, int *level, int silent) offset = eb_prev_line(s->b, offset); } if (!silent) - put_status(s, "Before first heading"); + put_error(s, "Before first heading"); return -1; } @@ -568,7 +568,7 @@ static void do_outline_up_heading(EditState *s) return; if (level <= 1) { - put_status(s, "Already at top level of the outline"); + put_error(s, "Already at top level of the outline"); return; } @@ -585,7 +585,7 @@ static void do_mkd_backward_same_level(EditState *s) offset = mkd_prev_heading(s, offset, level, &level1); if (level1 != level) { - put_status(s, "No previous same-level heading"); + put_error(s, "No previous same-level heading"); return; } s->offset = offset; @@ -601,7 +601,7 @@ static void do_mkd_forward_same_level(EditState *s) offset = mkd_next_heading(s, offset, level, &level1); if (level1 != level) { - put_status(s, "No following same-level heading"); + put_error(s, "No following same-level heading"); return; } s->offset = offset; @@ -625,7 +625,7 @@ static void do_mkd_goto(EditState *s, const char *dest) for (; nb > 0; nb--) { offset = mkd_next_heading(s, offset, level, &level1); if (level != level1) { - put_status(s, "Heading not found"); + put_error(s, "Heading not found"); return; } } @@ -712,7 +712,7 @@ static void do_mkd_promote(EditState *s, int dir) if (level > 1) eb_delete_char32(s->b, offset); else - put_status(s, "Cannot promote to level 0"); + put_error(s, "Cannot promote to level 0"); } } @@ -735,7 +735,7 @@ static void do_mkd_promote_subtree(EditState *s, int dir) if (level > 1) { eb_delete_char32(s->b, offset); } else { - put_status(s, "Cannot promote to level 0"); + put_error(s, "Cannot promote to level 0"); return; } } @@ -754,7 +754,7 @@ static void do_mkd_move_subtree(EditState *s, int dir) return; if (!mkd_is_header_line(s, s->offset)) { - put_status(s, "Not on header line"); + put_error(s, "Not on header line"); return; } @@ -768,12 +768,12 @@ static void do_mkd_move_subtree(EditState *s, int dir) if (dir < 0) { offset2 = mkd_prev_heading(s, offset, level, &level2); if (level2 < level) { - put_status(s, "Cannot move substree"); + put_error(s, "Cannot move substree"); return; } } else { if (offset1 == s->b->total_size || level1 < level) { - put_status(s, "Cannot move substree"); + put_error(s, "Cannot move substree"); return; } offset2 = mkd_next_heading(s, offset1, level, &level2); diff --git a/modes/orgmode.c b/modes/orgmode.c index edcff01..c39cedf 100644 --- a/modes/orgmode.c +++ b/modes/orgmode.c @@ -320,7 +320,7 @@ static int org_find_heading(EditState *s, int offset, int *level, int silent) offset = eb_prev_line(s->b, offset); } if (!silent) - put_status(s, "Before first heading"); + put_error(s, "Before first heading"); return -1; } @@ -394,7 +394,7 @@ static void do_outline_up_heading(EditState *s) return; if (level <= 1) { - put_status(s, "Already at top level of the outline"); + put_error(s, "Already at top level of the outline"); return; } @@ -411,7 +411,7 @@ static void do_org_backward_same_level(EditState *s) offset = org_prev_heading(s, offset, level, &level1); if (level1 != level) { - put_status(s, "No previous same-level heading"); + put_error(s, "No previous same-level heading"); return; } s->offset = offset; @@ -427,7 +427,7 @@ static void do_org_forward_same_level(EditState *s) offset = org_next_heading(s, offset, level, &level1); if (level1 != level) { - put_status(s, "No following same-level heading"); + put_error(s, "No following same-level heading"); return; } s->offset = offset; @@ -451,7 +451,7 @@ static void do_org_goto(EditState *s, const char *dest) for (; nb > 0; nb--) { offset = org_next_heading(s, offset, level, &level1); if (level != level1) { - put_status(s, "Heading not found"); + put_error(s, "Heading not found"); return; } } @@ -572,7 +572,7 @@ static void do_org_promote(EditState *s, int dir) if (level > 1) eb_delete_char32(s->b, offset); else - put_status(s, "Cannot promote to level 0"); + put_error(s, "Cannot promote to level 0"); } } @@ -595,7 +595,7 @@ static void do_org_promote_subtree(EditState *s, int dir) if (level > 1) { eb_delete_char32(s->b, offset); } else { - put_status(s, "Cannot promote to level 0"); + put_error(s, "Cannot promote to level 0"); return; } } @@ -614,7 +614,7 @@ static void do_org_move_subtree(EditState *s, int dir) return; if (!org_is_header_line(s, s->offset)) { - put_status(s, "Not on header line"); + put_error(s, "Not on header line"); return; } @@ -628,12 +628,12 @@ static void do_org_move_subtree(EditState *s, int dir) if (dir < 0) { offset2 = org_prev_heading(s, offset, level, &level2); if (level2 < level) { - put_status(s, "Cannot move substree"); + put_error(s, "Cannot move substree"); return; } } else { if (offset1 == s->b->total_size || level1 < level) { - put_status(s, "Cannot move substree"); + put_error(s, "Cannot move substree"); return; } offset2 = org_next_heading(s, offset1, level, &level2); diff --git a/modes/shell.c b/modes/shell.c index 6b69d29..a5ce472 100644 --- a/modes/shell.c +++ b/modes/shell.c @@ -204,8 +204,8 @@ static int run_process(ShellState *s, pty_fd = get_pty(tty_name, sizeof(tty_name)); if (pty_fd < 0) { - put_status(s->b->qs->active_window, "run_process: cannot get tty: %s", - strerror(errno)); + put_error(s->b->qs->active_window, "run_process: cannot get tty: %s", + strerror(errno)); return -1; } fcntl(pty_fd, F_SETFL, O_NONBLOCK); @@ -219,7 +219,7 @@ static int run_process(ShellState *s, pid = fork(); if (pid < 0) { - put_status(s->b->qs->active_window, "run_process: cannot fork"); + put_error(s->b->qs->active_window, "run_process: cannot fork"); return -1; } if (pid == 0) { @@ -2439,7 +2439,6 @@ static void shell_read_cb(void *opaque) /* now we do some refresh (should just invalidate?) */ qe_display(qs); - dpy_flush(qs->screen); } static void shell_mode_free(EditBuffer *b, void *state) @@ -2558,7 +2557,6 @@ static void shell_pid_cb(void *opaque, int status) qe_free_mode_data(&s->base); } qe_display(qs); - dpy_flush(qs->screen); } EditBuffer *qe_new_shell_buffer(QEmacsState *qs, EditBuffer *b0, EditState *e, @@ -3158,7 +3156,7 @@ static void do_shell_yank(EditState *e) if (b) { if (b->total_size > 1024) { - put_status(e, "too much data to yank at shell prompt"); + put_error(e, "Too much data to yank at shell prompt"); return; } for (offset = 0; offset < b->total_size;) { @@ -3241,7 +3239,7 @@ static void do_shell_refresh(EditState *e, int flags) if (flags & SR_REFRESH) do_refresh_complete(e); if (s && !(flags & SR_SILENT)) { - put_status(e, "terminal size set to %d by %d", s->cols, s->rows); + put_status(e, "Terminal size set to %d by %d", s->cols, s->rows); } } @@ -3415,7 +3413,7 @@ static void do_next_error(EditState *s, int arg, int dir) if ((b = qe_find_buffer_name(qs, "*compilation*")) == NULL && (b = qe_find_buffer_name(qs, "*shell*")) == NULL && (b = qe_find_buffer_name(qs, "*errors*")) == NULL) { - put_status(s, "No compilation buffer"); + put_error(s, "No compilation buffer"); return; } set_error_offset(b, -1); @@ -3429,12 +3427,12 @@ static void do_next_error(EditState *s, int arg, int dir) if (dir > 0) { offset = eb_next_line(b, offset); if (offset >= b->total_size) { - put_status(s, "No more errors"); + put_error(s, "No more errors"); return; } } else { if (offset <= 0) { - put_status(s, "No previous error"); + put_error(s, "No previous error"); return; } offset = eb_prev_line(b, offset); diff --git a/modes/stb.c b/modes/stb.c index 2d4eac3..ee00a64 100644 --- a/modes/stb.c +++ b/modes/stb.c @@ -133,7 +133,7 @@ static void image_display_hook(EditState *s) { ms->pic.data[0] = ms->stb_image; ms->pic.linesize[0] = ms->stb_x * 4; } else { - put_status(s, "stbi_load error"); + put_error(s, "stbi_load error"); } } edit_invalidate(s, 1); diff --git a/modes/video.c b/modes/video.c index 78e16fa..6bdf4ae 100644 --- a/modes/video.c +++ b/modes/video.c @@ -244,7 +244,6 @@ static void video_refresh_timer(void *opaque) /* display picture */ qe_display(qs); - dpy_flush(qs->screen); /* update queue size and signal for next picture */ if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) @@ -268,7 +267,6 @@ static void video_refresh_timer(void *opaque) /* display picture */ qe_display(qs); - dpy_flush(qs->screen); } else { is->video_timer = qe_add_timer(100, s, video_refresh_timer); } @@ -965,8 +963,8 @@ static void av_cycle_stream(EditState *s, int codec_type) start_index = is->audio_stream; if (start_index < 0) { - put_status(s, "No %s stream to cycle", - (codec_type == CODEC_TYPE_VIDEO) ? "video" : "audio"); + put_error(s, "No %s stream to cycle", + (codec_type == CODEC_TYPE_VIDEO) ? "video" : "audio"); return; } @@ -975,8 +973,8 @@ static void av_cycle_stream(EditState *s, int codec_type) if (++stream_index >= ic->nb_streams) stream_index = 0; if (stream_index == start_index) { - put_status(s, "Only one %s stream", - (codec_type == CODEC_TYPE_VIDEO) ? "video" : "audio"); + put_error(s, "Only one %s stream", + (codec_type == CODEC_TYPE_VIDEO) ? "video" : "audio"); return; } st = ic->streams[stream_index]; diff --git a/qe.c b/qe.c index 6d35e39..26a33ca 100644 --- a/qe.c +++ b/qe.c @@ -452,9 +452,9 @@ void do_set_key(EditState *s, const char *keystr, KeyDef **lp = local ? &s->mode->first_key : &qs->first_key; int res = qe_register_bindings(qs, lp, cmd_name, keystr); if (res == -2) - put_status(s, "Invalid keys: %s", keystr); + put_error(s, "Invalid keys: %s", keystr); if (res == -1) - put_status(s, "Invalid command: %s", cmd_name); + put_error(s, "Invalid command: %s", cmd_name); } void do_unset_key(EditState *s, const char *keystr, int local) { @@ -590,9 +590,9 @@ void do_set_emulation(EditState *s, const char *name) { qs->emulation_flags = 2; } else if (strequal(name, "vi") || strequal(name, "vim")) { - put_status(s, "Emulation '%s' not available yet", name); + put_error(s, "Emulation '%s' not available yet", name); } else { - put_status(s, "Unknown emulation '%s'", name); + put_error(s, "Unknown emulation '%s'", name); } } @@ -681,7 +681,7 @@ void do_set_trace_options(EditState *s, const char *options) { } } if (!found) { - put_status(s, "Unsupported flag: %s", p); + put_error(s, "Unsupported flag: %s", p); return; } } @@ -695,10 +695,10 @@ void do_cd(EditState *s, const char *path) canonicalize_absolute_path(s, buf, sizeof(buf), path); if (chdir(buf)) { - put_status(s, "Cannot change directory to '%s'", buf); + put_error(s, "Cannot change directory to '%s'", buf); } else { if (!getcwd(buf, sizeof(buf))) - put_status(s, "Cannot get current directory"); + put_error(s, "Cannot get current directory"); else put_status(s, "Current directory: %s", buf); } @@ -1149,7 +1149,7 @@ void do_backspace(EditState *s, int argval) /* return the cursor position relative to the screen. Note that xc is given in pixel coordinates */ -typedef struct { +typedef struct CursorContext { int linec; int yc; int xc; @@ -1160,9 +1160,9 @@ typedef struct { int cursor_height; } CursorContext; -int cursor_func(DisplayState *ds, - int offset1, int offset2, int line_num, - int x, int y, int w, int h, qe__unused__ int hex_mode) +static int cursor_func(DisplayState *ds, + int offset1, int offset2, int line_num, + int x, int y, int w, int h, qe__unused__ int hex_mode) { CursorContext *m = ds->cursor_opaque; @@ -1204,7 +1204,7 @@ static void get_cursor_pos(EditState *s, CursorContext *m) display_close(ds); } -typedef struct { +typedef struct MoveContext { int yd; int xd; int xdmin; @@ -2037,7 +2037,6 @@ static void quote_key(void *opaque, int key) } s->overwrite = save_overwrite; qe_display(qs); - dpy_flush(&global_screen); } } @@ -2300,7 +2299,7 @@ static void do_unknown_key(EditState *s) { buf_init(out, buf, sizeof buf); for (i = 0; i < qs->input_len; i++) buf_quote_byte(out, qs->input_buf[i]); - put_status(s, "Unknown key: %s", buf); + put_error(s, "Unknown key: %s", buf); } void do_keyboard_quit(EditState *s) @@ -2324,7 +2323,7 @@ void do_keyboard_quit(EditState *s) /* well, currently nothing needs to be aborted in global context */ /* CG: Should remove sidepanes, helppanes... */ put_status(s, "|"); - put_status(s, "\007Quit"); + put_error(s, "Quit"); } /* block functions */ @@ -2557,7 +2556,7 @@ void do_yank_pop(EditState *s) QEmacsState *qs = s->qs; if (qs->last_cmd_func != (CmdFunc)do_yank) { - put_status(s, "Previous command was not a yank"); + put_error(s, "Previous command was not a yank"); return; } @@ -2624,9 +2623,9 @@ static int reload_buffer(EditState *s, EditBuffer *b) if (ret < 0) { fail: if (!f1) { - put_status(s, "Could not load '%s'", b->filename); + put_error(s, "Could not load '%s'", b->filename); } else { - put_status(s, "Error while reloading '%s'", b->filename); + put_error(s, "Error while reloading '%s'", b->filename); } return -1; } else { @@ -2665,7 +2664,7 @@ void *qe_get_buffer_mode_data(EditBuffer *b, ModeDef *m, EditState *e) } } if (e) - put_status(e, "Not a %s buffer", m->name); + put_error(e, "Not a %s buffer", m->name); return NULL; } @@ -2695,7 +2694,7 @@ void *qe_get_window_mode_data(EditState *e, ModeDef *m, int status) return md; } if (status) - put_status(e, "Not a %s buffer", m->name); + put_error(e, "Not a %s buffer", m->name); return NULL; } @@ -2854,7 +2853,7 @@ int edit_set_mode(EditState *s, ModeDef *m) reload_buffer(s, b); } if (errstr) { - put_status(s, "Cannot set mode %s: %s", m->name, errstr); + put_error(s, "Cannot set mode %s: %s", m->name, errstr); m = &text_mode; rc = -1; } @@ -2888,7 +2887,7 @@ void do_set_mode(EditState *s, const char *name) if (m) edit_set_mode(s, m); else - put_status(s, "No mode %s", name); + put_error(s, "No mode %s", name); } QECharset *read_charset(EditState *s, const char *charset_str, @@ -2917,7 +2916,7 @@ QECharset *read_charset(EditState *s, const char *charset_str, charset = qe_find_charset(s->qs, charset_str); if (!charset) { - put_status(s, "Unknown charset '%s'", charset_str); + put_error(s, "Unknown charset '%s'", charset_str); return NULL; } *eol_typep = eol_type; @@ -3197,7 +3196,7 @@ void do_goto(EditState *s, const char *str, int unit) return; } error: - put_status(s, "Invalid position: %s", str); + put_error(s, "Invalid position: %s", str); } void do_goto_line(EditState *s, int line, int column) @@ -3697,13 +3696,13 @@ void do_set_style(EditState *e, const char *stylestr, stp = find_style(stylestr); if (!stp) { - put_status(e, "Unknown style '%s'", stylestr); + put_error(e, "Unknown style '%s'", stylestr); return; } prop_index = find_style_property(propstr); if (prop_index < 0) { - put_status(e, "Unknown property '%s'", propstr); + put_error(e, "Unknown property '%s'", propstr); return; } @@ -3717,7 +3716,7 @@ void do_set_style(EditState *e, const char *stylestr, goto bad_color; break; bad_color: - put_status(e, "Unknown color '%s'", value); + put_error(e, "Unknown color '%s'", value); return; case CSS_PROP_FONT_FAMILY: v = css_get_font_family(value); @@ -3768,7 +3767,7 @@ void do_set_style(EditState *e, const char *stylestr, void do_define_color(EditState *e, const char *name, const char *value) { if (css_define_color(name, value)) - put_status(e, "Invalid color '%s'", value); + put_error(e, "Invalid color '%s'", value); } #endif @@ -3792,7 +3791,7 @@ void do_toggle_full_screen(EditState *s) screen->dpy.dpy_full_screen(screen, qs->is_full_screen); do_refresh(s); } else { - put_status(s, "full screen unsupported on this device"); + put_error(s, "Full screen unsupported on this device"); } } @@ -3807,7 +3806,7 @@ void do_set_window_style(EditState *s, const char *stylestr) int style_index = find_style_index(stylestr); if (style_index < 0) { - put_status(s, "Unknown style '%s'", stylestr); + put_error(s, "Unknown style '%s'", stylestr); return; } s->default_style = style_index; @@ -3821,7 +3820,7 @@ void do_set_system_font(EditState *s, const char *qe_font_name, font_type = css_get_enum(qe_font_name, "fixed,serif,sans"); if (font_type < 0) { - put_status(s, "Invalid qemacs font"); + put_error(s, "Invalid qemacs font"); return; } pstrcpy(qs->system_fonts[font_type], sizeof(qs->system_fonts[0]), @@ -5607,7 +5606,7 @@ void exec_command(EditState *s, const CmdDef *d, int argval, int key) if (*argdesc == '*') { argdesc++; if (s->b->flags & BF_READONLY) { - put_status(s, "Buffer is read only"); + put_error(s, "Buffer is read only"); return; } } @@ -5813,7 +5812,7 @@ static void arg_edit_cb(void *opaque, char *str, CompletionDef *completion) val = strtol_c(str, &p, 0); } if (*p != '\0') { - put_status(es->s, "Invalid number: %s", str); + put_error(es->s, "Invalid number: %s", str); goto fail; } es->args[index].n = val; @@ -5833,7 +5832,7 @@ static void arg_edit_cb(void *opaque, char *str, CompletionDef *completion) int check_read_only(EditState *s) { if (s->b->flags & BF_READONLY) { - put_status(s, "Buffer is read-only"); + put_error(s, "Buffer is read-only"); return 1; } else { return 0; @@ -5849,7 +5848,7 @@ void do_execute_command(EditState *s, const char *cmd, int argval) if (d) { exec_command(s, d, argval, 0); } else { - put_status(s, "No command %s", cmd); + put_error(s, "No command %s", cmd); } } @@ -5947,6 +5946,7 @@ void qe_display(QEmacsState *qs) put_status(s, "|qe_display: %dms", elapsed_time); qs->complete_refresh = 0; + dpy_flush(qs->screen); } /*---------------- Keyboard macros ----------------*/ @@ -6113,7 +6113,7 @@ static void do_read_kbd_macro(EditState *s, int mark, int offset) { static void show_macro_counter(EditState *s) { QEmacsState *qs = s->qs; - put_status(s, "new macro counter: %d", qs->macro_counter); + put_status(s, "New macro counter: %d", qs->macro_counter); } static void do_macro_add_counter(EditState *s, int arg) { @@ -6194,7 +6194,7 @@ static void do_macro_insert_counter(EditState *s, int arg) { if (!fmt || !*fmt) fmt = "%d"; if (check_format_string(fmt, "%d%d%d%d", 1024) < 0) { - put_status(s, "Invalid macro format: %s", fmt); + put_error(s, "Invalid macro format: %s", fmt); return; } s->b->offset = s->offset; @@ -6228,7 +6228,7 @@ void do_end_kbd_macro(EditState *s) return; if (!qs->defining_macro) { - put_status(s, "Not defining kbd macro"); + put_error(s, "Not defining kbd macro"); return; } qs->defining_macro = 0; @@ -6252,7 +6252,7 @@ void do_call_last_kbd_macro(EditState *s, int argval) if (qs->defining_macro) { // XXX: should allow recursive definition qs->defining_macro = 0; - put_status(s, "Cannot execute macro while defining one"); + put_error(s, "Cannot execute macro while defining one"); return; } @@ -6492,7 +6492,7 @@ static void do_activate_multi_cursor(EditState *s) { s->multi_cursor_cur = 0; s->multi_cursor_active = 1; } else { - put_status(s, "No multi-cursor defined"); + put_error(s, "No multi-cursor defined"); } } @@ -6665,8 +6665,7 @@ static void qe_key_process(QEmacsState *qs, int key) if (s == NULL) return; } - put_status(s, " "); /* Erase pending keystrokes and message */ - dpy_flush(&global_screen); + put_status(s, "&"); /* Erase pending keystrokes and message */ /* Special case for escape: we transform it as meta so that unix users are happy ! */ @@ -6714,12 +6713,11 @@ static void qe_key_process(QEmacsState *qs, int key) buf_put_keys(out, c->keys, c->nb_keys); if (qs->trace_buffer) qe_trace_bytes(qs, buf1, -1, EB_TRACE_COMMAND); - put_status(s, "%s%s", buf1, c->describe_key ? "" : "\007"); + put_status(s, "&%s%s", buf1, c->describe_key ? "" : "\007"); c->describe_key = 0; qe_key_init(c); if (qs->trace_buffer) qe_display(qs); - dpy_flush(&global_screen); return; } else if (c->nb_keys == kd->nb_keys) { @@ -6808,7 +6806,6 @@ static void qe_key_process(QEmacsState *qs, int key) qe_key_init(c); // XXX: should delay until after macro execution qe_display(qs); - dpy_flush(&global_screen); /* CG: should move ungot key handling to generic event dispatch */ if (qs->ungot_key != -1) { key = qs->ungot_key; @@ -6828,10 +6825,9 @@ static void qe_key_process(QEmacsState *qs, int key) buf_put_key(out, key); buf_put_byte(out, '-'); } - put_status(s, "~%s", c->buf); + put_status(s, "&~%s", c->buf); if (qs->trace_buffer) qe_display(qs); - dpy_flush(&global_screen); } /* Print a UTF-8 encoded buffer as unicode */ @@ -6939,6 +6935,8 @@ void put_status(EditState *s, const char *fmt, ...) int force = 0; int beep = 0; int error = 0; + int flush = 0; + QEmacsState *qs; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); @@ -6959,14 +6957,23 @@ void put_status(EditState *s, const char *fmt, ...) } else if (*p == '!') { force = 1; + } else + if (*p == '&') { + flush = 1; } else { break; } } - if (s && s->qs->screen->dpy.dpy_probe) { + if (!s) { + if (qe_skip_spaces(&p)) + fprintf(stderr, "qe: %s\n", p); + return; + } + + qs = s->qs; + if (qs->screen->dpy.dpy_probe) { /* Display message on screen if initialized */ - QEmacsState *qs = s->qs; int width = qs->screen->width; int height = qs->status_height; int x = 0, y = qs->screen->height - height; @@ -6993,19 +7000,18 @@ void put_status(EditState *s, const char *fmt, ...) pstrcpy(qs->status_shadow, sizeof(qs->status_shadow), p); } } - if (!silent && qe_skip_spaces(&p)) { - if (error) - qe_format_message(qs, "*errors*", p); - qe_format_message(qs, "*messages*", p); - } - if (beep) { - qe_stop_macro(qs); - dpy_sound_bell(s->screen); - } - } else { - if (qe_skip_spaces(&p)) - fprintf(stderr, "qe: %s\n", p); } + if (!silent && qe_skip_spaces(&p)) { + if (error) + qe_format_message(qs, "*errors*", p); + qe_format_message(qs, "*messages*", p); + } + if (beep) { + qe_stop_macro(qs); + dpy_sound_bell(s->screen); + } + if (flush) + dpy_flush(s->screen); } #if 0 @@ -7958,7 +7964,7 @@ void do_minibuffer_exit(EditState *s, int do_abort) /* Force status update and call the callback */ if (do_abort) { - put_status(target, "\007!Canceled."); + put_error(target, "Canceled."); (*cb)(opaque, NULL, NULL); } else { put_status(target, "!"); @@ -8345,7 +8351,7 @@ void do_find_window(EditState *s, int key) QEmacsState *qs = s->qs; if (!qs->first_transient_key) { - put_status(s, "window navigation, repeat with , , , "); + put_status(s, "Window navigation, repeat with , , , "); qe_register_transient_binding(qs, "find-window-down", "down"); qe_register_transient_binding(qs, "find-window-left", "left"); qe_register_transient_binding(qs, "find-window-right", "right"); @@ -8433,7 +8439,7 @@ void do_buffer_navigation(EditState *s, int argval, int dir) if (buffer_count <= 1) return; if (!qs->first_transient_key) { - put_status(s, "buffer navigatiion, repeat with and "); + put_status(s, "Buffer navigation, repeat with and "); qe_register_transient_binding(qs, "next-buffer", "right, C-right"); qe_register_transient_binding(qs, "previous-buffer", "left, C-left"); } @@ -8475,7 +8481,7 @@ void do_kill_buffer(EditState *s, const char *bufname, int force) b = qe_find_buffer_name(qs, bufname); if (!b) { - put_status(s, "No buffer %s", bufname); + put_error(s, "No buffer %s", bufname); } else { /* if modified and associated to a filename, then ask */ if (!force && b->modified && b->filename[0] != '\0') { @@ -8869,7 +8875,7 @@ int qe_load_file(EditState *s, const char *filename1, int lflags, int bflags) if ((lflags & LF_LOAD_RESOURCE) && !strchr(filename1, '/')) { if (qe_find_resource_file(qs, filename, sizeof(filename), filename1)) { - put_status(s, "Cannot find resource file '%s'", filename1); + put_error(s, "Cannot find resource file '%s'", filename1); return -1; } } else { @@ -9027,8 +9033,7 @@ int qe_load_file(EditState *s, const char *filename1, int lflags, int bflags) fail: eb_free(&b); - put_status(s, "Could not open '%s': %s", - filename, strerror(errno)); + put_error(s, "Could not open '%s': %s", filename, strerror(errno)); return -1; } @@ -9070,13 +9075,12 @@ static void load_completion_cb(void *opaque, int err) s->b->st_mode = S_IFDIR; } else if (err < 0) { - put_status(s, "Could not read file"); + put_error(s, "Could not read file"); } if (!s->b->probed) { qe_set_next_mode(s, 0, 0); } qe_display(s->qs); - dpy_flush(&global_screen); } #endif @@ -9112,7 +9116,7 @@ void do_insert_file(EditState *s, const char *filename) f = fopen(filename, "r"); if (!f) { - put_status(s, "Could not open file '%s'", filename); + put_error(s, "Could not open file '%s'", filename); return; } /* CG: file charset will not be converted to buffer charset */ @@ -9127,7 +9131,7 @@ void do_insert_file(EditState *s, const char *filename) s->offset += s->b->total_size - lastsize; if (size < 0) { - put_status(s, "Error reading '%s'", filename); + put_error(s, "Error reading '%s'", filename); return; } } @@ -9156,7 +9160,7 @@ void do_set_visited_file_name(EditState *s, const char *filename, // XXX: should search for another buffer with the same file if (renamefile && *renamefile == 'y' && *s->b->filename) { if (rename(s->b->filename, path)) - put_status(s, "Cannot rename file to %s", path); + put_error(s, "Cannot rename file to %s", path); } } eb_set_filename(s->b, path); @@ -9167,7 +9171,7 @@ static void put_save_message(EditState *s, const char *filename, int nb) if (nb >= 0) { put_status(s, "Wrote %d bytes to %s", nb, filename); } else { - put_status(s, "Could not write %s", filename); + put_error(s, "Could not write %s", filename); } } @@ -9220,7 +9224,7 @@ static void quit_confirm_cb(void *opaque, char *reply, CompletionDef *completion static void do_suspend_qemacs(EditState *s, int argval) { - QEditScreen *sp = &global_screen; + QEditScreen *sp = s->screen; if (sp->dpy.dpy_suspend) sp->dpy.dpy_suspend(sp); } @@ -9263,8 +9267,7 @@ static void quit_examine_buffers(QuitState *is) case QS_ASK: /* XXX: display cursor */ put_status(qs->active_window, - "Save file %s? (y, n, !, ., q) ", b->filename); - dpy_flush(&global_screen); + "&Save file %s? (y, n, !, ., q) ", b->filename); /* will wait for a key */ return; case QS_NOSAVE: @@ -9286,7 +9289,6 @@ static void quit_examine_buffers(QuitState *is) NULL, "Modified buffers exist; exit anyway? (yes or no) ", NULL, NULL, quit_confirm_cb, NULL); qe_display(qs); - dpy_flush(&global_screen); } else { #ifdef CONFIG_SESSION if (use_session_file) @@ -9331,8 +9333,8 @@ static void quit_key(void *opaque, int ch) case KEY_CTRL('g'): /* abort */ qe_ungrab_keys(is->qs); - put_status(is->qs->active_window, "\007Quit"); - dpy_flush(&global_screen); + // FIXME: should use put_error() + put_error(is->qs->active_window, "&Quit"); return; default: /* get another key */ @@ -9824,7 +9826,7 @@ void do_create_window(EditState *s, const char *filename, const char *layout) b1 = qe_find_buffer_file(qs, filename); if (!b1) { - put_status(s, "create_window: no such file loaded: %s", filename); + put_error(s, "No such file loaded: %s", filename); return; } @@ -9966,7 +9968,7 @@ void do_describe_key_briefly(EditState *s, const char *keystr, int argval) { nb_keys = strtokeys(p, keys, MAX_KEYS, &p); if (!nb_keys || *p) { - put_status(s, "%s is not a valid key sequence", keystr); + put_error(s, "%s is not a valid key sequence", keystr); return; } kd = qe_find_current_binding(qs, keys, nb_keys, s->mode, 0); @@ -10275,7 +10277,7 @@ static int check_mouse_event(EditState *e, QEEvent *ev) { return 0; if (!e->mode->mouse_goto) { no_handler: - put_status(e, "no mouse handler for mode %s", e->mode->name); + put_error(e, "No mouse handler for mode %s", e->mode->name); return 0; } qe_save_selection(qs, FALSE); @@ -10292,7 +10294,6 @@ static int check_mouse_event(EditState *e, QEEvent *ev) { return 0; } qe_display(qs); - dpy_flush(qs->screen); return 1; } /* test for popup window caption and borders */ @@ -10399,7 +10400,6 @@ static void handle_mouse_motion(EditState *e, QEEvent *ev) { /* if inside the buffer, then update cursor position */ call_mouse_goto(e, mouse_x - e->xleft, mouse_y - e->ytop, ev); qe_display(qs); - dpy_flush(qs->screen); } break; case MOTION_CAPTION: @@ -10442,7 +10442,6 @@ static void handle_mouse_motion(EditState *e, QEEvent *ev) { //do_refresh(qs->first_window); qs->complete_refresh = 1; qe_display(qs); - dpy_flush(qs->screen); } } break; @@ -10453,7 +10452,6 @@ static void handle_mouse_motion(EditState *e, QEEvent *ev) { window_resize(e, e->x2 - e->x1, qs->motion_y - e->y1); do_refresh(qs->first_window); qe_display(qs); - dpy_flush(qs->screen); } break; case MOTION_RSEPARATOR: @@ -10463,7 +10461,6 @@ static void handle_mouse_motion(EditState *e, QEEvent *ev) { window_resize(e, qs->motion_x - e->x1, e->y2 - e->y1); do_refresh(qs->first_window); qe_display(qs); - dpy_flush(qs->screen); } break; } @@ -10536,7 +10533,6 @@ void qe_handle_event(QEmacsState *qs, QEEvent *ev) case QE_UPDATE_EVENT: redraw: qe_display(qs); - dpy_flush(qs->screen); break; #ifndef CONFIG_TINY case QE_BUTTON_PRESS_EVENT: @@ -10863,7 +10859,7 @@ static int qe_parse_command_line(QEmacsState *qs, int argc, char **argv) if (bstr_equal(opt1, shortname) || bstr_equal(opt2, name)) { if (p->need_arg && optarg_ == NULL) { if (optind_ >= argc) { - qe_put_error(qs, "cmdline argument %.*s expected for --%.*s", + qe_put_error(qs, "Argument %.*s expected for --%.*s", argname.len, argname.s, name.len, name.s); goto next_cmd; } @@ -10894,7 +10890,7 @@ static int qe_parse_command_line(QEmacsState *qs, int argc, char **argv) p++; } } - qe_put_error(qs, "unknown cmdline option '%s'", arg); + qe_put_error(qs, "Unknown command line option '%s'", arg); next_cmd: ; } @@ -11731,6 +11727,7 @@ static void qe_init(void *opaque) qs->input_buf = qs->input_buf_def; qs->input_size = countof(qs->input_buf_def); qs->double_click_threshold = DEFAULT_DOUBLE_CLICK_THRESHOLD; + qs->screen = &global_screen; // FIXME: Achtung Minen! qs->active_window is NULL until // the first window is created for the "*scratch*" buffer @@ -11782,9 +11779,6 @@ static void qe_init(void *opaque) qe_load_all_modules(qs); #endif - /* init of the editor state */ - qs->screen = &global_screen; - /* create first buffer */ b = qe_new_buffer(qs, "*scratch*", BF_SAVELOG | BF_UTF8); if (!b) { @@ -11799,7 +11793,7 @@ static void qe_init(void *opaque) * null display driver to have a consistent state * else many commands such as put_status would crash. */ - qe_screen_init(qs, &global_screen, NULL, screen_width, screen_height); + qe_screen_init(qs, qs->screen, NULL, screen_width, screen_height); /* handle options */ _optind = qe_parse_command_line(qs, argc, argv); @@ -11819,7 +11813,7 @@ static void qe_init(void *opaque) fprintf(stderr, "No suitable display found, exiting\n"); exit(1); } - if (qe_screen_init(qs, &global_screen, dpy, screen_width, screen_height) < 0) { + if (qe_screen_init(qs, qs->screen, dpy, screen_width, screen_height) < 0) { /* Just disable the display and try another */ //fprintf(stderr, "Could not initialize display '%s', exiting\n", // dpy->name); @@ -11902,7 +11896,6 @@ static void qe_init(void *opaque) } #endif qe_display(qs); - dpy_flush(&global_screen); qs->ec.function = NULL; } @@ -11931,7 +11924,8 @@ int main(int argc, char **argv) #endif /* restore TTY so console is clean for error messages */ - dpy_close(&global_screen); + free_font_cache(qs->screen); + dpy_close(qs->screen); #ifndef CONFIG_TINY /* exit all external modules in link order */ @@ -11987,7 +11981,6 @@ int main(int argc, char **argv) } } css_free_colors(); - free_font_cache(&global_screen); // before dpy_close()? qe_free(&qs->buffer_cache); qs->buffer_cache_size = qs->buffer_cache_len = 0; qe_clear_macro(qs); diff --git a/qe.h b/qe.h index b3aa8b7..7c1b14a 100644 --- a/qe.h +++ b/qe.h @@ -1625,9 +1625,6 @@ void do_mark_region(EditState *s, int mark, int offset); void do_changecase_word(EditState *s, int up); void do_changecase_region(EditState *s, int up); void do_delete_word(EditState *s, int dir); -int cursor_func(DisplayState *ds, - int offset1, int offset2, int line_num, - int x, int y, int w, int h, int hex_mode); // should take argval void do_scroll_left_right(EditState *s, int n); void do_scroll_up_down(EditState *s, int dir); diff --git a/qescript.c b/qescript.c index 29af960..fbeca52 100644 --- a/qescript.c +++ b/qescript.c @@ -1413,7 +1413,7 @@ static int do_eval_buffer_region(EditState *s, int start, int stop, int argval) /* extract region as UTF-8 with a size limit */ length = eb_get_region_content_size(s->b, start, stop); if (length > MAX_SCRIPT_LENGTH || !(buf = qe_malloc_array(char, length + 1))) { - put_error(s, "buffer region too large"); + put_error(s, "Buffer region too large"); return -1; } length = eb_get_region_contents(s->b, start, stop, buf, length + 1, 0); @@ -1454,7 +1454,7 @@ int parse_config_file(EditState *s, const char *filename) { ds.allocated_buf = file_load(filename, MAX_SCRIPT_LENGTH + 1, NULL); if (!ds.allocated_buf) { if (errno == ERANGE || errno == ENOMEM) { - put_error(s, "file too large"); + put_error(s, "File too large"); } return -1; } diff --git a/search.c b/search.c index c5af567..6e4e6e3 100644 --- a/search.c +++ b/search.c @@ -201,7 +201,7 @@ static int eb_search(EditBuffer *b, int dir, int flags, regexp_bytes = lre_compile(®exp_len, error_message, sizeof(error_message), source, source_len, re_flags, NULL); if (regexp_bytes == NULL) { - //put_status(b->qs->active_window, "regexp compile error: %s", error_message); + //put_error(b->qs->active_window, "Regexp compile error: %s", error_message); return -1; } capture_num = lre_get_capture_count(regexp_bytes); @@ -209,7 +209,7 @@ static int eb_search(EditBuffer *b, int dir, int flags, if (capture_num == 0 || capture == NULL) { qe_free(®exp_bytes); qe_free(&capture); - //put_status(b->qs->active_window, "cannot allocate capture array for %d entries", capture_num); + //put_error(b->qs->active_window, "Cannot allocate capture array for %d entries", capture_num); return -1; } for (offset1 = offset;;) { @@ -535,13 +535,11 @@ static void isearch_run(ISearchState *is) { /* display text */ do_center_cursor(s, 0); - qe_display(s->qs); put_status(s, "%s", out->buf); /* XXX: why NULL? */ + qe_display(s->qs); elapsed_time = get_clock_ms() - start_time; if (elapsed_time >= 100) - put_status(s, "|isearch_run: %dms", elapsed_time); - - dpy_flush(s->screen); + put_status(s, "&|isearch_run: %dms", elapsed_time); } static int isearch_grab(ISearchState *is, EditBuffer *b, int from, int to) { @@ -771,7 +769,6 @@ static void isearch_end(ISearchState *is) { } is->search_flags &= ~SEARCH_FLAG_ACTIVE; qe_display(qs); - dpy_flush(is->s->screen); } static void isearch_cancel(EditState *s) { @@ -791,7 +788,7 @@ static void isearch_abort(EditState *s) { * when search is successful aborts and moves point to starting point. * and signal quit (to abort macros?) */ - put_status(s, "Quit"); + put_error(s, "Quit"); isearch_cancel(s); } @@ -1066,7 +1063,6 @@ static void query_replace_abort(QueryReplaceState *is) qe_ungrab_keys(s->qs); qe_free(&is); qe_display(s->qs); - dpy_flush(s->screen); } static void query_replace_replace(QueryReplaceState *is) @@ -1122,8 +1118,7 @@ static void query_replace_run(QueryReplaceState *is) s->region_style = QE_STYLE_SEARCH_MATCH; do_center_cursor(s, 0); qe_display(s->qs); - put_status(s, "%s", out->buf); - dpy_flush(s->screen); + put_status(s, "&%s", out->buf); } static void query_replace_key(void *opaque, int key) @@ -1139,7 +1134,6 @@ static void query_replace_key(void *opaque, int key) // of the is->help_window popup. qs->active_window = s; qe_display(qs); - dpy_flush(is->s->screen); return; } @@ -1435,25 +1429,25 @@ void do_search_string(EditState *s, const char *search_str, int mode) put_status(s, "%d matches", count); break; case CMD_DELETE_MATCHING_LINES: - put_status(s, "deleted %d lines", count); + put_status(s, "Deleted %d lines", count); break; case CMD_DELETE_NON_MATCHING_LINES: eb_delete_range(s->b, offset, s->b->total_size); - put_status(s, "kept %d lines", count); + put_status(s, "Kept %d lines", count); break; case CMD_SEARCH_BACKWARD: case CMD_SEARCH_FORWARD: - put_status(s, "Search failed: \"%s\"", search_str); + put_error(s, "Search failed: \"%s\"", search_str); break; case CMD_COPY_MATCHING_LINES: - put_status(s, "copied %d lines", count); + put_status(s, "Copied %d lines", count); break; case CMD_KILL_MATCHING_LINES: - put_status(s, "killed %d lines", count); + put_status(s, "Killed %d lines", count); break; case CMD_LIST_MATCHING_LINES: if (!count) { - put_status(s, "no matches"); + put_status(s, "No matches"); } else { b1->offset = start; eb_printf(b1, "// %d lines in buffer %s:\n", count, s->b->name); diff --git a/tty.c b/tty.c index db08360..ddab8ed 100644 --- a/tty.c +++ b/tty.c @@ -185,6 +185,7 @@ typedef struct TTYState { char32_t comb_cache[COMB_CACHE_SIZE]; char *clipboard; size_t clipboard_size; + int got_focus; } TTYState; static QEditScreen *tty_screen; /* for tty_term_exit and tty_term_resize */ @@ -227,7 +228,7 @@ static void tty_term_set_raw(QEditScreen *s) { /* enable mouse reporting using SGR */ TTY_FPRINTF(s->STDOUT, "\033[?%d;1006h", tty_mouse == 1 ? 1002 : 1003); } - if (tty_clipboard > 0) { + if (tty_mouse > 0 || tty_clipboard > 0) { /* enable focus reporting */ TTY_FPRINTF(s->STDOUT, "\033[?1004h"); } @@ -265,7 +266,7 @@ static void tty_term_set_cooked(QEditScreen *s) { /* disable mouse reporting using SGR */ TTY_FPRINTF(s->STDOUT, "\033[?%d;1006l", tty_mouse == 1 ? 1002 : 1003); } - if (tty_clipboard > 0) { + if (tty_mouse > 0 || tty_clipboard > 0) { /* disable focus reporting */ TTY_FPRINTF(s->STDOUT, "\033[?1004l"); } @@ -571,7 +572,7 @@ static int tty_dpy_init(QEditScreen *s, QEmacsState *qs, s->charset = &charset_utf8; } } - put_status(qs->active_window, "tty charset: %s", s->charset->name); + put_status(qs->active_window, "TTY charset: %s", s->charset->name); atexit(tty_term_exit); @@ -1078,6 +1079,19 @@ static void tty_read_handler(void *opaque) /* Mouse events */ ts->input_state = IS_NORM; ts->has_meta = 0; + if (ts->got_focus) { + /* Ignore mouse events until either: + - down event is received after 100ms threshold + - up event is received (and ignored) + */ + if (ch == 'M' && get_clock_ms() - ts->got_focus > 100) { + ts->got_focus = 0; + } else { + if (ch == 'm') + ts->got_focus = 0; + break; + } + } if (ch == 'M') ev->button_event.type = QE_BUTTON_PRESS_EVENT; else @@ -1125,6 +1139,7 @@ static void tty_read_handler(void *opaque) case 'I': // FocusIn enabled by CSI ? 1004 h ts->input_state = IS_NORM; ts->has_meta = 0; + ts->got_focus = get_clock_ms(); qe_trace_bytes(qs, "tty-focus-in", -1, EB_TRACE_COMMAND); if (tty_clipboard > 0) { /* request clipboard contents into kill buffer if changed */ diff --git a/unix.c b/unix.c index 9ede6d2..70c6441 100644 --- a/unix.c +++ b/unix.c @@ -332,7 +332,6 @@ void url_main_loop(void (*init)(void *opaque), void *opaque) //qs->complete_refresh = 1; do_refresh(qs->first_window); qe_display(qs); - dpy_flush(qs->screen); url_display_request = 0; } } diff --git a/variables.c b/variables.c index 4e9eb10..b4d07a1 100644 --- a/variables.c +++ b/variables.c @@ -399,7 +399,7 @@ void do_show_variable(EditState *s, const char *name) char buf[MAX_FILENAME_SIZE]; if (qe_get_variable(s, name, buf, sizeof(buf), NULL, 1) == VAR_UNKNOWN) - put_status(s, "No variable %s", name); + put_error(s, "No variable %s", name); else put_status(s, "%s -> %s", name, buf); } @@ -408,13 +408,13 @@ void do_set_variable(EditState *s, const char *name, const char *value) { switch (qe_set_variable(s, name, value, 0)) { case VAR_UNKNOWN: - put_status(s, "Variable %s is invalid", name); + put_error(s, "Variable %s is invalid", name); break; case VAR_READONLY: - put_status(s, "Variable %s is read-only", name); + put_error(s, "Variable %s is read-only", name); break; case VAR_INVALID: - put_status(s, "Invalid value for variable %s: %s", name, value); + put_error(s, "Invalid value for variable %s: %s", name, value); break; default: do_show_variable(s, name); @@ -427,7 +427,7 @@ static void do_describe_variable(EditState *s, const char *name) { VarDef *vp; if ((vp = qe_find_variable(s->qs, name)) == NULL) { - put_status(s, "No variable %s", name); + put_error(s, "No variable %s", name); return; } b = new_help_buffer(s);