rpms/scim-sinhala/F-8 scim-sinhala-preedit-217065.patch, NONE, 1.1 scim-sinhala.spec, 1.6, 1.7
Pravin Satpute (pravins)
fedora-extras-commits at redhat.com
Tue Jan 15 12:40:21 UTC 2008
Author: pravins
Update of /cvs/pkgs/rpms/scim-sinhala/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv29106
Modified Files:
scim-sinhala.spec
Added Files:
scim-sinhala-preedit-217065.patch
Log Message:
* Tue Jan 08 2008 Pravin Satpute <psatpute at redhat.com> - 0.2.0-5
- removed preedit for unneccessary characters(#217065)
- modified scim-sinhala-preedit-217065.patch
* Fri Dec 14 2007 Pravin Satpute <psatpute at redhat.com> - 0.2.0-4
- implemented preedit in scim sinhala(#217065)
scim-sinhala-preedit-217065.patch:
--- NEW FILE scim-sinhala-preedit-217065.patch ---
diff -rup scim-sinhala-trans-0.2.0-20060825/src/scim_sinhala_imengine.cpp scim-sinhala-trans-0.2.0-20060825-modified/src/scim_sinhala_imengine.cpp
--- scim-sinhala-trans-0.2.0-20060825/src/scim_sinhala_imengine.cpp 2006-02-07 11:55:34.000000000 +0530
+++ scim-sinhala-trans-0.2.0-20060825-modified/src/scim_sinhala_imengine.cpp 2008-01-07 16:12:56.000000000 +0530
@@ -28,6 +28,7 @@
#define Uses_SCIM_LOOKUP_TABLE
#define Uses_SCIM_CONFIG_BASE
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -42,6 +43,9 @@
#include "scim_sinhala_imengine.h"
#include "intl.h"
+
+using namespace scim;
+
/*
* A BIG NOTE: Instead of working with three byte UTF-8 encoded
* characters, we will be using the 8 least significant bits of each
@@ -135,6 +139,8 @@ struct {
{0x8f, 0x90, 0x8f, 0x90, SCIM_KEY_Z},
{0, 0, 0, 0, 0}
};
+
+unsigned char nopreedit[] = {0xa4, 0xa5, 0xc0 ,0xbb , 0xba, 0xc6, 0xbd, 0xc5, 0x82, 0x9e, 0xb8, 0xb9};
SinhalaInstance::SinhalaInstance(SinhalaFactory *factory,
const String &encoding, int id) :
@@ -208,11 +214,13 @@ SinhalaInstance::reset ()
{
SCIM_DEBUG_IMENGINE(2) << "reset.\n";
- m_lookup_table.clear ();
+ m_preedit_string = WideString ();
+ update_preedit_string (m_preedit_string);
update_preedit_caret (0);
- update_preedit_string (utf8_mbstowcs (""));
+ m_lookup_table.clear ();
hide_lookup_table ();
hide_preedit_string ();
+
}
void
@@ -320,6 +328,22 @@ SinhalaInstance::find_consonent(int c)
return -1;
}
+/*
+ * search the nopreedit array, useful in deciding wheather to preedit character or
+ * commit it directly
+ */
+
+int
+SinhalaInstance::find_nopreedit(int c)
+{
+ int i = -1;
+ while (nopreedit[++i])
+ if (nopreedit[i]== c)
+ return i;
+ return -1;
+}
+
+
/*
* Search the vowel list to see if a key has a corresponding
@@ -377,6 +401,31 @@ SinhalaInstance::sinhala_transliterated_
if (event.code == 0) return false;
+ //reset key
+ if (event.code == SCIM_KEY_Escape && event.mask == 0) {
+ reset ();
+ return true;
+ }
+
+ //delete key
+ if (event.code == SCIM_KEY_BackSpace && event.mask == 0 &&
+ m_preedit_string.size () != 0) {
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+ return true;
+ }
+
+
+ // commit key
+ if (event.code == SCIM_KEY_space && event.mask == 0 && m_preedit_string.length ()) {
+ commit_string (m_preedit_string);
+ reset ();
+ return true;
+ }
+
+
+
if (event.is_key_release()) {
if (event.code == SCIM_KEY_Shift_L) shift_l = 0;
if (event.code == SCIM_KEY_Shift_R) shift_r = 0;
@@ -441,118 +490,215 @@ SinhalaInstance::handle_consonant_presse
{
int c1, l1;
unsigned char *u = NULL;
-
+
+ if (m_preedit_string.length () == 0) {
+ c1 = find_nopreedit(consonents[c].character);
+ if (c1 >= 0) /* dont preedit. */
+ {
+ u = create_unicode_character_from_lsb(consonents[c].character);
+ commit_string(utf8_mbstowcs((const char*)u));
+ free(u);
+ last_key = lsb_to_unicode(consonents[c].character);
+ return true;
+ }
+ else {
+ show_preedit_string ();
+ m_preedit_string.push_back (lsb_to_unicode(consonents[c].character));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+ return true;
+ }
+ }
+
/* do modifiers first. */
- c1 = get_known_lsb_character(last_key);
+ c1 = get_known_lsb_character((int)m_preedit_string[0]);
l1 = find_consonent(c1);
/* do modifiers only if there is a valid character before */
if (l1 >= 0) {
if (event.code == SCIM_KEY_w) {
- u = create_unicode_character_from_lsb(0xca);
- commit_string(utf8_mbstowcs((const char*)u));
- free(u);
+ commit_string(m_preedit_string);
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+ m_preedit_string.push_back (0x0dca);
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
last_key = 0xdca;
return true;
}
if (event.code == SCIM_KEY_W) {
/* bandi hal kireema */
- unsigned char u[7];
- u[0] = 0xe0; u[1] = 0xb7; u[2] = 0x8a;
- u[3] = 0xe2; u[4] = 0x80; u[5] = 0x8d;
- u[6] = 0;
+ m_preedit_string.push_back (0x0dca);
+ commit_string(m_preedit_string);
+ m_preedit_string.erase (m_preedit_string.length () - 2, 2);
- commit_string(utf8_mbstowcs((const char*)u));
+
+ m_preedit_string.push_back (0x200d);
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
last_key = 0x200d;
return true;
}
if ((event.code == SCIM_KEY_H) && (consonents[l1].mahaprana)) {
- backspace();
- u = create_unicode_character_from_lsb(consonents[l1].mahaprana);
- commit_string(utf8_mbstowcs((const char*)u));
- free(u);
+
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+
+ m_preedit_string.push_back (lsb_to_unicode(consonents[l1].mahaprana));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+
last_key = lsb_to_unicode(consonents[l1].mahaprana);
return true;
}
if ((event.code == SCIM_KEY_G) && (consonents[l1].sagngnaka)) {
- backspace();
- u = create_unicode_character_from_lsb(consonents[l1].sagngnaka);
- commit_string(utf8_mbstowcs((const char*)u));
- free(u);
+
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+ m_preedit_string.push_back (lsb_to_unicode(consonents[l1].sagngnaka));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+
last_key = lsb_to_unicode(consonents[l1].sagngnaka);
return true;
}
if (event.code == SCIM_KEY_R) {
- /* rakaraanshaya */
- unsigned char u[10];
- u[0] = 0xe0; u[1] = 0xb7; u[2] = 0x8a;
- u[3] = 0xe2; u[4] = 0x80; u[5] = 0x8d;
- u[6] = 0xe0; u[7] = 0xb6; u[8] = 0xbb;
- u[9] = 0;
- commit_string(utf8_mbstowcs((const char*)u));
+ m_preedit_string.push_back (0x0dca);
+ m_preedit_string.push_back (0x200d);
+ commit_string(m_preedit_string);
+ m_preedit_string.erase (m_preedit_string.length () - 3, 3);
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+
+
+
+
+ m_preedit_string.push_back (0x0dbb);
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
last_key = 0x0dbb;
return true;
}
if (event.code == SCIM_KEY_Y) {
- /* yansaya */
- unsigned char u[10];
- u[0] = 0xe0; u[1] = 0xb7; u[2] = 0x8a;
- u[3] = 0xe2; u[4] = 0x80; u[5] = 0x8d;
- u[6] = 0xe0; u[7] = 0xb6; u[8] = 0xba;
- u[9] = 0;
- commit_string(utf8_mbstowcs((const char*)u));
+ m_preedit_string.push_back (0x0dca);
+ m_preedit_string.push_back (0x200d);
+
+ commit_string(m_preedit_string);
+ m_preedit_string.erase (m_preedit_string.length () - 3, 3);
+
+ /* yansaya */
+ m_preedit_string.push_back (0x0dba);
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
last_key = 0x0dba;
return true;
}
+
}
- u = create_unicode_character_from_lsb(consonents[c].character);
- commit_string(utf8_mbstowcs((const char*)u));
- free(u);
+ commit_string(m_preedit_string);
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+ c1 = find_nopreedit(consonents[c].character);
+ if (c1 >= 0) /* dont preedit. */
+ {
+ u = create_unicode_character_from_lsb(consonents[c].character);
+ commit_string(utf8_mbstowcs((const char*)u));
+ free(u);
+ last_key = lsb_to_unicode(consonents[c].character);
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+ return true;
+ }
+ else
+ m_preedit_string.push_back (lsb_to_unicode(consonents[c].character));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+
- last_key = lsb_to_unicode(consonents[c].character);
+
+ last_key = lsb_to_unicode(consonents[c].character);
return true;
}
bool
SinhalaInstance::handle_vowel_pressed(const KeyEvent &event, int c)
{
- int c1;
- unsigned char *u = NULL;
+ int c1,l1, c2,l2;
+
+ c2 = get_known_lsb_character(last_key);
+ l2 = find_nopreedit(c2);
+
+
+ if (m_preedit_string.length () == 0) {
+
+ if(l2 >= 0){
+ m_preedit_string.push_back(lsb_to_unicode(vowels[c].single1));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+ last_key = lsb_to_unicode(vowels[c].single1);
+ return true;
+ }
+
+ show_preedit_string ();
+ m_preedit_string.push_back (lsb_to_unicode(vowels[c].single0));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+ return true;
+ }
+
+
+ else {
+
+ /* look for a previous character first. */
+ c1 = get_known_lsb_character((int)m_preedit_string[0]);
+
+
+
+ if (is_consonent(c1)) {
+ commit_string(m_preedit_string);
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+
+ m_preedit_string.push_back(lsb_to_unicode(vowels[c].single1));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+ last_key = lsb_to_unicode(vowels[c].single1);
+ }
+ else if (c1 == vowels[c].single0) {
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+ m_preedit_string.push_back(lsb_to_unicode(vowels[c].double0));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+
+
+ last_key = lsb_to_unicode(vowels[c].double0);
+ }
+ else if (c1 == vowels[c].single1) {
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+ m_preedit_string.push_back(lsb_to_unicode(vowels[c].double1));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
+
+ last_key = lsb_to_unicode(vowels[c].double1);
+ }
+ else {
+ commit_string(m_preedit_string);
+ m_preedit_string.erase (m_preedit_string.length () - 1, 1);
+
+
+ m_preedit_string.push_back(lsb_to_unicode(vowels[c].single0));
+ update_preedit_string (m_preedit_string);
+ update_preedit_caret (m_preedit_string.length ());
- /* look for a previous character first. */
- u = NULL;
- c1 = get_known_lsb_character(last_key);
- if (is_consonent(c1)) {
- u = create_unicode_character_from_lsb(vowels[c].single1);
- last_key = lsb_to_unicode(vowels[c].single1);
- }
- else if (c1 == vowels[c].single0) {
- backspace();
- u = create_unicode_character_from_lsb(vowels[c].double0);
- last_key = lsb_to_unicode(vowels[c].double0);
- }
- else if (c1 == vowels[c].single1) {
- backspace();
- u = create_unicode_character_from_lsb(vowels[c].double1);
- last_key = lsb_to_unicode(vowels[c].double1);
- }
- else {
- u = create_unicode_character_from_lsb(vowels[c].single0);
last_key = lsb_to_unicode(vowels[c].single0);
}
- commit_string(utf8_mbstowcs((const char*)u));
- free(u);
return true;
+ }
}
/*
diff -rup scim-sinhala-trans-0.2.0-20060825/src/scim_sinhala_imengine.h scim-sinhala-trans-0.2.0-20060825-modified/src/scim_sinhala_imengine.h
--- scim-sinhala-trans-0.2.0-20060825/src/scim_sinhala_imengine.h 2006-01-31 11:06:54.000000000 +0530
+++ scim-sinhala-trans-0.2.0-20060825-modified/src/scim_sinhala_imengine.h 2008-01-03 12:49:44.000000000 +0530
@@ -28,6 +28,7 @@
#include <scim.h>
+
using namespace scim;
class SinhalaInstance : public IMEngineInstanceBase
@@ -41,6 +42,8 @@ private:
/* for candidates window */
CommonLookupTable m_lookup_table;
+ std::vector<WideString> m_lookup_table_labels;
+ WideString m_preedit_string;
/* for toolbar */
PropertyList m_properties;
@@ -83,6 +86,7 @@ private:
int is_consonent (int c);
int find_consonent_by_key (int k);
int find_consonent (int c);
+ int find_nopreedit (int c);
int find_vowel_by_key (int k);
unsigned char* create_unicode_character_from_lsb (unsigned int lsb);
bool sinhala_transliterated_filter_keypress (const KeyEvent &key);
Index: scim-sinhala.spec
===================================================================
RCS file: /cvs/pkgs/rpms/scim-sinhala/F-8/scim-sinhala.spec,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- scim-sinhala.spec 22 Aug 2007 03:13:00 -0000 1.6
+++ scim-sinhala.spec 15 Jan 2008 12:39:44 -0000 1.7
@@ -1,30 +1,25 @@
%define snapdate 20060825
%define snapshot 0%{?snapdate:1}
-%define with_libstdc_preview 0
-
Name: scim-sinhala
Version: 0.2.0
-Release: 3%{?dist}
+Release: 5%{?dist}
Summary: Sri Lankan input method for SCIM
Group: System Environment/Libraries
License: GPLv2
-Url: http://sinhala.sourceforge.net/
+URL: http://sinhala.sourceforge.net/
Source: http://sinhala.cvs.sourceforge.net/sinhala/sinhala/scim/trans/%{name}-trans-%{version}%{?snapdate:-%{snapdate}}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%if %{snapshot}
Buildrequires: autoconf, automake, libtool
%endif
BuildRequires: scim-devel
-%if %{with_libstdc_preview}
-Buildrequires: libstdc++so7-devel
-%endif
Requires: scim
Patch1: scim-sinhala-trans-autogen-automake.patch
Patch2: scim-sinhala-remove-timeout-206253.patch
Patch3: scim-sinhala-help-text-206114.patch
-
+Patch4: scim-sinhala-preedit-217065.patch
%description
This package provides a Sinhala Trans input method for SCIM.
@@ -34,28 +29,19 @@
%patch1 -p1 -b .1-automake17
%patch2 -p1 -b .2-timeout
%patch3 -p1 -b .3-help
+%patch4 -p1 -b .4-preedit
%if %{snapshot}
./autogen.sh
%endif
%build
-%if %{with_libstdc_preview}
-export CXX=%{_bindir}/g++-libstdc++-so_7
-%endif
%configure --disable-static
-%if %{with_libstdc_preview}
-# tweak libtool for libstdc++-so7
-sed -i -e "s/4.1.0 /4.2.0-`grep datestamp= %{_bindir}/g++-libstdc++-so_7 | sed -e "s/datestamp=//"` /" libtool
-%endif
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
-%if %{with_libstdc_preview}
-export CXX=%{_bindir}/g++-libstdc++-so_7
-%endif
make install DESTDIR=$RPM_BUILD_ROOT
rm $RPM_BUILD_ROOT%{_libdir}/scim-1.0/*/*/*.la
@@ -73,6 +59,13 @@
%changelog
+* Tue Jan 08 2008 Pravin Satpute <psatpute at redhat.com> - 0.2.0-5
+- removed preedit for unneccessary characters(#217065)
+- modified scim-sinhala-preedit-217065.patch
+
+* Fri Dec 14 2007 Pravin Satpute <psatpute at redhat.com> - 0.2.0-4
+- implemented preedit in scim sinhala(#217065)
+
* Wed Aug 22 2007 Parag Nemade <pnemade at redhat.com> - 0.2.0-3
- rebuild against new rpm package
- update license tag
More information about the fedora-extras-commits
mailing list