Skip to content

Commit

Permalink
Merge branch 'master' of github.com:geany/geany
Browse files Browse the repository at this point in the history
  • Loading branch information
eht16 committed Nov 13, 2011
2 parents 639e88a + 6cee28d commit 70f41f6
Show file tree
Hide file tree
Showing 18 changed files with 2,941 additions and 2,746 deletions.
46 changes: 29 additions & 17 deletions HACKING
Expand Up @@ -419,8 +419,8 @@ Programming languages should have:
* [build_settings] for commands to run.

For languages with a Scintilla lexer, there should be a [styling] section,
to correspond to the styles used in styleset_foo() in highlighting.c -
see below.
to correspond to the styles used in highlighting_styles_FOO[] in
highlightingmappings.h - see below.

Syntax highlighting
^^^^^^^^^^^^^^^^^^^
Expand All @@ -440,21 +440,33 @@ When adding a lexer, update:
* wscript
* scintilla/KeyWords.cxx - add a LINK_LEXER command *manually*

For syntax highlighting, you will need to edit highlighting.c and add
the following things:

1. Write styleset_foo_init() to setup lexer styles and load style
settings from the filetypes.foo configuration file. You should probably
start by copying and adapting another filetype's initialization, such
as styleset_tcl_init(). You may want to use load_style_entries().
2. Write styleset_foo() to apply styles when a new scintilla widget
is created. Again you could copy and adapt a function like
styleset_tcl(). You may want to use apply_style_entries().
3. In highlighting_init_styles(), add
``init_styleset_case(GEANY_FILETYPES_FOO, styleset_foo_init);``.
4. In highlighting_set_styles(), add
``styleset_case(GEANY_FILETYPES_FOO, styleset_foo);``.
5. Write data/filetypes.foo configuration file [styling] section. See
For syntax highlighting, you will need to edit highlighting.c and
highlightingmappings.h and add the following things:

1. In highlightingmappings.h:

a. define ``highlighting_lexer_FOO`` to the Scintilla lexer ID for
this filtype, e.g. ``SCLEX_CPP``.
b. define the ``highlighting_styles_FOO`` array that maps Scintilla
style states to style names in the configuration file.
c. define ``highlighting_keywords_FOO`` to ``EMPTY_KEYWORDS`` if the
filtype has no keywords, or as an ``HLKeyword`` array mapping
the Scintilla keyword IDs to names in the configuration file.
d. define ``highlighting_properties_FOO`` to ``EMPTY_PROPERTIES``, or
as an array of ``HLProperty`` if the filetype requires some lexer
properties to be set. However, note that properties should
normally be set in the ``[lexer_properties]`` section of the
configuration file instead.

You may look at other filtype's definitions for some examples
(Ada, CSS or Diff being good examples).

2. In highlighting.c:

a. Add ``init_styleset_case(FOO);`` in ``highlighting_init_styles()``.
b. Add ``styleset_case(FOO);`` in ``highlighting_set_styles()``.

3. Write data/filetypes.foo configuration file [styling] section. See
the manual and see data/filetypes.d for a named style example.

.. note::
Expand Down
1 change: 1 addition & 0 deletions data/filetype_extensions.conf
Expand Up @@ -38,6 +38,7 @@ Make=*.mak;*.mk;GNUmakefile;makefile;Makefile;makefile.*;Makefile.*;
Markdown=*.mdml;*.markdown;*.md;*.mkd;
Matlab/Octave=*.m;
NSIS=*.nsi;*.nsh;
Objective-C=*.m;*.h;
Pascal=*.pas;*.pp;*.inc;*.dpr;*.dpk;
Perl=*.pl;*.perl;*.pm;*.agi;*.pod;
PHP=*.php;*.php3;*.php4;*.php5;*.phtml;
Expand Down
85 changes: 84 additions & 1 deletion data/filetypes.html
@@ -1,6 +1,89 @@
# For complete documentation of this file, please see Geany's main documentation
[styling]
# styling for PHP/HTML is done in filetypes.xml
# Edit these in the colorscheme .conf file instead
html_default=default
html_tag=tag
html_tagunknown=tag_unknown
html_attribute=attribute
html_attributeunknown=attribute_unknown
html_number=number_1
html_doublestring=string_1
html_singlestring=string_1
html_other=other
html_comment=comment
html_entity=entity
html_tagend=tag_end
html_xmlstart=tag
html_xmlend=tag_end
html_script=tag
html_asp=tag
html_aspat=tag
html_cdata=string_2
html_question=number_2
html_value=value
html_xccomment=comment

