about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.c15
-rw-r--r--src/common.h1
-rw-r--r--src/event/server_events.c11
3 files changed, 17 insertions, 10 deletions
diff --git a/src/common.c b/src/common.c
index 050fc2b7..c056d167 100644
--- a/src/common.c
+++ b/src/common.c
@@ -510,3 +510,18 @@ get_random_string(int length)
 
     return rand;
 }
+
+GSList*
+get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const message, const char *const nick)
+{
+    GSList *mentions = NULL;
+    char *message_search = case_sensitive ? strdup(message) : g_utf8_strdown(message, -1);
+    char *mynick_search = case_sensitive ? strdup(nick) : g_utf8_strdown(nick, -1);
+
+    mentions = prof_occurrences(mynick_search, message_search, 0, whole_word, &mentions);
+
+    g_free(message_search);
+    g_free(mynick_search);
+
+    return mentions;
+}
diff --git a/src/common.h b/src/common.h
index 1681d4ab..6924d935 100644
--- a/src/common.h
+++ b/src/common.h
@@ -99,6 +99,7 @@ gboolean is_notify_enabled(void);
 
 GSList* prof_occurrences(const char *const needle, const char *const haystack, int offset, gboolean whole_word,
     GSList **result);
+GSList* get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const message, const char *const nick);
 
 int is_regular_file(const char *path);
 int is_dir(const char *path);
diff --git a/src/event/server_events.c b/src/event/server_events.c
index e8f11aa3..2272016c 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -319,17 +319,8 @@ sv_ev_room_message(ProfMessage *message)
     char *old_plain = message->plain;
     message->plain = plugins_pre_room_message_display(message->jid->barejid, message->jid->resourcepart, message->plain);
 
-    gboolean whole_word = prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD);
-    gboolean case_sensitive = prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE);
-    char *message_search = case_sensitive ? strdup(message->plain) : g_utf8_strdown(message->plain, -1);
-    char *mynick_search = case_sensitive ? strdup(mynick) : g_utf8_strdown(mynick, -1);
-
-    GSList *mentions = NULL;
-    mentions = prof_occurrences(mynick_search, message_search, 0, whole_word, &mentions);
+    GSList *mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick);
     gboolean mention = g_slist_length(mentions) > 0;
-    g_free(message_search);
-    g_free(mynick_search);
-
     GList *triggers = prefs_message_get_triggers(message->plain);
 
     _clean_incoming_message(message);
-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
Environment for learning programming using Mu: http://akkartik.name/post/mu

Run it from the `mu` directory:

  ```shell
  $ ./mu edit
  ```

This will load all the `.mu` files in this directory and then run the editor.
Press ctrl-c to quit. Press F4 to save your work (if a lesson/ directory
exists) and to run the contents of the sandbox editor on the right.

You can also run the tests for the environment:

  ```shell
  $ ./mu test edit
  ```

You can also load the files more explicitly by enumerating them all:

  ```shell
  $  ./mu edit/*.mu
  ```

This is handy if you want to run simpler versions of the editor so you can
stage your learning.

  ```shell
  $ ./mu edit/00[12]*.mu  # run a simple editor rather than the full environment
  ```

To see how the various 'layers' are organized, peek inside the individual
`.mu` files.