Esempio n. 1
0
File: main.c Progetto: SUMPaul/vis
static const char *undo(Vis *vis, const char *keys, const Arg *arg) {
	size_t pos = text_undo(vis_text(vis));
	if (pos != EPOS) {
		View *view = vis_view(vis);
		if (view_cursors_count(view) == 1)
			view_cursor_to(view, pos);
		/* redraw all windows in case some display the same file */
		vis_draw(vis);
	}
	return keys;
}
Esempio n. 2
0
bool editor_run_func(menuptr m,bool iskey,int key)
{
    int func;
    const char *filename;
    if(!iskey)
        func = MenuID(m);
    else
    {
        func = key;
    }
    switch(func)
    {
    case MENU_MAIN_FILE:
    case MENU_MAIN_EDIT:
    case MENU_MAIN_HELP:
        get_sub_menu_choice(m);
        break;
    case MENU_SUB_NEWFILE:
        if(!editor_newfile(NULL)){
            messagebox_manager("open new file failed.");
            return false;
        }
        editor.mode = EDIT;
        break;
    case MENU_SUB_OPENFILE:
        filename = inputbox_manager("");
        if(!filename){
            if(!editor_newfile(filename)){
                messagebox_manager("open file failed.");
                return false;
            }
            editor.mode = EDIT;
        }
        else
            return false;
    case MENU_SUB_SAVE:
        if(editor.mode == EDIT)
            text_save(editor.txt);
        break;
    case MENU_SUB_SAVEAS:
        if(editor.mode == EDIT){
            filename = inputbox_manager("please input filename:");
            if(!filename){
                if(!text_saveas(editor.txt,filename))
                messagebox_manager("save file failed.!");
            }
        }
        break;
    case MENU_SUB_EXIT:
		editor_exit();
		break;
	case MENU_SUB_UNDO:
        text_undo(editor.txt);
		break;
	case MENU_SUB_REDO:
		text_redo(editor.txt);
        break;
    case MENU_SUB_FIND:
        editor_find();
        break;
    case MENU_SUB_REPLACE:
        editor_raplace();
        break;
    case MENU_SUB_ABOUT:
		messagebox_manager("Made by wr&fzy!");
        break;
    default:
        return false;
    }
    return true;
}