[hackers] [st] eliminated all other errors, fixed visibilities of functions in vt.c

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Mon Mar 05 15:29:24 2007

changeset: 63:b4382ab109d5
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Mon Mar 05 15:28:41 2007 +0100
summary: eliminated all other errors, fixed visibilities of functions in vt.c

diff -r 8baac73b9c9c -r b4382ab109d5 main.c
--- a/main.c Mon Mar 05 15:03:34 2007 +0100
+++ b/main.c Mon Mar 05 15:28:41 2007 +0100
@@ -4,6 +4,7 @@
 #include "st.h"
 #include <locale.h>
 #include <stdio.h>
+#include <string.h>
 #include <X11/Xutil.h>
 #include <X11/cursorfont.h>
 
@@ -111,7 +112,6 @@ initwin(void) {
         XSizeHints sh;
         XWMHints wmh;
         XClassHint ch;
- XGCValues gcv;
 
         win = XCreateSimpleWindow(dpy, root, 0, 0, ww, wh, 0, dc.bg[0], dc.bg[0]);
         XSelectInput(dpy, win, StructureNotifyMask);
@@ -137,8 +137,6 @@ initwin(void) {
         XSetWMProperties(dpy, win, NULL, NULL, &args[0], 0, &sh, &wmh, &ch);
         XStoreName(dpy, win, "st");
         XSync(dpy, 0);
- set_text_attrs(-1, 0);
- return 0;
 }
 
 /* extern */
@@ -202,7 +200,7 @@ main(int argc, char **argv) {
                         }
                         break;
                 case '\007': /* Bell */
- bell();
+ XBell(dpy, 0);
                         break;
                 case '\010': /* backspace */
                         curr_col--;
diff -r 8baac73b9c9c -r b4382ab109d5 process.c
--- a/process.c Mon Mar 05 15:03:34 2007 +0100
+++ b/process.c Mon Mar 05 15:28:41 2007 +0100
@@ -33,6 +33,16 @@ static int slave;
 static int slave;
 char *ptydev, *ttydev;
 
+static struct winsize *
+get_font_dim() {
+ static struct winsize w;
+
+ w.ws_row = screen_rows;
+ w.ws_col = screen_cols;
+ w.ws_xpixel = w.ws_ypixel = 0;
+ return &w;
+}
+
 static void
 sigchld_handler(int a) {
         int status = 0;
@@ -170,7 +180,7 @@ resize_app(void) {
 }
 
 int
-execute_command(int argc, const char **argv) {
+execute_command(int argc, char **argv) {
         char **args;
         struct passwd *pw;
 
diff -r 8baac73b9c9c -r b4382ab109d5 st.h
--- a/st.h Mon Mar 05 15:03:34 2007 +0100
+++ b/st.h Mon Mar 05 15:28:41 2007 +0100
@@ -16,7 +16,6 @@
 #define END_KEY "\033[4~"
 #define PREV_KEY "\033[5~"
 #define NEXT_KEY "\033[6~"
-#define win_set_icon_title win_set_window_title
 #define FIXME fprintf(stderr, "FIXME: %s: %d (%s)\n", __FILE__, __LINE__, __FUNCTION__)
 #define CP fprintf(stderr, "Checkpoint: %s:%d\n", __FILE__, __LINE__)
 #define min(a,b) (((a)<(b))?(a):(b))
@@ -83,25 +82,33 @@ int handle_x_events(void);
 
 /* process.c */
 int resize_app(void);
-int execute_command(int argc, const char **argv);
+int execute_command(int argc, char **argv);
 void wait_for_input(void);
 unsigned char cmdgetc(void);
 int cmd_write(const char *, int);
-
-extern int init_screen(void);
-extern int init_window(void);
-extern void wait_for_specific_event(int);
-extern struct winsize *get_font_dim(void);
-extern void buffer_resize(int,int);
-extern void cursor_rego(void);
-extern void redraw_screen(void);
-extern void redraw_region(int,int,int,int);
-extern void force_redraw_screen(void);
-extern void win_set_window_title(char *);
-extern Row *buffer_create(int rows, int cols);
 
 /* util.c */
 void *emalloc(unsigned int size);
 void *emallocz(unsigned int size);
 void eprint(const char *errstr, ...);
 char *estrdup(const char *str);
+
+/* vt.c */
+void wait_for_specific_event(int event_type);
+void set_text_attrs(Glyph l);
+void redraw_screen(void);
+void force_redraw_screen(void);
+void redraw_region(int x1, int y1, int x2, int y2);
+void show_cursor(void);
+void hide_cursor(void);
+Row *buffer_create(int rows, int cols);
+void cursor_rego(void);
+void buffer_resize(int rows, int cols);
+void scroll_up(int rows);
+void set_buffer_fg_color(int c);
+void set_buffer_bg_color(int c);
+void set_buffer_attrs(int bold);
+void write_buffer(unsigned char c);
+void wrap_line(void);
+void dispatch_escape(void);
+
diff -r 8baac73b9c9c -r b4382ab109d5 vt.c
--- a/vt.c Mon Mar 05 15:03:34 2007 +0100
+++ b/vt.c Mon Mar 05 15:28:41 2007 +0100
@@ -6,29 +6,22 @@
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/ioctl.h>
 #include <termios.h>
 
 /* Maximum (numerical) parameters to an escape sequence */
 #define NPAR 16
 
-void
-wait_for_specific_event(int event_type) {
- XEvent e;
- for(;;) {
- XNextEvent(dpy, &e);
- if(e.type == event_type)
- break;
- }
-}
-
-void
+/* static */
+
+static void
 win_clear_region(int x1, int y1, int x2, int y2, int color) {
         XSetBackground(dpy, dc.gc, color);
         XClearArea(dpy, win, x1, y1, x2 - x1, y2 - y1, 0);
 }
 
-void
+static void
 win_draw_string(int row, int col, char *s, int l) {
         if(dc.font.set)
                 XmbDrawImageString(dpy, win, dc.font.set, dc.gc, col * dc.font.width, row * dc.font.height + dc.font.ascent, s, l);
@@ -36,191 +29,43 @@ win_draw_string(int row, int col, char *
                 XDrawImageString(dpy, win, dc.gc, col * dc.font.width, row * dc.font.height + dc.font.ascent, s, l);
 }
 
-void
+static void
 win_set_window_title(char *title) {
         XStoreName(dpy, win, title);
 }
 
-void
+static void
 window_scroll_up(int lines) {
         XCopyArea(dpy, win, win, dc.gc, 0, lines * dc.font.height, ww, (screen_rows - lines + 1) * dc.font.height, 0, 0);
         win_clear_region(0, (screen_rows - lines) * dc.font.height, ww, screen_rows * dc.font.height, GET_BG_COLOR(text_attrs));
 }
 
-void
+static void
 region_scroll_up(int start, int end, int lines) {
         XCopyArea(dpy, win, win, dc.gc, 0, (start - 1 + lines) * dc.font.height, ww, (end - start + 2 - lines) * dc.font.height,
                         0, (start - 1) * dc.font.height);
         win_clear_region(0, (end - lines) * dc.font.height, ww, end * dc.font.height, GET_BG_COLOR(text_attrs));
 }
 
-void
+static void
 window_scroll_down(int lines) {
         XCopyArea(dpy, win, win, dc.gc, 0, 0, ww, (screen_rows - lines + 1) * dc.font.height, 0, lines * dc.font.height);
         win_clear_region(0, 0, ww, (lines) * dc.font.height, GET_BG_COLOR(text_attrs));
 }
 
-void
+static void
 region_scroll_down(int start, int end, int lines) {
         XCopyArea(dpy, win, win, dc.gc, 0, (start - 1) * dc.font.height, ww, (end - start + 2 - lines) * dc.font.height,
                         0, (start - 1 + lines) * dc.font.height);
         win_clear_region(0, (start - 1) * dc.font.height, ww, (start + lines - 1) * dc.font.height, GET_BG_COLOR(text_attrs));
 }
 
-void
-set_text_attrs(Glyph l) {
- int fg, bg;
-
- if(l.rev ^ l.sel)
- fg = l.bg, bg = l.fg;
- else
- fg = l.fg, bg = l.bg;
- if(l.bold && fg == 0)
- XSetForeground(dpy, dc.gc, dc.fg[8]);
- else
- XSetForeground(dpy, dc.gc, dc.fg[fg]);
- if(!dc.font.set)
- XSetFont(dpy, dc.gc, dc.font.xfont->fid);
- XSetBackground(dpy, dc.gc, dc.bg[bg]);
-}
-
-/* Max number of characters to be drawn at once */
-#define MAXRUNLENGTH 100
-
-void
-redraw_screen(void) {
- int i, j;
- int a;
- int sl, start;
- unsigned char buf[MAXRUNLENGTH];
-
- a = 0;
- set_text_attrs(text_screen[0].line[0]);
- for(i = 0; i < screen_rows; i++) {
- if(!text_screen[i].needs_update)
- continue;
- sl = 0; start = 0;
- for(j = 0; j <= screen_cols; j++) {
- if(j == screen_cols) {
- if(sl > 0)
- win_draw_string(i, start, &buf[0], sl);
- break;
- }
- if(a != ((*(int*)&(text_screen[i].line[j])) & ~0xff) || sl >= sizeof(buf)) {
- if(sl > 0)
- win_draw_string(i, start, &buf[0], sl);
- set_text_attrs(text_screen[i].line[j]);
- a = (*(int*)&(text_screen[i].line[j])) & ~0xff;
- start = j;
- sl = 0;
- }
- buf[sl] = text_screen[i].line[j].letter;
- sl++;
- }
- text_screen[i].needs_update = 0;
- }
- XFlush(dpy);
-}
-
-void
-force_redraw_screen(void) {
- int i;
- for(i = 0; i < screen_rows; i++)
- text_screen[i].needs_update = 1;
- redraw_screen();
-}
-
-void
-bell(void) {
- XBell(dpy, 0);
-}
-
-void
-redraw_region(int x1, int y1, int x2, int y2) {
- int i, j;
- int a;
- int sl, start;
- unsigned char buf[MAXRUNLENGTH];
-
- a = (*(int*)&(text_screen[y1-1].line[x1-1])) & ~0xff;
- set_text_attrs(text_screen[y1-1].line[x1-1]);
- for(i = y1 - 1; i < y2; i++) {
- sl = 0; start = x1 - 1;
- for(j = x1 - 1; j <= x2; j++) {
- if(j == x2) {
- if(sl > 0)
- win_draw_string(i, start, &buf[0], sl);
- break;
- }
- if(a != ((*(int*)&(text_screen[i].line[j])) & ~0xff) || sl >= sizeof(buf)) {
- if(sl > 0)
- win_draw_string(i, start, &buf[0], sl);
- set_text_attrs(text_screen[i].line[j]);
- a = (*(int*)&(text_screen[i].line[j])) & ~0xff;
- start = j;
- sl = 0;
- }
- buf[sl] = text_screen[i].line[j].letter;
- sl++;
- }
- text_screen[i].needs_update = 0;
- }
- XFlush(dpy);
-}
-
 extern int curr_row, curr_col;
 static int cursor_row, cursor_col;
 static int cursor_is_visible = 0;
 
-void
-show_cursor(void) {
- if(cursor_is_visible)
- return;
- if(!cursor_visible)
- return;
- cursor_row = curr_row;
- cursor_col = curr_col;
- if(curr_col > screen_cols)
- cursor_col = screen_cols;
- if(!dc.font.set)
- XSetFont(dpy, dc.gc, dc.font.xfont->fid);
- win_clear_region((cursor_col - 1) * dc.font.width, (cursor_row - 1) * dc.font.height,
- cursor_col * dc.font.width, cursor_row * dc.font.height, dc.fg[0]);
- XSetForeground(dpy, dc.gc, dc.fg[0]);
- XSetBackground(dpy, dc.gc, dc.fg[1]);
- win_draw_string(cursor_row - 1, cursor_col - 1, &(text_screen[cursor_row - 1].line[cursor_col - 1]), 1);
- XFlush(dpy);
- cursor_is_visible = 1;
-}
-
-void
-hide_cursor(void) {
- if(!cursor_is_visible)
- return;
- if(cursor_row <= screen_rows && cursor_col <= screen_cols)
- {
- set_text_attrs(text_screen[cursor_row-1].line[cursor_col-1]);
- win_clear_region((cursor_col - 1) * dc.font.width, (cursor_row - 1) * dc.font.height,
- cursor_col * dc.font.width, cursor_row * dc.font.height,
- GET_BG_COLOR(text_screen[cursor_row-1].line[cursor_col-1]));
- win_draw_string(cursor_row - 1, cursor_col - 1, &(text_screen[cursor_row - 1].line[cursor_col - 1]), 1);
- XFlush(dpy);
- }
- cursor_is_visible = 0;
-}
-Row *
-buffer_create(int rows, int cols) {
- int i;
- Row *tr;
-
- tr = emallocz(rows * sizeof(Row));
- for(i = 0; i < rows; i++)
- tr[i].line = emallocz(cols * sizeof(Glyph));
- return tr;
-}
-
 /* Cursor movement functions */
-int
+static int
 cursor_move_up(int n) {
         curr_row -= n;
         if(curr_row < 1)
@@ -228,7 +73,7 @@ cursor_move_up(int n) {
         return curr_row;
 }
 
-int
+static int
 cursor_move_down(int n) {
         curr_row += n;
         if(curr_row > screen_rows)
@@ -236,7 +81,7 @@ cursor_move_down(int n) {
         return curr_row;
 }
 
-int
+static int
 cursor_move_left(int n) {
         curr_col -= n;
         if(curr_col < 1)
@@ -244,7 +89,7 @@ cursor_move_left(int n) {
         return curr_col;
 }
 
-int
+static int
 cursor_move_right(int n) {
         curr_col += n;
         if(curr_col > screen_cols)
@@ -252,7 +97,7 @@ cursor_move_right(int n) {
         return curr_col;
 }
 
-int
+static int
 cursor_move_col(int n) {
         curr_col = n;
         if(curr_col < 1)
@@ -262,7 +107,7 @@ cursor_move_col(int n) {
         return curr_col;
 }
 
-int
+static int
 cursor_move_row(int n) {
         curr_row = n;
         if(curr_row < 1)
@@ -272,7 +117,7 @@ cursor_move_row(int n) {
         return curr_row;
 }
 
-void
+static void
 cursor_goto(int x, int y) {
         curr_col = x;
         curr_row = y;
@@ -286,12 +131,7 @@ cursor_goto(int x, int y) {
                 curr_row = screen_rows;
 }
 
-void
-cursor_rego(void) {
- cursor_goto(curr_col, curr_row);
-}
-
-void
+static void
 delete_rows(Row *screen, int start, int n) {
         int i;
 
@@ -299,7 +139,7 @@ delete_rows(Row *screen, int start, int
                 free(screen[start + i - 1].line);
 }
 
-void
+static void
 add_rows(Row *screen, int pos, int n) {
         int i, j;
 
@@ -313,7 +153,7 @@ add_rows(Row *screen, int pos, int n) {
         }
 }
 
-void
+static void
 buffer_destroy(Row *screen) {
         int i;
 
@@ -322,13 +162,13 @@ buffer_destroy(Row *screen) {
         free(screen);
 }
 
-void
+static void
 save_current_screen(void) {
         saved_screen = text_screen;
         text_screen = buffer_create(screen_rows, screen_cols);
 }
 
-void
+static void
 restore_saved_screen(void) {
         int i;
 
@@ -338,7 +178,12 @@ restore_saved_screen(void) {
                 text_screen[i].needs_update = 1;
 }
 
-void
+static void
+moverows(Row *screen, int from, int to, int n) {
+ memmove(&(screen[to-1]), &(screen[from-1]), n * sizeof(Row));
+}
+
+static void
 _buffer_resize(Row **s, int rows, int cols) {
         int i;
 
@@ -363,14 +208,7 @@ _buffer_resize(Row **s, int rows, int co
         }
 }
 
-void
-buffer_resize(int rows, int cols) {
- if(using_alternate_screen)
- _buffer_resize(&saved_screen, rows, cols);
- _buffer_resize(&text_screen, rows, cols);
-}
-
-void
+static void
 clear_area(int x1, int y1, int x2, int y2) {
         int i, j;
 
@@ -385,35 +223,7 @@ clear_area(int x1, int y1, int x2, int y
                 }
 }
 
-void
-clear_row(Row *r) {
- memset(r->line, '\0', screen_cols * sizeof(Glyph));
-}
-
-void
-moverows(Row *screen, int from, int to, int n) {
- memmove(&(screen[to-1]), &(screen[from-1]), n * sizeof(Row));
-}
-
-void
-scroll_up(int rows) {
- if(scroll_in_region) {
- /* Only scroll region */
- region_scroll_up(scroll_region_start, scroll_region_end, rows);
- delete_rows(text_screen, scroll_region_start, rows);
- moverows(text_screen, rows + scroll_region_start, scroll_region_start, scroll_region_end - scroll_region_start - rows + 1);
- add_rows(text_screen, scroll_region_end - rows + 1, rows);
- }
- else {
- /* Scroll entire buffer */
- window_scroll_up(rows);
- delete_rows(text_screen, 1, rows);
- moverows(text_screen, rows + 1, 1, screen_rows - rows);
- add_rows(text_screen, screen_rows - rows + 1, rows);
- }
-}
-
-void
+static void
 scroll_down(int rows) {
         if(scroll_in_region) {
                 /* Only scroll region */
@@ -431,7 +241,7 @@ scroll_down(int rows) {
         }
 }
 
-void
+static void
 insert_lines(int lines) {
         int a,b;
 
@@ -445,7 +255,7 @@ insert_lines(int lines) {
         scroll_in_region = b;
 }
 
-void
+static void
 delete_lines(int lines) {
         int a,b;
 
@@ -459,44 +269,12 @@ delete_lines(int lines) {
         scroll_in_region = b;
 }
 
-void
-set_buffer_fg_color(int c) {
- text_attrs.fg = c;
-}
-
-void
-set_buffer_bg_color(int c) {
- text_attrs.bg = c;
-}
-
-void
-set_buffer_attrs(int bold) {
- text_attrs.bold = bold ? 1 : 0;
-}
-
-void set_buffer_reverse(int rev)
+static void set_buffer_reverse(int rev)
 {
         text_attrs.rev = rev ? 1 : 0;
 }
 
-struct winsize *
-get_font_dim() {
- static struct winsize w;
-
- w.ws_row = screen_rows;
- w.ws_col = screen_cols;
- w.ws_xpixel = w.ws_ypixel = 0;
- return &w;
-}
-
-void
-write_buffer(unsigned char c) {
- text_attrs.letter = c;
- text_screen[curr_row-1].line[curr_col-1] = text_attrs;
- text_screen[curr_row-1].needs_update = 1;
-}
-
-void
+static void
 xterm_seq(int op) {
         unsigned char *buf;
         int len;
@@ -519,32 +297,19 @@ xterm_seq(int op) {
         case 0: /* set window and icon title */
         case 1: /* set icon title */
         case 2: /* set window title */
- win_set_window_title(buf);
- break;
- }
-}
-
-void
-wrap_line(void) {
- while(curr_col > screen_cols) {
- curr_col -= screen_cols;
- if(!wraparound_mode)
- curr_row++;
- if(curr_row > scroll_region_end) {
- scroll_up(curr_row - scroll_region_end);
- curr_row = scroll_region_end;
- }
- }
-}
+ win_set_window_title((char *)buf);
+ break;
+ }
+}
+
+/* extern */
 
 void
 dispatch_escape(void) {
- int len;
         int pos;
         int args[NPAR];
         int narg = 0;
         int digit;
- int rows, cols;
         int i;
         int questionmark;
         unsigned char c;
@@ -821,3 +586,222 @@ dispatch_escape(void) {
                 break;
         }
 }
+
+void
+wait_for_specific_event(int event_type) {
+ XEvent e;
+ for(;;) {
+ XNextEvent(dpy, &e);
+ if(e.type == event_type)
+ break;
+ }
+}
+
+void
+set_text_attrs(Glyph l) {
+ int fg, bg;
+
+ if(l.rev ^ l.sel)
+ fg = l.bg, bg = l.fg;
+ else
+ fg = l.fg, bg = l.bg;
+ if(l.bold && fg == 0)
+ XSetForeground(dpy, dc.gc, dc.fg[8]);
+ else
+ XSetForeground(dpy, dc.gc, dc.fg[fg]);
+ if(!dc.font.set)
+ XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+ XSetBackground(dpy, dc.gc, dc.bg[bg]);
+}
+
+/* Max number of characters to be drawn at once */
+#define MAXRUNLENGTH 100
+void
+redraw_screen(void) {
+ int i, j;
+ int a;
+ int sl, start;
+ unsigned char buf[MAXRUNLENGTH];
+
+ a = 0;
+ set_text_attrs(text_screen[0].line[0]);
+ for(i = 0; i < screen_rows; i++) {
+ if(!text_screen[i].needs_update)
+ continue;
+ sl = 0; start = 0;
+ for(j = 0; j <= screen_cols; j++) {
+ if(j == screen_cols) {
+ if(sl > 0)
+ win_draw_string(i, start, (char *)buf, sl);
+ break;
+ }
+ if(a != ((*(int*)&(text_screen[i].line[j])) & ~0xff) || sl >= sizeof(buf)) {
+ if(sl > 0)
+ win_draw_string(i, start, (char *)buf, sl);
+ set_text_attrs(text_screen[i].line[j]);
+ a = (*(int*)&(text_screen[i].line[j])) & ~0xff;
+ start = j;
+ sl = 0;
+ }
+ buf[sl] = text_screen[i].line[j].letter;
+ sl++;
+ }
+ text_screen[i].needs_update = 0;
+ }
+ XFlush(dpy);
+}
+
+void
+force_redraw_screen(void) {
+ int i;
+ for(i = 0; i < screen_rows; i++)
+ text_screen[i].needs_update = 1;
+ redraw_screen();
+}
+
+void
+redraw_region(int x1, int y1, int x2, int y2) {
+ int i, j;
+ int a;
+ int sl, start;
+ unsigned char buf[MAXRUNLENGTH];
+
+ a = (*(int*)&(text_screen[y1-1].line[x1-1])) & ~0xff;
+ set_text_attrs(text_screen[y1-1].line[x1-1]);
+ for(i = y1 - 1; i < y2; i++) {
+ sl = 0; start = x1 - 1;
+ for(j = x1 - 1; j <= x2; j++) {
+ if(j == x2) {
+ if(sl > 0)
+ win_draw_string(i, start, (char *)buf, sl);
+ break;
+ }
+ if(a != ((*(int*)&(text_screen[i].line[j])) & ~0xff) || sl >= sizeof(buf)) {
+ if(sl > 0)
+ win_draw_string(i, start, (char *)buf, sl);
+ set_text_attrs(text_screen[i].line[j]);
+ a = (*(int*)&(text_screen[i].line[j])) & ~0xff;
+ start = j;
+ sl = 0;
+ }
+ buf[sl] = text_screen[i].line[j].letter;
+ sl++;
+ }
+ text_screen[i].needs_update = 0;
+ }
+ XFlush(dpy);
+}
+
+void
+show_cursor(void) {
+ if(cursor_is_visible)
+ return;
+ if(!cursor_visible)
+ return;
+ cursor_row = curr_row;
+ cursor_col = curr_col;
+ if(curr_col > screen_cols)
+ cursor_col = screen_cols;
+ if(!dc.font.set)
+ XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+ win_clear_region((cursor_col - 1) * dc.font.width, (cursor_row - 1) * dc.font.height,
+ cursor_col * dc.font.width, cursor_row * dc.font.height, dc.fg[0]);
+ XSetForeground(dpy, dc.gc, dc.fg[0]);
+ XSetBackground(dpy, dc.gc, dc.fg[1]);
+ win_draw_string(cursor_row - 1, cursor_col - 1, (char *)&(text_screen[cursor_row - 1].line[cursor_col - 1]), 1);
+ XFlush(dpy);
+ cursor_is_visible = 1;
+}
+
+void
+hide_cursor(void) {
+ if(!cursor_is_visible)
+ return;
+ if(cursor_row <= screen_rows && cursor_col <= screen_cols)
+ {
+ set_text_attrs(text_screen[cursor_row-1].line[cursor_col-1]);
+ win_clear_region((cursor_col - 1) * dc.font.width, (cursor_row - 1) * dc.font.height,
+ cursor_col * dc.font.width, cursor_row * dc.font.height,
+ GET_BG_COLOR(text_screen[cursor_row-1].line[cursor_col-1]));
+ win_draw_string(cursor_row - 1, cursor_col - 1, (char *)&(text_screen[cursor_row - 1].line[cursor_col - 1]), 1);
+ XFlush(dpy);
+ }
+ cursor_is_visible = 0;
+}
+
+Row *
+buffer_create(int rows, int cols) {
+ int i;
+ Row *tr;
+
+ tr = emallocz(rows * sizeof(Row));
+ for(i = 0; i < rows; i++)
+ tr[i].line = emallocz(cols * sizeof(Glyph));
+ return tr;
+}
+
+void
+cursor_rego(void) {
+ cursor_goto(curr_col, curr_row);
+}
+
+void
+buffer_resize(int rows, int cols) {
+ if(using_alternate_screen)
+ _buffer_resize(&saved_screen, rows, cols);
+ _buffer_resize(&text_screen, rows, cols);
+}
+
+void
+scroll_up(int rows) {
+ if(scroll_in_region) {
+ /* Only scroll region */
+ region_scroll_up(scroll_region_start, scroll_region_end, rows);
+ delete_rows(text_screen, scroll_region_start, rows);
+ moverows(text_screen, rows + scroll_region_start, scroll_region_start, scroll_region_end - scroll_region_start - rows + 1);
+ add_rows(text_screen, scroll_region_end - rows + 1, rows);
+ }
+ else {
+ /* Scroll entire buffer */
+ window_scroll_up(rows);
+ delete_rows(text_screen, 1, rows);
+ moverows(text_screen, rows + 1, 1, screen_rows - rows);
+ add_rows(text_screen, screen_rows - rows + 1, rows);
+ }
+}
+
+void
+set_buffer_fg_color(int c) {
+ text_attrs.fg = c;
+}
+
+void
+set_buffer_bg_color(int c) {
+ text_attrs.bg = c;
+}
+
+void
+set_buffer_attrs(int bold) {
+ text_attrs.bold = bold ? 1 : 0;
+}
+
+void
+write_buffer(unsigned char c) {
+ text_attrs.letter = c;
+ text_screen[curr_row-1].line[curr_col-1] = text_attrs;
+ text_screen[curr_row-1].needs_update = 1;
+}
+
+void
+wrap_line(void) {
+ while(curr_col > screen_cols) {
+ curr_col -= screen_cols;
+ if(!wraparound_mode)
+ curr_row++;
+ if(curr_row > scroll_region_end) {
+ scroll_up(curr_row - scroll_region_end);
+ curr_row = scroll_region_end;
+ }
+ }
+}
+
Received on Mon Mar 05 2007 - 15:29:24 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:11 UTC