Note: this breaks the plugin API.
Replace doc_array with documents_array, a pointer array. This is necessary to avoid breaking the ABI every time a field is added to GeanyDocument. Remove deprecated pluginmacros.h documents macro, to avoid a conflict. Replace doc_list[] macro with documents[] macro, which returns a GeanyDocument pointer. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2624 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
4198167584
commit
be0d9e8ea7
21
ChangeLog
21
ChangeLog
@ -1,3 +1,24 @@
|
||||
2008-05-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
||||
* src/build.c, src/utils.c, src/win32.c, src/keybindings.c,
|
||||
src/printing.c, src/tools.c, src/prefs.c, src/dialogs.c,
|
||||
src/navqueue.c, src/plugindata.h, src/treeviews.c, src/msgwindow.c,
|
||||
src/callbacks.c, src/notebook.c, src/keyfile.c, src/vte.c,
|
||||
src/filetypes.c, src/search.c, src/document.c, src/plugins.c,
|
||||
src/document.h, src/main.c, src/editor.c, src/symbols.c,
|
||||
src/socket.c, src/ui_utils.c, plugins/export.c, plugins/vcdiff.c,
|
||||
plugins/filebrowser.c, plugins/htmlchars.c, plugins/autosave.c,
|
||||
plugins/pluginmacros.h, plugins/classbuilder.c:
|
||||
Note: this breaks the plugin API.
|
||||
Replace doc_array with documents_array, a pointer array. This is
|
||||
necessary to avoid breaking the ABI every time a field is added to
|
||||
GeanyDocument.
|
||||
Remove deprecated pluginmacros.h documents macro, to avoid a
|
||||
conflict.
|
||||
Replace doc_list[] macro with documents[] macro, which returns a
|
||||
GeanyDocument pointer.
|
||||
|
||||
|
||||
2008-05-28 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
||||
* doc/geany.css, doc/geany.html:
|
||||
|
@ -63,14 +63,14 @@ gboolean auto_save(gpointer data)
|
||||
idx = p_document->get_n_idx(i);
|
||||
|
||||
/* skip current file to save it lastly, skip files without name */
|
||||
if (idx != cur_idx && doc_list[idx].file_name != NULL)
|
||||
if (idx != cur_idx && documents[idx]->file_name != NULL)
|
||||
if (p_document->save_file(idx, FALSE))
|
||||
saved_files++;
|
||||
}
|
||||
}
|
||||
/* finally save current file, do it after all other files to get correct window title and
|
||||
* symbol list */
|
||||
if (doc_list[cur_idx].file_name != NULL)
|
||||
if (documents[cur_idx]->file_name != NULL)
|
||||
if (p_document->save_file(cur_idx, FALSE))
|
||||
saved_files++;
|
||||
|
||||
|
@ -732,7 +732,7 @@ static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg)
|
||||
{
|
||||
text = get_template_class_source(class_info);
|
||||
idx = p_document->new_file(class_info->source, NULL, NULL);
|
||||
p_sci->set_text(doc_list[idx].sci, text);
|
||||
p_sci->set_text(documents[idx]->sci, text);
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
@ -740,7 +740,7 @@ static void cc_dlg_on_create_class(CreateClassDialog *cc_dlg)
|
||||
{
|
||||
text = get_template_class_header(class_info);
|
||||
idx = p_document->new_file(class_info->header, NULL, NULL);
|
||||
p_sci->set_text(doc_list[idx].sci, text);
|
||||
p_sci->set_text(documents[idx]->sci, text);
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
|
@ -209,20 +209,20 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
|
||||
|
||||
/* if the current document has a filename we use it as the default. */
|
||||
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog));
|
||||
if (doc_list[idx].file_name != NULL)
|
||||
if (documents[idx]->file_name != NULL)
|
||||
{
|
||||
gchar *base_name = g_path_get_basename(doc_list[idx].file_name);
|
||||
gchar *base_name = g_path_get_basename(documents[idx]->file_name);
|
||||
gchar *short_name = p_utils->remove_ext_from_filename(base_name);
|
||||
gchar *file_name;
|
||||
gchar *locale_filename;
|
||||
gchar *locale_dirname;
|
||||
gchar *suffix = "";
|
||||
|
||||
if (g_str_has_suffix(doc_list[idx].file_name, extension))
|
||||
if (g_str_has_suffix(documents[idx]->file_name, extension))
|
||||
suffix = "_export";
|
||||
|
||||
file_name = g_strconcat(short_name, suffix, extension, NULL);
|
||||
locale_filename = p_utils->get_locale_from_utf8(doc_list[idx].file_name);
|
||||
locale_filename = p_utils->get_locale_from_utf8(documents[idx]->file_name);
|
||||
locale_dirname = g_path_get_dirname(locale_filename);
|
||||
/* set the current name to base_name.html which probably doesn't exist yet so
|
||||
* gtk_file_chooser_set_filename() can't be used and we need
|
||||
@ -357,25 +357,25 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
|
||||
GString *body;
|
||||
GString *cmds;
|
||||
GString *latex;
|
||||
gint style_max = pow(2, p_sci->send_message(doc_list[idx].sci, SCI_GETSTYLEBITS, 0, 0));
|
||||
gint style_max = pow(2, p_sci->send_message(documents[idx]->sci, SCI_GETSTYLEBITS, 0, 0));
|
||||
|
||||
/* first read all styles from Scintilla */
|
||||
for (i = 0; i < style_max; i++)
|
||||
{
|
||||
styles[i][FORE] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETFORE, i, 0);
|
||||
styles[i][BACK] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETBACK, i, 0);
|
||||
styles[i][BOLD] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETBOLD, i, 0);
|
||||
styles[i][ITALIC] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETITALIC, i, 0);
|
||||
styles[i][FORE] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETFORE, i, 0);
|
||||
styles[i][BACK] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETBACK, i, 0);
|
||||
styles[i][BOLD] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETBOLD, i, 0);
|
||||
styles[i][ITALIC] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETITALIC, i, 0);
|
||||
styles[i][USED] = 0;
|
||||
}
|
||||
|
||||
/* read the document and write the LaTeX code */
|
||||
body = g_string_new("");
|
||||
for (i = 0; i < p_sci->get_length(doc_list[idx].sci); i++)
|
||||
for (i = 0; i < p_sci->get_length(documents[idx]->sci); i++)
|
||||
{
|
||||
style = p_sci->get_style_at(doc_list[idx].sci, i);
|
||||
c = p_sci->get_char_at(doc_list[idx].sci, i);
|
||||
c_next = p_sci->get_char_at(doc_list[idx].sci, i + 1);
|
||||
style = p_sci->get_style_at(documents[idx]->sci, i);
|
||||
c = p_sci->get_char_at(documents[idx]->sci, i);
|
||||
c_next = p_sci->get_char_at(documents[idx]->sci, i + 1);
|
||||
|
||||
if (style != old_style || ! block_open)
|
||||
{
|
||||
@ -538,10 +538,10 @@ static void write_latex_file(gint idx, const gchar *filename, gboolean use_zoom)
|
||||
p_utils->string_replace_all(latex, "{export_content}", body->str);
|
||||
p_utils->string_replace_all(latex, "{export_styles}", cmds->str);
|
||||
p_utils->string_replace_all(latex, "{export_date}", get_date(DATE_TYPE_DEFAULT));
|
||||
if (doc_list[idx].file_name == NULL)
|
||||
if (documents[idx]->file_name == NULL)
|
||||
p_utils->string_replace_all(latex, "{export_filename}", GEANY_STRING_UNTITLED);
|
||||
else
|
||||
p_utils->string_replace_all(latex, "{export_filename}", doc_list[idx].file_name);
|
||||
p_utils->string_replace_all(latex, "{export_filename}", documents[idx]->file_name);
|
||||
|
||||
write_data(filename, latex->str);
|
||||
|
||||
@ -564,15 +564,15 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
|
||||
GString *body;
|
||||
GString *css;
|
||||
GString *html;
|
||||
gint style_max = pow(2, p_sci->send_message(doc_list[idx].sci, SCI_GETSTYLEBITS, 0, 0));
|
||||
gint style_max = pow(2, p_sci->send_message(documents[idx]->sci, SCI_GETSTYLEBITS, 0, 0));
|
||||
|
||||
/* first read all styles from Scintilla */
|
||||
for (i = 0; i < style_max; i++)
|
||||
{
|
||||
styles[i][FORE] = ROTATE_RGB(p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETFORE, i, 0));
|
||||
styles[i][BACK] = ROTATE_RGB(p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETBACK, i, 0));
|
||||
styles[i][BOLD] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETBOLD, i, 0);
|
||||
styles[i][ITALIC] = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETITALIC, i, 0);
|
||||
styles[i][FORE] = ROTATE_RGB(p_sci->send_message(documents[idx]->sci, SCI_STYLEGETFORE, i, 0));
|
||||
styles[i][BACK] = ROTATE_RGB(p_sci->send_message(documents[idx]->sci, SCI_STYLEGETBACK, i, 0));
|
||||
styles[i][BOLD] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETBOLD, i, 0);
|
||||
styles[i][ITALIC] = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETITALIC, i, 0);
|
||||
styles[i][USED] = 0;
|
||||
}
|
||||
|
||||
@ -581,18 +581,18 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
|
||||
font_name = pango_font_description_get_family(font_desc);
|
||||
/*font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE;*/
|
||||
/* take the zoom level also into account */
|
||||
font_size = p_sci->send_message(doc_list[idx].sci, SCI_STYLEGETSIZE, 0, 0);
|
||||
font_size = p_sci->send_message(documents[idx]->sci, SCI_STYLEGETSIZE, 0, 0);
|
||||
if (use_zoom)
|
||||
font_size += p_sci->send_message(doc_list[idx].sci, SCI_GETZOOM, 0, 0);
|
||||
font_size += p_sci->send_message(documents[idx]->sci, SCI_GETZOOM, 0, 0);
|
||||
|
||||
/* read the document and write the HTML body */
|
||||
body = g_string_new("");
|
||||
for (i = 0; i < p_sci->get_length(doc_list[idx].sci); i++)
|
||||
for (i = 0; i < p_sci->get_length(documents[idx]->sci); i++)
|
||||
{
|
||||
style = p_sci->get_style_at(doc_list[idx].sci, i);
|
||||
c = p_sci->get_char_at(doc_list[idx].sci, i);
|
||||
style = p_sci->get_style_at(documents[idx]->sci, i);
|
||||
c = p_sci->get_char_at(documents[idx]->sci, i);
|
||||
/* p_sci->get_char_at() takes care of index boundaries and return 0 if i is too high */
|
||||
c_next = p_sci->get_char_at(doc_list[idx].sci, i + 1);
|
||||
c_next = p_sci->get_char_at(documents[idx]->sci, i + 1);
|
||||
|
||||
if ((style != old_style || ! span_open) && ! isspace(c))
|
||||
{
|
||||
@ -690,10 +690,10 @@ static void write_html_file(gint idx, const gchar *filename, gboolean use_zoom)
|
||||
p_utils->string_replace_all(html, "{export_date}", get_date(DATE_TYPE_HTML));
|
||||
p_utils->string_replace_all(html, "{export_content}", body->str);
|
||||
p_utils->string_replace_all(html, "{export_styles}", css->str);
|
||||
if (doc_list[idx].file_name == NULL)
|
||||
if (documents[idx]->file_name == NULL)
|
||||
p_utils->string_replace_all(html, "{export_filename}", GEANY_STRING_UNTITLED);
|
||||
else
|
||||
p_utils->string_replace_all(html, "{export_filename}", doc_list[idx].file_name);
|
||||
p_utils->string_replace_all(html, "{export_filename}", documents[idx]->file_name);
|
||||
|
||||
write_data(filename, html->str);
|
||||
|
||||
|
@ -277,14 +277,14 @@ static void on_current_path(void)
|
||||
gchar *dir;
|
||||
gint idx = p_document->get_cur_idx();
|
||||
|
||||
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL ||
|
||||
! g_path_is_absolute(doc_list[idx].file_name))
|
||||
if (! DOC_IDX_VALID(idx) || documents[idx]->file_name == NULL ||
|
||||
! g_path_is_absolute(documents[idx]->file_name))
|
||||
{
|
||||
setptr(current_dir, get_default_dir());
|
||||
refresh();
|
||||
return;
|
||||
}
|
||||
fname = doc_list[idx].file_name;
|
||||
fname = documents[idx]->file_name;
|
||||
fname = p_utils->get_locale_from_utf8(fname);
|
||||
dir = g_path_get_dirname(fname);
|
||||
g_free(fname);
|
||||
|
@ -444,12 +444,12 @@ static gboolean sc_insert(GtkTreeModel *model, GtkTreeIter *iter)
|
||||
if (DOC_IDX_VALID(idx))
|
||||
{
|
||||
gchar *str;
|
||||
gint pos = p_sci->get_current_position(doc_list[idx].sci);
|
||||
gint pos = p_sci->get_current_position(documents[idx]->sci);
|
||||
|
||||
gtk_tree_model_get(model, iter, COLUMN_HTML_NAME, &str, -1);
|
||||
if (str && *str)
|
||||
{
|
||||
p_sci->insert_text(doc_list[idx].sci, pos, str);
|
||||
p_sci->insert_text(documents[idx]->sci, pos, str);
|
||||
g_free(str);
|
||||
result = TRUE;
|
||||
}
|
||||
@ -510,7 +510,7 @@ item_activate(GtkMenuItem *menuitem, gpointer gdata)
|
||||
/* refuse opening the dialog if we don't have an active tab */
|
||||
gint idx = p_document->get_cur_idx();
|
||||
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
|
||||
tools_show_dialog_insert_special_chars();
|
||||
}
|
||||
|
@ -38,13 +38,14 @@
|
||||
/* common data structs */
|
||||
#define app geany_data->app
|
||||
#define main_widgets geany_data->main_widgets
|
||||
#define doc_array geany_data->doc_array /**< Allows use of @c doc_list[] macro */
|
||||
#define documents_array geany_data->documents_array /**< Allows use of @c documents[] macro */
|
||||
#define filetypes_array geany_data->filetypes_array /**< Allows use of @c filetypes[] macro */
|
||||
#define prefs geany_data->prefs
|
||||
#define project app->project
|
||||
|
||||
|
||||
/* New function macros should be added here */
|
||||
#define p_document geany_functions->p_document /**< See document.h */
|
||||
#define p_filetypes geany_functions->p_filetypes /**< See filetypes.h */
|
||||
#define p_navqueue geany_functions->p_navqueue /**< See navqueue.h */
|
||||
#define p_editor geany_functions->p_editor /**< See editor.h */
|
||||
@ -53,7 +54,6 @@
|
||||
#ifdef GEANY_DISABLE_DEPRECATED
|
||||
|
||||
#define p_dialogs geany_functions->p_dialogs /**< See dialogs.h */
|
||||
#define p_document geany_functions->p_document /**< See document.h */
|
||||
#define p_encodings geany_functions->p_encodings /**< See encodings.h */
|
||||
#define p_highlighting geany_functions->p_highlighting /**< See highlighting.h */
|
||||
#define p_keybindings geany_functions->p_keybindings /**< See keybindings.h */
|
||||
@ -69,7 +69,6 @@
|
||||
#else
|
||||
|
||||
#define p_dialogs dialogs
|
||||
#define p_document documents
|
||||
#define p_encodings encodings
|
||||
#define p_highlighting highlighting
|
||||
#define p_keybindings keybindings
|
||||
@ -85,7 +84,6 @@
|
||||
|
||||
/* Temporary source compatibility macros - do not use these in new code, they may get removed. */
|
||||
#define dialogs geany_functions->p_dialogs
|
||||
#define documents geany_functions->p_document
|
||||
#define encodings geany_functions->p_encodings
|
||||
#define highlighting geany_functions->p_highlighting
|
||||
#define keybindings geany_functions->p_keybindings
|
||||
|
@ -252,10 +252,10 @@ static int find_by_filename(const gchar* filename)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].is_valid && doc_list[i].file_name &&
|
||||
strcmp(doc_list[i].file_name, filename) == 0)
|
||||
if (documents[i]->is_valid && documents[i]->file_name &&
|
||||
strcmp(documents[i]->file_name, filename) == 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
@ -295,11 +295,11 @@ static void show_output(const gchar *std_output, const gchar *name_prefix,
|
||||
}
|
||||
else
|
||||
{
|
||||
p_sci->set_text(doc_list[idx].sci, text);
|
||||
p_sci->set_text(documents[idx]->sci, text);
|
||||
book = GTK_NOTEBOOK(main_widgets->notebook);
|
||||
page = gtk_notebook_page_num(book, GTK_WIDGET(doc_list[idx].sci));
|
||||
page = gtk_notebook_page_num(book, GTK_WIDGET(documents[idx]->sci));
|
||||
gtk_notebook_set_current_page(book, page);
|
||||
doc_list[idx].changed = FALSE;
|
||||
documents[idx]->changed = FALSE;
|
||||
p_document->set_text_changed(idx);
|
||||
}
|
||||
|
||||
@ -403,14 +403,14 @@ static void vcdirectory_activated(GtkMenuItem *menuitem, gpointer gdata)
|
||||
|
||||
idx = p_document->get_cur_idx();
|
||||
|
||||
g_return_if_fail(DOC_IDX_VALID(idx) && doc_list[idx].file_name != NULL);
|
||||
g_return_if_fail(DOC_IDX_VALID(idx) && documents[idx]->file_name != NULL);
|
||||
|
||||
if (doc_list[idx].changed)
|
||||
if (documents[idx]->changed)
|
||||
{
|
||||
p_document->save_file(idx, FALSE);
|
||||
}
|
||||
|
||||
locale_filename = p_utils->get_locale_from_utf8(doc_list[idx].file_name);
|
||||
locale_filename = p_utils->get_locale_from_utf8(documents[idx]->file_name);
|
||||
base_name = g_path_get_dirname(locale_filename);
|
||||
|
||||
text = make_diff(base_name, VC_COMMAND_DIFF_DIR);
|
||||
@ -436,7 +436,7 @@ static void vcproject_activated(GtkMenuItem *menuitem, gpointer gdata)
|
||||
|
||||
g_return_if_fail(project != NULL && NZV(project->base_path));
|
||||
|
||||
if (DOC_IDX_VALID(idx) && doc_list[idx].changed && doc_list[idx].file_name != NULL)
|
||||
if (DOC_IDX_VALID(idx) && documents[idx]->changed && documents[idx]->file_name != NULL)
|
||||
{
|
||||
p_document->save_file(idx, FALSE);
|
||||
}
|
||||
@ -460,19 +460,19 @@ static void vcfile_activated(GtkMenuItem *menuitem, gpointer gdata)
|
||||
|
||||
idx = p_document->get_cur_idx();
|
||||
|
||||
g_return_if_fail(DOC_IDX_VALID(idx) && doc_list[idx].file_name != NULL);
|
||||
g_return_if_fail(DOC_IDX_VALID(idx) && documents[idx]->file_name != NULL);
|
||||
|
||||
if (doc_list[idx].changed)
|
||||
if (documents[idx]->changed)
|
||||
{
|
||||
p_document->save_file(idx, FALSE);
|
||||
}
|
||||
|
||||
locale_filename = p_utils->get_locale_from_utf8(doc_list[idx].file_name);
|
||||
locale_filename = p_utils->get_locale_from_utf8(documents[idx]->file_name);
|
||||
|
||||
text = make_diff(locale_filename, VC_COMMAND_DIFF_FILE);
|
||||
if (text)
|
||||
{
|
||||
show_output(text, doc_list[idx].file_name, doc_list[idx].encoding);
|
||||
show_output(text, documents[idx]->file_name, documents[idx]->encoding);
|
||||
g_free(text);
|
||||
}
|
||||
g_free(locale_filename);
|
||||
|
84
src/build.c
84
src/build.c
@ -129,16 +129,16 @@ static GPid build_compile_tex_file(gint idx, gint mode)
|
||||
{
|
||||
const gchar *cmd = NULL;
|
||||
|
||||
if (idx < 0 || doc_list[idx].file_name == NULL) return (GPid) 1;
|
||||
if (idx < 0 || documents[idx]->file_name == NULL) return (GPid) 1;
|
||||
|
||||
if (mode == LATEX_CMD_TO_DVI)
|
||||
{
|
||||
cmd = doc_list[idx].file_type->programs->compiler;
|
||||
cmd = documents[idx]->file_type->programs->compiler;
|
||||
build_info.type = GBO_COMPILE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = doc_list[idx].file_type->programs->linker;
|
||||
cmd = documents[idx]->file_type->programs->linker;
|
||||
build_info.type = GBO_BUILD;
|
||||
}
|
||||
|
||||
@ -161,12 +161,12 @@ static GPid build_view_tex_file(gint idx, gint mode)
|
||||
GError *error = NULL;
|
||||
struct stat st;
|
||||
|
||||
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL)
|
||||
if (! DOC_IDX_VALID(idx) || documents[idx]->file_name == NULL)
|
||||
return (GPid) 1;
|
||||
|
||||
run_info.file_type_id = GEANY_FILETYPES_LATEX;
|
||||
|
||||
executable = utils_remove_ext_from_filename(doc_list[idx].file_name);
|
||||
executable = utils_remove_ext_from_filename(documents[idx]->file_name);
|
||||
view_file = g_strconcat(executable, (mode == LATEX_CMD_VIEW_DVI) ? ".dvi" : ".pdf", NULL);
|
||||
|
||||
/* try convert in locale for stat() */
|
||||
@ -183,8 +183,8 @@ static GPid build_view_tex_file(gint idx, gint mode)
|
||||
|
||||
/* replace %f and %e in the run_cmd string */
|
||||
cmd_string = g_strdup((mode == LATEX_CMD_VIEW_DVI) ?
|
||||
g_strdup(doc_list[idx].file_type->programs->run_cmd) :
|
||||
g_strdup(doc_list[idx].file_type->programs->run_cmd2));
|
||||
g_strdup(documents[idx]->file_type->programs->run_cmd) :
|
||||
g_strdup(documents[idx]->file_type->programs->run_cmd2));
|
||||
cmd_string = utils_str_replace(cmd_string, "%f", view_file);
|
||||
cmd_string = utils_str_replace(cmd_string, "%e", executable);
|
||||
|
||||
@ -292,9 +292,9 @@ static gchar *get_object_filename(gint idx)
|
||||
{
|
||||
gchar *locale_filename, *short_file, *noext, *object_file;
|
||||
|
||||
if (doc_list[idx].file_name == NULL) return NULL;
|
||||
if (documents[idx]->file_name == NULL) return NULL;
|
||||
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(documents[idx]->file_name);
|
||||
|
||||
short_file = g_path_get_basename(locale_filename);
|
||||
g_free(locale_filename);
|
||||
@ -315,7 +315,7 @@ static GPid build_make_file(gint idx, gint build_opts)
|
||||
gchar *dir = NULL;
|
||||
GPid pid;
|
||||
|
||||
if (idx < 0 || doc_list[idx].file_name == NULL) return (GPid) 1;
|
||||
if (idx < 0 || documents[idx]->file_name == NULL) return (GPid) 1;
|
||||
|
||||
cmdstr = g_string_new(tool_prefs.make_cmd);
|
||||
g_string_append_c(cmdstr, ' ');
|
||||
@ -351,21 +351,21 @@ static GPid build_make_file(gint idx, gint build_opts)
|
||||
|
||||
static GPid build_compile_file(gint idx)
|
||||
{
|
||||
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL)
|
||||
if (! DOC_IDX_VALID(idx) || documents[idx]->file_name == NULL)
|
||||
return (GPid) 1;
|
||||
|
||||
build_info.type = GBO_COMPILE;
|
||||
return build_spawn_cmd(idx, doc_list[idx].file_type->programs->compiler, NULL);
|
||||
return build_spawn_cmd(idx, documents[idx]->file_type->programs->compiler, NULL);
|
||||
}
|
||||
|
||||
|
||||
static GPid build_link_file(gint idx)
|
||||
{
|
||||
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL)
|
||||
if (! DOC_IDX_VALID(idx) || documents[idx]->file_name == NULL)
|
||||
return (GPid) 1;
|
||||
|
||||
build_info.type = GBO_BUILD;
|
||||
return build_spawn_cmd(idx, doc_list[idx].file_type->programs->linker, NULL);
|
||||
return build_spawn_cmd(idx, documents[idx]->file_type->programs->linker, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -386,9 +386,9 @@ static void clear_errors(gint idx)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].is_valid)
|
||||
if (documents[i]->is_valid)
|
||||
editor_clear_indicators(i);
|
||||
}
|
||||
break;
|
||||
@ -441,7 +441,7 @@ static GPid build_spawn_cmd(gint idx, const gchar *cmd, const gchar *dir)
|
||||
clear_errors(idx);
|
||||
setptr(current_dir_entered, NULL);
|
||||
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(documents[idx]->file_name);
|
||||
executable = utils_remove_ext_from_filename(locale_filename);
|
||||
|
||||
cmd_string = g_strdup(cmd);
|
||||
@ -472,7 +472,7 @@ static GPid build_spawn_cmd(gint idx, const gchar *cmd, const gchar *dir)
|
||||
|
||||
utf8_cmd_string = utils_get_utf8_from_locale(cmd_string);
|
||||
utf8_working_dir = (dir != NULL) ? g_strdup(dir) :
|
||||
g_path_get_dirname(doc_list[idx].file_name);
|
||||
g_path_get_dirname(documents[idx]->file_name);
|
||||
working_dir = utils_get_locale_from_utf8(utf8_working_dir);
|
||||
|
||||
gtk_list_store_clear(msgwindow.store_compiler);
|
||||
@ -484,7 +484,7 @@ static GPid build_spawn_cmd(gint idx, const gchar *cmd, const gchar *dir)
|
||||
/* set the build info for the message window */
|
||||
g_free(build_info.dir);
|
||||
build_info.dir = g_strdup(working_dir);
|
||||
build_info.file_type_id = FILETYPE_ID(doc_list[idx].file_type);
|
||||
build_info.file_type_id = FILETYPE_ID(documents[idx]->file_type);
|
||||
|
||||
if (! g_spawn_async_with_pipes(working_dir, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
NULL, NULL, &(build_info.pid), NULL, &stdout_fd, &stderr_fd, &error))
|
||||
@ -591,7 +591,7 @@ static gchar *prepare_run_script(gint idx, gchar **vte_cmd_nonscript)
|
||||
gchar *locale_filename = NULL;
|
||||
gboolean have_project;
|
||||
GeanyProject *project = app->project;
|
||||
GeanyFiletype *ft = doc_list[idx].file_type;
|
||||
GeanyFiletype *ft = documents[idx]->file_type;
|
||||
gboolean check_exists;
|
||||
gchar *cmd = NULL;
|
||||
gchar *executable = NULL;
|
||||
@ -603,7 +603,7 @@ static gchar *prepare_run_script(gint idx, gchar **vte_cmd_nonscript)
|
||||
if (vte_cmd_nonscript != NULL)
|
||||
*vte_cmd_nonscript = NULL;
|
||||
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(documents[idx]->file_name);
|
||||
|
||||
have_project = (project != NULL && NZV(project->run_cmd));
|
||||
cmd = (have_project) ?
|
||||
@ -694,7 +694,7 @@ static GPid build_run_cmd(gint idx)
|
||||
gchar *vte_cmd_nonscript = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL)
|
||||
if (! DOC_IDX_VALID(idx) || documents[idx]->file_name == NULL)
|
||||
return (GPid) 0;
|
||||
|
||||
working_dir = prepare_run_script(idx, &vte_cmd_nonscript);
|
||||
@ -703,7 +703,7 @@ static GPid build_run_cmd(gint idx)
|
||||
return (GPid) 0;
|
||||
}
|
||||
|
||||
run_info.file_type_id = FILETYPE_ID(doc_list[idx].file_type);
|
||||
run_info.file_type_id = FILETYPE_ID(documents[idx]->file_type);
|
||||
|
||||
#ifdef HAVE_VTE
|
||||
if (vte_info.load_vte && vc != NULL && vc->run_in_vte)
|
||||
@ -1327,7 +1327,7 @@ static void show_includes_arguments_tex(void)
|
||||
gint response;
|
||||
GeanyFiletype *ft = NULL;
|
||||
|
||||
if (DOC_IDX_VALID(idx)) ft = doc_list[idx].file_type;
|
||||
if (DOC_IDX_VALID(idx)) ft = documents[idx]->file_type;
|
||||
g_return_if_fail(ft != NULL);
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons(_("Set Arguments"), GTK_WINDOW(main_widgets.window),
|
||||
@ -1496,7 +1496,7 @@ static void show_includes_arguments_gen(void)
|
||||
gint response;
|
||||
GeanyFiletype *ft = NULL;
|
||||
|
||||
if (DOC_IDX_VALID(idx)) ft = doc_list[idx].file_type;
|
||||
if (DOC_IDX_VALID(idx)) ft = documents[idx]->file_type;
|
||||
g_return_if_fail(ft != NULL);
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons(_("Set Includes and Arguments"), GTK_WINDOW(main_widgets.window),
|
||||
@ -1642,8 +1642,8 @@ void build_menu_update(gint idx)
|
||||
if (idx == -1)
|
||||
idx = document_get_cur_idx();
|
||||
if (idx == -1 ||
|
||||
(FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_NONE &&
|
||||
doc_list[idx].file_name == NULL))
|
||||
(FILETYPE_ID(documents[idx]->file_type) == GEANY_FILETYPES_NONE &&
|
||||
documents[idx]->file_name == NULL))
|
||||
{
|
||||
gtk_widget_set_sensitive(lookup_widget(main_widgets.window, "menu_build1"), FALSE);
|
||||
gtk_menu_item_remove_submenu(GTK_MENU_ITEM(lookup_widget(main_widgets.window, "menu_build1")));
|
||||
@ -1654,7 +1654,7 @@ void build_menu_update(gint idx)
|
||||
else
|
||||
gtk_widget_set_sensitive(lookup_widget(main_widgets.window, "menu_build1"), TRUE);
|
||||
|
||||
ft = doc_list[idx].file_type;
|
||||
ft = documents[idx]->file_type;
|
||||
g_return_if_fail(ft != NULL);
|
||||
|
||||
menu_items = build_get_menu_items(ft->id);
|
||||
@ -1663,13 +1663,13 @@ void build_menu_update(gint idx)
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(main_widgets.window, "menu_build1")),
|
||||
menu_items->menu);
|
||||
|
||||
have_path = (doc_list[idx].file_name != NULL);
|
||||
have_path = (documents[idx]->file_name != NULL);
|
||||
|
||||
can_make = have_path && build_info.pid <= (GPid) 1;
|
||||
|
||||
/* disable compile and link for C/C++ header files */
|
||||
if (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP)
|
||||
can_build = can_make && ! is_c_header(doc_list[idx].file_name);
|
||||
can_build = can_make && ! is_c_header(documents[idx]->file_name);
|
||||
else
|
||||
can_build = can_make;
|
||||
|
||||
@ -1787,7 +1787,7 @@ BuildMenuItems *build_get_menu_items(gint filetype_idx)
|
||||
GeanyFiletype *ft = NULL;
|
||||
|
||||
if (DOC_IDX_VALID(idx))
|
||||
ft = doc_list[idx].file_type;
|
||||
ft = documents[idx]->file_type;
|
||||
filetype_idx = FILETYPE_ID(ft);
|
||||
}
|
||||
|
||||
@ -1815,9 +1815,9 @@ on_build_compile_activate (GtkMenuItem *menuitem,
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
if (doc_list[idx].changed) document_save_file(idx, FALSE);
|
||||
if (documents[idx]->changed) document_save_file(idx, FALSE);
|
||||
|
||||
if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_LATEX)
|
||||
if (FILETYPE_ID(documents[idx]->file_type) == GEANY_FILETYPES_LATEX)
|
||||
build_compile_tex_file(idx, 0);
|
||||
else
|
||||
build_compile_file(idx);
|
||||
@ -1833,7 +1833,7 @@ on_build_tex_activate (GtkMenuItem *menuitem,
|
||||
if (! DOC_IDX_VALID(idx))
|
||||
return;
|
||||
|
||||
if (doc_list[idx].changed) document_save_file(idx, FALSE);
|
||||
if (documents[idx]->changed) document_save_file(idx, FALSE);
|
||||
|
||||
switch (GPOINTER_TO_INT(user_data))
|
||||
{
|
||||
@ -1855,9 +1855,9 @@ on_build_build_activate (GtkMenuItem *menuitem,
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
if (doc_list[idx].changed) document_save_file(idx, FALSE);
|
||||
if (documents[idx]->changed) document_save_file(idx, FALSE);
|
||||
|
||||
if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_LATEX)
|
||||
if (FILETYPE_ID(documents[idx]->file_type) == GEANY_FILETYPES_LATEX)
|
||||
build_compile_tex_file(idx, 1);
|
||||
else
|
||||
build_link_file(idx);
|
||||
@ -1869,7 +1869,7 @@ on_make_custom_input_response(const gchar *input)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
|
||||
if (doc_list[idx].changed)
|
||||
if (documents[idx]->changed)
|
||||
document_save_file(idx, FALSE);
|
||||
|
||||
setptr(build_info.custom_target, g_strdup(input));
|
||||
@ -1901,7 +1901,7 @@ on_build_make_activate (GtkMenuItem *menuitem,
|
||||
gint idx = document_get_cur_idx();
|
||||
gint build_opts = GPOINTER_TO_INT(user_data);
|
||||
|
||||
g_return_if_fail(DOC_IDX_VALID(idx) && doc_list[idx].file_name != NULL);
|
||||
g_return_if_fail(DOC_IDX_VALID(idx) && documents[idx]->file_name != NULL);
|
||||
|
||||
switch (build_opts)
|
||||
{
|
||||
@ -1915,7 +1915,7 @@ on_build_make_activate (GtkMenuItem *menuitem,
|
||||
/* fall through */
|
||||
case GBO_MAKE_ALL:
|
||||
{
|
||||
if (doc_list[idx].changed) document_save_file(idx, FALSE);
|
||||
if (documents[idx]->changed) document_save_file(idx, FALSE);
|
||||
|
||||
build_make_file(idx, build_opts);
|
||||
}
|
||||
@ -1941,7 +1941,7 @@ static gboolean use_html_builtin(gint idx, GeanyFiletype *ft)
|
||||
|
||||
if (use_builtin)
|
||||
{
|
||||
gchar *uri = g_strconcat("file:///", g_path_skip_root(doc_list[idx].file_name), NULL);
|
||||
gchar *uri = g_strconcat("file:///", g_path_skip_root(documents[idx]->file_name), NULL);
|
||||
utils_start_browser(uri);
|
||||
g_free(uri);
|
||||
|
||||
@ -1969,7 +1969,7 @@ on_build_execute_activate (GtkMenuItem *menuitem,
|
||||
return;
|
||||
}
|
||||
|
||||
ft_id = FILETYPE_ID(doc_list[idx].file_type);
|
||||
ft_id = FILETYPE_ID(documents[idx]->file_type);
|
||||
ft = filetypes[ft_id];
|
||||
if (ft_id == GEANY_FILETYPES_LATEX)
|
||||
{ /* run LaTeX file */
|
||||
@ -1983,7 +1983,7 @@ on_build_execute_activate (GtkMenuItem *menuitem,
|
||||
{ /* run everything else */
|
||||
|
||||
/* save the file only if the run command uses it */
|
||||
if (doc_list[idx].changed &&
|
||||
if (documents[idx]->changed &&
|
||||
NZV(ft->programs->run_cmd) && /* can happen when project is open */
|
||||
strstr(ft->programs->run_cmd, "%f") != NULL)
|
||||
document_save_file(idx, FALSE);
|
||||
|
222
src/callbacks.c
222
src/callbacks.c
@ -94,9 +94,9 @@ static gboolean check_no_unsaved(void)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].is_valid && doc_list[i].changed)
|
||||
if (documents[i]->is_valid && documents[i]->changed)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -111,7 +111,7 @@ static void verify_click_pos(gint idx)
|
||||
{
|
||||
if (insert_callback_from_menu)
|
||||
{
|
||||
editor_info.click_pos = sci_get_current_position(doc_list[idx].sci);
|
||||
editor_info.click_pos = sci_get_current_position(documents[idx]->sci);
|
||||
insert_callback_from_menu = FALSE;
|
||||
}
|
||||
}
|
||||
@ -180,7 +180,7 @@ on_save1_activate (GtkMenuItem *menuitem,
|
||||
|
||||
if (cur_page >= 0)
|
||||
{
|
||||
if (doc_list[idx].file_name == NULL)
|
||||
if (documents[idx]->file_name == NULL)
|
||||
dialogs_show_save_as();
|
||||
else
|
||||
document_save_file(idx, FALSE);
|
||||
@ -208,8 +208,8 @@ on_save_all1_activate (GtkMenuItem *menuitem,
|
||||
for (i = 0; i < max; i++)
|
||||
{
|
||||
idx = document_get_n_idx(i);
|
||||
if (! doc_list[idx].changed) continue;
|
||||
if (doc_list[idx].file_name == NULL)
|
||||
if (! documents[idx]->changed) continue;
|
||||
if (documents[idx]->file_name == NULL)
|
||||
{
|
||||
/* display unnamed document */
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
|
||||
@ -281,7 +281,7 @@ on_undo1_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
if (document_can_undo(idx)) document_undo(idx);
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ on_redo1_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
if (document_can_redo(idx)) document_redo(idx);
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ on_cut1_activate (GtkMenuItem *menuitem,
|
||||
gtk_editable_cut_clipboard(GTK_EDITABLE(focusw));
|
||||
else
|
||||
if (IS_SCINTILLA(focusw) && idx >= 0)
|
||||
sci_cut(doc_list[idx].sci);
|
||||
sci_cut(documents[idx]->sci);
|
||||
else
|
||||
if (GTK_IS_TEXT_VIEW(focusw))
|
||||
{
|
||||
@ -329,7 +329,7 @@ on_copy1_activate (GtkMenuItem *menuitem,
|
||||
gtk_editable_copy_clipboard(GTK_EDITABLE(focusw));
|
||||
else
|
||||
if (IS_SCINTILLA(focusw) && idx >= 0)
|
||||
sci_copy(doc_list[idx].sci);
|
||||
sci_copy(documents[idx]->sci);
|
||||
else
|
||||
if (GTK_IS_TEXT_VIEW(focusw))
|
||||
{
|
||||
@ -362,12 +362,12 @@ on_paste1_activate (GtkMenuItem *menuitem,
|
||||
gchar *content = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_NONE));
|
||||
if (content != NULL)
|
||||
{
|
||||
sci_replace_sel(doc_list[idx].sci, content);
|
||||
sci_replace_sel(documents[idx]->sci, content);
|
||||
g_free(content);
|
||||
}
|
||||
}
|
||||
#else
|
||||
sci_paste(doc_list[idx].sci);
|
||||
sci_paste(documents[idx]->sci);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -392,7 +392,7 @@ on_delete1_activate (GtkMenuItem *menuitem,
|
||||
gtk_editable_delete_selection(GTK_EDITABLE(focusw));
|
||||
else
|
||||
if (IS_SCINTILLA(focusw) && idx >= 0)
|
||||
sci_clear(doc_list[idx].sci);
|
||||
sci_clear(documents[idx]->sci);
|
||||
else
|
||||
if (GTK_IS_TEXT_VIEW(focusw))
|
||||
{
|
||||
@ -457,7 +457,7 @@ on_reload_as_activate (GtkMenuItem *menuitem,
|
||||
gint i = GPOINTER_TO_INT(user_data);
|
||||
gchar *charset = NULL;
|
||||
|
||||
if (idx < 0 || ! doc_list[idx].is_valid || doc_list[idx].file_name == NULL)
|
||||
if (idx < 0 || ! documents[idx]->is_valid || documents[idx]->file_name == NULL)
|
||||
return;
|
||||
if (i >= 0)
|
||||
{
|
||||
@ -465,7 +465,7 @@ on_reload_as_activate (GtkMenuItem *menuitem,
|
||||
charset = encodings[i].charset;
|
||||
}
|
||||
|
||||
base_name = g_path_get_basename(doc_list[idx].file_name);
|
||||
base_name = g_path_get_basename(documents[idx]->file_name);
|
||||
if (dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL,
|
||||
_("Any unsaved changes will be lost."),
|
||||
_("Are you sure you want to reload '%s'?"), base_name))
|
||||
@ -657,11 +657,11 @@ on_zoom_in1_activate (GtkMenuItem *menuitem,
|
||||
gint idx = document_get_cur_idx();
|
||||
static gboolean done = 1;
|
||||
|
||||
if (idx >= 0 && doc_list[idx].is_valid)
|
||||
if (idx >= 0 && documents[idx]->is_valid)
|
||||
{
|
||||
if (done++ % 3 == 0) sci_set_line_numbers(doc_list[idx].sci, editor_prefs.show_linenumber_margin,
|
||||
(sci_get_zoom(doc_list[idx].sci) / 2));
|
||||
sci_zoom_in(doc_list[idx].sci);
|
||||
if (done++ % 3 == 0) sci_set_line_numbers(documents[idx]->sci, editor_prefs.show_linenumber_margin,
|
||||
(sci_get_zoom(documents[idx]->sci) / 2));
|
||||
sci_zoom_in(documents[idx]->sci);
|
||||
}
|
||||
}
|
||||
|
||||
@ -671,11 +671,11 @@ on_zoom_out1_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx >= 0 && doc_list[idx].is_valid)
|
||||
if (idx >= 0 && documents[idx]->is_valid)
|
||||
{
|
||||
if (sci_get_zoom(doc_list[idx].sci) == 0)
|
||||
sci_set_line_numbers(doc_list[idx].sci, editor_prefs.show_linenumber_margin, 0);
|
||||
sci_zoom_out(doc_list[idx].sci);
|
||||
if (sci_get_zoom(documents[idx]->sci) == 0)
|
||||
sci_set_line_numbers(documents[idx]->sci, editor_prefs.show_linenumber_margin, 0);
|
||||
sci_zoom_out(documents[idx]->sci);
|
||||
}
|
||||
}
|
||||
|
||||
@ -685,10 +685,10 @@ on_normal_size1_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx >= 0 && doc_list[idx].is_valid)
|
||||
if (idx >= 0 && documents[idx]->is_valid)
|
||||
{
|
||||
sci_zoom_off(doc_list[idx].sci);
|
||||
sci_set_line_numbers(doc_list[idx].sci, editor_prefs.show_linenumber_margin, 0);
|
||||
sci_zoom_off(documents[idx]->sci);
|
||||
sci_set_line_numbers(documents[idx]->sci, editor_prefs.show_linenumber_margin, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -743,7 +743,7 @@ on_notebook1_switch_page_after (GtkNotebook *notebook,
|
||||
utils_check_disk_status(idx, FALSE);
|
||||
|
||||
#ifdef HAVE_VTE
|
||||
vte_cwd(doc_list[idx].file_name, FALSE);
|
||||
vte_cwd(documents[idx]->file_name, FALSE);
|
||||
#endif
|
||||
|
||||
if (geany_object)
|
||||
@ -780,9 +780,9 @@ on_crlf_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (ignore_callback || idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
sci_convert_eols(doc_list[idx].sci, SC_EOL_CRLF);
|
||||
sci_set_eol_mode(doc_list[idx].sci, SC_EOL_CRLF);
|
||||
if (ignore_callback || idx == -1 || ! documents[idx]->is_valid) return;
|
||||
sci_convert_eols(documents[idx]->sci, SC_EOL_CRLF);
|
||||
sci_set_eol_mode(documents[idx]->sci, SC_EOL_CRLF);
|
||||
}
|
||||
|
||||
|
||||
@ -791,9 +791,9 @@ on_lf_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (ignore_callback || idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
sci_convert_eols(doc_list[idx].sci, SC_EOL_LF);
|
||||
sci_set_eol_mode(doc_list[idx].sci, SC_EOL_LF);
|
||||
if (ignore_callback || idx == -1 || ! documents[idx]->is_valid) return;
|
||||
sci_convert_eols(documents[idx]->sci, SC_EOL_LF);
|
||||
sci_set_eol_mode(documents[idx]->sci, SC_EOL_LF);
|
||||
}
|
||||
|
||||
|
||||
@ -802,9 +802,9 @@ on_cr_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (ignore_callback || idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
sci_convert_eols(doc_list[idx].sci, SC_EOL_CR);
|
||||
sci_set_eol_mode(doc_list[idx].sci, SC_EOL_CR);
|
||||
if (ignore_callback || idx == -1 || ! documents[idx]->is_valid) return;
|
||||
sci_convert_eols(documents[idx]->sci, SC_EOL_CR);
|
||||
sci_set_eol_mode(documents[idx]->sci, SC_EOL_CR);
|
||||
}
|
||||
|
||||
|
||||
@ -858,7 +858,7 @@ toolbar_popup_menu (GtkWidget *widget,
|
||||
void on_toggle_case1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
ScintillaObject *sci = doc_list[idx].sci;
|
||||
ScintillaObject *sci = documents[idx]->sci;
|
||||
gchar *text;
|
||||
gboolean keep_sel = TRUE;
|
||||
|
||||
@ -971,7 +971,7 @@ on_line_wrapping1_toggled (GtkCheckMenuItem *checkmenuitem,
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
editor_set_line_wrapping(idx, ! doc_list[idx].line_wrapping);
|
||||
editor_set_line_wrapping(idx, ! documents[idx]->line_wrapping);
|
||||
}
|
||||
}
|
||||
|
||||
@ -984,8 +984,8 @@ on_set_file_readonly1_toggled (GtkCheckMenuItem *checkmenuitem,
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
doc_list[idx].readonly = ! doc_list[idx].readonly;
|
||||
sci_set_readonly(doc_list[idx].sci, doc_list[idx].readonly);
|
||||
documents[idx]->readonly = ! documents[idx]->readonly;
|
||||
sci_set_readonly(documents[idx]->sci, documents[idx]->readonly);
|
||||
ui_update_tab_status(idx);
|
||||
ui_update_statusbar(idx, -1);
|
||||
}
|
||||
@ -1000,7 +1000,7 @@ on_use_auto_indentation1_toggled (GtkCheckMenuItem *checkmenuitem,
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
doc_list[idx].auto_indent = ! doc_list[idx].auto_indent;
|
||||
documents[idx]->auto_indent = ! documents[idx]->auto_indent;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,10 +1015,10 @@ on_find_usage1_activate (GtkMenuItem *menuitem,
|
||||
idx = document_get_cur_idx();
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
if (sci_can_copy(doc_list[idx].sci))
|
||||
if (sci_can_copy(documents[idx]->sci))
|
||||
{ /* take selected text if there is a selection */
|
||||
search_text = g_malloc(sci_get_selected_text_length(doc_list[idx].sci) + 1);
|
||||
sci_get_selected_text(doc_list[idx].sci, search_text);
|
||||
search_text = g_malloc(sci_get_selected_text_length(documents[idx]->sci) + 1);
|
||||
sci_get_selected_text(documents[idx]->sci, search_text);
|
||||
flags = SCFIND_MATCHCASE;
|
||||
}
|
||||
else
|
||||
@ -1061,12 +1061,12 @@ on_show_color_chooser1_activate (GtkMenuItem *menuitem,
|
||||
{
|
||||
gchar colour[9];
|
||||
gint idx = document_get_cur_idx();
|
||||
gint pos = sci_get_current_position(doc_list[idx].sci);
|
||||
gint pos = sci_get_current_position(documents[idx]->sci);
|
||||
|
||||
if (idx == -1 || ! doc_list[idx].is_valid)
|
||||
if (idx == -1 || ! documents[idx]->is_valid)
|
||||
return;
|
||||
|
||||
editor_find_current_word(doc_list[idx].sci, pos, colour, sizeof colour, GEANY_WORDCHARS"#");
|
||||
editor_find_current_word(documents[idx]->sci, pos, colour, sizeof colour, GEANY_WORDCHARS"#");
|
||||
tools_color_chooser(colour);
|
||||
}
|
||||
|
||||
@ -1185,12 +1185,12 @@ on_goto_line_dialog_response (GtkDialog *dialog,
|
||||
gint idx = document_get_cur_idx();
|
||||
gint line = strtol(gtk_entry_get_text(GTK_ENTRY(user_data)), NULL, 10);
|
||||
|
||||
if (line > 0 && line <= sci_get_line_count(doc_list[idx].sci))
|
||||
if (line > 0 && line <= sci_get_line_count(documents[idx]->sci))
|
||||
{
|
||||
gint pos;
|
||||
|
||||
line--; /* the user counts lines from 1, we begin at 0 so bring the user line to our one */
|
||||
pos = sci_get_position_from_line(doc_list[idx].sci, line);
|
||||
pos = sci_get_position_from_line(documents[idx]->sci, line);
|
||||
editor_goto_pos(idx, pos, TRUE);
|
||||
}
|
||||
else
|
||||
@ -1280,7 +1280,7 @@ on_comments_function_activate (GtkMenuItem *menuitem,
|
||||
const gchar *cur_tag = NULL;
|
||||
gint line = -1, pos = 0;
|
||||
|
||||
if (doc_list[idx].file_type == NULL)
|
||||
if (documents[idx]->file_type == NULL)
|
||||
{
|
||||
ui_set_statusbar(FALSE, _("Please set the filetype for the current file before using this function."));
|
||||
return;
|
||||
@ -1289,11 +1289,11 @@ on_comments_function_activate (GtkMenuItem *menuitem,
|
||||
/* utils_get_current_function returns -1 on failure, so sci_get_position_from_line
|
||||
* returns the current position, so it should be safe */
|
||||
line = utils_get_current_function(idx, &cur_tag);
|
||||
pos = sci_get_position_from_line(doc_list[idx].sci, line - 1);
|
||||
pos = sci_get_position_from_line(documents[idx]->sci, line - 1);
|
||||
|
||||
text = templates_get_template_function(doc_list[idx].file_type->id, cur_tag);
|
||||
text = templates_get_template_function(documents[idx]->file_type->id, cur_tag);
|
||||
|
||||
sci_insert_text(doc_list[idx].sci, pos, text);
|
||||
sci_insert_text(documents[idx]->sci, pos, text);
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
@ -1304,7 +1304,7 @@ on_comments_multiline_activate (GtkMenuItem *menuitem,
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
|
||||
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_type == NULL)
|
||||
if (! DOC_IDX_VALID(idx) || documents[idx]->file_type == NULL)
|
||||
{
|
||||
ui_set_statusbar(FALSE, _("Please set the filetype for the current file before using this function."));
|
||||
return;
|
||||
@ -1323,11 +1323,11 @@ on_comments_gpl_activate (GtkMenuItem *menuitem,
|
||||
gint idx = document_get_cur_idx();
|
||||
gchar *text;
|
||||
|
||||
text = templates_get_template_licence(FILETYPE_ID(doc_list[idx].file_type), GEANY_TEMPLATE_GPL);
|
||||
text = templates_get_template_licence(FILETYPE_ID(documents[idx]->file_type), GEANY_TEMPLATE_GPL);
|
||||
|
||||
verify_click_pos(idx); /* make sure that the click_pos is valid */
|
||||
|
||||
sci_insert_text(doc_list[idx].sci, editor_info.click_pos, text);
|
||||
sci_insert_text(documents[idx]->sci, editor_info.click_pos, text);
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
@ -1340,11 +1340,11 @@ on_comments_bsd_activate (GtkMenuItem *menuitem,
|
||||
gint idx = document_get_cur_idx();
|
||||
gchar *text;
|
||||
|
||||
text = templates_get_template_licence(FILETYPE_ID(doc_list[idx].file_type), GEANY_TEMPLATE_BSD);
|
||||
text = templates_get_template_licence(FILETYPE_ID(documents[idx]->file_type), GEANY_TEMPLATE_BSD);
|
||||
|
||||
verify_click_pos(idx); /* make sure that the click_pos is valid */
|
||||
|
||||
sci_insert_text(doc_list[idx].sci, editor_info.click_pos, text);
|
||||
sci_insert_text(documents[idx]->sci, editor_info.click_pos, text);
|
||||
g_free(text);
|
||||
|
||||
}
|
||||
@ -1358,10 +1358,10 @@ on_comments_changelog_activate (GtkMenuItem *menuitem,
|
||||
gchar *text;
|
||||
|
||||
text = templates_get_template_changelog();
|
||||
sci_insert_text(doc_list[idx].sci, 0, text);
|
||||
sci_insert_text(documents[idx]->sci, 0, text);
|
||||
/* sets the cursor to the right position to type the changelog text,
|
||||
* the template has 21 chars + length of name and email */
|
||||
sci_goto_pos(doc_list[idx].sci, 21 + strlen(template_prefs.developer) + strlen(template_prefs.mail), TRUE);
|
||||
sci_goto_pos(documents[idx]->sci, 21 + strlen(template_prefs.developer) + strlen(template_prefs.mail), TRUE);
|
||||
|
||||
g_free(text);
|
||||
}
|
||||
@ -1378,12 +1378,12 @@ on_comments_fileheader_activate (GtkMenuItem *menuitem,
|
||||
|
||||
g_return_if_fail(DOC_IDX_VALID(idx));
|
||||
|
||||
ft = doc_list[idx].file_type;
|
||||
fname = doc_list[idx].file_name;
|
||||
ft = documents[idx]->file_type;
|
||||
fname = documents[idx]->file_name;
|
||||
text = templates_get_template_fileheader(FILETYPE_ID(ft), fname);
|
||||
|
||||
sci_insert_text(doc_list[idx].sci, 0, text);
|
||||
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
|
||||
sci_insert_text(documents[idx]->sci, 0, text);
|
||||
sci_goto_pos(documents[idx]->sci, 0, FALSE);
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
@ -1406,7 +1406,7 @@ on_insert_date_activate (GtkMenuItem *menuitem,
|
||||
time_t t;
|
||||
struct tm *tm;
|
||||
|
||||
if (idx < 0 || ! doc_list[idx].is_valid) return;
|
||||
if (idx < 0 || ! documents[idx]->is_valid) return;
|
||||
|
||||
if (utils_str_equal(_("dd.mm.yyyy"), (gchar*) user_data))
|
||||
format = "%d.%m.%Y";
|
||||
@ -1444,8 +1444,8 @@ on_insert_date_activate (GtkMenuItem *menuitem,
|
||||
{
|
||||
verify_click_pos(idx); /* make sure that the click_pos is valid */
|
||||
|
||||
sci_insert_text(doc_list[idx].sci, editor_info.click_pos, time_str);
|
||||
sci_goto_pos(doc_list[idx].sci, editor_info.click_pos + strlen(time_str), FALSE);
|
||||
sci_insert_text(documents[idx]->sci, editor_info.click_pos, time_str);
|
||||
sci_goto_pos(documents[idx]->sci, editor_info.click_pos + strlen(time_str), FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1478,10 +1478,10 @@ on_insert_include_activate (GtkMenuItem *menuitem,
|
||||
text = g_strconcat("#include <", user_data, ">\n", NULL);
|
||||
}
|
||||
|
||||
sci_insert_text(doc_list[idx].sci, editor_info.click_pos, text);
|
||||
sci_insert_text(documents[idx]->sci, editor_info.click_pos, text);
|
||||
g_free(text);
|
||||
if (pos >= 0)
|
||||
sci_goto_pos(doc_list[idx].sci, pos, FALSE);
|
||||
sci_goto_pos(documents[idx]->sci, pos, FALSE);
|
||||
}
|
||||
|
||||
|
||||
@ -1551,14 +1551,14 @@ on_encoding_change (GtkMenuItem *menuitem,
|
||||
guint i = GPOINTER_TO_INT(user_data);
|
||||
|
||||
if (ignore_callback || ! DOC_IDX_VALID(idx) || encodings[i].charset == NULL ||
|
||||
utils_str_equal(encodings[i].charset, doc_list[idx].encoding)) return;
|
||||
utils_str_equal(encodings[i].charset, documents[idx]->encoding)) return;
|
||||
|
||||
if (doc_list[idx].readonly)
|
||||
if (documents[idx]->readonly)
|
||||
{
|
||||
utils_beep();
|
||||
return;
|
||||
}
|
||||
document_undo_add(idx, UNDO_ENCODING, g_strdup(doc_list[idx].encoding));
|
||||
document_undo_add(idx, UNDO_ENCODING, g_strdup(documents[idx]->encoding));
|
||||
|
||||
document_set_encoding(idx, encodings[i].charset);
|
||||
}
|
||||
@ -1581,9 +1581,9 @@ on_menu_select_all1_activate (GtkMenuItem *menuitem,
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
|
||||
if (idx < 0 || ! doc_list[idx].is_valid) return;
|
||||
if (idx < 0 || ! documents[idx]->is_valid) return;
|
||||
|
||||
sci_select_all(doc_list[idx].sci);
|
||||
sci_select_all(documents[idx]->sci);
|
||||
}
|
||||
|
||||
|
||||
@ -1623,16 +1623,16 @@ on_menu_write_unicode_bom1_toggled (GtkCheckMenuItem *checkmenuitem,
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (doc_list[idx].readonly)
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
if (documents[idx]->readonly)
|
||||
{
|
||||
utils_beep();
|
||||
return;
|
||||
}
|
||||
|
||||
document_undo_add(idx, UNDO_BOM, GINT_TO_POINTER(doc_list[idx].has_bom));
|
||||
document_undo_add(idx, UNDO_BOM, GINT_TO_POINTER(documents[idx]->has_bom));
|
||||
|
||||
doc_list[idx].has_bom = ! doc_list[idx].has_bom;
|
||||
documents[idx]->has_bom = ! documents[idx]->has_bom;
|
||||
|
||||
ui_update_statusbar(idx, -1);
|
||||
}
|
||||
@ -1644,7 +1644,7 @@ on_menu_comment_line1_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
editor_do_comment(idx, -1, FALSE, FALSE);
|
||||
}
|
||||
|
||||
@ -1654,7 +1654,7 @@ on_menu_uncomment_line1_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
editor_do_uncomment(idx, -1, FALSE);
|
||||
}
|
||||
|
||||
@ -1665,7 +1665,7 @@ on_menu_toggle_line_commentation1_activate
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
editor_do_comment_toggle(idx);
|
||||
}
|
||||
|
||||
@ -1685,24 +1685,24 @@ on_menu_increase_indent1_activate (GtkMenuItem *menuitem,
|
||||
gint idx = document_get_cur_idx();
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
if (sci_get_lines_selected(doc_list[idx].sci) > 1)
|
||||
if (sci_get_lines_selected(documents[idx]->sci) > 1)
|
||||
{
|
||||
sci_cmd(doc_list[idx].sci, SCI_TAB);
|
||||
sci_cmd(documents[idx]->sci, SCI_TAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint line, ind_pos, old_pos, new_pos, step;
|
||||
|
||||
old_pos = sci_get_current_position(doc_list[idx].sci);
|
||||
line = sci_get_line_from_position(doc_list[idx].sci, old_pos);
|
||||
ind_pos = sci_get_line_indent_position(doc_list[idx].sci, line);
|
||||
old_pos = sci_get_current_position(documents[idx]->sci);
|
||||
line = sci_get_line_from_position(documents[idx]->sci, old_pos);
|
||||
ind_pos = sci_get_line_indent_position(documents[idx]->sci, line);
|
||||
/* when using tabs increase cur pos by 1, when using space increase it by tab_width */
|
||||
step = (doc_list[idx].use_tabs) ? 1 : editor_prefs.tab_width;
|
||||
step = (documents[idx]->use_tabs) ? 1 : editor_prefs.tab_width;
|
||||
new_pos = (old_pos > ind_pos) ? old_pos + step : old_pos;
|
||||
|
||||
sci_set_current_position(doc_list[idx].sci, ind_pos, TRUE);
|
||||
sci_cmd(doc_list[idx].sci, SCI_TAB);
|
||||
sci_set_current_position(doc_list[idx].sci, new_pos, TRUE);
|
||||
sci_set_current_position(documents[idx]->sci, ind_pos, TRUE);
|
||||
sci_cmd(documents[idx]->sci, SCI_TAB);
|
||||
sci_set_current_position(documents[idx]->sci, new_pos, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1714,31 +1714,31 @@ on_menu_decrease_indent1_activate (GtkMenuItem *menuitem,
|
||||
gint idx = document_get_cur_idx();
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
if (sci_get_lines_selected(doc_list[idx].sci) > 1)
|
||||
if (sci_get_lines_selected(documents[idx]->sci) > 1)
|
||||
{
|
||||
sci_cmd(doc_list[idx].sci, SCI_BACKTAB);
|
||||
sci_cmd(documents[idx]->sci, SCI_BACKTAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint line, ind_pos, old_pos, new_pos, step, indent;
|
||||
|
||||
old_pos = sci_get_current_position(doc_list[idx].sci);
|
||||
line = sci_get_line_from_position(doc_list[idx].sci, old_pos);
|
||||
ind_pos = sci_get_line_indent_position(doc_list[idx].sci, line);
|
||||
step = (doc_list[idx].use_tabs) ? 1 : editor_prefs.tab_width;
|
||||
old_pos = sci_get_current_position(documents[idx]->sci);
|
||||
line = sci_get_line_from_position(documents[idx]->sci, old_pos);
|
||||
ind_pos = sci_get_line_indent_position(documents[idx]->sci, line);
|
||||
step = (documents[idx]->use_tabs) ? 1 : editor_prefs.tab_width;
|
||||
new_pos = (old_pos >= ind_pos) ? old_pos - step : old_pos;
|
||||
|
||||
if (ind_pos == sci_get_position_from_line(doc_list[idx].sci, line))
|
||||
if (ind_pos == sci_get_position_from_line(documents[idx]->sci, line))
|
||||
return;
|
||||
|
||||
sci_set_current_position(doc_list[idx].sci, ind_pos, TRUE);
|
||||
indent = sci_get_line_indentation(doc_list[idx].sci, line);
|
||||
sci_set_current_position(documents[idx]->sci, ind_pos, TRUE);
|
||||
indent = sci_get_line_indentation(documents[idx]->sci, line);
|
||||
indent -= editor_prefs.tab_width;
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
sci_set_line_indentation(doc_list[idx].sci, line, indent);
|
||||
sci_set_line_indentation(documents[idx]->sci, line, indent);
|
||||
|
||||
sci_set_current_position(doc_list[idx].sci, new_pos, TRUE);
|
||||
sci_set_current_position(documents[idx]->sci, new_pos, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1869,7 +1869,7 @@ on_menu_open_selected_file1_activate (GtkMenuItem *menuitem,
|
||||
{ /* relative filename, add the path of the current file */
|
||||
gchar *path;
|
||||
|
||||
path = g_path_get_dirname(doc_list[idx].file_name);
|
||||
path = g_path_get_dirname(documents[idx]->file_name);
|
||||
filename = g_build_path(G_DIR_SEPARATOR_S, path, sel, NULL);
|
||||
|
||||
if (! g_file_test(filename, G_FILE_TEST_EXISTS) &&
|
||||
@ -1901,8 +1901,8 @@ on_remove_markers1_activate (GtkMenuItem *menuitem,
|
||||
if (! DOC_IDX_VALID(idx))
|
||||
return;
|
||||
|
||||
sci_marker_delete_all(doc_list[idx].sci, 0); /* delete the yellow tag marker */
|
||||
sci_marker_delete_all(doc_list[idx].sci, 1); /* delete user markers */
|
||||
sci_marker_delete_all(documents[idx]->sci, 0); /* delete the yellow tag marker */
|
||||
sci_marker_delete_all(documents[idx]->sci, 1); /* delete user markers */
|
||||
}
|
||||
|
||||
|
||||
@ -1925,10 +1925,10 @@ on_context_action1_activate (GtkMenuItem *menuitem,
|
||||
idx = document_get_cur_idx();
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
if (sci_can_copy(doc_list[idx].sci))
|
||||
if (sci_can_copy(documents[idx]->sci))
|
||||
{ /* take selected text if there is a selection */
|
||||
word = g_malloc(sci_get_selected_text_length(doc_list[idx].sci) + 1);
|
||||
sci_get_selected_text(doc_list[idx].sci, word);
|
||||
word = g_malloc(sci_get_selected_text_length(documents[idx]->sci) + 1);
|
||||
sci_get_selected_text(documents[idx]->sci, word);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1936,11 +1936,11 @@ on_context_action1_activate (GtkMenuItem *menuitem,
|
||||
}
|
||||
|
||||
/* use the filetype specific command if available, fallback to global command otherwise */
|
||||
if (doc_list[idx].file_type != NULL &&
|
||||
doc_list[idx].file_type->context_action_cmd != NULL &&
|
||||
*doc_list[idx].file_type->context_action_cmd != '\0')
|
||||
if (documents[idx]->file_type != NULL &&
|
||||
documents[idx]->file_type->context_action_cmd != NULL &&
|
||||
*documents[idx]->file_type->context_action_cmd != '\0')
|
||||
{
|
||||
command = g_strdup(doc_list[idx].file_type->context_action_cmd);
|
||||
command = g_strdup(documents[idx]->file_type->context_action_cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -393,11 +393,11 @@ static void handle_save_as(const gchar *utf8_filename, gboolean open_new_tab,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doc_list[idx].file_name != NULL)
|
||||
if (documents[idx]->file_name != NULL)
|
||||
{
|
||||
if (rename_file)
|
||||
{
|
||||
gchar *old_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
gchar *old_filename = utils_get_locale_from_utf8(documents[idx]->file_name);
|
||||
gchar *new_filename = utils_get_locale_from_utf8(utf8_filename);
|
||||
|
||||
g_rename(old_filename, new_filename);
|
||||
@ -405,11 +405,11 @@ static void handle_save_as(const gchar *utf8_filename, gboolean open_new_tab,
|
||||
g_free(new_filename);
|
||||
}
|
||||
/* create a new tm_source_file object otherwise tagmanager won't work correctly */
|
||||
tm_workspace_remove_object(doc_list[idx].tm_file, TRUE, TRUE);
|
||||
doc_list[idx].tm_file = NULL;
|
||||
g_free(doc_list[idx].file_name);
|
||||
tm_workspace_remove_object(documents[idx]->tm_file, TRUE, TRUE);
|
||||
documents[idx]->tm_file = NULL;
|
||||
g_free(documents[idx]->file_name);
|
||||
}
|
||||
doc_list[idx].file_name = g_strdup(utf8_filename);
|
||||
documents[idx]->file_name = g_strdup(utf8_filename);
|
||||
}
|
||||
|
||||
document_save_file_as(idx);
|
||||
@ -528,11 +528,11 @@ static gboolean gtk_show_save_as(const gchar *initdir)
|
||||
|
||||
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(ui_widgets.save_filesel));
|
||||
|
||||
if (doc_list[idx].file_name != NULL)
|
||||
if (documents[idx]->file_name != NULL)
|
||||
{
|
||||
if (g_path_is_absolute(doc_list[idx].file_name))
|
||||
if (g_path_is_absolute(documents[idx]->file_name))
|
||||
{
|
||||
gchar *locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
gchar *locale_filename = utils_get_locale_from_utf8(documents[idx]->file_name);
|
||||
gchar *locale_basename = g_path_get_basename(locale_filename);
|
||||
gchar *locale_dirname = g_path_get_dirname(locale_filename);
|
||||
|
||||
@ -548,16 +548,16 @@ static gboolean gtk_show_save_as(const gchar *initdir)
|
||||
}
|
||||
else
|
||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(ui_widgets.save_filesel),
|
||||
doc_list[idx].file_name);
|
||||
documents[idx]->file_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *fname = NULL;
|
||||
|
||||
if (doc_list[idx].file_type != NULL && doc_list[idx].file_type->id != GEANY_FILETYPES_NONE &&
|
||||
doc_list[idx].file_type->extension != NULL)
|
||||
if (documents[idx]->file_type != NULL && documents[idx]->file_type->id != GEANY_FILETYPES_NONE &&
|
||||
documents[idx]->file_type->extension != NULL)
|
||||
fname = g_strconcat(GEANY_STRING_UNTITLED, ".",
|
||||
doc_list[idx].file_type->extension, NULL);
|
||||
documents[idx]->file_type->extension, NULL);
|
||||
else
|
||||
fname = g_strdup(GEANY_STRING_UNTITLED);
|
||||
|
||||
@ -672,9 +672,9 @@ gboolean dialogs_show_unsaved_file(gint idx)
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
|
||||
document_get_notebook_page(idx));
|
||||
|
||||
if (doc_list[idx].file_name != NULL)
|
||||
if (documents[idx]->file_name != NULL)
|
||||
{
|
||||
short_fn = g_path_get_basename(doc_list[idx].file_name);
|
||||
short_fn = g_path_get_basename(documents[idx]->file_name);
|
||||
}
|
||||
|
||||
msg = g_strdup_printf(_("The file '%s' is not saved."),
|
||||
@ -708,7 +708,7 @@ gboolean dialogs_show_unsaved_file(gint idx)
|
||||
{
|
||||
case GTK_RESPONSE_YES:
|
||||
{
|
||||
if (doc_list[idx].file_name == NULL)
|
||||
if (documents[idx]->file_name == NULL)
|
||||
{
|
||||
ret = dialogs_show_save_as();
|
||||
}
|
||||
@ -969,7 +969,7 @@ void dialogs_show_file_properties(gint idx)
|
||||
# define S_IXOTH 0
|
||||
#endif
|
||||
|
||||
if (idx == -1 || ! doc_list[idx].is_valid || doc_list[idx].file_name == NULL)
|
||||
if (idx == -1 || ! documents[idx]->is_valid || documents[idx]->file_name == NULL)
|
||||
{
|
||||
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
|
||||
_("An error occurred or file information could not be retrieved (e.g. from a new file)."));
|
||||
@ -978,7 +978,7 @@ void dialogs_show_file_properties(gint idx)
|
||||
|
||||
|
||||
#if defined(HAVE_SYS_STAT_H) && defined(TIME_WITH_SYS_TIME) && defined(HAVE_SYS_TYPES_H)
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(documents[idx]->file_name);
|
||||
if (g_stat(locale_filename, &st) == 0)
|
||||
{
|
||||
/* first copy the returned string and the trim it, to not modify the static glibc string
|
||||
@ -1004,7 +1004,7 @@ void dialogs_show_file_properties(gint idx)
|
||||
time_accessed = g_strdup(_("unknown"));
|
||||
#endif
|
||||
|
||||
base_name = g_path_get_basename(doc_list[idx].file_name);
|
||||
base_name = g_path_get_basename(documents[idx]->file_name);
|
||||
title = g_strconcat(base_name, " ", _("Properties"), NULL);
|
||||
dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(main_widgets.window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
@ -1041,7 +1041,7 @@ void dialogs_show_file_properties(gint idx)
|
||||
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
|
||||
|
||||
label = gtk_label_new(doc_list[idx].file_type->title);
|
||||
label = gtk_label_new(documents[idx]->file_type->title);
|
||||
gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
@ -1069,7 +1069,7 @@ void dialogs_show_file_properties(gint idx)
|
||||
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
|
||||
|
||||
label = gtk_label_new(doc_list[idx].file_name);
|
||||
label = gtk_label_new(documents[idx]->file_name);
|
||||
gtk_table_attach(GTK_TABLE(table), label, 1, 2, 2, 3,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
@ -1085,7 +1085,7 @@ void dialogs_show_file_properties(gint idx)
|
||||
check = gtk_check_button_new_with_label(_("(only inside Geany)"));
|
||||
gtk_widget_set_sensitive(check, FALSE);
|
||||
gtk_button_set_focus_on_click(GTK_BUTTON(check), FALSE);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), doc_list[idx].readonly);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), documents[idx]->readonly);
|
||||
gtk_table_attach(GTK_TABLE(table), check, 1, 2, 3, 4,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
@ -1099,9 +1099,9 @@ void dialogs_show_file_properties(gint idx)
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
|
||||
|
||||
enctext = g_strdup_printf("%s %s",
|
||||
doc_list[idx].encoding,
|
||||
(encodings_is_unicode_charset(doc_list[idx].encoding)) ?
|
||||
((doc_list[idx].has_bom) ? _("(with BOM)") : _("(without BOM)")) : "");
|
||||
documents[idx]->encoding,
|
||||
(encodings_is_unicode_charset(documents[idx]->encoding)) ?
|
||||
((documents[idx]->has_bom) ? _("(with BOM)") : _("(without BOM)")) : "");
|
||||
|
||||
label = gtk_label_new(enctext);
|
||||
g_free(enctext);
|
||||
|
534
src/document.c
534
src/document.c
File diff suppressed because it is too large
Load Diff
@ -130,14 +130,14 @@ typedef struct _GeanyDocument
|
||||
} GeanyDocument;
|
||||
|
||||
|
||||
/* Dynamic array of document elements to hold all information of the notebook tabs. */
|
||||
extern GArray *doc_array;
|
||||
/** Dynamic array of GeanyDocument pointers holding information about the notebook tabs. */
|
||||
extern GPtrArray *documents_array;
|
||||
|
||||
/**
|
||||
* doc_list wraps doc_array so it can be used with C array syntax.
|
||||
* Example: doc_list[0].sci = NULL;
|
||||
* This wraps documents_array so it can be used with C array syntax.
|
||||
* Example: documents[0]->sci = NULL;
|
||||
**/
|
||||
#define doc_list ((GeanyDocument *)doc_array->data)
|
||||
#define documents ((GeanyDocument **)documents_array->pdata)
|
||||
|
||||
/**
|
||||
* DOC_IDX_VALID checks whether the passed index points to a valid %document object by checking
|
||||
@ -145,7 +145,7 @@ extern GArray *doc_array;
|
||||
* must not be used.
|
||||
**/
|
||||
#define DOC_IDX_VALID(doc_idx) \
|
||||
((doc_idx) >= 0 && (guint)(doc_idx) < doc_array->len && doc_list[doc_idx].is_valid)
|
||||
((doc_idx) >= 0 && (guint)(doc_idx) < documents_array->len && documents[doc_idx]->is_valid)
|
||||
|
||||
/**
|
||||
* DOC_FILENAME) returns the filename of the %document corresponding to the passed index or
|
||||
@ -153,7 +153,8 @@ extern GArray *doc_array;
|
||||
* This macro never returns NULL.
|
||||
**/
|
||||
#define DOC_FILENAME(doc_idx) \
|
||||
((doc_list[doc_idx].file_name != NULL) ? (doc_list[doc_idx].file_name) : GEANY_STRING_UNTITLED)
|
||||
((documents[doc_idx]->file_name != NULL) ? (documents[doc_idx]->file_name) : \
|
||||
GEANY_STRING_UNTITLED)
|
||||
|
||||
|
||||
gint document_find_by_filename(const gchar *filename, gboolean is_tm_filename);
|
||||
|
532
src/editor.c
532
src/editor.c
File diff suppressed because it is too large
Load Diff
@ -666,8 +666,8 @@ GeanyFiletype *filetypes_detect_from_file(gint idx)
|
||||
if (! DOC_IDX_VALID(idx))
|
||||
return filetypes[GEANY_FILETYPES_NONE];
|
||||
|
||||
line = sci_get_line(doc_list[idx].sci, 0);
|
||||
ft = filetypes_detect_from_file_internal(doc_list[idx].file_name, line);
|
||||
line = sci_get_line(documents[idx]->sci, 0);
|
||||
ft = filetypes_detect_from_file_internal(documents[idx]->file_name, line);
|
||||
g_free(line);
|
||||
return ft;
|
||||
}
|
||||
@ -716,7 +716,7 @@ on_filetype_change (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (ignore_callback || idx < 0 || ! doc_list[idx].is_valid) return;
|
||||
if (ignore_callback || idx < 0 || ! documents[idx]->is_valid) return;
|
||||
|
||||
document_set_filetype(idx, (GeanyFiletype*)user_data);
|
||||
}
|
||||
|
@ -787,9 +787,9 @@ static gboolean check_snippet_completion(guint keyval, guint state)
|
||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||
|
||||
/* keybinding only valid when scintilla widget has focus */
|
||||
if (DOC_IDX_VALID(idx) && focusw == GTK_WIDGET(doc_list[idx].sci))
|
||||
if (DOC_IDX_VALID(idx) && focusw == GTK_WIDGET(documents[idx]->sci))
|
||||
{
|
||||
ScintillaObject *sci = doc_list[idx].sci;
|
||||
ScintillaObject *sci = documents[idx]->sci;
|
||||
gint pos = sci_get_current_position(sci);
|
||||
|
||||
if (editor_prefs.complete_snippets)
|
||||
@ -1067,14 +1067,14 @@ static void cb_func_menu_zoomout(G_GNUC_UNUSED guint key_id)
|
||||
static void cb_func_menu_foldall(G_GNUC_UNUSED guint key_id)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
editor_fold_all(idx);
|
||||
}
|
||||
|
||||
static void cb_func_menu_unfoldall(G_GNUC_UNUSED guint key_id)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
editor_unfold_all(idx);
|
||||
}
|
||||
|
||||
@ -1087,7 +1087,7 @@ static void cb_func_build_action(guint key_id)
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
ft = doc_list[idx].file_type;
|
||||
ft = documents[idx]->file_type;
|
||||
if (! ft) return;
|
||||
menu_items = build_get_menu_items(ft->id);
|
||||
|
||||
@ -1133,7 +1133,7 @@ static void cb_func_build_action(guint key_id)
|
||||
static void cb_func_reloadtaglist(G_GNUC_UNUSED guint key_id)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
document_update_tag_list(idx, TRUE);
|
||||
}
|
||||
|
||||
@ -1146,9 +1146,9 @@ static gboolean check_current_word(void)
|
||||
if (! DOC_IDX_VALID(idx))
|
||||
return FALSE;
|
||||
|
||||
pos = sci_get_current_position(doc_list[idx].sci);
|
||||
pos = sci_get_current_position(documents[idx]->sci);
|
||||
|
||||
editor_find_current_word(doc_list[idx].sci, pos,
|
||||
editor_find_current_word(documents[idx]->sci, pos,
|
||||
editor_info.current_word, GEANY_MAX_WORD_LENGTH, NULL);
|
||||
|
||||
if (*editor_info.current_word == 0)
|
||||
@ -1163,8 +1163,8 @@ static gboolean check_current_word(void)
|
||||
static void cb_func_switch_editor(G_GNUC_UNUSED guint key_id)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
gtk_widget_grab_focus(GTK_WIDGET(doc_list[idx].sci));
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
gtk_widget_grab_focus(GTK_WIDGET(documents[idx]->sci));
|
||||
}
|
||||
|
||||
static void cb_func_switch_scribble(G_GNUC_UNUSED guint key_id)
|
||||
@ -1241,7 +1241,7 @@ static void cb_func_switch_tablastused(G_GNUC_UNUSED guint key_id)
|
||||
static void cb_func_move_tab(guint key_id)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
GtkWidget *sci = GTK_WIDGET(doc_list[idx].sci);
|
||||
GtkWidget *sci = GTK_WIDGET(documents[idx]->sci);
|
||||
GtkNotebook *nb = GTK_NOTEBOOK(main_widgets.notebook);
|
||||
gint cur_page = gtk_notebook_get_current_page(nb);
|
||||
|
||||
@ -1290,14 +1290,14 @@ static void goto_matching_brace(gint idx)
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
pos = sci_get_current_position(doc_list[idx].sci);
|
||||
if (! utils_isbrace(sci_get_char_at(doc_list[idx].sci, pos), TRUE))
|
||||
pos = sci_get_current_position(documents[idx]->sci);
|
||||
if (! utils_isbrace(sci_get_char_at(documents[idx]->sci, pos), TRUE))
|
||||
pos--; /* set pos to the brace */
|
||||
|
||||
new_pos = sci_find_bracematch(doc_list[idx].sci, pos);
|
||||
new_pos = sci_find_bracematch(documents[idx]->sci, pos);
|
||||
if (new_pos != -1)
|
||||
{ /* set the cursor at the brace */
|
||||
sci_set_current_position(doc_list[idx].sci, new_pos, FALSE);
|
||||
sci_set_current_position(documents[idx]->sci, new_pos, FALSE);
|
||||
editor_display_current_line(idx, 0.5F);
|
||||
}
|
||||
}
|
||||
@ -1321,10 +1321,10 @@ static void cb_func_clipboard(guint key_id)
|
||||
on_paste1_activate(NULL, NULL);
|
||||
break;
|
||||
case GEANY_KEYS_CLIPBOARD_COPYLINE:
|
||||
sci_cmd(doc_list[idx].sci, SCI_LINECOPY);
|
||||
sci_cmd(documents[idx]->sci, SCI_LINECOPY);
|
||||
break;
|
||||
case GEANY_KEYS_CLIPBOARD_CUTLINE:
|
||||
sci_cmd(doc_list[idx].sci, SCI_LINECUT);
|
||||
sci_cmd(documents[idx]->sci, SCI_LINECUT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1338,7 +1338,7 @@ static void cb_func_goto_action(guint key_id)
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
cur_line = sci_get_current_line(doc_list[idx].sci);
|
||||
cur_line = sci_get_current_line(documents[idx]->sci);
|
||||
|
||||
switch (key_id)
|
||||
{
|
||||
@ -1356,29 +1356,29 @@ static void cb_func_goto_action(guint key_id)
|
||||
break;
|
||||
case GEANY_KEYS_GOTO_TOGGLEMARKER:
|
||||
{
|
||||
gboolean set = sci_is_marker_set_at_line(doc_list[idx].sci, cur_line, 1);
|
||||
gboolean set = sci_is_marker_set_at_line(documents[idx]->sci, cur_line, 1);
|
||||
|
||||
sci_set_marker_at_line(doc_list[idx].sci, cur_line, ! set, 1);
|
||||
sci_set_marker_at_line(documents[idx]->sci, cur_line, ! set, 1);
|
||||
break;
|
||||
}
|
||||
case GEANY_KEYS_GOTO_NEXTMARKER:
|
||||
{
|
||||
gint mline = sci_marker_next(doc_list[idx].sci, cur_line + 1, 1 << 1, TRUE);
|
||||
gint mline = sci_marker_next(documents[idx]->sci, cur_line + 1, 1 << 1, TRUE);
|
||||
|
||||
if (mline != -1)
|
||||
{
|
||||
sci_set_current_line(doc_list[idx].sci, mline);
|
||||
sci_set_current_line(documents[idx]->sci, mline);
|
||||
editor_display_current_line(idx, 0.5F);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GEANY_KEYS_GOTO_PREVIOUSMARKER:
|
||||
{
|
||||
gint mline = sci_marker_previous(doc_list[idx].sci, cur_line - 1, 1 << 1, TRUE);
|
||||
gint mline = sci_marker_previous(documents[idx]->sci, cur_line - 1, 1 << 1, TRUE);
|
||||
|
||||
if (mline != -1)
|
||||
{
|
||||
sci_set_current_line(doc_list[idx].sci, mline);
|
||||
sci_set_current_line(documents[idx]->sci, mline);
|
||||
editor_display_current_line(idx, 0.5F);
|
||||
}
|
||||
break;
|
||||
@ -1423,7 +1423,7 @@ static void cb_func_editor_action(guint key_id)
|
||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||
|
||||
/* edit keybindings only valid when scintilla widget has focus */
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(doc_list[idx].sci)) return;
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(documents[idx]->sci)) return;
|
||||
|
||||
switch (key_id)
|
||||
{
|
||||
@ -1434,31 +1434,31 @@ static void cb_func_editor_action(guint key_id)
|
||||
on_redo1_activate(NULL, NULL);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_SCROLLTOLINE:
|
||||
editor_scroll_to_line(doc_list[idx].sci, -1, 0.5F);
|
||||
editor_scroll_to_line(documents[idx]->sci, -1, 0.5F);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_SCROLLLINEUP:
|
||||
sci_cmd(doc_list[idx].sci, SCI_LINESCROLLUP);
|
||||
sci_cmd(documents[idx]->sci, SCI_LINESCROLLUP);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_SCROLLLINEDOWN:
|
||||
sci_cmd(doc_list[idx].sci, SCI_LINESCROLLDOWN);
|
||||
sci_cmd(documents[idx]->sci, SCI_LINESCROLLDOWN);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_DUPLICATELINE:
|
||||
duplicate_lines(doc_list[idx].sci);
|
||||
duplicate_lines(documents[idx]->sci);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_DELETELINE:
|
||||
delete_lines(doc_list[idx].sci);
|
||||
delete_lines(documents[idx]->sci);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_TRANSPOSELINE:
|
||||
sci_cmd(doc_list[idx].sci, SCI_LINETRANSPOSE);
|
||||
sci_cmd(documents[idx]->sci, SCI_LINETRANSPOSE);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_AUTOCOMPLETE:
|
||||
editor_start_auto_complete(idx, sci_get_current_position(doc_list[idx].sci), TRUE);
|
||||
editor_start_auto_complete(idx, sci_get_current_position(documents[idx]->sci), TRUE);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_CALLTIP:
|
||||
editor_show_calltip(idx, -1);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_MACROLIST:
|
||||
editor_show_macro_list(doc_list[idx].sci);
|
||||
editor_show_macro_list(documents[idx]->sci);
|
||||
break;
|
||||
case GEANY_KEYS_EDITOR_CONTEXTACTION:
|
||||
if (check_current_word())
|
||||
@ -1473,10 +1473,10 @@ static void cb_func_editor_action(guint key_id)
|
||||
switch (kb->key)
|
||||
{
|
||||
case GDK_space:
|
||||
sci_add_text(doc_list[idx].sci, " ");
|
||||
sci_add_text(documents[idx]->sci, " ");
|
||||
break;
|
||||
case GDK_Tab:
|
||||
sci_cmd(doc_list[idx].sci, SCI_TAB);
|
||||
sci_cmd(documents[idx]->sci, SCI_TAB);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1494,7 +1494,7 @@ static void cb_func_format_action(guint key_id)
|
||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||
|
||||
/* keybindings only valid when scintilla widget has focus */
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(doc_list[idx].sci)) return;
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(documents[idx]->sci)) return;
|
||||
|
||||
switch (key_id)
|
||||
{
|
||||
@ -1558,7 +1558,7 @@ static void cb_func_select_action(guint key_id)
|
||||
}
|
||||
|
||||
/* keybindings only valid when scintilla widget has focus */
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(doc_list[idx].sci)) return;
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(documents[idx]->sci)) return;
|
||||
|
||||
switch (key_id)
|
||||
{
|
||||
@ -1566,13 +1566,13 @@ static void cb_func_select_action(guint key_id)
|
||||
on_menu_select_all1_activate(NULL, NULL);
|
||||
break;
|
||||
case GEANY_KEYS_SELECT_WORD:
|
||||
editor_select_word(doc_list[idx].sci);
|
||||
editor_select_word(documents[idx]->sci);
|
||||
break;
|
||||
case GEANY_KEYS_SELECT_LINE:
|
||||
editor_select_lines(doc_list[idx].sci, FALSE);
|
||||
editor_select_lines(documents[idx]->sci, FALSE);
|
||||
break;
|
||||
case GEANY_KEYS_SELECT_PARAGRAPH:
|
||||
editor_select_paragraph(doc_list[idx].sci);
|
||||
editor_select_paragraph(documents[idx]->sci);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1591,7 +1591,7 @@ static void cb_func_insert_action(guint key_id)
|
||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||
|
||||
/* keybindings only valid when scintilla widget has focus */
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(doc_list[idx].sci)) return;
|
||||
if (! DOC_IDX_VALID(idx) || focusw != GTK_WIDGET(documents[idx]->sci)) return;
|
||||
|
||||
switch (key_id)
|
||||
{
|
||||
|
@ -119,20 +119,20 @@ static void save_recent_files(GKeyFile *config)
|
||||
static gchar *get_session_file_string(gint idx)
|
||||
{
|
||||
gchar *fname;
|
||||
GeanyFiletype *ft = doc_list[idx].file_type;
|
||||
GeanyFiletype *ft = documents[idx]->file_type;
|
||||
|
||||
if (ft == NULL) /* can happen when saving a new file when quitting */
|
||||
ft = filetypes[GEANY_FILETYPES_NONE];
|
||||
|
||||
fname = g_strdup_printf("%d;%s;%d;%d;%d;%d;%d;%s;",
|
||||
sci_get_current_position(doc_list[idx].sci),
|
||||
sci_get_current_position(documents[idx]->sci),
|
||||
ft->name,
|
||||
doc_list[idx].readonly,
|
||||
encodings_get_idx_from_charset(doc_list[idx].encoding),
|
||||
doc_list[idx].use_tabs,
|
||||
doc_list[idx].auto_indent,
|
||||
doc_list[idx].line_wrapping,
|
||||
doc_list[idx].file_name);
|
||||
documents[idx]->readonly,
|
||||
encodings_get_idx_from_charset(documents[idx]->encoding),
|
||||
documents[idx]->use_tabs,
|
||||
documents[idx]->auto_indent,
|
||||
documents[idx]->line_wrapping,
|
||||
documents[idx]->file_name);
|
||||
return fname;
|
||||
}
|
||||
|
||||
@ -849,7 +849,7 @@ static gboolean open_session_file(gchar **tmp)
|
||||
{
|
||||
editor_set_use_tabs(new_idx, use_tabs);
|
||||
editor_set_line_wrapping(new_idx, line_wrapping);
|
||||
doc_list[new_idx].auto_indent = auto_indent;
|
||||
documents[new_idx]->auto_indent = auto_indent;
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -680,14 +680,14 @@ static void handle_cl_filename(gchar *const filename)
|
||||
idx = document_open_file(filename, FALSE, NULL, NULL);
|
||||
/* add recent file manually because opening_session_files is set */
|
||||
if (DOC_IDX_VALID(idx))
|
||||
ui_add_recent_file(doc_list[idx].file_name);
|
||||
ui_add_recent_file(documents[idx]->file_name);
|
||||
}
|
||||
else if (filename != NULL)
|
||||
{ /* create new file if it doesn't exist */
|
||||
idx = document_new_file(filename, NULL, NULL);
|
||||
if (DOC_IDX_VALID(idx))
|
||||
{
|
||||
ui_add_recent_file(doc_list[idx].file_name);
|
||||
ui_add_recent_file(documents[idx]->file_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -913,7 +913,7 @@ gint main(gint argc, gchar **argv)
|
||||
ui_save_buttons_toggle(FALSE);
|
||||
|
||||
idx = document_get_cur_idx();
|
||||
gtk_widget_grab_focus(GTK_WIDGET(doc_list[idx].sci));
|
||||
gtk_widget_grab_focus(GTK_WIDGET(documents[idx]->sci));
|
||||
treeviews_select_openfiles_item(idx);
|
||||
build_menu_update(idx);
|
||||
treeviews_update_tag_list(idx, FALSE);
|
||||
|
@ -274,7 +274,7 @@ void msgwin_show_hide(gboolean show)
|
||||
*
|
||||
* @param msg_color A color to be used for the text. It must be an element of #MsgColors.
|
||||
* @param line The document's line where the message belongs to. Set to -1 to ignore.
|
||||
* @param idx The document's index in the doc_array. Set to -1 to ignore.
|
||||
* @param idx The document's index in the documents_array. Set to -1 to ignore.
|
||||
* @param format Printf()-style format string.
|
||||
* @param ... Arguments for the @c format string.
|
||||
**/
|
||||
@ -542,7 +542,7 @@ gboolean msgwin_goto_compiler_file_line()
|
||||
|
||||
if (DOC_IDX_VALID(idx))
|
||||
{
|
||||
if (! doc_list[idx].changed) /* if modified, line may be wrong */
|
||||
if (! documents[idx]->changed) /* if modified, line may be wrong */
|
||||
editor_set_indicator_on_line(idx, line - 1);
|
||||
|
||||
ret = navqueue_goto_line(old_idx, idx, line);
|
||||
|
@ -151,20 +151,20 @@ gboolean navqueue_goto_line(gint old_idx, gint new_idx, gint line)
|
||||
g_return_val_if_fail(DOC_IDX_VALID(new_idx), FALSE);
|
||||
g_return_val_if_fail(line >= 1, FALSE);
|
||||
|
||||
pos = sci_get_position_from_line(doc_list[new_idx].sci, line - 1);
|
||||
pos = sci_get_position_from_line(documents[new_idx]->sci, line - 1);
|
||||
|
||||
/* first add old file position */
|
||||
if (DOC_IDX_VALID(old_idx) && doc_list[old_idx].file_name)
|
||||
if (DOC_IDX_VALID(old_idx) && documents[old_idx]->file_name)
|
||||
{
|
||||
gint cur_pos = sci_get_current_position(doc_list[old_idx].sci);
|
||||
gint cur_pos = sci_get_current_position(documents[old_idx]->sci);
|
||||
|
||||
add_new_position(doc_list[old_idx].file_name, cur_pos);
|
||||
add_new_position(documents[old_idx]->file_name, cur_pos);
|
||||
}
|
||||
|
||||
/* now add new file position */
|
||||
if (doc_list[new_idx].file_name)
|
||||
if (documents[new_idx]->file_name)
|
||||
{
|
||||
add_new_position(doc_list[new_idx].file_name, pos);
|
||||
add_new_position(documents[new_idx]->file_name, pos);
|
||||
}
|
||||
|
||||
return editor_goto_pos(new_idx, pos, TRUE);
|
||||
|
@ -82,7 +82,7 @@ static void focus_sci(GtkWidget *widget, gpointer user_data)
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
gtk_widget_grab_focus(GTK_WIDGET(doc_list[idx].sci));
|
||||
gtk_widget_grab_focus(GTK_WIDGET(documents[idx]->sci));
|
||||
}
|
||||
|
||||
|
||||
@ -319,7 +319,7 @@ gint notebook_new_tab(gint doc_idx)
|
||||
GtkWidget *hbox, *ebox;
|
||||
gint tabnum;
|
||||
gchar *title;
|
||||
GeanyDocument *this = &(doc_list[doc_idx]);
|
||||
GeanyDocument *this = documents[doc_idx];
|
||||
GtkWidget *page;
|
||||
|
||||
g_return_val_if_fail(doc_idx >= 0 && this != NULL, -1);
|
||||
@ -401,6 +401,7 @@ notebook_tab_close_clicked_cb(GtkButton *button, gpointer user_data)
|
||||
{
|
||||
gint cur_page = gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
|
||||
GTK_WIDGET(user_data));
|
||||
|
||||
document_remove(cur_page);
|
||||
}
|
||||
|
||||
|
@ -36,12 +36,12 @@
|
||||
|
||||
/* The API version should be incremented whenever any plugin data types below are
|
||||
* modified or appended to. */
|
||||
static const gint api_version = 65;
|
||||
static const gint api_version = 66;
|
||||
|
||||
/* The ABI version should be incremented whenever existing fields in the plugin
|
||||
* data types below have to be changed or reordered. It should stay the same if fields
|
||||
* are only appended, as this doesn't affect existing fields. */
|
||||
static const gint abi_version = 34;
|
||||
static const gint abi_version = 35;
|
||||
|
||||
/** Check the plugin can be loaded by Geany.
|
||||
* This performs runtime checks that try to ensure:
|
||||
@ -153,9 +153,9 @@ PluginFields;
|
||||
typedef struct GeanyData
|
||||
{
|
||||
struct GeanyApp *app; /**< Geany application data fields */
|
||||
struct GeanyMainWidgets *main_widgets; /**< Important widgets in the main window. */
|
||||
GArray *doc_array; /**< Dynamic array of document structs */
|
||||
GPtrArray *filetypes_array; /**< Dynamic array of filetype pointers */
|
||||
struct GeanyMainWidgets *main_widgets; /**< Important widgets in the main window */
|
||||
GPtrArray *documents_array; /**< Dynamic array of GeanyDocument pointers */
|
||||
GPtrArray *filetypes_array; /**< Dynamic array of GeanyFiletype pointers */
|
||||
struct GeanyPrefs *prefs; /**< General settings */
|
||||
struct GeanyInterfacePrefs *interface_prefs; /**< Interface settings */
|
||||
struct GeanyToolbarPrefs *toolbar_prefs; /**< Toolbar settings */
|
||||
|
@ -265,7 +265,7 @@ geany_data_init(void)
|
||||
GeanyData gd = {
|
||||
app,
|
||||
&main_widgets,
|
||||
doc_array,
|
||||
documents_array,
|
||||
filetypes_array,
|
||||
&prefs,
|
||||
&interface_prefs,
|
||||
|
14
src/prefs.c
14
src/prefs.c
@ -821,9 +821,9 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
if (editor_prefs.use_tabs != use_tabs)
|
||||
{
|
||||
editor_prefs.use_tabs = use_tabs;
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].is_valid)
|
||||
if (documents[i]->is_valid)
|
||||
editor_set_use_tabs(i, editor_prefs.use_tabs);
|
||||
}
|
||||
}
|
||||
@ -974,9 +974,9 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(main_widgets.sidebar_notebook), interface_prefs.tab_pos_sidebar);
|
||||
|
||||
/* re-colourise all open documents, if tab width or long line settings have changed */
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].is_valid)
|
||||
if (documents[i]->is_valid)
|
||||
{
|
||||
document_apply_update_prefs(i);
|
||||
if (! editor_prefs.folding)
|
||||
@ -1041,10 +1041,10 @@ void on_prefs_font_choosed(GtkFontButton *widget, gpointer user_data)
|
||||
if (strcmp(fontbtn, interface_prefs.tagbar_font) == 0) break;
|
||||
g_free(interface_prefs.tagbar_font);
|
||||
interface_prefs.tagbar_font = g_strdup(fontbtn);
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].is_valid && GTK_IS_WIDGET(doc_list[i].tag_tree))
|
||||
ui_widget_modify_font_from_string(doc_list[i].tag_tree,
|
||||
if (documents[i]->is_valid && GTK_IS_WIDGET(documents[i]->tag_tree))
|
||||
ui_widget_modify_font_from_string(documents[i]->tag_tree,
|
||||
interface_prefs.tagbar_font);
|
||||
}
|
||||
if (GTK_IS_WIDGET(tv.default_tag_tree))
|
||||
|
@ -767,7 +767,7 @@ static void printing_print_gtk(gint idx)
|
||||
g_signal_connect(op, "begin-print", G_CALLBACK(begin_print), dinfo);
|
||||
g_signal_connect(op, "end-print", G_CALLBACK(end_print), dinfo);
|
||||
g_signal_connect(op, "draw-page", G_CALLBACK(draw_page), dinfo);
|
||||
g_signal_connect(op, "status-changed", G_CALLBACK(status_changed), doc_list[idx].file_name);
|
||||
g_signal_connect(op, "status-changed", G_CALLBACK(status_changed), documents[idx]->file_name);
|
||||
g_signal_connect(op, "create-custom-widget", G_CALLBACK(create_custom_widget), widgets);
|
||||
g_signal_connect(op, "custom-widget-apply", G_CALLBACK(custom_widget_apply), widgets);
|
||||
|
||||
@ -789,7 +789,7 @@ static void printing_print_gtk(gint idx)
|
||||
else if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
|
||||
{
|
||||
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Printing of %s failed (%s)."),
|
||||
doc_list[idx].file_name, error->message);
|
||||
documents[idx]->file_name, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
@ -822,7 +822,7 @@ static void print_external(gint idx)
|
||||
{
|
||||
gchar *cmdline;
|
||||
|
||||
if (doc_list[idx].file_name == NULL)
|
||||
if (documents[idx]->file_name == NULL)
|
||||
return;
|
||||
|
||||
if (! NZV(printing_prefs.external_print_cmd))
|
||||
@ -833,11 +833,11 @@ static void print_external(gint idx)
|
||||
}
|
||||
|
||||
cmdline = g_strdup(printing_prefs.external_print_cmd);
|
||||
cmdline = utils_str_replace(cmdline, "%f", doc_list[idx].file_name);
|
||||
cmdline = utils_str_replace(cmdline, "%f", documents[idx]->file_name);
|
||||
|
||||
if (dialogs_show_question(
|
||||
_("The file \"%s\" will be printed with the following command:\n\n%s"),
|
||||
doc_list[idx].file_name, cmdline))
|
||||
documents[idx]->file_name, cmdline))
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
@ -853,12 +853,12 @@ static void print_external(gint idx)
|
||||
{
|
||||
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
|
||||
_("Printing of \"%s\" failed (return code: %s)."),
|
||||
doc_list[idx].file_name, error->message);
|
||||
documents[idx]->file_name, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
msgwin_status_add(_("File %s printed."), doc_list[idx].file_name);
|
||||
msgwin_status_add(_("File %s printed."), documents[idx]->file_name);
|
||||
}
|
||||
g_free(tmp_cmdline);
|
||||
}
|
||||
|
26
src/search.c
26
src/search.c
@ -410,7 +410,7 @@ void search_show_replace_dialog(void)
|
||||
gint idx = document_get_cur_idx();
|
||||
gchar *sel = NULL;
|
||||
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
|
||||
sel = editor_get_default_selection(idx, search_prefs.use_current_word, NULL);
|
||||
|
||||
@ -798,15 +798,15 @@ static gint search_mark(gint idx, const gchar *search_text, gint flags)
|
||||
g_return_val_if_fail(DOC_IDX_VALID(idx), 0);
|
||||
|
||||
ttf.chrg.cpMin = 0;
|
||||
ttf.chrg.cpMax = sci_get_length(doc_list[idx].sci);
|
||||
ttf.chrg.cpMax = sci_get_length(documents[idx]->sci);
|
||||
ttf.lpstrText = (gchar *)search_text;
|
||||
while (1)
|
||||
{
|
||||
pos = sci_find_text(doc_list[idx].sci, flags, &ttf);
|
||||
pos = sci_find_text(documents[idx]->sci, flags, &ttf);
|
||||
if (pos == -1) break;
|
||||
|
||||
line = sci_get_line_from_position(doc_list[idx].sci, pos);
|
||||
sci_set_marker_at_line(doc_list[idx].sci, line, TRUE, 1);
|
||||
line = sci_get_line_from_position(documents[idx]->sci, pos);
|
||||
sci_set_marker_at_line(documents[idx]->sci, line, TRUE, 1);
|
||||
|
||||
ttf.chrg.cpMin = ttf.chrgText.cpMax + 1;
|
||||
count++;
|
||||
@ -1011,7 +1011,7 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
{
|
||||
gint ix = document_get_n_idx(n);
|
||||
|
||||
if (! doc_list[ix].is_valid) continue;
|
||||
if (! documents[ix]->is_valid) continue;
|
||||
|
||||
if (document_replace_all(ix, find, replace, search_flags_re,
|
||||
search_replace_escape_re)) count++;
|
||||
@ -1025,7 +1025,7 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
/* show which docs had replacements: */
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_STATUS);
|
||||
|
||||
ui_save_buttons_toggle(doc_list[idx].changed); /* update save all */
|
||||
ui_save_buttons_toggle(documents[idx]->changed); /* update save all */
|
||||
break;
|
||||
}
|
||||
case GEANY_RESPONSE_REPLACE_IN_SEL:
|
||||
@ -1359,13 +1359,13 @@ static gint find_document_usage(gint idx, const gchar *search_text, gint flags)
|
||||
short_file_name = g_path_get_basename(DOC_FILENAME(idx));
|
||||
|
||||
ttf.chrg.cpMin = 0;
|
||||
ttf.chrg.cpMax = sci_get_length(doc_list[idx].sci);
|
||||
ttf.chrg.cpMax = sci_get_length(documents[idx]->sci);
|
||||
ttf.lpstrText = (gchar *)search_text;
|
||||
while (1)
|
||||
{
|
||||
gint pos, line, start, find_len;
|
||||
|
||||
pos = sci_find_text(doc_list[idx].sci, flags, &ttf);
|
||||
pos = sci_find_text(documents[idx]->sci, flags, &ttf);
|
||||
if (pos == -1)
|
||||
break; /* no more matches */
|
||||
find_len = ttf.chrgText.cpMax - ttf.chrgText.cpMin;
|
||||
@ -1373,8 +1373,8 @@ static gint find_document_usage(gint idx, const gchar *search_text, gint flags)
|
||||
break; /* Ignore regex ^ or $ */
|
||||
|
||||
count++;
|
||||
line = sci_get_line_from_position(doc_list[idx].sci, pos);
|
||||
buffer = sci_get_line(doc_list[idx].sci, line);
|
||||
line = sci_get_line_from_position(documents[idx]->sci, pos);
|
||||
buffer = sci_get_line(documents[idx]->sci, line);
|
||||
msgwin_msg_add_fmt(COLOR_BLACK, line + 1, idx,
|
||||
"%s:%d : %s", short_file_name, line + 1, g_strstrip(buffer));
|
||||
g_free(buffer);
|
||||
@ -1405,9 +1405,9 @@ void search_find_usage(const gchar *search_text, gint flags, gboolean in_session
|
||||
else
|
||||
{
|
||||
guint i;
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].is_valid)
|
||||
if (documents[i]->is_valid)
|
||||
if (find_document_usage(i, search_text, flags) > 0) found = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpoint
|
||||
|
||||
idx = document_new_file(buf, NULL, NULL);
|
||||
if (DOC_IDX_VALID(idx))
|
||||
ui_add_recent_file(doc_list[idx].file_name);
|
||||
ui_add_recent_file(documents[idx]->file_name);
|
||||
else
|
||||
geany_debug("got data from socket, but it does not look like a filename");
|
||||
}
|
||||
|
@ -400,8 +400,8 @@ static const GList *get_tag_list(gint idx, guint tag_types, gint sort_mode)
|
||||
{
|
||||
static GList *tag_names = NULL;
|
||||
|
||||
if (DOC_IDX_VALID(idx) && doc_list[idx].tm_file &&
|
||||
doc_list[idx].tm_file->tags_array)
|
||||
if (DOC_IDX_VALID(idx) && documents[idx]->tm_file &&
|
||||
documents[idx]->tm_file->tags_array)
|
||||
{
|
||||
TMTag *tag;
|
||||
guint i;
|
||||
@ -409,7 +409,7 @@ static const GList *get_tag_list(gint idx, guint tag_types, gint sort_mode)
|
||||
gboolean doc_is_utf8 = FALSE;
|
||||
gchar *utf8_name;
|
||||
const gchar *cosep =
|
||||
symbols_get_context_separator(FILETYPE_ID(doc_list[idx].file_type));
|
||||
symbols_get_context_separator(FILETYPE_ID(documents[idx]->file_type));
|
||||
|
||||
if (tag_names)
|
||||
{
|
||||
@ -425,20 +425,20 @@ static const GList *get_tag_list(gint idx, guint tag_types, gint sort_mode)
|
||||
|
||||
/* encodings_convert_to_utf8_from_charset() fails with charset "None", so skip conversion
|
||||
* for None at this point completely */
|
||||
if (utils_str_equal(doc_list[idx].encoding, "UTF-8") ||
|
||||
utils_str_equal(doc_list[idx].encoding, "None"))
|
||||
if (utils_str_equal(documents[idx]->encoding, "UTF-8") ||
|
||||
utils_str_equal(documents[idx]->encoding, "None"))
|
||||
doc_is_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < (doc_list[idx].tm_file)->tags_array->len; ++i)
|
||||
for (i = 0; i < (documents[idx]->tm_file)->tags_array->len; ++i)
|
||||
{
|
||||
tag = TM_TAG((doc_list[idx].tm_file)->tags_array->pdata[i]);
|
||||
tag = TM_TAG((documents[idx]->tm_file)->tags_array->pdata[i]);
|
||||
if (tag == NULL)
|
||||
return NULL;
|
||||
|
||||
if (tag->type & tag_types)
|
||||
{
|
||||
if (! doc_is_utf8) utf8_name = encodings_convert_to_utf8_from_charset(tag->name,
|
||||
(gsize)-1, doc_list[idx].encoding, TRUE);
|
||||
(gsize)-1, documents[idx]->encoding, TRUE);
|
||||
else utf8_name = tag->name;
|
||||
|
||||
if (utf8_name == NULL)
|
||||
@ -560,8 +560,8 @@ tag_list_add_groups(GtkTreeStore *tree_store, ...)
|
||||
|
||||
static void init_tag_list(gint idx)
|
||||
{
|
||||
filetype_id ft_id = doc_list[idx].file_type->id;
|
||||
GtkTreeStore *tag_store = doc_list[idx].tag_store;
|
||||
filetype_id ft_id = documents[idx]->file_type->id;
|
||||
GtkTreeStore *tag_store = documents[idx]->tag_store;
|
||||
|
||||
init_tag_iters();
|
||||
|
||||
@ -838,7 +838,7 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
|
||||
const GList *tags;
|
||||
GtkTreeIter iter;
|
||||
static gint prev_sort_mode = SYMBOLS_SORT_BY_NAME;
|
||||
filetype_id ft_id = FILETYPE_ID(doc_list[idx].file_type);
|
||||
filetype_id ft_id = FILETYPE_ID(documents[idx]->file_type);
|
||||
|
||||
g_return_val_if_fail(DOC_IDX_VALID(idx), FALSE);
|
||||
|
||||
@ -848,15 +848,15 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
|
||||
prev_sort_mode = sort_mode;
|
||||
|
||||
tags = get_tag_list(idx, tm_tag_max_t, sort_mode);
|
||||
if (doc_list[idx].tm_file == NULL || tags == NULL)
|
||||
if (documents[idx]->tm_file == NULL || tags == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* Make sure the model stays with us after the tree view unrefs it */
|
||||
g_object_ref(GTK_TREE_MODEL(doc_list[idx].tag_store));
|
||||
g_object_ref(GTK_TREE_MODEL(documents[idx]->tag_store));
|
||||
/* Detach model from view */
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(doc_list[idx].tag_tree), NULL);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(documents[idx]->tag_tree), NULL);
|
||||
/* Clear all contents */
|
||||
gtk_tree_store_clear(doc_list[idx].tag_store);
|
||||
gtk_tree_store_clear(documents[idx]->tag_store);
|
||||
|
||||
init_tag_list(idx);
|
||||
for (tmp = (GList*)tags; tmp; tmp = g_list_next(tmp))
|
||||
@ -939,10 +939,10 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
|
||||
|
||||
if (parent)
|
||||
{
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(doc_list[idx].tag_store), parent,
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(documents[idx]->tag_store), parent,
|
||||
SYMBOLS_COLUMN_ICON, &icon, -1);
|
||||
gtk_tree_store_append(doc_list[idx].tag_store, &iter, parent);
|
||||
gtk_tree_store_set(doc_list[idx].tag_store, &iter,
|
||||
gtk_tree_store_append(documents[idx]->tag_store, &iter, parent);
|
||||
gtk_tree_store_set(documents[idx]->tag_store, &iter,
|
||||
SYMBOLS_COLUMN_ICON, icon,
|
||||
SYMBOLS_COLUMN_NAME, buf,
|
||||
SYMBOLS_COLUMN_LINE, symbol->line, -1);
|
||||
@ -951,12 +951,12 @@ gboolean symbols_recreate_tag_list(gint idx, gint sort_mode)
|
||||
g_object_unref(icon);
|
||||
}
|
||||
}
|
||||
hide_empty_rows(doc_list[idx].tag_store);
|
||||
hide_empty_rows(documents[idx]->tag_store);
|
||||
/* Re-attach model to view */
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(doc_list[idx].tag_tree),
|
||||
GTK_TREE_MODEL(doc_list[idx].tag_store));
|
||||
g_object_unref(GTK_TREE_MODEL(doc_list[idx].tag_store));
|
||||
gtk_tree_view_expand_all(GTK_TREE_VIEW(doc_list[idx].tag_tree));
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(documents[idx]->tag_tree),
|
||||
GTK_TREE_MODEL(documents[idx]->tag_store));
|
||||
g_object_unref(GTK_TREE_MODEL(documents[idx]->tag_store));
|
||||
gtk_tree_view_expand_all(GTK_TREE_VIEW(documents[idx]->tag_tree));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1182,8 +1182,8 @@ gboolean symbols_goto_tag(const gchar *name, gboolean definition)
|
||||
type = (definition) ? tm_tag_max_t - forward_types : forward_types;
|
||||
|
||||
/* first look in the current document */
|
||||
if (doc_list[old_idx].tm_file)
|
||||
tmtag = find_work_object_tag(doc_list[old_idx].tm_file, name, type);
|
||||
if (documents[old_idx]->tm_file)
|
||||
tmtag = find_work_object_tag(documents[old_idx]->tm_file, name, type);
|
||||
|
||||
/* if not found, look in the workspace */
|
||||
if (tmtag == NULL)
|
||||
|
24
src/tools.c
24
src/tools.c
@ -173,7 +173,7 @@ static gboolean cc_replace_sel_cb(gpointer user_data)
|
||||
|
||||
if (! cc_error_occurred && cc_buffer != NULL)
|
||||
{ /* Command completed successfully */
|
||||
sci_replace_sel(doc_list[idx].sci, cc_buffer->str);
|
||||
sci_replace_sel(documents[idx]->sci, cc_buffer->str);
|
||||
g_string_free(cc_buffer, TRUE);
|
||||
cc_buffer = NULL;
|
||||
}
|
||||
@ -238,7 +238,7 @@ void tools_execute_custom_command(gint idx, const gchar *command)
|
||||
|
||||
g_return_if_fail(DOC_IDX_VALID(idx) && command != NULL);
|
||||
|
||||
if (! sci_can_copy(doc_list[idx].sci))
|
||||
if (! sci_can_copy(documents[idx]->sci))
|
||||
return;
|
||||
|
||||
argv = g_strsplit(command, " ", -1);
|
||||
@ -263,9 +263,9 @@ void tools_execute_custom_command(gint idx, const gchar *command)
|
||||
FALSE, cc_iofunc_err, (gpointer)command);
|
||||
|
||||
/* get selection */
|
||||
len = sci_get_selected_text_length(doc_list[idx].sci);
|
||||
len = sci_get_selected_text_length(documents[idx]->sci);
|
||||
sel = g_malloc0(len + 1);
|
||||
sci_get_selected_text(doc_list[idx].sci, sel);
|
||||
sci_get_selected_text(documents[idx]->sci, sel);
|
||||
|
||||
/* write data to the command */
|
||||
remaining = len - 1;
|
||||
@ -403,7 +403,7 @@ static void cc_on_custom_command_menu_activate(GtkMenuItem *menuitem, gpointer u
|
||||
|
||||
if (! DOC_IDX_VALID(idx)) return;
|
||||
|
||||
enable = sci_can_copy(doc_list[idx].sci) && (ui_prefs.custom_commands != NULL);
|
||||
enable = sci_can_copy(documents[idx]->sci) && (ui_prefs.custom_commands != NULL);
|
||||
|
||||
children = gtk_container_get_children(GTK_CONTAINER(user_data));
|
||||
len = g_list_length(children);
|
||||
@ -605,7 +605,7 @@ void tools_word_count(void)
|
||||
gchar *text, *range;
|
||||
|
||||
idx = document_get_cur_idx();
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons(_("Word Count"), GTK_WINDOW(main_widgets.window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
@ -613,16 +613,16 @@ void tools_word_count(void)
|
||||
vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog));
|
||||
gtk_widget_set_name(dialog, "GeanyDialog");
|
||||
|
||||
if (sci_can_copy(doc_list[idx].sci))
|
||||
if (sci_can_copy(documents[idx]->sci))
|
||||
{
|
||||
text = g_malloc0(sci_get_selected_text_length(doc_list[idx].sci) + 1);
|
||||
sci_get_selected_text(doc_list[idx].sci, text);
|
||||
text = g_malloc0(sci_get_selected_text_length(documents[idx]->sci) + 1);
|
||||
sci_get_selected_text(documents[idx]->sci, text);
|
||||
range = _("selection");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = g_malloc(sci_get_length(doc_list[idx].sci) + 1);
|
||||
sci_get_text(doc_list[idx].sci, sci_get_length(doc_list[idx].sci) + 1 , text);
|
||||
text = g_malloc(sci_get_length(documents[idx]->sci) + 1);
|
||||
sci_get_text(documents[idx]->sci, sci_get_length(documents[idx]->sci) + 1 , text);
|
||||
range = _("whole document");
|
||||
}
|
||||
word_count(text, &chars, &lines, &words);
|
||||
@ -716,7 +716,7 @@ on_color_ok_button_clicked (GtkButton *button,
|
||||
gchar *hex;
|
||||
|
||||
gtk_widget_hide(ui_widgets.open_colorsel);
|
||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
||||
if (idx == -1 || ! documents[idx]->is_valid) return;
|
||||
|
||||
gtk_color_selection_get_current_color(
|
||||
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(ui_widgets.open_colorsel)->colorsel), &color);
|
||||
|
@ -174,8 +174,8 @@ void treeviews_update_tag_list(gint idx, gboolean update)
|
||||
}
|
||||
|
||||
/* show default empty tag tree if there are no tags */
|
||||
if (idx == -1 || doc_list[idx].file_type == NULL ||
|
||||
! filetype_has_tags(doc_list[idx].file_type))
|
||||
if (idx == -1 || documents[idx]->file_type == NULL ||
|
||||
! filetype_has_tags(documents[idx]->file_type))
|
||||
{
|
||||
gtk_container_add(GTK_CONTAINER(tag_window), tv.default_tag_tree);
|
||||
return;
|
||||
@ -183,22 +183,22 @@ void treeviews_update_tag_list(gint idx, gboolean update)
|
||||
|
||||
if (update)
|
||||
{ /* updating the tag list in the left tag window */
|
||||
if (doc_list[idx].tag_tree == NULL)
|
||||
if (documents[idx]->tag_tree == NULL)
|
||||
{
|
||||
doc_list[idx].tag_store = gtk_tree_store_new(
|
||||
documents[idx]->tag_store = gtk_tree_store_new(
|
||||
SYMBOLS_N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
|
||||
doc_list[idx].tag_tree = gtk_tree_view_new();
|
||||
prepare_taglist(doc_list[idx].tag_tree, doc_list[idx].tag_store);
|
||||
gtk_widget_show(doc_list[idx].tag_tree);
|
||||
g_object_ref((gpointer)doc_list[idx].tag_tree); /* to hold it after removing */
|
||||
documents[idx]->tag_tree = gtk_tree_view_new();
|
||||
prepare_taglist(documents[idx]->tag_tree, documents[idx]->tag_store);
|
||||
gtk_widget_show(documents[idx]->tag_tree);
|
||||
g_object_ref((gpointer)documents[idx]->tag_tree); /* to hold it after removing */
|
||||
}
|
||||
|
||||
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_USE_PREVIOUS);
|
||||
documents[idx]->has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_USE_PREVIOUS);
|
||||
}
|
||||
|
||||
if (doc_list[idx].has_tags)
|
||||
if (documents[idx]->has_tags)
|
||||
{
|
||||
gtk_container_add(GTK_CONTAINER(tag_window), doc_list[idx].tag_tree);
|
||||
gtk_container_add(GTK_CONTAINER(tag_window), documents[idx]->tag_tree);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -294,11 +294,11 @@ static void prepare_openfiles(void)
|
||||
}
|
||||
|
||||
|
||||
/* Also sets doc_list[idx].iter.
|
||||
/* Also sets documents[idx]->iter.
|
||||
* This is called recursively in treeviews_openfiles_update_all(). */
|
||||
void treeviews_openfiles_add(gint idx)
|
||||
{
|
||||
GtkTreeIter *iter = &doc_list[idx].iter;
|
||||
GtkTreeIter *iter = &documents[idx]->iter;
|
||||
|
||||
gtk_list_store_append(store_openfiles, iter);
|
||||
treeviews_openfiles_update(idx);
|
||||
@ -314,7 +314,7 @@ void treeviews_openfiles_update(gint idx)
|
||||
basename = DOC_FILENAME(idx);
|
||||
else
|
||||
basename = g_path_get_basename(DOC_FILENAME(idx));
|
||||
gtk_list_store_set(store_openfiles, &doc_list[idx].iter,
|
||||
gtk_list_store_set(store_openfiles, &documents[idx]->iter,
|
||||
#if GTK_CHECK_VERSION(2, 12, 0)
|
||||
0, basename, 1, idx, 2, color, 3, DOC_FILENAME(idx), -1);
|
||||
#else
|
||||
@ -334,7 +334,7 @@ void treeviews_openfiles_update_all()
|
||||
for (i = 0; i < (guint) gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)); i++)
|
||||
{
|
||||
idx = document_get_n_idx(i);
|
||||
if (! doc_list[idx].is_valid) continue;
|
||||
if (! documents[idx]->is_valid) continue;
|
||||
|
||||
treeviews_openfiles_add(idx);
|
||||
}
|
||||
@ -343,19 +343,19 @@ void treeviews_openfiles_update_all()
|
||||
|
||||
void treeviews_remove_document(gint idx)
|
||||
{
|
||||
GtkTreeIter *iter = &doc_list[idx].iter;
|
||||
GtkTreeIter *iter = &documents[idx]->iter;
|
||||
|
||||
gtk_list_store_remove(store_openfiles, iter);
|
||||
|
||||
if (GTK_IS_WIDGET(doc_list[idx].tag_tree))
|
||||
if (GTK_IS_WIDGET(documents[idx]->tag_tree))
|
||||
{
|
||||
gtk_widget_destroy(doc_list[idx].tag_tree);
|
||||
if (GTK_IS_TREE_VIEW(doc_list[idx].tag_tree))
|
||||
gtk_widget_destroy(documents[idx]->tag_tree);
|
||||
if (GTK_IS_TREE_VIEW(documents[idx]->tag_tree))
|
||||
{
|
||||
/* Because it was ref'd in treeviews_update_tag_list, it needs unref'ing */
|
||||
g_object_unref((gpointer)doc_list[idx].tag_tree);
|
||||
g_object_unref((gpointer)documents[idx]->tag_tree);
|
||||
}
|
||||
doc_list[idx].tag_tree = NULL;
|
||||
documents[idx]->tag_tree = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -537,12 +537,12 @@ static void on_openfiles_document_action(GtkMenuItem *menuitem, gpointer user_da
|
||||
{
|
||||
case OPENFILES_ACTION_REMOVE:
|
||||
{
|
||||
document_remove(gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook), GTK_WIDGET(doc_list[idx].sci)));
|
||||
document_remove(gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook), GTK_WIDGET(documents[idx]->sci)));
|
||||
break;
|
||||
}
|
||||
case OPENFILES_ACTION_SAVE:
|
||||
{
|
||||
if (doc_list[idx].changed) document_save_file(idx, FALSE);
|
||||
if (documents[idx]->changed) document_save_file(idx, FALSE);
|
||||
break;
|
||||
}
|
||||
case OPENFILES_ACTION_RELOAD:
|
||||
@ -571,7 +571,7 @@ static gboolean change_focus(gpointer data)
|
||||
if (DOC_IDX_VALID(idx))
|
||||
{
|
||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||
GtkWidget *sci = GTK_WIDGET(doc_list[idx].sci);
|
||||
GtkWidget *sci = GTK_WIDGET(documents[idx]->sci);
|
||||
|
||||
if (focusw == tv.tree_openfiles)
|
||||
gtk_widget_grab_focus(sci);
|
||||
@ -592,7 +592,7 @@ static void on_openfiles_tree_selection_changed(GtkTreeSelection *selection, gpo
|
||||
gtk_tree_model_get(model, &iter, 1, &idx, -1);
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
|
||||
gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
|
||||
(GtkWidget*) doc_list[idx].sci));
|
||||
(GtkWidget*) documents[idx]->sci));
|
||||
g_idle_add((GSourceFunc) change_focus, GINT_TO_POINTER(idx));
|
||||
}
|
||||
}
|
||||
@ -606,14 +606,14 @@ static void on_taglist_tree_popup_clicked(GtkMenuItem *menuitem, gpointer user_d
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (DOC_IDX_VALID(idx))
|
||||
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_BY_NAME);
|
||||
documents[idx]->has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_BY_NAME);
|
||||
break;
|
||||
}
|
||||
case SYMBOL_ACTION_SORT_BY_APPEARANCE:
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (DOC_IDX_VALID(idx))
|
||||
doc_list[idx].has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_BY_APPEARANCE);
|
||||
documents[idx]->has_tags = symbols_recreate_tag_list(idx, SYMBOLS_SORT_BY_APPEARANCE);
|
||||
break;
|
||||
}
|
||||
case SYMBOL_ACTION_HIDE:
|
||||
|
@ -133,51 +133,51 @@ void ui_update_statusbar(gint idx, gint pos)
|
||||
gchar *filetype_name;
|
||||
|
||||
/* workaround to make the name of filetype GEANY_FILETYPES_NONE translatable */
|
||||
if (doc_list[idx].file_type == NULL || doc_list[idx].file_type->id == GEANY_FILETYPES_NONE)
|
||||
if (documents[idx]->file_type == NULL || documents[idx]->file_type->id == GEANY_FILETYPES_NONE)
|
||||
filetype_name = _("None");
|
||||
else
|
||||
filetype_name = doc_list[idx].file_type->name;
|
||||
filetype_name = documents[idx]->file_type->name;
|
||||
|
||||
if (stats_str == NULL)
|
||||
stats_str = g_string_sized_new(120);
|
||||
|
||||
if (pos == -1) pos = sci_get_current_position(doc_list[idx].sci);
|
||||
line = sci_get_line_from_position(doc_list[idx].sci, pos);
|
||||
if (pos == -1) pos = sci_get_current_position(documents[idx]->sci);
|
||||
line = sci_get_line_from_position(documents[idx]->sci, pos);
|
||||
|
||||
/* Add temporary fix for sci infinite loop in Document::GetColumn(int)
|
||||
* when current pos is beyond document end (can occur when removing
|
||||
* blocks of selected lines especially esp. brace sections near end of file). */
|
||||
if (pos <= sci_get_length(doc_list[idx].sci))
|
||||
col = sci_get_col_from_position(doc_list[idx].sci, pos);
|
||||
if (pos <= sci_get_length(documents[idx]->sci))
|
||||
col = sci_get_col_from_position(documents[idx]->sci, pos);
|
||||
else
|
||||
col = 0;
|
||||
|
||||
/* Status bar statistics: col = column, sel = selection. */
|
||||
g_string_printf(stats_str, _("line: %d\t col: %d\t sel: %d\t "),
|
||||
(line + 1), col,
|
||||
sci_get_selected_text_length(doc_list[idx].sci) - 1);
|
||||
sci_get_selected_text_length(documents[idx]->sci) - 1);
|
||||
|
||||
g_string_append(stats_str,
|
||||
/* RO = read-only */
|
||||
(doc_list[idx].readonly) ? _("RO ") :
|
||||
(documents[idx]->readonly) ? _("RO ") :
|
||||
/* OVR = overwrite/overtype, INS = insert */
|
||||
(sci_get_overtype(doc_list[idx].sci) ? _("OVR") : _("INS")));
|
||||
(sci_get_overtype(documents[idx]->sci) ? _("OVR") : _("INS")));
|
||||
g_string_append(stats_str, sp);
|
||||
g_string_append(stats_str,
|
||||
(doc_list[idx].use_tabs) ? _("TAB") : _("SP ")); /* SP = space */
|
||||
(documents[idx]->use_tabs) ? _("TAB") : _("SP ")); /* SP = space */
|
||||
g_string_append(stats_str, sp);
|
||||
g_string_append_printf(stats_str, _("mode: %s"),
|
||||
editor_get_eol_char_name(idx));
|
||||
g_string_append(stats_str, sp);
|
||||
g_string_append_printf(stats_str, _("encoding: %s %s"),
|
||||
(doc_list[idx].encoding) ? doc_list[idx].encoding : _("unknown"),
|
||||
(encodings_is_unicode_charset(doc_list[idx].encoding)) ?
|
||||
(documents[idx]->encoding) ? documents[idx]->encoding : _("unknown"),
|
||||
(encodings_is_unicode_charset(documents[idx]->encoding)) ?
|
||||
/* BOM = byte order mark */
|
||||
((doc_list[idx].has_bom) ? _("(with BOM)") : "") : "");
|
||||
((documents[idx]->has_bom) ? _("(with BOM)") : "") : "");
|
||||
g_string_append(stats_str, sp);
|
||||
g_string_append_printf(stats_str, _("filetype: %s"), filetype_name);
|
||||
g_string_append(stats_str, sp);
|
||||
if (doc_list[idx].changed)
|
||||
if (documents[idx]->changed)
|
||||
{
|
||||
g_string_append(stats_str, _("MOD")); /* MOD = modified */
|
||||
g_string_append(stats_str, sp);
|
||||
@ -210,9 +210,9 @@ void ui_set_window_title(gint idx)
|
||||
|
||||
if (idx >= 0)
|
||||
{
|
||||
g_string_append(str, doc_list[idx].changed ? "*" : "");
|
||||
g_string_append(str, documents[idx]->changed ? "*" : "");
|
||||
|
||||
if (doc_list[idx].file_name == NULL)
|
||||
if (documents[idx]->file_name == NULL)
|
||||
g_string_append(str, DOC_FILENAME(idx));
|
||||
else
|
||||
{
|
||||
@ -260,9 +260,9 @@ void ui_set_editor_font(const gchar *font_name)
|
||||
size = pango_font_description_get_size(font_desc) / PANGO_SCALE;
|
||||
|
||||
/* We copy the current style, and update the font in all open tabs. */
|
||||
for(i = 0; i < doc_array->len; i++)
|
||||
for(i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
if (doc_list[i].sci)
|
||||
if (documents[i]->sci)
|
||||
{
|
||||
editor_set_font(i, fname, size);
|
||||
}
|
||||
@ -320,7 +320,7 @@ void ui_update_popup_copy_items(gint idx)
|
||||
guint i;
|
||||
|
||||
if (idx == -1) enable = FALSE;
|
||||
else enable = sci_can_copy(doc_list[idx].sci);
|
||||
else enable = sci_can_copy(documents[idx]->sci);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(ui_widgets.popup_copy_items); i++)
|
||||
gtk_widget_set_sensitive(ui_widgets.popup_copy_items[i], enable);
|
||||
@ -342,7 +342,7 @@ void ui_update_menu_copy_items(gint idx)
|
||||
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
||||
|
||||
if (IS_SCINTILLA(focusw))
|
||||
enable = (idx == -1) ? FALSE : sci_can_copy(doc_list[idx].sci);
|
||||
enable = (idx == -1) ? FALSE : sci_can_copy(documents[idx]->sci);
|
||||
else
|
||||
if (GTK_IS_EDITABLE(focusw))
|
||||
enable = gtk_editable_get_selection_bounds(GTK_EDITABLE(focusw), NULL, NULL);
|
||||
@ -363,9 +363,9 @@ void ui_update_insert_include_item(gint idx, gint item)
|
||||
{
|
||||
gboolean enable = FALSE;
|
||||
|
||||
if (idx == -1 || doc_list[idx].file_type == NULL) enable = FALSE;
|
||||
else if (doc_list[idx].file_type->id == GEANY_FILETYPES_C ||
|
||||
doc_list[idx].file_type->id == GEANY_FILETYPES_CPP)
|
||||
if (idx == -1 || documents[idx]->file_type == NULL) enable = FALSE;
|
||||
else if (documents[idx]->file_type->id == GEANY_FILETYPES_C ||
|
||||
documents[idx]->file_type->id == GEANY_FILETYPES_CPP)
|
||||
{
|
||||
enable = TRUE;
|
||||
}
|
||||
@ -541,11 +541,11 @@ void ui_save_buttons_toggle(gboolean enable)
|
||||
gtk_widget_set_sensitive(ui_widgets.save_buttons[1], enable);
|
||||
|
||||
/* save all menu item and tool button */
|
||||
for (i = 0; i < doc_array->len; i++)
|
||||
for (i = 0; i < documents_array->len; i++)
|
||||
{
|
||||
/* check whether there are files where changes were made and if there are some,
|
||||
* we need the save all button / item */
|
||||
if (doc_list[i].is_valid && doc_list[i].changed)
|
||||
if (documents[i]->is_valid && documents[i]->changed)
|
||||
{
|
||||
dirty_tabs = TRUE;
|
||||
break;
|
||||
@ -680,31 +680,31 @@ void ui_document_show_hide(gint idx)
|
||||
|
||||
gtk_check_menu_item_set_active(
|
||||
GTK_CHECK_MENU_ITEM(lookup_widget(main_widgets.window, "menu_line_wrapping1")),
|
||||
doc_list[idx].line_wrapping);
|
||||
documents[idx]->line_wrapping);
|
||||
|
||||
gtk_check_menu_item_set_active(
|
||||
GTK_CHECK_MENU_ITEM(lookup_widget(main_widgets.window, "line_breaking1")),
|
||||
doc_list[idx].line_breaking);
|
||||
documents[idx]->line_breaking);
|
||||
|
||||
item = lookup_widget(main_widgets.window, "menu_use_auto_indentation1");
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
|
||||
doc_list[idx].auto_indent);
|
||||
documents[idx]->auto_indent);
|
||||
gtk_widget_set_sensitive(item, editor_prefs.indent_mode != INDENT_NONE);
|
||||
|
||||
item = lookup_widget(main_widgets.window,
|
||||
doc_list[idx].use_tabs ? "tabs1" : "spaces1");
|
||||
documents[idx]->use_tabs ? "tabs1" : "spaces1");
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
|
||||
|
||||
gtk_check_menu_item_set_active(
|
||||
GTK_CHECK_MENU_ITEM(lookup_widget(main_widgets.window, "set_file_readonly1")),
|
||||
doc_list[idx].readonly);
|
||||
documents[idx]->readonly);
|
||||
|
||||
item = lookup_widget(main_widgets.window, "menu_write_unicode_bom1");
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),
|
||||
doc_list[idx].has_bom);
|
||||
gtk_widget_set_sensitive(item, encodings_is_unicode_charset(doc_list[idx].encoding));
|
||||
documents[idx]->has_bom);
|
||||
gtk_widget_set_sensitive(item, encodings_is_unicode_charset(documents[idx]->encoding));
|
||||
|
||||
switch (sci_get_eol_mode(doc_list[idx].sci))
|
||||
switch (sci_get_eol_mode(documents[idx]->sci))
|
||||
{
|
||||
case SC_EOL_CR: widget_name = "cr"; break;
|
||||
case SC_EOL_LF: widget_name = "lf"; break;
|
||||
@ -713,8 +713,8 @@ void ui_document_show_hide(gint idx)
|
||||
gtk_check_menu_item_set_active(
|
||||
GTK_CHECK_MENU_ITEM(lookup_widget(main_widgets.window, widget_name)), TRUE);
|
||||
|
||||
encodings_select_radio_item(doc_list[idx].encoding);
|
||||
filetypes_select_radio_item(doc_list[idx].file_type);
|
||||
encodings_select_radio_item(documents[idx]->encoding);
|
||||
filetypes_select_radio_item(documents[idx]->file_type);
|
||||
|
||||
ignore_callback = FALSE;
|
||||
}
|
||||
@ -1055,7 +1055,7 @@ void ui_show_markers_margin(void)
|
||||
for(i = 0; i < max; i++)
|
||||
{
|
||||
idx = document_get_n_idx(i);
|
||||
sci_set_symbol_margin(doc_list[idx].sci, editor_prefs.show_markers_margin);
|
||||
sci_set_symbol_margin(documents[idx]->sci, editor_prefs.show_markers_margin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1067,7 +1067,7 @@ void ui_show_linenumber_margin(void)
|
||||
for(i = 0; i < max; i++)
|
||||
{
|
||||
idx = document_get_n_idx(i);
|
||||
sci_set_line_numbers(doc_list[idx].sci, editor_prefs.show_linenumber_margin, 0);
|
||||
sci_set_line_numbers(documents[idx]->sci, editor_prefs.show_linenumber_margin, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1202,10 +1202,10 @@ void ui_update_tab_status(gint idx)
|
||||
GdkColor *color = document_get_status_color(idx);
|
||||
|
||||
/* NULL color will reset to default */
|
||||
gtk_widget_modify_fg(doc_list[idx].tab_label, GTK_STATE_NORMAL, color);
|
||||
gtk_widget_modify_fg(doc_list[idx].tab_label, GTK_STATE_ACTIVE, color);
|
||||
gtk_widget_modify_fg(doc_list[idx].tabmenu_label, GTK_STATE_NORMAL, color);
|
||||
gtk_widget_modify_fg(doc_list[idx].tabmenu_label, GTK_STATE_ACTIVE, color);
|
||||
gtk_widget_modify_fg(documents[idx]->tab_label, GTK_STATE_NORMAL, color);
|
||||
gtk_widget_modify_fg(documents[idx]->tab_label, GTK_STATE_ACTIVE, color);
|
||||
gtk_widget_modify_fg(documents[idx]->tabmenu_label, GTK_STATE_NORMAL, color);
|
||||
gtk_widget_modify_fg(documents[idx]->tabmenu_label, GTK_STATE_ACTIVE, color);
|
||||
|
||||
treeviews_openfiles_update(idx);
|
||||
}
|
||||
|
58
src/utils.c
58
src/utils.c
@ -293,7 +293,7 @@ static gboolean reload_idx(gpointer data)
|
||||
|
||||
static gboolean check_reload(gint idx)
|
||||
{
|
||||
gchar *base_name = g_path_get_basename(doc_list[idx].file_name);
|
||||
gchar *base_name = g_path_get_basename(documents[idx]->file_name);
|
||||
gboolean want_reload;
|
||||
|
||||
want_reload = dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL,
|
||||
@ -323,31 +323,31 @@ gboolean utils_check_disk_status(gint idx, gboolean force)
|
||||
gboolean ret = FALSE;
|
||||
|
||||
if (file_prefs.disk_check_timeout == 0) return FALSE;
|
||||
if (idx == -1 || doc_list[idx].file_name == NULL) return FALSE;
|
||||
if (idx == -1 || documents[idx]->file_name == NULL) return FALSE;
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
if (! force && doc_list[idx].last_check > (t - file_prefs.disk_check_timeout))
|
||||
if (! force && documents[idx]->last_check > (t - file_prefs.disk_check_timeout))
|
||||
return FALSE;
|
||||
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(documents[idx]->file_name);
|
||||
if (g_stat(locale_filename, &st) != 0)
|
||||
{
|
||||
/* TODO: warn user file on disk is missing */
|
||||
}
|
||||
else if (doc_list[idx].mtime > t || st.st_mtime > t)
|
||||
else if (documents[idx]->mtime > t || st.st_mtime > t)
|
||||
{
|
||||
geany_debug("Strange: Something is wrong with the time stamps.");
|
||||
}
|
||||
else if (doc_list[idx].mtime < st.st_mtime)
|
||||
else if (documents[idx]->mtime < st.st_mtime)
|
||||
{
|
||||
if (check_reload(idx))
|
||||
{
|
||||
/* Disable checking until after reload, so ignore this change for now */
|
||||
doc_list[idx].mtime = st.st_mtime;
|
||||
documents[idx]->mtime = st.st_mtime;
|
||||
}
|
||||
else
|
||||
doc_list[idx].mtime = st.st_mtime; /* Ignore this change on disk completely */
|
||||
documents[idx]->mtime = st.st_mtime; /* Ignore this change on disk completely */
|
||||
|
||||
ret = TRUE; /* file has changed */
|
||||
}
|
||||
@ -360,7 +360,7 @@ gboolean utils_check_disk_status(gint idx, gboolean force)
|
||||
static gint get_function_fold_number(gint idx)
|
||||
{
|
||||
/* for Java the functions are always one fold level above the class scope */
|
||||
if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_JAVA)
|
||||
if (FILETYPE_ID(documents[idx]->file_type) == GEANY_FILETYPES_JAVA)
|
||||
return SC_FOLDLEVELBASE + 1;
|
||||
else
|
||||
return SC_FOLDLEVELBASE;
|
||||
@ -506,8 +506,8 @@ gint utils_get_current_function(gint idx, const gchar **tagname)
|
||||
return tag_line;
|
||||
}
|
||||
|
||||
line = sci_get_current_line(doc_list[idx].sci);
|
||||
fold_level = sci_get_fold_level(doc_list[idx].sci, line);
|
||||
line = sci_get_current_line(documents[idx]->sci);
|
||||
fold_level = sci_get_fold_level(documents[idx]->sci, line);
|
||||
/* check if the cached line and file index have changed since last time: */
|
||||
if (! current_function_changed(idx, line, fold_level))
|
||||
{
|
||||
@ -525,10 +525,10 @@ gint utils_get_current_function(gint idx, const gchar **tagname)
|
||||
tag_line = -1;
|
||||
return tag_line;
|
||||
}
|
||||
tm_file = doc_list[idx].tm_file;
|
||||
tm_file = documents[idx]->tm_file;
|
||||
|
||||
/* if the document has no changes, get the previous function name from TM */
|
||||
if(! doc_list[idx].changed && tm_file != NULL && tm_file->tags_array != NULL)
|
||||
if(! documents[idx]->changed && tm_file != NULL && tm_file->tags_array != NULL)
|
||||
{
|
||||
const TMTag *tag = (const TMTag*) tm_get_current_function(tm_file->tags_array, line);
|
||||
|
||||
@ -545,25 +545,25 @@ gint utils_get_current_function(gint idx, const gchar **tagname)
|
||||
|
||||
/* parse the current function name here because TM line numbers may have changed,
|
||||
* and it would take too long to reparse the whole file. */
|
||||
if (doc_list[idx].file_type != NULL &&
|
||||
doc_list[idx].file_type->id != GEANY_FILETYPES_NONE)
|
||||
if (documents[idx]->file_type != NULL &&
|
||||
documents[idx]->file_type->id != GEANY_FILETYPES_NONE)
|
||||
{
|
||||
const gint fn_fold = get_function_fold_number(idx);
|
||||
|
||||
tag_line = line;
|
||||
do /* find the top level fold point */
|
||||
{
|
||||
tag_line = sci_get_fold_parent(doc_list[idx].sci, tag_line);
|
||||
fold_level = sci_get_fold_level(doc_list[idx].sci, tag_line);
|
||||
tag_line = sci_get_fold_parent(documents[idx]->sci, tag_line);
|
||||
fold_level = sci_get_fold_level(documents[idx]->sci, tag_line);
|
||||
} while (tag_line >= 0 &&
|
||||
(fold_level & SC_FOLDLEVELNUMBERMASK) != fn_fold);
|
||||
|
||||
if (tag_line >= 0)
|
||||
{
|
||||
if (sci_get_lexer(doc_list[idx].sci) == SCLEX_CPP)
|
||||
cur_tag = parse_cpp_function_at_line(doc_list[idx].sci, tag_line);
|
||||
if (sci_get_lexer(documents[idx]->sci) == SCLEX_CPP)
|
||||
cur_tag = parse_cpp_function_at_line(documents[idx]->sci, tag_line);
|
||||
else
|
||||
cur_tag = parse_function_at_line(doc_list[idx].sci, tag_line);
|
||||
cur_tag = parse_function_at_line(documents[idx]->sci, tag_line);
|
||||
|
||||
if (cur_tag != NULL)
|
||||
{
|
||||
@ -1027,21 +1027,21 @@ void utils_replace_filename(gint idx)
|
||||
gchar *filename;
|
||||
struct TextToFind ttf;
|
||||
|
||||
if (idx == -1 || doc_list[idx].file_type == NULL) return;
|
||||
if (idx == -1 || documents[idx]->file_type == NULL) return;
|
||||
|
||||
filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (doc_list[idx].file_type)->extension, NULL);
|
||||
filename = g_path_get_basename(doc_list[idx].file_name);
|
||||
filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (documents[idx]->file_type)->extension, NULL);
|
||||
filename = g_path_get_basename(documents[idx]->file_name);
|
||||
|
||||
/* only search the first 3 lines */
|
||||
ttf.chrg.cpMin = 0;
|
||||
ttf.chrg.cpMax = sci_get_position_from_line(doc_list[idx].sci, 3);
|
||||
ttf.chrg.cpMax = sci_get_position_from_line(documents[idx]->sci, 3);
|
||||
ttf.lpstrText = (gchar*)filebase;
|
||||
|
||||
if (sci_find_text(doc_list[idx].sci, SCFIND_MATCHCASE, &ttf) != -1)
|
||||
if (sci_find_text(documents[idx]->sci, SCFIND_MATCHCASE, &ttf) != -1)
|
||||
{
|
||||
sci_target_start(doc_list[idx].sci, ttf.chrgText.cpMin);
|
||||
sci_target_end(doc_list[idx].sci, ttf.chrgText.cpMax);
|
||||
sci_target_replace(doc_list[idx].sci, filename, FALSE);
|
||||
sci_target_start(documents[idx]->sci, ttf.chrgText.cpMin);
|
||||
sci_target_end(documents[idx]->sci, ttf.chrgText.cpMax);
|
||||
sci_target_replace(documents[idx]->sci, filename, FALSE);
|
||||
}
|
||||
|
||||
g_free(filebase);
|
||||
@ -1074,7 +1074,7 @@ gchar *utils_get_current_file_dir_utf8(void)
|
||||
if (DOC_IDX_VALID(cur_idx)) /* if valid page found */
|
||||
{
|
||||
/* get current filename */
|
||||
const gchar *cur_fname = doc_list[cur_idx].file_name;
|
||||
const gchar *cur_fname = documents[cur_idx]->file_name;
|
||||
|
||||
if (cur_fname != NULL)
|
||||
{
|
||||
|
@ -437,7 +437,7 @@ static void vte_popup_menu_clicked(GtkMenuItem *menuitem, gpointer user_data)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
if (DOC_IDX_VALID(idx))
|
||||
vte_cwd(doc_list[idx].file_name, TRUE);
|
||||
vte_cwd(documents[idx]->file_name, TRUE);
|
||||
break;
|
||||
}
|
||||
case POPUP_RESTARTTERMINAL:
|
||||
|
@ -406,7 +406,7 @@ gboolean win32_show_file_dialog(gboolean file_open, const gchar *initial_dir)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
/* convert the resulting filename into UTF-8 */
|
||||
doc_list[idx].file_name = g_locale_to_utf8(fname, -1, NULL, NULL, NULL);
|
||||
documents[idx]->file_name = g_locale_to_utf8(fname, -1, NULL, NULL, NULL);
|
||||
document_save_file_as(idx);
|
||||
}
|
||||
g_free(fname);
|
||||
|
Loading…
x
Reference in New Issue
Block a user