diff options
| author | Devin J. Pohly <djpohly@gmail.com> | 2017-10-10 12:46:53 -0500 |
|---|---|---|
| committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:53:24 -0600 |
| commit | a8314643b1aeaa2187dad71dc5748aaac1760c1b (patch) | |
| tree | 563c3943af0790e419eae99da709b9dd5fd5cefb | |
| parent | a09138afa57adb4b76dba8ca72dc7ee2642a5c8d (diff) | |
| download | st-a8314643b1aeaa2187dad71dc5748aaac1760c1b.tar.gz st-a8314643b1aeaa2187dad71dc5748aaac1760c1b.zip | |
Move window-manipulating functions into x.c
xresize is now internal to x.c
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
| -rw-r--r-- | st.c | 36 | ||||
| -rw-r--r-- | st.h | 9 | ||||
| -rw-r--r-- | win.h | 1 | ||||
| -rw-r--r-- | x.c | 45 |
4 files changed, 45 insertions, 46 deletions
| @@ -165,7 +165,6 @@ static void tnewline(int); | |||
| 165 | static void tputtab(int); | 165 | static void tputtab(int); |
| 166 | static void tputc(Rune); | 166 | static void tputc(Rune); |
| 167 | static void treset(void); | 167 | static void treset(void); |
| 168 | static void tresize(int, int); | ||
| 169 | static void tscrollup(int, int); | 168 | static void tscrollup(int, int); |
| 170 | static void tscrolldown(int, int); | 169 | static void tscrolldown(int, int); |
| 171 | static void tsetattr(int *, int); | 170 | static void tsetattr(int *, int); |
| @@ -420,24 +419,6 @@ selinit(void) | |||
| 420 | } | 419 | } |
| 421 | 420 | ||
| 422 | int | 421 | int |
| 423 | x2col(int x) | ||
| 424 | { | ||
| 425 | x -= borderpx; | ||
| 426 | x /= win.cw; | ||
| 427 | |||
| 428 | return LIMIT(x, 0, term.col-1); | ||
| 429 | } | ||
| 430 | |||
| 431 | int | ||
| 432 | y2row(int y) | ||
| 433 | { | ||
| 434 | y -= borderpx; | ||
| 435 | y /= win.ch; | ||
| 436 | |||
| 437 | return LIMIT(y, 0, term.row-1); | ||
| 438 | } | ||
| 439 | |||
| 440 | int | ||
| 441 | tlinelen(int y) | 422 | tlinelen(int y) |
| 442 | { | 423 | { |
| 443 | int i = term.col; | 424 | int i = term.col; |
| @@ -2620,20 +2601,3 @@ kmap(KeySym k, uint state) | |||
| 2620 | 2601 | ||
| 2621 | return NULL; | 2602 | return NULL; |
| 2622 | } | 2603 | } |
| 2623 | |||
| 2624 | void | ||
| 2625 | cresize(int width, int height) | ||
| 2626 | { | ||
| 2627 | int col, row; | ||
| 2628 | |||
| 2629 | if (width != 0) | ||
| 2630 | win.w = width; | ||
| 2631 | if (height != 0) | ||
| 2632 | win.h = height; | ||
| 2633 | |||
| 2634 | col = (win.w - 2 * borderpx) / win.cw; | ||
| 2635 | row = (win.h - 2 * borderpx) / win.ch; | ||
| 2636 | |||
| 2637 | tresize(col, row); | ||
| 2638 | xresize(col, row); | ||
| 2639 | } | ||
| @@ -80,11 +80,6 @@ enum selection_snap { | |||
| 80 | SNAP_LINE = 2 | 80 | SNAP_LINE = 2 |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | enum window_state { | ||
| 84 | WIN_VISIBLE = 1, | ||
| 85 | WIN_FOCUSED = 2 | ||
| 86 | }; | ||
| 87 | |||
| 88 | typedef unsigned char uchar; | 83 | typedef unsigned char uchar; |
| 89 | typedef unsigned int uint; | 84 | typedef unsigned int uint; |
| 90 | typedef unsigned long ulong; | 85 | typedef unsigned long ulong; |
| @@ -186,6 +181,7 @@ void redraw(void); | |||
| 186 | 181 | ||
| 187 | int tattrset(int); | 182 | int tattrset(int); |
| 188 | void tnew(int, int); | 183 | void tnew(int, int); |
| 184 | void tresize(int, int); | ||
| 189 | void tsetdirt(int, int); | 185 | void tsetdirt(int, int); |
| 190 | void tsetdirtattr(int); | 186 | void tsetdirtattr(int); |
| 191 | int match(uint, uint); | 187 | int match(uint, uint); |
| @@ -198,15 +194,12 @@ void ttywrite(const char *, size_t); | |||
| 198 | void resettitle(void); | 194 | void resettitle(void); |
| 199 | 195 | ||
| 200 | char *kmap(KeySym, uint); | 196 | char *kmap(KeySym, uint); |
| 201 | void cresize(int, int); | ||
| 202 | void selclear(void); | 197 | void selclear(void); |
| 203 | 198 | ||
| 204 | void selinit(void); | 199 | void selinit(void); |
| 205 | void selnormalize(void); | 200 | void selnormalize(void); |
| 206 | int selected(int, int); | 201 | int selected(int, int); |
| 207 | char *getsel(void); | 202 | char *getsel(void); |
| 208 | int x2col(int); | ||
| 209 | int y2row(int); | ||
| 210 | 203 | ||
| 211 | size_t utf8decode(char *, Rune *, size_t); | 204 | size_t utf8decode(char *, Rune *, size_t); |
| 212 | size_t utf8encode(Rune, char *); | 205 | size_t utf8encode(Rune, char *); |
| @@ -16,7 +16,6 @@ void xloadcols(void); | |||
| 16 | int xsetcolorname(int, const char *); | 16 | int xsetcolorname(int, const char *); |
| 17 | void xsettitle(char *); | 17 | void xsettitle(char *); |
| 18 | void xsetpointermotion(int); | 18 | void xsetpointermotion(int); |
| 19 | void xresize(int, int); | ||
| 20 | void xselpaste(void); | 19 | void xselpaste(void); |
| 21 | void xsetsel(char *, Time); | 20 | void xsetsel(char *, Time); |
| 22 | void zoom(const Arg *); | 21 | void zoom(const Arg *); |
| @@ -88,12 +88,16 @@ static void xclear(int, int, int, int); | |||
| 88 | static void xdrawcursor(void); | 88 | static void xdrawcursor(void); |
| 89 | static int xgeommasktogravity(int); | 89 | static int xgeommasktogravity(int); |
| 90 | static void xinit(void); | 90 | static void xinit(void); |
| 91 | static void cresize(int, int); | ||
| 92 | static void xresize(int, int); | ||
| 91 | static int xloadfont(Font *, FcPattern *); | 93 | static int xloadfont(Font *, FcPattern *); |
| 92 | static void xloadfonts(char *, double); | 94 | static void xloadfonts(char *, double); |
| 93 | static void xunloadfont(Font *); | 95 | static void xunloadfont(Font *); |
| 94 | static void xunloadfonts(void); | 96 | static void xunloadfonts(void); |
| 95 | static void xsetenv(void); | 97 | static void xsetenv(void); |
| 96 | static void xseturgency(int); | 98 | static void xseturgency(int); |
| 99 | static int x2col(int); | ||
| 100 | static int y2row(int); | ||
| 97 | 101 | ||
| 98 | static void expose(XEvent *); | 102 | static void expose(XEvent *); |
| 99 | static void visibility(XEvent *); | 103 | static void visibility(XEvent *); |
| @@ -109,7 +113,6 @@ static void propnotify(XEvent *); | |||
| 109 | static void selnotify(XEvent *); | 113 | static void selnotify(XEvent *); |
| 110 | static void selclear_(XEvent *); | 114 | static void selclear_(XEvent *); |
| 111 | static void selrequest(XEvent *); | 115 | static void selrequest(XEvent *); |
| 112 | |||
| 113 | static void selcopy(Time); | 116 | static void selcopy(Time); |
| 114 | static void getbuttoninfo(XEvent *); | 117 | static void getbuttoninfo(XEvent *); |
| 115 | static void mousereport(XEvent *); | 118 | static void mousereport(XEvent *); |
| @@ -148,6 +151,11 @@ static DC dc; | |||
| 148 | static XWindow xw; | 151 | static XWindow xw; |
| 149 | static XSelection xsel; | 152 | static XSelection xsel; |
| 150 | 153 | ||
| 154 | enum window_state { | ||
| 155 | WIN_VISIBLE = 1, | ||
| 156 | WIN_FOCUSED = 2 | ||
| 157 | }; | ||
| 158 | |||
| 151 | /* Font Ring Cache */ | 159 | /* Font Ring Cache */ |
| 152 | enum { | 160 | enum { |
| 153 | FRC_NORMAL, | 161 | FRC_NORMAL, |
| @@ -200,6 +208,24 @@ zoomreset(const Arg *arg) | |||
| 200 | } | 208 | } |
| 201 | } | 209 | } |
| 202 | 210 | ||
| 211 | int | ||
| 212 | x2col(int x) | ||
| 213 | { | ||
| 214 | x -= borderpx; | ||
| 215 | x /= win.cw; | ||
| 216 | |||
| 217 | return LIMIT(x, 0, term.col-1); | ||
| 218 | } | ||
| 219 | |||
| 220 | int | ||
| 221 | y2row(int y) | ||
| 222 | { | ||
| 223 | y -= borderpx; | ||
| 224 | y /= win.ch; | ||
| 225 | |||
| 226 | return LIMIT(y, 0, term.row-1); | ||
| 227 | } | ||
| 228 | |||
| 203 | void | 229 | void |
| 204 | getbuttoninfo(XEvent *e) | 230 | getbuttoninfo(XEvent *e) |
| 205 | { | 231 | { |
| @@ -597,6 +623,23 @@ bmotion(XEvent *e) | |||
| 597 | } | 623 | } |
| 598 | 624 | ||
| 599 | void | 625 | void |
| 626 | cresize(int width, int height) | ||
| 627 | { | ||
| 628 | int col, row; | ||
| 629 | |||
| 630 | if (width != 0) | ||
| 631 | win.w = width; | ||
| 632 | if (height != 0) | ||
| 633 | win.h = height; | ||
| 634 | |||
| 635 | col = (win.w - 2 * borderpx) / win.cw; | ||
| 636 | row = (win.h - 2 * borderpx) / win.ch; | ||
| 637 | |||
| 638 | tresize(col, row); | ||
| 639 | xresize(col, row); | ||
| 640 | } | ||
| 641 | |||
| 642 | void | ||
| 600 | xresize(int col, int row) | 643 | xresize(int col, int row) |
| 601 | { | 644 | { |
| 602 | win.tw = MAX(1, col * win.cw); | 645 | win.tw = MAX(1, col * win.cw); |
