Geany e.v. — the registered association for the geany project

Вступление

Безусловной, самой убойной фишкой Geany является изобилие плагинов: именно они превращают хороший, но не выдающийся инструмент для работы с текстами в лучший текстовый редактор всех времён и народов. По крайней мере, времён нынешних, и народов, для которых профессией является сочинение текстов, причём не исходных, а нарративных. Хотя и для редактирования исходников он прекрасно подходит — но об его «лучшести» в этом плане судить не нам с Мануалом.

Вторая «общеубойная» фишка Geany — сочетаемость фишек. Каждая из которых по отдельности может быть полезной, но далёкой от «убойности». А вот две-три такие фишки в сочетании дают эффект кумулятивного заряда. Что можно проиллюстрировать на примере. Однако сначала — ещё пара общих слов.

Description

Geany is a small, free text editor that makes use of Scintilla and GTK+, along with basic IDE features. It offers support for a wide range of programming and markup languages (C++, C, Java, Python, PHP, HTML, CSS, etc.).

Its interface is similar to the editors designed for Microsoft Windows such as Notepad++ or Programmer’s Notepad while it has the advantage of being ported to many OS such as Microsoft Windows, Mac OS X, Linux, BSD and even Solaris.

Trademark Note 1: Microsoft, Windows and other product names are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

Trademark Note 2: Mac and OS X are trademarks of Apple Inc., registered in the U.S. and other countries.

Note: Considering the official homepage of Geany listed only the Microsoft Windows and Mac OS X versions and offered the versions for the other OS on a separate page, FossHub will also contain only these two versions. You can download the Geany version for other operating systems from the «Third Party Packages» page.

Creating a GTK runtime bundle

In order to run Geany and/or create an installer for distribution, you need a GTK runtime environment.
There is simple script which downloads all necessary packages and unpack them in an automated way.

After you have run the scripts as described below, you should copy the resulting files and directories
all into your Geany installation directory if you want to use it directly for your own Geany
installation.
In case you want to create an installer, leave the directories as they are and read on.

Geany

The script is available at https://raw.githubusercontent.com/geany/geany/master/scripts/gtk-bundle-from-msys2.sh.

To run it, simply create a new directory where the GTK runtime environment should be
unpacked and change into this directory.
Then call the script and wait a bit. It will download all necessary MSYS2 packages and extract them.
Finally it will download the sources for *grep* and then compile *grep*.

cd
curl -L -o geany-gtk-bundle-from-msys2.sh https://raw.githubusercontent.com/geany/geany/master/scripts/gtk-bundle-from-msys2.sh
mkdir /h/geany-bundle
cd /h/geany-bundle
bash ~/geany-gtk-bundle-from-msys2.sh -2
rsync -a --delete /h/geany-bundle/ ~/geany/gtk/

There are a few command line options for this script. Run it with “-h” for details.
The most important option is “-2” and “-3” which defines the GTK version to be used.

The trailing “rsync” command is only necessary if you intend to create an installer later on.

Geany-Plugins

For GeanyPlugins, the process is quite similar.
The script for GeanyPlugins is available at https://raw.githubusercontent.com/geany/geany-plugins/master/build/gtk-bundle-from-msys2.sh.

cd
curl -L -o geany-plugins-gtk-bundle-from-msys2.sh https://raw.githubusercontent.com/geany/geany-plugins/master/build/gtk-bundle-from-msys2.sh
mkdir /h/geany-plugins-bundle
cd /h/geany-plugins-bundle
bash ~/geany-plugins-gtk-bundle-from-msys2.sh -2
rsync -a --delete /h/geany-plugins-bundle/ ~/geany-plugins/contrib/

The trailing “rsync” command is only necessary if you intend to create an installer later on.

Geany Review

Geany is a lightweight, quick, and responsive Integrated Development Environment (IDE). It was designed to be speedy and easy to use, with only a few package dependencies- independent from specialized Desktop Environments like KDE and GNOME. Geany only needs GTK2 runtime libraries to function. If you’ve got that together, you’re not likely to have any problems with it.

Essential Features

— Syntax highlighting

