Skip to content

Instantly share code, notes, and snippets.

View codebrainz's full-sized avatar

Matthew Brush codebrainz

View GitHub Profile
@codebrainz
codebrainz / gist:1009404
Created June 5, 2011 20:44
On the fly tarball creation CGI script.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# archive.py
#
# Copyright 2011 Matthew Brush <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@codebrainz
codebrainz / ai-test.c
Created June 20, 2011 23:53
Why no "query-tooltip" signal with AppIndicator?
#include <gtk/gtk.h>
#include <libappindicator/app-indicator.h>
static void on_status_icon_activate(GtkStatusIcon *status_icon, GtkMenu *menu)
{
gtk_menu_popup(menu, NULL, NULL, gtk_status_icon_position_menu, status_icon,
0, gtk_get_current_event_time());
}
@codebrainz
codebrainz / gist:1223591
Created September 17, 2011 03:21
support embedded languages
diff --git a/src/editor.c b/src/editor.c
index b8419a0..516c919 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -378,6 +378,17 @@ static gboolean is_style_php(gint style)
}
+static gboolean is_style_js(gint style)
+{
@codebrainz
codebrainz / gist:1263776
Created October 5, 2011 06:15
Cleanup trailing spaces
#!/usr/bin/env python
import sys
filenames = sys.argv[1:]
def backup_file (fn):
open ("%s~" % fn, "w").write (open (fn, "r").read ())
for fn in filenames:
@codebrainz
codebrainz / gist:1288896
Created October 15, 2011 02:08
Guess the line-endings mode of a text buffer
typedef enum
{
LINE_END_MODE_CR,
LINE_END_MODE_LF,
LINE_END_MODE_CRLF
}
LineEndMode;
LineEndMode guess_line_endings(const char* buffer, size_t size)
{
diff --git a/src/utils.c b/src/utils.c
index cd06641..ff52a13 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -103,6 +103,7 @@ void utils_open_browser(const gchar *uri)
/* taken from anjuta, to determine the EOL mode of the file */
gint utils_get_line_endings(const gchar* buffer, gsize size)
{
+# define MAX_LINES 10
gsize i;
@codebrainz
codebrainz / gist:1290680
Created October 16, 2011 08:54
Use `document_update_highlighting()` in favour of `update_type_keywords()`
diff --git a/src/document.c b/src/document.c
index 57d5881..cdd8015 100644
--- a/src/document.c
+++ b/src/document.c
@@ -2384,69 +2384,6 @@ static gboolean get_project_typenames(const GString **types, gint lang)
}
-/* If sci is NULL, update project typenames for all documents that support typenames,
- * if typenames have changed.
@codebrainz
codebrainz / gist:1292214
Created October 17, 2011 08:43
Setting GtkInfoBarColors
gtk_rc_parse_string(
"style \"infobar-style\" {\n"
" color[\"info_bg_color\"] = \"" DEFAULT_BG_COLOR "\"\n"
" color[\"info_fg_color\"] = \"" DEFAULT_FG_COLOR "\"\n"
" color[\"warning_bg_color\"] = \"" DEFAULT_BG_COLOR "\"\n"
" color[\"warning_fg_color\"] = \"" DEFAULT_FG_COLOR "\"\n"
" color[\"question_bg_color\"] = \"" DEFAULT_BG_COLOR "\"\n"
" color[\"question_fg_color\"] = \"" DEFAULT_FG_COLOR "\"\n"
" color[\"error_bg_color\"] = \"" DEFAULT_BG_COLOR "\"\n"
" color[\"error_fg_color\"] = \"" DEFAULT_FG_COLOR "\"\n"
@codebrainz
codebrainz / gist:1325346
Created October 30, 2011 01:36
Geany ChangeLog, AUTHORS & COMMITTERS from Git log
#!/usr/bin/env python
'''
Helper script for Geany's distribution files generated by Git.
TODO: Use .mailmap or other means to use preferred name and emails.
'''
AUTHORS_HEADER = 'The following people have authored commits:\n'
AUTHORS_FOOTER = '''\nSee the COMMITTERS, ChangeLog and THANKS files for \
@codebrainz
codebrainz / gist:1332289
Created November 1, 2011 23:40
Remove editor_lexer_get_type_keyword_idx()
diff --git a/HACKING b/HACKING
index a50c179..420eaa8 100644
--- a/HACKING
+++ b/HACKING
@@ -458,9 +458,6 @@ this prevents calltips and autocompletion when typing in a comment
For brace indentation, update lexer_has_braces() in editor.c;
indentation after ':' is done from on_new_line_added().
-If the Scintilla lexer supports user type keyword highlighting (e.g.
-SCLEX_CPP), update editor_lexer_get_type_keyword_idx() in editor.c.