Esempio n. 1
0
bool editor_window_split(Win *original) {
	Win *win = window_new_file(original->editor, original->file);
	if (!win)
		return false;
	win->file = original->file;
	win->file->refcount++;
	view_syntax_set(win->view, view_syntax_get(original->view));
	view_cursor_to(win->view, view_cursor_get(original->view));
	editor_draw(win->editor);
	return true;
}
Esempio n. 2
0
File: vis.c Progetto: 5paceToast/vis
bool vis_window_new(Vis *vis, const char *filename) {
	File *file = file_new(vis, filename);
	if (!file)
		return false;
	Win *win = window_new_file(vis, file, UI_OPTION_STATUSBAR);
	if (!win) {
		file_free(vis, file);
		return false;
	}

	return true;
}
Esempio n. 3
0
File: vis.c Progetto: ewqasd200g/vis
bool vis_window_new(Vis *vis, const char *filename) {
	File *file = file_new(vis, filename);
	if (!file)
		return false;
	Win *win = window_new_file(vis, file);
	if (!win) {
		file_free(vis, file);
		return false;
	}

	vis_draw(vis);

	return true;
}
Esempio n. 4
0
void vis_message_show(Vis *vis, const char *msg) {
	if (!msg)
		return;
	if (!vis->message_window)
		vis->message_window = window_new_file(vis, vis->error_file, UI_OPTION_STATUSBAR);
	Win *win = vis->message_window;
	if (!win)
		return;
	Text *txt = win->file->text;
	size_t pos = text_size(txt);
	text_appendf(txt, "%s\n", msg);
	text_save(txt, NULL);
	view_cursor_to(win->view, pos);
	vis_window_focus(win);
}
Esempio n. 5
0
bool editor_window_new_fd(Editor *ed, int fd) {
	Text *text = text_load_fd(fd);
	if (!text)
		return false;
	File *file = file_new_text(ed, text);
	if (!file) {
		file_free(ed, file);
		return false;
	}
	Win *win = window_new_file(ed, file);
	if (!win) {
		file_free(ed, file);
		return false;
	}
	return true;
}
Esempio n. 6
0
File: vis.c Progetto: 5paceToast/vis
bool vis_window_split(Win *original) {
	Win *win = window_new_file(original->vis, original->file, UI_OPTION_STATUSBAR);
	if (!win)
		return false;
	for (size_t i = 0; i < LENGTH(win->modes); i++) {
		if (original->modes[i].bindings)
			win->modes[i].bindings = map_new();
		if (win->modes[i].bindings)
			map_copy(win->modes[i].bindings, original->modes[i].bindings);
	}
	win->file = original->file;
	win->file->refcount++;
	vis_window_syntax_set(win, vis_window_syntax_get(original));
	view_options_set(win->view, view_options_get(original->view));
	view_cursor_to(win->view, view_cursor_get(original->view));
	return true;
}
Esempio n. 7
0
void vis_prompt_show(Vis *vis, const char *title) {
	Win *active = vis->win;
	Win *prompt = window_new_file(vis, title[0] == ':' ? vis->command_file : vis->search_file,
		UI_OPTION_ONELINE);
	if (!prompt)
		return;
	if (vis->mode->visual)
		window_selection_save(active);
	Text *txt = prompt->file->text;
	text_insert(txt, text_size(txt), title, strlen(title));
	Cursor *cursor = view_cursors_primary_get(prompt->view);
	view_cursors_scroll_to(cursor, text_size(txt));
	prompt->parent = active;
	prompt->parent_mode = vis->mode;
	vis_window_mode_map(prompt, VIS_MODE_NORMAL, true, "<Enter>", &prompt_enter_binding);
	vis_window_mode_map(prompt, VIS_MODE_INSERT, true, "<Enter>", &prompt_enter_binding);
	vis_window_mode_map(prompt, VIS_MODE_VISUAL, true, "<Enter>", &prompt_enter_binding);
	vis_window_mode_map(prompt, VIS_MODE_NORMAL, true, "<Escape>", &prompt_esc_binding);
	vis_window_mode_map(prompt, VIS_MODE_INSERT, true, "<Up>", &prompt_up_binding);
	vis_window_mode_map(prompt, VIS_MODE_INSERT, true, "<Backspace>", &prompt_backspace_binding);
	vis_mode_switch(vis, VIS_MODE_INSERT);
}
Esempio n. 8
0
bool editor_window_new(Editor *ed, const char *filename) {
	File *file = file_new(ed, filename);
	if (!file)
		return false;
	Win *win = window_new_file(ed, file);
	if (!win) {
		file_free(ed, file);
		return false;
	}

	if (filename) {
		for (Syntax *syn = ed->syntaxes; syn && syn->name; syn++) {
			if (!regexec(&syn->file_regex, filename, 0, NULL, 0)) {
				view_syntax_set(win->view, syn);
				break;
			}
		}
	}

	editor_draw(ed);

	return true;
}