evil-qemacs/plugins/my_plugin.c
Charlie Gordon deb6972ca3 better charset handling
* make eb_insert_buffer return the number of bytes inserted
* reset page bits upon charset change
* add eb_delete_nextc: delete one encoded character at offset
* add eb_insert_uchar: insert a unicode character with encoding
* add eb_insert_utf8_buf: insert a utf8 encoded buffer with conversion
* make eb_printf insert utf8 bytes with conversion
* add eb_insert_buffer_convert: copy chars between buffers with charset
  conversion
* handle charset conversion correctly in various places
* insert wide caracters from hex mode
* create most buffers as BF_UTF8 by default
* set kill-buffer charset to that of kill source
* convert charsets when yanking
* handle charsets in search/replace system
2014-01-06 09:40:20 +00:00

30 lines
581 B
C

/*
* Simple plugin example
*/
#include "qe.h"
/* insert 'hello' at the current cursor position */
static void insert_hello(EditState *s)
{
static char hello[] = "Hello";
int len = strlen(hello);
s->offset += eb_insert_utf8_buf(s->b, s->offset, hello, len);
}
static CmdDef my_commands[] = {
CMD2( KEY_CTRLX('h'), KEY_NONE,
"insert-hello", insert_hello, ES, "*")
CMD_DEF_END,
};
static int my_plugin_init(void)
{
/* commands and default keys */
qe_register_cmd_table(my_commands, NULL);
return 0;
}
qe_module_init(my_plugin_init);