Revision: 2624 http://geany.svn.sourceforge.net/geany/?rev=2624&view=rev Author: ntrel Date: 2008-05-29 10:00:54 -0700 (Thu, 29 May 2008)
Log Message: ----------- 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.
Modified Paths: -------------- trunk/ChangeLog trunk/plugins/autosave.c trunk/plugins/classbuilder.c trunk/plugins/export.c trunk/plugins/filebrowser.c trunk/plugins/htmlchars.c trunk/plugins/pluginmacros.h trunk/plugins/vcdiff.c trunk/src/build.c trunk/src/callbacks.c trunk/src/dialogs.c trunk/src/document.c trunk/src/document.h trunk/src/editor.c trunk/src/filetypes.c trunk/src/keybindings.c trunk/src/keyfile.c trunk/src/main.c trunk/src/msgwindow.c trunk/src/navqueue.c trunk/src/notebook.c trunk/src/plugindata.h trunk/src/plugins.c trunk/src/prefs.c trunk/src/printing.c trunk/src/search.c trunk/src/socket.c trunk/src/symbols.c trunk/src/tools.c trunk/src/treeviews.c trunk/src/ui_utils.c trunk/src/utils.c trunk/src/vte.c trunk/src/win32.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/ChangeLog 2008-05-29 17:00:54 UTC (rev 2624) @@ -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:
Modified: trunk/plugins/autosave.c =================================================================== --- trunk/plugins/autosave.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/plugins/autosave.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -63,14 +63,14 @@ 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++;
Modified: trunk/plugins/classbuilder.c =================================================================== --- trunk/plugins/classbuilder.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/plugins/classbuilder.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -732,7 +732,7 @@ { 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 @@ { 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); }
Modified: trunk/plugins/export.c =================================================================== --- trunk/plugins/export.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/plugins/export.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -209,20 +209,20 @@
/* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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);
Modified: trunk/plugins/filebrowser.c =================================================================== --- trunk/plugins/filebrowser.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/plugins/filebrowser.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -277,14 +277,14 @@ 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);
Modified: trunk/plugins/htmlchars.c =================================================================== --- trunk/plugins/htmlchars.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/plugins/htmlchars.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -444,12 +444,12 @@ 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 @@ /* 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(); }
Modified: trunk/plugins/pluginmacros.h =================================================================== --- trunk/plugins/pluginmacros.h 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/plugins/pluginmacros.h 2008-05-29 17:00:54 UTC (rev 2624) @@ -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
Modified: trunk/plugins/vcdiff.c =================================================================== --- trunk/plugins/vcdiff.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/plugins/vcdiff.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -252,10 +252,10 @@ { 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 @@ } 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 @@
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 @@
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 @@
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);
Modified: trunk/src/build.c =================================================================== --- trunk/src/build.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/src/build.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -129,16 +129,16 @@ { 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 @@ 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 @@
/* 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 @@ { 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 @@ 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_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 @@ { 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 @@ 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 @@
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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@
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 @@ 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 @@
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 @@ { 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 @@ 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 @@ /* 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 @@
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 @@ 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 @@ { /* 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);
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/src/callbacks.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -94,9 +94,9 @@ { 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 @@ { 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 @@
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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ { 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 @@ { 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ /* 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@
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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ { 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { /* 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 @@ 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 @@ 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 @@ }
/* 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 {
Modified: trunk/src/dialogs.c =================================================================== --- trunk/src/dialogs.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/src/dialogs.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -393,11 +393,11 @@ } 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 @@ 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 @@
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 @@ } 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 @@ 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 @@ { 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 @@ # 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 @@
#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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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);
Modified: trunk/src/document.c =================================================================== --- trunk/src/document.c 2008-05-28 16:09:16 UTC (rev 2623) +++ trunk/src/document.c 2008-05-29 17:00:54 UTC (rev 2624) @@ -77,8 +77,7 @@
GeanyFilePrefs file_prefs;
-/* dynamic array of document elements to hold all information of the notebook tabs */ -GArray *doc_array; +GPtrArray *documents_array;
/* Whether to colourise the document straight after styling settings are changed. * (e.g. when filetype is set or typenames are updated) */ @@ -102,9 +101,9 @@ { guint i;
- for (i = 0; i < doc_array->len; i++) + for (i = 0; i < documents_array->len; i++) { - TMWorkObject *tm_file = doc_list[i].tm_file; + TMWorkObject *tm_file = documents[i]->tm_file;
if (tm_file == NULL || tm_file->file_name == NULL) continue;
@@ -150,9 +149,9 @@ realname = get_real_path_from_utf8(filename); /* dereference symlinks, /../ junk in path */ if (! realname) return -1;
- for (i = 0; i < doc_array->len; i++) + for (i = 0; i < documents_array->len; i++) { - GeanyDocument *doc = &doc_list[i]; + GeanyDocument *doc = documents[i]; gchar *docname;
if (doc->file_name == NULL) continue; @@ -180,9 +179,9 @@
if (! sci) return -1;
- 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].sci == sci) return i; + if (documents[i]->is_valid && documents[i]->sci == sci) return i; } return -1; } @@ -194,7 +193,7 @@ if (! DOC_IDX_VALID(doc_idx)) return -1;
return gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook), - GTK_WIDGET(doc_list[doc_idx].sci)); + GTK_WIDGET(documents[doc_idx]->sci)); }
@@ -209,7 +208,7 @@ gint document_get_n_idx(guint page_num) { ScintillaObject *sci; - if (page_num >= doc_array->len) return -1; + if (page_num >= documents_array->len) return -1;
sci = (ScintillaObject*)gtk_notebook_get_nth_page( GTK_NOTEBOOK(main_widgets.notebook), page_num); @@ -249,19 +248,19 @@ { gint idx = document_get_cur_idx();
- return DOC_IDX_VALID(idx) ? &doc_list[idx] : NULL; + return DOC_IDX_VALID(idx) ? documents[idx] : NULL; }
void document_init_doclist() { - doc_array = g_array_new(FALSE, FALSE, sizeof(GeanyDocument)); + documents_array = g_ptr_array_new(); }
void document_finalize() { - g_array_free(doc_array, TRUE); + g_ptr_array_free(documents_array, TRUE); }
@@ -277,7 +276,7 @@ if (DOC_IDX_VALID(idx) && ! main_status.quitting) { ui_update_tab_status(idx); - ui_save_buttons_toggle(doc_list[idx].changed); + ui_save_buttons_toggle(documents[idx]->changed); ui_set_window_title(idx); ui_update_statusbar(idx, -1); } @@ -287,7 +286,7 @@ /* Apply just the prefs that can change in the Preferences dialog */ void document_apply_update_prefs(gint idx) { - ScintillaObject *sci = doc_list[idx].sci; + ScintillaObject *sci = documents[idx]->sci;
sci_set_mark_long_lines(sci, editor_prefs.long_line_type, editor_prefs.long_line_column, editor_prefs.long_line_color);
@@ -301,7 +300,7 @@
sci_set_folding_margin_visible(sci, editor_prefs.folding);
- doc_list[idx].auto_indent = (editor_prefs.indent_mode != INDENT_NONE); + documents[idx]->auto_indent = (editor_prefs.indent_mode != INDENT_NONE);
sci_assign_cmdkey(sci, SCK_HOME, editor_prefs.smart_home_key ? SCI_VCHOMEWRAP : SCI_HOMEWRAP); @@ -313,6 +312,8 @@ * The flag is_valid is set to TRUE in document_create(). */ static void init_doc_struct(GeanyDocument *new_doc) { + memset(new_doc, 0, sizeof(GeanyDocument)); + new_doc->is_valid = FALSE; new_doc->has_tags = FALSE; new_doc->auto_indent = (editor_prefs.indent_mode != INDENT_NONE); @@ -338,15 +339,15 @@ }
-/* returns the next free place(i.e. index) in the document list, - * or -1 if the current doc_array is full */ +/* returns the next free place (i.e. index) in the document list, + * or -1 if the documents_array is full */ static gint document_get_new_idx(void) { guint i;
- for(i = 0; i < doc_array->len; i++) + for (i = 0; i < documents_array->len; i++) { - if (doc_list[i].sci == NULL) + if (documents[i]->sci == NULL) { return (gint) i; } @@ -440,17 +441,18 @@ { gint idx = document_get_cur_idx(); /* remove the empty document and open a new one */ - if (doc_list[idx].file_name == NULL && ! doc_list[idx].changed) document_remove(0); + if (documents[idx]->file_name == NULL && ! documents[idx]->changed) document_remove(0); }
new_idx = document_get_new_idx(); if (new_idx == -1) /* expand the array, no free places */ { - GeanyDocument new_doc; - new_idx = doc_array->len; - g_array_append_val(doc_array, new_doc); + GeanyDocument *new_doc = g_new0(GeanyDocument, 1); + + new_idx = documents_array->len; + g_ptr_array_add(documents_array, new_doc); } - this = &doc_list[new_idx]; + this = documents[new_idx]; init_doc_struct(this); /* initialize default document settings */
this->file_name = (utf8_filename) ? g_strdup(utf8_filename) : NULL; @@ -498,31 +500,31 @@
if (DOC_IDX_VALID(idx)) { - if (doc_list[idx].changed && ! dialogs_show_unsaved_file(idx)) + if (documents[idx]->changed && ! dialogs_show_unsaved_file(idx)) { return FALSE; } - /* TODO: check g_file_test(doc_list[idx].real_name, G_FILE_TEST_EXISTS) */ + /* TODO: check g_file_test(documents[idx]->real_name, G_FILE_TEST_EXISTS) */ if (! main_status.closing_all && g_path_is_absolute(DOC_FILENAME(idx))) - ui_add_recent_file(doc_list[idx].file_name); + ui_add_recent_file(documents[idx]->file_name);
notebook_remove_page(page_num); treeviews_remove_document(idx); - navqueue_remove_file(doc_list[idx].file_name); + navqueue_remove_file(documents[idx]->file_name); msgwin_status_add(_("File %s closed."), DOC_FILENAME(idx)); - g_free(doc_list[idx].encoding); - g_free(doc_list[idx].saved_encoding.encoding); - g_free(doc_list[idx].file_name); - tm_workspace_remove_object(doc_list[idx].tm_file, TRUE, TRUE); + g_free(documents[idx]->encoding); + g_free(documents[idx]->saved_encoding.encoding); + g_free(documents[idx]->file_name); + tm_workspace_remove_object(documents[idx]->tm_file, TRUE, TRUE);
- doc_list[idx].is_valid = FALSE; - doc_list[idx].sci = NULL; - doc_list[idx].file_name = NULL; - doc_list[idx].file_type = NULL; - doc_list[idx].encoding = NULL; - doc_list[idx].has_bom = FALSE; - doc_list[idx].tm_file = NULL; - doc_list[idx].scroll_percent = -1.0F; + documents[idx]->is_valid = FALSE; + documents[idx]->sci = NULL; + documents[idx]->file_name = NULL; + documents[idx]->file_type = NULL; + documents[idx]->encoding = NULL; + documents[idx]->has_bom = FALSE; + documents[idx]->tm_file = NULL; + documents[idx]->scroll_percent = -1.0F; document_undo_clear(idx); if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 0) { @@ -547,9 +549,9 @@ /* used to keep a record of the unchanged document state encoding */ static void store_saved_encoding(gint idx) { - g_free(doc_list[idx].saved_encoding.encoding); - doc_list[idx].saved_encoding.encoding = g_strdup(doc_list[idx].encoding); - doc_list[idx].saved_encoding.has_bom = doc_list[idx].has_bom; + g_free(documents[idx]->saved_encoding.encoding); + documents[idx]->saved_encoding.encoding = g_strdup(documents[idx]->encoding); + documents[idx]->saved_encoding.has_bom = documents[idx]->has_bom; }
@@ -571,7 +573,7 @@ * @param ft The filetype to set or @c NULL to detect it from @a filename if not @c NULL. * @param text The initial content of the file (in UTF-8 encoding), or @c NULL. * - * @return The index of the new file in the @ref doc_list array. + * @return The index of the new file in @ref documents_array. **/ gint document_new_file(const gchar *filename, GeanyFiletype *ft, const gchar *text) { @@ -579,26 +581,26 @@
g_assert(idx != -1);
- sci_set_undo_collection(doc_list[idx].sci, FALSE); /* avoid creation of an undo action */ + sci_set_undo_collection(documents[idx]->sci, FALSE); /* avoid creation of an undo action */ if (text) - sci_set_text(doc_list[idx].sci, text); + sci_set_text(documents[idx]->sci, text); else - sci_clear_all(doc_list[idx].sci); + sci_clear_all(documents[idx]->sci);
- sci_set_eol_mode(doc_list[idx].sci, file_prefs.default_eol_character); + sci_set_eol_mode(documents[idx]->sci, file_prefs.default_eol_character); /* convert the eol chars in the template text in case they are different from * from file_prefs.default_eol */ if (text != NULL) - sci_convert_eols(doc_list[idx].sci, file_prefs.default_eol_character); + sci_convert_eols(documents[idx]->sci, file_prefs.default_eol_character);
editor_set_use_tabs(idx, editor_prefs.use_tabs); - sci_set_undo_collection(doc_list[idx].sci, TRUE); - sci_empty_undo_buffer(doc_list[idx].sci); + sci_set_undo_collection(documents[idx]->sci, TRUE); + sci_empty_undo_buffer(documents[idx]->sci);
- doc_list[idx].mtime = time(NULL); - doc_list[idx].changed = FALSE; + documents[idx]->mtime = time(NULL); + documents[idx]->changed = FALSE;
- doc_list[idx].encoding = g_strdup(encodings[file_prefs.default_new_encoding].charset); + documents[idx]->encoding = g_strdup(encodings[file_prefs.default_new_encoding].charset); /* store the opened encoding for undo/redo */ store_saved_encoding(idx);
@@ -608,18 +610,18 @@
document_set_filetype(idx, ft); /* also clears taglist */ if (ft == NULL) - highlighting_set_styles(doc_list[idx].sci, GEANY_FILETYPES_NONE); + highlighting_set_styles(documents[idx]->sci, GEANY_FILETYPES_NONE); ui_set_window_title(idx); build_menu_update(idx); document_update_tag_list(idx, FALSE); document_set_text_changed(idx); ui_document_show_hide(idx); /* update the document menu */
- sci_set_line_numbers(doc_list[idx].sci, editor_prefs.show_linenumber_margin, 0); - sci_goto_pos(doc_list[idx].sci, 0, TRUE); + sci_set_line_numbers(documents[idx]->sci, editor_prefs.show_linenumber_margin, 0); + sci_goto_pos(documents[idx]->sci, 0, TRUE);
/* "the" SCI signal (connect after initial setup(i.e. adding text)) */ - g_signal_connect((GtkWidget*) doc_list[idx].sci, "sci-notify", + g_signal_connect((GtkWidget*) documents[idx]->sci, "sci-notify", G_CALLBACK(on_editor_notification), GINT_TO_POINTER(idx));
if (geany_object) @@ -628,7 +630,7 @@ }
msgwin_status_add(_("New file "%s" opened."), - (doc_list[idx].file_name != NULL) ? doc_list[idx].file_name : GEANY_STRING_UNTITLED); + (documents[idx]->file_name != NULL) ? documents[idx]->file_name : GEANY_STRING_UNTITLED);
return idx; } @@ -894,21 +896,21 @@ { if (cl_options.goto_line >= 0) { /* goto line which was specified on command line and then undefine the line */ - sci_goto_line(doc_list[idx].sci, cl_options.goto_line - 1, TRUE); - doc_list[idx].scroll_percent = 0.5F; + sci_goto_line(documents[idx]->sci, cl_options.goto_line - 1, TRUE); + documents[idx]->scroll_percent = 0.5F; cl_options.goto_line = -1; } else if (pos > 0) { - sci_set_current_position(doc_list[idx].sci, pos, FALSE); - doc_list[idx].scroll_percent = 0.5F; + sci_set_current_position(documents[idx]->sci, pos, FALSE); + documents[idx]->scroll_percent = 0.5F; }
if (cl_options.goto_column >= 0) { /* goto column which was specified on command line and then undefine the column */ - gint cur_pos = sci_get_current_position(doc_list[idx].sci); - sci_set_current_position(doc_list[idx].sci, cur_pos + cl_options.goto_column, FALSE); - doc_list[idx].scroll_percent = 0.5F; + gint cur_pos = sci_get_current_position(documents[idx]->sci); + sci_set_current_position(documents[idx]->sci, cur_pos + cl_options.goto_column, FALSE); + documents[idx]->scroll_percent = 0.5F; cl_options.goto_column = -1; } } @@ -949,13 +951,13 @@ static void set_indentation(gint idx) { /* force using tabs for indentation for Makefiles */ - if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_MAKE) + if (FILETYPE_ID(documents[idx]->file_type) == GEANY_FILETYPES_MAKE) editor_set_use_tabs(idx, TRUE); else if (! editor_prefs.detect_tab_mode) editor_set_use_tabs(idx, editor_prefs.use_tabs); else { /* detect & set tabs/spaces */ - gboolean use_tabs = detect_use_tabs(doc_list[idx].sci); + gboolean use_tabs = detect_use_tabs(documents[idx]->sci);
if (use_tabs != editor_prefs.use_tabs) ui_set_statusbar(TRUE, _("Setting %s indentation mode."), @@ -994,7 +996,7 @@
if (reload) { - utf8_filename = g_strdup(doc_list[idx].file_name); + utf8_filename = g_strdup(documents[idx]->file_name); locale_filename = utils_get_locale_from_utf8(utf8_filename); } else @@ -1022,7 +1024,7 @@ ui_add_recent_file(utf8_filename); /* either add or reorder recent item */ 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_free(utf8_filename); g_free(locale_filename); utils_check_disk_status(idx, TRUE); /* force a file changed check */ @@ -1045,32 +1047,32 @@ if (! reload) idx = document_create(utf8_filename); g_return_val_if_fail(idx != -1, -1); /* really should not happen */
- sci_set_undo_collection(doc_list[idx].sci, FALSE); /* avoid creation of an undo action */ - sci_empty_undo_buffer(doc_list[idx].sci); + sci_set_undo_collection(documents[idx]->sci, FALSE); /* avoid creation of an undo action */ + sci_empty_undo_buffer(documents[idx]->sci);
/* add the text to the ScintillaObject */ - sci_set_readonly(doc_list[idx].sci, FALSE); /* to allow replacing text */ - sci_set_text(doc_list[idx].sci, filedata.data); /* NULL terminated data */ + sci_set_readonly(documents[idx]->sci, FALSE); /* to allow replacing text */ + sci_set_text(documents[idx]->sci, filedata.data); /* NULL terminated data */
/* detect & set line endings */ editor_mode = utils_get_line_endings(filedata.data, filedata.len); - sci_set_eol_mode(doc_list[idx].sci, editor_mode); + sci_set_eol_mode(documents[idx]->sci, editor_mode); g_free(filedata.data);
- sci_set_undo_collection(doc_list[idx].sci, TRUE); + sci_set_undo_collection(documents[idx]->sci, TRUE);
- doc_list[idx].mtime = filedata.mtime; /* get the modification time from file and keep it */ - doc_list[idx].changed = FALSE; - g_free(doc_list[idx].encoding); /* if reloading, free old encoding */ - doc_list[idx].encoding = filedata.enc; - doc_list[idx].has_bom = filedata.bom; + documents[idx]->mtime = filedata.mtime; /* get the modification time from file and keep it */ + documents[idx]->changed = FALSE; + g_free(documents[idx]->encoding); /* if reloading, free old encoding */ + documents[idx]->encoding = filedata.enc; + documents[idx]->has_bom = filedata.bom; store_saved_encoding(idx); /* store the opened encoding for undo/redo */
- doc_list[idx].readonly = readonly || filedata.readonly; - sci_set_readonly(doc_list[idx].sci, doc_list[idx].readonly); + documents[idx]->readonly = readonly || filedata.readonly; + sci_set_readonly(documents[idx]->sci, documents[idx]->readonly);
/* update line number margin width */ - 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);
/* set the cursor position according to pos, cl_options.goto_line and cl_options.goto_column */ set_cursor_position(idx, pos); @@ -1078,7 +1080,7 @@ if (! reload) { /* "the" SCI signal (connect after initial setup(i.e. adding text)) */ - g_signal_connect((GtkWidget*) doc_list[idx].sci, "sci-notify", + g_signal_connect((GtkWidget*) documents[idx]->sci, "sci-notify", G_CALLBACK(on_editor_notification), GINT_TO_POINTER(idx));
use_ft = (ft != NULL) ? ft : filetypes_detect_from_file(idx); @@ -1090,7 +1092,7 @@ * without typenames changing. * Note: This could cause double colourising of the current document if typenames have * also changed, but it shouldn't be that noticeable. */ - sci_colourise(doc_list[idx].sci, 0, -1); + sci_colourise(documents[idx]->sci, 0, -1); use_ft = ft; } /* update taglist, typedef keywords and build menu if necessary */ @@ -1098,7 +1100,7 @@
/* set indentation settings after setting the filetype */ if (reload) - editor_set_use_tabs(idx, doc_list[idx].use_tabs); /* resetup sci */ + editor_set_use_tabs(idx, documents[idx]->use_tabs); /* resetup sci */ else set_indentation(idx);
@@ -1209,9 +1211,9 @@ return FALSE;
/* try to set the cursor to the position before reloading */ - pos = sci_get_current_position(doc_list[idx].sci); - idx = document_open_file_full(idx, NULL, pos, doc_list[idx].readonly, - doc_list[idx].file_type, forced_enc); + pos = sci_get_current_position(documents[idx]->sci); + idx = document_open_file_full(idx, NULL, pos, documents[idx]->readonly, + documents[idx]->file_type, forced_enc); return (idx != -1); }
@@ -1223,16 +1225,16 @@
g_return_val_if_fail(DOC_IDX_VALID(idx), 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) { - ui_set_statusbar(TRUE, _("Could not open file %s (%s)"), doc_list[idx].file_name, + ui_set_statusbar(TRUE, _("Could not open file %s (%s)"), documents[idx]->file_name, g_strerror(errno)); g_free(locale_filename); return FALSE; }
- doc_list[idx].mtime = st.st_mtime; /* get the modification time from file and keep it */ + documents[idx]->mtime = st.st_mtime; /* get the modification time from file and keep it */ g_free(locale_filename); return TRUE; } @@ -1246,8 +1248,8 @@ gint line_start;
/* for some reason we can use byte count instead of character count here */ - *line = sci_get_line_from_position(doc_list[idx].sci, byte_pos); - line_start = sci_get_position_from_line(doc_list[idx].sci, *line); + *line = sci_get_line_from_position(documents[idx]->sci, byte_pos); + line_start = sci_get_position_from_line(documents[idx]->sci, *line); /* get the column in the line */ *column = byte_pos - line_start;
@@ -1255,7 +1257,7 @@ * skip one byte(i++) and decrease the column number which is based on byte count */ for (i = line_start; i < (line_start + *column); i++) { - if (sci_get_char_at(doc_list[idx].sci, i) < 0) + if (sci_get_char_at(documents[idx]->sci, i) < 0) { (*column)--; i++; @@ -1278,7 +1280,7 @@ if (! DOC_IDX_VALID(idx)) return FALSE;
/* detect filetype */ - if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_NONE) + if (FILETYPE_ID(documents[idx]->file_type) == GEANY_FILETYPES_NONE) { GeanyFiletype *ft = filetypes_detect_from_file(idx);
@@ -1286,7 +1288,7 @@ if (document_get_cur_idx() == idx) { ignore_callback = TRUE; - filetypes_select_radio_item(doc_list[idx].file_type); + filetypes_select_radio_item(documents[idx]->file_type); ignore_callback = FALSE; } } @@ -1294,7 +1296,7 @@
ret = document_save_file(idx, TRUE); if (ret) - ui_add_recent_file(doc_list[idx].file_name); + ui_add_recent_file(documents[idx]->file_name); return ret; }
@@ -1310,14 +1312,14 @@ g_return_val_if_fail(len != NULL, FALSE);
/* try to convert it from UTF-8 to original encoding */ - conv_file_contents = g_convert(*data, *len - 1, doc_list[idx].encoding, "UTF-8", + conv_file_contents = g_convert(*data, *len - 1, documents[idx]->encoding, "UTF-8", &bytes_read, &conv_len, &conv_error);
if (conv_error != NULL) { gchar *text = g_strdup_printf( _("An error occurred while converting the file from UTF-8 in "%s". The file remains unsaved."), - doc_list[idx].encoding); + documents[idx]->encoding); gchar *error_text;
if (conv_error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE) @@ -1329,7 +1331,7 @@ /* don't read over the doc length */ gint max_len = MIN((gint)bytes_read + 6, (gint)*len - 1); context = g_malloc(7); /* read 6 bytes from Sci + '\0' */ - sci_get_text_range(doc_list[idx].sci, bytes_read, max_len, context); + sci_get_text_range(documents[idx]->sci, bytes_read, max_len, context);
/* take only one valid Unicode character from the context and discard the leftover */ unic = g_utf8_get_char_validated(context, -1); @@ -1372,7 +1374,7 @@
g_return_val_if_fail(data != NULL, EINVAL);
- locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name); + locale_filename = utils_get_locale_from_utf8(documents[idx]->file_name); fp = g_fopen(locale_filename, "wb"); if (fp == NULL) { @@ -1414,10 +1416,10 @@ return FALSE;
/* the "changed" flag should exclude the "readonly" flag, but check it anyway for safety */ - if (! force && (! doc_list[idx].changed || doc_list[idx].readonly)) + if (! force && (! documents[idx]->changed || documents[idx]->readonly)) return FALSE;
- if (doc_list[idx].file_name == NULL) + if (documents[idx]->file_name == NULL) { ui_set_statusbar(TRUE, _("Error saving file.")); utils_beep(); @@ -1425,34 +1427,34 @@ }
/* replaces tabs by spaces but only if the current file is not a Makefile */ - if (file_prefs.replace_tabs && FILETYPE_ID(doc_list[idx].file_type) != GEANY_FILETYPES_MAKE) + if (file_prefs.replace_tabs && FILETYPE_ID(documents[idx]->file_type) != GEANY_FILETYPES_MAKE) editor_replace_tabs(idx); /* strip trailing spaces */ if (file_prefs.strip_trailing_spaces) editor_strip_trailing_spaces(idx); /* ensure the file has a newline at the end */ if (file_prefs.final_new_line) editor_ensure_final_newline(idx);
- len = sci_get_length(doc_list[idx].sci) + 1; - if (doc_list[idx].has_bom && encodings_is_unicode_charset(doc_list[idx].encoding)) + len = sci_get_length(documents[idx]->sci) + 1; + if (documents[idx]->has_bom && encodings_is_unicode_charset(documents[idx]->encoding)) { /* always write a UTF-8 BOM because in this moment the text itself is still in UTF-8 - * encoding, it will be converted to doc_list[idx].encoding below and this conversion + * encoding, it will be converted to documents[idx]->encoding below and this conversion * also changes the BOM */ data = (gchar*) g_malloc(len + 3); /* 3 chars for BOM */ data[0] = (gchar) 0xef; data[1] = (gchar) 0xbb; data[2] = (gchar) 0xbf; - sci_get_text(doc_list[idx].sci, len, data + 3); + sci_get_text(documents[idx]->sci, len, data + 3); len += 3; } else { data = (gchar*) g_malloc(len); - sci_get_text(doc_list[idx].sci, len, data); + sci_get_text(documents[idx]->sci, len, data); }
/* save in original encoding, skip when it is already UTF-8 or has the encoding "None" */ - if (doc_list[idx].encoding != NULL && ! utils_str_equal(doc_list[idx].encoding, "UTF-8") && - ! utils_str_equal(doc_list[idx].encoding, encodings[GEANY_ENCODING_NONE].charset)) + if (documents[idx]->encoding != NULL && ! utils_str_equal(documents[idx]->encoding, "UTF-8") && + ! utils_str_equal(documents[idx]->encoding, encodings[GEANY_ENCODING_NONE].charset)) { if (! save_convert_to_encoding(idx, &data, &len)) { @@ -1484,28 +1486,28 @@ /* ignore the following things if we are quitting */ if (! main_status.quitting) { - gchar *base_name = g_path_get_basename(doc_list[idx].file_name); + gchar *base_name = g_path_get_basename(documents[idx]->file_name);
/* set line numbers again, to reset the margin width, if * there are more lines than before */ - sci_set_line_numbers(doc_list[idx].sci, editor_prefs.show_linenumber_margin, 0); - sci_set_savepoint(doc_list[idx].sci); + sci_set_line_numbers(documents[idx]->sci, editor_prefs.show_linenumber_margin, 0); + sci_set_savepoint(documents[idx]->sci);
/* stat the file to get the timestamp, otherwise on Windows the actual * timestamp can be ahead of time(NULL) */ document_update_timestamp(idx);
/* update filetype-related things */ - document_set_filetype(idx, doc_list[idx].file_type); + document_set_filetype(idx, documents[idx]->file_type);
tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE); - gtk_label_set_text(GTK_LABEL(doc_list[idx].tab_label), base_name); - gtk_label_set_text(GTK_LABEL(doc_list[idx].tabmenu_label), base_name); - msgwin_status_add(_("File %s saved."), doc_list[idx].file_name); + gtk_label_set_text(GTK_LABEL(documents[idx]->tab_label), base_name); + gtk_label_set_text(GTK_LABEL(documents[idx]->tabmenu_label), base_name); + msgwin_status_add(_("File %s saved."), documents[idx]->file_name); ui_update_statusbar(idx, -1); g_free(base_name); #ifdef HAVE_VTE - vte_cwd(doc_list[idx].file_name, FALSE); + vte_cwd(documents[idx]->file_name, FALSE); #endif } if (geany_object) @@ -1530,38 +1532,38 @@ if (! *text) return TRUE;
- start_pos = (inc) ? sci_get_selection_start(doc_list[idx].sci) : - sci_get_selection_end(doc_list[idx].sci); /* equal if no selection */ + start_pos = (inc) ? sci_get_selection_start(documents[idx]->sci) : + sci_get_selection_end(documents[idx]->sci); /* equal if no selection */
/* search cursor to end */ ttf.chrg.cpMin = start_pos; - ttf.chrg.cpMax = sci_get_length(doc_list[idx].sci); + ttf.chrg.cpMax = sci_get_length(documents[idx]->sci); ttf.lpstrText = (gchar *)text; - search_pos = sci_find_text(doc_list[idx].sci, flags, &ttf); + search_pos = sci_find_text(documents[idx]->sci, flags, &ttf);
/* if no match, search start to cursor */ if (search_pos == -1) { ttf.chrg.cpMin = 0; ttf.chrg.cpMax = start_pos + strlen(text); - search_pos = sci_find_text(doc_list[idx].sci, flags, &ttf); + search_pos = sci_find_text(documents[idx]->sci, flags, &ttf); }
if (search_pos != -1) { - gint line = sci_get_line_from_position(doc_list[idx].sci, ttf.chrgText.cpMin); + gint line = sci_get_line_from_position(documents[idx]->sci, ttf.chrgText.cpMin);
/* unfold maybe folded results */ - sci_ensure_line_is_visible(doc_list[idx].sci, line); + sci_ensure_line_is_visible(documents[idx]->sci, line);
- sci_set_selection_start(doc_list[idx].sci, ttf.chrgText.cpMin); - sci_set_selection_end(doc_list[idx].sci, ttf.chrgText.cpMax); + sci_set_selection_start(documents[idx]->sci, ttf.chrgText.cpMin); + sci_set_selection_end(documents[idx]->sci, ttf.chrgText.cpMax);
- if (! editor_line_in_view(doc_list[idx].sci, line)) + if (! editor_line_in_view(documents[idx]->sci, line)) { /* we need to force scrolling in case the cursor is outside of the current visible area - * doc_list[].scroll_percent doesn't work because sci isn't always updated + * GeanyDocument::scroll_percent doesn't work because sci isn't always updated * while searching */ - editor_scroll_to_line(doc_list[idx].sci, -1, 0.3F); + editor_scroll_to_line(documents[idx]->sci, -1, 0.3F); } return TRUE; } @@ -1572,7 +1574,7 @@ ui_set_statusbar(FALSE, _(""%s" was not found."), text); } utils_beep(); - sci_goto_pos(doc_list[idx].sci, start_pos, FALSE); /* clear selection */ + sci_goto_pos(documents[idx]->sci, start_pos, FALSE); /* clear selection */ return FALSE; } } @@ -1591,33 +1593,33 @@ /* Sci doesn't support searching backwards with a regex */ if (flags & SCFIND_REGEXP) search_backwards = FALSE;
- selection_start = sci_get_selection_start(doc_list[idx].sci); - selection_end = sci_get_selection_end(doc_list[idx].sci); + selection_start = sci_get_selection_start(documents[idx]->sci); + selection_end = sci_get_selection_end(documents[idx]->sci); if ((selection_end - selection_start) > 0) { /* there's a selection so go to the end */ if (search_backwards) - sci_goto_pos(doc_list[idx].sci, selection_start, TRUE); + sci_goto_pos(documents[idx]->sci, selection_start, TRUE); else - sci_goto_pos(doc_list[idx].sci, selection_end, TRUE); + sci_goto_pos(documents[idx]->sci, selection_end, TRUE); }
- sci_set_search_anchor(doc_list[idx].sci); + sci_set_search_anchor(documents[idx]->sci); if (search_backwards) - search_pos = sci_search_prev(doc_list[idx].sci, flags, text); + search_pos = sci_search_prev(documents[idx]->sci, flags, text); else - search_pos = sci_search_next(doc_list[idx].sci, flags, text); + search_pos = sci_search_next(documents[idx]->sci, flags, text);
if (search_pos != -1) { /* unfold maybe folded results */ - sci_ensure_line_is_visible(doc_list[idx].sci, - sci_get_line_from_position(doc_list[idx].sci, search_pos)); + sci_ensure_line_is_visible(documents[idx]->sci, + sci_get_line_from_position(documents[idx]->sci, search_pos)); if (scroll) - doc_list[idx].scroll_percent = 0.3F; + documents[idx]->scroll_percent = 0.3F; } else { - gint sci_len = sci_get_length(doc_list[idx].sci); + gint sci_len = sci_get_length(documents[idx]->sci);
/* if we just searched the whole text, give up searching. */ if ((selection_end == 0 && ! search_backwards) || @@ -1635,11 +1637,11 @@ { gint ret;
- sci_set_current_position(doc_list[idx].sci, (search_backwards) ? sci_len : 0, FALSE); + sci_set_current_position(documents[idx]->sci, (search_backwards) ? sci_len : 0, FALSE); ret = document_find_text(idx, text, flags, search_backwards, scroll, parent); if (ret == -1) { /* return to original cursor position if not found */ - sci_set_current_position(doc_list[idx].sci, selection_start, FALSE); + sci_set_current_position(documents[idx]->sci, selection_start, FALSE); } return ret; } @@ -1661,8 +1663,8 @@ /* Sci doesn't support searching backwards with a regex */ if (flags & SCFIND_REGEXP) search_backwards = FALSE;
- selection_start = sci_get_selection_start(doc_list[idx].sci); - selection_end = sci_get_selection_end(doc_list[idx].sci); + selection_start = sci_get_selection_start(documents[idx]->sci); + selection_end = sci_get_selection_end(documents[idx]->sci); if (selection_end == selection_start) { /* no selection so just find the next match */ @@ -1672,9 +1674,9 @@ /* there's a selection so go to the start before finding to search through it * this ensures there is a match */ if (search_backwards) - sci_goto_pos(doc_list[idx].sci, selection_end, TRUE); + sci_goto_pos(documents[idx]->sci, selection_end, TRUE); else - sci_goto_pos(doc_list[idx].sci, selection_start, TRUE); + sci_goto_pos(documents[idx]->sci, selection_start, TRUE);
search_pos = document_find_text(idx, find_text, flags, search_backwards, TRUE, NULL); /* return if the original selected text did not match (at the start of the selection) */ @@ -1684,11 +1686,11 @@ { gint replace_len; /* search next/prev will select matching text, which we use to set the replace target */ - sci_target_from_selection(doc_list[idx].sci); - replace_len = sci_target_replace(doc_list[idx].sci, replace_text, flags & SCFIND_REGEXP); + sci_target_from_selection(documents[idx]->sci); + replace_len = sci_target_replace(documents[idx]->sci, replace_text, flags & SCFIND_REGEXP); /* select the replacement - find text will skip past the selected text */ - sci_set_selection_start(doc_list[idx].sci, search_pos); - sci_set_selection_end(doc_list[idx].sci, search_pos + replace_len); + sci_set_selection_start(documents[idx]->sci, search_pos); + sci_set_selection_end(documents[idx]->sci, search_pos + replace_len); } else { @@ -1751,9 +1753,9 @@ if (new_range_end != NULL) *new_range_end = -1; g_return_val_if_fail(find_text != NULL && replace_text != NULL, 0); - if (idx == -1 || ! *find_text || doc_list[idx].readonly) return 0; + if (idx == -1 || ! *find_text || documents[idx]->readonly) return 0;
- sci = doc_list[idx].sci; + sci = documents[idx]->sci;
sci_start_undo_action(sci); ttf.chrg.cpMin = start; @@ -1827,8 +1829,8 @@ g_return_if_fail(find_text != NULL && replace_text != NULL); if (idx == -1 || ! *find_text) return;
- selection_start = sci_get_selection_start(doc_list[idx].sci); - selection_end = sci_get_selection_end(doc_list[idx].sci); + selection_start = sci_get_selection_start(documents[idx]->sci); + selection_end = sci_get_selection_end(documents[idx]->sci); /* do we have a selection? */ if ((selection_end - selection_start) == 0) { @@ -1836,24 +1838,24 @@ return; }
- selection_mode = sci_get_selection_mode(doc_list[idx].sci); - selected_lines = sci_get_lines_selected(doc_list[idx].sci); + selection_mode = sci_get_selection_mode(documents[idx]->sci); + selected_lines = sci_get_lines_selected(documents[idx]->sci); /* handle rectangle, multi line selections (it doesn't matter on a single line) */ if (selection_mode == SC_SEL_RECTANGLE && selected_lines > 1) { gint first_line, line;
- sci_start_undo_action(doc_list[idx].sci); + sci_start_undo_action(documents[idx]->sci);
- first_line = sci_get_line_from_position(doc_list[idx].sci, selection_start); + first_line = sci_get_line_from_position(documents[idx]->sci, selection_start); /* Find the last line with chars selected (not EOL char) */ - last_line = sci_get_line_from_position(doc_list[idx].sci, + last_line = sci_get_line_from_position(documents[idx]->sci, selection_end - editor_get_eol_char_len(idx)); last_line = MAX(first_line, last_line); for (line = first_line; line < (first_line + selected_lines); line++) { - gint line_start = sci_get_pos_at_line_sel_start(doc_list[idx].sci, line); - gint line_end = sci_get_pos_at_line_sel_end(doc_list[idx].sci, line); + gint line_start = sci_get_pos_at_line_sel_start(documents[idx]->sci, line); + gint line_end = sci_get_pos_at_line_sel_end(documents[idx]->sci, line);
/* skip line if there is no selection */ if (line_start != INVALID_POSITION) @@ -1868,11 +1870,11 @@ replaced = TRUE; /* this gets the greatest column within the selection after replacing */ max_column = MAX(max_column, - new_sel_end - sci_get_position_from_line(doc_list[idx].sci, line)); + new_sel_end - sci_get_position_from_line(documents[idx]->sci, line)); } } } - sci_end_undo_action(doc_list[idx].sci); + sci_end_undo_action(documents[idx]->sci); } else /* handle normal line selection */ { @@ -1888,26 +1890,26 @@ if (selection_mode == SC_SEL_RECTANGLE && selected_lines > 1) { /* now we can scroll to the selection and destroy it because we rebuild it later */ - /*sci_goto_pos(doc_list[idx].sci, selection_start, FALSE);*/ + /*sci_goto_pos(documents[idx]->sci, selection_start, FALSE);*/
/* Note: the selection will be wrapped to last_line + 1 if max_column is greater than * the highest column on the last line. The wrapped selection is completely different * from the original one, so skip the selection at all */ /* TODO is there a better way to handle the wrapped selection? */ - if ((sci_get_line_length(doc_list[idx].sci, last_line) - 1) >= max_column) + if ((sci_get_line_length(documents[idx]->sci, last_line) - 1) >= max_column) { /* for keeping and adjusting the selection in multi line rectangle selection we * need the last line of the original selection and the greatest column number after * replacing and set the selection end to the last line at the greatest column */ - sci_set_selection_start(doc_list[idx].sci, selection_start); - sci_set_selection_end(doc_list[idx].sci, - sci_get_position_from_line(doc_list[idx].sci, last_line) + max_column); - sci_set_selection_mode(doc_list[idx].sci, selection_mode); + sci_set_selection_start(documents[idx]->sci, selection_start); + sci_set_selection_end(documents[idx]->sci, + sci_get_position_from_line(documents[idx]->sci, last_line) + max_column); + sci_set_selection_mode(documents[idx]->sci, selection_mode); } } else { - sci_set_selection_start(doc_list[idx].sci, selection_start); - sci_set_selection_end(doc_list[idx].sci, selection_end); + sci_set_selection_start(documents[idx]->sci, selection_start); + sci_set_selection_end(documents[idx]->sci, selection_end); } } else /* no replacements */ @@ -1925,7 +1927,7 @@ g_return_val_if_fail(find_text != NULL && replace_text != NULL, FALSE); if (idx == -1 || ! *find_text) return FALSE;
- len = sci_get_length(doc_list[idx].sci); + len = sci_get_length(documents[idx]->sci); count = document_replace_range( idx, find_text, replace_text, flags, 0, len, TRUE, NULL);
@@ -1942,41 +1944,41 @@ gboolean success = FALSE;
/* if the filetype doesn't have a tag parser or it is a new file */ - if (idx == -1 || doc_list[idx].file_type == NULL || + if (idx == -1 || documents[idx]->file_type == NULL || app->tm_workspace == NULL || - ! filetype_has_tags(doc_list[idx].file_type) || ! doc_list[idx].file_name) + ! filetype_has_tags(documents[idx]->file_type) || ! documents[idx]->file_name) { /* set the default (empty) tag list */ treeviews_update_tag_list(idx, FALSE); return; }
- if (doc_list[idx].tm_file == NULL) + if (documents[idx]->tm_file == NULL) { - 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);
- doc_list[idx].tm_file = tm_source_file_new( - locale_filename, FALSE, doc_list[idx].file_type->name); + documents[idx]->tm_file = tm_source_file_new( + locale_filename, FALSE, documents[idx]->file_type->name); g_free(locale_filename);
- if (doc_list[idx].tm_file) + if (documents[idx]->tm_file) { - if (!tm_workspace_add_object(doc_list[idx].tm_file)) + if (!tm_workspace_add_object(documents[idx]->tm_file)) { - tm_work_object_free(doc_list[idx].tm_file); - doc_list[idx].tm_file = NULL; + tm_work_object_free(documents[idx]->tm_file); + documents[idx]->tm_file = NULL; } else { if (update) - tm_source_file_update(doc_list[idx].tm_file, TRUE, FALSE, TRUE); + tm_source_file_update(documents[idx]->tm_file, TRUE, FALSE, TRUE); success = TRUE; } } } else { - success = tm_source_file_update(doc_list[idx].tm_file, TRUE, FALSE, TRUE); + success = tm_source_file_update(documents[idx]->tm_file, TRUE, FALSE, TRUE); if (! success) geany_debug("tag list updating failed"); } @@ -2049,9 +2051,9 @@ } g_return_val_if_fail(s != NULL, FALSE);
- for (n = 0; n < doc_array->len; n++) + for (n = 0; n < documents_array->len; n++) { - ScintillaObject *wid = doc_list[n].sci; + ScintillaObject *wid = documents[n]->sci;
if (wid) { @@ -2082,22 +2084,22 @@ return;
geany_debug("%s : %s (%s)", - (doc_list[idx].file_name != NULL) ? doc_list[idx].file_name : "unknown", + (documents[idx]->file_name != NULL) ? documents[idx]->file_name : "unknown", (type->name != NULL) ? type->name : "unknown", - (doc_list[idx].encoding != NULL) ? doc_list[idx].encoding : "unknown"); + (documents[idx]->encoding != NULL) ? documents[idx]->encoding : "unknown");
- ft_changed = (doc_list[idx].file_type != type); + ft_changed = (documents[idx]->file_type != type); if (ft_changed) /* filetype has changed */ { - doc_list[idx].file_type = type; + documents[idx]->file_type = type;
/* delete tm file object to force creation of a new one */ - if (doc_list[idx].tm_file != NULL) + if (documents[idx]->tm_file != NULL) { - tm_workspace_remove_object(doc_list[idx].tm_file, TRUE, TRUE); - doc_list[idx].tm_file = NULL; + tm_workspace_remove_object(documents[idx]->tm_file, TRUE, TRUE); + documents[idx]->tm_file = NULL; } - highlighting_set_styles(doc_list[idx].sci, type->id); + highlighting_set_styles(documents[idx]->sci, type->id); build_menu_update(idx); colourise = TRUE; } @@ -2107,8 +2109,8 @@ { /* Check if project typename keywords have changed. * If they haven't, we may need to colourise the document. */ - if (! update_type_keywords(doc_list[idx].sci, type->lang) && colourise) - sci_colourise(doc_list[idx].sci, 0, -1); + if (! update_type_keywords(documents[idx]->sci, type->lang) && colourise) + sci_colourise(documents[idx]->sci, 0, -1); } if (ft_changed) { @@ -2129,14 +2131,14 @@ void document_set_encoding(gint idx, const gchar *new_encoding) { if (! DOC_IDX_VALID(idx) || new_encoding == NULL || - utils_str_equal(new_encoding, doc_list[idx].encoding)) return; + utils_str_equal(new_encoding, documents[idx]->encoding)) return;
- g_free(doc_list[idx].encoding); - doc_list[idx].encoding = g_strdup(new_encoding); + g_free(documents[idx]->encoding); + documents[idx]->encoding = g_strdup(new_encoding);
ui_update_statusbar(idx, -1); gtk_widget_set_sensitive(lookup_widget(main_widgets.window, "menu_write_unicode_bom1"), - encodings_is_unicode_charset(doc_list[idx].encoding)); + encodings_is_unicode_charset(documents[idx]->encoding)); }
@@ -2149,9 +2151,9 @@ { undo_action *a;
- while (g_trash_stack_height(&doc_list[idx].undo_actions) > 0) + while (g_trash_stack_height(&documents[idx]->undo_actions) > 0) { - a = g_trash_stack_pop(&doc_list[idx].undo_actions); + a = g_trash_stack_pop(&documents[idx]->undo_actions); if (a != NULL) { switch (a->type) @@ -2163,11 +2165,11 @@ g_free(a); } } - doc_list[idx].undo_actions = NULL; + documents[idx]->undo_actions = NULL;
- while (g_trash_stack_height(&doc_list[idx].redo_actions) > 0) + while (g_trash_stack_height(&documents[idx]->redo_actions) > 0) { - a = g_trash_stack_pop(&doc_list[idx].redo_actions); + a = g_trash_stack_pop(&documents[idx]->redo_actions); if (a != NULL) { switch (a->type) @@ -2179,13 +2181,13 @@ g_free(a); } } - doc_list[idx].redo_actions = NULL; + documents[idx]->redo_actions = NULL;
- doc_list[idx].changed = FALSE; + documents[idx]->changed = FALSE; if (! main_status.quitting) document_set_text_changed(idx);
/*geany_debug("%s: new undo stack height: %d, new redo stack height: %d", __func__, - *g_trash_stack_height(&doc_list[idx].undo_actions), g_trash_stack_height(&doc_list[idx].redo_actions)); */ + *g_trash_stack_height(&documents[idx]->undo_actions), g_trash_stack_height(&documents[idx]->redo_actions)); */ }
@@ -2199,14 +2201,14 @@ action->type = type; action->data = data;
- g_trash_stack_push(&doc_list[idx].undo_actions, action); + g_trash_stack_push(&documents[idx]->undo_actions, action);
- doc_list[idx].changed = TRUE; + documents[idx]->changed = TRUE; document_set_text_changed(idx); ui_update_popup_reundo_items(idx);
/*geany_debug("%s: new stack height: %d, added type: %d", __func__, - *g_trash_stack_height(&doc_list[idx].undo_actions), action->type); */ + *g_trash_stack_height(&documents[idx]->undo_actions), action->type); */ }
@@ -2214,7 +2216,7 @@ { if (! DOC_IDX_VALID(idx)) return FALSE;
- if (g_trash_stack_height(&doc_list[idx].undo_actions) > 0 || sci_can_undo(doc_list[idx].sci)) + if (g_trash_stack_height(&documents[idx]->undo_actions) > 0 || sci_can_undo(documents[idx]->sci)) return TRUE; else return FALSE; @@ -2223,10 +2225,10 @@
static void update_changed_state(gint idx) { - doc_list[idx].changed = - (sci_is_modified(doc_list[idx].sci) || - doc_list[idx].has_bom != doc_list[idx].saved_encoding.has_bom || - ! utils_str_equal(doc_list[idx].encoding, doc_list[idx].saved_encoding.encoding)); + documents[idx]->changed = + (sci_is_modified(documents[idx]->sci) || + documents[idx]->has_bom != documents[idx]->saved_encoding.has_bom || + ! utils_str_equal(documents[idx]->encoding, documents[idx]->saved_encoding.encoding)); document_set_text_changed(idx); }
@@ -2237,13 +2239,13 @@
if (! DOC_IDX_VALID(idx)) return;
- action = g_trash_stack_pop(&doc_list[idx].undo_actions); + action = g_trash_stack_pop(&documents[idx]->undo_actions);
if (action == NULL) { /* fallback, should not be necessary */ geany_debug("%s: fallback used", __func__); - sci_undo(doc_list[idx].sci); + sci_undo(documents[idx]->sci); } else { @@ -2253,14 +2255,14 @@ { document_redo_add(idx, UNDO_SCINTILLA, NULL);
- sci_undo(doc_list[idx].sci); + sci_undo(documents[idx]->sci); break; } case UNDO_BOM: { - document_redo_add(idx, UNDO_BOM, GINT_TO_POINTER(doc_list[idx].has_bom)); + document_redo_add(idx, UNDO_BOM, GINT_TO_POINTER(documents[idx]->has_bom));
- doc_list[idx].has_bom = GPOINTER_TO_INT(action->data); + documents[idx]->has_bom = GPOINTER_TO_INT(action->data); ui_update_statusbar(idx, -1); ui_document_show_hide(idx); break; @@ -2268,7 +2270,7 @@ case UNDO_ENCODING: { /* use the "old" encoding */ - document_redo_add(idx, UNDO_ENCODING, g_strdup(doc_list[idx].encoding)); + document_redo_add(idx, UNDO_ENCODING, g_strdup(documents[idx]->encoding));
document_set_encoding(idx, (const gchar*)action->data);
@@ -2286,7 +2288,7 @@
update_changed_state(idx); ui_update_popup_reundo_items(idx); - /*geany_debug("%s: new stack height: %d", __func__, g_trash_stack_height(&doc_list[idx].undo_actions));*/ + /*geany_debug("%s: new stack height: %d", __func__, g_trash_stack_height(&documents[idx]->undo_actions));*/ }
@@ -2294,7 +2296,7 @@ { if (! DOC_IDX_VALID(idx)) return FALSE;
- if (g_trash_stack_height(&doc_list[idx].redo_actions) > 0 || sci_can_redo(doc_list[idx].sci)) + if (g_trash_stack_height(&documents[idx]->redo_actions) > 0 || sci_can_redo(documents[idx]->sci)) return TRUE; else return FALSE; @@ -2307,13 +2309,13 @@
if (! DOC_IDX_VALID(idx)) return;
- action = g_trash_stack_pop(&doc_list[idx].redo_actions); + action = g_trash_stack_pop(&documents[idx]->redo_actions);
if (action == NULL) { /* fallback, should not be necessary */ geany_debug("%s: fallback used", __func__); - sci_redo(doc_list[idx].sci); + sci_redo(documents[idx]->sci); } else { @@ -2323,21 +2325,21 @@ { document_undo_add(idx, UNDO_SCINTILLA, NULL);
- sci_redo(doc_list[idx].sci); + sci_redo(documents[idx]->sci); break; } case UNDO_BOM: { - 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 = GPOINTER_TO_INT(action->data); + documents[idx]->has_bom = GPOINTER_TO_INT(action->data); ui_update_statusbar(idx, -1); ui_document_show_hide(idx); break; } case UNDO_ENCODING: { - 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, (const gchar*)action->data);
@@ -2355,7 +2357,7 @@
update_changed_state(idx); ui_update_popup_reundo_items(idx); - /*geany_debug("%s: new stack height: %d", __func__, g_trash_stack_height(&doc_list[idx].redo_actions));*/ + /*geany_debug("%s: new stack height: %d", __func__, g_trash_stack_height(&documents[idx]->redo_actions));*/ }
@@ -2369,14 +2371,14 @@ action->type = type; action->data = data;
- g_trash_stack_push(&doc_list[idx].redo_actions, action); + g_trash_stack_push(&documents[idx]->redo_actions, action);
- doc_list[idx].changed = TRUE; + documents[idx]->changed = TRUE; document_set_text_changed(idx); ui_update_popup_reundo_items(idx);
/*geany_debug("%s: new stack height: %d, added type: %d", __func__, - *g_trash_stack_height(&doc_list[idx].redo_actions), action->type); */ + *g_trash_stack_height(&documents[idx]->redo_actions), action->type); */ }
@@ -2388,9 +2390,9 @@ static GdkColor green = {0, 0, 0x7FFF, 0}; GdkColor *color = NULL;
- if (doc_list[idx].changed) + if (documents[idx]->changed) color = &red; - else if (doc_list[idx].readonly) + else if (documents[idx]->readonly) color = &green;
return color; /* return pointer to static GdkColor. */ @@ -2401,7 +2403,7 @@ #ifdef GEANY_DEBUG GeanyDocument *doc(gint idx) { - return DOC_IDX_VALID(idx) ? &doc_list[idx] : NULL; + return DOC_IDX_VALID(idx) ? documents[idx] : NULL; } #endif
@@ -2419,7 +2421,7 @@
/* make an array containing all the current document indexes */ doc_indexes = g_array_new(FALSE, FALSE, sizeof(gint)); - for (n = 0; n < (gint) doc_array->len; n++) + for (n = 0; n < (gint) documents_array->len; n++) { if (DOC_IDX_VALID(n)) g_array_append_val(doc_indexes, n); @@ -2436,14 +2438,14 @@ guint n, i; /* A bitset representing which docs need [re]colourising. * (use gint8 to save memory because gboolean = gint) */ - gint8 *doc_set = g_newa(gint8, doc_array->len); + gint8 *doc_set = g_newa(gint8, documents_array->len); gboolean recolour = FALSE; /* whether to recolourise existing typenames */
g_return_if_fail(delay_colourise == TRUE); g_return_if_fail(doc_indexes != NULL);
/* first assume recolourising all docs */ - memset(doc_set, TRUE, doc_array->len * sizeof(gint8)); + memset(doc_set, TRUE, documents_array->len * sizeof(gint8));
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.