TCRC Tibetan Input Method



I'd like to submit a new input method, TCRC Tibetan (Unicode), for
inclusion in GTK+.
This input method was originally developed by the Tibetan Computer
Resource Centre (TCRC -- Dharamsala, India) and is the standard way of
inputting Tibetan text outside of Tibet proper.
The input method descends from GtkIMContextSimple and is essentially
just table-based with the exception of a handful of keys which map (as
shortcuts) to multiple key events.
Two files attached:
1)  imtcrc.c -- the input method proper
2)  tibetan-keysyms.h -- list of key definitions, to be pasted into
gdk/gdkkeysyms.h

Notes:
1)  There are eight keys (marked FIXME) that I still need to get
clarification on... I'll do this as soon as possible.  All the other
key mappings have been tested and confirmed correct.

-- 
Jonas Bonn
McLeod Ganj, India
/* GTK - The GIMP Toolkit
 * Copyright (C) 2000 Red Hat Software
 * Copyright (C) 2005 Jonas Bonn
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Based on imcedilla.c, original author: Owen Taylor <otaylor redhat com>
 * Modified for TCRC Tibetan by: Jonas Bonn <jonas bonn gmail com>
 *
 */

#include <config.h>
#include <string.h>

#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>

#include "gtk/gtkintl.h"
#include "gtk/gtkimcontext.h"
#include "gtk/gtkimcontextsimple.h"
#include "gtk/gtkimmodule.h"

GType type_tcrc = 0;

static GtkIMContextSimpleClass *parent_class = NULL;

static void tcrc_class_init (GtkIMContextSimpleClass *class);
static void tcrc_init (GtkIMContextSimple *im_context);

static gboolean tcrc_filter_keypress(GtkIMContext* context, GdkEventKey* event);

static void
tcrc_register_type (GTypeModule *module)
{
  static const GTypeInfo object_info =
  {
    sizeof (GtkIMContextSimpleClass),
    (GBaseInitFunc) NULL,
    (GBaseFinalizeFunc) NULL,
    (GClassInitFunc) tcrc_class_init,
    NULL,           /* class_finalize */
    NULL,           /* class_data */
    sizeof (GtkIMContextSimple),
    0,
    (GInstanceInitFunc) tcrc_init,
  };

  type_tcrc = 
    g_type_module_register_type (module,
				 GTK_TYPE_IM_CONTEXT_SIMPLE,
				 "GtkIMContextTCRC",
				 &object_info, 0);
}

