Bump Geany ABI to mitigate Scintilla 5.1.5 changes
[geany-mirror.git] / HACKING
blob7c85b4a03eb315576585c42e1235dd9089947c4e
1 =============
2 Hacking Geany
3 =============
4 .. contents::
6 General
7 =======
9 About this file
10 ---------------
11 This file contains information for anyone wanting to work on the Geany
12 codebase. You should be aware of the open source licenses used - see
13 the README file or the documentation. It is reStructuredText; the
14 source file is HACKING.
16 You can generate this file by:
18 * Passing the *--enable-html-docs* option to ``configure``.
19 * Running ``make`` from the doc/ subdirectory.
21 Writing plugins
22 ---------------
23 * src/plugindata.h contains the plugin API data types.
24 * See plugins/demoplugin.c for a very basic example plugin.
25 * src/plugins.c loads and unloads plugins (you shouldn't need to read
26   this really).
27 * The API documentation contains a few basic guidelines and hints to
28   write plugins.
30 You should generate and read the plugin API documentation, see below.
32 Plugin API documentation
33 ^^^^^^^^^^^^^^^^^^^^^^^^
34 You can generate documentation for the plugin API using the doxygen
35 tool:
37 * Pass the *--enable-api-docs* option to ``configure``.
38 * Run ``make`` from the doc/ subdirectory.
40 The documentation will be output to doc/reference/index.html.
41 Alternatively you can view the API documentation online at
42 https://www.geany.org/manual/reference/.
44 Pull requests
45 -------------
46 Making pull requests on Github is the preferred way of contributing for geany.
48 .. note:: For helping you to get started: https://help.github.com/articles/fork-a-repo
50 See `Rules to contribute`_ for more information.
52 Patches
53 -------
54 We are happy to receive patches, but the preferred way is to make a pull
55 request on our Github repository. If you don't want to make a pull request,
56 you can send your patches on the devel mailing list, but the rules are the same:
57 see `Rules to contribute`_ for more information.
59 In general it's best to provide git-formatted patches made from the
60 current Git (see `Committing`_)::
62     $ git commit -a
63     $ git format-patch HEAD^
65 We also accept patches against other releases, but it's more work for us.
67 If you're not using Git, although you're strongly suggested to use it,
68 you can use the diff command::
70     $ diff -u originalpath modifiedpath > new-feature.patch
72 However, such a patch won't contain the authoring information nor the
73 patch's description.
75 .. note::
76     Please make sure patches follow the style of existing code - In
77     particular, use tabs for indentation. See `Coding`_.
79 Rules to contribute
80 -------------------
82 Keep in mind this is best to check with us by email on mailing list
83 whether a new feature is appropriate and whether someone is already
84 working on similar code.
86 Please, make sure contributions you make follow these rules:
88 * changes should be made in a dedicated branch for pull requests.
89 * only one feature should be in each pull request (or patch).
90 * pull requests (or patches) should not contain changes unrelated to the feature,
91   and commits should be sensible units of change.
92 * the submitter should squash together corrections that are part of
93   the development process, especially correcting your own mistakes.
94 * Please make sure your modifications follow the style of existing code:
95   see `Coding`_ for more information.
97 See `Committing`_ for more information.
99 Windows tools
100 -------------
101 * Git: http://git-scm.com/ and http://msysgit.github.io/
102 * diff, grep, etc: http://mingw.org/ or http://unxutils.sourceforge.net/
104 See also the 'Building on Windows' document on the website.
106 File organization
107 -----------------
108 callbacks.c is just for Glade callbacks.
109 Avoid adding code to geany.h if it will fit better elsewhere.
110 See the top of each ``src/*.c`` file for a brief description of what
111 it's for.
113 Plugin API code
114 ---------------
115 Please be aware that anything with a doc-comment (a comment with an
116 extra asterisk: ``/**``) is something in the plugin API. Things like
117 enums and structs can usually still be appended to, ensuring that all
118 the existing elements stay in place - this will keep the ABI stable.
120 .. warning::
122     Some structs like GeanyCallback cannot be appended to without
123     breaking the ABI because they are used to declare structs by
124     plugins, not just for accessing struct members through a pointer.
125     Normally structs should never be allocated by plugins.
127 Keeping the plugin ABI stable
128 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
129 In general the ABI changes as little as we can manage. The ABI number
130 must match exactly between Geany and plugins, so an ABI change breaks
131 all plugins until they are re-compiled. But sometimes it is absolutely
132 necessary. Removing a feature or significantly changing the semantics
133 of an existing feature require an ABI change since existing plugins may
134 no longer work with the modified version of Geany.
136 The API identifying number is increased whenever anything is added to
137 the API so plugins can test if the feature is available. The API number
138 required by a plugin needs only to be lower than the API Geany provides,
139 so an increase in API number without a change in ABI will not stop
140 plugins that need a lower number from working.
142 If you're reordering or changing existing elements of structs that are
143 used as part of the plugin API, you must increment GEANY_ABI_VERSION
144 in plugindata.h. This is usually not needed if you're just appending
145 fields to structs. The GEANY_API_VERSION value should be incremented
146 for any changes to the plugin API, including appending elements.
148 If you're in any doubt when making changes to plugin API code, just ask us.
150 Plugin API/ABI design
151 ^^^^^^^^^^^^^^^^^^^^^
152 You should not make plugins rely on the size of a struct. This means:
154 * Don't let plugins allocate any structs (stack or heap).
155 * Don't let plugins index any arrays of structs.
156 * Don't add any array fields to structs in case we want to change the
157   array size later.
159 Doc-comments
160 ^^^^^^^^^^^^
161 * The @file tag can go in the source .c file, but use the .h header name so
162   it appears normally in the generated documentation. See ui_utils.c for an
163   example.
164 * Function doc-comments should always go in the source file, not the
165   header, so they can be updated if/when the implementation changes.
167 Glade
168 -----
169 Add user-interface widgets to the Glade 3 file ``data/geany.glade``.
170 Callbacks for the user-interface should go in ``src/callbacks.c``.
172 Use Glade 3.8.5. The 3.8 series still supports GTK+ 2, and earlier
173 point releases did not preserve the order of XML elements, leading to
174 unmanageable diffs.
176 GTK versions & API documentation
177 --------------------------------
178 Geany requires GTK >= 3.0 and GLib >= 2.32. API symbols from newer GTK/GLib
179 versions should be avoided or made optional to keep the source code building
180 on older systems.
182 It is recommended to use the 3.0 API documentation of the GTK
183 libs (including GLib, GDK and Pango) has the advantages
184 that you don't get confused by any newer API additions and you
185 don't have to take care about whether you can use them or not.
187 You might want to pass the ``-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32`` C
188 preprocessor flag to get warnings about newer symbols from the GLib.
190 On the contrary, you might also want to get deprecation warnings for symbols
191 deprecated in newer versions, typically when preparing a dependency bump or
192 trying to improve forward compatibility.
193 To do so, use the ``-UGLIB_VERSION_MIN_REQUIRED`` flag for GLib deprecations,
194 and ``-UGDK_DISABLE_DEPRECATION_WARNINGS`` for GTK and GDK ones.
195 To change the lower deprecation bound for GLib (and then get warnings about
196 symbols deprecated more recently) instead of simply removing it entirely, use
197 ``-UGLIB_VERSION_MIN_REQUIRED -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_X_YY``.
199 See `Compiler options & warnings`_ for how to set such flags.
201 Coding
202 ------
203 * Don't write long functions with a lot of variables and/or scopes - break
204   them down into smaller static functions where possible. This makes code
205   much easier to read and maintain.
206 * Use GLib types and functions - gint not int, g_free() not free().
207 * Your code should build against GLib 2.32 and GTK 3.0. At least for the
208   moment, we want to keep the minimum requirement for GTK at 3.0 (of
209   course, you can use the GTK_CHECK_VERSION macro to protect code using
210   later versions).
211 * Variables should be declared (and initialized) as close as practical
212   to their first use. This reduces the chances of intervening code being
213   inserted between declaration and use, where the variable may be
214   uninitialized.
215 * Variables should be defined within the smallest scope that is practical,
216   for example inside a conditional branch which uses them or in the
217   initialization part of a for loop.
218 * Local variables that will not be modified should be marked as ``const``
219   to indicate intention. This allows the compiler to give a warning if
220   part of the code accidentally tries to change the value.
221 * Pointer parameters should be marked ``const`` if the value they point
222   to will not be mutated within the function.
223 * Don't let variable names shadow outer variables - use gcc's -Wshadow
224   option.
225 * Use the strictest possible data type where practical.
226   Avoid using untyped pointers (e.g. gpointer) where practical.
227   For an enumeration, use the actual enum type rather than just a
228   ``gint``, use a ``gchar`` for individual (ASCII/UTF-8) string
229   characters rather than ``gint``, and use a ``guint`` for integers
230   which cannot be negative rather than ``gint``.
231 * Prefer loops to calling ``some_type_foreach()`` with a ``user_data``
232   argument. (Note: Some containers don't support external iteration,
233   e.g. for tree structures, so ``*_foreach`` is fine for those).
234 * Do not use G_LIKELY or G_UNLIKELY (except in critical loops). These
235   add noise to the code with little real benefit.
237 Compiler options & warnings
238 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
239 Use ``CFLAGS='-Wfoo' ./configure`` or ``CFLAGS='-Wfoo' ./autogen.sh``
240 to set warning options (as well as anything else e.g. -g -O2).
242 * Enable warnings - for gcc use '-Wall -Wextra' (and optionally
243   -Wno-unused-parameter to avoid unused parameter warnings in Glade
244   callbacks). Alternatively you can use the Glib macro G_GNUC_UNUSED
245   to suppress warnings on single parameters, e.g.
246   ``void examplefunction(G_GNUC_UNUSED gchar *foo)``. Also see
247   https://developer.gnome.org/glib/stable/glib-Miscellaneous-Macros.html.
248 * You should try to write ISO C99 code for portability, so always
249   use C ``/* */`` comments and function_name(void) instead of
250   function_name(). This is for compatibility with various Unix-like
251   compilers. You should use -std=c99 to help check this.
253 .. tip::
254     Remember for gcc you need to enable optimization to get certain
255     warnings like uninitialized variables, but for debugging it's
256     better to have no optimization on.
258 Style
259 ^^^^^
260 * We use a tab width of 4 and indent completely with tabs not spaces.
261   Note the documentation files use (4) spaces instead, so you may want
262   to use the 'Detect from file' indent pref.
263 * Do not add whitespace at the end of lines, this adds to commit noise.
264   When editing with Geany set preference files->Strip trailing spaces
265   and tabs.
266 * Use the multiline comment ``/* */`` to comment small blocks of code,
267   functions descriptions or longer explanations of code, etc. The more
268   comments are in your code the better. (See also
269   ``scripts/fix-cxx-comments.pl`` in Git).
270 * Lines should not be longer than about 100 characters and after 100
271   characters the lines should be wrapped and indented once more to
272   show that the line is continued.
273 * We don't put spaces between function names and the opening brace for
274   argument lists.
275 * Variable declarations come first after an opening brace, then one
276   newline to separate declarations and code.
277 * 2-operand operators should have a space each side.
278 * Function bodies should have 2 blank newlines after them.
279 * Align braces together on separate lines.
280 * Don't put assignments in 'if/while/etc' expressions except for loops,
281   for example ``for (int i = 0; i < some_limit; i++)``.
282 * if statements without brace bodies should have the code on a separate
283   line, then a blank line afterwards.
284 * Use braces after if/while statements if the body uses another
285   if/while statement.
286 * Try to fit in with the existing code style.
288 .. note::
289     A few of the above can be done with the Git
290     ``scripts/fix-alignment.pl``, but it is quite dumb and it's much better
291     to write it correctly in the first place.
292     ``scripts/rstrip-whitespace.py`` just removes trailing whitespace.
295 .. below tabs should be used, but spaces are required for reST.
297 Example::
299     struct Bar;
301     typedef struct Foo  /* struct names normally are the same as typedef names */
302     {
303         gint    foo;    /* names are somewhat aligned visually */
304         gint    bar;    /* fields don't share the same line */
305         SomeLongTypeName baz; /* alignment is not strict */
306         gchar   *ptr;   /* pointer symbol must go next to variable name, not type */
307         Bar     public; /**< only plugin API fields have a doc-comment */
308     }
309     Foo;
312     gint some_func(void);
314     gint some_other_func(void);
317     /* optional function comment explains something important */
318     gint function_long_name(gchar arg1, <too many args to fit on this line>,
319             gchar argN)
320     {
321         /* variable declarations always go before code in each scope */
322         /* variable names should NOT be aligned at all */
323         gint foo, bar;  /* variables can go on the same line */
324         gint baz;       /* but often don't */
325         gchar *ptr;     /* pointer symbol must go next to variable name, not type */
326         gchar *another; /* pointers should normally go on separate lines */
328         /* Some long comment block
329          * taking several different
330          * lines to explain */
331         if (foo)
332         {
333             /* variables only used in one scope should normally be declared there */
334             gint dir = -1;
336             bar = foo;
337             if ((bar & (guint)dir) != 7)
338                 some_code(arg1, <too many args to fit on this line>,
339                     argN - 1, argN);
341             some_func();
342         }
343     }
346     /** Explains using doc-comments for plugin API functions.
347      * First line should be short and use the third person tense - 'explains',
348      * not 'explain'.
349      *
350      * @return Some number.
351      * @since 1.22. */
352     gint another_function(void)
353     {
354         ...
356 Header Includes
357 ---------------
359 In order to make including various headers in Geany more convenient, each
360 file should include what it uses. If there is a file named ``foo.c``, and a
361 file named ``foo.h``, it should be possible to include ``foo.h`` on its own
362 without depending on stuff in ``foo.c`` that is included for the first time
363 before ``foo.h``.
365 Private Headers
366 ^^^^^^^^^^^^^^^
368 If there is some data that needs to be shared between various parts of the
369 core code, put them in a "private header", that is, if the public header is
370 called ``foo.h``, then make a ``fooprivate.h`` header that contains the
371 non-public functions, types, globals, etc that are needed. Other core source
372 files can then just include the ``foo.h`` and/or ``fooprivate.h`` depending
373 what they need, without exposing that stuff to plugins.
375 Order of Includes
376 ^^^^^^^^^^^^^^^^^
378 Inside a source file the includes section should be ordered like this:
380 1. Always include the ``config.h`` file at the start of every source file,
381    for example::
383     #ifdef HAVE_CONFIG_H
384     # include "config.h"
385     #endif
387    This allows the Autotools and other build systems use the ``./configure``
388    time settings. If you don't do this, there's likely to be a number of
389    macros that you'll have to define in the build system or custom headers.
391    Warning: Never include ``config.h`` in headers, and especially in "public"
392    headers that plugins might include.
394 2. Then include the header that has the same name as the source file (if
395    applicable). For example, for a source file named ``foo.c``, include
396    the ``foo.h`` below the ``config.h`` include. If there is a
397    ``fooprivate.h``, ``foo.c`` will most likely want to include that too,
398    put it in with includes in #3.
400 3. At this point, it should be safe to include all the headers that declare
401    whatever is needed. If everything generally "includes what it uses" and
402    all files included contain the appropriate multiple-declaration guards
403    then the order of includes is fairly arbitrary. Prefer to use English
404    alphabetic order if possible.
406 4. By now it doesn't really matter about the order, nothing below here is
407    "our problem". Semi-arbitrarily, you should use an include order like this:
409     1. Standard C headers
410     2. Non-standard system headers (eg. ``windows.h`` or ``unistd.h``)
411     3. GLib/GTK+ or related headers
413 5. Everything else that should not influence 1-4.
415 Including in Header Files
416 ^^^^^^^^^^^^^^^^^^^^^^^^^
418 Headers should also include what they use. All of the types should defined in
419 order to allow the header to be included stand-alone. For example, if a
420 header uses a ``GtkWidget*``, it should ``#include <gtk/gtk.h>``. Or, if a
421 headers uses a ``GPtrArray*``, it should ``#include <glib.h>`` to ensure that
422 all of the types are declared, whether by pointers/opaquely or fully, as
423 required. Since all headers will use a ``G_BEGIN_DECLS`` and ``G_END_DECLS``
424 guard for C++, the bare minimum for a header is to include ``glib.h`` or
425 ``<gtk/gtk.h>`` or ``gtkcompat.h`` or some other header that makes those
426 macros available.
429 Committing
430 ----------
432 * Commit one thing at a time, do small commits.  Commits should be
433   meaningful and not too big when possible; multiple small commits are
434   good if there is no good reason to group them.
435 * Use meaningful name and email in the Author and Committer fields.
436   This helps knowing who did what and allows to contact the author if
437   there is a good reason to do so (unlikely, but can happen).
438 * When working on a new feature, create a new branch for it.  When
439   merging it, use the --no-ff option to make sure a merge commit will
440   be created to better track what happened.  However, if the feature
441   only took one commit you might merge it fast-forward since there is
442   not history to keep together.
444 Commit messages
445 ^^^^^^^^^^^^^^^
446 Follow the standard Git formatting:
448 * No line should use more than about 80 characters (around 72 is best).
449 * The first line is the commit's summary and is followed by an empty
450   line.  This summary should be one line and one line only, thus less
451   than 80 characters.  This summary should not include any punctuation
452   unless really needed.  See it as the subject of an email: keep it
453   concise and as precise as you can, but not tool long.
454 * Following lines are optional detailed commit information, with
455   paragraphs separated by blank lines.  This part should be as long as
456   needed to describe the commit in depth, should use proper
457   punctuation and should include any useful information, like the
458   motivation for the patch and/or any valuable details the diff itself
459   don't provide or don't make clear.  Make it as complete as you think
460   it makes sense, but don't include an information that is better
461   explained by the commit's diff.
463   It is OK to use ASCII formatting like bullet list using "*" or "-",
464   etc. if useful, but emphasis (bold, italic, underline) should be
465   avoided.
467 Example::
469     Ask the user if spawn fails in utils_open_browser()
471     Ask the user to configure a valid browser command if spawning it
472     fails rather than falling back to some arbitrary hardcoded defaults.
474     This avoid spawning an unexpected browser when the configured one is
475     wrong, and gives the user a chance to correctly fix the preference.
478 Testing
479 -------
480 * Run with ``-v`` to print any debug messages.
481 * You can use a second instance (``geany -i``).
482 * To check first-run behaviour, use an alternate config directory by
483   passing ``-c some_dir`` (but make sure the directory is clean first).
484 * For debugging tips, see `GDB`_.
486 Bugs to watch out for
487 ---------------------
488 * Forgetting to check *doc->is_valid* when looping through
489   *documents_array* - instead use *foreach_document()*.
490 * Inserting fields into structs in the plugin API instead of appending.
491 * Not breaking the plugin ABI when necessary.
492 * Using an idle callback that doesn't check main_status.quitting.
493 * Forgetting CRLF line endings on Windows.
494 * Not handling Tabs & Spaces indent mode.
496 Libraries
497 ---------
498 We try to use an unmodified version of Scintilla - any new lexers or
499 other changes should be passed on to the maintainers at
500 http://scintilla.org. We normally update to a new Scintilla release
501 shortly after one is made. See also scintilla/README.
503 We use an unmodified subset of universal-ctags sources
504 (https://github.com/universal-ctags/ctags) to parse open documents. We
505 also use the great majority of unmodified universal-ctags parsers except
506 a few outliers that are maintained by us (those whose file names start
507 with `geany_`). We normally update to the latest version of
508 universal-ctags shortly after making a Geany release and keep this
509 version during the rest of the development cycle.
511 Notes
512 =====
513 Some of these notes below are brief (or maybe incomplete) - please
514 contact the geany-devel mailing list for more information.
516 Using pre-defined autotools values
517 ----------------------------------
518 When you are use macros supplied by the autotools like GEANY_PREFIX,
519 GEANY_LIBDIR, GEANY_DATADIR and GEANY_LOCALEDIR be aware that these
520 might not be static strings when Geany is configured with
521 --enable-binreloc. Then these macros will be replaced by function calls
522 (in src/prefix.h). So, don't use anything like
523 printf("Prefix: " GEANY_PREFIX); but instead use
524 printf("Prefix: %s", GEANY_PREFIX);
526 Adding a source file foo.[hc] in src/ or plugins/
527 -------------------------------------------------
528 * Add foo.c, foo.h to SRCS in path/Makefile.am.
529 * Add path/foo.c to po/POTFILES.in (for string translation).
531 Adding a filetype
532 -----------------
533 You can add a filetype without syntax highlighting or tag parsing, but
534 check to see if those features have been written in upstream projects
535 first (scintilla or ctags).
537 **Custom:**
539 If you want to reuse an existing lexer and/or tag parser, making a
540 custom filetype is probably easier - it doesn't require any
541 changes to the source code. Follow instructions in the manual:
542 http://geany.org/manual/index.html#custom-filetypes. Don't forget to
543 update the ``[Groups]`` section in ``filetype_extensions.conf``.
545 .. warning::
546   You should use the newer `[build-menu]` section for default build
547   commands - the older `[build_settings]` may not work correctly for
548   custom filetypes.
550 **Built-in:**
552 * Add GEANY_FILETYPES_FOO to filetypes.h.
553 * Initialize GEANY_FILETYPES_FOO in init_builtin_filetypes() of
554   filetypes.c.
555 * Update data/filetype_extensions.conf.
557 The remaining notes relate mostly to built-in filetypes.
559 filetypes.* configuration file
560 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
561 All languages need a data/filetypes.foo configuration file. See
562 the "Filetype definition files" section in the manual and/or
563 data/filetypes.c for an example.
565 Programming languages should have:
567 * [keywords] if the lexer supports it.
568 * [settings] mostly for comment settings.
569 * [build-menu] (or [build_settings]) for commands to run.
571 For languages with a Scintilla lexer, there should be a [styling] section,
572 to correspond to the styles used in highlighting_styles_FOO[] in
573 highlightingmappings.h - see below.
575 Don't forget to add the newly created filetype file to data/Makefile.am.
577 Syntax highlighting
578 ^^^^^^^^^^^^^^^^^^^
579 It may be possible to use an existing Scintilla lexer in the scintilla/
580 subdirectory - if not, you will need to find (or write) one,
581 LexFoo.cxx. Try the official Scintilla project first.
583 .. warning::
584     We won't accept adding a lexer that conflicts with one in
585     Scintilla. All new lexers should be submitted back to the Scintilla
586     project to save duplication of work.
588 When adding a lexer, update:
590 * scintilla/Makefile.am
591 * scintilla/src/Catalogue.cxx - add a LINK_LEXER command *manually*
593 For syntax highlighting, you will need to edit highlighting.c and
594 highlightingmappings.h and add the following things:
596 1. In highlightingmappings.h:
598    a. define ``highlighting_lexer_FOO`` to the Scintilla lexer ID for
599       this filtype, e.g. ``SCLEX_CPP``.
600    b. define the ``highlighting_styles_FOO`` array that maps Scintilla
601       style states to style names in the configuration file.
602    c. define ``highlighting_keywords_FOO`` to ``EMPTY_KEYWORDS`` if the
603       filtype has no keywords, or as an ``HLKeyword`` array mapping
604       the Scintilla keyword IDs to names in the configuration file.
605    d. define ``highlighting_properties_FOO`` to ``EMPTY_PROPERTIES``, or
606       as an array of ``HLProperty`` if the filetype requires some lexer
607       properties to be set.  However, note that properties should
608       normally be set in the ``[lexer_properties]`` section of the
609       configuration file instead.
611    You may look at other filtype's definitions for some examples
612    (Ada, CSS or Diff being good examples).
614 2. In highlighting.c:
616    a. Add ``init_styleset_case(FOO);`` in ``highlighting_init_styles()``.
617    b. Add ``styleset_case(FOO);`` in ``highlighting_set_styles()``.
619 3. Write data/filetypes.foo configuration file [styling] section. See
620    the manual and see data/filetypes.d for a named style example.
622 .. note::
623     Please try to make your styles fit in with the other filetypes'
624     default colors, and to use named styles where possible (e.g.
625     "commentline=comment"). Filetypes that share a lexer should have
626     the same colors. If not using named styles, leave the background color
627     empty to match the default color.
629 Error message parsing
630 ^^^^^^^^^^^^^^^^^^^^^
631 New-style error message parsing is done with an extended GNU-style regex
632 stored in the filetypes.foo file - see the [build_settings] information
633 in the manual for details.
635 Old-style error message parsing is done in
636 msgwin_parse_compiler_error_line() of msgwindow.c - see the ParseData
637 typedef for more information.
639 Other features
640 ^^^^^^^^^^^^^^
641 If the lexer has comment styles, you should add them in
642 highlighting_is_comment_style(). You should also update
643 highlighting_is_string_style() for string/character styles. For now,
644 this prevents calltips and autocompletion when typing in a comment
645 (but it can still be forced by the user).
647 For brace indentation, update lexer_has_braces() in editor.c;
648 indentation after ':' is done from on_new_line_added().
650 If the Scintilla lexer supports user type keyword highlighting (e.g.
651 SCLEX_CPP), update document_update_tags() in document.c.
653 Adding a CTags parser
654 ^^^^^^^^^^^^^^^^^^^^^
655 This assumes the filetype for Geany already exists.
657 First write or find a CTags compatible parser, foo.c. Check this fork:
658 https://github.com/universal-ctags/ctags
660 Method
661 ``````
662 * Add foo.c to SRCS in Makefile.am.
663 * Add Foo to src/tagmanager/tm_parsers.h
664 * Add TM_PARSER_FOO to src/tagmanager/tm_parser.h.  The list here must follow
665   exactly the order in src/tagmanager/tm_parsers.h.
667 In src/tagmanager/tm_parser.c:
668 Add a map_FOO TMParserMapEntry mapping each kind's letter from foo.c's
669 FooKinds to the appropriate TMTagType, and add the corresponding
670 MAP_ENTRY(FOO) to parser_map.
672 In src/tagmanager/tm_parser.c:
673 Add a group_FOO TMParserMapGroup defining root nodes of the symbol tree,
674 used icons and TMTagType values grouped under the specified root.
675 Multiple TMTagType values can be combined under a single root using |
676 (bitwise OR).
678 In src/tagmanager/tm_parser.c:
679 Update various functions at the end of tm_parser.c to adjust Geany
680 behavior to the behavior of the added parser. In particular, update
681 tm_parser_scope_separator() and tm_parser_has_full_scope() so
682 scope-related functionality works correctly.
684 In filetypes.c, init_builtin_filetypes():
685 Set the 2nd argument of the FT_INIT() macro for this filetype to FOO.
687 Tests
688 `````
689 The tag parser tests checks if the proper tags are emitted
690 for a given source. Tests for tag parsers consist of two files: the
691 source to parse, and the expected output. Tests are run using ``make
692 check``.
694 The source to parse should be in the file ``tests/ctags/mytest.ext``,
695 where ``mytest`` is the name you choose for your test, and ``ext`` is an
696 extension recognized by Geany as the language the test file is for.
697 This file should contain a snippet of the language to test for.
698 It can be either long or short, depending on what it tests.
700 The expected output should be in the file ``tests/ctags/mytest.ext.tags``
701 (which is the same name as the source, but with ``.tags`` appended), and
702 should be in the format generated by::
704     $ geany -g tmp.ext.tags tests/ctags/mytest.ext
705     $ scripts/print-tags.py < tmp.ext.tags > tests/ctags/mytest.ext.tags
707 This file contains the tag information expected to be generated from
708 the corresponding source file together with its human-readable form.
710 When you have these two files, you have to list your new test along the
711 other ones in the ``test_source`` variable in ``tests/ctags/Makefile.am``.
712 Please keep this list sorted alphabetically.
714 Upgrading Scintilla
715 -------------------
717 To upgrade the local Scintilla copy, use the ``scripts/update-scintilla.sh``
718 script.
720 To use it, you need to first obtain a copy of the Scintilla sources you want
721 to update to.  This will generally mean checking out a release tag from the
722 Scintilla Mercurial repository, or extracting a tarball.
724 Then, just run the script from Geany's to source directory passing the path
725 to the Scintilla source directory as first argument, and follow the
726 instructions, if any::
728     ./scripts/update-scintilla.sh /path/to/scintilla/
733 Stop on warnings
734 ^^^^^^^^^^^^^^^^
735 When a GLib or GTK warning is printed, often you want to get a
736 backtrace to find out what code caused them. You can do that with the
737 ``--g-fatal-warnings`` argument, which will abort Geany on the first
738 warning it receives.
740 But for ordinary testing, you don't always want your editor to abort
741 just because of a warning - use::
743     (gdb) b handler_log if level <= G_LOG_LEVEL_WARNING
746 Running with batch commands
747 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
748 Use::
750     $ gdb src/geany -x gdb-commands
752 Where ``gdb-commands`` is a file with the following lines::
754     set pagination off
755     b handler_log if level <= G_LOG_LEVEL_WARNING
756     r -v
759 Loading a plugin
760 ^^^^^^^^^^^^^^^^
761 This is useful so you can load plugins without installing them first.
762 Alternatively you can use a symlink in ~/.config/geany/plugins or
763 $prefix/lib/geany (where $prefix is /usr/local by default).
765 The gdb session below was run from the toplevel Geany source directory.
766 Start normally with e.g. "gdb src/geany".
767 Type 'r' to run.
768 Press Ctrl-C from the gdb window to interrupt program execution.
770 Example::
772     Program received signal SIGINT, Interrupt.
773     0x00d16402 in __kernel_vsyscall ()
774     (gdb) call plugin_new("./plugins/.libs/demoplugin.so")
775     ** INFO: Loaded:   ./plugins/.libs/demoplugin.so (Demo)
776     $1 = (Plugin *) 0x905a890
777     (gdb) c
778     Continuing.
780     Program received signal SIGINT, Interrupt.
781     0x00d16402 in __kernel_vsyscall ()
782     (gdb) call plugin_free(0x905a890)
783     ** INFO: Unloaded: ./plugins/.libs/demoplugin.so
784     (gdb) c
785     Continuing.
787 Building Plugins
788 ^^^^^^^^^^^^^^^^
790 The geany-plugins autotools script automatically detects the
791 installed system Geany and builds the plugins against that.
793 To use plugins with a development version of Geany built with
794 a different prefix, the plugins will need to be compiled against
795 that version if the ABI has changed.
797 To do this you need to specify both --prefix and --with-geany-libdir
798 to the plugin configure.  Normally the plugin prefix is the
799 same as the Geany prefix to keep plugins with the version of Geany
800 that they are compiled against, and with-geany-libdir is the Geany
801 prefix/lib.
803 Whilst it is possible for the plugin prefix to be different to
804 the prefix of the libdir (which is why there are two settings),
805 it is probably better to keep the version of Geany and its plugins
806 together.