-typedef enum {\r
- STATUS = 0,\r
- TAGS = 1,\r
- EDIT = 2,\r
- SCROLL = 3,\r
- NREGIONS = 4,\r
- FOCUSED = 4\r
-} WinRegion;\r
-\r
-typedef struct {\r
- int mods;\r
- Rune key;\r
- void (*action)(void);\r
-} KeyBinding;\r
-\r
-typedef struct {\r
- size_t x;\r
- size_t y;\r
- size_t height;\r
- size_t width;\r
- size_t csrx;\r
- size_t csry;\r
- bool warp_ptr;\r
- View view;\r
-} Region;\r
-\r
-typedef void (*MouseFunc)(WinRegion id, size_t count, size_t row, size_t col);\r
-\r
-typedef struct {\r
- MouseFunc left;\r
- MouseFunc middle;\r
- MouseFunc right;\r
-} MouseConfig;\r
-\r
-void win_init(char* name);\r
-void win_loop(void);\r
-void win_settext(WinRegion id, char* text);\r
-void win_setkeys(KeyBinding* bindings);\r
-void win_setmouse(MouseConfig* mconfig);\r
-void win_warpptr(WinRegion id);\r
-View* win_view(WinRegion id);\r
-Buf* win_buf(WinRegion id);\r
-Sel* win_sel(WinRegion id);\r
-bool win_btnpressed(MouseBtn btn);\r
-WinRegion win_getregion(void);\r
-void win_setregion(WinRegion id);\r
-void win_setscroll(double offset, double visible);\r
-\r
-/* These functions must be implemented by any appliation that wishes \r
- to use this module */\r
-void onupdate(void);\r
-void onscroll(double percent);\r
-void onmouseleft(WinRegion id, size_t count, size_t row, size_t col);\r
-void onmousemiddle(WinRegion id, size_t count, size_t row, size_t col);\r
-void onmouseright(WinRegion id, size_t count, size_t row, size_t col);\r
-\r
+typedef enum {
+ STATUS = 0,
+ TAGS = 1,
+ EDIT = 2,
+ SCROLL = 3,
+ NREGIONS = 4,
+ FOCUSED = 4
+} WinRegion;
+
+typedef struct {
+ int mods;
+ Rune key;
+ void (*action)(void);
+} KeyBinding;
+
+typedef struct {
+ size_t x;
+ size_t y;
+ size_t height;
+ size_t width;
+ size_t csrx;
+ size_t csry;
+ bool warp_ptr;
+ View view;
+} Region;
+
+typedef void (*MouseFunc)(WinRegion id, size_t count, size_t row, size_t col);
+
+typedef struct {
+ MouseFunc left;
+ MouseFunc middle;
+ MouseFunc right;
+} MouseConfig;
+
+void win_init(char* name);
+void win_loop(void);
+void win_settext(WinRegion id, char* text);
+void win_setruler(size_t ruler);
+void win_setkeys(KeyBinding* bindings);
+void win_setmouse(MouseConfig* mconfig);
+void win_warpptr(WinRegion id);
+View* win_view(WinRegion id);
+Buf* win_buf(WinRegion id);
+Sel* win_sel(WinRegion id);
+bool win_btnpressed(MouseBtn btn);
+WinRegion win_getregion(void);
+void win_setregion(WinRegion id);
+void win_setscroll(double offset, double visible);
+
+/* These functions must be implemented by any appliation that wishes
+ to use this module */
+void onupdate(void);
+void onscroll(double percent);
+void onmouseleft(WinRegion id, size_t count, size_t row, size_t col);
+void onmousemiddle(WinRegion id, size_t count, size_t row, size_t col);
+void onmouseright(WinRegion id, size_t count, size_t row, size_t col);
+
static void onwheelup(WinRegion id, size_t count, size_t row, size_t col);
static void onwheeldn(WinRegion id, size_t count, size_t row, size_t col);
+static size_t Ruler = 0;
static double ScrollOffset = 0.0;
static double ScrollVisible = 1.0;
static XFont Font;
buf_logclear(&(view->buffer));
}
+void win_setruler(size_t ruler) {
+ Ruler = ruler;
+}
+
void win_setkeys(KeyBinding* bindings) {
Keys = bindings;
}
x11_draw_rect((i == TAGS ? CLR_BASE02 : CLR_BASE03),
0, Regions[i].y - 3, width, Regions[i].height + 8);
x11_draw_rect(CLR_BASE01, 0, Regions[i].y - 3, width, 1);
+ if ((i == EDIT) && (Ruler != 0))
+ x11_draw_rect(CLR_BASE02, (Ruler+1) * fwidth, Regions[i].y-2, 1, Regions[i].height+7);
for (size_t y = 0; y < view->nrows; y++) {
Row* row = view_getrow(view, y);
draw_glyphs(Regions[i].x, Regions[i].y + ((y+1) * fheight), row->cols, row->rlen, row->len);