[hackers] [st] renamed a bunch of variables

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Fri Mar 02 14:22:16 2007

changeset: 47:0b1a533fa0f7
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Fri Mar 02 14:17:49 2007 +0100
summary: renamed a bunch of variables

diff -r 3a4e782cc38a -r 0b1a533fa0f7 events.c
--- a/events.c Fri Mar 02 12:35:34 2007 +0100
+++ b/events.c Fri Mar 02 14:17:49 2007 +0100
@@ -73,8 +73,8 @@ selection_paste(Time tm) {
         int nbytes;
         char *text;
 
- XConvertSelection(Xdisplay, XA_PRIMARY, XA_CUT_BUFFER0, None, MainWindow, tm);
- text = XFetchBytes(Xdisplay, &nbytes);
+ XConvertSelection(dpy, XA_PRIMARY, XA_CUT_BUFFER0, None, win, tm);
+ text = XFetchBytes(dpy, &nbytes);
         cmd_write(text, nbytes);
 }
 
@@ -150,8 +150,8 @@ handle_resize(XEvent *xev) {
                 screen_rows = new_rows;
                 scroll_region_start = 1;
                 scroll_region_end = screen_rows;
- window_width = xev->xconfigure.width;
- window_height = xev->xconfigure.height;
+ ww = xev->xconfigure.width;
+ wh = xev->xconfigure.height;
                 /* make sure the cursor is within the window */
                 cursor_rego();
                 /* Finally: pass the info to the application */
@@ -216,8 +216,8 @@ selection_select_word(int row, int col,
         }
         fprintf(stderr, "len=%d\n", len);
         text_screen[row-1].needs_update = 1;
- XStoreBuffer(Xdisplay, selection_text, len, XA_CUT_BUFFER0);
- XSetSelectionOwner(Xdisplay, XA_PRIMARY, MainWindow, tm);
+ XStoreBuffer(dpy, selection_text, len, XA_CUT_BUFFER0);
+ XSetSelectionOwner(dpy, XA_PRIMARY, win, tm);
 }
 
 void
@@ -235,8 +235,8 @@ selection_select_line(int row, int col,
         }
         while(selection_text[i] == ' ') i--;
         text_screen[row-1].needs_update=1;
- XStoreBuffer(Xdisplay, selection_text, screen_cols, XA_CUT_BUFFER0);
- XSetSelectionOwner(Xdisplay, XA_PRIMARY, MainWindow, tm);
+ XStoreBuffer(dpy, selection_text, screen_cols, XA_CUT_BUFFER0);
+ XSetSelectionOwner(dpy, XA_PRIMARY, win, tm);
 }
 
 void
