Kaydet (Commit) 65fcc2b0 authored tarafından Enrico Tröger's avatar Enrico Tröger

Cleanup.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5578 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 87350d76
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
the 'Regular expressions' option as well. the 'Regular expressions' option as well.
* plugins/export.c: * plugins/export.c:
Add option to insert line numbers (closes #3197150). Add option to insert line numbers (closes #3197150).
Cleanup.
2011-03-05 Colomban Wendling <colomban(at)geany(dot)org> 2011-03-05 Colomban Wendling <colomban(at)geany(dot)org>
......
...@@ -156,10 +156,10 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func, ...@@ -156,10 +156,10 @@ static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
GeanyDocument *doc; GeanyDocument *doc;
ExportInfo *exi; ExportInfo *exi;
if (extension == NULL) g_return_if_fail(extension != NULL);
return;
doc = document_get_current(); doc = document_get_current();
g_return_if_fail(doc != NULL);
exi = g_new(ExportInfo, 1); exi = g_new(ExportInfo, 1);
exi->doc = doc; exi->doc = doc;
...@@ -366,6 +366,7 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, ...@@ -366,6 +366,7 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename,
gboolean use_zoom, gboolean insert_line_numbers) gboolean use_zoom, gboolean insert_line_numbers)
{ {
GeanyEditor *editor = doc->editor; GeanyEditor *editor = doc->editor;
ScintillaObject *sci = doc->editor->sci;
gint i, doc_len, style = -1, old_style = 0, column = 0; gint i, doc_len, style = -1, old_style = 0, column = 0;
gint k, line_number, line_number_width, line_number_max_width = 0, pad; gint k, line_number, line_number_width, line_number_max_width = 0, pad;
gchar c, c_next, *tmp, *date; gchar c, c_next, *tmp, *date;
...@@ -375,15 +376,15 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, ...@@ -375,15 +376,15 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename,
GString *body; GString *body;
GString *cmds; GString *cmds;
GString *latex; GString *latex;
gint style_max = pow(2, scintilla_send_message(doc->editor->sci, SCI_GETSTYLEBITS, 0, 0)); gint style_max = pow(2, scintilla_send_message(sci, SCI_GETSTYLEBITS, 0, 0));
/* first read all styles from Scintilla */ /* first read all styles from Scintilla */
for (i = 0; i < style_max; i++) for (i = 0; i < style_max; i++)
{ {
styles[i][FORE] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETFORE, i, 0); styles[i][FORE] = scintilla_send_message(sci, SCI_STYLEGETFORE, i, 0);
styles[i][BACK] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBACK, i, 0); styles[i][BACK] = scintilla_send_message(sci, SCI_STYLEGETBACK, i, 0);
styles[i][BOLD] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBOLD, i, 0); styles[i][BOLD] = scintilla_send_message(sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETITALIC, i, 0); styles[i][ITALIC] = scintilla_send_message(sci, SCI_STYLEGETITALIC, i, 0);
styles[i][USED] = 0; styles[i][USED] = 0;
} }
...@@ -392,17 +393,17 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, ...@@ -392,17 +393,17 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename,
/* read the document and write the LaTeX code */ /* read the document and write the LaTeX code */
body = g_string_new(""); body = g_string_new("");
doc_len = sci_get_length(doc->editor->sci); doc_len = sci_get_length(sci);
for (i = 0; i < doc_len; i++) for (i = 0; i < doc_len; i++)
{ {
style = sci_get_style_at(doc->editor->sci, i); style = sci_get_style_at(sci, i);
c = sci_get_char_at(doc->editor->sci, i); c = sci_get_char_at(sci, i);
c_next = sci_get_char_at(doc->editor->sci, i + 1); c_next = sci_get_char_at(sci, i + 1);
/* line numbers */ /* line numbers */
if (insert_line_numbers && column == 0) if (insert_line_numbers && column == 0)
{ {
line_number = sci_get_line_from_position(doc->editor->sci, i) + 1; line_number = sci_get_line_from_position(sci, i) + 1;
line_number_width = get_line_numbers_arity(line_number); line_number_width = get_line_numbers_arity(line_number);
/* padding */ /* padding */
pad = line_number_max_width - line_number_width; pad = line_number_max_width - line_number_width;
...@@ -593,6 +594,7 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, ...@@ -593,6 +594,7 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename,
gboolean use_zoom, gboolean insert_line_numbers) gboolean use_zoom, gboolean insert_line_numbers)
{ {
GeanyEditor *editor = doc->editor; GeanyEditor *editor = doc->editor;
ScintillaObject *sci = doc->editor->sci;
gint i, doc_len, style = -1, old_style = 0, column = 0; gint i, doc_len, style = -1, old_style = 0, column = 0;
gint k, line_number, line_number_width, line_number_max_width = 0, pad; gint k, line_number, line_number_width, line_number_max_width = 0, pad;
gchar c, c_next, *date; gchar c, c_next, *date;
...@@ -605,15 +607,15 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, ...@@ -605,15 +607,15 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename,
GString *body; GString *body;
GString *css; GString *css;
GString *html; GString *html;
gint style_max = pow(2, scintilla_send_message(doc->editor->sci, SCI_GETSTYLEBITS, 0, 0)); gint style_max = pow(2, scintilla_send_message(sci, SCI_GETSTYLEBITS, 0, 0));
/* first read all styles from Scintilla */ /* first read all styles from Scintilla */
for (i = 0; i < style_max; i++) for (i = 0; i < style_max; i++)
{ {
styles[i][FORE] = ROTATE_RGB(scintilla_send_message(doc->editor->sci, SCI_STYLEGETFORE, i, 0)); styles[i][FORE] = ROTATE_RGB(scintilla_send_message(sci, SCI_STYLEGETFORE, i, 0));
styles[i][BACK] = ROTATE_RGB(scintilla_send_message(doc->editor->sci, SCI_STYLEGETBACK, i, 0)); styles[i][BACK] = ROTATE_RGB(scintilla_send_message(sci, SCI_STYLEGETBACK, i, 0));
styles[i][BOLD] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBOLD, i, 0); styles[i][BOLD] = scintilla_send_message(sci, SCI_STYLEGETBOLD, i, 0);
styles[i][ITALIC] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETITALIC, i, 0); styles[i][ITALIC] = scintilla_send_message(sci, SCI_STYLEGETITALIC, i, 0);
styles[i][USED] = 0; styles[i][USED] = 0;
} }
...@@ -622,27 +624,27 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, ...@@ -622,27 +624,27 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename,
font_name = pango_font_description_get_family(font_desc); font_name = pango_font_description_get_family(font_desc);
/*font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE;*/ /*font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE;*/
/* take the zoom level also into account */ /* take the zoom level also into account */
font_size = scintilla_send_message(doc->editor->sci, SCI_STYLEGETSIZE, 0, 0); font_size = scintilla_send_message(sci, SCI_STYLEGETSIZE, 0, 0);
if (use_zoom) if (use_zoom)
font_size += scintilla_send_message(doc->editor->sci, SCI_GETZOOM, 0, 0); font_size += scintilla_send_message(sci, SCI_GETZOOM, 0, 0);
if (insert_line_numbers) if (insert_line_numbers)
line_number_max_width = get_line_number_width(doc); line_number_max_width = get_line_number_width(doc);
/* read the document and write the HTML body */ /* read the document and write the HTML body */
body = g_string_new(""); body = g_string_new("");
doc_len = sci_get_length(doc->editor->sci); doc_len = sci_get_length(sci);
for (i = 0; i < doc_len; i++) for (i = 0; i < doc_len; i++)
{ {
style = sci_get_style_at(doc->editor->sci, i); style = sci_get_style_at(sci, i);
c = sci_get_char_at(doc->editor->sci, i); c = sci_get_char_at(sci, i);
/* sci_get_char_at() takes care of index boundaries and return 0 if i is too high */ /* sci_get_char_at() takes care of index boundaries and return 0 if i is too high */
c_next = sci_get_char_at(doc->editor->sci, i + 1); c_next = sci_get_char_at(sci, i + 1);
/* line numbers */ /* line numbers */
if (insert_line_numbers && column == 0) if (insert_line_numbers && column == 0)
{ {
line_number = sci_get_line_from_position(doc->editor->sci, i) + 1; line_number = sci_get_line_from_position(sci, i) + 1;
line_number_width = get_line_numbers_arity(line_number); line_number_width = get_line_numbers_arity(line_number);
/* padding */ /* padding */
pad = line_number_max_width - line_number_width; pad = line_number_max_width - line_number_width;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment