2015-09-03 08:43:49 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 2015 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GTK_COMPOSETABLE_H__
|
|
|
|
#define __GTK_COMPOSETABLE_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
typedef struct _GtkComposeTable GtkComposeTable;
|
|
|
|
typedef struct _GtkComposeTableCompact GtkComposeTableCompact;
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
/* The layout of the data is as follows:
|
|
|
|
*
|
|
|
|
* The first part of the data contains rows of length max_seq_len + 1,
|
|
|
|
* where the first element is the item of the sequence, and the
|
|
|
|
* following elements are offsets to the data for sequences that
|
|
|
|
* start with the first item of length 2, ..., max_seq_len.
|
|
|
|
*
|
|
|
|
* The second part of the data contains the rest of the sequence
|
|
|
|
* data. It does not have a fixed stride. For each sequence, we
|
|
|
|
* put seq[2], ..., seq[len - 1], followed by the encoded value
|
|
|
|
* for this sequence.
|
|
|
|
*
|
|
|
|
* The values are encoded as follows:
|
|
|
|
*
|
2022-09-12 16:01:30 +00:00
|
|
|
* If the value is a single Unicode character smaller than 0x8000,
|
2021-07-08 21:59:50 +00:00
|
|
|
* then we place it directly. Otherwise, we put the UTF8-encoded
|
|
|
|
* value in the char_data array, and use offset | 0x8000 as the
|
|
|
|
* encoded value.
|
|
|
|
*/
|
2015-09-03 08:43:49 +00:00
|
|
|
struct _GtkComposeTable
|
|
|
|
{
|
2015-09-07 09:10:16 +00:00
|
|
|
guint16 *data;
|
2021-02-02 06:09:54 +00:00
|
|
|
char *char_data;
|
2020-07-24 13:54:49 +00:00
|
|
|
int max_seq_len;
|
2021-07-08 21:59:50 +00:00
|
|
|
int n_index_size;
|
|
|
|
int data_size;
|
2021-02-02 06:09:54 +00:00
|
|
|
int n_chars;
|
2021-07-15 12:14:40 +00:00
|
|
|
int n_sequences;
|
2015-09-07 09:10:16 +00:00
|
|
|
guint32 id;
|
2015-09-03 08:43:49 +00:00
|
|
|
};
|
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
GtkComposeTable * gtk_compose_table_new_with_file (const char *compose_file);
|
2021-07-14 11:38:32 +00:00
|
|
|
GtkComposeTable * gtk_compose_table_parse (const char *compose_file,
|
|
|
|
gboolean *found_include);
|
2021-07-08 21:59:50 +00:00
|
|
|
GtkComposeTable * gtk_compose_table_new_with_data (const guint16 *data,
|
|
|
|
int max_seq_len,
|
|
|
|
int n_seqs);
|
2015-09-03 08:43:49 +00:00
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
typedef void (* GtkComposeSequenceCallback) (gunichar *sequence,
|
|
|
|
int len,
|
|
|
|
const char *value,
|
|
|
|
gpointer data);
|
2021-02-02 00:40:22 +00:00
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
void gtk_compose_table_foreach (const GtkComposeTable *table,
|
|
|
|
GtkComposeSequenceCallback callback,
|
|
|
|
gpointer data);
|
2015-09-07 09:10:16 +00:00
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
gboolean gtk_compose_table_check (const GtkComposeTable *table,
|
2021-08-02 23:15:16 +00:00
|
|
|
const guint *compose_buffer,
|
2021-07-08 21:59:50 +00:00
|
|
|
int n_compose,
|
|
|
|
gboolean *compose_finish,
|
|
|
|
gboolean *compose_match,
|
|
|
|
GString *output);
|
2021-02-02 01:27:38 +00:00
|
|
|
|
2021-07-29 12:23:40 +00:00
|
|
|
void gtk_compose_table_get_prefix (const GtkComposeTable *table,
|
2021-08-02 23:15:16 +00:00
|
|
|
const guint *compose_buffer,
|
2021-07-29 12:23:40 +00:00
|
|
|
int n_compose,
|
|
|
|
int *prefix);
|
|
|
|
|
2021-08-02 23:15:16 +00:00
|
|
|
gboolean gtk_check_algorithmically (const guint *compose_buffer,
|
2021-07-08 21:59:50 +00:00
|
|
|
int n_compose,
|
2021-07-29 19:47:04 +00:00
|
|
|
GString *output);
|
2021-02-02 01:27:38 +00:00
|
|
|
|
2021-07-08 21:59:50 +00:00
|
|
|
guint32 gtk_compose_table_data_hash (const guint16 *data,
|
|
|
|
int max_seq_len,
|
|
|
|
int n_seqs);
|
2021-02-02 01:27:38 +00:00
|
|
|
|
2022-10-20 10:59:17 +00:00
|
|
|
char * gtk_compose_table_get_x11_compose_file_dir (void);
|
|
|
|
|
2015-09-03 08:43:49 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GTK_COMPOSETABLE_H__ */
|