sgml_default=default
sgml_comment=comment
sgml_special=number_1
sgml_command=number_2
sgml_doublestring=string_1
sgml_simplestring=string_1
sgml_1st_param=attribute
sgml_entity=entity
sgml_block_default=default
sgml_1st_param_comment=comment
sgml_error=error

php_default=default
php_simplestring=string_1
php_hstring=string_1
php_number=number_1
php_word=keyword_1
php_variable=preprocessor
php_comment=comment
php_commentline=comment_line
php_operator=operator
php_hstring_variable=string_2
php_complex_variable=preprocessor

jscript_start=tag
jscript_default=default
jscript_comment=comment
jscript_commentline=comment_line
jscript_commentdoc=comment_doc
jscript_number=number_1
jscript_word=keyword_1
jscript_keyword=keyword_2
jscript_doublestring=string_1
jscript_singlestring=string_1

jscript_symbols=operator
jscript_stringeol=string_eol
jscript_regex=regex

python_default=default
python_commentline=comment_line
python_number=number_1
python_string=string_1
python_character=character
python_word=keyword_1
python_triple=string_2
python_tripledouble=string_2
python_classname=type
python_defname=function
python_operator=operator
python_identifier=identifier_1


[keywords]
html=a abbr acronym address applet area b base basefont bdo big blockquote body br button caption center cite code col colgroup dd del dfn dir div dl dt em embed fieldset font form frame frameset h1 h2 h3 h4 h5 h6 head hr html i iframe img input ins isindex kbd label legend li link map menu meta noframes noscript object ol optgroup option p param pre q quality s samp script select small span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var xmlns leftmargin topmargin abbr accept-charset accept accesskey action align alink alt archive axis background bgcolor border cellpadding cellspacing char charoff charset checked cite class classid clear codebase codetype color cols colspan compact content coords data datafld dataformatas datapagesize datasrc datetime declare defer dir disabled enctype face for frame frameborder selected headers height href hreflang hspace http-equiv id ismap label lang language link longdesc marginwidth marginheight maxlength media framespacing method multiple name nohref noresize noshade nowrap object onblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseover onmouseout onmouseup onreset onselect onsubmit onunload profile prompt pluginspage readonly rel rev rows rowspan rules scheme scope scrolling shape size span src standby start style summary tabindex target text title type usemap valign value valuetype version vlink vspace width text password checkbox radio submit reset file hidden image public doctype xml xml:lang article aside audio canvas command details datalist figure figcaption footer header hgroup keygen mark meter nav output progress section time video wbr async autocomplete autofocus contenteditable contextmenu draggable formaction formenctype formnovalidate formtarget list manifest max min novalidate pattern ping placeholder required reversed role sandbox scoped seamless sizes spellcheck srcdoc step ^data- ^aria-
javascript=abs abstract acos anchor asin atan atan2 big bold boolean break byte case catch ceil char charAt charCodeAt class concat const continue cos Date debugger default delete do double else enum escape eval exp export extends false final finally fixed float floor fontcolor fontsize for fromCharCode function goto if implements import in indexOf Infinity instanceof int interface isFinite isNaN italics join lastIndexOf length link log long Math max MAX_VALUE min MIN_VALUE NaN native NEGATIVE_INFINITY new null Number package parseFloat parseInt pop POSITIVE_INFINITY pow private protected public push random return reverse round shift short sin slice small sort splice split sqrt static strike string String sub substr substring sup super switch synchronized tan this throw throws toLowerCase toString toUpperCase transient true try typeof undefined unescape unshift valueOf var void volatile while with
vbscript=and as boolean byref byte byval call case class const continue currency date dim do double each else elseif empty end error exit false for function get global goto if in integer long loop me new next not nothing object on optional or private property public put redim rem resume select set single string sub then to true type until variant wend while with
python=and assert break class continue complex def del elif else except exec finally for from global if import in inherit is int lambda not or pass print raise return tuple try unicode while yield long float str list
php=abstract and array as bool boolean break case catch cfunction __class__ class clone const continue declare default die __dir__ directory do double echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exception exit extends false __file__ final float for foreach __function__ function goto global if implements include include_once instanceof int integer interface isset __line__ list __method__ namespace __namespace__ new null object old_function or parent php_user_filter print private protected public real require require_once resource return __sleep static stdclass string switch this throw true try unset use var __wakeup while xor insteadof trait
sgml=ELEMENT DOCTYPE ATTLIST ENTITY NOTATION


