Colorize apropos window
- split eb_command_print_entry from command_print_entry - split eb_variable_print_entry from variable_print_entry - fix eb_sort_span to handle static styles - match description strings in apropos - use eb_xxx_print_entry in apropos to share code and colorization - bumped version to 5.3.2d
This commit is contained in:
parent
3ed7b6aa90
commit
4e5e42d2ea
9 changed files with 53 additions and 39 deletions
4
TODO.md
4
TODO.md
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
## Recent bugs and ideas
|
||||
|
||||
* preserve static styles in do_convert_buffer_file_coding_system()
|
||||
* optimize style transfer in eb_insert_buffer_convert()
|
||||
* style: add color themes
|
||||
* style: add style recent changes (`highlight-recent-changes`)
|
||||
* basic: use minor mode keymap to exit preview mode with `KEY_RET`
|
||||
|
|
@ -69,8 +71,6 @@
|
|||
* undo: undo some cursor movements
|
||||
* undo: group undo entries to match command and or macro boundaries
|
||||
* xml: merge xml and htmlsrc modes, add submodes for plist and other config files
|
||||
* help: match descriptions for apropos
|
||||
* help: colorize apropos window contents
|
||||
* basic: add method pointers in windows initialized from fallback chain
|
||||
* basic: check binding lookup along fallback chain
|
||||
* basic: make ModeDef structures read-only
|
||||
|
|
|
|||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
|||
5.3.2c
|
||||
5.3.2d
|
||||
|
|
|
|||
1
buffer.c
1
buffer.c
|
|
@ -2384,6 +2384,7 @@ int eb_insert_buffer_convert(EditBuffer *dest, int dest_offset,
|
|||
|
||||
/* well, not very fast, but simple */
|
||||
/* XXX: should optimize save_log system for insert sequences */
|
||||
// XXX: should optimize styles transfer
|
||||
offset_max = min(src->total_size, src_offset + size);
|
||||
size = 0;
|
||||
for (offset = src_offset; offset < offset_max;) {
|
||||
|
|
|
|||
33
extras.c
33
extras.c
|
|
@ -1002,19 +1002,15 @@ void do_apropos(EditState *s, const char *str)
|
|||
found = 0;
|
||||
for (i = 0; i < qs->cmd_array_count; i++) {
|
||||
for (j = qs->cmd_array[i].count, d = qs->cmd_array[i].array; j-- > 0; d++) {
|
||||
if (strstr(d->name, str)) {
|
||||
const char *desc;
|
||||
/* print name and prototype */
|
||||
qe_get_prototype(d, buf, sizeof(buf));
|
||||
eb_printf(b, "command: %s%s", d->name, buf);
|
||||
if (qe_list_bindings(d, s->mode, 1, buf, sizeof(buf)))
|
||||
eb_printf(b, " bound to %s", buf);
|
||||
const char *desc = d->spec + strlen(d->spec) + 1;
|
||||
if (strstr(d->name, str) || strstr(desc, str)) {
|
||||
/* print name, prototype, bindings */
|
||||
eb_command_print_entry(b, d, s);
|
||||
eb_putc(b, '\n');
|
||||
if (*(desc = d->spec + strlen(d->spec) + 1)) {
|
||||
if (*desc) {
|
||||
/* print short description */
|
||||
eb_printf(b, " %s", desc);
|
||||
eb_printf(b, " %s\n", desc);
|
||||
}
|
||||
eb_putc(b, '\n');
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1026,14 +1022,12 @@ void do_apropos(EditState *s, const char *str)
|
|||
for (vp = qs->first_variable; vp; vp = vp->next) {
|
||||
if (strstr(vp->name, str)) {
|
||||
/* print class, name and current value */
|
||||
qe_get_variable(s, vp->name, buf, sizeof(buf), NULL, 1);
|
||||
eb_printf(b, "%s variable: %s -> %s\n",
|
||||
var_domain[vp->domain], vp->name, buf);
|
||||
eb_variable_print_entry(b, vp, s);
|
||||
eb_putc(b, '\n');
|
||||
if (vp->desc && *vp->desc) {
|
||||
/* print short description */
|
||||
eb_printf(b, " %s", vp->desc);
|
||||
eb_printf(b, " %s\n", vp->desc);
|
||||
}
|
||||
eb_putc(b, '\n');
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1768,13 +1762,14 @@ static int eb_sort_span(EditBuffer *b, int *pp1, int *pp2, int cur_offset, int f
|
|||
}
|
||||
qe_qsort_r(chunk_array, lines, sizeof(*chunk_array), &ctx, chunk_cmp);
|
||||
|
||||
b1 = eb_new("*sorted*", BF_SYSTEM);
|
||||
b1 = eb_new("*sorted*", BF_SYSTEM | (b->flags & BF_STYLES));
|
||||
eb_set_charset(b1, b->charset, b->eol_type);
|
||||
|
||||
for (i = 0; i < lines; i++) {
|
||||
/* XXX: should keep track of point if sorting full buffer */
|
||||
eb_insert_buffer(b1, b1->total_size, b, chunk_array[i].start,
|
||||
chunk_array[i].end - chunk_array[i].start);
|
||||
eb_insert_buffer_convert(b1, b1->total_size, b, chunk_array[i].start,
|
||||
chunk_array[i].end - chunk_array[i].start);
|
||||
// XXX: style issue. Should include newline from source buffer
|
||||
eb_putc(b1, '\n');
|
||||
if ((i & 8191) == 8191) {
|
||||
QEmacsState *qs = &qe_state;
|
||||
|
|
@ -1784,7 +1779,7 @@ static int eb_sort_span(EditBuffer *b, int *pp1, int *pp2, int cur_offset, int f
|
|||
}
|
||||
eb_delete_range(b, p1, p2);
|
||||
*pp1 = p1;
|
||||
*pp2 = p1 + eb_insert_buffer(b, p1, b1, 0, b1->total_size);
|
||||
*pp2 = p1 + eb_insert_buffer_convert(b, p1, b1, 0, b1->total_size);
|
||||
eb_free(&b1);
|
||||
qe_free(&chunk_array);
|
||||
put_status(NULL, "%d lines sorted", lines);
|
||||
|
|
|
|||
28
qe.c
28
qe.c
|
|
@ -195,7 +195,7 @@ void qe_register_mode(ModeDef *m, int flags)
|
|||
|
||||
/* Achtung: embedded null bytes */
|
||||
spec_len = snprintf(spec, sizeof(spec),
|
||||
"S{%s}%cselect the %s mode for the current buffer",
|
||||
"S{%s}%cselect the %s mode",
|
||||
mode_name, 0, mode_name);
|
||||
def = qe_mallocz(CmdDef);
|
||||
/* allocate space for name and spec with embedded null bytes */
|
||||
|
|
@ -255,14 +255,11 @@ void command_complete(CompleteState *cp)
|
|||
}
|
||||
}
|
||||
|
||||
int command_print_entry(CompleteState *cp, EditState *s, const char *name)
|
||||
{
|
||||
EditBuffer *b = s->b;
|
||||
const CmdDef *d = qe_find_cmd(name);
|
||||
if (d) {
|
||||
char buf[256];
|
||||
int len;
|
||||
int eb_command_print_entry(EditBuffer *b, const CmdDef *d, EditState *s) {
|
||||
char buf[256];
|
||||
int len = 0;
|
||||
|
||||
if (d) {
|
||||
b->cur_style = QE_STYLE_FUNCTION;
|
||||
len = eb_puts(b, d->name);
|
||||
b->cur_style = QE_STYLE_DEFAULT;
|
||||
|
|
@ -281,9 +278,17 @@ int command_print_entry(CompleteState *cp, EditState *s, const char *name)
|
|||
b->cur_style = QE_STYLE_DEFAULT;
|
||||
}
|
||||
#endif
|
||||
return len;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int command_print_entry(CompleteState *cp, EditState *s, const char *name) {
|
||||
const CmdDef *d = qe_find_cmd(name);
|
||||
if (d) {
|
||||
// XXX: should pass the target window
|
||||
return eb_command_print_entry(s->b, d, s);
|
||||
} else {
|
||||
return eb_puts(b, name);
|
||||
return eb_puts(s->b, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2334,6 +2339,7 @@ void do_convert_buffer_file_coding_system(EditState *s,
|
|||
}
|
||||
}
|
||||
|
||||
// XXX: should use eb_insert_buffer_convert()
|
||||
/* slow, but simple iterative method */
|
||||
for (offset = 0; offset < b->total_size;) {
|
||||
QETermStyle style = eb_get_style(b, offset);
|
||||
|
|
@ -2348,6 +2354,8 @@ void do_convert_buffer_file_coding_system(EditState *s,
|
|||
eb_free(&b->b_styles);
|
||||
eb_delete(b, 0, b->total_size);
|
||||
eb_set_charset(b, charset, eol_type);
|
||||
// XXX: this does not transfer styles
|
||||
// should use eb_insert_buffer_convert()
|
||||
eb_insert_buffer(b, 0, b1, 0, b1->total_size);
|
||||
b->b_styles = b1->b_styles;
|
||||
b1->b_styles = NULL;
|
||||
|
|
|
|||
1
qe.h
1
qe.h
|
|
@ -2044,6 +2044,7 @@ void minibuffer_edit(EditState *e, const char *input, const char *prompt,
|
|||
StringArray *hist, const char *completion_name,
|
||||
void (*cb)(void *opaque, char *buf), void *opaque);
|
||||
void command_complete(CompleteState *cp);
|
||||
int eb_command_print_entry(EditBuffer *b, const CmdDef *d, EditState *s);
|
||||
int command_print_entry(CompleteState *cp, EditState *s, const char *name);
|
||||
int command_get_entry(EditState *s, char *dest, int size, int offset);
|
||||
void file_complete(CompleteState *cp);
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ static const CmdDef basic_commands[] = {
|
|||
"")
|
||||
CMD1( "set-auto-mode", "",
|
||||
do_set_next_mode, 0,
|
||||
"Select the best mode for the current buffer")
|
||||
"Select the best mode")
|
||||
CMD3( "set-next-mode", "M-m",
|
||||
do_set_next_mode, ESi, +1, "P",
|
||||
"Select the next mode appropriate for the current buffer")
|
||||
|
|
|
|||
20
variables.c
20
variables.c
|
|
@ -455,18 +455,16 @@ void qe_save_variables(EditState *s, EditBuffer *b)
|
|||
eb_putc(b, '\n');
|
||||
}
|
||||
|
||||
int variable_print_entry(CompleteState *cp, EditState *s, const char *name)
|
||||
{
|
||||
int eb_variable_print_entry(EditBuffer *b, VarDef *vp, EditState *s) {
|
||||
char buf[256];
|
||||
char typebuf[32];
|
||||
const char *type = typebuf;
|
||||
int len;
|
||||
VarDef *vp = qe_find_variable(name);
|
||||
EditBuffer *b = s->b;
|
||||
|
||||
len = eb_puts(b, name);
|
||||
if (!vp)
|
||||
return len;
|
||||
return 0;
|
||||
|
||||
len = eb_puts(b, vp->name);
|
||||
|
||||
switch (vp->type) {
|
||||
case VAR_NUMBER:
|
||||
|
|
@ -503,6 +501,16 @@ int variable_print_entry(CompleteState *cp, EditState *s, const char *name)
|
|||
return len;
|
||||
}
|
||||
|
||||
int variable_print_entry(CompleteState *cp, EditState *s, const char *name) {
|
||||
VarDef *vp = qe_find_variable(name);
|
||||
if (vp) {
|
||||
// XXX: should pass the target window
|
||||
return eb_variable_print_entry(s->b, vp, s);
|
||||
} else {
|
||||
return eb_puts(s->b, name);
|
||||
}
|
||||
}
|
||||
|
||||
static CompletionDef variable_completion = {
|
||||
"variable", variable_complete, variable_print_entry, command_get_entry
|
||||
};
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ struct VarDef {
|
|||
void qe_register_variables(VarDef *vars, int count);
|
||||
VarDef *qe_find_variable(const char *name);
|
||||
void variable_complete(CompleteState *cp);
|
||||
int eb_variable_print_entry(EditBuffer *b, VarDef *vp, EditState *s);
|
||||
int variable_print_entry(CompleteState *cp, EditState *s, const char *name);
|
||||
|
||||
QVarType qe_get_variable(EditState *s, const char *name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue