예제 #1
0
void editor_exit(void)
{
    Text *txt = editor.txt;
    if(text_modified(txt)){
        int choice = judgebox_manager("File not save,save?");
        switch(choice)
        {
        case 0:
            return;
        case 1:
            text_free(txt);
            break;
        case 2:
            if(text_save(txt) == 2){
                char * f = inputbox_manager("please input filename:");
                text_saveas(txt,f);
                free(f);
                text_free(txt);
            }
        }
    }
    FreeMenu(editor.root);
    clipborad_close(editor.cli);
    print_close();
    vga_close();
}
예제 #2
0
Text *editor_newfile(const char *filename)
{
    Text *newtxt;
    Text *txt = editor.txt;
    if(text_modified(txt)){
        int choice = judgebox_manager("File not save,save?");
        switch(choice)
        {
        case 0:
            return NULL;
        case 1:
            text_free(txt);
            break;
        case 2:
            if(text_save(txt) == 2){
                char * f = inputbox_manager("please input filename:");
                text_saveas(txt,f);
                free(f);
                text_free(txt);
            }
            break;
        }
    }
	newtxt = text_load(filename);
    if(!newtxt)
        messagebox_manager("open new file failed");
    editor.txt = newtxt;
    return newtxt;
}
예제 #3
0
static void ui_window_draw_status(UiWin *w) {
	UiCursesWin *win = (UiCursesWin*)w;
	if (!win->winstatus)
		return;
	UiCurses *uic = win->ui;
	Vis *vis = uic->vis;
	bool focused = uic->selwin == win;
	const char *filename = vis_file_name(win->file);
	const char *status = vis_mode_status(vis);
	wattrset(win->winstatus, focused ? A_REVERSE|A_BOLD : A_REVERSE);
	mvwhline(win->winstatus, 0, 0, ' ', win->width);
	mvwprintw(win->winstatus, 0, 0, "%s %s %s %s",
	          focused && status ? status : "",
	          filename ? filename : "[No Name]",
	          text_modified(vis_file_text(win->file)) ? "[+]" : "",
	          vis_macro_recording(vis) ? "recording": "");

	char buf[4*32] = "", *msg = buf;
	int cursor_count = view_cursors_count(win->view);
	if (cursor_count > 1) {
		Cursor *c = view_cursors_primary_get(win->view);
		int cursor_number = view_cursors_number(c) + 1;
		msg += sprintf(msg, "[%d/%d] ", cursor_number, cursor_count);
	}

	if (!(win->options & UI_OPTION_LARGE_FILE)) {
		CursorPos pos = view_cursor_getpos(win->view);
		msg += sprintf(msg, "%zd, %zd", pos.line, pos.col);
	}

	if (buf[0])
		mvwaddstr(win->winstatus, 0, win->width - (msg - buf) - 1, buf);
}
예제 #4
0
파일: vis.c 프로젝트: ewqasd200g/vis
bool vis_window_closable(Win *win) {
	if (!win || !text_modified(win->file->text))
		return true;
	return win->file->refcount > 1;
}