Lua plugin for Geany - The Keyfile Module

## The Keyfile module

The `keyfile` module provides a minimal Lua wrapper around the GLib library's `GKeyFile` object, for reading and writing of key-value file data, somewhat similar to MS-Windows `*.INI` files.

This file format is used by Geany for various configuration and project files. Note that this module does not provide any functions for reading or writing disk files, it simply receives or returns its file data as a single continuous string. If you need to read or write a disk file, you can use Lua's built-in `io` module.

The functions are listed below...
Optional parameters are noted in [ square ] brackets.

For get/set style functions, calling the function with the optional parameter assigns a new value, calling the function without the optional parameter returns the current value.

Note that you can also use these functions in object-oriented style:
For instance, `keyfile.value(kf,"foo","bar")`
can also be written as `kf:value("foo","bar")`

`function keyfile.new ()`

Creates a new, empty `keyfile` object.

`function keyfile.data ( kf [, text] )` -- get/set

Returns or assigns the full text of the keyfile.

`function keyfile.groups ( kf )`

Returns an iterator to list the groups within the keyfile.

`function keyfile.keys ( kf, group )`

Returns an iterator to list the keys within the specified group.

`function keyfile.value ( kf, group, key [, value] )` -- get/set

Returns or assigns the value of the specified key.

`function keyfile.comment ( kf, group, key [, comment] )` -- get/set

Returns or assigns the comment for the specified key.
If `key` is nil, it gets/sets the group comment.
If `group` is nil, it gets/sets the comment for the file.

`function keyfile.has ( kf, group [, key] )`

Returns `true` if the specified group (and optionally the key) already exists.

`function keyfile.remove ( kf, group [, key] )`

Deletes the key, if specified, else it deletes the entire group.

© 2007-2008 Jeff Pohlmeyer