Last active
August 29, 2015 14:21
-
-
Save b4n/eceff3c39f4c825c1106 to your computer and use it in GitHub Desktop.
Geany disabled C preprocessor highlighter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2015 Colomban Wendling <[email protected]> | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
#include <glib.h> | |
#include <geanyplugin.h> | |
#include <SciLexer.h> | |
GeanyPlugin *geany_plugin; | |
GeanyData *geany_data; | |
GeanyFunctions *geany_functions; | |
PLUGIN_VERSION_CHECK (211) /* FIXME */ | |
PLUGIN_SET_INFO ("C Proprocessor highlight", "Highlights disabled C code", | |
"0.1", "Colomban Wendling <[email protected]>") | |
#define BG_COLOR_ADD -0x111111 | |
#define FG_COLOR_ADD +0x333333 | |
#define ACTIVITY_FLAG 0x40 /* see LexCPP */ | |
static void on_filetype_set (GObject *obj, | |
GeanyDocument *doc, | |
GeanyFiletype *filetype_old, | |
gpointer user_data) | |
{ | |
sptr_t lexer = scintilla_send_message (doc->editor->sci, SCI_GETLEXER, 0, 0); | |
if (lexer == SCLEX_CPP) { | |
uptr_t i; | |
for (i = 0; i < ACTIVITY_FLAG; i++) { | |
sptr_t v; | |
v = scintilla_send_message (doc->editor->sci, SCI_STYLEGETBACK, i, 0); | |
scintilla_send_message (doc->editor->sci, SCI_STYLESETBACK, | |
i | ACTIVITY_FLAG, v + BG_COLOR_ADD); | |
v = scintilla_send_message (doc->editor->sci, SCI_STYLEGETFORE, i, 0); | |
scintilla_send_message (doc->editor->sci, SCI_STYLESETFORE, | |
i | ACTIVITY_FLAG, v + FG_COLOR_ADD); | |
#define COPY_SCI_STYLE(which) \ | |
v = scintilla_send_message (doc->editor->sci, SCI_STYLEGET##which, i, 0); \ | |
scintilla_send_message (doc->editor->sci, SCI_STYLESET##which, \ | |
i | ACTIVITY_FLAG, v); | |
COPY_SCI_STYLE (BOLD) | |
COPY_SCI_STYLE (ITALIC) | |
COPY_SCI_STYLE (SIZE) | |
COPY_SCI_STYLE (EOLFILLED) | |
COPY_SCI_STYLE (UNDERLINE) | |
COPY_SCI_STYLE (CASE) | |
COPY_SCI_STYLE (VISIBLE) | |
#undef COPY_SCI_STYLE | |
} | |
} | |
} | |
void plugin_init (GeanyData *data) | |
{ | |
plugin_signal_connect (geany_plugin, NULL, "document-filetype-set", TRUE, | |
G_CALLBACK (on_filetype_set), NULL); | |
} | |
void plugin_cleanup (void) | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/make -f | |
PLUGIN = c-preproc-hl | |
VPATH ?= . | |
# fetch from https://github.com/b4n/geany-plugin.mk | |
include $(VPATH)/geany-plugin.mk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment