aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--input.c20
-rw-r--r--tmux.h14
-rw-r--r--window.c13
3 files changed, 36 insertions, 11 deletions
diff --git a/input.c b/input.c
index 58f502fc..6f21e1b2 100644
--- a/input.c
+++ b/input.c
@@ -1,4 +1,4 @@
-/* $Id: input.c,v 1.7 2007-09-28 22:54:21 nicm Exp $ */
+/* $Id: input.c,v 1.8 2007-09-29 09:15:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -146,7 +146,17 @@ input_free(struct input_ctx *ictx)
ARRAY_FREE(&ictx->args);
}
-size_t
+void
+input_parse1(struct screen *s, u_char *buf, size_t len, struct buffer *b)
+{
+ struct input_ctx ictx;
+
+ input_init(&ictx, s);
+ input_parse(&ictx, buf, len, b);
+ input_free(&ictx);
+}
+
+void
input_parse(struct input_ctx *ictx, u_char *buf, size_t len, struct buffer *b)
{
enum input_class iclass;
@@ -157,6 +167,7 @@ input_parse(struct input_ctx *ictx, u_char *buf, size_t len, struct buffer *b)
ictx->off = 0;
ictx->b = b;
+ ictx->flags = 0;
log_debug2("entry; buffer=%zu", ictx->len);
@@ -165,8 +176,6 @@ input_parse(struct input_ctx *ictx, u_char *buf, size_t len, struct buffer *b)
iclass = input_lookup_class(ch);
ictx->state = ictx->state(ch, iclass, ictx);
}
-
- return (ictx->len);
}
void *
@@ -394,6 +403,9 @@ input_handle_c0_control(u_char ch, struct input_ctx *ictx)
case '\r': /* CR */
ictx->s->cx = 0;
break;
+ case '\007': /* BELL */
+ ictx->flags |= INPUT_BELL;
+ break;
case '\010': /* BS */
if (ictx->s->cx > 0)
ictx->s->cx--;
diff --git a/tmux.h b/tmux.h
index a4173985..504bf98c 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.21 2007-09-28 22:47:21 nicm Exp $ */
+/* $Id: tmux.h,v 1.22 2007-09-29 09:15:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -422,6 +422,9 @@ struct input_ctx {
size_t len;
size_t off;
+ int flags;
+#define INPUT_BELL 0x1
+
struct buffer *b;
struct screen *s;
@@ -435,6 +438,9 @@ struct input_ctx {
ARRAY_DECL(, struct input_arg) args;
};
+/* Input context macros. */
+#define INPUT_FLAGS(ictx) ((ictx)->flags)
+
/* Window structure. */
struct window {
char name[MAXNAMELEN];
@@ -447,6 +453,9 @@ struct window {
struct input_ctx ictx;
+ int flags;
+#define WINDOW_BELL 0x1
+
struct screen screen;
};
ARRAY_DECL(windows, struct window *);
@@ -540,7 +549,8 @@ void server_draw_client(struct client *, u_int, u_int);
/* input.c */
void input_init(struct input_ctx *, struct screen *);
void input_free(struct input_ctx *);
-size_t input_parse(struct input_ctx *, u_char *, size_t, struct buffer *);
+void input_parse1(struct screen *, u_char *, size_t, struct buffer *);
+void input_parse(struct input_ctx *, u_char *, size_t, struct buffer *);
uint8_t input_extract8(struct buffer *);
uint16_t input_extract16(struct buffer *);
void input_store8(struct buffer *, uint8_t);
diff --git a/window.c b/window.c
index ec22399b..bb44d28b 100644
--- a/window.c
+++ b/window.c
@@ -1,4 +1,4 @@
-/* $Id: window.c,v 1.12 2007-09-28 22:47:22 nicm Exp $ */
+/* $Id: window.c,v 1.13 2007-09-29 09:15:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -314,9 +314,12 @@ window_input(struct window *w, struct buffer *b, size_t size)
void
window_output(struct window *w, struct buffer *b)
{
- size_t used;
+ if (BUFFER_USED(w->in) == 0)
+ return;
- used = input_parse(&w->ictx, BUFFER_OUT(w->in), BUFFER_USED(w->in), b);
- if (used != 0)
- buffer_remove(w->in, used);
+ input_parse(&w->ictx, BUFFER_OUT(w->in), BUFFER_USED(w->in), b);
+ buffer_remove(w->in, BUFFER_USED(w->in));
+
+ if (INPUT_FLAGS(&w->ictx) & INPUT_BELL)
+ w->flags |= WINDOW_BELL;
}