[hackers] [st] removed separate main_loop functions, removed more useless functions

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Fri Mar 02 15:52:18 2007

changeset: 53:9dfcbdf43eff
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Fri Mar 02 15:51:38 2007 +0100
summary: removed separate main_loop functions, removed more useless functions

diff -r a76e7be497b5 -r 9dfcbdf43eff events.c
--- a/events.c Fri Mar 02 15:46:30 2007 +0100
+++ b/events.c Fri Mar 02 15:51:38 2007 +0100
@@ -433,12 +433,3 @@ handle_x_events(void) {
         }
         return 0;
 }
-
-int
-set_x_event_mask(void) {
- XSelectInput(dpy, win, KeyPressMask | ButtonPressMask
- | FocusChangeMask | VisibilityChangeMask
- | StructureNotifyMask | ExposureMask
- | Button1MotionMask | Button3MotionMask);
- return 0;
-}
diff -r a76e7be497b5 -r 9dfcbdf43eff main.c
--- a/main.c Fri Mar 02 15:46:30 2007 +0100
+++ b/main.c Fri Mar 02 15:51:38 2007 +0100
@@ -168,6 +168,7 @@ text_row_t *saved_screen;
 
 int
 main(int argc, char **argv) {
+ unsigned char c;
 
         setlocale(LC_CTYPE, "");
         if(!(dpy = XOpenDisplay(0)))
@@ -188,9 +189,58 @@ main(int argc, char **argv) {
         set_buffer_fg_color(7);
         set_buffer_bg_color(0);
         set_buffer_attrs(0);
- set_x_event_mask();
+ XSelectInput(dpy, win, KeyPressMask | ButtonPressMask
+ | FocusChangeMask | VisibilityChangeMask
+ | StructureNotifyMask | ExposureMask
+ | Button1MotionMask | Button3MotionMask);
         execute_command(argc, argv);
- main_loop();
- exit_display();
+ for(;;)
+ switch((c = cmdgetc())) {
+ default:
+ wrap_line();
+ if(c >= ' ') {
+ write_buffer(c);
+ curr_col++;
+ }
+ break;
+ case '\007': /* Bell */
+ bell();
+ break;
+ case '\010': /* backspace */
+ curr_col--;
+ if(curr_col < 1)
+ curr_col = 1;
+ break;
+ case '\011': /* tab */
+ curr_col = ((curr_col) | 7) + 2;
+ if(curr_col > screen_cols) {
+ curr_col = 8;
+ if(!wraparound_mode)
+ curr_row++;
+ if(curr_row > scroll_region_end) {
+ scroll_up(curr_row - scroll_region_end);
+ curr_row = scroll_region_end;
+ }
+ }
+ break;
+ case '\033': /* escape */
+ /* handle esc codes */
+ dispatch_escape();
+ break;
+ case '\n': /* newline */
+ if(!application_keypad_mode)
+ /* return carriage */
+ curr_col = 1;
+ curr_row++;
+ if(curr_row > scroll_region_end) {
+ scroll_up(curr_row - scroll_region_end);
+ curr_row = scroll_region_end;
+ }
+ break;
+ case '\r': /* carriage return */
+ curr_col = 1;
+ break;
+ }
+ XCloseDisplay(dpy);
         return 0;
 }
diff -r a76e7be497b5 -r 9dfcbdf43eff process.c
--- a/process.c Fri Mar 02 15:46:30 2007 +0100
+++ b/process.c Fri Mar 02 15:51:38 2007 +0100
@@ -157,7 +157,7 @@ wait_for_input(void) {
         int X_fd;
         int need_redraw = 0;
 
- X_fd = get_x_filedes();
+ X_fd = ConnectionNumber(dpy);
         hide_cursor();
         redraw_screen();
         for(;;) {
diff -r a76e7be497b5 -r 9dfcbdf43eff screen.c
--- a/screen.c Fri Mar 02 15:46:30 2007 +0100
+++ b/screen.c Fri Mar 02 15:51:38 2007 +0100
@@ -625,57 +625,3 @@ dispatch_escape(void) {
                 break;
         }
 }
-
-void
-main_loop() {
- unsigned char c;
-
- for(;;)
- switch((c = cmdgetc())) {
- default:
- wrap_line();
- if(c >= ' ')
- {
- write_buffer(c);
- curr_col++;
- }
- break;
- case '\007': /* Bell */
- bell();
- break;
- case '\010': /* backspace */
- curr_col--;
- if(curr_col < 1)
- curr_col = 1;
- break;
- case '\011': /* tab */
- curr_col = ((curr_col) | 7) + 2;
- if(curr_col > screen_cols) {
- curr_col = 8;
- if(!wraparound_mode)
- curr_row++;
- if(curr_row > scroll_region_end) {
- scroll_up(curr_row - scroll_region_end);
- curr_row = scroll_region_end;
- }
- }
- break;
- case '\033': /* escape */
- /* handle esc codes */
- dispatch_escape();
- break;
- case '\n': /* newline */
- if(!application_keypad_mode)
- /* return carriage */
- curr_col = 1;
- curr_row++;
- if(curr_row > scroll_region_end) {
- scroll_up(curr_row - scroll_region_end);
- curr_row = scroll_region_end;
- }
- break;
- case '\r': /* carriage return */
- curr_col = 1;
- break;
- }
-}
diff -r a76e7be497b5 -r 9dfcbdf43eff ui.c
--- a/ui.c Fri Mar 02 15:46:30 2007 +0100
+++ b/ui.c Fri Mar 02 15:51:38 2007 +0100
@@ -94,17 +94,6 @@ set_text_attrs(text_letter_t l) {
         if(!dc.font.set)
                 XSetFont(dpy, gc, dc.font.xfont->fid);
         XSetBackground(dpy, gc, dc.bg[bg]);
-}
-
-int
-exit_display(void) {
- XCloseDisplay(dpy);
- return 0;
-}
-
-int
-get_x_filedes(void) {
- return XConnectionNumber(dpy);
 }
 
 /* Max number of characters to be drawn at once */
Received on Fri Mar 02 2007 - 15:52:18 UTC

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