view_init(&(Regions[i].view), NULL, errfn);
x11_init(&Config);
Font = x11_font_load(config_get_str(FontString));
- Regions[STATUS].clrnor = config_get_int(ClrStatusNor);
Regions[SCROLL].clrnor = config_get_int(ClrScrollNor);
Regions[TAGS].clrnor = config_get_int(ClrTagsNor);
Regions[TAGS].clrsel = config_get_int(ClrTagsSel);
static void layout(int width, int height) {
size_t fheight = x11_font_height(Font);
size_t fwidth = x11_font_width(Font);
- View* statview = win_view(STATUS);
View* tagview = win_view(TAGS);
View* editview = win_view(EDIT);
Regions[i].height = fheight;
}
- /* place the status region */
- view_resize(statview, 1, Regions[STATUS].width / fwidth);
-
/* Place the tag region relative to status */
- Regions[TAGS].y = 5 + Regions[STATUS].y + Regions[STATUS].height;
size_t maxtagrows = ((height - Regions[TAGS].y - 5) / 4) / fheight;
size_t tagcols = Regions[TAGS].width / fwidth;
size_t tagrows = view_limitrows(tagview, maxtagrows, tagcols);
layout(width, height);
onupdate(); // Let the user program update the status and other content
- view_update(win_view(STATUS), Regions[STATUS].clrnor, Regions[STATUS].clrsel, &(Regions[STATUS].csrx), &(Regions[STATUS].csry));
view_update(win_view(TAGS), Regions[TAGS].clrnor, Regions[TAGS].clrsel, &(Regions[TAGS].csrx), &(Regions[TAGS].csry));
view_update(win_view(EDIT), Regions[EDIT].clrnor, Regions[EDIT].clrsel, &(Regions[EDIT].csrx), &(Regions[EDIT].csry));
onlayout(); // Let the user program update the scroll bar
#ifndef TEST
int main(int argc, char** argv) {
- char* title = getenv("PICKTITLE");
load_choices();
if (vec_size(&Choices) > 1) {
win_window("pick", true, onerror);
win_setkeys(Bindings, NULL);
- win_settext(STATUS, (title ? title : "pick"));
if (argc >= 2) {
for (char* str = argv[1]; *str; str++)
buf_insert(win_buf(TAGS), false, Pos++, *str);
}
void onupdate(void) {
- static char status_bytes[256];
- memset(status_bytes, 0, sizeof(status_bytes));
- char* status = status_bytes;
- Buf* buf = win_buf(EDIT);
- *(status++) = (buf->charset == BINARY ? 'B' : 'U');
- *(status++) = (buf->crlf ? 'C' : 'N');
- *(status++) = (buf->expand_tabs ? 'S' : 'T');
- *(status++) = (buf->copy_indent ? 'I' : 'i');
- *(status++) = (SearchDir < 0 ? '<' : '>');
- *(status++) = (buf->modified ? '*' : ' ');
- *(status++) = ' ';
- size_t remlen = sizeof(status_bytes) - strlen(status_bytes) - 1;
- if (pty_active()) {
- char* path = getcurrdir();
- strncat(status, path, remlen);
- free(path);
- } else {
- char* path = (buf->path ? buf->path : "*scratch*");
- strncat(status, path, remlen);
- }
- win_settext(STATUS, status_bytes);
- win_view(STATUS)->selection = (Sel){0,0,0};
}
void onlayout(void) {