1 /* # skkinput (Simple Kana-Kanji Input)
2  *
3  * This file is part of skkinput.
4  * Copyright (C) 2002
5  * Takashi SAKAMOTO (PXG01715@nifty.ne.jp)
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with skkinput; see the file COPYING.  If not, write to
19  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 #include "local.h"
22 #include <stdio.h>
23 #include <assert.h>
24 #include "lispmgrp.h"
25 #include "limclient.h"
26 
27 #define	lispEntity_GetIMClientPtr(ptr)	((TLispIMClient*)((TLispEntity *)(ptr) + 1))
28 
29 Boolean
lispMgr_CreateIMClient(register TLispManager * pLispMgr,register void * pvClient,register void (* pKeyNotify)(),register void (* pTextNotify)(),register void (* pEndNotify)(),register TLispEntity ** const ppEntReturn)30 lispMgr_CreateIMClient (
31 	register TLispManager*			pLispMgr,
32 	register void*					pvClient,
33 	register void					(*pKeyNotify)(),
34 	register void					(*pTextNotify)(),
35 	register void					(*pEndNotify)(),
36 	register TLispEntity** const	ppEntReturn)
37 {
38 	TLispEntity*			pEntity ;
39 	register TLispIMClient*	pIMClient ;
40 	register size_t			nSize ;
41 
42 	assert (pLispMgr    != NULL) ;
43 	assert (pvClient    != NULL) ;
44 	assert (ppEntReturn != NULL) ;
45 
46 	nSize	= sizeof (TLispIMClient) ;
47 	if (TFAILED (lispMgr_AllocateEntity (pLispMgr, nSize, &pEntity)))
48 		return	False ;
49 
50 	pEntity->m_iType		= LISPENTITY_IMCLIENT ;
51 	pEntity->m_lReferCount	= 0 ;
52 	pIMClient				= lispEntity_GetIMClientPtr (pEntity) ;
53 	pIMClient->m_pvClient		= pvClient ;
54 	pIMClient->m_pKeyNotify		= pKeyNotify ;
55 	pIMClient->m_pTextNotify	= pTextNotify ;
56 	pIMClient->m_pEndNotify		= pEndNotify ;
57 	lispMgr_RegisterMisc (pLispMgr, pEntity) ;
58 
59 	*ppEntReturn	= pEntity ;
60 	return	True ;
61 }
62 
63 void
lispIMClient_Destroy(register TLispEntity * pEntity)64 lispIMClient_Destroy (
65 	register TLispEntity*	pEntity)
66 {
67 	return ;
68 }
69 
70 Boolean
lispIMClient_KeyNotify(register TLispEntity * pEntity,register TXEvent * pEv)71 lispIMClient_KeyNotify (
72 	register TLispEntity*	pEntity,
73 	register TXEvent*		pEv)
74 {
75 	register TLispIMClient*	pIMClient ;
76 
77 	assert (pEntity != NULL) ;
78 
79 	pIMClient	= lispEntity_GetIMClientPtr (pEntity) ;
80 	assert (pIMClient->m_pvClient != NULL) ;
81 	/*	XEvent ������ˡ�ˤĤ��ƹͻ����ʤ���С��⤷
82 	 *	�����Ǥ��ʤ��Τʤ顢�Ф��Ƥ��������ʤ�������*/
83 	(pIMClient->m_pKeyNotify)(pIMClient->m_pvClient, pEv) ;
84 	return	True ;
85 }
86 
87 Boolean
lispIMClient_TextNotify(register TLispEntity * pEntity,register const Char * pText,register int nText)88 lispIMClient_TextNotify (
89 	register TLispEntity*	pEntity,
90 	register const Char*	pText,
91 	register int			nText)
92 {
93 	register TLispIMClient*	pIMClient ;
94 
95 	assert (pEntity != NULL) ;
96 
97 	if (pText != NULL && nText > 0) {
98 		pIMClient	= lispEntity_GetIMClientPtr (pEntity) ;
99 		assert (pIMClient->m_pvClient != NULL) ;
100 		(pIMClient->m_pTextNotify)(pIMClient->m_pvClient, pText, nText) ;
101 	}
102 	return	True ;
103 }
104 
105 Boolean
lispIMClient_EndNotify(register TLispEntity * pEntity)106 lispIMClient_EndNotify (
107 	register TLispEntity*	pEntity)
108 {
109 	register TLispIMClient*	pIMClient ;
110 
111 	assert (pEntity != NULL) ;
112 
113 	pIMClient	= lispEntity_GetIMClientPtr (pEntity) ;
114 	(pIMClient->m_pEndNotify)(pIMClient->m_pvClient) ;
115 	return	True ;
116 }
117 
118 
119 
120 
121