Skip to content

Commit

Permalink
Fix compilation.
Browse files Browse the repository at this point in the history
Move utils_get_current_function() to symbols.c.
Move utils_replace_filename() to document.c.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/editor-struct@2766 ea778897-0a13-0410-b9d1-a72fbfd435f5
  • Loading branch information
ntrel committed Jul 8, 2008
1 parent 7c71457 commit 4837030
Show file tree
Hide file tree
Showing 16 changed files with 309 additions and 296 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Expand Up @@ -17,6 +17,13 @@
src/editor.h:
Fix building editor.c, using GeanyEditor* instead of GeanyDocument*
(most global editor functions still need conversion though).
* src/utils.c, src/utils.h, src/treeviews.c, src/callbacks.c,
src/notebook.c, src/keyfile.c, src/filetypes.c, src/document.c,
src/editor.c, src/symbols.c, src/symbols.h, src/ui_utils.c,
plugins/vcdiff.c, plugins/htmlchars.c, plugins/classbuilder.c:
Fix compilation.
Move utils_get_current_function() to symbols.c.
Move utils_replace_filename() to document.c.


2008-07-07 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Expand Down
1 change: 1 addition & 0 deletions plugins/classbuilder.c
Expand Up @@ -30,6 +30,7 @@
#include "support.h"
#include "filetypes.h"
#include "document.h"
#include "editor.h"
#include "ui_utils.h"
#include "pluginmacros.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/htmlchars.c
Expand Up @@ -28,6 +28,7 @@
#include "support.h"
#include "plugindata.h"
#include "document.h"
#include "editor.h"
#include "keybindings.h"
#include "ui_utils.h"
#include "utils.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/vcdiff.c
Expand Up @@ -33,6 +33,7 @@
#include "support.h"
#include "plugindata.h"
#include "document.h"
#include "editor.h"
#include "filetypes.h"
#include "utils.h"
#include "project.h"
Expand Down
12 changes: 6 additions & 6 deletions src/callbacks.c
Expand Up @@ -999,7 +999,7 @@ on_use_auto_indentation1_toggled (GtkCheckMenuItem *checkmenuitem,
{
GeanyDocument *doc = document_get_current();
if (doc != NULL)
doc->auto_indent = ! doc->auto_indent;
doc->editor->auto_indent = ! doc->editor->auto_indent;
}
}

Expand Down Expand Up @@ -1288,9 +1288,9 @@ on_comments_function_activate (GtkMenuItem *menuitem,
return;
}

/* utils_get_current_function returns -1 on failure, so sci_get_position_from_line
/* symbols_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(doc, &cur_tag);
line = symbols_get_current_function(doc, &cur_tag);
pos = sci_get_position_from_line(doc->editor->scintilla, line - 1);

text = templates_get_template_function(doc->file_type->id, cur_tag);
Expand Down Expand Up @@ -1707,7 +1707,7 @@ on_menu_increase_indent1_activate (GtkMenuItem *menuitem,
line = sci_get_line_from_position(doc->editor->scintilla, old_pos);
ind_pos = sci_get_line_indent_position(doc->editor->scintilla, line);
/* when using tabs increase cur pos by 1, when using space increase it by tab_width */
step = (doc->use_tabs) ? 1 : editor_prefs.tab_width;
step = (doc->editor->use_tabs) ? 1 : editor_prefs.tab_width;
new_pos = (old_pos > ind_pos) ? old_pos + step : old_pos;

sci_set_current_position(doc->editor->scintilla, ind_pos, TRUE);
Expand Down Expand Up @@ -1736,7 +1736,7 @@ on_menu_decrease_indent1_activate (GtkMenuItem *menuitem,
old_pos = sci_get_current_position(doc->editor->scintilla);
line = sci_get_line_from_position(doc->editor->scintilla, old_pos);
ind_pos = sci_get_line_indent_position(doc->editor->scintilla, line);
step = (doc->use_tabs) ? 1 : editor_prefs.tab_width;
step = (doc->editor->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->editor->scintilla, line))
Expand Down Expand Up @@ -2153,7 +2153,7 @@ on_line_breaking1_activate (GtkMenuItem *menuitem,
doc = document_get_current();
g_return_if_fail(doc != NULL);

doc->line_breaking = !doc->line_breaking;
doc->editor->line_breaking = !doc->editor->line_breaking;
}

void
Expand Down
71 changes: 50 additions & 21 deletions src/document.c
Expand Up @@ -311,7 +311,7 @@ void document_apply_update_prefs(GeanyDocument *doc)

sci_set_folding_margin_visible(sci, editor_prefs.folding);