— Code folding

— Symbol name auto-complete

— Construct and complete/snippets

— Auto-close XML and HTML tags

— Call tips

— Many supported file types

— Symbol lists

— Code navigation

— Build system to compile and execute code

— Simple project management

— Plug-in interface

Geany runs under every major OS, as well as FreeBSD, NetBSD, OpenBSD, AIX v5.3, and Solaris Express. You should be able to use this editor on any platform supported by GTK libraries. Only the Windows, (surprise), Geany port is missing a few features. The code is GNU licensed, so you can use it as you like, just keep your hands off the innards.

My opinion is that there are only two good IDEs available at the moment, and Geany is one. Compared to Eclipse, its only real competition, Geany is equal in every way, but lighter.

Geany supports all the major relevant programming languages and has all the features that you expect with an IDE such as line numbering and syntax highlighting. When you start it up, (and it opens fast!), you’ll be presented with a tidy, no-frills interface and plenty of space to work. All compiler messages appear in the box at the bottom- and this is indispensable for debugging code. From there, you can open new files and choose the file type for the language you want to use. And away you go.

Light is Nice

In addition to being lightweight, Geany is powerful, non-interruptive, and displays everything you need handily. Syntax highlighting, line numbers, automatic brace closing, parenthesis, and more- all do precisely what you expect them to with no unpleasant surprises.

If you’re an experienced programmer, you know it’s best when you can fall into habits that are routine and comfortable. You want an IDE that doesn’t switch things up on you. Geany is very stable, reliable, and predictable.

Compiling your code and running it couldn’t be easier. Just click a button and it compiles everything for you, click another and your creation will run.

What you get after pressing ‘run’ depends on what you’ve written. If the program you’ve written is only a simple Java creature- run it, and the output will come through your terminal. Just press enter once and it will exit. This lean and mean IDE will keep everything as straightforward and tidy as possible- just like Geany itself.

Plugin API code

