2005-11-22 12:26:26 +00:00
|
|
|
/*
|
|
|
|
* document.c - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2006-01-11 18:38:17 +00:00
|
|
|
* Copyright 2006 Enrico Troeger <enrico.troeger@uvena.de>
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-05-10 19:54:44 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
2005-12-01 22:59:02 +00:00
|
|
|
* $Id$
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
|
|
|
|
2005-12-29 20:01:18 +00:00
|
|
|
#include "geany.h"
|
|
|
|
|
|
|
|
#ifdef TIME_WITH_SYS_TIME
|
|
|
|
# include <time.h>
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
# include <fcntl.h>
|
|
|
|
#endif
|
2006-06-13 19:37:21 +00:00
|
|
|
#include <ctype.h>
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
#include "document.h"
|
|
|
|
#include "callbacks.h"
|
2005-12-29 20:01:18 +00:00
|
|
|
#include "support.h"
|
|
|
|
#include "sciwrappers.h"
|
|
|
|
#include "sci_cb.h"
|
|
|
|
#include "dialogs.h"
|
|
|
|
#include "msgwindow.h"
|
|
|
|
#include "callbacks.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
#include "templates.h"
|
|
|
|
#include "treeviews.h"
|
2005-12-29 20:01:18 +00:00
|
|
|
#include "utils.h"
|
2006-06-21 18:54:07 +00:00
|
|
|
#include "encodings.h"
|
2006-06-25 12:13:35 +00:00
|
|
|
#include "notebook.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-07 21:24:15 +00:00
|
|
|
/* returns the index of the notebook page which has the given filename
|
|
|
|
* is_tm_filename is needed when passing TagManager filenames because they are
|
|
|
|
* dereferenced, and would not match the link filename. */
|
|
|
|
gint document_find_by_filename(const gchar *filename, gboolean is_tm_filename)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
if (! filename) return -1;
|
|
|
|
|
|
|
|
for(i = 0; i < GEANY_MAX_OPEN_FILES; i++)
|
|
|
|
{
|
2006-06-11 14:08:10 +00:00
|
|
|
gchar *dl_fname = (is_tm_filename && doc_list[i].tm_file) ?
|
|
|
|
doc_list[i].tm_file->file_name : doc_list[i].file_name;
|
2005-11-22 12:26:26 +00:00
|
|
|
#ifdef GEANY_WIN32
|
|
|
|
// ignore the case of filenames and paths under WIN32, causes errors if not
|
2006-06-07 21:24:15 +00:00
|
|
|
if (dl_fname && ! strcasecmp(dl_fname, filename)) return i;
|
2005-11-22 12:26:26 +00:00
|
|
|
#else
|
2006-06-07 21:24:15 +00:00
|
|
|
if (dl_fname && utils_strcmp(dl_fname, filename)) return i;
|
2005-11-22 12:26:26 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* returns the index of the notebook page which has sci */
|
|
|
|
gint document_find_by_sci(ScintillaObject *sci)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
if (! sci) return -1;
|
|
|
|
|
|
|
|
for(i = 0; i < GEANY_MAX_OPEN_FILES; i++)
|
|
|
|
{
|
2006-01-14 22:40:05 +00:00
|
|
|
if (doc_list[i].is_valid && doc_list[i].sci == sci) return i;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* returns the index of the given notebook page in the document list */
|
2006-01-11 18:38:17 +00:00
|
|
|
gint document_get_n_idx(guint page_num)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-05-08 01:57:25 +00:00
|
|
|
ScintillaObject *sci;
|
2006-04-27 18:06:35 +00:00
|
|
|
if (page_num >= GEANY_MAX_OPEN_FILES) return -1;
|
2006-01-11 18:38:17 +00:00
|
|
|
|
2006-05-08 01:57:25 +00:00
|
|
|
sci = (ScintillaObject*)gtk_notebook_get_nth_page(
|
2006-01-11 18:38:17 +00:00
|
|
|
GTK_NOTEBOOK(app->notebook), page_num);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
return document_find_by_sci(sci);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* returns the index of the current notebook page in the document list */
|
|
|
|
gint document_get_cur_idx(void)
|
|
|
|
{
|
|
|
|
gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(app->notebook));
|
|
|
|
ScintillaObject *sci = (ScintillaObject*)gtk_notebook_get_nth_page(GTK_NOTEBOOK(app->notebook), cur_page);
|
|
|
|
|
|
|
|
if (cur_page == -1)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return document_find_by_sci(sci);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* returns the next free place(i.e. index) in the document list
|
|
|
|
* If there is for any reason no free place, -1 is returned
|
|
|
|
*/
|
|
|
|
gint document_get_new_idx(void)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for(i = 0; i < GEANY_MAX_OPEN_FILES; i++)
|
|
|
|
{
|
|
|
|
if (doc_list[i].sci == NULL)
|
|
|
|
{
|
|
|
|
return (gint) i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* changes the color of the tab text according to the status */
|
|
|
|
void document_change_tab_color(gint index)
|
|
|
|
{
|
|
|
|
if (index >= 0 && doc_list[index].sci)
|
|
|
|
{
|
|
|
|
GdkColor colorred = {0, 65535, 0, 0};
|
|
|
|
GdkColor colorblack = {0, 0, 0, 0};
|
|
|
|
|
|
|
|
gtk_widget_modify_fg(doc_list[index].tab_label, GTK_STATE_NORMAL,
|
|
|
|
(doc_list[index].changed) ? &colorred : &colorblack);
|
|
|
|
gtk_widget_modify_fg(doc_list[index].tab_label, GTK_STATE_ACTIVE,
|
|
|
|
(doc_list[index].changed) ? &colorred : &colorblack);
|
|
|
|
gtk_widget_modify_fg(doc_list[index].tabmenu_label, GTK_STATE_PRELIGHT,
|
|
|
|
(doc_list[index].changed) ? &colorred : &colorblack);
|
|
|
|
gtk_widget_modify_fg(doc_list[index].tabmenu_label, GTK_STATE_NORMAL,
|
|
|
|
(doc_list[index].changed) ? &colorred : &colorblack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void document_set_text_changed(gint index)
|
|
|
|
{
|
|
|
|
document_change_tab_color(index);
|
|
|
|
utils_save_buttons_toggle(doc_list[index].changed);
|
|
|
|
utils_set_window_title(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-11 18:38:17 +00:00
|
|
|
/* sets in all document structs the flag is_valid to FALSE and initializes some members to NULL,
|
|
|
|
* to mark it uninitialized. The flag is_valid is set to TRUE in document_create_new_sci(). */
|
|
|
|
void document_init_doclist(void)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < GEANY_MAX_OPEN_FILES; i++)
|
|
|
|
{
|
|
|
|
doc_list[i].is_valid = FALSE;
|
2006-01-14 22:40:05 +00:00
|
|
|
doc_list[i].has_tags = FALSE;
|
2006-02-14 22:07:55 +00:00
|
|
|
doc_list[i].use_auto_indention = TRUE;
|
|
|
|
doc_list[i].line_breaking = TRUE;
|
|
|
|
doc_list[i].readonly = FALSE;
|
2006-01-11 18:38:17 +00:00
|
|
|
doc_list[i].tag_store = NULL;
|
|
|
|
doc_list[i].tag_tree = NULL;
|
|
|
|
doc_list[i].file_name = NULL;
|
|
|
|
doc_list[i].file_type = NULL;
|
|
|
|
doc_list[i].tm_file = NULL;
|
|
|
|
doc_list[i].encoding = NULL;
|
|
|
|
doc_list[i].sci = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
/* creates a new tab in the notebook and does all related stuff
|
|
|
|
* finally it returns the index of the created document */
|
|
|
|
gint document_create_new_sci(const gchar *filename)
|
|
|
|
{
|
|
|
|
ScintillaObject *sci;
|
|
|
|
PangoFontDescription *pfd;
|
|
|
|
gchar *title, *fname;
|
|
|
|
GtkTreeIter iter;
|
2006-01-14 22:40:05 +00:00
|
|
|
gint new_idx = document_get_new_idx();
|
2006-06-13 19:37:21 +00:00
|
|
|
document *this = &(doc_list[new_idx]);
|
2006-06-25 12:13:35 +00:00
|
|
|
gint tabnum;
|
2006-05-09 22:02:22 +00:00
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
/* SCI - Code */
|
|
|
|
sci = SCINTILLA(scintilla_new());
|
2006-01-14 22:40:05 +00:00
|
|
|
scintilla_set_id(sci, new_idx);
|
2006-06-13 19:37:21 +00:00
|
|
|
this->sci = sci;
|
2006-05-09 22:02:22 +00:00
|
|
|
|
|
|
|
gtk_widget_show(GTK_WIDGET(sci));
|
|
|
|
|
2006-02-26 18:19:28 +00:00
|
|
|
#ifdef GEANY_WIN32
|
2006-04-27 18:06:35 +00:00
|
|
|
sci_set_codepage(sci, 0);
|
2006-02-26 18:19:28 +00:00
|
|
|
#else
|
2006-04-27 18:06:35 +00:00
|
|
|
sci_set_codepage(sci, SC_CP_UTF8);
|
2006-02-26 18:19:28 +00:00
|
|
|
#endif
|
2005-12-01 22:59:02 +00:00
|
|
|
//SSM(sci, SCI_SETWRAPSTARTINDENT, 4, 0);
|
2006-02-26 18:19:28 +00:00
|
|
|
// disable scintilla provided popup menu
|
2005-11-22 12:26:26 +00:00
|
|
|
sci_use_popup(sci, FALSE);
|
2006-02-10 20:56:17 +00:00
|
|
|
sci_assign_cmdkey(sci, SCK_HOME, SCI_VCHOMEWRAP);
|
2006-02-26 18:19:28 +00:00
|
|
|
sci_assign_cmdkey(sci, SCK_END, SCI_LINEENDWRAP);
|
2005-11-22 12:26:26 +00:00
|
|
|
sci_set_mark_long_lines(sci, app->long_line_column, app->long_line_color);
|
|
|
|
sci_set_symbol_margin(sci, app->show_markers_margin);
|
2006-02-26 18:19:28 +00:00
|
|
|
sci_set_folding_margin_visible(sci, app->pref_editor_folding);
|
2006-05-09 22:02:22 +00:00
|
|
|
sci_set_line_numbers(sci, app->show_linenumber_margin, 0);
|
2006-02-14 22:07:55 +00:00
|
|
|
sci_set_lines_wrapped(sci, app->pref_editor_line_breaking);
|
|
|
|
sci_set_indentionguides(sci, app->pref_editor_show_indent_guide);
|
|
|
|
sci_set_visible_white_spaces(sci, app->pref_editor_show_white_space);
|
|
|
|
sci_set_visible_eols(sci, app->pref_editor_show_line_endings);
|
2005-11-22 12:26:26 +00:00
|
|
|
pfd = pango_font_description_from_string(app->editor_font);
|
|
|
|
fname = g_strdup_printf("!%s", pango_font_description_get_family(pfd));
|
2006-06-13 19:37:21 +00:00
|
|
|
document_set_font(new_idx, fname, pango_font_description_get_size(pfd) / PANGO_SCALE);
|
2005-11-22 12:26:26 +00:00
|
|
|
pango_font_description_free(pfd);
|
|
|
|
g_free(fname);
|
|
|
|
|
2006-05-11 23:01:50 +00:00
|
|
|
// this is only for testing, should be tested seriously, could speed up scrolling
|
|
|
|
if (alternative_scrolling)
|
|
|
|
{
|
|
|
|
SSM(sci, SCI_SETBUFFEREDDRAW, 0, 0);
|
|
|
|
SSM(sci, SCI_SETTWOPHASEDRAW, 0, 0);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-06-25 12:13:35 +00:00
|
|
|
title = (filename) ? g_path_get_basename(filename) : g_strdup(GEANY_STRING_UNTITLED);
|
|
|
|
|
|
|
|
tabnum = notebook_new_tab(new_idx, title, GTK_WIDGET(sci));
|
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), tabnum);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
iter = treeviews_openfiles_add(new_idx, title);
|
|
|
|
g_free(title);
|
|
|
|
|
2006-06-13 19:37:21 +00:00
|
|
|
this->tag_store = NULL;
|
|
|
|
this->tag_tree = NULL;
|
2005-12-18 22:08:42 +00:00
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
// "the" SCI signal
|
2006-04-27 18:06:35 +00:00
|
|
|
g_signal_connect((GtkWidget*) sci, "sci-notify",
|
|
|
|
G_CALLBACK(on_editor_notification), GINT_TO_POINTER(new_idx));
|
2005-11-22 12:26:26 +00:00
|
|
|
// signal for insert-key(works without too, but to update the right status bar)
|
2006-05-19 17:18:06 +00:00
|
|
|
/* g_signal_connect((GtkWidget*) sci, "key-press-event",
|
|
|
|
G_CALLBACK(keybindings_got_event), GINT_TO_POINTER(new_idx));
|
|
|
|
*/ // signal for the popup menu
|
2006-04-27 18:06:35 +00:00
|
|
|
g_signal_connect((GtkWidget*) sci, "button-press-event",
|
|
|
|
G_CALLBACK(on_editor_button_press_event), GINT_TO_POINTER(new_idx));
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
utils_close_buttons_toggle();
|
|
|
|
|
|
|
|
// store important pointers in the tab list
|
2006-06-13 19:37:21 +00:00
|
|
|
this->file_name = (filename) ? g_strdup(filename) : NULL;
|
|
|
|
this->encoding = NULL;
|
|
|
|
this->tm_file = NULL;
|
|
|
|
this->iter = iter;
|
|
|
|
this->file_type = NULL;
|
|
|
|
this->mtime = 0;
|
|
|
|
this->changed = FALSE;
|
|
|
|
this->last_check = time(NULL);
|
|
|
|
this->do_overwrite = FALSE;
|
|
|
|
this->readonly = FALSE;
|
|
|
|
this->line_breaking = TRUE;
|
|
|
|
this->use_auto_indention = TRUE;
|
|
|
|
this->has_tags = FALSE;
|
|
|
|
this->is_valid = TRUE;
|
2005-12-18 22:08:42 +00:00
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
return new_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-14 22:40:05 +00:00
|
|
|
/* removes the given notebook tab and clears the related entry in the document list */
|
2006-01-11 18:38:17 +00:00
|
|
|
gboolean document_remove(guint page_num)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
gint idx = document_get_n_idx(page_num);
|
|
|
|
|
2006-01-11 18:38:17 +00:00
|
|
|
if (idx >= 0 && idx <= GEANY_MAX_OPEN_FILES)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
if (doc_list[idx].changed && ! dialogs_show_unsaved_file(idx))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
gtk_notebook_remove_page(GTK_NOTEBOOK(app->notebook), page_num);
|
|
|
|
treeviews_openfiles_remove(doc_list[idx].iter);
|
2005-12-18 22:08:42 +00:00
|
|
|
if (GTK_IS_WIDGET(doc_list[idx].tag_tree))
|
|
|
|
{
|
2006-01-14 22:40:05 +00:00
|
|
|
//g_object_unref(doc_list[idx].tag_tree); // no need to unref when destroying?
|
2005-12-18 22:08:42 +00:00
|
|
|
gtk_widget_destroy(doc_list[idx].tag_tree);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
msgwin_status_add(_("File %s closed."),
|
|
|
|
(doc_list[idx].file_name) ? doc_list[idx].file_name : GEANY_STRING_UNTITLED);
|
|
|
|
g_free(doc_list[idx].encoding);
|
|
|
|
g_free(doc_list[idx].file_name);
|
|
|
|
tm_workspace_remove_object(doc_list[idx].tm_file, TRUE);
|
2006-01-11 18:38:17 +00:00
|
|
|
doc_list[idx].is_valid = FALSE;
|
2005-11-22 12:26:26 +00:00
|
|
|
doc_list[idx].sci = NULL;
|
|
|
|
doc_list[idx].file_name = NULL;
|
|
|
|
doc_list[idx].file_type = NULL;
|
2006-04-27 18:06:35 +00:00
|
|
|
doc_list[idx].encoding = NULL;
|
2005-11-22 12:26:26 +00:00
|
|
|
doc_list[idx].tm_file = NULL;
|
|
|
|
if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0)
|
|
|
|
{
|
2005-12-18 22:08:42 +00:00
|
|
|
utils_update_tag_list(-1, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
//on_notebook1_switch_page(GTK_NOTEBOOK(app->notebook), NULL, 0, NULL);
|
|
|
|
utils_set_window_title(-1);
|
|
|
|
utils_save_buttons_toggle(FALSE);
|
|
|
|
utils_close_buttons_toggle();
|
2006-05-19 19:49:17 +00:00
|
|
|
utils_build_show_hide(-1);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-14 22:40:05 +00:00
|
|
|
else geany_debug("Error: idx: %d page_num: %d", idx, page_num);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* This creates a new document, by clearing the text widget and setting the
|
|
|
|
current filename to NULL. */
|
|
|
|
void document_new_file(filetype *ft)
|
|
|
|
{
|
|
|
|
if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) < GEANY_MAX_OPEN_FILES)
|
|
|
|
{
|
|
|
|
gint idx = document_create_new_sci(NULL);
|
|
|
|
gchar *template = document_prepare_template(ft);
|
|
|
|
|
|
|
|
sci_clear_all(doc_list[idx].sci);
|
|
|
|
sci_set_text(doc_list[idx].sci, template);
|
|
|
|
g_free(template);
|
|
|
|
|
2006-06-21 18:54:07 +00:00
|
|
|
doc_list[idx].encoding = g_strdup(
|
|
|
|
encodings_get_charset(&encodings[app->pref_editor_default_encoding]));
|
2006-06-05 15:10:40 +00:00
|
|
|
document_set_filetype(idx, ft);
|
2005-11-22 12:26:26 +00:00
|
|
|
utils_set_window_title(idx);
|
|
|
|
utils_build_show_hide(idx);
|
2005-12-21 19:43:48 +00:00
|
|
|
utils_update_tag_list(idx, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
doc_list[idx].mtime = time(NULL);
|
|
|
|
doc_list[idx].changed = FALSE;
|
|
|
|
document_set_text_changed(idx);
|
|
|
|
sci_set_eol_mode(doc_list[idx].sci, SC_EOL_LF);
|
2006-02-14 22:07:55 +00:00
|
|
|
sci_set_line_numbers(doc_list[idx].sci, app->show_linenumber_margin, 0);
|
2005-11-22 12:26:26 +00:00
|
|
|
sci_empty_undo_buffer(doc_list[idx].sci);
|
2006-02-26 18:19:28 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, 0, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
msgwin_status_add(_("New file opened."));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dialogs_show_file_open_error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* If idx is set to -1, it creates a new tab, opens the file from filename and
|
|
|
|
* set the cursor to pos.
|
|
|
|
* If idx is greater than -1, it reloads the file in the tab corresponding to
|
|
|
|
* idx and set the cursor to position 0. In this case, filename should be NULL
|
2006-06-11 22:39:11 +00:00
|
|
|
* It returns the idx of the opened file or -1 if an error occurred.
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
2006-06-11 22:39:11 +00:00
|
|
|
int document_open_file(gint idx, const gchar *filename, gint pos, gboolean readonly, filetype *ft)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-05-17 18:29:29 +00:00
|
|
|
gint editor_mode;
|
|
|
|
gsize size;
|
2005-11-22 12:26:26 +00:00
|
|
|
gboolean reload = (idx == -1) ? FALSE : TRUE;
|
|
|
|
struct stat st;
|
|
|
|
gchar *enc = NULL;
|
2006-01-23 17:05:29 +00:00
|
|
|
gchar *utf8_filename = NULL;
|
2006-02-06 06:26:53 +00:00
|
|
|
gchar *locale_filename = NULL;
|
2006-01-23 17:05:29 +00:00
|
|
|
GError *err = NULL;
|
2006-05-16 19:06:08 +00:00
|
|
|
gchar *data = NULL;
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
//struct timeval tv, tv1;
|
|
|
|
//struct timezone tz;
|
|
|
|
//gettimeofday(&tv, &tz);
|
|
|
|
|
|
|
|
if (reload)
|
|
|
|
{
|
2006-02-06 06:26:53 +00:00
|
|
|
utf8_filename = g_strdup(doc_list[idx].file_name);
|
|
|
|
locale_filename = g_locale_from_utf8(utf8_filename, -1, NULL, NULL, NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-27 18:06:35 +00:00
|
|
|
// filename must not be NULL when it is a new file
|
|
|
|
if (filename == NULL)
|
|
|
|
{
|
|
|
|
msgwin_status_add(_("Invalid filename"));
|
2006-06-11 22:39:11 +00:00
|
|
|
return -1;
|
2006-04-27 18:06:35 +00:00
|
|
|
}
|
2006-05-08 01:57:25 +00:00
|
|
|
|
2006-01-23 17:05:29 +00:00
|
|
|
// try to get the UTF-8 equivalent for the filename, fallback to filename if error
|
2006-02-06 06:26:53 +00:00
|
|
|
locale_filename = g_strdup(filename);
|
|
|
|
utf8_filename = g_locale_to_utf8(locale_filename, -1, NULL, NULL, &err);
|
2006-01-23 17:05:29 +00:00
|
|
|
if (utf8_filename == NULL)
|
|
|
|
{
|
2006-04-27 18:06:35 +00:00
|
|
|
if (err != NULL) msgwin_status_add("%s (%s)", _("Invalid filename"), err->message);
|
|
|
|
else msgwin_status_add(_("Invalid filename"));
|
2006-02-06 06:26:53 +00:00
|
|
|
utf8_filename = g_strdup(locale_filename);
|
2006-04-27 18:06:35 +00:00
|
|
|
g_error_free(err);
|
2006-01-23 17:05:29 +00:00
|
|
|
err = NULL; // set to NULL for further usage
|
|
|
|
}
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
// if file is already open, switch to it and go
|
2006-06-07 21:24:15 +00:00
|
|
|
idx = document_find_by_filename(utf8_filename, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
if (idx >= 0)
|
|
|
|
{
|
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook),
|
|
|
|
gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook),
|
|
|
|
(GtkWidget*) doc_list[idx].sci));
|
2006-06-11 22:39:11 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, pos, TRUE);
|
2006-02-06 06:26:53 +00:00
|
|
|
g_free(utf8_filename);
|
|
|
|
g_free(locale_filename);
|
2006-06-11 22:39:11 +00:00
|
|
|
return idx;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-06 06:26:53 +00:00
|
|
|
if (stat(locale_filename, &st) != 0)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-01-23 17:05:29 +00:00
|
|
|
msgwin_status_add(_("Could not open file %s (%s)"), utf8_filename, g_strerror(errno));
|
2006-02-06 06:26:53 +00:00
|
|
|
g_free(utf8_filename);
|
|
|
|
g_free(locale_filename);
|
2006-06-11 22:39:11 +00:00
|
|
|
return -1;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2006-05-16 19:06:08 +00:00
|
|
|
|
|
|
|
#ifdef GEANY_WIN32
|
|
|
|
if (! g_file_get_contents(utf8_filename, &data, &size, &err))
|
2005-12-29 20:01:18 +00:00
|
|
|
#else
|
2006-05-16 19:06:08 +00:00
|
|
|
if (! g_file_get_contents(locale_filename, &data, &size, &err))
|
|
|
|
#endif
|
2006-02-20 22:57:59 +00:00
|
|
|
{
|
2006-05-16 19:06:08 +00:00
|
|
|
//msgwin_status_add(_("Could not open file %s (%s)"), utf8_filename, g_strerror(err->code));
|
|
|
|
msgwin_status_add(err->message);
|
2006-04-27 18:06:35 +00:00
|
|
|
g_error_free(err);
|
2006-02-06 06:26:53 +00:00
|
|
|
g_free(utf8_filename);
|
|
|
|
g_free(locale_filename);
|
2006-06-11 22:39:11 +00:00
|
|
|
return -1;
|
2005-12-29 20:01:18 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
/* Determine character encoding and convert to utf-8*/
|
|
|
|
if (size > 0)
|
|
|
|
{
|
2006-05-16 19:06:08 +00:00
|
|
|
if (g_utf8_validate(data, size, NULL))
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
enc = g_strdup("UTF-8");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-16 19:06:08 +00:00
|
|
|
gchar *converted_text = utils_convert_to_utf8(data, size, &enc);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
if (converted_text == NULL)
|
|
|
|
{
|
|
|
|
msgwin_status_add(_("The file does not look like a text file or the file encoding is not supported."));
|
2006-02-06 06:26:53 +00:00
|
|
|
utils_beep();
|
2006-05-16 19:06:08 +00:00
|
|
|
g_free(data);
|
2006-02-06 06:26:53 +00:00
|
|
|
g_free(utf8_filename);
|
|
|
|
g_free(locale_filename);
|
2006-06-11 22:39:11 +00:00
|
|
|
return -1;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-16 19:06:08 +00:00
|
|
|
g_free(data);
|
|
|
|
data = (void*)converted_text;
|
2005-11-22 12:26:26 +00:00
|
|
|
size = strlen(converted_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-05-08 01:57:25 +00:00
|
|
|
else
|
2006-04-27 18:06:35 +00:00
|
|
|
{
|
|
|
|
enc = g_strdup("UTF-8");
|
|
|
|
}
|
2006-05-08 01:57:25 +00:00
|
|
|
|
2006-01-23 17:05:29 +00:00
|
|
|
if (! reload) idx = document_create_new_sci(utf8_filename);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-05-25 12:57:12 +00:00
|
|
|
// set editor mode and add the text to the ScintillaObject
|
|
|
|
sci_set_text(doc_list[idx].sci, data); // NULL terminated data; avoids Unsaved
|
2006-05-16 19:06:08 +00:00
|
|
|
editor_mode = utils_get_line_endings(data, size);
|
2005-11-22 12:26:26 +00:00
|
|
|
sci_set_eol_mode(doc_list[idx].sci, editor_mode);
|
|
|
|
|
2006-02-14 22:07:55 +00:00
|
|
|
sci_set_line_numbers(doc_list[idx].sci, app->show_linenumber_margin, 0);
|
2005-11-22 12:26:26 +00:00
|
|
|
sci_set_savepoint(doc_list[idx].sci);
|
|
|
|
sci_empty_undo_buffer(doc_list[idx].sci);
|
2006-03-10 00:52:09 +00:00
|
|
|
// get the modification time from file and keep it
|
|
|
|
doc_list[idx].mtime = st.st_mtime;
|
2005-11-22 12:26:26 +00:00
|
|
|
doc_list[idx].changed = FALSE;
|
2006-01-23 17:05:29 +00:00
|
|
|
doc_list[idx].file_name = g_strdup(utf8_filename);
|
2005-11-22 12:26:26 +00:00
|
|
|
doc_list[idx].encoding = enc;
|
2006-06-20 11:55:34 +00:00
|
|
|
|
|
|
|
sci_goto_pos(doc_list[idx].sci, pos, TRUE);
|
|
|
|
|
2006-06-20 14:54:09 +00:00
|
|
|
if (! reload)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-02-10 20:56:17 +00:00
|
|
|
filetype *use_ft = (ft != NULL) ? ft : filetypes_get_from_filename(utf8_filename);
|
2006-05-08 01:57:25 +00:00
|
|
|
|
2006-04-28 15:06:39 +00:00
|
|
|
if (readonly) gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
|
|
|
|
lookup_widget(app->window, "set_file_readonly1")), TRUE);
|
|
|
|
/* This is so ugly, but the checkbox in the file menu can be still checked from a previous
|
|
|
|
* read only file, a won't be checked out since notebook-switch-signal is ignored
|
|
|
|
* so we need to check it out by hand and this emits the toggled-signal and therefore
|
|
|
|
* we must set the file to read only and the toggle-callback will set it again to not
|
|
|
|
* read only. It's ugly. Any ideas are welcome. */
|
|
|
|
else if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(
|
|
|
|
lookup_widget(app->window, "set_file_readonly1"))))
|
|
|
|
{
|
|
|
|
doc_list[idx].readonly = TRUE;
|
|
|
|
sci_set_readonly(doc_list[idx].sci, TRUE);
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
|
|
|
|
lookup_widget(app->window, "set_file_readonly1")), FALSE);
|
|
|
|
}
|
2006-05-08 01:57:25 +00:00
|
|
|
|
2006-02-10 20:56:17 +00:00
|
|
|
document_set_filetype(idx, use_ft);
|
2005-11-22 12:26:26 +00:00
|
|
|
utils_build_show_hide(idx);
|
2006-06-20 14:54:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// update sci to send SCN_UPDATEUI before we set status messages
|
|
|
|
while (gtk_events_pending())
|
|
|
|
gtk_main_iteration();
|
|
|
|
if (reload)
|
|
|
|
msgwin_status_add(_("File %s reloaded."), utf8_filename);
|
|
|
|
else
|
2005-11-22 12:26:26 +00:00
|
|
|
msgwin_status_add(_("File %s opened(%d%s)."),
|
2006-01-23 17:05:29 +00:00
|
|
|
utf8_filename, gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)),
|
2005-11-22 12:26:26 +00:00
|
|
|
(readonly) ? _(", read-only") : "");
|
2006-06-20 14:54:09 +00:00
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
document_set_text_changed(idx);
|
|
|
|
|
2006-05-16 19:06:08 +00:00
|
|
|
g_free(data);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2005-12-21 19:43:48 +00:00
|
|
|
// finally add current file to recent files menu, but not the files from the last session
|
|
|
|
if (! app->opening_session_files &&
|
2006-01-23 17:05:29 +00:00
|
|
|
g_queue_find_custom(app->recent_queue, utf8_filename, (GCompareFunc) strcmp) == NULL)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-01-23 17:05:29 +00:00
|
|
|
g_queue_push_head(app->recent_queue, g_strdup(utf8_filename));
|
2005-12-12 02:23:51 +00:00
|
|
|
if (g_queue_get_length(app->recent_queue) > app->mru_length)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
g_free(g_queue_pop_tail(app->recent_queue));
|
|
|
|
}
|
|
|
|
utils_update_recent_menu();
|
|
|
|
}
|
2006-01-23 17:05:29 +00:00
|
|
|
|
|
|
|
g_free(utf8_filename);
|
2006-02-06 06:26:53 +00:00
|
|
|
g_free(locale_filename);
|
2005-11-22 12:26:26 +00:00
|
|
|
//gettimeofday(&tv1, &tz);
|
|
|
|
//geany_debug("%s: %d", filename, (gint)(tv1.tv_usec - tv.tv_usec));
|
2006-06-11 22:39:11 +00:00
|
|
|
|
|
|
|
return idx;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-20 11:55:34 +00:00
|
|
|
int document_reload_file(gint idx)
|
|
|
|
{
|
|
|
|
gint pos = 0;
|
|
|
|
if (idx < 0 || ! doc_list[idx].is_valid)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
// try to set the cursor to the position before reloading
|
|
|
|
pos = sci_get_current_position(doc_list[idx].sci);
|
|
|
|
return document_open_file(idx, NULL, pos, doc_list[idx].readonly,
|
|
|
|
doc_list[idx].file_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
/* This saves the file */
|
|
|
|
void document_save_file(gint idx)
|
|
|
|
{
|
|
|
|
gchar *data;
|
|
|
|
FILE *fp;
|
|
|
|
gint bytes_written, len;
|
2006-02-10 20:56:17 +00:00
|
|
|
gchar *locale_filename = NULL;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
if (idx == -1) return;
|
|
|
|
|
|
|
|
if (doc_list[idx].file_name == NULL)
|
|
|
|
{
|
|
|
|
msgwin_status_add(_("Error saving file."));
|
2006-02-10 20:56:17 +00:00
|
|
|
utils_beep();
|
2005-11-22 12:26:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-06-21 18:54:07 +00:00
|
|
|
// replaces tabs by spaces
|
|
|
|
if (app->pref_editor_replace_tabs) utils_replace_tabs(idx);
|
2005-11-22 12:26:26 +00:00
|
|
|
// strip trailing spaces
|
|
|
|
if (app->pref_editor_trail_space) utils_strip_trailing_spaces(idx);
|
|
|
|
// ensure the file has a newline at the end
|
|
|
|
if (app->pref_editor_new_line) utils_ensure_final_newline(idx);
|
|
|
|
// ensure there a really the same EOL chars
|
|
|
|
sci_convert_eols(doc_list[idx].sci, sci_get_eol_mode(doc_list[idx].sci));
|
|
|
|
|
|
|
|
len = sci_get_length(doc_list[idx].sci) + 1;
|
|
|
|
data = (gchar*) g_malloc(len);
|
|
|
|
sci_get_text(doc_list[idx].sci, len, data);
|
|
|
|
|
2006-06-19 18:31:17 +00:00
|
|
|
// save in original encoding
|
|
|
|
if (doc_list[idx].encoding != NULL)
|
|
|
|
{
|
|
|
|
GError *conv_error = NULL;
|
|
|
|
gchar* conv_file_contents = NULL;
|
|
|
|
|
|
|
|
// try to convert it from UTF-8 to original encoding
|
|
|
|
conv_file_contents = g_convert(data, -1, doc_list[idx].encoding, "UTF-8",
|
|
|
|
NULL, NULL, &conv_error);
|
|
|
|
|
|
|
|
if (conv_error != NULL)
|
|
|
|
{
|
|
|
|
geany_debug("error while converting the file to its orinial encoding");
|
2006-06-21 18:54:07 +00:00
|
|
|
geany_debug("encoding: %s error message: %s)",
|
|
|
|
doc_list[idx].encoding, conv_error->message);
|
|
|
|
g_free(doc_list[idx].encoding);
|
|
|
|
doc_list[idx].encoding = g_strdup("UTF-8");
|
|
|
|
msgwin_status_add(_("Error while converting file (%s)."), conv_error->message);
|
|
|
|
g_error_free(conv_error);
|
2006-06-19 18:31:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_free(data);
|
|
|
|
data = conv_file_contents;
|
|
|
|
len = strlen(conv_file_contents);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-10 20:56:17 +00:00
|
|
|
locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
|
|
|
|
fp = fopen(locale_filename, "w");
|
2005-11-22 12:26:26 +00:00
|
|
|
if (fp == NULL)
|
|
|
|
{
|
|
|
|
msgwin_status_add(_("Error saving file (%s)."), strerror(errno));
|
2006-02-10 20:56:17 +00:00
|
|
|
utils_beep();
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef GEANY_WIN32
|
2005-12-29 20:01:18 +00:00
|
|
|
// ugly hack: on windows '\n' (LF) is taken as CRLF so we must convert it prior to save the doc
|
2005-11-22 12:26:26 +00:00
|
|
|
if (sci_get_eol_mode(doc_list[idx].sci) == SC_EOL_CRLF) sci_convert_eols(doc_list[idx].sci, SC_EOL_CRLF);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
len = strlen(data);
|
|
|
|
bytes_written = fwrite(data, sizeof (gchar), len, fp);
|
|
|
|
fclose (fp);
|
|
|
|
|
|
|
|
g_free(data);
|
|
|
|
|
|
|
|
if (len != bytes_written)
|
|
|
|
{
|
|
|
|
msgwin_status_add(_("Error saving file."));
|
2006-02-10 20:56:17 +00:00
|
|
|
utils_beep();
|
2005-11-22 12:26:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-11 18:38:17 +00:00
|
|
|
// ignore the following things if we are quitting
|
2006-01-14 22:40:05 +00:00
|
|
|
if (! app->quitting)
|
2006-02-10 20:56:17 +00:00
|
|
|
{
|
|
|
|
gchar *basename = g_path_get_basename(doc_list[idx].file_name);
|
2006-01-14 22:40:05 +00:00
|
|
|
|
2006-02-10 20:56:17 +00:00
|
|
|
// set line numbers again, to reset the margin width, if
|
|
|
|
// there are more lines than before
|
2006-02-14 22:07:55 +00:00
|
|
|
sci_set_line_numbers(doc_list[idx].sci, app->show_linenumber_margin, 0);
|
2006-01-11 18:38:17 +00:00
|
|
|
sci_set_savepoint(doc_list[idx].sci);
|
|
|
|
doc_list[idx].mtime = time(NULL);
|
|
|
|
if (doc_list[idx].file_type == NULL || doc_list[idx].file_type->id == GEANY_FILETYPES_ALL)
|
|
|
|
doc_list[idx].file_type = filetypes_get_from_filename(doc_list[idx].file_name);
|
|
|
|
document_set_filetype(idx, doc_list[idx].file_type);
|
|
|
|
tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
|
2006-02-10 20:56:17 +00:00
|
|
|
gtk_label_set_text(GTK_LABEL(doc_list[idx].tab_label), basename);
|
|
|
|
gtk_label_set_text(GTK_LABEL(doc_list[idx].tabmenu_label), basename);
|
2006-01-14 22:40:05 +00:00
|
|
|
treeviews_openfiles_update(doc_list[idx].iter, doc_list[idx].file_name);
|
2006-01-11 18:38:17 +00:00
|
|
|
msgwin_status_add(_("File %s saved."), doc_list[idx].file_name);
|
2006-04-27 18:06:35 +00:00
|
|
|
utils_update_statusbar(idx, -1);
|
2006-02-10 20:56:17 +00:00
|
|
|
treeviews_openfiles_update(doc_list[idx].iter, basename);
|
|
|
|
g_free(basename);
|
2006-01-11 18:38:17 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* special search function, used from the find entry in the toolbar */
|
|
|
|
void document_find_next(gint idx, const gchar *text, gint flags, gboolean find_button, gboolean inc)
|
|
|
|
{
|
|
|
|
gint selection_end, search_pos;
|
|
|
|
|
|
|
|
if (idx == -1 || ! strlen(text)) return;
|
|
|
|
|
|
|
|
selection_end = sci_get_selection_end(doc_list[idx].sci);
|
|
|
|
if (!inc && sci_can_copy(doc_list[idx].sci))
|
|
|
|
{ // there's a selection so go to the end
|
2006-05-26 17:11:41 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, selection_end, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sci_set_search_anchor(doc_list[idx].sci);
|
|
|
|
search_pos = sci_search_next(doc_list[idx].sci, flags, text);
|
|
|
|
if (search_pos != -1)
|
|
|
|
{
|
|
|
|
sci_scroll_caret(doc_list[idx].sci);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (find_button)
|
|
|
|
{
|
|
|
|
if (dialogs_show_not_found(text))
|
|
|
|
{
|
2006-02-26 18:19:28 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
document_find_next(idx, text, flags, TRUE, inc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-10 20:56:17 +00:00
|
|
|
utils_beep();
|
2006-02-26 18:19:28 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* general search function, used from the find dialog */
|
|
|
|
void document_find_text(gint idx, const gchar *text, gint flags, gboolean search_backwards)
|
|
|
|
{
|
|
|
|
gint selection_end, selection_start, search_pos;
|
|
|
|
|
|
|
|
if (idx == -1 || ! strlen(text)) return;
|
|
|
|
|
|
|
|
selection_start = sci_get_selection_start(doc_list[idx].sci);
|
|
|
|
selection_end = sci_get_selection_end(doc_list[idx].sci);
|
|
|
|
if ((selection_end - selection_start) > 0)
|
|
|
|
{ // there's a selection so go to the end
|
|
|
|
if (search_backwards)
|
2006-05-26 17:11:41 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, selection_start, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
else
|
2006-05-26 17:11:41 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, selection_end, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sci_set_search_anchor(doc_list[idx].sci);
|
|
|
|
if (search_backwards)
|
|
|
|
search_pos = sci_search_prev(doc_list[idx].sci, flags, text);
|
|
|
|
else
|
|
|
|
search_pos = sci_search_next(doc_list[idx].sci, flags, text);
|
|
|
|
|
|
|
|
if (search_pos != -1)
|
|
|
|
{
|
|
|
|
sci_scroll_caret(doc_list[idx].sci);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (dialogs_show_not_found(text))
|
|
|
|
{
|
2006-02-26 18:19:28 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, (search_backwards) ? sci_get_length(doc_list[idx].sci) : 0, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
document_find_text(idx, text, flags, search_backwards);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void document_replace_text(gint idx, const gchar *find_text, const gchar *replace_text, gint flags, gboolean search_backwards)
|
|
|
|
{
|
|
|
|
gint selection_end, selection_start, search_pos;
|
|
|
|
gint find_text_len = strlen(find_text);
|
|
|
|
|
|
|
|
if (idx == -1 || ! find_text_len) return;
|
|
|
|
|
|
|
|
selection_start = sci_get_selection_start(doc_list[idx].sci);
|
|
|
|
selection_end = sci_get_selection_end(doc_list[idx].sci);
|
|
|
|
if ((selection_end - selection_start) > 0)
|
|
|
|
{ // there's a selection so go to the end
|
|
|
|
if (search_backwards)
|
2006-05-26 17:11:41 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, selection_start, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
else
|
2006-05-26 17:11:41 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, selection_end, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sci_set_search_anchor(doc_list[idx].sci);
|
|
|
|
if (search_backwards)
|
|
|
|
search_pos = sci_search_prev(doc_list[idx].sci, flags, find_text);
|
|
|
|
else
|
|
|
|
search_pos = sci_search_next(doc_list[idx].sci, flags, find_text);
|
|
|
|
|
|
|
|
if (search_pos != -1)
|
|
|
|
{
|
|
|
|
sci_target_start(doc_list[idx].sci, search_pos);
|
|
|
|
sci_target_end(doc_list[idx].sci, search_pos + find_text_len);
|
|
|
|
sci_target_replace(doc_list[idx].sci, replace_text);
|
|
|
|
sci_scroll_caret(doc_list[idx].sci);
|
|
|
|
sci_set_selection_start(doc_list[idx].sci, search_pos);
|
|
|
|
sci_set_selection_end(doc_list[idx].sci, search_pos + strlen(replace_text));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-10 20:56:17 +00:00
|
|
|
utils_beep();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-25 15:32:03 +00:00
|
|
|
void document_replace_sel(gint idx, const gchar *find_text, const gchar *replace_text, gint flags)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
gint selection_end, selection_start, search_pos;
|
2006-05-25 15:32:03 +00:00
|
|
|
gint anchor_pos;
|
2005-11-22 12:26:26 +00:00
|
|
|
gint find_text_len = strlen(find_text);
|
2006-03-10 00:52:09 +00:00
|
|
|
gint replace_text_len = strlen(replace_text);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
if (idx == -1 || ! find_text_len) return;
|
|
|
|
|
2006-05-25 15:32:03 +00:00
|
|
|
selection_start = sci_get_selection_start(doc_list[idx].sci);
|
|
|
|
selection_end = sci_get_selection_end(doc_list[idx].sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
if ((selection_end - selection_start) == 0)
|
|
|
|
{
|
2006-02-10 20:56:17 +00:00
|
|
|
utils_beep();
|
2005-11-22 12:26:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-25 15:32:03 +00:00
|
|
|
sci_start_undo_action(doc_list[idx].sci);
|
|
|
|
anchor_pos = selection_start;
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
sci_goto_pos(doc_list[idx].sci, anchor_pos, TRUE);
|
|
|
|
sci_set_search_anchor(doc_list[idx].sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
search_pos = sci_search_next(doc_list[idx].sci, flags, find_text);
|
|
|
|
|
2006-05-25 15:32:03 +00:00
|
|
|
if (search_pos == -1 ||
|
|
|
|
search_pos < selection_start ||
|
|
|
|
search_pos + find_text_len > selection_end) break;
|
2006-03-10 00:52:09 +00:00
|
|
|
else
|
|
|
|
{
|
2006-05-25 15:32:03 +00:00
|
|
|
sci_target_start(doc_list[idx].sci, search_pos);
|
|
|
|
sci_target_end(doc_list[idx].sci, search_pos + find_text_len);
|
|
|
|
sci_target_replace(doc_list[idx].sci, replace_text);
|
|
|
|
anchor_pos = search_pos + replace_text_len; //avoid rematch
|
|
|
|
// update selection end point for each replacement
|
2006-03-10 00:52:09 +00:00
|
|
|
selection_end += replace_text_len - find_text_len;
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2006-05-25 15:32:03 +00:00
|
|
|
sci_end_undo_action(doc_list[idx].sci);
|
|
|
|
// set selection again, because it got lost and end may be moved
|
2005-11-22 12:26:26 +00:00
|
|
|
sci_set_selection_start(doc_list[idx].sci, selection_start);
|
|
|
|
sci_set_selection_end(doc_list[idx].sci, selection_end);
|
2006-05-25 15:32:03 +00:00
|
|
|
|
|
|
|
sci_scroll_caret(doc_list[idx].sci);
|
|
|
|
gtk_widget_hide(app->replace_dialog);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void document_replace_all(gint idx, const gchar *find_text, const gchar *replace_text, gint flags)
|
|
|
|
{
|
|
|
|
gint search_pos;
|
|
|
|
gint find_text_len = strlen(find_text);
|
2006-03-10 00:52:09 +00:00
|
|
|
gint replace_text_len = strlen(replace_text);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
if (idx == -1 || ! find_text_len) return;
|
|
|
|
|
2006-05-25 15:32:03 +00:00
|
|
|
sci_start_undo_action(doc_list[idx].sci);
|
2006-02-26 18:19:28 +00:00
|
|
|
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
sci_set_search_anchor(doc_list[idx].sci);
|
|
|
|
|
|
|
|
search_pos = sci_search_next(doc_list[idx].sci, flags, find_text);
|
|
|
|
while (search_pos != -1)
|
|
|
|
{
|
|
|
|
sci_target_start(doc_list[idx].sci, search_pos);
|
|
|
|
sci_target_end(doc_list[idx].sci, search_pos + find_text_len);
|
|
|
|
sci_target_replace(doc_list[idx].sci, replace_text);
|
2006-03-10 00:52:09 +00:00
|
|
|
// next search starts after replaced text (avoids rematching):
|
|
|
|
sci_goto_pos(doc_list[idx].sci, search_pos + replace_text_len, TRUE);
|
|
|
|
sci_set_search_anchor(doc_list[idx].sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
search_pos = sci_search_next(doc_list[idx].sci, flags, find_text);
|
|
|
|
}
|
2006-05-25 15:32:03 +00:00
|
|
|
sci_end_undo_action(doc_list[idx].sci);
|
2006-03-10 00:52:09 +00:00
|
|
|
sci_scroll_caret(doc_list[idx].sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
gtk_widget_hide(app->replace_dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-13 19:37:21 +00:00
|
|
|
void document_set_font(gint idx, const gchar *font_name, gint size)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
gint style;
|
|
|
|
|
|
|
|
for (style = 0; style <= 127; style++)
|
2006-06-13 19:37:21 +00:00
|
|
|
sci_set_font(doc_list[idx].sci, style, font_name, size);
|
2005-11-22 12:26:26 +00:00
|
|
|
// line number and braces
|
2006-06-13 19:37:21 +00:00
|
|
|
sci_set_font(doc_list[idx].sci, STYLE_LINENUMBER, font_name, size);
|
|
|
|
sci_set_font(doc_list[idx].sci, STYLE_BRACELIGHT, font_name, size);
|
|
|
|
sci_set_font(doc_list[idx].sci, STYLE_BRACEBAD, font_name, size);
|
2005-11-22 12:26:26 +00:00
|
|
|
// zoom to 100% to prevent confusion
|
2006-06-13 19:37:21 +00:00
|
|
|
sci_zoom_off(doc_list[idx].sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-10 23:06:47 +00:00
|
|
|
void document_update_tag_list(gint idx, gboolean update)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
// if the filetype doesn't has a tag parser or it is a new file, leave
|
|
|
|
if (idx == -1 || ! doc_list[idx].file_type->has_tags || ! doc_list[idx].file_name) return;
|
|
|
|
|
|
|
|
if (doc_list[idx].tm_file == NULL)
|
|
|
|
{
|
2006-01-23 17:05:29 +00:00
|
|
|
gchar *locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
|
2006-06-24 14:36:35 +00:00
|
|
|
doc_list[idx].tm_file = tm_source_file_new(locale_filename, FALSE,
|
|
|
|
doc_list[idx].file_type->name);
|
2006-01-23 17:05:29 +00:00
|
|
|
g_free(locale_filename);
|
|
|
|
if (! doc_list[idx].tm_file) return;
|
2005-11-22 12:26:26 +00:00
|
|
|
tm_workspace_add_object(doc_list[idx].tm_file);
|
2006-05-10 23:06:47 +00:00
|
|
|
if (update)
|
|
|
|
tm_source_file_update(doc_list[idx].tm_file, TRUE, FALSE, TRUE);
|
2005-12-18 22:08:42 +00:00
|
|
|
utils_update_tag_list(idx, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-10 19:54:44 +00:00
|
|
|
gint len = sci_get_length(doc_list[idx].sci) + 1;
|
|
|
|
gchar *buf = (gchar*) g_malloc(len);
|
|
|
|
|
|
|
|
sci_get_text(doc_list[idx].sci, len, buf);
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
if (tm_source_file_update(doc_list[idx].tm_file, TRUE, FALSE, TRUE))
|
2006-05-10 19:54:44 +00:00
|
|
|
//if (tm_source_file_buffer_update(doc_list[idx].tm_file, buf, len, TRUE))
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2005-12-18 22:08:42 +00:00
|
|
|
utils_update_tag_list(idx, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
geany_debug(_("tag list updating failed"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* sets the filetype of the the document (sets syntax highlighting and tagging) */
|
|
|
|
void document_set_filetype(gint idx, filetype *type)
|
|
|
|
{
|
|
|
|
if (! type || idx < 0) return;
|
2006-04-27 18:06:35 +00:00
|
|
|
if (type->id > GEANY_MAX_FILE_TYPES) return;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-04-27 18:06:35 +00:00
|
|
|
doc_list[idx].file_type = type;
|
2006-05-10 23:06:47 +00:00
|
|
|
document_update_tag_list(idx, TRUE);
|
2006-04-27 18:06:35 +00:00
|
|
|
type->style_func_ptr(doc_list[idx].sci);
|
|
|
|
|
|
|
|
// For C/C++/Java files, get list of typedefs for colourising
|
|
|
|
if (sci_get_lexer(doc_list[idx].sci) == SCLEX_CPP)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-04-27 18:06:35 +00:00
|
|
|
guint j, n;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-04-27 18:06:35 +00:00
|
|
|
// assign project keywords
|
|
|
|
if ((app->tm_workspace) && (app->tm_workspace->work_object.tags_array))
|
|
|
|
{
|
|
|
|
GPtrArray *typedefs = tm_tags_extract(app->tm_workspace->work_object.tags_array,
|
|
|
|
tm_tag_typedef_t | tm_tag_struct_t | tm_tag_class_t);
|
|
|
|
if ((typedefs) && (typedefs->len > 0))
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-04-27 18:06:35 +00:00
|
|
|
GString *s = g_string_sized_new(typedefs->len * 10);
|
|
|
|
for (j = 0; j < typedefs->len; ++j)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-04-27 18:06:35 +00:00
|
|
|
if (!(TM_TAG(typedefs->pdata[j])->atts.entry.scope))
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-04-27 18:06:35 +00:00
|
|
|
if (TM_TAG(typedefs->pdata[j])->name)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-04-27 18:06:35 +00:00
|
|
|
g_string_append(s, TM_TAG(typedefs->pdata[j])->name);
|
|
|
|
g_string_append_c(s, ' ');
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-27 18:06:35 +00:00
|
|
|
for (n = 0; n < GEANY_MAX_OPEN_FILES; n++)
|
|
|
|
{
|
|
|
|
if (doc_list[n].sci)
|
|
|
|
{
|
|
|
|
sci_set_keywords(doc_list[n].sci, 3, s->str);
|
|
|
|
sci_colourise(doc_list[n].sci, 0, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//SSM(doc_list[idx].sci, SCI_SETKEYWORDS, 3, (sptr_t) s->str);
|
|
|
|
g_string_free(s, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2006-04-27 18:06:35 +00:00
|
|
|
g_ptr_array_free(typedefs, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-27 18:06:35 +00:00
|
|
|
sci_colourise(doc_list[idx].sci, 0, -1);
|
|
|
|
utils_build_show_hide(idx);
|
|
|
|
geany_debug("%s : %s (%s)", (doc_list[idx].file_name) ? doc_list[idx].file_name : "(null)",
|
|
|
|
type->name, doc_list[idx].encoding);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gchar *document_get_eol_mode(gint idx)
|
|
|
|
{
|
|
|
|
if (idx == -1) return '\0';
|
|
|
|
|
|
|
|
switch (sci_get_eol_mode(doc_list[idx].sci))
|
|
|
|
{
|
|
|
|
case SC_EOL_CRLF: return _("Win (CRLF)"); break;
|
|
|
|
case SC_EOL_CR: return _("Max (CR)"); break;
|
|
|
|
case SC_EOL_LF:
|
|
|
|
default: return _("Unix (LF)"); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-13 19:37:21 +00:00
|
|
|
/// TODO move me to filetypes.c
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *document_prepare_template(filetype *ft)
|
|
|
|
{
|
|
|
|
gchar *gpl_notice = NULL;
|
2006-05-10 19:54:44 +00:00
|
|
|
gchar *template = NULL;
|
|
|
|
gchar *ft_template = NULL;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
if (ft != NULL)
|
|
|
|
{
|
|
|
|
switch (ft->id)
|
|
|
|
{
|
|
|
|
case GEANY_FILETYPES_PHP:
|
2006-02-06 06:26:53 +00:00
|
|
|
{ // PHP: include the comment in <?php ?> - tags
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *tmp = templates_get_template_fileheader(
|
|
|
|
GEANY_TEMPLATE_FILEHEADER, ft->extension, -1);
|
2006-02-06 06:26:53 +00:00
|
|
|
gpl_notice = g_strconcat("<?php\n", tmp, "?>\n\n", NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(tmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GEANY_FILETYPES_PASCAL:
|
|
|
|
{ // Pascal: comments are in { } brackets
|
|
|
|
gpl_notice = templates_get_template_fileheader(
|
|
|
|
GEANY_TEMPLATE_FILEHEADER_PASCAL, ft->extension, -1);
|
|
|
|
break;
|
|
|
|
}
|
2006-05-10 19:54:44 +00:00
|
|
|
case GEANY_FILETYPES_PYTHON:
|
|
|
|
case GEANY_FILETYPES_RUBY:
|
|
|
|
case GEANY_FILETYPES_SH:
|
|
|
|
case GEANY_FILETYPES_MAKE:
|
|
|
|
case GEANY_FILETYPES_PERL:
|
|
|
|
{
|
|
|
|
gpl_notice = templates_get_template_fileheader(
|
|
|
|
GEANY_TEMPLATE_FILEHEADER_ROUTE, ft->extension, -1);
|
|
|
|
break;
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
default:
|
|
|
|
{ // -> C, C++, Java, ...
|
|
|
|
gpl_notice = templates_get_template_fileheader(
|
|
|
|
GEANY_TEMPLATE_FILEHEADER, ft->extension, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ft_template = filetypes_get_template(ft);
|
|
|
|
template = g_strconcat(gpl_notice, ft_template, NULL);
|
|
|
|
g_free(ft_template);
|
|
|
|
g_free(gpl_notice);
|
|
|
|
return template;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // new file w/o template
|
|
|
|
return templates_get_template_fileheader(GEANY_TEMPLATE_FILETYPE_NONE, NULL, -1);
|
|
|
|
}
|
|
|
|
}
|
2006-02-26 18:19:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
void document_unfold_all(gint idx)
|
|
|
|
{
|
|
|
|
gint lines, pos, i;
|
|
|
|
|
|
|
|
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
|
|
|
|
|
|
|
lines = sci_get_line_count(doc_list[idx].sci);
|
|
|
|
pos = sci_get_current_position(doc_list[idx].sci);
|
|
|
|
|
|
|
|
for (i = 0; i < lines; i++)
|
|
|
|
{
|
|
|
|
sci_ensure_line_is_visible(doc_list[idx].sci, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void document_fold_all(gint idx)
|
|
|
|
{
|
|
|
|
gint lines, pos, i;
|
|
|
|
|
|
|
|
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
|
|
|
|
|
|
|
lines = sci_get_line_count(doc_list[idx].sci);
|
|
|
|
pos = sci_get_current_position(doc_list[idx].sci);
|
|
|
|
|
|
|
|
for (i = 0; i < lines; i++)
|
|
|
|
{
|
|
|
|
gint level = sci_get_fold_level(doc_list[idx].sci, i);
|
|
|
|
if (level & SC_FOLDLEVELHEADERFLAG)
|
|
|
|
{
|
|
|
|
if (sci_get_fold_expanded(doc_list[idx].sci, i))
|
|
|
|
sci_toggle_fold(doc_list[idx].sci, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-06-13 19:37:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
void document_clear_indicators(gint idx)
|
|
|
|
{
|
|
|
|
glong last_pos = sci_get_length(doc_list[idx].sci);
|
|
|
|
if (last_pos > 0)
|
|
|
|
{
|
|
|
|
sci_start_styling(doc_list[idx].sci, 0, INDIC2_MASK);
|
|
|
|
sci_set_styling(doc_list[idx].sci, last_pos, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void document_set_indicator(gint idx, gint line)
|
|
|
|
{
|
|
|
|
gint start, end, current_mask;
|
|
|
|
guint i = 0, len;
|
|
|
|
gchar *linebuf;
|
|
|
|
|
|
|
|
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
|
|
|
|
|
|
|
start = sci_get_position_from_line(doc_list[idx].sci, line);
|
|
|
|
end = sci_get_position_from_line(doc_list[idx].sci, line + 1);
|
|
|
|
|
|
|
|
// skip blank lines
|
|
|
|
if ((start + 1) == end) return;
|
|
|
|
|
|
|
|
len = end - start;
|
|
|
|
linebuf = g_malloc(len);
|
|
|
|
|
|
|
|
// don't set the indicator on whitespace
|
|
|
|
sci_get_line(doc_list[idx].sci, line, linebuf);
|
|
|
|
if (linebuf == NULL) return;
|
|
|
|
|
|
|
|
while (isspace(linebuf[i])) i++;
|
|
|
|
while (isspace(linebuf[len-1])) len--;
|
|
|
|
g_free(linebuf);
|
|
|
|
|
|
|
|
current_mask = sci_get_style_at(doc_list[idx].sci, start);
|
|
|
|
current_mask &= INDICS_MASK;
|
|
|
|
current_mask |= INDIC2_MASK;
|
|
|
|
sci_start_styling(doc_list[idx].sci, start + i, INDIC2_MASK);
|
|
|
|
sci_set_styling(doc_list[idx].sci, len - i, current_mask);
|
|
|
|
}
|