doc->auto_indent = (editor_prefs.indent_mode != INDENT_NONE);
doc->editor->auto_indent = (editor_prefs.indent_mode != INDENT_NONE);

sci_assign_cmdkey(sci, SCK_HOME,
editor_prefs.smart_home_key ? SCI_VCHOMEWRAP : SCI_HOMEWRAP);
Expand All @@ -324,22 +324,23 @@ void document_apply_update_prefs(GeanyDocument *doc)
static void init_doc_struct(GeanyDocument *new_doc)
{
Document *full_doc = DOCUMENT(new_doc);
GeanyEditor *editor = new_doc->editor;

memset(full_doc, 0, sizeof(Document));

new_doc->is_valid = FALSE;
new_doc->has_tags = FALSE;
new_doc->auto_indent = (editor_prefs.indent_mode != INDENT_NONE);
new_doc->line_wrapping = editor_prefs.line_wrapping;
editor->auto_indent = (editor_prefs.indent_mode != INDENT_NONE);
editor->line_wrapping = editor_prefs.line_wrapping;
new_doc->readonly = FALSE;
new_doc->file_name = NULL;
new_doc->file_type = NULL;
new_doc->tm_file = NULL;
new_doc->encoding = NULL;
new_doc->has_bom = FALSE;
new_doc->editor->scintilla = NULL;
new_doc->scroll_percent = -1.0F;
new_doc->line_breaking = FALSE;
editor->scroll_percent = -1.0F;
editor->line_breaking = FALSE;
new_doc->mtime = 0;
new_doc->changed = FALSE;
new_doc->last_check = time(NULL);
Expand Down Expand Up @@ -502,7 +503,7 @@ gboolean document_remove_page(guint page_num)
doc->encoding = NULL;
doc->has_bom = FALSE;
doc->tm_file = NULL;
doc->scroll_percent = -1.0F;
doc->editor->scroll_percent = -1.0F;
document_undo_clear(doc);
if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 0)
{
Expand Down Expand Up @@ -857,25 +858,25 @@ static gboolean load_text_file(const gchar *locale_filename, const gchar *utf8_f
/* Sets the cursor position on opening a file. First it sets the line when cl_options.goto_line
* is set, otherwise it sets the line when pos is greater than zero and finally it sets the column
* if cl_options.goto_column is set. */
static void set_cursor_position(GeanyDocument *doc, gint pos)
static void set_cursor_position(GeanyEditor *editor, gint pos)
{
if (cl_options.goto_line >= 0)
{ /* goto line which was specified on command line and then undefine the line */
sci_goto_line(doc->editor->scintilla, cl_options.goto_line - 1, TRUE);
doc->scroll_percent = 0.5F;
sci_goto_line(editor->scintilla, cl_options.goto_line - 1, TRUE);
editor->scroll_percent = 0.5F;
cl_options.goto_line = -1;
}
else if (pos > 0)
{
sci_set_current_position(doc->editor->scintilla, pos, FALSE);
doc->scroll_percent = 0.5F;
sci_set_current_position(editor->scintilla, pos, FALSE);
editor->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->editor->scintilla);
sci_set_current_position(doc->editor->scintilla, cur_pos + cl_options.goto_column, FALSE);
doc->scroll_percent = 0.5F;
gint cur_pos = sci_get_current_position(editor->scintilla);
sci_set_current_position(editor->scintilla, cur_pos + cl_options.goto_column, FALSE);
editor->scroll_percent = 0.5F;
cl_options.goto_column = -1;
}
}
Expand Down Expand Up @@ -985,7 +986,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename
g_free(utf8_filename);
g_free(locale_filename);
document_check_disk_status(doc, TRUE); /* force a file changed check */
set_cursor_position(doc, pos);
set_cursor_position(doc->editor, pos);
return doc;
}
}
Expand Down Expand Up @@ -1032,7 +1033,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename
sci_set_line_numbers(doc->editor->scintilla, 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(doc, pos);
set_cursor_position(doc->editor, pos);

if (! reload)
{
Expand All @@ -1057,7 +1058,7 @@ GeanyDocument *document_open_file_full(GeanyDocument *doc, const gchar *filename

/* set indentation settings after setting the filetype */
if (reload)
editor_set_use_tabs(doc->editor, doc->use_tabs); /* resetup sci */
editor_set_use_tabs(doc->editor, doc->editor->use_tabs); /* resetup sci */
else
set_indentation(doc);

Expand Down Expand Up @@ -1215,6 +1216,34 @@ static void get_line_column_from_pos(GeanyDocument *doc, guint byte_pos, gint *l
}


static void replace_header_filename(GeanyDocument *doc)
{
gchar *filebase;
gchar *filename;
struct TextToFind ttf;

if (doc == NULL || doc->file_type == NULL) return;

filebase = g_strconcat(GEANY_STRING_UNTITLED, ".", (doc->file_type)->extension, NULL);
filename = g_path_get_basename(doc->file_name);

/* only search the first 3 lines */
ttf.chrg.cpMin = 0;
ttf.chrg.cpMax = sci_get_position_from_line(doc->editor->scintilla, 3);
ttf.lpstrText = (gchar*)filebase;

if (sci_find_text(doc->editor->scintilla, SCFIND_MATCHCASE, &ttf) != -1)
{
sci_target_start(doc->editor->scintilla, ttf.chrgText.cpMin);
sci_target_end(doc->editor->scintilla, ttf.chrgText.cpMax);
sci_target_replace(doc->editor->scintilla, filename, FALSE);
}

g_free(filebase);
g_free(filename);
}


/*
* Save the %document, detecting the filetype.
*
Expand Down Expand Up @@ -1249,7 +1278,7 @@ gboolean document_save_file_as(GeanyDocument *doc, const gchar *utf8_fname)
ignore_callback = FALSE;
}
}
utils_replace_filename(doc);
replace_header_filename(doc);

ret = document_save_file(doc, TRUE);
if (ret)
Expand Down Expand Up @@ -1582,7 +1611,7 @@ gint document_find_text(GeanyDocument *doc, const gchar *text, gint flags, gbool
sci_ensure_line_is_visible(doc->editor->scintilla,
sci_get_line_from_position(doc->editor->scintilla, search_pos));
if (scroll)
doc->scroll_percent = 0.3F;
doc->editor->scroll_percent = 0.3F;
}
else
{
Expand Down Expand Up @@ -2394,11 +2423,11 @@ GeanyDocument *document_clone(GeanyDocument *old_doc, const gchar *utf8_filename
g_free(text);

/* copy file properties */
doc->line_wrapping = old_doc->line_wrapping;
doc->editor->line_wrapping = old_doc->editor->line_wrapping;
doc->readonly = old_doc->readonly;
doc->has_bom = old_doc->has_bom;
document_set_encoding(doc, old_doc->encoding);
sci_set_lines_wrapped(doc->editor->scintilla, doc->line_wrapping);
sci_set_lines_wrapped(doc->editor->scintilla, doc->editor->line_wrapping);
sci_set_readonly(doc->editor->scintilla, doc->readonly);

ui_document_show_hide(doc);
Expand Down
2 changes: 1 addition & 1 deletion src/editor.c
Expand Up @@ -3501,7 +3501,7 @@ static void editor_colourise(ScintillaObject *sci)

/* now that the current document is colourised, fold points are now accurate,
* so force an update of the current function/tag. */
utils_get_current_function(NULL, NULL);
symbols_get_current_function(NULL, NULL);
ui_update_statusbar(NULL, -1);
}

Expand Down
1 change: 1 addition & 0 deletions src/filetypes.c
Expand Up @@ -34,6 +34,7 @@
#include "support.h"
#include "templates.h"
#include "document.h"
#include "editor.h"
#include "msgwindow.h"
#include "utils.h"
#include "sciwrappers.h"
Expand Down
10 changes: 5 additions & 5 deletions src/keyfile.c
Expand Up @@ -148,9 +148,9 @@ static gchar *get_session_file_string(GeanyDocument *doc)
ft->name,
doc->readonly,
encodings_get_idx_from_charset(doc->encoding),
doc->use_tabs,
doc->auto_indent,
doc->line_wrapping,
doc->editor->use_tabs,
doc->editor->auto_indent,
doc->editor->line_wrapping,
doc->file_name);
return fname;
}
Expand Down Expand Up @@ -888,11 +888,11 @@ static gboolean open_session_file(gchar **tmp)
(enc_idx >= 0 && enc_idx < GEANY_ENCODINGS_MAX) ?
encodings[enc_idx].charset : NULL);

if (DOC_VALID(doc))
if (doc)
{
editor_set_use_tabs(doc->editor, use_tabs);
editor_set_line_wrapping(doc->editor, line_wrapping);
doc->auto_indent = auto_indent;
doc->editor->auto_indent = auto_indent;
ret = TRUE;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/notebook.c
Expand Up @@ -28,6 +28,7 @@
#include "geany.h"
#include "notebook.h"
#include "document.h"
#include "editor.h"
#include "documentprivate.h"
#include "ui_utils.h"
#include "treeviews.h"
Expand Down

0 comments on commit 4837030

Please sign in to comment.