bool edlib_testing(struct pane *p safe)
{
- struct ed_info *ei = &pane_root(p)->data;
+ struct ed_info *ei = pane_root(p)->data;
return ei->testing;
}
DEF_CMD(global_set_command)
{
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
struct map *map = ei->map;
bool prefix = strcmp(ci->key, "global-set-command-prefix") == 0;
DEF_CMD(global_get_command)
{
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
struct map *map = ei->map;
struct command *cm;
#endif
DEF_CMD(editor_load_module)
{
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
struct map *map = ei->map;
const char *name = ci->str;
char buf[PATH_MAX];
* have to use key_lookup_prefix to find them.
* If nothing is found, autoload lib-libevent (hack?)
*/
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
struct map *map = ei->map;
int ret = key_lookup_prefix(map, ci);
DEF_CMD(editor_multicall)
{
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
struct map *map = ei->map;
int ret;
const char *key = ci->key;
DEF_CMD(editor_free_panes)
{
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
while (ei->freelist) {
struct pane *p = ei->freelist;
DEF_CMD(editor_free_marks)
{
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
while (ei->mark_free_list) {
struct mark *m = ei->mark_free_list;
DEF_CMD(editor_free_store)
{
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
while (ei->store) {
struct store *s = ei->store;
DEF_CMD(editor_close)
{
- struct ed_info *ei = &ci->home->data;
+ struct ed_info *ei = ci->home->data;
stat_free();
free(ei->here); ei->here = NULL;
free(ei->data_path); ei->data_path = NULL;
struct ed_info *ei;
p = pane_root(p);
- ei = &p->data;
+ ei = p->data;
ASSERT(ei->magic==ED_MAGIC);
if (!ei->store)
call_comm("event:on-idle", p, &editor_free_store, 2);
void editor_delayed_free(struct pane *ed safe, struct pane *p safe)
{
- struct ed_info *ei = &ed->data;
+ struct ed_info *ei = ed->data;
if (!ei) {
p->damaged &= ~DAMAGED_DEAD;
pane_call(p, "Free", p);
void editor_delayed_mark_free(struct mark *m safe)
{
struct pane *ed = pane_root(m->owner);
- struct ed_info *ei = &ed->data;
+ struct ed_info *ei = ed->data;
ASSERT(ei->magic==ED_MAGIC);
if (!ei->mark_free_list)
static char *set_here(struct pane *p safe)
{
- struct ed_info *ei = &p->data;
+ struct ed_info *ei = p->data;
Dl_info info;
if (ei->here)
static char *set_data_path(struct pane *p safe)
{
- struct ed_info *ei = &p->data;
+ struct ed_info *ei = p->data;
char *dh, *dd, *here;
struct buf b;
static char *set_config_path(struct pane *p safe)
{
- struct ed_info *ei = &p->data;
+ struct ed_info *ei = p->data;
char *ch, *cd, *here;
struct buf b;
static char *set_bin_path(struct pane *p safe)
{
- struct ed_info *ei = &p->data;
+ struct ed_info *ei = p->data;
char *bd, *here;
struct buf b;
ed = pane_register_root(&ed_handle.c, NULL, sizeof(*ei));
if (!ed)
return NULL;
- ei = &ed->data;
+ ei = ed->data;
ei->magic = ED_MAGIC;
attr_set_str(&ed->attrs, "command-name", comm_name ?: "edlib");
ei->testing = (getenv("EDLIB_TESTING") != NULL);
DEF_CMD(log_append)
{
- struct log *l = &ci->home->doc_data;
+ struct log *l = ci->home->doc_data;
struct logbuf *b;
unsigned int len;
DEF_CMD(log_content)
{
- struct log *log = &ci->home->doc_data;
+ struct log *log = ci->home->doc_data;
struct mark *from = ci->mark, *to = ci->mark2;
struct mark *m;
struct logbuf *b, *first, *last;
DEF_CMD(log_set_ref)
{
- struct log *log = &ci->home->doc_data;
+ struct log *log = ci->home->doc_data;
struct mark *m = ci->mark;
if (!m)
static inline wint_t log_next(struct pane *p safe, struct doc_ref *r safe, bool bytes)
{
- struct log *log = &p->doc_data;
+ struct log *log = p->doc_data;
wint_t ret;
if (!r->b)
static inline wint_t log_prev(struct pane *p safe, struct doc_ref *r safe, bool bytes)
{
- struct log *log = &p->doc_data;
+ struct log *log = p->doc_data;
const char *s;
if (list_empty(&log->log))
DEF_CMD(log_val_marks)
{
/* mark1 and mark2 must be correctly ordered */
- struct log *log = &ci->home->doc_data;
+ struct log *log = ci->home->doc_data;
struct logbuf *b;
int found = 0;
DEF_CMD(log_close)
{
- struct log *l = &ci->home->doc_data;
+ struct log *l = ci->home->doc_data;
while (!list_empty(&l->log)) {
struct logbuf *b = list_first_entry(&l->log, struct logbuf, h);
p = doc_register(ci->focus, &log_handle.c);
if (!p)
return Efail;
- l = &p->doc_data;
+ l = p->doc_data;
INIT_LIST_HEAD(&l->log);
attr_set_str(&p->attrs, "render-default", "text");
attr_set_str(&p->attrs, "doc-type", "text");
log_pane = doc_register(ed, &log_handle.c);
if (!log_pane)
return;
- log_doc = &log_pane->doc_data;
+ log_doc = log_pane->doc_data;
INIT_LIST_HEAD(&log_doc->log);
fname = getenv("EDLIB_LOG");
union {
struct doc doc;
#ifdef PANE_DATA_TYPE
- PANE_DATA_TYPE data;
+ PANE_DATA_TYPE data[1];
#else
void *data safe;
#endif
#ifdef DOC_DATA_TYPE
- DOC_DATA_TYPE doc_data;
+ DOC_DATA_TYPE doc_data[1];
#endif
void *_data;
};
DEF_CMD(selection_claim)
{
- struct window_data *wd = &ci->home->data;
+ struct window_data *wd = ci->home->data;
if (wd->sel_owner && wd->sel_owner != ci->focus) {
call("Notify:selection:claimed", wd->sel_owner);
DEF_CMD(selection_commit)
{
- struct window_data *wd = &ci->home->data;
+ struct window_data *wd = ci->home->data;
if (wd->sel_owner && !wd->sel_committed) {
if (call("Notify:selection:commit", wd->sel_owner) != 2)
DEF_CMD(selection_discard)
{
- struct window_data *wd = &ci->home->data;
+ struct window_data *wd = ci->home->data;
struct pane *op, *fp;
if (!wd->sel_owner)
DEF_CMD(close_notify)
{
- struct window_data *wd = &ci->home->data;
+ struct window_data *wd = ci->home->data;
if (wd->sel_owner_fallback == ci->focus)
wd->sel_owner_fallback = NULL;
current_screen = NULL;
return;
}
- dd = &p->data;
+ dd = p->data;
current_dd = dd;
if (!dd)
return;
static bool parse_event(struct pane *p safe);
static bool prepare_recrep(struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
char *name;
name = getenv("EDLIB_RECORD");
static void close_recrep(struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
if (dd->log) {
fprintf(dd->log, "Close %d\n", dd->clears);
static void record_key(struct pane *p safe, char *key safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
char q;
if (!dd->log)
static void record_mouse(struct pane *p safe, char *key safe, int x, int y)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
char q;
if (!dd->log)
return;
static void record_screen(struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
struct md5_state ctx;
uint16_t buf[CCHARW_MAX+5];
char out[MD5_DIGEST_SIZE*2+1];
static bool parse_event(struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
char line[80];
line[79] = 0;
REDEF_CMD(next_evt)
{
struct pane *p = ci->home;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
int button = 0, type = 0;
dd->input_sleeping = 0;
DEF_CB(ns_resume)
{
- struct display_data *dd = &ci->home->data;
+ struct display_data *dd = ci->home->data;
if (dd->suspended) {
dd->suspended = False;
DEF_CMD(nc_external_viewer)
{
struct pane *p = ci->home;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
char *disp = pane_attr_get(p, "DISPLAY");
char *disp_auth = pane_attr_get(p, "XAUTHORITY");
char *remote = pane_attr_get(p, "REMOTE_SESSION");
static void ncurses_stop(struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
if (dd->is_xterm) {
/* disable bracketed-paste */
static void ncurses_end(struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
if (dd->did_close)
return;
static int cvt_attrs(struct pane *p safe, struct pane *home safe,
const char *attrs, int *pairp safe, bool use_parent)
{
- struct display_data *dd = &home->data;
+ struct display_data *dd = home->data;
int attr = 0;
const char *a, *v;
char *col = NULL;
DEF_CMD(nc_notify_display)
{
- struct display_data *dd = &ci->home->data;
+ struct display_data *dd = ci->home->data;
comm_call(ci->comm2, "callback:display", ci->home, dd->last_event);
return 1;
}
DEF_CMD(nc_close)
{
struct pane *p = ci->home;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
ncurses_end(p);
hash_free(dd);
fclose(dd->scr_file);
DEF_CMD(nc_clear)
{
struct pane *p = ci->home;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
cchar_t cc = {};
int pair = 0;
int attr = cvt_attrs(ci->focus, p, ci->str, &pair, ci->str == NULL);
* 'y' will fit down.
*/
struct pane *p = ci->home;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
int x = 0, y = 0;
bool stretch = ci->num & 16;
int pos = ci->num;
DEF_CMD(nc_refresh_post)
{
struct pane *p = ci->home;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
struct pane *p1;
PANEL *pan, *pan2;
static void ncurses_start(struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
int rows, cols;
start_color();
p = pane_register(ed, 1, &ncurses_handle.c);
if (!p)
return NULL;
- dd = &p->data;
+ dd = p->data;
dd->scr = scr;
dd->scr_file = f;
dd->is_xterm = (term && strstarts(term, "xterm"));
REDEF_CMD(handle_winch)
{
struct pane *p = ci->home;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
struct winsize size;
ioctl(fileno(dd->scr_file), TIOCGWINSZ, &size);
set_screen(p);
static void send_key(int keytype, wint_t c, int alt, struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
char *n;
char buf[100];/* FIXME */
char t[5];
int button, char *mod, int type)
{
int ret;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
record_mouse(p, cmd, x, y);
ret = call("Mouse-event", p, button, NULL, cmd, type, NULL, mod, x, y);
static void send_mouse(MEVENT *mev safe, struct pane *p safe)
{
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
int x = mev->x;
int y = mev->y;
int b;
static void paste_start(struct pane *home safe)
{
- struct display_data *dd = &home->data;
+ struct display_data *dd = home->data;
dd->paste_start = time(NULL);
buf_init(&dd->paste_buf);
static void paste_flush(struct pane *home safe)
{
- struct display_data *dd = &home->data;
+ struct display_data *dd = home->data;
if (!dd->paste_start)
return;
static bool paste_recv(struct pane *home safe, int is_keycode, wint_t ch)
{
- struct display_data *dd = &home->data;
+ struct display_data *dd = home->data;
time_t now;
if (dd->paste_start == 0)
return False;
DEF_CMD(nc_get_paste)
{
- struct display_data *dd = &ci->home->data;
+ struct display_data *dd = ci->home->data;
comm_call(ci->comm2, "cb", ci->focus,
dd->paste_start, NULL, dd->paste_latest);
REDEF_CMD(input_handle)
{
struct pane *p = ci->home;
- struct display_data *dd = &p->data;
+ struct display_data *dd = p->data;
static const char paste_seq[] = "\e[200~";
wint_t c;
int is_keycode;
static struct panes *get_pixmap(struct pane *home safe,
struct pane *p safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
struct panes **pp, *ps;
for (pp = &xd->panes; (ps = *pp) != NULL; pp = &(*pp)->next) {
DEF_CMD(xcb_external_viewer)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
const char *path = ci->str;
struct pids *p;
int pid;
DEF_CMD(xcb_fullscreen)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
xcb_client_message_event_t msg = {};
msg.response_type = XCB_CLIENT_MESSAGE;
DEF_CMD(xcb_close)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
xcb_destroy_window(xd->conn, xd->win);
kbd_free(xd);
DEF_CMD(xcb_free)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
pango_font_description_free(xd->fd);
cairo_destroy(xd->cairo);
DEF_CMD(xcb_clear)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
const char *attr = ci->str;
struct panes *src = NULL, *dest;
struct rgb bg;
DEF_CMD(xcb_text_size)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
const char *attr = ci->str2 ?: "";
const char *str = ci->str ?: "";
int scale = ci->num2;
DEF_CMD(xcb_draw_text)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
const char *str = ci->str;
const char *attr = ci->str2;
int scale = 1000;
* p->cx, p->cy of a size so that 'x' will fit across and
* 'y' will fit down.
*/
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
bool stretch = ci->num & 16;
int pos = ci->num;
int w = ci->focus->w, h = ci->focus->h;
DEF_CMD(xcb_refresh_post)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
struct panes *ps;
time_start(TIME_WINDOW);
/* FIXME: should I consider resizing the window?
* For now, just ensure we redraw everything.
*/
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
cairo_rectangle_int_t r = {
.x = 0,
.y = 0,
DEF_CMD(xcb_pane_close)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
struct panes **pp, *ps;
for (pp = &xd->panes; (ps = *pp) != NULL; pp = &(*pp)->next) {
DEF_CMD(xcb_notify_display)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
comm_call(ci->comm2, "callback:display", ci->home, xd->last_event);
return 1;
}
static void handle_button(struct pane *home safe,
xcb_button_press_event_t *be safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
bool press = (be->response_type & 0x7f) == XCB_BUTTON_PRESS;
char mod[2+2+2+1];
char key[2+2+2+9+1+1];
static void handle_motion(struct pane *home safe,
xcb_motion_notify_event_t *mne safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
xcb_query_pointer_cookie_t c;
xcb_query_pointer_reply_t *qpr;
int ret;
static void handle_focus(struct pane *home safe, xcb_focus_in_event_t *fie safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
bool in = (fie->response_type & 0x7f) == XCB_FOCUS_IN;
struct pane *p;
struct mark *pt;
static void handle_key_press(struct pane *home safe,
xcb_key_press_event_t *kpe safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
xkb_keycode_t keycode = kpe->detail;
xcb_keysym_t keysym;
xkb_keysym_t sym;
static void handle_xkb_event(struct pane *home safe,
xcb_generic_event_t *ev safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
switch (ev->pad0) {
xcb_xkb_new_keyboard_notify_event_t *nkne;
static void handle_configure(struct pane *home safe,
xcb_configure_notify_event_t *cne safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
pane_resize(home, 0, 0, cne->width, cne->height);
cairo_xcb_surface_set_size(xd->surface, cne->width, cne->height);
static void handle_expose(struct pane *home safe,
xcb_expose_event_t *ee safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
cairo_rectangle_int_t r = {
.x = ee->x,
.y = ee->y,
static void handle_client_message(struct pane *home safe,
xcb_client_message_event_t *cme safe)
{
- struct xcb_data *xd = &home->data;
+ struct xcb_data *xd = home->data;
if (cme->type == xd->atoms[a_WM_PROTOCOLS] &&
cme->format == 32 &&
DEF_CMD(xcb_input)
{
- struct xcb_data *xd = &ci->home->data;
+ struct xcb_data *xd = ci->home->data;
xcb_generic_event_t *ev;
int ret = 1;
p = pane_register(pane_root(focus), 1, &xcb_handle.c);
if (!p)
return NULL;
- xd = &p->data;
+ xd = p->data;
xd->motion_blocked = True;
xd->in_focus = True;
p = doc_register(ci->home, &dir_handle.c);
if (!p)
return Efail;
- dr = &p->doc_data;
+ dr = p->doc_data;
INIT_LIST_HEAD(&dr->ents);
dr->fname = NULL;
{
int fd = ci->num2;
const char *name = ci->str;
- struct directory *dr = &ci->home->doc_data;
+ struct directory *dr = ci->home->doc_data;
struct list_head new;
struct dir_ent *de1, *de2;
struct mark *prev, *m;
DEF_CMD(dir_revisited)
{
- struct directory *dr = &ci->home->doc_data;
+ struct directory *dr = ci->home->doc_data;
struct stat st;
if (ci->num <= 0)
{
int fd = ci->num2;
struct stat stb;
- struct directory *dr = &ci->home->doc_data;
+ struct directory *dr = ci->home->doc_data;
if (!dr->fname)
return 0;
static inline wint_t dir_next(struct pane *p safe, struct doc_ref *r safe, bool bytes)
{
- struct directory *dr = &p->doc_data;
+ struct directory *dr = p->doc_data;
struct dir_ent *d = r->d;
if (d == NULL)
static inline wint_t dir_prev(struct pane *p safe, struct doc_ref *r safe, bool bytes)
{
- struct directory *dr = &p->doc_data;
+ struct directory *dr = p->doc_data;
struct dir_ent *d = r->d;
if (d == list_first_entry(&dr->ents, struct dir_ent, lst))
DEF_CMD(dir_set_ref)
{
- struct directory *dr = &ci->home->doc_data;
+ struct directory *dr = ci->home->doc_data;
struct mark *m = ci->mark;
if (!m)
const char *attr safe)
{
- struct directory *dr = &home->doc_data;
+ struct directory *dr = home->doc_data;
struct dir_ent *de;
de = m->ref.d;
DEF_CMD(dir_get_attr)
{
- struct directory *dr = &ci->home->doc_data;
+ struct directory *dr = ci->home->doc_data;
const char *attr = ci->str;
const char *val;
DEF_CMD(dir_val_marks)
{
- struct directory *dr = &ci->home->doc_data;
+ struct directory *dr = ci->home->doc_data;
struct dir_ent *de;
int found;
DEF_CMD(dir_destroy)
{
- struct directory *dr = &ci->home->doc_data;
+ struct directory *dr = ci->home->doc_data;
while (!list_empty(&dr->ents)) {
struct dir_ent *de = list_entry(dr->ents.next,
/* This document (p) is about to be moved in the list (d->collection).
* Any mark pointing at it is moved forward
*/
- struct docs *doc = &d->doc_data;
+ struct docs *doc = d->doc_data;
struct mark *m, *first = NULL;
struct pane *next;
struct pane *col = doc->collection;
/* This document has just been added to the list.
* any mark pointing just past it is moved back.
*/
- struct docs *doc = &d->doc_data;
+ struct docs *doc = d->doc_data;
struct mark *m, *first = NULL;
struct pane *next;
struct pane *col = doc->collection;
static void doc_checkname(struct pane *p safe, struct pane *d safe, int n)
{
- struct docs *ds = &d->doc_data;
+ struct docs *ds = d->doc_data;
ASSERT(p->parent->handle == &docs_aux.c);
check_name(ds, p);
if (n) {
DEF_CMD(docs_callback_byname)
{
- struct docs *doc = &ci->home->doc_data;
+ struct docs *doc = ci->home->doc_data;
struct pane *p;
if (ci->str == NULL || strcmp(ci->str, "*Documents*") == 0)
DEF_CMD(docs_callback_byfd)
{
- struct docs *doc = &ci->home->doc_data;
+ struct docs *doc = ci->home->doc_data;
struct pane *p;
list_for_each_entry(p, &doc->collection->children, siblings) {
DEF_CMD(docs_callback_byeach)
{
- struct docs *doc = &ci->home->doc_data;
+ struct docs *doc = ci->home->doc_data;
struct pane *p;
list_for_each_entry(p, &doc->collection->children, siblings) {
DEF_CMD(docs_callback_choose)
{
- struct docs *doc = &ci->home->doc_data;
+ struct docs *doc = ci->home->doc_data;
struct pane *choice = NULL, *last = NULL;
struct pane *p;
DEF_CMD(docs_callback_saveall)
{
- struct docs *doc = &ci->home->doc_data;
+ struct docs *doc = ci->home->doc_data;
struct pane *p;
int dirlen = ci->str ? (int)strlen(ci->str) : -1;
DEF_CMD(docs_callback_modified)
{
- struct docs *doc = &ci->home->doc_data;
+ struct docs *doc = ci->home->doc_data;
struct pane *p;
p = home_call_ret(pane, ci->home, "doc:attach-view", ci->focus,
DEF_CMD(docs_callback_appeared)
{
- struct docs *doc = &ci->home->doc_data;
+ struct docs *doc = ci->home->doc_data;
struct pane *p;
/* Always return Efallthrough so other handlers get a chance */
{
struct pane *p = ci->focus;
struct pane *dp = ci->home->data;
- struct docs *docs = &dp->doc_data;
+ struct docs *docs = dp->doc_data;
if (!p)
return Einval;
static inline wint_t docs_next(struct pane *home safe, struct doc_ref *r safe, bool bytes)
{
- struct docs *d = &home->doc_data;
+ struct docs *d = home->doc_data;
struct pane *p = r->p;
if (p == NULL)
}
static inline wint_t docs_prev(struct pane *home safe, struct doc_ref *r safe, bool bytes)
{
- struct docs *d = &home->doc_data;
+ struct docs *d = home->doc_data;
struct pane *p = r->p;
if (list_empty(&d->collection->children))
DEF_CMD(docs_set_ref)
{
- struct docs *d = &ci->home->doc_data;
+ struct docs *d = ci->home->doc_data;
struct mark *m = ci->mark;
if (!m)
DEF_CMD(docs_val_marks)
{
- struct docs *d = &ci->home->doc_data;
+ struct docs *d = ci->home->doc_data;
struct pane *p;
int found;
DEF_CMD(docs_close)
{
- struct docs *docs = &ci->home->doc_data;
+ struct docs *docs = ci->home->doc_data;
call_comm("global-set-command-prefix", ci->home, &edlib_noop,
0, NULL, "docs:");
pd = doc_register(ci->home, &docs_handle.c);
if (!pd)
return Efail;
- doc = &pd->doc_data;
+ doc = pd->doc_data;
doc->doc.name = strdup("*Documents*");
paux = pane_register(ci->home, 0, &docs_aux.c, pd);
if (!paux) {
DEF_CMD(email_view_free)
{
- struct email_view *evi = &ci->home->data;
+ struct email_view *evi = ci->home->data;
free(evi->invis);
return 1;
static inline wint_t email_next(struct pane *p safe, struct mark *m safe,
struct doc_ref *r safe, bool bytes)
{
- struct email_view *evi = &p->data;
+ struct email_view *evi = p->data;
bool move = r == &m->ref;
wint_t ret;
int n = -1;
static inline wint_t email_prev(struct pane *p safe, struct mark *m safe,
struct doc_ref *r safe, bool bytes)
{
- struct email_view *evi = &p->data;
+ struct email_view *evi = p->data;
bool move = r == &m->ref;
wint_t ret;
int n = -1;
* what is invisible, marking all spacers as invisible
*/
struct pane *p = ci->home;
- struct email_view *evi = &p->data;
+ struct email_view *evi = p->data;
char *invis2 = strsave(p, evi->invis);
int i;
DEF_CMD(email_set_ref)
{
struct pane *p = ci->home;
- struct email_view *evi = &p->data;
+ struct email_view *evi = p->data;
if (!ci->mark)
return Enoarg;
DEF_CMD(email_step_part)
{
struct pane *p = ci->home;
- struct email_view *evi = &p->data;
+ struct email_view *evi = p->data;
if (!ci->mark)
return Enoarg;
{
int p;
char *v;
- struct email_view *evi = &ci->home->data;
+ struct email_view *evi = ci->home->data;
if (!ci->str || !ci->mark)
return Enoarg;
DEF_CMD(email_view_set_attr)
{
int p;
- struct email_view *evi = &ci->home->data;
+ struct email_view *evi = ci->home->data;
if (!ci->str || !ci->mark)
return Enoarg;
p = pane_register(ci->focus, 0, &email_view_handle.c);
if (!p)
return Efail;
- evi = &p->data;
+ evi = p->data;
evi->parts = n;
evi->invis = calloc(n+1, sizeof(char));
for (i = 0; i < n; i++) {
static inline wint_t list_next(struct pane *p safe, struct doc_ref *r safe, bool bytes)
{
- struct list *l = &p->doc_data;
+ struct list *l = p->doc_data;
if (r->p == NULL)
return WEOF;
static inline wint_t list_prev(struct pane *p safe, struct doc_ref *r safe, bool bytes)
{
- struct list *l = &p->doc_data;
+ struct list *l = p->doc_data;
if (r->p == list_first_entry_or_null(&l->content, struct elmnt, list))
return WEOF;
DEF_CMD(list_set_ref)
{
- struct list *l = &ci->home->doc_data;
+ struct list *l = ci->home->doc_data;
struct mark *m = ci->mark;
if (!m)
DEF_CMD(list_add_elmnt)
{
- struct list *l = &ci->home->doc_data;
+ struct list *l = ci->home->doc_data;
struct mark *m = ci->mark;
struct elmnt *e;
DEF_CMD(list_sort)
{
- struct list *l = &ci->home->doc_data;
+ struct list *l = ci->home->doc_data;
struct mark *m;
if (!ci->str)
p = doc_register(ci->home, &list_handle.c);
if (!p)
return Efail;
- l = &p->doc_data;
+ l = p->doc_data;
INIT_LIST_HEAD(&l->content);
return comm_call(ci->comm2, "callback:doc", p);
DEF_CMD(list_close)
{
- struct list *l = &ci->home->doc_data;
+ struct list *l = ci->home->doc_data;
struct elmnt *e;
while ((e = list_first_entry_or_null(&l->content,
DEF_CMD(mp_close)
{
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
int i;
struct mark *m;
DEF_CMD(mp_free)
{
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
free(mpi->parts);
return 1;
DEF_CMD(mp_set_ref)
{
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
const char *vis = ci->str && (int)strlen(ci->str) >= mpi->nparts ?
ci->str : NULL;
int ret = 1;
int forward, bool bytes, const char *str)
{
int move = r == &mark->ref;
- struct mp_info *mpi = &home->doc_data;
+ struct mp_info *mpi = home->doc_data;
struct mark *m1 = NULL;
struct mark *m = mark;
const char *vis = str && (int)strlen(str) >= mpi->nparts ?
* Return part number plus 1.
* If ->str is given, only consider visible parts.
*/
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
struct mark *m = ci->mark;
const char *vis = ci->str && (int)strlen(ci->str) >= mpi->nparts ?
ci->str : NULL;
/* Call doc:content on any visible docs in the range.
* Callback must re-wrap any marks
*/
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
struct mp_cb cb;
struct mark *m, *m2;
const char *invis = ci->str;
DEF_CMD(mp_attr)
{
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
struct mark *m1 = NULL;
struct part *p;
int ret = Efallthrough;
DEF_CMD(mp_set_attr)
{
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
struct part *p;
struct mark *m = ci->mark;
struct mark *m1;
/* sub-document has been closed.
* Can we survive? or should we just shut down?
*/
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
int i;
for (i = 0; i < mpi->nparts; i++)
DEF_CMD(mp_add)
{
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
struct mark *m;
int n;
DEF_CMD(mp_forward_by_num)
{
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
struct mark *m1 = NULL, *m2 = NULL;
struct part *p;
const char *key;
DEF_CMD(mp_get_part)
{
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
struct part *p;
int d = ci->num;
* ci->mark2.
* ci->mark is forwarded if it is in same document
*/
- struct mp_info *mpi = &ci->home->doc_data;
+ struct mp_info *mpi = ci->home->doc_data;
struct part *p;
struct mark *m1, *m2;
const char *key;
h = doc_register(ci->home, &mp_handle.c);
if (!h)
return Efail;
- mpi = &h->doc_data;
+ mpi = h->doc_data;
mpi->doc.refcnt = mp_mark_refcnt;
attr_set_str(&h->attrs, "render-default", "text");
static bool check_file_changed(struct pane *p safe)
{
- struct text *t = &p->doc_data;
+ struct text *t = p->doc_data;
struct stat st;
if (t->file_changed)
DEF_CMD(text_readonly)
{
struct doc *d = ci->home->data;
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
if (t->file_changed && !d->readonly && ci->num)
t->file_changed = 2;
struct text_alloc *a;
struct text_chunk *c = NULL;
int len;
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
if (t->saved != t->undo)
return Einval;
DEF_CMD(text_insert_file)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
struct mark *pm = ci->mark, *early;
struct text_alloc *a;
int len;
static bool do_text_output_file(struct pane *p safe, struct doc_ref *start,
struct doc_ref *end, int fd)
{
- struct text *t = &p->doc_data;
+ struct text *t = p->doc_data;
struct text_chunk *c;
int offset = 0;
* Create a temp file with #basename#~, write to that,
* copy mode across, fsync and then rename
*/
- struct text *t = &p->doc_data;
+ struct text *t = p->doc_data;
char *tempname = malloc(strlen(fname) + 3 + 10);
const char *base;
char *tbase;
static void do_text_autosave(struct pane *p safe)
{
- struct text *t = &p->doc_data;
+ struct text *t = p->doc_data;
int fd = -1;
if (!t->fname)
static void text_check_autosave(struct pane *p safe)
{
- struct text *t = &p->doc_data;
+ struct text *t = p->doc_data;
if (t->undo == t->saved)
t->as.changes = 0;
DEF_CMD(text_save_file)
{
struct doc *d = ci->home->data;
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
int ret;
char *msg;
int change_status = 0;
DEF_CMD(text_same_file)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
struct stat stb, stb2;
int fd = ci->num2;
static bool check_readonly(const struct cmd_info *ci safe)
{
struct doc *d = ci->home->data;
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
if (t->undo == t->saved &&
check_file_changed(ci->home) &&
struct text_edit *ed = NULL;
bool first = 1;
int status;
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
if (!m)
return Enoarg;
static inline wint_t text_next(struct pane *p safe, struct doc_ref *r safe, bool bytes)
{
- struct text *t = &p->doc_data;
+ struct text *t = p->doc_data;
wint_t ret = WERR;
const char *c;
static inline wint_t text_prev(struct pane *p safe, struct doc_ref *r safe, bool bytes)
{
- struct text *t = &p->doc_data;
+ struct text *t = p->doc_data;
wint_t ret;
const char *c;
p = doc_register(ci->home, &text_handle.c);
if (!p)
return Efail;
- t = &p->doc_data;
+ t = p->doc_data;
t->alloc = safe_cast NULL;
INIT_LIST_HEAD(&t->text);
t->saved = t->undo = t->redo = NULL;
{
struct mark *from = ci->mark, *to = ci->mark2;
struct mark *m;
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
struct text_chunk *c, *first, *last;
int bytes = strcmp(ci->key, "doc:content-bytes") == 0;
int l = 0, head, tail;
DEF_CMD(text_val_marks)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
struct text_chunk *c;
int found;
DEF_CMD(text_set_ref)
{
struct mark *m = ci->mark;
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
if (!m)
return Enoarg;
*/
if (ref->c != target->c && (!ref->c || ref->o <= ref->c->start))
- if (text_prev(safe_cast container_of(t, struct pane, doc_data), ref, 1) == WEOF)
+ if (text_prev(safe_cast container_of(t, struct pane, doc_data[0]), ref, 1) == WEOF)
return 0;
if (ref->c == target->c) {
DEF_CMD(text_replace)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
struct mark *pm = ci->mark2;
struct mark *end = ci->mark;
const char *str = ci->str;
int *op safe)
{
struct text_chunk *c;
- struct text *t = &p->doc_data;
+ struct text *t = p->doc_data;
unsigned int o;
c = m->ref.c;
DEF_CMD(text_get_attr)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
const char *attr = ci->str;
const char *val;
const char *attr = ci->str;
const char *val = ci->str2;
struct text_chunk *c, *c2;
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
unsigned int o, o2;
if (!attr)
DEF_CMD(text_modified)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
if (ci->num == 0) {
/* toggle status */
DEF_CMD(text_revisited)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
if (ci->num <= 0)
/* Being buried, not visited */
DEF_CMD(text_destroy)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
text_cleanout(t);
return Efallthrough;
/* Clear the document, including undo/redo records
* i.e. free all text
*/
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
struct mark *m;
text_cleanout(t);
DEF_CMD(text_free)
{
- struct text *t = &ci->home->doc_data;
+ struct text *t = ci->home->doc_data;
free((void*)t->fname);
free((void*)t->autosave_name);
DEF_CMD(askpass_refresh_view)
{
struct buf b;
- struct apinfo *ai = &ci->home->data;
+ struct apinfo *ai = ci->home->data;
int shift = 0;
int i;
DEF_CMD(askpass_key)
{
const char *k = ksuffix(ci, "K-");
- struct apinfo *ai = &ci->home->data;
+ struct apinfo *ai = ci->home->data;
buf_concat(&ai->b, k);
pane_damaged(ci->home, DAMAGED_VIEW);
DEF_CMD(askpass_bs)
{
- struct apinfo *ai = &ci->home->data;
+ struct apinfo *ai = ci->home->data;
if (ai->b.len > 0)
ai->b.len = utf8_round_len(ai->b.b, ai->b.len-1);
DEF_CMD(askpass_done)
{
- struct apinfo *ai = &ci->home->data;
+ struct apinfo *ai = ci->home->data;
comm_call(ai->c, "cb", ci->focus, ai->b.len, NULL,
buf_final(&ai->b));
DEF_CMD(askpass_abort)
{
- struct apinfo *ai = &ci->home->data;
+ struct apinfo *ai = ci->home->data;
memset(ai->b.b, 0, ai->b.size);
comm_call(ai->c, "cb", ci->focus, -1);
attr_set_str(&p->attrs, "pane-title", "Ask Password");
- p->data.msg = strdup(ci->str);
- p->data.c = command_get(ci->comm2);
- buf_init(&p->data.b);
+ p->data->msg = strdup(ci->str);
+ p->data->c = command_get(ci->comm2);
+ buf_init(&p->data->b);
pane_damaged(p, DAMAGED_VIEW);
return 1;
DEF_CMD(askpass_close)
{
- struct apinfo *ai = &ci->home->data;
+ struct apinfo *ai = ci->home->data;
free(ai->msg);
ai->msg = safe_cast NULL;
DEF_CMD(crop_close)
{
- struct crop_data *cd = &ci->home->data;
+ struct crop_data *cd = ci->home->data;
mark_free(cd->start);
mark_free(cd->end);
DEF_CMD(crop_write)
{
struct pane *p = ci->home->parent;
- struct crop_data *cd = &ci->home->data;
+ struct crop_data *cd = ci->home->data;
return home_call(p, ci->key, ci->focus, ci->num,
ci->mark ?: cd->start,
struct doc_ref *r, bool bytes)
{
struct pane *p = home->parent;
- struct crop_data *cd = &home->data;
+ struct crop_data *cd = home->data;
int move = r == &mark->ref;
int ret;
struct doc_ref *r, bool bytes)
{
struct pane *p = home->parent;
- struct crop_data *cd = &home->data;
+ struct crop_data *cd = home->data;
int move = r == &mark->ref;
int ret;
DEF_CMD(crop_clip)
{
- struct crop_data *cd = &ci->home->data;
+ struct crop_data *cd = ci->home->data;
mark_clip(cd->start, ci->mark, ci->mark2, !!ci->num);
mark_clip(cd->end, ci->mark, ci->mark2, !!ci->num);
DEF_CMD(crop_content)
{
- struct crop_data *cd = &ci->home->data;
+ struct crop_data *cd = ci->home->data;
struct mark *m, *m2;
int ret;
DEF_CMD(crop_generic)
{
struct pane *p = ci->home->parent;
- struct crop_data *cd = &ci->home->data;
+ struct crop_data *cd = ci->home->data;
int ret;
if (!ci->mark && !ci->mark2)
if (!p)
return Efail;
- cd = &p->data;
+ cd = p->data;
cd->start = mark_dup(ci->mark);
cd->end = mark_dup(ci->mark2);
int splitpos, int len,
int maxwidth)
{
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
struct call_return cr;
char tb[] = " ";
char *str = rd->line + ri->start + splitpos;
char *str safe,
const char *attr)
{
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
return call_ret(all, "Draw:text-size", p,
-1, NULL, str,
int offset,
int x, int y)
{
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
char tmp;
char *str;
int len;
char *str safe,
int x, int y)
{
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
home_call(focus, "Draw:text", p,
-1, NULL, str,
* 3 if both.
* 0 if neither
*/
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
struct render_item *ri, *wraprl;
int shift_left = pane_attr_get_int(focus, "render-wrap", -1);
bool wrap = shift_left < 0;
static void draw_line(struct pane *p safe, struct pane *focus safe, int offset)
{
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
struct render_item *ri;
char *wrap_tail = rd->wrap_tail ?: "\\";
char *wrap_head = rd->wrap_head ?: "";
* We do not consider the eol render_item
*/
struct call_return cr;
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
struct render_item *r, *ri = NULL;
int splitpos = 0;
int start = 0;
struct xy xy = {0,0};
int split;
int st;
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
struct render_item *r, *ri = NULL;
for (r = rd->content; r; r = r->next) {
int dodraw,
int offset, int want_xypos, short x, short y)
{
- struct rline_data *rd = &p->data;
+ struct rline_data *rd = p->data;
char *fname = NULL;
const char *orig_line = line;
short width, height;
DEF_CMD(renderline_draw)
{
- struct rline_data *rd = &ci->home->data;
+ struct rline_data *rd = ci->home->data;
struct xy xy;
int offset = -1;
DEF_CMD(renderline_refresh)
{
- struct rline_data *rd = &ci->home->data;
+ struct rline_data *rd = ci->home->data;
int offset = -1;
if (rd->curspos >= 0)
DEF_CMD(renderline_measure)
{
- struct rline_data *rd = &ci->home->data;
+ struct rline_data *rd = ci->home->data;
int ret;
if (rd->image)
DEF_CMD(renderline_findxy)
{
- struct rline_data *rd = &ci->home->data;
+ struct rline_data *rd = ci->home->data;
const char *xyattr = NULL;
int pos;
DEF_CMD(renderline_get)
{
- struct rline_data *rd = &ci->home->data;
+ struct rline_data *rd = ci->home->data;
char buf[20];
const char *val = buf;
DEF_CMD(renderline_set)
{
- struct rline_data *rd = &ci->home->data;
+ struct rline_data *rd = ci->home->data;
const char *old = rd->line;
char *prefix = pane_attr_get(ci->focus, "prefix");
bool word_wrap = pane_attr_get_int(ci->focus, "word-wrap", 0) != 0;
DEF_CMD(renderline_close)
{
- struct rline_data *rd = &ci->home->data;
+ struct rline_data *rd = ci->home->data;
struct render_item *ri = rd->content;
free((void*)rd->line);
p = pane_register(ci->focus, ci->num, &renderline_handle.c);
if (!p)
return Efail;
- rd = &p->data;
+ rd = p->data;
rd->line = strdup(ETX); // Imposible string
return comm_call(ci->comm2, "cb", p);
DEF_CMD(format_free)
{
- struct rf_data *rf = &ci->home->data;
+ struct rf_data *rf = ci->home->data;
free(rf->attr_cache);
free(rf->fields);
struct mark *m safe, int field,
const char **valp safe)
{
- struct rf_data *rd = &home->data;
+ struct rf_data *rd = home->data;
struct rf_field *rf;
const char *val;
int l;
static int normalize(struct pane *home safe, struct pane *focus safe,
struct mark *m safe, int inc)
{
- struct rf_data *rd = &home->data;
+ struct rf_data *rd = home->data;
int index = m->ref.i;
unsigned short f = FIELD_NUM(index);
unsigned short o = FIELD_OFFSET(index);
static void prev_line(struct pane *home safe, struct mark *m safe)
{
- struct rf_data *rd = &home->data;
+ struct rf_data *rd = home->data;
/* Move m to end of previous line, just before the newline */
if (doc_prev(home->parent, m) == WEOF) {
static void next_line(struct pane *home safe, struct mark *m safe)
{
- struct rf_data *rd = &home->data;
+ struct rf_data *rd = home->data;
doc_next(home->parent, m);
update_offset(m, rd, MAKE_INDEX(0, 0));
struct mark *m safe, struct doc_ref *r safe,
int forward, bool bytes)
{
- struct rf_data *rd = &home->data;
+ struct rf_data *rd = home->data;
struct rf_field *rf;
int move = r == &m->ref;
int f, o;
*/
struct pane *home = ci->home;
struct pane *focus = ci->focus;
- struct rf_data *rd = &home->data;
+ struct rf_data *rd = home->data;
struct rf_field *rf;
struct mark *m = ci->mark;
struct mark *end = ci->mark2;
* Also "format:plain" which formats the line directly
* without the cost of all the lib-markup machinery.
*/
- struct rf_data *rd = &ci->home->data;
+ struct rf_data *rd = ci->home->data;
struct mark *m = ci->mark;
int previ;
int f0, f;
DEF_CMD(format_map)
{
- struct rf_data *rd = &ci->home->data;
+ struct rf_data *rd = ci->home->data;
struct mark *m = ci->mark;
int idx, previ;
int f0, f;
DEF_CMD(render_line_prev2)
{
- struct rf_data *rd = &ci->home->data;
+ struct rf_data *rd = ci->home->data;
struct mark *m = ci->mark;
struct mark *m2, *mn;