aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2017-10-10 12:46:53 -0500
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:53:24 -0600
commita8314643b1aeaa2187dad71dc5748aaac1760c1b (patch)
tree563c3943af0790e419eae99da709b9dd5fd5cefb
parenta09138afa57adb4b76dba8ca72dc7ee2642a5c8d (diff)
downloadst-patched-a8314643b1aeaa2187dad71dc5748aaac1760c1b.tar.bz2
st-patched-a8314643b1aeaa2187dad71dc5748aaac1760c1b.tar.xz
st-patched-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.c36
-rw-r--r--st.h9
-rw-r--r--win.h1
-rw-r--r--x.c45
4 files changed, 45 insertions, 46 deletions
diff --git a/st.c b/st.c
index 540b487..75c191d 100644
--- a/st.c
+++ b/st.c
@@ -165,7 +165,6 @@ static void tnewline(int);
165static void tputtab(int); 165static void tputtab(int);
166static void tputc(Rune); 166static void tputc(Rune);
167static void treset(void); 167static void treset(void);
168static void tresize(int, int);
169static void tscrollup(int, int); 168static void tscrollup(int, int);
170static void tscrolldown(int, int); 169static void tscrolldown(int, int);
171static void tsetattr(int *, int); 170static void tsetattr(int *, int);
@@ -420,24 +419,6 @@ selinit(void)
420} 419}
421 420
422int 421int
423x2col(int x)
424{
425 x -= borderpx;
426 x /= win.cw;
427
428 return LIMIT(x, 0, term.col-1);
429}
430
431int
432y2row(int y)
433{
434 y -= borderpx;
435 y /= win.ch;
436
437 return LIMIT(y, 0, term.row-1);
438}
439
440int
441tlinelen(int y) 422tlinelen(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
2624void
2625cresize(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}
diff --git a/st.h b/st.h
index 2199c13..5d44411 100644
--- a/st.h
+++ b/st.h
@@ -80,11 +80,6 @@ enum selection_snap {
80 SNAP_LINE = 2 80 SNAP_LINE = 2
81}; 81};
82 82
83enum window_state {
84 WIN_VISIBLE = 1,
85 WIN_FOCUSED = 2
86};
87
88typedef unsigned char uchar; 83typedef unsigned char uchar;
89typedef unsigned int uint; 84typedef unsigned int uint;
90typedef unsigned long ulong; 85typedef unsigned long ulong;
@@ -186,6 +181,7 @@ void redraw(void);
186 181
187int tattrset(int); 182int tattrset(int);
188void tnew(int, int); 183void tnew(int, int);
184void tresize(int, int);
189void tsetdirt(int, int); 185void tsetdirt(int, int);
190void tsetdirtattr(int); 186void tsetdirtattr(int);
191int match(uint, uint); 187int match(uint, uint);
@@ -198,15 +194,12 @@ void ttywrite(const char *, size_t);
198void resettitle(void); 194void resettitle(void);
199 195
200char *kmap(KeySym, uint); 196char *kmap(KeySym, uint);
201void cresize(int, int);
202void selclear(void); 197void selclear(void);
203 198
204void selinit(void); 199void selinit(void);
205void selnormalize(void); 200void selnormalize(void);
206int selected(int, int); 201int selected(int, int);
207char *getsel(void); 202char *getsel(void);
208int x2col(int);
209int y2row(int);
210 203
211size_t utf8decode(char *, Rune *, size_t); 204size_t utf8decode(char *, Rune *, size_t);
212size_t utf8encode(Rune, char *); 205size_t utf8encode(Rune, char *);
diff --git a/win.h b/win.h
index dee0b7f..00113c5 100644
--- a/win.h
+++ b/win.h
@@ -16,7 +16,6 @@ void xloadcols(void);
16int xsetcolorname(int, const char *); 16int xsetcolorname(int, const char *);
17void xsettitle(char *); 17void xsettitle(char *);
18void xsetpointermotion(int); 18void xsetpointermotion(int);
19void xresize(int, int);
20void xselpaste(void); 19void xselpaste(void);
21void xsetsel(char *, Time); 20void xsetsel(char *, Time);
22void zoom(const Arg *); 21void zoom(const Arg *);
diff --git a/x.c b/x.c
index 186e408..01ef1b0 100644
--- a/x.c
+++ b/x.c
@@ -88,12 +88,16 @@ static void xclear(int, int, int, int);
88static void xdrawcursor(void); 88static void xdrawcursor(void);
89static int xgeommasktogravity(int); 89static int xgeommasktogravity(int);
90static void xinit(void); 90static void xinit(void);
91static void cresize(int, int);
92static void xresize(int, int);
91static int xloadfont(Font *, FcPattern *); 93static int xloadfont(Font *, FcPattern *);
92static void xloadfonts(char *, double); 94static void xloadfonts(char *, double);
93static void xunloadfont(Font *); 95static void xunloadfont(Font *);
94static void xunloadfonts(void); 96static void xunloadfonts(void);
95static void xsetenv(void); 97static void xsetenv(void);
96static void xseturgency(int); 98static void xseturgency(int);
99static int x2col(int);
100static int y2row(int);
97 101
98static void expose(XEvent *); 102static void expose(XEvent *);
99static void visibility(XEvent *); 103static void visibility(XEvent *);
@@ -109,7 +113,6 @@ static void propnotify(XEvent *);
109static void selnotify(XEvent *); 113static void selnotify(XEvent *);
110static void selclear_(XEvent *); 114static void selclear_(XEvent *);
111static void selrequest(XEvent *); 115static void selrequest(XEvent *);
112
113static void selcopy(Time); 116static void selcopy(Time);
114static void getbuttoninfo(XEvent *); 117static void getbuttoninfo(XEvent *);
115static void mousereport(XEvent *); 118static void mousereport(XEvent *);
@@ -148,6 +151,11 @@ static DC dc;
148static XWindow xw; 151static XWindow xw;
149static XSelection xsel; 152static XSelection xsel;
150 153
154enum window_state {
155 WIN_VISIBLE = 1,
156 WIN_FOCUSED = 2
157};
158
151/* Font Ring Cache */ 159/* Font Ring Cache */
152enum { 160enum {
153 FRC_NORMAL, 161 FRC_NORMAL,
@@ -200,6 +208,24 @@ zoomreset(const Arg *arg)
200 } 208 }
201} 209}
202 210
211int
212x2col(int x)
213{
214 x -= borderpx;
215 x /= win.cw;
216
217 return LIMIT(x, 0, term.col-1);
218}
219
220int
221y2row(int y)
222{
223 y -= borderpx;
224 y /= win.ch;
225
226 return LIMIT(y, 0, term.row-1);
227}
228
203void 229void
204getbuttoninfo(XEvent *e) 230getbuttoninfo(XEvent *e)
205{ 231{
@@ -597,6 +623,23 @@ bmotion(XEvent *e)
597} 623}
598 624
599void 625void
626cresize(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
642void
600xresize(int col, int row) 643xresize(int col, int row)
601{ 644{
602 win.tw = MAX(1, col * win.cw); 645 win.tw = MAX(1, col * win.cw);