static guint16 tcrc_compose_seqs[] = {
  GDK_space,0,0,0,0,GDK_Tibetan_Tsheg,
  GDK_exclam,0,0,0,0,GDK_Tibetan_Rin_Chen_Spungs_Chad,
  GDK_quotedbl,0,0,0,0,GDK_Tibetan_Subjoined_Aa,
/*  GDK_numbersign,0,0,0,0,GDK_Tibetan_?, */ /*FIXME*/
/*  GDK_dollar,0,0,0,0,GDK_Tibet_? */ /*FIXME*/
  GDK_ampersand,0,0,0,0,GDK_Tibetan_Ang_Khang_Gyon,
  GDK_apostrophe,0,0,0,0,GDK_Tibetan_Aa,
  GDK_quoteright,0,0,0,0,GDK_Tibetan_Tsheg,
  GDK_asterisk,0,0,0,0,GDK_Tibetan_Ang_Khang_Gyas,
  GDK_plus,0,0,0,0,GDK_Tibetan_Anusvara, 
  GDK_minus,0,0,0,0,GDK_Tibetan_Reversed_I,
  GDK_slash,0,0,0,0,GDK_Tibetan_Shad,
  GDK_0,0,0,0,0,GDK_Tibetan_Zero,
  GDK_1,0,0,0,0,GDK_Tibetan_One,
  GDK_2,0,0,0,0,GDK_Tibetan_Two,
  GDK_3,0,0,0,0,GDK_Tibetan_Three,
  GDK_4,0,0,0,0,GDK_Tibetan_Four,
  GDK_5,0,0,0,0,GDK_Tibetan_Five,
  GDK_6,0,0,0,0,GDK_Tibetan_Six,
  GDK_7,0,0,0,0,GDK_Tibetan_Seven,
  GDK_8,0,0,0,0,GDK_Tibetan_Eight,
  GDK_9,0,0,0,0,GDK_Tibetan_Nine,
  GDK_colon,0,0,0,0,GDK_Tibetan_Rnam_Bcad,
  GDK_semicolon,0,0,0,0,GDK_Tibetan_Ddha,
/*  GDK_equal,0,0,0,0,GDK_Tibetan_?, */ /* FIXME */
  GDK_at,0,0,0,0,GDK_Tibetan_Yig_Mgo_Mdun_Ma,
  GDK_A,0,0,0,0,GDK_Tibetan_A,
  GDK_B,0,0,0,0,GDK_Tibetan_Bha,
  GDK_C,0,0,0,0,GDK_Tibetan_Cha,
  GDK_D,0,0,0,0,GDK_Tibetan_Dza,
  GDK_E,0,0,0,0,GDK_Tibetan_Ee,
  GDK_F,0,0,0,0,GDK_Tibetan_Dha,
  GDK_G,0,0,0,0,GDK_Tibetan_Gha,
  GDK_H,0,0,0,0,GDK_Tibetan_Subjoined_Ha,
  GDK_I,0,0,0,0,GDK_Tibetan_Ii,
  GDK_J,0,0,0,0,GDK_Tibetan_Dzha,
  GDK_K,0,0,0,0,GDK_Tibetan_Kha,
  GDK_M,0,0,0,0,GDK_Tibetan_Sa,
  GDK_N,0,0,0,0,GDK_Tibetan_Nya,
  GDK_O,0,0,0,0,GDK_Tibetan_Oo,
  GDK_P,0,0,0,0,GDK_Tibetan_Pha,
  GDK_Q,0,0,0,0,GDK_Tibetan_Tha,
  GDK_S,0,0,0,0,GDK_Tibetan_Sha,
  GDK_T,0,0,0,0,GDK_Tibetan_Tha,
  GDK_U,0,0,0,0,GDK_Tibetan_Uu,
  GDK_V,0,0,0,0,GDK_Tibetan_Nna,
  GDK_W,0,0,0,0,GDK_Tibetan_Subjoined_Wa,
  GDK_X,0,0,0,0,GDK_Tibetan_Tsha,
  GDK_Y,0,0,0,0,GDK_hyphen,
  GDK_Z,0,0,0,0,GDK_Tibetan_Zha,  
  GDK_bracketleft,0,0,0,0,GDK_quoteright,
/*  GDK_backslash,0,0,0,0,GDK_Tibetan_?, */  /* FIXME */
  GDK_bracketright,0,0,0,0,GDK_comma,
/*  GDK_asciicircum,0,0,0,0,GDK_Tibetan_?, */ /* FIXME */
  GDK_underscore,0,0,0,0,GDK_Tibetan_Reversed_Ii,
  GDK_grave,0,0,0,0,GDK_Tibetan_Nonbreaking_Tsheg,
  GDK_a,0,0,0,0,GDK_Tibetan_Halanta,
  GDK_a,GDK_B,0,0,0,GDK_Tibetan_Subjoined_Bha,
  GDK_a,GDK_C,0,0,0,GDK_Tibetan_Subjoined_Cha,
  GDK_a,GDK_D,0,0,0,GDK_Tibetan_Subjoined_Dza,
  GDK_a,GDK_F,0,0,0,GDK_Tibetan_Subjoined_Dha,
  GDK_a,GDK_G,0,0,0,GDK_Tibetan_Subjoined_Gha,
  GDK_a,GDK_H,0,0,0,GDK_Tibetan_Subjoined_Ha,
  GDK_a,GDK_J,0,0,0,GDK_Tibetan_Subjoined_Dzha,
  GDK_a,GDK_K,0,0,0,GDK_Tibetan_Subjoined_Kha,
  GDK_a,GDK_M,0,0,0,GDK_Tibetan_Subjoined_Ssa,
  GDK_a,GDK_N,0,0,0,GDK_Tibetan_Subjoined_Nya,
  GDK_a,GDK_P,0,0,0,GDK_Tibetan_Subjoined_Pha,
  GDK_a,GDK_Q,0,0,0,GDK_Tibetan_Subjoined_Ttha,
  GDK_a,GDK_S,0,0,0,GDK_Tibetan_Subjoined_Sha,
  GDK_a,GDK_T,0,0,0,GDK_Tibetan_Subjoined_Tha,
  GDK_a,GDK_V,0,0,0,GDK_Tibetan_Subjoined_Nna,
  GDK_a,GDK_X,0,0,0,GDK_Tibetan_Subjoined_Tsha,
  GDK_a,GDK_Z,0,0,0,GDK_Tibetan_Subjoined_Zha,
  GDK_a,GDK_b,0,0,0,GDK_Tibetan_Subjoined_Ba,
  GDK_a,GDK_c,0,0,0,GDK_Tibetan_Subjoined_Ca,
  GDK_a,GDK_d,0,0,0,GDK_Tibetan_Subjoined_Da,
  GDK_a,GDK_f,0,0,0,GDK_Tibetan_Subjoined_Nga,
  GDK_a,GDK_g,0,0,0,GDK_Tibetan_Subjoined_Ga,
  GDK_a,GDK_h,0,0,0,GDK_Tibetan_Subjoined_Ha,
  GDK_a,GDK_j,0,0,0,GDK_Tibetan_Subjoined_Ja,
  GDK_a,GDK_k,0,0,0,GDK_Tibetan_Subjoined_Ka,
  GDK_a,GDK_l,0,0,0,GDK_Tibetan_Subjoined_La,
  GDK_a,GDK_m,0,0,0,GDK_Tibetan_Subjoined_Ma,
  GDK_a,GDK_n,0,0,0,GDK_Tibetan_Subjoined_Na,
  GDK_a,GDK_p,0,0,0,GDK_Tibetan_Subjoined_Pa,
  GDK_a,GDK_q,0,0,0,GDK_Tibetan_Subjoined_Tta,
  GDK_a,GDK_r,0,0,0,GDK_Tibetan_Subjoined_Ra,
  GDK_a,GDK_s,0,0,0,GDK_Tibetan_Subjoined_Sa,
  GDK_a,GDK_t,0,0,0,GDK_Tibetan_Subjoined_Ta,
  GDK_a,GDK_v,0,0,0,GDK_Tibetan_Subjoined_Dda,
  GDK_a,GDK_w,0,0,0,GDK_Tibetan_Subjoined_Wa,
  GDK_a,GDK_x,0,0,0,GDK_Tibetan_Subjoined_Tsa,
  GDK_a,GDK_y,0,0,0,GDK_Tibetan_Subjoined_Ya,
  GDK_a,GDK_z,0,0,0,GDK_Tibetan_Subjoined_Za,
  GDK_b,0,0,0,0,GDK_Tibetan_Ba,
  GDK_c,0,0,0,0,GDK_Tibetan_Ca,
  GDK_d,0,0,0,0,GDK_Tibetan_Da,
  GDK_e,0,0,0,0,GDK_Tibetan_E,
  GDK_f,0,0,0,0,GDK_Tibetan_Nga,
  GDK_g,0,0,0,0,GDK_Tibetan_Ga,
  GDK_h,0,0,0,0,GDK_Tibetan_Ha,
  GDK_i,0,0,0,0,GDK_Tibetan_I,
  GDK_j,0,0,0,0,GDK_Tibetan_Ja,
  GDK_k,0,0,0,0,GDK_Tibetan_Ka,
  GDK_l,0,0,0,0,GDK_Tibetan_La,
  GDK_m,0,0,0,0,GDK_Tibetan_Ma,
  GDK_n,0,0,0,0,GDK_Tibetan_Na,
  GDK_o,0,0,0,0,GDK_Tibetan_O,
  GDK_p,0,0,0,0,GDK_Tibetan_Pa,
  GDK_q,0,0,0,0,GDK_Tibetan_Tta,
  GDK_r,0,0,0,0,GDK_Tibetan_Ra,
  GDK_s,0,0,0,0,GDK_Tibetan_Sa,
  GDK_t,0,0,0,0,GDK_Tibetan_Ta,
  GDK_u,0,0,0,0,GDK_Tibetan_U,
  GDK_v,0,0,0,0,GDK_Tibetan_Dda,
  GDK_w,0,0,0,0,GDK_Tibetan_Wa,
  GDK_x,0,0,0,0,GDK_Tibetan_Tsa,
  GDK_y,0,0,0,0,GDK_Tibetan_Ya,
  GDK_z,0,0,0,0,GDK_Tibetan_Za,
  GDK_braceleft,0,0,0,0,GDK_quoteleft,
/*  GDK_bar,0,0,0,0,GDK_Tibetan_Reversed_?, */ /*FIXME*/
/*  GDK_braceright,0,0,0,0,GDK_Tibetan_?, */ /*FIXME*/
/*  GDK_asciitilde,0,0,0,0,GDK_Tibetan_?, */ /*FIXME*/
};

