Added application-level Input Method support.
This commit is contained in:
parent
092fd95579
commit
f043a733e6
10 changed files with 12902 additions and 85 deletions
57
Makefile
57
Makefile
|
|
@ -73,6 +73,11 @@ LOCALE_PREFIX=$(PKG_ROOT)$(PREFIX)/share/locale
|
|||
# LOCALE_PREFIX=/usr/share/locale
|
||||
|
||||
|
||||
# IM files
|
||||
|
||||
IM_PREFIX=$(PKG_ROOT)$(PREFIX)/share/im
|
||||
|
||||
|
||||
# Built with sound by default (override with "make nosound")
|
||||
|
||||
NOSOUNDFLAG=__SOUND
|
||||
|
|
@ -82,10 +87,12 @@ NOSOUNDFLAG=__SOUND
|
|||
|
||||
NOSVGFLAG=__SVG
|
||||
|
||||
|
||||
# Maemo flag
|
||||
|
||||
MAEMOFLAG=NO_MAEMOFLAG
|
||||
|
||||
|
||||
# Where to find cursor shape XBMs
|
||||
|
||||
MOUSEDIR=mouse
|
||||
|
|
@ -117,7 +124,8 @@ CFLAGS=$(OPTFLAGS) -W -Wall -fno-common -ffloat-store \
|
|||
|
||||
DEFS=-DDATA_PREFIX=\"$(DATA_PREFIX)/\" \
|
||||
-D$(NOSOUNDFLAG) -D$(NOSVGFLAG) -DDOC_PREFIX=\"$(DOC_PREFIX)/\" \
|
||||
-DLOCALEDIR=\"$(LOCALE_PREFIX)/\" -DCONFDIR=\"$(CONFDIR)/\" \
|
||||
-DLOCALEDIR=\"$(LOCALE_PREFIX)/\" -DIMDIR=\"$(IM_PREFIX)/\" \
|
||||
-DCONFDIR=\"$(CONFDIR)/\" \
|
||||
-DVER_VERSION=\"$(VER_VERSION)\" \
|
||||
-DVER_DATE=\"$(VER_DATE)\" \
|
||||
-D$(MAEMOFLAG)
|
||||
|
|
@ -211,6 +219,7 @@ beos:
|
|||
ICON_PREFIX=. \
|
||||
X11_ICON_PREFIX=. \
|
||||
LOCALE_PREFIX=/boot/home/config/share/locale \
|
||||
IM_PREFIX=./src \
|
||||
CFLAGS="-O1 -funroll-loops -fomit-frame-pointer -pipe -Wall" \
|
||||
RSRC_CMD="xres -o tuxpaint tuxpaint.rsrc" \
|
||||
MIMESET_CMD="mimeset -f tuxpaint" \
|
||||
|
|
@ -232,6 +241,7 @@ win32:
|
|||
ICON_PREFIX=. \
|
||||
X11_ICON_PREFIX=. \
|
||||
LOCALE_PREFIX=$(PREFIX)/share/locale \
|
||||
IM_PREFIX=$(PREFIX)/share/tuxpaint/im \
|
||||
CONFDIR=$(PREFIX)/etc/tuxpaint \
|
||||
ARCH_LINKS="-lintl -lpng12 -lwinspool -lshlwapi" \
|
||||
ARCH_HEADERS="src/win32_print.h" \
|
||||
|
|
@ -253,7 +263,7 @@ nokia770:
|
|||
# to do this as superuser ("root"))
|
||||
|
||||
install: install-bin install-data install-man install-doc \
|
||||
install-icon install-gettext install-importscript \
|
||||
install-icon install-gettext install-im install-importscript \
|
||||
install-default-config install-example-stamps \
|
||||
install-example-starters \
|
||||
install-gnome install-kde install-kde-icons
|
||||
|
|
@ -278,7 +288,7 @@ install: install-bin install-data install-man install-doc \
|
|||
# Installs the various parts for the MinGW/MSYS development/testing environment.
|
||||
|
||||
install-private-win32: install-bin install-data install-man install-doc \
|
||||
install-gettext install-importscript \
|
||||
install-gettext install-im install-importscript \
|
||||
install-default-config install-example-stamps \
|
||||
install-example-starters
|
||||
@echo
|
||||
|
|
@ -302,7 +312,7 @@ install-private-win32: install-bin install-data install-man install-doc \
|
|||
# Installs the various parts for the MinGW/MSYS development/testing environment.
|
||||
|
||||
bdist-private-win32: install-bin install-data install-doc \
|
||||
install-gettext install-dlls\
|
||||
install-gettext install-im install-dlls\
|
||||
install-example-stamps install-example-starters
|
||||
@echo
|
||||
@echo "--------------------------------------------------------------"
|
||||
|
|
@ -327,6 +337,7 @@ install-beos:
|
|||
ICON_PREFIX=. \
|
||||
X11_ICON_PREFIX=. \
|
||||
LOCALE_PREFIX=/boot/home/config/share/locale \
|
||||
IM_PREFIX=./src \
|
||||
CFLAGS="-O1 -funroll-loops -fomit-frame-pointer -pipe -Wall" \
|
||||
RSRC_CMD="xres -o tuxpaint tuxpaint.rsrc" \
|
||||
MIMESET_CMD="mimeset -f tuxpaint" \
|
||||
|
|
@ -348,6 +359,7 @@ install-win32:
|
|||
ICON_PREFIX=. \
|
||||
X11_ICON_PREFIX=. \
|
||||
LOCALE_PREFIX=$(PREFIX)/share/locale \
|
||||
IM_PREFIX=$(PREFIX)/share/tuxpaint/im \
|
||||
CONFDIR=$(PREFIX)/etc/tuxpaint \
|
||||
|
||||
# "make bdist-win32" recompiles Tux Paint to work with executable-relative
|
||||
|
|
@ -363,6 +375,7 @@ bdist-win32:
|
|||
DATA_PREFIX=data \
|
||||
DOC_PREFIX=docs \
|
||||
LOCALE_PREFIX=locale \
|
||||
IM_PREFIX=im \
|
||||
ARCH_LINKS="-lintl -lpng12 -lwinspool -lshlwapi" \
|
||||
ARCH_HEADERS="src/win32_print.h" \
|
||||
ARCH_LIBS="obj/win32_print.o obj/resource.o"
|
||||
|
|
@ -374,6 +387,7 @@ bdist-win32:
|
|||
DATA_PREFIX=./visualc/bdist/data \
|
||||
DOC_PREFIX=./visualc/bdist/docs \
|
||||
LOCALE_PREFIX=./visualc/bdist/locale \
|
||||
IM_PREFIX=./visualc/bdist/im \
|
||||
|
||||
# "make bdist-clean" deletes the 'bdist' directory
|
||||
bdist-clean:
|
||||
|
|
@ -495,6 +509,8 @@ uninstall:
|
|||
-rm $(LOCALE_PREFIX)/xh/LC_MESSAGES/tuxpaint.mo
|
||||
-rm $(LOCALE_PREFIX)/zh_CN/LC_MESSAGES/tuxpaint.mo
|
||||
-rm $(LOCALE_PREFIX)/zh_TW/LC_MESSAGES/tuxpaint.mo
|
||||
-rm $(IM_PREFIX)/ja.im
|
||||
-rm $(IM_PREFIX)/ko.im
|
||||
-rm -f -r $(CONFDIR)
|
||||
|
||||
|
||||
|
|
@ -1037,6 +1053,29 @@ install-gettext:
|
|||
@chmod 644 $(LOCALE_PREFIX)/xh/LC_MESSAGES/tuxpaint.mo
|
||||
|
||||
|
||||
# Install the Input Method files:
|
||||
|
||||
ifneq ($(IM_PREFIX),)
|
||||
install-im:
|
||||
@echo
|
||||
@echo "...Installing Input Method files..."
|
||||
@#
|
||||
@install -d $(IM_PREFIX)
|
||||
@#
|
||||
@echo " ja ...Japanese..."
|
||||
@cp im/ja.im $(IM_PREFIX)/ja.im
|
||||
@chmod 644 $(IM_PREFIX)/ja.im
|
||||
@#
|
||||
@echo " ko ...Korean..."
|
||||
@cp im/ko.im $(IM_PREFIX)/ko.im
|
||||
@chmod 644 $(IM_PREFIX)/ko.im
|
||||
else
|
||||
install-im:
|
||||
@echo
|
||||
@echo "...Not Installing Input Method files (no IM_PREFIX defined)..."
|
||||
endif
|
||||
|
||||
|
||||
# Install the text documentation:
|
||||
|
||||
install-doc:
|
||||
|
|
@ -1073,7 +1112,7 @@ install-man:
|
|||
|
||||
# Build the program!
|
||||
|
||||
tuxpaint: obj/tuxpaint.o obj/i18n.o obj/cursor.o obj/pixels.o \
|
||||
tuxpaint: obj/tuxpaint.o obj/i18n.o obj/im.o obj/cursor.o obj/pixels.o \
|
||||
obj/floodfill.o obj/rgblinear.o obj/playsound.o obj/fonts.o \
|
||||
obj/progressbar.o obj/dirwalk.o obj/get_fname.o \
|
||||
$(HQXX_O) $(ARCH_LIBS)
|
||||
|
|
@ -1093,7 +1132,7 @@ tuxpaint: obj/tuxpaint.o obj/i18n.o obj/cursor.o obj/pixels.o \
|
|||
# Build the object for the program!
|
||||
|
||||
obj/tuxpaint.o: src/tuxpaint.c \
|
||||
src/i18n.h src/cursor.h src/pixels.h \
|
||||
src/i18n.h src/im.h src/cursor.h src/pixels.h \
|
||||
src/floodfill.h src/rgblinear.h src/playsound.h src/fonts.h \
|
||||
src/progressbar.h src/dirwalk.h src/get_fname.h \
|
||||
src/compiler.h src/debug.h \
|
||||
|
|
@ -1125,6 +1164,12 @@ obj/i18n.o: src/i18n.c src/i18n.h src/debug.h
|
|||
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(DEFS) \
|
||||
-c src/i18n.c -o obj/i18n.o
|
||||
|
||||
obj/im.o: src/im.c src/im.h src/debug.h
|
||||
@echo
|
||||
@echo "...Compiling IM support..."
|
||||
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
|
||||
-c src/im.c -o obj/im.o
|
||||
|
||||
obj/get_fname.o: src/get_fname.c src/get_fname.h src/debug.h
|
||||
@echo
|
||||
@echo "...Compiling filename support..."
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ $Id$
|
|||
Bilinear interpolation code based on an example by Christian Graus
|
||||
( http://www.codeproject.com/cs/media/imageprocessing4.asp ).
|
||||
|
||||
Input Method (IM) Framework and Korean/Japanese IM implemented by:
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
|
||||
* Graphics
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,15 @@ http://www.newbreedsoftware.com/tuxpaint/
|
|||
$Id$
|
||||
|
||||
|
||||
2007.April.6 (0.9.17)
|
||||
2007.April.21 (0.9.17)
|
||||
|
||||
* Tool Improvements:
|
||||
------------------
|
||||
* Input Method Framework, with implementations of Korean (Hangul 2-Bul)
|
||||
and Japanese (Romanized Hiragana and Katakana) input methods. Should
|
||||
be extensible to other languages.
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Stamps now supports SVG vector-based graphics! (Via Cairo library)
|
||||
(Only SVG versions of stamps are loaded, when both PNG and SVG
|
||||
variations are found.)
|
||||
|
|
@ -412,7 +417,7 @@ $Id$
|
|||
|
||||
* Source files and documentation files tagged with CVS Id tags
|
||||
for easier version tracking.
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Locale update:
|
||||
--------------
|
||||
|
|
@ -867,7 +872,7 @@ $Id$
|
|||
TOYAMA Shin-ichi <shin1@wmail.plala.or.jp>
|
||||
|
||||
* Korean
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Lithuanian
|
||||
Gintaras Go?tautas <gintaras@nes.lt>
|
||||
|
|
@ -994,7 +999,7 @@ $Id$
|
|||
Bill Kendrick <bill@newbreedsoftware.com>
|
||||
|
||||
* Korean README.txt documentation added, in both EUC-KR and UTF-8 formats.
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Serbian translation created.
|
||||
Aleksandar Jelenak <jelenak@netlinkplus.net>
|
||||
|
|
@ -1062,7 +1067,7 @@ $Id$
|
|||
TOYAMA Shin-ichi <shin1@wmail.plala.or.jp>
|
||||
|
||||
* Updated Korean translation.
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Updated Malay translation.
|
||||
Muhammad Najmi Ahmad Zabidi <mnajem@linuxmail.org>
|
||||
|
|
@ -1144,7 +1149,7 @@ $Id$
|
|||
John Popplewell <john@johnnypops.demon.co.uk>
|
||||
|
||||
* Updated Makefile for easier install.
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Cleaned up desktop entry file.
|
||||
Karl Ove Hufthammer <karl@huftis.org>
|
||||
|
|
@ -1176,7 +1181,7 @@ $Id$
|
|||
Mark K. Kim & John Popplewell
|
||||
|
||||
* Fixed security issue with permissions to Tux Paint docs directory.
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Fixed 'savedir' bug. (Was dropping filenames)
|
||||
|
||||
|
|
@ -1357,7 +1362,7 @@ $Id$
|
|||
* Right-to-left language support (for Hebrew, for example).
|
||||
|
||||
* Updated Korean translations.
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* UTF-8 support in the Text Tool!
|
||||
Robert Glowczynski <robertg@software.com.pl>,
|
||||
|
|
@ -1636,7 +1641,7 @@ $Id$
|
|||
* UTF-8 support working.
|
||||
|
||||
* Korean translation completed!
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Fixed errors in 'uninstall' target in Makefile
|
||||
|
||||
|
|
@ -1694,7 +1699,7 @@ $Id$
|
|||
Török Gábor <gabo@linuxmania.hu>
|
||||
|
||||
* Partly translated to Korean. PO file in an unusable charset, though...
|
||||
Mark K. Kim <tuxNO_SOLICITATIONpaint-dev@cbreak.org>
|
||||
Mark K. Kim <mkkim214@gmail.com>
|
||||
|
||||
* Supports locale-specific fonts for languages that need Unicode.
|
||||
e.g., Korean will use "ko.ttf", if found, for translated strings.
|
||||
|
|
|
|||
188
im/ja.im
Normal file
188
im/ja.im
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
##############################################################################
|
||||
# Japanese IM Character Map
|
||||
#
|
||||
# $Id$
|
||||
|
||||
# Hiragana
|
||||
section
|
||||
|
||||
3041 xa -
|
||||
3042 a -
|
||||
3043 xi -
|
||||
3044 i -
|
||||
3045 xu -
|
||||
3046 u -
|
||||
3047 xe -
|
||||
3048 e -
|
||||
3049 xo -
|
||||
304A o -
|
||||
304B ka -
|
||||
304C ga -
|
||||
304D ki -
|
||||
304E gi -
|
||||
304F ku -
|
||||
3050 gu -
|
||||
3051 ke -
|
||||
3052 ge -
|
||||
3053 ko -
|
||||
3054 go -
|
||||
3055 sa -
|
||||
3056 za -
|
||||
3057 si -
|
||||
3058 zi -
|
||||
3059 su -
|
||||
305A zu -
|
||||
305B se -
|
||||
305C ze -
|
||||
305D so -
|
||||
305E zo -
|
||||
305F ta -
|
||||
3060 da -
|
||||
3061 ti -
|
||||
3062 di -
|
||||
3063 xtu -
|
||||
3064 tu -
|
||||
3065 du -
|
||||
3066 te -
|
||||
3067 de -
|
||||
3068 to -
|
||||
3069 do -
|
||||
306A na -
|
||||
306B ni -
|
||||
306C nu -
|
||||
306D ne -
|
||||
306E no -
|
||||
306F ha -
|
||||
3070 ba -
|
||||
3071 pa -
|
||||
3072 hi -
|
||||
3073 bi -
|
||||
3074 pi -
|
||||
3075 hu -
|
||||
3076 bu -
|
||||
3077 pu -
|
||||
3078 he -
|
||||
3079 be -
|
||||
307A pe -
|
||||
307B ho -
|
||||
307C bo -
|
||||
307D po -
|
||||
307E ma -
|
||||
307F mi -
|
||||
3080 mu -
|
||||
3081 me -
|
||||
3082 mo -
|
||||
3083 xya -
|
||||
3084 ya -
|
||||
3085 xyu -
|
||||
3086 yu -
|
||||
3087 xyo -
|
||||
3088 yo -
|
||||
3089 ra -
|
||||
308A ri -
|
||||
308B ru -
|
||||
308C re -
|
||||
308D ro -
|
||||
308E xwa -
|
||||
308F wa -
|
||||
3090 wi -
|
||||
3091 we -
|
||||
3092 wo -
|
||||
3093 n -
|
||||
|
||||
|
||||
# Katakana
|
||||
section
|
||||
|
||||
30A1 xa -
|
||||
30A2 a -
|
||||
30A3 xi -
|
||||
30A4 i -
|
||||
30A5 xu -
|
||||
30A6 u -
|
||||
30A7 xe -
|
||||
30A8 e -
|
||||
30A9 xo -
|
||||
30AA o -
|
||||
30AB ka -
|
||||
30AC ga -
|
||||
30AD ki -
|
||||
30AE gi -
|
||||
30AF ku -
|
||||
30B0 gu -
|
||||
30B1 ke -
|
||||
30B2 ge -
|
||||
30B3 ko -
|
||||
30B4 go -
|
||||
30B5 sa -
|
||||
30B6 za -
|
||||
30B7 si -
|
||||
30B8 zi -
|
||||
30B9 su -
|
||||
30BA zu -
|
||||
30BB se -
|
||||
30BC ze -
|
||||
30BD so -
|
||||
30BE zo -
|
||||
30BF ta -
|
||||
30C0 da -
|
||||
30C1 ti -
|
||||
30C2 di -
|
||||
30C3 xtu -
|
||||
30C4 tu -
|
||||
30C5 du -
|
||||
30C6 te -
|
||||
30C7 de -
|
||||
30C8 to -
|
||||
30C9 do -
|
||||
30CA na -
|
||||
30CB ni -
|
||||
30CC nu -
|
||||
30CD ne -
|
||||
30CE no -
|
||||
30CF ha -
|
||||
30D0 ba -
|
||||
30D1 pa -
|
||||
30D2 hi -
|
||||
30D3 bi -
|
||||
30D4 pi -
|
||||
30D5 hu -
|
||||
30D6 bu -
|
||||
30D7 pu -
|
||||
30D8 he -
|
||||
30D9 be -
|
||||
30DA pe -
|
||||
30DB ho -
|
||||
30DC bo -
|
||||
30DD po -
|
||||
30DE ma -
|
||||
30DF mi -
|
||||
30E0 mu -
|
||||
30E1 me -
|
||||
30E2 mo -
|
||||
30E3 xya -
|
||||
30E4 ya -
|
||||
30E5 xyu -
|
||||
30E6 yu -
|
||||
30E7 xyo -
|
||||
30E8 yo -
|
||||
30E9 ra -
|
||||
30EA ri -
|
||||
30EB ru -
|
||||
30EC re -
|
||||
30ED ro -
|
||||
30EE xwa -
|
||||
30EF wa -
|
||||
30F0 wi -
|
||||
30F1 we -
|
||||
30F2 wo -
|
||||
30F3 n -
|
||||
30F4 vu -
|
||||
30F5 xka -
|
||||
30F6 xke -
|
||||
30F7 va -
|
||||
30F8 vi -
|
||||
30F9 ve -
|
||||
30FA vo -
|
||||
30FB . -
|
||||
30FC - -
|
||||
46
src/i18n.c
46
src/i18n.c
|
|
@ -35,12 +35,33 @@
|
|||
#include "i18n.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* (Trouble building this for 10.2.8 target; bjk & mf 2006.01.14) */
|
||||
#ifndef __APPLE_10_2_8__
|
||||
#include <wchar.h>
|
||||
#else
|
||||
#undef FORKED_FONTS
|
||||
#define wchar_t char
|
||||
#define wcslen strlen
|
||||
#define towupper toupper
|
||||
#define iswprint isprint
|
||||
#define OLD_UPPERCASE_CODE
|
||||
#endif
|
||||
|
||||
#ifndef OLD_UPPERCASE_CODE
|
||||
#include <wctype.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Globals: */
|
||||
|
||||
static int langint = LANG_EN;
|
||||
|
||||
const char *lang_prefixes[NUM_LANGS] = {
|
||||
"af",
|
||||
"ar",
|
||||
|
|
@ -279,9 +300,9 @@ void set_langstr(const char *s)
|
|||
void ctype_utf8(void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
char *names[] = {"en_US.UTF8","en_US.UTF-8","UTF8","UTF-8",};
|
||||
const char *names[] = {"en_US.UTF8","en_US.UTF-8","UTF8","UTF-8",};
|
||||
int i = sizeof(names)/sizeof(names[0]);
|
||||
while(i-- && !iswprint((wchar_t)0xf7) && !setlocale(LC_CTYPE,names[i]))
|
||||
while(i && !iswprint((wchar_t)0xf7) && !setlocale(LC_CTYPE,names[--i]))
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -291,7 +312,7 @@ void ctype_utf8(void)
|
|||
void set_current_language(void)
|
||||
{
|
||||
char *loc;
|
||||
int lang, i, found;
|
||||
int i, found;
|
||||
|
||||
bindtextdomain("tuxpaint", LOCALEDIR);
|
||||
/* Old version of glibc does not have bind_textdomain_codeset() */
|
||||
|
|
@ -302,7 +323,7 @@ void set_current_language(void)
|
|||
|
||||
/* Default... */
|
||||
|
||||
lang = LANG_EN;
|
||||
langint = LANG_EN;
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
|
|
@ -343,24 +364,30 @@ void set_current_language(void)
|
|||
// Case-insensitive (both "pt_BR" and "pt_br" work, etc.)
|
||||
if (strncasecmp(loc, lang_prefixes[i], strlen(lang_prefixes[i])) == 0)
|
||||
{
|
||||
lang = i;
|
||||
langint = i;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lang_prefix = lang_prefixes[lang];
|
||||
need_own_font = search_int_array(lang, lang_use_own_font);
|
||||
need_right_to_left = search_int_array(lang, lang_use_right_to_left);
|
||||
lang_prefix = lang_prefixes[langint];
|
||||
need_own_font = search_int_array(langint, lang_use_own_font);
|
||||
need_right_to_left = search_int_array(langint, lang_use_right_to_left);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: Language is %s (%d)\n", lang_prefix, lang);
|
||||
fprintf(stderr, "DEBUG: Language is %s (%d)\n", lang_prefix, langint);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
int get_current_language(void)
|
||||
{
|
||||
return langint;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: All this should REALLY be array-based!!! */
|
||||
/* Show available languages: */
|
||||
void show_lang_usage(FILE * f, const char *const prg)
|
||||
|
|
@ -586,6 +613,7 @@ void setup_language(const char *const prg)
|
|||
setlocale(LC_ALL, "");
|
||||
ctype_utf8();
|
||||
free(langstr);
|
||||
langstr = NULL;
|
||||
}
|
||||
|
||||
set_current_language();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
|
||||
|
||||
#ifndef I18N_H
|
||||
#define I18N_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/* Possible languages: */
|
||||
|
||||
|
|
@ -118,6 +122,7 @@ extern const language_to_locale_struct language_to_locale_array[];
|
|||
|
||||
void set_langstr(const char *s);
|
||||
void set_current_language(void);
|
||||
int get_current_language(void);
|
||||
void show_lang_usage(FILE * f, const char *const prg);
|
||||
void show_locale_usage(FILE * f, const char *const prg);
|
||||
void setup_language(const char *const prg);
|
||||
|
|
|
|||
63
src/im.h
Normal file
63
src/im.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
im.h
|
||||
|
||||
Input method handling
|
||||
Copyright (c) 2007 by Mark K. Kim and others
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef TUXPAINT_IM_H
|
||||
#define TUXPAINT_IM_H
|
||||
|
||||
#include "SDL.h"
|
||||
#include "i18n.h"
|
||||
|
||||
|
||||
/* ***************************************************************************
|
||||
* TYPES
|
||||
*/
|
||||
|
||||
typedef struct IM_DATA {
|
||||
int lang; /* Language used in sequence translation */
|
||||
wchar_t s[8]; /* Characters that should be displayed */
|
||||
const char* tip_text; /* Tip text, read-only please */
|
||||
|
||||
/* For use by language-specific im_event_<lang> calls. PRIVATE! */
|
||||
wchar_t buf[8]; /* Buffered characters */
|
||||
int discard; /* Discard parameter */
|
||||
int request; /* Event request */
|
||||
} IM_DATA;
|
||||
|
||||
|
||||
/* ***************************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
void im_init(IM_DATA* im, int lang); /* Initialize IM */
|
||||
void im_fullreset(IM_DATA* im); /* Full Reset IM */
|
||||
void im_softreset(IM_DATA* im); /* Soft Reset IM */
|
||||
void im_free(IM_DATA* im); /* Free IM resources */
|
||||
|
||||
int im_read(IM_DATA* im, SDL_keysym ks);
|
||||
|
||||
|
||||
#endif /* TUXPAINT_IM_H */
|
||||
|
||||
/* vim:ts=8
|
||||
*/
|
||||
148
src/tuxpaint.c
148
src/tuxpaint.c
|
|
@ -391,6 +391,8 @@ typedef struct safer_dirent
|
|||
#include "tip_tux.h"
|
||||
#include "great.h"
|
||||
|
||||
#include "im.h"
|
||||
|
||||
|
||||
#ifdef DEBUG_MALLOC
|
||||
#include "malloc.c"
|
||||
|
|
@ -1045,6 +1047,7 @@ static int eraser_scroll, shape_scroll; // dummy variables for now
|
|||
|
||||
static int eraser_sound;
|
||||
|
||||
static IM_DATA im_data;
|
||||
static wchar_t texttool_str[256];
|
||||
static unsigned int texttool_len;
|
||||
|
||||
|
|
@ -1802,6 +1805,9 @@ static void mainloop(void)
|
|||
|
||||
if (cur_tool == TOOL_TEXT && cursor_x != -1 && cursor_y != -1)
|
||||
{
|
||||
static int discard = 0;
|
||||
wchar_t* im_cp = im_data.s;
|
||||
|
||||
key_down = key;
|
||||
key_unicode = event.key.keysym.unicode;
|
||||
|
||||
|
|
@ -1829,81 +1835,102 @@ static void mainloop(void)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
if (key_down == SDLK_BACKSPACE)
|
||||
{
|
||||
hide_blinking_cursor();
|
||||
if (texttool_len > 0)
|
||||
{
|
||||
texttool_len--;
|
||||
texttool_str[texttool_len] = 0;
|
||||
playsound(screen, 0, SND_KEYCLICK, 0, SNDPOS_CENTER,
|
||||
SNDDIST_NEAR);
|
||||
/* Discard previous # of instructed characters */
|
||||
if((int)texttool_len <= discard) texttool_len = 0;
|
||||
else texttool_len -= discard;
|
||||
texttool_str[texttool_len] = L'\0';
|
||||
|
||||
do_render_cur_text(0);
|
||||
/* Read IM, remember how many to discard next iteration */
|
||||
discard = im_read(&im_data, event.key.keysym);
|
||||
|
||||
/* Queue each character to be displayed */
|
||||
while(*im_cp) {
|
||||
if (*im_cp == L'\b')
|
||||
{
|
||||
hide_blinking_cursor();
|
||||
if (texttool_len > 0)
|
||||
{
|
||||
texttool_len--;
|
||||
texttool_str[texttool_len] = 0;
|
||||
playsound(screen, 0, SND_KEYCLICK, 0, SNDPOS_CENTER,
|
||||
SNDDIST_NEAR);
|
||||
|
||||
do_render_cur_text(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key_down == SDLK_RETURN)
|
||||
{
|
||||
int font_height;
|
||||
|
||||
hide_blinking_cursor();
|
||||
if (texttool_len > 0)
|
||||
else if (*im_cp == L'\r')
|
||||
{
|
||||
rec_undo_buffer();
|
||||
do_render_cur_text(1);
|
||||
texttool_len = 0;
|
||||
cursor_textwidth = 0;
|
||||
int font_height;
|
||||
|
||||
hide_blinking_cursor();
|
||||
if (texttool_len > 0)
|
||||
{
|
||||
rec_undo_buffer();
|
||||
do_render_cur_text(1);
|
||||
texttool_len = 0;
|
||||
cursor_textwidth = 0;
|
||||
}
|
||||
font_height = TTF_FontHeight(getfonthandle(cur_font));
|
||||
|
||||
cursor_x = cursor_left;
|
||||
cursor_y = min(cursor_y + font_height, canvas->h - font_height);
|
||||
|
||||
playsound(screen, 0, SND_RETURN, 1, SNDPOS_RIGHT, SNDDIST_NEAR);
|
||||
im_softreset(&im_data);
|
||||
}
|
||||
font_height = TTF_FontHeight(getfonthandle(cur_font));
|
||||
|
||||
cursor_x = cursor_left;
|
||||
cursor_y = min(cursor_y + font_height, canvas->h - font_height);
|
||||
|
||||
playsound(screen, 0, SND_RETURN, 1, SNDPOS_RIGHT, SNDDIST_NEAR);
|
||||
}
|
||||
else if (key_down == SDLK_TAB)
|
||||
{
|
||||
if (texttool_len > 0)
|
||||
else if (*im_cp == L'\t')
|
||||
{
|
||||
rec_undo_buffer();
|
||||
do_render_cur_text(1);
|
||||
cursor_x = min(cursor_x + cursor_textwidth, canvas->w);
|
||||
texttool_len = 0;
|
||||
cursor_textwidth = 0;
|
||||
if (texttool_len > 0)
|
||||
{
|
||||
rec_undo_buffer();
|
||||
do_render_cur_text(1);
|
||||
cursor_x = min(cursor_x + cursor_textwidth, canvas->w);
|
||||
texttool_len = 0;
|
||||
cursor_textwidth = 0;
|
||||
}
|
||||
im_softreset(&im_data);
|
||||
}
|
||||
}
|
||||
else if (iswprint(key_unicode))
|
||||
{
|
||||
if (texttool_len < (sizeof(texttool_str) / sizeof(wchar_t)) - 1)
|
||||
else if (iswprint(*im_cp))
|
||||
{
|
||||
int old_cursor_textwidth = cursor_textwidth;
|
||||
#ifdef DEBUG
|
||||
wprintf(L" key = <%c>\nunicode = <%lc> 0x%04x %d\n\n",
|
||||
key_down, key_unicode, key_unicode, key_unicode);
|
||||
if (texttool_len < (sizeof(texttool_str) / sizeof(wchar_t)) - 1)
|
||||
{
|
||||
int old_cursor_textwidth = cursor_textwidth;
|
||||
#ifdef DEBUG
|
||||
wprintf(L" key = <%c>\nunicode = <%lc> 0x%04x %d\n\n",
|
||||
key_down, key_unicode, key_unicode, key_unicode);
|
||||
#endif
|
||||
|
||||
texttool_str[texttool_len++] = key_unicode;
|
||||
texttool_str[texttool_len] = 0;
|
||||
texttool_str[texttool_len++] = *im_cp;
|
||||
texttool_str[texttool_len] = 0;
|
||||
|
||||
do_render_cur_text(0);
|
||||
do_render_cur_text(0);
|
||||
|
||||
|
||||
if (cursor_x + old_cursor_textwidth <= canvas->w - 50 &&
|
||||
cursor_x + cursor_textwidth > canvas->w - 50)
|
||||
{
|
||||
playsound(screen, 0, SND_KEYCLICKRING, 1, SNDPOS_RIGHT,
|
||||
SNDDIST_NEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: Might be fun to position the
|
||||
sound based on keyboard layout...? */
|
||||
if (cursor_x + old_cursor_textwidth <= canvas->w - 50 &&
|
||||
cursor_x + cursor_textwidth > canvas->w - 50)
|
||||
{
|
||||
playsound(screen, 0, SND_KEYCLICKRING, 1, SNDPOS_RIGHT,
|
||||
SNDDIST_NEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: Might be fun to position the
|
||||
sound based on keyboard layout...? */
|
||||
|
||||
playsound(screen, 0, SND_KEYCLICK, 0, SNDPOS_CENTER,
|
||||
SNDDIST_NEAR);
|
||||
}
|
||||
playsound(screen, 0, SND_KEYCLICK, 0, SNDPOS_CENTER,
|
||||
SNDDIST_NEAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
im_cp++;
|
||||
} /* while(*im_cp) */
|
||||
|
||||
/* Show IM tip text */
|
||||
if(im_data.tip_text) {
|
||||
draw_tux_text(TUX_DEFAULT, im_data.tip_text, 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6461,6 +6488,7 @@ static void setup(int argc, char *argv[])
|
|||
|
||||
|
||||
setup_language(getfilename(argv[0]));
|
||||
im_init(&im_data, get_current_language());
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue