summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3a92aa1)
raw | patch | inline | side by side (parent: 3a92aa1)
author | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:56:08 +0000 (14:56 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Mon, 6 Oct 2008 12:56:08 +0000 (14:56 +0200) |
Declare all screen position variables as "unsigned", and all buffer
positions as "size_t". We don't need signed values.
positions as "size_t". We don't need signed values.
src/wreadln.c | patch | blob | history | |
src/wreadln.h | patch | blob | history |
diff --git a/src/wreadln.c b/src/wreadln.c
index 5d019d9003d3438b1287141082fa380349dbf167..6c66895f7611c6e43edbeeb418a0b5c753e2abd7 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
WINDOW *const w;
/** the origin coordinates in the window */
- gint x, y;
+ unsigned x, y;
/** the screen width of the input field */
- gint width;
+ unsigned width;
/** is the input masked, i.e. characters displayed as '*'? */
const gboolean masked;
/** the byte position of the cursor */
- gint cursor;
+ size_t cursor;
/** the byte position displayed at the origin (for horizontal
scrolling) */
- gint start;
+ size_t start;
/** the current value */
gchar line[1024];
/* move the cursor one step to the right */
static inline void cursor_move_right(struct wreadln *wr)
{
- if (wr->cursor < (int)strlen(wr->line)) {
+ if (wr->cursor < strlen(wr->line)) {
++wr->cursor;
- if (wr->cursor >= wr->width &&
+ if (wr->cursor >= (size_t)wr->width &&
wr->start < wr->cursor - wr->width + 1)
++wr->start;
}
_wreadln(WINDOW *w,
const gchar *prompt,
const gchar *initial_value,
- gint x1,
+ unsigned x1,
GList **history,
GCompletion *gcmp,
gboolean masked)
.start = 0,
};
GList *hlist = NULL, *hcurrent = NULL;
- gint key = 0, i;
+ gint key = 0;
+ size_t i;
/* turn off echo */
noecho();
/* retrive y and x0 position */
getyx(w, wr.y, wr.x);
/* check the x1 value */
- if (x1 <= wr.x || x1 > COLS)
+ if (x1 <= wr.x || x1 > (unsigned)COLS)
x1 = COLS;
wr.width = x1 - wr.x;
/* clear input area */
/* check if key is a function key */
for (i = 0; i < 63; i++)
- if (key == KEY_F(i)) {
+ if (key == (int)KEY_F(i)) {
key = KEY_F(1);
i = 64;
}
break;
case KEY_DC: /* handle delete key. As above */
case KEY_CTRL_D:
- if (wr.cursor <= (gint)utf8_width(wr.line) - 1) {
+ if (wr.cursor <= utf8_width(wr.line) - 1) {
for (i = wr.cursor; wr.line[i] != 0; i++)
wr.line[i] = wr.line[i + 1];
}
wreadln(WINDOW *w,
const gchar *prompt,
const gchar *initial_value,
- gint x1,
+ unsigned x1,
GList **history,
GCompletion *gcmp)
{
wreadln_masked(WINDOW *w,
const gchar *prompt,
const gchar *initial_value,
- gint x1,
+ unsigned x1,
GList **history,
GCompletion *gcmp)
{
diff --git a/src/wreadln.h b/src/wreadln.h
index 692f4fd69fffc60c2054b7bc0b0783e61ac81c8b..e1efe1c501600e7dd0092c3870808b786c27bab5 100644 (file)
--- a/src/wreadln.h
+++ b/src/wreadln.h
const gchar *prompt, /* the prompt string or NULL */
const gchar *initial_value, /* initial value or NULL for a empty line
* (char *) -1 = get value from history */
- gint x1, /* the maximum x position or 0 */
+ unsigned x1, /* the maximum x position or 0 */
GList **history, /* a pointer to a history list or NULL */
GCompletion *gcmp /* a GCompletion structure or NULL */
);
wreadln_masked(WINDOW *w,
const gchar *prompt,
const gchar *initial_value,
- gint x1,
+ unsigned x1,
GList **history,
GCompletion *gcmp);