static void
tcrc_class_init (GtkIMContextSimpleClass *class)
{
	GtkIMContextClass* im_context_class = GTK_IM_CONTEXT_CLASS(class);

	parent_class = g_type_class_peek_parent(class);

	im_context_class->filter_keypress = tcrc_filter_keypress;
}

static void
tcrc_init (GtkIMContextSimple *im_context)
{
  gtk_im_context_simple_add_table (im_context,
				   tcrc_compose_seqs,
				   4,
				   G_N_ELEMENTS (tcrc_compose_seqs) / 6);
}

static const GtkIMContextInfo tcrc_info = { 
  "tcrc",		                 /* ID */
  N_("TCRC Tibetan"),   	   /* Human readable name */ 
  "gtk20",			             /* Translation domain */
   GTK_LOCALEDIR,	           /* Dir for bindtextdomain (not strictly needed for "gtk+") */
  "bo"				               /* Languages for which this module is the default */
};

static const GtkIMContextInfo *info_list[] = {
  &tcrc_info
};

static gboolean
tcrc_filter_keypress(GtkIMContext* context, GdkEventKey* event) 
{
	/* Some key strokes are just shortcuts for other key
     combinations; handle those here and chain up
     to normal key handling of GtkIMContextSimple. 
  */

	switch(event->keyval) {
		case('.'):
			event->keyval = 'a';
			GTK_IM_CONTEXT_CLASS(parent_class)->filter_keypress(context, event);
			event->keyval = 'r';
			break;
		case(','):
			event->keyval = 'a';
			GTK_IM_CONTEXT_CLASS(parent_class)->filter_keypress(context, event);
			event->keyval = 'y';
			break;
		case('<'):
			event->keyval = 'a';
			GTK_IM_CONTEXT_CLASS(parent_class)->filter_keypress(context, event);
			event->keyval = 'l';
			break;
		case('>'):
			event->keyval = 'r';
			GTK_IM_CONTEXT_CLASS(parent_class)->filter_keypress(context, event);
			event->keyval = 'a';
			break;
		case('?'):
			event->keyval = 'A';
			GTK_IM_CONTEXT_CLASS(parent_class)->filter_keypress(context, event);
			event->keyval = 'a';
			break;
		case('L'):
			event->keyval = 'l';
			GTK_IM_CONTEXT_CLASS(parent_class)->filter_keypress(context, event);
			event->keyval = 'a';
			break;
		case('R'):
			event->keyval = 'r';
			GTK_IM_CONTEXT_CLASS(parent_class)->filter_keypress(context, event);
			event->keyval = 'a';
			break;
		default: break;
	}

	return GTK_IM_CONTEXT_CLASS(parent_class)->filter_keypress(context, event);
}

