Use default emacs-style filter
parent
60aae898d7
commit
c18eff8ab2
|
@ -1,44 +1,60 @@
|
|||
<filter id="bison" name="Bison">
|
||||
<match what="stderr" pattern="(?P<file>[^:]+):(?P<line>\d+)\.(\d+|\d+\-\d+):"/>
|
||||
</filter>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<medit-filters version="1.0">
|
||||
<!-- Output filter for shell commands -->
|
||||
<filter id="default" _name="Filter|Default">
|
||||
<match what="stdout" pattern="^(?P<file>[^:]+):(?P<line>\d+)?"/>
|
||||
<match what="stderr" pattern="^(?P<file>[^:]+):(?P<line>\d+)?"/>
|
||||
</filter>
|
||||
|
||||
<filter id="python" name="Python">
|
||||
<match what="stderr" pattern='\s*File\s*\"(?P<file>[^"]+)\",\s*line\s*(?P<line>\d+).*' style="output-error"/>
|
||||
<match what="stderr" pattern='\s*(?P<file>[^:]+):(?P<line>\d+):.*' style="output-error"/>
|
||||
</filter>
|
||||
<!-- Output filter for shell commands -->
|
||||
<filter id="none" _name="Filter|None"/>
|
||||
|
||||
<filter id="latex" name="LaTeX">
|
||||
<match what="stdout" pattern="^l\.(?P<line>\d+)" style="output-error" span="2"/>
|
||||
<match what="stdout" pattern="^LaTeX Warning: .* on input line (?P<line>\d+)\." style="output-error"/>
|
||||
<match what="stdout" pattern="^(Over|Under)full \\[vh]box .* detected at line (?P<line>\d+)" style="output-error"/>
|
||||
<match what="stdout" pattern="^(Over|Under)full \\[vh]box .* in paragraph at lines (?P<line>\d+)\-\-\d+" style="output-error"/>
|
||||
<match what="stdout" pattern="^LaTeX Warning: .*" style="output-error"/>
|
||||
<match what="stdout" pattern="^\! LaTeX Error: .*" style="output-error"/>
|
||||
<match what="stdout" pattern="\((?P<file>[/.][^\(\)\s]+)">
|
||||
<action type="push" name="file" substring="file"/>
|
||||
</match>
|
||||
<match what="stdout" pattern="\(">
|
||||
<action type="push" name="file"/>
|
||||
</match>
|
||||
<match what="stdout" pattern="\)">
|
||||
<action type="pop" name="file"/>
|
||||
</match>
|
||||
</filter>
|
||||
<!-- Output filter for shell commands -->
|
||||
<filter id="bison" _name="Filter|Bison">
|
||||
<match what="stderr" pattern="(?P<file>[^:]+):(?P<line>\d+)\.(\d+|\d+\-\d+):"/>
|
||||
</filter>
|
||||
|
||||
<filter id="make" name="Make">
|
||||
<match what="stderr" pattern=".* from (?P<file>[^:]+):(?P<line>\d+)[:,].*" style="output-error"/>
|
||||
<match what="stderr" pattern="(?P<file>[^:]+):(?P<line>\d+):(\d+:)?\s*(?:error|warning)\s*:.*" style="output-error"/>
|
||||
<match what="stderr" pattern="(?P<file>[^:]+):(?P<line>\d+):.*" style="output-error"/>
|
||||
<match what="stderr" pattern="(?P<file>[^:]+):(?P<line>\d+).\d+-\d+:.*" style="output-error"/>
|
||||
<!-- Output filter for shell commands -->
|
||||
<filter id="python" _name="Filter|Python">
|
||||
<match what="stderr" pattern='\s*File\s*\"(?P<file>[^"]+)\",\s*line\s*(?P<line>\d+).*' style="output-error"/>
|
||||
<match what="stderr" pattern='\s*(?P<file>[^:]+):(?P<line>\d+):.*' style="output-error"/>
|
||||
</filter>
|
||||
|
||||
<match what="stderr" pattern="(?P<file>[^:]+)\((?P<line>\d+)\):(\d+:)?\s*(error|warning|remark).*" style="output-error"/>
|
||||
<!-- Output filter for shell commands -->
|
||||
<filter id="latex" _name="Filter|LaTeX">
|
||||
<match what="stdout" pattern="^l\.(?P<line>\d+)" style="output-error" span="2"/>
|
||||
<match what="stdout" pattern="^LaTeX Warning: .* on input line (?P<line>\d+)\." style="output-error"/>
|
||||
<match what="stdout" pattern="^(Over|Under)full \\[vh]box .* detected at line (?P<line>\d+)" style="output-error"/>
|
||||
<match what="stdout" pattern="^(Over|Under)full \\[vh]box .* in paragraph at lines (?P<line>\d+)\-\-\d+" style="output-error"/>
|
||||
<match what="stdout" pattern="^LaTeX Warning: .*" style="output-error"/>
|
||||
<match what="stdout" pattern="^\! LaTeX Error: .*" style="output-error"/>
|
||||
<match what="stdout" pattern="\((?P<file>[/.][^\(\)\s]+)">
|
||||
<action type="push" name="file" substring="file"/>
|
||||
</match>
|
||||
<match what="stdout" pattern="\(">
|
||||
<action type="push" name="file"/>
|
||||
</match>
|
||||
<match what="stdout" pattern="\)">
|
||||
<action type="pop" name="file"/>
|
||||
</match>
|
||||
</filter>
|
||||
|
||||
<match what="stderr" pattern="\s+File "(?P<file>[^"]+)", line (?P<line>\d+).*" style="output-error"/>
|
||||
<!-- Output filter for shell commands -->
|
||||
<filter id="make" _name="Filter|Make">
|
||||
<match what="stderr" pattern=".* from (?P<file>[^:]+):(?P<line>\d+)[:,].*" style="output-error"/>
|
||||
<match what="stderr" pattern="(?P<file>[^:]+):(?P<line>\d+):(\d+:)?\s*(?:error|warning)\s*:.*" style="output-error"/>
|
||||
<match what="stderr" pattern="(?P<file>[^:]+):(?P<line>\d+):.*" style="output-error"/>
|
||||
<match what="stderr" pattern="(?P<file>[^:]+):(?P<line>\d+).\d+-\d+:.*" style="output-error"/>
|
||||
|
||||
<match what="stdout" pattern="^g?make\[\d+\]: Entering directory `(?P<dir>.*)'">
|
||||
<action type="push" name="directory" substring="dir"/>
|
||||
</match>
|
||||
<match what="stdout" pattern="^g?make\[\d+\]: Leaving directory">
|
||||
<action type="pop" name="directory"/>
|
||||
</match>
|
||||
</filter>
|
||||
<match what="stderr" pattern="(?P<file>[^:]+)\((?P<line>\d+)\):(\d+:)?\s*(error|warning|remark).*" style="output-error"/>
|
||||
|
||||
<match what="stderr" pattern="\s+File "(?P<file>[^"]+)", line (?P<line>\d+).*" style="output-error"/>
|
||||
|
||||
<match what="stdout" pattern="^g?make\[\d+\]: Entering directory `(?P<dir>.*)'">
|
||||
<action type="push" name="directory" substring="dir"/>
|
||||
</match>
|
||||
<match what="stdout" pattern="^g?make\[\d+\]: Leaving directory">
|
||||
<action type="pop" name="directory"/>
|
||||
</match>
|
||||
</filter>
|
||||
</medit-filters>
|
||||
|
|
|
@ -259,8 +259,10 @@ run_in_pane (MooEditWindow *window,
|
|||
moo_edit_window_present_output (window);
|
||||
gtk_widget_grab_focus (output);
|
||||
|
||||
if (filter_id)
|
||||
filter = moo_command_filter_create (filter_id);
|
||||
if (!filter_id)
|
||||
filter_id = "default";
|
||||
|
||||
filter = moo_command_filter_create (filter_id);
|
||||
|
||||
if (filter)
|
||||
{
|
||||
|
@ -873,10 +875,6 @@ init_filter_combo (GtkComboBox *combo)
|
|||
|
||||
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
/* Translators: "None" means no output filter for a shell command, do not translate the part before | */
|
||||
gtk_list_store_set (store, &iter, COLUMN_NAME, Q_("Filter|None"), -1);
|
||||
|
||||
ids = moo_command_filter_list ();
|
||||
|
||||
while (ids)
|
||||
|
@ -897,7 +895,7 @@ init_filter_combo (GtkComboBox *combo)
|
|||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_ID, id,
|
||||
COLUMN_NAME, _(name),
|
||||
COLUMN_NAME, name,
|
||||
-1);
|
||||
|
||||
g_free (id);
|
||||
|
@ -923,7 +921,7 @@ set_filter_combo (GtkComboBox *combo,
|
|||
return;
|
||||
}
|
||||
|
||||
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, 1))
|
||||
if (gtk_tree_model_get_iter_first (model, &iter))
|
||||
{
|
||||
do {
|
||||
char *id_here;
|
||||
|
|
|
@ -68,6 +68,7 @@ struct _MooCommandData {
|
|||
};
|
||||
|
||||
typedef struct {
|
||||
char *id;
|
||||
char *name;
|
||||
MooCommandFilterFactory factory_func;
|
||||
gpointer data;
|
||||
|
@ -1410,6 +1411,7 @@ moo_command_filter_register (const char *id,
|
|||
}
|
||||
|
||||
info = g_new0 (FilterInfo, 1);
|
||||
info->id = g_strdup (id);
|
||||
info->name = g_strdup (name);
|
||||
info->factory_func = factory_func;
|
||||
info->data = data;
|
||||
|
@ -1440,6 +1442,7 @@ moo_command_filter_unregister (const char *id)
|
|||
info->data_notify (info->data);
|
||||
|
||||
g_free (info->name);
|
||||
g_free (info->id);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
|
@ -1458,22 +1461,48 @@ moo_command_filter_lookup (const char *id)
|
|||
|
||||
|
||||
static void
|
||||
prepend_filter_id (const char *id,
|
||||
G_GNUC_UNUSED gpointer info,
|
||||
GSList **list)
|
||||
prepend_filter_info (G_GNUC_UNUSED const char *id,
|
||||
FilterInfo *info,
|
||||
GSList **list)
|
||||
{
|
||||
*list = g_slist_prepend (*list, g_strdup (id));
|
||||
*list = g_slist_prepend (*list, info);
|
||||
}
|
||||
|
||||
static int
|
||||
compare_filter_names (FilterInfo *fi1,
|
||||
FilterInfo *fi2)
|
||||
{
|
||||
if (strcmp (fi1->id, "default") == 0)
|
||||
return -1;
|
||||
else if (strcmp (fi2->id, "default") == 0)
|
||||
return 1;
|
||||
else if (strcmp (fi1->id, "none") == 0)
|
||||
return -1;
|
||||
else if (strcmp (fi2->id, "none") == 0)
|
||||
return 1;
|
||||
else
|
||||
return g_utf8_collate (fi1->name, fi2->name);
|
||||
}
|
||||
|
||||
GSList *
|
||||
moo_command_filter_list (void)
|
||||
{
|
||||
GSList *list = NULL;
|
||||
GSList *ids = NULL;
|
||||
|
||||
if (registered_filters)
|
||||
g_hash_table_foreach (registered_filters, (GHFunc) prepend_filter_id, &list);
|
||||
g_hash_table_foreach (registered_filters, (GHFunc) prepend_filter_info, &list);
|
||||
|
||||
return list;
|
||||
list = g_slist_sort (list, (GCompareFunc) compare_filter_names);
|
||||
|
||||
while (list)
|
||||
{
|
||||
FilterInfo *fi = list->data;
|
||||
ids = g_slist_prepend (ids, g_strdup (fi->id));
|
||||
list = g_slist_delete_link (list, list);
|
||||
}
|
||||
|
||||
return g_slist_reverse (ids);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,15 +19,21 @@
|
|||
#include "mooutils/mooutils-gobject.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
#include "mooutils/moomarkup.h"
|
||||
#include "mooutils/mooi18n.h"
|
||||
#include <glib/gregex.h>
|
||||
#include <string.h>
|
||||
|
||||
#define FILTERS_VERSION "1.0"
|
||||
|
||||
#define FILTERS_FILE "filters.xml"
|
||||
#define ELEMENT_ROOT "medit-filters"
|
||||
#define ELEMENT_FILTER "filter"
|
||||
#define ELEMENT_MATCH "match"
|
||||
#define ELEMENT_ACTION "action"
|
||||
#define PROP_VERSION "version"
|
||||
#define PROP_FILTER_ID "id"
|
||||
#define PROP_FILTER_NAME "name"
|
||||
#define PROP_FILTER__NAME "_name"
|
||||
#define PROP_OUTPUT_TYPE "what"
|
||||
#define PROP_SPAN "span"
|
||||
#define PROP_PATTERN "pattern"
|
||||
|
@ -927,12 +933,14 @@ parse_filter_node (MooMarkupNode *elm,
|
|||
{
|
||||
const char *id;
|
||||
const char *name;
|
||||
const char *_name;
|
||||
FilterInfo *info;
|
||||
GSList *patterns = NULL;
|
||||
MooMarkupNode *child;
|
||||
|
||||
id = moo_markup_get_prop (elm, PROP_FILTER_ID);
|
||||
name = moo_markup_get_prop (elm, PROP_FILTER_NAME);
|
||||
_name = moo_markup_get_prop (elm, PROP_FILTER__NAME);
|
||||
|
||||
if (!id || !id[0])
|
||||
{
|
||||
|
@ -940,7 +948,11 @@ parse_filter_node (MooMarkupNode *elm,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!name || !name[0])
|
||||
if (_name && _name[0])
|
||||
{
|
||||
name = Q_(_name);
|
||||
}
|
||||
else if (!name || !name[0])
|
||||
{
|
||||
g_warning ("in file %s: filter name missing", file);
|
||||
return NULL;
|
||||
|
@ -983,7 +995,7 @@ static void
|
|||
parse_filter_file (const char *file)
|
||||
{
|
||||
MooMarkupDoc *doc;
|
||||
MooMarkupNode *node;
|
||||
MooMarkupNode *root, *node;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_file_test (file, G_FILE_TEST_EXISTS))
|
||||
|
@ -998,7 +1010,26 @@ parse_filter_file (const char *file)
|
|||
return;
|
||||
}
|
||||
|
||||
for (node = doc->children; node != NULL; node = node->next)
|
||||
root = moo_markup_get_root_element (doc, ELEMENT_ROOT);
|
||||
|
||||
if (root)
|
||||
{
|
||||
const char *version = moo_markup_get_prop (root, PROP_VERSION);
|
||||
|
||||
if (!version || strcmp (version, FILTERS_VERSION) != 0)
|
||||
{
|
||||
g_warning ("in file %s: invalid version '%s'",
|
||||
file, version ? version : "(null)");
|
||||
moo_markup_doc_unref (doc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
root = MOO_MARKUP_NODE (doc);
|
||||
}
|
||||
|
||||
for (node = root->children; node != NULL; node = node->next)
|
||||
{
|
||||
FilterInfo *info;
|
||||
|
||||
|
|
Loading…
Reference in New Issue