[latexila] Build Tools: restructure the BuildMsg structure
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Build Tools: restructure the BuildMsg structure
- Date: Tue, 10 Jul 2012 05:57:37 +0000 (UTC)
commit 57629936a138a5241f01e239e68ed1dc3af2a4ff
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Tue Jul 10 07:55:01 2012 +0200
Build Tools: restructure the BuildMsg structure
src/build_tool_runner.vala | 5 --
src/build_view.vala | 82 +++++++++++++++++++++++------------------
src/latex_post_processor.vala | 18 +--------
src/post_processors.vala | 15 ++-----
4 files changed, 52 insertions(+), 68 deletions(-)
---
diff --git a/src/build_tool_runner.vala b/src/build_tool_runner.vala
index 7c9a16f..a6d53c0 100644
--- a/src/build_tool_runner.vala
+++ b/src/build_tool_runner.vala
@@ -98,7 +98,6 @@ public class BuildToolRunner : GLib.Object
BuildMsg message = BuildMsg ();
message.text = "Failed to parse command line:";
message.type = BuildMsgType.ERROR;
- message.lines_set = false;
view.append_single_message (job_partition, message);
message.text = e.message;
@@ -214,7 +213,6 @@ public class BuildToolRunner : GLib.Object
_("Rubber may not support filenames with spaces (even in a directory)");
message.type = BuildMsgType.WARNING;
message.filename = filename;
- message.lines_set = false;
view.append_single_message (job_partitions[job_num], message);
}
@@ -235,7 +233,6 @@ public class BuildToolRunner : GLib.Object
BuildMsg error_msg = BuildMsg ();
error_msg.text = e.message;
error_msg.type = BuildMsgType.ERROR;
- error_msg.lines_set = false;
view.append_single_message (job_partitions[job_num], error_msg);
// If the command doesn't seem to be installed, display a more understandable
@@ -245,8 +242,6 @@ public class BuildToolRunner : GLib.Object
BuildMsg info_msg = BuildMsg ();
info_msg.text =
_("%s doesn't seem to be installed.").printf (command[0]);
- info_msg.type = BuildMsgType.INFO;
- info_msg.lines_set = false;
view.append_single_message (job_partitions[job_num], info_msg);
}
diff --git a/src/build_view.vala b/src/build_view.vala
index 3da5044..c0b1693 100644
--- a/src/build_view.vala
+++ b/src/build_view.vala
@@ -42,18 +42,28 @@ public enum BuildMsgType
public struct BuildMsg
{
- public string text;
- public BuildMsgType type;
- public string? filename;
+ BuildMsgType type;
+ string? text;
- public bool lines_set;
- public int start_line;
+ // Reference to a certain file.
+ string? filename;
- // if -1, takes the same value as start_line
- public int end_line;
+ // Reference to lines in the file. -1 to unset.
+ int start_line;
+ int end_line;
- // if the message have children, show them?
- public bool expand;
+ // If the message have children, whether to show them.
+ bool expand;
+
+ public BuildMsg ()
+ {
+ type = BuildMsgType.INFO;
+ text = null;
+ filename = null;
+ start_line = -1;
+ end_line = -1;
+ expand = true;
+ }
}
public class BuildView : TreeView
@@ -202,26 +212,28 @@ public class BuildView : TreeView
);
if (file != null)
- jump_to_file (file, start_line, end_line);
+ {
+ if (start_line == -1)
+ _main_window.open_document (file);
+ else
+ jump_to_file_lines (file, start_line, end_line);
+ }
// the row is selected, so we can copy/paste its content
return true;
}
- private void jump_to_file (File file, int start_line, int end_line)
+ private void jump_to_file_lines (File file, int start_line, int end_line)
{
+ return_if_fail (start_line >= 0 && end_line >= 0);
+
DocumentTab tab = _main_window.open_document (file);
- // If the file was not yet opened, it takes some time. If we try to select the
- // lines when the file is not fully charged, the lines are simply not selected.
+ // Ensure that the file is fully loaded before selecting the lines.
Utils.flush_queue ();
- if (start_line != -1)
- {
- // start_line and end_line begins at 1, but select_lines() begins at 0
- int end = end_line != -1 ? end_line - 1 : start_line;
- tab.document.select_lines (start_line - 1, end);
- }
+ // start_line and end_line begins at 1, but select_lines() begins at 0
+ tab.document.select_lines (start_line - 1, end_line - 1);
}
public void clear ()
@@ -280,41 +292,39 @@ public class BuildView : TreeView
this.expand_row (_store.get_path (parent), false);
}
- public TreeIter append_single_message (TreeIter parent, BuildMsg message)
+ public TreeIter append_single_message (TreeIter parent, BuildMsg msg)
{
File file = null;
string path = null;
- if (message.filename != null)
+ if (msg.filename != null)
{
- file = File.new_for_path (message.filename);
- path = Utils.replace_home_dir_with_tilde (message.filename);
+ file = File.new_for_path (msg.filename);
+ path = Utils.replace_home_dir_with_tilde (msg.filename);
// the path is displayed in a tooltip
path = Markup.escape_text (path);
}
- int start_line = -1;
- int end_line = -1;
- string line_str = null;
- if (message.lines_set)
- {
- start_line = message.start_line;
- end_line = message.end_line;
- line_str = start_line.to_string ();
- }
+ string? line_str = null;
+ if (msg.start_line != -1)
+ line_str = msg.start_line.to_string ();
+
+ int end_line = msg.end_line;
+ if (end_line == -1)
+ end_line = msg.start_line;
TreeIter iter;
_store.append (out iter, parent);
_store.set (iter,
- BuildMsgColumn.ICON, get_icon_from_msg_type (message.type),
- BuildMsgColumn.MESSAGE, message.text,
- BuildMsgColumn.MESSAGE_TYPE, message.type,
+ BuildMsgColumn.ICON, get_icon_from_msg_type (msg.type),
+ BuildMsgColumn.MESSAGE, msg.text,
+ BuildMsgColumn.MESSAGE_TYPE, msg.type,
BuildMsgColumn.WEIGHT, 400,
BuildMsgColumn.BASENAME, file != null ? file.get_basename () : null,
BuildMsgColumn.FILE, file,
BuildMsgColumn.PATH, path,
- BuildMsgColumn.START_LINE, start_line,
+ BuildMsgColumn.START_LINE, msg.start_line,
BuildMsgColumn.END_LINE, end_line,
BuildMsgColumn.LINE_STR, line_str
);
diff --git a/src/latex_post_processor.vala b/src/latex_post_processor.vala
index f74eeb1..384873d 100644
--- a/src/latex_post_processor.vala
+++ b/src/latex_post_processor.vala
@@ -91,7 +91,7 @@ private class LatexPostProcessor : PostProcessor
public LatexPostProcessor ()
{
- reset_msg ();
+ msg = BuildMsg ();
if (reg_badbox != null)
return;
@@ -791,7 +791,7 @@ private class LatexPostProcessor : PostProcessor
if (msg.type == BuildMsgType.WARNING
&& msg.text == "There were undefined references.")
{
- reset_msg ();
+ msg = BuildMsg ();
return;
}
@@ -824,21 +824,7 @@ private class LatexPostProcessor : PostProcessor
break;
}
- if (msg.start_line != NO_LINE)
- msg.lines_set = true;
-
append_message (msg);
- reset_msg ();
- }
-
- private void reset_msg ()
- {
msg = BuildMsg ();
- msg.text = null;
- msg.type = BuildMsgType.INFO;
- msg.filename = null;
- msg.start_line = NO_LINE;
- msg.end_line = NO_LINE;
- msg.lines_set = false;
}
}
diff --git a/src/post_processors.vala b/src/post_processors.vala
index 4cbcc7d..007bfc6 100644
--- a/src/post_processors.vala
+++ b/src/post_processors.vala
@@ -83,9 +83,6 @@ private class AllOutputPostProcessor : PostProcessor
nb_lines--;
BuildMsg message = BuildMsg ();
- message.type = BuildMsgType.INFO;
- message.filename = null;
- message.lines_set = false;
for (int line_num = 0 ; line_num < nb_lines ; line_num++)
{
@@ -131,21 +128,20 @@ private class RubberPostProcessor : PostProcessor
// message type
message.type = BuildMsgType.ERROR;
- if (message.text.contains ("Underfull") || message.text.contains ("Overfull"))
+ if (message.text.contains ("Underfull") ||
+ message.text.contains ("Overfull"))
+ {
message.type = BuildMsgType.BADBOX;
+ }
// line
- message.lines_set = false;
string? line = match_info.fetch_named ("line");
if (line != null && 0 < line.length)
{
- message.lines_set = true;
string[] parts = line.split ("-");
message.start_line = int.parse (parts[0]);
if (1 < parts.length && parts[1] != null && 0 < parts[1].length)
message.end_line = int.parse (parts[1]);
- else
- message.end_line = -1;
}
// filename
@@ -246,7 +242,6 @@ private class LatexmkPostProcessor : PostProcessor
/* title */
BuildMsg title_msg = BuildMsg ();
title_msg.type = BuildMsgType.JOB_SUB_COMMAND;
- title_msg.lines_set = false;
title_msg.text = match_info.fetch_named ("title");
// Do not expand the row, so the user have first a global view of what have
@@ -257,8 +252,6 @@ private class LatexmkPostProcessor : PostProcessor
/* command line */
BuildMsg cmd_line_msg = BuildMsg ();
- cmd_line_msg.type = BuildMsgType.INFO;
- cmd_line_msg.lines_set = false;
cmd_line_msg.text = "$ " + match_info.fetch_named ("cmd");
cmd_messages.insert_data (0, cmd_line_msg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]