[lexer_properties]
# default scripting language for ASP
Expand Down
48 changes: 48 additions & 0 deletions data/filetypes.objectivec
@@ -0,0 +1,48 @@
# For complete documentation of this file, please see Geany's main documentation
[styling=C]

[keywords]
# all items must be in one line
primary=asm auto break case char const continue default do double else enum extern float for goto if inline int long register restrict return short signed sizeof static struct switch typedef union unsigned void volatile while FALSE NULL TRUE
secondary=@class @defs @dynamic @encode @end @implementation @interface @optional @package @public @private @property @protocol @protected @required @selector @synthesize @synchronized
# these are some doxygen keywords (incomplete)
docComment=attention author brief bug class code date def enum example exception file fn namespace note param remarks return see since struct throw todo typedef var version warning union

[lexer_properties=C]

[settings]
# default extension used when saving files
extension=m

# the following characters are these which a "word" can contains, see documentation
#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

# single comments, like # in this file
comment_single=//
# multiline comments
comment_open=/*
comment_close=*/

# set to false if a comment character/string should start at column 0 of a line, true uses any
# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d
#command_example();
# setting to false would generate this
# command_example();
# This setting works only for single line comments
comment_use_indent=true

# context action command (please see Geany's main documentation for details)
context_action_cmd=

[indentation]
#width=4
# 0 is spaces, 1 is tabs, 2 is tab & spaces
#type=1

[build_settings]
# %f will be replaced by the complete filename
# %e will be replaced by the filename without extension
# (use only one of it at one time)
compiler=gcc -Wall -c "%f"
linker=gcc -Wall -o "%e" "%f" -lobjc
run_cmd="./%e"
5 changes: 3 additions & 2 deletions data/filetypes.php
@@ -1,6 +1,7 @@
# For complete documentation of this file, please see Geany's main documentation
[styling]
# styling for PHP/HTML is done in filetypes.xml
[styling=HTML]

[keywords=HTML]

[lexer_properties]
phpscript.mode=1
Expand Down
72 changes: 2 additions & 70 deletions data/filetypes.xml
@@ -1,75 +1,7 @@
# For complete documentation of this file, please see Geany's main documentation
[styling]
# Edit these in the colorscheme .conf file instead
html_default=default
html_tag=tag
html_tagunknown=tag_unknown
html_attribute=attribute
html_attributeunknown=attribute_unknown
html_number=number_1
html_doublestring=string_1
html_singlestring=string_1
html_other=other
html_comment=comment
html_entity=entity
html_tagend=tag_end
html_xmlstart=tag
html_xmlend=tag_end
html_script=tag
html_asp=tag
html_aspat=tag
html_cdata=string_2
html_question=number_2
html_value=value
html_xccomment=comment

sgml_default=default
sgml_comment=comment
sgml_special=number_1
sgml_command=number_2
sgml_doublestring=string_1
sgml_simplestring=string_1
sgml_1st_param=attribute
sgml_entity=entity
sgml_block_default=default
sgml_1st_param_comment=comment
sgml_error=error

