summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 109a63c)
raw | patch | inline | side by side (parent: 109a63c)
author | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:38:22 +0000 (14:38 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:38:22 +0000 (14:38 +0200) |
Several internal functions calculate the width of the input field by
subtracting "x0" from "x1", although the width is already being passed
to them. Eliminate the parameter "x1" in all functions, and use
"width" instead.
subtracting "x0" from "x1", although the width is already being passed
to them. Eliminate the parameter "x1" in all functions, and use
"width" instead.
src/wreadln.c | patch | blob | history |
diff --git a/src/wreadln.c b/src/wreadln.c
index f6773a7f9a9374d568f5eb2b610e122deee33817..eb78a57f1d9fb8bb258e56cb42a0dceb679e6124 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
static inline void cursor_move_right(gint *cursor,
gint *start,
gint width,
- gint x0,
- gint x1,
gchar *line)
{
if (*cursor < (int)strlen(line) &&
*cursor < (int)wrln_max_line_size - 1) {
(*cursor)++;
- if (*cursor + x0 >= x1 && *start < *cursor - width + 1)
+ if (*cursor >= width && *start < *cursor - width + 1)
(*start)++;
}
}
static inline void cursor_move_to_eol(gint *cursor,
gint *start,
gint width,
- gint x0,
- gint x1,
gchar *line)
{
*cursor = strlen(line);
- if (*cursor + x0 >= x1)
+ if (*cursor >= width)
*start = *cursor - width + 1;
}
hlist = hlist->prev;
g_strlcpy(line, hlist->data, wrln_max_line_size);
}
- cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
+ cursor_move_to_eol(&cursor, &start, width, line);
drawline(cursor, start, width, x0, y, masked, line, w);
} else if (initial_value) {
/* copy the initial value to the line buffer */
g_strlcpy(line, initial_value, wrln_max_line_size);
- cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
+ cursor_move_to_eol(&cursor, &start, width, line);
drawline(cursor, start, width, x0, y, masked, line, w);
}
list = g_completion_complete(gcmp, line, &prefix);
if (prefix) {
g_strlcpy(line, prefix, wrln_max_line_size);
- cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
+ cursor_move_to_eol(&cursor, &start, width, line);
g_free(prefix);
} else
screen_bell();
break;
case KEY_RIGHT:
case KEY_CTRL_F:
- cursor_move_right(&cursor, &start, width, x0, x1, line);
+ cursor_move_right(&cursor, &start, width, line);
break;
case KEY_HOME:
case KEY_CTRL_A:
break;
case KEY_END:
case KEY_CTRL_E:
- cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
+ cursor_move_to_eol(&cursor, &start, width, line);
break;
case KEY_CTRL_K:
line[cursor] = 0;
hlist = hlist->prev;
g_strlcpy(line, hlist->data, wrln_max_line_size);
}
- cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
+ cursor_move_to_eol(&cursor, &start, width, line);
break;
case KEY_DOWN:
case KEY_CTRL_N:
hlist = hlist->next;
g_strlcpy(line, hlist->data, wrln_max_line_size);
}
- cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
+ cursor_move_to_eol(&cursor, &start, width, line);
break;
case '\n':
line[cursor + 1] = 0;
g_strlcat (&line[cursor + 1], tmp, size);
g_free(tmp);
- cursor_move_right(&cursor, &start, width, x0, x1, line);
+ cursor_move_right(&cursor, &start, width, line);
} else {
line[cursor + 1] = 0;
line[cursor] = key;
- cursor_move_right(&cursor, &start, width, x0, x1, line);
+ cursor_move_right(&cursor, &start, width, line);
}
}
}