void
im_module_init (GTypeModule *module)
{
  tcrc_register_type (module);
}

void 
im_module_exit (void)
{
}

void 
im_module_list (const GtkIMContextInfo ***contexts,
		int                      *n_contexts)
{
  *contexts = info_list;
  *n_contexts = G_N_ELEMENTS (info_list);
}

GtkIMContext *
im_module_create (const gchar *context_id)
{
  if (strcmp (context_id, "tcrc") == 0)
    return g_object_new (type_tcrc, NULL);
  else
    return NULL;
}
#define GDK_Tibetan_Yig_Mgo_Mdun_Ma 0x0f04
#define GDK_Tibetan_Yig_Mgo_Sgab_Ma 0x0f05
#define GDK_Tibetan_Rin_Chen_Spungs_Chad 0x0f11
#define GDK_Tibetan_Ngas_Bzung_Sgor_Rtags 0x0f37
#define GDK_Tibetan_Ang_Khang_Gyon 0x0f3c
#define GDK_Tibetan_Ang_Khang_Gyas 0x0f3d
#define GDK_Tibetan_Tsheg 0x0f0b
#define GDK_Tibetan_Nonbreaking_Tsheg 0x0f0c
#define GDK_Tibetan_Shad 0x0f0d
#define GDK_Tibetan_Zero 0x0f20
#define GDK_Tibetan_One 0x0f21
#define GDK_Tibetan_Two 0x0f22
#define GDK_Tibetan_Three 0x0f23
#define GDK_Tibetan_Four 0x0f24
#define GDK_Tibetan_Five 0x0f25
#define GDK_Tibetan_Six 0x0f26
#define GDK_Tibetan_Seven 0x0f27
#define GDK_Tibetan_Eight 0x0f28
#define GDK_Tibetan_Nine 0x0f29	
#define GDK_Tibetan_Ka 0x0f40
#define GDK_Tibetan_Kha 0x0f41
#define GDK_Tibetan_Ga 0x0f42
#define GDK_Tibetan_Gha 0x0f43
#define GDK_Tibetan_Nga 0x0f44
#define GDK_Tibetan_Ca 0x0f45
#define GDK_Tibetan_Cha 0x0f46
#define GDK_Tibetan_Ja 0x0f47
#define GDK_Tibetan_Nya 0x0f49
#define GDK_Tibetan_Tta 0x0f4a
#define GDK_Tibetan_Ttha 0x0f4b
#define GDK_Tibetan_Dda 0x0f4c
#define GDK_Tibetan_Ddha 0x0f4d
#define GDK_Tibetan_Nna 0x0f4e
#define GDK_Tibetan_Ta 0x0f4f
#define GDK_Tibetan_Tha 0x0f50
#define GDK_Tibetan_Da 0x0f51
#define GDK_Tibetan_Dha 0x0f52
#define GDK_Tibetan_Na 0x0f53
#define GDK_Tibetan_Pa 0x0f54
#define GDK_Tibetan_Pha 0x0f55
#define GDK_Tibetan_Ba 0x0f56
#define GDK_Tibetan_Bha 0x0f57
#define GDK_Tibetan_Ma 0x0f58
#define GDK_Tibetan_Tsa 0x0f59
#define GDK_Tibetan_Tsha 0x0f5a
#define GDK_Tibetan_Dza 0x0f5b
#define GDK_Tibetan_Dzha 0x0f5c
#define GDK_Tibetan_Wa 0x0f5d
#define GDK_Tibetan_Zha 0x0f5e
#define GDK_Tibetan_Za 0x0f5f
#define GDK_Tibetan_Aa 0x0f60
#define GDK_Tibetan_Ya 0x0f61
#define GDK_Tibetan_Ra 0x0f62
#define GDK_Tibetan_La 0x0f63
#define GDK_Tibetan_Sha 0x0f64
#define GDK_Tibetan_Ssa 0x0f65
#define GDK_Tibetan_Sa 0x0f66
#define GDK_Tibetan_Ha 0x0f67
#define GDK_Tibetan_A 0x0f68
#define GDK_Tibetan_Kssa 0x0f69
#define GDK_Tibetan_I 0x0f72
#define GDK_Tibetan_Ii 0x0f73
#define GDK_Tibetan_U 0x0f74
#define GDK_Tibetan_Uu 0x0f75
#define GDK_Tibetan_E 0x0f7a
#define GDK_Tibetan_Ee 0x0f7b
#define GDK_Tibetan_O 0x0f7c
#define GDK_Tibetan_Oo 0x0f7d
#define GDK_Tibetan_Anusvara 0x0f7e
#define GDK_Tibetan_Rnam_Bcad 0x0f7f
#define GDK_Tibetan_Reversed_I 0x0f80
#define GDK_Tibetan_Reversed_Ii 0x0f81
#define GDK_Tibetan_Halanta 0x0f84
#define GDK_Tibetan_Subjoined_Ka 0x0f90
#define GDK_Tibetan_Subjoined_Kha 0x0f91
#define GDK_Tibetan_Subjoined_Ga 0x0f92
#define GDK_Tibetan_Subjoined_Gha 0x0f93
#define GDK_Tibetan_Subjoined_Nga 0x0f94
#define GDK_Tibetan_Subjoined_Ca 0x0f95
#define GDK_Tibetan_Subjoined_Cha 0x0f96
#define GDK_Tibetan_Subjoined_Ja 0x0f97
#define GDK_Tibetan_Subjoined_Nya 0x0f99
#define GDK_Tibetan_Subjoined_Tta 0x0f9a
#define GDK_Tibetan_Subjoined_Ttha 0x0f9b
#define GDK_Tibetan_Subjoined_Dda 0x0f9c
#define GDK_Tibetan_Subjoined_Ddha 0x0f9d
#define GDK_Tibetan_Subjoined_Nna 0x0f9e
#define GDK_Tibetan_Subjoined_Ta 0x0f9f
#define GDK_Tibetan_Subjoined_Tha 0x0fa0
#define GDK_Tibetan_Subjoined_Da 0x0fa1
#define GDK_Tibetan_Subjoined_Dha 0x0fa2
#define GDK_Tibetan_Subjoined_Na 0x0fa3
#define GDK_Tibetan_Subjoined_Pa 0x0fa4
#define GDK_Tibetan_Subjoined_Pha 0x0fa5
#define GDK_Tibetan_Subjoined_Ba 0x0fa6
#define GDK_Tibetan_Subjoined_Bha 0x0fa7
#define GDK_Tibetan_Subjoined_Ma 0x0fa8
#define GDK_Tibetan_Subjoined_Tsa 0x0fa9
#define GDK_Tibetan_Subjoined_Tsha 0x0faa
#define GDK_Tibetan_Subjoined_Dza 0x0fab
#define GDK_Tibetan_Subjoined_Dzha 0x0fac
#define GDK_Tibetan_Subjoined_Wa 0x0fad
#define GDK_Tibetan_Subjoined_Zha 0x0fae
#define GDK_Tibetan_Subjoined_Za 0x0faf
#define GDK_Tibetan_Subjoined_Aa 0x0fb0
#define GDK_Tibetan_Subjoined_Ya 0x0fb1
#define GDK_Tibetan_Subjoined_Ra 0x0fb2
#define GDK_Tibetan_Subjoined_La 0x0fb3
#define GDK_Tibetan_Subjoined_Sha 0x0fb4
#define GDK_Tibetan_Subjoined_Ssa 0x0fb5
#define GDK_Tibetan_Subjoined_Sa 0x0fb6
#define GDK_Tibetan_Subjoined_Ha 0x0fb7
#define GDK_Tibetan_Subjoined_A 0x0fb8
#define GDK_Tibetan_Subjoined_Kssa 0x0fb9


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]