Skip to content

Instantly share code, notes, and snippets.

View codebrainz's full-sized avatar

Matthew Brush codebrainz

View GitHub Profile
@codebrainz
codebrainz / listdeps.py
Last active August 29, 2015 14:12
Getting a list of header dependencies using GCC -MM
#!/usr/bin/env python3
import argparse
import json
import re
import sys
from collections import OrderedDict
from subprocess import Popen, PIPE
RE_INC = re.compile(r'^(?P<target>.+?):\s+(?P<deps>.+?)$', re.MULTILINE)
@codebrainz
codebrainz / gist:69b8df344481b51112c5
Last active August 29, 2015 14:13
Run build system when sources change
#!/bin/bash
# Inspired by: https://exyr.org/2011/inotify-run/
# base source dir, found from script's dir, in my case it's `..` to the base srcdir
SRCDIR=$(cd "$(dirname $(dirname "$0"))"; pwd -P)
# command to run initially and on file changes, in my case in `build` dir
COMMAND="make -C $SRCDIR/build"
@codebrainz
codebrainz / gist:95681f9d30937359f6f5
Last active August 29, 2015 14:16
Make "hunting for Scintilla" a little more robust
diff --git a/src/document.c b/src/document.c
index 8a57d93..edaed0d 100644
--- a/src/document.c
+++ b/src/document.c
@@ -226,16 +226,8 @@ GeanyDocument *document_find_by_filename(const gchar *utf8_filename)
/* returns the document which has sci, or NULL. */
GeanyDocument *document_find_by_sci(ScintillaObject *sci)
{
- guint i;
-
AC_DEFUN([AX_POSIX], [
AC_MSG_CHECKING([for POSIX 2008 support])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#define _POSIX_C_SOURCE 200809L
#include <unistd.h>
# if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L
# error "Not POSIX 2008"
#endif
int main() { return 0; }
])], [
@codebrainz
codebrainz / newwin_dynamic.patch
Created July 28, 2015 01:03
Fix "Open in New Window" feature
diff --git a/src/utils.c b/src/utils.c
index c5edd5a..37ae12a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -2154,30 +2154,35 @@ const gchar *utils_resource_dir(GeanyResourceDirType type)
void utils_start_new_geany_instance(const gchar *doc_path)
{
- const gchar *const *argv;
const gchar *command = is_osx_bundle() ? "open" : "geany";
@codebrainz
codebrainz / "Open in a New Tab" for Geany
Created November 22, 2010 23:14
Patch for notebook.c file in Geany to add an item to open the file in a new instance of Geany to the tabs' right-click menu when the tab contains a saved file.
--- geany-svn/src/notebook.c 2010-11-21 20:53:12.943333841 -0800
+++ geany-local/src/notebook.c 2010-11-21 20:54:20.836667216 -0800
@@ -193,10 +193,35 @@
}
+static void on_open_in_new_window_activate(GtkMenuItem *menuitem, gpointer user_data)
+{
+ gchar **argv;
+ gchar *doc_path;
/* large portions of this were taken from Geany's source code */
#include "geanyplugin.h"
#include <math.h>
GeanyPlugin *geany_plugin;
GeanyData *geany_data;
GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(147)
@codebrainz
codebrainz / persistent_gtk_notebooks.py
Created March 22, 2011 01:34
Test code to try and save and restore tabs inside two notebooks, including which notebook and order.
#!/usr/bin/env python
"""
Demo for storing tabs inside two detachable and re-orderable notebooks
to disk on close and reloading them in the correct notebook and in
order on load.
"""
import gtk
from ConfigParser import SafeConfigParser
diff --git a/plugins/splitwindow.c b/plugins/splitwindow.c
index ff67508..f5a2d8c 100644
--- a/plugins/splitwindow.c
+++ b/plugins/splitwindow.c
@@ -307,14 +307,25 @@ static void split_view(gboolean horizontal)
set_state(horizontal ? STATE_SPLIT_HORIZONTAL : STATE_SPLIT_VERTICAL);
+#ifndef G_OS_WIN32
/* temporarily put document notebook in main vbox (scintilla widgets must stay
@codebrainz
codebrainz / 0001-Add-basic-support-for-loading-binary-files.patch
Created May 11, 2011 00:56
Add basic support for loading binary files.
From 696cc02fa371f75390a6dc28f1551faf34759df0 Mon Sep 17 00:00:00 2001
From: Matthew Brush <matthewbrush(at)gmail(dot)com>
Date: Tue, 10 May 2011 16:53:21 -0700
Subject: [PATCH] Add basic support for loading binary files.
Read the entire file instead of only to the first nul byte, then,
if converting it to UTF-8 fails, assume it's binary, make it read-only,
warn the user and set the text in Scintilla anyway.
Add sci_set_text2() function (terrible name) to support setting