Jump to content

[TUT]How to use Geany as the script editor of LUA


Recommended Posts

Introduction

In this tutorial, I will show you how to use Geany as the scripting editor of LUA.

Downloading

The first step is to download the program Geany. You can do that by visiting their website and clicking the Download link or just by clicking this. I prefer going here then downloading the latest version for bug fixes and new features.

Installing

The installation is pretty self explanatory if you are using binary installer.

Installation

============

Requirements

------------

You will need the GTK (>= 2.12.0) libraries and their dependencies

(Pango, GLib and ATK). Your distro should provide packages for these,

usually installed by default. For Windows, you can download an installer

from the website which bundles these libraries.

Binary packages

---------------

There are many binary packages available. For an up-to-date but maybe

incomplete list see http://www.geany.org/Download/ThirdPartyPackages.

Source compilation

------------------

Compiling Geany is quite easy.

To do so, you need the GTK (>= 2.12.0) libraries and header files.

You also need the Pango, GLib and ATK libraries and header files.

All these files are available at http://www.gtk.org, but very often

your distro will provide development packages to save the trouble of

building these yourself.

Furthermore you need, of course, a C and C++ compiler. The GNU versions

of these tools are recommended.

Autotools based build system

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The Autotools based build system is very mature and has been well tested.

To use it, you just need the Make tool, preferably GNU Make.

Then run the following commands::

$ ./configure

$ make

Then as root::

% make install

Waf based build system

^^^^^^^^^^^^^^^^^^^^^^

The Waf build system is still quite young and under heavy development but already in a

usable state. In contrast to the Autotools system, Waf needs Python. So before using Waf, you need

to install Python on your system.

The advantage of the Waf build system over the Autotools based build system is that the whole

build process might be a bit faster. Especially when you use the Waf

cache feature for repetitive builds (e.g. when changing only a few source files

to test something) will become much faster since Waf will cache and re-use the

unchanged built files and only compile the changed code again. See `Waf Cache`_ for details.

To build Geany with Waf as run::

$ ./waf configure

$ ./waf build

Then as root::

% ./waf install

Waf cache

`````````

The Waf build system has a nice and interesting feature which can help to avoid

a lot of unnecessary rebuilding of unchanged code. This often happens when developing new features

or trying to debug something in Geany.

Waf is able to store and retrieve the object files from a cache. This cache is declared

using the environment variable ``WAFCACHE``.

A possible location of the cache directory could be ``~/.cache/waf``. In order to make use of

this, you first need to create this directory::

$ mkdir -p ~/.cache/waf

then add the environment variable to your shell configuration (the following example is for

Bash and should be adjusted to your used shell)::

export WAFCACHE=/home/username/.cache/waf

Remember to replace ``username`` with your actual username.

More information about the Waf cache feature are available at

http://code.google.com/p/waf/wiki/CacheObjectFiles.

Cleaning the cache

******************

You should be careful about the size of the cache directory as it may

grow rapidly over time.

Waf doesn't do any cleaning or other house-keeping of the cache yet, so you need to keep it

clean by yourself.

An easy way to keep it clean is to run the following command regularly to remove old

cached files::

$ find /home/username/.cache/waf -mtime +14 -exec rm {} \;

This will delete all files in the cache directory which are older than 14 days.

For details about the ``find`` command and its options, check its manual page.

Custom installation

^^^^^^^^^^^^^^^^^^^

The configure script supports several common options, for a detailed

list, type::

$ ./configure --help

or::

$ ./waf --help

(depending on which build system you use).

You may also want to read the INSTALL file for advanced installation

options.

* See also `Compile-time options`_.

Dynamic linking loader support and VTE

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In the case that your system lacks dynamic linking loader support, you

probably want to pass the option ``--disable-vte`` to the ``configure``

script. This prevents compiling Geany with dynamic linking loader

support for automatically loading ``libvte.so.4`` if available.

Build problems

^^^^^^^^^^^^^^

If there are any errors during compilation, check your build

environment and try to find the error, otherwise contact the mailing

list or one the authors. Sometimes you might need to ask for specific

help from your distribution.

Installation prefix

-------------------

If you want to find Geany's system files after installation you may

want to know the installation prefix.

Pass the ``--print-prefix`` option to Geany to check this - see

`Command line options`_. The first path is the prefix.

On Unix-like systems this is commonly ``/usr`` if you installed from

a binary package, or ``/usr/local`` if you build from source.

.. note::

Editing system files is not necessary as you can use the

per-user configuration files instead, which don't need root

permissions. See `Configuration files`_.

Running

You can run the program by going to the directory the program installed and opening the executable named Geany. If you chose Creating Shortcut then you will find it on your desktop duh.

Setting

Now, I will tell you how to set it up. You can change the preference if you want but that really doesn't matters. Now we will just create a dummy file in order to access the preference. To do that, click on File->New or Ctrl+N as keyboard shortcut. Now, click Edit->Preferences or Ctrl+Alt+P as keyboard shortcut. Go to Editor->Completions and enable Snippet completion. Then just click Apply and if you want, you can customize to your needs.

Snippet

This is one of the cool features of Geany. You can add custom snippets and access it by pressing the tab key. Go to Tools->Configurations files->snippets.conf. Then under

 section add this.

[code=text] 
[Lua]
for=for key,value in %cursor% do \n\t\nend
if=if %cursor% then \n\nend
while=while i > %cursor% do \n\nend
repeat=repeat \n\nuntil i %cursor%
 
[/code]

So that it look like this.

[code=text] 
[html]
table=<table>\n\t<tr>\n\t\t<td>%cursor%</td>\n\t</tr>\n</table>
 
[Lua]
for=for key,value in %cursor% do \n\t\nend
if=if %cursor% then \n\nend
while=while i > %cursor% do \n\nend
repeat=repeat \n\nuntil i %cursor%
 
[/code]

[u][size=0]How it works?[/size][/u]

This is how it works. First of all you have to write the name of the snippet which will be the keyword. Then you will add the thing which will occur after you write the keyword and press tab. \n is for new line and \t is for tab. %cursor% is the place where the cursor will be located afterwards. Don't forget to save and see the changes in real time. :)

[b][i]If you have any problems or questions, please ask below.[/i][/b]

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...