@@ -287,8 +287,8 @@ handle_motionnotify(XEvent *xev) {
 handle_motionnotify(XEvent *xev) {
         int unused;
 
- while(XCheckTypedWindowEvent(Xdisplay, MainWindow, MotionNotify, xev));
- XQueryPointer(Xdisplay, MainWindow, &unused, &unused,
+ while(XCheckTypedWindowEvent(dpy, win, MotionNotify, xev));
+ XQueryPointer(dpy, win, &unused, &unused,
                         &unused, &unused, &(xev->xbutton.x), &(xev->xbutton.y), &unused);
 }
 
@@ -319,7 +319,7 @@ selection_copy(XEvent *xev) {
                 target_list[1] = (Atom32) XA_STRING;
                 target_list[2] = (Atom32) xa_text;
                 target_list[3] = (Atom32) xa_compound_text;
- XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target,
+ XChangeProperty(dpy, rq->requestor, rq->property, rq->target,
                                 (8 * sizeof(target_list[0])), PropModeReplace,
                                 (unsigned char *)target_list,
                                 (sizeof(target_list) / sizeof(target_list[0])));
@@ -336,13 +336,13 @@ selection_copy(XEvent *xev) {
                                 : XStdICCTextStyle;
                 }
                 cl[0] = selection_text;
- XmbTextListToTextProperty(Xdisplay, cl, 1, style, &ct);
- XChangeProperty(Xdisplay, rq->requestor, rq->property,
+ XmbTextListToTextProperty(dpy, cl, 1, style, &ct);
+ XChangeProperty(dpy, rq->requestor, rq->property,
                                 target, 8, PropModeReplace,
                                 ct.value, ct.nitems);
                 ev.xselection.property = rq->property;
         }
- XSendEvent(Xdisplay, rq->requestor, False, 0, &ev);
+ XSendEvent(dpy, rq->requestor, False, 0, &ev);
 }
 
 int
@@ -350,9 +350,9 @@ handle_x_events(void) {
         XEvent xev;
 
         /* Input from the X server */
- while (XPending(Xdisplay)) {
+ while (XPending(dpy)) {
                 /* process pending X events */
- XNextEvent(Xdisplay, &xev);
+ XNextEvent(dpy, &xev);
 
                 switch(xev.type) {
                 default:
@@ -436,7 +436,7 @@ handle_x_events(void) {
 
 int
 set_x_event_mask(void) {
- XSelectInput(Xdisplay, MainWindow, KeyPressMask | ButtonPressMask
+ XSelectInput(dpy, win, KeyPressMask | ButtonPressMask
                         | FocusChangeMask | VisibilityChangeMask
                         | StructureNotifyMask | ExposureMask
                         | Button1MotionMask | Button3MotionMask);
diff -r 3a4e782cc38a -r 0b1a533fa0f7 st.h
--- a/st.h Fri Mar 02 12:35:34 2007 +0100
+++ b/st.h Fri Mar 02 14:17:49 2007 +0100
@@ -9,7 +9,6 @@
 #define PREV_KEY "\033[5~"
 #define NEXT_KEY "\033[6~"
 #define DEFAULT_FONT "-*-proggyclean-medium-r-*-*-13-*-*-*-*-*-*-*"
-#define DEFAULT_BOLD_FONT DEFAULT_FONT
 #define DEFAULT_NR_ROWS 24
 #define DEFAULT_NR_COLS 80
 #define DELETE_KEY "\033[3~"
@@ -86,18 +85,15 @@ extern XColor colors[9];
 extern XColor colors[9];
 extern XColor bgcolors[8];
 extern XColor cursor_color;
-extern Display *Xdisplay;
-extern Window MainWindow;
-extern XFontStruct *Xfont;
-extern XFontStruct *Xboldfont;
-extern GC Xgc;
-extern Colormap Xcolmap;
-extern Cursor Xcursor;
-extern int Xdepth;
-extern Visual *Xvisual;
-extern int Xscreen;
-extern int window_width;
-extern int window_height;
+extern Display *dpy;
+extern Window win;
+extern XFontStruct *font;
+extern GC gc;
+extern Colormap cmap;
+extern Cursor cursor;
+extern int screen;
+extern int ww;
+extern int wh;
 extern int font_height;
 extern int font_width;
 
diff -r 3a4e782cc38a -r 0b1a533fa0f7 ui.c
--- a/ui.c Fri Mar 02 12:35:34 2007 +0100
+++ b/ui.c Fri Mar 02 14:17:49 2007 +0100
@@ -9,38 +9,33 @@
 #include <X11/Xutil.h>
 #include <X11/cursorfont.h>
 
-Display *Xdisplay;
-Window MainWindow;
-XFontStruct *Xfont;
-XFontStruct *Xboldfont;
-GC Xgc;
-Colormap Xcolmap;
-Cursor Xcursor;
+Display *dpy;
+Window win;
+XFontStruct *font;
+GC gc;
+Colormap cmap;
+Cursor cursor;
 
 XColor colors[9];
 XColor bgcolors[8];
 XColor cursor_color;
-int Xdepth;
-Visual *Xvisual;
-int Xscreen;
-int window_width;
-int window_height;
+int screen;
+int ww;
+int wh;
 int font_height = -1;
 int font_width = -1;
 
 int
 init_display(void) {
- Xdisplay = XOpenDisplay(NULL);
-
- if(!Xdisplay) {
+ dpy = XOpenDisplay(NULL);
+
+ if(!dpy) {
                 fprintf(stderr, "Couldn't open display\n");
                 return -1;
         }
- Xscreen = DefaultScreen(Xdisplay);
- Xdepth = DefaultDepth(Xdisplay, Xscreen);
- Xcolmap = DefaultColormap(Xdisplay, Xscreen);
- Xvisual = DefaultVisual(Xdisplay, Xscreen);
- if(!(Xcursor = XCreateFontCursor(Xdisplay, XC_xterm))) {
+ screen = DefaultScreen(dpy);
+ cmap = DefaultColormap(dpy, screen);
+ if(!(cursor = XCreateFontCursor(dpy, XC_xterm))) {
                 fprintf(stderr, "Couldn't create cursor\n");
                 return -1;
         }
@@ -51,60 +46,49 @@ init_window(void) {
 init_window(void) {
         char *args[] = { NULL };
         XSizeHints sh;
- XWMHints wh;
+ XWMHints wmh;
         XClassHint ch;
 
- MainWindow = XCreateSimpleWindow(Xdisplay, DefaultRootWindow(Xdisplay), 0, 0,
- window_width, window_height,
+ win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, ww, wh,
                         0, DEFAULT_BACKGROUND_COLOR.pixel, DEFAULT_BACKGROUND_COLOR.pixel);
- XSelectInput(Xdisplay, MainWindow, StructureNotifyMask);
- XMapWindow(Xdisplay, MainWindow);
+ XSelectInput(dpy, win, StructureNotifyMask);
+ XMapWindow(dpy, win);
         /* Wait for the window to be mapped */
         wait_for_specific_event(MapNotify);
- Xgc = XCreateGC(Xdisplay, MainWindow, 0, NULL);
- XSetForeground(Xdisplay, Xgc, DEFAULT_FOREGROUND_COLOR.pixel);
- XSetBackground(Xdisplay, Xgc, DEFAULT_BACKGROUND_COLOR.pixel);
- XDefineCursor(Xdisplay, MainWindow, Xcursor);
+ gc = XCreateGC(dpy, win, 0, NULL);
+ XSetForeground(dpy, gc, DEFAULT_FOREGROUND_COLOR.pixel);
+ XSetBackground(dpy, gc, DEFAULT_BACKGROUND_COLOR.pixel);
+ XDefineCursor(dpy, win, cursor);
         sh.x = sh.y = 0;
- sh.width = window_width;
- sh.height = window_height;
+ sh.width = ww;
+ sh.height = wh;
         sh.width_inc = font_width;
         sh.height_inc = font_height;
         sh.flags = PPosition | PSize | PResizeInc;
- wh.input = 1;
- wh.flags = InputHint;
+ wmh.input = 1;
+ wmh.flags = InputHint;
         ch.res_name = "st";
         ch.res_class = "st";
- XSetWMProperties(Xdisplay, MainWindow, NULL, NULL, &args[0], 0, &sh, &wh, &ch);
- XStoreName(Xdisplay, MainWindow, "st");
- XSync(Xdisplay, 0);
+ XSetWMProperties(dpy, win, NULL, NULL, &args[0], 0, &sh, &wmh, &ch);
+ XStoreName(dpy, win, "st");
+ XSync(dpy, 0);
         set_text_attrs(-1, 0);
- XSetFont(Xdisplay, Xgc, Xfont->fid);
+ XSetFont(dpy, gc, font->fid);
         return 0;
 }
 
 int
 init_font() {
- Xfont = XLoadQueryFont(Xdisplay, DEFAULT_FONT);
- if(!Xfont) {
- fprintf(stderr, "Couldn't open font `%s'\n",
- DEFAULT_FONT);
- return -1;
- }
- Xboldfont = XLoadQueryFont(Xdisplay, DEFAULT_BOLD_FONT);
- if(!Xfont) {
- fprintf(stderr, "Couldn't open font `%s'\n",
- DEFAULT_FONT);
- return -1;
- }
+ if(!(font = XLoadQueryFont(dpy, DEFAULT_FONT)))
+ eprint("Couldn't load font `%s'\n", DEFAULT_FONT);
         if(font_height == -1 || font_width == -1) {
- font_height = Xfont->ascent + Xfont->descent;
- font_width = Xfont->max_bounds.width;
+ font_height = font->ascent + font->descent;
+ font_width = font->max_bounds.width;
         }
         screen_rows = screen_rows == -1 ? DEFAULT_NR_ROWS : screen_rows;
         screen_cols = screen_cols == -1 ? DEFAULT_NR_COLS : screen_cols;
- window_width = screen_cols * font_width;
- window_height = screen_rows * font_height;
+ ww = screen_cols * font_width;
+ wh = screen_rows * font_height;
         return 0;
 }
 
@@ -112,7 +96,7 @@ wait_for_specific_event(int event_type)
 wait_for_specific_event(int event_type) {
         XEvent e;
         for(;;) {
- XNextEvent(Xdisplay, &e);
+ XNextEvent(dpy, &e);
                 if(e.type == event_type)
                         break;
         }
@@ -120,8 +104,8 @@ wait_for_specific_event(int event_type)
 
 int
 find_color(XColor *Xc, char *def) {
- if((XParseColor(Xdisplay, Xcolmap, def, Xc)))
- if(!(XAllocColor(Xdisplay, Xcolmap, Xc)))
+ if((XParseColor(dpy, cmap, def, Xc)))
+ if(!(XAllocColor(dpy, cmap, Xc)))
                         return -1;
         return 0;
 }
@@ -168,63 +152,63 @@ init_colors(void) {
 
 void
 win_clear_region(int x1, int y1, int x2, int y2, int color) {
- XSetBackground(Xdisplay, Xgc, color);
- XClearArea(Xdisplay, MainWindow, x1, y1, x2 - x1, y2 - y1, 0);
+ XSetBackground(dpy, gc, color);
+ XClearArea(dpy, win, x1, y1, x2 - x1, y2 - y1, 0);
 }
 
 void
 win_draw_string(int row, int col, char *s, int l) {
- XDrawImageString(Xdisplay, MainWindow, Xgc,
- col * font_width, row * font_height + Xfont->ascent,
+ XDrawImageString(dpy, win, gc,
+ col * font_width, row * font_height + font->ascent,
                         s, l);
 }
 
 void
 win_set_window_title(char *title) {
- XStoreName(Xdisplay, MainWindow, title);
+ XStoreName(dpy, win, title);
 }
 
 void
 window_scroll_up(int lines) {
- XCopyArea(Xdisplay, MainWindow, MainWindow, Xgc,
+ XCopyArea(dpy, win, win, gc,
                         0, lines * font_height,
- window_width, (screen_rows - lines + 1) * font_height,
+ ww, (screen_rows - lines + 1) * font_height,
                         0, 0);
         win_clear_region(0, (screen_rows - lines) * font_height,
- window_width, screen_rows * font_height,
+ ww, screen_rows * font_height,
                         GET_BG_COLOR(text_attrs));
 }
 
 void
 region_scroll_up(int start, int end, int lines) {
- XCopyArea(Xdisplay, MainWindow, MainWindow, Xgc,
+ XCopyArea(dpy, win, win, gc,
                         0, (start - 1 + lines) * font_height,
- window_width, (end - start + 2 - lines) * font_height,
+ ww, (end - start + 2 - lines) * font_height,
                         0, (start - 1) * font_height);
         win_clear_region(0, (end - lines) * font_height,
- window_width, end * font_height,
+ ww, end * font_height,
                         GET_BG_COLOR(text_attrs));
 }
 
 void
 window_scroll_down(int lines) {
- XCopyArea(Xdisplay, MainWindow, MainWindow, Xgc,
+ XCopyArea(dpy, win, win, gc,
                         0, 0,
- window_width, (screen_rows - lines + 1) * font_height,
+ ww, (screen_rows - lines + 1) * font_height,
                         0, lines * font_height);
         win_clear_region(0, 0,
- window_width, (lines) * font_height,
+ ww, (lines) * font_height,
                         GET_BG_COLOR(text_attrs));
 }
 
 void
 region_scroll_down(int start, int end, int lines) {
- XCopyArea(Xdisplay, MainWindow, MainWindow, Xgc,
+ XCopyArea(dpy, win, win, gc,
                         0, (start - 1) * font_height,
- window_width, (end - start + 2 - lines) * font_height,
+ ww, (end - start + 2 - lines) * font_height,
                         0, (start - 1 + lines) * font_height);
         win_clear_region(0, (start - 1) * font_height,
- window_width, (start + lines - 1) * font_height,
+ ww, (start + lines - 1) * font_height,
                         GET_BG_COLOR(text_attrs));
 }
 
@@ -237,25 +221,22 @@ set_text_attrs(text_letter_t l) {
         else
                 fg = l.fg, bg = l.bg;
         if(l.bold && fg == 0)
- XSetForeground(Xdisplay, Xgc, colors[8].pixel);
+ XSetForeground(dpy, gc, colors[8].pixel);
         else
- XSetForeground(Xdisplay, Xgc, colors[fg].pixel);
- if(l.bold)
- XSetFont(Xdisplay, Xgc, Xboldfont->fid);
- else
- XSetFont(Xdisplay, Xgc, Xfont->fid);
- XSetBackground(Xdisplay, Xgc, bgcolors[bg].pixel);
+ XSetForeground(dpy, gc, colors[fg].pixel);
+ XSetFont(dpy, gc, font->fid);
+ XSetBackground(dpy, gc, bgcolors[bg].pixel);
 }
 
 int
 exit_display(void) {
- XCloseDisplay(Xdisplay);
+ XCloseDisplay(dpy);
         return 0;
 }
 
 int
 get_x_filedes(void) {
- return XConnectionNumber(Xdisplay);
+ return XConnectionNumber(dpy);
 }
 
 /* Max number of characters to be drawn at once */
@@ -273,7 +254,7 @@ redraw_screen(void) {
         for(i = 0; i < screen_rows; i++) {
                 if(!text_screen[i].needs_update)
                         continue;
- /* win_clear_region(0, i * font_height, window_width-1, (i + 1) * font_height - 1); */
+ /* win_clear_region(0, i * font_height, ww-1, (i + 1) * font_height - 1); */
                 sl = 0; start = 0;
                 for(j = 0; j <= screen_cols; j++) {
                         if(j == screen_cols) {
@@ -294,7 +275,7 @@ redraw_screen(void) {
                 }
                 text_screen[i].needs_update = 0;
         }
- XFlush(Xdisplay);
+ XFlush(dpy);
 }
 
 void
@@ -307,7 +288,7 @@ force_redraw_screen(void) {
 
 void
 bell(void) {
- XBell(Xdisplay, 0);
+ XBell(dpy, 0);
 }
 
 void
@@ -341,7 +322,7 @@ redraw_region(int x1, int y1, int x2, in
                 }
                 text_screen[i].needs_update = 0;
         }
- XFlush(Xdisplay);
+ XFlush(dpy);
 }
 
 extern int curr_row, curr_col;
@@ -359,17 +340,17 @@ show_cursor(void) {
         if(curr_col > screen_cols)
                 cursor_col = screen_cols;
         if(text_screen[cursor_row-1].line[cursor_col-1].bold)
- XSetFont(Xdisplay, Xgc, Xboldfont->fid);
+ XSetFont(dpy, gc, font->fid);
         else
- XSetFont(Xdisplay, Xgc, Xfont->fid);
+ XSetFont(dpy, gc, font->fid);
         win_clear_region((cursor_col - 1) * font_width, (cursor_row - 1) * font_height,
                         cursor_col * font_width, cursor_row * font_height,
                         cursor_color.pixel);
 
- XSetForeground(Xdisplay, Xgc, colors[0].pixel);
- XSetBackground(Xdisplay, Xgc, cursor_color.pixel);
+ XSetForeground(dpy, gc, colors[0].pixel);
+ XSetBackground(dpy, gc, cursor_color.pixel);
         win_draw_string(cursor_row - 1, cursor_col - 1, &(text_screen[cursor_row - 1].line[cursor_col - 1]), 1);
- XFlush(Xdisplay);
+ XFlush(dpy);
         cursor_is_visible = 1;
 }
 
@@ -384,7 +365,7 @@ hide_cursor(void) {
                                 cursor_col * font_width, cursor_row * 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(Xdisplay);
+ XFlush(dpy);
         }
         cursor_is_visible = 0;
 }
Received on Fri Mar 02 2007 - 14:22:16 UTC

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