php_default=default
php_simplestring=string_1
php_hstring=string_1
php_number=number_1
php_word=keyword_1
php_variable=preprocessor
php_comment=comment
php_commentline=comment_line
php_operator=operator
php_hstring_variable=string_2
php_complex_variable=preprocessor

jscript_start=tag
jscript_default=default
jscript_comment=comment
jscript_commentline=comment_line
jscript_commentdoc=comment_doc
jscript_number=number_1
jscript_word=keyword_1
jscript_keyword=keyword_2
jscript_doublestring=string_1
jscript_singlestring=string_1

jscript_symbols=operator
jscript_stringeol=string_eol
jscript_regex=regex

[keywords]
html=a abbr acronym address applet area b base basefont bdo big blockquote body br button caption center cite code col colgroup dd del dfn dir div dl dt em embed fieldset font form frame frameset h1 h2 h3 h4 h5 h6 head hr html i iframe img input ins isindex kbd label legend li link map menu meta noframes noscript object ol optgroup option p param pre q quality s samp script select small span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var xmlns leftmargin topmargin abbr accept-charset accept accesskey action align alink alt archive axis background bgcolor border cellpadding cellspacing char charoff charset checked cite class classid clear codebase codetype color cols colspan compact content coords data datafld dataformatas datapagesize datasrc datetime declare defer dir disabled enctype face for frame frameborder selected headers height href hreflang hspace http-equiv id ismap label lang language link longdesc marginwidth marginheight maxlength media framespacing method multiple name nohref noresize noshade nowrap object onblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseover onmouseout onmouseup onreset onselect onsubmit onunload profile prompt pluginspage readonly rel rev rows rowspan rules scheme scope scrolling shape size span src standby start style summary tabindex target text title type usemap valign value valuetype version vlink vspace width text password checkbox radio submit reset file hidden image public doctype xml xml:lang article aside audio canvas command details datalist figure figcaption footer header hgroup keygen mark meter nav output progress section time video wbr async autocomplete autofocus contenteditable contextmenu draggable formaction formenctype formnovalidate formtarget list manifest max min novalidate pattern ping placeholder required reversed role sandbox scoped seamless sizes spellcheck srcdoc step ^data- ^aria-
javascript=abs abstract acos anchor asin atan atan2 big bold boolean break byte case catch ceil char charAt charCodeAt class concat const continue cos Date debugger default delete do double else enum escape eval exp export extends false final finally fixed float floor fontcolor fontsize for fromCharCode function goto if implements import in indexOf Infinity instanceof int interface isFinite isNaN italics join lastIndexOf length link log long Math max MAX_VALUE min MIN_VALUE NaN native NEGATIVE_INFINITY new null Number package parseFloat parseInt pop POSITIVE_INFINITY pow private protected public push random return reverse round shift short sin slice small sort splice split sqrt static strike string String sub substr substring sup super switch synchronized tan this throw throws toLowerCase toString toUpperCase transient true try typeof undefined unescape unshift valueOf var void volatile while with
vbscript=and as boolean byref byte byval call case class const continue currency date dim do double each else elseif empty end error exit false for function get global goto if in integer long loop me new next not nothing object on optional or private property public put redim rem resume select set single string sub then to true type until variant wend while with
python=and assert break class continue complex def del elif else except exec finally for from global if import in inherit is int lambda not or pass print raise return tuple try unicode while yield long float str list
php=abstract and array as bool boolean break case catch cfunction __class__ class clone const continue declare default die __dir__ directory do double echo else elseif empty enddeclare endfor endforeach endif endswitch endwhile eval exception exit extends false __file__ final float for foreach __function__ function goto global if implements include include_once instanceof int integer interface isset __line__ list __method__ namespace __namespace__ new null object old_function or parent php_user_filter print private protected public real require require_once resource return __sleep static stdclass string switch this throw true try unset use var __wakeup while xor insteadof trait
sgml=ELEMENT DOCTYPE ATTLIST ENTITY NOTATION
[styling=HTML]

[keywords=HTML]