Please be aware that anything with a doc-comment (a comment with an
extra asterix: /**) is something in the plugin API. Things like
enums and structs can usually still be appended to, ensuring that all
the existing elements stay in place — this will keep the ABI stable.

Warning

Some structs like GeanyCallback cannot be appended to without
breaking the ABI because they are used to declare structs by
plugins, not just for accessing struct members through a pointer.
Normally structs should never be allocated by plugins.

Before the 1.0 release series, the ABI can change when necessary, and
even the API can change. An ABI change just means that all plugins will
not load and they must be rebuilt. An API change means that some plugins
might not build correctly.

If you’re reordering or changing existing elements of structs that are
used as part of the plugin API, you must increment GEANY_ABI_VERSION
in plugindata.h. This is usually not needed if you’re just appending
fields to structs. The GEANY_API_VERSION value should be incremented
for any changes to the plugin API, including appending elements.

If you’re in any doubt when making changes to plugin API code, just ask us.

You should not make plugins rely on the size of a struct. This means:

  • Don’t let plugins allocate any structs (stack or heap).
  • Don’t let plugins index any arrays of structs.
  • Don’t add any array fields to structs in case we want to change the
    array size later.

Настройка Geany

Далее запускаем Geany и производим его настройку.
Geany еще “не знает”, что мы будем работать с языком Python. Для информирования его об этом, необходимо создать файл с расширением “*.py”, так как Geany распознает языки программирования по расширению файлов.

После запуска Geany перед вами открывается следующее окно рис 9

Обратите внимание, что все вкладки имеют название “без имени”. рис

9

рис. 9

После запуска выбираем в меню Файл -> Сохранить как… рис 10.
Даем имя файлу и обязательно проверяем, чтобы расширение у файла было PY

рис. 10

После создания данного файла Geany понимает, что мы хотим работать с языком Python. И мы можем написать свою первую программу на языке Python.
Наша программа будет состоять из одной строчки, которая должна вывести сообщение «Привет!!!»

print («Привет!!!»)

1 print(«Привет!!!»)

Если вы еще не знакомы с синтаксисом языка Python, то просто перепишите этот код, как на рисунке 11:

Рис. 11

Следующим шагом запустим нашу программу.
Для запуска необходимо нажать на кнопку F5.
Если у вас не появилось сообщение, как на рисунке 20, то у вас одна из ниже перечисленных ошибок. Давайте посмотрим, как их ликвидировать.
Ошибка №1 на рис 12. возникает в случае, если при запуске на консоли появилась следующая ошибка:
““python” не является внутренней или внешней командой, исполняемой программой или пакетным файлом.”

рис. 12

Это ошибка возникает в двух случаях:
1. На данном компьютере не установлен интерпретатор Python
2. Не прописаны пути Path

JHBuild Installation

To create the bundle, you need to first install JHBuild and GTK as described below.

  1. Create a new account for jhbuild (not necessary but this makes sure
    jhbuild does not interfere with some other command-line tools installed
    on your system).

  2. Get by

    and run it:

  3. Run

    to set path to jhbuild installed in the previous step.

  4. Add the following lines to :

    With this settings, the build creates a 64-bit binary that works on
    macOS 10.13 and later. By default, jhbuild compiles without
    optimization flags. The call enables optimizations.

  5. Install GTK and all of its dependencies by running the following
    command inside the directory:

    The upstream project is sometimes in an unstable state and fails to build;
    if this happens, you can use our snapshot of modulesets which was used
    to build the last release of Geany:

Adding a filetype

You can add a filetype without syntax highlighting or tag parsing, but
check to see if those features have been written in upstream projects
first (scintilla or ctags).

Custom:

If you want to reuse an existing lexer and/or tag parser, making a
custom filetype is probably easier — it doesn’t require any
changes to the source code. Follow instructions in the manual:
. Don’t forget to
update the section in filetype_extensions.conf.

Warning

You should use the newer section for default build
commands — the older may not work correctly for
custom filetypes.

Built-in:

  • Add GEANY_FILETYPES_FOO to filetypes.h.
  • Initialize GEANY_FILETYPES_FOO in init_builtin_filetypes() of
    filetypes.c.
  • Update data/filetype_extensions.conf.

The remaining notes relate mostly to built-in filetypes.

All languages need a data/filetypes.foo configuration file. See
the «Filetype definition files» section in the manual and/or
data/filetypes.c for an example.

Programming languages should have:

  • if the lexer supports it.
  • mostly for comment settings.
  • (or ) for commands to run.

For languages with a Scintilla lexer, there should be a section,
to correspond to the styles used in highlighting_styles_FOO[] in
highlightingmappings.h — see below.

Don’t forget to add the newly created filetype file to data/Makefile.am.

It may be possible to use an existing Scintilla lexer in the scintilla/
subdirectory — if not, you will need to find (or write) one,
LexFoo.cxx. Try the official Scintilla project first.

Warning

We won’t accept adding a lexer that conflicts with one in
Scintilla. All new lexers should be submitted back to the Scintilla
project to save duplication of work.

When adding a lexer, update:

  • scintilla/Makefile.am
  • scintilla/src/Catalogue.cxx — add a LINK_LEXER command manually

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

  1. In highlightingmappings.h:

    1. define highlighting_lexer_FOO to the Scintilla lexer ID for
      this filtype, e.g. SCLEX_CPP.
    2. define the highlighting_styles_FOO array that maps Scintilla
      style states to style names in the configuration file.
    3. 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.
    4. 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 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:

    1. Add init_styleset_case(FOO); in highlighting_init_styles().
    2. Add styleset_case(FOO); in highlighting_set_styles().
  3. Write data/filetypes.foo configuration file section. See
    the manual and see data/filetypes.d for a named style example.

Note

Please try to make your styles fit in with the other filetypes’
default colors, and to use named styles where possible (e.g.
«commentline=comment»). Filetypes that share a lexer should have
the same colors. If not using named styles, leave the background color
empty to match the default color.

New-style error message parsing is done with an extended GNU-style regex
stored in the filetypes.foo file — see the information
in the manual for details.

Old-style error message parsing is done in
msgwin_parse_compiler_error_line() of msgwindow.c — see the ParseData
typedef for more information.

If the lexer has comment styles, you should add them in
highlighting_is_comment_style(). You should also update
highlighting_is_string_style() for string/character styles. For now,
this prevents calltips and autocompletion when typing in a comment
(but it can still be forced by the user).

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 document_update_tags() in document.c.

GTK+2 compilation

This is effectively the same procedure as cross-compiling on Linux. You can either clone the source code from the GIT repository or download a release tarball (1.27 or later) and unpack it.

curl -L -o geany-master.zip https://github.com/geany/geany/archive/master.zip
unzip geany-master.zip
cd geany-master
# autogen.sh is not needed for tarballs!
NOCONFIGURE=1 ./autogen.sh
# configure and make take a while, don't panic
./configure --prefix=/c/geany
make -j2
make install

After that, you can run Geany either through msys2 shell () or use the Windows Explorer to locate the executable and run it.

The first run should look like this, on GTK+ 2.24.28

GTK versions & API documentation

Geany requires GTK >= 3.0 and GLib >= 2.32. API symbols from newer GTK/GLib
versions should be avoided or made optional to keep the source code building
on older systems.

It is recommended to use the 3.0 API documentation of the GTK
libs (including GLib, GDK and Pango) has the advantages
that you don’t get confused by any newer API additions and you
don’t have to take care about whether you can use them or not.

You might want to pass the -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 C
preprocessor flag to get warnings about newer symbols from the GLib.

On the contrary, you might also want to get deprecation warnings for symbols
deprecated in newer versions, typically when preparing a dependency bump or
trying to improve forward compatibility.
To do so, use the -UGLIB_VERSION_MIN_REQUIRED flag for GLib deprecations,
and -UGDK_DISABLE_DEPRECATION_WARNINGS for GTK and GDK ones.
To change the lower deprecation bound for GLib (and then get warnings about
symbols deprecated more recently) instead of simply removing it entirely, use
-UGLIB_VERSION_MIN_REQUIRED -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_X_YY.

GTK+3 compilation

This is effectively the same procedure as cross-compiling on Linux. You can either clone the source code from the GIT repository or download a release tarball (1.27 or later) and unpack it.

curl -L -o geany-master.zip https://github.com/geany/geany/archive/master.zip
unzip geany-master.zip
cd geany-master
# autogen.sh is not needed for tarballs!
NOCONFIGURE=1 ./autogen.sh
# configure and make take a while, don't panic
./configure --enable-gtk3 --prefix=/c/geany
make -j2
make install

After that, you can run Geany either through msys2 shell () or use the Windows Explorer to locate the executable and run it.

The first run should look like this, on GTK+ 3.18.6

Header Includes

In order to make including various headers in Geany more convenient, each
file should include what it uses. If there is a file named foo.c, and a
file named foo.h, it should be possible to include foo.h on its own
without depending on stuff in foo.c that is included for the first time
before foo.h.

If there is some data that needs to be shared between various parts of the
core code, put them in a «private header», that is, if the public header is
called foo.h, then make a fooprivate.h header that contains the
non-public functions, types, globals, etc that are needed. Other core source
files can then just include the foo.h and/or fooprivate.h depending
what they need, without exposing that stuff to plugins.

Inside a source file the includes section should be ordered like this:

  1. Always include the config.h file at the start of every source file,
    for example:

    #ifdef HAVE_CONFIG_H
    # include "config.h"
    #endif
    

    This allows the Autotools and other build systems use the ./configure
    time settings. If you don’t do this, there’s likely to be a number of
    macros that you’ll have to define in the build system or custom headers.

    Warning: Never include config.h in headers, and especially in «public»
    headers that plugins might include.

  2. Then include the header that has the same name as the source file (if
    applicable). For example, for a source file named foo.c, include
    the foo.h below the config.h include. If there is a
    fooprivate.h, foo.c will most likely want to include that too,
    put it in with includes in #3.

  3. At this point, it should be safe to include all the headers that declare
    whatever is needed. If everything generally «includes what it uses» and
    all files included contain the appropriate multiple-declaration guards
    then the order of includes is fairly arbitrary. Prefer to use English
    alphabetic order if possible.

  4. By now it doesn’t really matter about the order, nothing below here is
    «our problem». Semi-arbitrarily, you should use an include order like this:

  5. Everything else that should not influence 1-4.

Maintenance

This section describes some maintenance-related activities which do not
have to be performed during normal bundle/installer creation:

  • To get the file associations in sync with
    , copy the filetype extension portion from
    to the marked place in
    and run the script. Copy the output of the script to the marked
    place in .

  • Before the release, update the Geany version and copyright years inside
    and . Also update the targets in
    file to point to the new release. Dependencies inside
    can also be updated to newer versions.

  • To make sure nothing is left from the previous build when making a
    new release, run

Jiri Techet, 2021

GDB

When a GLib or GTK warning is printed, often you want to get a
backtrace to find out what code caused them. You can do that with the
--g-fatal-warnings argument, which will abort Geany on the first
warning it receives.

But for ordinary testing, you don’t always want your editor to abort
just because of a warning — use:

(gdb) b handler_log if level <= G_LOG_LEVEL_WARNING

Use:

$ gdb src/geany -x gdb-commands

Where gdb-commands is a file with the following lines:

set pagination off
b handler_log if level <= G_LOG_LEVEL_WARNING
r -v

This is useful so you can load plugins without installing them first.
Alternatively you can use a symlink in ~/.config/geany/plugins or
$prefix/lib/geany (where $prefix is /usr/local by default).

The gdb session below was run from the toplevel Geany source directory.
Start normally with e.g. «gdb src/geany».
Type ‘r’ to run.
Press Ctrl-C from the gdb window to interrupt program execution.

Example:

Program received signal SIGINT, Interrupt.
0x00d16402 in __kernel_vsyscall ()
(gdb) call plugin_new("./plugins/.libs/demoplugin.so")
** INFO: Loaded:   ./plugins/.libs/demoplugin.so (Demo)
$1 = (Plugin *) 0x905a890
(gdb) c
Continuing.

Program received signal SIGINT, Interrupt.
0x00d16402 in __kernel_vsyscall ()
(gdb) call plugin_free(0x905a890)
** INFO: Unloaded: ./plugins/.libs/demoplugin.so
(gdb) c
Continuing.

The geany-plugins autotools script automatically detects the
installed system Geany and builds the plugins against that.

Plugins will build with either GTK2 or GTK3, whichever the detected
Geany was built with.

To use plugins with a development version of Geany built with
a different prefix, the plugins will need to be compiled against
that version if the ABI has changed.

To do this you need to specify both —prefix and —with-geany-libdir
to the plugin configure. Normally the plugin prefix is the
same as the Geany prefix to keep plugins with the version of Geany
that they are compiled against, and with-geany-libdir is the Geany
prefix/lib.

Whilst it is possible for the plugin prefix to be different to
the prefix of the libdir (which is why there are two settings),
it is probably better to keep the version of Geany and its plugins
together.

Навигация по тэгам

Во Вступлении к этому очерку кот Мануал отметил, что большинство убойных фишек в Geany обеспечиваются сочетанием штатных возможностей этого редактора и сопровождающих его плагинов (а то и плагинами только). Однако в нём и собственная уникальная фишка, ни от каких плагинов не зависящая. И называется она в настройках — Отображать список символов.

Опция с таким именем по умолчанию включена в настройках редактора. Как, впрочем, и опция Показывать список документов, которая на скриншоте ниже выключена за ненадобностью (для нас):

Визуально это выражается в том, что в боковой панели, а она, естественно, тоже выводится по умолчанию, будут видны две вкладки, именуемые, соответственно, Символы и Документы. Со второй из них всё ясно — она содержит список открытых в редакторе документов:

А вот первая — пуста, если не считать надписи Символы не найдены. А какие такие символы — для меня оставалось покрыто мраком неизвестности, пока я не открыл в Geany большой структурированный HTML-файл с рубрикацией нескольких уровней. Не тот, который можно будет увидеть на следующем скриншоте — это было до сочинения книжки про «Linux Mint и его Cinnamon». И, конечно же, задолго до знакомства с котом Мануалом — уж он-то сразу вразумил бы меня, что Список символов представляет собой лёгкий и удобный способ навигацию по тексту, включающем какие-либо коды. Например, теги HTML-разметки:

В котором можно развернуть, например, заголовки 2-го уровня и щелчком на имени рубрики переместиться к ней:

И потом проделать то же самое для заголовков 3-го уровня (или сколько их там есть):

Список заголовков каждого уровня может быть отсортирован по имени (это умолчание Geany) или по появлению в тексте (что удобней при навигации по HTML-файлу):

Конечно, это — не совсем представление структуры документа, а именно список рубрик. Однако такая возможность оказалась незаменимой при сборке книжек из отдельных ранее написанных статей и глав.

Впрочем, навигация по списку символов оказалась не менее удобной и при редактировании конфигурационных файлов. И вот здесь сортировка списка по имени может в некоторых случаях оказаться предпочтительной:

Можно предполагать, что механизм списка символов оказался бы полезным и при работе с make-файлами и прочими конфигами при сборке ядра и прочих софтин. Но, к счастью (или всё-таки к сожалению?) такие задачи для нас с Мануалом нынче не актуальны.

Джинни

Джинни, вставай, идем.

Вставай, пожалуйста, ты же вся промокнешь.

Уже поздно, идем, мы должны уйти отсюда,

Вон из лесу, ты не понимаешь?

Где твоя туфля, ты ее потеряла,

Когда я должен был показать тебе дорогу?

Кто потерял? Ты себя?

Я себя? Или мы себя?

(Припев)

Джинни, перестань жить в мечтах.

Джинни, жизнь не такая, как кажется.

Такая одинокая девочка в холодном,

холодном мире.

Есть тот, кому ты нужна.

Джинни, перестань жить в мечтах.

Джинни, жизнь не такая, как кажется.

Ты потерялась в ночи,

Не хочешь сражаться, бороться.

Есть тот, кому ты нужна.

Тут холодно, мы должны уходить, идем.

Твоя помада стерлась.

Я видел, как ты ее покупала.

Много красного на твоих губах.

И ты сказала: «Не навязывайся».

Но я видел тебя насквозь:

Глаза говорят больше, чем слова.

Я же тебе нужен, а?

Все знают, что с сегодняшнего дня

мы вместе.

Сейчас я их слышу! Они идут,

Они идут за тобой.

Они тебя не найдут, ты рядом со мной.

 
Припев
 

Обзор новостей:

За предыдущий месяц число

потерявшихся людей

значительно возросло.

Последняя публикация местного полицейского

участка сообщает об очередном

несчастном случае.

Речь идет об 19-летней девушке,

которую видели в последний раз

14 дней назад.

Полицейские не исключают

вариант преступления.

 
Припев
 

Добавлено Ganna Novytska в чт, 08/03/2012 — 10:40

Files and Directories

A brief description of the contents of the project directory:

Directories

  • Launcher: A binary launcher which is used to set up environment
    variables to run Geany.
  • WhiteSur-light-solid: WhiteSur GTK 3 Theme
  • Papirus, Papirus-Dark: Papirus GTK 3 icon theme with lots of unneeded
    icons removed to save space.
  • iconbuilder.iconset: source Geany icons for the bundle.
  • patches: various patches fixing dependencies to enable bundling.
  • utils: various utility scripts.

Configuration files

  • Info.plist: macOS application configuration file containing some basic
    information such as application name, version, etc. but also additional
    configuration including file types the application can open.
  • geany.bundle: configuration file describing the contents of the app bundle.
  • geany.entitlements: runtime hardening entitlements file.
  • geany.modules: JHBuild modules file with Geany dependencies.
  • settings.ini: default theme configuration file for GTK 3.

Scripts

  • bundle.sh: script creating the app bundle.
  • create_dmg.sh: script calling create-dmg to create the dmg installer
    image.
  • notarize.sh: script for notarizing the dmg using Apple notary service.
  • sign.sh: script signing the app bundle.
Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector