commit - 51dc2fa43014052f22b32332d00829ada9c52b3f
commit + 72b1826897c1396d069eb29216fbcb0414439255
blob - 3ba4d3e4d8e9345a1655de012dc96fc5d3e8e706
blob + c25d777832e3a2caecad4b8b79c6f5a9e2423251
--- ChangeLog
+++ ChangeLog
2021-06-19 Omar Polo <op@omarpolo.com>
+ * defaults.c (config_setvari): added olivetti-mode!
+
* fs.c (load_last_session): load about:help during the first startup
* pages.c: added about:about, about:blank and about:help pages
blob - 545355ce305ae31951d0f567dfa7458c9e3c1300
blob + 50d7b4cc73d328e088739e38f6ae9357a2279ed6
--- defaults.c
+++ defaults.c
char *new_tab_url = NULL;
int fill_column = INT_MAX;
+int olivetti_mode = 0;
struct lineprefix line_prefixes[] = {
[LINE_TEXT] = { "", "" },
if (!strcmp(var, "fill-column")) {
if (val > 0)
fill_column = val;
+ } else if (!strcmp(var, "olivetti-mode")) {
+ olivetti_mode = !!val;
} else
return 0;
return 1;
blob - 205c9652b75da5595fa21d5826b53e1fde9c3363
blob + d56d1135ac820f016d1e15baa26b4149dfc2dd73
--- telescope.h
+++ telescope.h
extern char *new_tab_url;
extern int fill_column;
+extern int olivetti_mode;
struct lineprefix {
const char *prfx1;
blob - ca480f95f4709c7ea8e9873866bd689ffc199b00
blob + 7570f977147d4f3f4b165b68af02858df87ecea6
--- ui.c
+++ ui.c
static void session_new_tab_cb(const char*);
static void usage(void);
+static int x_offset;
+
static struct { short meta; int key; uint32_t cp; } thiskey;
static struct event resizeev;
struct hist *hist_cur;
size_t hist_off;
} ministate;
+
+static inline void
+update_x_offset()
+{
+ if (olivetti_mode && fill_column < body_cols)
+ x_offset = (body_cols - fill_column)/2;
+ else
+ x_offset = 0;
+}
static inline void
global_set_key(const char *key, void (*fn)(struct buffer*))
else
buffer->curs_x = utf8_snwidth(vl->line, buffer->cpoff);
+ buffer->curs_x += x_offset;
+
if (vl != NULL) {
prfx = line_prefixes[vl->parent->type].prfx1;
buffer->curs_x += utf8_swidth(prfx);
} else
mvwin(body, 1, 0);
+ update_x_offset();
wresize(body, body_lines, body_cols);
wresize(tabline, 1, COLS);
struct line *l;
const struct line *orig;
struct vline *vl;
+ int pre_width;
const char *prfx;
orig = buffer->current_line == NULL
wrap_text(buffer, prfx, l, MIN(fill_column, width));
break;
case LINE_PRE_CONTENT:
- hardwrap_text(buffer, l, width);
+ if (olivetti_mode)
+ pre_width = MIN(fill_column, width);
+ else
+ pre_width = width;
+ hardwrap_text(buffer, l, pre_width);
break;
}
l = 0;
vl = nth_line(buffer, buffer->line_off);
for (; vl != NULL; vl = TAILQ_NEXT(vl, vlines)) {
- wmove(win, l, 0);
+ wmove(win, l, x_offset);
print_vline(win, vl);
l++;
if (l == height)
redraw_help();
wnoutrefresh(help);
}
+
+ restore_cursor(&tab->buffer);
redraw_tabline();
redraw_body(tab);
body_lines = LINES-3;
body_cols = COLS;
+
+ update_x_offset();
keypad(body, TRUE);
scrollok(body, TRUE);