[settings]
# default extension used when saving files
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Expand Up @@ -21,6 +21,7 @@ SRCS = \
geanyobject.c geanyobject.h \
geanywraplabel.c geanywraplabel.h \
highlighting.c highlighting.h \
highlightingmappings.h \
interface.c interface.h \
keybindings.c keybindings.h \
keyfile.c keyfile.h \
Expand Down
18 changes: 8 additions & 10 deletions src/dialogs.c
Expand Up @@ -167,19 +167,16 @@ static void open_file_dialog_handle_response(GtkWidget *dialog, gint response)
app->project->base_path, NULL);
}

#ifndef G_VALUE_INIT
#define G_VALUE_INIT { 0 }
#endif

static void on_file_open_notify(GObject *filechooser, GParamSpec *pspec, gpointer data)
static void on_file_open_show_hidden_notify(GObject *filechooser,
GParamSpec *pspec, gpointer data)
{
GValue value = G_VALUE_INIT;
GtkWidget *toggle_button;

g_value_init(&value, pspec->value_type);
g_object_get_property(filechooser, pspec->name, &value);
toggle_button = ui_lookup_widget(GTK_WIDGET(filechooser), "check_hidden");

gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
ui_lookup_widget(GTK_WIDGET(filechooser), "check_hidden")), g_value_get_boolean(&value));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_button),
gtk_file_chooser_get_show_hidden(GTK_FILE_CHOOSER(filechooser)));
}


Expand Down Expand Up @@ -416,7 +413,8 @@ static GtkWidget *create_open_file_dialog(void)
gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(encoding_combo), encoding_renderer,
encoding_combo_cell_data_func, NULL, NULL);

g_signal_connect(dialog, "notify::show-hidden", G_CALLBACK(on_file_open_notify), NULL);
g_signal_connect(dialog, "notify::show-hidden",
G_CALLBACK(on_file_open_show_hidden_notify), NULL);

return dialog;
}
Expand Down
2 changes: 2 additions & 0 deletions src/document.c
Expand Up @@ -2279,6 +2279,7 @@ void document_update_tags(GeanyDocument *doc)
case GEANY_FILETYPES_CS:
case GEANY_FILETYPES_D:
case GEANY_FILETYPES_JAVA:
case GEANY_FILETYPES_OBJECTIVEC:
case GEANY_FILETYPES_VALA:
{

Expand All @@ -2301,6 +2302,7 @@ void document_update_tags(GeanyDocument *doc)
keywords = g_string_free(keywords_str, FALSE);
sci_set_keywords(doc->editor->sci, keyword_idx, keywords);
g_free(keywords);
queue_colourise(doc); /* force re-highlighting the entire document */
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/filetypes.c
Expand Up @@ -118,6 +118,14 @@ static void init_builtin_filetypes(void)
ft->mime_type = g_strdup("text/x-c++src");
ft->group = GEANY_FILETYPE_GROUP_COMPILED;

#define OBJECTIVEC
ft = filetypes[GEANY_FILETYPES_OBJECTIVEC];
ft->lang = 42;
ft->name = g_strdup("Objective-C");
filetype_make_title(ft, TITLE_SOURCE_FILE);
ft->mime_type = g_strdup("text/x-objc");
ft->group = GEANY_FILETYPE_GROUP_COMPILED;

#define CS
ft = filetypes[GEANY_FILETYPES_CS];
ft->lang = 25;
Expand Down Expand Up @@ -1430,6 +1438,8 @@ static gchar *filetypes_get_conf_extension(const GeanyFiletype *ft)
case GEANY_FILETYPES_NONE: result = g_strdup("common"); break;
/* name is Matlab/Octave */
case GEANY_FILETYPES_MATLAB: result = g_strdup("matlab"); break;
/* name is Objective-C, and we don't want the hyphen */
case GEANY_FILETYPES_OBJECTIVEC: result = g_strdup("objectivec"); break;
default:
result = g_ascii_strdown(ft->name, -1);
break;
Expand Down

0 comments on commit 70f41f6

Please sign in to comment.