x11_flush();
}
+void win_load(char* path) {
+ View* view = win_view(EDIT);
+ view_init(view, path, view->buffer.errfn);
+}
+
+void win_save(char* path) {
+ View* view = win_view(EDIT);
+ if (!path) path = view->buffer.path;
+ if (!path) return;
+ path = stringdup(path);
+ free(view->buffer.path);
+ view->buffer.path = path;
+ buf_save(&(view->buffer));
+}
+
void win_loop(void) {
x11_show();
x11_flip();
char* title = getenv("PICKTITLE");
load_choices();
if (vec_size(&Choices) > 1) {
- win_dialog("pick", true, onerror);
+ win_window("pick", true, onerror);
win_setkeys(Bindings, NULL);
win_settext(STATUS, (title ? title : "pick"));
if (argc >= 2) {
static void overwrite(void) {
trim_whitespace();
- buf_save(win_buf(EDIT));
+ win_save(NULL);
}
static void save(void) {
/* Keyboard Handling
******************************************************************************/
static void saveas(char* arg) {
- //win_saveas(stringdup(arg));
- if (arg) {
- char* path = win_buf(EDIT)->path;
- win_buf(EDIT)->path = stringdup(arg);
- buf_save(win_buf(EDIT));
- free(path);
- }
+ win_save(arg);
}
static void tag_undo(void) {
else
strconcat(currpath, fname, 0);
chdir(currdir);
- //win_open(currpath, ondiagmsg);
- view_init(win_view(EDIT), currpath, ondiagmsg);
+ win_load(currpath);
} else {
chdir(origdir);
- //win_open(path, ondiagmsg);
- view_init(win_view(EDIT), path, ondiagmsg);
+ win_load(path);
}
/* cleanup */