[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.c qe.h qeconfig.h
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.c qe.h qeconfig.h |
Date: |
Sat, 15 Dec 2007 07:34:44 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 07/12/15 07:34:44
Modified files:
. : qe.c qe.h qeconfig.h
Log message:
added and improved some buffer functions:
renamed eb_get_str to eb_get_contents
fixed buffer size issues in eb_get_line
fixed utf-8 issues in eb_get_strline
added eb_prev_line
added eb_goto_bol2: computes number of code points skipped
added eb_goto_eol
simplified code accordingly
added set_color1 inline function
renamed parse_config to do_load_config_file (invocable from A-x)
changed command name from parse-config-file to load-config-file
fixed bug when invoked with a filename
renamed center_cursor to do_center_cursor (invocable from A-x)
made it invocable as center-cursor
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/qemacs/qeconfig.h?cvsroot=qemacs&r1=1.16&r2=1.17
Patches:
Index: qe.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- qe.c 12 Dec 2007 11:49:03 -0000 1.41
+++ qe.c 15 Dec 2007 07:34:43 -0000 1.42
@@ -423,28 +423,12 @@
void text_move_bol(EditState *s)
{
- int c, offset1;
-
- for (;;) {
- if (s->offset <= 0)
- break;
- c = eb_prevc(s->b, s->offset, &offset1);
- if (c == '\n')
- break;
- s->offset = offset1;
- }
+ s->offset = eb_goto_bol(s->b, s->offset);
}
void text_move_eol(EditState *s)
{
- int c, offset1;
-
- for (;;) {
- c = eb_nextc(s->b, s->offset, &offset1);
- if (c == '\n')
- break;
- s->offset = offset1;
- }
+ s->offset = eb_goto_eol(s->b, s->offset);
}
int isword(int c)
@@ -553,8 +537,7 @@
offset = eb_start_paragraph(s->b, offset);
/* line just before */
- eb_prevc(s->b, offset, &offset);
- offset = eb_goto_bol(s->b, offset);
+ offset = eb_prev_line(s->b, offset);
s->offset = offset;
}
@@ -1020,6 +1003,7 @@
void text_scroll_up_down(EditState *s, int dir)
{
int h, line_height;
+
/* try to round to a line height */
line_height = get_line_height(s->screen, s->default_style);
h = 1;
@@ -1036,7 +1020,7 @@
/* center the cursor in the window */
/* XXX: make it generic to all modes */
-void center_cursor(EditState *s)
+void do_center_cursor(EditState *s)
{
CursorContext cm;
@@ -2938,18 +2922,17 @@
colorize_state = s->colorize_states[s->colorize_nb_valid_lines - 1];
for (l = s->colorize_nb_valid_lines; l <= line_num; l++) {
- len = eb_get_line(s->b, buf, buf_size - 1, &offset);
+ len = eb_get_line(s->b, buf, buf_size, &offset);
// XXX: should force \0 instead of \n
buf[len] = '\n';
s->colorize_func(buf, len, &colorize_state, 1);
-
s->colorize_states[l] = colorize_state;
}
}
/* compute line color */
- len = eb_get_line(s->b, buf, buf_size - 1, &offset1);
+ len = eb_get_line(s->b, buf, buf_size, &offset1);
// XXX: should force \0 instead of \n
buf[len] = '\n';
@@ -3065,7 +3048,7 @@
/* colorize */
if (s->get_colorized_line_func) {
colored_nb_chars = s->get_colorized_line_func(s, colored_chars,
- COLORED_MAX_LINE_SIZE,
+ countof(colored_chars),
offset, line_num);
} else {
colored_nb_chars = 0;
@@ -4414,7 +4397,7 @@
return;
}
- len = eb_get_str(s->b, input, sizeof(input));
+ len = eb_get_contents(s->b, input, sizeof(input));
memset(&cs, 0, sizeof(cs));
completion_function(&cs, input);
count = cs.nb_items;
@@ -4551,7 +4534,7 @@
return;
if (qs->last_cmd_func != do_history) {
/* save currently edited line */
- eb_get_str(s->b, buf, sizeof(buf));
+ eb_get_contents(s->b, buf, sizeof(buf));
set_string(hist, hist->nb_items - 1, buf);
minibuffer_history_saved_offset = s->offset;
}
@@ -4607,7 +4590,7 @@
do_refresh(s);
}
- len = eb_get_str(s->b, buf, sizeof(buf));
+ len = eb_get_contents(s->b, buf, sizeof(buf));
if (hist && hist->nb_items > 0) {
/* if null string, do not insert in history */
hist->nb_items--;
@@ -5528,7 +5511,7 @@
}
/* display text */
- center_cursor(s);
+ do_center_cursor(s);
edit_display(s->qe_state);
put_status(NULL, "%s", out.buf);
@@ -5735,7 +5718,7 @@
/* display text */
s->offset = is->found_offset;
- center_cursor(s);
+ do_center_cursor(s);
edit_display(s->qe_state);
put_status(NULL, "Query replace %s with %s: ",
@@ -5821,7 +5804,7 @@
0, NULL, NULL);
if (found_offset >= 0) {
s->offset = found_offset;
- center_cursor(s);
+ do_center_cursor(s);
}
}
@@ -6876,14 +6859,14 @@
return 0;
}
-void parse_config(EditState *e, const char *file)
+void do_load_config_file(EditState *e, const char *file)
{
QEmacsState *qs = e->qe_state;
FindFileState *ffst;
char filename[MAX_FILENAME_SIZE];
if (file && *file) {
- parse_config_file(e, filename);
+ parse_config_file(e, file);
return;
}
@@ -7440,7 +7423,7 @@
/* load config file unless command line option given */
if (!no_init_file)
- parse_config(s, NULL);
+ do_load_config_file(s, NULL);
qe_key_init();
Index: qe.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qe.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- qe.h 12 Dec 2007 11:49:03 -0000 1.33
+++ qe.h 15 Dec 2007 07:34:44 -0000 1.34
@@ -705,13 +705,16 @@
int size);
void eb_printf(EditBuffer *b, const char *fmt, ...) __attr_printf(2,3);
void eb_line_pad(EditBuffer *b, int n);
-int eb_get_str(EditBuffer *b, char *buf, int buf_size);
+int eb_get_contents(EditBuffer *b, char *buf, int buf_size);
int eb_get_line(EditBuffer *b, unsigned int *buf, int buf_size,
int *offset_ptr);
int eb_get_strline(EditBuffer *b, char *buf, int buf_size,
int *offset_ptr);
+int eb_prev_line(EditBuffer *b, int offset);
int eb_goto_bol(EditBuffer *b, int offset);
+int eb_goto_bol2(EditBuffer *b, int offset, int *countp);
int eb_is_empty_line(EditBuffer *b, int offset);
+int eb_goto_eol(EditBuffer *b, int offset);
int eb_next_line(EditBuffer *b, int offset);
void eb_register_data_type(EditBufferDataType *bdt);
@@ -1174,12 +1177,16 @@
return display_char_bidir(s, offset1, offset2, 0, ch);
}
-static inline void set_color(unsigned int *p, unsigned int *to, int style) {
+static inline void set_color(unsigned int *p, const unsigned int *to, int
style) {
style <<= STYLE_SHIFT;
while (p < to)
*p++ |= style;
}
+static inline void set_color1(unsigned int *p, int style) {
+ *p |= style << STYLE_SHIFT;
+}
+
/* input.c */
#define INPUTMETHOD_NOMATCH (-1)
@@ -1262,7 +1269,7 @@
#endif
/* config file support */
-void parse_config(EditState *e, const char *file);
+void do_load_config_file(EditState *e, const char *file);
void do_load_qerc(EditState *e, const char *file);
/* popup / low level window handling */
@@ -1367,7 +1374,7 @@
int x, int y, int w, int h, int hex_mode);
void do_scroll_up_down(EditState *s, int dir);
void perform_scroll_up_down(EditState *s, int h);
-void center_cursor(EditState *s);
+void do_center_cursor(EditState *s);
void do_quote(EditState *s);
void do_insert(EditState *s);
void do_open_line(EditState *s);
Index: qeconfig.h
===================================================================
RCS file: /cvsroot/qemacs/qemacs/qeconfig.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- qeconfig.h 12 Dec 2007 02:51:05 -0000 1.16
+++ qeconfig.h 15 Dec 2007 07:34:44 -0000 1.17
@@ -128,6 +128,7 @@
CMD0( KEY_CTRLX('n'), KEY_NONE, "next-window", do_other_window)
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_CTRL('x'), KEY_UP, "find-window-up", do_find_window,
KEY_UP)
CMD1( KEY_CTRL('x'), KEY_DOWN, "find-window-down", do_find_window,
@@ -182,7 +183,7 @@
/* other stuff */
CMD_( KEY_NONE, KEY_NONE, "load-file-from-path", do_load_file_from_path,
"s{Load file from path: }|file|")
- CMD_( KEY_NONE, KEY_NONE, "parse-config-file", parse_config,
+ CMD_( KEY_NONE, KEY_NONE, "load-config-file", do_load_config_file,
"s{Configuration file: }[file]|file|")
CMD_( KEY_NONE, KEY_NONE, "load-qerc", do_load_qerc,
"s{path: }[file]|file|")
- [Qemacs-commit] qemacs qe.c qe.h qeconfig.h,
Charlie Gordon <=