diff --git a/src/add-ons/input_server/methods/canna/Bitmaps.h b/src/add-ons/input_server/methods/canna/Bitmaps.h new file mode 100644 index 0000000000..dd31fa7cab --- /dev/null +++ b/src/add-ons/input_server/methods/canna/Bitmaps.h @@ -0,0 +1,25 @@ +#include + +const int32 kSmallIconWidth = 16; +const int32 kSmallIconHeight = 16; +const color_space kSmallIconColorSpace = B_COLOR_8_BIT; + +const unsigned char kCannaIcon [] = { + 0xff,0xff,0xff,0xff,0x2b,0x2b,0x2b,0x2b,0x2b,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0xff,0xff,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0xff,0xff,0xff,0xff,0xff, + 0xff,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0xff,0xff,0xff,0xff, + 0xff,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0xff,0xff,0xff,0xff, + 0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0xff,0xff,0xff, + 0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0xff,0xff,0xff, + 0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0xff,0xff,0xff, + 0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0xff,0xff,0xff, + 0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x3f,0x3f,0x3f,0x3f,0x2b,0xff,0xff,0xff, + 0xff,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xff,0xff,0xff, + 0xff,0x2b,0x2b,0x2b,0x2b,0x2b,0x2b,0x73,0x73,0x73,0x73,0x73,0x73,0xff,0xff,0xff, + 0xff,0xff,0x2b,0x2b,0x2b,0x2b,0x73,0x73,0x73,0x73,0x73,0x73,0x73,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff,0x2b,0x73,0x73,0x73,0x73,0x73,0x73,0x73,0x73,0x73,0x73,0xff, + 0xff,0xff,0xff,0xff,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92,0x92, + 0xff,0xff,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2, + 0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2 +}; + diff --git a/src/add-ons/input_server/methods/canna/CannaCommon.h b/src/add-ons/input_server/methods/canna/CannaCommon.h new file mode 100644 index 0000000000..66108ecf65 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/CannaCommon.h @@ -0,0 +1,61 @@ +// +// CannaCommon.h +// Common data and variable definition for CannaIM +// (c) 1999 Masao Kawamura +// + +#ifndef _CANNACOMMON_H +#define _CANNACOMMON_H + +#include +#include +//BMessage constant +#define CANNA_METHOD_ACTIVATED 'Cact' + +//Kouho Window messages +#define KOUHO_WINDOW_SHOW 'Kshw' +#define KOUHO_WINDOW_HIDE 'Khid' +#define KOUHO_WINDOW_SHOWAT 'Ksat' +#define KOUHO_WINDOW_SETTEXT 'Kstx' +#define KOUHO_WINDOW_SHOW_ALONE 'Ksal' +#define NUM_SELECTED_FROM_KOUHO_WIN 'Knum' + +//Palette Window messages +#define PALETTE_WINDOW_SHOW 'Pshw' +#define PALETTE_WINDOW_HIDE 'Phid' +#define PALETTE_WINDOW_BUTTON_UPDATE 'Pupd' +#define MODE_CHANGED_FROM_PALETTE 'Pmch' + +//result codes from CannaInterface object +const uint32 MIKAKUTEI_NO_CHANGE = 0x00; +const uint32 KAKUTEI_EXISTS = 0x01; +const uint32 MIKAKUTEI_EXISTS = 0x02; +const uint32 NEW_INPUT_STARTED = 0x04; +const uint32 THROUGH_INPUT = 0x08; +const uint32 GUIDELINE_APPEARED = 0x10; +const uint32 GUIDELINE_DISAPPEARED = 0x20; +const uint32 GUIDELINE_CHANGED = 0x40; +const uint32 MODE_CHANGED = 0x80; +const uint32 NOTHING_TO_KAKUTEI = 0x100; +const uint32 MIKAKUTEI_BECOME_EMPTY = 0x200; + +//Menu messages +#define RELOAD_INIT_FILE 'Mrel' +#define ARROW_KEYS_FLIPPED 'Marf' + +//buffer related constants +#define CONVERT_BUFFER_SIZE 510 +#define KOUHO_WINDOW_MAXCHAR 150 +#define NUMBER_DISPLAY_MAXCHAR 20 + +#define CANNAIM_SETTINGS_FILE "/boot/home/config/settings/cannaim_settings" + +typedef struct Preferences +{ + BPoint palette_loc; + bool convert_arrowkey; + BPoint standalone_loc; +} Preferences; + + +#endif diff --git a/src/add-ons/input_server/methods/canna/CannaIM_icon b/src/add-ons/input_server/methods/canna/CannaIM_icon new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/add-ons/input_server/methods/canna/CannaInterface.cpp b/src/add-ons/input_server/methods/canna/CannaInterface.cpp new file mode 100644 index 0000000000..fb0dd3e93a --- /dev/null +++ b/src/add-ons/input_server/methods/canna/CannaInterface.cpp @@ -0,0 +1,812 @@ +// +// CannaInterface.cpp +// canna library wrapper + +// This is a part of... +// CannaIM +// version 1.0 +// (c) 1999 M.Kawamura +// + +#include "CannaInterface.h" +#include +#include + +#ifdef DEBUG +#include +#endif + +inline int32 +UTF8CharLen(uchar c) + { return (((0xE5000000 >> ((c >> 3) & 0x1E)) & 3) + 1); } + +CannaInterface::CannaInterface( char *path ) +{ + strcpy( basePath, path ); + InitializeCanna(); +} + +void +CannaInterface::InitializeCanna() +{ + char **warn; + + context_id = 0; //context id is now fixed to zero. +#ifdef DEBUG + SERIAL_PRINT(( "CannaInterface:Setting basepath to %s.\n", basePath )); +#endif + + setBasePath( basePath ); + + jrKanjiControl(context_id, KC_INITIALIZE, (char *)&warn); +#ifdef DEBUG + SERIAL_PRINT(( "CannaInterface:Canna Initialize result = %x.\n", warn )); +#endif + + if (warn) + { + canna_enabled = false; + return; + } + + int32 max_width = KOUHO_WINDOW_MAXCHAR - 2; + jrKanjiControl(context_id, KC_SETWIDTH, (char *) max_width); + + jrKanjiControl( context_id, KC_SETMODEINFOSTYLE, (char *)(int32) 0); + + jrKanjiControl(context_id, KC_SETHEXINPUTSTYLE, (char *)(int32) 1); + + jrKanjiControl( context_id, KC_SETUNDEFKEYFUNCTION, (char *)(int32) kc_through ); + + jrKanjiStatusWithValue ks; + uchar buf[CONVERT_BUFFER_SIZE]; + + ks.val = CANNA_MODE_HenkanMode; + ks.buffer = buf; + ks.bytes_buffer = CONVERT_BUFFER_SIZE; + ks.ks = &kanji_status; + jrKanjiControl( context_id, KC_CHANGEMODE, (char *)&ks); + + canna_enabled = true; + convert_arrowkey = gSettings.convert_arrowkey; + hadMikakuteiStr = false; + hadGuideLine = false; +} + +CannaInterface::~CannaInterface() +{ +#ifdef DEBUG + SERIAL_PRINT(( "CannaInterface: Destructor called.\n" )); +#endif + jrKanjiStatusWithValue ks; + ks.val = 0; + ks.buffer = (unsigned char *)kakuteiStr; + ks.bytes_buffer = CONVERT_BUFFER_SIZE; + ks.ks = &kanji_status; + jrKanjiControl(context_id, KC_FINALIZE, (char *)&ks); +} + +status_t CannaInterface::InitCheck() +{ + if ( canna_enabled ) + { + jrKanjiControl( context_id, KC_SETMODEINFOSTYLE, (char *)(int32) 2); + char mode[5]; + jrKanjiControl( context_id, KC_QUERYMODE, mode ); + current_mode = mode[1] - '@'; + jrKanjiControl( context_id, KC_SETMODEINFOSTYLE, (char *)(int32) 0); + return B_NO_ERROR; + } + else + return B_ERROR; +} + +uint32 CannaInterface::KeyIn( char ch, uint32 mod, int32 key ) +{ + int inkey; + + inkey = ConvertSpecial( ch, mod, key ); +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: KeyIn() returned from ConvertSpecial. inkey = 0x%x\n", inkey )); +#endif + if ( convert_arrowkey && kanji_status.gline.length != 0 ) + inkey = ConvertArrowKey( inkey ); +/* + if ( kanji_status.length == 0 ) + { + hadMikakuteiStr = false; + previousUTF[0] = '\0'; + } + else + { + strcpy( previousUTF, mikakuteiUTF ); + hadMikakuteiStr = true; + } +*/ +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: Calling jrKanjiString()...\n" )); +#endif + kakuteiLen = jrKanjiString(context_id, inkey, kakuteiStr, CONVERT_BUFFER_SIZE, &kanji_status); +#ifdef DEBUG +SERIAL_PRINT(( "kakL = %d, mikL = %d, glineL = %d, info = 0x%x\n", kakuteiLen, kanji_status.length, kanji_status.gline.length, kanji_status.info )); +#endif + //return UpdateKanjiStatus(); + uint32 result = UpdateKanjiStatus(); +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: KeyIn() returning 0x%x.\n", result )); +#endif + return result; +} + +uint32 CannaInterface::UpdateKanjiStatus() +{ + uint32 result = 0; +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: Entering UpdateKanjiStatus()...\n" )); +#endif + + if ( hadGuideLine && kanji_status.gline.length == 0 ) + { + result |= GUIDELINE_DISAPPEARED; + hadGuideLine = false; + } + + if ( kanji_status.length == -1 ) + { + result |= MIKAKUTEI_NO_CHANGE; + return result; + } + + if ( kanji_status.info & KanjiThroughInfo ) + { + result |= THROUGH_INPUT; + return result; + } + + if ( kanji_status.info & KanjiModeInfo ) + { + jrKanjiControl( context_id, KC_SETMODEINFOSTYLE, (char *)(int32) 2); + char mode[5]; + jrKanjiControl( context_id, KC_QUERYMODE, mode ); + current_mode = mode[1] - '@'; + jrKanjiControl( context_id, KC_SETMODEINFOSTYLE, (char *)(int32) 0); + result |= MODE_CHANGED; + } + + if ( !hadMikakuteiStr && (kanji_status.length != 0 || kakuteiLen != 0 )) + { + //ClearPrevious(); + result |= NEW_INPUT_STARTED; + } + + kakuteiUTF[0] = mikakuteiUTF[0] = '\0'; + kakuteiUTFLen = mikakuteiUTFLen = 0; + int32 length; + int32 state; + //Convert KakuteiString to UTF-8 + if ( kakuteiLen > 0 ) + { + length = kakuteiLen; //make copy + kakuteiUTFLen = CONVERT_BUFFER_SIZE * 2; + convert_to_utf8( B_EUC_CONVERSION, (const char *)kakuteiStr, &length, + kakuteiUTF, &kakuteiUTFLen, &state ); + kakuteiUTF[kakuteiUTFLen] = '\0'; //terminating NULL + + result |= KAKUTEI_EXISTS; + } + + //Convert MikakuteiString to UTF-8 + if ( kanji_status.length > 0 ) + { + length = kanji_status.length; //make copy + mikakuteiUTFLen = CONVERT_BUFFER_SIZE * 2; + convert_to_utf8( B_EUC_CONVERSION, + (const char *)kanji_status.echoStr, &length, + mikakuteiUTF, &mikakuteiUTFLen, &state ); + mikakuteiUTF[mikakuteiUTFLen] = '\0'; //terminating NULL + + result |= MIKAKUTEI_EXISTS; + } + + //when mikakutei string is deleted and become empty + if ( hadMikakuteiStr && kanji_status.length == 0 && kakuteiLen == 0 ) + result |= MIKAKUTEI_BECOME_EMPTY; + + if ( kanji_status.length == 0 ) // set hadMikakuteiStr flag for the next transaction + hadMikakuteiStr = false; + else + hadMikakuteiStr = true; + + if ( hadGuideLine && (kanji_status.info & KanjiGLineInfo) ) + result |= GUIDELINE_CHANGED; + + if ( !hadGuideLine && kanji_status.gline.length != 0 ) + { + result |= GUIDELINE_APPEARED; + hadGuideLine = true; + } + + // calculate revpos, revlen + if ( kanji_status.revLen == 0 ) + { + revBegin = 0; + revEnd = 0; + } + else + { + length = kanji_status.revPos; + revBegin = CONVERT_BUFFER_SIZE * 2; + convert_to_utf8( B_EUC_CONVERSION, (const char*)kanji_status.echoStr, &length, + mikakuteiUTF, &revBegin, &state ); + revBegin += kakuteiUTFLen; + + length = kanji_status.revPos + kanji_status.revLen; + revEnd = CONVERT_BUFFER_SIZE * 2; + convert_to_utf8( B_EUC_CONVERSION, (const char*)kanji_status.echoStr, &length, + mikakuteiUTF, &revEnd, &state ); + revEnd += kakuteiUTFLen; + } +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: UpdateKanjiStatus() returning 0x%x.\n", result )); +#endif + return result; +} + +int32 +CannaInterface::GetMode() +{ + jrKanjiControl( context_id, KC_SETMODEINFOSTYLE, (char *)(int32) 2); + char mode[5]; + jrKanjiControl( context_id, KC_QUERYMODE, mode ); + current_mode = mode[1] - '@'; +//printf ("New mode = %x\n", current_mode ); + jrKanjiControl( context_id, KC_SETMODEINFOSTYLE, (char *)(int32) 0); + return current_mode; +} + + +int +CannaInterface::ConvertSpecial( char ch, uint32 mod, int32 key ) +{ +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: ConvertSpecial ch = 0x%x, mod = 0x%x, key = 0x%x\n", ch, mod, key )); +#endif + if ( mod & B_CONTROL_KEY ) // if control key is held down, do not convert special key + { + switch ( ch ) + { + case B_UP_ARROW: + return CANNA_KEY_Cntrl_Up; + break; + case B_DOWN_ARROW: + return CANNA_KEY_Cntrl_Down; + break; + case B_RIGHT_ARROW: + return CANNA_KEY_Cntrl_Right; + break; + case B_LEFT_ARROW: + return CANNA_KEY_Cntrl_Left; + break; + default: + return (uint8)ch; + } + } + + switch ( ch ) + { + case B_FUNCTION_KEY: + switch( key ) + { + case B_F1_KEY: + case B_F2_KEY: + case B_F3_KEY: + case B_F4_KEY: + case B_F5_KEY: + case B_F6_KEY: + case B_F7_KEY: + case B_F8_KEY: + case B_F9_KEY: + case B_F10_KEY: + case B_F11_KEY: + case B_F12_KEY: + return (int)CANNA_KEY_F1 + (int)key - (int)B_F1_KEY; + break; + } + break; + + case B_INSERT: + return CANNA_KEY_Insert; + break; + case B_PAGE_UP: + return CANNA_KEY_Rollup; + break; + case B_PAGE_DOWN: + return CANNA_KEY_Rolldown; + break; + case B_UP_ARROW: + if (mod & B_SHIFT_KEY /* shifted */ ) + return CANNA_KEY_Shift_Up; + else + return CANNA_KEY_Up; + break; + case B_DOWN_ARROW: + if (mod & B_SHIFT_KEY /* shifted */ ) + return CANNA_KEY_Shift_Down; + else + return CANNA_KEY_Down; + break; + case B_RIGHT_ARROW: + if (mod & B_SHIFT_KEY /* shifted */ ) + return CANNA_KEY_Shift_Right; + else + return CANNA_KEY_Right; + break; + case B_LEFT_ARROW: + if (mod & B_SHIFT_KEY /* shifted */ ) + return CANNA_KEY_Shift_Left; + else + return CANNA_KEY_Left; + break; + case B_END: + return CANNA_KEY_Help; + break; + case B_HOME: + return CANNA_KEY_Home; + break; + default: + return (int)ch; + break; + } +} + +int +CannaInterface::ConvertArrowKey( int key ) +{ + switch ( key ) + { + case CANNA_KEY_Up: + return CANNA_KEY_Left; + break; + case CANNA_KEY_Down: + return CANNA_KEY_Right; + break; + case CANNA_KEY_Shift_Up: + return CANNA_KEY_Up; + break; + case CANNA_KEY_Shift_Down: + return CANNA_KEY_Down; + break; + case CANNA_KEY_Right: + return (uint8)B_RETURN; + break; + default: + return key; + } +} + +/* +void CannaInterface::ClearPrevious() +{ + for ( long i = 0 ; i < CONVERT_BUFFER_SIZE * 2 ; i++ ) + previousUTF[i] = '\0'; +} + +void CannaInterface::GetModified( int32* from, int32* to, char** string ) +{ + int32 i, previousLen; + previousLen = strlen( previousUTF ); + + for( i = 0 ; + mikakuteiUTF[i] == previousUTF[i] + && mikakuteiUTF[i] != '\0' + && previousUTF[i] != '\0' ; + i++ ) {} + + *from = i; + + if ( mikakuteiUTFLen > previousLen ) + *to = mikakuteiUTFLen; + else + *to = previousLen; + + *string = &mikakuteiUTF[ i ]; +} + +int32 CannaInterface::ForceKakutei() +{ + if ( !canna_enabled ) + return 0; + + jrKanjiStatusWithValue ks; + ks.val = 0; + ks.buffer = (unsigned char *)kakuteiStr; + ks.bytes_buffer = CONVERT_BUFFER_SIZE; + ks.ks = &kanji_status; + jrKanjiControl(context_id, KC_KAKUTEI, (char *)&ks); + return ks.val; +} + +bool CannaInterface::ReadSetting(char *path, BFont *aFont) +{ + BMessage pref; + BFile preffile( INLINE_SETTING_FILE, B_READ_ONLY ); + if ( preffile.InitCheck() != B_NO_ERROR ) + return false; + + if ( pref.Unflatten( &preffile ) != B_OK ) + return false; + + font_family fontfamily; + float size; + char *string; + + underline_color = FindColorData( &pref, "underline" ); + highlight_color = FindColorData( &pref, "highlight" ); + selection_color = FindColorData( &pref, "selection" ); + pref.FindString( "font", &string ); + strcpy( fontfamily, string ); + pref.FindString( "dictpath", &string ); + strcpy( path, string ); + pref.FindFloat( "size", &size ); + pref.FindBool( "arrow", &convert_arrowkey ); + + aFont->SetFamilyAndStyle( fontfamily, NULL ); + aFont->SetSize( size ); + return true; +} + +rgb_color CannaInterface::FindColorData( BMessage *msg, char *name ) +{ + rgb_color result; + msg->FindInt8( name, 0, (int8 *)&result.red ); + msg->FindInt8( name, 1, (int8 *)&result.green ); + msg->FindInt8( name, 2, (int8 *)&result.blue ); + msg->FindInt8( name, 3, (int8 *)&result.alpha ); + return result; +} +*/ + +bool CannaInterface::HasRev() +{ + if ( kanji_status.revLen == 0 ) + return false; + else + return true; +} + +BMessage * +CannaInterface::GenerateKouhoString() +{ + int32 length = kanji_status.gline.length; + int32 revposition = kanji_status.gline.revPos; + int32 revend; + int32 revposUTF; + int32 revendUTF; + int32 state; + bool noindex, sizelimit, partialhighlight; +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: GenerateKouhoStr() revPos = %d, revLen = %d, mode = %d\n", revposition, kanji_status.gline.revLen, current_mode )); +#endif + + noindex = sizelimit = partialhighlight = false; + + kouhoUTFLen = KOUHO_WINDOW_MAXCHAR * 2; + convert_to_utf8( B_EUC_CONVERSION, (const char*)kanji_status.gline.line, &length, + kouhoUTF, &kouhoUTFLen, &state ); + kouhoUTF[ kouhoUTFLen ] = '\0'; + + + //find gline revpos by converting to UTF8 + if ( kanji_status.gline.revLen == 0 ) + kouhoRevLine = -1; + else + { + revposUTF = KOUHO_WINDOW_MAXCHAR * 2; + convert_to_utf8( B_EUC_CONVERSION, (const char*)kanji_status.gline.line, &revposition, + kouhoUTF, &revposUTF, &state ); + //then, count full-spaces before revpos + kouhoRevLine = 0; + + if ( current_mode == CANNA_MODE_TourokuMode + || ( kanji_status.gline.length != 0 && current_mode != CANNA_MODE_KigoMode + && current_mode != CANNA_MODE_IchiranMode + && current_mode != CANNA_MODE_YesNoMode + && current_mode != CANNA_MODE_OnOffMode + && current_mode != CANNA_MODE_BushuMode + && current_mode != CANNA_MODE_ExtendMode + && current_mode != CANNA_MODE_RussianMode + && current_mode != CANNA_MODE_GreekMode + && current_mode != CANNA_MODE_LineMode + && current_mode != CANNA_MODE_ChangingServerMode +// && current_mode != CANNA_MODE_HenkanMethodMode + && current_mode != CANNA_MODE_DeleteDicMode + && current_mode != CANNA_MODE_TourokuHinshiMode + && current_mode != CANNA_MODE_TourokuDicMode + && current_mode != CANNA_MODE_MountDicMode )) // in Touroku mode, delimiter is '['and ']' + { + revendUTF = KOUHO_WINDOW_MAXCHAR * 2; + revend = kanji_status.gline.revPos + kanji_status.gline.revLen; + convert_to_utf8( B_EUC_CONVERSION, (const char*)kanji_status.gline.line, &revend, + kouhoUTF, &revendUTF, &state ); + partialhighlight = true; + } + else + { + for ( long i = 0; i < revposUTF ; i++ ) + { + if ( (uint8)kouhoUTF[ i ] == 0xe3 + && (uint8)kouhoUTF[ i + 1 ] == 0x80 + && (uint8)kouhoUTF[ i + 2 ] == 0x80 ) + kouhoRevLine++; + } + } + + } +//printf("KouhoRevLine = %d\n", kouhoRevLine ); + + // setup title string + switch ( current_mode ) + { + case CANNA_MODE_IchiranMode: + infoUTF[0] = '\0'; + break; + case CANNA_MODE_HexMode: + strcpy( infoUTF, "16進" ); + noindex = true; + sizelimit = true; + break; + case CANNA_MODE_BushuMode: + strcpy( infoUTF, "部首 " ); + sizelimit = true; + break; + case CANNA_MODE_ExtendMode: + strcpy( infoUTF, "拡張 " ); + break; + case CANNA_MODE_RussianMode: + strcpy( infoUTF, "ロシア " ); + noindex = true; + sizelimit = true; + break; + case CANNA_MODE_GreekMode: + strcpy( infoUTF, "ギリシャ " ); + noindex = true; + sizelimit = true; + break; + case CANNA_MODE_LineMode: + strcpy( infoUTF, "罫線 " ); + noindex = true; + sizelimit = true; + break; + case CANNA_MODE_TourokuMode: + strcpy( infoUTF, "単語登録" ); + noindex = true; + sizelimit = true; + break; + case CANNA_MODE_TourokuHinshiMode: + strcpy( infoUTF, "品詞選択" ); + break; + case CANNA_MODE_TourokuDicMode: + strcpy( infoUTF, "辞書選択" ); + sizelimit = true; + break; + case CANNA_MODE_DeleteDicMode: + strcpy( infoUTF, "単語削除" ); + noindex = true; + sizelimit = true; + break; + case CANNA_MODE_MountDicMode: + strcpy( infoUTF, "辞書" ); + noindex = true; + break; + case CANNA_MODE_KigoMode: + strcpy( infoUTF, "記号 " ); + noindex = true; + sizelimit = true; + break; + default: + strcpy( infoUTF, "情報" ); + noindex = true; + } + + //setup info string according to current mode + char* index; + int32 len; + + if ( current_mode == CANNA_MODE_IchiranMode + || current_mode == CANNA_MODE_ExtendMode + || (current_mode == CANNA_MODE_TourokuHinshiMode + && kouhoRevLine != -1 ) + || current_mode == CANNA_MODE_TourokuDicMode + || current_mode == CANNA_MODE_BushuMode ) + { + //remove first index + memmove( kouhoUTF, kouhoUTF + 2, kouhoUTFLen - 1 ); + + //convert full-space to LF + while( index = strstr( kouhoUTF, "\xe3\x80\x80" ) ) + { + *index = '\x0a'; + len = strlen( index ); + memmove( index + 1, index + 5, len - 4 ); + } + kouhoUTFLen = strlen( kouhoUTF ); + } + + if ( current_mode == CANNA_MODE_KigoMode ) + { + char num[ 5 ]; + for ( long i = 0 ; i < 4 ; i++ ) + num[ i ] = kouhoUTF[ i + 3 ]; + num[ 4 ] = '\0'; + strcat( infoUTF, num ); + kouhoUTFLen -= 9; + memmove( kouhoUTF, kouhoUTF + 10, kouhoUTFLen ); + } + + if ( current_mode == CANNA_MODE_KigoMode + || current_mode == CANNA_MODE_MountDicMode + || current_mode == CANNA_MODE_RussianMode + || current_mode == CANNA_MODE_LineMode + || current_mode == CANNA_MODE_GreekMode ) + { + //convert full-space to LF + while( index = strstr( kouhoUTF, "\xe3\x80\x80" ) ) + { + *index = '\x0a'; + len = strlen( index ); + memmove( index + 1, index + 3, len - 2 ); + } + kouhoUTFLen = strlen( kouhoUTF ); + } +/* + if ( current_mode == CANNA_MODE_TourokuMode + || ( kanji_status.gline.length != 0 && ( current_mode == CANNA_MODE_TankouhoMode + || current_mode == CANNA_MODE_TankouhoMode + || current_mode == CANNA_MODE_AdjustBunsetsuMode ))) + { + //convert '[' and ']' to LF + for ( index = kouhoUTF ; index < kouhoUTF + kouhoUTFLen ; index++ ) + { + if ( *index == '[' || *index == ']' ) + *index = '\x0a'; + } + } +*/ + if ( current_mode == CANNA_MODE_IchiranMode + || current_mode == CANNA_MODE_RussianMode + || current_mode == CANNA_MODE_LineMode + || current_mode == CANNA_MODE_GreekMode + || current_mode == CANNA_MODE_ExtendMode + || (current_mode == CANNA_MODE_TourokuHinshiMode + && kouhoRevLine != -1 ) + || current_mode == CANNA_MODE_BushuMode + || current_mode == CANNA_MODE_TourokuDicMode + || current_mode == CANNA_MODE_MountDicMode ) + { + + //extract number display + index = kouhoUTF + kouhoUTFLen - 1; + while ( ( *index >= '0' && *index <= '9' ) || *index == '/' ) + index--; + strcat( infoUTF, index ); + + //remove excess spaces before number display + while ( *index == ' ' ) + *index-- = '\0'; + } + BMessage* msg = new BMessage( KOUHO_WINDOW_SETTEXT ); + msg->AddString( "text", kouhoUTF ); + msg->AddString( "info", infoUTF ); + msg->AddBool( "index", noindex ); + msg->AddBool( "limit", sizelimit ); + if ( partialhighlight ) + { + msg->AddBool( "partial", true ); + msg->AddInt32( "revbegin", revposUTF ); + msg->AddInt32( "revend", revendUTF ); + } + else + msg->AddInt32( "kouhorev", kouhoRevLine ); + return msg; +} + +uint32 CannaInterface::ChangeMode( int32 mode ) +{ + jrKanjiStatusWithValue ksv; + ksv.ks = &kanji_status; + ksv.buffer = (unsigned char *)kakuteiStr; + ksv.bytes_buffer = CONVERT_BUFFER_SIZE; + ksv.val = mode; + + jrKanjiControl( context_id, KC_CHANGEMODE, (char *)&ksv ); + kakuteiLen = ksv.val; +#ifdef DEBUG + SERIAL_PRINT(( "CannaInterface: ChangeMode returned kakuteiLen = %d\n", kakuteiLen )); + SERIAL_PRINT(( "CannaInterface: ChangeMode mikakuteiLen = %d\n", kanji_status.length )); +#endif + + return UpdateKanjiStatus(); +} + +uint32 CannaInterface::Kakutei() +{ +#ifdef DEBUG + SERIAL_PRINT(( "CannaInterface: Kakutei() called. mikL = %d\n", mikakuteiUTFLen )); +#endif + if ( mikakuteiUTFLen == 0 ) + return NOTHING_TO_KAKUTEI; + jrKanjiStatusWithValue ksv; + ksv.ks = &kanji_status; + ksv.buffer = (unsigned char *)kakuteiStr; + ksv.bytes_buffer = CONVERT_BUFFER_SIZE; + + jrKanjiControl( context_id, KC_KAKUTEI, (char *)&ksv ); + kakuteiLen = ksv.val; +#ifdef DEBUG + SERIAL_PRINT(( "CannaInterface: Kakutei() processed. kakL = %d, mikL = %d, info = 0x%x\n", kakuteiLen, kanji_status.length, kanji_status.info )); +#endif + return UpdateKanjiStatus(); +} + +/* +void CannaInterface::SetTargetITView( BView *itView ) +{ + kouhoWindow->Lock(); + kouhoWindow->SetTargetITView( itView ); + kouhoWindow->Unlock(); +} + + +void CannaInterface::ShowPalette() +{ + if ( paletteApp != NULL && paletteApp->IsValid() ) + paletteApp->SendMessage( CPW_SHOW ); +} + +void CannaInterface::HidePalette() +{ + if ( paletteApp != NULL && paletteApp->IsValid() ) + paletteApp->SendMessage( CPW_HIDE ); +} +*/ + +// RevStartPositionInChar() returns rev postion in 'Nth char in UTFed MikakuteiStr'. +// This function returns zero when rev postion is not found. + +int32 +CannaInterface::GetRevStartPositionInChar() +{ + int32 charNum; + charNum = 0; + + if ( mikakuteiUTFLen == 0 ) + return 0; +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: GetRevStartPos revBegin = %d\n", revBegin )); +#endif + + for ( int32 i = 0 ; i < mikakuteiUTFLen ; i += UTF8CharLen( mikakuteiUTF[i] ) ) + { + + if ( i == revBegin ) + { +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: GetRevStartPos found. charNum= %d\n", charNum )); +#endif + return charNum; + } + else + charNum++; + } + return 0; +} + +void +CannaInterface::Reset() +{ +#ifdef DEBUG +SERIAL_PRINT(( "CannaInterface: Resetting canna...\n" )); +#endif + jrKanjiControl( context_id, KC_FINALIZE, 0 ); + InitializeCanna(); +} diff --git a/src/add-ons/input_server/methods/canna/CannaInterface.h b/src/add-ons/input_server/methods/canna/CannaInterface.h new file mode 100644 index 0000000000..2e80df82fb --- /dev/null +++ b/src/add-ons/input_server/methods/canna/CannaInterface.h @@ -0,0 +1,98 @@ +// +// CannaInterface.h +// canna library wrapper + +// This is a part of... +// CannaIM +// version 1.0 +// (c) 1999 M.Kawamura +// + +#ifndef _CANNA_INTERFACE_H +#define _CANNA_INTERFACE_H + +#include +#include +#include +#include + +#include "canna/jrkanji.h" +#include "CannaCommon.h" +//#include "InlineTextViewDefs.h" +//#include "InlineKouhoWindow.h" + +extern Preferences gSettings; + +class CannaInterface +{ +private: + jrKanjiStatus kanji_status; +// InlineKouhoWindow* kouhoWindow; +// BMessenger* paletteApp; + bool canna_enabled; + bool hadMikakuteiStr; + bool hadGuideLine; + bool convert_arrowkey; + int context_id; +// BFont kouhoFont; +// rgb_color underline_color; +// rgb_color highlight_color; + rgb_color selection_color; + int32 kakuteiLen; + int32 kakuteiUTFLen; + int32 mikakuteiUTFLen; + int32 kouhoUTFLen; + int32 revBegin; + int32 revEnd; + int32 kouhoRevLine; + int32 current_mode; + char basePath[ B_PATH_NAME_LENGTH + 1 ]; + char kakuteiStr[ CONVERT_BUFFER_SIZE ]; + char kakuteiUTF[ CONVERT_BUFFER_SIZE * 2 ]; + char mikakuteiUTF[ CONVERT_BUFFER_SIZE * 2 ]; +// char previousUTF[ CONVERT_BUFFER_SIZE * 2]; + char kouhoUTF[ KOUHO_WINDOW_MAXCHAR * 2 ]; + char infoUTF[ NUMBER_DISPLAY_MAXCHAR ]; + int ConvertSpecial( char ch, uint32 mod, int32 key ); + int ConvertArrowKey( int key ); +// void ClearPrevious(); +// bool ReadSetting(char *path, BFont *aFont); + uint32 UpdateKanjiStatus(); + void InitializeCanna(); + + +public: + CannaInterface( char *basepath ); + ~CannaInterface(); + //void SetTargetITView( BView *itView ); + status_t InitCheck(); + uint32 KeyIn( char ch, uint32 mod, int32 key ); + char* GetKakuteiStr() + { return kakuteiUTF; }; + int32 KakuteiLength() + { return kakuteiUTFLen; }; + char* GetMikakuteiStr() + { return mikakuteiUTF; }; + int32 MikakuteiLength() + { return mikakuteiUTFLen; }; +// void GetModified( int32* from, int32* to, char** string ); +// int32 ForceKakutei(); + bool HasRev(); + void GetRevPosition( int32* begin, int32 *end ) + { *begin = revBegin; *end = revEnd; }; + int32 GetRevStartPositionInChar(); + void SetConvertArrowKey( bool convert ) + { convert_arrowkey = convert; }; + uint32 ChangeMode( int32 mode ); + uint32 CurrentMode() + { return current_mode; }; + uint32 Kakutei(); + BMessage* GenerateKouhoString(); + int32 GetMode(); + void Reset(); + //void HidePalette(); + //void ShowPalette(); + //void UpdateModePalette(); +}; + +#endif diff --git a/src/add-ons/input_server/methods/canna/CannaLooper.cpp b/src/add-ons/input_server/methods/canna/CannaLooper.cpp new file mode 100644 index 0000000000..2db89c22ae --- /dev/null +++ b/src/add-ons/input_server/methods/canna/CannaLooper.cpp @@ -0,0 +1,534 @@ +// +// CannaLooper.cpp +// CannaIM looper object + +// This is a part of... +// CannaIM +// version 1.0 +// (c) 1999 M.Kawamura +// + +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +#include +#endif + +#include "CannaCommon.h" +#include "CannaLooper.h" +#include "CannaMethod.h" +#include "KouhoWindow.h" +#include "PaletteWindow.h" + +CannaLooper::CannaLooper( CannaMethod *method ) + :BLooper( "Canna Looper" ) +{ + owner = method; + canna = 0; + theKouhoWindow = 0; + thePalette = 0; + self = BMessenger( NULL, this ); + + theMenu = new BMenu( B_EMPTY_STRING ); + theMenu->SetFont( be_plain_font ); + theMenu->AddItem( new BMenuItem( "About CannaIM…", new BMessage( B_ABOUT_REQUESTED ))); + theMenu->AddSeparatorItem(); + theMenu->AddItem( new BMenuItem( "Convert arrow keys", new BMessage( ARROW_KEYS_FLIPPED ))); + theMenu->AddItem( new BMenuItem( "Reload Init file", new BMessage( RELOAD_INIT_FILE ))); + + if ( gSettings.convert_arrowkey ) + { + BMenuItem *item = theMenu->FindItem( ARROW_KEYS_FLIPPED ); + item->SetMarked( true ); + } + + Run(); +} + +status_t +CannaLooper::InitCheck() +{ + status_t err; + char basepath[ B_PATH_NAME_LENGTH + 1 ]; + err = ReadSettings( basepath ); + if ( err != B_NO_ERROR ) + return err; + + canna = new CannaInterface( basepath ); + err = canna->InitCheck(); + if ( err != B_NO_ERROR ) + return err; + +// theKouhoWindow = new KouhoWindow( &kouhoFont ); + + return B_NO_ERROR; +} + +void +CannaLooper::Quit() +{ + // delete palette here +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: destructor called.\n" )); +#endif + if ( canna ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: Deleting canna...\n" )); +#endif + delete canna; + } + + if ( theKouhoWindow ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: Sending QUIT to kouho window...\n" )); +#endif + theKouhoWindow->Lock(); + theKouhoWindow->Quit(); + } + + if ( thePalette ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: Sending QUIT to palette...\n" )); +#endif + thePalette->Lock(); + thePalette->Quit(); + } + + owner->SetMenu( NULL, BMessenger() ); + delete theMenu; + BLooper::Quit(); +} + +status_t +CannaLooper::ReadSettings( char *basepath ) +{ + strcpy( basepath, "/boot/home/config/KanBe/" ); + font_family family; + font_style style; + strcpy( family, "Haru" ); + strcpy( style, "Regular" ); + kouhoFont.SetFamilyAndStyle( family, style ); + kouhoFont.SetSize( 12 ); + return B_NO_ERROR; +} + +void +CannaLooper::EnqueueMessage( BMessage *msg ) +{ + owner->EnqueueMessage( msg ); +} + +void +CannaLooper::MessageReceived( BMessage *msg ) +{ +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: Entering MessageReceived() what=%x\n", msg->what )); +#endif + switch ( msg->what ) + { + case B_KEY_DOWN: + case NUM_SELECTED_FROM_KOUHO_WIN: + HandleKeyDown( msg ); + break; + + case B_INPUT_METHOD_EVENT: + uint32 opcode, result; + opcode = 0; + msg->FindInt32( "be:opcode", (int32 *)&opcode ); + switch ( opcode ) + { + case B_INPUT_METHOD_LOCATION_REQUEST: + HandleLocationReply( msg ); + break; + + case B_INPUT_METHOD_STOPPED: +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_STOPPED received\n" )); +#endif + ForceKakutei(); + break; + } + break; + + case CANNA_METHOD_ACTIVATED: +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: CANNA_METHOD_ACTIVATED received\n" )); +#endif + HandleMethodActivated( msg->HasBool( "active" ) ); + break; + + case MODE_CHANGED_FROM_PALETTE: + ForceKakutei(); + int32 mode; + msg->FindInt32( "mode", &mode ); + result = canna->ChangeMode( mode ); + ProcessResult( result ); + break; + + case B_ABOUT_REQUESTED: +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_ABOUT_REQUESTED received\n" )); +#endif + BAlert *panel; + panel = new BAlert( "", "CannaIM Version 1.02\n" + " by Masao Kawamura 1999\n\n" + "Canna\n Copyright 1992 NEC Corporation, Tokyo, Japan\n" + " Special thanks to T.Murai for porting\n" + " BeOS Version 1.02", + "OK" ); + panel->Go(); + break; + + case RELOAD_INIT_FILE: + ForceKakutei(); + canna->Reset(); + break; + + case ARROW_KEYS_FLIPPED: + { + BMenuItem *item = theMenu->FindItem( ARROW_KEYS_FLIPPED ); + gSettings.convert_arrowkey = !gSettings.convert_arrowkey; + item->SetMarked( gSettings.convert_arrowkey ); + canna->SetConvertArrowKey( gSettings.convert_arrowkey ); + + } + break; + + + default: + BLooper::MessageReceived( msg ); + break; + } +} + +void CannaLooper::HandleKeyDown( BMessage *msg ) +{ + uint32 result; + uint32 modifier; +// int32 rawchar; + int32 key; + char theChar; + + msg->FindInt32( "modifiers", (int32 *)&modifier ); + msg->FindInt32( "key", &key ); +// msg->FindInt32( "raw_char", &rawchar ); + + if ( ( modifier & B_COMMAND_KEY ) != 0 ) + { + EnqueueMessage( DetachCurrentMessage() ); + return; + } + + msg->FindInt8( "byte", (int8 *)&theChar ); + +// The if clause below is to avoid processing key input which char code is 0x80 or more. +// if mikakutei string exists, dispose current message. +// Otherwise, send it to application as usual B_KEY_DOWN message. +// This is a bug fix for version 1.0 beta 2 + + if ( theChar & 0x80 ) + { + if ( canna->MikakuteiLength() != 0 ) + { + BMessage *blackhole = DetachCurrentMessage(); + delete blackhole; + } + else + EnqueueMessage( DetachCurrentMessage() ); + + return; + } + +// end of bug fix + +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: HandleKeyDown() calling CannaInterface::KeyIn()...\n", result )); +#endif + + result = canna->KeyIn( theChar, modifier, key ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: HandleKeyDown() received result = %d from CannaInterface.\n", result )); +#endif + ProcessResult( result ); +} + +void +CannaLooper::ProcessResult( uint32 result ) +{ +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing result = %d\n", result )); +#endif + if ( result & GUIDELINE_APPEARED ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing GUIDELINE_APPEARED\n" )); +#endif + if ( canna->MikakuteiLength() != 0 ) // usual guideline i.e. kouho + { + BMessage *msg = new BMessage( B_INPUT_METHOD_EVENT ); + msg->AddInt32( "be:opcode", B_INPUT_METHOD_LOCATION_REQUEST ); + owner->EnqueueMessage( msg ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_LOCATION_REQUEST has been sent\n" )); +#endif + } + else // guideline exists, but no mikakutei string - means extend mode and such. + { +#ifdef DEBUG + SERIAL_PRINT(( " GUIDELINE_APPEARED: calling GenerateKouho()...\n" )); +#endif + theKouhoWindow->PostMessage( canna->GenerateKouhoString() ); + BMessage m( KOUHO_WINDOW_SHOW_ALONE ); +#ifdef DEBUG + SERIAL_PRINT(( " GUIDELINE_APPEARED: posting KouhoMsg to KouhoWindow %x...\n", theKouhoWindow )); +#endif + theKouhoWindow->PostMessage( &m ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: KOUHO_WINDOW_SHOW_ALONE has been sent\n" )); +#endif + } + + } + +// if ( result == MIKAKUTEI_NO_CHANGE ) +// return; + + if ( result & GUIDELINE_DISAPPEARED ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing GUIDELINE_DISAPPEARED\n" )); +#endif + theKouhoWindow->PostMessage( KOUHO_WINDOW_HIDE ); + } + + if ( result & MODE_CHANGED ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing MODE_CHANGED\n" )); +#endif + int32 mode; + mode = canna->GetMode(); + BMessage m( PALETTE_WINDOW_BUTTON_UPDATE ); + m.AddInt32( "mode", mode ); + thePalette->PostMessage( &m ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: PALETTE_BUTTON_UPDATE has been sent. mode = %d\n", mode )); +#endif + } + + if ( result & GUIDELINE_CHANGED ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing GUIDELINE_CHANGED\n" )); +#endif + theKouhoWindow->PostMessage( canna->GenerateKouhoString() ); + } + + if ( result & THROUGH_INPUT ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing THROUGH_INPUT\n" )); +#endif + EnqueueMessage( DetachCurrentMessage() ); + } + + if ( result & NEW_INPUT_STARTED ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing NEW_INPUT_STARTED\n" )); +#endif + SendInputStarted(); + } + + if ( result & KAKUTEI_EXISTS ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing KAKUTEI_EXISTS\n" )); +#endif + BMessage *msg = new BMessage( B_INPUT_METHOD_EVENT ); + msg->AddInt32( "be:opcode", B_INPUT_METHOD_CHANGED ); + + msg->AddString("be:string", canna->GetKakuteiStr() ); + msg->AddInt32("be:clause_start", 0); + msg->AddInt32("be:clause_end", canna->KakuteiLength() ); + msg->AddInt32("be:selection", canna->KakuteiLength() ); + msg->AddInt32("be:selection", canna->KakuteiLength() ); + msg->AddBool( "be:confirmed", true ); + owner->EnqueueMessage( msg ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_CHANGED (confired) has been sent\n" )); +#endif + if ( !(result & MIKAKUTEI_EXISTS) ) //if both kakutei and mikakutei exist, do not send B_INPUT_STOPPED + SendInputStopped(); + + } + + if ( result & MIKAKUTEI_EXISTS ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing MIKAKUTEI_EXISTS\n" )); +#endif + int32 start, finish; + BMessage *msg = new BMessage( B_INPUT_METHOD_EVENT ); + msg->AddInt32( "be:opcode", B_INPUT_METHOD_CHANGED ); + + msg->AddString("be:string", canna->GetMikakuteiStr() ); + if ( canna->HasRev() ) + { + canna->GetRevPosition( &start, &finish ); + msg->AddInt32("be:clause_start", 0); + msg->AddInt32("be:clause_end", start ); + msg->AddInt32("be:clause_start", start ); + msg->AddInt32("be:clause_end", finish ); + msg->AddInt32("be:clause_start", finish ); + msg->AddInt32("be:clause_end", canna->MikakuteiLength() ); + } + else + { + start = finish = canna->MikakuteiLength(); + msg->AddInt32("be:clause_start", 0); + msg->AddInt32("be:clause_end", canna->MikakuteiLength() ); + } + + msg->AddInt32("be:selection", start ); + msg->AddInt32("be:selection", finish ); + //msg->AddBool( "be:confirmed", false ); + owner->EnqueueMessage( msg ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_CHANGED (non-confirmed) has been sent\n" )); +#endif + } + + if ( result & MIKAKUTEI_BECOME_EMPTY ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ProcessResult() processing MIKAKUTEI_BECOME_EMPTY\n" )); +#endif + BMessage *msg = new BMessage( B_INPUT_METHOD_EVENT ); + msg->AddInt32( "be:opcode", B_INPUT_METHOD_CHANGED ); + + msg->AddString("be:string", B_EMPTY_STRING ); + msg->AddInt32("be:clause_start", 0); + msg->AddInt32("be:clause_end", 0 ); + msg->AddInt32("be:selection", 0 ); + msg->AddInt32("be:selection", 0 ); + msg->AddBool( "be:confirmed", true ); + owner->EnqueueMessage( msg ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_CHANGED (NULL, confired) has been sent\n" )); +#endif + + SendInputStopped(); + } +} + +void +CannaLooper::HandleLocationReply( BMessage *msg ) +{ + BPoint where = B_ORIGIN; + float height = 0.0; + int32 start; + +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_LOCATION_REQUEST received\n" )); +#endif + + start = canna->GetRevStartPositionInChar(); +#ifdef DEBUG + type_code type; + int32 count; + msg->GetInfo( "be:location_reply", &type, &count ); + SERIAL_PRINT(( "CannaLooper: LOCATION_REPLY has %d locations.\n", count )); + SERIAL_PRINT(( "CannaLooper: RevStartPosition is %d.\n", start )); +#endif + msg->FindPoint( "be:location_reply", start, &where ); + msg->FindFloat( "be:height_reply", start, &height ); + BMessage m( KOUHO_WINDOW_SHOWAT ); + m.AddPoint( "position", where ); + m.AddFloat( "height", height ); + + + theKouhoWindow->PostMessage( canna->GenerateKouhoString() ); + theKouhoWindow->PostMessage( &m ); +} + +void +CannaLooper::HandleMethodActivated( bool active ) +{ + if ( active ) + { + if ( !thePalette ) //first time input method activated + { + float x = gSettings.palette_loc.x; + float y = gSettings.palette_loc.y; + BRect frame( x, y, x + 114, y + 44 ); + thePalette = new PaletteWindow( frame, this ); + thePalette->Show(); + theKouhoWindow = new KouhoWindow( &kouhoFont, this ); + theKouhoWindow->Run(); + } + thePalette->PostMessage( PALETTE_WINDOW_SHOW ); + owner->SetMenu( theMenu, self ); + } + else + { + ForceKakutei(); + uint32 result = canna->ChangeMode( CANNA_MODE_HenkanMode ); + BMessage m( PALETTE_WINDOW_BUTTON_UPDATE ); + m.AddInt32( "mode", CANNA_MODE_HenkanMode ); + thePalette->PostMessage( &m ); + thePalette->PostMessage( PALETTE_WINDOW_HIDE ); + theKouhoWindow->PostMessage( KOUHO_WINDOW_HIDE ); + owner->SetMenu( NULL, self ); + } +} + +void +CannaLooper::ForceKakutei() +{ +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: ForceKakutei() called\n" )); +#endif + uint32 result = canna->Kakutei(); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: returned from Kakutei(). result = %d\n", result )); +#endif + if ( result != NOTHING_TO_KAKUTEI ) + ProcessResult( result ); + else + SendInputStopped(); + + return; +} + +void +CannaLooper::SendInputStopped() +{ + BMessage *msg = new BMessage( B_INPUT_METHOD_EVENT ); + msg->AddInt32( "be:opcode", B_INPUT_METHOD_STOPPED ); + EnqueueMessage( msg ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_STOPPED has been sent\n" )); +#endif +} + +void +CannaLooper::SendInputStarted() +{ + BMessage *msg = new BMessage( B_INPUT_METHOD_EVENT ); + msg->AddInt32( "be:opcode", B_INPUT_METHOD_STARTED ); + msg->AddMessenger( "be:reply_to", BMessenger( NULL, this ) ); + EnqueueMessage( msg ); +#ifdef DEBUG + SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_STARTED has been sent\n" )); +#endif +} + diff --git a/src/add-ons/input_server/methods/canna/CannaLooper.h b/src/add-ons/input_server/methods/canna/CannaLooper.h new file mode 100644 index 0000000000..a8c52bae81 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/CannaLooper.h @@ -0,0 +1,55 @@ +// +// CannaLooper.h +// CannaIM Looper object + +// This is a part of... +// CannaIM +// version 1.0 +// (c) 1999 M.Kawamura +// + +#ifndef _CANNA_LOOPER_H +#define _CANNA_LOOPER_H + +#include +#include +#include +#include "CannaInterface.h" + +class CannaMethod; +class KouhoWindow; +class PaletteWindow; +class BMenu; +class BMessenger; + +extern Preferences gSettings; + +class CannaLooper : public BLooper +{ +public: + CannaLooper( CannaMethod *method ); + virtual void Quit(); + void MessageReceived( BMessage *msg ); + void EnqueueMessage( BMessage *msg ); + status_t InitCheck(); + status_t ReadSettings( char *basepath ); +// bool QuitRequested(); + void SendInputStopped(); + void SendInputStarted(); + +private: + CannaMethod* owner; + CannaInterface* canna; + BFont kouhoFont; + void HandleKeyDown( BMessage *msg ); + void HandleLocationReply( BMessage *msg ); + void HandleMethodActivated( bool active ); + void ProcessResult( uint32 result ); + void ForceKakutei(); + KouhoWindow* theKouhoWindow; + PaletteWindow* thePalette; + BMenu* theMenu; + BMessenger self; +}; + +#endif diff --git a/src/add-ons/input_server/methods/canna/CannaMethod.cpp b/src/add-ons/input_server/methods/canna/CannaMethod.cpp new file mode 100644 index 0000000000..4d4d0e170c --- /dev/null +++ b/src/add-ons/input_server/methods/canna/CannaMethod.cpp @@ -0,0 +1,144 @@ +// +// CannaIM - Canna-based Input Method Add-on for BeOS R4 +// + +#include +#include +#include +#include +#include + +#include "CannaCommon.h" +#include "CannaMethod.h" +#include "CannaLooper.h" + +#include "Bitmaps.h" + +#ifdef DEBUG +#include +#endif + +Preferences gSettings; + +BInputServerMethod* +instantiate_input_method() +{ + return (new CannaMethod()); +} + + +CannaMethod::CannaMethod() + :BInputServerMethod( "Canna", (const uchar *)kCannaIcon ) +{ +#ifdef DEBUG + SERIAL_PRINT(( "CannaIM:Constructor called.\n" )); +#endif + ReadSettings(); +} + +CannaMethod::~CannaMethod() +{ + BLooper *looper = NULL; + cannaLooper.Target( &looper ); + if ( looper != NULL ) + { +#ifdef DEBUG + SERIAL_PRINT(( "CannaIM:Locking CannaLooper...\n" )); +#endif + if ( looper->Lock() ) +#ifdef DEBUG + SERIAL_PRINT(( "CannaIM:CannaLooper locked. Calling Quit().\n" )); +#endif + looper->Quit(); + } + WriteSettings(); +} + +status_t +CannaMethod::MethodActivated( bool active ) +{ + BMessage msg( CANNA_METHOD_ACTIVATED ); + + if ( active ) + msg.AddBool( "active", true ); + + cannaLooper.SendMessage( &msg ); + + return B_OK; +} + +filter_result +CannaMethod::Filter( BMessage *msg, BList *outList ) +{ + if ( msg->what != B_KEY_DOWN ) + return B_DISPATCH_MESSAGE; + + cannaLooper.SendMessage( msg ); + return B_SKIP_MESSAGE; +} + +status_t +CannaMethod::InitCheck() +{ +#ifdef DEBUG + SERIAL_PRINT(( "CannaIM:InitCheck() called.\n" )); +#endif + CannaLooper *looper; + status_t err; + looper = new CannaLooper( this ); + looper->Lock(); + err = looper->InitCheck(); + looper->Unlock(); + cannaLooper = BMessenger( NULL, looper ); +#ifdef DEBUG + if ( err != B_NO_ERROR ) + SERIAL_PRINT(( "CannaLooper::InitCheck() failed.\n" )); + else + SERIAL_PRINT(( "CannaLooper::InitCheck() success.\n" )); +#endif + + return err; +} + +void +CannaMethod::ReadSettings() +{ + BMessage pref; + BFile preffile( CANNAIM_SETTINGS_FILE, B_READ_ONLY ); + if ( preffile.InitCheck() == B_NO_ERROR && pref.Unflatten( &preffile ) == B_OK ) + { + pref.FindBool( "arrowkey", &gSettings.convert_arrowkey ); + pref.FindPoint( "palette", &gSettings.palette_loc ); + pref.FindPoint( "standalone", &gSettings.standalone_loc ); +#ifdef DEBUG +SERIAL_PRINT(( "CannaMethod: ReadSettings() success. arrowkey=%d, palette_loc=%d,%d standalone_loc=%d, %d\n", gSettings.convert_arrowkey, gSettings.palette_loc.x, gSettings.palette_loc.y, gSettings.standalone_loc.x, gSettings.standalone_loc.y )); +#endif + return; + } + + //set default values +#ifdef DEBUG +SERIAL_PRINT(( "CannaMethod: ReadSettings() failed.\n" )); +#endif + gSettings.convert_arrowkey = true; + gSettings.palette_loc.Set( 800, 720 ); + gSettings.standalone_loc.Set( 256, 576 ); +} + +void CannaMethod::WriteSettings() +{ + BMessage pref; + BFile preffile( CANNAIM_SETTINGS_FILE, + B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE ); + + if ( preffile.InitCheck() == B_NO_ERROR ) + { + pref.AddBool( "arrowkey", gSettings.convert_arrowkey ); + pref.AddPoint( "palette", gSettings.palette_loc ); + pref.AddPoint( "standalone", gSettings.standalone_loc ); + pref.Flatten( &preffile ); +#ifdef DEBUG +SERIAL_PRINT(( "CannaMethod: WriteSettings() success. arrowkey=%d, palette_loc=%d,%d standalone_loc=%d, %d\n", gSettings.convert_arrowkey, gSettings.palette_loc.x, gSettings.palette_loc.y, gSettings.standalone_loc.x, gSettings.standalone_loc.y )); +#endif + } +} diff --git a/src/add-ons/input_server/methods/canna/CannaMethod.h b/src/add-ons/input_server/methods/canna/CannaMethod.h new file mode 100644 index 0000000000..82b14b1f1a --- /dev/null +++ b/src/add-ons/input_server/methods/canna/CannaMethod.h @@ -0,0 +1,35 @@ +// +// CannaIM - Canna-based Input Method Add-on for BeOS R4 +// + +#ifndef _CANNAMETHOD_H +#define _CANNAMETHOD_H + +#include +#include + +#if __POWERPC__ +#pragma export on +#endif +extern "C" _EXPORT BInputServerMethod* instantiate_input_method(); +#if __POWERPC__ +#pragma export off +#endif + +class CannaLooper; + +class CannaMethod : public BInputServerMethod +{ +public: + CannaMethod(); + virtual ~CannaMethod(); + status_t MethodActivated( bool active ); + status_t InitCheck(); + filter_result Filter(BMessage *message, BList *outList); +private: + BMessenger cannaLooper; + void ReadSettings(); + void WriteSettings(); +}; + +#endif diff --git a/src/add-ons/input_server/methods/canna/Jamfile b/src/add-ons/input_server/methods/canna/Jamfile new file mode 100644 index 0000000000..c24e45fe7f --- /dev/null +++ b/src/add-ons/input_server/methods/canna/Jamfile @@ -0,0 +1,13 @@ +SubDir OBOS_TOP src add-ons input_server methods canna ; + +Addon canna : input_server/methods : + CannaInterface.cpp + CannaLooper.cpp + CannaMethod.cpp + KouhoWindow.cpp + PaletteWindow.cpp + : false + : be textencoding input_server libcanna.a librk.a ; + +SubInclude OBOS_TOP src add-ons input_server methods canna lib ; +SubInclude OBOS_TOP src add-ons input_server methods canna rk ; diff --git a/src/add-ons/input_server/methods/canna/KouhoWindow.cpp b/src/add-ons/input_server/methods/canna/KouhoWindow.cpp new file mode 100644 index 0000000000..f072e784c9 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/KouhoWindow.cpp @@ -0,0 +1,362 @@ +// +// KouhoWindow.cpp +// +// This is a part of... +// CannaIM +// version 1.0 +// (c) 1999 M.Kawamura +// + +#include +#ifdef DEBUG +#include +#endif + +#include "KouhoWindow.h" + +KouhoWindow::KouhoWindow( BFont *font, BLooper *looper ) + :BWindow( DUMMY_RECT, + "kouho", (window_look) 25/*B_FLOATING_WINDOW_LOOK*/, + B_FLOATING_ALL_WINDOW_FEEL, + B_NOT_RESIZABLE | B_NOT_CLOSABLE | + B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AVOID_FOCUS | + B_NOT_ANCHORED_ON_ACTIVATE ) +{ + float fontHeight; + BRect frame; + BFont indexfont; + + cannaLooper = looper; + kouhoFont = font; + + font_family family; + font_style style; + strcpy( family, "Haru" ); + strcpy( style, "Regular" ); + indexfont.SetFamilyAndStyle( family, style ); + indexfont.SetSize( 10 ); + +#ifdef DEBUG +SERIAL_PRINT(( "kouhoWindow: Constructor called.\n" )); +#endif + + //setup main pane + indexWidth = indexfont.StringWidth( "W" ) + INDEXVIEW_SIDE_MARGIN * 2; + minimumWidth = indexfont.StringWidth( "ギリシャ 100/100" ); + + frame = Bounds(); + frame.left = indexWidth + 2; + frame.bottom -= INFOVIEW_HEIGHT; + kouhoView = new KouhoView( frame ); + BRect screenrect = BScreen( this ).Frame(); + kouhoView->SetTextRect( screenrect ); //big enough + kouhoView->SetFontAndColor( kouhoFont ); + kouhoView->SetWordWrap( false ); + AddChild( kouhoView ); + fontHeight = kouhoView->LineHeight(); + + frame = Bounds(); + frame.right = indexWidth; + frame.bottom = frame.bottom - INFOVIEW_HEIGHT + 1; + indexView = new KouhoIndexView( frame, fontHeight ); + indexView->SetFont( &indexfont ); + AddChild( indexView ); + + frame = Bounds(); + frame.top = frame.bottom - INFOVIEW_HEIGHT + 1; + infoView = new KouhoInfoView( frame ); + infoView->SetFont( &indexfont ); + infoView->SetAlignment( B_ALIGN_RIGHT ); + AddChild( infoView ); +} + +void KouhoWindow::MessageReceived( BMessage* msg ) +{ + float height, width, x, y, w; + BPoint point; + BRect screenrect, frame; + + switch( msg->what ) + { + case KOUHO_WINDOW_HIDE: +#ifdef DEBUG +SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_HIDE recieved.\n" )); +#endif + if ( !IsHidden() ) + { + Hide(); + standalone_mode = false; + } + break; + + case KOUHO_WINDOW_SHOW: +#ifdef DEBUG +SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_SHOW recieved.\n" )); +#endif + ShowWindow(); + break; + + case KOUHO_WINDOW_SHOW_ALONE: + standalone_mode = true; + frame = Frame(); + screenrect = BScreen().Frame(); + frame.OffsetTo( gSettings.standalone_loc.x, gSettings.standalone_loc.y ); + + x = screenrect.right - frame.right; + y = screenrect.bottom - frame.bottom; + + if ( x < 0 ) + frame.OffsetBy( x, 0 ); + + if ( y < 0 ) + frame.OffsetBy( 0, y ); + + gSettings.standalone_loc.x = frame.left; + gSettings.standalone_loc.y = frame.top; + point = frame.LeftTop(); + MoveTo( point ); + ShowWindow(); + break; + + case KOUHO_WINDOW_SHOWAT: +#ifdef DEBUG +SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_SHOWAT recieved.\n" )); +#endif + msg->FindPoint( "position", &point ); + msg->FindFloat( "height", &height ); + ShowAt( point, height ); + break; + + case KOUHO_WINDOW_SETTEXT: + const char* newtext; + bool hideindex, limitsize, partialhighlight; + msg->FindString( "text", &newtext ); + kouhoView->SetText( newtext ); + + msg->FindBool( "index", &hideindex ); + indexView->HideNumberDisplay( hideindex ); + + msg->FindBool( "limit", &limitsize ); + height = kouhoView->TextHeight( 0, kouhoView->TextLength() ); + height += INFOVIEW_HEIGHT; + + msg->FindString( "info", &newtext ); + infoView->SetText( newtext ); + // calculate widest line width + width = 0; + for ( int32 line = 0, numlines = kouhoView->CountLines() ; + line < numlines ; line++ ) + { + w = kouhoView->LineWidth( line ); + if ( w > width ) + width = w; + } + if ( limitsize && width < minimumWidth ) + width = minimumWidth; + ResizeTo( width + indexWidth + KOUHOVIEW_SIDE_MARGIN, height ); + + if ( msg->HasBool( "partial" ) ) + { + int32 begin, end; + msg->FindInt32( "revbegin", &begin ); + msg->FindInt32( "revend", &end ); + kouhoView->HighlightPartial( begin, end ); +#ifdef DEBUG +SERIAL_PRINT(( "kouhoWindow: KOUHO_WINDOW_SETTEXT(partial) received. rev = %d to %d\n", begin, end )); +#endif + } + else + { + int32 kouhorevline; + msg->FindInt32( "kouhorev", &kouhorevline ); + kouhoView->HighlightLine( kouhorevline ); + } + + break; + + case NUM_SELECTED_FROM_KOUHO_WIN: + cannaLooper->PostMessage( msg ); + break; + + default: + BWindow::MessageReceived( msg ); + } +} + +void KouhoWindow::ShowAt( BPoint revpoint, float height ) +{ + BRect screenrect; + BPoint point; + int32 kouhowidth, kouhoheight; + + kouhowidth = Frame().IntegerWidth(); + kouhoheight = Frame().IntegerHeight(); + + screenrect = BScreen( this ).Frame(); +#ifdef DEBUG +SERIAL_PRINT(( "KouhoWindow: ShowAt activated. point x= %f, y= %f, height= %f", revpoint.x, revpoint.y, height )); +#endif + //adjust to preferred position - considering window border & index + //revpoint.y += WINDOW_BORDER_WIDTH; + point.y = revpoint.y + height + WINDOW_BORDER_WIDTH_V; + point.x = revpoint.x - indexView->Frame().IntegerWidth() + - INDEXVIEW_SIDE_MARGIN; + + if ( point.y + kouhoheight > screenrect.bottom ) + point.y = revpoint.y - kouhoheight - WINDOW_BORDER_WIDTH_V; +// else +// point.y = revpoint.y + height; + + if ( point.x + kouhowidth > screenrect.right ) + point.x = point.x - (screenrect.right - (point.x + kouhowidth )); +// point.x = revpoint.x +// - ( revpoint.x + kouhowidth + WINDOW_BORDER_WIDTH - screenrect.right ); +// else +// point.x = revpoint.x; + + MoveTo( point ); + ShowWindow(); +} + +void +KouhoWindow::FrameMoved( BPoint screenPoint ) +{ + if ( standalone_mode ) + gSettings.standalone_loc = screenPoint; + return; +} + +// ShowWindow() shows kouho window on current workspace +// This is a bug fix for version 1.0 beta 2 +void +KouhoWindow::ShowWindow() +{ + if ( IsHidden() ) + { + SetWorkspaces( B_CURRENT_WORKSPACE ); + Show(); + } +} + +/* + KouhoView section +*/ + +KouhoView::KouhoView( BRect rect ) + :BTextView( rect, "kouhoview", rect, B_FOLLOW_ALL, B_WILL_DRAW ) +{ + selection_color.red = 203; + selection_color.green = 152; + selection_color.blue = 255; +} + +void KouhoView::HighlightLine( int32 line ) +{ +//printf( "highlightLine set to :%d\n", line); + int32 begin, end; + BRegion region; + + if ( line != -1 ) + { + begin = OffsetAt( line ); + if ( line == CountLines() ) + end = TextLength() + 1; + else + end = OffsetAt( line + 1 ) - 1; +//printf( "Highlight line:%d, offset %d-%d\n", line,begin,end); + GetTextRegion( begin, end, ®ion ); + //as hightlight is just one line, 0 is enough. + highlightRect = region.RectAt( 0 ); + //extend highlihght region to right end + highlightRect.right = Bounds().right; + Invalidate( highlightRect ); + + } + +} + +void +KouhoView::HighlightPartial( int32 begin, int32 end ) +{ + BRegion region; + GetTextRegion( begin, end, ®ion ); + highlightRect = region.RectAt( 0 ); + Invalidate( highlightRect ); +} + +void KouhoView::Draw( BRect rect ) +{ + rgb_color viewcolor = ViewColor(); + SetHighColor( selection_color ); + SetDrawingMode( B_OP_MIN ); + FillRect( highlightRect ); + BTextView::Draw( rect ); +// SetViewColor( viewcolor ); +} + +void KouhoView::MouseDown( BPoint point ) +{ + BWindow *win; + KouhoIndexView *iview; + iview = (KouhoIndexView *)(Window()->FindView( "index" )); + if ( iview->IsNumberDisplayHidden() ) + return; + + int32 number; + number = LineAt( point ); + BMessage msg( NUM_SELECTED_FROM_KOUHO_WIN ); + msg.AddInt32( "modifiers", 0 ); + msg.AddInt8( "byte", (int8)number + '1' ); + Window()->PostMessage( &msg ); +} +/* + KouhoIndexView section +*/ + +KouhoIndexView::KouhoIndexView( BRect frame, float fontheight ) + :BBox( frame, "index", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW ) +{ + font_height ht; + float indexfontheight; + lineHeight = fontheight; + be_plain_font->GetHeight( &ht ); + indexfontheight = ht.ascent + ht.descent + ht.leading; + if ( indexfontheight < lineHeight ) + fontOffset = (int32)((lineHeight - indexfontheight) / 2 + 1.5); +//printf("line height=%f, index font height=%f, offset=%d\n", lineHeight, indexfontheight, fontOffset ); + +} + +void KouhoIndexView::Draw( BRect rect ) +{ + BBox::Draw( rect ); + for ( long i = 1; i < 17 ; i++ ) + { + MovePenTo( INDEXVIEW_SIDE_MARGIN + 2, lineHeight * i - fontOffset ); + if ( hideNumber ) + DrawString( "•" ); + else + DrawChar( '0' + i ); + } +} + +// +// InfoView section +// + +KouhoInfoView::KouhoInfoView( BRect frame ) + :BStringView( frame, "infoview", "0/0", + B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM ) +{ +} + +void +KouhoInfoView::Draw( BRect rect ) +{ + BPoint start, end; + BRect bounds = Bounds(); + start = B_ORIGIN; + end.Set( bounds.right, 0 ); + StrokeLine( start, end ); + BStringView::Draw( rect ); +} diff --git a/src/add-ons/input_server/methods/canna/KouhoWindow.h b/src/add-ons/input_server/methods/canna/KouhoWindow.h new file mode 100644 index 0000000000..e9b8db0a23 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/KouhoWindow.h @@ -0,0 +1,89 @@ +// +// KouhoWindow.h +// +// This is a part of... +// CannaIM +// version 1.0 +// (c) 1999 M.Kawamura +// + +#ifndef KOUHOWINDOW_H +#define KOUHOWINDOW_H + +#include +#include +#include +#include +#include +#include + +#include "CannaCommon.h" +#include "CannaLooper.h" + +#define DUMMY_RECT BRect(0,0,150,30) +#define INDEXVIEW_SIDE_MARGIN 2 +#define KOUHOVIEW_SIDE_MARGIN 2 +#define WINDOW_BORDER_WIDTH_H 22 +#define WINDOW_BORDER_WIDTH_V 5 +#define INFOVIEW_HEIGHT 14 + +extern Preferences gSettings; + +class KouhoView : public BTextView +{ +private: + BRect highlightRect; +// BView* theView; + rgb_color selection_color; +public: + KouhoView( BRect rect ); + void HighlightLine( int32 line ); + void HighlightPartial( int32 begin, int32 end ); + virtual void Draw( BRect rect ); +// void SetTargetITView( BView *itView ) +// { theView = itView; }; + virtual void MouseDown( BPoint point ); +}; + +class KouhoIndexView : public BBox +{ +private: + float lineHeight; + int32 fontOffset; //for vertical centering + bool hideNumber; +public: + KouhoIndexView( BRect rect, float height ); + virtual void Draw( BRect rect ); + void HideNumberDisplay( bool hide ) + { hideNumber = hide; Invalidate(); }; + bool IsNumberDisplayHidden() + { return hideNumber; }; +}; + +class KouhoInfoView : public BStringView +{ +public: + KouhoInfoView( BRect rect ); + virtual void Draw( BRect rect ); +}; + +class KouhoWindow : public BWindow +{ +private: + BLooper* cannaLooper; + KouhoView* kouhoView; + KouhoIndexView* indexView; + KouhoInfoView* infoView; + BFont* kouhoFont; + float indexWidth; //width of index pane + float minimumWidth; + void ShowAt( BPoint revpoint, float height ); + bool standalone_mode; + void ShowWindow(); //beta 2 fix +public: + KouhoWindow( BFont *font, BLooper *looper ); + virtual void MessageReceived( BMessage *msg ); + virtual void FrameMoved( BPoint screenPoint ); +}; + +#endif diff --git a/src/add-ons/input_server/methods/canna/PaletteIconImages.h b/src/add-ons/input_server/methods/canna/PaletteIconImages.h new file mode 100644 index 0000000000..9cfad2b128 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/PaletteIconImages.h @@ -0,0 +1,1648 @@ +#define BushuOnwidth 28 +#define BushuOnheight 20 +#define BushuOncspace B_RGB32 +#define BushuOnbytesperpixel 3 + +unsigned char BushuOnbits[] = { +0x11,0x1c,0xb,0x23,0x3a,0x17,0x3b,0x63,0x28,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x4a,0x7b,0x31,0x5a,0x96,0x3c,0x6f,0xb9,0x4a,0x24,0x3c,0x18,0x11,0x1c,0xb, +0x2d,0x4b,0x1e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x52,0x89,0x37,0x6a,0xb1,0x47, +0x9b,0xe8,0x75,0x3d,0x65,0x28,0x2f,0x4f,0x20,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xad,0xf7,0x88,0xc1,0xff,0xa3,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x8f,0xee,0x5f, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x8f,0xee,0x5f,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x8f,0xee,0x5f, +0x52,0x88,0x36,0x52,0x88,0x36,0x5c,0x99,0x3d,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x8f,0xee,0x5f,0x14,0x22,0xe,0x8f,0xee,0x5f,0x99,0xff,0x66, +0x5c,0x99,0x3d,0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x85,0xdd,0x58,0x29,0x44,0x1b,0x29,0x44,0x1b,0x0,0x0,0x0, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x5c,0x99,0x3d,0x1f,0x33,0x14,0x7a,0xcc,0x52, +0x14,0x22,0xe,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x52,0x88,0x36,0x52,0x88,0x36, +0x29,0x44,0x1b,0x47,0x77,0x30,0x52,0x88,0x36,0xa,0x11,0x7,0x3d,0x66,0x29, +0x52,0x88,0x36,0x52,0x88,0x36,0x7a,0xcc,0x52,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66, +0x66,0xaa,0x44,0x52,0x88,0x36,0x99,0xff,0x66,0x47,0x77,0x30,0x52,0x88,0x36, +0x7a,0xcc,0x52,0x29,0x44,0x1b,0x7a,0xcc,0x52,0x29,0x44,0x1b,0x99,0xff,0x66, +0x8f,0xee,0x5f,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x47,0x77,0x30, +0x29,0x44,0x1b,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x8f,0xee,0x5f,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x8f,0xee,0x5f,0x5c,0x99,0x3d,0x29,0x44,0x1b, +0x7a,0xcc,0x52,0x14,0x22,0xe,0x66,0xaa,0x44,0x66,0xaa,0x44,0x29,0x44,0x1b, +0x33,0x55,0x22,0x5c,0x99,0x3d,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x14,0x22,0xe,0x14,0x22,0xe,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x47,0x77,0x30,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x66,0xaa,0x44,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x3d,0x66,0x29,0x29,0x44,0x1b,0x66,0xaa,0x44,0x1f,0x33,0x14, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x0,0x0,0x0,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52,0x29,0x44,0x1b, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x85,0xdd,0x58, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x85,0xdd,0x58,0x7a,0xcc,0x52, +0x29,0x44,0x1b,0x99,0xff,0x66,0x14,0x22,0xe,0x70,0xbb,0x4b,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x1f,0x33,0x14,0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x3d,0x66,0x29,0x52,0x88,0x36, +0x3d,0x66,0x29,0x29,0x44,0x1b,0x7a,0xcc,0x52,0x29,0x44,0x1b,0x99,0xff,0x66, +0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66,0x0,0x0,0x0, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x5c,0x99,0x3d, +0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x7a,0xcc,0x52,0x99,0xff,0x66,0x7a,0xcc,0x52,0x29,0x44,0x1b, +0x7a,0xcc,0x52,0x29,0x44,0x1b,0x47,0x77,0x30,0xa,0x11,0x7,0x7a,0xcc,0x52, +0x99,0xff,0x66,0x99,0xff,0x66,0x0,0x0,0x0,0x52,0x88,0x36,0x52,0x88,0x36, +0x52,0x88,0x36,0x52,0x88,0x36,0x3d,0x66,0x29,0x29,0x44,0x1b,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x1f,0x33,0x14, +0x29,0x44,0x1b,0x1f,0x33,0x14,0x29,0x44,0x1b,0x7a,0xcc,0x52,0x29,0x44,0x1b, +0x8f,0xee,0x5f,0x8f,0xee,0x5f,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x0,0x0,0x0,0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36, +0x3d,0x66,0x29,0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x47,0x77,0x30,0x85,0xdd,0x58,0x99,0xff,0x66,0x8f,0xee,0x5f, +0x66,0xaa,0x44,0x85,0xdd,0x58,0x47,0x77,0x30,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x66,0xaa,0x44,0x47,0x77,0x30, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x4b,0x7d,0x32,0x53,0x8a,0x37,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xd3,0xff,0xbe,0xcb,0xff,0xb1,0x5d,0x9b,0x3e, +0x6d,0xb6,0x49,0xae,0xf8,0x89,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xd6,0xff,0xc2, +0xf3,0xff,0xed,0xdf,0xff,0xcf,0x70,0xbb,0x4b,0x9d,0xea,0x77,0xc2,0xff,0xa4, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xcc,0xff,0xb3,0xe1,0xff,0xd1,0xf3,0xff,0xed, +}; +#define BushuOffwidth 28 +#define BushuOffheight 20 +#define BushuOffcspace B_RGB32 +#define BushuOffbytesperpixel 3 + +unsigned char BushuOffbits[] = { +0xf9,0xf9,0xf9,0xf0,0xf0,0xf0,0xe4,0xe4,0xe4,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xdd,0xdd,0xdd,0xd0,0xd0,0xd0,0xaa,0xaa,0xaa,0xef,0xef,0xef,0xf9,0xf9,0xf9, +0xeb,0xeb,0xeb,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xd9,0xd9,0xd9,0xb4,0xb4,0xb4, +0x84,0x84,0x84,0xe4,0xe4,0xe4,0xea,0xea,0xea,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x77,0x77,0x77,0x60,0x60,0x60,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb, +0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x78,0x78,0x78,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0x1b,0x1b,0x1b,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8, +0x78,0x78,0x78,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xad,0xad,0xad,0x35,0x35,0x35,0x35,0x35,0x35,0x0,0x0,0x0, +0x35,0x35,0x35,0x35,0x35,0x35,0x78,0x78,0x78,0x28,0x28,0x28,0xa0,0xa0,0xa0, +0x1b,0x1b,0x1b,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b, +0x35,0x35,0x35,0x5d,0x5d,0x5d,0x6b,0x6b,0x6b,0xd,0xd,0xd,0x50,0x50,0x50, +0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x85,0x85,0x85,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0x5d,0x5d,0x5d,0x6b,0x6b,0x6b, +0xa0,0xa0,0xa0,0x35,0x35,0x35,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8, +0xbb,0xbb,0xbb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x5d,0x5d,0x5d, +0x35,0x35,0x35,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0x78,0x78,0x78,0x35,0x35,0x35, +0xa0,0xa0,0xa0,0x1b,0x1b,0x1b,0x85,0x85,0x85,0x85,0x85,0x85,0x35,0x35,0x35, +0x43,0x43,0x43,0x78,0x78,0x78,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x35,0x35,0x35,0x35,0x35,0x35,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x35,0x35,0x35, +0x35,0x35,0x35,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0x85,0x85,0x85,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35, +0x35,0x35,0x35,0x50,0x50,0x50,0x35,0x35,0x35,0x85,0x85,0x85,0x28,0x28,0x28, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x0,0x0,0x0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xad,0xad,0xad, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xad,0xad,0xad,0xa0,0xa0,0xa0, +0x35,0x35,0x35,0xc8,0xc8,0xc8,0x1b,0x1b,0x1b,0x93,0x93,0x93,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x0,0x0,0x0,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35, +0x35,0x35,0x35,0x28,0x28,0x28,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35,0x50,0x50,0x50,0x6b,0x6b,0x6b, +0x50,0x50,0x50,0x35,0x35,0x35,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x0,0x0,0x0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x78,0x78,0x78, +0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x35,0x35,0x35,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35, +0xa0,0xa0,0xa0,0x35,0x35,0x35,0x5d,0x5d,0x5d,0xd,0xd,0xd,0xa0,0xa0,0xa0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x0,0x0,0x0,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b, +0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x50,0x50,0x50,0x35,0x35,0x35,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35,0x28,0x28,0x28, +0x35,0x35,0x35,0x28,0x28,0x28,0x35,0x35,0x35,0xa0,0xa0,0xa0,0x35,0x35,0x35, +0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x0,0x0,0x0,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b, +0x50,0x50,0x50,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x5d,0x5d,0x5d,0xad,0xad,0xad,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb, +0x85,0x85,0x85,0xad,0xad,0xad,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x85,0x85,0x85,0x5d,0x5d,0x5d, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xdd,0xdd,0xdd,0xd9,0xd9,0xd9,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x45,0x45,0x45,0x52,0x52,0x52,0xcb,0xcb,0xcb, +0xaf,0xaf,0xaf,0x76,0x76,0x76,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x41,0x41,0x41, +0x17,0x17,0x17,0x34,0x34,0x34,0xa9,0xa9,0xa9,0x82,0x82,0x82,0x5e,0x5e,0x5e, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x50,0x50,0x50,0x32,0x32,0x32,0x17,0x17,0x17, +}; +#define ExtendOnwidth 28 +#define ExtendOnheight 20 +#define ExtendOncspace B_RGB32 +#define ExtendOnbytesperpixel 3 + +unsigned char ExtendOnbits[] = { +0x11,0x1c,0xb,0x23,0x3a,0x17,0x3b,0x63,0x28,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x4a,0x7b,0x31,0x5a,0x96,0x3c,0x6f,0xb9,0x4a,0x24,0x3c,0x18,0x11,0x1c,0xb, +0x2d,0x4b,0x1e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x52,0x89,0x37,0x6a,0xb1,0x47, +0x9b,0xe8,0x75,0x3d,0x65,0x28,0x2f,0x4f,0x20,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xad,0xf7,0x88,0xc1,0xff,0xa3,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66,0x47,0x77,0x30, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x85,0xdd,0x58,0x66,0xaa,0x44,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x85,0xdd,0x58,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x7a,0xcc,0x52, +0x99,0xff,0x66,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x1f,0x33,0x14,0x5c,0x99,0x3d, +0x7a,0xcc,0x52,0x85,0xdd,0x58,0x85,0xdd,0x58,0x7a,0xcc,0x52,0x1f,0x33,0x14, +0x7a,0xcc,0x52,0x52,0x88,0x36,0x3d,0x66,0x29,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x85,0xdd,0x58,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0xa,0x11,0x7,0x1f,0x33,0x14,0x3d,0x66,0x29,0x14,0x22,0xe, +0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36,0x66,0xaa,0x44, +0x8f,0xee,0x5f,0x7a,0xcc,0x52,0x1f,0x33,0x14,0x7a,0xcc,0x52,0x52,0x88,0x36, +0x29,0x44,0x1b,0x52,0x88,0x36,0x52,0x88,0x36,0x66,0xaa,0x44,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x29,0x44,0x1b,0x99,0xff,0x66,0x5c,0x99,0x3d, +0x66,0xaa,0x44,0x99,0xff,0x66,0x99,0xff,0x66,0x3d,0x66,0x29,0x3d,0x66,0x29, +0x52,0x88,0x36,0x8f,0xee,0x5f,0x52,0x88,0x36,0x14,0x22,0xe,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x47,0x77,0x30,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x3d,0x66,0x29,0x3d,0x66,0x29, +0x29,0x44,0x1b,0x99,0xff,0x66,0x1f,0x33,0x14,0x7a,0xcc,0x52,0x99,0xff,0x66, +0x99,0xff,0x66,0x29,0x44,0x1b,0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66, +0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x1f,0x33,0x14, +0x0,0x0,0x0,0x3d,0x66,0x29,0x70,0xbb,0x4b,0x29,0x44,0x1b,0x99,0xff,0x66, +0xa,0x11,0x7,0x99,0xff,0x66,0x8f,0xee,0x5f,0x99,0xff,0x66,0x14,0x22,0xe, +0x29,0x44,0x1b,0x0,0x0,0x0,0x47,0x77,0x30,0x14,0x22,0xe,0x14,0x22,0xe, +0x14,0x22,0xe,0x14,0x22,0xe,0x29,0x44,0x1b,0x47,0x77,0x30,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52,0x29,0x44,0x1b,0x7a,0xcc,0x52, +0x66,0xaa,0x44,0x3d,0x66,0x29,0x66,0xaa,0x44,0x33,0x55,0x22,0x66,0xaa,0x44, +0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x0,0x0,0x0, +0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x66,0xaa,0x44,0x33,0x55,0x22, +0x29,0x44,0x1b,0x47,0x77,0x30,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x29,0x44,0x1b,0x7a,0xcc,0x52,0x3d,0x66,0x29,0x5c,0x99,0x3d, +0x3d,0x66,0x29,0x66,0xaa,0x44,0x99,0xff,0x66,0x1f,0x33,0x14,0x7a,0xcc,0x52, +0x99,0xff,0x66,0x99,0xff,0x66,0xa,0x11,0x7,0x99,0xff,0x66,0x52,0x88,0x36, +0x52,0x88,0x36,0x99,0xff,0x66,0x14,0x22,0xe,0x3d,0x66,0x29,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b, +0x5c,0x99,0x3d,0xa,0x11,0x7,0x3d,0x66,0x29,0x14,0x22,0xe,0x14,0x22,0xe, +0x0,0x0,0x0,0x14,0x22,0xe,0x33,0x55,0x22,0x8f,0xee,0x5f,0x5c,0x99,0x3d, +0x29,0x44,0x1b,0x7a,0xcc,0x52,0x29,0x44,0x1b,0x14,0x22,0xe,0x0,0x0,0x0, +0x70,0xbb,0x4b,0xa,0x11,0x7,0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x3d,0x66,0x29,0x1f,0x33,0x14,0x8f,0xee,0x5f,0x66,0xaa,0x44, +0x66,0xaa,0x44,0x70,0xbb,0x4b,0x85,0xdd,0x58,0x99,0xff,0x66,0x99,0xff,0x66, +0x47,0x77,0x30,0x85,0xdd,0x58,0x33,0x55,0x22,0x85,0xdd,0x58,0x52,0x88,0x36, +0x52,0x88,0x36,0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52, +0x47,0x77,0x30,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x4b,0x7d,0x32,0x53,0x8a,0x37,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xd3,0xff,0xbe,0xcb,0xff,0xb1,0x5d,0x9b,0x3e, +0x6d,0xb6,0x49,0xae,0xf8,0x89,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xd6,0xff,0xc2, +0xf3,0xff,0xed,0xdf,0xff,0xcf,0x70,0xbb,0x4b,0x9d,0xea,0x77,0xc2,0xff,0xa4, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xcc,0xff,0xb3,0xe1,0xff,0xd1,0xf3,0xff,0xed, +}; +#define ExtendOffwidth 28 +#define ExtendOffheight 20 +#define ExtendOffcspace B_RGB32 +#define ExtendOffbytesperpixel 3 + +unsigned char ExtendOffbits[] = { +0xf9,0xf9,0xf9,0xf0,0xf0,0xf0,0xe4,0xe4,0xe4,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xdd,0xdd,0xdd,0xd0,0xd0,0xd0,0xaa,0xaa,0xaa,0xef,0xef,0xef,0xf9,0xf9,0xf9, +0xeb,0xeb,0xeb,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xd9,0xd9,0xd9,0xb4,0xb4,0xb4, +0x84,0x84,0x84,0xe4,0xe4,0xe4,0xea,0xea,0xea,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x77,0x77,0x77,0x60,0x60,0x60,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x35,0x35,0x35,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x35,0x35,0x35,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x5d,0x5d,0x5d, +0x35,0x35,0x35,0x35,0x35,0x35,0xad,0xad,0xad,0x85,0x85,0x85,0x35,0x35,0x35, +0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0xad,0xad,0xad,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35,0xa0,0xa0,0xa0, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x28,0x28,0x28,0x78,0x78,0x78, +0xa0,0xa0,0xa0,0xad,0xad,0xad,0xad,0xad,0xad,0xa0,0xa0,0xa0,0x28,0x28,0x28, +0xa0,0xa0,0xa0,0x6b,0x6b,0x6b,0x50,0x50,0x50,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xad,0xad,0xad,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x35,0x35,0x35,0xd,0xd,0xd,0x28,0x28,0x28,0x50,0x50,0x50,0x1b,0x1b,0x1b, +0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x85,0x85,0x85, +0xbb,0xbb,0xbb,0xa0,0xa0,0xa0,0x28,0x28,0x28,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b, +0x35,0x35,0x35,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x85,0x85,0x85,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8,0x78,0x78,0x78, +0x85,0x85,0x85,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x50,0x50,0x50,0x50,0x50,0x50, +0x6b,0x6b,0x6b,0xbb,0xbb,0xbb,0x6b,0x6b,0x6b,0x1b,0x1b,0x1b,0x35,0x35,0x35, +0x35,0x35,0x35,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35,0x50,0x50,0x50,0x50,0x50,0x50, +0x35,0x35,0x35,0xc8,0xc8,0xc8,0x28,0x28,0x28,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x28,0x28,0x28, +0x0,0x0,0x0,0x50,0x50,0x50,0x93,0x93,0x93,0x35,0x35,0x35,0xc8,0xc8,0xc8, +0xd,0xd,0xd,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0x1b,0x1b,0x1b, +0x35,0x35,0x35,0x0,0x0,0x0,0x5d,0x5d,0x5d,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b, +0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x35,0x35,0x35,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xa0,0xa0,0xa0, +0x85,0x85,0x85,0x50,0x50,0x50,0x85,0x85,0x85,0x43,0x43,0x43,0x85,0x85,0x85, +0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x0,0x0,0x0, +0xc8,0xc8,0xc8,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x85,0x85,0x85,0x43,0x43,0x43, +0x35,0x35,0x35,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0xa0,0xa0,0xa0,0x50,0x50,0x50,0x78,0x78,0x78, +0x50,0x50,0x50,0x85,0x85,0x85,0xc8,0xc8,0xc8,0x28,0x28,0x28,0xa0,0xa0,0xa0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xd,0xd,0xd,0xc8,0xc8,0xc8,0x6b,0x6b,0x6b, +0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0x1b,0x1b,0x1b,0x50,0x50,0x50,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35, +0x78,0x78,0x78,0xd,0xd,0xd,0x50,0x50,0x50,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b, +0x0,0x0,0x0,0x1b,0x1b,0x1b,0x43,0x43,0x43,0xbb,0xbb,0xbb,0x78,0x78,0x78, +0x35,0x35,0x35,0xa0,0xa0,0xa0,0x35,0x35,0x35,0x1b,0x1b,0x1b,0x0,0x0,0x0, +0x93,0x93,0x93,0xd,0xd,0xd,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x50,0x50,0x50,0x28,0x28,0x28,0xbb,0xbb,0xbb,0x85,0x85,0x85, +0x85,0x85,0x85,0x93,0x93,0x93,0xad,0xad,0xad,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x5d,0x5d,0x5d,0xad,0xad,0xad,0x43,0x43,0x43,0xad,0xad,0xad,0x6b,0x6b,0x6b, +0x6b,0x6b,0x6b,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0x5d,0x5d,0x5d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xdd,0xdd,0xdd,0xd9,0xd9,0xd9,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x45,0x45,0x45,0x52,0x52,0x52,0xcb,0xcb,0xcb, +0xaf,0xaf,0xaf,0x76,0x76,0x76,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x41,0x41,0x41, +0x17,0x17,0x17,0x34,0x34,0x34,0xa9,0xa9,0xa9,0x82,0x82,0x82,0x5e,0x5e,0x5e, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x50,0x50,0x50,0x32,0x32,0x32,0x17,0x17,0x17, +}; +#define HanAlphaOnwidth 20 +#define HanAlphaOnheight 20 +#define HanAlphaOncspace B_RGB32 +#define HanAlphaOnbytesperpixel 3 + +unsigned char HanAlphaOnbits[] = { +0x11,0x1c,0xb,0x23,0x3a,0x17,0x3b,0x63,0x28,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x4a,0x7b,0x31,0x5a,0x96,0x3c,0x6f,0xb9,0x4a, +0x24,0x3c,0x18,0x11,0x1c,0xb,0x2d,0x4b,0x1e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x52,0x89,0x37,0x6a,0xb1,0x47,0x9b,0xe8,0x75, +0x3d,0x65,0x28,0x2f,0x4f,0x20,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xad,0xf7,0x88,0xc1,0xff,0xa3, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x66,0xaa,0x44,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x33,0x55,0x22,0x85,0xdd,0x58,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x3d,0x66,0x29,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x52,0x88,0x36,0xa,0x11,0x7,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x1f,0x33,0x14,0x7a,0xcc,0x52,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x7a,0xcc,0x52,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x7a,0xcc,0x52,0xa,0x11,0x7,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x85,0xdd,0x58,0xa,0x11,0x7,0x85,0xdd,0x58,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x47,0x77,0x30,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x33,0x55,0x22,0x66,0xaa,0x44,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x52,0x88,0x36,0x3d,0x66,0x29,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x5c,0x99,0x3d,0x14,0x22,0xe,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x66,0xaa,0x44,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x3d,0x66,0x29,0x85,0xdd,0x58,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x4b,0x7d,0x32,0x53,0x8a,0x37,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xd3,0xff,0xbe,0xcb,0xff,0xb1, +0x5d,0x9b,0x3e,0x6d,0xb6,0x49,0xae,0xf8,0x89,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xd6,0xff,0xc2,0xf3,0xff,0xed,0xdf,0xff,0xcf, +0x70,0xbb,0x4b,0x9d,0xea,0x77,0xc2,0xff,0xa4,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xcc,0xff,0xb3,0xe1,0xff,0xd1,0xf3,0xff,0xed, +}; +#define HanAlphaOffwidth 20 +#define HanAlphaOffheight 20 +#define HanAlphaOffcspace B_RGB32 +#define HanAlphaOffbytesperpixel 3 + +unsigned char HanAlphaOffbits[] = { +0xf9,0xf9,0xf9,0xf0,0xf0,0xf0,0xe4,0xe4,0xe4,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xdd,0xdd,0xdd,0xd0,0xd0,0xd0,0xaa,0xaa,0xaa, +0xef,0xef,0xef,0xf9,0xf9,0xf9,0xeb,0xeb,0xeb,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xd9,0xd9,0xd9,0xb4,0xb4,0xb4,0x84,0x84,0x84, +0xe4,0xe4,0xe4,0xea,0xea,0xea,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x77,0x77,0x77,0x60,0x60,0x60, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xad,0xad,0xad,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35, +0x43,0x43,0x43,0xad,0xad,0xad,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x28,0x28,0x28,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0x78,0x78,0x78,0xd,0xd,0xd,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x28,0x28,0x28,0xad,0xad,0xad,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x28,0x28,0x28,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0x78,0x78,0x78,0x28,0x28,0x28,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xd,0xd,0xd,0x35,0x35,0x35,0x35,0x35,0x35, +0x1b,0x1b,0x1b,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x93,0x93,0x93,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x5d,0x5d,0x5d,0x78,0x78,0x78,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xbb,0xbb,0xbb,0xd,0xd,0xd,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0xd,0xd,0xd,0x85,0x85,0x85,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xdd,0xdd,0xdd,0xd9,0xd9,0xd9,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x45,0x45,0x45,0x52,0x52,0x52, +0xcb,0xcb,0xcb,0xaf,0xaf,0xaf,0x76,0x76,0x76,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x41,0x41,0x41,0x17,0x17,0x17,0x34,0x34,0x34, +0xa9,0xa9,0xa9,0x82,0x82,0x82,0x5e,0x5e,0x5e,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x50,0x50,0x50,0x32,0x32,0x32,0x17,0x17,0x17, +}; +#define HexOnwidth 28 +#define HexOnheight 20 +#define HexOncspace B_RGB32 +#define HexOnbytesperpixel 3 + +unsigned char HexOnbits[] = { +0x11,0x1c,0xb,0x23,0x3a,0x17,0x3b,0x63,0x28,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x4a,0x7b,0x31,0x5a,0x96,0x3c,0x6f,0xb9,0x4a,0x24,0x3c,0x18,0x11,0x1c,0xb, +0x2d,0x4b,0x1e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x52,0x89,0x37,0x6a,0xb1,0x47, +0x9b,0xe8,0x75,0x3d,0x65,0x28,0x2f,0x4f,0x20,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xad,0xf7,0x88,0xc1,0xff,0xa3,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x85,0xdd,0x58,0x66,0xaa,0x44, +0x99,0xff,0x66,0x99,0xff,0x66,0x47,0x77,0x30,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x8f,0xee,0x5f,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x8f,0xee,0x5f,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x7a,0xcc,0x52,0x52,0x88,0x36,0x99,0xff,0x66,0x70,0xbb,0x4b, +0x47,0x77,0x30,0x8f,0xee,0x5f,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66, +0x66,0xaa,0x44,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x1f,0x33,0x14, +0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52, +0x52,0x88,0x36,0x99,0xff,0x66,0x66,0xaa,0x44,0x70,0xbb,0x4b,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52,0x1f,0x33,0x14,0x85,0xdd,0x58, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x7a,0xcc,0x52,0x52,0x88,0x36,0x47,0x77,0x30,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x99,0xff,0x66, +0x7a,0xcc,0x52,0x29,0x44,0x1b,0x14,0x22,0xe,0x47,0x77,0x30,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52,0x52,0x88,0x36, +0x85,0xdd,0x58,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x99,0xff,0x66,0x7a,0xcc,0x52,0x52,0x88,0x36, +0x99,0xff,0x66,0x52,0x88,0x36,0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x7a,0xcc,0x52,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x7a,0xcc,0x52,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x8f,0xee,0x5f,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66, +0x66,0xaa,0x44,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x1f,0x33,0x14, +0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52, +0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x8f,0xee,0x5f,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x66,0xaa,0x44,0x66,0xaa,0x44,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52,0x52,0x88,0x36,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x85,0xdd,0x58,0x66,0xaa,0x44,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x4b,0x7d,0x32,0x53,0x8a,0x37,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xd3,0xff,0xbe,0xcb,0xff,0xb1,0x5d,0x9b,0x3e, +0x6d,0xb6,0x49,0xae,0xf8,0x89,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xd6,0xff,0xc2, +0xf3,0xff,0xed,0xdf,0xff,0xcf,0x70,0xbb,0x4b,0x9d,0xea,0x77,0xc2,0xff,0xa4, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xcc,0xff,0xb3,0xe1,0xff,0xd1,0xf3,0xff,0xed, +}; +#define HexOffwidth 28 +#define HexOffheight 20 +#define HexOffcspace B_RGB32 +#define HexOffbytesperpixel 3 + +unsigned char HexOffbits[] = { +0xf9,0xf9,0xf9,0xf0,0xf0,0xf0,0xe4,0xe4,0xe4,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xdd,0xdd,0xdd,0xd0,0xd0,0xd0,0xaa,0xaa,0xaa,0xef,0xef,0xef,0xf9,0xf9,0xf9, +0xeb,0xeb,0xeb,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xd9,0xd9,0xd9,0xb4,0xb4,0xb4, +0x84,0x84,0x84,0xe4,0xe4,0xe4,0xea,0xea,0xea,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x77,0x77,0x77,0x60,0x60,0x60,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xad,0xad,0xad,0x85,0x85,0x85, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0x93,0x93,0x93, +0x5d,0x5d,0x5d,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x85,0x85,0x85,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x28,0x28,0x28, +0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0x85,0x85,0x85,0x93,0x93,0x93,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x28,0x28,0x28,0xad,0xad,0xad, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0x6b,0x6b,0x6b,0x5d,0x5d,0x5d,0x35,0x35,0x35,0x35,0x35,0x35, +0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0x35,0x35,0x35,0x1b,0x1b,0x1b,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b, +0xad,0xad,0xad,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b, +0xc8,0xc8,0xc8,0x6b,0x6b,0x6b,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x85,0x85,0x85,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x28,0x28,0x28, +0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x85,0x85,0x85,0x85,0x85,0x85,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xad,0xad,0xad,0x85,0x85,0x85,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xdd,0xdd,0xdd,0xd9,0xd9,0xd9,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x45,0x45,0x45,0x52,0x52,0x52,0xcb,0xcb,0xcb, +0xaf,0xaf,0xaf,0x76,0x76,0x76,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x41,0x41,0x41, +0x17,0x17,0x17,0x34,0x34,0x34,0xa9,0xa9,0xa9,0x82,0x82,0x82,0x5e,0x5e,0x5e, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x50,0x50,0x50,0x32,0x32,0x32,0x17,0x17,0x17, +}; +#define HiraOnwidth 20 +#define HiraOnheight 20 +#define HiraOncspace B_RGB32 +#define HiraOnbytesperpixel 3 + +unsigned char HiraOnbits[] = { +0x11,0x1c,0xb,0x23,0x3a,0x17,0x3b,0x63,0x28,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x4a,0x7b,0x31,0x5a,0x96,0x3c,0x6f,0xb9,0x4a, +0x24,0x3c,0x18,0x11,0x1c,0xb,0x2d,0x4b,0x1e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x52,0x89,0x37,0x6a,0xb1,0x47,0x9b,0xe8,0x75, +0x3d,0x65,0x28,0x2f,0x4f,0x20,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xad,0xf7,0x88,0xc1,0xff,0xa3, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x85,0xdd,0x58, +0x70,0xbb,0x4b,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x70,0xbb,0x4b,0x5c,0x99,0x3d, +0x0,0x0,0x0,0x7a,0xcc,0x52,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x8f,0xee,0x5f,0x70,0xbb,0x4b,0x3d,0x66,0x29,0x1f,0x33,0x14,0x99,0xff,0x66, +0x99,0xff,0x66,0x70,0xbb,0x4b,0x3d,0x66,0x29,0x33,0x55,0x22,0x1f,0x33,0x14, +0x66,0xaa,0x44,0x8f,0xee,0x5f,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x8f,0xee,0x5f,0x0,0x0,0x0, +0x0,0x0,0x0,0x14,0x22,0xe,0x0,0x0,0x0,0xa,0x11,0x7,0x85,0xdd,0x58, +0x99,0xff,0x66,0x52,0x88,0x36,0x0,0x0,0x0,0x70,0xbb,0x4b,0x66,0xaa,0x44, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52, +0x99,0xff,0x66,0x47,0x77,0x30,0xa,0x11,0x7,0x85,0xdd,0x58,0x99,0xff,0x66, +0x99,0xff,0x66,0x7a,0xcc,0x52,0x0,0x0,0x0,0x3d,0x66,0x29,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x70,0xbb,0x4b,0x0,0x0,0x0,0x70,0xbb,0x4b,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x7a,0xcc,0x52,0x0,0x0,0x0,0x0,0x0,0x0,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x14,0x22,0xe,0x33,0x55,0x22,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x7a,0xcc,0x52,0x0,0x0,0x0,0x0,0x0,0x0,0x52,0x88,0x36, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x66,0xaa,0x44, +0x0,0x0,0x0,0x85,0xdd,0x58,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x7a,0xcc,0x52,0x0,0x0,0x0,0x3d,0x66,0x29,0xa,0x11,0x7, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x3d,0x66,0x29, +0x14,0x22,0xe,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x52,0x88,0x36,0xa,0x11,0x7,0x8f,0xee,0x5f,0x0,0x0,0x0, +0x33,0x55,0x22,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x1f,0x33,0x14,0x29,0x44,0x1b,0x99,0xff,0x66,0x47,0x77,0x30, +0x1f,0x33,0x14,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x3d,0x66,0x29, +0xa,0x11,0x7,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x66,0xaa,0x44,0x0,0x0,0x0,0x66,0xaa,0x44,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x85,0xdd,0x58, +0x0,0x0,0x0,0x1f,0x33,0x14,0x70,0xbb,0x4b,0x7a,0xcc,0x52,0x47,0x77,0x30, +0x0,0x0,0x0,0x1f,0x33,0x14,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x7a,0xcc,0x52,0x1f,0x33,0x14,0x0,0x0,0x0,0x0,0x0,0x0,0x1f,0x33,0x14, +0x5c,0x99,0x3d,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x4b,0x7d,0x32,0x53,0x8a,0x37,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xd3,0xff,0xbe,0xcb,0xff,0xb1, +0x5d,0x9b,0x3e,0x6d,0xb6,0x49,0xae,0xf8,0x89,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xd6,0xff,0xc2,0xf3,0xff,0xed,0xdf,0xff,0xcf, +0x70,0xbb,0x4b,0x9d,0xea,0x77,0xc2,0xff,0xa4,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xcc,0xff,0xb3,0xe1,0xff,0xd1,0xf3,0xff,0xed, +}; +#define HiraOffwidth 20 +#define HiraOffheight 20 +#define HiraOffcspace B_RGB32 +#define HiraOffbytesperpixel 3 + +unsigned char HiraOffbits[] = { +0xf9,0xf9,0xf9,0xf0,0xf0,0xf0,0xe4,0xe4,0xe4,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xdd,0xdd,0xdd,0xd0,0xd0,0xd0,0xaa,0xaa,0xaa, +0xef,0xef,0xef,0xf9,0xf9,0xf9,0xeb,0xeb,0xeb,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xd9,0xd9,0xd9,0xb4,0xb4,0xb4,0x84,0x84,0x84, +0xe4,0xe4,0xe4,0xea,0xea,0xea,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x77,0x77,0x77,0x60,0x60,0x60, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x93,0x93,0x93, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x85,0x85,0x85,0x43,0x43,0x43, +0x28,0x28,0x28,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0x93,0x93,0x93,0x6b,0x6b,0x6b,0x35,0x35,0x35,0xd,0xd,0xd,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x85,0x85,0x85,0x5d,0x5d,0x5d,0x28,0x28,0x28,0x43,0x43,0x43, +0x85,0x85,0x85,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x1b,0x1b,0x1b, +0xd,0xd,0xd,0x35,0x35,0x35,0xd,0xd,0xd,0xd,0xd,0xd,0xad,0xad,0xad, +0xc8,0xc8,0xc8,0x43,0x43,0x43,0xd,0xd,0xd,0xc8,0xc8,0xc8,0xad,0xad,0xad, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x5d,0x5d,0x5d,0xd,0xd,0xd,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x6b,0x6b,0x6b,0x0,0x0,0x0,0x93,0x93,0x93,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x93,0x93,0x93,0x0,0x0,0x0,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x6b,0x6b,0x6b,0x0,0x0,0x0,0x43,0x43,0x43,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x1b,0x1b,0x1b,0x50,0x50,0x50,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x6b,0x6b,0x6b,0x1b,0x1b,0x1b,0x0,0x0,0x0,0xbb,0xbb,0xbb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0x0,0x0,0x0,0x93,0x93,0x93,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x50,0x50,0x50,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x6b,0x6b,0x6b, +0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x28,0x28,0x28,0x5d,0x5d,0x5d,0xad,0xad,0xad,0x0,0x0,0x0, +0x78,0x78,0x78,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x6b,0x6b,0x6b, +0x0,0x0,0x0,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0x0,0x0,0x0,0x85,0x85,0x85,0xc8,0xc8,0xc8,0x85,0x85,0x85, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb, +0x0,0x0,0x0,0x43,0x43,0x43,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0x85,0x85,0x85, +0xd,0xd,0xd,0x28,0x28,0x28,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x85,0x85,0x85,0xd,0xd,0xd,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x50,0x50,0x50,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xdd,0xdd,0xdd,0xd9,0xd9,0xd9,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x45,0x45,0x45,0x52,0x52,0x52, +0xcb,0xcb,0xcb,0xaf,0xaf,0xaf,0x76,0x76,0x76,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x41,0x41,0x41,0x17,0x17,0x17,0x34,0x34,0x34, +0xa9,0xa9,0xa9,0x82,0x82,0x82,0x5e,0x5e,0x5e,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x50,0x50,0x50,0x32,0x32,0x32,0x17,0x17,0x17, +}; +#define KataOnwidth 20 +#define KataOnheight 20 +#define KataOncspace B_RGB32 +#define KataOnbytesperpixel 3 + +unsigned char KataOnbits[] = { +0x11,0x1c,0xb,0x23,0x3a,0x17,0x3b,0x63,0x28,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x4a,0x7b,0x31,0x5a,0x96,0x3c,0x6f,0xb9,0x4a, +0x24,0x3c,0x18,0x11,0x1c,0xb,0x2d,0x4b,0x1e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x52,0x89,0x37,0x6a,0xb1,0x47,0x9b,0xe8,0x75, +0x3d,0x65,0x28,0x2f,0x4f,0x20,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xad,0xf7,0x88,0xc1,0xff,0xa3, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x8f,0xee,0x5f,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x85,0xdd,0x58,0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x1f,0x33,0x14, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xa,0x11,0x7,0x5c,0x99,0x3d,0x3d,0x66,0x29, +0x85,0xdd,0x58,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x66,0xaa,0x44,0x14,0x22,0xe,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x66,0xaa,0x44,0x33,0x55,0x22,0x8f,0xee,0x5f,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x70,0xbb,0x4b,0x52,0x88,0x36,0x29,0x44,0x1b, +0x0,0x0,0x0,0x0,0x0,0x0,0x14,0x22,0xe,0x70,0xbb,0x4b,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x0,0x0,0x0,0x29,0x44,0x1b,0x3d,0x66,0x29, +0x5c,0x99,0x3d,0x85,0xdd,0x58,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x33,0x55,0x22,0x0,0x0,0x0,0x1f,0x33,0x14,0x52,0x88,0x36,0x52,0x88,0x36, +0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36,0x8f,0xee,0x5f, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x5c,0x99,0x3d,0x3d,0x66,0x29,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x85,0xdd,0x58, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x4b,0x7d,0x32,0x53,0x8a,0x37,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xd3,0xff,0xbe,0xcb,0xff,0xb1, +0x5d,0x9b,0x3e,0x6d,0xb6,0x49,0xae,0xf8,0x89,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xd6,0xff,0xc2,0xf3,0xff,0xed,0xdf,0xff,0xcf, +0x70,0xbb,0x4b,0x9d,0xea,0x77,0xc2,0xff,0xa4,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xcc,0xff,0xb3,0xe1,0xff,0xd1,0xf3,0xff,0xed, +}; +#define KataOffwidth 20 +#define KataOffheight 20 +#define KataOffcspace B_RGB32 +#define KataOffbytesperpixel 3 + +unsigned char KataOffbits[] = { +0xf9,0xf9,0xf9,0xf0,0xf0,0xf0,0xe4,0xe4,0xe4,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xdd,0xdd,0xdd,0xd0,0xd0,0xd0,0xaa,0xaa,0xaa, +0xef,0xef,0xef,0xf9,0xf9,0xf9,0xeb,0xeb,0xeb,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xd9,0xd9,0xd9,0xb4,0xb4,0xb4,0x84,0x84,0x84, +0xe4,0xe4,0xe4,0xea,0xea,0xea,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x77,0x77,0x77,0x60,0x60,0x60, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xbb,0xbb,0xbb,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xd,0xd,0xd,0x5d,0x5d,0x5d, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0xd,0xd,0xd,0x6b,0x6b,0x6b,0x5d,0x5d,0x5d, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x85,0x85,0x85,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0x5d,0x5d,0x5d,0x43,0x43,0x43,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0x35,0x35,0x35,0x1b,0x1b,0x1b,0x0,0x0,0x0, +0x0,0x0,0x0,0x28,0x28,0x28,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0x5d,0x5d,0x5d,0x78,0x78,0x78,0xa0,0xa0,0xa0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x6b,0x6b,0x6b,0x0,0x0,0x0,0x6b,0x6b,0x6b,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xad,0xad,0xad,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x43,0x43,0x43,0x1b,0x1b,0x1b,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x35,0x35,0x35,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xdd,0xdd,0xdd,0xd9,0xd9,0xd9,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x45,0x45,0x45,0x52,0x52,0x52, +0xcb,0xcb,0xcb,0xaf,0xaf,0xaf,0x76,0x76,0x76,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x41,0x41,0x41,0x17,0x17,0x17,0x34,0x34,0x34, +0xa9,0xa9,0xa9,0x82,0x82,0x82,0x5e,0x5e,0x5e,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x50,0x50,0x50,0x32,0x32,0x32,0x17,0x17,0x17, +}; +#define KigoOnwidth 28 +#define KigoOnheight 20 +#define KigoOncspace B_RGB32 +#define KigoOnbytesperpixel 3 + +unsigned char KigoOnbits[] = { +0x11,0x1c,0xb,0x23,0x3a,0x17,0x3b,0x63,0x28,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x4a,0x7b,0x31,0x5a,0x96,0x3c,0x6f,0xb9,0x4a,0x24,0x3c,0x18,0x11,0x1c,0xb, +0x2d,0x4b,0x1e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x52,0x89,0x37,0x6a,0xb1,0x47, +0x9b,0xe8,0x75,0x3d,0x65,0x28,0x2f,0x4f,0x20,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xad,0xf7,0x88,0xc1,0xff,0xa3,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x47,0x77,0x30, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x66,0xaa,0x44,0x47,0x77,0x30,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x47,0x77,0x30,0x99,0xff,0x66,0x99,0xff,0x66, +0x29,0x44,0x1b,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x8f,0xee,0x5f,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x85,0xdd,0x58,0x85,0xdd,0x58,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x5c,0x99,0x3d, +0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x7a,0xcc,0x52, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x0,0x0,0x0, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x7a,0xcc,0x52, +0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36,0x66,0xaa,0x44,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52,0x29,0x44,0x1b,0x99,0xff,0x66, +0x99,0xff,0x66,0x29,0x44,0x1b,0x1f,0x33,0x14,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x47,0x77,0x30,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x66,0xaa,0x44,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x7a,0xcc,0x52,0x29,0x44,0x1b,0x99,0xff,0x66,0x99,0xff,0x66,0x85,0xdd,0x58, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x66,0xaa,0x44,0x52,0x88,0x36,0x52,0x88,0x36,0x7a,0xcc,0x52, +0x52,0x88,0x36,0x14,0x22,0xe,0x29,0x44,0x1b,0x1f,0x33,0x14,0x29,0x44,0x1b, +0x7a,0xcc,0x52,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x85,0xdd,0x58, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x8f,0xee,0x5f,0x52,0x88,0x36,0x52,0x88,0x36, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x70,0xbb,0x4b,0x1f,0x33,0x14,0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x0,0x0,0x0,0x29,0x44,0x1b,0x14,0x22,0xe, +0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x47,0x77,0x30,0x14,0x22,0xe, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0xa,0x11,0x7, +0x7a,0xcc,0x52,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66, +0x0,0x0,0x0,0x99,0xff,0x66,0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36, +0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66,0x85,0xdd,0x58,0x8f,0xee,0x5f, +0x99,0xff,0x66,0x66,0xaa,0x44,0x85,0xdd,0x58,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x14,0x22,0xe,0x85,0xdd,0x58,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e, +0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x0,0x0,0x0,0x29,0x44,0x1b, +0x14,0x22,0xe,0x52,0x88,0x36,0x52,0x88,0x36,0x29,0x44,0x1b,0x52,0x88,0x36, +0x52,0x88,0x36,0x1f,0x33,0x14,0x70,0xbb,0x4b,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x0,0x0,0x0,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66, +0x99,0xff,0x66,0x29,0x44,0x1b,0x99,0xff,0x66,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x8f,0xee,0x5f,0x52,0x88,0x36,0x52,0x88,0x36,0x52,0x88,0x36,0x5c,0x99,0x3d, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x70,0xbb,0x4b,0x0,0x0,0x0,0x47,0x77,0x30,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab,0x44,0x72,0x2e,0x44,0x72,0x2e, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab, +0xc7,0xff,0xab,0x4b,0x7d,0x32,0x53,0x8a,0x37,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0xd3,0xff,0xbe,0xcb,0xff,0xb1,0x5d,0x9b,0x3e, +0x6d,0xb6,0x49,0xae,0xf8,0x89,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xd6,0xff,0xc2, +0xf3,0xff,0xed,0xdf,0xff,0xcf,0x70,0xbb,0x4b,0x9d,0xea,0x77,0xc2,0xff,0xa4, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xcc,0xff,0xb3,0xe1,0xff,0xd1,0xf3,0xff,0xed, +}; +#define KigoOffwidth 28 +#define KigoOffheight 20 +#define KigoOffcspace B_RGB32 +#define KigoOffbytesperpixel 3 + +unsigned char KigoOffbits[] = { +0xf9,0xf9,0xf9,0xf0,0xf0,0xf0,0xe4,0xe4,0xe4,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xdd,0xdd,0xdd,0xd0,0xd0,0xd0,0xaa,0xaa,0xaa,0xef,0xef,0xef,0xf9,0xf9,0xf9, +0xeb,0xeb,0xeb,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xd9,0xd9,0xd9,0xb4,0xb4,0xb4, +0x84,0x84,0x84,0xe4,0xe4,0xe4,0xea,0xea,0xea,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x77,0x77,0x77,0x60,0x60,0x60,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x5d,0x5d,0x5d, +0x35,0x35,0x35,0x35,0x35,0x35,0x85,0x85,0x85,0x5d,0x5d,0x5d,0x35,0x35,0x35, +0x35,0x35,0x35,0x35,0x35,0x35,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x35,0x35,0x35,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xad,0xad,0xad,0xad,0xad,0xad,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x78,0x78,0x78, +0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35,0xa0,0xa0,0xa0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x0,0x0,0x0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x85,0x85,0x85,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x28,0x28,0x28,0x35,0x35,0x35,0x35,0x35,0x35, +0x35,0x35,0x35,0x35,0x35,0x35,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x5d,0x5d,0x5d,0x35,0x35,0x35, +0x35,0x35,0x35,0x85,0x85,0x85,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xad,0xad,0xad, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x85,0x85,0x85,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0xa0,0xa0,0xa0, +0x6b,0x6b,0x6b,0x1b,0x1b,0x1b,0x35,0x35,0x35,0x28,0x28,0x28,0x35,0x35,0x35, +0xa0,0xa0,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xad,0xad,0xad, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xbb,0xbb,0xbb,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x93,0x93,0x93,0x28,0x28,0x28,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x0,0x0,0x0,0x35,0x35,0x35,0x1b,0x1b,0x1b, +0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x5d,0x5d,0x5d,0x1b,0x1b,0x1b, +0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0xd,0xd,0xd, +0xa0,0xa0,0xa0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x0,0x0,0x0,0xc8,0xc8,0xc8,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b, +0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xad,0xad,0xad,0xbb,0xbb,0xbb, +0xc8,0xc8,0xc8,0x85,0x85,0x85,0xad,0xad,0xad,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x1b,0x1b,0x1b,0xad,0xad,0xad,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x0,0x0,0x0,0x35,0x35,0x35, +0x1b,0x1b,0x1b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x35,0x35,0x35,0x6b,0x6b,0x6b, +0x6b,0x6b,0x6b,0x28,0x28,0x28,0x93,0x93,0x93,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xbb,0xbb,0xbb,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b,0x78,0x78,0x78, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x93,0x93,0x93,0x0,0x0,0x0,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58, +0x58,0x58,0x58,0xdd,0xdd,0xdd,0xd9,0xd9,0xd9,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x45,0x45,0x45,0x52,0x52,0x52,0xcb,0xcb,0xcb, +0xaf,0xaf,0xaf,0x76,0x76,0x76,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x41,0x41,0x41, +0x17,0x17,0x17,0x34,0x34,0x34,0xa9,0xa9,0xa9,0x82,0x82,0x82,0x5e,0x5e,0x5e, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x50,0x50,0x50,0x32,0x32,0x32,0x17,0x17,0x17, +}; +#define ZenAlphaOnwidth 20 +#define ZenAlphaOnheight 20 +#define ZenAlphaOncspace B_RGB32 +#define ZenAlphaOnbytesperpixel 3 + +unsigned char ZenAlphaOnbits[] = { +0x11,0x1c,0xb,0x23,0x3a,0x17,0x3b,0x63,0x28,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x4a,0x7b,0x31,0x5a,0x96,0x3c,0x6f,0xb9,0x4a, +0x24,0x3c,0x18,0x11,0x1c,0xb,0x2d,0x4b,0x1e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e,0x45,0x73,0x2e, +0x45,0x73,0x2e,0x45,0x73,0x2e,0x52,0x89,0x37,0x6a,0xb1,0x47,0x9b,0xe8,0x75, +0x3d,0x65,0x28,0x2f,0x4f,0x20,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xad,0xf7,0x88,0xc1,0xff,0xa3, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x5c,0x99,0x3d,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x29,0x44,0x1b,0x52,0x88,0x36,0x52,0x88,0x36, +0x52,0x88,0x36,0x3d,0x66,0x29,0x0,0x0,0x0,0x29,0x44,0x1b,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x66,0xaa,0x44,0x0,0x0,0x0,0x85,0xdd,0x58, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x7a,0xcc,0x52,0x0,0x0,0x0,0x7a,0xcc,0x52, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x8f,0xee,0x5f,0x1f,0x33,0x14,0x1f,0x33,0x14,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7a,0xcc,0x52,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x3d,0x66,0x29,0x7a,0xcc,0x52,0x7a,0xcc,0x52, +0x7a,0xcc,0x52,0x70,0xbb,0x4b,0x33,0x55,0x22,0x0,0x0,0x0,0x7a,0xcc,0x52, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x14,0x22,0xe,0x33,0x55,0x22, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x52,0x88,0x36,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x8f,0xee,0x5f,0x0,0x0,0x0,0x47,0x77,0x30, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x0,0x0,0x0,0x29,0x44,0x1b,0x52,0x88,0x36,0x52,0x88,0x36, +0x52,0x88,0x36,0x47,0x77,0x30,0xa,0x11,0x7,0x1f,0x33,0x14,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b,0x29,0x44,0x1b, +0x29,0x44,0x1b,0x29,0x44,0x1b,0x5c,0x99,0x3d,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x44,0x72,0x2e,0x44,0x72,0x2e,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xc7,0xff,0xab,0xc7,0xff,0xab, +0x4b,0x7d,0x32,0x53,0x8a,0x37,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66, +0x99,0xff,0x66,0x99,0xff,0x66,0x99,0xff,0x66,0xd3,0xff,0xbe,0xcb,0xff,0xb1, +0x5d,0x9b,0x3e,0x6d,0xb6,0x49,0xae,0xf8,0x89,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xd6,0xff,0xc2,0xf3,0xff,0xed,0xdf,0xff,0xcf, +0x70,0xbb,0x4b,0x9d,0xea,0x77,0xc2,0xff,0xa4,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac,0xc8,0xff,0xac, +0xc8,0xff,0xac,0xc8,0xff,0xac,0xcc,0xff,0xb3,0xe1,0xff,0xd1,0xf3,0xff,0xed, +}; +#define ZenAlphaOffwidth 20 +#define ZenAlphaOffheight 20 +#define ZenAlphaOffcspace B_RGB32 +#define ZenAlphaOffbytesperpixel 3 + +unsigned char ZenAlphaOffbits[] = { +0xf9,0xf9,0xf9,0xf0,0xf0,0xf0,0xe4,0xe4,0xe4,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xdd,0xdd,0xdd,0xd0,0xd0,0xd0,0xaa,0xaa,0xaa, +0xef,0xef,0xef,0xf9,0xf9,0xf9,0xeb,0xeb,0xeb,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xd9,0xd9,0xd9,0xb4,0xb4,0xb4,0x84,0x84,0x84, +0xe4,0xe4,0xe4,0xea,0xea,0xea,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x77,0x77,0x77,0x60,0x60,0x60, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x5d,0x5d,0x5d,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35,0x35, +0x35,0x35,0x35,0x35,0x35,0x35,0x78,0x78,0x78,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x35,0x35,0x35,0x6b,0x6b,0x6b,0x6b,0x6b,0x6b, +0x6b,0x6b,0x6b,0x50,0x50,0x50,0xd,0xd,0xd,0x5d,0x5d,0x5d,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x85,0x85,0x85,0x0,0x0,0x0,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x93,0x93,0x93,0xd,0xd,0xd,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x50,0x50,0x50,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0x85,0x85,0x85,0x1b,0x1b,0x1b,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0xd,0xd,0xd,0x85,0x85,0x85,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x78,0x78,0x78,0x0,0x0,0x0,0xad,0xad,0xad, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x35,0x35,0x35,0x6b,0x6b,0x6b, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x6b,0x6b,0x6b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x1b,0x1b,0x1b,0x78,0x78,0x78, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x50,0x50,0x50,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0x93,0x93,0x93,0x43,0x43,0x43,0xd,0xd,0xd,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x35,0x35,0x35,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x43,0x43,0x43,0xad,0xad,0xad,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x58,0x58,0x58,0x58,0x58,0x58, +0xdd,0xdd,0xdd,0xd9,0xd9,0xd9,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x45,0x45,0x45,0x52,0x52,0x52, +0xcb,0xcb,0xcb,0xaf,0xaf,0xaf,0x76,0x76,0x76,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x41,0x41,0x41,0x17,0x17,0x17,0x34,0x34,0x34, +0xa9,0xa9,0xa9,0x82,0x82,0x82,0x5e,0x5e,0x5e,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56,0x56, +0x56,0x56,0x56,0x56,0x56,0x56,0x50,0x50,0x50,0x32,0x32,0x32,0x17,0x17,0x17, +}; diff --git a/src/add-ons/input_server/methods/canna/PaletteIconImages_old.h b/src/add-ons/input_server/methods/canna/PaletteIconImages_old.h new file mode 100644 index 0000000000..3a4a07ceba --- /dev/null +++ b/src/add-ons/input_server/methods/canna/PaletteIconImages_old.h @@ -0,0 +1,1294 @@ +#define BushuOnwidth 24 +#define BushuOnheight 16 +#define BushuOncspace B_RGB32 +#define BushuOnbytesperpixel 3 + +unsigned char BushuOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x32,0x6f,0x32,0x5c,0xcf,0x5c,0x72,0xff,0x72, +0x64,0xdf,0x64,0x39,0x7f,0x39,0x39,0x7f,0x39,0x40,0x8f,0x40,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x23,0x4f,0x23,0x5c,0xcf,0x5c,0x72,0xff,0x72, +0x47,0x9f,0x47,0x32,0x6f,0x32,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x32,0x6f,0x32, +0x1c,0x3f,0x1c,0x7,0xf,0x7,0x15,0x2f,0x15,0x1c,0x3f,0x1c,0x46,0x9b,0x46, +0x2b,0x5f,0x2b,0x4e,0xaf,0x4e,0xe,0x1f,0xe,0x72,0xff,0x72,0x1c,0x3f,0x1c, +0x1c,0x3f,0x1c,0xe,0x1f,0xe,0xe,0x1f,0xe,0x1c,0x3f,0x1c,0x6,0xf,0x6, +0x15,0x2f,0x15,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c, +0x72,0xff,0x72,0x47,0x9f,0x47,0x32,0x6f,0x32,0x55,0xbf,0x55,0x39,0x7f,0x39, +0x40,0x8f,0x40,0x38,0x7f,0x38,0x72,0xff,0x72,0x56,0xbf,0x56,0x56,0xbf,0x56, +0x55,0xbf,0x55,0x40,0x8f,0x40,0x1c,0x3f,0x1c,0x55,0xbf,0x55,0x55,0xbf,0x55, +0x55,0xbf,0x55,0x56,0xbf,0x56,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x5d,0xcf,0x5d,0x1c,0x3f,0x1c,0x4e,0xaf,0x4e, +0x23,0x4f,0x23,0x40,0x8f,0x40,0x4a,0xa7,0x4a,0x39,0x7f,0x39,0x15,0x2f,0x15, +0x64,0xdf,0x64,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39,0x15,0x2f,0x15, +0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x15,0x2f,0x15,0x39,0x7f,0x39, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x47,0x9f,0x47,0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x40,0x8f,0x40,0x39,0x7f,0x39,0x40,0x8f,0x40,0x32,0x6f,0x32, +0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39,0x40,0x8f,0x40,0x55,0xbf,0x55, +0x55,0xbf,0x55,0x55,0xbf,0x55,0x40,0x8f,0x40,0x39,0x7f,0x39,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x5c,0xcf,0x5c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x31,0x6f,0x31, +0x55,0xbf,0x55,0x39,0x7f,0x39,0x72,0xff,0x72,0xe,0x1f,0xe,0x6b,0xef,0x6b, +0x72,0xff,0x72,0x39,0x7f,0x39,0x2b,0x5f,0x2b,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x2a,0x5f,0x2a,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x56,0xbf,0x56, +0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x55,0xbf,0x55, +0x39,0x7f,0x39,0x55,0xbf,0x55,0x15,0x2f,0x15,0x5c,0xcf,0x5c,0x72,0xff,0x72, +0x39,0x7f,0x39,0x15,0x2f,0x15,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x15,0x2f,0x15,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x55,0xbf,0x55,0xe,0x1f,0xe, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x1c,0x3f,0x1c,0x55,0xbf,0x55,0x39,0x7f,0x39, +0x32,0x6f,0x32,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39, +0x40,0x8f,0x40,0x56,0xbf,0x56,0x55,0xbf,0x55,0x55,0xbf,0x55,0x40,0x8f,0x40, +0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x55,0xbf,0x55,0x15,0x2f,0x15,0x55,0xbf,0x55, +0x56,0xbf,0x56,0x31,0x6f,0x31,0x55,0xbf,0x55,0x39,0x7f,0x39,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39,0x2b,0x5f,0x2b, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39,0x2b,0x5f,0x2b,0x39,0x7f,0x39, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,}; +#define BushuOffwidth 24 +#define BushuOffheight 16 +#define BushuOffcspace B_RGB32 +#define BushuOffbytesperpixel 3 + +unsigned char BushuOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x57,0x57,0x57,0xa2,0xa2,0xa2,0xc8,0xc8,0xc8, +0xaf,0xaf,0xaf,0x64,0x64,0x64,0x64,0x64,0x64,0x70,0x70,0x70,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x3e,0x3e,0x3e,0xa2,0xa2,0xa2,0xc8,0xc8,0xc8, +0x7c,0x7c,0x7c,0x57,0x57,0x57,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x57,0x57,0x57, +0x31,0x31,0x31,0xc,0xc,0xc,0x25,0x25,0x25,0x32,0x32,0x32,0x7a,0x7a,0x7a, +0x4a,0x4a,0x4a,0x89,0x89,0x89,0x18,0x18,0x18,0xc8,0xc8,0xc8,0x31,0x31,0x31, +0x31,0x31,0x31,0x19,0x19,0x19,0x18,0x18,0x18,0x31,0x31,0x31,0xc,0xc,0xc, +0x25,0x25,0x25,0x32,0x32,0x32,0x31,0x31,0x31,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x31,0x31,0x31, +0xc8,0xc8,0xc8,0x7d,0x7d,0x7d,0x57,0x57,0x57,0x96,0x96,0x96,0x63,0x63,0x63, +0x70,0x70,0x70,0x64,0x64,0x64,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x96,0x96,0x96, +0x96,0x96,0x96,0x70,0x70,0x70,0x31,0x31,0x31,0x96,0x96,0x96,0x96,0x96,0x96, +0x96,0x96,0x96,0x96,0x96,0x96,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa2,0xa2,0xa2,0x32,0x32,0x32,0x89,0x89,0x89, +0x3e,0x3e,0x3e,0x70,0x70,0x70,0x83,0x83,0x83,0x63,0x63,0x63,0x25,0x25,0x25, +0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x63,0x63,0x63,0x25,0x25,0x25, +0x31,0x31,0x31,0x32,0x32,0x32,0x32,0x32,0x32,0x25,0x25,0x25,0x64,0x64,0x64, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x7d,0x7d,0x7d,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64, +0x64,0x64,0x64,0x70,0x70,0x70,0x64,0x64,0x64,0x70,0x70,0x70,0x57,0x57,0x57, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x63,0x63,0x63,0x70,0x70,0x70,0x96,0x96,0x96, +0x96,0x96,0x96,0x96,0x96,0x96,0x70,0x70,0x70,0x64,0x64,0x64,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa2,0xa2,0xa2,0x31,0x31,0x31,0x31,0x31,0x31,0x32,0x32,0x32,0x57,0x57,0x57, +0x96,0x96,0x96,0x64,0x64,0x64,0xc8,0xc8,0xc8,0x18,0x18,0x18,0xbb,0xbb,0xbb, +0xc8,0xc8,0xc8,0x64,0x64,0x64,0x4a,0x4a,0x4a,0x64,0x64,0x64,0x64,0x64,0x64, +0x64,0x64,0x64,0x4b,0x4b,0x4b,0x64,0x64,0x64,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x96,0x96,0x96, +0x32,0x32,0x32,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x32,0x32,0x32,0x96,0x96,0x96, +0x63,0x63,0x63,0x96,0x96,0x96,0x25,0x25,0x25,0xa2,0xa2,0xa2,0xc8,0xc8,0xc8, +0x64,0x64,0x64,0x25,0x25,0x25,0x32,0x32,0x32,0x31,0x31,0x31,0x31,0x31,0x31, +0x25,0x25,0x25,0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x18,0x18,0x18, +0x64,0x64,0x64,0x64,0x64,0x64,0x31,0x31,0x31,0x96,0x96,0x96,0x64,0x64,0x64, +0x57,0x57,0x57,0x64,0x64,0x64,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64, +0x70,0x70,0x70,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x70,0x70,0x70, +0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x25,0x25,0x25,0x96,0x96,0x96, +0x96,0x96,0x96,0x57,0x57,0x57,0x96,0x96,0x96,0x64,0x64,0x64,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64,0x4a,0x4a,0x4a, +0x64,0x64,0x64,0x63,0x63,0x63,0x63,0x63,0x63,0x4a,0x4a,0x4a,0x64,0x64,0x64, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,}; +#define ExtendOnwidth 24 +#define ExtendOnheight 16 +#define ExtendOncspace B_RGB32 +#define ExtendOnbytesperpixel 3 + +unsigned char ExtendOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x32,0x6f,0x32,0x5d,0xcf,0x5d,0x72,0xff,0x72,0x72,0xff,0x72, +0x56,0xbf,0x56,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x47,0x9f,0x47,0x38,0x7f,0x38,0x47,0x9f,0x47,0x72,0xff,0x72,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39,0x55,0xbf,0x55,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x1c,0x3f,0x1c,0x55,0xbf,0x55,0x64,0xdf,0x64,0x55,0xbf,0x55,0x40,0x8f,0x40, +0x15,0x2f,0x15,0x56,0xbf,0x56,0x56,0xbf,0x56,0x72,0xff,0x72,0x5c,0xcf,0x5c, +0x55,0xbf,0x55,0x1c,0x3f,0x1c,0x72,0xff,0x72,0xe,0x1f,0xe,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x38,0x7f,0x38,0x64,0xdf,0x64,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x7,0xf,0x7, +0x15,0x2f,0x15,0x2f,0x67,0x2f,0x2a,0x5f,0x2a,0x39,0x7f,0x39,0x38,0x7f,0x38, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x72,0xff,0x72,0x55,0xbf,0x55,0x39,0x7f,0x39, +0x1c,0x3f,0x1c,0x72,0xff,0x72,0xe,0x1f,0xe,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x55,0xbf,0x55, +0x39,0x7f,0x39,0x55,0xbf,0x55,0x64,0xdf,0x64,0x2b,0x5f,0x2b,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x2a,0x5f,0x2a,0x40,0x8f,0x40,0x5c,0xcf,0x5c, +0x72,0xff,0x72,0x7,0xf,0x7,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x6b,0xef,0x6b,0x15,0x2f,0x15,0xe,0x1f,0xe,0x2e,0x67,0x2e, +0x55,0xbf,0x55,0x47,0x9f,0x47,0x32,0x6f,0x32,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x2b,0x5f,0x2b,0x47,0x9f,0x47,0x39,0x7f,0x39, +0xe,0x1f,0xe,0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x15,0x2f,0x15,0xe,0x1f,0xe,0x55,0xbf,0x55,0x32,0x6f,0x32,0x55,0xbf,0x55, +0x2a,0x5f,0x2a,0x47,0x9f,0x47,0x47,0x9f,0x47,0x72,0xff,0x72,0x72,0xff,0x72, +0x47,0x9f,0x47,0x40,0x8f,0x40,0x1c,0x3f,0x1c,0x56,0xbf,0x56,0x15,0x2f,0x15, +0x56,0xbf,0x56,0x15,0x2f,0x15,0x56,0xbf,0x56,0x39,0x7f,0x39,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x1c,0x3f,0x1c,0x55,0xbf,0x55,0x1c,0x3f,0x1c,0x5c,0xcf,0x5c,0xe,0x1f,0xe, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x64,0xdf,0x64,0x72,0xff,0x72,0x72,0xff,0x72, +0x55,0xbf,0x55,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x72,0xff,0x72, +0x15,0x2f,0x15,0x1c,0x3f,0x1c,0x40,0x8f,0x40,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c, +0x4a,0xa7,0x4a,0xe,0x1f,0xe,0x4e,0xaf,0x4e,0x15,0x2f,0x15,0x47,0x9f,0x47, +0x23,0x4f,0x23,0x2a,0x5f,0x2a,0x72,0xff,0x72,0x72,0xff,0x72,0x4e,0xaf,0x4e, +0x39,0x7f,0x39,0x72,0xff,0x72,0x15,0x2f,0x15,0x4e,0xaf,0x4e,0x47,0x9f,0x47, +0x15,0x2f,0x15,0x6b,0xef,0x6b,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x47,0x9f,0x47,0xe,0x1f,0xe,0x3e,0x8b,0x3e, +0x4e,0xaf,0x4e,0x1c,0x3f,0x1c,0x32,0x6f,0x32,0x40,0x8f,0x40,0x55,0xbf,0x55, +0x1c,0x3f,0x1c,0x6b,0xef,0x6b,0x4e,0xaf,0x4e,0x15,0x2f,0x15,0x51,0xb5,0x51, +0xe,0x1f,0xe,0x23,0x4f,0x23,0x39,0x7f,0x39,0x6b,0xef,0x6b,0x47,0x9f,0x47, +0x15,0x2f,0x15,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x6b,0xef,0x6b,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,}; +#define ExtendOffwidth 24 +#define ExtendOffheight 16 +#define ExtendOffcspace B_RGB32 +#define ExtendOffbytesperpixel 3 + +unsigned char ExtendOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x57,0x57,0x57,0xa2,0xa2,0xa2,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x96,0x96,0x96,0x32,0x32,0x32,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x7d,0x7d,0x7d,0x64,0x64,0x64,0x7c,0x7c,0x7c,0xc8,0xc8,0xc8,0x64,0x64,0x64, +0x64,0x64,0x64,0x64,0x64,0x64,0x63,0x63,0x63,0x96,0x96,0x96,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x31,0x31,0x31,0x96,0x96,0x96,0xaf,0xaf,0xaf,0x96,0x96,0x96,0x70,0x70,0x70, +0x25,0x25,0x25,0x96,0x96,0x96,0x96,0x96,0x96,0xc8,0xc8,0xc8,0xa3,0xa3,0xa3, +0x96,0x96,0x96,0x31,0x31,0x31,0xc8,0xc8,0xc8,0x18,0x18,0x18,0x64,0x64,0x64, +0x64,0x64,0x64,0x64,0x64,0x64,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x31,0x31,0x31,0xc,0xc,0xc, +0x25,0x25,0x25,0x51,0x51,0x51,0x4a,0x4a,0x4a,0x64,0x64,0x64,0x64,0x64,0x64, +0x63,0x63,0x63,0x64,0x64,0x64,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x64,0x64,0x64, +0x31,0x31,0x31,0xc8,0xc8,0xc8,0x18,0x18,0x18,0x64,0x64,0x64,0x64,0x64,0x64, +0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x32,0x32,0x32,0x96,0x96,0x96, +0x64,0x64,0x64,0x96,0x96,0x96,0xaf,0xaf,0xaf,0x4a,0x4a,0x4a,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x4b,0x4b,0x4b,0x70,0x70,0x70,0xa3,0xa3,0xa3, +0xc8,0xc8,0xc8,0xc,0xc,0xc,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xbc,0xbc,0xbc,0x25,0x25,0x25,0x18,0x18,0x18,0x51,0x51,0x51, +0x96,0x96,0x96,0x7d,0x7d,0x7d,0x57,0x57,0x57,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x32,0x32,0x32,0x4b,0x4b,0x4b,0x7d,0x7d,0x7d,0x64,0x64,0x64, +0x18,0x18,0x18,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x63,0x63,0x63, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x25,0x25,0x25,0x18,0x18,0x18,0x96,0x96,0x96,0x57,0x57,0x57,0x95,0x95,0x95, +0x4b,0x4b,0x4b,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x7d,0x7d,0x7d,0x70,0x70,0x70,0x32,0x32,0x32,0x96,0x96,0x96,0x25,0x25,0x25, +0x96,0x96,0x96,0x25,0x25,0x25,0x96,0x96,0x96,0x64,0x64,0x64,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x31,0x31,0x31,0x96,0x96,0x96,0x31,0x31,0x31,0xa2,0xa2,0xa2,0x18,0x18,0x18, +0xc8,0xc8,0xc8,0x32,0x32,0x32,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x96,0x96,0x96,0x32,0x32,0x32,0xc8,0xc8,0xc8,0x31,0x31,0x31,0xc8,0xc8,0xc8, +0x25,0x25,0x25,0x31,0x31,0x31,0x70,0x70,0x70,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x32,0x32,0x32, +0x83,0x83,0x83,0x18,0x18,0x18,0x89,0x89,0x89,0x25,0x25,0x25,0x7d,0x7d,0x7d, +0x3e,0x3e,0x3e,0x4a,0x4a,0x4a,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x89,0x89,0x89, +0x64,0x64,0x64,0xc8,0xc8,0xc8,0x25,0x25,0x25,0x89,0x89,0x89,0x7c,0x7c,0x7c, +0x25,0x25,0x25,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x7c,0x7c,0x7c,0x18,0x18,0x18,0x6d,0x6d,0x6d, +0x89,0x89,0x89,0x32,0x32,0x32,0x57,0x57,0x57,0x70,0x70,0x70,0x96,0x96,0x96, +0x31,0x31,0x31,0xbb,0xbb,0xbb,0x8a,0x8a,0x8a,0x25,0x25,0x25,0x8e,0x8e,0x8e, +0x18,0x18,0x18,0x3e,0x3e,0x3e,0x63,0x63,0x63,0xbc,0xbc,0xbc,0x7d,0x7d,0x7d, +0x25,0x25,0x25,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xbc,0xbc,0xbc,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,}; +#define HanAlphaOnwidth 16 +#define HanAlphaOnheight 16 +#define HanAlphaOncspace B_RGB32 +#define HanAlphaOnbytesperpixel 3 + +unsigned char HanAlphaOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x5d,0xcf,0x5d, +0x55,0xbf,0x55,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x31,0x6f,0x31,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x6b,0xef,0x6b,0x23,0x4f,0x23,0x39,0x7f,0x39,0x56,0xbf,0x56, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x4e,0xaf,0x4e,0x40,0x8f,0x40,0x55,0xbf,0x55, +0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x31,0x6f,0x31,0x5d,0xcf,0x5d, +0x72,0xff,0x72,0x15,0x2f,0x15,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x15,0x2f,0x15, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6b,0xef,0x6b,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x6b,0xef,0x6b, +0x23,0x4f,0x23,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39,0x4e,0xaf,0x4e, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x4e,0xaf,0x4e,0x40,0x8f,0x40,0x72,0xff,0x72,0x72,0xff,0x72,0x55,0xbf,0x55, +0x31,0x6f,0x31,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x55,0xbf,0x55,0x64,0xdf,0x64,0x72,0xff,0x72,0x72,0xff,0x72, +0x6b,0xef,0x6b,0x47,0x9f,0x47,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,}; +#define HanAlphaOffwidth 16 +#define HanAlphaOffheight 16 +#define HanAlphaOffcspace B_RGB32 +#define HanAlphaOffbytesperpixel 3 + +unsigned char HanAlphaOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa2,0xa2,0xa2, +0x96,0x96,0x96,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x57,0x57,0x57,0x31,0x31,0x31,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x32,0x32,0x32,0x32,0x32,0x32,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0x3e,0x3e,0x3e,0x63,0x63,0x63,0x96,0x96,0x96, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x89,0x89,0x89,0x70,0x70,0x70,0x96,0x96,0x96, +0x64,0x64,0x64,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x57,0x57,0x57,0xa2,0xa2,0xa2, +0xc8,0xc8,0xc8,0x25,0x25,0x25,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x25,0x25,0x25, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb, +0x3e,0x3e,0x3e,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64,0x89,0x89,0x89, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x89,0x89,0x89,0x70,0x70,0x70,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x96,0x96,0x96, +0x57,0x57,0x57,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x96,0x96,0x96,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xbb,0xbb,0xbb,0x7d,0x7d,0x7d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,}; +#define HexOnwidth 24 +#define HexOnheight 16 +#define HexOncspace B_RGB32 +#define HexOnbytesperpixel 3 + +unsigned char HexOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x31,0x6f,0x31,0x72,0xff,0x72,0x6b,0xef,0x6b,0x5c,0xcf,0x5c,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x5c,0xcf,0x5c, +0x55,0xbf,0x55,0x55,0xbf,0x55,0x55,0xbf,0x55,0x5c,0xcf,0x5c,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c, +0x72,0xff,0x72,0x4e,0xaf,0x4e,0x32,0x6f,0x32,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x32,0x6f,0x32,0x1c,0x3f,0x1c, +0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x72,0xff,0x72, +0x4e,0xaf,0x4e,0x5c,0xcf,0x5c,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x2b,0x5f,0x2b,0x6b,0xef,0x6b, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x1c,0x3f,0x1c,0x72,0xff,0x72,0x56,0xbf,0x56,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x55,0xbf,0x55,0x72,0xff,0x72, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x39,0x7f,0x39,0xe,0x1f,0xe,0x55,0xbf,0x55, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x1c,0x3f,0x1c,0x72,0xff,0x72,0x5c,0xcf,0x5c,0x32,0x6f,0x32,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x47,0x9f,0x47, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39,0x1c,0x3f,0x1c,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x47,0x9f,0x47,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,}; +#define HexOffwidth 24 +#define HexOffheight 16 +#define HexOffcspace B_RGB32 +#define HexOffbytesperpixel 3 + +unsigned char HexOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x57,0x57,0x57,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0xa2,0xa2,0xa2,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa2,0xa2,0xa2, +0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0xa3,0xa3,0xa3,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x31,0x31,0x31, +0xc8,0xc8,0xc8,0x8a,0x8a,0x8a,0x57,0x57,0x57,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x57,0x57,0x57,0x32,0x32,0x32, +0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x32,0x32,0x32,0xc8,0xc8,0xc8, +0x89,0x89,0x89,0xa2,0xa2,0xa2,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x32,0x32,0x32,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x31,0x31,0x31,0x4b,0x4b,0x4b,0xbc,0xbc,0xbc, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x31,0x31,0x31,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x96,0x96,0x96,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x31,0x31,0x31,0x64,0x64,0x64,0x19,0x19,0x19,0x96,0x96,0x96, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x31,0x31,0x31, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x31,0x31,0x31,0xc8,0xc8,0xc8,0xa2,0xa2,0xa2,0x57,0x57,0x57,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x7d,0x7d,0x7d, +0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x31,0x31,0x31,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x32,0x32,0x32, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x7d,0x7d,0x7d,0x64,0x64,0x64, +0x63,0x63,0x63,0x64,0x64,0x64,0x31,0x31,0x31,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x31,0x31,0x31,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x32,0x32,0x32,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,}; +#define HiraOnwidth 16 +#define HiraOnheight 16 +#define HiraOncspace B_RGB32 +#define HiraOnbytesperpixel 3 + +unsigned char HiraOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c, +0x5c,0xcf,0x5c,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x0,0x0,0x0,0x56,0xbf,0x56,0x4e,0xaf,0x4e,0x32,0x6f,0x32,0x47,0x9f,0x47, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x39,0x7f,0x39, +0x64,0xdf,0x64,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x55,0xbf,0x55,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x64,0xdf,0x64, +0x47,0x9f,0x47,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39,0x7,0xf,0x7,0x0,0x0,0x0, +0x7,0xf,0x7,0x6,0xf,0x6,0x31,0x6f,0x31,0x6b,0xef,0x6b,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x6b,0xef,0x6b,0x1c,0x3f,0x1c,0xe,0x1f,0xe,0x1c,0x3f,0x1c, +0x55,0xbf,0x55,0x7,0xf,0x7,0x63,0xdf,0x63,0x32,0x6f,0x32,0x15,0x2f,0x15, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x32,0x6f,0x32,0x2b,0x5f,0x2b,0x56,0xbf,0x56, +0x15,0x2f,0x15,0xe,0x1f,0xe,0x4e,0xaf,0x4e,0x72,0xff,0x72,0x72,0xff,0x72, +0xe,0x1f,0xe,0x56,0xbf,0x56,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x64,0xdf,0x64,0xe,0x1f,0xe,0x72,0xff,0x72, +0x56,0xbf,0x56,0x0,0x0,0x0,0x32,0x6f,0x32,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x15,0x2f,0x15,0x55,0xbf,0x55,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x55,0xbf,0x55,0x1c,0x3f,0x1c, +0x6b,0xef,0x6b,0x2a,0x5f,0x2a,0x0,0x0,0x0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x47,0x9f,0x47,0x6,0xf,0x6,0x6b,0xef,0x6b,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x6b,0xef,0x6b, +0x7,0xf,0x7,0x0,0x0,0x0,0x39,0x7f,0x39,0x47,0x9f,0x47,0x64,0xdf,0x64, +0x32,0x6f,0x32,0x15,0x2f,0x15,0xe,0x1f,0xe,0x5d,0xcf,0x5d,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x39,0x7f,0x39,0x56,0xbf,0x56,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,}; +#define HiraOffwidth 16 +#define HiraOffheight 16 +#define HiraOffcspace B_RGB32 +#define HiraOffbytesperpixel 3 + +unsigned char HiraOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x31,0x31,0x31, +0xa3,0xa3,0xa3,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x0,0x0,0x0,0x96,0x96,0x96,0x89,0x89,0x89,0x57,0x57,0x57,0x7d,0x7d,0x7d, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x31,0x31,0x31,0x31,0x31,0x64,0x64,0x64, +0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x96,0x96,0x96,0x32,0x32,0x32,0xc8,0xc8,0xc8,0xaf,0xaf,0xaf, +0x7d,0x7d,0x7d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64,0xc,0xc,0xc,0x0,0x0,0x0, +0xc,0xc,0xc,0xc,0xc,0xc,0x57,0x57,0x57,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0x32,0x32,0x32,0x18,0x18,0x18,0x31,0x31,0x31, +0x96,0x96,0x96,0xb,0xb,0xb,0xaf,0xaf,0xaf,0x57,0x57,0x57,0x25,0x25,0x25, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x57,0x57,0x57,0x4b,0x4b,0x4b,0x96,0x96,0x96, +0x25,0x25,0x25,0x19,0x19,0x19,0x89,0x89,0x89,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x18,0x18,0x18,0x96,0x96,0x96,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xaf,0xaf,0xaf,0x18,0x18,0x18,0xc8,0xc8,0xc8, +0x96,0x96,0x96,0x0,0x0,0x0,0x57,0x57,0x57,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x25,0x25,0x25,0x96,0x96,0x96,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x31,0x31,0x31, +0xbb,0xbb,0xbb,0x4a,0x4a,0x4a,0x0,0x0,0x0,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x7d,0x7d,0x7d,0xc,0xc,0xc,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb, +0xb,0xb,0xb,0x0,0x0,0x0,0x64,0x64,0x64,0x7d,0x7d,0x7d,0xaf,0xaf,0xaf, +0x57,0x57,0x57,0x25,0x25,0x25,0x19,0x19,0x19,0xa2,0xa2,0xa2,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x63,0x63,0x63,0x96,0x96,0x96,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,}; +#define KataOnwidth 16 +#define KataOnheight 16 +#define KataOncspace B_RGB32 +#define KataOnbytesperpixel 3 + +unsigned char KataOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x23,0x4f,0x23,0x6b,0xef,0x6b,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x55,0xbf,0x55,0x55,0xbf,0x55, +0x55,0xbf,0x55,0x55,0xbf,0x55,0x55,0xbf,0x55,0x56,0xbf,0x56,0x4e,0xaf,0x4e, +0x0,0x0,0x0,0x2b,0x5f,0x2b,0x6b,0xef,0x6b,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x6b,0xef,0x6b,0x55,0xbf,0x55,0x5d,0xcf,0x5d, +0x7,0xf,0x7,0x2b,0x5f,0x2b,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x55,0xbf,0x55,0x0,0x0,0x0, +0x7,0xf,0x7,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x55,0xbf,0x55, +0x0,0x0,0x0,0x64,0xdf,0x64,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x40,0x8f,0x40,0x15,0x2f,0x15,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x2a,0x5f,0x2a,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x32,0x6f,0x32,0x6,0xf,0x6,0x64,0xdf,0x64,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x56,0xbf,0x56,0xe,0x1f,0xe,0x7,0xf,0x7,0x55,0xbf,0x55,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x40,0x8f,0x40,0x6b,0xef,0x6b,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,}; +#define KataOffwidth 16 +#define KataOffheight 16 +#define KataOffcspace B_RGB32 +#define KataOffbytesperpixel 3 + +unsigned char KataOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31, +0x31,0x31,0x31,0x32,0x32,0x32,0x32,0x32,0x32,0x31,0x31,0x31,0x32,0x32,0x32, +0x3e,0x3e,0x3e,0xbc,0xbc,0xbc,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x96,0x96,0x96, +0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x89,0x89,0x89, +0x0,0x0,0x0,0x4b,0x4b,0x4b,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0x96,0x96,0x96,0xa2,0xa2,0xa2, +0xb,0xb,0xb,0x4a,0x4a,0x4a,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x0,0x0,0x0, +0xc,0xc,0xc,0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x96,0x96,0x96, +0x0,0x0,0x0,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x70,0x70,0x70,0x25,0x25,0x25,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x31,0x31,0x31,0x4b,0x4b,0x4b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x57,0x57,0x57,0xc,0xc,0xc,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x96,0x96,0x96,0x18,0x18,0x18,0xc,0xc,0xc,0x96,0x96,0x96,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x70,0x70,0x70,0xbc,0xbc,0xbc,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,}; +#define KigoOnwidth 24 +#define KigoOnheight 16 +#define KigoOncspace B_RGB32 +#define KigoOnbytesperpixel 3 + +unsigned char KigoOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x64,0xdf,0x64,0x39,0x7f,0x39,0x39,0x7f,0x39,0x56,0xbf,0x56,0x47,0x9f,0x47, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39,0x56,0xbf,0x56,0x72,0xff,0x72, +0x72,0xff,0x72,0x56,0xbf,0x56,0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x55,0xbf,0x55,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x57,0xc2,0x57, +0x40,0x8f,0x40,0x40,0x8f,0x40,0x4b,0xa7,0x4b,0x47,0x9f,0x47,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x1c,0x3f,0x1c,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72, +0x39,0x7f,0x39,0x2a,0x5f,0x2a,0x56,0xbf,0x56,0x55,0xbf,0x55,0x55,0xbf,0x55, +0x2a,0x5f,0x2a,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x47,0x9f,0x47,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39, +0x1c,0x3f,0x1c,0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39,0x1c,0x3f,0x1c, +0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x5d,0xcf,0x5d,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x47,0x9f,0x47,0x55,0xbf,0x55,0x39,0x7f,0x39,0x39,0x7f,0x39,0x1c,0x3f,0x1c, +0x39,0x7f,0x39,0x72,0xff,0x72,0x55,0xbf,0x55,0x4a,0xa7,0x4a,0x40,0x8f,0x40, +0x40,0x8f,0x40,0x3f,0x8f,0x3f,0x40,0x8f,0x40,0x40,0x8f,0x40,0x4a,0xa7,0x4a, +0x55,0xbf,0x55,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x5d,0xcf,0x5d,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x47,0x9f,0x47, +0x39,0x7f,0x39,0x1c,0x3f,0x1c,0x39,0x7f,0x39,0x39,0x7f,0x39,0x56,0xbf,0x56, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x15,0x2f,0x15,0x6,0xf,0x6,0x1c,0x3f,0x1c, +0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x55,0xbf,0x55,0x38,0x7f,0x38,0x39,0x7f,0x39,0x47,0x9f,0x47,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x47,0x9f,0x47,0xe,0x1f,0xe,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x38,0x7f,0x38,0x47,0x9f,0x47,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39, +0x1c,0x3f,0x1c,0x2a,0x5f,0x2a,0x1c,0x3f,0x1c,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x2b,0x5f,0x2b,0x39,0x7f,0x39,0x55,0xbf,0x55,0x56,0xbf,0x56,0x55,0xbf,0x55, +0x39,0x7f,0x39,0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x38,0x7f,0x38,0x2b,0x5f,0x2b, +0x40,0x8f,0x40,0x1c,0x3f,0x1c,0x39,0x7f,0x39,0x31,0x6f,0x31,0x72,0xff,0x72, +0x6b,0xef,0x6b,0x1c,0x3f,0x1c,0x6b,0xef,0x6b,0x72,0xff,0x72,0x72,0xff,0x72, +0x6b,0xef,0x6b,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39,0x1c,0x3f,0x1c,0x32,0x6f,0x32, +0x31,0x6f,0x31,0x63,0xdf,0x63,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x32,0x6f,0x32,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x32,0x6f,0x32,0xe,0x1f,0xe,0x4e,0xaf,0x4e, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x64,0xdf,0x64,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,}; +#define KigoOffwidth 24 +#define KigoOffheight 16 +#define KigoOffcspace B_RGB32 +#define KigoOffbytesperpixel 3 + +unsigned char KigoOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xaf,0xaf,0xaf,0x63,0x63,0x63,0x64,0x64,0x64,0x96,0x96,0x96,0x7c,0x7c,0x7c, +0x64,0x64,0x64,0x63,0x63,0x63,0x64,0x64,0x64,0x95,0x95,0x95,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x96,0x96,0x96,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64, +0x64,0x64,0x64,0x64,0x64,0x64,0x96,0x96,0x96,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x99,0x99,0x99, +0x70,0x70,0x70,0x70,0x70,0x70,0x83,0x83,0x83,0x7d,0x7d,0x7d,0x63,0x63,0x63, +0x63,0x63,0x63,0x32,0x32,0x32,0x64,0x64,0x64,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x63,0x63,0x63,0x4b,0x4b,0x4b,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96, +0x4a,0x4a,0x4a,0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x7d,0x7d,0x7d,0x64,0x64,0x64, +0x63,0x63,0x63,0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x64,0x64,0x64,0x64,0x64,0x64,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x63,0x63,0x63, +0x32,0x32,0x32,0x63,0x63,0x63,0x64,0x64,0x64,0x64,0x64,0x64,0x32,0x32,0x32, +0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa2,0xa2,0xa2,0x32,0x32,0x32,0x31,0x31,0x31, +0x7c,0x7c,0x7c,0x96,0x96,0x96,0x64,0x64,0x64,0x63,0x63,0x63,0x31,0x31,0x31, +0x63,0x63,0x63,0xc8,0xc8,0xc8,0x96,0x96,0x96,0x83,0x83,0x83,0x70,0x70,0x70, +0x71,0x71,0x71,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x83,0x83,0x83, +0x96,0x96,0x96,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa2,0xa2,0xa2,0x32,0x32,0x32,0x31,0x31,0x31,0x7d,0x7d,0x7d, +0x64,0x64,0x64,0x31,0x31,0x31,0x63,0x63,0x63,0x64,0x64,0x64,0x96,0x96,0x96, +0xc8,0xc8,0xc8,0x31,0x31,0x31,0x25,0x25,0x25,0xc,0xc,0xc,0x32,0x32,0x32, +0x32,0x32,0x32,0x32,0x32,0x32,0x31,0x31,0x31,0x32,0x32,0x32,0x31,0x31,0x31, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x96,0x96,0x96,0x63,0x63,0x63,0x64,0x64,0x64,0x7d,0x7d,0x7d,0x64,0x64,0x64, +0x64,0x64,0x64,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x7c,0x7c,0x7c,0x18,0x18,0x18,0x64,0x64,0x64,0x64,0x64,0x64, +0x64,0x64,0x64,0x63,0x63,0x63,0x7d,0x7d,0x7d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x63,0x63,0x63, +0x31,0x31,0x31,0x4a,0x4a,0x4a,0x31,0x31,0x31,0x64,0x64,0x64,0x63,0x63,0x63, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x4b,0x4b,0x4b,0x64,0x64,0x64,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96, +0x64,0x64,0x64,0x32,0x32,0x32,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64,0x4b,0x4b,0x4b, +0x70,0x70,0x70,0x31,0x31,0x31,0x64,0x64,0x64,0x57,0x57,0x57,0xc8,0xc8,0xc8, +0xbb,0xbb,0xbb,0x31,0x31,0x31,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64, +0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64,0x31,0x31,0x31,0x57,0x57,0x57, +0x57,0x57,0x57,0xaf,0xaf,0xaf,0x31,0x31,0x31,0x32,0x32,0x32,0x31,0x31,0x31, +0x57,0x57,0x57,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x57,0x57,0x57,0x18,0x18,0x18,0x89,0x89,0x89, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,}; +#define TorokuOnwidth 24 +#define TorokuOnheight 16 +#define TorokuOncspace B_RGB32 +#define TorokuOnbytesperpixel 3 + +unsigned char TorokuOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39,0x40,0x8f,0x40,0x32,0x6f,0x32, +0x5d,0xcf,0x5d,0x2b,0x5f,0x2b,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x6b,0xef,0x6b,0x15,0x2f,0x15,0x6b,0xef,0x6b,0x55,0xbf,0x55,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x55,0xbf,0x55,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x31,0x6f,0x31, +0x4e,0xaf,0x4e,0x2b,0x5f,0x2b,0x23,0x4f,0x23,0x4e,0xaf,0x4e,0x0,0x0,0x0, +0x47,0x9f,0x47,0x32,0x6f,0x32,0x72,0xff,0x72,0x72,0xff,0x72,0x23,0x4f,0x23, +0x23,0x4f,0x23,0xe,0x1f,0xe,0x52,0xb5,0x52,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x2a,0x5f,0x2a,0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x4e,0xaf,0x4e,0xe,0x1f,0xe, +0x15,0x2f,0x15,0x6b,0xef,0x6b,0x72,0xff,0x72,0x38,0x7f,0x38,0x7,0xf,0x7, +0x47,0x9f,0x47,0x72,0xff,0x72,0x39,0x7f,0x39,0x15,0x2f,0x15,0x55,0xbf,0x55, +0x4e,0xaf,0x4e,0x64,0xdf,0x64,0x39,0x7f,0x39,0x38,0x7f,0x38,0x2a,0x5f,0x2a, +0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x5d,0xcf,0x5d,0x1c,0x3f,0x1c,0x32,0x6f,0x32,0x1c,0x3f,0x1c, +0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x31,0x6f,0x31,0xe,0x1f,0xe, +0x4e,0xaf,0x4e,0x6b,0xef,0x6b,0x40,0x8f,0x40,0x0,0x0,0x0,0x55,0xbf,0x55, +0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x15,0x2f,0x15,0xe,0x1f,0xe, +0x47,0x9f,0x47,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x6b,0xef,0x6b,0x56,0xbf,0x56,0x47,0x9f,0x47,0x39,0x7f,0x39,0x39,0x7f,0x39, +0x39,0x7f,0x39,0x39,0x7f,0x39,0x39,0x7f,0x39,0x64,0xdf,0x64,0x6b,0xef,0x6b, +0x5c,0xcf,0x5c,0x1c,0x3f,0x1c,0x0,0x0,0x0,0x1c,0x3f,0x1c,0x6b,0xef,0x6b, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x56,0xbf,0x56,0x64,0xdf,0x64,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x1c,0x3f,0x1c,0x55,0xbf,0x55,0x55,0xbf,0x55,0x55,0xbf,0x55, +0x55,0xbf,0x55,0x15,0x2f,0x15,0x72,0xff,0x72,0x72,0xff,0x72,0x5e,0xd1,0x5e, +0x4b,0xa7,0x4b,0x0,0x0,0x0,0x4b,0xa7,0x4b,0x4f,0xaf,0x4f,0x39,0x7f,0x39, +0x1c,0x3f,0x1c,0x24,0x4f,0x24,0x15,0x2f,0x15,0x64,0xdf,0x64,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x7,0xf,0x7,0x72,0xff,0x72,0x72,0xff,0x72,0x5d,0xcf,0x5d,0x2a,0x5f,0x2a, +0x0,0x0,0x0,0x15,0x2f,0x15,0x64,0xe0,0x64,0x3c,0x86,0x3c,0x1c,0x3f,0x1c, +0xe,0x1f,0xe,0x40,0x8f,0x40,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x15,0x2f,0x15,0x6b,0xef,0x6b,0x72,0xff,0x72,0x15,0x2f,0x15,0x6b,0xef,0x6b, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x51,0xb5,0x51,0x0,0x0,0x0, +0x38,0x7d,0x38,0x24,0x4f,0x24,0x47,0x9f,0x47,0x1c,0x3f,0x1c,0x4e,0xaf,0x4e, +0x15,0x2f,0x15,0x47,0x9f,0x47,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x5d,0xcf,0x5d,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c,0x1c,0x3f,0x1c, +0x47,0x9f,0x47,0x47,0x9f,0x47,0x15,0x2f,0x15,0x32,0x6f,0x32,0x47,0x9f,0x47, +0x72,0xff,0x72,0x56,0xbf,0x56,0xe,0x1f,0xe,0x5d,0xcf,0x5d,0x6b,0xef,0x6b, +0x64,0xdf,0x64,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,}; +#define TorokuOffwidth 24 +#define TorokuOffheight 16 +#define TorokuOffcspace B_RGB32 +#define TorokuOffbytesperpixel 3 + +unsigned char TorokuOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x63,0x63,0x63,0x63,0x63,0x63,0x64,0x64,0x64,0x70,0x70,0x70,0x57,0x57,0x57, +0xa3,0xa3,0xa3,0x4b,0x4b,0x4b,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xbc,0xbc,0xbc,0x25,0x25,0x25,0xbc,0xbc,0xbc,0x96,0x96,0x96,0x64,0x64,0x64, +0x64,0x64,0x64,0x64,0x64,0x64,0x96,0x96,0x96,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x57,0x57,0x57, +0x89,0x89,0x89,0x4a,0x4a,0x4a,0x3e,0x3e,0x3e,0x89,0x89,0x89,0x0,0x0,0x0, +0x7d,0x7d,0x7d,0x57,0x57,0x57,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x3e,0x3e,0x3e, +0x3e,0x3e,0x3e,0x19,0x19,0x19,0x8e,0x8e,0x8e,0x63,0x63,0x63,0x63,0x63,0x63, +0x4b,0x4b,0x4b,0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x89,0x89,0x89,0x18,0x18,0x18, +0x25,0x25,0x25,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0x63,0x63,0x63,0xc,0xc,0xc, +0x7d,0x7d,0x7d,0xc8,0xc8,0xc8,0x63,0x63,0x63,0x25,0x25,0x25,0x96,0x96,0x96, +0x89,0x89,0x89,0xaf,0xaf,0xaf,0x63,0x63,0x63,0x64,0x64,0x64,0x4a,0x4a,0x4a, +0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xa2,0xa2,0xa2,0x31,0x31,0x31,0x57,0x57,0x57,0x31,0x31,0x31, +0x31,0x31,0x31,0x32,0x32,0x32,0x31,0x31,0x31,0x57,0x57,0x57,0x18,0x18,0x18, +0x89,0x89,0x89,0xbb,0xbb,0xbb,0x70,0x70,0x70,0x0,0x0,0x0,0x96,0x96,0x96, +0x32,0x32,0x32,0x32,0x32,0x32,0x31,0x31,0x31,0x25,0x25,0x25,0x18,0x18,0x18, +0x7d,0x7d,0x7d,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xbb,0xbb,0xbb,0x96,0x96,0x96,0x7d,0x7d,0x7d,0x64,0x64,0x64,0x63,0x63,0x63, +0x64,0x64,0x64,0x64,0x64,0x64,0x63,0x63,0x63,0xaf,0xaf,0xaf,0xbb,0xbb,0xbb, +0xa2,0xa2,0xa2,0x32,0x32,0x32,0x0,0x0,0x0,0x31,0x31,0x31,0xbc,0xbc,0xbc, +0xc8,0xc8,0xc8,0x31,0x31,0x31,0x96,0x96,0x96,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x31,0x31,0x31,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96, +0x96,0x96,0x96,0x25,0x25,0x25,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa4,0xa4,0xa4, +0x83,0x83,0x83,0x0,0x0,0x0,0x83,0x83,0x83,0x89,0x89,0x89,0x64,0x64,0x64, +0x32,0x32,0x32,0x3e,0x3e,0x3e,0x25,0x25,0x25,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x31,0x31,0x31,0x32,0x32,0x32,0x31,0x31,0x31,0x32,0x32,0x32,0x31,0x31,0x31, +0xc,0xc,0xc,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa2,0xa2,0xa2,0x4b,0x4b,0x4b, +0x0,0x0,0x0,0x25,0x25,0x25,0xb0,0xb0,0xb0,0x69,0x69,0x69,0x31,0x31,0x31, +0x19,0x19,0x19,0x70,0x70,0x70,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x25,0x25,0x25,0xbb,0xbb,0xbb,0xc8,0xc8,0xc8,0x25,0x25,0x25,0xbb,0xbb,0xbb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x8f,0x8f,0x8f,0x0,0x0,0x0, +0x62,0x62,0x62,0x3e,0x3e,0x3e,0x7d,0x7d,0x7d,0x32,0x32,0x32,0x89,0x89,0x89, +0x25,0x25,0x25,0x7d,0x7d,0x7d,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xa2,0xa2,0xa2,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31, +0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31,0x31, +0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x25,0x25,0x25,0x57,0x57,0x57,0x7d,0x7d,0x7d, +0xc8,0xc8,0xc8,0x96,0x96,0x96,0x18,0x18,0x18,0xa2,0xa2,0xa2,0xbb,0xbb,0xbb, +0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,}; +#define ZenAlphaOnwidth 16 +#define ZenAlphaOnheight 16 +#define ZenAlphaOncspace B_RGB32 +#define ZenAlphaOnbytesperpixel 3 + +unsigned char ZenAlphaOnbits[] = { +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x4e,0xaf,0x4e, +0x40,0x8f,0x40,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x6b,0xef,0x6b, +0x7,0xf,0x7,0x0,0x0,0x0,0x64,0xdf,0x64,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x47,0x9f,0x47,0x15,0x2f,0x15,0x23,0x4f,0x23,0x2b,0x5f,0x2b,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x15,0x2f,0x15,0x47,0x9f,0x47,0x55,0xbf,0x55,0x7,0xf,0x7, +0x6b,0xef,0x6b,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x55,0xbf,0x55,0x7,0xf,0x7,0x6b,0xef,0x6b,0x72,0xff,0x72, +0xe,0x1f,0xe,0x40,0x8f,0x40,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x2a,0x5f,0x2a,0x31,0x6f,0x31,0x72,0xff,0x72, +0x72,0xff,0x72,0x40,0x8f,0x40,0xe,0x1f,0xe,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x6b,0xef,0x6b,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4e,0xaf,0x4e, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x39,0x7f,0x39,0x1c,0x3f,0x1c, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x2a,0x5f,0x2a, +0x1c,0x3f,0x1c,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xe,0x1f,0xe, +0x47,0x9f,0x47,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x5d,0xcf,0x5d,0x0,0x0,0x0,0x64,0xdf,0x64,0x72,0xff,0x72,0x72,0xff,0x72, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72,0x63,0xdf,0x63, +0x39,0x7f,0x39,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x40,0x8f,0x40,0x55,0xbf,0x55,0x72,0xff,0x72, +0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb,0xa0,0xa0,0xa0, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72, +0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0x72,0xff,0x72,0xeb,0xeb,0xeb, +0xa0,0xa0,0xa0,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xe9, +0xe9,0xe9,0xe9,0xe9,0xe9,0xe9,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,}; +#define ZenAlphaOffwidth 16 +#define ZenAlphaOffheight 16 +#define ZenAlphaOffcspace B_RGB32 +#define ZenAlphaOffbytesperpixel 3 + +unsigned char ZenAlphaOffbits[] = { +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xeb, +0xeb,0xeb,0xeb,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x89,0x89,0x89, +0x70,0x70,0x70,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb, +0xc,0xc,0xc,0x0,0x0,0x0,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0x7d,0x7d,0x7d,0x25,0x25,0x25,0x3e,0x3e,0x3e,0x4a,0x4a,0x4a,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x25,0x25,0x25,0x7d,0x7d,0x7d,0x96,0x96,0x96,0xc,0xc,0xc, +0xbc,0xbc,0xbc,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x96,0x96,0x96,0xc,0xc,0xc,0xbc,0xbc,0xbc,0xc8,0xc8,0xc8, +0x18,0x18,0x18,0x70,0x70,0x70,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x4b,0x4b,0x4b,0x57,0x57,0x57,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0x70,0x70,0x70,0x18,0x18,0x18,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xbb,0xbb,0xbb,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x89,0x89,0x89, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x64,0x64,0x64,0x31,0x31,0x31, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x4b,0x4b,0x4b, +0x31,0x31,0x31,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x18,0x18,0x18, +0x7d,0x7d,0x7d,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa2,0xa2,0xa2,0x0,0x0,0x0,0xaf,0xaf,0xaf,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xaf,0xaf,0xaf, +0x63,0x63,0x63,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0x70,0x70,0x70,0x96,0x96,0x96,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0,0xeb,0xeb,0xeb, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8, +0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xc8,0xa0,0xa0,0xa0, +0xeb,0xeb,0xeb,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0,0xa0, +0xa0,0xa0,0xa0,}; diff --git a/src/add-ons/input_server/methods/canna/PaletteWindow.cpp b/src/add-ons/input_server/methods/canna/PaletteWindow.cpp new file mode 100644 index 0000000000..4198e3b941 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/PaletteWindow.cpp @@ -0,0 +1,296 @@ +// +// PaletteWindow.cpp +// +// This is a part of... +// CannaIM +// version 1.0 +// (c) 1999 M.Kawamura +// + +#include "CannaCommon.h" +#include "PaletteWindow.h" +#include "canna/mfdef.h" +#include "PaletteIconImages.h" +#include +#include + +PaletteWindow::PaletteWindow( BRect rect, BLooper *looper ) + :BWindow( rect, B_EMPTY_STRING, (window_look) 25 /*B_FLOATING_WINDOW_LOOK*/, + B_FLOATING_ALL_WINDOW_FEEL, + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE | + B_AVOID_FOCUS | B_WILL_ACCEPT_FIRST_CLICK ) +{ + cannaLooper = looper; + + ResizeTo( 122, 46 ); + BRect frame = Frame(); + frame.OffsetTo( -1, -1 ); + frame.bottom += 3; + frame.right += 3; + back = new BBox( frame ); + AddChild( back ); + + BRect largerect( 0, 0, HexOnwidth - 1, HexOnheight - 1 ); + BRect smallrect( 0, 0, HiraOnwidth - 1, HiraOnheight - 1); + int32 largebytes = HexOnbytesperpixel * HexOnwidth * HexOnheight; + int32 smallbytes = HiraOnbytesperpixel * HiraOnwidth * HiraOnheight; + color_space cspace = HexOncspace; + BPicture *onpict, *offpict; + BBitmap *smallimage, *largeimage; + BMessage *msg; +//printf( "smallbytes = %d\n", smallbytes ); + smallimage = new BBitmap( smallrect, cspace ); + largeimage = new BBitmap( largerect, cspace ); + + back->MovePenTo( 0, 0 ); + + smallimage->SetBits( HiraOnbits, smallbytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( smallimage ); + onpict = back->EndPicture(); + smallimage->SetBits( HiraOffbits, smallbytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( smallimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_HenkanMode ); + HiraButton = new BPictureButton( BRect( 4, 4, 4 + HiraOnwidth - 1, 4 + HiraOnheight - 1), "hira", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( HiraButton ); + + smallimage->SetBits( KataOnbits, smallbytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( smallimage ); + onpict = back->EndPicture(); + smallimage->SetBits( KataOffbits, smallbytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( smallimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_ZenKataHenkanMode ); + KataButton = new BPictureButton( BRect( 26, 4, 26 + HiraOnwidth - 1, 4 + HiraOnheight - 1 ), "kata", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( KataButton ); + + smallimage->SetBits( ZenAlphaOnbits, smallbytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( smallimage ); + onpict = back->EndPicture(); + smallimage->SetBits( ZenAlphaOffbits, smallbytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( smallimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_ZenAlphaHenkanMode ); + ZenAlphaButton = new BPictureButton( BRect( 48, 4, 48 + HiraOnwidth - 1, 4 + HiraOnheight - 1 ), "zenalpha", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( ZenAlphaButton ); + + smallimage->SetBits( HanAlphaOnbits, smallbytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( smallimage ); + onpict = back->EndPicture(); + smallimage->SetBits( HanAlphaOffbits, smallbytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( smallimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_HanAlphaHenkanMode ); + HanAlphaButton = new BPictureButton( BRect( 70, 4, 70 + HiraOnwidth - 1, 4 + HiraOnheight - 1 ), "hanalpha", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( HanAlphaButton ); + + largeimage->SetBits( ExtendOnbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + onpict = back->EndPicture(); + largeimage->SetBits( ExtendOffbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_TourokuMode ); + ExtendButton = new BPictureButton( BRect( 94, 4, 94 + HexOnwidth -1 , 4 + HexOnheight - 1 ), "extend", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( ExtendButton ); + + largeimage->SetBits( KigoOnbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + onpict = back->EndPicture(); + largeimage->SetBits( KigoOffbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_KigoMode ); + KigoButton = new BPictureButton( BRect( 4, 26, 4 + HexOnwidth -1, 26 + HexOnheight - 1 ), "kigo", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( KigoButton ); + + largeimage->SetBits( HexOnbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + onpict = back->EndPicture(); + largeimage->SetBits( HexOffbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_HexMode ); + HexButton = new BPictureButton( BRect( 34, 26, 34 + HexOnwidth -1, 26 + HexOnheight - 1 ), "hex", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( HexButton ); + + largeimage->SetBits( BushuOnbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + onpict = back->EndPicture(); + largeimage->SetBits( BushuOffbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_BushuMode ); + BushuButton = new BPictureButton( BRect( 64, 26, 64 + HexOnwidth -1, 26 + HexOnheight - 1 ), "bushu", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( BushuButton ); + +/* + largeimage->SetBits( TorokuOnbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + onpict = back->EndPicture(); + largeimage->SetBits( TorokuOffbits, largebytes, 0, cspace ); + back->BeginPicture( new BPicture ); + back->DrawBitmap( largeimage ); + offpict = back->EndPicture(); + msg = new BMessage( MODE_CHANGED_FROM_PALETTE ); + msg->AddInt32( "mode", CANNA_MODE_ExtendMode ); + TorokuButton = new BPictureButton( BRect( 87, 26, 110, 41 ), "toroku", + offpict, onpict, msg, B_TWO_STATE_BUTTON ); + back->AddChild( TorokuButton ); +*/ + HiraButton->SetValue( B_CONTROL_ON ); + delete smallimage; + delete largeimage; + delete offpict; + delete onpict; + +} + + +void PaletteWindow::MessageReceived( BMessage *msg ) +{ + int32 mode; + switch( msg->what ) + { + case PALETTE_WINDOW_HIDE: + if ( !IsHidden() ) + Hide(); + break; + + case PALETTE_WINDOW_SHOW: + if ( IsHidden() ) + { + BRect frame = Frame(); + BRect screenrect = BScreen().Frame(); + float x, y; + + x = screenrect.right - frame.right; + y = screenrect.bottom - frame.bottom; + + if ( x < 0 ) + frame.OffsetBy( x, 0 ); + + if ( y < 0 ) + frame.OffsetBy( 0, y ); + + MoveTo( frame.left, frame.top ); + SetWorkspaces( B_CURRENT_WORKSPACE ); + Show(); + } + break; + + case MODE_CHANGED_FROM_PALETTE: + cannaLooper->PostMessage( msg ); + break; + + case PALETTE_WINDOW_BUTTON_UPDATE: + msg->FindInt32( "mode", &mode ); + AllButtonOff(); +//printf( "Palette:NewMode = %d\n", mode ); + switch( mode ) + { + case CANNA_MODE_ZenKataKakuteiMode: + case CANNA_MODE_ZenKataHenkanMode: + KataButton->SetValue( B_CONTROL_ON ); + break; + case CANNA_MODE_ZenAlphaKakuteiMode: + case CANNA_MODE_ZenAlphaHenkanMode: + ZenAlphaButton->SetValue( B_CONTROL_ON ); + break; + case CANNA_MODE_HanAlphaKakuteiMode: + case CANNA_MODE_HanAlphaHenkanMode: + HanAlphaButton->SetValue( B_CONTROL_ON ); + break; + case CANNA_MODE_ExtendMode: + case CANNA_MODE_TourokuMode: + case CANNA_MODE_TourokuHinshiMode: + case CANNA_MODE_TourokuDicMode: + case CANNA_MODE_DeleteDicMode: + case CANNA_MODE_MountDicMode: + ExtendButton->SetValue( B_CONTROL_ON ); + break; + case CANNA_MODE_KigoMode: + case CANNA_MODE_RussianMode: + case CANNA_MODE_GreekMode: + case CANNA_MODE_LineMode: + KigoButton->SetValue( B_CONTROL_ON ); + break; + case CANNA_MODE_HexMode: + HexButton->SetValue( B_CONTROL_ON ); + break; + case CANNA_MODE_BushuMode: + BushuButton->SetValue( B_CONTROL_ON ); + break; +/* + case CANNA_MODE_TourokuMode: + case CANNA_MODE_TourokuHinshiMode: + case CANNA_MODE_TourokuDicMode: + case CANNA_MODE_DeleteDicMode: + case CANNA_MODE_MountDicMode: + TorokuButton->SetValue( B_CONTROL_ON ); + break; +*/ + default: + HiraButton->SetValue( B_CONTROL_ON ); + break; + } + break; + + + default: + BWindow::MessageReceived( msg ); + } +} + +void PaletteWindow::AllButtonOff() +{ + HiraButton->SetValue( B_CONTROL_OFF ); + KataButton->SetValue( B_CONTROL_OFF ); + ZenAlphaButton->SetValue( B_CONTROL_OFF ); + HanAlphaButton->SetValue( B_CONTROL_OFF ); + ExtendButton->SetValue( B_CONTROL_OFF ); + KigoButton->SetValue( B_CONTROL_OFF ); + HexButton->SetValue( B_CONTROL_OFF ); + BushuButton->SetValue( B_CONTROL_OFF ); +// TorokuButton->SetValue( B_CONTROL_OFF ); +} + +void +PaletteWindow::FrameMoved( BPoint screenPoint ) +{ + gSettings.palette_loc = screenPoint; +} + diff --git a/src/add-ons/input_server/methods/canna/PaletteWindow.h b/src/add-ons/input_server/methods/canna/PaletteWindow.h new file mode 100644 index 0000000000..e3c4d19022 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/PaletteWindow.h @@ -0,0 +1,41 @@ +// +// PaletteWindow.h +// +// This is a part of... +// CannaIM +// version 1.0 +// (c) 1999 M.Kawamura +// + +#ifndef PALETTEWINDOW_H +#define PALETTEWINDOW_H + +#include +#include +#include +#include + +extern Preferences gSettings; + +class PaletteWindow : public BWindow +{ +private: + BLooper* cannaLooper; + BBox* back; + BPictureButton* HiraButton; + BPictureButton* KataButton; + BPictureButton* ZenAlphaButton; + BPictureButton* HanAlphaButton; + BPictureButton* ExtendButton; + BPictureButton* KigoButton; + BPictureButton* HexButton; + BPictureButton* BushuButton; + BPictureButton* TorokuButton; + void AllButtonOff(); +public: + PaletteWindow( BRect rect, BLooper* looper ); + virtual void MessageReceived( BMessage *msg ); + virtual void FrameMoved( BPoint screenPoint ); +}; + +#endif diff --git a/src/add-ons/input_server/methods/canna/lib/Jamfile b/src/add-ons/input_server/methods/canna/lib/Jamfile new file mode 100644 index 0000000000..76437e3349 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/Jamfile @@ -0,0 +1,43 @@ +SubDir OBOS_TOP src add-ons input_server methods canna lib ; + +SubDirCcFlags -x c++ -ansi -trigraphs -funsigned-char -funsigned-bitfields -Wall -Wno-multichar -Wno-ctor-dtor-privacy -pedantic -Wno-long-long -Woverloaded-virtual -D_BUILDING_CANNALIB -D_WCHAR_T ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) canna ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) rk ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ; + +StaticLibrary canna : + RKkana.c + RKroma.c + bunsetsu.c + bushu.c + chikuji.c + commondata.c + defaultmap.c + ebind.c + empty.c + engine.c + henkan.c + hex.c + ichiran.c + jishu.c + jrbind.c + kctrl.c + keydef.c + kigo.c + lisp.c + mode.c + multi.c + onoff.c + parse.c + romaji.c + uiutil.c + uldefine.c + uldelete.c + ulhinshi.c + ulkigo.c + ulmount.c + ulserver.c + util.c + yesno.c +; diff --git a/src/add-ons/input_server/methods/canna/lib/RKkana.c b/src/add-ons/input_server/methods/canna/lib/RKkana.c new file mode 100644 index 0000000000..bae6453b80 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/RKkana.c @@ -0,0 +1,1199 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="@(#) 102.1 $Id: RKkana.c,v 1.1 2004/12/23 21:23:48 korli Exp $"; +#endif + +/* LINTLIBRARY */ +#include "canna.h" +#include "RKintern.h" + + +/* RkCvtZen + * hankaku moji wo zenkaku moji ni suru + */ +static +unsigned short +hiragana[] = +{ +/* 0x00 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/* 0x10 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/* 0x20 */ + 0xa1a1, 0xa1aa, 0xa1ed, 0xa1f4, 0xa1f0, 0xa1f3, 0xa1f5, 0xa1c7, + 0xa1ca, 0xa1cb, 0xa1f6, 0xa1dc, 0xa1a4, 0xa1dd, 0xa1a5, 0xa1bf, +/* 0x30 */ + 0xa3b0, 0xa3b1, 0xa3b2, 0xa3b3, 0xa3b4, 0xa3b5, 0xa3b6, 0xa3b7, + 0xa3b8, 0xa3b9, 0xa1a7, 0xa1a8, 0xa1e3, 0xa1e1, 0xa1e4, 0xa1a9, +/* 0x40 */ + 0xa1f7, 0xa3c1, 0xa3c2, 0xa3c3, 0xa3c4, 0xa3c5, 0xa3c6, 0xa3c7, + 0xa3c8, 0xa3c9, 0xa3ca, 0xa3cb, 0xa3cc, 0xa3cd, 0xa3ce, 0xa3cf, +/* 0x50 */ + 0xa3d0, 0xa3d1, 0xa3d2, 0xa3d3, 0xa3d4, 0xa3d5, 0xa3d6, 0xa3d7, + 0xa3d8, 0xa3d9, 0xa3da, 0xa1ce, 0xa1ef, 0xa1cf, 0xa1b0, 0xa1b2, +/* 0x60 */ + 0xa1c6, 0xa3e1, 0xa3e2, 0xa3e3, 0xa3e4, 0xa3e5, 0xa3e6, 0xa3e7, + 0xa3e8, 0xa3e9, 0xa3ea, 0xa3eb, 0xa3ec, 0xa3ed, 0xa3ee, 0xa3ef, +/* 0x70 */ + 0xa3f0, 0xa3f1, 0xa3f2, 0xa3f3, 0xa3f4, 0xa3f5, 0xa3f6, 0xa3f7, + 0xa3f8, 0xa3f9, 0xa3fa, 0xa1d0, 0xa1c3, 0xa1d1, 0xa1c1, 0xa2a2, +/*0x80 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x90 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0xa0 */ + 0xa1a1, 0xa1a3, 0xa1d6, 0xa1d7, 0xa1a2, 0xa1a6, 0xa4f2, 0xa4a1, + 0xa4a3, 0xa4a5, 0xa4a7, 0xa4a9, 0xa4e3, 0xa4e5, 0xa4e7, 0xa4c3, +/*0xb0 */ + 0xa1bc, 0xa4a2, 0xa4a4, 0xa4a6, 0xa4a8, 0xa4aa, 0xa4ab, 0xa4ad, + 0xa4af, 0xa4b1, 0xa4b3, 0xa4b5, 0xa4b7, 0xa4b9, 0xa4bb, 0xa4bd, +/*0xc0 */ + 0xa4bf, 0xa4c1, 0xa4c4, 0xa4c6, 0xa4c8, 0xa4ca, 0xa4cb, 0xa4cc, + 0xa4cd, 0xa4ce, 0xa4cf, 0xa4d2, 0xa4d5, 0xa4d8, 0xa4db, 0xa4de, +/*0xd0 */ + 0xa4df, 0xa4e0, 0xa4e1, 0xa4e2, 0xa4e4, 0xa4e6, 0xa4e8, 0xa4e9, + 0xa4ea, 0xa4eb, 0xa4ec, 0xa4ed, 0xa4ef, 0xa4f3, 0xa1ab, 0xa1ac, +/* 0xe0 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/* 0xf0 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +}; +static +unsigned short +hankaku[] = { +/*0x00*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x10*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x20*/ + 0x0000, ' ', 0x8ea4, 0x8ea1, ',', '.', 0x8ea5, ':', + ';', '?', '!', 0x8ede, 0x8edf, 0x0000, 0x0000, 0x0000, +/*0x30*/ + '^', 0x0000, '_', 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x8eb0, 0x0000, 0x0000, '/', +/*0x40*/ + 0x0000, '~', 0x0000, '|', 0x0000, 0x0000, '\'', '\'', + '"', '"', '(', ')', '[', ']', '[', ']', +/*0x50*/ + '{', '}', 0x0000, 0x0000, 0x0000, 0x0000, 0x8ea2, 0x8ea3, + 0x0000, 0x0000, 0x0000, 0x0000, '+', '-', 0x0000, 0x0000, +/*0x60*/ + 0x0000, '=', 0x0000, '<', '>', 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, '\\', +/*0x70*/ + '$',0x0000, 0x0000, '%', '#', '&', '*', '@', + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x80*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x90*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0xa0*/ + 0x0020, 0x00a7, 0x00b1, 0x00a8, 0x00b2, 0x00a9, 0x00b3, 0x00aa, + 0x00b4, 0x00ab, 0x00b5, 0x00b6, 0xb6de, 0x00b7, 0xb7de, 0x00b8, +/*0xb0*/ + 0xb8de, 0x00b9, 0xb9de, 0x00ba, 0xbade, 0x00bb, 0xbbde, 0x00bc, + 0xbcde, 0x00bd, 0xbdde, 0x00be, 0xbede, 0x00bf, 0xbfde, 0x00c0, +/*0xc0*/ + 0xc0de, 0x00c1, 0xc1de, 0x00af, 0x00c2, 0xc2de, 0x00c3, 0xc3de, + 0x00c4, 0xc4de, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, +/*0xd0*/ + 0xcade, 0xcadf, 0x00cb, 0xcbde, 0xcbdf, 0x00cc, 0xccde, 0xccdf, + 0x00cd, 0xcdde, 0xcddf, 0x00ce, 0xcede, 0xcedf, 0x00cf, 0x00d0, +/*0xe0*/ + 0x00d1, 0x00d2, 0x00d3, 0x00ac, 0x00d4, 0x00ad, 0x00d5, 0x00ae, + 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dc, +/*0xf0*/ + 0x00b2, 0x00b4, 0x00a6, 0x00dd, 0xb3de, 0x00b6, 0x00b9, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +}; + +#ifdef OBSOLETE_RKKANA + +#define ADDCODE(dst, maxdst, count, code, length) {\ + if ( (unsigned long)(length) <= (unsigned long)(maxdst) ) {\ + (maxdst) -= (length); (count) += (length);\ + if ( (dst) ) {\ + (dst) += (length);\ + switch((length)) {\ + case 4: *--(dst) = (code)&255; (code) >>= 8;\ + case 3: *--(dst) = (code)&255; (code) >>= 8;\ + case 2: *--(dst) = (code)&255; (code) >>= 8;\ + case 1: *--(dst) = (code)&255; (code) >>= 8;\ + };\ + (dst) += (length);\ + };\ + };\ +} + +#else /* !OBSOLETE_RKKANA */ + +static int _ADDCODE(unsigned char *dst, int maxdst, int count, unsigned long code, int length); + +static int +_ADDCODE(unsigned char *dst, int maxdst, int count, unsigned long code, int length) +{ + if ((unsigned long)length <= (unsigned long)maxdst) { + maxdst -= length; + count += length; + if (dst) { + dst += length; + switch (length) { + case 4: *--dst = (unsigned char)code; code >>= 8; + case 3: *--dst = (unsigned char)code; code >>= 8; + case 2: *--dst = (unsigned char)code; code >>= 8; + case 1: *--dst = (unsigned char)code; code >>= 8; + } + } + return length; + } + return 0; +} + +#define ADDCODE(dst, maxdst, count, code, length) \ +{ int llen = _ADDCODE(dst, maxdst, count, (unsigned long)code, length); \ + if (llen > 0 && (dst)) { (dst) += llen; (maxdst) -= llen; (count) += llen; }} + +#define ADDWCODE(dst, maxdst, count, code) {\ + if ( (maxdst) > 0 ) {\ + (maxdst)-- ; (count)++ ;\ + if ( (dst) ) {\ + *(dst)++ = (code);\ + }\ + }\ +} + +#endif /* !OBSOLETE_RKKANA */ + +/* RkCvtZen + * hankaku moji(ASCII+katakana) wo taiou suru zenkaku moji ni suru + * dakuten,handakuten shori mo okonau. + */ +int +RkCvtZen(unsigned char *zen, int maxzen, unsigned char *han, int maxhan) +{ + unsigned char *z = zen; + unsigned char *h = han; + unsigned char *H = han + maxhan; + unsigned short hi, lo; + unsigned byte; + int count = 0; + unsigned long code; + + if ( --maxzen <= 0 ) + return count; + while ( h < H ) { + hi = *h++; + byte = 2; + if ( hi == 0x8e ) { /* hankaku katakana */ + if ( !(code = hiragana[lo = *h++]) ) + code = (hi<<8)|lo; + byte = (code>>8) ? 2 : 1; + if ( (code>>8) == 0xa4 ) { + code |= 0x100; + /* dakuten/handakuten ga tuku baai */ + if ( h + 1 < H && h[0] == 0x8e ) { + lo = h[1]; + switch(code&255) { + /* u */ case 0xa6: + if ( lo == 0xde ) code = 0xa5f4, h += 2; + break; + /* ha */case 0xcf: case 0xd2: case 0xd5: case 0xd8: case 0xdb: + if ( lo == 0xdf ) { + code += 2, h += 2; + break; + }; + /* ka */case 0xab: case 0xad: case 0xaf: case 0xb1: case 0xb3: + /* sa */case 0xb5: case 0xb7: case 0xb9: case 0xbb: case 0xbd: + /* ta */case 0xbf: case 0xc1: case 0xc4: case 0xc6: case 0xc8: + if ( lo == 0xde ) { + code += 1, h += 2; + break; + }; + }; + }; + }; + } + else if (hi == 0x8f) { + ADDCODE(z, maxzen, count, hi, 1); + code = (((unsigned long)h[0]) << 8) + | ((unsigned long)h[1]); h += 2; + byte = 2; + } + else if ( hi & 0x80 ) + code = (hi<<8)|*h++; + else { + if ( !(code = hiragana[hi]) ) + code = hi; + byte = (code>>8) ? 2 : 1; + } + ADDCODE(z, maxzen, count, code, byte); + }; + if ( z ) + *z = 0; + return count; +} +/* RkCvtHan + * zenkaku kana moji wo hankaku moji ni suru + */ +int +RkCvtHan(unsigned char *han, int maxhan, unsigned char *zen, int maxzen) +{ + unsigned char *h = han; + unsigned char *z = zen; + unsigned char *Z = zen + maxzen; + unsigned short hi, lo; + unsigned short byte; + int count = 0; + unsigned long code; + + if ( --maxhan <= 0 ) + return 0; + while ( z < Z ) { + hi = *z++; + byte = 1; + switch(hi) { + case 0xa1: /* kigou */ + lo = *z++; + if ( !(code = hankaku[lo&0x7f]) ) + code = (hi<<8)|lo; + byte = (code>>8) ? 2 : 1; + break; + case 0xa3: /* eisuuji */ + lo = *z++; + if ( 0xb0 <= lo && lo <= 0xb9 ) code = (lo - 0xb0) + '0'; + else + if ( 0xc1 <= lo && lo <= 0xda ) code = (lo - 0xc1) + 'A'; + else + if ( 0xe1 <= lo && lo <= 0xfa ) code = (lo - 0xe1) + 'a'; + else + code = (hi<<8)|lo, byte = 2; + break; + case 0xa4: /* hiragana */ + case 0xa5: /* katakana */ + lo = *z++; + if ( (code = hankaku[lo]) && + (lo <= (unsigned short)(hi==0xa4 ? 0xf3: 0xf6)) ) { + if ( code>>8 ) { + code = 0x8e000000|((code>>8)<<16)|0x00008e00|(code&255); + byte = 4; + } + else { + code = 0x00008e00|(code&255); + byte = 2; + }; + } + else + code = (hi<<8)|lo, byte = 2; + break; + default: + if (hi == 0x8f) { + ADDCODE(h, maxhan, count, hi, 1); + code = (((unsigned long)z[0]) << 8) + | ((unsigned long)z[1]); z += 2; + byte = 2; + } + else if ( hi & 0x80 ) { /* kanji */ + code = (hi<<8)|(*z++); + byte = 2; + } + else + switch(hi) { + /* + case ',': code = 0x8ea4; byte = 2; break; + case '-': code = 0x8eb0; byte = 2; break; + case '.': code = 0x8ea1; byte = 2; break; + */ + default: code = hi; break; + }; + break; + }; + ADDCODE(h, maxhan, count, code, byte); + }; + if ( h ) + *h = 0; + return count; +} +/* RkCvtKana/RkCvtHira + * zenkaku hiragana wo katakana ni suru + */ +int +RkCvtKana(unsigned char *kana, int maxkana, unsigned char *hira, int maxhira) +{ + register unsigned char *k = kana; + register unsigned char *h = hira; + register unsigned char *H = hira + maxhira; + unsigned short hi; + unsigned short byte; + int count = 0; + unsigned long code; + + if ( --maxkana <= 0 ) + return 0; + while ( h < H ) { + hi = *h++; + if (hi == 0x8f) { + ADDCODE(k, maxkana, count, hi, 1); + code = (((unsigned long)h[0]) << 8) + | ((unsigned long)h[1]); h += 2; + byte = 2; + } + else if ( hi & 0x80 ) { + int dakuon; + + code = (hi == 0xa4) ? (0xa500|(*h++)) : ((hi<<8)|(*h++)); + byte = 2; + /* hiragana U + " */ + dakuon = ( h + 1 < H && + ((((unsigned long)h[0])<<8)|((unsigned long)h[1])) == 0xa1ab ); + if ( hi == 0xa4 && code == 0xa5a6 && dakuon ) { + code = 0xa5f4; + h += 2; + }; + } + else + code = hi, byte = 1; + ADDCODE(k, maxkana, count, code, byte); + }; + if ( k ) + *k = 0; + return count; +} +int +RkCvtHira(unsigned char *hira, int maxhira, unsigned char *kana, int maxkana) +{ + register unsigned char *h = hira; + register unsigned char *k = kana; + register unsigned char *K = kana + maxkana; + unsigned short hi; + unsigned short byte; + int count = 0; + unsigned long code; + + if ( --maxhira <= 0 ) + return 0; + while ( k < K ) { + hi = *k++; + if (hi == 0x8f) { + ADDCODE(h, maxhira, count, hi, 1); + code = (((unsigned long)k[0]) << 8) + | ((unsigned long)k[1]); k += 2; + byte = 2; + } + else if ( hi & 0x80 ) { + code = (hi == 0xa5) ? (0xa400|(*k++)) : ((hi<<8)|(*k++)); + byte = 2; + /* katakana U + " */ + if ( code == 0xa4f4 ) { /* u no dakuon */ + code = 0xa4a6a1ab; + byte = 4; + } + else + if ( code == 0xa4f5 ) + code = 0xa4ab; + else + if ( code == 0xa4f6 ) + code = 0xa4b1; + } + else + code = hi, byte = 1; + ADDCODE(h, maxhira, count, code, byte); + }; + if ( h ) + *h = 0; + return count; +} +int +RkCvtNone(unsigned char *dst, int maxdst, unsigned char *src, int maxsrc) +{ + register unsigned char *d = dst; + register unsigned char *s = src; + register unsigned char *S = src + maxsrc; + unsigned short byte; + int count = 0; + unsigned long code; + + if ( --maxdst <= 0 ) + return 0; + while ( s < S ) { + code = *s++; + byte = 1; + if (code == 0x8f) { + ADDCODE(d, maxdst, count, code, 1); + code = (((unsigned long)s[0]) << 8) + | ((unsigned long)s[1]); s += 2; + byte = 2; + } + else if ( code & 0x80 ) + code = (code<<8)|(*s++), byte = 2; + ADDCODE(d, maxdst, count, code, byte); + }; + if ( d ) + *d = 0; + return count; +} + +/* RkEuc + * shift jis --> euc + */ +int +RkCvtEuc(unsigned char *euc, int maxeuc, unsigned char *sj, int maxsj) +{ + unsigned char *e = euc; + unsigned char *s = sj; + unsigned char *S = sj + maxsj; + unsigned short hi, lo; + unsigned short byte; + int count = 0; + unsigned long code; + + if ( --maxeuc <= 0 ) + return 0; + + while ( s < S ) { + hi = *s++; + if ( hi <= 0x7f ) /* ascii */ + code = hi, byte = 1; + else + if ( 0xa0 <= hi && hi <= 0xdf ) /* hankaku katakana */ + code = 0x8e00|hi, byte = 2; + else + if (0xf0 <= hi && hi <= 0xfc) { /* gaiji */ + hi -= 0xf0; + hi = 2*hi + 0x21; + if ((lo = *s++) <= 0x9e) { + if (lo < 0x80) + lo++; + lo -= 0x20; + } + else { + hi++; + lo -= 0x7e; + } + code = 0x8f8080 | (hi<<8) | lo, byte = 3; + } + else { + hi -= (hi <= 0x9f) ? 0x80 : 0xc0; + hi = 2*hi + 0x20; + if ( (lo = *s++) <= 0x9e ) { /* kisuu ku */ + hi--; + if ( 0x80 <= lo ) lo--; + lo -= (0x40 - 0x21); + } + else /* guusuu ku */ + lo -= (0x9f - 0x21); + code = 0x8080|(hi<<8)|lo, byte = 2; + }; + ADDCODE(e, maxeuc, count, code, byte); + }; + if ( e ) + *e = 0; + return count; +} +/* RkCvtSuuji + * arabia suuji wo kansuuji ni kaeru + */ +static unsigned suujinew[] = { + 0xa1bb, 0xb0ec, 0xc6f3, 0xbbb0, 0xbbcd, + 0xb8de, 0xcfbb, 0xbcb7, 0xc8ac, 0xb6e5, +}; +static unsigned suujiold[] = { + 0xa1bb, 0xb0ed, 0xc6f5, 0xbbb2, 0xbbcd, + 0xb8e0, 0xcfbb, 0xbcb7, 0xc8ac, 0xb6e5, +}; +static unsigned kurai4[] = { + 0, 0xcbfc, 0xb2af, 0xc3fb, 0xb5fe, 0, +}; + +static unsigned kurai3new[] = { 0, 0xbdbd, 0xc9b4, 0xc0e9, }; +static unsigned kurai3old[] = { 0, 0xbdbd, 0xc9b4, 0xc0e9, }; + +int +RkCvtSuuji(unsigned char *dst, int maxdst, unsigned char *src, int maxsrc, int format) +{ + int count; + int i, j, k; + int digit[4], pend; + unsigned code, tmp; + unsigned char *d = dst; + unsigned char *s = src + maxsrc - 1; + + if ( --maxdst <= 0 ) + return 0; +/* yuukou keta suu wo kazoeru */ + pend = 0; + for ( count = k = 0; s >= src; k++ ) { + int dec; + + if ( *s & 0x80 ) { + if ( !(0xb0 <= *s && *s <= 0xb9) ) + break; + dec = *s - 0xb0; + if ( --s < src || *s != 0xa3 ) + break; + s--; + } + else { + if ( !('0' <= *s && *s <= '9') ) + break; + dec = *s-- - '0'; + }; + + switch(format) { + /* simple */ + case 0: /* sanyou suuji */ + code = hiragana[dec + '0']; + ADDCODE(d, maxdst, count, code, 2); + break; + case 1: /* kanji suuji */ + code = suujinew[dec]; + ADDCODE(d, maxdst, count, code, 2); + break; + /* kanji kurai dori */ + case 2: + case 3: + case 4: /* 12 O 3456 M 7890 */ + digit[pend++] = dec; + if ( pend == 4 ) { + while ( pend > 0 && digit[pend - 1] == 0 ) + pend--; + if ( pend ) { + /* kurai wo shuturyoku */ + code = kurai4[k/4]; + if (code) + ADDCODE(d, maxdst, count, code, 2) + else + if ( k >= 4 ) + return 0; + + for ( i = 0; i < pend; i++ ) + switch(format) { + case 2: + if ( digit[i] ) { + code = kurai3new[i]; + if (code) + ADDCODE(d, maxdst, count, code, 2); + if ( i == 0 || (digit[i] > 1) ) { + code = suujinew[digit[i]]; + ADDCODE(d, maxdst, count, code, 2); + }; + }; + break; + case 3: + if ( digit[i] ) { + code = kurai3old[i]; + if (code) + ADDCODE(d, maxdst, count, code, 2); + code = suujiold[digit[i]]; + ADDCODE(d, maxdst, count, code, 2); + }; + break; + case 4: + code = hiragana[digit[i]+'0']; + ADDCODE(d, maxdst, count, code, 2); + break; + }; + }; + pend = 0; + }; + break; + case 5: /* 1,234,567,890 */ + if ( k && k%3 == 0 ) { + code = hiragana[',']; + ADDCODE(d, maxdst, count, code, 2); + }; + code = hiragana[dec + '0']; + ADDCODE(d, maxdst, count, code, 2); + break; + default: + return 0; + }; + }; + + if ( format == 2 || format == 3 || format == 4 ) { + while ( pend > 0 && digit[pend - 1] == 0 ) + pend--; + if ( pend ) { + code = kurai4[k/4]; + if (code) + ADDCODE(d, maxdst, count, code, 2) + else + if ( k >= 4 ) + return 0; + for ( i = 0; i < pend; i++ ) + switch(format) { + case 2: + if ( digit[i] ) { + code = kurai3new[i]; + if (code) + ADDCODE(d, maxdst, count, code, 2); + if ( i == 0 || (digit[i] > 1) ) { + code = suujinew[digit[i]]; + ADDCODE(d, maxdst, count, code, 2); + }; + }; + break; + case 3: + if ( digit[i] ) { + code = kurai3old[i]; + if (code) + ADDCODE(d, maxdst, count, code, 2); + code = suujiold[digit[i]]; + ADDCODE(d, maxdst, count, code, 2); + }; + break; + case 4: + code = hiragana[digit[i]+'0']; + ADDCODE(d, maxdst, count, code, 2); + break; + }; + }; + }; + + if ( dst ) { + *d = 0; + for ( i = 0, j = count - 1; i < j; i++, j-- ) { + tmp = dst[i]; dst[i] = dst[j]; dst[j] = tmp; + }; + for ( i = count - 1; i > 0; i-- ) + if ( dst[i] & 0x80 ) { + tmp = dst[i+0]; dst[i+0] = dst[i-1]; dst[i-1] = tmp; + i--; + }; + }; + return count; +} + +/* ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿ */ + +#define CBUFSIZE 512 + +RkwCvtHan(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int len = 0; +#ifndef WIN + char cbuf[CBUFSIZE], cbuf2[CBUFSIZE]; +#else + char *cbuf, *cbuf2; + + cbuf = malloc(CBUFSIZE); + cbuf2 = malloc(CBUFSIZE); + if (!cbuf || !cbuf2) { + if (cbuf) { + free(cbuf); + } + if (cbuf2) { + free(cbuf2); + } + return len; + } +#endif + + len = CNvW2E(src, srclen, cbuf, CBUFSIZE); + len = RkCvtHan((unsigned char *)cbuf2, CBUFSIZE, (unsigned char *)cbuf, len); + if (len > 0) { + cbuf2[len] = '\0'; + len = MBstowcs(dst, cbuf2, maxdst); + } +#ifdef WIN + free(cbuf2); + free(cbuf); +#endif + return len; +} + +RkwCvtHira(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int len = 0; +#ifndef WIN + char cbuf[CBUFSIZE], cbuf2[CBUFSIZE]; +#else + char *cbuf, *cbuf2; + + cbuf = malloc(CBUFSIZE); + cbuf2 = malloc(CBUFSIZE); + if (!cbuf || !cbuf2) { + if (cbuf) { + free(cbuf); + } + if (cbuf2) { + free(cbuf2); + } + return len; + } +#endif + + len = CNvW2E(src, srclen, cbuf, CBUFSIZE); + len = RkCvtHira((unsigned char *)cbuf2, CBUFSIZE, + (unsigned char *)cbuf, len); + if (len > 0) { + cbuf2[len] = (unsigned char)0; + len = MBstowcs(dst, cbuf2, maxdst); + } +#ifdef WIN + free(cbuf2); + free(cbuf); +#endif + return len; +} + +RkwCvtKana(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int len = 0; +#ifndef WIN + char cbuf[CBUFSIZE], cbuf2[CBUFSIZE]; +#else + char *cbuf, *cbuf2; + + cbuf = malloc(CBUFSIZE); + cbuf2 = malloc(CBUFSIZE); + if (!cbuf || !cbuf2) { + if (cbuf) { + free(cbuf); + } + if (cbuf2) { + free(cbuf2); + } + return len; + } +#endif + + len = CNvW2E(src, srclen, cbuf, CBUFSIZE); + len = RkCvtKana((unsigned char *)cbuf2, CBUFSIZE, + (unsigned char *)cbuf, len); + if (len > 0) { + cbuf2[len] = '\0'; + len = MBstowcs(dst, cbuf2, maxdst); + } +#ifdef WIN + free(cbuf2); + free(cbuf); +#endif + return len; +} + +RkwCvtZen(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int len = 0; +#ifndef WIN + char cbuf[CBUFSIZE], cbuf2[CBUFSIZE]; +#else + char *cbuf, *cbuf2; + + cbuf = malloc(CBUFSIZE); + cbuf2 = malloc(CBUFSIZE); + if (!cbuf || !cbuf2) { + if (cbuf) { + free(cbuf); + } + if (cbuf2) { + free(cbuf2); + } + return len; + } +#endif + + len = CNvW2E(src, srclen, cbuf, CBUFSIZE); + len = RkCvtZen((unsigned char *)cbuf2, CBUFSIZE, + (unsigned char *)cbuf, len); + if (len > 0) { + cbuf2[len] = '\0'; + len = MBstowcs(dst, cbuf2, maxdst); + } +#ifdef WIN + free(cbuf2); + free(cbuf); +#endif + return len; +} + +int +RkwCvtNone(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int i; + + if(!dst || !src) return 0; + + int len = (maxdst < srclen) ? maxdst : srclen; + for (int i = 0 ; i < len ; i++) { + *dst++ = *src++; + } +/* *dst = *src; ¤Ê¤ó¤Ç¤³¤ì¤¬É¬ÍפʤΡ© */ + return len; +} + +int +RkwMapRoma(struct RkRxDic *romaji, WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen, int flags, int *status) +{ + int len = 0, ret; + char cbuf1[CBUFSIZE], cbuf2[CBUFSIZE]; + + len = CNvW2E(src, srclen, cbuf1, CBUFSIZE); + len = RkMapRoma(romaji, (unsigned char *)cbuf2, CBUFSIZE, + (unsigned char *)cbuf1, len, flags, status); + cbuf2[(*status > 0) ? *status : -*status] = (unsigned char)0; + ret = MBstowcs(dst, cbuf2, maxdst); + if (*status > 0) { + *status = ret; + } + else { + *status = -ret; + } + + return len; +} + +int +RkwMapPhonogram(struct RkRxDic *romaji, WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen, WCHAR_T key, int flags, int *ulen, int *dlen, int *tlen, int *rule) +{ + int status = 0; + char tmpch; + int len, ret, fdlen, fulen, ftlen; + char cbuf1[CBUFSIZE], cbuf2[CBUFSIZE]; + WCHAR_T wbuf[CBUFSIZE]; + + len = CNvW2E(src, srclen, cbuf1, CBUFSIZE); + status = RkMapPhonogram(romaji, (unsigned char *)cbuf2, CBUFSIZE, + (unsigned char *)cbuf1, len, + (unsigned) key, flags, + &fulen, &fdlen, &ftlen, rule); + tmpch = cbuf2[fdlen]; + cbuf2[fdlen] = '\0'; + ret = MBstowcs(dst, cbuf2, maxdst); + cbuf2[fdlen] = tmpch; + if (dlen) { + *dlen = ret; + } + cbuf2[fdlen + ftlen] = (unsigned char)0; + ret = MBstowcs(dst + ret, cbuf2 + fdlen, maxdst - ret); + if (tlen) { + *tlen = ret; + } + if (ulen) { + cbuf1[fulen] = '\0'; + *ulen = MBstowcs(wbuf, cbuf1, CBUFSIZE); + } + + return status; +} + +int +RkwCvtRoma(struct RkRxDic *romaji, WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen, int flags) +{ + int ret = 0, len; + char cbuf1[CBUFSIZE], cbuf2[CBUFSIZE]; + + if (srclen) { + len = CNvW2E(src, srclen, cbuf1, CBUFSIZE); + len = RkCvtRoma(romaji, (unsigned char *)cbuf2, CBUFSIZE, + (unsigned char *)cbuf1, len, flags); + cbuf2[len] = (unsigned char)0; + ret = MBstowcs(dst, cbuf2, maxdst); + dst[ret] = (WCHAR_T)0; + } else { + ret = 0; + *dst = (WCHAR_T)0; + } + + return ret; +} + +#define SUUJI_THROUGH 0 +#define SUUJI_HANKAKU 1 +#define SUUJI_ZENKAKU 2 +#define SUUJI_SIMPLEKANJI 3 +#define SUUJI_FULLKANJI 4 +#define SUUJI_FULLKANJITRAD 5 +#define SUUJI_WITHKANJIUNIT 6 +#define SUUJI_WITHCOMMA 7 + +/* RkCvtSuuji + * arabia suuji wo kansuuji ni kaeru + */ +int +RkwCvtSuuji(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format) +{ + int count; + int i, j, k; + int digit[4], pend; + WCHAR_T code, tmp; + WCHAR_T *d = dst; + WCHAR_T *s = src + maxsrc - 1; + + if ( --maxdst <= 0 ) + return 0; + /* Í­¸ú¤Ê·å¿ô¤ò¿ô¤¨¤ë */ + pend = 0; + for ( count = k = 0; s >= src; k++ ) { + int dec, thru = *s; + + if ( thru & 0x8080 ) { + if ( !((WCHAR_T)0xa3b0 <= *s && *s <= (WCHAR_T)0xa3b9) ) + break; + dec = *s-- - 0xa3b0; + } + else { + if ( !((WCHAR_T)'0' <= *s && *s <= (WCHAR_T)'9') ) + break; + dec = *s-- - '0'; + } + + switch(format) { + /* simple */ + case SUUJI_THROUGH: /* sanyou suuji */ + code = thru; + ADDWCODE(d, maxdst, count, code); + break; + case SUUJI_HANKAKU: /* sanyou suuji */ + code = dec + '0'; + if (code == thru) { + return 0; + } + ADDWCODE(d, maxdst, count, code); + break; + case SUUJI_ZENKAKU: /* sanyou suuji */ + code = hiragana[dec + '0']; + if (code == thru) { + return 0; + } + ADDWCODE(d, maxdst, count, code); + break; + /* kanji kurai dori */ + case SUUJI_SIMPLEKANJI: /* kanji suuji */ + code = suujinew[dec]; + ADDWCODE(d, maxdst, count, code); + break; + case SUUJI_FULLKANJI: + case SUUJI_FULLKANJITRAD: + case SUUJI_WITHKANJIUNIT: /* 12 O 3456 M 7890 */ + digit[pend++] = dec; + if ( pend == 4 ) { + while ( pend > 0 && digit[pend - 1] == 0 ) + pend--; + if ( pend ) { + /* kurai wo shuturyoku */ + code = kurai4[k/4]; + if (code) + ADDWCODE(d, maxdst, count, code) + else + if ( k >= 4 ) + return 0; + + for ( i = 0; i < pend; i++ ) + switch(format) { + case SUUJI_FULLKANJI: + if ( digit[i] ) { + code = kurai3new[i]; + if (code) + ADDWCODE(d, maxdst, count, code); + if ( i == 0 || (digit[i] > 1) ) { + code = suujinew[digit[i]]; + ADDWCODE(d, maxdst, count, code); + } + } + break; + case SUUJI_FULLKANJITRAD: + if ( digit[i] ) { + code = kurai3old[i]; + if (code) + ADDWCODE(d, maxdst, count, code); + code = suujiold[digit[i]]; + ADDWCODE(d, maxdst, count, code); + }; + break; + case SUUJI_WITHKANJIUNIT: + code = hiragana[digit[i]+'0']; + ADDWCODE(d, maxdst, count, code); + break; + } + } + pend = 0; + } + break; + case SUUJI_WITHCOMMA: /* 1,234,567,890 */ + if ( k && k%3 == 0 ) { + code = hiragana[',']; + ADDWCODE(d, maxdst, count, code); + } + code = hiragana[dec + '0']; + ADDWCODE(d, maxdst, count, code); + break; + default: + return 0; + }; + }; + + if (format == SUUJI_FULLKANJI || format == SUUJI_FULLKANJITRAD || + format == SUUJI_WITHKANJIUNIT) { + while ( pend > 0 && digit[pend - 1] == 0 ) + pend--; + if ( pend ) { + code = kurai4[k/4]; + if (code) + ADDWCODE(d, maxdst, count, code) + else + if ( k >= 4 ) + return 0; + for ( i = 0; i < pend; i++ ) + switch(format) { + case SUUJI_FULLKANJI: + if ( digit[i] ) { + code = kurai3new[i]; + if (code) + ADDWCODE(d, maxdst, count, code); + if ( i == 0 || (digit[i] > 1) ) { + code = suujinew[digit[i]]; + ADDWCODE(d, maxdst, count, code); + }; + }; + break; + case SUUJI_FULLKANJITRAD: + if ( digit[i] ) { + code = kurai3old[i]; + if (code) + ADDWCODE(d, maxdst, count, code); + code = suujiold[digit[i]]; + ADDWCODE(d, maxdst, count, code); + }; + break; + case SUUJI_WITHKANJIUNIT: + code = hiragana[digit[i]+'0']; + ADDWCODE(d, maxdst, count, code); + break; + } + } + } + + if ( dst ) { + *d = 0; + for ( i = 0, j = count - 1; i < j; i++, j-- ) { + tmp = dst[i]; dst[i] = dst[j]; dst[j] = tmp; + } + } + return count; +} +/* RkCvtNarrow + * + */ +int +RkCvtNarrow(char *dst, int maxdst, WCHAR_T *src, int maxsrc) +{ +#ifdef USE_SJIS_TEXT_DIC + return Wcstosjis(dst, maxdst, src, maxsrc); +#else /* !USE_SJIS_TEXT_DIC */ + unsigned char *d = (unsigned char *)dst; + WCHAR_T *s = src; + WCHAR_T *S = src + maxsrc; + int count = 0; + long code; + int byte; + + if ( --maxdst <= 0 ) + return count; + while ( s < S ) + { + code = *s++; + switch(code&0x8080) + { + case 0x0000: + code &= 0xff; + byte = 1; + break; + case 0x0080: + code &= 0xff; + code |= 0x8e00; + byte = 2; + break; + case 0x8000: + code &= 0xffff; + code |= 0x8f8080; + byte = 3; + break; + case 0x8080: + code &= 0xffff; + byte = 2; + break; + }; + ADDCODE(d, maxdst, count, code, byte); + }; + if ( d ) + *d = 0; + return count; +#endif /* !USE_SJIS_TEXT_DIC */ +} + +/* RkCvtWide + * + */ +int +RkCvtWide(WCHAR_T *dst, int maxdst, char *src, int maxsrc) +{ +#ifdef USE_SJIS_TEXT_DIC + return SJistowcs(dst, maxdst, src, maxsrc); +#else /* !USE_SJIS_TEXT_DIC, that is, EUC */ + WCHAR_T *d = dst; + unsigned char *s = (unsigned char *)src; + unsigned char *S = (unsigned char *)src + maxsrc; + int count = 0; + unsigned long code; + + if ( --maxdst <= 0 ) + return count; + while ( s < S ) + { + code = *s++; + if ( code & 0x80 ) + { + switch(code) + { + case RK_SS2: /* hankaku katakana */ + code = 0x0080|(s[0]&0x7f); + s++; + break; + case RK_SS3: /* gaiji */ + code = 0x8000|(((s[0]<<8)|s[1])&0x7f7f); + s += 2; + break; + default: + code = 0x8080|(((s[-1]<<8)|s[0])&0x7f7f); + s += 1; + }; + }; + ADDWCODE(d, maxdst, count, (WCHAR_T)code); + }; + if ( d ) + *d = 0; + return count; +#endif /* !USE_SJIS_TEXT_DIC */ +} + diff --git a/src/add-ons/input_server/methods/canna/lib/RKroma.c b/src/add-ons/input_server/methods/canna/lib/RKroma.c new file mode 100644 index 0000000000..c01ea2777c --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/RKroma.c @@ -0,0 +1,715 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +//////////////////////////////////////////////////////////////////////// +// This source cdde is Modified 1998 by T.Murai for kanBe. +//////////////////////////////////////////////////////////////////////// + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="@(#) 102.1 $Id: RKroma.c,v 1.1 2004/12/23 21:23:48 korli Exp $"; +#endif + +#include "canna.h" +// There is Exported Symbols !! +#include +#include +#include +#include + +#define S2TOS(s2) (((unsigned short)(s2)[0]<<8)|(s2)[1]) + +#ifdef WIN +#define JAPANESE_SORT +#endif + +#ifdef JAPANESE_SORT + +struct romaRec { + unsigned char *roma; + unsigned char bang; +}; + +static int findRoma(struct RkRxDic *rdic, struct rstat *m, unsigned char c, int n, int flg); +static unsigned char *getKana(struct RkRxDic *rdic, int p, int flags); +static unsigned char *getTSU(struct RkRxDic *rdic, int flags); +static unsigned char *getTemp(struct RkRxDic *rdic, int p); + +int +compar(struct romaRec *p, struct romaRec *q) +{ + unsigned char *s = p->roma; + unsigned char *t = q->roma; + + while ( *s == *t ) + if (*s) + s++, t++; + else + return 0; + return ((int)*s) - ((int)*t); +} +#endif /* JAPANESE_SORT */ + +#define ROMDICHEADERLEN 6 + +struct RkRxDic * +RkwOpenRoma(char *romaji) +{ + struct RkRxDic *rdic; +#ifdef JAPANESE_SORT + struct romaRec *tmp_rdic; +#endif + + rdic = (struct RkRxDic *)malloc(sizeof(struct RkRxDic)); + if (rdic) { + int dic; + unsigned char header[ROMDICHEADERLEN]; + unsigned char *s; + int i, sz, open_flags = O_RDONLY; + +#ifdef O_BINARY + open_flags |= O_BINARY; +#endif + if ( (dic = open((char *)romaji, open_flags)) < 0 ) { + free(rdic); + return((struct RkRxDic *)0); + } +/* magic no shougou */ + if ( read(dic, (char *)header, ROMDICHEADERLEN) != ROMDICHEADERLEN || + (strncmp((char *)header, "RD", 2) && + strncmp((char *)header, "KP", 2)) ) { + (void)close(dic); + free(rdic); + return((struct RkRxDic *)0); + } + if ( !strncmp((char *)header, "KP", 2) ) { + rdic->dic = RX_KPDIC; + } + else { + rdic->dic = RX_RXDIC; + } + rdic->nr_strsz = S2TOS(header + 2); + rdic->nr_nkey = S2TOS(header + 4); + if (rdic->nr_strsz > 0) { + rdic->nr_string = + (unsigned char *)malloc((unsigned int)rdic->nr_strsz); + + if ( !rdic->nr_string ) { + (void)close(dic); + free(rdic); + return((struct RkRxDic *)0); + } + + sz = read(dic, (char *)rdic->nr_string, rdic->nr_strsz); + (void)close(dic); + if ( sz != rdic->nr_strsz ) { + free(rdic->nr_string); + free(rdic); + return((struct RkRxDic *)0); + } + } + else { + rdic->nr_string = (unsigned char *)0; + } + + if (rdic->nr_nkey > 0) { + rdic->nr_keyaddr = + (unsigned char **)calloc((unsigned)rdic->nr_nkey, + sizeof(unsigned char *)); + if ( !rdic->nr_keyaddr ) { + free(rdic->nr_string); + free(rdic); + return((struct RkRxDic *)0); + } + } + else { + rdic->nr_keyaddr = (unsigned char **)0; + } + + s = rdic->nr_string; + + /* ¥È¥ê¥¬¡¼Ê¸»ú¤Î¥Ý¥¤¥ó¥¿ */ + if (rdic->dic == RX_KPDIC) { /* KPDIC ¤Ç nr_string ¤¬Ìµ¤¤¤³¤È¤Ï¤Ê¤¤ */ + rdic->nr_bchars = s; + while (*s++) + /* EMPTY */ + ; + + /* ¥È¥ê¥¬¡¼Ê¸»ú¤¬¤¢¤ë¤Î¤Ê¤é¡¢¥È¥ê¥¬¡¼¥ë¡¼¥ë¤â¤¢¤ë¤Ï¤º */ + if (*rdic->nr_string && rdic->nr_nkey > 0) { + rdic->nr_brules = (unsigned char *)calloc((unsigned)rdic->nr_nkey, + sizeof(unsigned char)); + } + else { + rdic->nr_brules = (unsigned char *)0; + } + } + else { + rdic->nr_brules = (unsigned char *)0; + } + + /* ¥ë¡¼¥ë¤ÎÆÉ¤ß¹þ¤ß */ + for ( i = 0; i < rdic->nr_nkey; i++ ) { + rdic->nr_keyaddr[i] = s; + while (*s++) + /* EMPTY */ + ; + while (*s++) + /* EMPTY */ + ; + if (rdic->dic == RX_KPDIC) { + while ( *s > 0x19 ) s++; + if (*s) { /* ¥È¥ê¥¬¡¼¥ë¡¼¥ë */ + if (rdic->nr_brules) { + rdic->nr_brules[i] = (unsigned char)1; + } + *s = (unsigned char)'\0'; + } + s++; + } + } + +#ifdef JAPANESE_SORT + tmp_rdic = (struct romaRec *)calloc((unsigned)rdic->nr_nkey, + sizeof(struct romaRec)); + if (!tmp_rdic) { + if (rdic->nr_string) + free(rdic->nr_string); + if (rdic->nr_keyaddr) + free(rdic->nr_keyaddr); + if (rdic->nr_brules) + free(rdic->nr_brules); + free(rdic); + return (struct RkRxDic *)NULL; + } + + for (i = 0; i < rdic->nr_nkey; i++) { + tmp_rdic[i].roma = rdic->nr_keyaddr[i]; + if (rdic->nr_brules) + tmp_rdic[i].bang = rdic->nr_brules[i]; + } + + qsort((char *)tmp_rdic, rdic->nr_nkey, sizeof(struct romaRec), + (int (*) (const void *, const void *)))compar; + + for (i = 0; i < rdic->nr_nkey; i++) { + rdic->nr_keyaddr[i] = tmp_rdic[i].roma; + if (rdic->nr_brules) + rdic->nr_brules[i] = tmp_rdic[i].bang; + } + free ((char *)tmp_rdic); +#endif /* JAPANESE_SORT */ + } + return((struct RkRxDic *)rdic); +} +/* RkCloseRoma + * romaji henkan table wo tojiru + */ +void +RkwCloseRoma(struct RkRxDic *rdic) +{ + if ( rdic ) { + if (rdic->nr_string) free(rdic->nr_string); + if (rdic->nr_keyaddr) free(rdic->nr_keyaddr); + if (rdic->nr_brules) free(rdic->nr_brules); + free(rdic); + }; +} + +struct RkRxDic * +RkOpenRoma(char *romaji) +{ + return RkwOpenRoma(romaji); +} + +void +RkCloseRoma(struct RkRxDic *rdic) +{ + RkwCloseRoma(rdic); +} + +/* RkMapRoma + * key no sentou wo saichou itti hou ni yori,henkan suru + */ +#define xkey(roma, line, n) ((roma)->nr_keyaddr[line][n]) + +struct rstat { + int start, end; /* match sury key no hanni */ +}; + +static +int +findRoma(struct RkRxDic *rdic, struct rstat *m, unsigned char c, int n, int flg) +{ + register int s, e; + + if (flg && 'A' <= c && c <= 'Z') { + c += 'a' - 'A'; + } + for(s = m->start; s < m->end; s++) + if( c == xkey(rdic, s, n) ) + break; + for(e = s; e < m->end; e++) + if( c != xkey(rdic, e, n) ) + break; + m->start = s; + m->end = e; + return e - s; +} +static +unsigned char * +getKana(struct RkRxDic *rdic, int p, int flags) +{ + register unsigned char *kana; + int klen; + static unsigned char tmp[256]; + + for (kana = rdic->nr_keyaddr[p] ; *kana++ ; ) + /* EMPTY */ + ; + + klen = strlen((char *)kana); + switch(flags&RK_XFERMASK) { + default: + (void)RkCvtNone(tmp, sizeof(tmp), kana, klen); + return tmp; + case RK_XFER: + (void)RkCvtHira(tmp, sizeof(tmp), kana, klen); + return tmp; + case RK_HFER: + (void)RkCvtHan(tmp, sizeof(tmp), kana, klen); + return tmp; + case RK_KFER: + (void)RkCvtKana(tmp, sizeof(tmp), kana, klen); + return tmp; + case RK_ZFER: + (void)RkCvtZen(tmp, sizeof(tmp), kana, klen); + return tmp; + }; +} + +inline +unsigned char * +getRoma(struct RkRxDic *rdic, int p) +{ + return rdic->nr_keyaddr[p]; +} + +/*ARGSUSED*/ +static +unsigned char * +getTSU(struct RkRxDic *rdic, int flags) +{ + static unsigned char hira_tsu[] = {0xa4, 0xc3, 0}; + static unsigned char kana_tsu[] = {0xa5, 0xc3, 0}; + static unsigned char han_tsu[] = {0x8e, 0xaf, 0}; + + switch(flags&RK_XFERMASK) { + default: return hira_tsu; + case RK_HFER: return han_tsu; + case RK_KFER: return kana_tsu; + }; +} + +int +RkMapRoma(struct RkRxDic *rdic, unsigned char *dst, int maxdst, unsigned char *src, int maxsrc, int flags, int *status) +{ + register int i; + unsigned char *roma; + unsigned char *kana = src; + int count = 0; + int byte; + int found = 1; + struct rstat *m; + struct rstat match[256]; + + if ( rdic ) { + m = match; + m->start = 0; + m->end = rdic->nr_nkey; + for (i = 0; (flags & RK_FLUSH) || i < maxsrc; i++) { + m[1] = m[0]; + m++; + switch((i < maxsrc) ? findRoma(rdic, m, src[i], i, 0) : 0) { + case 0: + while (--m > match && xkey(rdic, m->start, m - match)) + /* EMPTY */ + ; + if(m == match) { /* table ni nakatta tokino shori */ + kana = src; + count = (maxsrc <= 0)? 0 : (*src & 0x80)? 2 : 1; + if( (flags & RK_SOKON) && + (match[1].start < rdic->nr_nkey) && + (2 <= maxsrc) && + (src[0] == src[1]) && + (i == 1)) { + kana = getTSU(rdic, flags); + /* tsu ha jisho ni aru kao wo suru */ + byte = strlen((char *)kana); + } + else { + static unsigned char tmp[256]; + + switch(flags&RK_XFERMASK) { + default: + byte = RkCvtNone(tmp, sizeof(tmp), src, count); + break; + case RK_XFER: + byte = RkCvtHira(tmp, sizeof(tmp), src, count); + break; + case RK_HFER: + byte = RkCvtHan(tmp, sizeof(tmp), src, count); + break; + case RK_KFER: + byte = RkCvtKana(tmp, sizeof(tmp), src, count); + break; + case RK_ZFER: + byte = RkCvtZen(tmp, sizeof(tmp), src, count); + break; + }; + kana = tmp; + found = -1; + }; + } + else { /* 'n' nado no shori: saitan no monowo toru */ + kana = getKana(rdic, m->start, flags); + byte = strlen((char *)kana); + count = m - match; + } + goto done; + case 1: /* determined uniquely */ + /* key no hou ga nagai baai */ + roma = getRoma(rdic, m->start); + if ( roma[i + 1] ) /* waiting suffix */ + continue; + kana = getKana(rdic, m->start, flags); + byte = strlen((char *)kana); + count = i + 1; + goto done; + }; + }; + byte = 0; + } + else + byte = (maxsrc <= 0) ? 0 : (*src & 0x80) ? 2 : 1; +done: + *status = found*byte; + if ( byte + 1 <= maxdst ) { + if ( dst ) { + while ( byte-- ) + *dst++ = *kana++; + *dst = 0; + }; + }; + return count; +} + +inline +unsigned char * +getrawKana(struct RkRxDic *rdic, int p) +{ + register unsigned char *kana; + + for (kana = rdic->nr_keyaddr[p] ; *kana++ ; ) + /* EMPTY */ + ; + + return kana; +} + +static +unsigned char * +getTemp(struct RkRxDic *rdic, int p) +{ + register unsigned char *kana; + + if (rdic->dic != RX_KPDIC) { + return (unsigned char *)0; + } + kana = rdic->nr_keyaddr[p]; + while (*kana++) + /* EMPTY */ + ; + while (*kana++) + /* EMPTY */ + ; + + return kana; +} + + +int +RkMapPhonogram(struct RkRxDic *rdic, unsigned char *dst, int maxdst, unsigned char *src, int srclen, unsigned key, int flags, int *used_len_return, int *dst_len_return, int *tmp_len_return, int *rule_id_inout) +{ + register int i; + unsigned char *roma, *temp; + unsigned char *kana = src; + int count = 0; + int byte; + int found = 1; + int templen, lastrule; + struct rstat *m; + struct rstat match[256]; + + if ( rdic ) { + if (rdic->dic == RX_KPDIC + && rule_id_inout && (lastrule = *rule_id_inout)) { + if (!key) { + if (rdic->nr_brules && rdic->nr_brules[lastrule] && + !(flags & RK_FLUSH)) { + /* ¤â¤·¡¢! ¤¬ÉÕ¤¤¤Æ¤¤¤¿¾ì¹ç¤Ë¤ÏÂ裳¥Õ¥£¡¼¥ë¥É¤Ë½ñ¤«¤ì¤Æ¤¤¤ë + ʸ»ú¤Ç»Ï¤Þ¤ë¥ë¡¼¥ë¤¬¤¢¤ë¤È²¾ÁÛŪ¤Ë¹Í¤¨¤é¤ì¤ë¤ï¤±¤Ç¤¢¤ë¤« + ¤é key ¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¤¢¤ì¤ÐÍ¿¤¨¤é¤ì¤¿Ê¸»úÎó¤¬Ã»¤« + ¤¹¤®¤ë¤¿¤á¤Ê¤ó¤È¤â¤Ç¤­¤Ê¤¤¤è¤·¤Î¥ê¥¿¡¼¥óÃͤòÊÖ¤¹¡£ */ + /* RK_FLUSH ¤ÏÄ´¤Ù¤ë¤Ù¤­¤«¤É¤¦¤«Çº¤à¤È¤³¤í */ + byte = count = 0; + templen = 0; + found = 0; + goto done; + } + }else{ + lastrule--; + if (lastrule < rdic->nr_nkey && rdic->nr_brules) { + if (rdic->nr_brules[lastrule]) { + unsigned char *p; + + for (p = rdic->nr_bchars ; *p ; p++) { + if (key == *p) { + unsigned char *origin = getTemp(rdic, lastrule), *ret; + int dstlen = 0, tmplen; + + ret = dst; + for (i = 0 ; i < maxdst && *origin ; i++) { + origin++; + } + if (i + 1 == srclen) { + /* ¥Ð¥Ã¥¯¥È¥é¥Ã¥¯¤ò¤¹¤ë */ + origin = rdic->nr_keyaddr[lastrule]; + + for (i = 0 ; i < maxdst && *origin ; i++) { + *dst++ = *origin++; + } + tmplen = ++i; + if (i < maxdst) { + *dst++ = key; + *dst = (unsigned char)0; + } + if (used_len_return) *used_len_return = srclen; + if (*ret & 0x80) { /* very dependent on Japanese EUC */ + if (*ret == 0x8f) { + dstlen++; + } + dstlen++; + } + dstlen++; + if (dst_len_return) *dst_len_return = dstlen; + if (tmp_len_return) *tmp_len_return = tmplen - dstlen; + *rule_id_inout = 0; + goto return_found; + } + } + } + } + } + } + } + m = match; + m->start = 0; + m->end = rdic->nr_nkey; + for (i = 0; (flags & RK_FLUSH) || i < srclen; i++) { + m[1] = m[0]; + m++; + switch((i < srclen) ? + findRoma(rdic, m, src[i], i, flags & RK_IGNORECASE) : 0) { + case 0: + while (--m > match && xkey(rdic, m->start, m - match)) + /* EMPTY */ + ; + if(m == match) { /* ¥Æ¡¼¥Ö¥ë¤Ë¤Ê¤«¤Ã¤¿»þ¤Î½èÍý */ + count = (*src & 0x80) ? 2 : 1; + if (srclen < count) { + count = 0; + } + if( (rdic->dic == RX_RXDIC) && /* tt ¤ÎµßºÑ(µì¼­½ñÍÑ) */ + (flags & RK_SOKON) && + (match[1].start < rdic->nr_nkey) && + (2 <= srclen) && + (src[0] == src[1]) && + (i == 1)) { + kana = getTSU(rdic, flags); + /* tsu ha jisho ni aru kao wo suru */ + byte = strlen((char *)kana); + templen = 0; + if (rule_id_inout) *rule_id_inout = 0; + } + else { /* £±Ê¸»úÊÑ´¹¤µ¤ì¤¿¤³¤È¤Ë¤¹¤ë */ + byte = count; + templen = 0; + kana = src; + found = 0; + } + } + else { /* 'n' ¤Ê¤É¤Î½èÍý: ºÇû¤Î¤â¤Î¤ò¼è¤ë */ + kana = getrawKana(rdic, m->start); + byte = strlen((char *)kana); + temp = getTemp(rdic, m->start); + templen = temp ? strlen((char *)temp) : 0; + count = m - match; + if (rule_id_inout) { + if (byte == 0 && templen > 0) { + *rule_id_inout = m->start + 1; + } + else { + *rule_id_inout = 0; + } + } + } + goto done; + case 1: /* ÅÓÃæ¤Ç¤É¤ó¤Ô¤·¤ã¤¬¸«¤Ä¤«¤Ã¤¿ */ + /* key no hou ga nagai baai */ + roma = getRoma(rdic, m->start); + if ( roma[i + 1] ) /* waiting suffix */ + continue; + kana = getrawKana(rdic, m->start); + byte = strlen((char *)kana); + temp = getTemp(rdic, m->start); + templen = temp ? strlen((char *)temp) : 0; + count = i + 1; + if (rule_id_inout) { + if (byte == 0 && templen > 0) { + *rule_id_inout = m->start + 1; + } + else { + *rule_id_inout = 0; + } + } + goto done; + } + } + byte = count = 0; + templen = 0; + } + else { + byte = (*src & 0x80) ? 2 : 1; + if (srclen < byte) { + byte = 0; + } + count = byte; + kana = src; + templen = 0; + found = 0; + } + done: + + if (dst_len_return) { + *dst_len_return = byte; + } + if (used_len_return) { + *used_len_return = count; + } + if (tmp_len_return) { + *tmp_len_return = templen; + } + if ( byte < maxdst ) { + if ( dst ) { + int ii; + for (ii = 0 ; ii < byte ; ii++) + *dst++ = *kana++; + *dst = 0; + } + if (byte + templen < maxdst) { + if (dst) { + while (templen--) { + *dst++ = *temp++; + } + *dst = 0; + } + } + } + return_found: + return found; +} + +/* RkCvtRoma + */ +int +RkCvtRoma(struct RkRxDic *rdic, unsigned char *dst, int maxdst, unsigned char *src, int maxsrc, unsigned flags) +{ + register unsigned char *d = dst; + register unsigned char *s = src; + register unsigned char *S = src + maxsrc; + int count = 0; + unsigned xp = 0; + unsigned char key; +#ifndef WIN + unsigned char xxxx[64], yyyy[64]; +#else + unsigned char *xxxx, *yyyy; + xxxx = (unsigned char *)malloc(64); + yyyy = (unsigned char *)malloc(64); + if (!xxxx || !yyyy) { + if (xxxx) { + free(xxxx); + } + if (yyyy) { + free(yyyy); + } + return count; + } +#endif + + if (!(maxdst <= 0 || maxsrc < 0)) { + while ( s < S ) { + int ulen, dlen, tlen, rule = 0; + unsigned dontflush = RK_FLUSH; + + key = xxxx[xp++] = *s++; + flush: + do { + RkMapPhonogram(rdic, d, maxdst, xxxx, xp, (unsigned)key, + flags & ~dontflush, &ulen, &dlen, &tlen, &rule); + + if ( dlen + 1 <= maxdst ) { + maxdst -= dlen; count += dlen; + if ( dst ) { + d += dlen; + (void)strncpy((char *)yyyy, (char *)d, tlen); + } + } + + if (ulen < (int)xp) { + strncpy((char *)yyyy + tlen, (char *)xxxx + ulen, xp - ulen); + } + strncpy((char *)xxxx, (char *)yyyy, tlen + xp - ulen); + xp = tlen + xp - ulen; + key = 0; + } while (ulen > 0); + if (s == S && dontflush) { + dontflush = 0; + goto flush; + } + } + } +#ifdef WIN + free(yyyy); + free(xxxx); +#endif + return count; +} diff --git a/src/add-ons/input_server/methods/canna/lib/alphamap.h b/src/add-ons/input_server/methods/canna/lib/alphamap.h new file mode 100644 index 0000000000..b0bbfcd795 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/alphamap.h @@ -0,0 +1,317 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char alphamap_id[] = "@(#) 102.1 $Id: alphamap.h,v 1.1 2004/12/23 21:23:48 korli Exp $"; +#endif /* lint */ + +extern int JapaneseMode(); +extern int DoFuncSequence(),UseOtherKeymap(); + +static struct funccfunc alpha_funcs[] = { + {CANNA_FN_SelfInsert ,AlphaSelfInsert }, + {CANNA_FN_JapaneseMode ,JapaneseMode }, + {CANNA_FN_Nop ,AlphaNop }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {CANNA_FN_FunctionalInsert ,AlphaSelfInsert }, + {DEFAULTBEHAVIOR ,AlphaSelfInsert }, + +#ifdef WIN + {CANNA_FN_DefineDicMode ,dicTouroku }, + {CANNA_FN_DeleteDicMode ,dicSakujo }, + + {CANNA_FN_HenkanRegion ,HenkanRegion }, + {CANNA_FN_PhonoEdit ,PhonoEdit }, + {CANNA_FN_DicEdit ,DicEdit }, + {CANNA_FN_Configure ,Configure }, +#endif + {0 ,0 }, +}; + +BYTE alpha_kmap[256] = +{ +/* C-@ */ CANNA_FN_SelfInsert, +/* C-a */ CANNA_FN_SelfInsert, +/* C-b */ CANNA_FN_SelfInsert, +/* C-c */ CANNA_FN_SelfInsert, +/* C-d */ CANNA_FN_SelfInsert, +/* C-e */ CANNA_FN_SelfInsert, +/* C-f */ CANNA_FN_SelfInsert, +/* C-g */ CANNA_FN_SelfInsert, +/* C-h */ CANNA_FN_SelfInsert, +/* C-i */ CANNA_FN_SelfInsert, +/* C-j */ CANNA_FN_SelfInsert, +/* C-k */ CANNA_FN_SelfInsert, +/* C-l */ CANNA_FN_SelfInsert, +/* C-m */ CANNA_FN_SelfInsert, +/* C-n */ CANNA_FN_SelfInsert, +/* C-o */ CANNA_FN_JapaneseMode, +/* C-p */ CANNA_FN_SelfInsert, +/* C-q */ CANNA_FN_SelfInsert, +/* C-r */ CANNA_FN_SelfInsert, +/* C-s */ CANNA_FN_SelfInsert, +/* C-t */ CANNA_FN_SelfInsert, +/* C-u */ CANNA_FN_SelfInsert, +/* C-v */ CANNA_FN_SelfInsert, +/* C-w */ CANNA_FN_SelfInsert, +/* C-x */ CANNA_FN_SelfInsert, +/* C-y */ CANNA_FN_SelfInsert, +/* C-z */ CANNA_FN_SelfInsert, +/* C-[ */ CANNA_FN_SelfInsert, +/* C-\ */ CANNA_FN_SelfInsert, +/* C-] */ CANNA_FN_SelfInsert, +/* C-^ */ CANNA_FN_SelfInsert, +/* C-_ */ CANNA_FN_SelfInsert, +/* space */ CANNA_FN_SelfInsert, +/* ! */ CANNA_FN_SelfInsert, +/* " */ CANNA_FN_SelfInsert, +/* # */ CANNA_FN_SelfInsert, +/* $ */ CANNA_FN_SelfInsert, +/* % */ CANNA_FN_SelfInsert, +/* & */ CANNA_FN_SelfInsert, +/* ' */ CANNA_FN_SelfInsert, +/* ( */ CANNA_FN_SelfInsert, +/* ) */ CANNA_FN_SelfInsert, +/* * */ CANNA_FN_SelfInsert, +/* + */ CANNA_FN_SelfInsert, +/* , */ CANNA_FN_SelfInsert, +/* - */ CANNA_FN_SelfInsert, +/* . */ CANNA_FN_SelfInsert, +/* / */ CANNA_FN_SelfInsert, +/* 0 */ CANNA_FN_SelfInsert, +/* 1 */ CANNA_FN_SelfInsert, +/* 2 */ CANNA_FN_SelfInsert, +/* 3 */ CANNA_FN_SelfInsert, +/* 4 */ CANNA_FN_SelfInsert, +/* 5 */ CANNA_FN_SelfInsert, +/* 6 */ CANNA_FN_SelfInsert, +/* 7 */ CANNA_FN_SelfInsert, +/* 8 */ CANNA_FN_SelfInsert, +/* 9 */ CANNA_FN_SelfInsert, +/* : */ CANNA_FN_SelfInsert, +/* ; */ CANNA_FN_SelfInsert, +/* < */ CANNA_FN_SelfInsert, +/* = */ CANNA_FN_SelfInsert, +/* > */ CANNA_FN_SelfInsert, +/* ? */ CANNA_FN_SelfInsert, +/* @ */ CANNA_FN_SelfInsert, +/* A */ CANNA_FN_SelfInsert, +/* B */ CANNA_FN_SelfInsert, +/* C */ CANNA_FN_SelfInsert, +/* D */ CANNA_FN_SelfInsert, +/* E */ CANNA_FN_SelfInsert, +/* F */ CANNA_FN_SelfInsert, +/* G */ CANNA_FN_SelfInsert, +/* H */ CANNA_FN_SelfInsert, +/* I */ CANNA_FN_SelfInsert, +/* J */ CANNA_FN_SelfInsert, +/* K */ CANNA_FN_SelfInsert, +/* L */ CANNA_FN_SelfInsert, +/* M */ CANNA_FN_SelfInsert, +/* N */ CANNA_FN_SelfInsert, +/* O */ CANNA_FN_SelfInsert, +/* P */ CANNA_FN_SelfInsert, +/* Q */ CANNA_FN_SelfInsert, +/* R */ CANNA_FN_SelfInsert, +/* S */ CANNA_FN_SelfInsert, +/* T */ CANNA_FN_SelfInsert, +/* U */ CANNA_FN_SelfInsert, +/* V */ CANNA_FN_SelfInsert, +/* W */ CANNA_FN_SelfInsert, +/* X */ CANNA_FN_SelfInsert, +/* Y */ CANNA_FN_SelfInsert, +/* Z */ CANNA_FN_SelfInsert, +/* [ */ CANNA_FN_SelfInsert, +/* \ */ CANNA_FN_SelfInsert, +/* ] */ CANNA_FN_SelfInsert, +/* ^ */ CANNA_FN_SelfInsert, +/* _ */ CANNA_FN_SelfInsert, +/* ` */ CANNA_FN_SelfInsert, +/* a */ CANNA_FN_SelfInsert, +/* b */ CANNA_FN_SelfInsert, +/* c */ CANNA_FN_SelfInsert, +/* d */ CANNA_FN_SelfInsert, +/* e */ CANNA_FN_SelfInsert, +/* f */ CANNA_FN_SelfInsert, +/* g */ CANNA_FN_SelfInsert, +/* h */ CANNA_FN_SelfInsert, +/* i */ CANNA_FN_SelfInsert, +/* j */ CANNA_FN_SelfInsert, +/* k */ CANNA_FN_SelfInsert, +/* l */ CANNA_FN_SelfInsert, +/* m */ CANNA_FN_SelfInsert, +/* n */ CANNA_FN_SelfInsert, +/* o */ CANNA_FN_SelfInsert, +/* p */ CANNA_FN_SelfInsert, +/* q */ CANNA_FN_SelfInsert, +/* r */ CANNA_FN_SelfInsert, +/* s */ CANNA_FN_SelfInsert, +/* t */ CANNA_FN_SelfInsert, +/* u */ CANNA_FN_SelfInsert, +/* v */ CANNA_FN_SelfInsert, +/* w */ CANNA_FN_SelfInsert, +/* x */ CANNA_FN_SelfInsert, +/* y */ CANNA_FN_SelfInsert, +/* z */ CANNA_FN_SelfInsert, +/* { */ CANNA_FN_SelfInsert, +/* | */ CANNA_FN_SelfInsert, +/* } */ CANNA_FN_SelfInsert, +/* ~ */ CANNA_FN_SelfInsert, +/* DEL */ CANNA_FN_SelfInsert, +/* Nfer */ CANNA_FN_SelfInsert, +/* Xfer */ CANNA_FN_JapaneseMode, +/* Up */ CANNA_FN_SelfInsert, +/* Left */ CANNA_FN_SelfInsert, +/* Right */ CANNA_FN_SelfInsert, +/* Down */ CANNA_FN_SelfInsert, +/* Insert */ CANNA_FN_SelfInsert, +/* Rollup */ CANNA_FN_SelfInsert, +/* Rolldown */ CANNA_FN_SelfInsert, +/* Home */ CANNA_FN_SelfInsert, +/* Help */ CANNA_FN_SelfInsert, +/* KeyPad */ CANNA_FN_SelfInsert, +/* 8c */ CANNA_FN_SelfInsert, +/* 8d */ CANNA_FN_SelfInsert, +/* 8e */ CANNA_FN_SelfInsert, +/* 8f */ CANNA_FN_SelfInsert, +/* S-nfer */ CANNA_FN_SelfInsert, +/* S-xfer */ CANNA_FN_JapaneseMode, +/* S-up */ CANNA_FN_SelfInsert, +/* S-left */ CANNA_FN_SelfInsert, +/* S-right */ CANNA_FN_SelfInsert, +/* S-down */ CANNA_FN_SelfInsert, +/* C-nfer */ CANNA_FN_SelfInsert, +/* C-xfer */ CANNA_FN_JapaneseMode, +/* C-up */ CANNA_FN_SelfInsert, +/* C-left */ CANNA_FN_SelfInsert, +/* C-right */ CANNA_FN_SelfInsert, +/* C-down */ CANNA_FN_SelfInsert, +/* 9c */ CANNA_FN_SelfInsert, +/* 9d */ CANNA_FN_SelfInsert, +/* 9e */ CANNA_FN_SelfInsert, +/* 9f */ CANNA_FN_SelfInsert, +/* KANASPACE */ CANNA_FN_SelfInsert, +/* ¡£ */ CANNA_FN_SelfInsert, +/* ¡Ö */ CANNA_FN_SelfInsert, +/* ¡× */ CANNA_FN_SelfInsert, +/* ¡¢ */ CANNA_FN_SelfInsert, +/* ¡¦ */ CANNA_FN_SelfInsert, +/* ¥ò */ CANNA_FN_SelfInsert, +/* ¥¡ */ CANNA_FN_SelfInsert, +/* ¥£ */ CANNA_FN_SelfInsert, +/* ¥¥ */ CANNA_FN_SelfInsert, +/* ¥§ */ CANNA_FN_SelfInsert, +/* ¥© */ CANNA_FN_SelfInsert, +/* ¥ã */ CANNA_FN_SelfInsert, +/* ¥å */ CANNA_FN_SelfInsert, +/* ¥ç */ CANNA_FN_SelfInsert, +/* ¥Ã */ CANNA_FN_SelfInsert, +/* ¡¼ */ CANNA_FN_SelfInsert, +/* ¥¢ */ CANNA_FN_SelfInsert, +/* ¥¤ */ CANNA_FN_SelfInsert, +/* ¥¦ */ CANNA_FN_SelfInsert, +/* ¥¨ */ CANNA_FN_SelfInsert, +/* ¥ª */ CANNA_FN_SelfInsert, +/* ¥« */ CANNA_FN_SelfInsert, +/* ¥­ */ CANNA_FN_SelfInsert, +/* ¥¯ */ CANNA_FN_SelfInsert, +/* ¥± */ CANNA_FN_SelfInsert, +/* ¥³ */ CANNA_FN_SelfInsert, +/* ¥µ */ CANNA_FN_SelfInsert, +/* ¥· */ CANNA_FN_SelfInsert, +/* ¥¹ */ CANNA_FN_SelfInsert, +/* ¥» */ CANNA_FN_SelfInsert, +/* ¥½ */ CANNA_FN_SelfInsert, +/* ¥¿ */ CANNA_FN_SelfInsert, +/* ¥Á */ CANNA_FN_SelfInsert, +/* ¥Ä */ CANNA_FN_SelfInsert, +/* ¥Æ */ CANNA_FN_SelfInsert, +/* ¥È */ CANNA_FN_SelfInsert, +/* ¥Ê */ CANNA_FN_SelfInsert, +/* ¥Ë */ CANNA_FN_SelfInsert, +/* ¥Ì */ CANNA_FN_SelfInsert, +/* ¥Í */ CANNA_FN_SelfInsert, +/* ¥Î */ CANNA_FN_SelfInsert, +/* ¥Ï */ CANNA_FN_SelfInsert, +/* ¥Ò */ CANNA_FN_SelfInsert, +/* ¥Õ */ CANNA_FN_SelfInsert, +/* ¥Ø */ CANNA_FN_SelfInsert, +/* ¥Û */ CANNA_FN_SelfInsert, +/* ¥Þ */ CANNA_FN_SelfInsert, +/* ¥ß */ CANNA_FN_SelfInsert, +/* ¥à */ CANNA_FN_SelfInsert, +/* ¥á */ CANNA_FN_SelfInsert, +/* ¥â */ CANNA_FN_SelfInsert, +/* ¥ä */ CANNA_FN_SelfInsert, +/* ¥æ */ CANNA_FN_SelfInsert, +/* ¥è */ CANNA_FN_SelfInsert, +/* ¥é */ CANNA_FN_SelfInsert, +/* ¥ê */ CANNA_FN_SelfInsert, +/* ¥ë */ CANNA_FN_SelfInsert, +/* ¥ì */ CANNA_FN_SelfInsert, +/* ¥í */ CANNA_FN_SelfInsert, +/* ¥ï */ CANNA_FN_SelfInsert, +/* ¥ó */ CANNA_FN_SelfInsert, +/* ¡« */ CANNA_FN_SelfInsert, +/* ¡¬ */ CANNA_FN_SelfInsert, +/* F1 */ CANNA_FN_SelfInsert, +/* F2 */ CANNA_FN_SelfInsert, +/* F3 */ CANNA_FN_SelfInsert, +/* F4 */ CANNA_FN_SelfInsert, +/* F5 */ CANNA_FN_SelfInsert, +/* F6 */ CANNA_FN_SelfInsert, +/* F7 */ CANNA_FN_SelfInsert, +/* F8 */ CANNA_FN_SelfInsert, +/* F9 */ CANNA_FN_SelfInsert, +/* F10 */ CANNA_FN_SelfInsert, +/* ea */ CANNA_FN_SelfInsert, +/* eb */ CANNA_FN_SelfInsert, +/* ec */ CANNA_FN_SelfInsert, +/* ed */ CANNA_FN_SelfInsert, +/* ee */ CANNA_FN_SelfInsert, +/* ef */ CANNA_FN_SelfInsert, +/* PF1 */ CANNA_FN_SelfInsert, +/* PF2 */ CANNA_FN_SelfInsert, +/* PF3 */ CANNA_FN_SelfInsert, +/* PF4 */ CANNA_FN_SelfInsert, +/* PF5 */ CANNA_FN_SelfInsert, +/* PF6 */ CANNA_FN_SelfInsert, +/* PF7 */ CANNA_FN_SelfInsert, +/* PF8 */ CANNA_FN_SelfInsert, +/* PF9 */ CANNA_FN_SelfInsert, +/* PF10 */ CANNA_FN_SelfInsert, +/* fa */ CANNA_FN_SelfInsert, +/* fb */ CANNA_FN_SelfInsert, +/* fc */ CANNA_FN_SelfInsert, +/* fd */ CANNA_FN_SelfInsert, +/* fe */ CANNA_FN_SelfInsert, +/* ff */ CANNA_FN_SelfInsert, +}; + + +KanjiModeRec alpha_mode = { + searchfunc, + alpha_kmap, + CANNA_KANJIMODE_TABLE_SHARED | CANNA_KANJIMODE_EMPTY_MODE, + alpha_funcs, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/bunmap.h b/src/add-ons/input_server/methods/canna/lib/bunmap.h new file mode 100644 index 0000000000..a4d2d1381c --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/bunmap.h @@ -0,0 +1,60 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char bunmap_id[] = "@(#) 102.1 $Id: bunmap.h,v 1.1 2004/12/23 21:23:48 korli Exp $"; +#endif /* lint */ + +extern DoFuncSequence(),UseOtherKeymap(); +extern TanNop (uiContext), YomiKakutei (uiContext); + +static struct funccfunc bun_funcs[] = { + {CANNA_FN_FunctionalInsert ,BunSelfInsert }, + {CANNA_FN_QuotedInsert ,BunQuotedInsert }, + {CANNA_FN_Forward ,BunExtend }, + {CANNA_FN_Backward ,BunShrink }, + {CANNA_FN_BeginningOfLine ,BunFullShrink }, + {CANNA_FN_EndOfLine ,BunFullExtend }, + {CANNA_FN_DeleteNext ,BunQuit }, + {CANNA_FN_DeletePrevious ,BunQuit }, + {CANNA_FN_KillToEndOfLine ,BunKillToEOL }, + {CANNA_FN_Henkan ,BunHenkan }, + {CANNA_FN_HenkanOrInsert ,BunHenkan }, + {CANNA_FN_HenkanOrNothing ,BunHenkan }, + {CANNA_FN_Kakutei ,YomiKakutei }, + {CANNA_FN_Extend ,BunExtend }, + {CANNA_FN_Shrink ,BunShrink }, + {CANNA_FN_Quit ,BunQuit }, + {CANNA_FN_Nop ,TanNop }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {0 ,0 }, +}; + +extern searchfunc(...); +KanjiModeRec bunsetsu_mode = { + searchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + bun_funcs, +}; + diff --git a/src/add-ons/input_server/methods/canna/lib/bunsetsu.c b/src/add-ons/input_server/methods/canna/lib/bunsetsu.c new file mode 100644 index 0000000000..db6df7e2e4 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/bunsetsu.c @@ -0,0 +1,225 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: bunsetsu.c,v 1.1 2004/12/23 21:23:48 korli Exp $"; +#endif /* lint */ + +#include +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +extern int BunsetsuKugiri; + +static char *e_message[] = { +#ifdef WIN + /* 0*/"\312\270\300\341\244\316\260\334\306\260\244\313\274\272\307\324\244\267\244\336\244\267\244\277", + /* 1*/"\264\301\273\372\244\316\306\311\244\337\244\362\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307\244\267\244\277", + /* 2*/"\312\270\300\341\244\316\260\334\306\260\244\313\274\272\307\324\244\267\244\336\244\267\244\277", + /* 3*/"\264\301\273\372\244\316\306\311\244\337\244\362\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307\244\267\244\277", + /* 4*/"\244\253\244\312\264\301\273\372\312\321\264\271\244\313\274\272\307\324\244\267\244\336\244\267\244\277", +#else + /* 0*/"ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿", + /* 1*/"´Á»ú¤ÎÆÉ¤ß¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿", + /* 2*/"ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿", + /* 3*/"´Á»ú¤ÎÆÉ¤ß¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿", + /* 4*/"¤«¤Ê´Á»úÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿", +#endif +}; + +int +enterAdjustMode(uiContext d, yomiContext yc) +{ + extern KanjiModeRec bunsetsu_mode; + int i, n = 0; + RkStat rst; + + for (i = 0 ; i < yc->curbun ; i++) { + if (RkwGoTo(yc->context, i) == -1) { + return makeRkError(d, e_message[0]); + } + if (RkwGetStat(yc->context, &rst) == -1) { + return makeRkError(d, e_message[1]); + } + n += rst.ylen; + } + yc->kanjilen = n; + /* ¥«¥ì¥ó¥ÈʸÀá¤ÎÆÉ¤ß¤ÎŤµ¤ò¼è¤ê½Ð¤¹ */ + if (RkwGoTo(yc->context, yc->curbun) == -1) { + return makeRkError(d, e_message[2]); + } + if (RkwGetStat(yc->context, &rst) == -1) { + return makeRkError(d, e_message[3]); + } + yc->bunlen = rst.ylen; + + yc->tanMode = yc->curMode; + yc->tanMinorMode = yc->minorMode; + yc->minorMode = CANNA_MODE_AdjustBunsetsuMode; + d->current_mode = yc->curMode = &bunsetsu_mode; + return 0; +} + +int +leaveAdjustMode(uiContext d, yomiContext yc) +{ + extern KanjiModeRec bunsetsu_mode; + + yc->bunlen = yc->kanjilen = 0; + yc->minorMode = yc->tanMinorMode; + d->current_mode = yc->curMode = yc->tanMode; + return 0; +} + + +static int +BunFullExtend(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + yc->bunlen = yc->kEndp - yc->kanjilen; + makeKanjiStatusReturn(d, yc); + return 0; +} + +static int +BunFullShrink(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + yc->bunlen = 1; + makeKanjiStatusReturn(d, yc); + return 0; +} + +static int +BunExtend(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->kanjilen + yc->bunlen < yc->kEndp) { + /* ¤Þ¤À¿­¤Ð¤»¤ë */ + + yc->bunlen++; + makeKanjiStatusReturn(d, yc); + return 0; + } + else if (cannaconf.CursorWrap) { + return BunFullShrink(d); + } + (void)NothingChangedWithBeep(d); + return 0; +} + +static int +BunShrink(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->bunlen > 0) { + /* ¤Þ¤À½Ì¤Þ¤ë */ + int newlen = yc->bunlen; + + newlen--; + if (newlen > 0) { + yc->bunlen = newlen; + makeKanjiStatusReturn(d, yc); + return 0; + } + else if (cannaconf.CursorWrap) { + return BunFullExtend(d); + } + } + (void)NothingChangedWithBeep(d); + return 0; +} + +static int +BunHenkan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + yc->nbunsetsu = RkwResize(yc->context, yc->bunlen); + leaveAdjustMode(d, yc); + if (yc->nbunsetsu < 0) { + makeRkError(d, e_message[4]); + yc->nbunsetsu = 1/* dummy */; + return TanMuhenkan(d); + } + makeKanjiStatusReturn(d, yc); + currentModeInfo(d); + return 0; +} + +static int +BunQuit(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + leaveAdjustMode(d, yc); + makeKanjiStatusReturn(d, yc); + currentModeInfo(d); + return 0; +} + +static int +BunSelfInsert(uiContext d) +{ + d->nbytes = BunQuit(d); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = CANNA_FN_FunctionalInsert; + return d->nbytes; +} + +static int +BunQuotedInsert(uiContext d) +{ + d->nbytes = BunQuit(d); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = CANNA_FN_QuotedInsert; + return d->nbytes; +} + +static int +BunKillToEOL(uiContext d) +{ + d->nbytes = BunQuit(d); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = CANNA_FN_KillToEndOfLine; + return d->nbytes; +} + +#include "bunmap.h" + +/* »Ä¤Ã¤Æ¤¤¤ë¤ª»Å»ö + + ¡¦Ã༡¼«Æ°ÊÑ´¹Ãæ¤ÎʸÀá¿­½Ì¥â¡¼¥É + */ diff --git a/src/add-ons/input_server/methods/canna/lib/bushu.c b/src/add-ons/input_server/methods/canna/lib/bushu.c new file mode 100644 index 0000000000..89ded1a8ab --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/bushu.c @@ -0,0 +1,778 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: bushu.c,v 1.1 2004/12/23 21:23:48 korli Exp $"; +#endif /* lint */ + +#include +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +extern WCHAR_T *WString(); + + + +#define BUSHU_SZ 150 + +static +char *bushu_schar[] = +{ + /* "°ì", "Ш", "Ñá", "½½", "ÒÇ", "Åá", */ + "\260\354", "\320\250", "\321\341", "\275\275", "\322\307", "\305\341", + + /* "´¢¡Ê¤ê¤Ã¤È¤¦¡Ë", "ÎÏ", "ÒÌ", "Ò±", "ÑÄÒ¹Óø", "е", */ + "\264\242\241\312\244\352\244\303\244\310\244\246\241\313", "\316\317", "\322\314", "\322\261", "\321\304\322\271\323\370", "\320\265", + + /* "ÑÒ", "¿Í¡¿¿Î¡Ê¤Ë¤ó¤Ù¤ó¡Ë", "Ëô", "ÑÜ", "Ȭ", "ѹ", */ + "\321\322", "\277\315\241\277\277\316\241\312\244\313\244\363\244\331\244\363\241\313", "\313\364", "\321\334", "\310\254", "\321\271", + + /* "ÑÌ", "Õß", "×®", "°ê¡Ê¤ª¤ª¤¶¤È)", "¸Ê", "½÷", */ + "\321\314", "\325\337", "\327\256", "\260\352\241\312\244\252\244\252\244\266\244\310\51", "\270\312", "\275\367", + + /* "ׯ", "¸ý", "Áð¡Ê¤¯¤µ¤«¤ó¤à¤ê)", "ÆÈ¡Ê¤±¤â¤Î¤Ø¤ó¡Ë", */ + "\327\306", "\270\375", "\301\360\241\312\244\257\244\265\244\253\244\363\244\340\244\352\51", "\306\310\241\312\244\261\244\342\244\316\244\330\244\363\241\313", + + /* "»Ò", "ïú¡Ê¤³¤¶¤È¡Ë", "»Î", "¹¾¡Ê¤µ¤ó¤º¤¤¡Ë", "×µ", */ + "\273\322", "\357\372\241\312\244\263\244\266\244\310\241\313", "\273\316", "\271\276\241\312\244\265\244\363\244\272\244\244\241\313", "\327\265", + + /* "Õù", "¾®¡¿Ã±¡Ê¤Ä¡Ë", "íè¡Ê¤·¤ó¤Ë¤ç¤¦¡Ë", "À£", "Âç", */ + "\325\371", "\276\256\241\277\303\261\241\312\244\304\241\313", "\355\350\241\312\244\267\244\363\244\313\244\347\244\246\241\313", "\300\243", "\302\347", + + /* "ÅÚ", "¼ê¡Ê¤Æ¤Ø¤ó¡Ë", "¶Ò", "Öø", "»³", "ͼ", */ + "\305\332", "\274\352\241\312\244\306\244\330\244\363\241\313", "\266\322", "\326\370", "\273\263", "\315\274", + + /* "µÝ", "Ë»¡Ê¤ê¤Ã¤·¤ó¤Ù¤ó¡Ë", "·ç", "ÝÆ", "¸¤", */ + "\265\335", "\313\273\241\312\244\352\244\303\244\267\244\363\244\331\244\363\241\313", "\267\347", "\335\306", "\270\244", + + /* "µí¡¿²´¡Ê¤¦¤·¤Ø¤ó¡Ë", "ÊÒ", "ÌÚ", "Ýã", "ÌÓ", "¿´", */ + "\265\355\241\277\262\264\241\312\244\246\244\267\244\330\244\363\241\313", "\312\322", "\314\332", "\335\343", "\314\323", "\277\264", + + /* "¿å", "·î", "ÄÞ", "Æü", "Ú¾", "²Ð", */ + "\277\345", "\267\356", "\304\336", "\306\374", "\332\276", "\262\320", + + /* "Êý", "Øù", "ÅÀ¡Ê¤ì¤Ã¤«¡Ë", "ÝÕ", "·ê", "ÀÐ", */ + "\312\375", "\330\371", "\305\300\241\312\244\354\244\303\244\253\241\313", "\335\325", "\267\352", "\300\320", + + /* "¶Ì", "Èé", "´¤", "»®", "¼¨", "¿À¡Ê¤·¤á¤¹¤Ø¤ó¡Ë", "Çò", */ + "\266\314", "\310\351", "\264\244", "\273\256", "\274\250", "\277\300\241\312\244\267\244\341\244\271\244\330\244\363\241\313", "\307\362", + + /* "ÅÄ", "Ω", "²Ó", "ÌÜ", "â¢", "Ìð", */ + "\305\304", "\316\251", "\262\323", "\314\334", "\342\242", "\314\360", + + /* "áˡʤä¤Þ¤¤¤À¤ì¡Ë", "»Í", "»å", "±±", "±»", "Ï·", */ + "\341\313\241\312\244\344\244\336\244\244\244\300\244\354\241\313", "\273\315", "\273\345", "\261\261", "\261\273", "\317\267", + + /* "´Ì", "°á", "½é¡Ê¤³¤í¤â¤Ø¤ó¡Ë", "ÊÆ", "Àå", "æÐ", */ + "\264\314", "\260\341", "\275\351\241\312\244\263\244\355\244\342\244\330\244\363\241\313", "\312\306", "\300\345", "\346\320", + + /* "Ãݡʤ¿¤±¤«¤ó¤à¤ê¡Ë", "·ì", "¸×¡Ê¤È¤é¤«¤ó¤à¤ê¡Ë", "Æù", */ + "\303\335\241\312\244\277\244\261\244\253\244\363\244\340\244\352\241\313", "\267\354", "\270\327\241\312\244\310\244\351\244\253\244\363\244\340\244\352\241\313", "\306\371", + + /* "À¾", "±©", "ÍÓ", "ææ", "½®", "¼ª", */ + "\300\276", "\261\251", "\315\323", "\346\346", "\275\256", "\274\252", + + /* "Ãî", "ÀÖ", "­¡¿É¥", "ìµ", "¿Ã", */ + "\303\356", "\300\326", "\302\255\241\277\311\245", "\354\265", "\277\303", + + /* "³­", "¿É", "¼Ö", "¸«", "¸À", "ÆÓ", "Áö", "ë", */ + "\263\255", "\277\311", "\274\326", "\270\253", "\270\300", "\306\323", "\301\366", "\303\253", + + /* "³Ñ", "ÈÐ", "Çþ", "Ʀ", "¿È", "ì¸", "±«", "Èó", */ + "\263\321", "\310\320", "\307\376", "\306\246", "\277\310", "\354\270", "\261\253", "\310\363", + + /* "¶â", "Ìç", "ð²", "ÊÇ", "²»", "¹á", "³×", "É÷", */ + "\266\342", "\314\347", "\360\262", "\312\307", "\262\273", "\271\341", "\263\327", "\311\367", + + /* "¼ó", "¿©", "ðê", "ÌÌ", "ÇÏ", "µ´", "ñõ", "¹â", */ + "\274\363", "\277\251", "\360\352", "\314\314", "\307\317", "\265\264", "\361\365", "\271\342", + + /* "ò¨", "¹ü", "µû", "µµ", "Ä»", "¹õ", "¼¯", "É¡", */ + "\362\250", "\271\374", "\265\373", "\265\265", "\304\273", "\271\365", "\274\257", "\311\241", + + /* "óï", "µ­¹æ", "¤½¤Î¾" */ + "\363\357", "\265\255\271\346", "\244\275\244\316\302\276" +}; + +static +char *bushu_skey[] = +{ +/* "¤¤¤Á", "¤Î", "¤¦¤±¤Ð¤³", "¤¸¤å¤¦", "¤Õ¤·", "¤«¤¿¤Ê", */ +"\244\244\244\301", "\244\316", "\244\246\244\261\244\320\244\263", "\244\270\244\345\244\246", "\244\325\244\267", "\244\253\244\277\244\312", + +/* "¤ê¤Ã¤È¤¦", "¤«", "¤¬¤ó", "¤¯", "¤«¤Þ¤¨", "¤Ê¤Ù", "¤Ë", */ +"\244\352\244\303\244\310\244\246", "\244\253", "\244\254\244\363", "\244\257", "\244\253\244\336\244\250", "\244\312\244\331", "\244\313", + +/* "¤Ò¤È", "¤Ì", "¤Ä¤¯¤¨", "¤Ï¤Á", "¤ë", "¤ï", */ +"\244\322\244\310", "\244\314", "\244\304\244\257\244\250", "\244\317\244\301", "\244\353", "\244\357", + +/* "¤¦", "¤¨¤ó", "¤ª¤ª¤¶¤È", "¤ª¤Î¤ì", "¤ª¤ó¤Ê", "¤®¤ç¤¦", */ +"\244\246", "\244\250\244\363", "\244\252\244\252\244\266\244\310", "\244\252\244\316\244\354", "\244\252\244\363\244\312", "\244\256\244\347\244\246", + +/* "¤í", "¤¯¤µ", "¤±¤â¤Î", "¤³", "¤³¤¶¤È", "¤µ¤à¤é¤¤", */ +"\244\355", "\244\257\244\265", "\244\261\244\342\244\316", "\244\263", "\244\263\244\266\244\310", "\244\265\244\340\244\351\244\244", + +/* "¤·", "¤·¤­", "¤·¤ã¤¯", "¤Ä", "¤·¤ó", "¤¹¤ó", */ +"\244\267", "\244\267\244\255", "\244\267\244\343\244\257", "\244\304", "\244\267\244\363", "\244\271\244\363", + +/* "¤À¤¤", "¤É", "¤Æ", "¤Ï¤Ð", "¤Þ", "¤ä¤Þ", */ +"\244\300\244\244", "\244\311", "\244\306", "\244\317\244\320", "\244\336", "\244\344\244\336", + +/* "¤æ¤¦", "¤æ¤ß", "¤ê¤Ã¤·¤ó", "¤±¤Ä", "¤¤¤Á¤¿", "¤¤¤Ì", */ +"\244\346\244\246", "\244\346\244\337", "\244\352\244\303\244\267\244\363", "\244\261\244\304", "\244\244\244\301\244\277", "\244\244\244\314", + +/* "¤¦¤·", "¤«¤¿", "¤­", "¤­¤¬¤Þ¤¨", "¤±", "¤³¤³¤í", */ +"\244\246\244\267", "\244\253\244\277", "\244\255", "\244\255\244\254\244\336\244\250", "\244\261", "\244\263\244\263\244\355", + +/* "¤¹¤¤", "¤Ä¤­", "¤Ä¤á", "¤Ë¤Á", "¤Î¤Ö¤ó", "¤Ò", */ +"\244\271\244\244", "\244\304\244\255", "\244\304\244\341", "\244\313\244\301", "\244\316\244\326\244\363", "\244\322", + +/* "¤Û¤¦", "¤Û¤³", "¤è¤Ä¤Æ¤ó", "¤ë¤Þ¤¿", "¤¢¤Ê", "¤¤¤·", */ +"\244\333\244\246", "\244\333\244\263", "\244\350\244\304\244\306\244\363", "\244\353\244\336\244\277", "\244\242\244\312", "\244\244\244\267", + +/* "¤ª¤¦", "¤«¤ï", "¤«¤ï¤é", "¤µ¤é", "¤·¤á¤¹", "¤Í", */ +"\244\252\244\246", "\244\253\244\357", "\244\253\244\357\244\351", "\244\265\244\351", "\244\267\244\341\244\271", "\244\315", + +/* "¤·¤í", "¤¿", "¤¿¤Ä", "¤Î¤®", "¤á", "¤Ï¤Ä", "¤ä", */ +"\244\267\244\355", "\244\277", "\244\277\244\304", "\244\316\244\256", "\244\341", "\244\317\244\304", "\244\344", + +/* "¤ä¤Þ¤¤", "¤è¤ó", "¤¤¤È", "¤¦¤¹", "¤¦¤ê", "¤ª¤¤", */ +"\244\344\244\336\244\244", "\244\350\244\363", "\244\244\244\310", "\244\246\244\271", "\244\246\244\352", "\244\252\244\244", + +/* "¤«¤ó", "¤­¤Ì", "¤³¤í¤â", "¤³¤á", "¤·¤¿", "¤¹¤­", */ +"\244\253\244\363", "\244\255\244\314", "\244\263\244\355\244\342", "\244\263\244\341", "\244\267\244\277", "\244\271\244\255", + +/* "¤¿¤±", "¤Á", "¤È¤é", "¤Ë¤¯", "¤Ë¤·", "¤Ï¤Í", "¤Ò¤Ä¤¸", */ +"\244\277\244\261", "\244\301", "\244\310\244\351", "\244\313\244\257", "\244\313\244\267", "\244\317\244\315", "\244\322\244\304\244\270", + +/* "¤Õ¤Ç", "¤Õ¤Í", "¤ß¤ß", "¤à¤·", "¤¢¤«", "¤¢¤·", */ +"\244\325\244\307", "\244\325\244\315", "\244\337\244\337", "\244\340\244\267", "\244\242\244\253", "\244\242\244\267", + +/* "¤¤¤Î¤³", "¤ª¤ß", "¤«¤¤", "¤«¤é¤¤", "¤¯¤ë¤Þ", "¤±¤ó", */ +"\244\244\244\316\244\263", "\244\252\244\337", "\244\253\244\244", "\244\253\244\351\244\244", "\244\257\244\353\244\336", "\244\261\244\363", + +/* "¤´¤ó", "¤µ¤±", "¤½¤¦", "¤¿¤Ë", "¤Ä¤Î", "¤Î¤´¤á", */ +"\244\264\244\363", "\244\265\244\261", "\244\275\244\246", "\244\277\244\313", "\244\304\244\316", "\244\316\244\264\244\341", + +/* "¤Ð¤¯", "¤Þ¤á", "¤ß", "¤à¤¸¤Ê", "¤¢¤á", "¤¢¤é¤º", */ +"\244\320\244\257", "\244\336\244\341", "\244\337", "\244\340\244\270\244\312", "\244\242\244\341", "\244\242\244\351\244\272", + +/* "¤«¤Í", "¤â¤ó", "¤Õ¤ë¤È¤ê", "¤Ú¡¼¤¸", "¤ª¤È", "¤³¤¦", */ +"\244\253\244\315", "\244\342\244\363", "\244\325\244\353\244\310\244\352", "\244\332\241\274\244\270", "\244\252\244\310", "\244\263\244\246", + +/* "¤«¤¯", "¤«¤¼", "¤¯¤Ó", "¤·¤ç¤¯", "¤Ê¤á¤·", "¤á¤ó", */ +"\244\253\244\257", "\244\253\244\274", "\244\257\244\323", "\244\267\244\347\244\257", "\244\312\244\341\244\267", "\244\341\244\363", + +/* "¤¦¤Þ", "¤ª¤Ë", "¤«¤ß", "¤¿¤«¤¤", "¤È¤¦", "¤Û¤Í", */ +"\244\246\244\336", "\244\252\244\313", "\244\253\244\337", "\244\277\244\253\244\244", "\244\310\244\246", "\244\333\244\315", + +/* "¤¦¤ª", "¤«¤á", "¤È¤ê", "¤¯¤í", "¤·¤«", "¤Ï¤Ê", */ +"\244\246\244\252", "\244\253\244\341", "\244\310\244\352", "\244\257\244\355", "\244\267\244\253", "\244\317\244\312", + +/* "¤Ï", "¤­¤´¤¦", "¤½¤Î¤¿" */ +"\244\317", "\244\255\244\264\244\246", "\244\275\244\316\244\277" +}; + + +#define BUSHU_CNT (sizeof(bushu_schar)/sizeof(char *)) + + +static forichiranContext newForIchiranContext(void); +static vBushuMode(uiContext d, int major_mode); +static vBushuIchiranQuitCatch(uiContext d, int retval, mode_context env); +static vBushuExitCatch(uiContext d, int retval, mode_context env); +static bushuEveryTimeCatch(uiContext d, int retval, mode_context env); +static bushuExitCatch(uiContext d, int retval, mode_context env); +static bushuQuitCatch(uiContext d, int retval, mode_context env); +static convBushuQuitCatch(uiContext d, int retval, mode_context env); +static bushuHenkan(uiContext d, int flag, int ext, int cur, int (*quitfunc )(uiContext, int, mode_context )); +static makeBushuIchiranQuit(uiContext d, int flag); + +static WCHAR_T *bushu_char[BUSHU_CNT]; +static WCHAR_T *bushu_key[BUSHU_CNT]; + +int +initBushuTable(void) +{ + int retval = 0; + + retval = setWStrings(bushu_char, bushu_schar, BUSHU_CNT); + if (retval != NG) { + retval = setWStrings(bushu_key, bushu_skey, BUSHU_CNT); + } + return retval; +} + + +/* + * Éô¼ó¸õÊä¤Î¥¨¥³¡¼ÍѤÎʸ»úÎó¤òºî¤ë + * + * °ú¤­¿ô RomeStruct + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +inline int +makeBushuEchoStr(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + d->kanji_status_return->echoStr = ic->allkouho[*(ic->curIkouho)]; + d->kanji_status_return->length = 1; + d->kanji_status_return->revPos = 0; + d->kanji_status_return->revLen = 1; + + return(0); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * forichiranContextÍÑ´Ø¿ô * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * forichiranContext ¤Î½é´ü²½ + */ +inline int +clearForIchiranContext(forichiranContext p) +{ + p->id = FORICHIRAN_CONTEXT; + p->curIkouho = 0; + p->allkouho = 0; + + return(0); +} + +static forichiranContext +newForIchiranContext(void) +{ + forichiranContext fcxt; + + if ((fcxt = (forichiranContext)malloc(sizeof(forichiranContextRec))) + == (forichiranContext)NULL) { +#ifndef WIN + jrKanjiError = "malloc (newForIchiranContext) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (newForIchiranContext) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ +#endif + return (forichiranContext)NULL; + } + clearForIchiranContext(fcxt); + + return fcxt; +} + +getForIchiranContext(uiContext d) +{ + forichiranContext fc; + int retval = 0; + + if (pushCallback(d, d->modec, NO_CALLBACK, NO_CALLBACK, + NO_CALLBACK, NO_CALLBACK) == 0) { +#ifndef WIN + jrKanjiError = "malloc (pushCallback) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ +#endif + return(NG); + } + + if((fc = newForIchiranContext()) == NULL) { + popCallback(d); + return(NG); + } + fc->next = d->modec; + d->modec = (mode_context)fc; + + fc->prevMode = d->current_mode; + fc->majorMode = d->majorMode; + + return(retval); +} + +void +popForIchiranMode(uiContext d) +{ + forichiranContext fc = (forichiranContext)d->modec; + + d->modec = fc->next; + d->current_mode = fc->prevMode; + freeForIchiranContext(fc); +} + +#ifndef NO_EXTEND_MENU +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Éô¼ó¥â¡¼¥ÉÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +vBushuMode(uiContext d, int major_mode) +{ + forichiranContext fc; + ichiranContext ic; + unsigned inhibit = 0; + int retval = 0; + + d->status = 0; + + if((retval = getForIchiranContext(d)) == NG) { + killmenu(d); + return(GLineNGReturn(d)); + } + + fc = (forichiranContext)d->modec; + + /* selectOne ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */ + fc->allkouho = bushu_char; + fc->curIkouho = 0; + if (!cannaconf.HexkeySelect) + inhibit |= ((unsigned char)NUMBERING | (unsigned char)CHARINSERT); + else + inhibit |= (unsigned char)CHARINSERT; + + if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, BUSHU_SZ, + BANGOMAX, inhibit, 0, WITH_LIST_CALLBACK, + NO_CALLBACK, vBushuExitCatch, + bushuQuitCatch, uiUtilIchiranTooSmall)) == NG) { + killmenu(d); + return(GLineNGReturnFI(d)); + } + + ic = (ichiranContext)d->modec; + ic->majorMode = major_mode; + ic->minorMode = CANNA_MODE_BushuMode; + currentModeInfo(d); + + *(ic->curIkouho) = d->curbushu; + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + killmenu(d); + return(retval); + } + + if ( !(ic->flags & ICHIRAN_ALLOW_CALLBACK) ) { + makeGlineStatus(d); + } + /* d->status = ICHIRAN_EVERYTIME; */ + + return(retval); +} + +static +vBushuIchiranQuitCatch(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */ + + if (((forichiranContext)env)->allkouho != (WCHAR_T **)bushu_char) { + /* bushu_char ¤Ï static ¤ÎÇÛÎó¤À¤«¤é free ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£ + ¤³¤¦¸À¤¦¤Î¤Ã¤Æ¤Ê¤ó¤«±ø¤¤¤Ê¤¢ */ + freeGetIchiranList(((forichiranContext)env)->allkouho); + } + popForIchiranMode(d); + popCallback(d); + + return(vBushuMode(d, CANNA_MODE_BushuMode)); +} + +static +vBushuExitCatch(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + forichiranContext fc; + int cur, res; + + popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */ + + fc = (forichiranContext)d->modec; + cur = fc->curIkouho; + + popForIchiranMode(d); + popCallback(d); + + res = bushuHenkan(d, 1, 1, cur, vBushuIchiranQuitCatch); + if (res < 0) { + makeYomiReturnStruct(d); + return 0; + } + return res; +} + +BushuMode(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + killmenu(d); + return NothingChangedWithBeep(d); + } + + return(vBushuMode(d, CANNA_MODE_BushuMode)); +} +#endif /* not NO_EXTEND_MENU */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Éô¼ó¥â¡¼¥ÉÆþÎϤΰìÍ÷ɽ¼¨ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static bushuEveryTimeCatch (uiContext, int, mode_context); + +static +bushuEveryTimeCatch(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + makeBushuEchoStr(d); + + return(retval); +} + +static bushuExitCatch (uiContext, int, mode_context); + +static +bushuExitCatch(uiContext d, int retval, mode_context env) +{ + yomiContext yc; + + popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */ + + if (((forichiranContext)env)->allkouho != bushu_char) { + /* bushu_char ¤Ï static ¤ÎÇÛÎó¤À¤«¤é free ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£ + ¤³¤¦¸À¤¦¤Î¤Ã¤Æ¤Ê¤ó¤«±ø¤¤¤Ê¤¢ */ + freeGetIchiranList(((forichiranContext)env)->allkouho); + } + popForIchiranMode(d); + popCallback(d); + yc = (yomiContext)d->modec; + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + } + retval = YomiExit(d, retval); + killmenu(d); + currentModeInfo(d); + + return retval; +} + +#ifndef NO_EXTEND_MENU +static +bushuQuitCatch(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */ + + if (((forichiranContext)env)->allkouho != (WCHAR_T **)bushu_char) { + /* bushu_char ¤Ï static ¤ÎÇÛÎó¤À¤«¤é free ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£ + ¤³¤¦¸À¤¦¤Î¤Ã¤Æ¤Ê¤ó¤«±ø¤¤¤Ê¤¢ */ + freeGetIchiranList(((forichiranContext)env)->allkouho); + } + popForIchiranMode(d); + popCallback(d); + currentModeInfo(d); + GlineClear(d); + + return prevMenuIfExist(d); +} +#endif /* not NO_EXTEND_MENU */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Éô¼ó¤È¤·¤Æ¤ÎÊÑ´¹¤Î°ìÍ÷ɽ¼¨ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +convBushuQuitCatch(uiContext d, int retval, mode_context env) +{ + popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */ + + if (((forichiranContext)env)->allkouho != (WCHAR_T **)bushu_char) { + /* bushu_char ¤Ï static ¤ÎÇÛÎó¤À¤«¤é free ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£ + ¤³¤¦¸À¤¦¤Î¤Ã¤Æ¤Ê¤ó¤«±ø¤¤¤Ê¤¢ */ + freeGetIchiranList(((forichiranContext)env)->allkouho); + } + popForIchiranMode(d); + popCallback(d); + + makeYomiReturnStruct(d); + currentModeInfo(d); + + return(retval); +} + +/* + * ÆÉ¤ß¤òÉô¼ó¤È¤·¤ÆÊÑ´¹¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +int ConvertAsBushu (uiContext); + +ConvertAsBushu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int res; + + d->status = 0; /* clear status */ + + if (yc->henkanInhibition & CANNA_YOMI_INHIBIT_ASBUSHU || + yc->right || yc->left) { + return NothingChangedWithBeep(d); + } + + if (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) { + if (!(yc->status & CHIKUJI_OVERWRAP) && yc->nbunsetsu) { + moveToChikujiTanMode(d); + return TanKouhoIchiran(d); + } + else if (yc->nbunsetsu) { + return NothingChanged(d); + } + } + + d->nbytes = yc->kEndp; + WStrncpy(d->buffer_return, yc->kana_buffer, d->nbytes); + + /* 0 ¤Ï¡¢ConvertAsBushu ¤«¤é¸Æ¤Ð¤ì¤¿¤³¤È¤ò¼¨¤¹ */ + res = bushuHenkan(d, 0, 1, 0, convBushuQuitCatch); + if (res < 0) { + makeYomiReturnStruct(d); + return 0; + } + return res; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ¶¦ÄÌÉô * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * ÆÉ¤ß¤òÉô¼ó¼­½ñ¤«¤éÉô¼óÊÑ´¹¤¹¤ë + */ +inline int +bushuBgnBun(RkStat *st, WCHAR_T *yomi, int length) +{ + int nbunsetsu; + extern defaultBushuContext; + + /* ϢʸÀáÊÑ´¹¤ò³«»Ï¤¹¤ë *//* ¼­½ñ¤Ë¤¢¤ë¸õÊä¤Î¤ß¼è¤ê½Ð¤¹ */ + if ((defaultBushuContext == -1)) { + if (KanjiInit() == -1 || defaultBushuContext == -1) { + jrKanjiError = KanjiInitError(); + return(NG); + } + } + + nbunsetsu = RkwBgnBun(defaultBushuContext, yomi, length, RK_CTRLHENKAN); + if(nbunsetsu == -1) { + if(errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\313\274\272\307\324\244\267\244\336\244\267\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return(NG); + } + + if(RkwGetStat(defaultBushuContext, st) == -1) { + if(errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\245\271\245\306\245\244\245\277\245\271\244\362\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307\244\267\244\277"; + /* ¥¹¥Æ¥¤¥¿¥¹¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + return(NG); + } + + return(nbunsetsu); +} + +/* + * ÆÉ¤ß¤ËȾÂùÅÀ¤òÉղ䷤ƸõÊä°ìÍ÷¹Ô¤òɽ¼¨¤¹¤ë + * + * °ú¤­¿ô uiContext + * flag ConvertAsBushu¤«¤é¸Æ¤Ð¤ì¤¿ 0 + * BushuYomiHenkan¤«¤é¸Æ¤Ð¤ì¤¿ 1 + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + * + * + * ¤³¤³¤ËÍè¤ë»þ¤Ï¤Þ¤À getForIchiranContext ¤¬¸Æ¤Ð¤ì¤Æ¤¤¤Ê¤¤¤â¤Î¤È¤¹¤ë + */ + +static +bushuHenkan(uiContext d, int flag, int ext, int cur, int (*quitfunc )(uiContext, int, mode_context )) +{ + forichiranContext fc; + ichiranContext ic; + unsigned inhibit = 0; + WCHAR_T *yomi, **allBushuCands; + RkStat st; + int nelem, currentkouho, nbunsetsu, length, retval = 0; + extern defaultBushuContext; + + + if(flag) { + yomi = (WCHAR_T *)bushu_key[cur]; + length = WStrlen(yomi); + d->curbushu = (short)cur; + } else { + d->nbytes = RomajiFlushYomi(d, d->buffer_return, d->n_buffer); + yomi = d->buffer_return; + length = d->nbytes; + } + + if((nbunsetsu = bushuBgnBun(&st, yomi, length)) == NG) { + killmenu(d); + (void)GLineNGReturn(d); + return -1; + } + + if((nbunsetsu != 1) || (st.klen > 1) || (st.maxcand == 0)) { + /* Éô¼ó¤È¤·¤Æ¤Î¸õÊ䤬¤Ê¤¤ */ + + d->kanji_status_return->length = -1; + + makeBushuIchiranQuit(d, flag); + currentModeInfo(d); + + killmenu(d); + if(flag) { + makeGLineMessageFromString(d, "\244\263\244\316\311\364\274\363\244\316\270\365\312\344\244\317\244\242\244\352\244\336\244\273\244\363"); + /* ¤³¤ÎÉô¼ó¤Î¸õÊä¤Ï¤¢¤ê¤Þ¤»¤ó */ + } else { + return(NothingChangedWithBeep(d)); + } + return(0); + } + + /* ¸õÊä°ìÍ÷¹Ô¤òɽ¼¨¤¹¤ë */ + /* 0 ¤Ï¡¢¥«¥ì¥ó¥È¸õÊä + 0 ¤ò¥«¥ì¥ó¥È¸õÊä¤Ë¤¹¤ë¤³¤È¤ò¼¨¤¹ */ + + if((allBushuCands + = getIchiranList(defaultBushuContext, &nelem, ¤tkouho)) == 0) { + killmenu(d); + (void)GLineNGReturn(d); + return -1; + } + + /* Éô¼óÊÑ´¹¤Ï³Ø½¬¤·¤Ê¤¤¡£ */ + if(RkwEndBun(defaultBushuContext, 0) == -1) { /* 0:³Ø½¬¤·¤Ê¤¤ */ + if(errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + freeGetIchiranList(allBushuCands); + killmenu(d); + (void)GLineNGReturn(d); + return -1; + } + + if(getForIchiranContext(d) == NG) { + freeGetIchiranList(allBushuCands); + killmenu(d); + (void)GLineNGReturn(d); + return -1; + } + + fc = (forichiranContext)d->modec; + fc->allkouho = allBushuCands; + + if (!cannaconf.HexkeySelect) + inhibit |= (unsigned char)NUMBERING; + fc->curIkouho = currentkouho; /* ¸½ºß¤Î¥«¥ì¥ó¥È¸õÊäÈÖ¹æ¤òÊݸ¤¹¤ë */ + currentkouho = 0; /* ¥«¥ì¥ó¥È¸õÊ䤫¤é²¿ÈÖÌܤò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë¤« */ + + if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, nelem, BANGOMAX, + inhibit, currentkouho, WITH_LIST_CALLBACK, + bushuEveryTimeCatch, bushuExitCatch, + quitfunc, uiUtilIchiranTooSmall)) == NG) { + freeGetIchiranList(allBushuCands); + killmenu(d); + (void)GLineNGReturnFI(d); + return -1; + } + + ic = (ichiranContext)d->modec; + + if(!flag) { /* convertAsBushu */ + ic->majorMode = ic->minorMode = CANNA_MODE_BushuMode; + } else { + if(ext) { + ic->majorMode = ic->minorMode = CANNA_MODE_BushuMode; + } else { + ic->majorMode = CANNA_MODE_ExtendMode; + ic->minorMode = CANNA_MODE_BushuMode; + } + } + currentModeInfo(d); + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + killmenu(d); + return(retval); + } + + if ( !(ic->flags & ICHIRAN_ALLOW_CALLBACK) ) { + makeGlineStatus(d); + } + /* d->status = EVERYTIME_CALLBACK; */ + + return(retval); +} + +/* + * ¸õÊä¹Ô¤ò¾Ãµî¤·¡¢Éô¼ó¥â¡¼¥É¤«¤éÈ´¤±¡¢ÆÉ¤ß¤¬¤Ê¤¤¥â¡¼¥É¤Ë°Ü¹Ô¤¹¤ë + * + * °ú¤­¿ô uiContext + * flag ConvertAsBushu¤«¤é¸Æ¤Ð¤ì¤¿ 0 + * BushuYomiHenkan¤«¤é¸Æ¤Ð¤ì¤¿ 1 + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static +makeBushuIchiranQuit(uiContext d, int flag) +{ + extern defaultBushuContext; + + /* Éô¼óÊÑ´¹¤Ï³Ø½¬¤·¤Ê¤¤¡£ */ + if(RkwEndBun(defaultBushuContext, 0) == -1) { /* 0:³Ø½¬¤·¤Ê¤¤ */ + if(errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return(NG); + } + + if(flag) { + /* kanji_status_return ¤ò¥¯¥ê¥¢¤¹¤ë */ + d->kanji_status_return->length = 0; + d->kanji_status_return->revLen = 0; + +/* + d->status = QUIT_CALLBACK; +*/ + } else { + makeYomiReturnStruct(d); + } + GlineClear(d); + + return(0); +} + + diff --git a/src/add-ons/input_server/methods/canna/lib/canna.h b/src/add-ons/input_server/methods/canna/lib/canna.h new file mode 100644 index 0000000000..4d81c0fcb7 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/canna.h @@ -0,0 +1,1275 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * @(#) 102.1 $Id: canna.h,v 1.1 2004/12/23 21:23:48 korli Exp $ + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#ifndef _CANNA_H_ +#define _CANNA_H_ + +#include "cannaconf.h" +#include "widedef.h" +#include +#include +#include +#include + +#include +# ifndef index +# define index strchr +# endif + +#include +#include + +#ifdef BIGPOINTER +#define POINTERINT long long +#else +#define POINTERINT long +#endif + +#define WCHARSIZE (sizeof(WCHAR_T)) + +#ifdef HAVE_WCHAR_OPERATION + +#ifndef JAPANESE_LOCALE +#define JAPANESE_LOCALE "japan" +#endif + +#define MBstowcs mbstowcs +#define WCstombs wcstombs + +#else + +#define MBstowcs CANNA_mbstowcs +#define WCstombs CANNA_wcstombs + +extern CANNA_wcstombs (char *, WCHAR_T *, int); + +#endif + +#define STROKE_LIMIT 500 /* ¥¹¥È¥í¡¼¥¯¤ÇÀܳ¤òÀÚ¤ë */ + +# include + +typedef unsigned char BYTE; + +/* + * CANNALIBDIR -- ¥·¥¹¥Æ¥à¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤ä¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹ + * ¥Æ¡¼¥Ö¥ë¤¬ÃÖ¤«¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¡£ + */ + +//#ifndef CANNALIBDIR +//#define CANNALIBDIR "/usr/lib/canna" +//#endif + +/* flags ¤Î¾ðÊó */ +#define CANNA_KANJIMODE_TABLE_SHARED 01 +#define CANNA_KANJIMODE_EMPTY_MODE 02 + +/* func ¤ÎÂè»°°ú¿ô */ +#define KEY_CALL 0 +#define KEY_CHECK 1 +#define KEY_SET 2 + +extern BYTE default_kmap[]; + +/* menuitem -- ¥á¥Ë¥å¡¼É½¼¨¤Î¹àÌܤòÄêµÁ¤¹¤ë¥Æ¡¼¥Ö¥ë */ + +typedef struct _menuitem { + int flag; /* ²¼¤ò¸«¤è */ + union { + struct _menustruct *menu_next; /* ¥á¥Ë¥å¡¼¤Ø¤Î¥Ý¥¤¥ó¥¿ */ + int fnum; /* µ¡Ç½ÈÖ¹æ */ + char *misc; /* ¤½¤Î¾(lisp ¤Î¥·¥ó¥Ü¥ë¤Ê¤É) */ + } u; +} menuitem; + +#define MENU_SUSPEND 0 /* ¤Þ¤À·è¤Þ¤Ã¤Æ¤¤¤Ê¤¤(lisp ¤Î¥·¥ó¥Ü¥ë) */ +#define MENU_MENU 1 /* ¥á¥Ë¥å¡¼ */ +#define MENU_FUNC 2 /* µ¡Ç½ÈÖ¹æ */ + +/* menustruct -- ¥á¥Ë¥å¡¼¤ò¤·¤­¤ë¹½Â¤ÂÎ */ + +typedef struct _menustruct { + int nentries; /* ¥á¥Ë¥å¡¼¤Î¹àÌܤοô */ + WCHAR_T **titles; /* ¥á¥Ë¥å¡¼¤Î¸«½Ð¤·¥ê¥¹¥È */ + WCHAR_T *titledata; /* ¾å¤Î¥ê¥¹¥È¤Î¼ÂÂÖʸ»úÎó */ + menuitem *body; /* ¥á¥Ë¥å¡¼¤ÎÃæ¿È(ÇÛÎó) */ + int modeid; /* ¥á¥Ë¥å¡¼¤Î¥â¡¼¥ÉÈÖ¹æ */ + struct _menustruct *prev; /* °ì¤ÄÁ°¤Î¥á¥Ë¥å¡¼¤Ø¤Î¥Ý¥¤¥ó¥¿ */ +} menustruct; + +typedef struct _menuinfo { + menustruct *mstruct; /* ¤É¤Î¥á¥Ë¥å¡¼¤Î */ + int curnum; /* ¤³¤Ê¤¤¤ÀÁªÂò¤µ¤ì¤¿ÈÖ¹æ¤Ï¤³¤ì¤Ç¤¹¤è */ + struct _menuinfo *next; +} menuinfo; + +/* defselection ¤ÇÄêµÁ¤µ¤ì¤¿µ­¹æ´Ø·¸¤Î°ìÍ÷¤ò¤È¤Ã¤Æ¤ª¤¯¹½Â¤ÂÎ */ + +typedef struct { + WCHAR_T **kigo_data; /* °ìÍ÷ɽ¼¨¤Î³ÆÍ×ÁǤÎÇÛÎó */ + WCHAR_T *kigo_str; /* °ìÍ÷ɽ¼¨¤ÎÁ´Í×ÁǤòÆþ¤ì¤ëÇÛÎó */ + int kigo_size; /* Í×ÁǤοô */ + int kigo_mode; /* ¤½¤Î¤È¤­¤Î¥â¡¼¥É */ +} kigoIchiran; + +typedef struct _selectinfo { + kigoIchiran *ichiran; /* ¤É¤Î°ìÍ÷¤Î */ + int curnum; /* Á°²óÁªÂò¤µ¤ì¤¿ÈÖ¹æ */ + struct _selectinfo *next; +} selectinfo; + +/* deldicinfo -- ñ¸ìºï½ü¤ÎºÝ¤ËɬÍפʼ­½ñ¤Î¾ðÊó¤ò¤¤¤ì¤Æ¤ª¤¯¹½Â¤ÂÎ */ + +#define INDPHLENGTH 16 /* ¼«Î©¸ì¤Ç°ìÈÖŤ¤ÉÊ»ì¤ÎŤµ */ + +typedef struct _deldicinfo { + WCHAR_T *name; + WCHAR_T hcode[INDPHLENGTH]; +} deldicinfo; + +/* + * glineinfo -- ¸õÊä°ìÍ÷ɽ¼¨¤Î¤¿¤á¤ÎÆâÉô¾ðÊó¤ò³ÊǼ¤·¤Æ¤ª¤¯¤¿¤á¤Î¹½Â¤ÂΡ£ + * ¤½¤ì¤¾¤ì¤Î¥á¥ó¥Ð¤Ï°Ê²¼¤Î°ÕÌ£¤ò»ý¤Ä¡£ + * + * glkosu -- ¤½¤Î¹Ô¤Ë¤¢¤ë¸õÊä¤Î¿ô + * glhead -- ¤½¤Î¹Ô¤ÎÀèÆ¬¸õÊ䤬¡¢kouhoinfo¤Î²¿ÈÖÌܤ«(0¤«¤é¿ô¤¨¤ë) + * gllen -- ¤½¤Î¹Ô¤òɽ¼¨¤¹¤ë¤¿¤á¤Îʸ»úÎó¤ÎŤµ + * gldata -- ¤½¤Î¹Ô¤òɽ¼¨¤¹¤ë¤¿¤á¤Îʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + */ + +typedef struct { + int glkosu; + int glhead; + int gllen; + WCHAR_T *gldata; +} glineinfo; + +/* + * kouhoinfo -- ¸õÊä°ìÍ÷¤Î¤¿¤á¤ÎÆâÉô¾ðÊó¤ò³ÊǼ¤·¤Æ¤ª¤¯¤¿¤á¤Î¹½Â¤ÂÎ + * ¤½¤ì¤¾¤ì¤Î¥á¥ó¥Ð¤Ï°Ê²¼¤Î°ÕÌ£¤ò»ý¤Ä¡£ + * + * khretsu -- ¤½¤Î¸õÊ䤬¤¢¤ë¹Ô + * khpoint -- ¤½¤Î¸õÊä¤Î¹Ô¤Î¤Ê¤«¤Ç¤Î°ÌÃÖ + * khdata -- ¤½¤Î¸õÊä¤Îʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + */ + +typedef struct { + int khretsu; + int khpoint; + WCHAR_T *khdata; +} kouhoinfo; + +#define ROMEBUFSIZE 1024 +#define BANGOSIZE 2 /* ¸õÊä¹ÔÃæ¤Î³Æ¸õÊä¤ÎÈÖ¹æ¤Î¥³¥é¥à¿ô */ +#define BANGOMAX 9 /* £±¸õÊä¹ÔÃæ¤ÎºÇÂç¸õÊä¿ô */ + +#define KIGOBANGOMAX 16 /* £±¸õÊä¹ÔÃæ¤ÎºÇÂç¸õÊä¿ô */ +#define GOBISUU 9 + +#define ON 1 +#define OFF 0 + +#define NG -1 + +#define NO_CALLBACK (canna_callback_t)0 +#define NCALLBACK 4 + +#define JISHU_HIRA 0 +#define JISHU_ZEN_KATA 1 +#define JISHU_HAN_KATA 2 +#define JISHU_ZEN_ALPHA 3 +#define JISHU_HAN_ALPHA 4 +#define MAX_JISHU 5 + +#define SENTOU 0x01 +#define HENKANSUMI 0x02 +#define SUPKEY 0x04 +#define GAIRAIGO 0x08 +#define STAYROMAJI 0x10 + +/* ñ¸ìÅÐÏ¿¤ÎÉÊ»ì */ +#define MEISHI 0 +#define KOYUMEISHI 1 +#define DOSHI 2 +#define KEIYOSHI 3 +#define KEIYODOSHI 4 +#define FUKUSHI 5 +#define TANKANJI 6 +#define SUSHI 7 +#define RENTAISHI 8 +#define SETSUZOKUSHI 9 +#define SAHENMEISHI 10 +#define MEISHIN 11 +#define JINMEI 12 +#define KOYUMEISHIN 13 +#define GODAN 14 +#define RAGYODOSHI 15 +#define RAGYOGODAN 16 +#define KAMISHIMO 17 +#define KEIYOSHIY 18 +#define KEIYOSHIN 19 +#define KEIYODOSHIY 20 +#define KEIYODOSHIN 21 +#define FUKUSHIY 22 +#define FUKUSHIN 23 + +/* identifier for each context structures */ +#define CORE_CONTEXT ((BYTE)0) +#define YOMI_CONTEXT ((BYTE)1) +#define ICHIRAN_CONTEXT ((BYTE)2) +#define FORICHIRAN_CONTEXT ((BYTE)3) +#define MOUNT_CONTEXT ((BYTE)4) +#define TOUROKU_CONTEXT ((BYTE)5) +#define TAN_CONTEXT ((BYTE)6) + +typedef struct _coreContextRec { + BYTE id; + BYTE majorMode, minorMode; + struct _kanjiMode *prevMode; /* £±¤ÄÁ°¤Î¥â¡¼¥É */ + struct _coreContextRec *next; +} coreContextRec, *coreContext; + +typedef coreContext mode_context; + +typedef struct _yomiContextRec { + /* core ¾ðÊó¤ÈƱ¤¸¾ðÊó */ + BYTE id; + BYTE majorMode, minorMode; + struct _kanjiMode *prevMode; /* £±¤ÄÁ°¤Î¥â¡¼¥É */ + mode_context next; + + struct _kanjiMode *curMode; + struct _tanContextRec *left, *right; + + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹´Ø·¸ */ + struct RkRxDic *romdic; /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë */ + WCHAR_T romaji_buffer[ROMEBUFSIZE]; + /* ¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¤Ï rStartp, rEndp ¤Î£²¤Ä¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì + * ¤ë¡£rStartp ¤Ï¥«¥Ê¤ËÊÑ´¹¤Ç¤­¤Ê¤«¤Ã¤¿¥í¡¼¥Þ»ú¤ÎºÇ½é¤Îʸ»ú¤Ø¤Î¥¤¥ó¥Ç¥Ã + * ¥¯¥¹¤Ç¤¢¤ê¡¢rEndp ¤Ï¿·¤¿¤Ë¥í¡¼¥Þ»ú¤òÆþÎϤ¹¤ë»þ¤Ë¡¢³ÊǼ¤¹¤Ù¤­ + * romaji_buffer Æâ¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤Ç¤¢¤ë¡£¿·¤¿¤ËÆþÎϤµ¤ì¤ë¥í¡¼¥Þ»ú¤Ï¡¢ + * romaji_buffer + rEndp ¤è¤êÀè¤Ë³ÊǼ¤µ¤ì¡¢¤½¤Î¥í¡¼¥Þ»ú¤ò¥«¥Ê¤ËÊÑ´¹¤¹ + * ¤ë»þ¤Ï¡¢romaji_buffer + rStartp ¤«¤é rEndp - rStartp ¥Ð¥¤¥È¤Îʸ»ú¤¬ + * ÂоݤȤʤ롣 */ + int rEndp, rStartp, rCurs; /* ¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¤Î¥Ý¥¤¥ó¥¿ */ + WCHAR_T kana_buffer[ROMEBUFSIZE]; + BYTE rAttr[ROMEBUFSIZE], kAttr[ROMEBUFSIZE]; + int kEndp; /* ¤«¤Ê¥Ð¥Ã¥Õ¥¡¤ÎºÇ¸å¤ò²¡¤¨¤ë¥Ý¥¤¥ó¥¿ */ + int kRStartp, kCurs; + + /* ¤½¤Î¾¤Î¥ª¥×¥·¥ç¥ó */ + BYTE myMinorMode; /* yomiContext ¸ÇÍ­¤Î¥Þ¥¤¥Ê¥â¡¼¥É */ + struct _kanjiMode *myEmptyMode; /* empty ¥â¡¼¥É¤Ï¤É¤ì¤« */ + long generalFlags; /* see below */ + long savedFlags; /* ¾å¤Î¥Õ¥é¥°¤Î°ìÉô¤Î¥»¡¼¥Ö */ + BYTE savedMinorMode; /* ¥Þ¥¤¥Ê¥â¡¼¥É¤Î¥»¡¼¥Ö */ + BYTE allowedChars; /* see jrkanji.h */ + BYTE henkanInhibition; /* see below */ + int cursup; /* ¥í¤«¤Ê¤ÎÊäÄɤλþ¤Ë»È¤¦ */ +#define SUSPCHARBIAS 100 + int n_susp_chars; + +/* from henkanContext */ + /* ¥«¥Ê´Á»úÊÑ´¹´Ø·¸ */ + int context; + int kouhoCount; /* ²¿²ó henkanNext ¤¬Ï¢Â³¤·¤Æ²¡¤µ¤ì¤¿¤« */ + WCHAR_T echo_buffer[ROMEBUFSIZE]; + WCHAR_T **allkouho; /* RkGetKanjiList¤ÇÆÀ¤é¤ì¤ëʸ»úÎó¤òÇÛÎó¤Ë¤·¤Æ + ¤È¤Ã¤Æ¤ª¤¯¤È¤³¤í */ + int curbun; /* ¥«¥ì¥ó¥ÈʸÀá */ + int curIkouho; /* ¥«¥ì¥ó¥È¸õÊä */ + int nbunsetsu; /* ʸÀá¤Î¿ô */ + +/* ifdef MEASURE_TIME */ + long proctime; /* ½èÍý»þ´Ö(ÊÑ´¹¤Ç·×¬¤¹¤ë */ + long rktime; /* ½èÍý»þ´Ö(RK¤Ë¤«¤«¤ë»þ´Ö) */ +/* endif MEASURE_TIME */ +/* end of from henkanContext */ + +/* Ã༡¥³¥ó¥Æ¥­¥¹¥È¤«¤é */ + int ye, ys, status; +/* Ã༡¥³¥ó¥Æ¥­¥¹¥È¤«¤é(¤³¤³¤Þ¤Ç) */ + int cStartp, cRStartp; /* Ã༡¤ÇÆÉ¤ß¤È¤·¤Æ»Ä¤Ã¤Æ¤¤¤ëÉôʬ */ + +/* »ú¼ï¥³¥ó¥Æ¥­¥¹¥È¤«¤é */ + BYTE inhibition; + BYTE jishu_kc, jishu_case; + int jishu_kEndp, jishu_rEndp; + short rmark; +/* »ú¼ï¥³¥ó¥Æ¥­¥¹¥È¤«¤é(¤³¤³¤Þ¤Ç) */ + +/* adjustContext ¤«¤é */ + int kanjilen, bunlen; /* ´Á»úÉôʬ¡¢Ê¸Àá¤ÎŤµ */ +/* adjustContext ¤«¤é(¤³¤³¤Þ¤Ç) */ + struct _kanjiMode *tanMode; /* ñ¸õÊä¤Î¤È¤­¤Î¥â¡¼¥É */ + int tanMinorMode; /* ¡· */ + + /* ºî¶ÈÍÑÊÑ¿ô */ + int last_rule; /* Á°²ó¤Î¥í¤«¤ÊÊÑ´¹¤Ë»È¤ï¤ì¤¿¥ë¡¼¥ë */ + WCHAR_T *retbuf, *retbufp; + int retbufsize; + short pmark, cmark; /* £±¤ÄÁ°¤Î¥Þ¡¼¥¯¤Èº£¤Î¥Þ¡¼¥¯ */ + BYTE englishtype; /* ±Ñ¸ì¥¿¥¤¥×(°Ê²¼¤ò¸«¤è) */ +} yomiContextRec, *yomiContext; + +/* for generalFlags */ +#define CANNA_YOMI_MODE_SAVED 0x01L /* savedFlags ¤Ë¤·¤«»È¤ï¤ì¤Ê¤¤ */ + +#define CANNA_YOMI_BREAK_ROMAN 0x01L +#define CANNA_YOMI_CHIKUJI_MODE 0x02L +#define CANNA_YOMI_CHGMODE_INHIBITTED 0x04L +#define CANNA_YOMI_END_IF_KAKUTEI 0x08L +#define CANNA_YOMI_DELETE_DONT_QUIT 0x10L + +#define CANNA_YOMI_IGNORE_USERSYMBOLS 0x20L +#define CANNA_YOMI_IGNORE_HENKANKEY 0x40L + +#define CANNA_YOMI_BASE_CHIKUJI 0x80L /* ¿´¤ÏÃ༡ */ + +/* for generalFlags also used in savedFlags */ + +/* °Ê²¼¤Î ATTRFUNCS ¤Ë¥Þ¥¹¥¯¤µ¤ì¤ë¥Ó¥Ã¥È¤Ï defmode ¤Î°À­¤È¤·¤Æ»È¤ï¤ì¤ë */ +#define CANNA_YOMI_KAKUTEI 0x0100L +#define CANNA_YOMI_HENKAN 0x0200L +#define CANNA_YOMI_ZENKAKU 0x0400L +#define CANNA_YOMI_HANKAKU 0x0800L /* ¼ÂºÝ¤ËȾ³Ñ */ +#define CANNA_YOMI_HIRAGANA 0x1000L +#define CANNA_YOMI_KATAKANA 0x2000L +#define CANNA_YOMI_ROMAJI 0x4000L +#define CANNA_YOMI_JISHUFUNCS 0x7c00L +#define CANNA_YOMI_ATTRFUNCS 0x7f00L + +#define CANNA_YOMI_BASE_HANKAKU 0x8000L /* ¿´¤ÏȾ³Ñ */ + +/* kind of allowed input keys */ +#define CANNA_YOMI_INHIBIT_NONE 0 +#define CANNA_YOMI_INHIBIT_HENKAN 1 +#define CANNA_YOMI_INHIBIT_JISHU 2 +#define CANNA_YOMI_INHIBIT_ASHEX 4 +#define CANNA_YOMI_INHIBIT_ASBUSHU 8 +#define CANNA_YOMI_INHIBIT_ALL 15 + +/* ¸õÊä°ìÍ÷¤Î¤¿¤á¤Î¥Õ¥é¥° */ +#define NUMBERING 1 +#define CHARINSERT 2 + +#define CANNA_JISHU_UPPER 1 +#define CANNA_JISHU_LOWER 2 +#define CANNA_JISHU_CAPITALIZE 3 +#define CANNA_JISHU_MAX_CASE 4 + +/* englishtype */ +#define CANNA_ENG_KANA 0 /* ½Ì¾®¤¹¤ë¤³¤È */ +#define CANNA_ENG_ENG1 1 +#define CANNA_ENG_ENG2 2 /* ξü¤Ë¶õÇò¤¬Æþ¤Ã¤Æ¤¤¤ë */ +#define CANNA_ENG_NO 3 + +/* yc->status ¤Î¥Õ¥é¥°(Ã༡ÍÑ) */ + +#define CHIKUJI_ON_BUNSETSU 0x0001 /* ʸÀá¾å¤Ë¤¢¤ë */ +#define CHIKUJI_OVERWRAP 0x0002 /* ʸÀᤫ¤ÄÆÉ¤ß¾õÂÖ¡© */ +#define CHIKUJI_NULL_STATUS 0 /* ¾å¤Î¤ò¾Ã¤¹ÍÑ */ + +/* yc ¤ò»È¤¦¥â¡¼¥É¤Î¶èÊÌ(Í¥Àè½ç) */ + +#define adjustp(yc) (0< (yc)->bunlen) +#define jishup(yc) (0 < (yc)->jishu_kEndp) +#define chikujip(yc) ((yc)->generalFlags & CANNA_YOMI_CHIKUJI_MODE) +#define henkanp(yc) (0 < (yc)->nbunsetsu) + +#define chikujiyomiremain(yc) ((yc)->cStartp < (yc)->kEndp) + +typedef struct _ichiranContextRec { + BYTE id; + BYTE majorMode, minorMode; + struct _kanjiMode *prevMode; /* £±¤ÄÁ°¤Î¥â¡¼¥É */ + mode_context next; + + int svIkouho; /* ¥«¥ì¥ó¥È¸õÊä¤ò°ì»þ¤È¤Ã¤Æ¤ª¤¯(°ìÍ÷ɽ¼¨¹Ô) */ + int *curIkouho; /* ¥«¥ì¥ó¥È¸õÊä */ + int nIkouho; /* ¸õÊä¤Î¿ô(°ìÍ÷ɽ¼¨¹Ô) */ + int tooSmall; /* ¥«¥é¥à¿ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤¤è¥Õ¥é¥° */ + int curIchar; /* ̤³ÎÄêʸ»úÎ󤢤ê¤Îñ¸ìÅÐÏ¿¤Îñ¸ìÆþÎϤΠ+ ÀèÆ¬Ê¸»ú¤Î°ÌÃÖ */ + BYTE inhibit; + BYTE flags; /* ²¼¤ò¸«¤Æ¤Í */ + WCHAR_T **allkouho; /* RkGetKanjiList¤ÇÆÀ¤é¤ì¤ëʸ»úÎó¤òÇÛÎó¤Ë¤·¤Æ + ¤È¤Ã¤Æ¤ª¤¯¤È¤³¤í */ + WCHAR_T *glinebufp; /* ¸õÊä°ìÍ÷¤Î¤¢¤ë°ì¹Ô¤òɽ¼¨¤¹¤ë¤¿¤á¤Îʸ»ú + Îó¤Ø¤Î¥Ý¥¤¥ó¥¿ */ + kouhoinfo *kouhoifp; /* ¸õÊä°ìÍ÷´Ø·¸¤Î¾ðÊó¤ò³ÊǼ¤·¤Æ¤ª¤¯¹½Â¤ÂÎ + ¤Ø¤Î¥Ý¥¤¥ó¥¿ */ + glineinfo *glineifp; /* ¸õÊä°ìÍ÷´Ø·¸¤Î¾ðÊó¤ò³ÊǼ¤·¤Æ¤ª¤¯¹½Â¤ÂÎ + ¤Ø¤Î¥Ý¥¤¥ó¥¿ */ +} ichiranContextRec, *ichiranContext; + +/* ¥Õ¥é¥°¤Î°ÕÌ£ */ +#define ICHIRAN_ALLOW_CALLBACK 1 /* ¥³¡¼¥ë¥Ð¥Ã¥¯¤ò¤·¤Æ¤âÎɤ¤ */ +#define ICHIRAN_STAY_LONG 0x02 /* Áª¤Ö¤ÈÈ´¤±¤ë */ +#define ICHIRAN_NEXT_EXIT 0x04 /* ¼¡¤Î quit ¤ÇÈ´¤±¤ë */ + + +typedef struct _foirchiranContextRec { + BYTE id; + BYTE majorMode, minorMode; + struct _kanjiMode *prevMode; /* £±¤ÄÁ°¤Î¥â¡¼¥É */ + mode_context next; + + int curIkouho; /* ¥«¥ì¥ó¥È¸õÊä */ + WCHAR_T **allkouho; /* RkGetKanjiList¤ÇÆÀ¤é¤ì¤ëʸ»úÎó¤òÇÛÎó¤Ë¤·¤Æ + ¤È¤Ã¤Æ¤ª¤¯¤È¤³¤í */ + menustruct *table; /* ʸ»úÎó¤È´Ø¿ô¤Î¥Æ¡¼¥Ö¥ë */ + int *prevcurp; /* Á°¤Î¥«¥ì¥ó¥È¸õÊä */ +} forichiranContextRec, *forichiranContext; + +typedef struct _mountContextRec { + BYTE id; + BYTE majorMode, minorMode; + struct _kanjiMode *prevMode; /* £±¤ÄÁ°¤Î¥â¡¼¥É */ + mode_context next; + + BYTE *mountOldStatus; /* ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¤«¤¤¤Ê¤¤¤« */ + BYTE *mountNewStatus; /* ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¤«¤¤¤Ê¤¤¤« */ + char **mountList; /* ¥Þ¥¦¥ó¥È²Äǽ¤Ê¼­½ñ¤Î°ìÍ÷ */ + int curIkouho; /* ¥«¥ì¥ó¥È¸õÊä */ +} mountContextRec, *mountContext; + +typedef struct _tourokuContextRec { + BYTE id; + BYTE majorMode, minorMode; + struct _kanjiMode *prevMode; /* £±¤ÄÁ°¤Î¥â¡¼¥É */ + mode_context next; + + WCHAR_T genbuf[ROMEBUFSIZE]; + WCHAR_T qbuf[ROMEBUFSIZE]; + WCHAR_T tango_buffer[ROMEBUFSIZE]; + int tango_len; /* ñ¸ìÅÐÏ¿¤Îñ¸ì¤Îʸ»úÎó¤ÎŤµ */ + WCHAR_T yomi_buffer[ROMEBUFSIZE]; + int yomi_len; /* ñ¸ìÅÐÏ¿¤ÎÆÉ¤ß¤Îʸ»úÎó¤ÎŤµ */ + int curHinshi; /* ÉÊ»ì¤ÎÁªÂò */ + int workDic; /* ºî¶ÈÍѤμ­½ñ */ + deldicinfo *workDic2; /* ñ¸ìºï½ü²Äǽ¤Ê¼­½ñ */ + int nworkDic2; /* ñ¸ìºï½ü²Äǽ¤Ê¼­½ñ¤Î¿ô */ + deldicinfo *workDic3; /* ñ¸ìºï½ü¤¹¤ë¼­½ñ */ + int nworkDic3; /* ñ¸ìºï½ü¤¹¤ë¼­½ñ¤Î¿ô */ + struct dicname *newDic; /* Äɲ乤뼭½ñ */ + WCHAR_T hcode[INDPHLENGTH]; /* ñ¸ìÅÐÏ¿¤ÎÉÊ»ì */ + int katsuyou; /* ñ¸ìÅÐÏ¿¤Îư»ì¤Î³èÍÑ·Á */ + WCHAR_T **udic; /* ñ¸ìÅÐÏ¿¤Ç¤­¤ë¼­½ñ (¼­½ñ̾) */ + int nudic; /* ñ¸ìÅÐÏ¿¤Ç¤­¤ë¼­½ñ¤Î¿ô */ + int delContext; /* ñ¸ìºï½ü¤Ç£±¤Ä¤Î¼­½ñ¤ò¥Þ¥¦¥ó¥È¤¹¤ë */ +} tourokuContextRec, *tourokuContext; + +typedef struct _tanContextRec { + BYTE id; + BYTE majorMode, minorMode; + struct _kanjiMode *prevMode; /* £±¤ÄÁ°¤Î¥â¡¼¥É */ + mode_context next; + + struct _kanjiMode *curMode; + struct _tanContextRec *left, *right; + + struct RkRxDic *romdic; /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë */ + BYTE myMinorMode; /* yomiContext ¸ÇÍ­¤Î¥Þ¥¤¥Ê¥â¡¼¥É */ + struct _kanjiMode *myEmptyMode; /* empty ¥â¡¼¥É¤Ï¤É¤ì¤« */ + long generalFlags, savedFlags; /* yomiContext ¤Î¥³¥Ô¡¼ */ + BYTE savedMinorMode; /* ¥Þ¥¤¥Ê¥â¡¼¥É¤Î¥»¡¼¥Ö */ + BYTE allowedChars; /* see jrkanji.h */ + BYTE henkanInhibition; /* see below */ + + WCHAR_T *kanji, *yomi, *roma; + BYTE *kAttr, *rAttr; +} tanContextRec, *tanContext; + +struct moreTodo { + BYTE todo; /* ¤â¤Ã¤È¤¢¤ë¤Î¡©¤ò¼¨¤¹ */ + BYTE fnum; /* ´Ø¿ôÈֹ档£°¤Ê¤é¼¡¤Îʸ»ú¤Ç¼¨¤µ¤ì¤ë¤³¤È¤ò¤¹¤ë */ + int ch; /* ʸ»ú */ +}; + +/* ¥â¡¼¥É̾¤ò³ÊǼ¤¹¤ë¥Ç¡¼¥¿¤Î·¿ÄêµÁ */ + +struct ModeNameRecs { + int alloc; + WCHAR_T *name; +}; + +/* °ìÍ÷¤ÎÈÖ¹æ¤Î¥»¥Ñ¥ì¡¼¥¿¡¼¤Î¥Ç¥Õ¥©¥ë¥È¤ÎÄêµÁ */ + +#define DEFAULTINDEXSEPARATOR '.' + +/* + wcKanjiAttribute for internal use + */ + +typedef struct { + wcKanjiAttribute u; + int len; + char *sp, *ep; +} wcKanjiAttributeInternal; + +/* + + uiContext ¤Ï¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¡¢¥«¥Ê´Á»úÊÑ´¹¤Ë»È¤ï¤ì¤ë¹½Â¤ÂΤǤ¢¤ë¡£ + XLookupKanjiString ¤Ê¤É¤Ë¤è¤ëÊÑ´¹¤Ï¡¢¥¦¥£¥ó¥É¥¦¤ËʬΥ¤µ¤ì¤¿Ê£¿ô¤ÎÆþ + Îϥݡ¼¥È¤ËÂбþ¤·¤Æ¤¤¤ë¤Î¤Ç¡¢ÆþÎÏÃæ¤Î¥í¡¼¥Þ»ú¤Î¾ðÊó¤ä¡¢¥«¥Ê´Á»úÊÑ´¹ + ¤ÎÍͻҤʤɤò¤½¤ì¤¾¤ì¤Î¥¦¥£¥ó¥É¥¦Ëè¤ËʬΥ¤·¤ÆÊÝ»ý¤·¤Æ¤ª¤«¤Ê¤±¤ì¤Ð¤Ê + ¤é¤Ê¤¤¡£¤³¤Î¹½Â¤ÂΤϤ½¤Î¤¿¤á¤Ë»È¤ï¤ì¤ë¹½Â¤ÂΤǤ¢¤ë¡£ + + ¹½Â¤ÂΤΥá¥ó¥Ð¤¬¤É¤Î¤è¤¦¤Ê¤â¤Î¤¬¤¢¤ë¤«¤Ï¡¢ÄêµÁ¤ò»²¾È¤¹¤ë¤³¤È + + */ + +typedef struct _uiContext { + + /* XLookupKanjiString¤Î¥Ñ¥é¥á¥¿ */ + WCHAR_T *buffer_return; + int n_buffer; + wcKanjiStatus *kanji_status_return; + + /* XLookupKanjiString¤ÎÌá¤êÃͤǤ¢¤ëʸ»úÎó¤ÎŤµ */ + int nbytes; + + /* ¥­¥ã¥é¥¯¥¿ */ + int ch; + + /* ¥»¥ß¥°¥í¡¼¥Ð¥ë¥Ç¡¼¥¿ */ + int contextCache; /* ÊÑ´¹¥³¥ó¥Æ¥¯¥¹¥È¥­¥ã¥Ã¥·¥å */ + struct _kanjiMode *current_mode; + BYTE majorMode, minorMode; /* ľÁ°¤Î¤â¤Î */ + + short curkigo; /* ¥«¥ì¥ó¥Èµ­¹æ(µ­¹æÁ´ÈÌ) */ + char currussia; /* ¥«¥ì¥ó¥Èµ­¹æ(¥í¥·¥¢Ê¸»ú) */ + char curgreek; /* ¥«¥ì¥ó¥Èµ­¹æ(¥®¥ê¥·¥ãʸ»ú) */ + char curkeisen; /* ¥«¥ì¥ó¥Èµ­¹æ(·ÓÀþ) */ + short curbushu; /* ¥«¥ì¥ó¥ÈÉô¼ó̾ */ + int ncolumns; /* °ì¹Ô¤Î¥³¥é¥à¿ô¡¢¸õÊä°ìÍ÷¤Î»þ¤ËÍѤ¤¤é¤ì¤ë */ + WCHAR_T genbuf[ROMEBUFSIZE]; /* ÈÆÍѥХåե¡ */ + short strokecounter; /* ¥­¡¼¥¹¥È¥í¡¼¥¯¤Î¥«¥¦¥ó¥¿ + ¥í¡¼¥Þ»ú¥â¡¼¥É¤Ç¥¯¥ê¥¢¤µ¤ì¤ë */ + wcKanjiAttributeInternal *attr; + + /* ¥ê¥¹¥È¥³¡¼¥ë¥Ð¥Ã¥¯´ØÏ¢ */ + char *client_data; /* ¥¢¥×¥ê¥±¡¼¥·¥ç¥óÍѥǡ¼¥¿ */ + int (*list_func) (char *, int, WCHAR_T **, int, int *); + /* ¥ê¥¹¥È¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô */ + /* ¤½¤Î¾ */ + char flags; /* ²¼¤ò¸«¤Æ¤Í */ + char status; /* ¤É¤Î¤è¤¦¤Ê¾õÂÖ¤ÇÊ֤俤Τ«¤ò¼¨¤¹ÃÍ + ¤½¤Î¥â¡¼¥É¤È¤·¤Æ¡¢ + ¡¦½èÍýÃæ + ¡¦½èÍý½ªÎ» + ¡¦½èÍýÃæÃÇ + ¡¦¤½¤Î¾ + ¤¬¤¢¤ë¡£(²¼¤ò¸«¤è) */ + + /* ¥³¡¼¥ë¥Ð¥Ã¥¯¥Á¥§¡¼¥ó */ + struct callback *cb; + + /* ¤â¤Ã¤È¤¹¤ë¤³¤È¤¬¤¢¤ë¤è¤È¤¤¤¦¹½Â¤ÂÎ */ + struct moreTodo more; + + /* ¥¯¥¤¥Ã¥È¥Á¥§¡¼¥ó */ + menustruct *prevMenu; + + /* ³Æ¥á¥Ë¥å¡¼¤ÇÁª¤Ð¤ì¤¿ÈÖ¹æ¤òµ­Ï¿¤·¤Æ¤ª¤¯¹½Â¤ÂΤؤΥݥ¤¥ó¥¿ */ + menuinfo *minfo; + + /* ³Æ°ìÍ÷¤ÇÁª¤Ð¤ì¤¿ÈÖ¹æ¤òµ­Ï¿¤·¤Æ¤ª¤¯¹½Â¤ÂΤؤΥݥ¤¥ó¥¿ */ + selectinfo *selinfo; + + /* ¥µ¥Ö¥³¥ó¥Æ¥¯¥¹¥È¤Ø¤Î¥ê¥ó¥¯ */ + mode_context modec; /* Á´Éô¤³¤³¤Ë¤Ä¤Ê¤°Í½Äê */ +} uiContextRec, *uiContext; + +/* uiContext ¤Î flags ¤Î¥Ó¥Ã¥È¤Î°ÕÌ£ */ +#define PLEASE_CLEAR_GLINE 1 /* GLine ¤ò¾Ã¤·¤Æ¤Í */ +#define PCG_RECOGNIZED 2 /* GLine ¤ò¼¡¤Ï¾Ã¤·¤Þ¤¹¤è */ +#define MULTI_SEQUENCE_EXECUTED 4 /* ¤µ¤Ã¤­¥Þ¥ë¥Á¥·¡¼¥±¥ó¥¹¤¬¹Ô¤ï¤ì¤¿ */ + +#define EVERYTIME_CALLBACK 0 +#define EXIT_CALLBACK 1 +#define QUIT_CALLBACK 2 +#define AUX_CALLBACK 3 + +/* + * ¥«¥Ê´Á»úÊÑ´¹¤Î¤¿¤á¤ÎÍÍ¡¹¤Ê¥­¡¼¥Þ¥Ã¥×¥Æ¡¼¥Ö¥ë + * ¥­¡¼¥Þ¥Ã¥×¥Æ¡¼¥Ö¥ë¤Ï½èÍý´Ø¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿¤ÎÇÛÎó¤È¤Ê¤Ã¤Æ¤¤¤ë¡£ + */ + +struct funccfunc { + BYTE funcid; + int (*cfunc) (struct _uiContext *); +}; + +typedef struct _kanjiMode { + int (*func) (struct _uiContext *, struct _kanjiMode *, int, int, int); + BYTE *keytbl; + int flags; /* ²¼¤ò¸«¤è */ + struct funccfunc *ftbl; +} *KanjiMode, KanjiModeRec; + +struct callback { + int (*func[NCALLBACK]) (struct _uiContext *, int, mode_context); + mode_context env; + struct callback *next; +}; + +/* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë */ + +extern struct RkRxDic *RkwOpenRoma(char *romaji); +extern void RkwCloseRoma(struct RkRxDic *rdic); + +/* + * ¼­½ñ¤Î̾Á°¤òÆþ¤ì¤Æ¤ª¤¯ÊÑ¿ô + */ + +struct dicname { + struct dicname *next; + char *name; + int dictype; + unsigned long dicflag; +}; + +/* dictype ¤Ë¤Ï°Ê²¼¤Î¤¤¤º¤ì¤«¤¬Æþ¤ë */ +#define DIC_PLAIN 0 /* Ä̾ï¤ÎÍøÍÑ */ +#define DIC_USER 1 /* ñ¸ìÅÐÏ¿ÍѼ­½ñ */ +#define DIC_BUSHU 2 /* Éô¼óÊÑ´¹ÍѼ­½ñ */ +#define DIC_GRAMMAR 3 /* ʸˡ¼­½ñ */ +#define DIC_RENGO 4 /* Ï¢¸ì³Ø½¬¼­½ñ */ +#define DIC_KATAKANA 5 /* ¥«¥¿¥«¥Ê³Ø½¬¼­½ñ */ +#define DIC_HIRAGANA 6 /* ¤Ò¤é¤¬¤Ê³Ø½¬¼­½ñ */ + +/* dicflag ¤Ë¤Ï°Ê²¼¤Î¤¤¤º¤ì¤«¤¬Æþ¤ë */ +#define DIC_NOT_MOUNTED 0 +#define DIC_MOUNTED 1 +#define DIC_MOUNT_FAILED 2 + +extern struct dicname *kanjidicnames; + +/* + * ¥¨¥é¡¼¤Î¥á¥Ã¥»¡¼¥¸¤òÆþ¤ì¤Æ¤ª¤¯ÊÑ¿ô + */ + +extern char *jrKanjiError; + +/* + * ¥Ç¥Ð¥°Ê¸¤òɽ¼¨¤¹¤ë¤«¤É¤¦¤«¤Î¥Õ¥é¥° + */ + +extern int iroha_debug; + +/* + * ¥­¡¼¥·¡¼¥±¥ó¥¹¤òȯÀ¸¤¹¤ë¤è¤¦¤Ê¥­¡¼ + */ + +#define IrohaFunctionKey(key) \ + ((0x80 <= (int)(unsigned char)(key) && \ + (int)(unsigned char)(key) <= 0x8b) || \ + (0x90 <= (int)(unsigned char)(key) && \ + (int)(unsigned char)(key) <= 0x9b) || \ + (0xe0 <= (int)(unsigned char)(key) && \ + (int)(unsigned char)(key) <= 0xff) ) + +/* selectOne ¤Ç¥³¡¼¥ë¥Ð¥Ã¥¯¤òȼ¤¦¤«¤É¤¦¤«¤òɽ¤¹¥Þ¥¯¥í */ + +#define WITHOUT_LIST_CALLBACK 0 +#define WITH_LIST_CALLBACK 1 + +/* + * Rk ´Ø¿ô¤ò¥È¥ì¡¼¥¹¤¹¤ë¤¿¤á¤Î̾Á°¤Î½ñ¤­´¹¤¨¡£ + */ + +#ifdef DEBUG +#include "traceRK.h" +#endif /* DEBUG */ + +/* + * ¥Ç¥Ð¥°¥á¥Ã¥»¡¼¥¸½ÐÎÏÍѤΥޥ¯¥í + */ + +#ifdef DEBUG +#define debug_message(fmt, x, y, z) dbg_msg(fmt, x, y, z) +#else /* !DEBUG */ +#define debug_message(fmt, x, y, z) +#endif /* !DEBUG */ + +/* + * malloc ¤Î¥Ç¥Ð¥° + */ + +#ifdef DEBUG_ALLOC +extern char *debug_malloc (int); +extern int fail_malloc; +#define malloc(n) debug_malloc(n) +#endif /* DEBUG_MALLOC */ + +/* + * ¿·¤·¤¤¥â¡¼¥É¤òÄêµÁ¤¹¤ë¹½Â¤ÂÎ + */ + +typedef struct { + char *romaji_table; /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë̾(EUC) */ + struct RkRxDic *romdic; /* ¥í¡¼¥Þ»ú¼­½ñ¹½Â¤ÂÎ */ + int romdic_owner; /* ¥í¡¼¥Þ»ú¼­½ñ¤ò¼«Ê¬¤ÇOpen¤·¤¿¤« */ + long flags; /* flags for yomiContext->generalFlags */ + KanjiMode emode; /* current_mode ¤ËÆþ¤ë¹½Â¤ÂÎ */ +} newmode; + +/* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤òÊä­¤¹¤ë¥­¡¼¤Èʸ»ú¤ÎÊÑ´¹¥Æ¡¼¥Ö¥ë */ + +typedef struct { + WCHAR_T key; /* ¥­¡¼ */ + WCHAR_T xkey; + int groupid; /* ¥°¥ë¡¼¥×id */ + int ncand; /* ¸õÊä¤Î¿ô */ + WCHAR_T **cand; /* ¸õÊä¤ÎÇÛÎó */ + WCHAR_T *fullword; /* ¸õÊäÎó (¸õÊä1@¸õÊä2@...¸õÊän@@) */ +#ifdef WIN_CANLISP + int fullwordsize; /* sizeof fullword by WCHAR_T unit */ +#endif +} keySupplement; + +#define MAX_KEY_SUP 64 + +#define HEX_USUAL 0 +#define HEX_IMMEDIATE 1 + +#define ModeInfoStyleIsString 0 +#define ModeInfoStyleIsNumeric 1 +#define ModeInfoStyleIsExtendedNumeric 2 +#define ModeInfoStyleIsBaseNumeric 3 +#define MaxModeInfoStyle ModeInfoStyleIsBaseNumeric + +#define killmenu(d) ((d)->prevMenu = (menustruct *)0) +#define defineEnd(d) killmenu(d) +#define deleteEnd(d) killmenu(d) + +/* defmode¡¢defselection¡¢defmenu ÍѤι½Â¤ÂÎ */ + +typedef struct _extra_func { + int fnum; /* ´Ø¿ôÈÖ¹æ */ + int keyword; /* ¿·¤·¤¤¥â¡¼¥É¤¬ÄêµÁ¤µ¤ì¤¿¥­¡¼¥ï¡¼¥É */ + WCHAR_T *display_name; /* ¥â¡¼¥Éɽ¼¨Ì¾ */ + union { + newmode *modeptr; /* defmode ¤ËÂбþ¤¹¤ë¹½Â¤ÂÎ */ + kigoIchiran *kigoptr; /* defselection ¤ËÂбþ¤¹¤ë¹½Â¤ÂÎ */ + menustruct *menuptr; /* defmenu ¤ËÂбþ¤¹¤ë¹½Â¤ÂÎ */ + } u; +#ifdef BINARY_CUSTOM + int mid; + char *symname; +#endif + struct _extra_func *next; +} extraFunc; + +#define EXTRA_FUNC_DEFMODE 1 +#define EXTRA_FUNC_DEFSELECTION 2 +#define EXTRA_FUNC_DEFMENU 3 + +#define tanbunMode(d, tan) /* tanContext ´ØÏ¢¥â¡¼¥É¤Ø¤Î°Ü¹Ô */ \ + { extern KanjiModeRec tankouho_mode; (d)->current_mode = &tankouho_mode; \ + (d)->modec = (mode_context)(tan); currentModeInfo(d); } + +#define freeForIchiranContext(fc) free((char *)fc) +#define freeIchiranContext(ic) free((char *)ic) +#define freeYomiContext(yc) free((char *)yc) +#define freeCoreContext(cc) free((char *)cc) + +#define DEFAULT_CANNA_SERVER_NAME "cannaserver" + +#ifndef _UTIL_FUNCTIONS_DEF_ + +#define _UTIL_FUNCTIONS_DEF_ + +/* ¤«¤ó¤Ê¤Î¥Ð¡¼¥¸¥ç¥ó¤òÄ´¤Ù¤ë */ +#define canna_version(majv, minv) ((majv) * 1024 + (minv)) + +/* ¤è¤¯¥¹¥Ú¥ë¥ß¥¹¤¹¤ë¤Î¤Ç¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¤Ò¤Ã¤«¤«¤ë¤è¤¦¤ËÆþ¤ì¤ë */ +extern RkwGoto (char *, int); + +/* storing customize configuration to the following structure. */ +struct CannaConfig { /* °Ê²¼¤Î¥³¥á¥ó¥È¤Ï¥À¥¤¥¢¥í¥°¤Ê¤É¤Ëµ­½Ò¤¹¤ë¤È¤­¤Ê¤É¤Ë + ÍѤ¤¤ë¸ì×á£! ¤¬ÀèÆ¬¤Ë¤Ä¤¤¤Æ¤¤¤ë¤Î¤Ï¥í¥¸¥Ã¥¯¤¬È¿Å¾ + ¤·¤Æ¤¤¤ë¤³¤È¤òɽ¤¹ */ + int CannaVersion; /* (¸ß´¹ÍÑ) ¤«¤ó¤Ê¤Î¥Ð¡¼¥¸¥ç¥ó */ + int kouho_threshold; /* ÊÑ´¹¥­¡¼¤ò²¿²óÂǤĤȰìÍ÷¤¬½Ð¤ë¤« */ + int strokelimit; /* (¸ß´¹ÍÑ) ²¿¥¹¥È¥í¡¼¥¯¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤òÆþ¤ì¤ë¤ÈÀÚÃǤ« */ + int indexSeparator; /* (¸ß´¹ÍÑ) °ìÍ÷»þ¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¥»¥Ñ¥ì¡¼¥¿ */ + BYTE ReverseWidely; /* ȿžÎΰè¤ò¹­¤¯¤È¤ë */ + BYTE chikuji; /* Ã༡¼«Æ°ÊÑ´¹ */ + BYTE Gakushu; /* ³Ø½¬¤¹¤ë¤«¤É¤¦¤« */ + BYTE CursorWrap; /* ±¦Ã¼¤Ç±¦¤Çº¸Ã¼¤Ø¹Ô¤¯ */ + BYTE SelectDirect; /* °ìÍ÷»þ¡¢ÁªÂò¤Ç°ìÍ÷¤òÈ´¤±¤ë */ + BYTE HexkeySelect; /* (¸ß´¹ÍÑ) 16¿Ê¿ô»ú¤Ç¤â°ìÍ÷ÁªÂò²Ä */ + BYTE BunsetsuKugiri; /* ÊÑ´¹»þʸÀá´Ö¤Ë¶õÇò¤òÁÞÆþ */ + BYTE ChBasedMove; /* !¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹Ã±°Ì¤Î¥«¡¼¥½¥ë°Üư */ + BYTE ReverseWord; /* (¸ß´¹ÍÑ) °ìÍ÷¤Ç¸ì¤òȿž¤¹¤ë */ + BYTE QuitIchiranIfEnd; /* °ìÍ÷ËöÈø¤Ç°ìÍ÷¤òÊĤ¸¤ë */ + BYTE kakuteiIfEndOfBunsetsu; /* ʸÀáËöÈø¤Ç±¦°Üư¤Ç³ÎÄꤹ¤ë */ + BYTE stayAfterValidate; /* !°ìÍ÷¤ÇÁªÂò¸å¼¡¤ÎʸÀá¤Ø°Üư */ + BYTE BreakIntoRoman; /* BS¥­¡¼¤Ç¥í¡¼¥Þ»ú¤ØÌ᤹ */ + BYTE grammaticalQuestion; /* (¸ß´¹ÍÑ) ñ¸ìÅÐÏ¿»þʸˡŪ¼ÁÌä¤ò¤¹¤ë */ + BYTE forceKana; /* Isn't this used? */ + BYTE kCount; /* (¸ß´¹ÍÑ) ¸õÊ䤬²¿ÈÖÌܤ«¤òɽ¼¨¤¹¤ë */ + BYTE LearnNumericalType; /* Isn't this used? */ + BYTE BackspaceBehavesAsQuit; /* Ã༡¼«Æ°ÊÑ´¹»þ BS ¥­¡¼¤ÇÁ´ÂΤòÆÉ¤ß¤ËÌ᤹ */ + BYTE iListCB; /* (¸ß´¹ÍÑ) ¥ê¥¹¥È¥³¡¼¥ë¥Ð¥Ã¥¯¤ò¶Ø»ß¤¹¤ë */ + BYTE keepCursorPosition; /* !ÊÑ´¹»þ¤ËBSÂǸ°»þ¥«¡¼¥½¥ë°ÌÃÖ¤òËöÈø¤Ë°Üư */ + BYTE abandonIllegalPhono; /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤Ë»È¤ï¤ì¤Ê¤¤¥­¡¼¤ò¼Î¤Æ¤ë */ + BYTE hexCharacterDefiningStyle; /* Isn't this used? */ + BYTE kojin; /* ¸Ä¿Í³Ø½¬ */ + BYTE indexHankaku; /* (¸ß´¹ÍÑ) °ìÍ÷»þ¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤òȾ³Ñ¤Ë¤¹¤ë */ + BYTE allowNextInput; /* ¸õÊä°ìÍ÷ɽ¼¨»þ¡¢¼¡¤ÎÆþÎϤ¬²Äǽ¤Ë¤¹¤ë */ + BYTE doKatakanaGakushu; /* Isn't this used? */ + BYTE doHiraganaGakushu; /* Isn't this used? */ + BYTE ChikujiContinue; /* Ã༡¼«Æ°ÊÑ´¹»þ¼¡¤ÎÆþÎϤǴûÊÑ´¹Éôʬ¤ò³ÎÄꤷ¤Ê¤¤ */ + BYTE RenbunContinue; /* ϢʸÀáÊÑ´¹»þ¼¡¤ÎÆþÎϤǴûÊÑ´¹Éôʬ¤ò³ÎÄꤷ¤Ê¤¤ */ + BYTE MojishuContinue; /* »ú¼ïÊÑ´¹»þ¼¡¤ÎÆþÎϤǴûÊÑ´¹Éôʬ¤ò³ÎÄꤷ¤Ê¤¤ */ + BYTE chikujiRealBackspace; /* Ã༡¼«Æ°ÊÑ´¹»þBS¤Çɬ¤º°ìʸ»ú¾Ãµî¤¹¤ë */ + BYTE ignore_case; /* Âçʸ»ú¾®Ê¸»ú¤ò¶èÊ̤·¤Ê¤¤ */ + BYTE romaji_yuusen; /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤òÍ¥À褹¤ë */ + BYTE auto_sync; /* Äê´üŪ¤Ë¼­½ñ¤ò½ñ¤­Ì᤹ */ + BYTE quickly_escape; /* (¸ß´¹ÍÑ) °ìÍ÷ɽ¼¨»þ¡¢ÁªÂò¤Ç¨ºÂ¤Ë°ìÍ÷¤òÈ´¤±¤ë */ + BYTE InhibitHankakuKana; /* Ⱦ³Ñ¥«¥¿¥«¥Ê¤Î¶Ø»ß */ + BYTE code_input; /* ¥³¡¼¥É(0: jis, 1: sjis, 2: ¶èÅÀ) */ +}; + +#define CANNA_CODE_JIS 0 +#define CANNA_CODE_SJIS 1 +#define CANNA_CODE_KUTEN 2 +#define CANNA_MAX_CODE 3 + +extern struct CannaConfig cannaconf; +typedef int (* canna_callback_t) (uiContext, int, mode_context); + +/* RKkana.c */ +int RkCvtZen(unsigned char *zen, int maxzen, unsigned char *han, int maxhan); +int RkCvtHan(unsigned char *han, int maxhan, unsigned char *zen, int maxzen); +int RkCvtKana(unsigned char *kana, int maxkana, unsigned char *hira, int maxhira); +int RkCvtHira(unsigned char *hira, int maxhira, unsigned char *kana, int maxkana); +int RkCvtNone(unsigned char *dst, int maxdst, unsigned char *src, int maxsrc); +int RkCvtEuc(unsigned char *euc, int maxeuc, unsigned char *sj, int maxsj); +int RkCvtSuuji(unsigned char *dst, int maxdst, unsigned char *src, int maxsrc, int format); +int RkwCvtHan(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen); +int RkwCvtHira(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen); +int RkwCvtKana(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen); +int RkwCvtZen(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen); +int RkwCvtNone(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen); +int RkwMapRoma(struct RkRxDic *romaji, WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen, int flags, int *status); +int RkwMapPhonogram(struct RkRxDic *romaji, WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen, WCHAR_T key, int flags, int *ulen, int *dlen, int *tlen, int *rule); +int RkwCvtRoma(struct RkRxDic *romaji, WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen, int flags); + +/* RKroma.c */ +int compar(struct romaRec *p, struct romaRec *q); +struct RkRxDic *RkwOpenRoma(char *romaji); +void RkwCloseRoma(struct RkRxDic *rdic); +struct RkRxDic *RkOpenRoma(char *romaji); +void RkCloseRoma(struct RkRxDic *rdic); +int RkMapRoma(struct RkRxDic *rdic, unsigned char *dst, int maxdst, unsigned char *src, int maxsrc, int flags, int *status); +int RkMapPhonogram(struct RkRxDic *rdic, unsigned char *dst, int maxdst, unsigned char *src, int srclen, unsigned key, int flags, int *used_len_return, int *dst_len_return, int *tmp_len_return, int *rule_id_inout); +int RkCvtRoma(struct RkRxDic *rdic, unsigned char *dst, int maxdst, unsigned char *src, int maxsrc, unsigned flags); + +/* bunsetsu.c */ +int enterAdjustMode(uiContext d, yomiContext yc); +int leaveAdjustMode(uiContext d, yomiContext yc); + +/* bushu.c */ +int initBushuTable(void); +int getForIchiranContext(uiContext d); +void popForIchiranMode(uiContext d); +int BushuMode(uiContext d); +int ConvertAsBushu(uiContext d); + +/* chikuji.c */ +void clearHenkanContext(yomiContext yc); +int chikujiInit(uiContext d); +int ChikujiSubstYomi(uiContext d); +int ChikujiTanDeletePrevious(uiContext d); +void moveToChikujiTanMode(uiContext d); +void moveToChikujiYomiMode(uiContext d); + +/* commondata.c */ +void InitCannaConfig(struct CannaConfig *cf); +void restoreBindings(void); + +/* defaultmap.c */ +int searchfunc (uiContext, KanjiMode, int, int, int); +int CYsearchfunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum); + +/* ebind.c */ +int XLookupKanji2(unsigned int dpy, unsigned int win, char *buffer_return, int bytes_buffer, int nbytes, int functionalChar, jrKanjiStatus *kanji_status_return); +int XKanjiControl2(unsigned int display, unsigned int window, unsigned int request, BYTE *arg); + +/* empty.c */ +extraFunc *FindExtraFunc(int fnum); +int getBaseMode(yomiContext yc); +void EmptyBaseModeInfo(uiContext d, yomiContext yc); +int EmptyBaseHira(uiContext d); +int EmptyBaseKata(uiContext d); +int EmptyBaseEisu(uiContext d); +int EmptyBaseZen(uiContext d); +int EmptyBaseHan(uiContext d); +int EmptyBaseKana(uiContext d); +int EmptyBaseKakutei(uiContext d); +int EmptyBaseHenkan(uiContext d); + +/* engine.c */ +int RkSetServerName(char *s); +char *RkGetServerHost(void); +void close_engine(void); + +/* henkan.c */ +int KanjiInit(void); +int KanjiFin(void); +void freeTanContext(tanContext tan); +int doTanConvertTb(uiContext d, yomiContext yc); +int YomiBubunKakutei(uiContext d); +yomiContext newFilledYomiContext(mode_context next, KanjiMode prev); +int TanBubunMuhenkan(uiContext d); +int prepareHenkanMode(uiContext d); +int doHenkan(uiContext d, int len, WCHAR_T *kanji); +int TanNop(uiContext d); +int TanForwardBunsetsu(uiContext d); +int TanBackwardBunsetsu(uiContext d); +int TanKouhoIchiran(uiContext d); +int TanNextKouho(uiContext d); +int TanPreviousKouho(uiContext d); +int TanHiragana(uiContext d); +int TanKatakana(uiContext d); +int TanRomaji(uiContext d); +int TanUpper(uiContext d); +int TanCapitalize(uiContext d); +int TanZenkaku(uiContext d); +int TanHankaku(uiContext d); +int TanKanaRotate(uiContext d); +int TanRomajiRotate(uiContext d); +int TanCaseRotateForward(uiContext d); +int TanBeginningOfBunsetsu(uiContext d); +int TanEndOfBunsetsu(uiContext d); +int tanMuhenkan(uiContext d, int kCurs); +int TanMuhenkan(uiContext d); +int TanDeletePrevious(uiContext d); +void finishTanKakutei(uiContext d); +int TanKakutei(uiContext d); +int TanPrintBunpou(uiContext d); +void jrKanjiPipeError(void); +void setMode(uiContext d, tanContext tan, int forw); +int TbForward(uiContext d); +int TbBackward(uiContext d); +int TbBeginningOfLine(uiContext d); +int TbEndOfLine(uiContext d); + +/* hex.c */ +int HexMode(uiContext d); + +/* ichiran.c */ +int initIchiran(void); +void makeGlineStatus(uiContext d); +void freeIchiranBuf(ichiranContext ic); +void freeGetIchiranList(WCHAR_T **buf); +WCHAR_T **getIchiranList(int context, int *nelem, int *currentkouho); +ichiranContext newIchiranContext(void); +int selectOne (uiContext d, WCHAR_T **buf, int *ck, int nelem, int bangomax, unsigned inhibit, int currentkouho, int allowcallback, canna_callback_t everyTimeCallback, canna_callback_t exitCallback, canna_callback_t quitCallback, canna_callback_t auxCallback); +int allocIchiranBuf(uiContext d); +int tanKouhoIchiran(uiContext d, int step); +int IchiranQuit(uiContext d); +int IchiranNop(uiContext d); +int IchiranForwardKouho(uiContext d); +int IchiranBackwardKouho(uiContext d); +int IchiranPreviousKouhoretsu(uiContext d); +int IchiranNextKouhoretsu(uiContext d); +int IchiranBeginningOfKouho(uiContext d); +int IchiranEndOfKouho(uiContext d); +void ichiranFin(uiContext d); + +/* jishu.c */ +void enterJishuMode(uiContext d, yomiContext yc); +void leaveJishuMode(uiContext d, yomiContext yc); +int extractJishuString(yomiContext yc, WCHAR_T *s, WCHAR_T *e, WCHAR_T **sr, WCHAR_T **er); + +/* jrbind.c */ +int XwcLookupKanji2(unsigned int dpy, unsigned int win, WCHAR_T *buffer_return, int nbuffer, int nbytes, int functionalChar, wcKanjiStatus *kanji_status_return); +int XwcKanjiControl2(unsigned int display, unsigned int window, unsigned int request, BYTE *arg); +struct callback *pushCallback(uiContext d, mode_context env, canna_callback_t ev, canna_callback_t ex, canna_callback_t qu, canna_callback_t au); +void popCallback(uiContext d); + +/* kctrl.c */ +int initRomeStruct(uiContext d, int flg); +void freeRomeStruct(uiContext d); +uiContext keyToContext(unsigned int data1, unsigned int data2); +struct bukRec *internContext(unsigned int data1, unsigned int data2, uiContext context); +void rmContext(unsigned int data1, unsigned int data2); +void addWarningMesg(char *s); +int escapeToBasicStat(uiContext d, int how); +void makeAllContextToBeClosed(int flag); +int _do_func_slightly(uiContext d, int fnum, mode_context mode_c, KanjiMode c_mode); +int _doFunc(uiContext d, int fnum); +int _afterDoFunc(uiContext d, int retval); +int doFunc(uiContext d, int fnum); +int wcCloseKanjiContext (int context); +int jrCloseKanjiContext (int context); +int ToggleChikuji(uiContext d, int flg); +int kanjiControl(int request, uiContext d, caddr_t arg); + +/* keydef.c */ +int initKeyTables(void); +void restoreDefaultKeymaps(void); +int changeKeyfunc(int modenum, int key, int fnum, unsigned char *actbuff, unsigned char *keybuff); +int changeKeyfuncOfAll(int key, int fnum, unsigned char *actbuff, unsigned char *keybuff); +unsigned char *actFromHash(unsigned char *tbl_ptr, unsigned char key); +struct map *mapFromHash(KanjiMode tbl, unsigned char key, struct map ***ppp); +int askQuitKey(unsigned key); + +/* kigo.c */ +void initKigoTable(void); +int KigoIchiran(uiContext d); +int makeKigoIchiran(uiContext d, int major_mode); + +/* lisp.c */ +int WCinit(void); +int clisp_init(void); +void clisp_fin(void); +int YYparse_by_rcfilename(char *s); +int parse_string(char *str); +void clisp_main(void); +int DEFVAR(int Vromkana, int StrAcc, char *, int RomkanaTable); + +/* mode.c */ +newmode *findExtraKanjiMode(int mnum); +void currentModeInfo(uiContext d); +void initModeNames(void); +void resetModeNames(void); +int JapaneseMode(uiContext d); +int AlphaMode(uiContext d); +int HenkanNyuryokuMode(uiContext d); +int queryMode(uiContext d, WCHAR_T *arg); +int changeModeName(int modeid, char *str); + +/* multi.c */ +int UseOtherKeymap(uiContext d); +int DoFuncSequence(uiContext d); +int multiSequenceFunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum); + +/* onoff.c */ +int initOnoffTable(void); +int selectOnOff(uiContext d, WCHAR_T **buf, int *ck, int nelem, int bangomax, int currentkouho, unsigned char *status, int (*everyTimeCallback )(...), int (*exitCallback )(...), int (*quitCallback )(...), int (*auxCallback )(...)); + +/* parse.c */ +#ifdef BINARY_CUSTOM +int binparse (void); +#else +void parse(void); +#endif + +int parse_string(char *str); +void clisp_main(void); + +/* romaji.c */ +void debug_yomi(yomiContext x); +void kPos2rPos(yomiContext yc, int s, int e, int *rs, int *re); +void makeYomiReturnStruct(uiContext d); +int RomkanaInit(void); +void RomkanaFin(void); +yomiContext newYomiContext(WCHAR_T *buf, int bufsize, int allowedc, int chmodinhibit, int quitTiming, int hinhibit); +yomiContext GetKanjiString(uiContext d, WCHAR_T *buf, int bufsize, int allowedc, int chmodinhibit, int quitTiming, int hinhibit, canna_callback_t everyTimeCallback, canna_callback_t exitCallback, canna_callback_t quitCallback); +void popYomiMode(uiContext d); +void fitmarks(yomiContext yc); +void ReCheckStartp(yomiContext yc); +void removeCurrentBunsetsu(uiContext d, tanContext tan); +void restoreChikujiIfBaseChikuji(yomiContext yc); +int YomiInsert(uiContext d); +int findSup(WCHAR_T key); +void moveStrings(WCHAR_T *str, BYTE *attr, int start, int end, int distance); +int forceRomajiFlushYomi(uiContext d); +int RomajiFlushYomi(uiContext d, WCHAR_T *b, int bsize); +void restoreFlags(yomiContext yc); +int xString(WCHAR_T *str, int len, WCHAR_T *s, WCHAR_T *e); +int appendTan2Yomi(tanContext tan, yomiContext yc); +yomiContext dupYomiContext(yomiContext yc); +void doMuhenkan(uiContext d, yomiContext yc); +int doKakutei(uiContext d, tanContext st, tanContext et, WCHAR_T *s, WCHAR_T *e, yomiContext *yc_return); +int cutOffLeftSide(uiContext d, yomiContext yc, int n); +int YomiKakutei(uiContext d); +void clearYomiContext(yomiContext yc); +void RomajiClearYomi(uiContext d); +int YomiExit(uiContext d, int retval); +void RomajiStoreYomi(uiContext d, WCHAR_T *kana, WCHAR_T *roma); +int KanaDeletePrevious(uiContext d); +coreContext newCoreContext(void); +int alphaMode(uiContext d); +int YomiQuotedInsert(uiContext d); +int convertAsHex(uiContext d); +int selectKeysup(uiContext d, yomiContext yc, int ind); +int containUnconvertedKey(yomiContext yc); +int YomiBaseHiraKataToggle(uiContext d); +int YomiBaseZenHanToggle(uiContext d); +int YomiBaseRotateForw(uiContext d); +int YomiBaseRotateBack(uiContext d); +int YomiBaseKanaEisuToggle(uiContext d); +int YomiBaseKakuteiHenkanToggle(uiContext d); +int YomiModeBackup(uiContext d); +int exitJishu(uiContext d); +int YomiMark(uiContext d); +int Yomisearchfunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum); +void trimYomi(uiContext d, int sy, int ey, int sr, int er); +int TanBubunKakutei(uiContext d); +int TanBubunKakutei(uiContext d); +void removeKana(uiContext d, yomiContext yc, int k, int r); +int cvtAsHex(uiContext d, WCHAR_T *buf, WCHAR_T *hexbuf, int hexlen); + +/* uiutil.c */ +menustruct *allocMenu(int n, int nc); +int uiUtilIchiranTooSmall(uiContext d, int retval, mode_context env); +int UiUtilMode(uiContext d); + +#ifndef NO_EXTEND_MENU +int initExtMenu(void); +int prevMenuIfExist(uiContext d); +int showmenu(uiContext d, menustruct *table); +void finExtMenu(void); +void freeAllMenuInfo(menuinfo *p); +void freeMenu(menustruct *m); +#endif + +/* uldefine.c */ +int dicTouroku(uiContext d); +int dicSakujo(uiContext d); +int initHinshiTable(void); +void clearYomi(uiContext d); +int getTourokuContext(uiContext d); +void popTourokuMode(uiContext d); +int uuTTangoQuitCatch(uiContext d, int retval, mode_context env); +WCHAR_T **getUserDicName(uiContext d); +int dicTouroku(uiContext d); +int dicTourokuTango(uiContext d, canna_callback_t quitfunc); +int dicTourokuHinshi(uiContext d); +int dicTourokuControl(uiContext d, WCHAR_T *tango, canna_callback_t quitfunc); + +/* uldelete.c */ +void freeWorkDic3(tourokuContext tc); +void freeWorkDic(tourokuContext tc); +void freeDic(tourokuContext tc); +void freeAndPopTouroku(uiContext d); +int dicSakujo(uiContext d); + +/* ulhinshi.c */ +int initHinshiMessage(void); +void EWStrcat(WCHAR_T *buf, char *xxxx); +int initGyouTable(void); +int dicTourokuHinshiDelivery(uiContext d); +int dicTourokuDictionary(uiContext d, int (*exitfunc )(...), int (*quitfunc )(...)); + +/* ulkigo.c */ +int initUlKigoTable(void); +int initUlKeisenTable(void); +int uuKigoGeneralExitCatch(uiContext d, int retval, mode_context env); +int uuKigoMake(uiContext d, WCHAR_T **allkouho, int size, char cur, char mode, int (*exitfunc )(...), int *posp); +int kigoRussia(uiContext d); +int kigoGreek(uiContext d); +int kigoKeisen(uiContext d); + +/* ulmount.c */ +int getMountContext(uiContext d); +void popMountMode(uiContext d); +int dicMount(uiContext d); + +/* ulserver.c */ +int serverFin(uiContext d); +int serverChange(uiContext d); + +/* util.c */ +void GlineClear(uiContext d); +void echostrClear(uiContext d); +int checkGLineLen(uiContext d); +int NothingChanged(uiContext d); +int NothingForGLine(uiContext d); +void CannaBeep(void); +int NothingChanged(uiContext d); +int NothingChangedWithBeep(uiContext d); +int NothingForGLineWithBeep(uiContext d); +int Insertable(unsigned char ch); +int extractTanString(tanContext tan, WCHAR_T *s, WCHAR_T *e); +int extractTanYomi(tanContext tan, WCHAR_T *s, WCHAR_T *e); +int extractTanRomaji(tanContext tan, WCHAR_T *s, WCHAR_T *e); +void makeKanjiStatusReturn(uiContext d, yomiContext yc); +void makeGLineMessage(uiContext d, WCHAR_T *msg, int sz); +void makeGLineMessageFromString(uiContext d, char *msg); +int setWStrings(WCHAR_T **ws, char **s, int sz); +int dbg_msg(char *fmt, int x, int y, int z); +int checkModec(uiContext d); +int showRomeStruct(unsigned int dpy, unsigned int win); +int NoMoreMemory(void); +int GLineNGReturn(uiContext d); +int GLineNGReturnFI(uiContext d); +int specialfunc(uiContext d, int fn); +int GLineNGReturnTK(uiContext d); +int copyAttribute(BYTE *dest, BYTE *src, int n); +char *debug_malloc(int n); +int WCinit(void); +int WStrlen(WCHAR_T *ws); +WCHAR_T *WStrcpy(WCHAR_T *ws1, WCHAR_T *ws2); +WCHAR_T *WStrncpy(WCHAR_T *ws1, WCHAR_T *ws2, int cnt); +WCHAR_T *WStraddbcpy(WCHAR_T *ws1, WCHAR_T *ws2, int cnt); +WCHAR_T *WStrcat(WCHAR_T *ws1, WCHAR_T *ws2); +int WStrcmp(WCHAR_T *w1, WCHAR_T *w2); +int WStrncmp(WCHAR_T *w1, WCHAR_T *w2, int n); +int WWhatGPlain(WCHAR_T wc); +int WIsG0(WCHAR_T wc); +int WIsG1(WCHAR_T wc); +int WIsG2(WCHAR_T wc); +int WIsG3(WCHAR_T wc); +int CANNA_mbstowcs(WCHAR_T *dest, char *src, int destlen); +int CNvW2E(WCHAR_T *src, int srclen, char *dest, int destlen); +int CANNA_wcstombs(char *dest, WCHAR_T *src, int destlen); +int WStringOpen(void); +WCHAR_T *WString(char *s); +void WStringClose(void); +int WSfree(WCHAR_T *s); +void generalReplace(WCHAR_T *buf, BYTE *attr, int *startp, int *cursor, int *endp, int bytes, WCHAR_T *rplastr, int len, int attrmask); +int WToupper(WCHAR_T w); +int WTolower(WCHAR_T w); +WCHAR_T key2wchar(int key, int *check); +int confirmContext(uiContext d, yomiContext yc); +int abandonContext(uiContext d, yomiContext yc); +int makeRkError(uiContext d, char *str); +int canna_alert(uiContext d, char *message, canna_callback_t cnt); +void EWStrcat(WCHAR_T *buf, char *xxxx); +char *KanjiInitError(void); +int wchar2ushort(WCHAR_T *src, int slen, uint32 *dst, int dlen); +int ushort2wchar(uint32 *src, int slen, WCHAR_T *dst, int dlen); +int euc2ushort(char *src, int srclen, uint32 *dest, int destlen); + +/* yesno.c */ +int getYesNoContext(uiContext d, canna_callback_t everyTimeCallback, canna_callback_t exitCallback, canna_callback_t quitCallback, canna_callback_t auxCallback); + +#endif /* _UTIL_FUNCTIONS_DEF_ */ +#endif /* !_CANNA_H_ */ diff --git a/src/add-ons/input_server/methods/canna/lib/chikuji.c b/src/add-ons/input_server/methods/canna/lib/chikuji.c new file mode 100644 index 0000000000..cf4aab4e7e --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/chikuji.c @@ -0,0 +1,789 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "$Id: chikuji.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +#ifdef MEASURE_TIME +#include +#ifdef WIN +#include +#else +/* If you compile with Visual C++, then please comment out the next line. */ +#include +#endif +#endif /* MEASURE_TIME */ + + +static int restoreChikujiYomi(uiContext d, int old); +static int doesSupportChikuji(void); +static int chikujiSubstYomi(uiContext d); +static int chikuji_restore_yomi(uiContext d); +static int chikuji_subst_yomi(uiContext d); +static int ChikujiTanExtend(uiContext d); +static int ChikujiTanShrink(uiContext d); +static int ChikujiYomiDeletePrevious(uiContext d); +static int ChikujiHenkan(uiContext d); +static int generalNaive(uiContext d, int (*fn )(...)); +static int ChikujiHenkanNaive(uiContext d); +static int ChikujiHenkanOrNothing(uiContext d); +static int ChikujiMuhenkan(uiContext d); + +extern int yomiInfoLevel, nKouhoBunsetsu, KeepCursorPosition; +extern int defaultContext; +extern KanjiModeRec tankouho_mode, cy_mode, cb_mode; +extern void makeYomiReturnStruct (uiContext); +extern int RkwGetServerVersion (int *, int *); +extern int RkwGetProtocolVersion (int *, int *); + +int forceRomajiFlushYomi (uiContext); +void moveToChikujiTanMode (uiContext); +void moveToChikujiYomiMode (uiContext); + + +inline void +clearHenkanContent(yomiContext yc) +{ + yc->allkouho = 0; + yc->kouhoCount = yc->curIkouho = 0; + return; +} + +void +clearHenkanContext(yomiContext yc) +{ + if (yc->context >= 0) { + RkwCloseContext(yc->context); + yc->context = -1; + } + yc->nbunsetsu = yc->curbun = 0; + clearHenkanContent(yc); + return; +} + +extern NothingChanged (uiContext); + +/* + restoreChikujiYomi + + °ú¿ô: + d : uiContext + old : Á°¤ÎʸÀá¿ô + + ¤ä¤ë¤³¤È: + (1) ʸÀá¿ô¤¬Áý¤¨¤¿¤éµ¬Äê¿ô°Ê¾å¤ÎʸÀá¤ò³ÎÄꤵ¤»¤ë¡£ + (2) ¤½¤Î¤È¤­¡¢RkwRemoveBun ¤â¤¹¤ë¡£ + (3) ¤½¤Îʬ¡¢ÆÉ¤ß¤âºï¤ë¡£ + (4) ʸÀá¤Ë¤Ê¤Ã¤¿Ê¬¤ÎÆÉ¤ß¤ò¥«¥¦¥ó¥È¡£ + */ + +static int +restoreChikujiYomi(uiContext d, int old) +{ + yomiContext yc = (yomiContext)d->modec; + WCHAR_T *s = d->buffer_return, *e = s + d->n_buffer; + RkStat stat; + int len, i, j, yomilen, ll = 0, m = 0, n = 0, recalc = 0; + + d->nbytes = 0; + yomilen = yc->kEndp - yc->cStartp; + if (yc->nbunsetsu) { + yc->status |= CHIKUJI_ON_BUNSETSU; + if (yc->nbunsetsu > old) { + recalc = 1; + } + if (nKouhoBunsetsu) { + (void)cutOffLeftSide(d, yc, nKouhoBunsetsu - yc->nbunsetsu); + if (nKouhoBunsetsu < yc->nbunsetsu) { + n = yc->nbunsetsu - nKouhoBunsetsu; + if (n > old) { + n = old; /* Á°¤Ë¤Þ¤À´Á»ú¤Ë¤Ê¤Ã¤Æ¤¤¤Ê¤«¤Ã¤¿Ê¬¤Þ¤Ç¤Ï³ÎÄꤵ¤»¤Ê¤¤ */ + } + } + } + if (n > 0) { /* ³ÎÄꤵ¤»¤ëʸÀá¿ô */ + + recalc = 1; + for (i = 0 ; i < n ; i++) { + if (RkwGoTo(yc->context, i) < 0 || + (len = RkwGetKanji(yc->context, s, (int)(e - s))) < 0 || + RkwGetStat(yc->context, &stat) == -1) { + return -1; + } + s += len; + + ll += stat.ylen; + m += stat.klen; + } + d->nbytes = s - d->buffer_return; + if (s < e) { + *s++ = (WCHAR_T)'\0'; + } + + if (RkwRemoveBun(yc->context, cannaconf.Gakushu ? 1 : 0) == -1) { + return -1; + } + + /* ¤«¤Ê¥Ð¥Ã¥Õ¥¡¤È¤«¤âºï¤ë */ + kPos2rPos(yc, 0, ll, (int *)0, &j); + + if (yomiInfoLevel > 0) { + d->kanji_status_return->info |= KanjiYomiInfo; + len = xString(yc->kana_buffer, ll, s, e); + s += len; + if (s < e) { + *s++ = (WCHAR_T)'\0'; + } + if (yomiInfoLevel > 1) { + len = xString(yc->romaji_buffer, j, s, e); + s += len; + } + if (s < e) { + *s++ = (WCHAR_T)'\0'; + } + } + + removeKana(d, yc, ll, j); + + yc->nbunsetsu -= n; + } + if (RkwGoTo(yc->context, yc->nbunsetsu - 1) == -1) + return(-1); + yc->curbun = yc->nbunsetsu - 1; + if (old < yc->curbun) { /* ¤»¤á¤ÆÁ°¤Î¤ä¤Ä¤Î±¦¤Ë¹Ô¤¯ */ + yc->curbun = old; + } + } + + if (recalc) { + yomilen = RkwGetLastYomi(yc->context, d->genbuf, ROMEBUFSIZE); + if (yomilen == -1) { + return -1; + } + if (yomilen < yc->kEndp) { /* ɬ¤º¿¿¤Ç¤Ï¡© */ + kPos2rPos(yc, 0, yc->kEndp - yomilen, (int *)0, &j); + yc->cStartp = yc->kEndp - yomilen; + yc->cRStartp = j; + } + yc->ys = yc->ye = yc->kEndp; + } + + if (yc->nbunsetsu) { + moveToChikujiTanMode(d); + } + return(0); +} + +static int +doesSupportChikuji(void) +{ + int a, b; + + if (defaultContext == -1) { + if (KanjiInit() < 0 || defaultContext == -1) { + jrKanjiError = KanjiInitError(); + return(-1); + } + } + RkwGetProtocolVersion(&a, &b); + return(a > 1); +} + +#ifndef NO_EXTEND_MENU +int +chikujiInit(uiContext d) +{ + int chikuji_f; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + + d->status = 0; + killmenu(d); + + chikuji_f = doesSupportChikuji(); + + if (ToggleChikuji(d, 1) == -1) { + if(!chikuji_f) + jrKanjiError = "\245\265\241\274\245\320\244\254\303\340\274\241\274\253" + "\306\260\312\321\264\271\244\362\245\265\245\335\241\274\245\310" + "\244\267\244\306\244\244\244\336\244\273\244\363"; + /* ¥µ¡¼¥Ð¤¬Ã༡¼«Æ°ÊÑ´¹¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó */ + else + jrKanjiError = "\303\340\274\241\274\253\306\260\312\321\264\271\244\313" + "\300\332\302\330\244\250\244\353\244\263\244\310\244\254\244\307" + "\244\255\244\336\244\273\244\363"; + /* Ã༡¼«Æ°ÊÑ´¹¤ËÀÚÂØ¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó */ + makeGLineMessageFromString(d, jrKanjiError); + currentModeInfo(d); + return(-1); + } + else { + if(!chikuji_f) + makeGLineMessageFromString(d, "\245\265\241\274\245\320\244\254\303\340" + "\274\241\274\253\306\260\312\321\264\271\244\362\245\265\245\335" + "\241\274\245\310\244\267\244\306\244\244\244\336\244\273\244\363"); + /* ¥µ¡¼¥Ð¤¬Ã༡¼«Æ°ÊÑ´¹¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó */ + else + makeGLineMessageFromString(d, "\303\340\274\241\274\253\306\260\312\321" + "\264\271\244\313\300\332\302\330\244\250\244\336\244\267\244\277"); + /* Ã༡¼«Æ°ÊÑ´¹¤ËÀÚÂØ¤¨¤Þ¤·¤¿ */ + currentModeInfo(d); + return 0; + } +} +#endif /* not NO_EXTEND_MENU */ + +static int +chikujiSubstYomi(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int n = yc->nbunsetsu, ret; + + if (yc->context == -1) { /* ¡Ö½Ð¤À¤·¤À¤Ã¤¿¤é¡×¤Î°ÕÌ£¤â¤¢¤ë */ + if (confirmContext(d, yc) < 0) { + return -1; + } + if (!doesSupportChikuji()) { + jrKanjiError = "\245\265\241\274\245\320\244\254\303\340\274\241\274\253" + "\306\260\312\321\264\271\244\362\245\265\245\335\241\274\245\310" + "\244\267\244\306\244\244\244\336\244\273\244\363"; + /* ¥µ¡¼¥Ð¤¬Ã༡¼«Æ°ÊÑ´¹¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó */ + abandonContext(d, yc); + return(-1); + } + if (RkwBgnBun(yc->context, (WCHAR_T *)0, 1, + RK_XFER << RK_XFERBITS | RK_KFER) == NG) { + substError: + jrKanjiError = "\303\340\274\241\274\253\306\260\312\321\264\271\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"; + /* Ã༡¼«Æ°ÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + /* °Ê²¼¤Ï²¿¤ò¤ä¤Ã¤Æ¤¤¤ë¤Î¤«¤·¤é¡© */ + if (TanMuhenkan(d) == -1) { + return -2; + } + return(-1); + } + } + yc->nbunsetsu = RkwSubstYomi(yc->context, + yc->ys - yc->cStartp, yc->ye - yc->cStartp, + yc->kana_buffer + yc->ys, yc->kEndp - yc->ys); + yc->ys = yc->ye = yc->kEndp; + if (yc->nbunsetsu < 0 || (ret = restoreChikujiYomi(d, n)) < 0) { + goto substError; + } + return(ret); +} + +ChikujiSubstYomi(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if ((yc->ys == yc->ye && yc->kEndp == yc->ye) + || yc->kEndp != yc->kCurs + || !(yc->kAttr[yc->kEndp - 1] & HENKANSUMI)) { + /* ¿·¤·¤¤ÆþÎϤ¬¤Ê¤«¤Ã¤¿¤ê¡¢ + ºÇ¸å¤Ø¤ÎÆþÎϤ¸¤ã¤Ê¤«¤Ã¤¿¤ê¡¢ + ºÇ¸å¤Î»ú¤¬¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤µ¤ì¤Ä¤¯¤·¤Æ¤¤¤Ê¤«¤Ã¤¿¤ê¤·¤¿¤é */ + return 0; /* ¤Ê¤Ë¤â¤·¤Ê¤¤ */ + } + return chikujiSubstYomi(d); +} + +int +ChikujiTanDeletePrevious(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int i, j, l = 0, flg = 0; + RkStat stat; + + if (yc->cRStartp < yc->rEndp) { /* ¥í¡¼¥Þ»ú¤¬Æþ¤Ã¤Æ¤¤¤ë */ + flg = 1; + } + d->nbytes = 0; + + /* ¤Þ¤º¥«¥ì¥ó¥ÈʸÀᤫ¤é¸å¤í¤òÆÉ¤ß¤ËÌ᤹ */ + if (forceRomajiFlushYomi(d)) { + return d->nbytes; + } + if (RkwSubstYomi(yc->context, 0, yc->ye - yc->cStartp, + (WCHAR_T *)0, 0) == NG) { + /* ÆÉ¤ß¤Ç»Ä¤Ã¤Æ¤¤¤ëʬ¤òÃ༡¤Î¥Ç¡¼¥¿¤«¤é¾Ã¤¹ */ + (void)makeRkError(d, "\306\311\244\337\244\313\314\341\244\271\244\263" + "\244\310\244\254\244\307\244\255\244\336\244\273\244\363"); + /* ÆÉ¤ß¤ËÌ᤹¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó */ + (void)TanMuhenkan(d); /* ¤³¤ìÍפë¤Î¡© */ + return 0; + } + yc->ys = yc->ye = yc->cStartp; + for (i = yc->nbunsetsu - 1 ; i >= yc->curbun ; i--) { + /* ¥«¥ì¥ó¥ÈʸÀᤫ¤é¸å¤í¤òÆÉ¤ß¤ËÌ᤹¤¿¤á¤Î½àÈ÷ */ + if (RkwGoTo(yc->context, i) == NG + || RkwGetStat(yc->context, &stat) == NG + || RkwStoreYomi(yc->context, (WCHAR_T *)0, 0) == NG) { + (void)makeRkError(d, "\306\311\244\337\244\313\314\341\244\271\244\263" + "\244\310\244\254\244\307\244\255\244\336\244\273\244\363"); + /* ÆÉ¤ß¤ËÌ᤹¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó */ + TanMuhenkan(d); /* ¤³¤ì¡¢Íפë¤Î¡© */ + return 0; + } + l += stat.ylen; + } + yc->nbunsetsu = yc->curbun; + if (l) { + i = j = 0; + do { + ++i; + if (yc->kAttr[yc->cStartp - i] & SENTOU) { + for (j++ ; + j < yc->cRStartp && !(yc->rAttr[yc->cRStartp - j] & SENTOU) ;) { + j++; + } + } + } while (i < l); + yc->cStartp = (i < yc->cStartp) ? yc->cStartp - i : 0; + yc->cRStartp = (j < yc->cRStartp) ? yc->cRStartp - j : 0; + } + if (KeepCursorPosition && yc->kCurs != yc->kEndp) { + yc->kRStartp = yc->kCurs = yc->cStartp; + yc->rStartp = yc->rCurs = yc->cRStartp; + } + else { + yc->kRStartp = yc->kCurs = yc->kEndp; + yc->rStartp = yc->rCurs = yc->rEndp; + } + yc->ys = yc->ye = yc->cStartp; + clearHenkanContent(yc); + if (yc->curbun) { + yc->curbun--; + } + yc->status |= CHIKUJI_OVERWRAP; + moveToChikujiYomiMode(d); + makeKanjiStatusReturn(d, yc); + if (flg && cannaconf.chikujiRealBackspace && !KeepCursorPosition) { + d->more.todo = 1; + d->more.ch = 0; + d->more.fnum = CANNA_FN_DeletePrevious; + /* Ʊ¤¸¤³¤È¤ò¤Þ¤¿¤ä¤ë¤Ã¤Æ´¶¤¸¤À¤¾ */ + } + return 0; +} + +/* + chikuji_restore_yomi + + cStartp, cRStartp ¤òÄ´À°¤¹¤ë + */ + +static int +chikuji_restore_yomi(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int l, j; + + if ((l = RkwGetLastYomi(yc->context, d->genbuf, ROMEBUFSIZE)) == -1) { + return makeRkError(d, "\314\244\267\350\312\270\300\341\244\362\274\350" + "\244\352\275\320\244\273\244\336\244\273\244\363\244\307\244\267" + "\244\277"); + /* ̤·èʸÀá¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + } + if (l != yc->kEndp - yc->cStartp) { /* ÊѤï¤Ã¤¿¤é */ + kPos2rPos(yc, 0, yc->kEndp - l, (int *)0, &j); + yc->cStartp = yc->kEndp - l; + yc->cRStartp = j; + } + + yc->ys = yc->ye = yc->cStartp; + return 0; +} + +static int +chikuji_subst_yomi(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int l, n = yc->nbunsetsu; + + /* ÆÉ¤ß¤òÁ´Éô¿©¤ï¤»¤ë */ + l = RkwSubstYomi(yc->context, yc->ys - yc->cStartp, yc->ye - yc->cStartp, + yc->kana_buffer + yc->ys, yc->kEndp - yc->ys); + yc->ys = yc->ye = yc->kEndp; + if (l == -1) { + jrKanjiError = "\312\321\264\271\244\313\274\272\307\324\244\267\244\336" + "\244\267\244\277"; + /* ÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + (void)TanMuhenkan(d); + return -1; + } + yc->nbunsetsu = l; + if (l > n) { + yc->curbun = n; /* Á°¤ÎʸÀ᤬¥«¥ì¥ó¥È */ + } + return chikuji_restore_yomi(d); +} + + +static int +ChikujiTanExtend(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int i; + + d->nbytes = 0; + yc->kouhoCount = 0; + + if (yc->ys < yc->kEndp || yc->ye != yc->kEndp) { + i = yc->curbun; /* ¤È¤Ã¤È¤¯ */ + if (chikuji_subst_yomi(d) == -1) { + makeGLineMessageFromString(d, jrKanjiError); + return TanMuhenkan(d); + } + if (RkwGoTo(yc->context, i) == -1) { + (void)makeRkError(d, "\312\270\300\341\244\316\260\334\306\260\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return TanMuhenkan(d); + } + yc->curbun = i; + } + if ((yc->nbunsetsu = RkwEnlarge(yc->context)) <= 0) { + (void)makeRkError(d, "\312\270\300\341\244\316\263\310\302\347\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î³ÈÂç¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return TanMuhenkan(d); + } + if (chikuji_restore_yomi(d) == NG) { + return TanMuhenkan(d); + } + yc->status |= CHIKUJI_OVERWRAP; + makeKanjiStatusReturn(d, yc); + return d->nbytes; +} + + +static int +ChikujiTanShrink(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + RkStat stat; + int i; + + d->nbytes = 0; + yc->kouhoCount = 0; + if (yc->ys < yc->kEndp || yc->ye != yc->kEndp) { + i = yc->curbun; + if (chikuji_subst_yomi(d) == -1) { + makeGLineMessageFromString(d, jrKanjiError); + return TanMuhenkan(d); + } + if (RkwGoTo(yc->context, i) == -1) { + (void)makeRkError(d, "\312\270\300\341\244\316\275\314\276\256\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î½Ì¾®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return TanMuhenkan(d); + } + yc->curbun = i; + } + + if (RkwGetStat(yc->context, &stat) < 0 || stat.ylen == 1) { + /* ¤³¤ì°Ê¾åû¤¯¤Ç¤­¤ë¤«¤É¤¦¤«³Îǧ¡£Íפ롩 */ + return NothingForGLine(d); + } + yc->nbunsetsu = RkwShorten(yc->context); + if (yc->nbunsetsu <= 0) { /* 0 ¤Ã¤Æ¤³¤È¤¢¤ó¤Î¤«¤Ê¤¢¡© */ + (void)makeRkError(d, "\312\270\300\341\244\316\275\314\276\256\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î½Ì¾®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return TanMuhenkan(d); + } + if (chikuji_restore_yomi(d) == NG) { + return TanMuhenkan(d); + } + yc->status |= CHIKUJI_OVERWRAP; + makeKanjiStatusReturn(d, yc); + return d->nbytes; +} + + +static int +ChikujiYomiDeletePrevious(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + RkStat stat; + int i, j, l = 0; + + d->nbytes = 0; + if (!(yc->cStartp < yc->kCurs)) { /* ÆÉ¤ß¤¬¤Ê¤¤¤Ê¤é */ + if (!yc->nbunsetsu) { /* ʸÀá¤â¤Ê¤¤ */ + return NothingChanged(d); + } + else { + if (RkwSubstYomi(yc->context, 0, yc->ye - yc->cStartp, + (WCHAR_T *)0, 0) == NG) { + (void)makeRkError(d, "\306\311\244\337\244\313\314\341\244\271\244\263" + "\244\310\244\254\244\307\244\255\244\336\244\273\244\363"); + /* ÆÉ¤ß¤ËÌ᤹¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó */ + (void)TanMuhenkan(d); + return 0; + } + yc->ys = yc->ye = yc->cStartp; + yc->curbun = yc->nbunsetsu - 1; /* ¤Ò¤È¤ÄÆÉ¤ß¤ËÌ᤹ */ + for (i = yc->nbunsetsu - 1; i >= yc->curbun; i--) { + if (RkwGoTo(yc->context, i) == NG || + RkwGetStat(yc->context, &stat) == NG || + RkwStoreYomi(yc->context, (WCHAR_T *)0, 0) == NG) { + return makeRkError(d, "\306\311\244\337\244\313\314\341\244\271" + "\244\263\244\310\244\254\244\307\244\255\244\336\244\273\244\363"); + /* ÆÉ¤ß¤ËÌ᤹¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó */ + } + l += stat.ylen; + yc->nbunsetsu--; + } + i = j = 0; + do { + ++i; + if (yc->kAttr[yc->cStartp - i] & SENTOU) { + for (j++ ; + j < yc->cRStartp && !(yc->rAttr[yc->cRStartp - j] & SENTOU) ;) { + j++; + } + } + } while (i < l); + yc->kCurs = yc->kRStartp = yc->cStartp; + yc->rCurs = yc->rStartp = yc->cRStartp; + yc->cStartp = (i < yc->cStartp) ? yc->cStartp - i : 0; + yc->cRStartp = (j < yc->cRStartp) ? yc->cRStartp - j : 0; + yc->ys = yc->ye = yc->cStartp; + clearHenkanContent(yc); + if (yc->curbun) { + yc->curbun--; + } + + makeKanjiStatusReturn(d, yc); + return 0; + } + } + if (yc->kCurs - 1 < yc->ys) { + yc->ys = yc->kCurs - 1; + } + if (yc->ys < 0) { + yc->ys = 0; + } + KanaDeletePrevious(d); + yc->status |= CHIKUJI_OVERWRAP; + if (yc->kCurs <= yc->cStartp && yc->kEndp <= yc->cStartp && yc->nbunsetsu) { + /* ʸÀá¤Ï¤¢¤ë¤Î¤ËÆÉ¤ß¤¬¤Ê¤¤¤Ê¤é */ + if (RkwGoTo(yc->context, yc->nbunsetsu - 1) == -1) { + return makeRkError(d, "\312\270\300\341\244\316\260\334\306\260\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + yc->kouhoCount = 0; + yc->curbun = yc->nbunsetsu - 1; + moveToChikujiTanMode(d); + makeKanjiStatusReturn(d, yc); + } + else { + moveToChikujiYomiMode(d); + makeYomiReturnStruct(d); + if (yc->kEndp <= yc->cStartp && !yc->nbunsetsu) { + /* ²¿¤Ë¤â¤Ê¤¤ */ + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + } + return 0; +} + + +static int +ChikujiHenkan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int n, tmp, idx; + + if (!yc->nbunsetsu && yc->rEndp == /* yc->cRStartp(== 0) + */ 1 && + (yc->kAttr[0] & SUPKEY) && + (idx = findSup(yc->romaji_buffer[0]))) { + return selectKeysup(d, yc, idx - 1); + } + if (!doesSupportChikuji()) { + jrKanjiError = "\245\265\241\274\245\320\244\254\303\340\274\241\274\253" + "\306\260\312\321\264\271\244\362\245\265\245\335\241\274\245\310" + "\244\267\244\306\244\244\244\336\244\273\244\363"; + /* ¥µ¡¼¥Ð¤¬Ã༡¼«Æ°ÊÑ´¹¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó */ + makeGLineMessageFromString(d, jrKanjiError); + makeKanjiStatusReturn(d, yc); + d->nbytes = 0; + return 0; + } + if (yc->status & CHIKUJI_ON_BUNSETSU) { + tmp = yc->curbun; + } + else { + tmp = yc->nbunsetsu; + } + d->nbytes = 0; + if (yc->kCurs < yc->ys) { + yc->ys = yc->kCurs; + } + if (forceRomajiFlushYomi(d)) { + return d->nbytes; + } + + if (containUnconvertedKey(yc)) { + if (yc->cmark < yc->cStartp) { + yc->cmark = yc->cStartp; + } + YomiMark(d); + yc->ys = yc->pmark; + if (forceRomajiFlushYomi(d)) { + return d->nbytes; + } + } + + yc->kRStartp = yc->kCurs = yc->kEndp; + yc->rStartp = yc->rCurs = yc->rEndp; + + if (yc->cStartp < yc->kEndp) { /* ÆÉ¤ß¤¬¤¢¤ì¤Ð */ + yc->kCurs = yc->kEndp; + if (chikujiSubstYomi(d) < 0) { + makeGLineMessageFromString(d, jrKanjiError); + TanMuhenkan(d); + return 0; + } + n = RkwFlushYomi(yc->context); + if (n == -1) { + (void)makeRkError(d, "\312\321\264\271\244\313\274\272\307\324\244\267" + "\244\336\244\267\244\277"); + /* ÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + (void)TanMuhenkan(d); + return 0; + } + yc->cStartp = yc->kEndp; + yc->cRStartp = yc->rEndp; + yc->kouhoCount = 1; + yc->status |= CHIKUJI_ON_BUNSETSU; + if (n > yc->nbunsetsu) { + yc->curbun = yc->nbunsetsu; + yc->nbunsetsu = n; + } + } + if (RkwGoTo(yc->context, tmp) == -1) { + makeRkError(d, "\303\340\274\241\312\321\264\271\244\313\274\272\307\324" + "\244\267\244\336\244\267\244\277"); + /* Ã༡ÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return 0; + } + yc->curbun = tmp; + yc->ys = yc->ye = yc->cStartp; + d->current_mode = yc->curMode = &tankouho_mode; + yc->minorMode = CANNA_MODE_TankouhoMode; + if (cannaconf.kouho_threshold > 0 && + yc->kouhoCount >= cannaconf.kouho_threshold) { + return tanKouhoIchiran(d, 0); + } + currentModeInfo(d); + makeKanjiStatusReturn(d, yc); + return d->nbytes; +} + +void +moveToChikujiTanMode(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + yc->status |= CHIKUJI_ON_BUNSETSU; + yc->minorMode = CANNA_MODE_ChikujiTanMode; + d->current_mode = yc->curMode = &cb_mode; + currentModeInfo(d); +} + +void +moveToChikujiYomiMode(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + yc->status &= ~CHIKUJI_ON_BUNSETSU; + d->current_mode = yc->curMode = &cy_mode; + EmptyBaseModeInfo(d, yc); +} + +static int +generalNaive(uiContext d, int (*fn )(...)) +{ + if ((((yomiContext)d->modec)->generalFlags) & + (CANNA_YOMI_HANKAKU | CANNA_YOMI_ROMAJI | CANNA_YOMI_BASE_HANKAKU)) { + return (*fn)(d); + } + else { + return ChikujiHenkan(d); + } +} + +static int +ChikujiHenkanNaive(uiContext d) +{ + return generalNaive(d, YomiInsert); +} + + +static int +ChikujiHenkanOrNothing(uiContext d) +{ + return generalNaive(d, NothingChanged); +} + + +static int +ChikujiMuhenkan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->nbunsetsu) { + return TanMuhenkan(d); + } + else if (yc->left || yc->right) { + removeCurrentBunsetsu(d, (tanContext)yc); + yc = (yomiContext)d->modec; + } + else { + RomajiClearYomi(d); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + makeKanjiStatusReturn(d, yc); + return 0; +} + +#include "chikujimap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/chikujimap.h b/src/add-ons/input_server/methods/canna/lib/chikujimap.h new file mode 100644 index 0000000000..84fcae83d4 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/chikujimap.h @@ -0,0 +1,93 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char chikuji_id[] = "$Id: chikujimap.h,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif +#include "canna.h" + +#define BUNPOU_DISPLAY +#define NONE CANNA_FN_Undefined + +/* CYsearchfunc ¤¬»È¤ï¤ì¤ë¤Î¤Ç°Ê²¼¤Îɽ¤Ë²Ã¤¨¤Æ yomi_mode ¤Î¥Þ¥Ã¥×¤â»È¤ï¤ì¤ë */ + +static struct funccfunc cy_funcs[] = { + {CANNA_FN_FunctionalInsert , YomiInsert/* ËÜÅö¤ÏÍפé¤Ê¤¤ */}, + {CANNA_FN_DeletePrevious , ChikujiYomiDeletePrevious }, + {CANNA_FN_Henkan , ChikujiHenkan }, + {CANNA_FN_HenkanOrInsert , ChikujiHenkanNaive }, + {CANNA_FN_HenkanOrNothing , ChikujiHenkanOrNothing }, + {CANNA_FN_Quit , ChikujiMuhenkan }, + {0 , 0 }, +}; + +extern BYTE default_kmap[]; + +KanjiModeRec cy_mode = { + CYsearchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + cy_funcs, +}; + +static struct funccfunc cb_funcs[] = { + {CANNA_FN_FunctionalInsert , YomiInsert/* ËÜÅö¤ÏÍפé¤Ê¤¤ */}, + {CANNA_FN_Forward , TanForwardBunsetsu }, + {CANNA_FN_Backward , TanBackwardBunsetsu }, + {CANNA_FN_Next , TanNextKouho }, + {CANNA_FN_Prev , TanPreviousKouho }, + {CANNA_FN_BeginningOfLine , TanBeginningOfBunsetsu }, + {CANNA_FN_EndOfLine , TanEndOfBunsetsu }, + {CANNA_FN_DeletePrevious , ChikujiTanDeletePrevious }, + {CANNA_FN_KillToEndOfLine , TanBubunKakutei }, + {CANNA_FN_Henkan , ChikujiHenkan }, + {CANNA_FN_HenkanOrInsert , ChikujiHenkanNaive }, + {CANNA_FN_HenkanOrNothing , ChikujiHenkanOrNothing }, + {CANNA_FN_Quit , TanMuhenkan }, + {CANNA_FN_Extend , ChikujiTanExtend }, + {CANNA_FN_Shrink , ChikujiTanShrink }, +/* {CANNA_FN_AdjustBunsetsu , TanBunsetsuMode }, */ + {CANNA_FN_KouhoIchiran , TanKouhoIchiran }, + {CANNA_FN_BubunMuhenkan , TanBubunMuhenkan }, + {CANNA_FN_Zenkaku , TanZenkaku }, + {CANNA_FN_Hankaku , TanHankaku }, + {CANNA_FN_Hiragana , TanHiragana }, + {CANNA_FN_Katakana , TanKatakana }, + {CANNA_FN_Romaji , TanRomaji }, + {CANNA_FN_ToUpper , TanUpper }, + {CANNA_FN_ToLower , TanRomaji }, + {CANNA_FN_Capitalize , TanCapitalize }, + {CANNA_FN_KanaRotate , TanKanaRotate }, + {CANNA_FN_RomajiRotate , TanRomajiRotate }, + {CANNA_FN_CaseRotate , TanCaseRotateForward }, +#ifdef BUNPOU_DISPLAY + {CANNA_FN_ConvertAsHex ,TanPrintBunpou }, +#endif + {0 , 0 }, +}; + +KanjiModeRec cb_mode = { + CYsearchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + cb_funcs +}; diff --git a/src/add-ons/input_server/methods/canna/lib/commondata.c b/src/add-ons/input_server/methods/canna/lib/commondata.c new file mode 100644 index 0000000000..7f00c7c62f --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/commondata.c @@ -0,0 +1,258 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: commondata.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include +#include "patchlevel.h" +#include + +struct CannaConfig cannaconf; + +/* ¥Ç¥Õ¥©¥ë¥È¤Î¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹ÍѤΥХåե¡ */ + +int defaultContext = -1; +int defaultBushuContext = -1; + +/* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë */ +/* + * ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Ï£±¸Ä¤¢¤ì¤ÐÎɤ¤¤Ç¤·¤ç¤¦¡£Ê£¿ô¸ÄɬÍ×¤Ê¤Î¤Ç + * ¤¢¤ì¤Ð RomeStruct ¤Î¥á¥ó¥Ð¤È¤·¤ÆÆþ¤ì¤Æ¤ª¤¯É¬Íפ⤢¤ê¤Þ¤·¤ç¤¦¤¬...¤½ + * ¤Î»þ¤Ï¤½¤Î»þ¤Ç¹Í¤¨¤Þ¤·¤ç¤¦¡£ + */ + +struct RkRxDic *romajidic, *englishdic; + +/* ̤ÄêµÁ¥­¡¼ÂǸ°»þ¤Î½èÍý¤Î¤·¤«¤¿ */ + +int howToBehaveInCaseOfUndefKey = kc_normal; + +/* + * ¼­½ñ¤Î̾Á°¤òÆþ¤ì¤Æ¤ª¤¯ÊÑ¿ô + */ + +char saveapname[CANNA_MAXAPPNAME]; /* ¥µ¡¼¥Ð¤È¤ÎÀܳ¤òÀÚ¤ë¤È¤­¤ÎAP̾ */ + +/* + * irohacheck ¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤Æ»È¤ï¤ì¤Æ¤¤¤ë¤«¤È¤«¡¢ + * irohacheck ¤Ê¤¤¤Ç¤Î verbose ¤òɽ¤¹ÃÍ¡£ + */ + +int ckverbose = 0; + +/* + * ¥¨¥é¡¼¤Î¥á¥Ã¥»¡¼¥¸¤òÆþ¤ì¤Æ¤ª¤¯ÊÑ¿ô + */ + +char *jrKanjiError = ""; + +/* + * ¥Ç¥Ð¥°¥á¥Ã¥»¡¼¥¸¤ò½Ð¤¹¤«¤É¤¦¤«¤Î¥Õ¥é¥° + */ + +int iroha_debug = 0; + +/* + * »Ï¤á¤Æ¤Î»ÈÍѤ«¤É¤¦¤«¤ò¼¨¤¹¥Õ¥é¥° + */ + +int FirstTime = 1; + +/* +* dictonary base path +*/ + +char basepath[256]; + +/* + * ¥Ó¡¼¥×²»¤òÌĤ餹´Ø¿ô¤ò³ÊǼ¤¹¤ë¤È¤³¤í + */ + +int (*jrBeepFunc)() = (int (*)())NULL; +//int (*jrBeepFunc)() = (int (*)())beep(); + +/* + * KC_INITIALIZE ľ¸å¤Ë¼Â¹Ô¤¹¤ëµ¡Ç½¤ÎÎó + */ + +BYTE *initfunc = (BYTE *)0; +int howToReturnModeInfo = ModeInfoStyleIsString; +char *RomkanaTable = (char *)NULL; +char *EnglishTable = (char *)NULL; +/* char *Dictionary = (char *)NULL; */ +struct dicname *RengoGakushu = (struct dicname *)NULL; +struct dicname *KatakanaGakushu = (struct dicname *)NULL; +struct dicname *HiraganaGakushu = (struct dicname *)NULL; + +int nKouhoBunsetsu = 16; + +int KeepCursorPosition = 0; + +int nothermodes = 0; + +keySupplement keysup[MAX_KEY_SUP]; +int nkeysup = 0; + +/* + * ½é´ü²½¤ÎºÝ»ÈÍѤ·¤¿½é´ü²½¥Õ¥¡¥¤¥ë̾¤òÁ´¤Æ¤È¤Ã¤Æ¤ª¤¯¥Ð¥Ã¥Õ¥¡¡£ + * ¥Õ¥¡¥¤¥ë̾¤Ï","¤Ç¶èÀÚ¤é¤ì¤ë¡£(³ÈÄ¥µ¡Ç½¤Ç»ÈÍÑ) + */ + +char *CANNA_initfilename = (char *)NULL; + +/* + * ¥Ð¡¼¥¸¥ç¥ó + */ + +int protocol_version = -1; +int server_version = -1; +char *server_name = (char *)NULL; + +int chikuji_debug = 0; +int auto_define = 0; + +int locale_insufficient = 0; + +void (*keyconvCallback)(...) = (void (*)(...))0; + +extraFunc *extrafuncp = (extraFunc *)NULL; +struct dicname *kanjidicnames; /* .canna ¤Ç»ØÄꤷ¤Æ¤¤¤ë¼­½ñ¥ê¥¹¥È */ +char *kataautodic = (char *)NULL; /* ¥«¥¿¥«¥Ê¸ì¼«Æ°ÅÐÏ¿ÍѼ­½ñ */ +#ifdef HIRAGANAAUTO +char *hiraautodic = (char *)NULL; /* ¤Ò¤é¤¬¤Ê¸ì¼«Æ°ÅÐÏ¿ÍѼ­½ñ */ +#endif + +static void freeUInfo(void); + +/* ¥æ¡¼¥¶¾ðÊó */ +jrUserInfoStruct *uinfo = (jrUserInfoStruct *)NULL; + +/* ¥¹¥¿¥ó¥É¥¢¥í¥ó¤«¤É¤¦¤«¤Î¥Õ¥é¥° */ +int standalone = 0; + +void +InitCannaConfig(struct CannaConfig *cf) +{ + bzero(cf, sizeof(struct CannaConfig)); + cf->CannaVersion = CANNA_MAJOR_MINOR; + cf->kouho_threshold = 2; + cf->strokelimit = STROKE_LIMIT; + cf->CursorWrap = 1; + cf->SelectDirect = 1; + cf->HexkeySelect = 1; + cf->ChBasedMove = 1; + cf->Gakushu = 1; + cf->grammaticalQuestion = 1; + cf->stayAfterValidate = 1; + cf->kCount = 1; + cf->hexCharacterDefiningStyle = HEX_USUAL; + cf->ChikujiContinue = 1; + cf->MojishuContinue = 1; + cf->kojin = 1; + cf->indexSeparator = DEFAULTINDEXSEPARATOR; + cf->allowNextInput = 1; + cf->chikujiRealBackspace = 1; + cf->BackspaceBehavesAsQuit = 1; + cf->doKatakanaGakushu = 1; + cf->doHiraganaGakushu = 1; + cf->auto_sync = 1; +} + +static void freeUInfo (void); + +static void +freeUInfo(void) +{ + if (uinfo) { + if (uinfo->uname) + free(uinfo->uname); + if (uinfo->gname) + free(uinfo->gname); + if (uinfo->srvname) + free(uinfo->srvname); + if (uinfo->topdir) + free(uinfo->topdir); + if (uinfo->cannafile) + free(uinfo->cannafile); + if (uinfo->romkanatable) + free(uinfo->romkanatable); + free(uinfo); + uinfo = (jrUserInfoStruct *)NULL; + } +} + +/* + ¥Ç¥Õ¥¡¡¼¥ë¥ÈÃͤˤâ¤É¤¹¡£ +*/ +void +restoreBindings(void) +{ + InitCannaConfig(&cannaconf); + + if (initfunc) free(initfunc); + initfunc = (BYTE *)NULL; + + if (server_name) free(server_name); + server_name = (char *)NULL; + + if (RomkanaTable) { + free(RomkanaTable); + RomkanaTable = (char *)NULL; + } + if (EnglishTable) { + free(EnglishTable); + EnglishTable = (char *)NULL; + } + romajidic = (struct RkRxDic *)NULL; + englishdic = (struct RkRxDic *)NULL; + RengoGakushu = (struct dicname *)NULL; + KatakanaGakushu = (struct dicname *)NULL; + HiraganaGakushu = (struct dicname *)NULL; + howToBehaveInCaseOfUndefKey = kc_normal; +/* kanjidicname[nkanjidics = 0] = (char *)NULL; Âå¤ï¤ê¤Î¤³¤È¤ò¤·¤Ê¤±¤ì¤Ð */ + kanjidicnames = (struct dicname *)NULL; + kataautodic = (char *)NULL; +#ifdef HIRAGANAAUTO + hiraautodic = (char *)NULL; +#endif + auto_define = 0; + saveapname[0] = '\0'; + KeepCursorPosition = 0; + + nothermodes = 0; + protocol_version = server_version = -1; + nKouhoBunsetsu = 16; + nkeysup = 0; + chikuji_debug = 0; + keyconvCallback = (void (*)(...))0; + locale_insufficient = 0; + freeUInfo(); + standalone = 0; +} diff --git a/src/add-ons/input_server/methods/canna/lib/defaultmap.c b/src/add-ons/input_server/methods/canna/lib/defaultmap.c new file mode 100644 index 0000000000..0e72f62f72 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/defaultmap.c @@ -0,0 +1,473 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: defaultmap.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include + +extern int howToBehaveInCaseOfUndefKey; + +#define DEFAULTBEHAVIOR 0 + +static int +(*getfunc( +struct funccfunc *tbl, +unsigned char f))(...) +{ + struct funccfunc *p; + + for (p = tbl ; p->funcid || p->cfunc ; p++) { + if (p->funcid == (unsigned char)f) { + return p->cfunc; + } + } + return (int (*)())0; +} + +static +simpleUndefBehavior(uiContext d) +{ + switch (howToBehaveInCaseOfUndefKey) + { + case kc_through: + d->kanji_status_return->length = -1; + return d->nbytes; + case kc_kakutei: + d->nbytes = escapeToBasicStat(d, CANNA_FN_Kakutei); + if (d->n_buffer > d->nbytes) { + int check; + d->buffer_return[d->nbytes] = + key2wchar(d->ch, &check); + if (check) { + d->nbytes++; + } + } + return d->nbytes; + case kc_kill: + d->nbytes = escapeToBasicStat(d, CANNA_FN_Quit); + if (d->n_buffer > d->nbytes) { + int check; + d->buffer_return[d->nbytes] = + key2wchar(d->ch, &check); + if (check) { + d->nbytes++; + } + } + return d->nbytes; + case kc_normal: + default: + return NothingChangedWithBeep(d); + } +} + +int +searchfunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum) +{ + int (*func)(...); + + if (fnum == 0) { + fnum = mode->keytbl[key]; + } + switch (whattodo) { + case KEY_CALL: + /* ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¥â¡¼¥É¤¬ strokelimit ¥¹¥È¥í¡¼¥¯°Ê¾å³¤¤¤¿¤é + ¥µ¡¼¥Ð¤È¤ÎÀܳ¤òÀÚ¤ë */ + if (cannaconf.strokelimit > 0) { + extern KanjiModeRec alpha_mode; + if (mode == &alpha_mode) { + d->strokecounter++; +#ifdef DEBUG + if (iroha_debug) { + fprintf(stderr, "d->strokecounter=%d\n", d->strokecounter); + } +#endif + if (d->strokecounter == cannaconf.strokelimit + 1) { + jrKanjiPipeError(); + } + }else{ + d->strokecounter = 0; +#ifdef DEBUG + if (iroha_debug) { + fprintf(stderr, "d->strokecounter=%d\n", d->strokecounter); + } +#endif + } + } + /* ¤¤¤è¤¤¤èËܳÊŪ¤Ê½èÍý(¤³¤³¤Þ¤Ç¤ÏÁ°½èÍý) */ + if (fnum < CANNA_FN_MAX_FUNC) { + func = getfunc(mode->ftbl, fnum); + if (func) { + return (*func)(d); + } + } + else { + func = getfunc(mode->ftbl, CANNA_FN_UserMode); + if (func) { + /* func ¤Î¥¿¥¤¥×¤¬¾å¤È°ã¤Ã¤Æ¤Æ±ø¤¤¤Ê¤¢... */ + return (*func)(d, fnum); + } + } + /* ¤½¤Î¥â¡¼¥É¤Ç fnum ¤ËÂбþ¤¹¤ëµ¡Ç½¤¬¤Ê¤¤¡£¤·¤«¤¿¤¬¤Ê¤¤¤Î¤Ç¡¢ + ¥Ç¥Õ¥©¥ë¥Èµ¡Ç½¤òõ¤¹ */ + func = getfunc(mode->ftbl, DEFAULTBEHAVIOR); + if (func) { + return (*func)(d); + } + else { + return simpleUndefBehavior(d); + } + /* NOTREACHED */ + break; + case KEY_CHECK: + if (fnum >= CANNA_FN_MAX_FUNC) { + fnum = CANNA_FN_UserMode; + } + return getfunc(mode->ftbl, fnum) ? 1 : 0; + /* NOTREACHED */ + break; + case KEY_SET: /* is not supported yet */ + return 0; + /* NOTREACHED */ + break; + } + /* NOTREACHED */ +} + +/* Ã༡ÆÉ¤ß¥â¡¼¥ÉÍÑ */ + +int +CYsearchfunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum) +{ + int (*func)(...); + extern KanjiModeRec yomi_mode; + + if (fnum == 0) { + fnum = mode->keytbl[key]; + } + if (Yomisearchfunc(d, mode, KEY_CHECK, key, fnum)) { + return Yomisearchfunc(d, mode, whattodo, key, fnum); + } + else { + func = getfunc(yomi_mode.ftbl, fnum); + switch (whattodo) { + case KEY_CALL: + if (func) { + return (*func)(d); + }else{ + return Yomisearchfunc(d, mode, whattodo, key, fnum); + } + /* NOTREACHED */ + break; + case KEY_CHECK: + return func ? 1 : 0; + /* NOTREACHED */ + break; + case KEY_SET: + return 0; + /* NOTREACHED */ + break; + } + } + /* may be NOTREACHED */ + return 0; +} + +#define NONE CANNA_FN_Undefined + +BYTE default_kmap[256] = +{ +/* C-@ */ CANNA_FN_Mark, +/* C-a */ CANNA_FN_BeginningOfLine, +/* C-b */ CANNA_FN_Backward, +/* C-c */ CANNA_FN_BubunMuhenkan, +/* C-d */ CANNA_FN_DeleteNext, +/* C-e */ CANNA_FN_EndOfLine, +/* C-f */ CANNA_FN_Forward, +/* C-g */ CANNA_FN_Quit, +/* C-h */ CANNA_FN_DeletePrevious, +/* C-i */ CANNA_FN_Shrink, +/* C-j */ CANNA_FN_BubunKakutei, +/* C-k */ CANNA_FN_KillToEndOfLine, +/* C-l */ CANNA_FN_ToLower, +/* C-m */ CANNA_FN_Kakutei, +/* C-n */ CANNA_FN_Next, +/* C-o */ CANNA_FN_Extend, +/* C-p */ CANNA_FN_Prev, +/* C-q */ CANNA_FN_QuotedInsert, +/* C-r */ NONE, +/* C-s */ NONE, +/* C-t */ NONE, +/* C-u */ CANNA_FN_ToUpper, +/* C-v */ NONE, +/* C-w */ CANNA_FN_KouhoIchiran, +/* C-x */ NONE, +/* C-y */ CANNA_FN_ConvertAsHex, +/* C-z */ NONE, +#ifdef WIN +/* C-[ */ CANNA_FN_Quit, +#else +/* C-[ */ NONE, +#endif +/* C-\ */ NONE, +/* C-] */ NONE, +/* C-^ */ NONE, +/* C-_ */ NONE, +/* space */ CANNA_FN_Henkan, +/* ! */ CANNA_FN_FunctionalInsert, +/* " */ CANNA_FN_FunctionalInsert, +/* # */ CANNA_FN_FunctionalInsert, +/* $ */ CANNA_FN_FunctionalInsert, +/* % */ CANNA_FN_FunctionalInsert, +/* & */ CANNA_FN_FunctionalInsert, +/* ' */ CANNA_FN_FunctionalInsert, +/* ( */ CANNA_FN_FunctionalInsert, +/* ) */ CANNA_FN_FunctionalInsert, +/* * */ CANNA_FN_FunctionalInsert, +/* + */ CANNA_FN_FunctionalInsert, +/* , */ CANNA_FN_FunctionalInsert, +/* - */ CANNA_FN_FunctionalInsert, +/* . */ CANNA_FN_FunctionalInsert, +/* / */ CANNA_FN_FunctionalInsert, +/* 0 */ CANNA_FN_FunctionalInsert, +/* 1 */ CANNA_FN_FunctionalInsert, +/* 2 */ CANNA_FN_FunctionalInsert, +/* 3 */ CANNA_FN_FunctionalInsert, +/* 4 */ CANNA_FN_FunctionalInsert, +/* 5 */ CANNA_FN_FunctionalInsert, +/* 6 */ CANNA_FN_FunctionalInsert, +/* 7 */ CANNA_FN_FunctionalInsert, +/* 8 */ CANNA_FN_FunctionalInsert, +/* 9 */ CANNA_FN_FunctionalInsert, +/* : */ CANNA_FN_FunctionalInsert, +/* ; */ CANNA_FN_FunctionalInsert, +/* < */ CANNA_FN_FunctionalInsert, +/* = */ CANNA_FN_FunctionalInsert, +/* > */ CANNA_FN_FunctionalInsert, +/* ? */ CANNA_FN_FunctionalInsert, +/* @ */ CANNA_FN_FunctionalInsert, +/* A */ CANNA_FN_FunctionalInsert, +/* B */ CANNA_FN_FunctionalInsert, +/* C */ CANNA_FN_FunctionalInsert, +/* D */ CANNA_FN_FunctionalInsert, +/* E */ CANNA_FN_FunctionalInsert, +/* F */ CANNA_FN_FunctionalInsert, +/* G */ CANNA_FN_FunctionalInsert, +/* H */ CANNA_FN_FunctionalInsert, +/* I */ CANNA_FN_FunctionalInsert, +/* J */ CANNA_FN_FunctionalInsert, +/* K */ CANNA_FN_FunctionalInsert, +/* L */ CANNA_FN_FunctionalInsert, +/* M */ CANNA_FN_FunctionalInsert, +/* N */ CANNA_FN_FunctionalInsert, +/* O */ CANNA_FN_FunctionalInsert, +/* P */ CANNA_FN_FunctionalInsert, +/* Q */ CANNA_FN_FunctionalInsert, +/* R */ CANNA_FN_FunctionalInsert, +/* S */ CANNA_FN_FunctionalInsert, +/* T */ CANNA_FN_FunctionalInsert, +/* U */ CANNA_FN_FunctionalInsert, +/* V */ CANNA_FN_FunctionalInsert, +/* W */ CANNA_FN_FunctionalInsert, +/* X */ CANNA_FN_FunctionalInsert, +/* Y */ CANNA_FN_FunctionalInsert, +/* Z */ CANNA_FN_FunctionalInsert, +/* [ */ CANNA_FN_FunctionalInsert, +/* \ */ CANNA_FN_FunctionalInsert, +/* ] */ CANNA_FN_FunctionalInsert, +/* ^ */ CANNA_FN_FunctionalInsert, +/* _ */ CANNA_FN_FunctionalInsert, +/* ` */ CANNA_FN_FunctionalInsert, +/* a */ CANNA_FN_FunctionalInsert, +/* b */ CANNA_FN_FunctionalInsert, +/* c */ CANNA_FN_FunctionalInsert, +/* d */ CANNA_FN_FunctionalInsert, +/* e */ CANNA_FN_FunctionalInsert, +/* f */ CANNA_FN_FunctionalInsert, +/* g */ CANNA_FN_FunctionalInsert, +/* h */ CANNA_FN_FunctionalInsert, +/* i */ CANNA_FN_FunctionalInsert, +/* j */ CANNA_FN_FunctionalInsert, +/* k */ CANNA_FN_FunctionalInsert, +/* l */ CANNA_FN_FunctionalInsert, +/* m */ CANNA_FN_FunctionalInsert, +/* n */ CANNA_FN_FunctionalInsert, +/* o */ CANNA_FN_FunctionalInsert, +/* p */ CANNA_FN_FunctionalInsert, +/* q */ CANNA_FN_FunctionalInsert, +/* r */ CANNA_FN_FunctionalInsert, +/* s */ CANNA_FN_FunctionalInsert, +/* t */ CANNA_FN_FunctionalInsert, +/* u */ CANNA_FN_FunctionalInsert, +/* v */ CANNA_FN_FunctionalInsert, +/* w */ CANNA_FN_FunctionalInsert, +/* x */ CANNA_FN_FunctionalInsert, +/* y */ CANNA_FN_FunctionalInsert, +/* z */ CANNA_FN_FunctionalInsert, +/* { */ CANNA_FN_FunctionalInsert, +/* | */ CANNA_FN_FunctionalInsert, +/* } */ CANNA_FN_FunctionalInsert, +/* ~ */ CANNA_FN_FunctionalInsert, +/* DEL */ NONE, +#ifdef WIN +/* Nfer */ CANNA_FN_KanaRotate, +#else +/* Nfer */ CANNA_FN_Kakutei, +#endif +/* Xfer */ CANNA_FN_Henkan, +/* Up */ CANNA_FN_Prev, +/* Left */ CANNA_FN_Backward, +/* Right */ CANNA_FN_Forward, +/* Down */ CANNA_FN_Next, +#ifdef WIN +/* Insert */ NONE, +#else +/* Insert */ CANNA_FN_KigouMode, +#endif +/* Rollup */ CANNA_FN_PageDown, +/* Rolldown */ CANNA_FN_PageUp, +/* Home */ CANNA_FN_BeginningOfLine, +/* Help */ CANNA_FN_EndOfLine, +/* KeyPad */ NONE, +/* End */ CANNA_FN_EndOfLine, +/* 8d */ NONE, +/* 8e */ NONE, +/* 8f */ NONE, +#ifdef WIN +/* S-nfer */ CANNA_FN_RomajiRotate, +#else +/* S-nfer */ NONE, +#endif +/* S-xfer */ CANNA_FN_Prev, +/* S-up */ NONE, +/* S-left */ CANNA_FN_Shrink, +/* S-right */ CANNA_FN_Extend, +/* S-down */ NONE, +/* C-nfer */ NONE, +/* C-xfer */ NONE, +/* C-up */ NONE, +/* C-left */ CANNA_FN_Shrink, +/* C-right */ CANNA_FN_Extend, +/* C-down */ NONE, +/* KP-, */ NONE, +/* KP-. */ NONE, +/* KP-/ */ NONE, +/* KP-- */ NONE, +/* S-space */ NONE, +/* ¡£ */ CANNA_FN_FunctionalInsert, +/* ¡Ö */ CANNA_FN_FunctionalInsert, +/* ¡× */ CANNA_FN_FunctionalInsert, +/* ¡¢ */ CANNA_FN_FunctionalInsert, +/* ¡¦ */ CANNA_FN_FunctionalInsert, +/* ¥ò */ CANNA_FN_FunctionalInsert, +/* ¥¡ */ CANNA_FN_FunctionalInsert, +/* ¥£ */ CANNA_FN_FunctionalInsert, +/* ¥¥ */ CANNA_FN_FunctionalInsert, +/* ¥§ */ CANNA_FN_FunctionalInsert, +/* ¥© */ CANNA_FN_FunctionalInsert, +/* ¥ã */ CANNA_FN_FunctionalInsert, +/* ¥å */ CANNA_FN_FunctionalInsert, +/* ¥ç */ CANNA_FN_FunctionalInsert, +/* ¥Ã */ CANNA_FN_FunctionalInsert, +/* ¡¼ */ CANNA_FN_FunctionalInsert, +/* ¥¢ */ CANNA_FN_FunctionalInsert, +/* ¥¤ */ CANNA_FN_FunctionalInsert, +/* ¥¦ */ CANNA_FN_FunctionalInsert, +/* ¥¨ */ CANNA_FN_FunctionalInsert, +/* ¥ª */ CANNA_FN_FunctionalInsert, +/* ¥« */ CANNA_FN_FunctionalInsert, +/* ¥­ */ CANNA_FN_FunctionalInsert, +/* ¥¯ */ CANNA_FN_FunctionalInsert, +/* ¥± */ CANNA_FN_FunctionalInsert, +/* ¥³ */ CANNA_FN_FunctionalInsert, +/* ¥µ */ CANNA_FN_FunctionalInsert, +/* ¥· */ CANNA_FN_FunctionalInsert, +/* ¥¹ */ CANNA_FN_FunctionalInsert, +/* ¥» */ CANNA_FN_FunctionalInsert, +/* ¥½ */ CANNA_FN_FunctionalInsert, +/* ¥¿ */ CANNA_FN_FunctionalInsert, +/* ¥Á */ CANNA_FN_FunctionalInsert, +/* ¥Ä */ CANNA_FN_FunctionalInsert, +/* ¥Æ */ CANNA_FN_FunctionalInsert, +/* ¥È */ CANNA_FN_FunctionalInsert, +/* ¥Ê */ CANNA_FN_FunctionalInsert, +/* ¥Ë */ CANNA_FN_FunctionalInsert, +/* ¥Ì */ CANNA_FN_FunctionalInsert, +/* ¥Í */ CANNA_FN_FunctionalInsert, +/* ¥Î */ CANNA_FN_FunctionalInsert, +/* ¥Ï */ CANNA_FN_FunctionalInsert, +/* ¥Ò */ CANNA_FN_FunctionalInsert, +/* ¥Õ */ CANNA_FN_FunctionalInsert, +/* ¥Ø */ CANNA_FN_FunctionalInsert, +/* ¥Û */ CANNA_FN_FunctionalInsert, +/* ¥Þ */ CANNA_FN_FunctionalInsert, +/* ¥ß */ CANNA_FN_FunctionalInsert, +/* ¥à */ CANNA_FN_FunctionalInsert, +/* ¥á */ CANNA_FN_FunctionalInsert, +/* ¥â */ CANNA_FN_FunctionalInsert, +/* ¥ä */ CANNA_FN_FunctionalInsert, +/* ¥æ */ CANNA_FN_FunctionalInsert, +/* ¥è */ CANNA_FN_FunctionalInsert, +/* ¥é */ CANNA_FN_FunctionalInsert, +/* ¥ê */ CANNA_FN_FunctionalInsert, +/* ¥ë */ CANNA_FN_FunctionalInsert, +/* ¥ì */ CANNA_FN_FunctionalInsert, +/* ¥í */ CANNA_FN_FunctionalInsert, +/* ¥ï */ CANNA_FN_FunctionalInsert, +/* ¥ó */ CANNA_FN_FunctionalInsert, +/* ¡« */ CANNA_FN_FunctionalInsert, +/* ¡¬ */ CANNA_FN_FunctionalInsert, +/* F1 */ NONE, +/* F2 */ NONE, +/* F3 */ NONE, +/* F4 */ NONE, +/* F5 */ NONE, +/* F6 */ NONE, +/* F7 */ NONE, +/* F8 */ NONE, +/* F9 */ NONE, +/* F10 */ NONE, +/* ea */ NONE, +/* eb */ NONE, +/* ec */ NONE, +/* ed */ NONE, +/* ee */ NONE, +/* ef */ NONE, +/* PF1 */ NONE, +/* PF2 */ NONE, +/* PF3 */ NONE, +/* PF4 */ NONE, +/* PF5 */ NONE, +/* PF6 */ NONE, +/* PF7 */ NONE, +/* PF8 */ NONE, +/* PF9 */ NONE, +/* PF10 */ NONE, +/* HIRAGANA */ CANNA_FN_BaseHiragana, +/* KATAKANA */ CANNA_FN_BaseKatakana, +/* HAN-ZEN */ CANNA_FN_BaseZenHanToggle, +/* EISU */ CANNA_FN_BaseEisu, +/* fe */ NONE, +/* ff */ NONE, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/ebind.c b/src/add-ons/input_server/methods/canna/lib/ebind.c new file mode 100644 index 0000000000..3c5ae128ee --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/ebind.c @@ -0,0 +1,358 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[] = "$Id: ebind.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#include "canna.h" +// There is Exported Symbols !! +extern int howToReturnModeInfo; + +static WCHAR_T *inbuf = 0; +static int inbufsize = 0; + + +static +StoreWCtoEUC(WCHAR_T *wbuf, int wbuflen, wcKanjiStatus *wks, char *ebuf, int maxebuf, jrKanjiStatus *ks, int ch, int nbytes) +{ + int ret, rest, totallen = 0, len; + char *p; + + /* info */ + + ks->info = wks->info; + + /* ·ë²Ì */ + + if (ks->info & KanjiThroughInfo) { + if (nbytes) { + ebuf[0] = ch; + } + ret = nbytes; + } + else { + ret = (wbuflen > 0) ? WCstombs(ebuf, wbuf, maxebuf) : 0; + if (ks->info & KanjiYomiInfo) { + WCHAR_T *ep; + len = WCstombs(ebuf + ret + 1, wbuf + wbuflen + 1, + maxebuf - ret - 1); + ep = wbuf + wbuflen + 1; + while (*ep) ep++; + WCstombs(ebuf + ret + 1 + len + 1, ep + 1, + maxebuf - ret - 1 - len - 1); + } + } + + if (wks->length > 0) { + totallen = wks->length; + } + if (wks->info & KanjiModeInfo) { + totallen += WStrlen(wks->mode); + } + if (wks->info & KanjiGLineInfo) { + totallen += wks->gline.length; + } + + if (inbufsize < totallen) { + inbufsize = totallen; /* inbufsize will be greater than 0 */ + if (inbuf) free(inbuf); + inbuf = (WCHAR_T *)malloc(inbufsize * sizeof(WCHAR_T)); + if (!inbuf) { + inbufsize = 0; + jrKanjiError = "\245\341\245\342\245\352\244\254\302\255\244\352\244\336\244\273\244\363"; + /* ¥á¥â¥ê¤¬Â­¤ê¤Þ¤»¤ó */ + return -1; + } + } + + rest = inbufsize * sizeof(WCHAR_T); + p = (char *)inbuf; + + if (wks->length < 0) { + ks->length = -1; + } + else { + /* ¥¨¥³¡¼Ê¸»ú */ + + ks->length = ks->revLen = ks->revPos = 0; + + if (wks->length > 0) { + ks->echoStr = (unsigned char *)p; + if (wks->revPos > 0) { + len = ks->revPos = CNvW2E(wks->echoStr, wks->revPos, p, rest); + p += len; + rest -= len; + } + if (wks->revLen > 0) { + len = ks->revLen + = CNvW2E(wks->echoStr + wks->revPos, wks->revLen, p, rest); + p += len; + rest -= len; + } + len = 0; + if (wks->length - wks->revPos - wks->revLen > 0) { + len = CNvW2E(wks->echoStr + wks->revPos + wks->revLen, + wks->length - wks->revPos - wks->revLen, p, rest); + p += len; + rest -= len; + } + ks->length = ks->revLen + ks->revPos + len; + *p++ = '\0'; + rest--; + } + } + + /* ¥â¡¼¥Éɽ¼¨ */ + + if (wks->info & KanjiModeInfo) { + len = WCstombs(p, wks->mode, rest); + ks->mode = (unsigned char *)p; + p[len] = '\0'; + p += len + 1; + rest -= len + 1; + } + + /* °ìÍ÷¹Ôɽ¼¨ */ + + if (wks->info & KanjiGLineInfo) { + ks->gline.length = ks->gline.revLen = ks->gline.revPos = 0; + + if (wks->gline.length > 0) { + ks->gline.line = (unsigned char *)p; + if (wks->gline.revPos > 0) { + len = ks->gline.revPos + = CNvW2E(wks->gline.line, wks->gline.revPos, p, rest); + p += len; + rest -= len; + } + if (wks->gline.revLen > 0) { + len = ks->gline.revLen + = CNvW2E(wks->gline.line + wks->gline.revPos, wks->gline.revLen, + p, rest); + p += len; + rest -= len; + } + len = 0; + if (wks->gline.length - wks->gline.revPos - wks->gline.revLen > 0) { + len = CNvW2E(wks->gline.line + wks->gline.revPos + + wks->gline.revLen, + wks->gline.length - + wks->gline.revPos - wks->gline.revLen, + p, rest); + p += len; + rest -= len; + } + ks->gline.length = ks->gline.revLen + ks->gline.revPos + len; + *p++ = '\0'; + rest--; + } + } + return ret; +} + +inline +XLookupKanji2( + unsigned int dpy, + unsigned int win, + char *buffer_return, + int bytes_buffer, + int nbytes, + int functionalChar, + jrKanjiStatus *kanji_status_return, + int key) +{ + int ret; + wcKanjiStatus wks; + + /* ÆâÉô¥Ð¥Ã¥Õ¥¡¤ò¥¢¥í¥±¡¼¥È¤¹¤ë */ + if (inbufsize < bytes_buffer) { + inbufsize = bytes_buffer; /* inbufsize will be greater than 0 */ + if (inbuf) free(inbuf); + inbuf = (WCHAR_T *)malloc(inbufsize * sizeof(WCHAR_T)); + if (!inbuf) { + inbufsize = 0; + jrKanjiError = "\245\341\245\342\245\352\244\254\302\255\244\352\244\336\244\273\244\363"; + /* ¥á¥â¥ê¤¬Â­¤ê¤Þ¤»¤ó */ + return -1; + } + } + + inbuf[0] = key; + + ret = XwcLookupKanji2(dpy, win, inbuf, inbufsize, 1/*nbytes*/, 1/*functionalChar*/, + &wks); + if (ret >= inbufsize) + ret = inbufsize - 1; + inbuf[ret] = 0; + + return StoreWCtoEUC(inbuf, ret, &wks, + buffer_return, bytes_buffer, kanji_status_return, + key, nbytes); +} + + +int +XKanjiControl2(unsigned int display, unsigned int window, unsigned int request, BYTE *arg) +{ + int ret = -1, len1, len2; + wcKanjiStatusWithValue wksv; + wcKanjiStatus wks; + int ch; + WCHAR_T arg2[256]; + WCHAR_T wbuf[320], wbuf1[320], wbuf2[320]; + + wksv.buffer = wbuf; + wksv.n_buffer = 320; + wksv.ks = &wks; + + switch (request) { + case KC_DO: /* val ¤È buffer_return ¤ËÆþ¤ì¤ë¥¿¥¤¥× */ + wbuf[0] = ((jrKanjiStatusWithValue *)arg)->buffer[0]; + /* ²¼¤ØÂ³¤¯ */ + case KC_CHANGEMODE: /* val ¤òÍ¿¤¨¤ë¥¿¥¤¥× */ + wksv.val = ((jrKanjiStatusWithValue *)arg)->val; + goto withksv; + case KC_STOREYOMI: /* echoStr ¤È length ¤È mode ¤òÍ¿¤¨¤ë¥¿¥¤¥× */ + /* ¤Þ¤º mode ¤ò¥ï¥¤¥É¤Ë¤·¤Æ¤ß¤è¤¦ */ + if (((jrKanjiStatusWithValue *)arg)->ks->mode) { + len2 = MBstowcs(wbuf2, (char *)((jrKanjiStatusWithValue *)arg)->ks->mode, + 320); + wbuf2[len2] = (WCHAR_T)0; + wks.mode = wbuf2; + } + else { + wks.mode = (WCHAR_T *)0; + } + /* ²¼¤ØÂ³¤¯ */ + case KC_DEFINEKANJI: /* echoStr ¤È length ¤òÍ¿¤¨¤ë¥¿¥¤¥× */ + /* echoStr ¤ò¥ï¥¤¥É¤Ë¤·¤ÆÍ¿¤¨¤Æ¤ß¤è¤¦ */ + len1 = MBstowcs(wbuf1, + (char *)((jrKanjiStatusWithValue *)arg)->ks->echoStr, 320); + wbuf1[len1] = (WCHAR_T)0; + wks.echoStr = wbuf1; + wks.length = len1; + /* ²¼¤ØÂ³¤¯ */ + case KC_KAKUTEI: /* ¤¿¤Àñ¤ËÍ¿¤¨¤ÆÊ֤äÆÍè¤ë¥¿¥¤¥× */ + case KC_KILL: + goto withksv; + case KC_CLOSEUICONTEXT: + goto closecont; + case KC_QUERYMODE: /* querymode */ + ret = XwcKanjiControl2(display, window, request, (BYTE *)arg2); + if (!ret) { + switch (howToReturnModeInfo) { + case ModeInfoStyleIsString: + WCstombs((char *)arg, arg2, 256); + break; + case ModeInfoStyleIsBaseNumeric: + arg[2] = (unsigned char)arg2[2]; + case ModeInfoStyleIsExtendedNumeric: + arg[1] = (unsigned char)arg2[1]; + case ModeInfoStyleIsNumeric: + arg[0] = (unsigned char)arg2[0]; + break; + } + } + goto return_ret; + case KC_SETLISTCALLBACK: /* ¤É¤¦¤·¤¿¤éÎɤ¤¤«¤ï¤«¤é¤Ê¤¤¤â¤Î */ + ret = -1; + goto return_ret; + default: /* ¥ï¥¤¥É¤Ç¤âEUC¤Ç¤âÊѤï¤é¤Ê¤¤¤â¤Î */ + ret = XwcKanjiControl2(display, window, request, arg); + goto return_ret; + } + withksv: + ch = ((jrKanjiStatusWithValue *)arg)->buffer[0]; + ret = XwcKanjiControl2(display, window, request, (BYTE *)&wksv); + if (ret < 0) { + goto return_ret; + } + else { + wksv.buffer[ret] = (WCHAR_T)0; + ((jrKanjiStatusWithValue *)arg)->val = + StoreWCtoEUC(wksv.buffer, wksv.val, wksv.ks, + (char *)((jrKanjiStatusWithValue *)arg)->buffer, + ((jrKanjiStatusWithValue *)arg)->bytes_buffer, + ((jrKanjiStatusWithValue *)arg)->ks, + ch, ((jrKanjiStatusWithValue *)arg)->val); + ret = ((jrKanjiStatusWithValue *)arg)->val; + goto return_ret; + } + closecont: + ch = ((jrKanjiStatusWithValue *)arg)->buffer[0]; + ret = XwcKanjiControl2(display, window, request, (BYTE *)&wksv); + if (ret < 0) { + goto return_ret; + } + else { + wksv.val = 0; + ((jrKanjiStatusWithValue *)arg)->val = + StoreWCtoEUC(wksv.buffer, wksv.val, wksv.ks, + (char *)((jrKanjiStatusWithValue *)arg)->buffer, + ((jrKanjiStatusWithValue *)arg)->bytes_buffer, + ((jrKanjiStatusWithValue *)arg)->ks, + ch, ((jrKanjiStatusWithValue *)arg)->val); + goto return_ret; + } + return_ret: + return ret; +} + +int +jrKanjiString ( + int context_id, + int ch, + char *buffer_return, + int nbuffer, + jrKanjiStatus *kanji_status_return) +{ + *buffer_return = ch; + + return XLookupKanji2(0, context_id, + buffer_return, nbuffer, + 1/* byte */, 1/* functional char*/, + kanji_status_return, ch); +} + +/* jrKanjiControl -- ¥«¥Ê´Á»úÊÑ´¹¤ÎÀ©¸æ¤ò¹Ô¤¦ */ +int +jrKanjiControl ( +int context, +int request, +char *arg) +{ + return XKanjiControl2((unsigned int)0, (unsigned int)context, + request, (BYTE *)arg); +} + +void +setBasePath(const char *path) +{ +extern char basepath[]; + strcpy(basepath, path); +} diff --git a/src/add-ons/input_server/methods/canna/lib/empty.c b/src/add-ons/input_server/methods/canna/lib/empty.c new file mode 100644 index 0000000000..f0ed634e1f --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/empty.c @@ -0,0 +1,772 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: empty.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include "patchlevel.h" +#include "RK.h" +#include "RKintern.h" + +extern struct RkRxDic *romajidic, *englishdic; + +static inEmptySelfInsert(uiContext d); +static EmptySelfInsert(uiContext d); +static EmptyYomiInsert(uiContext d); +static EmptyQuotedInsert(uiContext d); +static AlphaSelfInsert(uiContext d); +static AlphaNop(uiContext d); +static EmptyQuit(uiContext d); +static EmptyKakutei(uiContext d); +static EmptyDeletePrevious(uiContext d); +static UserMode(uiContext d, extraFunc *estruct); +static UserSelect(uiContext d, extraFunc *estruct); +static UserMenu(uiContext d, extraFunc *estruct); +static ProcExtraFunc(uiContext d, int fnum); +static HenkanRegion(uiContext d); +static PhonoEdit(uiContext d); +static DicEdit(uiContext d); +static Configure(uiContext d); +static int renbunInit(uiContext d); +static int showVersion(uiContext d); +static int showServer(uiContext d); +static int showGakushu(uiContext d); +static int showInitFile(uiContext d); +static int showRomkanaFile(uiContext d); +static int dicSync(uiContext d); + +extern KanjiModeRec yomi_mode, cy_mode; + +/* EmptySelfInsert -- ¼«Ê¬¼«¿È¤ò³ÎÄêʸ»úÎó¤È¤·¤ÆÊÖ¤¹´Ø¿ô¡£ + * + */ + +static +inEmptySelfInsert(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int res = 0; + + d->kanji_status_return->info |= KanjiThroughInfo | KanjiEmptyInfo; + if (!(yc->generalFlags & CANNA_YOMI_END_IF_KAKUTEI)) { + res = d->nbytes; + } + /* else { ³ÎÄê¥Ç¡¼¥¿¤À¤±¤òÂԤäƤ¤¤ë¿Í¤Ë¤Ï³ÎÄê¥Ç¡¼¥¿¤òÅϤµ¤Ê¤¤ } */ + + return res; +} + + +static +EmptySelfInsert(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int res = inEmptySelfInsert(d); + +/* ñ¸ìÅÐÏ¿¤Î¤È¤­¤Ë yomi mode ¤Î³ÎÄꥭ¡¼¤¬ empty mode ¤Ç¤Ï³ÎÄꥭ¡¼¤Ç¤Ê + ¤«¤Ã¤¿¤ê¤¹¤ë¤È¡¢¤½¤Î¥­¡¼¤Î²¡²¼¤Ç»à¤ó¤Ç¤·¤Þ¤Ã¤¿¤ê¤¹¤ë¤Î¤ÎµßºÑ¡£yomi + mode ¤Î¾å¤Ë yomi mode ¤¬¾è¤Ã¤Æ¤¤¤ë¤Î¤Ïñ¸ìÅÐÏ¿¤Î»þ¤°¤é¤¤¤À¤í¤¦¤È¸À + ¤¦¤³¤È¤ÇȽÃǤκàÎÁ¤Ë¤·¤Æ¤¤¤ë¡£ËÜÅö¤Ï¤³¤ó¤Ê¤³¤È¤ä¤ê¤¿¤¯¤Ê¤¤¡£ */ + + if (yc->next && yc->next->id == YOMI_CONTEXT && + yomi_mode.keytbl[d->buffer_return[0]] == CANNA_FN_Kakutei) { + d->status = EXIT_CALLBACK; + if (d->cb->func[EXIT_CALLBACK] != NO_CALLBACK) { + d->kanji_status_return->info &= ~KanjiThroughInfo; /* »Å»ö¤·¤¿ */ + popYomiMode(d); + } + } + return res; +} + +/* EmptyYomiInsert -- ¡û¥â¡¼¥É¤Ë°Ü¹Ô¤·¡¢ÆÉ¤ß¤òÆþÎϤ¹¤ë´Ø¿ô + * + */ + + +static +EmptyYomiInsert(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + d->current_mode = (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) ? + &cy_mode : &yomi_mode; + RomajiClearYomi(d); + return YomiInsert(d); /* ¥³¡¼¥ë¥Ð¥Ã¥¯¤Î¥Á¥§¥Ã¥¯¤Ï YomiInsert ¤Ç¤µ¤ì¤ë */ +} + +/* EmptyQuotedInsert -- ¼¡¤Î°ì»ú¤¬¤É¤Î¤è¤¦¤Êʸ»ú¤Ç¤â¥¹¥ë¡¼¤ÇÄ̤¹´Ø¿ô¡£ + * + */ + +/* + Empty ¥â¡¼¥É¤Ç¤Î quotedInset ¤Ï ^Q ¤Î¤è¤¦¤Êʸ»ú¤¬°ì²ó Emacs ¤Ê¤É¤ÎÊý + ¤ËÄ̤äƤ·¤Þ¤¨¤Ð¥Þ¥Ã¥×¤¬ÊÖ¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤Ç¡¢¥«¥Ê´Á»úÊÑ´¹¤ÎÊý¤Ç²¿¤«¤ò + ¤¹¤ë¤Ê¤ó¤Æ¤³¤È¤ÏɬÍפʤ¤¤Î¤Ç¤Ï¤Ê¤¤¤Î¤«¤Ê¤¡¡£ + */ + +static +EmptyQuotedInsert(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + d->current_mode = (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) ? + &cy_mode : &yomi_mode; + return YomiQuotedInsert(d); +} + +/* + AlphaSelfInsert -- ¼«Ê¬¼«¿È¤ò³ÎÄêʸ»úÎó¤È¤·¤ÆÊÖ¤¹´Ø¿ô¡£ + */ + +static +AlphaSelfInsert(uiContext d) +{ + unsigned kanap = (unsigned)d->ch; + + d->kanji_status_return->length = 0; + d->kanji_status_return->info |= KanjiEmptyInfo; + d->kanji_status_return->info |= KanjiThroughInfo; + if ( d->nbytes != 1 || kanap <= 0xa0 || 0xe0 <= kanap ) { + return d->nbytes; + } + else { /* ²¾Ì¾¥­¡¼ÆþÎϤξì¹ç */ + if (d->n_buffer > 1) { + return 1; + } + else { + return 0; + } + } +} + +static +AlphaNop(uiContext d) +{ + /* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */ + d->majorMode = d->minorMode = CANNA_MODE_KigoMode; + currentModeInfo(d); + return 0; +} + +static +EmptyQuit(uiContext d) +{ + int res; + + res = inEmptySelfInsert(d); + d->status = QUIT_CALLBACK; + if (d->cb->func[QUIT_CALLBACK] != NO_CALLBACK) { + d->kanji_status_return->info &= ~KanjiThroughInfo; /* »Å»ö¤·¤¿ */ + popYomiMode(d); + } + return res; +} + +static +EmptyKakutei(uiContext d) +{ + int res; + + res = inEmptySelfInsert(d); + d->status = EXIT_CALLBACK; + if (d->cb->func[EXIT_CALLBACK] != NO_CALLBACK) { + d->kanji_status_return->info &= ~KanjiThroughInfo; /* »Å»ö¤·¤¿ */ + popYomiMode(d); + } + return res; +} + +static +EmptyDeletePrevious(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_DELETE_DONT_QUIT) { + /* Delete ¤Ç QUIT ¤·¤Ê¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢selfInsert */ + return inEmptySelfInsert(d); + } + else { + return EmptyQuit(d); + } +} + +extraFunc * +FindExtraFunc(int fnum) +{ + extern extraFunc *extrafuncp; + extraFunc *extrafunc; + + for (extrafunc = extrafuncp; extrafunc; extrafunc = extrafunc->next) { + if (extrafunc->fnum == fnum) { + return extrafunc; + } + } + return (extraFunc *)0; +} + +static +UserMode(uiContext d, extraFunc *estruct) +{ + newmode *nmode = estruct->u.modeptr; + yomiContext yc = (yomiContext)d->modec; + int modeid + = estruct->fnum - CANNA_FN_MAX_FUNC + CANNA_MODE_MAX_IMAGINARY_MODE; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + + yc->generalFlags &= ~CANNA_YOMI_ATTRFUNCS; + yc->generalFlags |= nmode->flags; + if (yc->generalFlags & CANNA_YOMI_END_IF_KAKUTEI) { + /* ³ÎÄê¤Ç½ª¤ï¤ë¤è¤¦¤Ê¥â¡¼¥É¤À¤Ã¤¿¤é³ÎÄê¥â¡¼¥É¤Ë¤Ê¤é¤Ê¤¤ */ + yc->generalFlags &= ~CANNA_YOMI_KAKUTEI; + } + yc->romdic = nmode->romdic; + d->current_mode = yc->myEmptyMode = nmode->emode; + + yc->majorMode = yc->minorMode = yc->myMinorMode = (BYTE)modeid; + + currentModeInfo(d); + + d->kanji_status_return->length = 0; + return 0; +} + +#ifndef NO_EXTEND_MENU /* continues to the bottom of this file */ +static +UserSelect(uiContext d, extraFunc *estruct) +{ + int curkigo = 0, *posp = (int *)0; + kigoIchiran *kigop = (kigoIchiran *)0; + selectinfo *selinfo = (selectinfo *)0, *info; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + info = d->selinfo; + while (info) { + if (info->ichiran == estruct->u.kigoptr) { + selinfo = info; + break; + } + info = info->next; + } + + if (!selinfo) { + selinfo = (selectinfo *)malloc(sizeof(selectinfo)); + /* malloc ¤Ë¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¡¢Á°²óÁªÂò¤·¤¿Èֹ椬Êݸ¤µ¤ì¤Ê¤¤ */ + if (selinfo) { + selinfo->ichiran = estruct->u.kigoptr; + selinfo->curnum = 0; + selinfo->next = d->selinfo; + d->selinfo = selinfo; + } + } + + if (selinfo) { + curkigo = selinfo->curnum; + posp = &selinfo->curnum; + } + + kigop = estruct->u.kigoptr; + if (!kigop) { + return NothingChangedWithBeep(d); + } + return uuKigoMake(d, kigop->kigo_data, kigop->kigo_size, + curkigo, kigop->kigo_mode, uuKigoGeneralExitCatch, posp); +} + +static +UserMenu(uiContext d, extraFunc *estruct) +{ + return showmenu(d, estruct->u.menuptr); +} +#endif /* NO_EXTEND_MENU */ + +/* ¥Ç¥Õ¥©¥ë¥È°Ê³°¤Î¥â¡¼¥É»ÈÍÑ»þ¤Ë¸Æ¤Ó½Ð¤¹´Ø¿ô¤òÀÚ¤êʬ¤±¤ë */ + +static +ProcExtraFunc(uiContext d, int fnum) +{ + extraFunc *extrafunc; + + extrafunc = FindExtraFunc(fnum); + if (extrafunc) { + switch (extrafunc->keyword) { + case EXTRA_FUNC_DEFMODE: + return UserMode(d, extrafunc); +#ifndef NO_EXTEND_MENU + case EXTRA_FUNC_DEFSELECTION: + return UserSelect(d, extrafunc); + case EXTRA_FUNC_DEFMENU: + return UserMenu(d, extrafunc); +#endif + default: + break; + } + } + return NothingChangedWithBeep(d); +} + +getBaseMode(yomiContext yc) +{ + int res; + long fl = yc->generalFlags; + + if (yc->myMinorMode) { + return yc->myMinorMode; + } + else if (fl & CANNA_YOMI_ROMAJI) { + res = CANNA_MODE_ZenAlphaHenkanMode; + } + else if (fl & CANNA_YOMI_KATAKANA) { + res = CANNA_MODE_ZenKataHenkanMode; + } + else { + res = CANNA_MODE_ZenHiraHenkanMode; + } + if (fl & CANNA_YOMI_BASE_HANKAKU) { + res++; + } + if (fl & CANNA_YOMI_KAKUTEI) { + res += CANNA_MODE_ZenHiraKakuteiMode - CANNA_MODE_ZenHiraHenkanMode; + } + if (res == CANNA_MODE_ZenHiraHenkanMode) { + if (chikujip(yc)) { + res = CANNA_MODE_ChikujiYomiMode; + } + else { + res = CANNA_MODE_HenkanMode; + } + } + return res; +} + +/* ¥Ù¡¼¥¹Ê¸»ú¤ÎÀÚ¤êÂØ¤¨ */ + +void +EmptyBaseModeInfo(uiContext d, yomiContext yc) +{ + coreContext cc = (coreContext)d->modec; + + cc->minorMode = getBaseMode(yc); + currentModeInfo(d); +} + +EmptyBaseHira(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + yc->generalFlags &= ~(CANNA_YOMI_KATAKANA | CANNA_YOMI_HANKAKU | + CANNA_YOMI_ROMAJI | CANNA_YOMI_ZENKAKU); + EmptyBaseModeInfo(d, yc); + return 0; +} + +EmptyBaseKata(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if ((yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) + || (cannaconf.InhibitHankakuKana + && (yc->generalFlags & CANNA_YOMI_BASE_HANKAKU))) { + return NothingChangedWithBeep(d); + } + yc->generalFlags &= ~(CANNA_YOMI_ROMAJI | CANNA_YOMI_ZENKAKU); + yc->generalFlags |= CANNA_YOMI_KATAKANA | + ((yc->generalFlags & CANNA_YOMI_BASE_HANKAKU) ? CANNA_YOMI_HANKAKU : 0); + EmptyBaseModeInfo(d, yc); + return 0; +} + +EmptyBaseEisu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } +/* yc->generalFlags &= ~CANNA_YOMI_ATTRFUNCS; ¥¯¥ê¥¢¤¹¤ë¤Î¤ä¤á */ + yc->generalFlags |= CANNA_YOMI_ROMAJI | + ((yc->generalFlags & CANNA_YOMI_BASE_HANKAKU) ? 0 : CANNA_YOMI_ZENKAKU); + EmptyBaseModeInfo(d, yc); + return 0; +} + +EmptyBaseZen(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + yc->generalFlags &= ~CANNA_YOMI_BASE_HANKAKU; + if (yc->generalFlags & CANNA_YOMI_ROMAJI) { + yc->generalFlags |= CANNA_YOMI_ZENKAKU; + } + /* ¢¨Ãí ¥í¡¼¥Þ»ú¥â¡¼¥É¤Ç¤«¤Ä¥«¥¿¥«¥Ê¥â¡¼¥É¤Î»þ¤¬¤¢¤ë + (¤½¤Î¾ì¹çɽÌ̾å¤Ï¥í¡¼¥Þ»ú¥â¡¼¥É) */ + if (yc->generalFlags & CANNA_YOMI_KATAKANA) { + yc->generalFlags &= ~CANNA_YOMI_HANKAKU; + } + EmptyBaseModeInfo(d, yc); + return 0; +} + +EmptyBaseHan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if ((yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) || + /* ¥â¡¼¥ÉÊѹ¹¤¬¶Ø»ß¤µ¤ì¤Æ¤¤¤ë¤È¤« */ + (cannaconf.InhibitHankakuKana && + (yc->generalFlags & CANNA_YOMI_KATAKANA) && + !(yc->generalFlags & CANNA_YOMI_ROMAJI))) { + /* Ⱦ³Ñ¥«¥Ê¤¬¶Ø»ß¤µ¤ì¤Æ¤¤¤ë¤Î¤ËȾ³Ñ¥«¥Ê¤Ë¤¤¤­¤½¤¦¤Ê¤È¤­ */ + return NothingChangedWithBeep(d); + } + yc->generalFlags |= CANNA_YOMI_BASE_HANKAKU; + if (yc->generalFlags & CANNA_YOMI_ROMAJI) { + yc->generalFlags &= ~CANNA_YOMI_ZENKAKU; + } + /* ¢¨Ãí ¥í¡¼¥Þ»ú¥â¡¼¥É¤Ç¤«¤Ä¥«¥¿¥«¥Ê¥â¡¼¥É¤Î»þ¤¬¤¢¤ë + (¤½¤Î¾ì¹çɽÌ̾å¤Ï¥í¡¼¥Þ»ú¥â¡¼¥É) */ + if (yc->generalFlags & CANNA_YOMI_KATAKANA) { + if (!cannaconf.InhibitHankakuKana) { + yc->generalFlags |= CANNA_YOMI_HANKAKU; + } + } + EmptyBaseModeInfo(d, yc); + return 0; +} + +EmptyBaseKana(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if ((yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) || + /* ¥â¡¼¥ÉÊѹ¹¤¬¶Ø»ß¤µ¤ì¤Æ¤¤¤¿¤ê */ + (!cannaconf.InhibitHankakuKana && + (yc->generalFlags & CANNA_YOMI_KATAKANA) && + (yc->generalFlags & CANNA_YOMI_BASE_HANKAKU))) { + /* Ⱦ³Ñ¥«¥Ê¤¬¶Ø»ß¤µ¤ì¤Æ¤¤¤ë¤Î¤ËȾ³Ñ¥«¥Ê¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¤¤½¤¦¤Ê¾ì¹ç */ + return NothingChangedWithBeep(d); + } + yc->generalFlags &= ~(CANNA_YOMI_ROMAJI | CANNA_YOMI_ZENKAKU); + + if ((yc->generalFlags & CANNA_YOMI_BASE_HANKAKU) && + (yc->generalFlags & CANNA_YOMI_KATAKANA)) { + yc->generalFlags |= CANNA_YOMI_HANKAKU; + } + EmptyBaseModeInfo(d, yc); + return 0; +} + +EmptyBaseKakutei(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + yc->generalFlags |= CANNA_YOMI_KAKUTEI; + + EmptyBaseModeInfo(d, yc); + return 0; +} + +EmptyBaseHenkan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + yc->generalFlags &= ~CANNA_YOMI_KAKUTEI; + + EmptyBaseModeInfo(d, yc); + return 0; +} + +#ifdef WIN + +extern specialfunc (uiContext, int); + +static HenkanRegion (uiContext); + +static +HenkanRegion(uiContext d) +{ + return specialfunc(d, CANNA_FN_HenkanRegion); +} + +static PhonoEdit (uiContext); + +static +PhonoEdit(uiContext d) +{ + return specialfunc(d, CANNA_FN_PhonoEdit); +} + +static DicEdit (uiContext); + +static +DicEdit(uiContext d) +{ + return specialfunc(d, CANNA_FN_DicEdit); +} + +static Configure (uiContext); + +static +Configure(uiContext d) +{ + return specialfunc(d, CANNA_FN_Configure); +} + +#endif + +#ifndef NO_EXTEND_MENU +static int +renbunInit(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + killmenu(d); + if (ToggleChikuji(d, 0) == -1) { + jrKanjiError = "\317\242\312\270\300\341\312\321\264\271\244\313\300\332" + "\302\330\244\250\244\353\244\263\244\310\244\254\244\307\244\255" + "\244\336\244\273\244\363"; + /* ϢʸÀáÊÑ´¹¤ËÀÚÂØ¤¨¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó */ + makeGLineMessageFromString(d, jrKanjiError); + currentModeInfo(d); + return(-1); + } + else { + makeGLineMessageFromString(d, "\317\242\312\270\300\341\312\321\264\271" + "\244\313\300\332\302\330\244\250\244\336\244\267\244\277"); + /* ϢʸÀáÊÑ´¹¤ËÀÚÂØ¤¨¤Þ¤·¤¿ */ + currentModeInfo(d); + return 0; + } +} + +static int +showVersion(uiContext d) +{ + int retval = 0; + char s[512]; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + killmenu(d); + + sprintf(s, "\306\374\313\334\270\354\306\376\316\317\245\267\245\271\245\306" + "\245\340\241\330\244\253\244\363\244\312\241\331Version %d.%d", + cannaconf.CannaVersion / 1000, cannaconf.CannaVersion % 1000); + /* ÆüËܸìÆþÎÏ¥·¥¹¥Æ¥à¡Ø¤«¤ó¤Ê¡Ù */ + strcat(s, CANNA_PATCH_LEVEL); + makeGLineMessageFromString(d, s); + currentModeInfo(d); + + return (retval); +} + +static int +showServer(uiContext d) +{ +#ifndef STANDALONE /* This is not used in Windows environment 1996.7.30 kon */ + int retval = 0; + char s[512]; + extern defaultContext; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + killmenu(d); + + if(defaultContext == -1) { + sprintf(s, "\244\253\244\312\264\301\273\372\312\321\264\271\245\265" + "\241\274\245\320\244\310\244\316\300\334\302\263\244\254\300\332" + "\244\354\244\306\244\244\244\336\244\271"); + /* ¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤È¤ÎÀܳ¤¬ÀÚ¤ì¤Æ¤¤¤Þ¤¹ */ + } + else { + sprintf(s, "%s \244\316\244\253\244\312\264\301\273\372\312\321\264\271" + "\245\265\241\274\245\320\244\313\300\334\302\263\244\267\244\306" + "\244\244\244\336\244\271", RkwGetServerName()); + /* ¤Î¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ËÀܳ¤·¤Æ¤¤¤Þ¤¹ */ + } + makeGLineMessageFromString(d, s); + currentModeInfo(d); + + return (retval); +#else + return (0); +#endif /* STANDALONE */ +} + +static int +showGakushu(uiContext d) +{ + int retval = 0; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + killmenu(d); + + if (cannaconf.Gakushu == 1) { + makeGLineMessageFromString(d, "\263\330\275\254\244\254\243\317\243\316" + "\244\316\276\365\302\326\244\307\244\271"); + /* ³Ø½¬¤¬£Ï£Î¤Î¾õÂ֤Ǥ¹ */ + } + else { + makeGLineMessageFromString(d, "\263\330\275\254\244\254\243\317\243\306" + "\243\306\244\316\276\365\302\326\244\307\244\271"); + /* ³Ø½¬¤¬£Ï£Æ£Æ¤Î¾õÂ֤Ǥ¹ */ + } + currentModeInfo(d); + + return (retval); +} + +static int +showInitFile(uiContext d) +{ + int retval = 0; + char s[512]; + extern char *CANNA_initfilename; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + killmenu(d); + + if (CANNA_initfilename && strlen(CANNA_initfilename)) { + sprintf(s, "\245\253\245\271\245\277\245\336\245\244\245\272\245\325" + "\245\241\245\244\245\353\244\317 %s \244\362\273\310\315\321\244\267" + "\244\306\244\244\244\336\244\271", CANNA_initfilename); + /* ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Ï %s ¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹ */ + makeGLineMessageFromString(d, s); + } + else { + sprintf(s, "\245\253\245\271\245\277\245\336\245\244\245\272\245\325" + "\245\241\245\244\245\353\244\317\300\337\304\352\244\265\244\354" + "\244\306\244\244\244\336\244\273\244\363"); + /* ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤ÏÀßÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó */ + makeGLineMessageFromString(d, s); + } + currentModeInfo(d); + + return (retval); +} + +static int +showRomkanaFile(uiContext d) +{ + int retval = 0; + char s[512]; + extern char *RomkanaTable; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + killmenu(d); + + if (RomkanaTable && romajidic) { + sprintf(s, "\245\355\241\274\245\336\273\372\244\253\244\312\312\321" + "\264\271\245\306\241\274\245\326\245\353\244\317 %s \244\362\273\310" + "\315\321\244\267\244\306\244\244\244\336\244\271", + RomkanaTable); + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Ï %s ¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹ */ + makeGLineMessageFromString(d, s); + } + else { + sprintf(s, "\245\355\241\274\245\336\273\372\244\253\244\312\312\321" + "\264\271\245\306\241\274\245\326\245\353\244\317\273\310\315\321" + "\244\265\244\354\244\306\244\244\244\336\244\273\244\363"); + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Ï»ÈÍѤµ¤ì¤Æ¤¤¤Þ¤»¤ó */ + makeGLineMessageFromString(d, s); + } + currentModeInfo(d); + + return (retval); +} + +static int +dicSync(uiContext d) +{ + int retval = 0; + char s[512]; + extern defaultContext; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + killmenu(d); + + retval = RkwSync(defaultContext, ""); + sprintf(s, "\274\255\275\361\244\316 Sync \275\350\315\375%s", + retval < 0 ? "\244\313\274\272\307\324\244\267\244\336\244\267" + "\244\277" : "\244\362\271\324\244\244\244\336\244\267\244\277"); + /* ¼­½ñ¤Î Sync ½èÍý%s", + retval < 0 ? "¤Ë¼ºÇÔ¤·¤Þ¤·¤¿" : "¤ò¹Ô¤¤¤Þ¤·¤¿ */ + makeGLineMessageFromString(d, s); + currentModeInfo(d); + + return 0; +} +#endif /* not NO_EXTEND_MENU */ + +#include "emptymap.h" +#include "alphamap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/emptymap.h b/src/add-ons/input_server/methods/canna/lib/emptymap.h new file mode 100644 index 0000000000..b3e6e4e23f --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/emptymap.h @@ -0,0 +1,368 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +// modified by T.Murai 1998 + +#if !defined(lint) && !defined(__CODECENTER__) +static char emptymap_id[] = "@(#) 102.1 $Id: emptymap.h,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ +#include "canna.h" + +#define NONE CANNA_FN_Undefined + +static struct funccfunc empty_funcs[] = { + {CANNA_FN_SelfInsert ,EmptySelfInsert }, + {CANNA_FN_FunctionalInsert ,EmptyYomiInsert }, + {CANNA_FN_QuotedInsert ,EmptyQuotedInsert }, + {CANNA_FN_AlphaMode ,AlphaMode }, + {CANNA_FN_HenkanNyuryokuMode ,HenkanNyuryokuMode }, + {CANNA_FN_KigouMode ,KigoIchiran }, + {CANNA_FN_DeletePrevious ,EmptyDeletePrevious }, + {CANNA_FN_Kakutei ,EmptyKakutei }, + {CANNA_FN_Quit ,EmptyQuit }, + {CANNA_FN_ExtendMode ,UiUtilMode }, + {CANNA_FN_BaseHiragana ,EmptyBaseHira }, + {CANNA_FN_BaseKatakana ,EmptyBaseKata }, + {CANNA_FN_BaseKana ,EmptyBaseKana }, + {CANNA_FN_BaseEisu ,EmptyBaseEisu }, + {CANNA_FN_BaseZenkaku ,EmptyBaseZen }, + {CANNA_FN_BaseHankaku ,EmptyBaseHan }, + {CANNA_FN_BaseKakutei ,EmptyBaseKakutei }, + {CANNA_FN_BaseHenkan ,EmptyBaseHenkan }, + {CANNA_FN_BaseHiraKataToggle ,YomiBaseHiraKataToggle }, + {CANNA_FN_BaseZenHanToggle ,YomiBaseZenHanToggle }, + {CANNA_FN_BaseKanaEisuToggle ,YomiBaseKanaEisuToggle }, + {CANNA_FN_BaseKakuteiHenkanToggle ,YomiBaseKakuteiHenkanToggle }, + {CANNA_FN_BaseRotateForward ,YomiBaseRotateForw }, + {CANNA_FN_BaseRotateBackward ,YomiBaseRotateBack }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_TemporalMode ,YomiModeBackup }, + + {CANNA_FN_Nop ,AlphaNop }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {CANNA_FN_UserMode ,(int (*)(struct _uiContext *)) + ProcExtraFunc }, +#ifdef WIN + {CANNA_FN_DefineDicMode ,dicTouroku }, + {CANNA_FN_DeleteDicMode ,dicSakujo }, + {CANNA_FN_HenkanRegion ,HenkanRegion }, + {CANNA_FN_PhonoEdit ,PhonoEdit }, + {CANNA_FN_DicEdit ,DicEdit }, + {CANNA_FN_Configure ,Configure }, +#endif + +#ifndef NO_EXTEND_MENU +#ifndef WIN + {CANNA_FN_DefineDicMode ,dicTouroku }, + {CANNA_FN_DeleteDicMode ,dicSakujo }, +#endif + {CANNA_FN_HexMode ,HexMode }, + {CANNA_FN_BushuMode ,BushuMode }, + {CANNA_FN_RussianMode ,kigoRussia }, + {CANNA_FN_GreekMode ,kigoGreek }, + {CANNA_FN_LineMode ,kigoKeisen }, + {CANNA_FN_SyncDic ,dicSync }, + {CANNA_FN_DicMountMode ,dicMount }, + {CANNA_FN_ChangeServerMode ,serverChange }, + {CANNA_FN_DisconnectServer ,serverFin }, + {CANNA_FN_ShowServer ,showServer }, + {CANNA_FN_ShowGakushu ,showGakushu }, + {CANNA_FN_ShowVersion ,showVersion }, + {CANNA_FN_ShowPhonogramFile ,showRomkanaFile }, + {CANNA_FN_ShowCannaFile ,showInitFile }, + {CANNA_FN_EnterChikujiMode ,chikujiInit }, + {CANNA_FN_EnterRenbunMode ,renbunInit }, +#endif + {DEFAULTBEHAVIOR ,EmptySelfInsert }, + {0 ,0 }, +}; + +BYTE empty_kmap[256] = +{ +/* C-@ */ CANNA_FN_SelfInsert, +/* C-a */ CANNA_FN_SelfInsert, +/* C-b */ CANNA_FN_SelfInsert, +/* C-c */ CANNA_FN_SelfInsert, +/* C-d */ CANNA_FN_SelfInsert, +/* C-e */ CANNA_FN_SelfInsert, +/* C-f */ CANNA_FN_SelfInsert, +/* C-g */ CANNA_FN_Quit, +/* C-h */ CANNA_FN_DeletePrevious, +/* C-i */ CANNA_FN_SelfInsert, +/* C-j */ CANNA_FN_Kakutei, +/* C-k */ CANNA_FN_SelfInsert, +/* C-l */ CANNA_FN_SelfInsert, +/* C-m */ CANNA_FN_Kakutei, +/* C-n */ CANNA_FN_SelfInsert, +/* C-o */ CANNA_FN_AlphaMode, +/* C-p */ CANNA_FN_SelfInsert, +/* C-q */ CANNA_FN_QuotedInsert, +/* C-r */ CANNA_FN_SelfInsert, +/* C-s */ CANNA_FN_SelfInsert, +/* C-t */ CANNA_FN_SelfInsert, +/* C-u */ CANNA_FN_SelfInsert, +/* C-v */ CANNA_FN_SelfInsert, +/* C-w */ CANNA_FN_SelfInsert, +/* C-x */ CANNA_FN_SelfInsert, +/* C-y */ CANNA_FN_SelfInsert, +/* C-z */ CANNA_FN_SelfInsert, +/* C-[ */ CANNA_FN_SelfInsert, +/* C-\ */ CANNA_FN_SelfInsert, +/* C-] */ CANNA_FN_SelfInsert, +/* C-^ */ CANNA_FN_SelfInsert, +/* C-_ */ CANNA_FN_SelfInsert, +/* space */ CANNA_FN_SelfInsert, +/* ! */ CANNA_FN_FunctionalInsert, +/* " */ CANNA_FN_FunctionalInsert, +/* # */ CANNA_FN_FunctionalInsert, +/* $ */ CANNA_FN_FunctionalInsert, +/* % */ CANNA_FN_FunctionalInsert, +/* & */ CANNA_FN_FunctionalInsert, +/* ' */ CANNA_FN_FunctionalInsert, +/* ( */ CANNA_FN_FunctionalInsert, +/* ) */ CANNA_FN_FunctionalInsert, +/* * */ CANNA_FN_FunctionalInsert, +/* + */ CANNA_FN_FunctionalInsert, +/* , */ CANNA_FN_FunctionalInsert, +/* - */ CANNA_FN_FunctionalInsert, +/* . */ CANNA_FN_FunctionalInsert, +/* / */ CANNA_FN_FunctionalInsert, +/* 0 */ CANNA_FN_FunctionalInsert, +/* 1 */ CANNA_FN_FunctionalInsert, +/* 2 */ CANNA_FN_FunctionalInsert, +/* 3 */ CANNA_FN_FunctionalInsert, +/* 4 */ CANNA_FN_FunctionalInsert, +/* 5 */ CANNA_FN_FunctionalInsert, +/* 6 */ CANNA_FN_FunctionalInsert, +/* 7 */ CANNA_FN_FunctionalInsert, +/* 8 */ CANNA_FN_FunctionalInsert, +/* 9 */ CANNA_FN_FunctionalInsert, +/* : */ CANNA_FN_FunctionalInsert, +/* ; */ CANNA_FN_FunctionalInsert, +/* < */ CANNA_FN_FunctionalInsert, +/* = */ CANNA_FN_FunctionalInsert, +/* > */ CANNA_FN_FunctionalInsert, +/* ? */ CANNA_FN_FunctionalInsert, +/* @ */ CANNA_FN_FunctionalInsert, +/* A */ CANNA_FN_FunctionalInsert, +/* B */ CANNA_FN_FunctionalInsert, +/* C */ CANNA_FN_FunctionalInsert, +/* D */ CANNA_FN_FunctionalInsert, +/* E */ CANNA_FN_FunctionalInsert, +/* F */ CANNA_FN_FunctionalInsert, +/* G */ CANNA_FN_FunctionalInsert, +/* H */ CANNA_FN_FunctionalInsert, +/* I */ CANNA_FN_FunctionalInsert, +/* J */ CANNA_FN_FunctionalInsert, +/* K */ CANNA_FN_FunctionalInsert, +/* L */ CANNA_FN_FunctionalInsert, +/* M */ CANNA_FN_FunctionalInsert, +/* N */ CANNA_FN_FunctionalInsert, +/* O */ CANNA_FN_FunctionalInsert, +/* P */ CANNA_FN_FunctionalInsert, +/* Q */ CANNA_FN_FunctionalInsert, +/* R */ CANNA_FN_FunctionalInsert, +/* S */ CANNA_FN_FunctionalInsert, +/* T */ CANNA_FN_FunctionalInsert, +/* U */ CANNA_FN_FunctionalInsert, +/* V */ CANNA_FN_FunctionalInsert, +/* W */ CANNA_FN_FunctionalInsert, +/* X */ CANNA_FN_FunctionalInsert, +/* Y */ CANNA_FN_FunctionalInsert, +/* Z */ CANNA_FN_FunctionalInsert, +/* [ */ CANNA_FN_FunctionalInsert, +/* \ */ CANNA_FN_FunctionalInsert, +/* ] */ CANNA_FN_FunctionalInsert, +/* ^ */ CANNA_FN_FunctionalInsert, +/* _ */ CANNA_FN_FunctionalInsert, +/* ` */ CANNA_FN_FunctionalInsert, +/* a */ CANNA_FN_FunctionalInsert, +/* b */ CANNA_FN_FunctionalInsert, +/* c */ CANNA_FN_FunctionalInsert, +/* d */ CANNA_FN_FunctionalInsert, +/* e */ CANNA_FN_FunctionalInsert, +/* f */ CANNA_FN_FunctionalInsert, +/* g */ CANNA_FN_FunctionalInsert, +/* h */ CANNA_FN_FunctionalInsert, +/* i */ CANNA_FN_FunctionalInsert, +/* j */ CANNA_FN_FunctionalInsert, +/* k */ CANNA_FN_FunctionalInsert, +/* l */ CANNA_FN_FunctionalInsert, +/* m */ CANNA_FN_FunctionalInsert, +/* n */ CANNA_FN_FunctionalInsert, +/* o */ CANNA_FN_FunctionalInsert, +/* p */ CANNA_FN_FunctionalInsert, +/* q */ CANNA_FN_FunctionalInsert, +/* r */ CANNA_FN_FunctionalInsert, +/* s */ CANNA_FN_FunctionalInsert, +/* t */ CANNA_FN_FunctionalInsert, +/* u */ CANNA_FN_FunctionalInsert, +/* v */ CANNA_FN_FunctionalInsert, +/* w */ CANNA_FN_FunctionalInsert, +/* x */ CANNA_FN_FunctionalInsert, +/* y */ CANNA_FN_FunctionalInsert, +/* z */ CANNA_FN_FunctionalInsert, +/* { */ CANNA_FN_FunctionalInsert, +/* | */ CANNA_FN_FunctionalInsert, +/* } */ CANNA_FN_FunctionalInsert, +/* ~ */ CANNA_FN_FunctionalInsert, +/* DEL */ CANNA_FN_SelfInsert, +/* Nfer */ CANNA_FN_Kakutei, +/* Xfer */ CANNA_FN_AlphaMode, +/* Up */ NONE, +/* Left */ NONE, +/* Right */ NONE, +/* Down */ NONE, +/* Insert */ CANNA_FN_KigouMode, +/* Rollup */ NONE, +/* Rolldown */ NONE, +#ifdef WIN +/* Home */ NONE, +/* Help */ NONE, +#else +/* Home */ CANNA_FN_ExtendMode, +/* Help */ CANNA_FN_ExtendMode, +#endif +/* KeyPad */ NONE, +/* 8c */ NONE, +/* 8d */ NONE, +/* 8e */ NONE, +/* 8f */ NONE, +/* S-nfer */ NONE, +/* S-xfer */ CANNA_FN_AlphaMode, +/* S-up */ NONE, +/* S-left */ NONE, +/* S-right */ NONE, +/* S-down */ NONE, +/* C-nfer */ NONE, +/* C-xfer */ CANNA_FN_AlphaMode, +/* C-up */ NONE, +/* C-left */ NONE, +/* C-right */ NONE, +/* C-down */ NONE, +/* 9c */ NONE, +/* 9d */ NONE, +/* 9e */ NONE, +/* 9f */ NONE, +/* KANASPACE */ NONE, +/* ¡£ */ CANNA_FN_FunctionalInsert, +/* ¡Ö */ CANNA_FN_FunctionalInsert, +/* ¡× */ CANNA_FN_FunctionalInsert, +/* ¡¢ */ CANNA_FN_FunctionalInsert, +/* ¡¦ */ CANNA_FN_FunctionalInsert, +/* ¥ò */ CANNA_FN_FunctionalInsert, +/* ¥¡ */ CANNA_FN_FunctionalInsert, +/* ¥£ */ CANNA_FN_FunctionalInsert, +/* ¥¥ */ CANNA_FN_FunctionalInsert, +/* ¥§ */ CANNA_FN_FunctionalInsert, +/* ¥© */ CANNA_FN_FunctionalInsert, +/* ¥ã */ CANNA_FN_FunctionalInsert, +/* ¥å */ CANNA_FN_FunctionalInsert, +/* ¥ç */ CANNA_FN_FunctionalInsert, +/* ¥Ã */ CANNA_FN_FunctionalInsert, +/* ¡¼ */ CANNA_FN_FunctionalInsert, +/* ¥¢ */ CANNA_FN_FunctionalInsert, +/* ¥¤ */ CANNA_FN_FunctionalInsert, +/* ¥¦ */ CANNA_FN_FunctionalInsert, +/* ¥¨ */ CANNA_FN_FunctionalInsert, +/* ¥ª */ CANNA_FN_FunctionalInsert, +/* ¥« */ CANNA_FN_FunctionalInsert, +/* ¥­ */ CANNA_FN_FunctionalInsert, +/* ¥¯ */ CANNA_FN_FunctionalInsert, +/* ¥± */ CANNA_FN_FunctionalInsert, +/* ¥³ */ CANNA_FN_FunctionalInsert, +/* ¥µ */ CANNA_FN_FunctionalInsert, +/* ¥· */ CANNA_FN_FunctionalInsert, +/* ¥¹ */ CANNA_FN_FunctionalInsert, +/* ¥» */ CANNA_FN_FunctionalInsert, +/* ¥½ */ CANNA_FN_FunctionalInsert, +/* ¥¿ */ CANNA_FN_FunctionalInsert, +/* ¥Á */ CANNA_FN_FunctionalInsert, +/* ¥Ä */ CANNA_FN_FunctionalInsert, +/* ¥Æ */ CANNA_FN_FunctionalInsert, +/* ¥È */ CANNA_FN_FunctionalInsert, +/* ¥Ê */ CANNA_FN_FunctionalInsert, +/* ¥Ë */ CANNA_FN_FunctionalInsert, +/* ¥Ì */ CANNA_FN_FunctionalInsert, +/* ¥Í */ CANNA_FN_FunctionalInsert, +/* ¥Î */ CANNA_FN_FunctionalInsert, +/* ¥Ï */ CANNA_FN_FunctionalInsert, +/* ¥Ò */ CANNA_FN_FunctionalInsert, +/* ¥Õ */ CANNA_FN_FunctionalInsert, +/* ¥Ø */ CANNA_FN_FunctionalInsert, +/* ¥Û */ CANNA_FN_FunctionalInsert, +/* ¥Þ */ CANNA_FN_FunctionalInsert, +/* ¥ß */ CANNA_FN_FunctionalInsert, +/* ¥à */ CANNA_FN_FunctionalInsert, +/* ¥á */ CANNA_FN_FunctionalInsert, +/* ¥â */ CANNA_FN_FunctionalInsert, +/* ¥ä */ CANNA_FN_FunctionalInsert, +/* ¥æ */ CANNA_FN_FunctionalInsert, +/* ¥è */ CANNA_FN_FunctionalInsert, +/* ¥é */ CANNA_FN_FunctionalInsert, +/* ¥ê */ CANNA_FN_FunctionalInsert, +/* ¥ë */ CANNA_FN_FunctionalInsert, +/* ¥ì */ CANNA_FN_FunctionalInsert, +/* ¥í */ CANNA_FN_FunctionalInsert, +/* ¥ï */ CANNA_FN_FunctionalInsert, +/* ¥ó */ CANNA_FN_FunctionalInsert, +/* ¡« */ CANNA_FN_FunctionalInsert, +/* ¡¬ */ CANNA_FN_FunctionalInsert, +/* F1 */ NONE, +/* F2 */ NONE, +/* F3 */ NONE, +/* F4 */ NONE, +/* F5 */ NONE, +/* F6 */ NONE, +/* F7 */ NONE, +/* F8 */ NONE, +/* F9 */ NONE, +/* F10 */ NONE, +/* ea */ NONE, +/* eb */ NONE, +/* ec */ NONE, +/* ed */ NONE, +/* ee */ NONE, +/* ef */ NONE, +/* PF1 */ NONE, +/* PF2 */ NONE, +/* PF3 */ NONE, +/* PF4 */ NONE, +/* PF5 */ NONE, +/* PF6 */ NONE, +/* PF7 */ NONE, +/* PF8 */ NONE, +/* PF9 */ NONE, +/* PF10 */ NONE, +/* fa */ NONE, +/* fb */ NONE, +/* fc */ NONE, +/* fd */ NONE, +/* fe */ NONE, +/* ff */ NONE, +}; + +KanjiModeRec empty_mode = { + searchfunc, + empty_kmap, + CANNA_KANJIMODE_TABLE_SHARED | CANNA_KANJIMODE_EMPTY_MODE, + empty_funcs, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/engine.c b/src/add-ons/input_server/methods/canna/lib/engine.c new file mode 100644 index 0000000000..86ac1c6a0c --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/engine.c @@ -0,0 +1,60 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "$Id: engine.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#include "canna.h" + +#define CANNA_SERVER_NAME_LEN 128 +static char iroha_server_name[CANNA_SERVER_NAME_LEN] = {0, 0}; + +RkSetServerName(char *s) +{ + if (s) + (void)strncpy(iroha_server_name, s, CANNA_SERVER_NAME_LEN); + else + iroha_server_name[0] = '\0'; + return 0; +} + +char * +RkGetServerHost(void) +{ +// if (iroha_server_name[0]) { +// return iroha_server_name; +// } +// else { + return (char *)0; +// } +} + +void +close_engine(void) +{ +} + diff --git a/src/add-ons/input_server/methods/canna/lib/henkan.c b/src/add-ons/input_server/methods/canna/lib/henkan.c new file mode 100644 index 0000000000..aaae34da58 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/henkan.c @@ -0,0 +1,2578 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: henkan.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +#include +#include +#ifdef MEASURE_TIME +#include +#ifdef WIN +#include +#else +/* If you compile with Visual C++ on WIN, then please comment out next line. */ +#include +#endif +#endif + +extern struct RkRxDic *romajidic, *englishdic; + +extern int defaultBushuContext; +extern int yomiInfoLevel; +extern int ckverbose; +extern int defaultContext; +extern struct dicname *RengoGakushu, *KatakanaGakushu, *HiraganaGakushu; +extern KanjiModeRec cy_mode, cb_mode, yomi_mode, tankouho_mode, empty_mode; +extern char saveapname[]; +extern int RkwGetServerVersion (int *, int *); + +#define DICERRORMESGLEN 78 + + +static doYomiHenkan(uiContext d, int len, WCHAR_T *kanji); + +static char dictmp[DICERRORMESGLEN]; + +inline int +kanakanError(uiContext d) +{ + return makeRkError(d, "Kana-kanji conversion feiled"); + /* ¤«¤Ê´Á»úÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ +} + +static void +dicMesg(char *s, char *d) +{ +#ifndef WIN + if (ckverbose == CANNA_FULL_VERBOSE) { + char buf[128]; + sprintf(buf, "\"%s\"", d); + printf("%14s %-20s ¤ò»ØÄꤷ¤Æ¤¤¤Þ¤¹¡£\n", s, buf); + } +#endif +} + +static void +RkwInitError(void) +{ + if (errno == EPIPE) { + jrKanjiError = KanjiInitError(); + }else { + jrKanjiError = "Error in initailzaton of Kana-kanji conversion dictionaly."; + /* ¤«¤Ê´Á»úÊÑ´¹¼­½ñ¤Î½é´ü²½¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + addWarningMesg(jrKanjiError); + RkwFinalize(); +} + +static void +mountError(char *dic) +{ +static char *mountErrorMessage = " can't mount. "; /* ¤ò¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ +int mnterrlen; + + if (DICERRORMESGLEN < + (unsigned)(strlen(dic) + (mnterrlen = strlen(mountErrorMessage)) + 1)) { + (void)strncpy(dictmp, dic, DICERRORMESGLEN - mnterrlen - 3/* ... */ - 1); + (void)strcpy(dictmp + DICERRORMESGLEN - mnterrlen - 3 - 1, "..."); + strcpy(dictmp + DICERRORMESGLEN - mnterrlen - 1, mountErrorMessage); + } + else { + sprintf(dictmp, "%s%s", dic, mountErrorMessage); + } + jrKanjiError = dictmp; + addWarningMesg(dictmp); +} + +inline void +autodicError(void) +{ + jrKanjiError = "¼«Æ°ÅÐÏ¿ÍѼ­½ñ¤¬Â¸ºß¤·¤Þ¤»¤ó"; + addWarningMesg(jrKanjiError); +} + +/* + * ¤«¤Ê´Á»úÊÑ´¹¤Î¤¿¤á¤Î½é´ü½èÍý + * + * ¡¦RkwInitialize¤ò¸Æ¤ó¤Ç¡¢defaultContext ¤òºîÀ®¤¹¤ë + * ¡¦defaultBushuContext ¤òºîÀ®¤¹¤ë + * ¡¦¼­½ñ¤Î¥µ¡¼¥Á¥Ñ¥¹¤òÀßÄꤹ¤ë + * ¡¦¥·¥¹¥Æ¥à¼­½ñ¡¢Éô¼óÍѼ­½ñ¡¢¥æ¡¼¥¶¼­½ñ¤ò¥Þ¥¦¥ó¥È¤¹¤ë + * + * °ú¤­¿ô ¤Ê¤· + * Ìá¤êÃÍ 0:¤Þ¤¢Àµ¾ï¡¢ -1:¤È¤³¤È¤óÉÔÎÉ + */ +KanjiInit() +{ +char *ptr, *getenv(), *kodmesg = ""/* ¼­½ñ¤Î¼ïÊÌËè¤Î¥á¥Ã¥»¡¼¥¸ */; +int con; +static int mountnottry = 1; /* ¥Þ¥¦¥ó¥È½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤ë¤«¤É¤¦¤« */ +struct dicname *stp; +extern struct dicname *kanjidicnames; +extern FirstTime; +extern jrUserInfoStruct *uinfo; +extern char *RkGetServerHost(void); +extern char basepath[]; +int ret = -1; +char dichomedir[256]; + +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { + fprintf(stderr,"\n¥µ¡¼¥Ð¤ËÀܳ¤·¤¿ strokelimit = %d (default:%d)\n", + cannaconf.strokelimit, STROKE_LIMIT); + } +#endif + /* ϢʸÀá¥é¥¤¥Ö¥é¥ê¤ò½é´ü²½¤¹¤ë */ + if (uinfo) { + RkwSetUserInfo(uinfo->uname, uinfo->gname, uinfo->topdir); + } + + sprintf(dichomedir, "%s%s", basepath, "dic"); +// puts(dichomedir); + fputs( dichomedir, stderr ); + if ((defaultContext = RkwInitialize(dichomedir)) == -1) { + RkwInitError(); + ret = -1; + goto return_ret; + } + + if (defaultContext != -1) { + if((defaultBushuContext = RkwCreateContext()) == -1) { + jrKanjiError = "\311\364\274\363\315\321\244\316\245\263\245\363\245\306" + "\245\257\245\271\245\310\244\362\272\356\300\256\244\307\244\255" + "\244\336\244\273\244\363\244\307\244\267\244\277"; + /* Éô¼óÍѤΥ³¥ó¥Æ¥¯¥¹¥È¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + addWarningMesg(jrKanjiError); + defaultContext = -1; + RkwFinalize(); + ret = -1; + goto return_ret; + } + } else { + defaultBushuContext = -1; + } + + debug_message("\245\307\245\325\245\251\245\353\245\310\245\263\245\363" + "\245\306\245\255\245\271\245\310(%d), \311\364\274\363\245\263" + "\245\363\245\306\245\255\245\271\245\310(%d)\n", + defaultContext, defaultBushuContext, 0); + /* ¥Ç¥Õ¥©¥ë¥È¥³¥ó¥Æ¥­¥¹¥È(%d), Éô¼ó¥³¥ó¥Æ¥­¥¹¥È(%d)\n */ + + if((RkwSetDicPath(defaultContext, "canna")) == -1) { + jrKanjiError = "¼­½ñ¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÀßÄê¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; + RkwFinalize(); + return(NG); + } + if((RkwSetDicPath(defaultBushuContext, "canna")) == -1) { + jrKanjiError = "¼­½ñ¤Î¥Ç¥£¥ì¥¯¥È¥ê¤òÀßÄê¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; + RkwFinalize(); + return(NG); + } + + + if (defaultContext != -1) { + + if (saveapname[0]) { + RkwSetAppName(defaultContext, saveapname); + } + + if (!FirstTime && !mountnottry) { /* KC_INITIALIZE ¤Ç¸Æ¤Ó½Ð¤µ¤ì¤Æ¤¤¤Ê¤¯¤Æ¡¢ + ´û¤Ë¥Þ¥¦¥ó¥È½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤ë¾ì¹ç */ + /* ʸˡ¼­½ñ¤Î¥Þ¥¦¥ó¥È */ + for (stp = kanjidicnames; stp ; stp = stp->next) { + if (stp->dictype == DIC_GRAMMAR) { + if (stp->dicflag == DIC_MOUNTED) { + if (RkwMountDic(defaultContext, stp->name, + cannaconf.kojin ? PL_ALLOW : PL_INHIBIT) == -1) { + stp->dicflag = DIC_MOUNT_FAILED; + mountError(stp->name); + } + else { + stp->dicflag = DIC_MOUNTED; + dicMesg("\312\270\313\241\274\255\275\361", stp->name); + /* ʸˡ¼­½ñ */ + } + } + } + } + /* ¥·¥¹¥Æ¥à¼­½ñ¤Î¥Þ¥¦¥ó¥È */ + for (stp = kanjidicnames ; stp ; stp = stp->next) { + if (stp->dictype != DIC_GRAMMAR) { + if (stp->dicflag == DIC_MOUNTED) { + if (stp->dictype == DIC_BUSHU) { + con = defaultBushuContext; + } + else { + con = defaultContext; + } + if (RkwMountDic(con, stp->name, + cannaconf.kojin ? PL_ALLOW : PL_INHIBIT) + == -1) { +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { + fprintf(stderr, "saveddicname = %s\n", stp->name); + } +#endif + stp->dicflag = DIC_MOUNT_FAILED; + mountError(stp->name); + } + dicMesg("saveddicname\244\316\274\255\275\361", stp->name); + /* saveddicname¤Î¼­½ñ */ + } + } + } + } + else { /* KC_INITIALIZE ¤«¤é¸Æ¤Ó½Ð¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡£ + ¤Þ¤¿¤Ï¡¢¥Þ¥¦¥ó¥È½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Ê¤¤¾ì¹ç */ +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { + fprintf(stderr, "¼­½ñ¤Ï.canna¤ÎÄ̤ê¤Ë¥Þ¥¦¥ó¥È¤¹¤ë\n"); + } +#endif + + mountnottry = 0; /* ¥Þ¥¦¥ó¥È½èÍý¤ò¹Ô¤¦¤Î¤Ç mountnottry = 0 ¤Ë¤¹¤ë */ + /* ʸˡ¼­½ñ¤Î¥Þ¥¦¥ó¥È */ + for (stp = kanjidicnames; stp ; stp = stp->next) { + if (stp->dictype == DIC_GRAMMAR) { + if (RkwMountDic(defaultContext, stp->name, + cannaconf.kojin ? PL_ALLOW : PL_INHIBIT) == -1) { + stp->dicflag = DIC_MOUNT_FAILED; + mountError(stp->name); + } + else { + stp->dicflag = DIC_MOUNTED; + dicMesg("\312\270\313\241\274\255\275\361", stp->name); + /* ʸˡ¼­½ñ */ + } + } + } + + /* ¥·¥¹¥Æ¥à¼­½ñ¤Î¥Þ¥¦¥ó¥È */ + for (stp = kanjidicnames ; stp ; stp = stp->next) { + if (stp->dictype != DIC_GRAMMAR) { + con = defaultContext; + if (stp->dictype == DIC_PLAIN) { + kodmesg = "\245\267\245\271\245\306\245\340\274\255\275\361"; + /* "¥·¥¹¥Æ¥à¼­½ñ"; */ + } + else if (stp->dictype == DIC_USER) { + /* ¥æ¡¼¥¶¼­½ñ¤Î¥Þ¥¦¥ó¥È */ + kodmesg = "\303\261\270\354\305\320\317\277\315\321\274\255\275\361"; + /* "ñ¸ìÅÐÏ¿ÍѼ­½ñ"; */ + } + else if (stp->dictype == DIC_RENGO) { + /* Ï¢¸ì¼­½ñ¤Î¥Þ¥¦¥ó¥È */ + RengoGakushu = stp; + kodmesg = "\317\242\270\354\274\255\275\361"; + /* "Ï¢¸ì¼­½ñ"; */ + } + else if (stp->dictype == DIC_KATAKANA) { + KatakanaGakushu = stp; + kodmesg = "\274\253\306\260\305\320\317\277\315\321\274\255\275\361"; + /* "¼«Æ°ÅÐÏ¿ÍѼ­½ñ"; */ + } + else if (stp->dictype == DIC_HIRAGANA) { + HiraganaGakushu = stp; +#ifdef HIRAGANAAUTO + kodmesg = "\274\253\306\260\305\320\317\277\315\321\274\255\275\361"; + /* "¼«Æ°ÅÐÏ¿ÍѼ­½ñ"; */ +#else + kodmesg = "\317\242\270\354\274\255\275\361"; + /* "Ï¢¸ì¼­½ñ"; */ +#endif + } + else if (stp->dictype == DIC_BUSHU) { + kodmesg = "\311\364\274\363\274\255\275\361"; + /* "Éô¼ó¼­½ñ"; */ + con = defaultBushuContext; + } + if (RkwMountDic(con, stp->name, + cannaconf.kojin ? PL_ALLOW : PL_INHIBIT) == -1) { + extern int auto_define; + + stp->dicflag = DIC_MOUNT_FAILED; + if (stp->dictype == DIC_KATAKANA +#ifdef HIRAGANAAUTO + || stp->dictype == DIC_HIRAGANA +#endif + ) { + /* ¼«Æ°ÅÐÏ¿¼­½ñ¤À¤Ã¤¿¤é¡¢¼«Æ°ÅÐÏ¿¤·¤Ê¤¤ */ + auto_define = 0; + } + if (stp->dictype != DIC_USER || strcmp(stp->name, "user")) { + /* ¥æ¡¼¥¶¼­½ñ¤Ç user ¤È¤¤¤¦Ì¾Á°¤Î¾ì¹ç¤Ï¥¨¥é¡¼É½¼¨ * + * ¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¤¿¤á */ + int majv, minv; + + RkwGetServerVersion(&majv, &minv); + if (!(canna_version(majv, minv) < canna_version(3, 4)) + || ((stp->dictype != DIC_KATAKANA || + strcmp(stp->name, "katakana")) +#ifdef HIRAGANAAUTO + && (stp->dictype != DIC_HIRAGANA || + strcmp(stp->name, "hiragana")) +#endif + )) { + /* V3.3 °ÊÁ°¤Ç¡¢¥«¥¿¥«¥Ê¼­½ñ¤¬ katakana¡¢¤Ò¤é¤¬¤Ê¼­½ñ¤¬ + hiragana ¤Î¾ì¹ç¤Ï¥¨¥é¡¼¤Ë¤·¤Ê¤¤¤¿¤á */ + extern char *kataautodic; +#ifdef HIRAGANAAUTO + extern char *hiraautodic; +#endif + + if (!auto_define || + ((kataautodic && strcmp(stp->name, kataautodic)) +#ifdef HIRAGANAAUTO + && (hiraautodic && strcmp(stp->name, hiraautodic)) +#endif + )) { + if (stp->dictype == DIC_KATAKANA +#ifdef HIRAGANAAUTO + || stp->dictype == DIC_HIRAGANA +#endif + ) { + autodicError(); + } + else { + mountError(stp->name); + } + } + } + } + } + else { + stp->dicflag = DIC_MOUNTED; + dicMesg(kodmesg, stp->name); + } + } + } + } + ret = 0; + goto return_ret; + } + ret = -1; + return_ret: +#ifdef WIN + free(buf); +#endif + return ret; +} +/* + * ¤«¤Ê´Á»úÊÑ´¹¤Î¤¿¤á¤Î¸å½èÍý + * + * ¡¦¥·¥¹¥Æ¥à¼­½ñ¡¢Éô¼óÍѼ­½ñ¡¢¥æ¡¼¥¶¼­½ñ¤ò¥¢¥ó¥Þ¥¦¥ó¥È¤¹¤ë + * ¡¦RkwFinalize¤ò¸Æ¤Ö + * + * °ú¤­¿ô ¤Ê¤· + * Ìá¤êÃÍ ¤Ê¤· + */ +KanjiFin(void) +{ + struct dicname *dp, *np; + int con; + + for (dp = kanjidicnames ; dp ;) { + if (dp->dictype == DIC_BUSHU) { + con = defaultBushuContext; + } + else { + con = defaultContext; + } + if (dp->dicflag == DIC_MOUNTED) { + if (RkwUnmountDic(con, dp->name) == -1) { +#ifdef WIN + char *buf = malloc(128); + if (buf) { + sprintf(buf, "%s \244\362\245\242\245\363\245\336\245\246\245\363" + "\245\310\244\307\244\255\244\336\244\273\244\363\244\307\244\267" + "\244\277", dp->name); + addWarningMesg(buf); + free(buf); + } +#else + char buf[256]; + sprintf(buf, "%s ¤ò¥¢¥ó¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", dp->name); + addWarningMesg(buf); +#endif + } + } + np = dp->next; + free(dp->name); + free(dp); + dp = np; + } + kanjidicnames = (struct dicname *)0; + + /* ϢʸÀá¥é¥¤¥Ö¥é¥ê¤ò½ªÎ»¤µ¤»¤ë */ + RkwFinalize(); + + return(0); +} + +static tanContext +newTanContext(int majo, int mino) +{ + tanContext tan; + + tan = (tanContext)malloc(sizeof(tanContextRec)); + if (tan) { + bzero(tan, sizeof(tanContextRec)); + tan->id = TAN_CONTEXT; + tan->majorMode = majo; + tan->minorMode = mino; + tan->left = tan->right = (tanContext)0; + tan->next = (mode_context)0; + tan->curMode = &tankouho_mode; + } + return tan; +} + +void +freeTanContext(tanContext tan) +{ + if (tan->kanji) free(tan->kanji); + if (tan->yomi) free(tan->yomi); + if (tan->roma) free(tan->roma); + if (tan->kAttr) free(tan->kAttr); + if (tan->rAttr) free(tan->rAttr); + free(tan); +} + +static WCHAR_T * +DUpwstr(WCHAR_T *w, int l) +{ + WCHAR_T *res; + + res = (WCHAR_T *)malloc((l + 1) * sizeof(WCHAR_T)); + if (res) { + WStrncpy(res, w, l); + res[l] = (WCHAR_T)0; + } + return res; +} + +static BYTE * +DUpattr(BYTE *a, int l) +{ + BYTE *res; + + res = (BYTE *)malloc((l + 1) * sizeof(BYTE)); + if (res) { + bcopy(a, res, (l + 1) * sizeof(BYTE)); + } + return res; +} + +static void +copyYomiinfo2Tan(yomiContext yc, tanContext tan) +{ + tan->next = yc->next; + tan->prevMode = yc->prevMode; + tan->generalFlags = yc->generalFlags; + tan->savedFlags = yc->savedFlags; + + tan->romdic = yc->romdic; + tan->myMinorMode = yc->myMinorMode; + tan->myEmptyMode = yc->myEmptyMode; + tan->savedMinorMode = yc->savedMinorMode; + tan->allowedChars = yc->allowedChars; + tan->henkanInhibition = yc->henkanInhibition; +} + +static void +copyTaninfo2Yomi(tanContext tan, yomiContext yc) +{ + /* next ¤È prevMode ¤Ï´û¤ËÀßÄêºÑ¤ß */ + yc->generalFlags = tan->generalFlags; + yc->savedFlags = tan->savedFlags; + + yc->romdic = tan->romdic; + yc->myMinorMode = tan->myMinorMode; + yc->myEmptyMode = tan->myEmptyMode; + yc->savedMinorMode = tan->savedMinorMode; + yc->allowedChars = tan->allowedChars; + yc->henkanInhibition = tan->henkanInhibition; +} + +extern yomiContext dupYomiContext (yomiContext); +extern void setMode (uiContext, tanContext, int); + +extern void trimYomi (uiContext, int, int, int, int); + +/* + Á´Ê¸Àá¤ò tanContext ¤ËÊÑ´¹¤¹¤ë + */ + +int +doTanConvertTb(uiContext d, yomiContext yc) +{ + int cur = yc->curbun, i, len, ylen = 0, rlen = 0, ret = 0; + int scuryomi, ecuryomi, scurroma, ecurroma; + tanContext tan, prevLeft = yc->left, curtan = (tanContext)0; + BYTE *p, *q, *r; +#ifndef WIN + WCHAR_T xxx[ROMEBUFSIZE]; +#else + WCHAR_T *xxx = (WCHAR_T *)malloc(sizeof(WCHAR_T) * ROMEBUFSIZE); + if (!xxx) { + return ret; + } +#endif + + yc->kouhoCount = 0; + scuryomi = ecuryomi = scurroma = ecurroma = 0; + +/* jrKanjiError = "¥á¥â¥ê¤¬Â­¤ê¤Þ¤»¤ó"; */ + jrKanjiError = "malloc (doTanBubunMuhenkan) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277\241\243"; + /* malloc (doTanBubunMuhenkan) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + for (i = 0 ; i < yc->nbunsetsu ; i++) { + tan = newTanContext(yc->majorMode, CANNA_MODE_TankouhoMode); + if (tan) { + copyYomiinfo2Tan(yc, tan); + RkwGoTo(yc->context, i); + len = RkwGetKanji(yc->context, xxx, ROMEBUFSIZE); + if (len >= 0) { + tan->kanji = DUpwstr(xxx, len); + if (tan->kanji) { + len = RkwGetYomi(yc->context, xxx, ROMEBUFSIZE); + if (len >= 0) { + tan->yomi = DUpwstr(xxx, len); + if (tan->yomi) { + tan->kAttr = DUpattr(yc->kAttr + ylen, len); + if (tan->kAttr) { + r = yc->rAttr + rlen; + for (p = yc->kAttr + ylen, q = p + len ; p < q ; p++) { + if (*p & SENTOU) { + r++; + while (!(*r & SENTOU)) { + r++; + } + } + } + ylen += len; + len = r - yc->rAttr - rlen; /* ¥í¡¼¥Þ»ú¤ÎŤµ */ + tan->roma = DUpwstr(yc->romaji_buffer + rlen, len); + if (tan->roma) { + tan->rAttr = DUpattr(yc->rAttr + rlen, len); + if (tan->rAttr) { + rlen += len; + /* ¤È¤ê¤¢¤¨¤ºº¸¤Ë¤Ä¤Ê¤²¤ë */ + tan->right = (tanContext)yc; + tan->left = yc->left; + if (yc->left) { + yc->left->right = tan; + } + yc->left = tan; + if (i == cur) { + curtan = tan; + } + continue; + } + free(tan->roma); + } + free(tan->kAttr); + } + free(tan->yomi); + } + } + else { + makeRkError(d, KanjiInitError()); + } + free(tan->kanji); + } + }else{ + makeRkError(d, KanjiInitError()); + } + freeTanContext(tan); + } + /* ¥¨¥é¡¼½èÍý¤ò¤¹¤ë */ + procerror: + while ((tan = yc->left) != prevLeft) { + yc->left = tan->left; + freeTanContext(tan); + } + ret = -1; + goto return_ret; + } + + if (chikujip(yc) && chikujiyomiremain(yc)) { + int rpos; + yomiContext lyc = dupYomiContext(yc); + + if (!lyc) { /* ¥¨¥é¡¼½èÍý¤ò¤¹¤ë */ + goto procerror; + } + + if (yc->right) { /* Ã༡¤Î¾ì¹ç¤Ê¤¤¤Ï¤º¤À¤¬Ç°¤Î¤¿¤á */ + yc->right->left = (tanContext)lyc; + } + lyc->right = yc->right; + yc->right = (tanContext)lyc; + lyc->left = (tanContext)yc; + + kPos2rPos(lyc, 0, yc->cStartp, (int *)0, &rpos); + d->modec = (mode_context)lyc; + moveToChikujiYomiMode(d); + trimYomi(d, yc->cStartp, yc->kEndp, rpos, yc->rEndp); + d->modec = (mode_context)yc; + yc->status = lyc->status; + lyc->cStartp = lyc->cRStartp = lyc->ys = lyc->ye = 0; + } + + RkwGoTo(yc->context, cur); + if (RkwEndBun(yc->context, cannaconf.Gakushu ? 1 : 0) == -1) { + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316" + "\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267" + "\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + if (errno == EPIPE) { + jrKanjiPipeError(); + } + } + + d->modec = (mode_context)curtan; + setMode(d, curtan, 1); + makeKanjiStatusReturn(d, (yomiContext)curtan); + + /* yc ¤ò¥ê¥ó¥¯¤«¤éÈ´¤¯ */ + if (yc->left) { + yc->left->right = yc->right; + } + if (yc->right) { + yc->right->left = yc->left; + } + abandonContext(d, yc); + freeYomiContext(yc); + + return_ret: +#ifdef WIN + free(xxx); +#endif + + return ret; +} + +static int +doTanBubunMuhenkan(uiContext d, yomiContext yc) +{ + int cur = yc->curbun, i, len, ylen = 0, rlen = 0, ret = 0; + int scuryomi, ecuryomi, scurroma, ecurroma; + tanContext tan, prevLeft = yc->left; + BYTE *p, *q, *r; +#ifndef WIN + WCHAR_T xxx[ROMEBUFSIZE]; +#else + WCHAR_T *xxx = (WCHAR_T *)malloc(sizeof(WCHAR_T) * ROMEBUFSIZE); + if (!xxx) { + return ret; + } +#endif + + yc->kouhoCount = 0; + scuryomi = ecuryomi = scurroma = ecurroma = 0; + +/* jrKanjiError = "¥á¥â¥ê¤¬Â­¤ê¤Þ¤»¤ó"; */ + jrKanjiError = "malloc (doTanBubunMuhenkan) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277\241\243"; + /* malloc (doTanBubunMuhenkan) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + for (i = 0 ; i < yc->nbunsetsu ; i++) { + tan = (tanContext)0; + if (i == cur || + (tan = newTanContext(yc->majorMode, CANNA_MODE_TankouhoMode))) { + if (tan) { + copyYomiinfo2Tan(yc, tan); + } + RkwGoTo(yc->context, i); + len = RkwGetKanji(yc->context, xxx, ROMEBUFSIZE); + if (len >= 0) { + if (!tan || (tan->kanji = DUpwstr(xxx, len))) { + len = RkwGetYomi(yc->context, xxx, ROMEBUFSIZE); + if (len >= 0) { + if (!tan || (tan->yomi = DUpwstr(xxx, len))) { + if (!tan || (tan->kAttr = DUpattr(yc->kAttr + ylen, len))) { + r = yc->rAttr + rlen; + for (p = yc->kAttr + ylen, q = p + len ; p < q ; p++) { + if (*p & SENTOU) { + r++; + while (!(*r & SENTOU)) { + r++; + } + } + } + if (i == cur) { + scuryomi = ylen; + ecuryomi = ylen + len; + } + ylen += len; + len = r - yc->rAttr - rlen; /* ¥í¡¼¥Þ»ú¤ÎŤµ */ + if (!tan || + (tan->roma = DUpwstr(yc->romaji_buffer + rlen, len))) { + if (!tan || (tan->rAttr = DUpattr(yc->rAttr + rlen, len))) { + if (i == cur) { + scurroma = rlen; + ecurroma = rlen + len; + } + rlen += len; + if (tan) { + if (i != cur) { + /* ¤È¤ê¤¢¤¨¤ºº¸¤Ë¤Ä¤Ê¤²¤ë */ + tan->right = (tanContext)yc; + tan->left = yc->left; + if (yc->left) { + yc->left->right = tan; + } + yc->left = tan; + } +#if defined(DEBUG) && !defined(WIN) + { + char yyy[ROMEBUFSIZE]; + WCstombs(yyy, tan->kanji, ROMEBUFSIZE); + printf("%s/", yyy); + WCstombs(yyy, tan->yomi, ROMEBUFSIZE); + printf("%s/", yyy); + WCstombs(yyy, tan->roma, ROMEBUFSIZE); + printf("%s\n", yyy); + } +#endif + } + continue; + } + if (tan) free(tan->roma); + } + if (tan) free(tan->kAttr); + } + if (tan) free(tan->yomi); + } + } + else { + makeRkError(d, KanjiInitError()); + } + if (tan) free(tan->kanji); + } + }else{ + makeRkError(d, KanjiInitError()); + } + if (tan) freeTanContext(tan); + } + /* ¥¨¥é¡¼½èÍý¤ò¤¹¤ë */ + while ((tan = yc->left) != prevLeft) { + yc->left = tan->left; + freeTanContext(tan); + } + ret = -1; + goto return_ret; + } + + if (chikujip(yc) && chikujiyomiremain(yc)) { + int rpos; + yomiContext lyc = dupYomiContext(yc); + + if (!lyc) { /* ¥¨¥é¡¼½èÍý¤ò¤¹¤ë */ + while ((tan = yc->left) != prevLeft) { + yc->left = tan->left; + freeTanContext(tan); + } + ret = -1; + goto return_ret; + } + + if (yc->right) { /* ¤Ê¤¤¤Ï¤º */ + yc->right->left = (tanContext)lyc; + } + lyc->right = yc->right; + yc->right = (tanContext)lyc; + lyc->left = (tanContext)yc; + + kPos2rPos(lyc, 0, yc->cStartp, (int *)0, &rpos); + d->modec = (mode_context)lyc; + moveToChikujiYomiMode(d); + trimYomi(d, yc->cStartp, yc->kEndp, rpos, yc->rEndp); + d->modec = (mode_context)yc; + yc->status = lyc->status; + lyc->cStartp = lyc->cRStartp = lyc->ys = lyc->ye = 0; + } + + if (cur + 1 < yc->nbunsetsu) { /* yc ¤¬ºÇ¸å¤¸¤ã¤Ê¤¤¾ì¹ç */ + int n = yc->nbunsetsu - cur - 1; + tan = yc->left; + tan->right = yc->right; + if (yc->right) { + yc->right->left = tan; + } + for (i = 1 ; i < n ; i++) { /* yomi ¤Î right ¤ËÍè¤ë¤Ù¤­ tan ¤òÆÀ¤¿¤¤ */ + tan = tan->left; + } + if (tan->left) { + tan->left->right = (tanContext)yc; + } + yc->left = tan->left; + tan->left = (tanContext)yc; + yc->right = tan; + } + RkwGoTo(yc->context, cur); + if (RkwEndBun(yc->context, cannaconf.Gakushu ? 1 : 0) == -1) { + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316" + "\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267" + "\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + if (errno == EPIPE) { + jrKanjiPipeError(); + } + } + + trimYomi(d, scuryomi, ecuryomi, scurroma, ecurroma); + + yc->cRStartp = yc->rCurs = yc->rStartp = 0; + yc->cStartp = yc->kCurs = yc->kRStartp = + yc->ys = yc->ye = 0; + yc->status &= CHIKUJI_NULL_STATUS; + /* ¤Ê¤ó¤ÈÃ༡¤Ç¤Ê¤¯¤Ê¤ë */ + if (chikujip(yc)) { + yc->generalFlags &= ~CANNA_YOMI_CHIKUJI_MODE; + yc->generalFlags |= CANNA_YOMI_BASE_CHIKUJI; + } + + d->current_mode = yc->curMode = &yomi_mode; + yc->minorMode = getBaseMode(yc); + + /* Á´Éô̵ÊÑ´¹¤Ë¤¹¤ë */ + yc->nbunsetsu = 0; + + /* ñ¸õÊä¾õÂÖ¤«¤éÆÉ¤ß¤ËÌá¤ë¤È¤­¤Ë¤Ï̵¾ò·ï¤Ëmark¤òÀèÆ¬¤ËÌ᤹ */ + yc->cmark = yc->pmark = 0; + + abandonContext(d, yc); + ret = 0; + + return_ret: +#ifdef WIN + free(xxx); +#endif + + return ret; +} + +extern void restoreChikujiIfBaseChikuji (yomiContext); +extern void ReCheckStartp (yomiContext); +extern void fitmarks (yomiContext); + +int YomiBubunKakutei (uiContext); + +int +YomiBubunKakutei(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + tanContext tan; + int len; + + if (yc->id != YOMI_CONTEXT) { + /* ¤¢¤êÆÀ¤Ê¤¤¤Î¤Ç¤Ï? */ + } + else /* if (yc->left) */ { + /* yomiContext ¤Çºï½ü¤¹¤ëÉôʬ¤ò¤Þ¤º tanContext ¤ËÀÚ¤ê½Ð¤·¡¢yc ¤Îº¸ + ¦¤ËÁÞÆþ¤¹¤ë¡£¼¡¤Ë yc ¤Îº¸¤ò¤Ð¤Ã¤µ¤ê¤È³ÎÄꤹ¤ë¡£ + Á´¤Æ¤³¤Î¥í¥¸¥Ã¥¯¤Ç¤ä¤í¤¦¤«¤·¤é¡£ + */ + tan = newTanContext(yc->majorMode, CANNA_MODE_TankouhoMode); + if (tan) { + copyYomiinfo2Tan(yc, tan); + /* ¤«¤Ê¤ò¥³¥Ô¡¼¤¹¤ë */ + tan->kanji = DUpwstr(yc->kana_buffer, yc->kCurs); + if (tan->kanji) { + /* ¤³¤³¤âƱ¤¸¤«¤Ê¤ò¥³¥Ô¡¼¤¹¤ë */ + tan->yomi = DUpwstr(yc->kana_buffer, yc->kCurs); + if (tan->yomi) { + tan->kAttr = DUpattr(yc->kAttr, yc->kCurs); + if (tan->kAttr) { + tan->roma = DUpwstr(yc->romaji_buffer, yc->rCurs); + if (tan->roma) { + tan->rAttr = DUpattr(yc->rAttr, yc->rCurs); + if (tan->rAttr) { + WCHAR_T *sb = d->buffer_return, *eb = sb + d->n_buffer; + + tan->left = yc->left; + tan->right = (tanContext)yc; + if (yc->left) { + yc->left->right = tan; + } + yc->left = tan; + while (tan->left) { + tan = tan->left; + } + + trimYomi(d, yc->kCurs, yc->kEndp, yc->rCurs, yc->rEndp); + + len = doKakutei(d, tan, (tanContext)yc, sb, eb, + (yomiContext *)0); + d->modec = (mode_context)yc; + yc->left = (tanContext)0; + goto done; + } + free(tan->roma); + } + free(tan->kAttr); + } + free(tan->yomi); + } + free(tan->kanji); + } + free(tan); /* not freeTanContext(tan); */ + } + } +#if 0 + /* ËÜÍ褳¤³¤Î½èÍý¤ò¤¤¤ì¤¿Êý¤¬¸úΨ¤¬Îɤ¤¤È»×¤ï¤ì¤ë¤¬¡¢ÆÉ¤ß¤Î°ìÉô¤ò³Î + Äꤵ¤»¤Æ¡¢¤·¤«¤â¥í¡¼¥Þ»ú¾ðÊó¤Ê¤É¤â¤¤¤ì¤ë¤Î¤ÏÌÌÅݤʤΤǤ¢¤È¤Þ¤ï¤·¤È¤¹¤ë */ + else { + + /* ³ÎÄꤵ¤»¤ë¡£ + ¼¡¤Ë trim ¤¹¤ë*/ + } +#endif + + done: + if (!yc->kEndp) { + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + } + if (yc->right) { + removeCurrentBunsetsu(d, (tanContext)yc); + yc = (yomiContext)0; + } + else { + /* ̤³ÎÄêʸ»úÎó¤¬Á´¤¯¤Ê¤¯¤Ê¤Ã¤¿¤Î¤Ê¤é¡¢¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + currentModeInfo(d); + } + else { + if (yc->kCurs != yc->kRStartp) { + ReCheckStartp(yc); + } + } + + if (yc) { + fitmarks(yc); + } + + makeYomiReturnStruct(d); + return len; +} + +yomiContext +newFilledYomiContext(mode_context next, KanjiMode prev) +{ + yomiContext yc; + + yc = newYomiContext((WCHAR_T *)NULL, 0, /* ·ë²Ì¤Ï³ÊǼ¤·¤Ê¤¤ */ + CANNA_NOTHING_RESTRICTED, + (int)!CANNA_YOMI_CHGMODE_INHIBITTED, + (int)!CANNA_YOMI_END_IF_KAKUTEI, + CANNA_YOMI_INHIBIT_NONE); + if (yc) { + yc->majorMode = yc->minorMode = CANNA_MODE_HenkanMode; + yc->curMode = &yomi_mode; + yc->myEmptyMode = &empty_mode; + yc->romdic = romajidic; + yc->next = next; + yc->prevMode = prev; + } + return yc; +} + +#ifdef DO_MERGE +static +yomiContext +mergeYomiContext(yomiContext yc) +{ + yomiContext res, a, b; + + res = yc; + while (res->left && res->left->id == YOMI_CONTEXT) { + res = (yomiContext)res->left; + } + for (a = (yomiContext)res->right ; a && a->id == YOMI_CONTEXT ; a = b) { + b = (yomiContext)a->right; + appendYomi2Yomi(a, res); + if (yc == a) { + res->kCurs = res->kRStartp = res->kEndp; + res->rCurs = res->rStartp = res->rEndp; + res->cmark = res->kCurs; + } + res->right = a->right; + if (res->right) { + res->right->left = (tanContext)res; + } + /* yc->context ¤Î close ¤Ï¤¤¤é¤Ê¤¤¤Î¤«¤Ê¤¢¡£1996.10.30 º£ */ + freeYomiContext(a); + } + return res; +} +#endif + +/* + tanContext ¤ò yomiContext ¤Ë¤·¤Æ¡¢ÆÉ¤ßÆþÎϾõÂ֤ˤ¹¤ë + + 0 ¼ºÇÔ + otherwise ¤¢¤¿¤é¤·¤¤ÆÉ¤ß¥³¥ó¥Æ¥­¥¹¥È¤¬ÊÖ¤ë + + */ + +static yomiContext +tanbunUnconvert(uiContext d, tanContext tan) +{ + yomiContext yc; + + yc = newFilledYomiContext(tan->next, tan->prevMode); + if (yc) { + extern KanjiModeRec yomi_mode, empty_mode; + + appendTan2Yomi(tan, yc); + copyTaninfo2Yomi(tan, yc); + yc->right = tan->right; + yc->left = tan->left; + if (yc->myMinorMode) { + yc->minorMode = yc->myMinorMode; + } + + if (chikujip(yc)) { /* Ã༡¤Ë¤Ï¤·¤Ê¤¤ */ + yc->generalFlags &= ~CANNA_YOMI_CHIKUJI_MODE; + yc->generalFlags |= CANNA_YOMI_BASE_CHIKUJI; + } + + if (yc->left) { + yc->left->right = (tanContext)yc; + } + if (yc->right) { + yc->right->left = (tanContext)yc; + } + freeTanContext(tan); +#ifdef DO_MERGE /* ÄêµÁ¤·¤Æ¤¤¤Ê¤¤ */ + yc = mergeYomiContext(yc); +#endif + d->current_mode = yc->curMode; + d->modec = (mode_context)yc; + return yc; + } + jrKanjiError = "\245\341\245\342\245\352\244\254\302\255\244\352\244\336" + "\244\273\244\363"; + /* ¥á¥â¥ê¤¬Â­¤ê¤Þ¤»¤ó */ + return (yomiContext)0; +} + +static int +TbBubunMuhenkan(uiContext d) +{ + tanContext tan = (tanContext)d->modec; + yomiContext yc; + + yc = tanbunUnconvert(d, tan); + if (yc) { + currentModeInfo(d); + makeKanjiStatusReturn(d, yc); + return 0; + } + makeGLineMessageFromString(d, jrKanjiError); + return NothingChangedWithBeep(d); +} + +/* + TanBubunMuhenkan -- ÊÑ´¹Ãæ¤Îʸ»úÎó¤òʸÀáËè¤Ëʬ³ä¤¹¤ë¡£ + + ¤½¤ÎºÝ¡¢ÆÉ¤ß¤ä¥í¡¼¥Þ»ú¤âʬ³ä¤¹¤ë + */ + +int +TanBubunMuhenkan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return TbBubunMuhenkan(d); + } + + if (!yc->right && !yc->left && yc->nbunsetsu == 1) { + return TanMuhenkan(d); + } + + if (doTanBubunMuhenkan(d, yc) < 0) { + makeGLineMessageFromString(d, jrKanjiError); + return TanMuhenkan(d); + } + makeYomiReturnStruct(d); + currentModeInfo(d); + return 0; +} + +int +prepareHenkanMode(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (confirmContext(d, yc) < 0) { + return 0; + } + d->current_mode = yc->curMode = &tankouho_mode; + + return 1; +} + +doHenkan(uiContext d, int len, WCHAR_T *kanji) +{ + /* ¤è¤ß¤ò´Á»ú¤ËÊÑ´¹¤¹¤ë */ + if(doYomiHenkan(d, len, kanji) == NG) { + return -1; + } + + /* kanji_status_return¤òºî¤ë */ + makeKanjiStatusReturn(d, (yomiContext)d->modec); + return 0; +} + + +/* + * ¤«¤Ê´Á»úÊÑ´¹¤ò¹Ô¤¦ + * ¡¦d->yomi_buffer¤Ë¤è¤ß¤ò¼è¤ê½Ð¤·¡¢RkwBgnBun¤ò¸Æ¤ó¤Ç¤«¤Ê´Á»úÊÑ´¹¤ò³«»Ï¤¹¤ë + * ¡¦¥«¥ì¥ó¥ÈʸÀá¤òÀèÆ¬Ê¸Àá¤Ë¤·¤Æ¡¢¥¨¥³¡¼Ê¸»úÎó¤òºî¤ë + * + * °ú¤­¿ô uiContext + * len len ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤éʸÀáŤò¤½¤ÎŤµ¤Ë¤¹¤ë¡£ + * kanji kanji ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤éñʸÀáÊÑ´¹¤·¤Æ¡¢ + * ¥«¥ì¥ó¥È¸õÊä¤ò kanji ¤Ç¼¨¤µ¤ì¤¿¸õÊä¤Ë¹ç¤ï¤»¤ë¡£ + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static +doYomiHenkan(uiContext d, int len, WCHAR_T *kanji) +{ + unsigned int mode; + yomiContext yc = (yomiContext)d->modec; + extern defaultContext; + +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { +/* printf("yomi => "); Wprintf(hc->yomi_buffer); putchar('\n');*/ + printf("yomi len => %d\n", hc->yomilen); + } +#endif + + /* ϢʸÀáÊÑ´¹¤ò³«»Ï¤¹¤ë *//* ¼­½ñ¤Ë¤Ê¤¤ ¥«¥¿¥«¥Ê ¤Ò¤é¤¬¤Ê ¤òÉղ乤ë */ + mode = 0; + mode = (RK_XFER<nbunsetsu = + RkwBgnBun(yc->context, yc->kana_buffer, yc->kEndp, mode)) == -1) { + yc->nbunsetsu = 0; + return kanakanError(d); + } + + if (len > 0 && (yc->nbunsetsu = RkwResize(yc->context, len)) == -1) { + RkwEndBun(yc->context, 0); + yc->nbunsetsu = 0; + return kanakanError(d); + } + + if (kanji) { + /* kanji ¤¬»ØÄꤵ¤ì¤Æ¤¤¤¿¤é¡¢Æ±¤¸¸õÊ䤬¤Ç¤ë¤Þ¤Ç RkwNext ¤ò¤¹¤ë */ + int i, n; + + n = RkwGetKanjiList(yc->context, d->genbuf, ROMEBUFSIZE); + if (n < 0) { + return kanakanError(d); + } + for (i = 0 ; i < n ; i++) { + RkwXfer(yc->context, i); + len = RkwGetKanji(yc->context, d->genbuf, ROMEBUFSIZE); + if (len < 0) { + return kanakanError(d); + } + d->genbuf[len] = (WCHAR_T)'\0'; + if (!WStrcmp(kanji, d->genbuf)) { + break; + } + } + if (i == n) { + RkwXfer(yc->context, 0); + } + } + +#ifdef MEASURE_TIME + yc->rktime = times(&timebuf); + yc->rktime -= RkTime; + } +#endif /* MEASURE_TIME */ + + /* ¥«¥ì¥ó¥ÈʸÀá¤ÏÀèÆ¬Ê¸Àá */ + yc->curbun = 0; + + return(0); +} + +int +TanNop(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + /* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */ + d->majorMode = d->minorMode = CANNA_MODE_AlphaMode; + currentModeInfo(d); + + makeKanjiStatusReturn(d, yc); + return 0; +} + +static int +doGoTo(uiContext d, yomiContext yc) +{ + if (RkwGoTo(yc->context, yc->curbun) == -1) { + return makeRkError(d, "\312\270\300\341\244\316\260\334\306\260\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + yc->status |= CHIKUJI_OVERWRAP; + + /* kanji_status_return¤òºî¤ë */ + makeKanjiStatusReturn(d, yc); + return 0; +} + +/* + * ¼¡Ê¸Àá¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +int +TanForwardBunsetsu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return TbForward(d); + } + + yc->kouhoCount = 0; + if (yc->curbun + 1 < yc->nbunsetsu) { + yc->curbun++; + } + else if (yc->cStartp && yc->cStartp < yc->kEndp) { /* Ã༡¤ÎÆÉ¤ß¤¬±¦¤Ë¤¢¤ë */ + yc->kRStartp = yc->kCurs = yc->cStartp; + yc->rStartp = yc->rCurs = yc->cRStartp; + moveToChikujiYomiMode(d); + } + else if (yc->right) { + return TbForward(d); + } + else if (cannaconf.kakuteiIfEndOfBunsetsu) { + d->nbytes = TanKakutei(d); + d->kanji_status_return->length + = d->kanji_status_return->revPos + = d->kanji_status_return->revLen = 0; + return d->nbytes; + } + else if (!cannaconf.CursorWrap) { + return NothingForGLine(d); + } + else if (yc->left) { + return TbBeginningOfLine(d); + } + else { + yc->curbun = 0; + } + + /* ¥«¥ì¥ó¥ÈʸÀá¤ò£±¤Ä±¦¤Ë°Ü¤¹ */ + /* ¥«¥ì¥ó¥ÈʸÀ᤬ºÇ±¦¤À¤Ã¤¿¤é¡¢ + ºÇº¸¤ò¥«¥ì¥ó¥ÈʸÀá¤Ë¤¹¤ë */ + return doGoTo(d, yc); +} + +/* + * Á°Ê¸Àá¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +int +TanBackwardBunsetsu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return TbBackward(d); + } + + yc->kouhoCount = 0; + if (yc->curbun) { + yc->curbun--; + } + else if (yc->left) { + return TbBackward(d); + } + else if (!cannaconf.CursorWrap) { + return NothingForGLine(d); + } + else if (yc->right) { + return TbEndOfLine(d); + } + else if (yc->cStartp && yc->cStartp < yc->kEndp) { /* Ã༡¤ÎÆÉ¤ß¤¬±¦¤Ë¤¢¤ë */ + yc->kCurs = yc->kRStartp = yc->kEndp; + yc->rCurs = yc->rStartp = yc->rEndp; + moveToChikujiYomiMode(d); + } + else { + yc->curbun = yc->nbunsetsu - 1; + } + + return doGoTo(d, yc); +} + +/* + * ¼¡¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤Ë¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +static +tanNextKouho(uiContext d, yomiContext yc) +{ +#ifdef MEASURE_TIME + struct tms timebuf; + long time, times(; + + time = times(&timebuf; +#endif /* MEASURE_TIME */ + + /* ¼¡¤Î¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë */ + if (RkwNext(yc->context) == -1) { + makeRkError(d, "\245\253\245\354\245\363\245\310\270\365\312\344\244\362" + "\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307" + "\244\267\244\277"); + /* ¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + return TanMuhenkan(d); + } + +#ifdef MEASURE_TIME + yc->rktime = times(&timebuf); + yc->rktime -= proctime; +#endif /* MEASURE_TIME */ + + /* kanji_status_return¤òºî¤ë */ + makeKanjiStatusReturn(d, yc); + +#ifdef MEASURE_TIME + yc->time = times(&timebuf; + yc->proctime -= proctime; +#endif /* MEASURE_TIME */ + + return(0); +} + +/* + tanbunHenkan -- ÊÑ´¹¤¹¤ë¡£ + + ¤ß¤½¤Ï¡¢kanji ¤Ç¼¨¤µ¤ì¤¿¸õÊä¤ÈƱ¤¸¸õÊ䤬½Ð¤ë¤Þ¤Ç RkwNext ¤ò¤¹¤ë¤³¤È + ¤Ç¤¢¤ë¡£°ì¼þ¤·¤¿¤³¤È¤â¸¡½Ð¤·¤Ê¤±¤ì¤Ð¤Ê¤ë¤Þ¤¤¡£ + */ + +static int +tanbunHenkan(uiContext d, yomiContext yc, WCHAR_T *kanji) +{ + if (!prepareHenkanMode(d)) { + makeGLineMessageFromString(d, jrKanjiError); + makeYomiReturnStruct(d); + return 0; + } + yc->minorMode = CANNA_MODE_TankouhoMode; + yc->kouhoCount = 1; + if (doHenkan(d, 0, kanji) < 0) { + makeGLineMessageFromString(d, jrKanjiError); + makeYomiReturnStruct(d); + return 0; + } + if (cannaconf.kouho_threshold > 0 && + yc->kouhoCount >= cannaconf.kouho_threshold) { + return tanKouhoIchiran(d, 0); + } + + currentModeInfo(d); + makeKanjiStatusReturn(d, yc); + return 0; +} + +/* + enterTanHenkanMode -- tanContext ¤ò yomiContext ¤Ë¤·¤ÆÊÑ´¹¤Î½àÈ÷¤ò¤¹¤ë + + */ + +static int +enterTanHenkanMode(uiContext d, int fnum) +{ + tanContext tan = (tanContext)d->modec; + yomiContext yc; + WCHAR_T *prevkanji; + + prevkanji = tan->kanji; + tan->kanji = (WCHAR_T *)0; + + yc = tanbunUnconvert(d, tan); + if (yc) { + tanbunHenkan(d, yc, prevkanji); + free(prevkanji); + + /*¤³¤³¤Ç + ñ¸õÊä¥â¡¼¥É¤Î·Á¤Ë¤¹¤ë + */ + + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = fnum; + return 0; + } + else { /* Æó½Å¥Õ¥ê¡¼¤ò¤·¤Ê¤¤¤¿¤á¶¯Ä´Åª¤Ë else ¤ò½ñ¤¯ */ + free(prevkanji); + } + makeGLineMessageFromString(d, jrKanjiError); + return NothingChangedWithBeep(d); +} + +/* + * ¸õÊä°ìÍ÷¹Ô¤òɽ¼¨¤¹¤ë + * + * ¡¦¸õÊä°ìÍ÷ɽ¼¨¤Î¤¿¤á¤Î¥Ç¡¼¥¿¤ò¥Æ¡¼¥Ö¥ë¤ËºîÀ®¤¹¤ë + * ¡¦¸õÊä°ìÍ÷ɽ¼¨¹Ô¤¬¶¹¤¤¤È¤­¤Ï¡¢°ìÍ÷¤òɽ¼¨¤·¤Ê¤¤¤Ç¼¡¸õÊä¤ò¤½¤Î¾ì¤Ëɽ¼¨¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +TanKouhoIchiran(uiContext d) +{ + if (d->modec->id != YOMI_CONTEXT) { + return enterTanHenkanMode(d, CANNA_FN_KouhoIchiran); + } + return tanKouhoIchiran(d, 1); +} + +TanNextKouho(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return enterTanHenkanMode(d, CANNA_FN_Next); + } + yc->status |= CHIKUJI_OVERWRAP; + yc->kouhoCount = 0; + return tanNextKouho(d, yc); +} + +/* + + TanHenkan -- ²ó¿ô¤ò¥Á¥§¥Ã¥¯¤¹¤ë°Ê³°¤Ï TanNextKouho ¤È¤Û¤ÜƱ¤¸ + + */ +static TanHenkan (uiContext); + +static int +TanHenkan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return enterTanHenkanMode(d, CANNA_FN_Henkan); + } + + if (cannaconf.kouho_threshold && + ++yc->kouhoCount >= cannaconf.kouho_threshold) { + return TanKouhoIchiran(d); + } + else { + return tanNextKouho(d, yc); + } +} + +/* + * Á°¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤Ë¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +TanPreviousKouho(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return enterTanHenkanMode(d, CANNA_FN_Prev); + } + + yc->status |= CHIKUJI_OVERWRAP; + yc->kouhoCount = 0; + /* Á°¤Î¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë */ + if (RkwPrev(yc->context) == -1) { + makeRkError(d, "\245\253\245\354\245\363\245\310\270\365\312\344\244\362" + "\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307" + "\244\267\244\277"); + /* ¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + return TanMuhenkan(d); + } + + /* kanji_status_return¤òºî¤ë */ + makeKanjiStatusReturn(d, yc); + + return 0; +} + +/* + tanJishuHenkan -- ÆÃÄê¤ÎʸÀá¤À¤±»ú¼ïÊÑ´¹¤¹¤ë + */ + +static int tanJishuHenkan (uiContext, int); + +static int +tanJishuHenkan(uiContext d, int fn) +{ + d->nbytes = TanBubunMuhenkan(d); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = fn; + return d->nbytes; +} + +TanHiragana(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_Hiragana); +} + +TanKatakana(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_Katakana); +} + +TanRomaji(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_Romaji); +} + +TanUpper(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_ToUpper); +} + +TanCapitalize(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_Capitalize); +} + +TanZenkaku(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_Zenkaku); +} + +TanHankaku(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_Hankaku); +} + +int TanKanaRotate (uiContext); + +TanKanaRotate(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_KanaRotate); +} + +int TanRomajiRotate (uiContext); + +TanRomajiRotate(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_RomajiRotate); +} + +int TanCaseRotateForward (uiContext); + +TanCaseRotateForward(uiContext d) +{ + return tanJishuHenkan(d, CANNA_FN_CaseRotate); +} + +static int +gotoBunsetsu(yomiContext yc, int n) +{ + /* ¥«¥ì¥ó¥ÈʸÀá¤ò°Üư¤¹¤ë */ + if (RkwGoTo(yc->context, n) == -1) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\312\270\300\341\244\316\260\334\306\260\244\313\274\272" + "\307\324\244\267\244\336\244\267\244\277"; + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return NG; + } + yc->curbun = n; + return 0; +} + +/* + * ºÇº¸Ê¸Àá¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +int +TanBeginningOfBunsetsu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT || yc->left) { + return TbBeginningOfLine(d); + } + yc->kouhoCount = 0; + if (gotoBunsetsu(yc, 0) < 0) { + return NG; + } + makeKanjiStatusReturn(d, yc); + return 0; +} + +/* + * ºÇ±¦Ê¸Àá¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +int +TanEndOfBunsetsu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT || yc->right) { + return TbEndOfLine(d); + } + + yc->kouhoCount = 0; + if (yc->cStartp && yc->cStartp < yc->kEndp) { + yc->kRStartp = yc->kCurs = yc->kEndp; + yc->rStartp = yc->rCurs = yc->rEndp; + moveToChikujiYomiMode(d); + } + if (gotoBunsetsu(yc, yc->nbunsetsu - 1) < 0) { + return NG; + } + yc->status |= CHIKUJI_OVERWRAP; + makeKanjiStatusReturn(d, yc); + return 0; +} + +int +tanMuhenkan(uiContext d, int kCurs) +{ + extern KanjiModeRec yomi_mode; + yomiContext yc = (yomiContext)d->modec; + int autoconvert = (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE); + + if (RkwEndBun(yc->context, 0) == -1) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + } + + if (autoconvert) { + yc->status &= CHIKUJI_NULL_STATUS; + d->current_mode = yc->curMode = &cy_mode; + yc->ys = yc->ye = yc->cStartp = yc->cRStartp = 0; + yc->rCurs = yc->rStartp = yc->rEndp; + yc->kCurs = yc->kRStartp = yc->kEndp; + clearHenkanContext(yc); + } + else { + d->current_mode = yc->curMode = &yomi_mode; + } + yc->minorMode = getBaseMode(yc); + + if (kCurs >= 0) { + int rpos; + + kPos2rPos(yc, 0, kCurs, (int *)0, &rpos); + yc->kCurs = yc->kRStartp = kCurs; + yc->rCurs = yc->rStartp = rpos; + } + + /* Á´Éô̵ÊÑ´¹¤Ë¤¹¤ë */ + yc->nbunsetsu = 0; + + /* ñ¸õÊä¾õÂÖ¤«¤éÆÉ¤ß¤ËÌá¤ë¤È¤­¤Ë¤Ï̵¾ò·ï¤Ëmark¤òÀèÆ¬¤ËÌ᤹ */ + yc->cmark = yc->pmark = 0; + + abandonContext(d, yc); + + return 0; +} + +/* + * Á´¤Æ¤ÎʸÀá¤òÆÉ¤ß¤ËÌᤷ¡¢YomiInputMode ¤ËÌá¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +TanMuhenkan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec, newyc; + tanContext tan; + + if (yc->id != YOMI_CONTEXT || yc->left || yc->right) { + tan = (tanContext)yc; + while (tan->left) { + tan = tan->left; + } + if (tan->id == YOMI_CONTEXT) { + newyc = (yomiContext)tan; + } + else { + newyc = newFilledYomiContext(yc->next, yc->prevMode); + if (newyc) { + tan->left = (tanContext)newyc; + newyc->right = tan; + newyc->generalFlags = tan->generalFlags; + newyc->savedFlags = tan->savedFlags; + if (chikujip(newyc)) { + newyc->curMode = &cy_mode; + } + newyc->minorMode = getBaseMode(newyc); + }else{ + jrKanjiError = "\245\341\245\342\245\352\244\254\302\255\244\352" + "\244\336\244\273\244\363"; + /* ¥á¥â¥ê¤¬Â­¤ê¤Þ¤»¤ó */ + makeGLineMessageFromString(d, jrKanjiError); + return NothingChangedWithBeep(d); + } + } + d->modec = (mode_context)newyc; + d->current_mode = newyc->curMode; + + doMuhenkan(d, newyc); + + if (newyc->generalFlags & + (CANNA_YOMI_CHIKUJI_MODE | CANNA_YOMI_BASE_CHIKUJI)) { + /* ¡Ö¿´¤ÏÃ༡¤À¤Ã¤¿¡×¤Î¤Ç¤¢¤ì¤Ð¡¢Ã༡¥â¡¼¥É¤ËÌ᤹ */ + newyc->generalFlags |= CANNA_YOMI_CHIKUJI_MODE; + newyc->generalFlags &= ~CANNA_YOMI_BASE_CHIKUJI; + newyc->minorMode = getBaseMode(newyc); + d->current_mode = newyc->curMode = &cy_mode; + } + + makeYomiReturnStruct(d); + currentModeInfo(d); + return 0; + } + + if (yc->generalFlags & + (CANNA_YOMI_CHIKUJI_MODE | CANNA_YOMI_BASE_CHIKUJI)) { + /* ¡Ö¿´¤ÏÃ༡¤À¤Ã¤¿¡×¤Î¤Ç¤¢¤ì¤Ð¡¢Ã༡¥â¡¼¥É¤ËÌ᤹ */ + yc->generalFlags |= CANNA_YOMI_CHIKUJI_MODE; + yc->generalFlags &= ~CANNA_YOMI_BASE_CHIKUJI; + /* ¥Ì¥ë¥¹¥Æ¡¼¥¿¥¹¤ËÌ᤹ */ + yc->status &= CHIKUJI_NULL_STATUS; + } + + tanMuhenkan(d, -1); + makeYomiReturnStruct(d); + currentModeInfo(d); + return 0; +} + +int +TanDeletePrevious(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int i, j, l = -1, ret = 0; +#ifndef WIN + WCHAR_T tmpbuf[ROMEBUFSIZE]; +#else + WCHAR_T *tmpbuf = (WCHAR_T *)malloc(sizeof(WCHAR_T) * ROMEBUFSIZE); + if (!tmpbuf) { + return ret; + } +#endif + + if (yc->id != YOMI_CONTEXT) { + ret = TanMuhenkan(d); + goto return_ret; + } + + if ((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && + !cannaconf.BackspaceBehavesAsQuit) { + ret = ChikujiTanDeletePrevious(d); + goto return_ret; + } + else { + if (cannaconf.keepCursorPosition) { + for (i = 0, l = 0; i <= yc->curbun; i++) { + if (RkwGoTo(yc->context, i) == -1 + || (j = RkwGetYomi(yc->context, tmpbuf, ROMEBUFSIZE)) == -1) { + l = -1; + break; + } + l += j; + } + } + yc->status &= CHIKUJI_NULL_STATUS; + tanMuhenkan(d, l); + makeYomiReturnStruct(d); + currentModeInfo(d); + ret = 0; + } + return_ret: +#ifdef WIN + free(tmpbuf); +#endif + return ret; +} + +#if 0 +/* + doTanKakutei -- ³ÎÄꤵ¤»¤ëưºî¤ò¤¹¤ë + + retval 0 -- ÌäÂê̵¤¯³ÎÄꤷ¤¿¡£ + 1 -- ³ÎÄꤷ¤¿¤é¤Ê¤¯¤Ê¤Ã¤¿¡£ + -1 -- ¥¨¥é¡¼¡© + */ + +static +doTanKakutei(uiContext d, yomiContext yc) +{ + if ((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && + (yc->cStartp < yc->kEndp)) { + (void)RomajiFlushYomi(d, (WCHAR_T *)0, 0); + } + + return 0; +} +#endif /* 0 */ + +void +finishTanKakutei(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int autoconvert = yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE; + +#ifdef DO_RENGO_LEARNING +#define RENGOBUFSIZE 256 + + /* This will not be defined when WIN is defined. So I don't care + about the local array located below. 1996.6.5 kon */ + + if (RengoGakushu && hc->nbunsetsu > 1) { /* Ï¢¸ì³Ø½¬¤ò¤·¤è¤¦¤«¤Ê¤¡ */ + RkLex lex[2][RENGOBUFSIZE]; + WCHAR_T yomi[2][RENGOBUFSIZE]; + WCHAR_T kanji[2][RENGOBUFSIZE]; + WCHAR_T word[1024], *w; + unsigned char xxxx[ROMEBUFSIZE]; + int nword[2], wlen; + + *(w = word) = (WCHAR_T) '\0'; + wlen = 1024; + + RkwGoTo(hc->context, 0); + nword[0] = RkwGetLex(hc->context, lex[0], RENGOBUFSIZE); + yomi[0][0] = + (WCHAR_T) '\0'; /* yomi[current][0]¤Î¿¿ÍýÃÍ ¢á RkwGetYomi¤·¤¿¤« */ + + for (i = 1 ; i < hc->nbunsetsu ; i++) { + int current, previous, mighter; + + current = i % 2; + previous = 1 - current; + + nword[current] = 0; + if ( !nword[previous] ) { + nword[previous] = RkwGetLex(hc->context, lex[previous], RENGOBUFSIZE); + } + RkwRight(hc->context); + + if (nword[previous] == 1) { + nword[current] = RkwGetLex(hc->context, lex[current], RENGOBUFSIZE); + yomi[current][0] = (WCHAR_T) '\0'; + if (((lex[previous][0].ylen <= 3 && lex[previous][0].klen == 1) || + (lex[current][0].ylen <= 3 && lex[current][0].klen == 1)) && + (lex[current][0].rownum < R_K5 || + R_NZX < lex[current][0].rownum)) { + if ( !yomi[previous][0] ) { + RkwLeft(hc->context); + RkwGetYomi(hc->context, yomi[previous], RENGOBUFSIZE); + RkwGetKanji(hc->context, kanji[previous], RENGOBUFSIZE); + RkwRight(hc->context); + } + RkwGetYomi(hc->context, yomi[current], RENGOBUFSIZE); + RkwGetKanji(hc->context, kanji[current], RENGOBUFSIZE); + + WStrncpy(yomi[previous] + lex[previous][0].ylen, + yomi[current], lex[current][0].ylen); + yomi[previous][lex[previous][0].ylen + lex[current][0].ylen] = + (WCHAR_T) '\0'; + + WStrncpy(kanji[previous] + lex[previous][0].klen, + kanji[current], lex[current][0].klen); + kanji[previous][lex[previous][0].klen + lex[current][0].klen] = + (WCHAR_T) '\0'; + +#ifdef NAGASADEBUNPOUWOKIMEYOU + if (lex[previous][0].klen >= lex[current][0].klen) { + /* Á°¤Î´Á»ú¤ÎŤµ >= ¸å¤í¤Î´Á»ú¤ÎŤµ */ + mighter = previous; + } + else { + mighter = current; + } +#else /* !NAGASADEBUNPOUWOKIMEYOU */ + mighter = current; +#endif /* !NAGASADEBUNPOUWOKIMEYOU */ + WStrcpy(w, yomi[previous]); + printf(xxxx, " #%d#%d ", lex[mighter][0].rownum, + lex[mighter][0].colnum); + MBstowcs(w + WStrlen(w), xxxx, wlen - WStrlen(w)); + WStrcat(w, kanji[previous]); + wlen -= (WStrlen(w) + 1); w += WStrlen(w) + 1; *w = (WCHAR_T) '\0'; + } + } + } + } +#endif /* DO_RENGO_LEARNING */ + + if (RkwEndBun(yc->context, cannaconf.Gakushu ? 1 : 0) == -1) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + } + +#ifdef DO_RENGO_LEARNING + if (RengoGakushu && yc->nbunsetsu > 1) { /* Ï¢¸ì³Ø½¬¤ò¤·¤è¤¦¤«¤Ê¤¡ */ + for (w = word ; *w ; w += WStrlen(w) + 1) { + RkwDefineDic(yc->context, RengoGakushu, w); + } + } +#endif /* DO_RENGO_LEARNING */ + + if (autoconvert) { + yc->status &= CHIKUJI_NULL_STATUS; + yc->ys = yc->ye = yc->cStartp = yc->cRStartp = 0; + clearHenkanContext(yc); + yc->kEndp = yc->rEndp = yc->kCurs = yc->rCurs = + yc->cStartp = yc->cRStartp = + yc->rStartp = yc->kRStartp = 0; + yc->kAttr[0] = yc->rAttr[0] = SENTOU; + yc->kana_buffer[0] = yc->romaji_buffer[0] = 0; +/* d->kanji_status_return->info |= KanjiEmptyInfo; ¿ʬÍפé¤Ê¤¤¤Î¤Ç.. */ + d->current_mode = yc->curMode = yc->myEmptyMode; + } + yc->minorMode = getBaseMode(yc); + + /* ñ¸õÊä¾õÂÖ¤«¤éÆÉ¤ß¤ËÌá¤ë¤È¤­¤Ë¤Ï̵¾ò·ï¤Ëmark¤òÀèÆ¬¤ËÌ᤹ */ + yc->nbunsetsu = 0; + yc->cmark = yc->pmark = 0; + + abandonContext(d, yc); + + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + } +} + +TanKakutei(uiContext d) +{ + return YomiKakutei(d); +} + +/* + * ´Á»ú¸õÊä¤ò³ÎÄꤵ¤»¡¢¥í¡¼¥Þ»ú¤ò¥¤¥ó¥µ¡¼¥È¤¹¤ë + * + * renbun-continue ¤¬ t ¤Î¤È¤­¤Ï¡¢¼ÂºÝ¤Ë¤Ï³ÎÄꤷ¤Ê¤¤¤Î¤Ç½èÍý¤¬ + * ÌÌÅݤÀ¤Ã¤¿¤ê¤¹¤ë¡£ + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +static TanKakuteiYomiInsert (uiContext); + +static int +TanKakuteiYomiInsert(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + tanContext tan; + + if (cannaconf.RenbunContinue || cannaconf.ChikujiContinue) { + d->nbytes = 0; + for (tan = (tanContext)yc ; tan->right ; tan = tan->right) + /* bodyless 'for' */; + yc = (yomiContext)0; /* ǰ¤Î¤¿¤á */ + d->modec = (mode_context)tan; + setMode(d, tan, 1); + + if (tan->id == YOMI_CONTEXT) { + yc = (yomiContext)tan; + + if (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) { + /* Ã༡¤Ê¤éÉáÄ̤˳¤±¤ë¤À¤±¤À¤«¤é¤Ê¤¢ */ + yc->minorMode = CANNA_MODE_ChikujiTanMode; + d->current_mode = yc->curMode = &cb_mode; + currentModeInfo(d); + yc->status &= ~CHIKUJI_OVERWRAP; + if (yc->kCurs != yc->kEndp) { + yc->rStartp = yc->rCurs = yc->rEndp; + yc->kRStartp = yc->kCurs = yc->kEndp; + } + yc->ys = yc->ye = yc->cStartp; + return YomiInsert(d); + }else{ /* Ã༡¤¸¤ã¤Ê¤¤¾ì¹ç */ + extern nKouhoBunsetsu; + + yc->curbun = yc->nbunsetsu; + if (doTanBubunMuhenkan(d, yc) < 0) { + makeGLineMessageFromString(d, jrKanjiError); + return NothingChangedWithBeep(d); + } + if (nKouhoBunsetsu) { + (void)cutOffLeftSide(d, yc, nKouhoBunsetsu); + } + } + } + else { + yc = newFilledYomiContext(tan->next, tan->prevMode); + /* ¤¢¤êÆÀ¤Ê¤¤ if (tan->right) yc->right = tan->right; + yc->right->left = yc; */ + tan->right = (tanContext)yc; + yc->left = tan; + d->modec = (mode_context)yc; + /* d->current_mode = yc->curMode = yc->myEmptyMode; */ + } + } + else { + d->nbytes = YomiKakutei(d); + } + /* YomiKakutei(d) ¤Ç d->modec ¤¬Êѹ¹¤µ¤ì¤¿²ÄǽÀ­¤¬¤¢¤ë¤Î¤ÇºÆÆÉ¤ß¹þ¤ß¤¹¤ë */ + yc = (yomiContext)d->modec; + + if (yc->id == YOMI_CONTEXT) { + yc->minorMode = getBaseMode(yc); + } + currentModeInfo(d); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = 0; /* ¾å¤Î ch ¤Ç¼¨¤µ¤ì¤ë½èÍý¤ò¤»¤è */ + return d->nbytes; +} + + +/* cfuncdef + + pos ¤Ç»ØÄꤵ¤ì¤¿Ê¸Àᤪ¤è¤Ó¤½¤ì¤è¤ê¸å¤ÎʸÀá¤Î»ú¼ïÊÑ´¹¾ðÊó¤ò + ¥¯¥ê¥¢¤¹¤ë¡£ +*/ + +static int +doTbResize(uiContext d, yomiContext yc, int n) +{ + int len; + + if (doTanBubunMuhenkan(d, yc) < 0) { + makeGLineMessageFromString(d, jrKanjiError); + return NothingChangedWithBeep(d); + } + len = yc->kEndp; + doMuhenkan(d, yc); /* yc ¤«¤é±¦¤ò¤ß¤ó¤Ê̵ÊÑ´¹¤Ë¤·¤Æ yc ¤Ë¤Ä¤Ê¤²¤ë */ + if (!prepareHenkanMode(d)) { + makeGLineMessageFromString(d, jrKanjiError); + makeYomiReturnStruct(d); + currentModeInfo(d); + return 0; + } + yc->minorMode = CANNA_MODE_TankouhoMode; + yc->kouhoCount = 0; + if (doHenkan(d, len + n, (WCHAR_T *)0) < 0) { + makeGLineMessageFromString(d, jrKanjiError); + makeYomiReturnStruct(d); + currentModeInfo(d); + return 0; + } + currentModeInfo(d); + makeKanjiStatusReturn(d, yc); + return 0; +} + +/* + * ʸÀá¤ò¿­¤Ð¤¹ + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static TanExtendBunsetsu (uiContext); + +static int +TanExtendBunsetsu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return enterTanHenkanMode(d, CANNA_FN_Extend); + } + + d->nbytes = 0; + yc->kouhoCount = 0; + if (yc->right) { + return doTbResize(d, yc, 1); + } + if ((yc->nbunsetsu = RkwEnlarge(yc->context)) <= 0) { + makeRkError(d, "\312\270\300\341\244\316\263\310\302\347\244\313\274\272" + "\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î³ÈÂç¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return TanMuhenkan(d); + } + makeKanjiStatusReturn(d, yc); + return(d->nbytes); +} + +/* + * ʸÀá¤ò½Ì¤á¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static TanShrinkBunsetsu (uiContext); + +static int +TanShrinkBunsetsu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return enterTanHenkanMode(d, CANNA_FN_Shrink); + } + + d->nbytes = 0; + yc->kouhoCount = 0; + + if (yc->right) { + return doTbResize(d, yc, -1); + } + + /* ʸÀá¤ò½Ì¤á¤ë */ + if ((yc->nbunsetsu = RkwShorten(yc->context)) <= 0) { + makeRkError(d, "\312\270\300\341\244\316\275\314\276\256\244\313\274\272" + "\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î½Ì¾®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return TanMuhenkan(d); + } + makeKanjiStatusReturn(d, yc); + + return(d->nbytes); +} + +#define BUNPOU_DISPLAY + +#ifdef BUNPOU_DISPLAY +/* + * ʸˡ¾ðÊó¤ò¥×¥ê¥ó¥È¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +TanPrintBunpou(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + static WCHAR_T mesg[512]; /* static! */ + + if (yc->id != YOMI_CONTEXT) { + return enterTanHenkanMode(d, CANNA_FN_ConvertAsHex); + } + +#ifdef notdef +#ifdef DO_GETYOMI + if (RkwGetYomi(yc->context, buf, 256) == -1) { + if (errno == EPIPE) { + jrKanjiPipeError(); + TanMuhenkan(d); + } + fprintf(stderr, "¥«¥ì¥ó¥È¸õÊä¤ÎÆÉ¤ß¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿¡£\n"); + } + Wfprintf(stderr, "%s\n", buf); +#endif /* DO_GETYOMI */ + + if(RkwGetKanji(yc->context, buf, 256) == -1) { + if(errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\245\253\245\354\245\363\245\310\270\365\312\344\244\362" + "\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307" + "\244\267\244\277"; + /* ¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + return NG; + } +#endif + + if (RkwGetHinshi(yc->context, mesg, sizeof(mesg) / sizeof(WCHAR_T)) < 0) { + jrKanjiError = "\311\312\273\354\276\360\312\363\244\362\274\350\244\352" + "\275\320\244\273\244\336\244\273\244\363\244\307\244\267\244\277"; + /* ÉÊ»ì¾ðÊó¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + makeGLineMessageFromString(d, jrKanjiError); + makeKanjiStatusReturn(d, yc); + return 0; + } + + makeKanjiStatusReturn(d, yc); + d->kanji_status_return->info |= KanjiGLineInfo; + d->kanji_status_return->gline.line = mesg; + d->kanji_status_return->gline.length = WStrlen(mesg); + d->kanji_status_return->gline.revPos = 0; + d->kanji_status_return->gline.revLen = 0; + d->flags |= PLEASE_CLEAR_GLINE; + return 0; +} +#endif /* BUNPOU_DISPLAY */ + +#ifdef MEASURE_TIME +static +TanPrintTime(uiContext d) +{ + /* MEASURE_TIME will not be defined when WIN is defined. So I will not + care about arrays located on stack below. 1996.6.5 kon */ + unsgined char tmpbuf[1024]; + static WCHAR_T buf[256]; + yomiContext yc = (yomiContext)d->modec; + + ycc->kouhoCount = 0; + sprintf(tmpbuf, "\312\321\264\271\273\376\264\326 %d [ms]¡¢\244\246\244\301" + " UI \311\364\244\317 %d [ms]", + (yc->time * 50 / 3, + (yc->time - yc->rktime) * 50 / 3; + /* ÊÑ´¹»þ´Ö %d [ms]¡¢¤¦¤Á UI Éô¤Ï %d [ms] */ + MBstowcs(buf, tmpbuf, 1024); + d->kanji_status_return->info |= KanjiGLineInfo; + d->kanji_status_return->gline.line = buf; + d->kanji_status_return->gline.length = WStrlen(buf); + d->kanji_status_return->gline.revPos = 0; + d->kanji_status_return->gline.revLen = 0; + d->kanji_status_return->length = -1; + d->flags |= PLEASE_CLEAR_GLINE; + return 0; +} +#endif /* MEASURE_TIME */ + +void +jrKanjiPipeError(void) +{ + extern defaultContext, defaultBushuContext; + + defaultContext = -1; + defaultBushuContext = -1; + + makeAllContextToBeClosed(0); + + RkwFinalize(); +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { + fprintf(stderr, "\300\334\302\263\244\254\300\332\244\354\244\277\n"); + /* Àܳ¤¬Àڤ줿 */ + } +#endif +} + +/* cfuncdef + + TanBunsetsuMode -- ñ¸õÊä¥â¡¼¥É¤«¤éʸÀá¿­¤Ð¤·½Ì¤á¥â¡¼¥É¤Ø°Ü¹Ô¤¹¤ë + + */ + +static TanBunsetsuMode (uiContext); + +static +TanBunsetsuMode(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->id != YOMI_CONTEXT) { + return enterTanHenkanMode(d, CANNA_FN_AdjustBunsetsu); + } + if (yc->right) { + doTbResize(d, yc, 0); + yc = (yomiContext)d->modec; + } + if (enterAdjustMode(d, yc) < 0) { + return TanMuhenkan(d); + } + makeKanjiStatusReturn(d, yc); + currentModeInfo(d); + return 0; +} + +static void +chikujiSetCursor(uiContext d, int forw) +{ + yomiContext yc = (yomiContext)d->modec; + + if (forw) { /* °ìÈÖº¸¤Ø¹Ô¤¯ */ + if (yc->nbunsetsu) { /* ʸÀ᤬¤¢¤ë¡© */ + gotoBunsetsu(yc, 0); + moveToChikujiTanMode(d); + } + else { + yc->kRStartp = yc->kCurs = yc->cStartp; + yc->rStartp = yc->rCurs = yc->cRStartp; + moveToChikujiYomiMode(d); + } + } + else { /* °ìÈÖ±¦¤Ø¹Ô¤¯ */ + if (yc->cStartp < yc->kEndp) { /* ÆÉ¤ß¤¬¤¢¤ë¡© */ + yc->kRStartp = yc->kCurs = yc->kEndp; + yc->rStartp = yc->rCurs = yc->rEndp; + moveToChikujiYomiMode(d); + } + else { + gotoBunsetsu(yc, yc->nbunsetsu - 1); + moveToChikujiTanMode(d); + } + } +} + + +void +setMode(uiContext d, tanContext tan, int forw) +{ + yomiContext yc = (yomiContext)tan; + + d->current_mode = yc->curMode; + currentModeInfo(d); + if (tan->id == YOMI_CONTEXT) { + if (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) { + chikujiSetCursor(d, forw); + } + else if (yc->nbunsetsu) { + if (forw) { + gotoBunsetsu(yc, 0); + }else{ + gotoBunsetsu(yc, yc->nbunsetsu - 1); + } + } + else /* ÆÉ¤ß¥â¡¼¥É */ if (forw) { + yc->kCurs = yc->kRStartp = yc->cStartp; + yc->rCurs = yc->rStartp = yc->cRStartp; + } + else { + yc->kCurs = yc->kRStartp = yc->kEndp; + yc->rCurs = yc->rStartp = yc->rEndp; + } + } +} + +int +TbForward(uiContext d) +{ + tanContext tan = (tanContext)d->modec; + + if (tan->right) { + d->modec = (mode_context)tan->right; + tan = (tanContext)d->modec; + } + else if (cannaconf.CursorWrap && tan->left) { + while (tan->left) { + tan = tan->left; + } + d->modec = (mode_context)tan; + } + else { + return NothingChanged(d); + } + setMode(d, tan, 1); + makeKanjiStatusReturn(d, (yomiContext)d->modec); + return 0; +} + +int +TbBackward(uiContext d) +{ + tanContext tan = (tanContext)d->modec; + + if (tan->left) { + d->modec = (mode_context)tan->left; + tan = (tanContext)d->modec; + } + else if (cannaconf.CursorWrap && tan->right) { + while (tan->right) { + tan = tan->right; + } + d->modec = (mode_context)tan; + } + else { + return NothingChanged(d); + } + setMode(d, tan, 0); + makeKanjiStatusReturn(d, (yomiContext)d->modec); + return 0; +} + +int +TbBeginningOfLine(uiContext d) +{ + tanContext tan = (tanContext)d->modec; + + while (tan->left) { + tan = tan->left; + } + d->modec = (mode_context)tan; + setMode(d, tan, 1); + makeKanjiStatusReturn(d, (yomiContext)d->modec); + return 0; +} + +int +TbEndOfLine(uiContext d) +{ + tanContext tan = (tanContext)d->modec; + + while (tan->right) { + tan = tan->right; + } + d->modec = (mode_context)tan; + setMode(d, tan, 0); + makeKanjiStatusReturn(d, (yomiContext)d->modec); + return 0; +} + + +inline int +TbChooseChar(uiContext d, int head) +{ + tanContext tan = (tanContext)d->modec; + + if (!head) { + int len = WStrlen(tan->kanji); + tan->kanji[0] = tan->kanji[len - 1]; + } + tan->yomi[0] = tan->roma[0] = tan->kanji[0]; + tan->yomi[1] = tan->roma[1] = tan->kanji[1] = (WCHAR_T)0; + tan->rAttr[0] = SENTOU; + tan->kAttr[0] = SENTOU | HENKANSUMI; + tan->rAttr[1] = tan->kAttr[1] = 0; + + makeKanjiStatusReturn(d, (yomiContext)tan); + return 0; +} + +static int +TanChooseChar(uiContext d, int head) +{ + int retval, len; + yomiContext yc = (yomiContext)d->modec; +#ifndef WIN + WCHAR_T xxx[ROMEBUFSIZE]; +#else + WCHAR_T *xxx; +#endif + + if (yc->id != YOMI_CONTEXT) { + return TbChooseChar(d, head); + } +#ifdef WIN + xxx = (WCHAR_T *)malloc(sizeof(WCHAR_T) * ROMEBUFSIZE); + if (!xxx) { + return 0; + } +#endif + RkwGoTo(yc->context, yc->curbun); + len = RkwGetKanji(yc->context, xxx, ROMEBUFSIZE); + if (len >= 0) { + retval = TanBubunMuhenkan(d); + if (retval >= 0) { + tanContext tan; + yc = (yomiContext)d->modec; + tan = newTanContext(yc->majorMode, CANNA_MODE_TankouhoMode); + if (tan) { + copyYomiinfo2Tan(yc, tan); + tan->kanji = DUpwstr(xxx + (head ? 0 : len - 1), 1); + tan->yomi = DUpwstr(yc->kana_buffer, yc->kEndp); + tan->roma = DUpwstr(yc->romaji_buffer, yc->rEndp); + tan->kAttr = DUpattr(yc->kAttr, yc->kEndp); + tan->rAttr = DUpattr(yc->rAttr, yc->rEndp); + tan->right = yc->right; + if (tan->right) tan->right->left = tan; + yc->right = tan; + tan->left = (tanContext)yc; + removeCurrentBunsetsu(d, (tanContext)yc); + makeKanjiStatusReturn(d, (yomiContext)tan); + goto done; + } + } + } + retval = NothingChangedWithBeep(d); + done: +#ifdef WIN + free(xxx); +#endif + return retval; +} + +static TanChooseHeadChar (uiContext); +static TanChooseTailChar (uiContext); + +static +TanChooseHeadChar(uiContext d) +{ + return TanChooseChar(d, 1); +} + +static +TanChooseTailChar(uiContext d) +{ + return TanChooseChar(d, 0); +} + +#include "tanmap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/hex.c b/src/add-ons/input_server/methods/canna/lib/hex.c new file mode 100644 index 0000000000..261d590ec3 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/hex.c @@ -0,0 +1,161 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: hex.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#ifndef NO_EXTEND_MENU +#include "canna.h" + +#define HEXPROMPT "\245\263\241\274\245\311: " +#define HEXPROMPTLEN 5 /* "¥³¡¼¥É: " ¤ÎŤµ¤Ï5¥Ð¥¤¥È */ + +static hexEveryTimeCatch(uiContext d, int retval, mode_context env); +static exitHex(uiContext d, int retval, mode_context env); +static quitHex(uiContext d, int retval, mode_context env); +static hexMode(uiContext d, int major_mode); + +static int quitHex(); + +/* cfuncdef + + hexEveryTimeCatch -- ÆÉ¤ß¤ò£±£¶¿ÊÆþÎϥ⡼¥É¤Çɽ¼¨¤¹¤ë´Ø¿ô + + */ + +static +hexEveryTimeCatch(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + yomiContext yc = (yomiContext)d->modec; + static WCHAR_T buf[256]; + /* ??? ¤³¤Î¤è¤¦¤Ê¥Ð¥Ã¥Õ¥¡¤ò¤¤¤í¤¤¤í¤ÊÉôʬ¤Ç»ý¤Ä¤Î¤Ï¹¥¤Þ¤·¤¯¤Ê¤¤¤Î¤Ç¡¢ + uiContext ¤Ë¤Þ¤È¤á¤Æ»ý¤Ã¤Æ¶¦Í­¤·¤Æ»È¤Ã¤¿Êý¤¬Îɤ¤ */ + int codelen = d->kanji_status_return->length; + + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + + if (codelen >= 0) { + MBstowcs(buf, HEXPROMPT, 256); + WStrncpy(buf + HEXPROMPTLEN, d->kanji_status_return->echoStr, codelen); + d->kanji_status_return->gline.line = buf; + d->kanji_status_return->gline.length = codelen + HEXPROMPTLEN; + d->kanji_status_return->gline.revPos = + d->kanji_status_return->revPos + HEXPROMPTLEN; + d->kanji_status_return->gline.revLen = d->kanji_status_return->revLen; + d->kanji_status_return->info |= KanjiGLineInfo; + echostrClear(d); + if (codelen == 4) { /* £´Ê¸»ú¤Ë¤Ê¤Ã¤¿¤È¤­¤Ë¤Ï.... */ + if (convertAsHex(d)) { + yc->allowedChars = CANNA_NOTHING_ALLOWED; + *(d->kanji_status_return->echoStr = yc->kana_buffer + yc->kEndp + 1) + = *(d->buffer_return); + d->kanji_status_return->revPos = d->kanji_status_return->revLen = 0; + d->kanji_status_return->length = 1; + retval = 0; + if (cannaconf.hexCharacterDefiningStyle != HEX_USUAL) { + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = CANNA_FN_Kakutei; + } + }else{ + CannaBeep(); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = CANNA_FN_DeletePrevious; + } + } + else { + yc->allowedChars = CANNA_ONLY_HEX; + } + } + checkGLineLen(d); + return retval; +} + +static +exitHex(uiContext d, int retval, mode_context env) +{ + killmenu(d); + if (cvtAsHex(d, d->buffer_return, d->buffer_return, d->nbytes)) { + GlineClear(d); + popCallback(d); + retval = YomiExit(d, 1); + currentModeInfo(d); + return retval; + } + else { + return quitHex(d, 0, env); + } +} + +static int +quitHex(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + GlineClear(d); + popCallback(d); + currentModeInfo(d); + return prevMenuIfExist(d); +} + +yomiContext GetKanjiString(); + +static +hexMode(uiContext d, int major_mode) +{ + yomiContext yc; + + yc = GetKanjiString(d, (WCHAR_T *)NULL, 0, + CANNA_ONLY_HEX, + (int)CANNA_YOMI_CHGMODE_INHIBITTED, + (int)CANNA_YOMI_END_IF_KAKUTEI, + CANNA_YOMI_INHIBIT_ALL, + hexEveryTimeCatch, exitHex, quitHex); + if (yc == (yomiContext)0) { + return NoMoreMemory(); + } + yc->majorMode = major_mode; + yc->minorMode = CANNA_MODE_HexMode; + currentModeInfo(d); + return 0; +} + +/* cfuncdef + + HexMode -- £±£¶¿ÊÆþÎϥ⡼¥É¤Ë¤Ê¤ë¤È¤­¤Ë¸Æ¤Ð¤ì¤ë¡£ + + */ + +HexMode(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + + return hexMode(d, CANNA_MODE_HexMode); +} + +#endif /* NO_EXTEND_MENU */ diff --git a/src/add-ons/input_server/methods/canna/lib/ichiran.c b/src/add-ons/input_server/methods/canna/lib/ichiran.c new file mode 100644 index 0000000000..f040122e79 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/ichiran.c @@ -0,0 +1,1654 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: ichiran.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +extern int TanNextKouho(); + +static void clearIchiranContext(); +static int IchiranKakutei(); +static void getIchiranPreviousKouhoretsu(); +static void getIchiranNextKouhoretsu(); + + +#define ICHISIZE 9 + +static void makeIchiranEchoStrCurChange(yomiContext yc); +static void makeIchiranKanjiStatusReturn(uiContext d, mode_context env, yomiContext yc); +static ichiranEveryTimeCatch(uiContext d, int retval, mode_context env); +static ichiranExitCatch(uiContext d, int retval, mode_context env); +static ichiranQuitCatch(uiContext d, int retval, mode_context env); +static void popIchiranMode(uiContext d); +static void clearIchiranContext(ichiranContext p); +static int makeKouhoIchiran(uiContext d, int nelem, int bangomax, unsigned char inhibit, int currentkouho); +static IchiranKakuteiThenDo(uiContext d, int func); +static IchiranQuitThenDo(uiContext d, int func); +static IchiranConvert(uiContext d); +static void getIchiranPreviousKouhoretsu(uiContext d); +static IchiranNextPage(uiContext d); +static IchiranPreviousPage(uiContext d); +static void getIchiranNextKouhoretsu(uiContext d); +static IchiranBangoKouho(uiContext d); +static int getIchiranBangoKouho(uiContext d); +static IchiranKakutei(uiContext d); +static IchiranExtendBunsetsu(uiContext d); +static IchiranShrinkBunsetsu(uiContext d); +static IchiranAdjustBunsetsu(uiContext d); +static IchiranKillToEndOfLine(uiContext d); +static IchiranDeleteNext(uiContext d); +static IchiranBubunMuhenkan(uiContext d); +static IchiranHiragana(uiContext d); +static IchiranKatakana(uiContext d); +static IchiranZenkaku(uiContext d); +static IchiranHankaku(uiContext d); +static IchiranRomaji(uiContext d); +static IchiranToUpper(uiContext d); +static IchiranToLower(uiContext d); +static IchiranCapitalize(uiContext d); +static IchiranKanaRotate(uiContext d); +static IchiranRomajiRotate(uiContext d); +static IchiranCaseRotateForward(uiContext d); +static char *sbango = + "\243\261\241\241\243\262\241\241\243\263\241\241\243\264\241\241\243\265" + "\241\241\243\266\241\241\243\267\241\241\243\270\241\241\243\271\241\241" + "\243\341\241\241\243\342\241\241\243\343\241\241\243\344\241\241\243\345" + "\241\241\243\346"; + /* £±¡¡£²¡¡£³¡¡£´¡¡£µ¡¡£¶¡¡£·¡¡£¸¡¡£¹¡¡£á¡¡£â¡¡£ã¡¡£ä¡¡£å¡¡£æ */ + /* ¸õÊä¹Ô¤Î¸õÊäÈÖ¹æ¤Îʸ»úÎó */ +static WCHAR_T *bango; + +/* "1.","¡¡2.","¡¡3.","¡¡4.","¡¡5.","¡¡6.","¡¡7.","¡¡8.","¡¡9.",*/ +static char *sbango2[] = { + "1","\241\2412","\241\2413","\241\2414","\241\2415", + "\241\2416","\241\2417","\241\2418","\241\2419", + }; + +static WCHAR_T *bango2[ICHISIZE]; + +static char *skuuhaku = "\241\241"; + /* ¡¡ */ +static WCHAR_T *kuuhaku; + +initIchiran(void) +{ + int i, retval = 0; + char buf[16]; + + retval = setWStrings(&bango, &sbango, 1); + if (retval != NG) { + for(i = 0; i < ICHISIZE; i++) { + + /* ¥»¥Ñ¥ì¡¼¥¿¡¼¤Î½èÍý */ + if (cannaconf.indexSeparator && + 0x20 <= cannaconf.indexSeparator && + 0x80 > cannaconf.indexSeparator) + sprintf(buf, "%s%c", sbango2[i], (char)cannaconf.indexSeparator); + else + sprintf(buf, "%s%c", sbango2[i], (char)DEFAULTINDEXSEPARATOR); + + bango2[i] = WString(buf); + } + + retval = setWStrings(&kuuhaku, &skuuhaku, 1); + } + return retval; +} + + +/* + * °ìÍ÷¹Ôɽ¼¨Ãæ¤Î¥«¥ì¥ó¥ÈʸÀá¤Î¸õÊä¤ò¹¹¿·¤¹¤ë + * + * ¡¦¥«¥ì¥ó¥È¸õÊä¤òÊѤ¨¤ë¡£ + * ¡¦¤³¤ì¤Ë¤È¤â¤Ê¤¤ kugiri ¤â¹¹¿·¤µ¤ì¤ë + * + * °ú¤­¿ô uiContext + * yomiContext + */ +static void +makeIchiranEchoStrCurChange(yomiContext yc) +{ + RkwXfer(yc->context, yc->curIkouho); +} + +/* + * ¤«¤Ê´Á»úÊÑ´¹ÍѤι½Â¤ÂÎ¤ÎÆâÍÆ¤ò¹¹¿·¤¹¤ë(¤½¤Î¾ì¤Î¤ß) + * + * ¡¦°ìÍ÷¤ò¸Æ¤Ó½Ð¤¹Á°¤Î¾õÂ֤ˤĤ¤¤Æ¤Îɽ¼¨Ê¸»úÎó¤òºî¤ë + * + * °ú¤­¿ô uiContext + * yomiContext + */ +static void +makeIchiranKanjiStatusReturn(uiContext d, mode_context env, yomiContext yc) +{ + mode_context sv; + + sv = d->modec; + d->modec = env; + makeKanjiStatusReturn(d, yc); + d->modec = sv; +} + +#define DEC_COLUMNS(n) ((n) < 10 ? 1 : (n) < 100 ? 2 : (n) < 1000 ? 3 : 4) + +/* + * ¸õÊä¹Ô¤Ë´Ø¤¹¤ë¹½Â¤ÂÎ¤ÎÆâÍÆ¤ò¹¹¿·¤¹¤ë + * + * ¡¦glineinfo ¤È kouhoinfo ¤«¤é¸õÊä¹Ô¤òºîÀ®¤·¡¢¥«¥ì¥ó¥È¸õÊäÈÖ¹æ¤òȿž¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ ¤Ê¤· + */ +void +makeGlineStatus(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + WCHAR_T *p; + char str[16]; + int i, cur; + + if (cannaconf.kCount) { + cur = *(ic->curIkouho) + 1; + } + + d->kanji_status_return->info |= KanjiGLineInfo; + d->kanji_status_return->gline.line = + ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].gldata; + d->kanji_status_return->gline.length = + ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].gllen; + d->kanji_status_return->gline.revPos = + ic->kouhoifp[*(ic->curIkouho)].khpoint; + if (cannaconf.ReverseWord && ic->inhibit & NUMBERING) { + p = ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].gldata + + ic->kouhoifp[*(ic->curIkouho)].khpoint; + for (i = 0; + *p != *kuuhaku && *p != ((WCHAR_T)' ') && *p != ((WCHAR_T)0) + && i < ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].gllen; + i++) { + p++; + } + d->kanji_status_return->gline.revLen = i; + } else + d->kanji_status_return->gline.revLen = 1; + + if (cannaconf.kCount && d->kanji_status_return->gline.length) { + register int a = ic->nIkouho, b = DEC_COLUMNS(cur) + DEC_COLUMNS(a) + 2; + sprintf(str, " %d/%d", cur, a); + MBstowcs(d->kanji_status_return->gline.line + + d->kanji_status_return->gline.length - b, str, b + 1); + /* °Ê²¼¤Ï¤¤¤é¤Ê¤¤¤Î¤Ç¤Ï¡© */ + d->kanji_status_return->gline.length + = WStrlen(d->kanji_status_return->gline.line); + } +} + +static ichiranEveryTimeCatch (uiContext, int, mode_context); + +static +ichiranEveryTimeCatch(uiContext d, int retval, mode_context env) +{ + yomiContext yc; + + yc = (yomiContext)env; + + makeIchiranEchoStrCurChange(yc); + makeIchiranKanjiStatusReturn(d, env, yc); + + return(retval); +} + +static ichiranExitCatch (uiContext, int, mode_context); + +static +ichiranExitCatch(uiContext d, int retval, mode_context env) +{ + yomiContext yc; + + yc = (yomiContext)env; + yc->kouhoCount = 0; + /* d->curIkouho¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë */ + if ((retval = RkwXfer(yc->context, yc->curIkouho)) == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\245\253\245\354\245\363\245\310\270\365\312\344\244\362" + "\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307" + "\244\267\244\277"; + /* ¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + /* ¥«¥ì¥ó¥È¸õÊ䤬¼è¤ê½Ð¤»¤Ê¤¤¤¯¤é¤¤¤Ç¤Ï²¿¤È¤â¤Ê¤¤¤¾ */ + } + else { + retval = d->nbytes = 0; + } + + makeIchiranEchoStrCurChange(yc); + makeIchiranKanjiStatusReturn(d, env, yc); + + freeGetIchiranList(yc->allkouho); + + popCallback(d); + + if (!cannaconf.stayAfterValidate && !d->more.todo) { + d->more.todo = 1; + d->more.ch = 0; + d->more.fnum = CANNA_FN_Forward; + } + currentModeInfo(d); + + return(retval); +} + +static ichiranQuitCatch (uiContext, int, mode_context); + +static +ichiranQuitCatch(uiContext d, int retval, mode_context env) +{ + yomiContext yc; + + yc = (yomiContext)env; + yc->kouhoCount = 0; + + if ((retval = RkwXfer(yc->context, yc->curIkouho)) == NG) { + if(errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\245\253\245\354\245\363\245\310\270\365\312\344\244\362" + "\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307" + "\244\267\244\277"; + /* ¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + /* ¥«¥ì¥ó¥È¸õÊ䤬¼è¤ê½Ð¤»¤Ê¤¤¤¯¤é¤¤¤Ç¤Ï²¿¤È¤â¤Ê¤¤¤¾ */ + } + else { + retval = d->nbytes = 0; + } + + makeIchiranEchoStrCurChange(yc); + makeIchiranKanjiStatusReturn(d, env, yc); + + freeGetIchiranList(yc->allkouho); + + popCallback(d); + currentModeInfo(d); + return(retval); +} + +void +freeIchiranBuf(ichiranContext ic) +{ + if(ic->glinebufp) + free(ic->glinebufp); + if(ic->kouhoifp) + free(ic->kouhoifp); + if(ic->glineifp) + free(ic->glineifp); +} + +void +freeGetIchiranList(WCHAR_T **buf) +{ + /* ¸õÊä°ìÍ÷ɽ¼¨¹ÔÍѤΥ¨¥ê¥¢¤ò¥Õ¥ê¡¼¤¹¤ë */ + if(buf) { + if(*buf) { + free(*buf); + } + free(buf); + } +} + +static void +popIchiranMode(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + d->modec = ic->next; + d->current_mode = ic->prevMode; + freeIchiranContext(ic); +} + +/* + * ¤¹¤Ù¤Æ¤Î¸õÊä¤ò¼è¤ê½Ð¤·¤Æ¡¢ÇÛÎó¤Ë¤¹¤ë + */ + + +WCHAR_T ** +getIchiranList(int context, int *nelem, int *currentkouho) +{ + WCHAR_T *work, *wptr, **bptr, **buf; + RkStat st; + int i; + + /* RkwGetKanjiList ¤ÇÆÀ¤ë¡¢¤¹¤Ù¤Æ¤Î¸õÊä¤Î¤¿¤á¤ÎÎΰè¤òÆÀ¤ë */ + if ((work = (WCHAR_T *)malloc(ROMEBUFSIZE * sizeof(WCHAR_T))) + == (WCHAR_T *)NULL) { +#ifndef WIN + jrKanjiError = "malloc (getIchiranList) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (getIchiranList) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; +#endif + return (WCHAR_T **)NULL; + } + + /* ¤¹¤Ù¤Æ¤Î¸õÊä¤òÆÀ¤ë¡£ + Îã: ¤±¤¤¤«¤ó ¢ª ·Ù´±@·Ê´Ñ@³Ý´§@@ (@¤ÏNULL) */ + if((*nelem = RkwGetKanjiList(context, work, ROMEBUFSIZE)) < 0) { + jrKanjiError = "\244\271\244\331\244\306\244\316\270\365\312\344\244\316" + "\274\350\244\352\275\320\244\267\244\313\274\272\307\324\244\267" + "\244\336\244\267\244\277"; + /* ¤¹¤Ù¤Æ¤Î¸õÊä¤Î¼è¤ê½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + free(work); + return (WCHAR_T **)NULL; + } + +#ifdef INHIBIT_DUPLICATION + if (*nelem == 3) { + WCHAR_T *w1, *w2, *w3; + + w1 = work; + w2 = w1 + WStrlen(w1); + w3 = w2 + WStrlen(w2); + if (!WStrcmp(w1, ++w3)) { + if (!WStrcmp(w1, ++w2)) + *nelem = 1; + else + *nelem = 2; + } + } +#endif /* INHIBIT_DUPLICATION */ + + /* makeKouhoIchiran()¤ËÅϤ¹¥Ç¡¼¥¿ */ + if((buf = (WCHAR_T **)calloc + (*nelem + 1, sizeof(WCHAR_T *))) == (WCHAR_T **)NULL) { + jrKanjiError = "malloc (getIchiranList) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + free(work); + return (WCHAR_T **)NULL; + } + for(wptr = work, bptr = buf, i = 0; *wptr && i++ < *nelem; bptr++) { + *bptr = wptr; + while(*wptr++) + /* EMPTY */ + ; + } + *bptr = (WCHAR_T *)0; + + if(RkwGetStat(context, &st) == -1) { + jrKanjiError = "\245\271\245\306\245\244\245\277\245\271\244\362\274\350" + "\244\352\275\320\244\273\244\336\244\273\244\363\244\307\244\267" + "\244\277"; + /* ¥¹¥Æ¥¤¥¿¥¹¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + free(work); + free(buf); + return (WCHAR_T **)NULL; + } + *currentkouho = st.candnum; /* ¥«¥ì¥ó¥È¸õÊä¤Ï²¿ÈÖÌÜ¡© */ + + return(buf); +} + +/* cfunc ichiranContext + * + * ichiranContext ¸õÊä°ìÍ÷ÍѤι½Â¤ÂΤòºî¤ê½é´ü²½¤¹¤ë + * + */ +ichiranContext +newIchiranContext(void) +{ + ichiranContext icxt; + + if ((icxt = (ichiranContext)malloc(sizeof(ichiranContextRec))) + == (ichiranContext)NULL) { +#ifndef WIN + jrKanjiError = "malloc (newIchiranContext) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (newIchiranContext) \244\307\244\255\244\336" + "\244\273\244\363\244\307\244\267\244\277"; +#endif + return (ichiranContext)NULL; + } + clearIchiranContext(icxt); + + return icxt; +} + +/* + * ¸õÊä°ìÍ÷¹Ô¤òºî¤ë + */ + +int +selectOne(uiContext d, WCHAR_T **buf, int *ck, int nelem, int bangomax, unsigned inhibit, int currentkouho, int allowcallback, canna_callback_t everyTimeCallback, canna_callback_t exitCallback, canna_callback_t quitCallback, canna_callback_t auxCallback) +{ + extern KanjiModeRec ichiran_mode; + ichiranContext ic; + + if (allowcallback != WITHOUT_LIST_CALLBACK && + d->list_func == NULL) { + allowcallback = WITHOUT_LIST_CALLBACK; + } + + if(pushCallback(d, d->modec, + everyTimeCallback, exitCallback, quitCallback, auxCallback) == 0) { + jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + return(NG); + } + + if((ic = newIchiranContext()) == (ichiranContext)NULL) { + popCallback(d); + return(NG); + } + ic->majorMode = d->majorMode; + ic->next = d->modec; + d->modec = (mode_context)ic; + + ic->prevMode = d->current_mode; + d->current_mode = &ichiran_mode; + d->flags &= ~(PLEASE_CLEAR_GLINE | PCG_RECOGNIZED); + /* ¤³¤³¤Ë¤¯¤ëľÁ°¤Ë C-t ¤È¤«¤¬ Gline ¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¾å¤Î£±¹Ô¤ò + ¤ä¤ëɬÍפ¬½Ð¤Æ¤¯¤ë¡£ */ + + ic->allkouho = buf; + ic->curIkouho = ck; + ic->inhibit = inhibit; + ic->nIkouho = nelem; + + if (allowcallback != WITHOUT_LIST_CALLBACK) { + ic->flags |= ICHIRAN_ALLOW_CALLBACK; + /* listcallback ¤Ç¤ÏÈÖ¹æ¤Ï¤Ä¤±¤Ê¤¤ */ + ic->inhibit |= NUMBERING; + } + + if (allowcallback == WITHOUT_LIST_CALLBACK) { + if (makeKouhoIchiran(d, nelem, bangomax, inhibit, currentkouho) == NG) { + popIchiranMode(d); + popCallback(d); + return(NG); + } + } + else { + if (cannaconf.kCount) { + *(ic->curIkouho) += currentkouho; + if (*(ic->curIkouho) >= ic->nIkouho) + ic->svIkouho = *(ic->curIkouho) = 0; + } + d->list_func(d->client_data, CANNA_LIST_Start, buf, nelem, ic->curIkouho); + } + + return(0); +} + +/* + * IchiranContext ¤Î½é´ü²½ + */ +static void +clearIchiranContext(ichiranContext p) +{ + p->id = ICHIRAN_CONTEXT; + p->svIkouho = 0; + p->curIkouho = 0; + p->nIkouho = 0; + p->tooSmall = 0; + p->curIchar = 0; + p->allkouho = 0; + p->glinebufp = 0; + p->kouhoifp = (kouhoinfo *)0; + p->glineifp = (glineinfo *)0; + p->flags = (unsigned char)0; +} + +/* + * ¸õÊä°ìÍ÷¤Î¥Ç¡¼¥¿¹½Â¤ÂΤòºî¤ë¤¿¤á¤ÎÎΰè¤ò³ÎÊݤ¹¤ë + */ +allocIchiranBuf(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + int size; + + /* ¥µ¥¤¥º¤Îʬ¤ÈÈÖ¹æ¤Îʬ¤ÎÎΰè¤òÆÀ¤ë*/ + size = ic->nIkouho * (d->ncolumns + 1) * WCHARSIZE; /* ¤¨¤¤¤ä¤Ã */ + if((ic->glinebufp = (WCHAR_T *)malloc(size)) == (WCHAR_T *)NULL) { + jrKanjiError = "malloc (allocIchiranBuf) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + return(NG); + } + + /* kouhoinfo¤ÎÎΰè¤òÆÀ¤ë */ + size = (ic->nIkouho + 1) * sizeof(kouhoinfo); + if((ic->kouhoifp = (kouhoinfo *)malloc(size)) == (kouhoinfo *)NULL) { + jrKanjiError = "malloc (allocIchiranBuf) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + free(ic->glinebufp); + return(NG); + } + + /* glineinfo¤ÎÎΰè¤òÆÀ¤ë */ + size = (ic->nIkouho + 1) * sizeof(glineinfo); + if((ic->glineifp = (glineinfo *)malloc(size)) == (glineinfo *)NULL) { + jrKanjiError = "malloc (allocIchiranBuf) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + free(ic->glinebufp); + free(ic->kouhoifp); + return(NG); + } + return(0); +} + +/* + * ¸õÊä°ìÍ÷¹Ô¤òɽ¼¨ÍѤΥǡ¼¥¿¤ò¥Æ¡¼¥Ö¥ë¤ËºîÀ®¤¹¤ë + * + * ¡¦glineinfo ¤È kouhoinfo¤òºîÀ®¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static int +makeKouhoIchiran(uiContext d, int nelem, int bangomax, unsigned char inhibit, int currentkouho) +{ + ichiranContext ic = (ichiranContext)d->modec; + WCHAR_T **kkptr, *kptr, *gptr, *svgptr; + int ko, lnko, cn = 0, svcn, line = 0, dn = 0, svdn; + int netwidth; + + netwidth = d->ncolumns - + (cannaconf.kCount ? (DEC_COLUMNS(nelem) * 2 + 2/* 2¤Ï/¤ÈSP¤Îʬ */) : 0); + + ic->nIkouho = nelem; /* ¸õÊä¤Î¿ô */ + + /* ¥«¥ì¥ó¥È¸õÊä¤ò¥»¥Ã¥È¤¹¤ë */ + ic->svIkouho = *(ic->curIkouho); + *(ic->curIkouho) += currentkouho; + if(*(ic->curIkouho) >= ic->nIkouho) + ic->svIkouho = *(ic->curIkouho) = 0; + + if(allocIchiranBuf(d) == NG) + return(NG); + + if(d->ncolumns < 1) { + ic->tooSmall = 1; + return(0); + } + + /* glineinfo¤Èkouhoinfo¤òºî¤ë */ + /* + ¡öglineinfo¡ö + int glkosu : int glhead : int gllen : WCHAR_T *gldata + £±¹Ô¤Î¸õÊä¿ô : ÀèÆ¬¸õÊ䤬 : £±¹Ô¤ÎŤµ : ¸õÊä°ìÍ÷¹Ô¤Îʸ»úÎó + : ²¿ÈÖÌܤθõÊ䤫 : + ------------------------------------------------------------------------- + 0 | 6 : 0 : 24 : £±¿·£²¿´£³¿Ê£´¿¿£µ¿À£¶¿® + 1 | 4 : 6 : 16 : £±¿Ã£²¿²£³¿­£´¿Ä + + ¡ökouhoinfo¡ö + int khretsu : int khpoint : WCHAR_T *khdata + ¤Ê¤óÎóÌÜ¤Ë : ¹Ô¤ÎÀèÆ¬¤«¤é : ¸õÊä¤Îʸ»úÎó + ¤¢¤ë¸õÊ䤫 : ²¿¥Ð¥¤¥ÈÌܤ« : + ------------------------------------------------------------------------- + 0 | 0 : 0 : ¿· + 1 | 0 : 4 : ¿´ + : : : + 7 | 1 : 0 : ¿Ã + 8 | 1 : 4 : ¿² + */ + + kkptr = ic->allkouho; + kptr = *(ic->allkouho); + gptr = ic->glinebufp; + + /* line -- ²¿ÎóÌܤ« + ko -- Á´ÂΤÎÀèÆ¬¤«¤é²¿ÈÖÌܤθõÊ䤫 + lnko -- Îó¤ÎÀèÆ¬¤«¤é²¿ÈÖÌܤθõÊ䤫 + cn -- Îó¤ÎÀèÆ¬¤«¤é²¿¥Ð¥¤¥ÈÌܤ« */ + + for(line=0, ko=0; konIkouho; line++) { + ic->glineifp[line].gldata = gptr; /* ¸õÊä¹Ô¤òɽ¼¨¤¹¤ë¤¿¤á¤Îʸ»úÎó */ + ic->glineifp[line].glhead = ko; /* ¤³¤Î¹Ô¤ÎÀèÆ¬¸õÊä¤Ï¡¢Á´ÂΤǤÎkoÈÖÌÜ */ + + ic->tooSmall = 1; + for (lnko = cn = dn = 0 ; + dn < netwidth && lnko < bangomax && ko < ic->nIkouho ; lnko++, ko++) { + ic->tooSmall = 0; + kptr = kkptr[ko]; + ic->kouhoifp[ko].khretsu = line; /* ²¿¹ÔÌܤ˸ºß¤¹¤ë¤«¤òµ­Ï¿ */ + ic->kouhoifp[ko].khpoint = cn + (lnko ? 1 : 0); + ic->kouhoifp[ko].khdata = kptr; /* ¤½¤Îʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ */ + svgptr = gptr; + svcn = cn; + svdn = dn; + /* £²¼ïÎà¤Îɽ¼¨¤òʬ¤±¤ë */ + if(!(inhibit & (unsigned char)NUMBERING)) { + /* ÈÖ¹æ¤ò¥³¥Ô¡¼¤¹¤ë */ + if (!cannaconf.indexHankaku) {/* Á´³Ñ */ + if(lnko == 0) { + *gptr++ = *bango; cn ++; dn +=2; + } else { + WStrncpy(gptr, bango + 1 + BANGOSIZE * (lnko - 1), BANGOSIZE); + cn += BANGOSIZE; gptr += BANGOSIZE, dn += BANGOSIZE*2; + } + } + else{ /* Ⱦ³Ñ */ + WStrcpy(gptr, bango2[lnko]); + if(lnko == 0) { + dn +=2; + } else { + dn +=4; + } + cn += WStrlen(bango2[lnko]); + gptr += WStrlen(bango2[lnko]); + } + } else { + /* ¶õÇò¤ò¥³¥Ô¡¼¤¹¤ë */ + if(lnko) { + *gptr++ = *kuuhaku; cn ++; dn +=2; + } + } + /* ¸õÊä¤ò¥³¥Ô¡¼¤¹¤ë */ + for (; *kptr && dn < netwidth ; gptr++, kptr++, cn++) { + *gptr = *kptr; + if (WIsG0(*gptr)) + dn++; + else if (WIsG1(*gptr)) + dn += 2; + else if (WIsG2(*gptr)) + dn ++; + else if (WIsG3(*gptr)) + dn += 2; + } + + /* ¥«¥é¥à¿ô¤è¤ê¤Ï¤ß¤À¤·¤Æ¤·¤Þ¤¤¤½¤¦¤Ë¤Ê¤Ã¤¿¤Î¤Ç£±¤ÄÌ᤹ */ + if (dn >= netwidth) { + if (lnko) { + gptr = svgptr; + cn = svcn; + dn = svdn; + } + else { + ic->tooSmall = 1; + } + break; + } + } + if (ic->tooSmall) { + return 0; + } + if (cannaconf.kCount) { + for (;dn < d->ncolumns - 1; dn++) + *gptr++ = ' '; + } + /* £±¹Ô½ª¤ï¤ê */ + *gptr++ = 0; + ic->glineifp[line].glkosu = lnko; + ic->glineifp[line].gllen = WStrlen(ic->glineifp[line].gldata); + } + + /* ºÇ¸å¤ËNULL¤òÆþ¤ì¤ë */ + ic->kouhoifp[ko].khretsu = 0; + ic->kouhoifp[ko].khpoint = 0; + ic->kouhoifp[ko].khdata = (WCHAR_T *)NULL; + ic->glineifp[line].glkosu = 0; + ic->glineifp[line].glhead = 0; + ic->glineifp[line].gllen = 0; + ic->glineifp[line].gldata = (WCHAR_T *)NULL; + +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { + int i; + for(i=0; ic->glineifp[i].glkosu; i++) + printf("%d: %s\n", i, ic->glineifp[i].gldata); + } +#endif + + return(0); +} + +tanKouhoIchiran(uiContext d, int step) +{ + yomiContext yc = (yomiContext)d->modec; + ichiranContext ic; + int nelem, currentkouho, retval = 0; + unsigned inhibit = 0; + unsigned char listcallback = (unsigned char)(d->list_func ? 1 : 0); + int netwidth; + + netwidth = d->ncolumns - + (cannaconf.kCount ? (DEC_COLUMNS(9999) * 2 + 2/* 2¤Ï / ¤È SP ¤Îʬ */) : 0); + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if (listcallback == 0 && netwidth < 2) { + /* tooSmall */ + return TanNextKouho(d); + } + + /* Ã༡´ØÏ¢ */ + yc->status |= CHIKUJI_OVERWRAP; + + /* ¤¹¤Ù¤Æ¤Î¸õÊä¤ò¼è¤ê½Ð¤¹ */ + yc->allkouho = getIchiranList(yc->context, &nelem, ¤tkouho); + if (yc->allkouho == 0) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + TanMuhenkan(d); + makeGLineMessageFromString(d, jrKanjiError); + return 0; + } + + if (!cannaconf.HexkeySelect) { + inhibit |= (unsigned char)NUMBERING; + } + + yc->curIkouho = currentkouho; /* ¸½ºß¤Î¥«¥ì¥ó¥È¸õÊäÈÖ¹æ¤òÊݸ¤¹¤ë */ + currentkouho = step; /* ¥«¥ì¥ó¥È¸õÊ䤫¤é²¿ÈÖÌܤò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë¤« */ + + /* ¸õÊä°ìÍ÷¤Ë°Ü¹Ô¤¹¤ë */ + if ((retval = selectOne(d, yc->allkouho, &yc->curIkouho, nelem, BANGOMAX, + inhibit, currentkouho, WITH_LIST_CALLBACK, + ichiranEveryTimeCatch, ichiranExitCatch, + ichiranQuitCatch, NO_CALLBACK)) == NG) { + freeGetIchiranList(yc->allkouho); + return GLineNGReturn(d); + } + + ic = (ichiranContext)d->modec; + if (ic->tooSmall) { + freeGetIchiranList(yc->allkouho); + popIchiranMode(d); + popCallback(d); + return TanNextKouho(d); + } + + ic->minorMode = CANNA_MODE_IchiranMode; + currentModeInfo(d); + + if ( !(ic->flags & ICHIRAN_ALLOW_CALLBACK) ) { + makeGlineStatus(d); + } + /* d->status = EVERYTIME_CALLBACK; */ + + return(retval); +} + +/* + * ¸õÊä°ìÍ÷¹Ô¤Îɽ¼¨¤ò¶¯À©½ªÎ»¤¹¤ë + */ +IchiranQuit(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + int retval = 0; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + if (ic->flags & ICHIRAN_NEXT_EXIT) { + d->list_func(d->client_data, + CANNA_LIST_Select, (WCHAR_T **)0, 0, (int *)0); + } + else { + d->list_func(d->client_data, + CANNA_LIST_Quit, (WCHAR_T **)0, 0, (int *)0); + } + } + + if (ic->flags & ICHIRAN_NEXT_EXIT) { + ichiranFin(d); + d->status = EXIT_CALLBACK; + } + else { + *(ic->curIkouho) = ic->nIkouho - 1; /* ¤Ò¤é¤¬¤Ê¸õÊä¤Ë¤¹¤ë */ + ichiranFin(d); + d->status = QUIT_CALLBACK; + } + return(retval); +} + +int +IchiranNop(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if ((ic->flags & ICHIRAN_ALLOW_CALLBACK) && d->list_func) { + (*d->list_func) + (d->client_data, CANNA_LIST_Query, (WCHAR_T **)0, 0, (int *)0); + } + + /* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */ + d->majorMode = d->minorMode = CANNA_MODE_AlphaMode; + currentModeInfo(d); + + if (!(ic->flags & ICHIRAN_ALLOW_CALLBACK)) { + makeGlineStatus(d); + } + return 0; +} + +/* + IchiranKakuteiThenDo + + -- Do determine from the candidate list, then do one more function. + */ + +static +IchiranKakuteiThenDo(uiContext d, int func) +{ + ichiranContext ic = (ichiranContext)d->modec; + int retval; + BYTE ifl = ic->flags; + + if (!ic->prevMode || !ic->prevMode->func || + !(*ic->prevMode->func)((uiContext)0/*dummy*/, ic->prevMode, KEY_CHECK, + 0/*dummy*/, func)) { + return NothingChangedWithBeep(d); + } + retval = IchiranKakutei(d); + if (ifl & ICHIRAN_STAY_LONG) { + (void)IchiranQuit(d); + } + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = func; + return retval; +} + +static +IchiranQuitThenDo(uiContext d, int func) +{ + ichiranContext ic = (ichiranContext)d->modec; + int retval; + + if (!ic->prevMode || !ic->prevMode->func || + !(*ic->prevMode->func)((uiContext)0/*dummy*/, ic->prevMode, KEY_CHECK, + 0/*dummy*/, func)) { + return NothingChangedWithBeep(d); + } + retval = IchiranQuit(d); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = func; + return retval; +} + +/* + * ¼¡¸õÊä¤Ë°Üư¤¹¤ë + * + * ¡¦¥«¥ì¥ó¥È¸õÊ䤬ºÇ½ª¸õÊä¤À¤Ã¤¿¤éÀèÆ¬¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +IchiranForwardKouho(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + int res; + + res = (*d->list_func) + (d->client_data, CANNA_LIST_Forward, (WCHAR_T **)0, 0, (int *)0); + if (res) { + return 0; + } + else { /* CANNA_LIST_Forward was not prepared at the callback func */ + return IchiranKakuteiThenDo(d, CANNA_FN_Forward); + } + } + + /* ¼¡¸õÊä¤Ë¤¹¤ë (ñ¸ì¸õÊä°ìÍ÷¾õÂ֤ǡ¢ºÇ¸å¤Î¸õÊä¤À¤Ã¤¿¤é°ìÍ÷¤ò¤ä¤á¤ë) */ + *(ic->curIkouho) += 1; + if(*(ic->curIkouho) >= ic->nIkouho) { + if (cannaconf.QuitIchiranIfEnd + && (((coreContext)d->modec)->minorMode == CANNA_MODE_IchiranMode)) { + return(IchiranQuit(d)); + } + else if (cannaconf.CursorWrap) { + *(ic->curIkouho) = 0; + } else { + *(ic->curIkouho) -= 1; + return NothingChangedWithBeep(d); + } + } + + if(ic->tooSmall) { /* for bushu */ + d->status = AUX_CALLBACK; + return 0; + } + + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return 0; +} + +/* + * Á°¸õÊä¤Ë°Üư¤¹¤ë + * + * ¡¦¥«¥ì¥ó¥È¸õÊ䤬ÀèÆ¬¸õÊä¤À¤Ã¤¿¤éºÇ½ª¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +IchiranBackwardKouho(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + BYTE mode; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + int res; + res = (*d->list_func) + (d->client_data, CANNA_LIST_Backward, (WCHAR_T **)0, 0, (int *)0); + if (res) { + return 0; + } + else { /* CANNA_LIST_Backward was not prepared at the callback func */ + return IchiranKakuteiThenDo(d, CANNA_FN_Backward); + } + } + + /* ¸½ºß¤Î¥â¡¼¥É¤òµá¤á¤ë */ + if (cannaconf.QuitIchiranIfEnd) + mode = ((coreContext)d->modec)->minorMode; + + /* Á°¸õÊä¤Ë¤¹¤ë (ñ¸ì¸õÊä°ìÍ÷¾õÂ֤ǡ¢ºÇ½é¤Î¸õÊä¤À¤Ã¤¿¤é°ìÍ÷¤ò¤ä¤á¤ë) */ + if(*(ic->curIkouho)) + *(ic->curIkouho) -= 1; + else { + if (cannaconf.QuitIchiranIfEnd && (mode == CANNA_MODE_IchiranMode)) { + return(IchiranQuit(d)); + } + else if (cannaconf.CursorWrap) { + *(ic->curIkouho) = ic->nIkouho - 1; + } else { + *(ic->curIkouho) = 0; + return NothingChangedWithBeep(d); + } + } + + if(ic->tooSmall) { /* for bushu */ + d->status = AUX_CALLBACK; + return 0; + } + + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return 0; +} + +/* + IchiranConvert() will be called when `convert' key is pressed + */ + +static IchiranConvert (uiContext); + +static +IchiranConvert(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && d->list_func) { + (*d->list_func) + (d->client_data, CANNA_LIST_Convert, (WCHAR_T **)0, 0, (int *)0); + return 0; + } + else { + return IchiranForwardKouho(d); + } +} + +/* + * Á°¸õÊäÎó¤Ë°Üư¤¹¤ë + * + * ¡¦¥«¥ì¥ó¥È¸õÊä¤òµá¤á¤Æ¸õÊä°ìÍ÷¤È¤½¤Î¾ì¤Î¸õÊä¤òɽ¼¨¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +IchiranPreviousKouhoretsu(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + int res; + res = (*d->list_func) + (d->client_data, CANNA_LIST_Prev, (WCHAR_T **)0, 0, (int *)0); + if (res) { + return 0; + } + else { /* CANNA_LIST_Backward was not prepared at the callback func */ + return IchiranKakuteiThenDo(d, CANNA_FN_Prev); + } + } + + if(ic->tooSmall) { /* for bushu */ + return(IchiranBackwardKouho(d)); + } + + /* Á°¸õÊäÎó¤Ë¤¹¤ë (*(ic->curIkouho)¤òµá¤á¤ë)*/ + getIchiranPreviousKouhoretsu(d); + + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return 0; +} + +/* + * Á°¸õÊäÎó¤Î¥«¥ì¥ó¥È¸õÊä¤òµá¤á¤ë + * + * ¡¦Á°¸õÊäÎóÃæ¤ÎƱ¤¸¸õÊäÈÖ¹æ¤Î¤â¤Î¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë + * ¡¦¸õÊäÈÖ¹æ¤ÎƱ¤¸¤â¤Î¤¬¤Ê¤¤»þ¤Ï¡¢¤½¤Î¸õÊäÃæ¤ÎºÇ½ª¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static void +getIchiranPreviousKouhoretsu(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + int kindex; + int curretsu, nretsu; + + /* ¥«¥ì¥ó¥È¸õÊä¹Ô¤Î¤Ê¤«¤Ç²¿ÈÖÌܤθõÊ䤫¤Ê¤Î¤«¤òÆÀ¤ë */ + kindex = *(ic->curIkouho) - + ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].glhead; + /* Á°¸õÊäÎó¤òÆÀ¤ë */ + curretsu = ic->kouhoifp[*(ic->curIkouho)].khretsu; + nretsu = ic->kouhoifp[ic->nIkouho - 1].khretsu + 1; + if(curretsu == 0) { + if (cannaconf.CursorWrap) + curretsu = nretsu; + else { + NothingChangedWithBeep(d); + return; + } + } + curretsu -= 1; + /* kindex ¤¬¥«¥ì¥ó¥È¸õÊäÎó¤Î¸õÊä¿ô¤è¤êÂ礭¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¤é + ºÇ±¦¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë */ + if(ic->glineifp[curretsu].glkosu <= kindex) + kindex = ic->glineifp[curretsu].glkosu - 1; + /* Á°¸õÊäÎó¤ÎƱ¤¸ÈÖ¹æ¤Ë°Üư¤¹¤ë */ + *(ic->curIkouho) = kindex + ic->glineifp[curretsu].glhead; + return; +} + +/* + * ¼¡¸õÊäÎó¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +IchiranNextKouhoretsu(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + int res; + res = (*d->list_func) + (d->client_data, CANNA_LIST_Next, (WCHAR_T **)0, 0, (int *)0); + if (res) { + return 0; + } + else { /* CANNA_LIST_Backward was not prepared at the callback func */ + return IchiranKakuteiThenDo(d, CANNA_FN_Next); + } + } + + if(ic->tooSmall) { + return(IchiranForwardKouho(d)); + } + + /* ¼¡¸õÊäÎó¤Ë¤¹¤ë (*(ic->curIkouho) ¤òµá¤á¤ë) */ + getIchiranNextKouhoretsu(d); + + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return 0; +} + +/* + * ¼¡¸õÊäÊÇ¤Ë°ÜÆ°¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +static IchiranNextPage (uiContext); + +static +IchiranNextPage(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + int res; + res = (*d->list_func) + (d->client_data, CANNA_LIST_PageDown, (WCHAR_T **)0, 0, (int *)0); + if (res) { + return 0; + } + else { /* CANNA_LIST_Backward was not prepared at the callback func */ + return IchiranKakuteiThenDo(d, CANNA_FN_PageDown); + } + } + + return IchiranNextKouhoretsu(d); +} + +/* + * Á°¸õÊäÊÇ¤Ë°ÜÆ°¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +static IchiranPreviousPage (uiContext); + +static +IchiranPreviousPage(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + int res; + res = (*d->list_func) + (d->client_data, CANNA_LIST_PageUp, (WCHAR_T **)0, 0, (int *)0); + if (res) { + return 0; + } + else { /* CANNA_LIST_Backward was not prepared at the callback func */ + return IchiranKakuteiThenDo(d, CANNA_FN_PageUp); + } + } + + return IchiranPreviousKouhoretsu(d); +} + +/* + * ¼¡¸õÊäÎó¤Ë°Üư¤¹¤ë + * + * ¡¦¼¡¸õÊäÎóÃæ¤ÎƱ¤¸¸õÊäÈÖ¹æ¤Î¤â¤Î¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë + * ¡¦¸õÊäÈÖ¹æ¤ÎƱ¤¸¤â¤Î¤¬¤Ê¤¤»þ¤Ï¡¢¤½¤Î¸õÊäÃæ¤ÎºÇ½ª¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static void +getIchiranNextKouhoretsu(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + int kindex; + int curretsu, nretsu; + + /* ¥«¥ì¥ó¥È¸õÊä¹Ô¤Î¤Ê¤«¤Ç²¿ÈÖÌܤθõÊ䤫¤Ê¤Î¤«¤òÆÀ¤ë */ + kindex = *(ic->curIkouho) - + ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].glhead; + /* ¼¡¸õÊäÎó¤òÆÀ¤ë */ + curretsu = ic->kouhoifp[*(ic->curIkouho)].khretsu; + nretsu = ic->kouhoifp[ic->nIkouho - 1].khretsu + 1; + curretsu += 1; + if(curretsu >= nretsu) { + if (cannaconf.CursorWrap) + curretsu = 0; + else { + NothingChangedWithBeep(d); + return; + } + } + /* kindex ¤¬¥«¥ì¥ó¥È¸õÊäÎó¤Î¸õÊä¿ô¤è¤êÂ礭¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¤é + ºÇ±¦¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë */ + if(ic->glineifp[curretsu].glkosu <= kindex) + kindex = ic->glineifp[curretsu].glkosu - 1; + /* Á°¸õÊäÎó¤ÎƱ¤¸ÈÖ¹æ¤Ë°Üư¤¹¤ë */ + *(ic->curIkouho) = kindex + ic->glineifp[curretsu].glhead; + return; +} + +/* + * ¸õÊä¹ÔÃæ¤ÎÀèÆ¬¸õÊä¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +IchiranBeginningOfKouho(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + int res; + res = (*d->list_func) + (d->client_data, CANNA_LIST_BeginningOfLine, (WCHAR_T **)0, 0,(int *)0); + if (res) { + return 0; + } + else { /* CANNA_LIST_Backward was not prepared at the callback func */ + return IchiranKakuteiThenDo(d, CANNA_FN_BeginningOfLine); + } + } + + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return 0; + } + + /* ¸õÊäÎó¤ÎÀèÆ¬¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤Ë¤¹¤ë */ + *(ic->curIkouho) = + ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].glhead; + + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return 0; +} + +/* + * ¸õÊä¹ÔÃæ¤ÎºÇ±¦¸õÊä¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +IchiranEndOfKouho(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && + d->list_func) { + int res; + res = (*d->list_func) + (d->client_data, CANNA_LIST_EndOfLine, (WCHAR_T **)0, 0, (int *)0); + if (res) { + return 0; + } + else { /* CANNA_LIST_Backward was not prepared at the callback func */ + return IchiranKakuteiThenDo(d, CANNA_FN_EndOfLine); + } + } + + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return 0; + } + + /* ¸õÊäÎó¤ÎºÇ±¦¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤Ë¤¹¤ë */ + *(ic->curIkouho) = + ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].glhead + + ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].glkosu - 1; + + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return 0; +} + +/* + * ¸õÊä¹ÔÃæ¤ÎÆþÎϤµ¤ì¤¿ÈÖ¹æ¤Î¸õÊä¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +static int getIchiranBangoKouho (uiContext); +static IchiranBangoKouho (uiContext); + +static +IchiranBangoKouho(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + int zflag, retval = 0; + + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return(retval); + } + + /* d->status = EVERYTIME_CALLBACK; */ + + if (cannaconf.HexkeySelect && !(ic->inhibit & NUMBERING)) { + /* ÆþÎϤµ¤ì¤¿ÈÖ¹æ¤Î¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë */ + if((zflag = getIchiranBangoKouho(d)) == NG) + goto insert; + + /* SelectDirect ¤Î¥«¥¹¥¿¥Þ¥¤¥º¤Î½èÍý */ + do_selection: + if (cannaconf.SelectDirect) /* ON */ { + if(zflag) /* £°¤¬ÆþÎϤµ¤ì¤¿ */ + retval = IchiranQuit(d); + else + retval = IchiranKakutei(d); + } else { /* OFF */ + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + } + return(retval); + } + else { +#ifdef CANNA_LIST_Insert /* ÀäÂÐÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤ó¤À¤±¤É¤Í */ + if (ic->flags & ICHIRAN_ALLOW_CALLBACK && d->list_func) { + int res = (*d->list_func) /* list_func ¤ò¸Æ¤Ó½Ð¤¹ */ + (d->client_data, CANNA_LIST_Insert, (WCHAR_T **)0, d->ch, (int *)0); + if (res) { /* d->ch ¤¬¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¦¤Ç½èÍý¤µ¤ì¤¿ */ + if (res == CANNA_FN_FunctionalInsert) { + zflag = 1; /* 0 ¤¸¤ã¤Ê¤±¤ì¤Ð¤¤¤¤ */ + goto do_selection; + } + else if (res != CANNA_FN_Nop) { + /* ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¦¤«¤éÍ׵ᤷ¤ÆÍ褿µ¡Ç½¤ò³¤±¤Æ¼Â¹Ô¤¹¤ë */ + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = CANNA_FN_FunctionalInsert; + } + return 0; + }else{ /* CANNA_LIST_Insert was not processed at the callback func */ + /* continue to the 'insert:' tag.. */ + } + } +#endif + + insert: + if(!(ic->inhibit & CHARINSERT) && cannaconf.allowNextInput) { + BYTE ifl = ic->flags; + retval = IchiranKakutei(d); + if (ifl & ICHIRAN_STAY_LONG) { + (void)IchiranQuit(d); + } + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = CANNA_FN_FunctionalInsert; + } else { + NothingChangedWithBeep(d); + } + return(retval); + } +} + +/* + * ¸õÊä¹ÔÃæ¤ÎÆþÎϤµ¤ì¤¿ÈÖ¹æ¤Î¸õÊä¤Ë°Üư¤¹¤ë + * + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ £°¤¬ÆþÎϤµ¤ì¤¿¤é £±¤òÊÖ¤¹ + * £±¡Á£¹¡¢£á¡Á£æ¤¬ÆþÎϤµ¤ì¤¿¤é £°¤òÊÖ¤¹ + * ¥¨¥é¡¼¤À¤Ã¤¿¤é ¡¼£±¤òÊÖ¤¹ + */ +static int +getIchiranBangoKouho(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + int num, kindex; + + /* ÆþÎϥǡ¼¥¿¤Ï £°¡Á£¹ £á¡Á£æ ¤«¡© */ + if(((0x30 <= d->ch) && (d->ch <= 0x39)) + || ((0x61 <= d->ch) && (d->ch <= 0x66))) { + if((0x30 <= d->ch) && (d->ch <= 0x39)) + num = (int)(d->ch & 0x0f); + else if((0x61 <= d->ch) && (d->ch <= 0x66)) + num = (int)(d->ch - 0x57); + } + else { + /* ÆþÎϤµ¤ì¤¿ÈÖ¹æ¤ÏÀµ¤·¤¯¤¢¤ê¤Þ¤»¤ó */ + return(NG); + } + /* ÆþÎϥǡ¼¥¿¤Ï ¸õÊä¹Ô¤ÎÃæ¤Ë¸ºß¤¹¤ë¿ô¤«¡© */ + if(num > ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].glkosu) { + /* ÆþÎϤµ¤ì¤¿ÈÖ¹æ¤ÏÀµ¤·¤¯¤¢¤ê¤Þ¤»¤ó */ + return(NG); + } + + /* ÆþÎϤµ¤ì¤¿¿ô¤¬£°¤Ç SelectDirect ¤¬ ON ¤Ê¤éÆÉ¤ß¤ËÌᤷ¤Æ£±¤òÊÖ¤¹ */ + if(num == 0) { + if (cannaconf.SelectDirect) + return(1); + else { + /* ÆþÎϤµ¤ì¤¿ÈÖ¹æ¤ÏÀµ¤·¤¯¤¢¤ê¤Þ¤»¤ó */ + return(NG); + } + } else { + /* ¸õÊäÎó¤ÎÀèÆ¬¸õÊä¤òÆÀ¤ë */ + kindex = ic->glineifp[ic->kouhoifp[*(ic->curIkouho)].khretsu].glhead; + *(ic->curIkouho) = kindex + (num - 1); + } + + return(0); +} + +/* + * ¸õÊä¹ÔÃæ¤«¤éÁªÂò¤µ¤ì¤¿¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +// static IchiranKakutei (uiContext); + +static int +IchiranKakutei(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + int retval = 0; + WCHAR_T *kakuteiStrings; + + if ((ic->flags & ICHIRAN_ALLOW_CALLBACK) && d->list_func) { + if (ic->flags & ICHIRAN_STAY_LONG) { + d->list_func(d->client_data, + CANNA_LIST_Query, (WCHAR_T **)0, 0, (int *)0); + } + else { + d->list_func(d->client_data, + CANNA_LIST_Select, (WCHAR_T **)0, 0, (int *)0); + } + } + + kakuteiStrings = ic->allkouho[*(ic->curIkouho)]; + retval = d->nbytes = WStrlen(kakuteiStrings); + WStrcpy(d->buffer_return, kakuteiStrings); + + if (ic->flags & ICHIRAN_STAY_LONG) { + ic->flags |= ICHIRAN_NEXT_EXIT; + d->status = EVERYTIME_CALLBACK; + } + else { + ichiranFin(d); + + d->status = EXIT_CALLBACK; + } + + return(retval); +} + +/* + * ¸õÊä¹Ôɽ¼¨¥â¡¼¥É¤«¤éÈ´¤±¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +void +ichiranFin(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + /* ¸õÊä°ìÍ÷ɽ¼¨¹ÔÍѤΥ¨¥ê¥¢¤ò¥Õ¥ê¡¼¤¹¤ë */ + freeIchiranBuf(ic); + + popIchiranMode(d); + + /* gline ¤ò¥¯¥ê¥¢¤¹¤ë */ + GlineClear(d); +} + +static IchiranExtendBunsetsu (uiContext); + +static +IchiranExtendBunsetsu(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_Extend); +} + +static IchiranShrinkBunsetsu (uiContext); + +static +IchiranShrinkBunsetsu(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_Shrink); +} + +static IchiranAdjustBunsetsu (uiContext); + +static +IchiranAdjustBunsetsu(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_AdjustBunsetsu); +} + +static IchiranKillToEndOfLine (uiContext); + +static +IchiranKillToEndOfLine(uiContext d) +{ + return IchiranKakuteiThenDo(d, CANNA_FN_KillToEndOfLine); +} + +static IchiranDeleteNext (uiContext); + +static +IchiranDeleteNext(uiContext d) +{ + return IchiranKakuteiThenDo(d, CANNA_FN_DeleteNext); +} + +static IchiranBubunMuhenkan (uiContext); + +static +IchiranBubunMuhenkan(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_BubunMuhenkan); +} + +static IchiranHiragana (uiContext); + +static +IchiranHiragana(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_Hiragana); +} + +static IchiranKatakana (uiContext); + +static +IchiranKatakana(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_Katakana); +} + +static IchiranZenkaku (uiContext); + +static +IchiranZenkaku(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_Zenkaku); +} + +static IchiranHankaku (uiContext); + +static +IchiranHankaku(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_Hankaku); +} + +static IchiranRomaji (uiContext); + +static +IchiranRomaji(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_Romaji); +} + +static IchiranToUpper (uiContext); + +static +IchiranToUpper(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_ToUpper); +} + +static IchiranToLower (uiContext); + +static +IchiranToLower(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_ToLower); +} + +static IchiranCapitalize (uiContext); + +static +IchiranCapitalize(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_Capitalize); +} + +static IchiranKanaRotate (uiContext); + +static +IchiranKanaRotate(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_KanaRotate); +} + +static IchiranRomajiRotate (uiContext); + +static +IchiranRomajiRotate(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_RomajiRotate); +} + +static IchiranCaseRotateForward (uiContext); + +static +IchiranCaseRotateForward(uiContext d) +{ + return IchiranQuitThenDo(d, CANNA_FN_CaseRotate); +} + +#include "ichiranmap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/ichiranmap.h b/src/add-ons/input_server/methods/canna/lib/ichiranmap.h new file mode 100644 index 0000000000..e297fba6d2 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/ichiranmap.h @@ -0,0 +1,79 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +// Modified by T.Murai + +#if !defined(lint) && !defined(__CODECENTER__) +static char ichiranmap_id[] = "@(#) 102.1 $Id: ichiranmap.h,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" + +#ifdef WIN +struct funccfunc ichiran_funcs[] = { +#else +static struct funccfunc ichiran_funcs[] = { +#endif + {CANNA_FN_FunctionalInsert ,IchiranBangoKouho }, + {CANNA_FN_Forward ,IchiranForwardKouho }, + {CANNA_FN_Backward ,IchiranBackwardKouho }, + {CANNA_FN_Next ,IchiranNextKouhoretsu }, + {CANNA_FN_Prev ,IchiranPreviousKouhoretsu }, + {CANNA_FN_BeginningOfLine ,IchiranBeginningOfKouho }, + {CANNA_FN_EndOfLine ,IchiranEndOfKouho }, + {CANNA_FN_DeletePrevious ,IchiranQuit }, + {CANNA_FN_Henkan ,IchiranConvert }, + {CANNA_FN_HenkanOrInsert ,IchiranForwardKouho }, + {CANNA_FN_HenkanOrNothing ,IchiranForwardKouho }, + {CANNA_FN_Kakutei ,IchiranKakutei }, + {CANNA_FN_Quit ,IchiranQuit }, + {CANNA_FN_PageUp ,IchiranPreviousPage }, + {CANNA_FN_PageDown ,IchiranNextPage }, + {CANNA_FN_AdjustBunsetsu ,IchiranAdjustBunsetsu }, + {CANNA_FN_Extend ,IchiranExtendBunsetsu }, + {CANNA_FN_Shrink ,IchiranShrinkBunsetsu }, + {CANNA_FN_KillToEndOfLine ,IchiranKillToEndOfLine }, + {CANNA_FN_DeleteNext ,IchiranDeleteNext }, + {CANNA_FN_BubunMuhenkan ,IchiranBubunMuhenkan }, + {CANNA_FN_Hiragana ,IchiranHiragana }, + {CANNA_FN_Katakana ,IchiranKatakana }, + {CANNA_FN_Romaji ,IchiranRomaji }, + {CANNA_FN_ToUpper ,IchiranToUpper }, + {CANNA_FN_ToLower ,IchiranToLower }, + {CANNA_FN_Capitalize ,IchiranCapitalize }, + {CANNA_FN_Zenkaku ,IchiranZenkaku }, + {CANNA_FN_Hankaku ,IchiranHankaku }, + {CANNA_FN_KanaRotate ,IchiranKanaRotate }, + {CANNA_FN_RomajiRotate ,IchiranRomajiRotate }, + {CANNA_FN_CaseRotate ,IchiranCaseRotateForward }, + {CANNA_FN_Nop ,IchiranNop }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {0 ,0 }, +}; + +extern searchfunc(...); +KanjiModeRec ichiran_mode = { + searchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + ichiran_funcs, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/jishu.c b/src/add-ons/input_server/methods/canna/lib/jishu.c new file mode 100644 index 0000000000..bd1a4546d8 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/jishu.c @@ -0,0 +1,958 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: jishu.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include + +extern struct RkRxDic *romajidic, *englishdic; + +extern int WToupper (WCHAR_T); +static void setInhibitInformation (yomiContext); +static void jishuAdjustRome (uiContext), jishuAdjustRome (uiContext); +static int JishuZenkaku(); +static int JishuHankaku(); + +/* yc->jishu_kc ²¿¤Îʸ»ú¼ï¤« + * d->jishu_rEndp + * d->jishu_kEndp + * ¡ÚÎã¡Û + * ¤¢¤¤¤·sh| + * C- ¥¢¥¤¥·sh| + * C- ¥¢¥¤¥·s|h + * C- ¥¢¥¤¥·|sh + * C- ¥¢¥¤|¤·sh + * + * ¤¢¤¤¤·sh| + * C- aishish| + * C- £á£é£ó£è£é£ó£è| + * C- £á£é£ó£è£é£ó|h + * C- £á£é£ó£è£é|sh + * C- £á£é£ó£è|¤¤sh + * C- aish|¤¤sh + * C- ¤¢¤¤sh|¤¤sh + * C- ¥¢¥¤sh|sh + * C- ¥¢¥¤s|¤Òsh + * C- ¥¢¥¤|¤·sh + * C- + * + */ + +#define INHIBIT_HANKATA 0x01 +#define INHIBIT_KANA 0x02 +#define INHIBIT_ALPHA 0x04 +#define INHIBIT_HIRA 0x08 + +static void setInhibitInformation(yomiContext yc); +static inhibittedJishu(uiContext d); +static nextJishu(uiContext d); +static previousJishu(uiContext d); +static JishuNextJishu(uiContext d); +static JishuPreviousJishu(uiContext d); +static JishuRotateWithInhibition(uiContext d, unsigned inhibit); +static JishuKanaRotate(uiContext d); +static JishuRomajiRotate(uiContext d); +static JishuShrink(uiContext d); +static JishuNop(uiContext d); +static JishuExtend(uiContext d); +static void jishuAdjustRome(uiContext d); +static void myjishuAdjustRome(uiContext d); +static JishuZenkaku(uiContext d); +static JishuHankaku(uiContext d); +static exitJishuAndDoSomething(uiContext d, int fnum); +static JishuYomiInsert(uiContext d); +static JishuQuit(uiContext d); +static JishuToUpper(uiContext d); +static JishuCapitalize(uiContext d); +static JishuToLower(uiContext d); +static JishuHiragana(uiContext d); +static JishuKatakana(uiContext d); +static JishuRomaji(uiContext d); +static void nextCase(yomiContext yc); +static JishuCaseRotateForward(uiContext d); +static JishuKanjiHenkan(uiContext d); +static JishuKanjiHenkanOInsert(uiContext d); +static JishuKanjiHenkanONothing(uiContext d); + +void +enterJishuMode(uiContext d, yomiContext yc) +{ + extern KanjiModeRec jishu_mode; + int pos; + + yc->jishu_kc = JISHU_HIRA;/* º£¤Ï¤Ò¤é¤¬¤Ê¥â¡¼¥É¤Ç¤¹ */ + yc->jishu_case = 0; /* Case ÊÑ´¹¤Ê¤·¤Î¥â¡¼¥É¤Ç¤¹ */ + setInhibitInformation(yc); + if (yc->cmark < yc->cStartp) { + yc->cmark = yc->cStartp; + } + if (yc->kCurs == yc->cmark) { + yc->jishu_kEndp = yc->kEndp; + yc->jishu_rEndp = yc->rEndp; + } + else if (yc->kCurs < yc->cmark) { + int rpos; + + yc->jishu_kEndp = yc->cmark; + yc->cmark = yc->kCurs; + yc->kRStartp = yc->kCurs = yc->jishu_kEndp; + kPos2rPos(yc, 0, yc->kCurs, (int *)0, &rpos); + yc->jishu_rEndp = yc->rStartp = yc->rCurs = rpos; + } + else { + yc->jishu_kEndp = yc->kCurs; + yc->jishu_rEndp = yc->rCurs; + } +/* yc->majorMode = d->majorMode; */ + kPos2rPos(yc, 0, (int)yc->cmark, (int *)0, &pos); + yc->rmark = (short)pos; + d->current_mode = yc->curMode = &jishu_mode; +} + +void +leaveJishuMode(uiContext d, yomiContext yc) +{ + extern KanjiModeRec yomi_mode, cy_mode; + + yc->jishu_kEndp = 0; + if (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) { + d->current_mode = yc->curMode = &cy_mode; + } + else { + d->current_mode = yc->curMode = &yomi_mode; + } + yc->minorMode = getBaseMode(yc); + currentModeInfo(d); +} + +static void +setInhibitInformation(yomiContext yc) +{ + int i; + + yc->inhibition = cannaconf.InhibitHankakuKana ? INHIBIT_HANKATA : 0; + for (i = 0 ; i < yc->kEndp ; i++) { + if ( !(yc->kAttr[i] & HENKANSUMI) && WIsG0(yc->kana_buffer[i]) ) { + yc->inhibition |= INHIBIT_KANA; + break; + } + } + for (i = 0 ; i < yc->rEndp ; i++) { + if (!WIsG0(yc->romaji_buffer[i])) { + yc->inhibition |= INHIBIT_ALPHA; + } + } +} + +extractJishuString(yomiContext yc, WCHAR_T *s, WCHAR_T *e, WCHAR_T **sr, WCHAR_T **er) +{ + WCHAR_T *ss = s; + int jishulen, len, revlen; +#ifndef WIN + WCHAR_T xxxx[1024], yyyy[1024]; +#else + WCHAR_T *xxxx, *yyyy; + xxxx = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 1024); + yyyy = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 1024); + if (!xxxx || !yyyy) { + if (xxxx) { + free(xxxx); + } + if (yyyy) { + free(yyyy); + } + return 0; + } +#endif + + if (s + yc->cmark - yc->cStartp < e) { + WStrncpy(s, yc->kana_buffer + yc->cStartp, yc->cmark - yc->cStartp); + s += yc->cmark - yc->cStartp; + } + else { + WStrncpy(s, yc->kana_buffer + yc->cStartp, (int)(e - s)); + s = e; + } + + if ((yc->jishu_kc == JISHU_ZEN_KATA || + yc->jishu_kc == JISHU_HAN_KATA || + yc->jishu_kc == JISHU_HIRA)) { + int i, j, m, n, t, r; + WCHAR_T *p = yyyy; + for (i = yc->cmark ; i < yc->jishu_kEndp ;) { + if (yc->kAttr[i] & STAYROMAJI) { + j = i++; + while (i < yc->jishu_kEndp && (yc->kAttr[i] & STAYROMAJI)) { + i++; + } + t = r = 0; + while (j < i) { + int st = t; + WStrncpy(xxxx + t, yc->kana_buffer + j, i - j); + RkwMapPhonogram(yc->romdic, p, 1024 - (int)(p - yyyy), + xxxx, st + i - j, xxxx[0], + RK_FLUSH | RK_SOKON, &n, &m, &t, &r); + /* RK_SOKON ¤òÉÕ¤±¤ë¤Î¤Ïµì¼­½ñÍÑ */ + p += m; + j += n - st; + WStrncpy(xxxx, p, t); + } + }else{ + *p++ = yc->kana_buffer[i++]; + } + } + jishulen = p - yyyy; + } + + switch (yc->jishu_kc) + { + case JISHU_ZEN_KATA: /* Á´³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤¹¤ë */ + len = RkwCvtZen(xxxx, 1024, yyyy, jishulen); + revlen = RkwCvtKana(s, (int)(e - s), xxxx, len); + break; + + case JISHU_HAN_KATA: /* Ⱦ³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤¹¤ë */ + len = RkwCvtKana(xxxx, 1024, yyyy, jishulen); + revlen = RkwCvtHan(s, (int)(e - s), xxxx, len); + break; + + case JISHU_HIRA: /* ¤Ò¤é¤¬¤Ê¤ËÊÑ´¹¤¹¤ë */ + len = RkwCvtZen(xxxx, 1024, yyyy, jishulen); + revlen = RkwCvtHira(s, (int)(e - s), xxxx, len); + break; + + case JISHU_ZEN_ALPHA: /* Á´³Ñ±Ñ¿ô¤ËÊÑ´¹¤¹¤ë */ + if (yc->jishu_case == CANNA_JISHU_UPPER || + yc->jishu_case == CANNA_JISHU_LOWER || + yc->jishu_case == CANNA_JISHU_CAPITALIZE) { + int i, head = 1; + WCHAR_T *p = yc->romaji_buffer; + + for (i = yc->rmark ; i < yc->jishu_rEndp ; i++) { + xxxx[i - yc->rmark] = + (yc->jishu_case == CANNA_JISHU_UPPER) ? WToupper(p[i]) : + (yc->jishu_case == CANNA_JISHU_LOWER) ? WTolower(p[i]) : p[i]; + if (yc->jishu_case == CANNA_JISHU_CAPITALIZE) { + if (p[i] <= ' ') { + head = 1; + } + else if (head) { + head = 0; + xxxx[i - yc->rmark] = WToupper(p[i]); + } + } + } + xxxx[yc->jishu_rEndp - yc->rmark] = 0; + revlen = RkwCvtZen(s, (int)(e - s), xxxx, + yc->jishu_rEndp - yc->rmark); +#if 0 + } else if (yc->jishu_case == CANNA_JISHU_CAPITALIZE) { + WStrncpy(xxxx, yc->romaji_buffer + yc->rmark, + yc->jishu_rEndp - yc->rmark); + *xxxx = WToupper(*xxxx); + xxxx[yc->jishu_rEndp - yc->rmark] = 0; + revlen = RkwCvtZen(s, (int)(e - s), xxxx, + yc->jishu_rEndp - yc->rmark); +#endif + } else { + revlen = RkwCvtZen(s, (int)(e - s), yc->romaji_buffer + yc->rmark, + yc->jishu_rEndp - yc->rmark); + } + break; + + case JISHU_HAN_ALPHA: /* Ⱦ³Ñ±Ñ¿ô¤ËÊÑ´¹¤¹¤ë */ + revlen = yc->jishu_rEndp - yc->rmark; + if (yc->jishu_case == CANNA_JISHU_UPPER || + yc->jishu_case == CANNA_JISHU_LOWER || + yc->jishu_case == CANNA_JISHU_CAPITALIZE) { + int i, head = 1; + WCHAR_T *p = yc->romaji_buffer + yc->rmark; + + for (i = 0 ; i < revlen && s < e ; i++) { + *s++ = + (yc->jishu_case == CANNA_JISHU_UPPER) ? WToupper(p[i]) : + (yc->jishu_case == CANNA_JISHU_LOWER) ? WTolower(p[i]) : p[i]; + if (yc->jishu_case == CANNA_JISHU_CAPITALIZE) { + if (p[i] <= ' ') { + head = 1; + } + else if (head) { + head = 0; + s[-1] = WToupper(p[i]); + } + } + } + s -= revlen; +#if 0 + } else if (yc->jishu_case == CANNA_JISHU_CAPITALIZE) { + if (s + revlen < e) { + WStrncpy(s, yc->romaji_buffer + yc->rmark, revlen); + } + else { + WStrncpy(s, yc->romaji_buffer + yc->rmark, (int)(e - s)); + revlen = (int)(e - s); + } + *s = WToupper(yc->romaji_buffer[yc->rmark]); +#endif + } + else if (s + revlen < e) { + WStrncpy(s, yc->romaji_buffer + yc->rmark, revlen); + }else{ + WStrncpy(s, yc->romaji_buffer + yc->rmark, (int)(e - s)); + revlen = (int)(e - s); + } + break; + + default:/* ¤É¤ì¤Ç¤â¤Ê¤«¤Ã¤¿¤éÊÑ´¹½ÐÍè¤Ê¤¤¤Î¤Ç²¿¤â¤·¤Ê¤¤ */ + break; + } + + *sr = s; + s += revlen; + *er = s; + +/* ʸ»ú¼ïÊÑ´¹¤·¤Ê¤¤Éôʬ¤òÉÕ¤±²Ã¤¨¤ë */ + switch (yc->jishu_kc) + { + case JISHU_HIRA: /* ¤Ò¤é¤¬¤Ê¤Ê¤é */ + case JISHU_ZEN_KATA: /* Á´³Ñ¥«¥¿¥«¥Ê¤Ê¤é */ + case JISHU_HAN_KATA: /* Ⱦ³Ñ¥«¥¿¥«¥Ê¤Ê¤é */ + /* ¤«¤Ê¥Ð¥Ã¥Õ¥¡¤«¤éʸ»úÎó¤ò¼è¤ê½Ð¤¹ */ + if (s + yc->kEndp - yc->jishu_kEndp < e) { + WStrncpy(s, yc->kana_buffer + yc->jishu_kEndp, + yc->kEndp - yc->jishu_kEndp); + s += yc->kEndp - yc->jishu_kEndp; + }else{ + WStrncpy(s, yc->kana_buffer + yc->jishu_kEndp, (int)(e - s)); + s = e; + } + break; + + case JISHU_ZEN_ALPHA: /* Á´³Ñ±Ñ¿ô¤Ê¤é */ + case JISHU_HAN_ALPHA: /* Ⱦ³Ñ±Ñ¿ô¤Ê¤é */ + len = RkwCvtRoma(romajidic, s, (int)(e - s), + yc->romaji_buffer + yc->jishu_rEndp, + yc->rEndp - yc->jishu_rEndp, + RK_FLUSH | RK_SOKON | RK_XFER); + s += len; + break; + default:/* ¤É¤ì¤Ç¤â¤Ê¤«¤Ã¤¿¤é²¿¤â¤·¤Ê¤¤ */ + break; + } + + if (s < e) { + *s = (WCHAR_T)0; + } +#ifdef WIN + free(xxxx); + free(yyyy); +#endif + return (int)(s - ss); +} + +static +inhibittedJishu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + return (((yc->inhibition & INHIBIT_KANA) && + (yc->jishu_kc == JISHU_ZEN_KATA || + yc->jishu_kc == JISHU_HAN_KATA)) || + ((yc->inhibition & INHIBIT_ALPHA) && + (yc->jishu_kc == JISHU_ZEN_ALPHA || + yc->jishu_kc == JISHU_HAN_ALPHA)) || + ((yc->inhibition & INHIBIT_HANKATA) && + (yc->jishu_kc == JISHU_HAN_KATA)) + ); +} + +static +nextJishu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + BYTE startkc = yc->jishu_kc; + + do { + yc->jishu_kc = (BYTE)(((int)yc->jishu_kc + 1) % MAX_JISHU); + } while (inhibittedJishu(d) && yc->jishu_kc != startkc); + return yc->jishu_kc != startkc; +} + +static +previousJishu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + BYTE startkc = yc->jishu_kc; + + do { + yc->jishu_kc = (unsigned char) + (((int)yc->jishu_kc + MAX_JISHU - 1) % MAX_JISHU); + } while (inhibittedJishu(d) && yc->jishu_kc != startkc); + return yc->jishu_kc != startkc; +} + +static JishuNextJishu (uiContext); + +static +JishuNextJishu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + +/* ¼è¤ê½Ð¤·¤¿Ê¸»úÎó¤òÊÑ´¹¤¹¤ë */ + if (!nextJishu(d)) { + return NothingChangedWithBeep(d); + } + if (yc->jishu_kc == JISHU_HIRA) { + if (yc->jishu_kEndp == yc->kEndp && yc->jishu_rEndp == yc->rEndp) { + leaveJishuMode(d, yc); + } + } + makeKanjiStatusReturn(d, yc); + return 0; +} + +static JishuPreviousJishu (uiContext); + +static +JishuPreviousJishu(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + +/* ¼è¤ê½Ð¤·¤¿Ê¸»úÎó¤òÊÑ´¹¤¹¤ë */ + if (!previousJishu(d)) { + return NothingChangedWithBeep(d); + } + if (yc->jishu_kc == JISHU_HIRA) { + if (yc->jishu_kEndp == yc->kEndp && yc->jishu_rEndp == yc->rEndp) { + leaveJishuMode(d, yc); + } + } + makeKanjiStatusReturn(d, yc); + return 0; +} + +static JishuRotateWithInhibition (uiContext, unsigned); + +static +JishuRotateWithInhibition(uiContext d, unsigned inhibit) +{ + yomiContext yc = (yomiContext)d->modec; + BYTE savedInhibition = yc->inhibition; + int res; + + yc->inhibition |= inhibit; + + res = JishuNextJishu(d); + yc->inhibition = savedInhibition; + return res; +} + +static JishuKanaRotate (uiContext); + +static +JishuKanaRotate(uiContext d) +{ + return JishuRotateWithInhibition(d, INHIBIT_ALPHA); +} + +static JishuRomajiRotate (uiContext); + +static +JishuRomajiRotate(uiContext d) +{ + return JishuRotateWithInhibition(d, INHIBIT_KANA | INHIBIT_HIRA); +} + +static void myjishuAdjustRome (uiContext); +static JishuShrink (uiContext); + +static +JishuShrink(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + /* ¼ï¡¹¤Î¥Ý¥¤¥ó¥¿¤òÌ᤹ */ + switch (yc->jishu_kc) + { + case JISHU_ZEN_ALPHA: + case JISHU_HAN_ALPHA: /* Á´³Ñ±Ñ¿ô»ú¤«È¾³Ñ±Ñ¿ô»ú¤Ê¤é */ + myjishuAdjustRome(d); + yc->jishu_rEndp--; /* »ú¼ï¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò£±Ì᤹ */ + if (yc->rAttr[yc->jishu_rEndp] & SENTOU) { + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹ÀèÆ¬¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡¤¬ + * Ω¤Ã¤Æ¤¤¤¿¤é + */ + for (--yc->jishu_kEndp ; + yc->jishu_kEndp > 0 && !(yc->kAttr[yc->jishu_kEndp] & SENTOU) ;) { + --yc->jishu_kEndp; + } + /* ¤«¤ÊÊÑ´¹¤·¤¿¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡¤ÎÀèÆ¬¤¬ + * Ω¤Ã¤Æ¤¤¤ë½ê¤Þ¤Ç + * »ú¼ï¤«¤Ê¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò + * Ì᤹ + */ + } + break; + case JISHU_HIRA: + case JISHU_ZEN_KATA: + case JISHU_HAN_KATA: /* ¤Ò¤é¤¬¤Ê¤«Á´³Ñ¥«¥¿¥«¥Ê¤«È¾³Ñ¥«¥¿¥«¥Ê¤Ê¤é */ + jishuAdjustRome(d); + yc->jishu_kEndp--; /* »ú¼ï¤«¤Ê¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò£±Ê¸»úʬÌ᤹ */ + if (yc->kAttr[yc->jishu_kEndp] & SENTOU) { + /* ¤«¤ÊÊÑ´¹¤·¤¿¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡¤¬ + * Ω¤Ã¤Æ¤¤¤¿¤é + */ + for (--yc->jishu_rEndp ; + yc->jishu_rEndp > 0 && !(yc->rAttr[yc->jishu_rEndp] & SENTOU) ;) { + --yc->jishu_rEndp; + } + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹ÀèÆ¬¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡¤¬ + * Ω¤Ã¤Æ¤¤¤ë½ê¤Þ¤Ç + * »ú¼ï¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò + * Ì᤹ + */ + } + break; + } + + if(yc->jishu_rEndp <= yc->rmark) {/* £±¼þ¤·¤¿¤é»ú¼ï¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò + * ¸µ¤ÎŤµ¤ËÌ᤹ + */ + yc->jishu_kEndp = yc->kEndp; + yc->jishu_rEndp = yc->rEndp; + } + makeKanjiStatusReturn(d, yc); + return 0; +} + +static JishuNop (uiContext); + +static +JishuNop(uiContext d) +{ + /* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */ + d->majorMode = d->minorMode = CANNA_MODE_AlphaMode; + currentModeInfo(d); + + makeKanjiStatusReturn(d, (yomiContext)d->modec); + return 0; +} + +static JishuExtend (uiContext); + +static +JishuExtend(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + /* ¼ï¡¹¤Î¥Ý¥¤¥ó¥¿¤òÁý¤ä¤¹ */ + switch (yc->jishu_kc) { + case JISHU_ZEN_ALPHA: + case JISHU_HAN_ALPHA: /* Á´³Ñ±Ñ¿ô»ú¤«È¾³Ñ±Ñ¿ô»ú¤Ê¤é */ + myjishuAdjustRome(d); + + if(yc->jishu_rEndp >= yc->rEndp && yc->jishu_kEndp >= yc->kEndp ) { + /* £±¼þ¤·¤¿¤é»ú¼ï¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò + * °ìÈÖÁ°¤ËÌ᤹ + */ + yc->jishu_rEndp = yc->rmark; + yc->jishu_kEndp = yc->cmark; + } + + if (yc->rAttr[yc->jishu_rEndp] & SENTOU) { + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹ÀèÆ¬¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡¤¬ + * Ω¤Ã¤Æ¤¤¤¿¤é + */ + + for (yc->jishu_kEndp++ ; + yc->jishu_kEndp > 0 && !(yc->kAttr[yc->jishu_kEndp] & SENTOU) ;) { + yc->jishu_kEndp++; + } + /* ¤«¤ÊÊÑ´¹¤·¤¿¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡¤ÎÀèÆ¬¤¬ + * Ω¤Ã¤Æ¤¤¤ë½ê¤Þ¤Ç + * »ú¼ï¤«¤Ê¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤òÁý¤ä¤¹ + */ + } + yc->jishu_rEndp++; /* »ú¼ï¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò£±Áý¤ä¤¹ */ + break; + case JISHU_HIRA: + case JISHU_ZEN_KATA: + case JISHU_HAN_KATA: /* ¤Ò¤é¤¬¤Ê¤«Á´³Ñ¥«¥¿¥«¥Ê¤«È¾³Ñ¥«¥¿¥«¥Ê¤Ê¤é */ + jishuAdjustRome(d); + + if(yc->jishu_rEndp >= yc->rEndp && yc->jishu_kEndp >= yc->kEndp ) { + /* £±¼þ¤·¤¿¤é»ú¼ï¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò + * °ìÈÖÁ°¤ËÌ᤹ + */ + yc->jishu_rEndp = yc->rmark; + yc->jishu_kEndp = yc->cmark; + } + + if (yc->kAttr[yc->jishu_kEndp] & SENTOU) { + /* ¤«¤ÊÊÑ´¹¤·¤¿¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡¤¬ + * Ω¤Ã¤Æ¤¤¤¿¤é + */ + for (yc->jishu_rEndp++ ; + yc->jishu_rEndp > 0 && !(yc->rAttr[yc->jishu_rEndp] & SENTOU) ;) { + yc->jishu_rEndp++; + } + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹ÀèÆ¬¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡¤¬ + * Ω¤Ã¤Æ¤¤¤ë½ê¤Þ¤Ç + * »ú¼ï¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤òÁý¤ä¤¹ + */ + } + yc->jishu_kEndp++; /* »ú¼ï¤«¤Ê¥Ð¥Ã¥Õ¥¡¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò£±Ê¸»úʬÁý¤ä¤¹ */ + break; + } + makeKanjiStatusReturn(d, yc); + return 0; +} + +static void +jishuAdjustRome(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + while (!(yc->rAttr[yc->jishu_rEndp] & SENTOU)) { + ++yc->jishu_rEndp; + } +} + +static void +myjishuAdjustRome(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + while (!(yc->kAttr[yc->jishu_kEndp] & SENTOU) + && !(yc->jishu_kEndp == yc->kEndp)) { + ++yc->jishu_kEndp; + } +} + +static int +JishuZenkaku(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + +/* ¼è¤ê½Ð¤·¤¿Ê¸»úÎó¤òÊÑ´¹¤¹¤ë */ + switch(yc->jishu_kc) + { + case JISHU_HIRA: /* ¤Ò¤é¤¬¤Ê¤Ê¤é²¿¤â¤·¤Ê¤¤ */ + break; + + case JISHU_HAN_ALPHA: /* Ⱦ³Ñ±Ñ¿ô¤Ê¤éÁ´³Ñ±Ñ¿ô¤ËÊÑ´¹¤¹¤ë */ + yc->jishu_kc = JISHU_ZEN_ALPHA; + break; + + case JISHU_ZEN_ALPHA: /* Á´³Ñ±Ñ¿ô¤Ê¤é²¿¤â¤·¤Ê¤¤ */ + break; + + case JISHU_HAN_KATA: /* Ⱦ³Ñ¥«¥¿¥«¥Ê¤Ê¤éÁ´³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤¹¤ë */ + yc->jishu_kc = JISHU_ZEN_KATA; + break; + + case JISHU_ZEN_KATA: /* Á´³Ñ¥«¥¿¥«¥Ê¤Ê¤é²¿¤â¤·¤Ê¤¤ */ + break; + + default: /* ¤É¤ì¤Ç¤â¤Ê¤«¤Ã¤¿¤éÊÑ´¹½ÐÍè¤Ê¤¤¤Î¤Ç²¿¤â¤·¤Ê¤¤ */ + break; + } + + makeKanjiStatusReturn(d, yc); + return 0; +} + +static int +JishuHankaku(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + /* ¼è¤ê½Ð¤·¤¿Ê¸»úÎó¤òÊÑ´¹¤¹¤ë */ + switch(yc->jishu_kc) + { + case JISHU_HIRA: /* ¤Ò¤é¤¬¤Ê¤Ê¤éȾ³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤¹¤ë */ + if (cannaconf.InhibitHankakuKana) { + return NothingChangedWithBeep(d); + } + yc->jishu_kc = JISHU_HAN_KATA; + break; + + case JISHU_ZEN_KATA: /* Á´³Ñ¥«¥¿¥«¥Ê¤Ê¤éȾ³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤¹¤ë */ + if (cannaconf.InhibitHankakuKana) { + return NothingChangedWithBeep(d); + } + yc->jishu_kc = JISHU_HAN_KATA; + break; + + case JISHU_HAN_KATA: /* Ⱦ³Ñ¥«¥¿¥«¥Ê¤Ê¤é²¿¤â¤·¤Ê¤¤ */ + break; + + case JISHU_ZEN_ALPHA: /* Á´³Ñ±Ñ¿ô¤Ê¤éȾ³Ñ±Ñ¿ô¤ËÊÑ´¹¤¹¤ë */ + yc->jishu_kc = JISHU_HAN_ALPHA; + break; + + case JISHU_HAN_ALPHA: /* Ⱦ³Ñ±Ñ¿ô¤Ê¤é²¿¤â¤·¤Ê¤¤ */ + break; + + default: /* ¤É¤ì¤Ç¤â¤Ê¤«¤Ã¤¿¤éÊÑ´¹½ÐÍè¤Ê¤¤¤Î¤Ç²¿¤â¤·¤Ê¤¤ */ + break; + } + + makeKanjiStatusReturn(d, yc); + return 0; +} + +static +exitJishuAndDoSomething(uiContext d, int fnum) +{ + exitJishu(d); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = fnum; + makeYomiReturnStruct(d); + currentModeInfo(d); + return d->nbytes = 0; +} + +static JishuYomiInsert (uiContext); + +static +JishuYomiInsert(uiContext d) +{ + if (cannaconf.MojishuContinue) { + return exitJishuAndDoSomething(d, 0); + } + else { + int res; + + res = YomiKakutei(d); + /* ¿·¤·¤¯¥Õ¥é¥°¤òÀߤ±¤Æ¡¢¤½¤ì¤Ë¤è¤Ã¤Æ¡¢ + YomiKakutei(); more.todo = self-insert ¤âÁªÂò¤Ç¤­¤ë¤è¤¦¤Ë¤·¤è¤¦ */ + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = CANNA_FN_FunctionalInsert; + makeYomiReturnStruct(d); + currentModeInfo(d); + return res; + } +} + +static JishuQuit (uiContext); + +static +JishuQuit(uiContext d) +{ + leaveJishuMode(d, (yomiContext)d->modec); + makeKanjiStatusReturn(d, (yomiContext)d->modec); + return 0; +} + +/* Âçʸ»ú¤Ë¤¹¤ë´Ø¿ô */ + +static JishuToUpper (uiContext); + +static +JishuToUpper(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (!(yc->inhibition & INHIBIT_ALPHA)) { /* ̵ÍýÌðÍýÂçʸ»ú¤ËÊÑ´¹¤¹¤ë */ + if (yc->jishu_kc == JISHU_HIRA || yc->jishu_kc == JISHU_ZEN_KATA) { + yc->jishu_kc = JISHU_ZEN_ALPHA; + } + else if (yc->jishu_kc == JISHU_HAN_KATA) { + yc->jishu_kc = JISHU_HAN_ALPHA; + } + } + + if (yc->jishu_kc == JISHU_ZEN_ALPHA || yc->jishu_kc == JISHU_HAN_ALPHA) { + yc->jishu_case = CANNA_JISHU_UPPER; + makeKanjiStatusReturn(d, yc); + return 0; + } + else { + /* Á°¤È²¿¤âÊѤï¤ê¤Þ¤»¤ó */ + d->kanji_status_return->length = -1; + return 0; + } +} + +static JishuCapitalize (uiContext); + +static +JishuCapitalize(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (!(yc->inhibition & INHIBIT_ALPHA)) { /* ̵ÍýÌðÍýÂçʸ»ú¤ËÊÑ´¹¤¹¤ë */ + if (yc->jishu_kc == JISHU_HIRA || yc->jishu_kc == JISHU_ZEN_KATA) { + yc->jishu_kc = JISHU_ZEN_ALPHA; + } + else if (yc->jishu_kc == JISHU_HAN_KATA) { + yc->jishu_kc = JISHU_HAN_ALPHA; + } + } + + if (yc->jishu_kc == JISHU_ZEN_ALPHA || yc->jishu_kc == JISHU_HAN_ALPHA) { + yc->jishu_case = CANNA_JISHU_CAPITALIZE; + makeKanjiStatusReturn(d, yc); + return 0; + } + else { + /* Á°¤È²¿¤âÊѤï¤ê¤Þ¤»¤ó */ + d->kanji_status_return->length = -1; + return 0; + } +} + +static JishuToLower (uiContext); + +static +JishuToLower(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (!(yc->inhibition & INHIBIT_ALPHA)) { /* ̵ÍýÌðÍýÂçʸ»ú¤ËÊÑ´¹¤¹¤ë */ + if (yc->jishu_kc == JISHU_HIRA || yc->jishu_kc == JISHU_ZEN_KATA) { + yc->jishu_kc = JISHU_ZEN_ALPHA; + } + else if (yc->jishu_kc == JISHU_HAN_KATA) { + yc->jishu_kc = JISHU_HAN_ALPHA; + } + } + + if (yc->jishu_kc == JISHU_ZEN_ALPHA || yc->jishu_kc == JISHU_HAN_ALPHA) { + yc->jishu_case = CANNA_JISHU_LOWER; + makeKanjiStatusReturn(d, yc); + return 0; + } + else { + /* Á°¤È²¿¤âÊѤï¤ê¤Þ¤»¤ó */ + d->kanji_status_return->length = -1; + return 0; + } +} + +static JishuHiragana (uiContext); + +static +JishuHiragana(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + yc->jishu_kc = JISHU_HIRA; + makeKanjiStatusReturn(d, yc); + return 0; +} + +static JishuKatakana (uiContext); + +static +JishuKatakana(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + yc->jishu_kc = JISHU_ZEN_KATA; + makeKanjiStatusReturn(d, yc); + return 0; +} + +static JishuRomaji (uiContext); + +static +JishuRomaji(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->inhibition == INHIBIT_ALPHA) { + return NothingChangedWithBeep(d); + } + yc->jishu_kc = JISHU_ZEN_ALPHA; + makeKanjiStatusReturn(d, yc); + return 0; +} + +static void +nextCase(yomiContext yc) +{ + yc->jishu_case = (BYTE)(((int)yc->jishu_case + 1) % CANNA_JISHU_MAX_CASE); +} + +static JishuCaseRotateForward (uiContext); + +static +JishuCaseRotateForward(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->inhibition == INHIBIT_ALPHA) { + return NothingChangedWithBeep(d); + } + if (yc->jishu_kc == JISHU_ZEN_ALPHA || + yc->jishu_kc == JISHU_HAN_ALPHA) { + nextCase(yc); + } + else if (yc->jishu_kc == JISHU_HIRA || yc->jishu_kc == JISHU_ZEN_KATA) { + yc->jishu_kc = JISHU_ZEN_ALPHA; + } + else if (yc->jishu_kc == JISHU_HAN_KATA) { + yc->jishu_kc = JISHU_HAN_ALPHA; + } + makeKanjiStatusReturn(d, yc); + return 0; +} + +/* + * ¤«¤Ê´Á»úÊÑ´¹¤ò¹Ô¤¤(ÊÑ´¹¥­¡¼¤¬½é¤á¤Æ²¡¤µ¤ì¤¿)¡¢TanKouhoMode¤Ë°Ü¹Ô¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +static JishuKanjiHenkan (uiContext); + +static +JishuKanjiHenkan(uiContext d) +{ + return exitJishuAndDoSomething(d, CANNA_FN_Henkan); +} + +static JishuKanjiHenkanOInsert (uiContext); + +static +JishuKanjiHenkanOInsert(uiContext d) +{ + return exitJishuAndDoSomething(d, CANNA_FN_HenkanOrInsert); +} + +static JishuKanjiHenkanONothing (uiContext); + +static +JishuKanjiHenkanONothing(uiContext d) +{ + return exitJishuAndDoSomething(d, CANNA_FN_HenkanOrNothing); +} + +#include "jishumap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/jishumap.h b/src/add-ons/input_server/methods/canna/lib/jishumap.h new file mode 100644 index 0000000000..df0d649c15 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/jishumap.h @@ -0,0 +1,70 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +// Modified by T.Murai + +#if !defined(lint) && !defined(__CODECENTER__) +static char jishumap_id[] = "@(#) 102.1 $Id: jishumap.h,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" + +static struct funccfunc jishu_funcs[] = { + {CANNA_FN_FunctionalInsert ,JishuYomiInsert }, + {CANNA_FN_Next ,JishuNextJishu }, + {CANNA_FN_Prev ,JishuPreviousJishu }, + {CANNA_FN_DeletePrevious ,JishuQuit }, + {CANNA_FN_Henkan ,JishuKanjiHenkan }, + {CANNA_FN_HenkanOrInsert ,JishuKanjiHenkanOInsert}, + {CANNA_FN_HenkanOrNothing ,JishuKanjiHenkanONothing}, + {CANNA_FN_Kakutei ,YomiKakutei }, + {CANNA_FN_Extend ,JishuExtend }, + {CANNA_FN_Shrink ,JishuShrink }, + {CANNA_FN_Quit ,JishuQuit }, + {CANNA_FN_BubunMuhenkan ,JishuQuit }, + {CANNA_FN_Zenkaku ,JishuZenkaku }, + {CANNA_FN_Hankaku ,JishuHankaku }, + {CANNA_FN_ToUpper ,JishuToUpper }, + {CANNA_FN_ToLower ,JishuToLower }, + {CANNA_FN_Hiragana ,JishuHiragana }, + {CANNA_FN_Katakana ,JishuKatakana }, + {CANNA_FN_Romaji ,JishuRomaji }, + {CANNA_FN_Capitalize ,JishuCapitalize }, + {CANNA_FN_Forward ,TbForward }, + {CANNA_FN_Backward ,TbBackward }, + {CANNA_FN_BeginningOfLine ,TbBeginningOfLine }, + {CANNA_FN_EndOfLine ,TbEndOfLine }, + {CANNA_FN_KanaRotate ,JishuKanaRotate }, + {CANNA_FN_RomajiRotate ,JishuRomajiRotate }, + {CANNA_FN_CaseRotate ,JishuCaseRotateForward }, + {CANNA_FN_Nop ,JishuNop }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {0 ,0 }, +}; +extern searchfunc(...); + +KanjiModeRec jishu_mode = { + searchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + jishu_funcs, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/jrbind.c b/src/add-ons/input_server/methods/canna/lib/jrbind.c new file mode 100644 index 0000000000..48ca34c292 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/jrbind.c @@ -0,0 +1,379 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: jrbind.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include +#include + +#define ACTHASHTABLESIZE 64 +#define KEYHASHTABLESIZE 16 + +typedef int (*keycallback)(unsigned, unsigned char *, int, + unsigned char *, int, char *); + +static uiContext newUiContext(unsigned int dpy, unsigned int win); +static void GetCannaKeyOnAMode(unsigned modeid, unsigned char *mode, keycallback keyfn, char *con); +static void GetCannaKeyfunc(keycallback keyfn, char *con); + +/* + + jrKanjiString ¤Ï TTY ¤Î¥­¡¼ÆþÎϤò¼õ¤±¼è¤ê¡¢¤½¤Î¥­¡¼¤Ë¤·¤¿¤¬¤Ã¤ÆÉ¬Í× + ¤Ê¤é¥«¥Ê´Á»úÊÑ´¹¤ò¹Ô¤¤¡¢¤½¤Î¥­¡¼ÆþÎϤηë²Ì¤È¤·¤ÆÆÀ¤é¤ì¤ëʸ»úÎó¤ò + buffer_return ¤ÇÊÖ¤¹¡£buffer_return ¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¦¤ËÍѰդ¹¤ë¥Ð¥Ã + ¥Õ¥¡¤Ç¤¢¤ê¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¤½¤Î¥Ð¥Ã¥Õ¥¡¤ÎŤµ¤ò bytes_buffer ¤ÇÅÏ + ¤¹¡£ + + kanji_status_return ¤Ï³ÎÄꤷ¤Æ¤¤¤Ê¤¤ÆþÎÏʸ»úÎó¤òɽ¼¨¤¹¤ë¤¿¤á¤Î¥Ç¡¼¥¿ + ¤Ç¤¢¤ê¡¢Ì¤³ÎÄê¤ÎÆÉ¤ß¤ä¸õÊä´Á»ú¤Ê¤É¤¬ÊÖ¤µ¤ì¤ë¡£kanji_status_return¤Î + ¥á¥ó¥Ð¤Ë¤Ï¡¢ echoStr, length, revPos, revLen ¤¬¤¢¤ê¤½¤ì¤¾¤ì¡¢Ì¤³ÎÄê + ʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¡¢¤½¤ÎŤµ¡¢Ì¤³ÎÄêʸ»úÎó¤Î¤¦¤Á¡¢¶¯Ä´¤¹¤ëÉôʬ¤Ø¤Î¥ª + ¥Õ¥»¥Ã¥È¡¢¶¯Ä´¤¹¤ëÉôʬ¤ÎŤµ¤òÊÖ¤¹¡£Ì¤³ÎÄêʸ»úÎó¤ò³ÊǼ¤¹¤ëÎΰè¤Ï + jrKanjiString ¤Ç¼«Æ°Åª¤ËÍѰդµ¤ì¤ë¡£ + + */ + +extern int FirstTime; + +extern BYTE *actFromHash(); + +int +wcKanjiString ( + int context_id, + int ch, + WCHAR_T *buffer_return, + const int nbuffer, + wcKanjiStatus *kanji_status_return) +{ + int res; + + *buffer_return = (WCHAR_T)ch; + + res = XwcLookupKanji2((unsigned int)0, (unsigned int)context_id, + buffer_return, nbuffer, + 1/* byte */, 1/* functional char*/, + kanji_status_return); + return res; +} + +/* jrKanjiControl -- ¥«¥Ê´Á»úÊÑ´¹¤ÎÀ©¸æ¤ò¹Ô¤¦ */ + +int +wcKanjiControl ( +const int context, +const int request, +char *arg) +{ + return XwcKanjiControl2((unsigned int)0, (unsigned int)context, + (unsigned int)request, (BYTE *)arg); +} + +inline +uiContext +newUiContext(unsigned int dpy, unsigned int win) +{ + extern struct CannaConfig cannaconf; + uiContext d; + + if ((d = (uiContext)malloc(sizeof(uiContextRec))) != (uiContext)0) { + if (initRomeStruct(d, cannaconf.chikuji) == 0) { + if (internContext(dpy, win, d)) { + return d; + } + freeRomeStruct(d); + } + free(d); + } + return (uiContext)0; +} + +extern int kanjiControl (int, uiContext, caddr_t); + +XwcLookupKanji2(unsigned int dpy, unsigned int win, WCHAR_T *buffer_return, int nbuffer, int nbytes, int functionalChar, wcKanjiStatus *kanji_status_return) +{ + uiContext d; + int retval; + extern int locale_insufficient; + + /* locale ¥Ç¡¼¥¿¥Ù¡¼¥¹¤¬ÉÔ½½Ê¬¤Ç WCHAR_T ¤È¤ÎÊÑ´¹½èÍý¤¬¤Ç¤­¤Ê¤¤¾ì¹ç¤Ï + ¡Ø¤«¤ó¤Ê¡Ù¤Ë¤È¤Ã¤ÆÂçÂÇ·â¡£¤â¤¦ÊÑ´¹¤Ï¤Ç¤­¤Ê¤¤¡ª */ + if (locale_insufficient) { + kanji_status_return->info = KanjiEmptyInfo | KanjiThroughInfo; + if (nbytes) { /* ¥­¥ã¥é¥¯¥¿¥³¡¼¥É¤¬¤È¤ì¤¿¾ì¹ç */ + kanji_status_return->length = + kanji_status_return->revPos = + kanji_status_return->revLen = 0; + return nbytes; + } + else { /* ¥­¥ã¥é¥¯¥¿¥³¡¼¥É¤¬¤È¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡Ê¥·¥Õ¥È¥­¡¼¤Ê¤É¡Ë... */ + kanji_status_return->length = -1; + return 0; + } + } + + /* ½é¤á¤Æ XLookupKanjiString ¤¬¸Æ¤Ð¤ì¤¿»þ¤Ï¼­½ñ¤Î½é´ü²½¤Ê¤É¤Î½èÍý¤¬ + ¹Ô¤ï¤ì¤ë¡£ */ + + if (FirstTime) { + if (kanjiControl(KC_INITIALIZE, (uiContext)NULL, (char *)NULL) == -1) { + return -1; + } + FirstTime = 0; + } + + d = keyToContext(dpy, win); + + if (d == (uiContext)NULL) { + /* ¤³¤Î¥¦¥£¥ó¥É¥¦¤«¤é¥¤¥Ù¥ó¥È¤¬Í褿¤Î¤¬»Ï¤á¤Æ¤À¤Ã¤¿¤ê¤¹¤ë¤ï¤±¤è */ + d = newUiContext(dpy, win); + if (d == (uiContext)NULL) { + return NoMoreMemory(); + } + } + + + bzero(kanji_status_return, sizeof(wcKanjiStatus)); + + d->ch = (unsigned)*buffer_return; + d->buffer_return = buffer_return; + d->n_buffer = nbuffer; + d->kanji_status_return = kanji_status_return; + + debug_message("current_mode(0x%x)\n", d->current_mode,0,0); + + if ( nbytes || functionalChar ) { /* ¥­¥ã¥é¥¯¥¿¥³¡¼¥É¤¬¤È¤ì¤¿¾ì¹ç */ + int check; + + *buffer_return = key2wchar(d->ch, &check); + if (!check) { + return NothingChangedWithBeep(d); + } + + d->nbytes = nbytes; + + retval = doFunc(d, 0); +#ifdef DEBUG + checkModec(d); +#endif /* DEBUG */ + return(retval); + } + else { /* ¥­¥ã¥é¥¯¥¿¥³¡¼¥É¤¬¤È¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡Ê¥·¥Õ¥È¥­¡¼¤Ê¤É¡Ë... */ + d->kanji_status_return->length = -1; + return 0; + } +} + +int +XwcKanjiControl2(unsigned int display, unsigned int window, unsigned int request, BYTE *arg) +{ + if (request == KC_INITIALIZE || request == KC_FINALIZE || + request == KC_SETSERVERNAME || request == KC_SETINITFILENAME || + request == KC_SETVERBOSE || request == KC_KEYCONVCALLBACK || + request == KC_QUERYCONNECTION || request == KC_SETUSERINFO || + request == KC_QUERYCUSTOM) { + return kanjiControl(request, (uiContext)NULL, (char *)arg); + } + else if (/* 0 <= request && (ɬ¤º¿¿) */ request < MAX_KC_REQUEST) { + uiContext d; + + /* ½é¤á¤Æ wcKanjiString ¤¬¸Æ¤Ð¤ì¤¿»þ¤Ï¼­½ñ¤Î½é´ü²½¤Ê¤É¤Î½èÍý¤¬ + ¹Ô¤ï¤ì¤ë¡£ */ + + if (FirstTime) { + if (kanjiControl(KC_INITIALIZE, (uiContext)NULL, (char *)NULL) == -1) { + return -1; + } + FirstTime = 0; + } + + d = keyToContext((unsigned int)display, (unsigned int)window); + + if (d == (uiContext)NULL) { + d = newUiContext(display, window); + if (d == (uiContext)NULL) { + return NoMoreMemory(); + } + } + + if (request == KC_CLOSEUICONTEXT) { + rmContext(display, window); + } + return kanjiControl(request, d, (char *)arg); + } + else { + return -1; + } +} + +struct map { + KanjiMode tbl; + BYTE key; + KanjiMode mode; + struct map *next; +} *mapFromHash(); + +/* cfuncdef + + pushCallback -- ¥³¡¼¥ë¥Ð¥Ã¥¯¤Î½¸¹ç¤ò¥×¥Ã¥·¥å¤¹¤ë¡£ + + ¥³¡¼¥ë¥Ð¥Ã¥¯¤Î½¸¹ç¤ò³ÊǼ¤¹¤ëÇÛÎó¤¬ malloc ¤µ¤ì¤Æ¡¢¤½¤ì¤¬ uiContext ¤Ë + ¥×¥Ã¥·¥å¤µ¤ì¤ë¡£ + + malloc ¤µ¤ì¤¿ÇÛÎó¤¬Ìá¤êÃͤȤ·¤ÆÊ֤롣 + + */ + +struct callback * +pushCallback(uiContext d, mode_context env, canna_callback_t ev, canna_callback_t ex, canna_callback_t qu, canna_callback_t au) +{ + struct callback *newCB; + + newCB = (struct callback *)malloc(sizeof(struct callback)); + if (newCB) { + newCB->func[0] = ev; + newCB->func[1] = ex; + newCB->func[2] = qu; + newCB->func[3] = au; + newCB->env = env; + newCB->next = d->cb; + d->cb = newCB; + } + return newCB; +} + +void +popCallback(uiContext d) +{ + struct callback *oldCB; + + oldCB = d->cb; + d->cb = oldCB->next; + free(oldCB); +} + +#if defined(WIN) && defined(_RK_h) + +extern RkwGetProtocolVersion (int *, int *); +extern char *RkwGetServerName (void); + +struct cannafn{ + { + RkwGetProtocolVersion, + RkwGetServerName, + RkwGetServerVersion, + RkwInitialize, + RkwFinalize, + RkwCreateContext, + RkwDuplicateContext, + RkwCloseContext, + RkwSetDicPath, + RkwCreateDic, + RkwSync, + RkwGetDicList, + RkwGetMountList, + RkwMountDic, + RkwRemountDic, + RkwUnmountDic, + RkwDefineDic, + RkwDeleteDic, + RkwGetHinshi, + RkwGetKanji, + RkwGetYomi, + RkwGetLex, + RkwGetStat, + RkwGetKanjiList, + RkwFlushYomi, + RkwGetLastYomi, + RkwRemoveBun, + RkwSubstYomi, + RkwBgnBun, + RkwEndBun, + RkwGoTo, + RkwLeft, + RkwRight, + RkwNext, + RkwPrev, + RkwNfer, + RkwXfer, + RkwResize, + RkwEnlarge, + RkwShorten, + RkwStoreYomi, + RkwSetAppName, + RkwSetUserInfo, + RkwQueryDic, + RkwCopyDic, + RkwListDic, + RkwRemoveDic, + RkwRenameDic, + RkwChmodDic, + RkwGetWordTextDic, + RkwGetSimpleKanji, + }, + wcKanjiControl, + wcKanjiString, +}; +#endif + +#ifdef WIN +#include "cannacnf.h" + +/* Interfaces for CannaGetConfigure/CannaSetConfigure */ + +#define CANNA_MODE_AllModes 255 +#define MAX_KEYS_IN_A_MODE 256 + + +inline void +GetCannaKeyOnAMode(unsigned modeid, unsigned char *mode, + keycallback keyfn, char *con) +{ + unsigned char key; + int i; + + for (i = 0 ; i < MAX_KEYS_IN_A_MODE ; i++) { + if (mode[i] != CANNA_FN_Undefined) { /* is this required? */ + key = i; + (*keyfn)(modeid, &key, 1, mode + i, 1, con); + } + } +} + +inline void +GetCannaKeyfunc(keycallback keyfn, char *con) +{ + extern unsigned char default_kmap[], alpha_kmap[], empty_kmap[]; + + GetCannaKeyOnAMode(CANNA_MODE_AllModes, default_kmap, keyfn, con); + GetCannaKeyOnAMode(CANNA_MODE_AlphaMode, alpha_kmap, keyfn, con); + GetCannaKeyOnAMode(CANNA_MODE_EmptyMode, empty_kmap, keyfn, con); +} + +#endif diff --git a/src/add-ons/input_server/methods/canna/lib/kctrl.c b/src/add-ons/input_server/methods/canna/lib/kctrl.c new file mode 100644 index 0000000000..ac5730f28c --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/kctrl.c @@ -0,0 +1,2249 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: kctrl.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +#include +#include +#include + +#define DEFAULT_COLUMN_WIDTH 70 + + +extern struct RkRxDic *romajidic, *englishdic; + +extern char *CANNA_initfilename; +extern char saveapname[]; + +static int insertEmptySlots (uiContext); +static int callCallback (uiContext, int); +static void freeKeysup (void); +static void freeBuffer (void); +static void freeExtra (void); + +static +doInitializeFunctions(uiContext d) +{ + BYTE *p; + int res = 0; + wcKanjiStatus ks, *pks; + extern BYTE *initfunc; + WCHAR_T xxxx[10]; + + d->ch = 0; + d->buffer_return = xxxx; + d->n_buffer = sizeof(xxxx) / sizeof(WCHAR_T); + d->nbytes = 0; + + if (initfunc) { + pks = d->kanji_status_return; + d->kanji_status_return = &ks; + for (p = initfunc ; *p ; p++) { + res = _doFunc(d, *p); + } + res = _afterDoFunc(d, res); + d->kanji_status_return = pks; + } + return res; +} + +/* uiContext ¤Î½é´ü²½ */ + +initRomeStruct(uiContext d, int flg) +{ + extern KanjiModeRec alpha_mode, empty_mode; + extern KanjiModeRec kzhr_mode, kzkt_mode, kzal_mode; + extern KanjiModeRec khkt_mode, khal_mode; + yomiContext yc; + extern defaultContext, defaultBushuContext; + + bzero(d, sizeof(uiContextRec)); + + if (insertEmptySlots(d) < 0) { + return -1; + } + + /* ¥³¥ó¥Æ¥¯¥¹¥È¤òºÇ½é¤Ë¥Ç¥å¥×¥ê¥±¡¼¥È¤·¤Æ¤¤¤¿²áµî¤¬¤¢¤Ã¤¿¤Ê¤¢ */ + d->contextCache = -1; + + /* ½é´ü¥â¡¼¥É(¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¥â¡¼¥É)¤òÆþ¤ì¤ë */ + d->majorMode = d->minorMode = CANNA_MODE_AlphaMode; + yc = (yomiContext)d->modec; + if (flg) { + yc->minorMode = CANNA_MODE_ChikujiYomiMode; + yc->generalFlags |= CANNA_YOMI_CHIKUJI_MODE; + } + alphaMode(d); + + /* ½é´ü func ¤ò¼Â¹Ô¤¹¤ë */ + + (void)doInitializeFunctions(d); + return 0; +} + +static void +freeModec(mode_context modec) +{ + coreContext cc; + union { + coreContext c; + yomiContext y; + ichiranContext i; + forichiranContext f; + mountContext m; + tourokuContext t; + } gc; + + cc = (coreContext)modec; + while (cc) { + switch (cc->id) { + case CORE_CONTEXT: + gc.c = cc; + cc = (coreContext)gc.c->next; + freeCoreContext(gc.c); + break; + case YOMI_CONTEXT: + gc.y = (yomiContext)cc; + cc = (coreContext)gc.y->next; + /* yc->context ¤Î close ¤Ï¤¤¤é¤Ê¤¤¤Î¤«¤Ê¤¢¡£1996.10.30 º£ */ + freeYomiContext(gc.y); + break; + case ICHIRAN_CONTEXT: + gc.i = (ichiranContext)cc; + cc = (coreContext)gc.i->next; + freeIchiranContext(gc.i); + break; + case FORICHIRAN_CONTEXT: + gc.f = (forichiranContext)cc; + cc = (coreContext)gc.f->next; + freeForIchiranContext(gc.f); + break; + case MOUNT_CONTEXT: + gc.m = (mountContext)cc; + cc = (coreContext)gc.m->next; + freeIchiranContext(gc.i); + break; + case TOUROKU_CONTEXT: + gc.t = (tourokuContext)cc; + cc = (coreContext)gc.t->next; + free(gc.t); + break; + default: + break; + } + } +} + +static void +freeCallbacks(struct callback *cb) +{ + struct callback *nextcb; + + for (; cb ; cb = nextcb) { + nextcb = cb->next; + free(cb); + } +} + +void +freeRomeStruct(uiContext d) +{ + freeModec(d->modec); + if (d->cb) { + freeCallbacks(d->cb); + } + if (d->contextCache >= 0) { + if (RkwCloseContext(d->contextCache) < 0) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + } + } +#ifndef NO_EXTEND_MENU + freeAllMenuInfo(d->minfo); +#endif + if (d->selinfo) { + selectinfo *p, *q; + + for (p = d->selinfo ; p ; p = q) { + q = p->next; + free(p); + } + } + if (d->attr) { + if (d->attr->u.attr) { + free(d->attr->u.attr); + } + free(d->attr); + } + free(d); +} + +static +insertEmptySlots(uiContext d) +{ + extern KanjiModeRec empty_mode; + yomiContext yc; + + if (pushCallback(d, (mode_context) NULL, NO_CALLBACK, NO_CALLBACK, + NO_CALLBACK, NO_CALLBACK) == (struct callback *)NULL) + return NoMoreMemory(); + + yc = newYomiContext((WCHAR_T *)NULL, 0, /* ·ë²Ì¤Ï³ÊǼ¤·¤Ê¤¤ */ + CANNA_NOTHING_RESTRICTED, + (int)!CANNA_YOMI_CHGMODE_INHIBITTED, + (int)!CANNA_YOMI_END_IF_KAKUTEI, + CANNA_YOMI_INHIBIT_NONE); + if (yc == (yomiContext)0) { + popCallback(d); + return NoMoreMemory(); + } + yc->majorMode = yc->minorMode = CANNA_MODE_HenkanMode; + d->majorMode = d->minorMode = CANNA_MODE_HenkanMode; + d->modec = (mode_context)yc; + + d->current_mode = yc->curMode = yc->myEmptyMode = &empty_mode; + yc->romdic = romajidic; + d->ncolumns = DEFAULT_COLUMN_WIDTH; + d->minfo = (menuinfo *)0; + d->selinfo = (selectinfo *)0; + d->prevMenu = (menustruct *)0; + return 0; +} + +/* + + display ¤È window ¤ÎÁÈ¤ä ¥³¥ó¥Æ¥¯¥¹¥ÈID ¤ò¼ÂºÝ¤Î¥³¥ó¥Æ¥¯¥¹¥È¤ËÂбþÉÕ + ¤±¤ë¤¿¤á¤Î¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë + + display ¤È window ¤«¤éºî¤é¤ì¤ë¥­¡¼¤Î¤È¤³¤í¤ò°ú¤¯¤È¡¢¤½¤³¤Ë¥³¥ó¥Æ¥¯¥¹¥È + ¤¬Æþ¤Ã¤Æ¤¤¤ë³ÎΨ¤¬¹â¤¤¡£¤â¤·Æþ¤Ã¤Æ¤¤¤Ê¤¯¤È¤â¡¢¥Ý¥¤¥ó¥¿¥Á¥§¡¼¥ó¤ò¤¿¤É¤Ã¤Æ + ¹Ô¤¯¤È¤¤¤Ä¤«¤Ï¥³¥ó¥Æ¥¯¥¹¥È¤¬ÆÀ¤é¤ì¤ë¤Ë°ã¤¤¤Ê¤¤¡£ + + */ + +#define HASHTABLESIZE 96 + +static struct bukRec { + unsigned int data1, data2; + uiContext context; + struct bukRec *next; +} *conHash[HASHTABLESIZE]; + +/* ¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤òÄ´¤Ù¤Æ¥³¥ó¥Æ¥¯¥¹¥È¤¬¤¢¤ë¤«¤É¤¦¤«Ä´¤Ù¤ë´Ø¿ô */ + +static +countContext(void) +{ + struct bukRec *hash; + + int i, c; + for(i = 0, c = 0; i < HASHTABLESIZE; i++) { + for(hash = conHash[i] ; hash && hash->context ;hash = hash->next){ + c++; + } + } +#if defined(DEBUG) && !defined(WIN) + fprintf(stderr, "¹ç·×=%d\n", c); +#endif + if(c) { + return 0; + } + else { + return 1; + } +} + +/* ¥Ï¥Ã¥·¥å¥­¡¼¤òºî¤ë´Ø¿ô(¤¤¤¤²Ã¸º) */ + +static unsigned int +makeKey(unsigned int data1, unsigned int data2) +{ + unsigned int key; + + key = data1 % HASHTABLESIZE; + key += data2 % HASHTABLESIZE; + key %= HASHTABLESIZE; + return key; +} + +/* + + keyToContext -- Display ¤È Window ¤ÎÁȤʤɤ«¤é¥³¥ó¥Æ¥¯¥¹¥È¤ò³ä¤ê½Ð¤¹½èÍý + + display ¤È window ¤ÎÁȤ¬¥³¥ó¥Æ¥¯¥¹¥È¤ò»ý¤Ã¤Æ¤¤¤ì¤Ð¤½¤Î¥³¥ó¥Æ¥¯¥¹¥È + ¤òÊÖ¤¹¡£ + + »ý¤Ã¤Æ¤¤¤Ê¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢NULL ¤òÊÖ¤¹¡£ + + */ + +uiContext +keyToContext(unsigned int data1, unsigned int data2) +{ + unsigned int key; + struct bukRec *p; + + key = makeKey(data1, data2); + for (p = conHash[key] ; p ; p = p->next) { + if (p->data1 == data1 && p->data2 == data2) { + /* ¤³¤ê¤ã¤¢¥³¥ó¥Æ¥¯¥¹¥È¤¬¸«¤Ä¤«¤ê¤Þ¤·¤¿¤Ê */ + return p->context; + } + } + return (uiContext)0; /* ¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£ */ +} + + +/* internContext -- ¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿¤¹¤ë + + ¤³¤Î¤È¤­¡¢´û¤Ë¡¢display ¤È window ¤ÎÁȤ¬Â¸ºß¤¹¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢ + ¤½¤ÎÀè¤Ë¤Ä¤Ê¤¬¤Ã¤Æ¤¤¤ë¥³¥ó¥Æ¥¯¥¹¥È¤ò¥Õ¥ê¡¼¤¹¤ë¤Î¤ÇÃí°Õ¡ª¡ª + +*/ + +struct bukRec * +internContext(unsigned int data1, unsigned int data2, uiContext context) +{ + unsigned int key; + struct bukRec *p, **pp; + + key = makeKey(data1, data2); + for (pp = &conHash[key]; (p = *pp) != (struct bukRec *)0; pp = &(p->next)) { + if (p->data1 == data1 && p->data2 == data2) { + freeRomeStruct(p->context); + p->context = context; + return p; + } + } + p = *pp = (struct bukRec *)malloc(sizeof(struct bukRec)); + if (p) { + p->data1 = data1; + p->data2 = data2; + p->context = context; + p->next = (struct bukRec *)0; + } + return p; +} + + +/* rmContext -- ¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤«¤éºï½ü¤¹¤ë + +*/ + +void +rmContext(unsigned int data1, unsigned int data2) +{ + unsigned int key; + struct bukRec *p, *q, **pp; + + key = makeKey(data1, data2); + pp = &conHash[key]; + for (p = *pp ; p ; p = q) { + q = p->next; + if (p->data1 == data1 && p->data2 == data2) { + *pp = q; + free(p); + } + else { + pp = &(p->next); + } + } +} + +/* cfuncdef + + freeBukRecs() -- ¥Ý¥¤¥ó¥È¤µ¤ì¤Æ¤¤¤ëÀè¤Î¥Ð¥±¥Ã¥È¤Î¥Õ¥ê¡¼ + + ¥Ð¥±¥Ã¥È¤Ë¤è¤Ã¤Æ¥Ý¥¤¥ó¥È¤µ¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿¤ò¤¹¤Ù¤Æ¥Õ¥ê¡¼¤¹¤ë¡£ + ¥Õ¥ê¡¼¤ÎÂÐ¾Ý¤Ë¤Ï uiContext ¤â´Þ¤Þ¤ì¤ë¡£ + +*/ + +static void +freeBukRecs(struct bukRec *p) +{ + struct bukRec *nextp; + + if (p) { /* reconfirm that p points some structure */ + freeRomeStruct(p->context); + nextp = p->next; + if (nextp) { + freeBukRecs(nextp); + } + free(p); + } +} + +/* cfuncdef + + clearHashTable() -- ¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤ÎÆâÍÆ¤ò¤¹¤Ù¤Æ¥Õ¥ê¡¼¤¹¤ë¡£ + +*/ + +static void +clearHashTable(void) +{ + int i; + struct bukRec *p; + + for (i = 0 ; i < HASHTABLESIZE ; i++) { + p = conHash[i]; + conHash[i] = 0; + if (p) { + freeBukRecs(p); + } + } +} + +#define NWARNINGMESG 64 +static char *WarningMesg[NWARNINGMESG + 1]; /* +1 ¤ÏºÇ¸å¤Î NULL ¥Ý¥¤¥ó¥¿¤Îʬ */ +static int nWarningMesg = 0; + +static void +initWarningMesg(void) +{ + int i; + + for (i = 0 ; i < nWarningMesg ; i++) { + free(WarningMesg[i]); + WarningMesg[i] = (char *)0; + } + nWarningMesg = 0; +} + +void +addWarningMesg(char *s) +{ + int n; + char *work; + + if (nWarningMesg < NWARNINGMESG) { + n = strlen(s); + work = (char *)malloc(n + 1); + if (work) { + strcpy(work, s); + WarningMesg[nWarningMesg++] = work; + } + } +} + +static int +KC_keyconvCallback(uiContext d, char *arg) +/* ARGSUSED */ +{ +extern void (*keyconvCallback)(...); + + if (arg) { + keyconvCallback = (void (*)(...))arg; + } + else { + keyconvCallback = (void (*)(...))NULL; + } + return 0; +} + +extern void restoreBindings(); + +static +KC_initialize(uiContext d, char *arg) + /* ARGSUSED */ +{ + extern int FirstTime; + + if (FirstTime) { +#ifdef ENGINE_SWITCH + extern char *RkGetServerEngine (void); + if (!RkGetServerEngine()) { + RkSetServerName((char *)0); + } +#endif + + InitCannaConfig(&cannaconf); + + if (WCinit() < 0) { + /* locale ´Ä¶­¤¬ÉÔ½½Ê¬¤ÇÆüËܸìÆþÎϤ¬¤Ç¤­¤Ê¤¤ */ + jrKanjiError = + "The locale database is insufficient for Japanese input system."; + if (arg) *(char ***)arg = (char **)0; + return -1; + } + + debug_message("KC_INITIALIZE \244\362\313\334\305\366\244\313\244\271\244\353\244\276\n",0,0,0); + /* ¤òËÜÅö¤Ë¤¹¤ë¤¾ */ + +#ifndef NO_EXTEND_MENU + if (initExtMenu() < 0) { + jrKanjiError = "Insufficient memory."; + if (arg) *(char ***)arg = (char **)0; + return -1; + } +#endif + + /* ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿ÍÑ¥á¥â¥ê´ÉÍý¤Î½é´ü²½ */ + + WStringOpen(); +#ifndef NO_EXTEND_MENU + if (initBushuTable() != NG) { + if (initGyouTable() != NG) { + if (initHinshiTable() != NG) { + if (initUlKigoTable() != NG) { + if (initUlKeisenTable() != NG) { + if (initOnoffTable() != NG) { + initKigoTable(); /* ²¿¤â¤·¤Æ¤¤¤Ê¤¤ */ + if (initHinshiMessage() != NG) { +#endif + + /* ¥¦¥©¡¼¥Ë¥ó¥°¥á¥Ã¥»¡¼¥¸¤Î½é´ü²½ */ + initWarningMesg(); + + /* ¥â¡¼¥É̾¤Î½é´ü²½ */ + initModeNames(); + + /* ¥­¡¼¥Æ¡¼¥Ö¥ë¤Î½é´ü²½ */ + if (initKeyTables() != NG) { + + /* ½é´ü²½¥Õ¥¡¥¤¥ë¤ÎÆÉ¤ß¹þ¤ß */ +#ifdef BINARY_CUSTOM + binparse(); +#else + parse(); +#endif + + /* keyconvCallback ¤Ï parse ¸å¤ÏÉÔÍפʤΤǥ¯¥ê¥¢¤¹¤ë */ + KC_keyconvCallback(d, (char *)0); + + /* °ìÍ÷´Ø·¸Ê¸»úÎó¤Î½é´ü²½ */ + if (initIchiran() != NG) { + + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤Î½é´ü²½ */ + RomkanaInit(); + + /* ¥«¥Ê´Á»úÊÑ´¹¤Î½é´ü²½ */ + KanjiInit(); + /* ¤³¤³¤Ç¤â¥¨¥é¡¼¤Ï̵»ë¤·¤Þ¤¹¡£ + ´Á»ú¤Ë¤Ê¤é¤Ê¤¯¤Æ¤â¤¤¤¤¤·¡£ */ + + { + extern standalone; + standalone = RkwGetServerName() ? 0 : 1; + } + + if (arg) { + *(char ***)arg = nWarningMesg ? WarningMesg : (char **)0; + } + FirstTime = 0; + return 0; + } + /* uiContext ¤Î¸¡º÷¤Î¤¿¤á¤Î¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤ò¥¯¥ê¥¢ + uiContext ¤â°ì½ï¤Ë¥Õ¥ê¡¼¤¹¤ë */ + clearHashTable(); + + /* µ­¹æÄêµÁ¤ò¾Ã¤¹ */ + freeKeysup(); + + /* ¿§¡¹¤È¥«¥¹¥¿¥Þ¥¤¥º¤µ¤ì¤Æ¤¤¤ë½ê¤ò¤â¤È¤ËÌ᤹¡£ */ + restoreBindings(); + + /* ³ÈÄ¥µ¡Ç½¤Îinitfileɽ¼¨ÍѤΥХåե¡¤ò²òÊü¤¹¤ë */ + freeBuffer(); + +#ifndef NO_EXTEND_MENU + /* ¥á¥Ë¥å¡¼´ØÏ¢¤Î¥á¥â¥ê¤Î³«Êü */ + finExtMenu(); +#endif + + /* ¥Ç¥Õ¥©¥ë¥È°Ê³°¤Î¥â¡¼¥ÉÍÑ¥á¥â¥ê¤Î³«Êü */ + freeExtra(); + + + /* ¥­¡¼¥Þ¥Ã¥×¥Æ¡¼¥Ö¥ë¤Î¥¯¥ê¥¢ */ + restoreDefaultKeymaps(); + } + /* ¥â¡¼¥Éʸ»úÎó¤Î¥Õ¥ê¡¼ */ + resetModeNames(); +#ifndef NO_EXTEND_MENU + } + } + } + } + } + } + } +#endif + /* ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿ÍѼ«Æ°¥á¥â¥ê´ÉÍý¤Î½ªÎ»½èÍý */ + WStringClose(); + + /* ¥µ¡¼¥Ð̾ÊÝ»ýÍÑ¥á¥â¥ê¤Î³«Êü */ + /* RkSetServerName((char *)0); ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¤Î¤Ç¤Ï¡© */ + + /* ¥¨¥ó¥¸¥ó¤Î¥¯¥í¡¼¥º */ + close_engine(); + + return -1; + } + else { + /* Á°¤ËInitialize¤ò¤·¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¤â¤¦¥á¥Ã¥»¡¼¥¸¤ò¤À¤µ¤Ê¤¤¤³¤È¤Ë¤¹¤ë */ + if (arg) { + *(char ***)arg = (char **)0; + } + return -1; + } +} + +static void +freeKeysup(void) +{ + int i; + extern keySupplement keysup[]; + extern int nkeysup; + + for (i = 0 ; i < nkeysup ; i++) { + if (keysup[i].cand) { + free(keysup[i].cand); + keysup[i].cand = (WCHAR_T **)0; + } + if (keysup[i].fullword) { + free(keysup[i].fullword); + keysup[i].fullword = (WCHAR_T *)0; + } + } + nkeysup = 0; +} + +extern int nothermodes; + +static void +freeBuffer(void) +{ + if(CANNA_initfilename) { + free(CANNA_initfilename); + } + CANNA_initfilename = (char *)NULL; +} + +static void +freeExtra(void) +{ + extern extraFunc *extrafuncp; + extraFunc *p, *q; + + for (p = extrafuncp ; p ; p = q) { + q = p->next; + switch (p->keyword) { + case EXTRA_FUNC_DEFMODE: + if (p->u.modeptr->romdic_owner && + p->u.modeptr->romdic != (struct RkRxDic *)NULL) { + RkwCloseRoma(p->u.modeptr->romdic); + } + free(p->u.modeptr->emode); + if (p->u.modeptr->romaji_table) { + free(p->u.modeptr->romaji_table); + } + free(p->u.modeptr); + break; + case EXTRA_FUNC_DEFSELECTION: + free(p->u.kigoptr->kigo_str); + free(p->u.kigoptr->kigo_data); + free(p->u.kigoptr); + break; +#ifndef NO_EXTEND_MENU + case EXTRA_FUNC_DEFMENU: + freeMenu(p->u.menuptr); + break; +#endif + } + free(p); + } + extrafuncp = (extraFunc *)0; +} + +static +KC_finalize(uiContext d, char *arg) + /* ARGSUSED */ +{ + extern int FirstTime; + int res; + + /* ¥¦¥©¡¼¥Ë¥ó¥°¥á¥Ã¥»¡¼¥¸¤Î½é´ü²½ */ + initWarningMesg(); + if (arg) { + *(char ***)arg = 0; + } + + if (FirstTime) { + jrKanjiError = "\275\351\264\374\262\275\244\342\244\265\244\354\244\306" + "\244\244\244\312\244\244\244\316\244\313\241\330\275\252\244\357" + "\244\354\241\331\244\310\270\300\244\357\244\354\244\336\244\267" + "\244\277"; + /* ½é´ü²½¤â¤µ¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ë¡Ø½ª¤ï¤ì¡Ù¤È¸À¤ï¤ì¤Þ¤·¤¿ */ + return -1; + } + else { + FirstTime = 1; + + /* ¥«¥Ê´Á»úÊÑ´¹¤Î½ªÎ» */ + res = KanjiFin(); + + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤Î½ªÎ» */ + RomkanaFin(); + + /* free all uiContexts and hash tables here */ + + /* ¥­¡¼¥Þ¥Ã¥×¥Æ¡¼¥Ö¥ë¤Î¥¯¥ê¥¢ */ + restoreDefaultKeymaps(); + + /* ¥â¡¼¥Éʸ»úÎó¤Î¥Õ¥ê¡¼ */ + resetModeNames(); + + /* uiContext ¤Î¸¡º÷¤Î¤¿¤á¤Î¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤ò¥¯¥ê¥¢ + uiContext ¤â°ì½ï¤Ë¥Õ¥ê¡¼¤¹¤ë */ + clearHashTable(); + + /* µ­¹æÄêµÁ¤ò¾Ã¤¹ */ + freeKeysup(); + + /* ¿§¡¹¤È¥«¥¹¥¿¥Þ¥¤¥º¤µ¤ì¤Æ¤¤¤ë½ê¤ò¤â¤È¤ËÌ᤹¡£ */ + restoreBindings(); + + /* ³ÈÄ¥µ¡Ç½¤Îinitfileɽ¼¨ÍѤΥХåե¡¤ò²òÊü¤¹¤ë */ + freeBuffer(); + + /* ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿ÍѼ«Æ°¥á¥â¥ê´ÉÍý¤Î½ªÎ»½èÍý */ + WStringClose(); + + /* ¥µ¡¼¥Ð̾ÊÝ»ýÍÑ¥á¥â¥ê¤Î³«Êü */ + /* RkSetServerName((char *)0); ¤·¤Æ¤Ï¤¤¤±¤Ê¤¤¤Î¤Ç¤Ï¡© */ + +#ifndef NO_EXTEND_MENU + /* ¥á¥Ë¥å¡¼´ØÏ¢¤Î¥á¥â¥ê¤Î³«Êü */ + finExtMenu(); +#endif + + /* ¥Ç¥Õ¥©¥ë¥È°Ê³°¤Î¥â¡¼¥ÉÍÑ¥á¥â¥ê¤Î³«Êü */ + freeExtra(); + + /* ¥¨¥ó¥¸¥ó¤Î¥¯¥í¡¼¥º */ + close_engine(); + + if (arg) { + *(char ***)arg = nWarningMesg ? WarningMesg : (char **)0; + } + return res; + } +} + +static +KC_setWidth(uiContext d, caddr_t arg) +{ + d->ncolumns = (int)(POINTERINT)arg; + return 0; +} + +static +KC_setBunsetsuKugiri(uiContext d, caddr_t arg) + /* ARGSUSED */ +{ + cannaconf.BunsetsuKugiri = (int)(POINTERINT)arg; + return 0; +} + +#define CHANGEBUFSIZE 1024 + +static long gflags[] = { + 0L, + CANNA_YOMI_BASE_HANKAKU, + CANNA_YOMI_KATAKANA, + CANNA_YOMI_KATAKANA | CANNA_YOMI_HANKAKU | CANNA_YOMI_BASE_HANKAKU, + CANNA_YOMI_ROMAJI | CANNA_YOMI_ZENKAKU, + CANNA_YOMI_ROMAJI | CANNA_YOMI_BASE_HANKAKU, + CANNA_YOMI_KAKUTEI, + CANNA_YOMI_BASE_HANKAKU | CANNA_YOMI_KAKUTEI, + CANNA_YOMI_KATAKANA | CANNA_YOMI_KAKUTEI, + CANNA_YOMI_KATAKANA | CANNA_YOMI_HANKAKU | CANNA_YOMI_BASE_HANKAKU | + CANNA_YOMI_KAKUTEI, + CANNA_YOMI_ROMAJI | CANNA_YOMI_ZENKAKU | CANNA_YOMI_KAKUTEI, + CANNA_YOMI_ROMAJI | CANNA_YOMI_BASE_HANKAKU | CANNA_YOMI_KAKUTEI, +}; + +static +KC_changeMode(uiContext d, wcKanjiStatusWithValue *arg) +{ + coreContext cc; + yomiContext yc; + + d->buffer_return = arg->buffer; + d->n_buffer = arg->n_buffer; + d->kanji_status_return = arg->ks; + + bzero(d->kanji_status_return, sizeof(wcKanjiStatus)); + + d->nbytes = escapeToBasicStat(d, CANNA_FN_Quit); + cc = (coreContext)d->modec; + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + + if (cc->majorMode == CANNA_MODE_AlphaMode) { + /* ¦Á¥â¡¼¥É¤À¤Ã¤¿¤éÈ´¤±¤ë¡£ + ¥Ù¡¼¥·¥Ã¥¯¥â¡¼¥É¤Ï¦Á¥â¡¼¥É¤«ÊÑ´¹¥â¡¼¥É¤°¤é¤¤¤·¤«¤Ê¤¤¤È»×¤¦¡£ */ + if (arg->val == CANNA_MODE_AlphaMode) { + return 0; + } + else { + cc = (coreContext)cc->next; /* ¼¡¤Î¥³¥ó¥Æ¥¯¥¹¥È */ + yc = (yomiContext)cc; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + CannaBeep(); + arg->val = 0; + return 0; + } + + doFunc(d, CANNA_FN_JapaneseMode); + } + } + else { + yc = (yomiContext)cc; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + CannaBeep(); + arg->val = 0; + return 0; + } + } + + switch (arg->val) { + case CANNA_MODE_AlphaMode: + arg->val = doFunc(d, CANNA_FN_AlphaMode); + return 0; + + case CANNA_MODE_HenkanMode: + arg->val = doFunc(d, CANNA_FN_HenkanNyuryokuMode); + return 0; + +#ifndef NO_EXTEND_MENU + case CANNA_MODE_HexMode: + arg->val = doFunc(d, CANNA_FN_HexMode); + return 0; +#endif /* not NO_EXTEND_MENU */ + + case CANNA_MODE_BushuMode: + arg->val = doFunc(d, CANNA_FN_BushuMode); + return 0; + + case CANNA_MODE_KigoMode: + arg->val = doFunc(d, CANNA_FN_KigouMode); + return 0; + + case CANNA_MODE_TourokuMode: + arg->val = doFunc(d, CANNA_FN_ExtendMode); + return 0; + + case CANNA_MODE_HanKataHenkanMode: + case CANNA_MODE_HanKataKakuteiMode: + if (cannaconf.InhibitHankakuKana) { + CannaBeep(); + arg->val = 0; + return 0; + } + case CANNA_MODE_ZenHiraHenkanMode: + case CANNA_MODE_HanHiraHenkanMode: + case CANNA_MODE_ZenKataHenkanMode: + case CANNA_MODE_ZenAlphaHenkanMode: + case CANNA_MODE_HanAlphaHenkanMode: + case CANNA_MODE_ZenHiraKakuteiMode: + case CANNA_MODE_HanHiraKakuteiMode: + case CANNA_MODE_ZenKataKakuteiMode: + case CANNA_MODE_ZenAlphaKakuteiMode: + case CANNA_MODE_HanAlphaKakuteiMode: + yc->generalFlags &= ~(CANNA_YOMI_ATTRFUNCS | CANNA_YOMI_BASE_HANKAKU); + yc->generalFlags |= gflags[arg->val - CANNA_MODE_ZenHiraHenkanMode]; + EmptyBaseModeInfo(d, yc); + arg->val = 0; + return 0; + default: + return(-1); + } + /* NOTREACHED */ +} + +static +baseModeP(uiContext d) +{ + extern KanjiModeRec alpha_mode, empty_mode; + + return (d->current_mode == &alpha_mode) || + (d->current_mode == &empty_mode + && ((yomiContext)(d->modec))->next == (mode_context)0); +} + +/* + + ´ðËÜŪ¤Ê¾õÂ֤ˤâ¤É¤ë¡£¤¹¤Ê¤ï¤Á¡¢ÆÉ¤ß¤¬Æþ¤Ã¤Æ¤¤¤¿¤êÊÑ´¹Ãæ¤Î¾õÂÖ¤«¤éÈ´ + ¤±¤ë¡£¤¤¤«¤ËÈ´¤±¤ë¤«¤ÏÂ裲°ú¿ô¤Ç»ØÄꤹ¤ë¡£È´¤±Êý¤È¤·¤Æ¤Ï + + ¡¦QUIT (C-g) ¤ÇÈ´¤±¤ë + ¡¦³ÎÄê (Return) ¤ÇÈ´¤±¤ë + + ¤¬¤¢¤ë¡£ + +*/ + +escapeToBasicStat(uiContext d, int how) +{ + int len = 0, totallen = 0; + WCHAR_T *p = d->buffer_return; + int totalinfo = 0; + int maxcount = 32; + + do { + if(d->kanji_status_return) { + d->kanji_status_return->length = 0; + totalinfo |= (d->kanji_status_return->info & KanjiModeInfo); + } + else { + return -1; + } + d->kanji_status_return->info = 0; + d->nbytes = 0; /* ¤³¤ÎÃͤòÆþÎÏʸ»úĹ¤È¤·¤Æ»È¤¦¾ì¹ç¤¬¤¢¤ë¤Î¤Ç¥¯¥ê¥¢¤¹¤ë */ + len = doFunc(d, how); + d->buffer_return += len; + d->n_buffer -= len; + totallen += len; + maxcount--; + } while (maxcount > 0 && !baseModeP(d)); + d->kanji_status_return->info |= KanjiGLineInfo | totalinfo; + d->kanji_status_return->gline.length = 0; + d->kanji_status_return->gline.revPos = 0; + d->kanji_status_return->gline.revLen = 0; + d->buffer_return = p; + return totallen; +} + +static +KC_setUFunc(uiContext d, caddr_t arg) + /* ARGSUSED */ +{ + extern howToBehaveInCaseOfUndefKey; + + howToBehaveInCaseOfUndefKey = (int)(POINTERINT)arg; + return 0; +} + +static +KC_setModeInfoStyle(uiContext d, caddr_t arg) + /* ARGSUSED */ +{ + int tmpval; + extern howToReturnModeInfo; + + if ((tmpval = (int)(POINTERINT)arg) < 0 || tmpval > MaxModeInfoStyle) + return(-1); + howToReturnModeInfo = (int)(POINTERINT)arg; + return 0; +} + +static +KC_setHexInputStyle(uiContext d, caddr_t arg) + /* ARGSUSED */ +{ + cannaconf.hexCharacterDefiningStyle = (int)(POINTERINT)arg; + return 0; +} + +static +KC_inhibitHankakuKana(uiContext d, caddr_t arg) + /* ARGSUSED */ +{ + cannaconf.InhibitHankakuKana = (int)(POINTERINT)arg; + return 0; +} + +#ifndef NO_EXTEND_MENU +extern void popTourokuMode (uiContext); + +static +popTourokuWithGLineClear(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + tourokuContext tc; + + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + tc = (tourokuContext)d->modec; + if (tc->udic) { + free(tc->udic); + } + popTourokuMode(d); + popCallback(d); + GlineClear(d); + currentModeInfo(d); + return 0; +} +#endif + +static +KC_defineKanji(uiContext d, wcKanjiStatusWithValue *arg) +{ +#ifdef NO_EXTEND_MENU + return 0; +#else + /* I will leave the arrays on stack because the code below will not + be used in case WIN is defined. 1996.6.5 kon */ + d->buffer_return = arg->buffer; + d->n_buffer = arg->n_buffer; + d->kanji_status_return = arg->ks; + + if(arg->ks->length > 0 && arg->ks->echoStr && arg->ks->echoStr[0]) { + WCHAR_T xxxx[ROMEBUFSIZE]; + + WStrncpy(xxxx, arg->ks->echoStr, arg->ks->length); + xxxx[arg->ks->length] = (WCHAR_T)0; + + bzero(d->kanji_status_return, sizeof(wcKanjiStatus)); + + d->nbytes = escapeToBasicStat(d, CANNA_FN_Quit); + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + dicTourokuControl(d, xxxx, popTourokuWithGLineClear); + arg->val = d->nbytes; + } else { + d->nbytes = escapeToBasicStat(d, CANNA_FN_Quit); + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + arg->val = dicTourokuControl(d, 0, popTourokuWithGLineClear); + } + arg->val = callCallback(d, arg->val); + + return 0; +#endif /* NO_EXTEND_MENU */ +} + + +/* cfuncdef + + RK ¥³¥ó¥Æ¥¯¥¹¥È¤ò̵¸ú¤Ë¤¹¤ë¡£ + flag ¤¬£°°Ê³°¤Ê¤é RkwClose() ¤â¹Ô¤¦¡£ + + */ + +static void +closeRK(int *cxp, int flag) +{ + if (flag && *cxp >= 0) { + RkwCloseContext(*cxp); + } + *cxp = -1; +} + +/* cfuncdef + + closeRKContextInUIContext -- uiContext Ãæ¤Î RK ¥³¥ó¥Æ¥¯¥¹¥È¤ò close ¤¹¤ë¡£ + + */ + +static void closeRKContextInUIContext (uiContext, int); + +static void +closeRKContextInUIContext(uiContext d, int flag) /* £°°Ê³°¤Ê¤é¥¯¥í¡¼¥º¤â¤¹¤ë¡£ */ +{ + coreContext cc; + + closeRK(&(d->contextCache), flag); + for (cc = (coreContext)d->modec ; cc ; cc = (coreContext)cc->next) { + if (cc->id == YOMI_CONTEXT) { + closeRK(&(((yomiContext)cc)->context), flag); + } + } +} + +/* cfuncdef + + closeRKContextInMemory() -- ¤¹¤Ù¤Æ¤Î RK ¥³¥ó¥Æ¥¯¥¹¥È¤Î¥¯¥í¡¼¥º + + ¥Ð¥±¥Ã¥È¤Ë¤è¤Ã¤Æ¥Ý¥¤¥ó¥È¤µ¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿Æâ¤ÎÁ´¤Æ¤Î RK ¥³¥ó¥Æ¥¯¥¹¥È¤ò + ¥¯¥í¡¼¥º¤¹¤ë¡£ + +*/ + +static void +closeRKContextInMemory(struct bukRec *p, int flag) +{ + + while (p) { /* reconfirm that p points some structure */ + closeRKContextInUIContext(p->context, flag); + p = p->next; + } +} + +/* cfuncdef + + makeContextToBeClosed() -- ¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ëÆâ¤Î¥³¥ó¥Æ¥¯¥¹¥È¤ò̵¸ú¤Ë¤¹¤ë + +*/ + +void +makeAllContextToBeClosed(int flag) +{ + int i; + struct bukRec *p; + + for (i = 0 ; i < HASHTABLESIZE ; i++) { + p = conHash[i]; + if (p) { + closeRKContextInMemory(p, flag); + } + } +} + +static +KC_kakutei(uiContext d, wcKanjiStatusWithValue *arg) +{ + d->buffer_return = arg->buffer; + d->n_buffer = arg->n_buffer; + d->kanji_status_return = arg->ks; + + bzero(d->kanji_status_return, sizeof(wcKanjiStatus)); + + d->nbytes = escapeToBasicStat(d, CANNA_FN_Kakutei); + if ( !baseModeP(d) ) { + d->nbytes = escapeToBasicStat(d, CANNA_FN_Quit); + } + d->kanji_status_return->info &= ~KanjiThroughInfo; + arg->val = d->nbytes; + return d->nbytes; +} + +static +KC_kill(uiContext d, wcKanjiStatusWithValue *arg) +{ + d->buffer_return = arg->buffer; + d->n_buffer = arg->n_buffer; + d->kanji_status_return = arg->ks; + + bzero(d->kanji_status_return, sizeof(wcKanjiStatus)); + + d->nbytes = escapeToBasicStat(d, CANNA_FN_Quit); + d->kanji_status_return->info &= ~KanjiThroughInfo; + arg->val = d->nbytes; + return d->nbytes; +} + +static +KC_modekeys(uiContext d, unsigned char *arg) +{ + int n = 0; + int i; + extern KanjiModeRec alpha_mode; + int func; + + for (i = 0 ; i < 256 ; i++) { + func = alpha_mode.keytbl[i]; + if (func != CANNA_FN_SelfInsert && + func != CANNA_FN_FunctionalInsert && + func != CANNA_FN_Undefined && + func != CANNA_FN_FuncSequence && + func != CANNA_FN_UseOtherKeymap && + alpha_mode.func(d, &alpha_mode, KEY_CHECK, 0/*dummy*/, func)) { + arg[n++] = i; + } + } + return n; +} + +static +KC_queryMode(uiContext d, WCHAR_T *arg) +{ + return queryMode(d, arg); +} + +static +KC_queryConnection(uiContext d, unsigned char *arg) + /* ARGSUSED */ +{ + extern defaultContext; + + if (defaultContext != -1) { + return 1; + } + else { + return 0; + } +} + +static +KC_setServerName(uiContext d, unsigned char *arg) + /* ARGSUSED */ +{ + return RkSetServerName((char *)arg); +} + +static +KC_parse(uiContext d, char **arg) + /* ARGSUSED */ +{ + initWarningMesg(); + + parse_string(*arg); + + *(char ***)arg = nWarningMesg ? WarningMesg : (char **)0; + + return nWarningMesg; +} + +int yomiInfoLevel = 0; + +static +KC_yomiInfo(uiContext d, int arg) + /* ARGSUSED */ +{ + yomiInfoLevel = arg; + return 0; +} + +static +KC_storeYomi(uiContext d, wcKanjiStatusWithValue *arg) +{ + extern KanjiModeRec yomi_mode, cy_mode; + coreContext cc; + WCHAR_T *p, *q; + int len = 0; +#ifndef WIN + WCHAR_T buf[2048]; +#else + WCHAR_T *buf = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 2048); + if (!buf) { + /* This should the 'no more memory' message on the guide line... */ + arg->val = 0; + arg->ks->length = 0; + arg->ks->info = 0; + return len; + } +#endif + + p = arg->ks->echoStr; + q = arg->ks->mode; + if (p) { + WStrcpy(buf, p); + p = buf; + len = WStrlen(buf); + } + if (q) { + WStrcpy(buf + len + 1, q); + q = buf + len + 1; + } + KC_kill(d, arg); + cc = (coreContext)d->modec; + if (cc->majorMode == CANNA_MODE_AlphaMode) { + doFunc(d, CANNA_FN_JapaneseMode); + } + d->kanji_status_return = arg->ks; + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + RomajiStoreYomi(d, p, q); + if (p && *p) { + d->current_mode = + (((yomiContext)d->modec)->generalFlags & CANNA_YOMI_CHIKUJI_MODE) + ? &cy_mode : &yomi_mode; + } + makeYomiReturnStruct(d); + arg->val = 0; +#ifdef WIN + free(buf); +#endif + return 0; +} + +char *initFileSpecified = (char *)NULL; + +static +KC_setInitFileName(uiContext d, char *arg) + /* ARGSUSED */ +{ + int len; + + if (initFileSpecified) { /* °ÊÁ°¤Î¤â¤Î¤ò¥Õ¥ê¡¼¤¹¤ë */ + free(initFileSpecified); + } + + if ( arg && *arg ) { + len = strlen(arg); + initFileSpecified = (char *)malloc(len + 1); + if (initFileSpecified) { + strcpy(initFileSpecified, arg); + } + else { + return -1; + } + } + else { + initFileSpecified = (char *)NULL; + } + return 0; +} + +static +KC_do(uiContext d, wcKanjiStatusWithValue *arg) +{ + d->buffer_return = arg->buffer; + d->n_buffer = arg->n_buffer; + d->kanji_status_return = arg->ks; + d->ch = (unsigned)*(d->buffer_return); + d->nbytes = 1; + + bzero(d->kanji_status_return, sizeof(wcKanjiStatus)); + + arg->val = doFunc(d, arg->val); + return 0; +} + +#ifndef NO_EXTEND_MENU +/* + + ¥È¥Ã¥×¥ì¥Ù¥ë¤Ë¤Ï¤Ê¤¤¥â¡¼¥É¤ËÂФ·¤Æ²¿¤é¤«¤Îºî¶È¤ò + ¤µ¤»¤¿¤¤¤È¤­¤Ë¸Æ¤Ó½Ð¤¹´Ø¿ô¡£fnum == 0 ¤Ç d->ch ¤ò¸«¤ë¡£ + + '91.12.28 ¸½ºß¤Ç uldefine.c ¤«¤é¤·¤«¸Æ¤Ð¤ì¤Æ¤ª¤é¤º modec ¤ÎÃÍ¤Ï + yomi_mode ¤·¤«Æþ¤Ã¤Æ¤¤¤Ê¤¤¡£ + + ¤³¤Î´Ø¿ô¤Ï¤½¤ÎÀè¤Ç¸Æ¤Ö´Ø¿ô¤Ë¤è¤Ã¤Æ¥â¡¼¥É¤¬¥×¥Ã¥·¥å¤µ¤ì¤¿»þ¤Ê¤ÉÉüµ¢¤µ + ¤»¤ë¤³¤È¤¬½ÐÍè¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¦¤Î¤Ç¥â¡¼¥ÉÊѹ¹¤òȼ¤¦µ¡Ç½¤Î¸Æ½Ð¤·¤ò°ì»þ + Ū¤Ë¶Ø»ß¤¹¤ë¤³¤È¤È¤¹¤ë¡£ + + */ + +_do_func_slightly(uiContext d, int fnum, mode_context mode_c, KanjiMode c_mode) +{ + wcKanjiStatus ks; + long gfback; + BYTE inhback; + int retval; + yomiContext yc = (yomiContext)0; +#ifndef WIN + uiContextRec f, *e = &f; +#else + uiContext e = (uiContext)malloc(sizeof(uiContextRec)); + + if (e) { +#endif + + bzero(e, sizeof(uiContextRec)); + e->buffer_return = e->genbuf; + e->n_buffer = ROMEBUFSIZE; + e->kanji_status_return = &ks; + + e->nbytes = d->nbytes; + e->ch = d->ch; + + e->status = 0; /* ¥â¡¼¥É¤Ë¤Ä¤¤¤Æ"½èÍýÃæ"¤Î¥¹¥Æ¡¼¥¿¥¹¤ò´ûÄêÃͤȤ¹¤ë */ + e->more.todo = 0; + e->modec = mode_c; + e->current_mode = c_mode; + e->cb = (struct callback *)0; + + if (((coreContext)mode_c)->id == YOMI_CONTEXT) { + yc = (yomiContext)mode_c; + gfback = yc->generalFlags; + inhback = yc->henkanInhibition; + yc->generalFlags |= CANNA_YOMI_CHGMODE_INHIBITTED; + yc->henkanInhibition |= CANNA_YOMI_INHIBIT_ALL; + } + + retval = (*c_mode->func)(e, c_mode, KEY_CALL, e->ch, fnum); + + if (yc) { + yc->generalFlags = gfback; + yc->henkanInhibition = inhback; + } +#ifdef WIN + free(e); + } +#endif + return retval; +} + +#endif + +static +callCallback(uiContext d, int res) +{ + struct callback *cbp; + + for (cbp = d->cb; cbp ;) { + int index; + int (*callbackfunc) (uiContext, int, mode_context); + + index = d->status; + d->status = 0; /* Callback ¤¬¤Ê¤¯¤Æ¤â EXIT¡¢QUIT¡¢AUX ¤Ï¥¯¥ê¥¢¤¹¤ë */ + callbackfunc = cbp->func[index]; + if (callbackfunc) { + d->kanji_status_return->info &= ~KanjiEmptyInfo; + if (index) { /* everytime °Ê³° */ + res = (*callbackfunc)(d, res, cbp->env); + cbp = d->cb; /* ¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤Ë¤è¤ê¥³¡¼¥ë¥Ð¥Ã¥¯¤¬ + ¸Æ¤Ó½Ð¤µ¤ì¤ë¤Î¤ò»Ù±ç¤¹¤ë¤¿¤áÆþ¤ìľ¤¹ */ + /* ¤³¤³¤Ç¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô¤ò¥Ý¥Ã¥×¥¢¥Ã¥×¤·¤è¤¦¤«¤É¤¦¤«¹Í¤¨¤É¤³¤í */ + continue; + }else{ + res = (*callbackfunc)(d, res, cbp->env); + } + } + cbp = cbp->next; + } + return res; +} + +_doFunc(uiContext d, int fnum) +{ + int res = 0, tmpres, ginfo = 0; + int reallyThrough = 1; + WCHAR_T *prevEcho, *prevGEcho; + int prevEchoLen = -1, prevRevPos, prevRevLen; + int prevGEchoLen, prevGRevPos, prevGRevLen; + + d->status = 0; /* ¥â¡¼¥É¤Ë¤Ä¤¤¤Æ"½èÍýÃæ"¤Î¥¹¥Æ¡¼¥¿¥¹¤ò´ûÄêÃͤȤ¹¤ë */ + d->more.todo = 0; + tmpres = d->current_mode->func(d, d->current_mode, KEY_CALL, d->ch, fnum); + + if (d->flags & MULTI_SEQUENCE_EXECUTED) { + d->flags &= ~MULTI_SEQUENCE_EXECUTED; + return tmpres; + } + + /* ¥³¡¼¥ë¥Ð¥Ã¥¯¤ò¼Â¹Ô¤¹¤ë */ + res = tmpres = callCallback(d, tmpres); + + if (d->kanji_status_return->length >= 0) { + prevEcho = d->kanji_status_return->echoStr; + prevEchoLen = d->kanji_status_return->length; + prevRevPos = d->kanji_status_return->revPos; + prevRevLen = d->kanji_status_return->revLen; + } + if (d->kanji_status_return->info & KanjiGLineInfo) { + ginfo = 1; + prevGEcho = d->kanji_status_return->gline.line; + prevGEchoLen = d->kanji_status_return->gline.length; + prevGRevPos = d->kanji_status_return->gline.revPos; + prevGRevLen = d->kanji_status_return->gline.revLen; + } + + /* moreToDo ¤â¼Â¹Ô¤·¤Ê¤¯¤Æ¤Ï */ + while (d->more.todo) { + if (!(d->kanji_status_return->info & KanjiThroughInfo)) { + reallyThrough = 0; + } + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + d->more.todo = 0; + d->ch = d->more.ch; /* moreTodo ¤Ë more.ch ¤Ï¤¤¤é¤Ê¤¤¤Î¤Ç¤Ï¡© */ + d->nbytes = 1; + d->buffer_return += tmpres; + d->n_buffer -= tmpres; + + { + int check; + /* £²²óÌܰʹߤ˰ʲ¼¤Î¥Ç¡¼¥¿¤¬¼º¤ï¤ì¤Æ¤¤¤ë¾ì¹ç¤¬¤¢¤ë¤Î¤ÇÆþ¤ìľ¤¹¡£ */ + d->buffer_return[0] = key2wchar(d->ch, &check); + if (!check) { + d->nbytes = 0; + } + } + + tmpres = _doFunc(d, d->more.fnum); + + if (tmpres >= 0) { + res += tmpres; + if (d->kanji_status_return->length >= 0) { + prevEcho = d->kanji_status_return->echoStr; + prevEchoLen = d->kanji_status_return->length; + prevRevPos = d->kanji_status_return->revPos; + prevRevLen = d->kanji_status_return->revLen; + } + if (d->kanji_status_return->info & KanjiGLineInfo) { + ginfo = 1; + prevGEcho = d->kanji_status_return->gline.line; + prevGEchoLen = d->kanji_status_return->gline.length; + prevGRevPos = d->kanji_status_return->gline.revPos; + prevGRevLen = d->kanji_status_return->gline.revLen; + } + } + } + if (!reallyThrough) { + d->kanji_status_return->info &= ~KanjiThroughInfo; + } + + d->kanji_status_return->length = prevEchoLen; + if (prevEchoLen >= 0) { + d->kanji_status_return->echoStr = prevEcho; + d->kanji_status_return->revPos = prevRevPos; + d->kanji_status_return->revLen = prevRevLen; + } + if (ginfo) { + d->kanji_status_return->gline.line = prevGEcho; + d->kanji_status_return->gline.length = prevGEchoLen; + d->kanji_status_return->gline.revPos = prevGRevPos; + d->kanji_status_return->gline.revLen = prevGRevLen; + d->kanji_status_return->info |= KanjiGLineInfo; + } + + return res; +} + +_afterDoFunc(uiContext d, int retval) +{ + int res = retval; + wcKanjiStatus *kanji_status_return = d->kanji_status_return; + + /* GLine ¤ò¾Ã¤»¤È¸À¤¦¤Î¤Ê¤é¾Ã¤·¤Þ¤·¤ç¤¦ */ + if (d->flags & PLEASE_CLEAR_GLINE) { + if (d->flags & PCG_RECOGNIZED) { /* Á°¤ÎÁ°°ÊÁ°¤Ê¤é */ + if (res >= 0 && kanji_status_return->length >= 0) { + d->flags &= ~(PLEASE_CLEAR_GLINE | PCG_RECOGNIZED); + /* ¤³¤ì¤ÇÌòÌܤò²Ì¤¿¤·¤Þ¤·¤¿ */ + if (!(kanji_status_return->info & KanjiGLineInfo)) { + GlineClear(d); + } + } + } + else { + d->flags |= PCG_RECOGNIZED; + } + } + return res; +} + +/* cfuncdef + + doFunc -- _doFunc ¤òÆÉ¤ó¤Ç¡¢¤µ¤é¤Ë ClearGLine ½èÍý¤ä¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¤Î + ½èÍý¤ò¤¹¤ë¡£ + + */ + +doFunc(uiContext d, int fnum) +{ + return _afterDoFunc(d, _doFunc(d, fnum)); +} + +static +KC_getContext(uiContext d, int arg) + /* ARGSUSED */ +{ + extern defaultContext, defaultBushuContext; + + switch (arg) + { + case 0: + return RkwDuplicateContext(defaultContext); + case 1: + return RkwDuplicateContext(defaultBushuContext); + case 2: + return defaultContext; + default: + return(-1); + } + /* NOTREACHED */ +} + +static +KC_closeUIContext(uiContext d, wcKanjiStatusWithValue *arg) +{ + extern struct ModeNameRecs ModeNames[]; + int ret; + + d->buffer_return = arg->buffer; + d->n_buffer = arg->n_buffer; + d->kanji_status_return = arg->ks; + + bzero(d->kanji_status_return, sizeof(wcKanjiStatus)); + + if ((d->nbytes = escapeToBasicStat(d, CANNA_FN_Quit)) < 0) + return -1; + d->kanji_status_return->info &= ~KanjiThroughInfo; + arg->val = d->nbytes; + freeRomeStruct(d); + + ret = countContext(); +#if defined(DEBUG) && !defined(WIN) + fprintf(stderr, "ret=%d\n", ret); +#endif + return ret; +} + +static yomiContext +getYomiContext(uiContext d) +{ + coreContext cc = (coreContext)d->modec; + yomiContext yc; + + switch (cc->id) { + case YOMI_CONTEXT: + yc = (yomiContext)cc; + break; + default: + if (cc->minorMode == CANNA_MODE_AlphaMode) { + yc = (yomiContext)(cc->next); + } + else { + yc = (yomiContext)0; + } + break; + } + return yc; +} + +static +KC_inhibitChangeMode(uiContext d, int arg) +{ + yomiContext yc; + + yc = getYomiContext(d); + if (yc) { + if (arg) { + yc->generalFlags |= CANNA_YOMI_CHGMODE_INHIBITTED; + } + else { + yc->generalFlags &= ~CANNA_YOMI_CHGMODE_INHIBITTED; + } + return 0; + } + else { + return -1; + } +} + +static +KC_letterRestriction(uiContext d, int arg) +{ + yomiContext yc; + + yc = getYomiContext(d); + if (yc) { + yc->allowedChars = arg; + return 0; + } + else { + return -1; + } +} + +static +countColumns(WCHAR_T *str) +{ + int len = 0; + WCHAR_T *p; + + if (str) { + for (p = str ; *p ; p++) { + switch (WWhatGPlain(*p)) { + case 0: + case 2: + len += 1; + break; + case 1: + case 3: + len += 2; + break; + } + } + } + return len; +} + +static +KC_queryMaxModeStr(uiContext d, int arg) + /* ARGSUSED */ +{ + int i, maxcolumns = 0, ncols; + extern struct ModeNameRecs ModeNames[]; + extern extraFunc *extrafuncp; + extraFunc *ep; + + for (i = 0 ; i < CANNA_MODE_MAX_IMAGINARY_MODE ; i++) { + ncols = countColumns(ModeNames[i].name); + if (ncols > maxcolumns) { + maxcolumns = ncols; + } + } + for (ep = extrafuncp ; ep ; ep = ep->next) { + ncols = countColumns(ep->display_name); + if (ncols > maxcolumns) { + maxcolumns = ncols; + } + } + return maxcolumns; +} + +static int +KC_setListCallback(uiContext d, jrListCallbackStruct *arg) +{ + if (cannaconf.iListCB) { + d->client_data = (char *)0; + d->list_func = (int (*) (char *, int, WCHAR_T **, int, int *))0; + return -1; + } + if (arg->callback_func) { + d->client_data = arg->client_data; + d->list_func = arg->callback_func; + } + else { + d->client_data = (char *)0; + d->list_func = (int (*) (char *, int, WCHAR_T **, int, int *))0; + } + return 0; +} + +static int +KC_setVerbose(uiContext d, int arg) + /* ARGSUSED */ +{ + extern int ckverbose; + + ckverbose = arg; + return 0; +} + +/* kanjiInitialize ¤«¤Ê´Á»úÊÑ´¹¤Î½é´ü²½ KC_INITIALIZE¤ÈÅù²Á¤Ç¤¢¤ë¡£ */ + +int kanjiInitialize (char ***mes) +{ + return KC_initialize((uiContext)0, (char *)mes); +} + +/* kanjiFinalize KC_FINALIZE¤ÈÅù²Á¤Ç¤¢¤ë¡£ */ + +int kanjiFinalize (char ***mes) +{ + return KC_finalize((uiContext)0, (char *)mes); +} + +/* createKanjiContext ¥³¥ó¥Æ¥¯¥¹¥È¤òºîÀ®¤¹¤ë¤â¤Î¤Ç¤¢¤ë¡£ */ + +static unsigned char context_table[100] = ""; + +createKanjiContext() +{ + int i; + + for (i = 0; i < 100; i++) { + if (!context_table[i]) { + context_table[i] = 1; + return i; + } + } + return -1; /* ¥³¥ó¥Æ¥¯¥¹¥È¤ò¼èÆÀ¤Ç¤­¤Ê¤«¤Ã¤¿¡£ */ +} + +/* wcCloseKanjiContext ¥³¥ó¥Æ¥¯¥¹¥È¤ò¥¯¥í¡¼¥º¤¹¤ë¤â¤Î¡£ */ +int +wcCloseKanjiContext ( +const int context, +wcKanjiStatusWithValue *ksva) +{ + context_table[context] = 0; + return XwcKanjiControl2(0, context, KC_CLOSEUICONTEXT, (BYTE *)ksva); +} + +/* jrCloseKanjiContext ¥³¥ó¥Æ¥¯¥¹¥È¤ò¥¯¥í¡¼¥º¤¹¤ë¤â¤Î¡£ */ + +int +jrCloseKanjiContext ( + const int context, + jrKanjiStatusWithValue *ksva +) +{ + context_table[context] = 0; + return XKanjiControl2(0, context, KC_CLOSEUICONTEXT, (BYTE *)ksva); +} + +int +ToggleChikuji(uiContext d, int flg) +{ + yomiContext yc = (yomiContext)d->modec; + extern KanjiModeRec empty_mode; + extern struct CannaConfig cannaconf; + + if ((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && + yc->context != -1) { + RkwEndBun(yc->context, 0); + abandonContext(d, yc); + } + (void)escapeToBasicStat(d, CANNA_FN_Kakutei); + d->kanji_status_return->info &= ~KanjiThroughInfo; + + if (flg) { + /* Ã༡¼«Æ°¤ËÊѤ¨¤ë */ + yc->generalFlags |= CANNA_YOMI_CHIKUJI_MODE; + yc->majorMode = CANNA_MODE_HenkanMode; + cannaconf.chikuji = 1; + } + else { + /* ϢʸÀá¤ËÊѤ¨¤ë */ + yc->generalFlags &= ~CANNA_YOMI_CHIKUJI_MODE; + yc->majorMode = CANNA_MODE_HenkanMode; + cannaconf.chikuji = 0; + } + yc->minorMode = getBaseMode(yc); + d->majorMode = d->minorMode = CANNA_MODE_AlphaMode; /* ¥À¥ß¡¼ */ + currentModeInfo(d); + return 0; +} + +static int +KC_lispInteraction(uiContext d, int arg) +/* ARGSUSED */ +{ + clisp_main(); + return 0; +} + +/* + * ¥µ¡¼¥Ð¤È¤ÎÀܳ¤òÀÚ¤ë + */ +static int +KC_disconnectServer(uiContext d, int arg) +/* ARGSUSED */ +{ + +#if defined(DEBUG) && !defined(WIN) + fprintf(stderr,"¥µ¡¼¥Ð¤È¤ÎÀܳ¤òÀÚ¤ë\n"); +#endif + jrKanjiPipeError(); + return 0; +} + +static int +KC_setAppName(uiContext d, unsigned char *arg) +/* ARGSUSED */ +{ + extern int defaultContext; + + if (strlen((char *)arg) > CANNA_MAXAPPNAME) { + strncpy(saveapname, (char *)arg, CANNA_MAXAPPNAME); + saveapname[CANNA_MAXAPPNAME - 1] = '\0'; + } + else { + strcpy(saveapname, (char *)arg); + } + RkwSetAppName(defaultContext, saveapname); + + return(0); +} + +static int +KC_debugmode(uiContext d, int arg) +/* ARGSUSED */ +{ + extern int iroha_debug; + + iroha_debug = arg; + return 0; +} + +static void +debug_yomibuf(yomiContext yc) +/* ARGSUSED */ +{ +#if defined(DEBUG) && !defined(WIN) + char kana[1024], roma[1024], ka[1024], ya[1024], *kanap, *romap, *kap, *yap; + int len, i, j, k, maxcol, columns, tmp; + WCHAR_T xxx[1024]; + +#define MANYSPACES " " + + kanap = kana; romap = roma; kap = ka; yap = ya; + + for (i = 0, j = 0 ; i < yc->kEndp || j < yc->rEndp ;) { + maxcol = 0; + + if (i < yc->kEndp) { + k = i + 1; + columns = 0; + tmp = + (WIsG0(yc->kana_buffer[i]) || WIsG2(yc->kana_buffer[i])) ? 1 : 2; + if (i == yc->kRStartp && i != yc->kCurs) { + *kanap++ = '\''; + *kap++ = '\''; + columns++; + } + if (yc->kAttr[i] & HENKANSUMI) { + *kap++ = ' '; + }else{ + *kap++ = 'x'; + } + if (tmp > 1) { + *kap++ = ' '; + } + columns += tmp; + while (!(yc->kAttr[k] & SENTOU)) { + tmp = (WIsG0(yc->kana_buffer[k]) || WIsG2(yc->kana_buffer[k])) ? 1 : 2; + columns += tmp; + if (yc->kAttr[k] & HENKANSUMI) { + *kap++ = ' '; + } + else { + *kap++ = 'x'; + } + if (tmp > 1) { + *kap++ = ' '; + } + k++; + } + WStrncpy(xxx, yc->kana_buffer + i, k - i); + xxx[k - i] = (WCHAR_T)0; + sprintf(kanap, "%ws ", xxx); + *kap++ = ' '; + len = strlen(kanap); + if (columns > maxcol) { + maxcol = columns; + }else{ + strncpy(kanap + len, MANYSPACES, maxcol - columns); + strncpy(kap, MANYSPACES, maxcol - columns); + kap += maxcol - columns; + len += maxcol - columns; + } + kanap += len; + i = k; + } + + if (j < yc->rEndp) { + k = j + 1; + columns = + (WIsG0(yc->romaji_buffer[j]) || WIsG2(yc->romaji_buffer[j])) ? 1 : 2; + if (j == yc->rStartp && j != yc->rCurs) { + *romap++ = '\''; + columns++; + } + while (!(yc->rAttr[k] & SENTOU)) { + columns += + (WIsG0(yc->romaji_buffer[k]) || WIsG2(yc->romaji_buffer[k])) ? 1 : 2; + k++; + } + WStrncpy(xxx, yc->romaji_buffer + j, k - j); + xxx[k - j] = (WCHAR_T)0; + sprintf(romap, "%ws ", xxx); + len = strlen(romap); + if (columns > maxcol) { + strncpy(kanap, MANYSPACES, columns - maxcol); + kanap += columns - maxcol; + strncpy(kap, MANYSPACES, columns - maxcol); + kap += columns - maxcol; + maxcol = columns; + }else{ + strncpy(romap + len, MANYSPACES, maxcol - columns); + len += maxcol - columns; + } + romap += len; + j = k; + } + } + *kap = *kanap = *romap = '\0'; + printf("%s\n", roma); + printf("%s\n", kana); + printf("%s\n", ka); +#endif /* DEBUG */ +} + +static int +KC_debugyomi(uiContext d, int arg) +/* ARGSUSED */ +{ + if (((coreContext)(d)->modec)->id == YOMI_CONTEXT) { + debug_yomibuf((yomiContext)d->modec); + } + return 0; +} + +static int +KC_queryPhono(uiContext d, char *arg) +/* ARGSUSED */ +{ + extern struct RkRxDic *romajidic; + struct RkRxDic **foo = (struct RkRxDic **)arg; + + *foo = romajidic; + return 0; +} + +static int +KC_changeServer(uiContext d, char *arg) +/* ARGSUSED */ +{ + extern defaultContext; + char *p; + + if (!arg) { + RkSetServerName((char *)0); + return 0; + } + + jrKanjiPipeError(); + if (RkSetServerName((char *)arg) && (p = index((char *)arg, '@'))) { +#ifndef WIN + char xxxx[512]; +#else + char *xxxx = malloc(512); + if (!xxxx) { + return 0; + } +#endif + + *p = '\0'; +#ifndef WIN + sprintf(xxxx, "¤«¤Ê´Á»úÊÑ´¹¥¨¥ó¥¸¥ó %s ¤ÏÍøÍѤǤ­¤Þ¤»¤ó", (char *)arg); +#else + sprintf(xxxx, "\244\253\244\312\264\301\273\372\312\321\264\271\245\250\245\363\245\270\245\363 %s \244\317\315\370\315\321\244\307\244\255\244\336\244\273\244\363\n", + (char *)arg); +#endif + makeGLineMessageFromString(d, xxxx); + + RkSetServerName((char *)0); +#ifdef WIN + free(xxxx); +#endif + return 0; + } + + if (defaultContext == -1) { + if ((KanjiInit() != 0) || (defaultContext == -1)) { +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271" + "\245\265\241\274\245\320\244\310\304\314\277\256" + "\244\307\244\255\244\336\244\273\244\363"; +#endif + return 0; + } + } + return (int)RkwGetServerName(); +} + +static int +KC_setUserInfo(uiContext d, jrUserInfoStruct *arg) +/* ARGSUSED */ +{ + extern jrUserInfoStruct *uinfo; + int ret = -1; + char *uname, *gname, *srvname, *topdir, *cannafile, *romkanatable; +#ifndef WIN + char buf[256]; +#else + char *buf = malloc(256); + if (!buf) { + return -1; + } +#endif + + if (arg) { + uname = arg->uname ? strdup(arg->uname) : (char *)0; + if (uname || !arg->uname) { + gname = arg->gname ? strdup(arg->gname) : (char *)0; + if (gname || !arg->gname) { + srvname = arg->srvname ? strdup(arg->srvname) : (char *)0; + if (srvname || !arg->srvname) { + topdir = arg->topdir ? strdup(arg->topdir) : (char *)0; + if (topdir || !arg->topdir) { + cannafile = arg->cannafile ? strdup(arg->cannafile) : (char *)0; + if (cannafile || !arg->cannafile) { + romkanatable = + arg->romkanatable ? strdup(arg->romkanatable) : (char *)0; + if (romkanatable || !arg->romkanatable) { + uinfo = (jrUserInfoStruct *)malloc(sizeof(jrUserInfoStruct)); + if (uinfo) { + uinfo->uname = uname; + uinfo->gname = gname; + uinfo->srvname = srvname; + uinfo->topdir = topdir; + uinfo->cannafile = cannafile; + uinfo->romkanatable = romkanatable; + + if (uinfo->srvname) { + KC_setServerName(d, (unsigned char *)uinfo->srvname); + } + if (uinfo->cannafile) { + char *p = uinfo->cannafile; + + if (strlen(p) >= 3 && (p[0] == '\\' || p[0] == '/' || + p[1] == ':' && p[2] == '\\' || + p[1] == ':' && p[2] == '/')) + strcpy(buf, p); + else if (uinfo->uname) + sprintf(buf, "%s/%s/%s/%s/%s", + uinfo->topdir ? uinfo->topdir : "", + "dic", "user", + uinfo->uname, uinfo->cannafile); + else + buf[0] = '\0'; + } + else { + sprintf(buf, "%s/%s", + uinfo->topdir ? uinfo->topdir : "", "default.can"); + } + wcKanjiControl((int)d, KC_SETINITFILENAME, buf); + RkwSetUserInfo(uinfo->uname, uinfo->gname, uinfo->topdir); + ret = 1; + goto return_ret; + } + if (romkanatable) free(romkanatable); + } + if (cannafile) free(cannafile); + } + if (topdir) free(topdir); + } + if (srvname) free(srvname); + } + if (gname) free(gname); + } + if (uname) free(uname); + } +#ifndef WIN + jrKanjiError = "malloc (SetUserinfo) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (SetUserinfo) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; +#endif + } + ret = -1; + + return_ret: +#ifdef WIN + free(buf); +#endif + return ret; +} + +static int +KC_queryCustom(uiContext d, jrCInfoStruct *arg) +/* ARGSUSED */ +{ + extern struct CannaConfig cannaconf; + static char *input_code[CANNA_MAX_CODE] = {"jis", "sjis", "kuten"}; + + if (/* 0 <= cannaconf.code_input && // unsigned ¤Ê¤Î¤Çɬ¤º¿¿ */ + cannaconf.code_input <= CANNA_MAX_CODE) { + strcpy(arg->codeinput, input_code[cannaconf.code_input]); + } + arg->quicklyescape = cannaconf.quickly_escape; + arg->indexhankaku = cannaconf.indexHankaku; + arg->indexseparator = cannaconf.indexSeparator; + arg->selectdirect = cannaconf.SelectDirect; + arg->numericalkeysel = cannaconf.HexkeySelect; + arg->kouhocount = cannaconf.kCount; + + return 0; +} + +static int +KC_closeAllContext(uiContext d, char *arg) +/* ARGSUSED */ +{ + makeAllContextToBeClosed(1); + return 0; +} + +static int +KC_attributeInfo(uiContext d, char *arg) +{ + wcKanjiAttributeInternal **p = (wcKanjiAttributeInternal **)arg; + + if (p) { + if (!d->attr) { + d->attr = (wcKanjiAttributeInternal *) + malloc(sizeof(wcKanjiAttributeInternal)); + if (d->attr) { + d->attr->u.attr = (char *)malloc(ROMEBUFSIZE); + if (d->attr->u.attr) { + d->attr->len = ROMEBUFSIZE; + *p = d->attr; + return 0; + } + free(d->attr); + d->attr = (wcKanjiAttributeInternal *)0; + } + } + else { /* called twice */ + *p = d->attr; + return 0; + } + } + else if (d->attr) { /* && !p */ + free(d->attr->u.attr); + free(d->attr); + d->attr = (wcKanjiAttributeInternal *)0; + return 0; + } + return -1; +} + +/* KanjiControl¤Î¸Ä¡¹¤ÎÀ©¸æ´Ø¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿ */ + +static int (*kctlfunc[MAX_KC_REQUEST])(...) = { + KC_initialize, + KC_finalize, + KC_changeMode, + KC_setWidth, + KC_setUFunc, + KC_setBunsetsuKugiri, + KC_setModeInfoStyle, + KC_setHexInputStyle, + KC_inhibitHankakuKana, + KC_defineKanji, + KC_kakutei, + KC_kill, + KC_modekeys, + KC_queryMode, + KC_queryConnection, + KC_setServerName, + KC_parse, + KC_yomiInfo, + KC_storeYomi, + KC_setInitFileName, + KC_do, + KC_getContext, + KC_closeUIContext, + KC_inhibitChangeMode, + KC_letterRestriction, + KC_queryMaxModeStr, + KC_setListCallback, + KC_setVerbose, + KC_lispInteraction, + KC_disconnectServer, + KC_setAppName, + KC_debugmode, + KC_debugyomi, + KC_keyconvCallback, + KC_queryPhono, + KC_changeServer, + KC_setUserInfo, + KC_queryCustom, + KC_closeAllContext, + KC_attributeInfo, +}; + +kanjiControl(int request, uiContext d, caddr_t arg) +{ + return kctlfunc[request](d, arg); +} diff --git a/src/add-ons/input_server/methods/canna/lib/keydef.c b/src/add-ons/input_server/methods/canna/lib/keydef.c new file mode 100644 index 0000000000..5f93c04dad --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/keydef.c @@ -0,0 +1,874 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: keydef.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include +#include + +extern KanjiModeRec alpha_mode, empty_mode, yomi_mode; +extern KanjiModeRec jishu_mode, ce_mode, cy_mode, cb_mode; +extern KanjiModeRec tankouho_mode, ichiran_mode, onoff_mode; +extern KanjiModeRec khal_mode, khkt_mode, kzal_mode, kzhr_mode, kzkt_mode; +extern KanjiModeRec kigo_mode; +extern KanjiModeRec tourokureibun_mode; +extern KanjiModeRec bunsetsu_mode; +extern KanjiModeRec cy_mode, cb_mode; + +//extern multiSequenceFunc +// (struct _uiContext *, struct _kanjiMode *, int, int, int); + +#define NONE 0 +#define ACTHASHTABLESIZE 64 +#define KEYHASHTABLESIZE 16 + +#define SINGLE 0 +#define MULTI 1 +#define OTHER 2 + +static unsigned char *duplicatekmap(unsigned char *kmap); +static int changeKeyOnSomeCondition(KanjiMode mode, int key, int fnum, unsigned char *actbuff, unsigned char *keybuff); +static void undefineKeyfunc(unsigned char *keytbl, unsigned fnum); +//static unsigned int createHashKey(unsigned char *data1, unsigned char data2, int which_seq); +static void regist_act_hash(unsigned char *tbl_ptr, unsigned char key, unsigned char *buff); +static void remove_hash(unsigned char *tbl_ptr, unsigned char key, int which_seq); +static void freeChain(struct seq_struct *p); +static void clearAllFuncSequence(void); +static void freeKeySeqMode(KanjiMode m); +static void freeMap(struct map *m); +static void clearAllKeySequence(void); +static specialen(unsigned char *block); +static to_write_act(int depth, int keysize, int actsize, unsigned singleAct); +static struct map *regist_map(KanjiMode tbl, unsigned char *keybuff, unsigned char *actbuff, int depth); +static int regist_key_hash(unsigned char *tbl_ptr, unsigned char *keybuff, unsigned char *actbuff); +static int copyMultiSequence(unsigned char key, KanjiMode old_tbl, KanjiMode new_tbl); +static void freeMultiSequence(unsigned char key, KanjiMode tbl); + +struct seq_struct{ + unsigned char *to_tbl; + unsigned char as_key; + unsigned char *kinou_seq; + struct seq_struct *next; +}; + +static struct seq_struct *seq_hash[ACTHASHTABLESIZE]; + +struct map{ + KanjiMode tbl; + unsigned char key; + KanjiMode mode; + struct map *next; +}; + +static struct map *otherMap[KEYHASHTABLESIZE]; + +static KanjiMode ModeTbl[CANNA_MODE_MAX_REAL_MODE] = { + &alpha_mode, /* AlphaMode ¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¥â¡¼¥É */ + &empty_mode, /* EmptyMode ÆÉ¤ßÆþÎϤ¬¤Ê¤¤¾õÂÖ */ + &kigo_mode, /* KigoMode ¸õÊä°ìÍ÷¤òɽ¼¨¤·¤Æ¤¤¤ë¾õÂÖ */ + &yomi_mode, /* YomiMode ÆÉ¤ßÆþÎϤ·¤Æ¤¤¤ë¾õÂÖ */ + &jishu_mode, /* JishuMode ʸ»ú¼ïÊÑ´¹¤·¤Æ¤¤¤ë¾õÂÖ */ + &tankouho_mode, /* TankouhoMode ñ°ì¤Î¸õÊä¤òɽ¼¨¤·¤Æ¤¤¤ë¾õÂÖ */ + &ichiran_mode, /* IchiranMode ¸õÊä°ìÍ÷¤òɽ¼¨¤·¤Æ¤¤¤ë¾õÂÖ */ + &tourokureibun_mode, /* TourokuReibunMode ñ¸ìÅÐÏ¿¤ÎÎãʸɽ¼¨¾õÂÖ */ + &onoff_mode, /* OnOffMode On/Off¤Î°ìÍ÷¤Îɽ¼¨¾õÂÖ */ + &bunsetsu_mode, /* AdjustBunsetsuMode ʸÀá¿­½Ì¥â¡¼¥É */ + &cy_mode, /* ChikujiYomiMode Ã༡¤Î»þ¤ÎÆÉ¤ßÉôʬ */ + &cb_mode, /* ChikujiHenkanMode Ã༡¤Î»þ¤ÎÊÑ´¹¤ÎÉôʬ */ +}; + + +static unsigned char * +duplicatekmap(unsigned char *kmap) +{ + unsigned char *res; + int i; + + res = (unsigned char *)calloc(256, sizeof(unsigned char)); + if (res) { + for (i = 0 ; i < 256 ; i++) { + res[i] = kmap[i]; + } + } + return res; +} + +static unsigned char *defaultkeytables[CANNA_MODE_MAX_REAL_MODE]; +static unsigned char defaultsharing[CANNA_MODE_MAX_REAL_MODE]; +static unsigned char *defaultmap; +unsigned char *alphamap, *emptymap; + +/* cfuncdef + + initKeyTables() -- ¥­¡¼¥Æ¡¼¥Ö¥ë¤ò½é´ü²½¤¹¤ë´Ø¿ô¡£ + + ¥Ç¥Õ¥©¥ë¥È¤Î¥­¡¼¥Æ¡¼¥Ö¥ë¤òµ­Ï¿¤·¤Æ¤ª¤­¡¢¼Â»ÈÍѤΥơ¼¥Ö¥ë¤ò ¥Ç¥Õ¥©¥ë + ¥È¥Æ¡¼¥Ö¥ë¤«¤é¥³¥Ô¡¼¤¹¤ë½èÍý¤ò¹Ô¤¦¡£ + +*/ + +initKeyTables(void) +{ + int i; + unsigned char *tbl; + extern unsigned char default_kmap[], alpha_kmap[], empty_kmap[]; + + defaultmap = duplicatekmap(default_kmap); + if (defaultmap) { + alphamap = duplicatekmap(alpha_kmap); + if (alphamap) { + emptymap = duplicatekmap(empty_kmap); + if (emptymap) { + for (i = 0 ; i < CANNA_MODE_MAX_REAL_MODE ; i++) { + if (ModeTbl[i]) { + defaultsharing[i] = ModeTbl[i]->flags; + tbl = defaultkeytables[i] = ModeTbl[i]->keytbl; + if (tbl == default_kmap) { + ModeTbl[i]->keytbl = defaultmap; + } + else if (tbl == alpha_kmap) { + ModeTbl[i]->keytbl = alphamap; + } + else if (tbl == empty_kmap) { + ModeTbl[i]->keytbl = emptymap; + } + } + } + return 0; + } + free(alphamap); + } + free(defaultmap); + } + return NG; +} + +void +restoreDefaultKeymaps(void) +{ + int i; + + for (i = 0 ; i < CANNA_MODE_MAX_REAL_MODE ; i++) { + if (ModeTbl[i]) { + if ( !(ModeTbl[i]->flags & CANNA_KANJIMODE_TABLE_SHARED) ) { + free(ModeTbl[i]->keytbl); + } + ModeTbl[i]->keytbl = defaultkeytables[i]; + ModeTbl[i]->flags = defaultsharing[i]; + } + } + free(defaultmap); + free(alphamap); + free(emptymap); + clearAllFuncSequence(); + clearAllKeySequence(); +} + + +/* + * ¤¢¤ë¥â¡¼¥É¤Î¥­¡¼¤ËÂФ·¤Æ´Ø¿ô¤ò³ä¤êÅö¤Æ¤ë½èÍý + * + */ + +/* + + £±£¶¿Ê¤Î»þ¤Ï£´Ê¸»úÌܤòÆþ¤ì¤¿»þ¤Î¥â¡¼¥É¤Ë¤âÀßÄꤹ¤ë¡£ + + */ + +extern int nothermodes; + +changeKeyfunc(int modenum, int key, int fnum, unsigned char *actbuff, unsigned char *keybuff) +{ + int i, retval = 0; + unsigned char *p, *q; + KanjiMode mode; + newmode *nmode; + + /* ¤Á¤ç¤Ã¤È¾®ºÙ¹© */ + if (modenum == CANNA_MODE_HenkanNyuryokuMode) { + retval = changeKeyfunc(CANNA_MODE_EmptyMode, key, fnum, actbuff, keybuff); + if (retval < 0) { + return retval; + } + modenum = CANNA_MODE_YomiMode; + } + + if (modenum < 0) { + return 0; + } + else if (modenum < CANNA_MODE_MAX_REAL_MODE) { + mode = ModeTbl[modenum]; + } + else if (modenum < CANNA_MODE_MAX_IMAGINARY_MODE) { + return 0; + } + else if (modenum < CANNA_MODE_MAX_IMAGINARY_MODE + nothermodes) { + nmode = findExtraKanjiMode(modenum); + if (!nmode) { + return 0; + } + else { + mode = nmode->emode; + } + } + else { + return 0; + } + + if (mode && mode->func((uiContext)0/*dummy*/, mode, + KEY_CHECK, 0/*dummy*/, fnum)) { + /* ¤½¤Îµ¡Ç½¤¬¤½¤Î¥â¡¼¥É¤Ë¤ª¤¤¤ÆÍ­¸ú¤Êµ¡Ç½¤Ç¤¢¤ì¤Ð */ + if (mode->keytbl) { /* ¥­¡¼¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ì¤Ð */ + /* ¤³¤ì¤ÏÀäÂФ˸ºß¤¹¤ë¤Î¤Ç¤Ï¡© */ + if (mode->flags & CANNA_KANJIMODE_TABLE_SHARED) { + /* ¥­¡¼¥Þ¥Ã¥×¤¬Â¾¤Î¥â¡¼¥É¤È¶¦Í­¤µ¤ì¤Æ¤¤¤ë¤Ê¤é */ + p = (unsigned char *)calloc(256, sizeof(unsigned char)); + if (!p) { + return -1; + } + bcopy(mode->keytbl, p, 256 * sizeof(unsigned char)); + for (i = 0; i < 256; i++) { + if (mode->keytbl[i] == CANNA_FN_FuncSequence) { + q = actFromHash(mode->keytbl,i); + if (q) { /* ³ºÅö¤¹¤ë¥­¡¼¥·¡¼¥±¥ó¥¹¤¬¤¢¤Ã¤¿¤é */ + regist_act_hash(p, i, q); + } + } + if (mode->keytbl[i] == CANNA_FN_UseOtherKeymap) { + debug_message("changeKeyfunc:\245\306\241\274\245\326\245\353" + "\260\334\306\260\72\244\263\244\316\244\310\244\255\244\316" + "\245\255\241\274\244\317%d\n",i,0,0); + /* ¥Æ¡¼¥Ö¥ë°Üư:¤³¤Î¤È¤­¤Î¥­¡¼¤Ï */ + (void)copyMultiSequence(i, (KanjiMode)mode->keytbl, + (KanjiMode)p); + } + } + mode->keytbl = p; + mode->flags &= ~CANNA_KANJIMODE_TABLE_SHARED; + if (modenum == CANNA_MODE_YomiMode && + (ModeTbl[CANNA_MODE_ChikujiYomiMode]->flags + & CANNA_KANJIMODE_TABLE_SHARED)) { + ModeTbl[CANNA_MODE_ChikujiYomiMode]->keytbl = p; + } + else if (modenum == CANNA_MODE_TankouhoMode && + (ModeTbl[CANNA_MODE_ChikujiTanMode]->flags + & CANNA_KANJIMODE_TABLE_SHARED)) { + ModeTbl[CANNA_MODE_ChikujiTanMode]->keytbl = p; + } + } + if (key >= 0 && key < 255) { + if (mode->keytbl[key] == CANNA_FN_UseOtherKeymap && + fnum != CANNA_FN_UseOtherKeymap) + freeMultiSequence(key,(KanjiMode)mode->keytbl); + mode->keytbl[key] = fnum; + if (fnum == CANNA_FN_FuncSequence) { + regist_act_hash(mode->keytbl,key,actbuff); + } + if (fnum == CANNA_FN_UseOtherKeymap) { + retval = regist_key_hash(mode->keytbl,keybuff,actbuff); + if (retval) { + return retval; + } + } + } + else if (key == CANNA_KEY_Undefine) { + undefineKeyfunc(mode->keytbl, fnum); + } + } + } + return 0; +} + +static int +changeKeyOnSomeCondition(KanjiMode mode, int key, int fnum, unsigned char *actbuff, unsigned char *keybuff) +{ + int retval = 0; + + if (mode && /* ¤½¤Î¥â¡¼¥É¤¬Â¸ºß¤¹¤ë¤Ê¤é */ + mode->func((uiContext)0/*dummy*/, mode, + KEY_CHECK, 0/*dummy*/, fnum)) { + /* ´Ø¿ô¤¬¤½¤Î¥â¡¼¥É¤ÇÍ­¸ú¤Ê¤é */ + if ( !(mode->flags & CANNA_KANJIMODE_TABLE_SHARED) ) { + /* ¥Æ¡¼¥Ö¥ë¤¬¶¦Í­¤µ¤ì¤Æ¤¤¤Ê¤¤¤Ê¤é */ + if (mode->keytbl) { /* ¥­¡¼¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ì¤Ð */ + if (mode->keytbl[key] == CANNA_FN_UseOtherKeymap && + fnum != CANNA_FN_UseOtherKeymap) + freeMultiSequence(key,(KanjiMode)mode->keytbl); + mode->keytbl[key] = fnum; + if (fnum == CANNA_FN_FuncSequence) { + regist_act_hash(mode->keytbl,key,actbuff); + } + if (fnum == CANNA_FN_UseOtherKeymap) { + retval = regist_key_hash(mode->keytbl,keybuff,actbuff); + } + } + } + } + return retval; +} + +/* + * Á´¤Æ¤Î¥â¡¼¥É¤Î¡¢¤¢¤ë¥­¡¼¤ËÂФ·¤Æ´Ø¿ô¤ò³ä¤êÅö¤Æ¤ë½èÍý + * + */ + +changeKeyfuncOfAll(int key, int fnum, unsigned char *actbuff, unsigned char *keybuff) +{ + extern extraFunc *extrafuncp; + extraFunc *ep; + KanjiMode mode; + int i, retval = 0; + + if (key >= 0 && key < 255) { + if (defaultmap[key] == CANNA_FN_UseOtherKeymap && + fnum != CANNA_FN_UseOtherKeymap) + freeMultiSequence(key,(KanjiMode)defaultmap); + if (alphamap[key] == CANNA_FN_UseOtherKeymap && + fnum != CANNA_FN_UseOtherKeymap) + freeMultiSequence(key,(KanjiMode)alphamap); + if (emptymap[key] == CANNA_FN_UseOtherKeymap && + fnum != CANNA_FN_UseOtherKeymap) + freeMultiSequence(key,(KanjiMode)emptymap); + defaultmap[key] = fnum; + alphamap[key] = fnum; + emptymap[key] = fnum; + if (fnum == CANNA_FN_FuncSequence) { + regist_act_hash(defaultmap,key,actbuff); + regist_act_hash(alphamap,key,actbuff); + regist_act_hash(emptymap,key,actbuff); + } + if (fnum == CANNA_FN_UseOtherKeymap) { + if (regist_key_hash(defaultmap,keybuff,actbuff) == NG || + regist_key_hash(alphamap,keybuff,actbuff) == NG || + regist_key_hash(emptymap,keybuff,actbuff) == NG) { + return -1; + } + } + for (i = 0 ; i < CANNA_MODE_MAX_REAL_MODE ; i++) { + mode = ModeTbl[i]; + retval = changeKeyOnSomeCondition(mode, key, fnum, actbuff, keybuff); + if (retval < 0) { + return retval; + } + } + for (ep = extrafuncp ; ep ; ep = ep->next) { + /* defmode ¤Ç¤ÎÁ´¤Æ¤Î¥â¡¼¥É¤ËÂФ·¤Æ¤ä¤ë */ + if (ep->keyword == EXTRA_FUNC_DEFMODE) { + retval = changeKeyOnSomeCondition(ep->u.modeptr->emode, key, fnum, + actbuff, keybuff); + if (retval < 0) { + return retval; + } + } + } + } + else if (key == CANNA_KEY_Undefine) { + undefineKeyfunc(defaultmap, (unsigned)fnum); + undefineKeyfunc(alphamap, (unsigned)fnum); + undefineKeyfunc(emptymap, (unsigned)fnum); + for (i = 0 ; i < CANNA_MODE_MAX_REAL_MODE ; i++) { + mode = ModeTbl[i]; + if (mode && /* ¤½¤Î¥â¡¼¥É¤¬Â¸ºß¤¹¤ë¤Ê¤é */ + mode->func((uiContext)0/*dummy*/, mode, + KEY_CHECK, 0/*dummy*/, fnum)) { + /* ´Ø¿ô¤¬¤½¤Î¥â¡¼¥É¤ÇÍ­¸ú¤Ê¤é */ + if ( !(mode->flags & CANNA_KANJIMODE_TABLE_SHARED) ) { + /* ¥Æ¡¼¥Ö¥ë¤¬¶¦Í­¤µ¤ì¤Æ¤¤¤Ê¤¤¤Ê¤é */ + if (mode->keytbl) { /* ¥­¡¼¥Æ¡¼¥Ö¥ë¤¬Â¸ºß¤¹¤ì¤Ð */ + undefineKeyfunc(mode->keytbl, (unsigned)fnum); + } + } + } + } + } + return retval; +} + +static void +undefineKeyfunc(unsigned char *keytbl, unsigned fnum) +{ + int i; + + for (i = 0 ; i < ' ' ; i++) { + if (keytbl[i] == fnum) { + keytbl[i] = CANNA_FN_Undefined; + } + } + for (i = ' ' ; i < 0x7f ; i++) { + if (keytbl[i] == fnum) { + keytbl[i] = CANNA_FN_FunctionalInsert; + } + } + for (i = 0x7f ; i < 0xa0 ; i++) { + if (keytbl[i] == fnum) { + keytbl[i] = CANNA_FN_Undefined; + } + } + for (i = 0xa0 ; i < 0xe0 ; i++) { + if (keytbl[i] == fnum) { + keytbl[i] = CANNA_FN_FunctionalInsert; + } + } + for (i = 0xe0 ; i < 0x100 ; i++) { + if (keytbl[i] == fnum) { + keytbl[i] = CANNA_FN_Undefined; + } + } +} + +inline +unsigned int +createHashKey(unsigned char *data1, unsigned char data2, unsigned long which_seq) +{ + unsigned long hashKey; + + hashKey = (*data1 + data2) % which_seq; + return hashKey; +} + +/* µ¡Ç½¥·¡¼¥±¥ó¥¹¤ò³ä¤ê½Ð¤¹ */ +unsigned char * +actFromHash(unsigned char *tbl_ptr, unsigned char key) +{ + unsigned int hashKey; + struct seq_struct *p; + + hashKey = createHashKey(tbl_ptr, key, ACTHASHTABLESIZE); + for (p = seq_hash[hashKey] ; p ; p = p->next) { + if (p->to_tbl == tbl_ptr && p->as_key == key) { + return p->kinou_seq; + } + } +#ifndef WIN + debug_message("actFromHash:¥­¡¼¥·¥±¥ó¥¹¤ò¤ß¤Ä¤±¤é¤ì¤Þ¤»¤ó¤Ç¤·¤¿¡£\n",0,0,0); +#else + debug_message("actFromHash:\245\255\241\274\245\267\245\261\245\363\245\271" + "\244\362\244\337\244\304\244\261\244\351\244\354\244\336\244\273" + "\244\363\244\307\244\267\244\277\241\243\n",0,0,0); +#endif + return (unsigned char *)NULL; /* ³ºÅö¤¹¤ë¥­¡¼¥·¡¼¥±¥ó¥¹¤Ï¸ºß¤·¤Ê¤¤ */ +} + +/* ¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤ËÅÐÏ¿ */ +static void +regist_act_hash(unsigned char *tbl_ptr, unsigned char key, unsigned char *buff) +{ + unsigned int hashKey; + struct seq_struct *p, **pp; + + hashKey = createHashKey(tbl_ptr, key, ACTHASHTABLESIZE); + for (pp = &seq_hash[hashKey] ; (p = *pp) != (struct seq_struct *)0 ; + pp = &(p->next)) { + if (p->to_tbl == tbl_ptr && p->as_key == key) { + if (p->kinou_seq) + free(p->kinou_seq); + p->kinou_seq = (unsigned char *)malloc(strlen((char *)buff)+1); + if (p->kinou_seq) + strcpy((char *)p->kinou_seq,(char *)buff); + return; + } + } + p = *pp = (struct seq_struct *)malloc(sizeof(struct seq_struct)); + if(p) { + p->to_tbl = tbl_ptr; + p->as_key = key; + p->kinou_seq = (unsigned char *)malloc(strlen((char *)buff)+1); + if(p->kinou_seq) + strcpy((char *)p->kinou_seq,(char *)buff); + p->next = (struct seq_struct *)NULL; + } +} + +/* ¥Ï¥Ã¥·¥å¥Æ¡¼¥Ö¥ë¤«¤éºï½ü */ +static void +remove_hash(unsigned char *tbl_ptr, unsigned char key, int which_seq) +{ + unsigned int hashKey; + struct seq_struct *p, **pp; + + hashKey = createHashKey(tbl_ptr, key, which_seq); + for (pp = &seq_hash[hashKey] ; (p = *pp) != (struct seq_struct *)0 ; + pp = &(p->next)) { + if (p->to_tbl == tbl_ptr && p->as_key == key) { + *pp = p->next; + free(p); + } + } +} + +static void +freeChain(struct seq_struct *p) +{ + struct seq_struct *nextp; + + while (p) { + free(p->kinou_seq); + nextp = p->next; + free(p); + p = nextp; + } +} + +static void +clearAllFuncSequence(void) +{ + int i; + + for (i = 0 ; i < ACTHASHTABLESIZE ; i++) { + freeChain(seq_hash[i]); + seq_hash[i] = 0; + } +} + +static void +freeKeySeqMode(KanjiMode m) +{ + if (m) { + if (m->keytbl) { + free(m->keytbl); + } + free(m); + } +} + +static void +freeMap(struct map *m) +{ + struct map *n; + + while (m) { + freeKeySeqMode(m->mode); + n = m->next; + free(m); + m = n; + } +} + +static void +clearAllKeySequence(void) +{ + int i; + + for (i = 0 ; i < KEYHASHTABLESIZE ; i++) { + freeMap(otherMap[i]); + otherMap[i] = 0; + } +} + +static +specialen(unsigned char *block) +{ + int i; + for (i = 0 ; block[i] != 255 ;) { + i++; + } + debug_message("specialen:\304\271\244\265\244\317%d\244\311\244\271\241\243\n",i,0,0); + /* specialen:Ťµ¤Ï%d¤É¤¹¡£ */ + return i; +} + +static +to_write_act(int depth, int keysize, int actsize, unsigned singleAct) +{ + if (depth == (keysize -2)) { + if (actsize > 1){ + debug_message("to_write_act:CANNA_FN_FuncSequence\244\307\244\271\241\243\n",0,0,0); + /* ¤Ç¤¹¡£ */ + return CANNA_FN_FuncSequence; + } + if (actsize == 1) { + debug_message("to_write_act:singleAct%d\244\307\244\271\241\243\n",singleAct,0,0); + /* ¤Ç¤¹¡£ */ + return (int)singleAct; + } + else { /* Í­¤êÆÀ¤Ê¤¤¡© */ + return 0; + } + } else if (depth < (keysize -2)){ + debug_message("to_write_act:CANNA_FN_UseOtherKeymap\244\307\244\271\241\243\n",0,0,0); + /* ¤Ç¤¹¡£ */ + return CANNA_FN_UseOtherKeymap; + } + else { /* Í­¤êÆÀ¤Ê¤¤¡© */ + return 0; + } +} + +static struct map * +regist_map(KanjiMode tbl, unsigned char *keybuff, unsigned char *actbuff, int depth) +{ + unsigned int hashKey; + int sequencelen, keybuffsize, actbuffsize, offs; + struct map *p,**pp; + unsigned char *q, prevfunc; + + actbuffsize = strlen((char *)actbuff); + keybuffsize = specialen(keybuff); + hashKey = + createHashKey((unsigned char *)tbl, keybuff[depth], KEYHASHTABLESIZE); + debug_message("regist_map:hashKey = %d \244\307\244\271\241\243\n",hashKey,0,0); + /* ¤Ç¤¹¡£ */ + for (pp = &otherMap[hashKey]; (p = *pp) != (struct map *)0 ; + pp = &(p->next)) { + if (p->key == keybuff[depth] && p->tbl == tbl) { + for (q = p->mode->keytbl; *q != 255; q += 2) { + if (*q == keybuff[depth+1]) { /* ´û¤ËƱ¤¸¥­¡¼¤¬Â¸ºß¤·¤¿¡£ */ + ++q; + prevfunc = *q; /* ¤½¤Î¥­¡¼¤Îº£¤Þ¤Ç¤Îµ¡Ç½¤ò¼è¤Ã¤Æ¤ª¤¯ */ + *q = to_write_act(depth,keybuffsize,actbuffsize,actbuff[0]); + if(prevfunc == CANNA_FN_UseOtherKeymap && + *q != CANNA_FN_UseOtherKeymap) { + freeMultiSequence(keybuff[depth + 1], p->mode); + } + if (*q == CANNA_FN_FuncSequence) { + regist_act_hash((unsigned char *)p->mode, keybuff[depth+1], + actbuff); + } + debug_message("regist_map:\264\373\244\313\306\261\244\270\245\255\241\274\244\254\302\270\272\337:q=%d\n",*q,0,0); + /* ´û¤ËƱ¤¸¥­¡¼¤¬Â¸ºß */ + return p; + } + } + /* ¤½¤³¤Þ¤Ç¤Î¡¢¥­¡¼¤ÎÍúÎò¤Ï¤¢¤Ã¤¿¤¬¤³¤Î¥­¡¼:keybuff[depth +1]¤Ï½é¤á¤Æ */ + sequencelen = specialen(p->mode->keytbl); + offs = q - p->mode->keytbl; + if (p->mode->keytbl) { + p->mode->keytbl = + (unsigned char *)realloc(p->mode->keytbl,sequencelen +3); + if (!p->mode->keytbl) { + return (struct map *)0; + } + p->mode->keytbl[sequencelen] = keybuff[depth +1]; + p->mode->keytbl[++sequencelen] = + to_write_act(depth,keybuffsize,actbuffsize,actbuff[0]); + p->mode->keytbl[++sequencelen] = (BYTE)-1; + } + if (p->mode->keytbl[offs] == CANNA_FN_FuncSequence) { + regist_act_hash((unsigned char *)p->mode, keybuff[depth+1], actbuff); + } + debug_message("regist_map:\244\275\244\263\244\336\244\307\244\316" + "\241\242\245\255\241\274\244\316\315\372\316\362\244\317\244\242" + "\244\303\244\277\244\254\244\263\244\316\245\255\241\274%u\244\317" + "\275\351\244\341\244\306\n", + p->mode->keytbl[sequencelen-3],0,0); + /* ¤½¤³¤Þ¤Ç¤Î¡¢¥­¡¼¤ÎÍúÎò¤Ï¤¢¤Ã¤¿¤¬¤³¤Î¥­¡¼%u¤Ï½é¤á¤Æ */ + debug_message("regist_map:sequencelen¤Ï%d¤Ç¤¹¡£\n",sequencelen,0,0); + return p; + } + } + /* ²áµî¤ÎÍúÎò¤ÏÁ´¤Æ¤Ê¤·¤Î¤Ï¤º¡¢¿·µ¬¤ËºîÀ® */ + p = *pp = (struct map *)malloc(sizeof(struct map)); + if (p) { + p->tbl = tbl; + p->key = keybuff[depth]; + p->mode = (KanjiMode)malloc(sizeof(KanjiModeRec)); + if (p->mode) { + p->mode->func = multiSequenceFunc; + p->mode->flags = 0; + p->mode->keytbl = (unsigned char *)malloc(3); + if (p->mode->keytbl) { + p->mode->keytbl[0] = keybuff[depth +1]; + p->mode->keytbl[1] = to_write_act(depth,keybuffsize,actbuffsize,actbuff[0]); + debug_message("regist_map:p->mode->keytbl[1]\244\317%d\244\307\244\271\241\243\n",p->mode->keytbl[1],0,0); + /* ¤Ï%d¤Ç¤¹¡£ */ + p->mode->keytbl[2] = (BYTE)-1; + + p->next = (struct map *)NULL; + if (p->mode->keytbl[1] == CANNA_FN_FuncSequence) { + regist_act_hash((unsigned char *)p->mode, keybuff[depth+1], actbuff); + } + return p; + } + free(p->mode); + } + free(p); + } + return (struct map *)0; +} + +struct map * +mapFromHash(KanjiMode tbl, unsigned char key, struct map ***ppp) +{ + unsigned int hashKey; + struct map *p, **pp; + + hashKey = createHashKey((unsigned char *)tbl, key, KEYHASHTABLESIZE); + debug_message("mapFromHash:hashKey¤Ï%d\n",hashKey,0,0); + for(pp = otherMap + hashKey ; (p = *pp) != (struct map *)0 ; + pp = &(p->next)) { + if (p->tbl == tbl && p->key == key) { + debug_message("mapFromHash:map\244\254\244\337\244\304\244\253\244\352" + "\244\336\244\267\244\277\241\243\n",0,0,0); + /* ¤¬¤ß¤Ä¤«¤ê¤Þ¤·¤¿¡£ */ + if (ppp) { + *ppp = pp; + } + return p; + } + } +#ifndef WIN + debug_message("mapFromHash:map¤¬¤ß¤Ä¤«¤ê¤Þ¤»¤ó¡£\n",0,0,0); +#else + debug_message("mapFromHash:map\244\254\244\337\244\304\244\253\244\352" + "\244\336\244\273\244\363\241\243\n",0,0,0); +#endif + return (struct map *)NULL; +} + +static int +regist_key_hash(unsigned char *tbl_ptr, unsigned char *keybuff, unsigned char *actbuff) +{ + struct map *map_ptr; + int keybuffsize, i; + + keybuffsize = specialen(keybuff); + map_ptr = regist_map((KanjiMode)tbl_ptr, keybuff, actbuff, 0); + if (!map_ptr) { + return NG; + } + for (i = 1; i <= (keybuffsize -2); i++) { + map_ptr = regist_map(map_ptr->mode, keybuff, actbuff, i); + if (!map_ptr) { + return NG; + } + } + debug_message("regist_key_hash:keybuffsize\244\317%d¡¡actbuffsize" + "\244\317¤Ï%d¡¡i\244\317%d\244\307\244\271\241\243\n", + keybuffsize,strlen(actbuff),i); + /* ¤Ï */ /* ¤Ï */ /* ¤Ï */ /* ¤Ç¤¹¡£ */ + return 0; +} + +static +int +copyMultiSequence(unsigned char key, KanjiMode old_tbl, KanjiMode new_tbl) +{ + unsigned char hashKey; + unsigned char *old_sequence, *new_sequence; + int i, sequencelen; + struct map *p, **pp; + struct map *old_map; + + old_map = mapFromHash(old_tbl, key, (struct map ***)0); + old_sequence = old_map->mode->keytbl; + sequencelen = specialen(old_sequence); + hashKey = createHashKey((unsigned char *)new_tbl, key, KEYHASHTABLESIZE); + for (pp = &otherMap[hashKey]; (p = *pp) != (struct map *)0 ; + pp = &(p->next)) { + if (p->key == key && p->tbl == new_tbl) { + return 0; + } + } + p = *pp = (struct map *)malloc(sizeof(struct map)); + if (p) { + p->tbl = new_tbl; + p->key = key; + p->mode = (KanjiMode)malloc(sizeof(KanjiModeRec)); + if (p->mode) { + p->mode->func = multiSequenceFunc; + p->mode->flags = 0; + p->next = (struct map *)NULL; + p->mode->keytbl = (unsigned char *)malloc(sequencelen+1); + if (p->mode->keytbl) { + for (i = 0, new_sequence = p->mode->keytbl; i <= sequencelen; i++) { + new_sequence[i] = old_sequence[i]; + if (i%2 == 1) { + if (old_sequence[i] == CANNA_FN_UseOtherKeymap) { + if (copyMultiSequence(old_sequence[i-1], + old_map->mode, p->mode) < 0) { + free(p->mode->keytbl); + free(p->mode); + free(p); + *pp = (struct map *)0; + return(-1); + } + } else if (old_sequence[i] == CANNA_FN_FuncSequence) + regist_act_hash((unsigned char *)p->mode, old_sequence[i-1], + actFromHash((unsigned char *)old_map->mode, + old_sequence[i-1])); + } + } + return 0; + } else { + free(p->mode); + free(p); + *pp = (struct map *)0; + return(-1); + } + } else { + free(p); + *pp = (struct map *)0; + return(-1); + } + } else + return(-1); +} + +static void +freeMultiSequence(unsigned char key, KanjiMode tbl) +{ + unsigned char *sequence; + int i, sequencelen; + struct map *map, **ptr; + + map = mapFromHash(tbl, key, &ptr); + if (!map) + return; + *ptr = map->next; + sequence = map->mode->keytbl; + sequencelen = specialen(sequence); + + for (i = 0; i <= sequencelen; i++) { + if (i%2 == 1) { + if (sequence[i] == CANNA_FN_UseOtherKeymap) + freeMultiSequence(sequence[i-1], map->mode); + if (sequence[i] == CANNA_FN_FuncSequence) + remove_hash((unsigned char *)map->mode, sequence[i-1], + ACTHASHTABLESIZE); + } + } + debug_message("\241\374\153\145\171\133\45\144\135\244\316\155\141\160\260" + "\312\262\274\244\362\245\325\245\352\241\274\244\267\244\306\244\244" + "\244\353\244\276\n",key,0,0); + /* ¡ükey[%d]¤Îmap°Ê²¼¤ò¥Õ¥ê¡¼¤·¤Æ¤¤¤ë¤¾ */ + if (map->mode && sequence) + free(sequence); + if (map->mode) + free(map->mode); + free(map); +} + +askQuitKey(unsigned key) +{ + if (defaultmap[key] == CANNA_FN_Quit) { + return 1; /* ¼õ¤±¼è¤Ã¤¿key¤Ïquit¤À¤Ã¤¿¡£ */ + } + return 0; /* ¼õ¤±¼è¤Ã¤¿key¤Ïquit¤Ç¤Ê¤«¤Ã¤¿¡£ */ +} diff --git a/src/add-ons/input_server/methods/canna/lib/kigo.c b/src/add-ons/input_server/methods/canna/lib/kigo.c new file mode 100644 index 0000000000..ffb76fce5d --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/kigo.c @@ -0,0 +1,702 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: kigo.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" + +#define BYTE1 84 /* JIS¥³¡¼¥Éɽ¤ÎÂè°ì¥Ð¥¤¥È¤Î¿ô */ +#define BYTE2 94 /* JIS¥³¡¼¥Éɽ¤ÎÂèÆó¥Ð¥¤¥È¤Î¿ô */ +#define KIGOSU (((BYTE1 - 1) * BYTE2) + 4) + /* µ­¹æ¤ÎÁí¿ô */ + +#define KIGOSIZE 1 /* µ­¹æ¸õÊä¤Îʸ»ú¿ô */ +#define KIGOCOLS 2 /* µ­¹æ¸õÊä¤Î¥³¥é¥à¿ô */ +#define KIGOSPACE 2 /* µ­¹æ¤Î´Ö¤Î¶õÇòʸ»ú¤Î¥³¥é¥à¿ô */ +#define KIGOWIDTH (KIGOCOLS + KIGOSPACE) + /* bangomax¤ò·×»»¤¹¤ë¤¿¤á¤Î¿ô */ + +#define NKAKKOCHARS 1 /* JIS¥³¡¼¥Éɽ¼¨Íѳç¸Ì¤Îʸ»ú¿ô */ +#define KAKKOCOLS 2 /* Ʊ¥³¥é¥à¿ô */ +#define NKCODECHARS 4 /* JIS¥³¡¼¥Éɽ¼¨¤½¤Î¤â¤Î¤Îʸ»ú¿ô */ +#define KCODECOLS 4 /* Ʊ¥³¥é¥à¿ô */ +/* JIS¥³¡¼¥Éɽ¼¨Á´ÂΤÎʸ»ú¿ô */ +#define NKCODEALLCHARS (NKAKKOCHARS + NKAKKOCHARS + NKCODECHARS) +/* Ʊ¥³¥é¥à¿ô */ +#define KCODEALLCOLS (KAKKOCOLS + KAKKOCOLS + KCODECOLS) + +static void freeKigoContext(ichiranContext kc); +static void makeKigoGlineStatus(uiContext d); +static makeKigoInfo(uiContext d, int headkouho); +static kigoIchiranExitCatch(uiContext d, int retval, mode_context env); +static kigoIchiranQuitCatch(uiContext d, int retval, mode_context env); +static KigoNop(uiContext d); +static KigoForwardKouho(uiContext d); +static KigoBackwardKouho(uiContext d); +static KigoPreviousKouhoretsu(uiContext d); +static KigoNextKouhoretsu(uiContext d); +static KigoBeginningOfKouho(uiContext d); +static KigoEndOfKouho(uiContext d); +static KigoKakutei(uiContext d); +static KigoBangoKouho(uiContext d); +static KigoQuit(uiContext d); + +static int kigo_curIkouho; + +void +initKigoTable(void) +{ +} + +/* cfunc ichiranContext + * + * ichiranContext + * + */ +inline void +clearKigoContext(ichiranContext p) +{ + p->id = ICHIRAN_CONTEXT; + p->svIkouho = 0; + p->curIkouho = 0; + p->nIkouho = 0; + p->tooSmall = 0; + p->curIchar = 0; + p->allkouho = 0; + p->glinebufp = 0; + p->kouhoifp = (kouhoinfo *)0; + p->glineifp = (glineinfo *)0; + p->flags = (unsigned char)0; +} + +inline ichiranContext +newKigoContext(void) +{ + ichiranContext kcxt; + + if((kcxt = (ichiranContext)malloc(sizeof(ichiranContextRec))) + == (ichiranContext)NULL) { +#ifndef WIN + jrKanjiError = "malloc (newKigoContext) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (newKigoContext) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + return (ichiranContext)0; + } + clearKigoContext(kcxt); + + return kcxt; +} + + +#ifdef SOMEONE_USES_THIS +static void +freeKigoContext(ichiranContext kc) +{ + free(kc); +} +#endif /* SOMEONE_USES_THIS */ + +/* + * µ­¹æ°ìÍ÷¹Ô¤òºî¤ë + */ +inline +getKigoContext(uiContext d, canna_callback_t everyTimeCallback, canna_callback_t exitCallback, canna_callback_t quitCallback, canna_callback_t auxCallback) +{ + extern KanjiModeRec kigo_mode; + ichiranContext kc; + int retval = 0; + + if(pushCallback(d, d->modec, + everyTimeCallback, exitCallback, quitCallback, auxCallback) == 0) { + jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + return(NG); + } + + if((kc = newKigoContext()) == (ichiranContext)NULL) { + popCallback(d); + return(NG); + } + kc->next = d->modec; + d->modec = (mode_context)kc; + + kc->prevMode = d->current_mode; + d->current_mode = &kigo_mode; + + return(retval); +} + +#ifndef NO_EXTEND_MENU +inline void +popKigoMode(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + + d->modec = kc->next; + d->current_mode = kc->prevMode; + freeIchiranContext(kc); +} + +/* + * µ­¹æ°ìÍ÷¹Ô¤Ë´Ø¤¹¤ë¹½Â¤ÂÎ¤ÎÆâÍÆ¤ò¹¹¿·¤¹¤ë + * + * ¡¦¥«¥ì¥ó¥È¸õÊä¤Ë¤è¤Ã¤Æ kouhoinfo ¤È glineinfo ¤«¤é¸õÊä°ìÍ÷¹Ô¤òºî¤ë + * ¡¦¥«¥ì¥ó¥È¸õÊä¤Î¥³¡¼¥É¤ò¥­¥ã¥é¥¯¥¿¤ËÊÑ´¹¤¹¤ë + * + * °ú¤­¿ô RomeStruct + * Ìá¤êÃÍ ¤Ê¤· + */ +static void +makeKigoGlineStatus(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + WCHAR_T *gptr; + char xxx[3]; + char *yyy = xxx; + int i, b1, b2; + + gptr = kc->glineifp->gldata + NKAKKOCHARS; + + /* ¥«¥ì¥ó¥Èµ­¹æ¤ÎJIS¥³¡¼¥É¤ò°ìÍ÷¹Ô¤ÎÃæ¤Î¥«¥Ã¥³Æâ¤ËÆþ¤ì¤ë */ + WCstombs(xxx, kc->kouhoifp[*(kc->curIkouho)].khdata, 3); + + for(i=0; i<2; i++, yyy++) { + b1 = (((unsigned long)*yyy & 0x7f) >> 4); + b2 = (*yyy & 0x0f); + *gptr++ = b1 + ((b1 > 0x09) ? ('a' - 10) : '0'); + *gptr++ = b2 + ((b2 > 0x09) ? ('a' - 10) : '0'); + } + + d->kanji_status_return->info |= KanjiGLineInfo; + d->kanji_status_return->gline.line = kc->glineifp->gldata; + d->kanji_status_return->gline.length = kc->glineifp->gllen; + d->kanji_status_return->gline.revPos = + kc->kouhoifp[*(kc->curIkouho)].khpoint; + d->kanji_status_return->gline.revLen = KIGOSIZE; + +} + +/* µ­¹æ°ìÍ÷ÍѤÎglineinfo¤Èkouhoinfo¤òºî¤ë + * + * ¡öglineinfo¡ö + * int glkosu : int glhead : int gllen : WCHAR_T *gldata + * £±¹Ô¤Î¸õÊä¿ô : ÀèÆ¬µ­¹æ¤¬ : £±¹Ô¤ÎŤµ : µ­¹æ°ìÍ÷¹Ô¤Îʸ»úÎó + * : ²¿ÈÖÌܤε­¹æ¤« : + * ------------------------------------------------------------------------- + * 0 | 6 : 0 : 24 : £±¡ù£²¡ú£³¡û£´¡ü£µ¡ý£¶¢¢ + * + * ¡ökouhoinfo¡ö + * int khretsu : int khpoint : WCHAR_T *khdata + * ̤»ÈÍÑ : ¹Ô¤ÎÀèÆ¬¤«¤é : µ­¹æ¤Îʸ»ú + * : ²¿¥Ð¥¤¥ÈÌܤ« : + * ------------------------------------------------------------------------- + * 0 | 0 : 0 : ¡ù + * 1 | 0 : 4 : ¡ú + * 2 | 0 : 8 : ¡û + * : : + * + * °ú¤­¿ô headkouho ¥«¥ì¥ó¥Èµ­¹æ¸õÊä¹Ô¤ÎÀèÆ¬¸õÊä¤Î°ÌÃÖ + * (2121¤«¤é²¿¸ÄÌܤ«(2121¤Ï£°ÈÖÌÜ)) + * uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +makeKigoInfo(uiContext d, int headkouho) +{ + ichiranContext kc = (ichiranContext)d->modec; + WCHAR_T *gptr; + int i, b1, b2, lnko, cn; + int byte1hex = 0xa1; + int byte2hex = 0xa1; + char xxx[3]; + + b2 = headkouho % BYTE2; /* JIS¥³¡¼¥ÉÉ½Ãæ(£Ø¼´)¤Î°ÌÃÖ (ÅÀ-1) */ + b1 = headkouho / BYTE2; /* JIS¥³¡¼¥ÉÉ½Ãæ(£Ù¼´)¤Î°ÌÃÖ (¶è-1) */ + + xxx[2] = '\0'; + +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { + printf("kigoinfo = bangomax %d, b1 %d, b2 %d\n", kc->nIkouho, b1, b2); + printf("kigoinfo = headkouho %d, curIkouho %d\n", + headkouho, *(kc->curIkouho)); + } +#endif + + /* µ­¹æ°ìÍ÷ÍѤÎglineinfo¤Èkouhoinfo¤òºî¤ë */ + gptr = kc->glinebufp; + + kc->glineifp->glhead = headkouho; + kc->glineifp->gldata = gptr; + + /* JIS¥³¡¼¥É¤Îɽ¼¨Îΰè¤ò°ìÍ÷¹ÔÃæ¤Ëºî¤ë */ + MBstowcs(gptr, "\241\316", 1); + /* ¡Î */ + for(i=0, gptr++; inIkouho && (headkouho+lnko)nIkouho && (headkouho+lnko)kouhoifp[lnko].khpoint = cn; + kc->kouhoifp[lnko].khdata = gptr; + + /* ¸õÊä¤ò¥³¥Ô¡¼¤¹¤ë */ + *xxx = (char)byte1hex + b1; + *(xxx + 1) = (char)byte2hex + b2; + MBstowcs(gptr++, xxx, 1); + cn ++; + } + b2 = 0; + } + *gptr = (WCHAR_T)0; + kc->glineifp->glkosu = lnko; + kc->glineifp->gllen = WStrlen(kc->glineifp->gldata); + + return(0); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * µ­¹æ°ìÍ÷ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +kigoIchiranExitCatch(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + popCallback(d); + retval = YomiExit(d, retval); + currentModeInfo(d); + + killmenu(d); + + return(retval); +} + +static +kigoIchiranQuitCatch(uiContext d, int retval, mode_context env) + /* ARGSUSED */ +{ + popCallback(d); + currentModeInfo(d); + + return prevMenuIfExist(d); +} +#endif /* NO_EXTEND_MENU */ + +KigoIchiran(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + +#ifdef NO_EXTEND_MENU + d->kanji_status_return->info |= KanjiKigoInfo; + return 0; +#else + if(makeKigoIchiran(d, CANNA_MODE_KigoMode) == NG) + return(GLineNGReturn(d)); + else + return(0); +#endif +} + +#ifndef NO_EXTEND_MENU +/* + * µ­¹æ°ìÍ÷¹Ô¤òɽ¼¨¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +makeKigoIchiran(uiContext d, int major_mode) +{ + ichiranContext kc; + int headkouho; + + if(d->ncolumns < (KCODEALLCOLS + KIGOCOLS)) { + NothingChangedWithBeep(d); + jrKanjiError = "\270\365\312\344\260\354\315\367\315\321\244\316\311\375" + "\244\254\266\271\244\244\244\316\244\307\265\255\271\346\260\354" + "\315\367\244\307\244\255\244\336\244\273\244\363"; + /* ¸õÊä°ìÍ÷ÍѤÎÉý¤¬¶¹¤¤¤Î¤Çµ­¹æ°ìÍ÷¤Ç¤­¤Þ¤»¤ó */ + return(NG); + } + + if(getKigoContext(d, NO_CALLBACK, kigoIchiranExitCatch, kigoIchiranQuitCatch, NO_CALLBACK) == NG) + return(NG); + + kc = (ichiranContext)d->modec; + kc->majorMode = major_mode; + kc->minorMode = CANNA_MODE_KigoMode; + kc->flags |= cannaconf.quickly_escape ? 0 : ICHIRAN_STAY_LONG; + + currentModeInfo(d); + + /* ºÇÂçµ­¹æÉ½¼¨¿ô¤Î¥»¥Ã¥È */ + /* Áí¥«¥é¥à¿ô¤«¤é "¡ÎJIS ¡Ï" ʬ¤òº¹¤·°ú¤¤¤Æ·×»»¤¹¤ë */ + if((kc->nIkouho = + (((d->ncolumns - KCODEALLCOLS - KIGOCOLS) / KIGOWIDTH) + 1)) + > KIGOBANGOMAX) { + kc->nIkouho = KIGOBANGOMAX; + } + + kc->curIkouho = &kigo_curIkouho; + + if(allocIchiranBuf(d) == NG) { /* µ­¹æ°ìÍ÷¥â¡¼¥É */ + popKigoMode(d); + popCallback(d); + return(NG); + } + + /* ¥«¥ì¥ó¥È¸õÊä¤Î¤¢¤ëµ­¹æ°ìÍ÷¹Ô¤ÎÀèÆ¬¸õÊä¤È¡¢ + °ìÍ÷¹ÔÃæ¤Î¥«¥ì¥ó¥È¸õÊä¤Î°ÌÃÖ¤òµá¤á¤ë */ + if(d->curkigo) { /* a1a1¤«¤é²¿ÈÖÌܤε­¹æ¤« */ + headkouho = (d->curkigo / kc->nIkouho) * kc->nIkouho; + *(kc->curIkouho) = d->curkigo % kc->nIkouho; + } else { + d->curkigo = 0; + headkouho = 0; + *(kc->curIkouho) = 0; + } + + /* ¤³¤³¤Ë¤¯¤ëľÁ°¤Ë C-t ¤È¤«¤¬ Gline ¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤ë¾ì¹ç²¼¤Î£±¹Ô¤ò + ¤ä¤ëɬÍפ¬½Ð¤Æ¤¯¤ë¡£ */ + d->flags &= ~(PLEASE_CLEAR_GLINE | PCG_RECOGNIZED); + + /* glineinfo¤Èkouhoinfo¤òºî¤ë */ + makeKigoInfo(d, headkouho); + + /* kanji_status_return¤òºî¤ë */ + makeKigoGlineStatus(d); + + return(0); +} + +static +KigoNop(uiContext d) +{ + /* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */ + d->majorMode = d->minorMode = CANNA_MODE_AlphaMode; + currentModeInfo(d); + + makeKigoGlineStatus(d); + return 0; +} + +/* + * µ­¹æ°ìÍ÷¹ÔÃæ¤Î¼¡¤Îµ­¹æ¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoForwardKouho(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + int headkouho; + + /* ¼¡¤Îµ­¹æ¤Ë¤¹¤ë */ + ++*(kc->curIkouho); + + /* °ìÍ÷ɽ¼¨¤ÎºÇ¸å¤Îµ­¹æ¤À¤Ã¤¿¤é¡¢¼¡¤Î°ìÍ÷¹Ô¤ÎÀèÆ¬µ­¹æ¤ò¥«¥ì¥ó¥Èµ­¹æ¤È¤¹¤ë */ + if((*(kc->curIkouho) >= kc->nIkouho) || + (kc->glineifp->glhead + *(kc->curIkouho) >= KIGOSU)) { + headkouho = kc->glineifp->glhead + kc->nIkouho; + if(headkouho >= KIGOSU) + headkouho = 0; + *(kc->curIkouho) = 0; + makeKigoInfo(d, headkouho); + } + + /* kanji_status_retusrn ¤òºî¤ë */ + makeKigoGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return(0); +} + +/* + * µ­¹æ°ìÍ÷¹ÔÃæ¤ÎÁ°¤Îµ­¹æ¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoBackwardKouho(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + int headkouho; + + /* Á°¤Îµ­¹æ¤Ë¤¹¤ë */ + --*(kc->curIkouho); + + /* °ìÍ÷ɽ¼¨¤ÎÀèÆ¬¤Îµ­¹æ¤À¤Ã¤¿¤é¡¢Á°¤Î°ìÍ÷¹Ô¤ÎºÇ½ªµ­¹æ¤ò¥«¥ì¥ó¥Èµ­¹æ¤È¤¹¤ë */ + if(*(kc->curIkouho) < 0) { + headkouho = kc->glineifp->glhead - kc->nIkouho; + if(headkouho < 0) + headkouho = ((KIGOSU - 1) / kc->nIkouho) * kc->nIkouho; + makeKigoInfo(d, headkouho); + *(kc->curIkouho) = kc->glineifp->glkosu - 1; + } + + /* kanji_status_retusrn ¤òºî¤ë */ + makeKigoGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return(0); +} + +/* + * Á°µ­¹æ°ìÍ÷Îó¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoPreviousKouhoretsu(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + int headkouho; + + /** Á°¸õÊäÎó¤Ë¤¹¤ë **/ + headkouho = kc->glineifp->glhead - kc->nIkouho; + if(headkouho < 0) + headkouho = ((KIGOSU -1) / kc->nIkouho) * kc->nIkouho; + makeKigoInfo(d, headkouho); + + /* *(kc->curIkouho) ¤¬¥«¥ì¥ó¥Èµ­¹æ°ìÍ÷¤Îµ­¹æ¿ô¤è¤êÂ礭¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¤é + ºÇ±¦µ­¹æ¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë */ + if(*(kc->curIkouho) >= kc->glineifp->glkosu) + *(kc->curIkouho) = kc->glineifp->glkosu - 1; + + /* kanji_status_retusrn ¤òºî¤ë */ + makeKigoGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return(0); +} + +/* + * ¼¡µ­¹æ°ìÍ÷Îó¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoNextKouhoretsu(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + int headkouho; + + /** ¼¡¸õÊäÎó¤Ë¤¹¤ë **/ + headkouho = kc->glineifp->glhead + kc->nIkouho; + if(headkouho >= KIGOSU) + headkouho = 0; + makeKigoInfo(d, headkouho); + + /* *(kc->curIkouho) ¤¬¥«¥ì¥ó¥Èµ­¹æ°ìÍ÷¤Îµ­¹æ¿ô¤è¤êÂ礭¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¤é + ºÇ±¦µ­¹æ¤ò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë */ + if(*(kc->curIkouho) >= kc->glineifp->glkosu) + *(kc->curIkouho) = kc->glineifp->glkosu - 1; + + /* kanji_status_retusrn ¤òºî¤ë */ + makeKigoGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return(0); +} + +/* + * µ­¹æ°ìÍ÷¹ÔÃæ¤ÎÀèÆ¬¤Îµ­¹æ¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoBeginningOfKouho(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + + /* ¸õÊäÎó¤ÎÀèÆ¬¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤Ë¤¹¤ë */ + *(kc->curIkouho) = 0; + + /* kanji_status_retusrn ¤òºî¤ë */ + makeKigoGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return(0); +} + +/* + * µ­¹æ°ìÍ÷¹ÔÃæ¤ÎºÇ±¦¤Îµ­¹æ¤Ë°Üư¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoEndOfKouho(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + + /** ¸õÊäÎó¤ÎºÇ±¦¸õÊä¤ò¥«¥ì¥ó¥È¸õÊä¤Ë¤¹¤ë **/ + *(kc->curIkouho) = kc->glineifp->glkosu - 1; + + /* kanji_status_retusrn ¤òºî¤ë */ + makeKigoGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return(0); +} + +/* + * µ­¹æ°ìÍ÷¹ÔÃæ¤«¤éÁªÂò¤µ¤ì¤¿µ­¹æ¤ò³ÎÄꤹ¤ë + * + * ¡¦¼¡¤Ëµ­¹æ°ìÍ÷¤·¤¿»þ¤ËÁ°²ó³ÎÄꤷ¤¿µ­¹æ¤¬¥«¥ì¥ó¥È¸õÊä¤È¤Ê¤ë¤è¤¦¤Ë¡¢ + * ³ÎÄꤷ¤¿¸õÊä¤ò¥»¡¼¥Ö¤·¤Æ¤ª¤¯ + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoKakutei(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + + /* ¥«¥ì¥ó¥Èµ­¹æ¤ò¥»¡¼¥Ö¤¹¤ë */ + d->curkigo = kc->glineifp->glhead + *(kc->curIkouho); + + /* ¥¨¥³¡¼¥¹¥È¥ê¥ó¥°¤ò³ÎÄêʸ»úÎó¤È¤¹¤ë */ + if (d->n_buffer >= KIGOSIZE) { + d->nbytes = KIGOSIZE; + WStrncpy(d->buffer_return, kc->kouhoifp[*(kc->curIkouho)].khdata, + d->nbytes); + d->buffer_return[KIGOSIZE] = (WCHAR_T)0; + } + else { + d->nbytes = 0; + } + + if (kc->flags & ICHIRAN_STAY_LONG) { + kc->flags |= ICHIRAN_NEXT_EXIT; + d->status = EVERYTIME_CALLBACK; + } + else { + freeIchiranBuf(kc); + popKigoMode(d); + GlineClear(d); + + d->status = EXIT_CALLBACK; + } + + return(d->nbytes); +} + +#ifdef SOMEONE_USES_THIS +/* + * µ­¹æ°ìÍ÷¹ÔÃæ¤ÎÆþÎϤµ¤ì¤¿ÈÖ¹æ¤Îµ­¹æ¤Ë°Üư¤¹¤ë ¡Ṳ́»ÈÍÑ¡Û + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoBangoKouho(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + int num; + + /* ÆþÎϥǡ¼¥¿¤Ï £°¡Á£¹ £á¡Á£æ ¤«¡© */ + if(((0x30 <= d->ch) && (d->ch <= 0x39)) + || ((0x61 <= d->ch) && (d->ch <= 0x66))) { + if((0x30 <= d->ch) && (d->ch <= 0x39)) + num = (int)(d->ch & 0x0f); + else if((0x61 <= d->ch) && (d->ch <= 0x66)) + num = (int)(d->ch - 0x57); + } + else { + /* ÆþÎϤµ¤ì¤¿ÈÖ¹æ¤ÏÀµ¤·¤¯¤¢¤ê¤Þ¤»¤ó */ + return NothingChangedWithBeep(d); + } + /* ÆþÎϥǡ¼¥¿¤Ï ¸õÊä¹Ô¤ÎÃæ¤Ë¸ºß¤¹¤ë¿ô¤«¡© */ + if(num >= kc->glineifp->glkosu) { + /* ÆþÎϤµ¤ì¤¿ÈÖ¹æ¤ÏÀµ¤·¤¯¤¢¤ê¤Þ¤»¤ó */ + return NothingChangedWithBeep(d); + } + + /* ¸õÊäÎó¤ÎÀèÆ¬¸õÊä¤òÆÀ¤ë */ + *(kc->curIkouho) = num; + + /* SelectDirect ¤Î¥«¥¹¥¿¥Þ¥¤¥º¤Î½èÍý */ + if (cannaconf.SelectDirect) /* ON */ { + return(KigoKakutei(d)); + } else /* OFF */ { + /* kanji_status_retusrn ¤òºî¤ë */ + makeKigoGlineStatus(d); + + return(0); + } +} +#endif /* SOMEONE_USES_THIS */ + +/* + * µ­¹æ°ìÍ÷¹Ô¤ò¾Ãµî¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 + */ +static +KigoQuit(uiContext d) +{ + ichiranContext kc = (ichiranContext)d->modec; + BYTE fl = kc->flags; + + freeIchiranBuf(kc); + popKigoMode(d); + /* gline ¤ò¥¯¥ê¥¢¤¹¤ë */ + GlineClear(d); + d->status = (fl & ICHIRAN_NEXT_EXIT) ? EXIT_CALLBACK : QUIT_CALLBACK; + return 0; +} +#endif /* NO_EXTEND_MENU */ + +#include "kigomap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/kigomap.h b/src/add-ons/input_server/methods/canna/lib/kigomap.h new file mode 100644 index 0000000000..5278f2b758 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/kigomap.h @@ -0,0 +1,61 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +// Modified by T.Murai + +#if !defined(lint) && !defined(__CODECENTER__) +static char kigomap_id[] = "@(#) 102.1 $Id: kigomap.h,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#ifdef NO_EXTEND_MENU +static struct funccfunc kigo_funcs[] = {{0, 0},}; +#else +extern DoFuncSequence(),UseOtherKeymap(); + +static struct funccfunc kigo_funcs[] = { + {CANNA_FN_KigouMode ,KigoQuit }, + {CANNA_FN_Forward ,KigoForwardKouho }, + {CANNA_FN_Backward ,KigoBackwardKouho }, + {CANNA_FN_Next ,KigoNextKouhoretsu }, + {CANNA_FN_Prev ,KigoPreviousKouhoretsu }, + {CANNA_FN_BeginningOfLine ,KigoBeginningOfKouho }, + {CANNA_FN_EndOfLine ,KigoEndOfKouho }, + {CANNA_FN_DeletePrevious ,KigoQuit }, + {CANNA_FN_Henkan ,KigoForwardKouho }, + {CANNA_FN_HenkanOrInsert ,KigoForwardKouho }, + {CANNA_FN_HenkanOrNothing ,KigoForwardKouho }, + {CANNA_FN_Kakutei ,KigoKakutei }, + {CANNA_FN_Quit ,KigoQuit }, + {CANNA_FN_Nop ,KigoNop }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {0 ,0 }, +}; +#endif /* NO_EXTEND_MENU */ + +extern searchfunc(...); + +KanjiModeRec kigo_mode = { + searchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + kigo_funcs, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/lisp.c b/src/add-ons/input_server/methods/canna/lib/lisp.c new file mode 100644 index 0000000000..fade2774ed --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/lisp.c @@ -0,0 +1,4897 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[] = "$Id: lisp.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +/* +** main program of lisp +*/ +#if (defined(_WINDOWS) || defined(WIN32)) && !defined(WIN) +#define WIN +#endif + +#ifdef WIN +#define WIN_CANLISP +#endif + +#include + +#include "lisp.h" +#include "patchlevel.h" + +#include + +extern void (*keyconvCallback)(...); + +//static int CANNA_mbstowcs(WCHAR_T *dest, char *src, int destlen); +static void fillMenuEntry(void); +static void intr(int sig); +static initIS(void); +static void finIS(void); +static identifySequence(unsigned c, int *val); +static int alloccell(void); +static allocarea(void); +static void freearea(void); +static list getatmz(char *name); +static list mkatm(char *name); +static list getatm(char *name, int key); +static void error(char *msg, list v); +static void fatal(char *msg, list v); +static void argnerr(char *msg); +static void numerr(char *fn, list arg); +static void lisp_strerr(char *fn, list arg); +static list Lread(int n); +static list read1(void); +static skipspaces(void); +static zaplin(void); +static list newcons(void); +static list newsymbol(char *name); +static void print(list l); +static list ratom(void); +static list ratom2(int a); +static list rstring(void); +static list rcharacter(void); +static isnum(char *name); +static void untyi(int c); +static int tyi(void); +static int tyipeek(void); +static void prins(char *s); +static isterm(int c); +static void push(list value); +static void pop(int x); +static list pop1(void); +static void epush(list value); +static list epop(void); +static void patom(list atm); +static void gc(void); +static list allocstring(int n); +static list copystring(char *s, int n); +static list copycons(struct cell *l); +static void markcopycell(list *addr); +static list bindall(list var, list par, list a, list e); +static list Lquote(void); +static list Leval(int n); +static list assq(list e, list a); +static int evpsh(list args); +static list Lprogn(void); +static list Lcons(int n); +static list Lncons(int n); +static list Lxcons(int n); +static list Lprint(int n); +static list Lset(int n); +static list Lsetq(void); +static list Lequal(int n); +static int Strncmp(char *x, char *y, int len); +static char *Strncpy(char *x, char *y, int len); +static int equal(list x, list y); +static list Lgreaterp(int n); +static list Llessp(int n); +static list Leq(int n); +static list Lcond(void); +static list Lnull(int n); +static list Lor(void); +static list Land(void); +static list Lplus(int n); +static list Ltimes(int n); +static list Ldiff(int n); +static list Lquo(int n); +static list Lrem(int n); +static list Lgc(int n); +static list Lusedic(int n); +static list Llist(int n); +static list Lcopysym(int n); +static list Lload(int n); +static list Lmodestr(int n); +static int xfseq(char *fname, list l, unsigned char *arr, int arrsize); +static list Lsetkey(int n); +static list Lgsetkey(int n); +static list Lputd(int n); +static list Ldefun(void); +static list Ldefmacro(void); +static list Lcar(int n); +static list Lcdr(int n); +static list Latom(int n); +static list Llet(void); +static list Lif(void); +static list Lunbindkey(int n); +static list Lgunbindkey(int n); +static list Ldefmode(void); +static list Ldefsym(void); +static int getKutenCode(char *data, int *ku, int *ten); +static int howManyCharsAre(char *tdata, char *edata, int *tku, int *tten, int *codeset); +static char *pickupChars(int tku, int tten, int num, int kodata); +static void numtostr(unsigned long num, char *str); +static list Ldefselection(void); +static list Ldefmenu(void); +static list Lsetinifunc(int n); +static list Lboundp(int n); +static list Lfboundp(int n); +static list Lgetenv(int n); +static list LdefEscSeq(int n); +static list LdefXKeysym(int n); +static list Lconcat(int n); +static void ObtainVersion(void); +static list VTorNIL(BYTE *var, int setp, list arg); +static list StrAcc(char **var, int setp, list arg); +static list NumAcc(int *var, int setp, list arg); +static list Vnkouhobunsetsu(int setp, list arg); +static list VProtoVer(int setp, list arg); +static list VServVer(int setp, list arg); +static list VServName(int setp, list arg); +static list VCannaDir(int setp, list arg); +static list VCodeInput(int setp, list arg); +static void deflispfunc(void); +static void defcannavar(void); +static void defcannamode(void); +static void defcannafunc(void); +static void defatms(void); +static void restoreLocalVariables(void); + +static FILE *outstream = (FILE *)0; + +#ifdef WIN +extern int RkwGetProtocolVersion (int *, int *); +extern int RkwGetServerVersion (int *, int *); +#endif + +static char *celltop, *cellbtm, *freecell; +static char *memtop; + +static int ncells = CELLSIZE; + + +/* parameter stack */ + +static list *stack, *sp; + +/* environment stack */ + +static list *estack, *esp; + +/* oblist */ + +static list *oblist; /* oblist hashing array */ + +#define LISPERROR -1 + +typedef struct { + FILE *f; + char *name; + unsigned line; +} lispfile; + +static lispfile *files; +static int filep; + +/* lisp read buffer & read pointer */ + +static char *readbuf; /* read buffer */ +static char *readptr; /* read pointer */ + +/* error functions */ + +static void argnerr(), numerr(), error(); + +/* multiple values */ + +#define MAXVALUES 16 +static list *values; /* multiple values here */ +static int valuec; /* number of values here */ + +/* symbols */ + +static list QUOTE, T, _LAMBDA, _MACRO, COND, USER; +static list BUSHU, GRAMMAR, RENGO, KATAKANA, HIRAGANA, HYPHEN; + +#include + +static struct lispcenv { + jmp_buf jmp_env; + int base_stack; + int base_estack; +} *env; /* environment for setjmp & longjmp */ +static int jmpenvp = MAX_DEPTH; + +static jmp_buf fatal_env; + +#ifdef WIN_CANLISP +#include "cannacnf.h" + +struct winstruct { + struct libconf *conf; + struct libconfwrite *confwrite; + struct RegInfo *rinfo; + char *context; +} wins; +#endif + +#ifdef WIN_CANLISP +char *RemoteGroup = (char *)NULL; +char *LocalGroup = (char *)NULL; +#endif + +/* tyo -- output one character */ + +inline +void tyo(int c) +{ + if (outstream) { + (void)putc(c, outstream); + } +} + +/* external functions + + ³°Éô´Ø¿ô¤Ï°Ê²¼¤Î£³¤Ä + + (1) clisp_init() -- ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤òÆÉ¤à¤¿¤á¤Î½àÈ÷¤ò¤¹¤ë + + lisp ¤Î½é´ü²½¤ò¹Ô¤¤É¬Íפʥá¥â¥ê¤ò allocate ¤¹¤ë¡£ + + (2) clisp_fin() -- ¥«¥¹¥¿¥Þ¥¤¥ºÆÉ¤ß¹þ¤ßÍѤÎÎΰè¤ò²òÊü¤¹¤ë¡£ + + ¾åµ­¤Î½é´ü²½¤ÇÆÀ¤¿¥á¥â¥ê¤ò²òÊü¤¹¤ë¡£ + + (3) YYparse_by_rcfilename((char *)s) -- ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤òÆÉ¤ß¹þ¤à¡£ + + s ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë̾¤Î¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤òÆÉ¤ß¹þ¤ó¤Ç¥«¥¹¥¿ + ¥Þ¥¤¥º¤ÎÀßÄê¤ò¹Ô¤¦¡£¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ì¤Ð 1 ¤òÊÖ¤·¤½¤¦¤Ç¤Ê¤±¤ì¤Ð + 0 ¤òÊÖ¤¹¡£ + + */ + +static list getatmz(char *); + +#ifdef WIN_CANLISP +/* + * ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¥ª¥Ú¥ì¡¼¥·¥ç¥ó (from util.c) + * + */ + +static int wchar_type; /* ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤Î¥¿¥¤¥×(²¼¤ò¸«¤è) */ + +#define CANNA_WCTYPE_16 0 /* 16¥Ó¥Ã¥Èɽ¸½ */ +#define CANNA_WCTYPE_32 1 /* 32¥Ó¥Ã¥Èɽ¸½ */ +#define CANNA_WCTYPE_OT 99 /* ¤½¤Î¾¤Îɽ¸½ */ + +/* + WCinit() -- ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤È¤·¤Æ¤É¤ì¤¬»È¤ï¤ì¤Æ¤¤¤ë¤«¤ò³Îǧ¤¹¤ë + + ¤³¤Î´Ø¿ô¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤Þ¤¨¤Ë setlocale ¤¬¤Ê¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ + */ + +#define TYPE16A 0x0000a4a2 +#define TYPE32A 0x30001222 + + +int +WCinit(void) +{ +#if defined(HAVE_WCHAR_OPERATION) && !defined(WIN) + extern int locale_insufficient; + WCHAR_T wc[24]; + char *a = "\244\242"; /* ¤¢ */ /* 0xa4a2 */ + + locale_insufficient = 0; + if (mbstowcs(wc, a, sizeof(wc) / sizeof(WCHAR_T)) != 1) { + /* ¿ʬ setlocale ¤¬¤Ê¤µ¤ì¤Æ¤¤¤Ê¤¤ */ + setlocale(LC_CTYPE, ""); + if (mbstowcs(wc, a, sizeof(wc) / sizeof(WCHAR_T)) != 1) { + setlocale(LC_CTYPE, JAPANESE_LOCALE); + if (mbstowcs(wc, a, sizeof(wc) / sizeof(WCHAR_T)) != 1) { + locale_insufficient = 1; + return -1; + } + } + } + switch (wc[0]) { + case TYPE16A: + wchar_type = CANNA_WCTYPE_16; + break; + case TYPE32A: + wchar_type = CANNA_WCTYPE_32; + break; + default: + wchar_type = CANNA_WCTYPE_OT; + break; + } +#else /* !HAVE_WCHAR_OPERATION || WIN */ +# ifdef WCHAR16 + + wchar_type = CANNA_WCTYPE_16; + +# else /* !WCHAR16 */ + + if (sizeof(WCHAR_T) == 2) { + /* NOTREACHED */ + wchar_type = CANNA_WCTYPE_16; + } + else { + /* NOTREACHED */ + wchar_type = CANNA_WCTYPE_32; + } + +# endif /* !WCHAR16 */ +#endif /* !HAVE_WCHAR_OPERATION || WIN */ + + return 0; +} + +static int +CANNA_mbstowcs(WCHAR_T *dest, char *src, int destlen) +{ + register int i, j; + register unsigned ec; + + if (wchar_type == CANNA_WCTYPE_16) { + for (i = 0, j = 0 ; + (ec = (unsigned)(unsigned char)src[i]) != 0 && j < destlen ; i++) { + if (ec & 0x80) { + switch (ec) { + case 0x8e: /* SS2 */ + dest[j++] = (WCHAR_T)(0x80 | ((unsigned)src[++i] & 0x7f)); + break; + case 0x8f: /* SS3 */ + dest[j++] = (WCHAR_T)(0x8000 + | (((unsigned)src[i + 1] & 0x7f) << 8) + | ((unsigned)src[i + 2] & 0x7f)); + i += 2; + break; + default: + dest[j++] = (WCHAR_T)(0x8080 | (((unsigned)src[i] & 0x7f) << 8) + | ((unsigned)src[i + 1] & 0x7f)); + i++; + break; + } + }else{ + dest[j++] = (WCHAR_T)ec; + } + } + if (j < destlen) + dest[j] = (WCHAR_T)0; + return j; + } + else if (wchar_type == CANNA_WCTYPE_32) { + for (i = 0, j = 0 ; + (ec = (unsigned)(unsigned char)src[i]) != 0 && j < destlen ; i++) { + if (ec & 0x80) { + switch (ec) { + case 0x8e: /* SS2 */ + dest[j++] = (WCHAR_T)(0x10000000L | ((unsigned)src[++i] & 0x7f)); + break; + case 0x8f: /* SS3 */ + dest[j++] = (WCHAR_T)(0x20000000L + | (((unsigned)src[i + 1] & 0x7f) << 7) + | ((unsigned)src[i + 2] & 0x7f)); + i += 2; + break; + default: + dest[j++] = (WCHAR_T)(0x30000000L | (((unsigned)src[i] & 0x7f) << 7) + | ((unsigned)src[i + 1] & 0x7f)); + i++; + break; + } + }else{ + dest[j++] = (WCHAR_T)ec; + } + } + if (j < destlen) + dest[j] = (WCHAR_T)0; + return j; + } + else { + return 0; + } +} + +#endif /* WIN */ + +int +clisp_init(void) +{ + int i; + +#ifdef WIN_CANLISP + WCinit(); +#endif + + if ( !allocarea() ) { + return 0; + } + + if ( !initIS() ) { + freearea(); + return 0; + } + + /* stack pointer initialization */ + sp = stack + STKSIZE; + esp = estack + STKSIZE; + epush(NIL); + + /* initialize read pointer */ + readptr = readbuf; + *readptr = '\0'; + files[filep = 0].f = stdin; + files[filep].name = (char *)0; + files[filep].line = 0; + + /* oblist initialization */ + for (i = 0; i < BUFSIZE ; i++) + oblist[i] = 0; + + /* symbol definitions */ + defatms(); + return 1; +} + +#ifndef NO_EXTEND_MENU +static void +fillMenuEntry(void) +{ + extern extraFunc *extrafuncp; + extraFunc *p, *fp; + int i, n, fid; + menuitem *mb; + + for (p = extrafuncp ; p ; p = p->next) { + if (p->keyword == EXTRA_FUNC_DEFMENU) { + n = p->u.menuptr->nentries; + mb = p->u.menuptr->body; + for (i = 0 ; i < n ; i++, mb++) { + if (mb->flag == MENU_SUSPEND) { + list l = (list)mb->u.misc; + fid = symbolpointer(l)->fid; + if (fid < CANNA_FN_MAX_FUNC) { + goto just_a_func; + } + else { + fp = FindExtraFunc(fid); + if (fp && fp->keyword == EXTRA_FUNC_DEFMENU) { + mb->u.menu_next = fp->u.menuptr; + mb->flag = MENU_MENU; + } + else { + just_a_func: + mb->u.fnum = fid; + mb->flag = MENU_FUNC; + } + } + } + } + } + } +} +#endif /* NO_EXTEND_MENU */ + +#define UNTYIUNIT 32 +static char *untyibuf = 0; +static int untyisize = 0, untyip = 0; + +void +clisp_fin(void) +{ +#ifndef NO_EXTEND_MENU + /* ½ª¤ë¤ËÅö¤¿¤Ã¤Æ¡¢menu ´ØÏ¢¤Î¥Ç¡¼¥¿¤òËä¤á¤ë */ + fillMenuEntry(); +#endif + + finIS(); + + while (filep >= 0) { + if (files[filep].f && files[filep].f != stdin) { + fclose(files[filep].f); + } + if (files[filep].name) { + free(files[filep].name); + } + filep--; + } + + freearea(); + if (untyisize) { + free(untyibuf); + untyisize = 0; + untyibuf = (char *)0; + } +} + +int +YYparse_by_rcfilename(char *s) +{ + extern int ckverbose; + int retval = 0; + FILE *f; + FILE *saved_outstream; + + if (setjmp(fatal_env)) { + retval = 0; + goto quit_parse_rcfile; + } + + if (jmpenvp <= 0) { /* ºÆµ¢¤¬¿¼¤¹¤®¤ë¾ì¹ç */ + return 0; + } + jmpenvp--; + + if (ckverbose >= CANNA_HALF_VERBOSE) { + saved_outstream = outstream; +#ifndef WIN /* what ? */ + outstream = stdout; +#endif + } + + f = fopen(s, "r"); + if (f) { + if (ckverbose == CANNA_FULL_VERBOSE) { +#ifndef WIN + printf("¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤È¤·¤Æ \"%s\" ¤òÍѤ¤¤Þ¤¹¡£\n", s); +#endif + } + files[++filep].f = f; + files[filep].name = (char *)malloc(strlen(s) + 1); + if (files[filep].name) { + strcpy(files[filep].name, s); + } + else { + filep--; + fclose(f); + goto quit_parse_rcfile; + } + files[filep].line = 0; + + setjmp(env[jmpenvp].jmp_env); + env[jmpenvp].base_stack = sp - stack; + env[jmpenvp].base_estack = esp - estack; + + for (;;) { + push(Lread(0)); + if (valuec > 1 && null(values[1])) { + break; + } + (void)Leval(1); + } + retval = 1; + } + + if (ckverbose >= CANNA_HALF_VERBOSE) { + outstream = saved_outstream; + } + + jmpenvp++; + quit_parse_rcfile: + return retval; +} + +#define WITH_MAIN +#ifdef WITH_MAIN + +static void +intr(int sig) +/* ARGSUSED */ +{ + error("Interrupt:",NON); + /* NOTREACHED */ +} + +/* cfuncdef + + parse_string -- ʸ»úÎó¤ò¥Ñ¡¼¥¹¤¹¤ë¡£ + +*/ + +parse_string(char *str) +{ + char *readbufbk; + + if (clisp_init() == 0) { + return -1; + } + + /* read buffer ¤È¤·¤ÆÍ¿¤¨¤é¤ì¤¿Ê¸»ú¤ò»È¤¦ */ + readbufbk = readbuf; + readptr = readbuf = str; + + if (setjmp(fatal_env)) { + goto quit_parse_string; + } + + if (jmpenvp <= 0) { /* ºÆµ¢¤¬¿¼¤¹¤®¤ë¾ì¹ç */ + return -1; + } + + jmpenvp--; + files[++filep].f = (FILE *)0; + files[filep].name = (char *)0; + files[filep].line = 0; + + setjmp(env[jmpenvp].jmp_env); + env[jmpenvp].base_stack = sp - stack; + env[jmpenvp].base_estack = esp - estack; + + for (;;) { + list t; + + t = Lread(0); + if (valuec > 1 && null(values[1])) { + break; + } + else { + push(t); + Leval(1); + } + } + jmpenvp++; + quit_parse_string: + readbuf = readbufbk; + clisp_fin(); + return 0; +} + +static void intr(); + +void +clisp_main(void) +{ + if (clisp_init() == 0) { /* initialize data area & etc.. */ + fprintf(stderr, "CannaLisp: initialization failed.\n"); +#ifndef WIN + exit(1); +#endif + } + + if (setjmp(fatal_env)) { + goto quit_clisp_main; + } + + if (jmpenvp <= 0) { /* ºÆµ¢¤¬¿¼¤¹¤®¤ë¾ì¹ç */ + return; + } + jmpenvp--; + + fprintf(stderr,"CannaLisp listener %d.%d%s\n", + CANNA_MAJOR_MINOR / 1000, CANNA_MAJOR_MINOR % 1000, + CANNA_PATCH_LEVEL); + + outstream = stdout; + + setjmp(env[jmpenvp].jmp_env); + env[jmpenvp].base_stack = sp - stack; + env[jmpenvp].base_estack = esp - estack; + +#ifndef WIN + signal(SIGINT, intr); +#endif + for (;;) { + prins("-> "); /* prompt */ + push(Lread(0)); + if (valuec > 1 && null(values[1])) { + break; + } + push(Leval(1)); + if (sp[0] == LISPERROR) { + (void)pop1(); + } + else { + (void)Lprint(1); + prins("\n"); + } + } + jmpenvp++; + quit_clisp_main: + prins("\nGoodbye.\n"); + clisp_fin(); +} + +#endif /* WITH_MAIN */ + +static int longestkeywordlen; + +typedef struct { + char *seq; + int id; +} SeqToID; + +/* #include */ +static SeqToID keywordtable[] = { + {"Space" ,' '}, + {"Escape" ,'\033'}, + {"Tab" ,B_TAB}, + {"Nfer" ,CANNA_KEY_Nfer}, + {"Xfer" ,CANNA_KEY_Xfer}, + {"Backspace" ,B_BACKSPACE}, + {"Delete" ,'\177'}, + {"Insert" ,CANNA_KEY_Insert}, + {"Rollup" ,CANNA_KEY_Rollup}, + {"Rolldown" ,CANNA_KEY_Rolldown}, + {"Up" ,CANNA_KEY_Up}, + {"Left" ,CANNA_KEY_Left}, + {"Right" ,CANNA_KEY_Right}, + {"Down" ,CANNA_KEY_Down}, + {"Home" ,CANNA_KEY_Home}, + {"Clear" ,'\013'}, + {"Help" ,CANNA_KEY_Help}, + {"Enter" ,B_RETURN}, + {"Return" ,B_RETURN}, +/* "F1" is processed by program */ + {"F2" ,CANNA_KEY_F2}, + {"F3" ,CANNA_KEY_F3}, + {"F4" ,CANNA_KEY_F4}, + {"F5" ,CANNA_KEY_F5}, + {"F6" ,CANNA_KEY_F6}, + {"F7" ,CANNA_KEY_F7}, + {"F8" ,CANNA_KEY_F8}, + {"F9" ,CANNA_KEY_F9}, + {"F10" ,CANNA_KEY_F10}, +/* "Pf1" is processed by program */ + {"Pf2" ,CANNA_KEY_PF2}, + {"Pf3" ,CANNA_KEY_PF3}, + {"Pf4" ,CANNA_KEY_PF4}, + {"Pf5" ,CANNA_KEY_PF5}, + {"Pf6" ,CANNA_KEY_PF6}, + {"Pf7" ,CANNA_KEY_PF7}, + {"Pf8" ,CANNA_KEY_PF8}, + {"Pf9" ,CANNA_KEY_PF9}, + {"Pf10" ,CANNA_KEY_PF10}, + {"S-Nfer" ,CANNA_KEY_Shift_Nfer}, + {"S-Xfer" ,CANNA_KEY_Shift_Xfer}, + {"S-Up" ,CANNA_KEY_Shift_Up}, + {"S-Down" ,CANNA_KEY_Shift_Down}, + {"S-Left" ,CANNA_KEY_Shift_Left}, + {"S-Right" ,CANNA_KEY_Shift_Right}, + {"C-Nfer" ,CANNA_KEY_Cntrl_Nfer}, + {"C-Xfer" ,CANNA_KEY_Cntrl_Xfer}, + {"C-Up" ,CANNA_KEY_Cntrl_Up}, + {"C-Down" ,CANNA_KEY_Cntrl_Down}, + {"C-Left" ,CANNA_KEY_Cntrl_Left}, + {"C-Right" ,CANNA_KEY_Cntrl_Right}, + {0 ,0}, +}; + +#define charToNum(c) charToNumTbl[(c) - ' '] + +static int *charToNumTbl; + +typedef struct { + int id; + int *tbl; +} seqlines; + +static seqlines *seqTbl; /* ÆâÉô¤Îɽ(¼ÂºÝ¤Ë¤Ïɽ¤Îɽ) */ +static int nseqtbl; /* ¾õÂ֤οô¡£¾õÂ֤οô¤À¤±É½¤¬¤¢¤ë */ +static int nseq; +static int seqline; + +static +initIS(void) +{ + SeqToID *p; + char *s; + int i; + seqlines seqTbls[1024]; + + seqTbl = (seqlines *)0; + seqline = 0; + nseqtbl = 0; + nseq = 0; + longestkeywordlen = 0; + for (i = 0 ; i < 1024 ; i++) { + seqTbls[i].tbl = (int *)0; + seqTbls[i].id = 0; + } + charToNumTbl = (int *)calloc('~' - ' ' + 1, sizeof(int)); + if ( !charToNumTbl ) { + return 0; + } + + /* ¤Þ¤º²¿Ê¸»ú»È¤ï¤ì¤Æ¤¤¤ë¤«¤òÄ´¤Ù¤ë¡£ + nseq ¤Ï»È¤ï¤ì¤Æ¤¤¤ëʸ»ú¿ô¤è¤ê£±Â礭¤¤ÃͤǤ¢¤ë */ + for (p = keywordtable ; p->id ; p++) { + int len = 0; + for (s = p->seq ; *s ; s++) { + if ( !charToNumTbl[*s - ' '] ) { + charToNumTbl[*s - ' '] = nseq; /* ³ÆÊ¸»ú¤Ë¥·¥ê¥¢¥ëÈÖ¹æ¤ò¿¶¤ë */ + nseq++; + } + len ++; + } + if (len > longestkeywordlen) { + longestkeywordlen = len; + } + } + /* ʸ»ú¿ôʬ¤Î¥Æ¡¼¥Ö¥ë */ + seqTbls[nseqtbl].tbl = (int *)calloc(nseq, sizeof(int)); + if ( !seqTbls[nseqtbl].tbl ) { + goto initISerr; + } + nseqtbl++; + for (p = keywordtable ; p->id ; p++) { + int line, nextline; + + line = 0; + for (s = p->seq ; *s ; s++) { + if (seqTbls[line].tbl == 0) { /* ¥Æ¡¼¥Ö¥ë¤¬¤Ê¤¤ */ + seqTbls[line].tbl = (int *)calloc(nseq, sizeof(int)); + if ( !seqTbls[line].tbl ) { + goto initISerr; + } + } + nextline = seqTbls[line].tbl[charToNum(*s)]; + /* ¤Á¤Ê¤ß¤Ë¡¢charToNum(*s) ¤ÏÀäÂФˣ°¤Ë¤Ê¤é¤Ê¤¤ */ + if ( nextline ) { + line = nextline; + }else{ /* ºÇ½é¤Ë¥¢¥¯¥»¥¹¤·¤¿ */ + line = seqTbls[line].tbl[charToNum(*s)] = nseqtbl++; + } + } + seqTbls[line].id = p->id; + } + seqTbl = (seqlines *)calloc(nseqtbl, sizeof(seqlines)); + if ( !seqTbl ) { + goto initISerr; + } + for (i = 0 ; i < nseqtbl ; i++) { + seqTbl[i].id = seqTbls[i].id; + seqTbl[i].tbl = seqTbls[i].tbl; + } + return 1; + + initISerr: + free(charToNumTbl); + charToNumTbl = (int *)0; + if (seqTbl) { + free(seqTbl); + seqTbl = (seqlines *)0; + } + for (i = 0 ; i < nseqtbl ; i++) { + if (seqTbls[i].tbl) { + free(seqTbls[i].tbl); + seqTbls[i].tbl = (int *)0; + } + } + return 0; +} + +static void +finIS(void) /* identifySequence ¤ËÍѤ¤¤¿¥á¥â¥ê»ñ¸»¤ò³«Êü¤¹¤ë */ +{ + int i; + + if (seqTbl) { + for (i = 0 ; i < nseqtbl ; i++) { + if (seqTbl[i].tbl) free(seqTbl[i].tbl); + seqTbl[i].tbl = (int *)0; + } + free(seqTbl); + seqTbl = (seqlines *)0; + } + if (charToNumTbl) { + free(charToNumTbl); + charToNumTbl = (int *)0; + } +} + +/* cvariable + + seqline: identifySequence ¤Ç¤Î¾õÂÖ¤òÊÝ»ý¤¹¤ëÊÑ¿ô + + */ + +#define CONTINUE 1 +#define END 0 + +static +identifySequence(unsigned c, int *val) +{ + int nextline; + + if (' ' <= c && c <= '~' && charToNum(c) && + (nextline = seqTbl[seqline].tbl[charToNum(c)]) ) { + seqline = nextline; + *val = seqTbl[seqline].id; + if (*val) { + seqline = 0; + return END; + } + else { + return CONTINUE; /* continue */ + } + } + else { + *val = -1; + seqline = 0; + return END; + } +} + + +static int +alloccell(void) +{ + int cellsize, odd; + char *p; + + cellsize = ncells * sizeof(list); + p = (char *)malloc(cellsize); + if (p == (char *)0) { + return 0; + } + memtop = p; + odd = (int)((pointerint)memtop % sizeof(list)); + freecell = celltop = memtop + (odd ? (sizeof(list)) - odd : 0); + cellbtm = memtop + cellsize - odd; + return 1; +} + +/* ¤¦¤Þ¤¯¹Ô¤«¤Ê¤«¤Ã¤¿¤é£°¤òÊÖ¤¹ */ + +static +allocarea(void) +{ + /* ¤Þ¤º¤Ï¥»¥ëÎΰè */ + if (alloccell()) { + /* ¥¹¥¿¥Ã¥¯Îΰè */ + stack = (list *)calloc(STKSIZE, sizeof(list)); + if (stack) { + estack = (list *)calloc(STKSIZE, sizeof(list)); + if (estack) { + /* oblist */ + oblist = (list *)calloc(BUFSIZE, sizeof(list)); + if (oblist) { + /* I/O */ + filep = 0; + files = (lispfile *)calloc(MAX_DEPTH, sizeof(lispfile)); + if (files) { + readbuf = (char *)malloc(BUFSIZE); + if (readbuf) { + /* jump env */ + jmpenvp = MAX_DEPTH; + env = (struct lispcenv *) + calloc(MAX_DEPTH, sizeof(struct lispcenv)); + if (env) { + /* multiple values returning buffer */ + valuec = 1; + values = (list *)calloc(MAXVALUES, sizeof(list)); + if (values) { + return 1; + } + free(env); + } + free(readbuf); + } + free(files); + } + free(oblist); + } + free(estack); + } + free(stack); + } + free(memtop); + } + return 0; +} + +static void +freearea(void) +{ + free(memtop); + free(stack); + free(estack); + free(oblist); + free(files); + free(env); + free(readbuf); + if (values) { + free(values); + values = 0; + } +} + +static list +getatmz(char *name) +{ + int key; + char *p; + + for (p = name, key = 0 ; *p ; p++) + key += *p; + return getatm(name,key); +} + +/* mkatm - + making symbol function */ + +static list +mkatm(char *name) +{ + list temp; + struct atomcell *newatom; + + temp = newsymbol(name); + newatom = symbolpointer(temp); + newatom->value = (*name == ':') ? (list)temp : (list)UNBOUND; + newatom->plist = NIL; /* set null plist */ + newatom->ftype = UNDEF; /* set undef func-type */ + newatom->func = (list (*)())0; /* Don't kill this line */ + newatom->valfunc = (list (*)())0; /* Don't kill this line */ + newatom->hlink = NIL; /* no hash linking */ + newatom->mid = -1; + newatom->fid = -1; + + return temp; +} + +/* getatm -- get atom from the oblist if possible */ + +static list +getatm(char *name, int key) +{ + list p; + struct atomcell *atomp; + + key &= 0x00ff; + for (p = oblist[key] ; p ;) { + atomp = symbolpointer(p); + if (!strcmp(atomp->pname, name)) { + return p; + } + p = atomp->hlink; + } + p = mkatm(name); + atomp = symbolpointer(p); + atomp->hlink = oblist[key]; + oblist[key] = p; + return p; +} + +#define MESSAGE_MAX 256 + +static void +error(char *msg, list v) +/* ARGSUSED */ +{ + char buf[MESSAGE_MAX]; + + prins(msg); + if (v != (list)NON) + print(v); + if (files[filep].f == stdin) { + prins("\n"); + } + else { + if (files[filep].name) { + sprintf(buf, " (%s near line %d)\n", + files[filep].name, files[filep].line); + } + else { + sprintf(buf, " (near line %d)\n", files[filep].line); + } + prins(buf); + } + sp = &stack[env[jmpenvp].base_stack]; + esp = &estack[env[jmpenvp].base_estack]; +/* epush(NIL); */ + longjmp(env[jmpenvp].jmp_env,YES); +} + +static void +fatal(char *msg, list v) +/* ARGSUSED */ +{ + char buf[MESSAGE_MAX]; + + prins(msg); + if (v != (list)NON) + print(v); + if (files[filep].f == stdin) { + prins("\n"); + } + else { + if (files[filep].name) { + sprintf(buf, " (%s near line %d)\n", + files[filep].name, files[filep].line); + } + else { + sprintf(buf, " (near line %d)\n", files[filep].line); + } + prins(buf); + } + longjmp(fatal_env, 1); +} + +static void +argnerr(char *msg) +{ + prins("incorrect number of args to "); + error(msg, NON); + /* NOTREACHED */ +} + +static void +numerr(char *fn, list arg) +{ + prins("Non-number "); + if (fn) { + prins("to "); + prins(fn); + } + error(": ",arg); + /* NOTREACHED */ +} + +static void +lisp_strerr(char *fn, list arg) +{ + prins("Non-string "); + if (fn) { + prins("to "); + prins(fn); + } + error(": ",arg); + /* NOTREACHED */ +} + +static list +Lread(int n) +{ + list t; + + argnchk("read",0); + valuec = 1; + if ((t = read1()) == (list)LISPERROR) { + readptr = readbuf; + *readptr = '\0'; + if (files[filep].f != stdin) { + fclose(files[filep].f); + if (files[filep].name) { + free(files[filep].name); + } + filep--; + } + values[0] = NIL; + values[1] = NIL; + valuec = 2; + return(NIL); + } + else { + values[0] = t; + values[1] = T; + valuec = 2; + return(t); + } + /* NOTREACHED */ +} + +static void untyi (int); +static list rcharacter (void); + +static list +read1(void) +{ + int c; + list p, *pp; + list t; + char *eofmsg = "EOF hit in reading a list : "; + + lab: + if ( !skipspaces() ) { + return((list)LISPERROR); + } + switch (c = tyi()) { + case '(': + push(NIL); + p = Lncons(1); /* get a new cell */ + car(p) = p; + push(p); + pp = sp; + + for (;;) { + lab2: + if ( !skipspaces() ) { + error(eofmsg,cdr(*pp)); + /* NOTREACHED */ + } + switch (c = tyi()) { + case ';': + zaplin(); + goto lab2; + case ')': + return(cdr(pop1())); + case '.': + if ( !(c = tyipeek()) ) { + error(eofmsg,cdr(*pp)); + /* NOTREACHED */ + } + else if ( !isterm(c) ) { + push(ratom2('.')); + push(NIL); + car(*pp) = cdar(*pp) = Lcons(2); + break; + } + else { + cdar(*pp) = read1(); + if (cdar(*pp) == (list)LISPERROR) { + error(eofmsg,cdr(*pp)); + /* NOTREACHED */ + } + while (')' != (c = tyi())) + if ( !c ) { + error(eofmsg,cdr(*pp)); + /* NOTREACHED */ + } + return(cdr(pop1())); + } + default: + untyi(c); + if ((t = read1()) == (list)LISPERROR) { + error(eofmsg,cdr(*pp)); + /* NOTREACHED */ + } + push(t); + push(NIL); + car(*pp) = cdar(*pp) = Lcons(2); + } + } + case '\'': + push(QUOTE); + if ((t = read1()) == (list)LISPERROR) { + error(eofmsg,NIL); + /* NOTREACHED */ + } + push(t); + push(NIL); + push(Lcons(2)); + return Lcons(2); + case '"': + return rstring(); + case '?': + return rcharacter(); + case ';': + zaplin(); + goto lab; + default: + untyi(c); + return ratom(); + } +} + +/* skipping spaces function - + if eof read then return NO */ + +static +skipspaces(void) +{ + int c; + + while ((c = tyi()) <= ' ') { + if ( !c ) { + return(NO); + } +#ifdef QUIT_IF_BINARY_CANNARC +/* ¼Â¤Ï fatal() ¤Ë¤·¤Æ¤·¤Þ¤¦¤È read ¤Ç¤­¤Ê¤«¤Ã¤¿¤È»×¤¤¡¢¼¡¤Î¥Õ¥¡¥¤¥ë¤ò + õ¤·¤Ë¹Ô¤¯¤Î¤Ç¤¢¤Þ¤êÎɤ¯¤Ê¤¤¡£return ¤ò¼õ¤±¤¿¤È¤³¤í¤âÊѤ¨¤Ê¤±¤ì¤Ð¤Ê + ¤é¤Ê¤¤¡£ÌÌÅݤʤΤǡ¢¤È¤ê¤¢¤¨¤º³°¤¹ */ + if (c != '\033' && c != '\n' && c != '\r' && c!= '\t' && c < ' ') { + fatal("read: Binary data read.", NON); + } +#endif + } + untyi(c); + return(YES); +} + +/* skip reading until '\n' - + if eof read then return NO */ + +static +zaplin(void) +{ + int c; + + while ((c = tyi()) != '\n') + if ( !c ) + return(NO); + return(YES); +} + +static void gc(); + +static list +newcons(void) +{ + list retval; + + if (freecell + sizeof(struct cell) >= cellbtm) { + gc(); + } + retval = CONS_TAG | (freecell - celltop); + freecell += sizeof(struct cell); + return retval; +} + +static list +newsymbol(char *name) +{ + list retval; + struct atomcell *temp; + int namesize; + + namesize = strlen(name); + namesize = ((namesize / sizeof(list)) + 1) * sizeof(list); /* +1¤Ï'\0'¤Îʬ */ + if (freecell + (sizeof(struct atomcell)) + namesize >= cellbtm) { + gc(); + } + temp = (struct atomcell *)freecell; + retval = SYMBOL_TAG | (freecell - celltop); + freecell += sizeof(struct atomcell); + (void)strcpy(freecell, name); + temp->pname = freecell; + freecell += namesize; + + return retval; +} + +static void patom(); + +static void +print(list l) +{ + if ( !l ) /* case NIL */ + prins("nil"); + else if (atom(l)) + patom(l); + else { + tyo('('); + print(car(l)); + for (l = cdr(l) ; l ; l = cdr(l)) { + tyo(' '); + if (atom(l)) { + tyo('.'); + tyo(' '); + patom(l); + break; + } + else + print(car(l)); + } + tyo(')'); + } +} + + + +/* +** read atom +*/ + + +static list +ratom(void) +{ + return(ratom2(tyi())); +} + +/* read atom with the first one character - + check if the token is numeric or pure symbol & return proper value */ + +static isnum(); + +static list +ratom2(int a) +{ + int i, c, flag; + char atmbuf[BUFSIZE]; + + flag = NO; + if (a == '\\') { + flag = YES; + a = tyi(); + } + atmbuf[0] = a; + for (i = 1, c = tyi(); !isterm(c) ; i++, c = tyi()) { + if ( !c ) { + error("Eof hit in reading symbol.", NON); + /* NOTREACHED */ + } + if (c == '\\') { + flag = YES; + } + if (i < BUFSIZE) { + atmbuf[i] = c; + } + else { + error("Too long symbol name read", NON); + /* NOTREACHED */ + } + } + untyi(c); + if (i < BUFSIZE) { + atmbuf[i] = '\0'; + } + else { + error("Too long symbol name read", NON); + /* NOTREACHED */ + } + if ( !flag && isnum(atmbuf)) { + return(mknum(atoi(atmbuf))); + } + else if ( !flag && !strcmp("nil",atmbuf) ) { + return(NIL); + } + else { + return (getatmz(atmbuf)); + } +} + +static list +rstring(void) +{ + char strb[BUFSIZE]; + int c; + int strp = 0; + + while ((c = tyi()) != '"') { + if ( !c ) { + error("Eof hit in reading a string.", NON); + /* NOTREACHED */ + } + if (strp < BUFSIZE) { + if (c == '\\') { + untyi(c); + c = (char)(((unsigned POINTERINT)rcharacter()) & 0xff); + } + strb[strp++] = (char)c; + } + else { + error("Too long string read.", NON); + /* NOTREACHED */ + } + } + if (strp < BUFSIZE) { + strb[strp] = '\0'; + } + else { + error("Too long string read.", NON); + /* NOTREACHED */ + } + + return copystring(strb, strp); +} + +/* rcharacter -- °ìʸ»úÆÉ¤ó¤ÇÍè¤ë¡£ */ + +static list +rcharacter(void) +{ + char *tempbuf; + unsigned ch; + list retval; + int bufp; + + tempbuf = (char *)malloc(longestkeywordlen + 1); + if ( !tempbuf ) { + fatal("read: (char *)malloc failed in reading character.", NON); + /* NOTREACHED */ + } + bufp = 0; + + ch = tyi(); + if (ch == '\\') { + int code, res; + + do { /* ¥­¡¼¥ï¡¼¥É¤È¾È¹ç¤¹¤ë */ + tempbuf[bufp++] = ch = tyi(); + res = identifySequence(ch, &code); + } while (res == CONTINUE); + if (code != -1) { /* ¥­¡¼¥ï¡¼¥É¤È°ìÃפ·¤¿¡£ */ + retval = mknum(code); + } + else if (bufp > 2 && tempbuf[0] == 'C' && tempbuf[1] == '-') { + while (bufp > 3) { + untyi(tempbuf[--bufp]); + } + retval = mknum(tempbuf[2] & (' ' - 1)); + } + else if (bufp == 3 && tempbuf[0] == 'F' && tempbuf[1] == '1') { + untyi(tempbuf[2]); + retval = mknum(CANNA_KEY_F1); + } + else if (bufp == 4 && tempbuf[0] == 'P' && tempbuf[1] == 'f' && + tempbuf[2] == '1') { + untyi(tempbuf[3]); + retval = mknum(CANNA_KEY_PF1); + } + else { /* Á´Á³ÂÌÌÜ */ + while (bufp > 1) { + untyi(tempbuf[--bufp]); + } + ch = (unsigned)(unsigned char)tempbuf[0]; + goto return_char; + } + } + else { + return_char: + if (ch == 0x8f) { /* SS3 */ + ch <<= 8; + ch += tyi(); + goto shift_more; + } + else if (ch & 0x80) { /* ¤¦¡Á¤ó¡¢ÆüËܸì¤Ë°Í¸¤·¤Æ¤¤¤ë */ + shift_more: + ch <<= 8; + ch += tyi(); + } + retval = mknum(ch); + } + + free(tempbuf); + return retval; +} + +static int +isnum(char *name) +{ + if (*name == '-') { + name++; + if ( !*name ) + return(NO); + } + for(; *name ; name++) { + if (*name < '0' || '9' < *name) { + if (*name != '.' || *(name + 1)) { + return(NO); + } + } + } + return(YES); +} + +/* tyi -- input one character from buffered stream */ + +static void +untyi(int c) +{ + if (readbuf < readptr) { + *--readptr = c; + } + else { + if (untyip >= untyisize) { + if (untyisize == 0) { + untyibuf = (char *)malloc(UNTYIUNIT); + if (untyibuf) { + untyisize = UNTYIUNIT; + } + }else{ + untyibuf = (char *)realloc(untyibuf, UNTYIUNIT + untyisize); + if (untyibuf) { + untyisize += UNTYIUNIT; + } + } + } + if (untyip < untyisize) { /* ¤½¤ì¤Ç¤â¥Á¥§¥Ã¥¯¤¹¤ë */ + untyibuf[untyip++] = c; + } + } +} + +static int +tyi(void) +{ + if (untyibuf) { + int ret = untyibuf[--untyip]; + if (untyip == 0) { + free(untyibuf); + untyibuf = (char *)0; + untyisize = 0; + } + return ret; + } + + if (readptr && *readptr) { + return ((int)(unsigned char)*readptr++); + } + else if (!files[filep].f) { + return NO; + } + else if (files[filep].f == stdin) { + readptr = fgets(readbuf, BUFSIZE, stdin); + files[filep].line++; + if ( !readptr ) { + return NO; + } + else { + return tyi(); + } + } + else { + readptr = fgets(readbuf,BUFSIZE,files[filep].f); + files[filep].line++; + if (readptr) { + return(tyi()); + } + else { + return(NO); + } + } + /* NOTREACHED */ +} + +/* tyipeek -- input one character without advance the read pointer */ + +static int +tyipeek(void) +{ + int c = tyi(); + untyi(c); + return c; +} + + + +/* prins - + print string */ + +static void prins(char *s) +{ + while (*s) { + tyo(*s++); + } +} + + +/* isterm - + check if the character is terminating the lisp expression */ + +static isterm(int c) +{ + if (c <= ' ') + return(YES); + else { + switch (c) + { + case '(': + case ')': + case ';': + return(YES); + default: + return(NO); + } + } +} + +/* push down an S-expression to parameter stack */ + +static void +push(list value) +{ + if (sp <= stack) { + error("Stack over flow",NON); + /* NOTREACHED */ + } + else + *--sp = value; +} + +/* pop up n S-expressions from parameter stack */ + +static void +pop(int x) +{ + if (0 < x && sp >= &stack[STKSIZE]) { + error("Stack under flow",NON); + /* NOTREACHED */ + } + sp += x; +} + +/* pop up an S-expression from parameter stack */ + +static list +pop1(void) +{ + if (sp >= &stack[STKSIZE]) { + error("Stack under flow",NON); + /* NOTREACHED */ + } + return(*sp++); +} + +static void +epush(list value) +{ + if (esp <= estack) { + error("Estack over flow",NON); + /* NOTREACHED */ + } + else + *--esp = value; +} + +static list +epop(void) +{ + if (esp >= &estack[STKSIZE]) { + error("Lstack under flow",NON); + /* NOTREACHED */ + } + return(*esp++); +} + + +/* +** output function for lisp S-Expression +*/ + + +/* +** print atom function +** please make sure it is an atom (not list) +** no check is done here. +*/ + +static void +patom(list atm) +{ + char namebuf[BUFSIZE]; + + if (constp(atm)) { + if (numberp(atm)) { + (void)sprintf(namebuf,"%d",xnum(atm)); + prins(namebuf); + } + else { /* this is a string */ + int i, len = xstrlen(atm); + char *s = xstring(atm); + + tyo('"'); + for (i = 0 ; i < len ; i++) { + tyo(s[i]); + } + tyo('"'); + } + } + else { + prins(symbolpointer(atm)->pname); + } +} + +static char *oldcelltop; +static char *oldcellp; + +#define oldpointer(x) (oldcelltop + celloffset(x)) + +static void +gc(void) /* ¥³¥Ô¡¼Êý¼°¤Î¥¬¡¼¥Ù¥¸¥³¥ì¥¯¥·¥ç¥ó¤Ç¤¢¤ë */ +{ + int i; + list *p; + static int under_gc = 0; + + if (under_gc) { + fatal("GC: memory exhausted.", NON); + } + else { + under_gc = 1; + } + + oldcellp = memtop; oldcelltop = celltop; + + if ( !alloccell() ) { + fatal("GC: failed in allocating new cell area.", NON); + /* NOTREACHED */ + } + + for (i = 0 ; i < BUFSIZE ; i++) { + markcopycell(oblist + i); + } + for (p = sp ; p < &stack[STKSIZE] ; p++) { + markcopycell(p); + } + for (p = esp ; p < &estack[STKSIZE] ; p++) { + markcopycell(p); + } + for (i = 0 ; i < valuec ; i++) { + markcopycell(values + i); + } + markcopycell(&T); + markcopycell("E); + markcopycell(&_LAMBDA); + markcopycell(&_MACRO); + markcopycell(&COND); + markcopycell(&USER); + markcopycell(&BUSHU); + markcopycell(&GRAMMAR); + markcopycell(&RENGO); + markcopycell(&KATAKANA); + markcopycell(&HIRAGANA); + markcopycell(&HYPHEN); + free(oldcellp); + if ((freecell - celltop) * 2 > cellbtm -celltop) { + ncells = (freecell - celltop) * 2 / sizeof(list); + } + under_gc = 0; +} + +static char *Strncpy(); + +static list +allocstring(int n) +{ + int namesize; + list retval; + + namesize = ((n + (sizeof(pointerint)) + 1 + 3)/ sizeof(list)) * sizeof(list); + if (freecell + namesize >= cellbtm) { /* gc Ãæ¤Ïµ¯¤³¤êÆÀ¤Ê¤¤¤Ï¤º */ + gc(); + } + ((struct stringcell *)freecell)->length = n; + retval = STRING_TAG | (freecell - celltop); + freecell += namesize; + return retval; +} + +static list +copystring(char *s, int n) +{ + list retval; + + retval = allocstring(n); + (void)Strncpy(xstring(retval), s, n); + xstring(retval)[n] = '\0'; + return retval; +} + +static list +copycons(struct cell *l) +{ + list newcell; + + newcell = newcons(); + car(newcell) = l->head; + cdr(newcell) = l->tail; + return newcell; +} + +static void +markcopycell(list *addr) +{ + list temp; + redo: + if (null(*addr) || numberp(*addr)) { + return; + } + else if (alreadycopied(oldpointer(*addr))) { + *addr = newaddr(gcfield(oldpointer(*addr))); + return; + } + else if (stringp(*addr)) { + temp = copystring(((struct stringcell *)oldpointer(*addr))->str, + ((struct stringcell *)oldpointer(*addr))->length); + gcfield(oldpointer(*addr)) = mkcopied(temp); + *addr = temp; + return; + } + else if (consp(*addr)) { + temp = copycons((struct cell *)(oldpointer(*addr))); + gcfield(oldpointer(*addr)) = mkcopied(temp); + *addr = temp; + markcopycell(&car(temp)); + addr = &cdr(temp); + goto redo; + } + else { /* symbol */ + struct atomcell *newatom, *oldatom; + + oldatom = (struct atomcell *)(oldpointer(*addr)); + temp = newsymbol(oldatom->pname); + newatom = symbolpointer(temp); + newatom->value = oldatom->value; + newatom->plist = oldatom->plist; + newatom->ftype = oldatom->ftype; + newatom->func = oldatom->func; + newatom->fid = oldatom->fid; + newatom->mid = oldatom->mid; + newatom->valfunc = oldatom->valfunc; + newatom->hlink = oldatom->hlink; + + gcfield(oldpointer(*addr)) = mkcopied(temp); + *addr = temp; + + if (newatom->value != (list)UNBOUND) { + markcopycell(&newatom->value); + } + markcopycell(&newatom->plist); + if (newatom->ftype == EXPR || newatom->ftype == MACRO) { + markcopycell((list *)&newatom->func); + } + addr = &newatom->hlink; + goto redo; + } +} + +static list +bindall(list var, list par, list a, list e) +{ + list *pa, *pe, retval; + + push(a); pa = sp; + push(e); pe = sp; + retry: + if (constp(var)) { + pop(2); + return(*pa); + } + else if (atom(var)) { + push(var); + push(par); + push(Lcons(2)); + push(*pa); + retval = Lcons(2); + pop(2); + return retval; + } + else if (atom(par)) { + error("Bad macro form ",e); + /* NOTREACHED */ + } + push(par); + push(var); + *pa = bindall(car(var),car(par),*pa,*pe); + var = cdr(pop1()); + par = cdr(pop1()); + goto retry; + /* NOTREACHED */ +} + +static list +Lquote(void) +{ + list p; + + p = pop1(); + if (atom(p)) + return(NIL); + else + return(car(p)); +} + +static list +Leval(int n) +{ + list e, t, s, tmp, aa, *pe, *pt, *ps, *paa; + list fn, (*cfn)(...), *pfn; + int i, j; + argnchk("eval",1); + e = sp[0]; + pe = sp; + if (atom(e)) { + if (constp(e)) { + pop1(); + return(e); + } + else { + struct atomcell *sym; + + t = assq(e, *esp); + if (t) { + (void)pop1(); + return(cdr(t)); + } + else if ((sym = symbolpointer(e))->valfunc) { + (void)pop1(); + return (sym->valfunc)(VALGET, 0); + }else{ + if ((t = (sym->value)) != (list)UNBOUND) { + pop1(); + return(t); + } + else { + error("Unbound variable: ",*pe); + /* NOTREACHED */ + } + } + } + } + else if (constp((fn = car(e)))) { /* not atom */ + error("eval: undefined function ", fn); + /* NOTREACHED */ + } + else if (atom(fn)) { + switch (symbolpointer(fn)->ftype) { + case UNDEF: + error("eval: undefined function ", fn); + /* NOTREACHED */ + break; + case SUBR: + cfn = symbolpointer(fn)->func; + i = evpsh(cdr(e)); + epush(NIL); + t = (*cfn)(i); + epop(); + pop1(); + return (t); + case SPECIAL: + push(cdr(e)); + t = (*(symbolpointer(fn)->func))(); + pop1(); + return (t); + case EXPR: + fn = (list)(symbolpointer(fn)->func); + aa = NIL; /* previous env won't be used */ + expr: + if (atom(fn) || car(fn) != _LAMBDA || atom(cdr(fn))) { + error("eval: bad lambda form ", fn); + /* NOTREACHED */ + } +/* Lambda binding begins here ... */ + s = cdr(e); /* actual parameter */ + t = cadr(fn); /* lambda list */ + push(s); ps = sp; + push(t); pt = sp; + push(fn); pfn = sp; + push(aa); paa = sp; + i = 0; /* count of variables */ + for (; consp(*ps) && consp(*pt) ; *ps = cdr(*ps), *pt = cdr(*pt)) { + if (consp(car(*pt))) { + tmp = cdar(*pt); /* push the cdr of element */ + if (!(atom(tmp) || null(cdr(tmp)))) { + push(cdr(tmp)); + push(T); + push(Lcons(2)); + i++; + } + push(caar(*pt)); + } + else { + push(car(*pt)); + } + push(car(*ps)); + push(Leval(1)); + push(Lcons(2)); + i++; + } + for (; consp(*pt) ; *pt = cdr(*pt)) { + if (atom(car(*pt))) { + error("Too few actual parameters ",*pe); + /* NOTREACHED */ + } + else { + tmp = cdar(*pt); + if (!(atom(tmp) || null(cdr(tmp)))) { + push(cdr(tmp)); + push(NIL); + push(Lcons(2)); + i++; + } + push(caar(*pt)); + tmp = cdar(*pt); /* restore for GC */ + if (atom(tmp)) + push(NIL); + else { + push(car(tmp)); + push(Leval(1)); + } + push(Lcons(2)); + i++; + } + } + if (null(*pt) && consp(*ps)) { + error("Too many actual arguments ",*pe); + /* NOTREACHED */ + } + else if (*pt) { + push(*pt); + for (j = 1 ; consp(*ps) ; j++) { + push(car(*ps)); + push(Leval(1)); + *ps = cdr(*ps); + } + push(NIL); + for (; j ; j--) { + push(Lcons(2)); + } + i++; + } + push(*paa); + for (; i ; i--) { + push(Lcons(2)); + } +/* Lambda binding finished, and a new environment is established. */ + epush(pop1()); /* set the new environment */ + push(cddr(*pfn)); + t = Lprogn(); + epop(); + pop(5); + return (t); + case MACRO: + fn = (list)(symbolpointer(fn)->func); + if (atom(fn) || car(fn) != _MACRO || atom(cdr(fn))) { + error("eval: bad macro form ",fn); + /* NOTREACHED */ + } + s = cdr(e); /* actual parameter */ + t = cadr(fn); /* lambda list */ + push(fn); + epush(bindall(t,s,NIL,e)); + push(cddr(pop1())); + t = Lprogn(); + epop(); + push(t); + push(t); + s = Leval(1); + t = pop1(); + if (!atom(t)) { + car(*pe) = car(t); + cdr(*pe) = cdr(t); + } + pop1(); + return (s); + case CMACRO: + push(e); + push(t = (*(symbolpointer(fn)->func))()); + push(t); + s = Leval(1); + t = pop1(); + if (!atom(t)) { + car(e) = car(t); + cdr(e) = cdr(t); + } + pop1(); + return (s); + default: + error("eval: unrecognized ftype used in ", fn); + /* NOTREACHED */ + break; + } + /* NOTREACHED */ + } + else { /* fn is list (lambda expression) */ + aa = *esp; /* previous environment is also used */ + goto expr; + } + /* maybe NOTREACHED */ + return NIL; +} + +static list +assq(list e, list a) +{ + list i; + + for (i = a ; i ; i = cdr(i)) { + if (consp(car(i)) && e == caar(i)) { + return(car(i)); + } + } + return((list)NIL); +} + +/* eval each argument and push down each value to parameter stack */ + +static int +evpsh(list args) +{ + int counter; + list temp; + + counter = 0; + while (consp(args)) { + push(args); + push(car(args)); + temp = Leval(1); + args = cdr(pop1()); + counter++; + push(temp); + } + return (counter); +} + +/* +static int +psh(args) +list args; +{ + int counter; + + counter = 0; + while (consp(args)) { + push(car(args)); + counter++; + args = cdr(args); + } + return (counter); +} +*/ + +static list +Lprogn(void) +{ + list val, *pf; + + val = NIL; + pf = sp; + for (; consp(*pf) ; *pf = cdr(*pf)) { + symbolpointer(T)->value = T; + push(car(*pf)); + val = Leval(1); + } + pop1(); + return (val); +} + +static list +Lcons(int n) +{ + list temp; + + argnchk("cons",2); + temp = newcons(); + cdr(temp) = pop1(); + car(temp) = pop1(); + return(temp); +} + +static list +Lncons(int n) +{ + list temp; + + argnchk("ncons",1); + temp = newcons(); + car(temp) = pop1(); + cdr(temp) = NIL; + return(temp); +} + +static list +Lxcons(int n) +{ + list temp; + + argnchk("cons",2); + temp = newcons(); + car(temp) = pop1(); + cdr(temp) = pop1(); + return(temp); +} + +static list +Lprint(int n) +{ + print(sp[0]); + pop(n); + return (T); +} + +static list +Lset(int n) +{ + list val, t; + list var; + struct atomcell *sym; + + argnchk("set",2); + val = pop1(); + var = pop1(); + if (!symbolp(var)) { + error("set/setq: bad variable type ",var); + /* NOTREACHED */ + } + sym = symbolpointer(var); + t = assq(var,*esp); + if (t) { + return cdr(t) = val; + } + else if (sym->valfunc) { + return (*(sym->valfunc))(VALSET, val); + } + else { + return sym->value = val; /* global set */ + } +} + +static list +Lsetq(void) +{ + list a, *pp; + + a = NIL; + for (pp = sp; consp(*pp) ; *pp = cdr(*pp)) { + push(car(*pp)); + *pp = cdr(*pp); + if ( atom(*pp) ) { + error("Odd number of args to setq",NON); + /* NOTREACHED */ + } + push(car(*pp)); + push(Leval(1)); + a = Lset(2); + } + pop1(); + return(a); +} + +static int equal(); + +static list +Lequal(int n) +{ + argnchk("equal (=)",2); + if (equal(pop1(),pop1())) + return(T); + else + return(NIL); +} + +/* null ʸ»ú¤Ç½ª¤ï¤é¤Ê¤¤ strncmp */ + +static int +Strncmp(char *x, char *y, int len) +{ + int i; + + for (i = 0 ; i < len ; i++) { + if (x[i] != y[i]) { + return (x[i] - y[i]); + } + } + return 0; +} + +/* null ʸ»ú¤Ç½ª¤ï¤é¤Ê¤¤ strncpy */ + +static char * +Strncpy(char *x, char *y, int len) +{ + int i; + + for (i = 0 ; i < len ; i++) { + x[i] = y[i]; + } + return x; +} + +static int +equal(list x, list y) +{ + equaltop: + if (x == y) + return(YES); + else if (null(x) || null(y)) + return(NO); + else if (numberp(x) || numberp(y)) { + return NO; + } + else if (stringp(x)) { + if (stringp(y)) { + return ((xstrlen(x) == xstrlen(y)) ? + (!Strncmp(xstring(x), xstring(y), xstrlen(x))) : 0); + } + else { + return NO; + } + } + else if (symbolp(x) || symbolp(y)) { + return(NO); + } + else { + if (equal(car(x), car(y))) { + x = cdr(x); + y = cdr(y); + goto equaltop; + } + else + return(NO); + } +} + +static list +Lgreaterp(int n) +{ + list p; + pointerint x, y; + + if ( !n ) + return(T); + else { + p = pop1(); + if (!numberp(p)) { + numerr("greaterp",p); + /* NOTREACHED */ + } + x = xnum(p); + for (n-- ; n ; n--) { + p = pop1(); + if (!numberp(p)) { + numerr("greaterp",p); + /* NOTREACHED */ + } + y = xnum(p); + if (y <= x) /* !(y > x) */ + return(NIL); + x = y; + } + return(T); + } +} + +static list +Llessp(int n) +{ + list p; + pointerint x, y; + + if ( !n ) + return(T); + else { + p = pop1(); + if (!numberp(p)) { + numerr("lessp",p); + /* NOTREACHED */ + } + x = xnum(p); + for (n-- ; n ; n--) { + p = pop1(); + if (!numberp(p)) { + numerr("lessp",p); + /* NOTREACHED */ + } + y = xnum(p); + if (y >= x) /* !(y < x) */ + return(NIL); + x = y; + } + return(T); + } +} + +static list +Leq(int n) +{ + list f; + + argnchk("eq",2); + f = pop1(); + if (f == pop1()) + return(T); + else + return(NIL); +} + +static list +Lcond(void) +{ + list *pp, t, a, c; + + pp = sp; + for (; consp(*pp) ; *pp = cdr(*pp)) { + t = car(*pp); + if (atom(t)) { + pop1(); + return (NIL); + } + else { + push(cdr(t)); + if ((c = car(t)) == T || (push(c), (a = Leval(1)))) { + /* if non NIL */ + t = pop1(); + if (null(t)) { /* if cdr is NIL */ + (void)pop1(); + return (a); + } + else { + (void)pop1(); + push(t); + return(Lprogn()); + } + }else{ + (void)pop1(); + } + } + } + pop1(); + return (NIL); +} + +static list +Lnull(int n) +{ + argnchk("null",1); + if (pop1()) + return NIL; + else + return T; +} + +static list +Lor(void) +{ + list *pp, t; + + for (pp = sp; consp(*pp) ; *pp = cdr(*pp)) { + push(car(*pp)); + t = Leval(1); + if (t) { + pop1(); + return(t); + } + } + pop1(); + return(NIL); +} + +static list +Land(void) +{ + list *pp, t; + + t = T; + for (pp = sp; consp(*pp) ; *pp = cdr(*pp)) { + push(car(*pp)); + if ( !(t = Leval(1)) ) { + pop1(); + return(NIL); + } + } + pop1(); + return(t); +} + +static list +Lplus(int n) +{ + list t; + int i; + pointerint sum; + + i = n; + sum = 0; + while (i--) { + t = sp[i]; + if ( !numberp(t) ) { + numerr("+",t); + /* NOTREACHED */ + } + else { + sum += xnum(t); + } + } + pop(n); + return(mknum(sum)); +} + +static list +Ltimes(int n) +{ + list t; + int i; + pointerint sum; + + i = n; + sum = 1; + while (i--) { + t = sp[i]; + if ( !numberp(t) ) { + numerr("*",t); + /* NOTREACHED */ + } + else + sum *= xnum(t); + } + pop(n); + return(mknum(sum)); +} + +static list +Ldiff(int n) +{ + list t; + int i; + pointerint sum; + + if ( !n ) + return(mknum(0)); + t = sp[n - 1]; + if ( !numberp(t) ) { + numerr("-",t); + /* NOTREACHED */ + } + sum = xnum(t); + if (n == 1) { + pop1(); + return(mknum(-sum)); + } + else { + i = n - 1; + while (i--) { + t = sp[i]; + if ( !numberp(t) ) { + numerr("-",t); + /* NOTREACHED */ + } + else + sum -= xnum(t); + } + pop(n); + return(mknum(sum)); + } +} + +static list +Lquo(int n) +{ + list t; + int i; + pointerint sum; + + if ( !n ) + return(mknum(1)); + t = sp[n - 1]; + if ( !numberp(t) ) { + numerr("/",t); + /* NOTREACHED */ + } + sum = xnum(t); + i = n - 1; + while (i--) { + t = sp[i]; + if ( !numberp(t) ) { + numerr("/",t); + /* NOTREACHED */ + } + else if (xnum(t) != 0) { + sum = sum / (pointerint)xnum(t); /* CP/M68K is bad... */ + } + else { /* division by zero */ + error("Division by zero",NON); + } + } + pop(n); + return(mknum(sum)); +} + +static list +Lrem(int n) +{ + list t; + int i; + pointerint sum; + + if ( !n ) + return(mknum(0)); + t = sp[n - 1]; + if ( !numberp(t) ) { + numerr("%",t); + /* NOTREACHED */ + } + sum = xnum(t); + i = n - 1; + while (i--) { + t = sp[i]; + if ( !numberp(t) ) { + numerr("%",t); + /* NOTREACHED */ + } + else if (xnum(t) != 0) { + sum = sum % (pointerint)xnum(t); /* CP/M68K is bad .. */ + } + else { /* division by zero */ + error("Division by zero",NON); + } + } + pop(n); + return(mknum(sum)); +} + +/* + * Garbage Collection + */ + +static list +Lgc(int n) +{ + argnchk("gc",0); + gc(); + return(NIL); +} + +static list +Lusedic(int n) +{ + int i; + list retval = NIL, temp; + int dictype; +#ifndef WIN_CANLISP + extern struct dicname *kanjidicnames; + struct dicname *kanjidicname; + extern int auto_define; +#endif + + for (i = n ; i ; i--) { + temp = sp[i - 1]; + dictype = DIC_PLAIN; + if (symbolp(temp) && i - 1 > 0) { + if (temp == USER) { + dictype = DIC_USER; + } + else if (temp == BUSHU) { + dictype = DIC_BUSHU; + } + else if (temp == GRAMMAR) { + dictype = DIC_GRAMMAR; + } + else if (temp == RENGO) { + dictype = DIC_RENGO; + } + else if (temp == KATAKANA) { + dictype = DIC_KATAKANA; +#ifndef WIN_CANLISP + auto_define = 1; +#endif + } + else if (temp == HIRAGANA) { + dictype = DIC_HIRAGANA; +#if defined(HIRAGANAAUTO) && defined(WIN_CANLISP) + auto_define = 1; +#endif + } + i--; temp = sp[i - 1]; + } + if (stringp(temp)) { +#ifndef WIN_CANLISP + kanjidicname = (struct dicname *)malloc(sizeof(struct dicname)); + if (kanjidicname) { + kanjidicname->name = (char *)malloc(strlen(xstring(temp)) + 1); + if (kanjidicname->name) { + strcpy(kanjidicname->name , xstring(temp)); + kanjidicname->dictype = dictype; + kanjidicname->dicflag = DIC_NOT_MOUNTED; + kanjidicname->next = kanjidicnames; + kanjidicnames = kanjidicname; + retval = T; + continue; + } + free(kanjidicname); + } +#else /* if WIN_CANLISP */ + if (wins.conf && wins.conf->dicfn) { + (*wins.conf->dicfn)(xstring(temp), dictype, wins.context); + } +#endif /* WIN_CANLISP */ + } + } + pop(n); + return retval; +} + +static list +Llist(int n) +{ + push(NIL); + for (; n ; n--) { + push(Lcons(2)); + } + return (pop1()); +} + +static list +Lcopysym(int n) +{ + list src, dst; + struct atomcell *dsta, *srca; + + argnchk("copy-symbol",2); + src = pop1(); + dst = pop1(); + if (!symbolp(dst)) { + error("copy-symbol: bad arg ", dst); + /* NOTREACHED */ + } + if (!symbolp(src)) { + error("copy-symbol: bad arg ", src); + /* NOTREACHED */ + } + dsta = symbolpointer(dst); + srca = symbolpointer(src); + dsta->plist = srca->plist; + dsta->value = srca->value; + dsta->ftype = srca->ftype; + dsta->func = srca->func; + dsta->valfunc = srca->valfunc; + dsta->mid = srca->mid; + dsta->fid = srca->fid; + return src; +} + +static list +Lload(int n) +{ + list p, t; + FILE *instream; + + argnchk("load",1); + p = pop1(); + if ( !stringp(p) ) { + error("load: illegal file name ",p); + /* NOTREACHED */ + } + if ((instream = fopen(xstring(p), "r")) == (FILE *)NULL) { + error("load: file not found ",p); + /* NOTREACHED */ + } + prins("[load "); + print(p); + prins("]\n"); + + if (jmpenvp <= 0) { /* ºÆµ¢¤¬¿¼¤¹¤®¤ë¾ì¹ç */ + return NIL; + } + jmpenvp--; + files[++filep].f = instream; + files[filep].name = (char *)malloc(xstrlen(p) + 1); + if (files[filep].name) { + strcpy(files[filep].name, xstring(p)); + } + files[filep].line = 0; + + setjmp(env[jmpenvp].jmp_env); + env[jmpenvp].base_stack = sp - stack; + env[jmpenvp].base_estack = esp - estack; + + for (;;) { + t = Lread(0); + if (valuec > 1 && null(values[1])) { + break; + } + else { + push(t); + Leval(1); + } + } + jmpenvp++; + return(T); +} + +static list +Lmodestr(int n) +{ + list p; + int mode; + + argnchk(S_SetModeDisp, 2); + if ( !null(p = sp[0]) && !stringp(p) ) { + lisp_strerr(S_SetModeDisp, p); + /* NOTREACHED */ + } + if (!symbolp(sp[1]) || (mode = symbolpointer(sp[1])->mid) == -1) { + error("Illegal mode ", sp[1]); + /* NOTREACHED */ + } +#ifndef WIN_CANLISP + changeModeName(mode, null(p) ? 0 : xstring(p)); +#endif + pop(2); + return p; +} + +/* µ¡Ç½¥·¡¼¥±¥ó¥¹¤Î¼è¤ê½Ð¤· */ + +static int +xfseq(char *fname, list l, unsigned char *arr, int arrsize) +{ + int i; + + if (atom(l)) { + if (symbolp(l) && + (arr[0] = (unsigned char)(symbolpointer(l)->fid)) != 255) { + arr[1] = 0; + } + else { + prins(fname); + error(": illegal function ", l); + /* NOTREACHED */ + } + return 1; + } + else { + for (i = 0 ; i < arrsize - 1 && consp(l) ; i++, l = cdr(l)) { + list temp = car(l); + + if (!symbolp(temp) || + (arr[i] = (unsigned char)(symbolpointer(temp)->fid)) == 255) { + prins(fname); + error(": illegal function ", temp); + /* NOTREACHED */ + } + } + arr[i] = 0; + return i; + } +} + +static list +Lsetkey(int n) +{ + list p; + int mode, slen; + unsigned char fseq[256]; + unsigned char keyseq[256]; +#ifndef WIN_CANLISP + int retval; +#endif + + argnchk(S_SetKey, 3); + if ( !stringp(p = sp[1]) ) { + lisp_strerr(S_SetKey, p); + /* NOTREACHED */ + } + if (!symbolp(sp[2]) || (mode = symbolpointer(sp[2])->mid) < 0 || + (CANNA_MODE_MAX_REAL_MODE <= mode && + mode < CANNA_MODE_MAX_IMAGINARY_MODE && + mode != CANNA_MODE_HenkanNyuryokuMode)) { + error("Illegal mode for set-key ", sp[2]); + /* NOTREACHED */ + } + if (xfseq(S_SetKey, sp[0], fseq, 256)) { + slen = xstrlen(p); + Strncpy((char *)keyseq, xstring(p), slen); + keyseq[slen] = 255; +#ifndef WIN_CANLISP + retval = changeKeyfunc(mode, (unsigned)keyseq[0], + slen > 1 ? CANNA_FN_UseOtherKeymap : + (fseq[1] != 0 ? CANNA_FN_FuncSequence : fseq[0]), + fseq, keyseq); + if (retval == NG) { + error("Insufficient memory.", NON); + /* NOTREACHED */ + } +#else + if (wins.conf && wins.conf->keyfn) { + (*wins.conf->keyfn)(mode, keyseq, slen, fseq, strlen(fseq), + wins.context); + } +#endif + } + pop(3); + return p; +} + +static list +Lgsetkey(int n) +{ + list p; + int slen; + unsigned char fseq[256]; + unsigned char keyseq[256]; +#ifndef WIN_CANLISP + int retval; +#endif + + argnchk(S_GSetKey, 2); + if ( !stringp(p = sp[1]) ) { + lisp_strerr(S_GSetKey, p); + /* NOTREACHED */ + } + if (xfseq(S_GSetKey, sp[0], fseq, 256)) { + slen = xstrlen(p); + Strncpy((char *)keyseq, xstring(p), slen); + keyseq[slen] = 255; +#ifndef WIN_CANLISP + retval = changeKeyfuncOfAll((unsigned)keyseq[0], + slen > 1 ? CANNA_FN_UseOtherKeymap : + (fseq[1] != 0 ? CANNA_FN_FuncSequence : fseq[0]), + fseq, keyseq); + if (retval == NG) { + error("Insufficient memory.", NON); + /* NOTREACHED */ + } +#else /* if WIN_CANLISP */ + if (wins.conf && wins.conf->keyfn) { + (*wins.conf->keyfn)(255, keyseq, slen, fseq, strlen(fseq), wins.context); + } +#endif /* WIN_CANLISP */ + pop(2); + return p; + } + else { + pop(2); + return NIL; + } +} + +static list +Lputd(int n) +{ + list body, a; + list sym; + struct atomcell *symp; + + argnchk("putd",2); + a = body = pop1(); + sym = pop1(); + symp = symbolpointer(sym); + if (constp(sym) || consp(sym)) { + error("putd: function name must be a symbol : ",sym); + /* NOTREACHED */ + } + if (null(body)) { + symp->ftype = UNDEF; + symp->func = (list (*)())UNDEF; + } + else if (consp(body)) { + if (car(body) == _MACRO) { + symp->ftype = MACRO; + symp->func = (list (*)())body; + } + else { + symp->ftype = EXPR; + symp->func = (list (*)())body; + } + } + return(a); +} + +static list +Ldefun(void) +{ + list form, res; + + form = sp[0]; + if (atom(form)) { + error("defun: illegal form ",form); + /* NOTREACHED */ + } + push(car(form)); + push(_LAMBDA); + push(cdr(form)); + push(Lcons(2)); + Lputd(2); + res = car(pop1()); + return (res); +} + +static list +Ldefmacro(void) +{ + list form, res; + + form = sp[0]; + if (atom(form)) { + error("defmacro: illegal form ",form); + /* NOTREACHED */ + } + push(res = car(form)); + push(_MACRO); + push(cdr(form)); + push(Lcons(2)); + Lputd(2); + pop1(); + return (res); +} + +static list +Lcar(int n) +{ + list f; + + argnchk("car",1); + f = pop1(); + if (!f) + return(NIL); + else if (atom(f)) { + error("Bad arg to car ",f); + /* NOTREACHED */ + } + return(car(f)); +} + +static list +Lcdr(int n) +{ + list f; + + argnchk("cdr",1); + f = pop1(); + if (!f) + return(NIL); + else if (atom(f)) { + error("Bad arg to cdr ",f); + /* NOTREACHED */ + } + return(cdr(f)); +} + +static list +Latom(int n) +{ + list f; + + argnchk("atom",1); + f = pop1(); + if (atom(f)) + return(T); + else + return(NIL); +} + +static list +Llet(void) +{ + list lambda, args, p, *pp, *pq, *pl, *px; + + px = sp; + *px = cdr(*px); + if (atom(*px)) { + (void)pop1(); + return(NIL); + } + else { + push(NIL); + args = Lncons(1); + push(args); pq = sp; + push(NIL); + lambda = p = Lncons(1); + push(lambda); + + push(p); pp = sp; + push(*pq); pq = sp; + push(NIL); pl = sp; + for (*pl = car(*px) ; consp(*pl) ; *pl = cdr(*pl)) { + if (atom(car(*pl))) { + push(car(*pl)); + *pp = cdr(*pp) = Lncons(1); + push(NIL); + *pq = cdr(*pq) = Lncons(1); + } + else if (atom(cdar(*pl))) { + push(caar(*pl)); + *pp = cdr(*pp) = Lncons(1); + push(NIL); + *pq = cdr(*pq) = Lncons(1); + }else{ + push(caar(*pl)); + *pp = cdr(*pp) = Lncons(1); + push(cadr(car(*pl))); + *pq = cdr(*pq) = Lncons(1); + } + } + pop(3); + sp[0] = cdr(sp[0]); + sp[1] = cdr(sp[1]); + push(cdr(*px)); + push(Lcons(2)); + push(_LAMBDA); + push(Lxcons(2)); + p = Lxcons(2); + (void)pop1(); + return(p); + } +} + +/* (if con tr . falist) -> (cond (con tr) (t . falist))*/ + +static list +Lif(void) +{ + list x, *px, retval; + + x = cdr(sp[0]); + if (atom(x) || atom(cdr(x))) { + (void)pop1(); + return NIL; + } + else { + push(x); px = sp; + + push(COND); + + push(car(x)); + push(cadr(x)); + push(Llist(2)); + + push(T); + push(cddr(*px)); + push(Lcons(2)); + + retval = Llist(3); + pop(2); + return retval; + } +} + +static list +Lunbindkey(int n) +{ + unsigned char fseq[2]; + static unsigned char keyseq[2] = {(unsigned char)CANNA_KEY_Undefine, + (unsigned char)255}; + int mode; + list retval; + + argnchk(S_UnbindKey, 2); + if (!symbolp(sp[1]) || (mode = symbolpointer(sp[1])->mid) == -1) { + error("Illegal mode ", sp[1]); + /* NOTREACHED */ + } + if (xfseq(S_UnbindKey, sp[0], fseq, 2)) { +#ifndef WIN_CANLISP + int ret; + ret = changeKeyfunc(mode, CANNA_KEY_Undefine, + fseq[1] != 0 ? CANNA_FN_FuncSequence : fseq[0], + fseq, keyseq); + if (ret == NG) { + error("Insufficient memory.", NON); + /* NOTREACHED */ + } +#else /* if WIN_CANLISP */ + if (wins.conf && wins.conf->keyfn) { + (*wins.conf->keyfn)(mode, keyseq, 1, fseq, 1, wins.context); + } +#endif /* WIN_CANLISP */ + retval = T; + } + else { + retval = NIL; + } + pop(2); + return retval; +} + +static list +Lgunbindkey(int n) +{ + unsigned char fseq[2]; + static unsigned char keyseq[2] = {(unsigned char)CANNA_KEY_Undefine, + (unsigned char)255}; + list retval; + + argnchk(S_GUnbindKey, 1); + if (xfseq(S_GUnbindKey, sp[0], fseq, 2)) { +#ifndef WIN_CANLISP + int ret; + ret = changeKeyfuncOfAll(CANNA_KEY_Undefine, + fseq[1] != 0 ? CANNA_FN_FuncSequence : fseq[0], + fseq, keyseq); + if (ret == NG) { + error("Insufficient memory.", NON); + /* NOTREACHED */ + } +#else /* if WIN_CANLISP */ + if (wins.conf && wins.conf->keyfn) { + (*wins.conf->keyfn)(255, keyseq, 1, fseq, 1, wins.context); + } +#endif /* WIN_CANLISP */ + retval = T; + } + else { + retval = NIL; + } + (void)pop1(); + return retval; +} + +#define DEFMODE_MEMORY 0 +#define DEFMODE_NOTSTRING 1 +#define DEFMODE_ILLFUNCTION 2 + +static list +Ldefmode(void) +{ + list form, *sym, e, *p, fn, rd, md, us; + extern extraFunc *extrafuncp; + extern int nothermodes; + extraFunc *extrafunc = (extraFunc *)0; + int i, j; +#ifndef WIN_CANLISP + int ecode; + list l, edata; +#endif + + form = pop1(); + if (atom(form)) { + error("Bad form ", form); + /* NOTREACHED */ + } + push(car(form)); + sym = sp; + if (!symbolp(*sym)) { + error("Symbol data expected ", *sym); + /* NOTREACHED */ + } + + /* °ú¿ô¤ò¥×¥Ã¥·¥å¤¹¤ë */ + for (i = 0, e = cdr(form) ; i < 4 ; i++, e = cdr(e)) { + if (atom(e)) { + for (j = i ; j < 4 ; j++) { + push(NIL); + } + break; + } + push(car(e)); + } + if (consp(e)) { + error("Bad form ", form); + /* NOTREACHED */ + } + + /* ɾ²Á¤¹¤ë */ + for (i = 0, p = sym - 1 ; i < 4 ; i++, p--) { + push(*p); + push(Leval(1)); + } + us = pop1(); + fn = pop1(); + rd = pop1(); + md = pop1(); + pop(4); + +#ifndef WIN_CANLISP + ecode = DEFMODE_MEMORY; + extrafunc = (extraFunc *)malloc(sizeof(extraFunc)); + if (extrafunc) { + /* ¥·¥ó¥Ü¥ë¤Î´Ø¿ôÃͤȤ·¤Æ¤ÎÄêµÁ */ + symbolpointer(*sym)->mid = CANNA_MODE_MAX_IMAGINARY_MODE + nothermodes; + symbolpointer(*sym)->fid = + extrafunc->fnum = CANNA_FN_MAX_FUNC + nothermodes; + + /* ¥Ç¥Õ¥©¥ë¥È¤ÎÀßÄê */ + extrafunc->display_name = (WCHAR_T *)NULL; + extrafunc->u.modeptr = (newmode *)malloc(sizeof(newmode)); + if (extrafunc->u.modeptr) { + KanjiMode kanjimode; + + extrafunc->u.modeptr->romaji_table = (char *)0; + extrafunc->u.modeptr->romdic = (struct RkRxDic *)0; + extrafunc->u.modeptr->romdic_owner = 0; + extrafunc->u.modeptr->flags = CANNA_YOMI_IGNORE_USERSYMBOLS; + extrafunc->u.modeptr->emode = (KanjiMode)0; + + /* ¥â¡¼¥É¹½Â¤ÂΤκîÀ® */ + kanjimode = (KanjiMode)malloc(sizeof(KanjiModeRec)); + if (kanjimode) { + extern KanjiModeRec empty_mode; + extern BYTE *emptymap; + + kanjimode->func = searchfunc; + kanjimode->keytbl = emptymap; + kanjimode->flags = + CANNA_KANJIMODE_TABLE_SHARED | CANNA_KANJIMODE_EMPTY_MODE; + kanjimode->ftbl = empty_mode.ftbl; + extrafunc->u.modeptr->emode = kanjimode; + + /* ¥â¡¼¥Éɽ¼¨Ê¸»úÎó */ + ecode = DEFMODE_NOTSTRING; + edata = md; + if (stringp(md) || null(md)) { + if (stringp(md)) { + extrafunc->display_name = WString(xstring(md)); + } + ecode = DEFMODE_MEMORY; + if (null(md) || extrafunc->display_name) { + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë */ + ecode = DEFMODE_NOTSTRING; + edata = rd; + if (stringp(rd) || null(rd)) { + char *newstr; + long f = extrafunc->u.modeptr->flags; + + if (stringp(rd)) { + newstr = (char *)malloc(strlen(xstring(rd)) + 1); + } + ecode = DEFMODE_MEMORY; + if (null(rd) || newstr) { + if (!null(rd)) { + strcpy(newstr, xstring(rd)); + extrafunc->u.modeptr->romaji_table = newstr; + } + /* ¼Â¹Ôµ¡Ç½ */ + for (e = fn ; consp(e) ; e = cdr(e)) { + l = car(e); + if (symbolp(l) && symbolpointer(l)->fid) { + switch (symbolpointer(l)->fid) { + case CANNA_FN_Kakutei: + f |= CANNA_YOMI_KAKUTEI; + break; + case CANNA_FN_Henkan: + f |= CANNA_YOMI_HENKAN; + break; + case CANNA_FN_Zenkaku: + f |= CANNA_YOMI_ZENKAKU; + break; + case CANNA_FN_Hankaku: + f |= CANNA_YOMI_HANKAKU; + break; + case CANNA_FN_Hiragana: + f |= CANNA_YOMI_HIRAGANA; + break; + case CANNA_FN_Katakana: + f |= CANNA_YOMI_KATAKANA; + break; + case CANNA_FN_Romaji: + f |= CANNA_YOMI_ROMAJI; + break; + /* °Ê²¼¤Ï¤½¤Î¤¦¤Á¤ä¤í¤¦ */ + case CANNA_FN_ToUpper: + break; + case CANNA_FN_Capitalize: + break; + case CANNA_FN_ToLower: + break; + default: + goto defmode_not_function; + } + } + else { + goto defmode_not_function; + } + } + extrafunc->u.modeptr->flags = f; + + /* ¥æ¡¼¥¶¥·¥ó¥Ü¥ë¤Î»ÈÍѤÎ̵ͭ */ + if (us) { + extrafunc->u.modeptr->flags &= + ~CANNA_YOMI_IGNORE_USERSYMBOLS; + } + + extrafunc->keyword = EXTRA_FUNC_DEFMODE; + extrafunc->next = extrafuncp; + extrafuncp = extrafunc; + nothermodes++; + return pop1(); + + defmode_not_function: + ecode = DEFMODE_ILLFUNCTION; + edata = l; + if (!null(rd)) { + free(newstr); + } + } + } + if (extrafunc->display_name) { + WSfree(extrafunc->display_name); + } + } + } + free(kanjimode); + } + free(extrafunc->u.modeptr); + } + free(extrafunc); + } + switch (ecode) { + case DEFMODE_MEMORY: + error("Insufficient memory", NON); + case DEFMODE_NOTSTRING: + error("String data expected ", edata); + case DEFMODE_ILLFUNCTION: + error("defmode: illegal subfunction ", edata); + } + /* NOTREACHED */ +#else /* if WIN_CANLISP */ + /* ¥·¥ó¥Ü¥ë¤Î´Ø¿ôÃͤȤ·¤Æ¤ÎÄêµÁ */ + symbolpointer(*sym)->mid = CANNA_MODE_MAX_IMAGINARY_MODE + nothermodes; + symbolpointer(*sym)->fid = CANNA_FN_MAX_FUNC + nothermodes; + nothermodes++; + return pop1(); +#endif /* WIN_CANLISP */ +} + +static list +Ldefsym(void) +{ + list form, res, e; + int i, ncand, group; + WCHAR_T cand[1024], *p, *mcand, **acand, key, xkey; + int mcandsize; + extern nkeysup; + extern keySupplement keysup[]; + + form = sp[0]; + if (atom(form)) { + error("Illegal form ",form); + /* NOTREACHED */ + } + /* ¤Þ¤º¿ô¤ò¤«¤¾¤¨¤ë */ + for (ncand = 0 ; consp(form) ; ) { + e = car(form); + if (!numberp(e)) { + error("Key data expected ", e); + /* NOTREACHED */ + } + if (null(cdr(form))) { + error("Illegal form ",sp[0]); + /* NOTREACHED */ + } + if (numberp(car(cdr(form)))) { + form = cdr(form); + } + for (i = 0, form = cdr(form) ; consp(form) ; i++, form = cdr(form)) { + e = car(form); + if (!stringp(e)) { + break; + } + } + if (ncand == 0) { + ncand = i; + } + else if (ncand != i) { + error("Inconsist number for each key definition ", sp[0]); + /* NOTREACHED */ + } + } + + group = nkeysup; + + for (form = sp[0] ; consp(form) ;) { + if (nkeysup >= MAX_KEY_SUP) { + error("Too many symbol definitions", sp[0]); + /* NOTREACHED */ + } + /* The following lines are for xkey translation rule */ + key = (WCHAR_T)xnum(car(form)); + if (numberp(car(cdr(form)))) { + xkey = (WCHAR_T)xnum(car(cdr(form))); + form = cdr(form); + } + else { + xkey = key; + } + p = cand; + for (form = cdr(form) ; consp(form) ; form = cdr(form)) { + int len; + + e = car(form); + if (!stringp(e)) { + break; + } + len = MBstowcs(p, xstring(e), 1024 - (p - cand)); + p += len; + *p++ = (WCHAR_T)0; + } + *p++ = (WCHAR_T)0; + mcandsize = p - cand; + mcand = (WCHAR_T *)malloc(mcandsize * sizeof(WCHAR_T)); + if (mcand == 0) { + error("Insufficient memory", NON); + /* NOTREACHED */ + } + acand = (WCHAR_T **)calloc(ncand + 1, sizeof(WCHAR_T *)); + if (acand == 0) { + free(mcand); + error("Insufficient memory", NON); + /* NOTREACHED */ + } + + for (i = 0 ; i < p - cand ; i++) { + mcand[i] = cand[i]; + } + for (i = 0, p = mcand ; i < ncand ; i++) { + acand[i] = p; + while (*p++) + /* EMPTY */ + ; + } + acand[i] = 0; + /* ¼ÂºÝ¤Ë³ÊǼ¤¹¤ë */ + keysup[nkeysup].key = key; + keysup[nkeysup].xkey = xkey; + keysup[nkeysup].groupid = group; + keysup[nkeysup].ncand = ncand; + keysup[nkeysup].cand = acand; + keysup[nkeysup].fullword = mcand; +#ifdef WIN_CANLISP + keysup[nkeysup].fullwordsize = mcandsize - 1; /* exclude the extra EOS */ +#endif + nkeysup++; + } +#ifdef WIN_CANLISP + if (wins.conf && wins.conf->symfn) { + unsigned char *keys, *xkeys; + WCHAR_T *words; + int ngroups = nkeysup - group, fullwordlen, i; + + for (fullwordlen = 0, i = group ; i < nkeysup ; i++) { + fullwordlen += keysup[i].fullwordsize; + } + + keys = (char *)malloc(ngroups + 1); + if (keys) { + xkeys = (char *)malloc(ngroups + 1); + if (xkeys) { + words = (WCHAR_T *)malloc(fullwordlen * sizeof(WCHAR_T)); + if (words) { + unsigned char *pk = keys, *px = xkeys; + WCHAR_T *pw = words, *ps; + int j, len; + + for (i = group ; i < nkeysup ; i++) { + *pk++ = (unsigned char)keysup[i].key; + *px++ = (unsigned char)keysup[i].xkey; + len = keysup[i].fullwordsize; + ps = keysup[i].fullword; + for (j = 0 ; j < len ; j++) { + *pw++ = *ps++; + } + } + *pk = (unsigned char)0; + *px = (unsigned char)0; + + (*wins.conf->symfn)(keysup[group].ncand, nkeysup - group, + pw - words, keys, xkeys, words, wins.context); + + free(words); + } + free(xkeys); + } + free(keys); + } + } +#endif + res = car(pop1()); + return (res); +} + +#ifndef NO_EXTEND_MENU + +/* + defselection ¤Ç°ìÍ÷¤Îʸ»ú¤ò¼è¤ê½Ð¤¹¤¿¤á¤ËɬÍפʤΤǡ¢°Ê²¼¤òÄêµÁ¤¹¤ë + */ + +#define SS2 ((char)0x8e) +#define SS3 ((char)0x8f) + +#define G0 0 +#define G1 1 +#define G2 2 +#define G3 3 + +static int cswidth[4] = {1, 2, 2, 3}; + + +/* + getKutenCode -- ʸ»ú¤Î¶èÅÀ¥³¡¼¥É¤ò¼è¤ê½Ð¤¹ + */ + +static int +getKutenCode(char *data, int *ku, int *ten) +{ + int codeset; + + *ku = (data[0] & 0x7f) - 0x20; + *ten = (data[1] & 0x7f) - 0x20; + if (*data == SS2) { + codeset = G2; + *ku = 0; + } + else if (*data == SS3) { + codeset = G3; + *ku = *ten; + *ten = (data[2] & 0x7f) - 0x20; + } + else if (*data & 0x80) { + codeset = G1; + } + else { + codeset = G0; + *ten = *ku; + *ku = 0; + } + return codeset; +} + +/* + howManuCharsAre -- defselection ¤ÇÈϰϻØÄꤷ¤¿¾ì¹ç¤Ë + ¤½¤ÎÈÏ°ÏÆâ¤Î¿Þ·Áʸ»ú¤Î¸Ä¿ô¤òÊÖ¤¹ + */ + +static int +howManyCharsAre(char *tdata, char *edata, int *tku, int *tten, int *codeset) +{ + int eku, eten, kosdata, koedata; + + kosdata = getKutenCode(tdata, tku, tten); + koedata = getKutenCode(edata, &eku, &eten); + if (kosdata != koedata) { + return 0; + } + else { + *codeset = kosdata; + return ((eku - *tku) * 94 + eten - *tten + 1); + } +} + + +/* + pickupChars -- ÈÏ°ÏÆâ¤Î¿Þ·Áʸ»ú¤ò¼è¤ê½Ð¤¹ + */ + +static char * +pickupChars(int tku, int tten, int num, int kodata) +{ + char *dptr, *tdptr, *edptr; + + dptr = (char *)malloc(num * cswidth[kodata] + 1); + if (dptr) { + tdptr = dptr; + edptr = dptr + num * cswidth[kodata]; + for (; dptr < edptr ; tten++) { + if (tten > 94) { + tku++; + tten = 1; + } + switch(kodata) { + case G0: + *dptr++ = (tten + 0x20); + break; + case G1: + *dptr++ = (tku + 0x20) | 0x80; + *dptr++ = (tten + 0x20) | 0x80; + break; + case G2: + *dptr++ = SS2; + *dptr++ = (tten + 0x20) | 0x80; + break; + case G3: + *dptr++ = SS3; + *dptr++ = (tku + 0x20) | 0x80; + *dptr++ = (tten + 0x20) | 0x80; + break; + default: + break; + } + } + *dptr++ = '\0'; + return tdptr; + } + else { + error("Insufficient memory", NON); + /* NOTREACHED */ + } +} + +/* + numtostr -- Key data ¤«¤éʸ»ú¤ò¼è¤ê½Ð¤¹ + */ + +static void +numtostr(unsigned long num, char *str) +{ + if (num & 0xff0000) { + *str++ = (char)((num >> 16) & 0xff); + } + if (num & 0xff00) { + *str++ = (char)((num >> 8) & 0xff); + } + *str++ = (char)(num & 0xff); + *str = '\0'; +} + +/* + defselection -- ʸ»ú°ìÍ÷¤ÎÄêµÁ + + ¡Ô·Á¼°¡Õ + (defselection function-symbol "¥â¡¼¥Éɽ¼¨" '(character-list)) + */ + +static list +Ldefselection(void) +{ + list form, sym, e, e2, md, kigo_list, buf; + extern extraFunc *extrafuncp; + extern int nothermodes; + int i, len, cs, nkigo_data = 0, kigolen = 0; + WCHAR_T *p, *kigo_str, **akigo_data; + extraFunc *extrafunc = (extraFunc *)0; + + form = sp[0]; + + if (atom(form) || atom(cdr(form)) || atom(cdr(cdr(form)))) { + error("Illegal form ",form); + /* NOTREACHED */ + } + + sym = car(form); + if (!symbolp(sym)) { + error("Symbol data expected ", sym); + /* NOTREACHED */ + } + + md = car(cdr(form)); + if (!stringp(md) && !null(md)) { + error("String data expected ", md); + /* NOTREACHED */ + } + + push(car(cdr(cdr(form)))); + push(Leval(1)); + + kigo_list = sp[0]; + if (atom(kigo_list)) { + error("Illegal form ", kigo_list); + /* NOTREACHED */ + } + + /* ¤Þ¤ºÎΰè¤ò³ÎÊݤ¹¤ë */ + buf = kigo_list; + while (!atom(buf)) { + if (!atom(cdr(buf)) && (car(cdr(buf)) == HYPHEN)) { + /* ÈϰϻØÄê¤Î¤È¤­ */ + if (atom(cdr(cdr(buf)))) { + error("Illegal form ", buf); + /* NOTREACHED */ + }else{ + int sku, sten, num; + char ss[4], ee[4]; + + e = car(buf); + if (!numberp(e)) { + error("Key data expected ", e); + /* NOTREACHED */ + } + e2 = car(cdr(cdr(buf))); + if (!numberp(e2)) { + error("Key data expected ", e2); + /* NOTREACHED */ + } + + numtostr(xnum(e), ss); + numtostr(xnum(e2), ee); + num = howManyCharsAre(ss, ee, &sku, &sten, &cs); + if (num <= 0) { + error("Inconsistent range of charcter code ", buf); + /* NOTREACHED */ + } + kigolen = kigolen + (cswidth[cs] + 1) * num; + nkigo_data += num; + } + buf = cdr(cdr(cdr(buf))); + } + else { + /* Í×ÁÇ»ØÄê¤Î¤È¤­ */ + char xx[4], *xxp; + + e = car(buf); + if (!numberp(e) && !stringp(e)) { + error("Key or string data expected ", e); + /* NOTREACHED */ + } + else if (numberp(e)) { + numtostr(xnum(e), xx); + xxp = xx; + }else{ + xxp = xstring(e); + } + + for ( ; *xxp ; xxp += cswidth[cs] ) { + if (*xxp == SS2) { + cs = G2; + } + else if (*xxp == SS3) { + cs = G3; + } + else if (*xxp & 0x80) { + cs = G1; + } + else { + cs = G0; + } + kigolen = kigolen + cswidth[cs]; + } + kigolen += 1; /* ³ÆÍ×ÁǤκǸå¤Ë \0 ¤òÆþ¤ì¤ë */ + nkigo_data++; + buf = cdr(buf); + } + } + + kigo_str = (WCHAR_T *)malloc(kigolen * sizeof(WCHAR_T)); + if (!kigo_str) { + error("Insufficient memory ", NON); + /* NOTREACHED */ + } + p = kigo_str; + + /* °ìÍ÷¤ò¼è¤ê½Ð¤¹ */ + while (!atom(kigo_list)) { + if (!atom(cdr(kigo_list)) && (car(cdr(kigo_list)) == HYPHEN)) { + /* ÈϰϻØÄê¤Î¤È¤­ */ + int sku, sten, codeset, num; + char *ww, *sww, *eww, ss[4], ee[4], bak; + + e = car(kigo_list); + e2 = car(cdr(cdr(kigo_list))); + numtostr(xnum(e), ss); + numtostr(xnum(e2), ee); + num = howManyCharsAre(ss, ee, &sku, &sten, &codeset); + sww = ww = pickupChars(sku, sten, num, codeset); + cs = cswidth[codeset]; + eww = ww + num * cs; + while (ww < eww) { + bak = ww[cs]; + ww[cs] = '\0'; + len = MBstowcs(p, ww, kigolen - (p - kigo_str)); + p += len; + *p++ = (WCHAR_T)0; + ww += cs; + ww[0] = bak; + } + free(sww); + kigo_list = cdr(cdr(cdr(kigo_list))); + } + else { + /* Í×ÁÇ»ØÄê¤Î¤È¤­ */ + char xx[4], *xxp; + + e = car(kigo_list); + if (numberp(e)) { + numtostr(xnum(e), xx); + xxp = xx; + }else{ + xxp = xstring(e); + } + len = MBstowcs(p, xxp, kigolen - (p - kigo_str)); + p += len; + *p++ = (WCHAR_T)0; + kigo_list = cdr(kigo_list); + } + } + + akigo_data = (WCHAR_T **)calloc(nkigo_data + 1, sizeof(WCHAR_T *)); + if (akigo_data == 0) { + free(kigo_str); + error("Insufficient memory", NON); + /* NOTREACHED */ + } + + for (i = 0, p = kigo_str ; i < nkigo_data ; i++) { + akigo_data[i] = p; + while (*p++) + /* EMPTY */ + ; + } + + /* Îΰè¤ò³ÎÊݤ¹¤ë */ + extrafunc = (extraFunc *)malloc(sizeof(extraFunc)); + if (!extrafunc) { + free(kigo_str); + free(akigo_data); + error("Insufficient memory", NON); + /* NOTREACHED */ + } + extrafunc->u.kigoptr = (kigoIchiran *)malloc(sizeof(kigoIchiran)); + if (!extrafunc->u.kigoptr) { + free(kigo_str); + free(akigo_data); + free(extrafunc); + error("Insufficient memory", NON); + /* NOTREACHED */ + } + + /* ¥·¥ó¥Ü¥ë¤Î´Ø¿ôÃͤȤ·¤Æ¤ÎÄêµÁ */ + symbolpointer(sym)->mid = extrafunc->u.kigoptr->kigo_mode + = CANNA_MODE_MAX_IMAGINARY_MODE + nothermodes; + symbolpointer(sym)->fid = extrafunc->fnum + = CANNA_FN_MAX_FUNC + nothermodes; + + /* ¼ÂºÝ¤Ë³ÊǼ¤¹¤ë */ + extrafunc->u.kigoptr->kigo_data = akigo_data; + extrafunc->u.kigoptr->kigo_str = kigo_str; + extrafunc->u.kigoptr->kigo_size = nkigo_data; + if (stringp(md)) { + extrafunc->display_name = WString(xstring(md)); + } + else { + extrafunc->display_name = (WCHAR_T *)0; + } + + extrafunc->keyword = EXTRA_FUNC_DEFSELECTION; + extrafunc->next = extrafuncp; + extrafuncp = extrafunc; + pop(2); + nothermodes++; + return sym; +} + +/* + defmenu -- ¥á¥Ë¥å¡¼¤ÎÄêµÁ + + ¡Ô·Á¼°¡Õ + (defmenu first-menu + ("ÅÐÏ¿" touroku) + ("¥µ¡¼¥ÐÁàºî" server)) + */ + +static list +Ldefmenu(void) +{ + list form, sym, e; + extern extraFunc *extrafuncp; + extern int nothermodes; + extraFunc *extrafunc = (extraFunc *)0; + int i, n, clen, len; + WCHAR_T foo[512]; + menustruct *men; + menuitem *menubody; + WCHAR_T *wp, **wpp; + + form = sp[0]; + if (atom(form) || atom(cdr(form))) { + error("Bad form ", form); + /* NOTREACHED */ + } + sym = car(form); + if (!symbolp(sym)) { + error("Symbol data expected ", sym); + /* NOTREACHED */ + } + + /* °ú¿ô¤ò¿ô¤¨¤ë¡£¤Ä¤¤¤Ç¤Ëɽ¼¨Ê¸»úÎó¤Îʸ»ú¿ô¤ò¿ô¤¨¤ë */ + for (n = 0, clen = 0, e = cdr(form) ; !atom(e) ; n++, e = cdr(e)) { + list l = car(e), d, fn; + if (atom(l) || atom(cdr(l))) { + error("Bad form ", form); + } + d = car(l); + fn = car(cdr(l)); + if (!stringp(d) || !symbolp(fn)) { + error("Bad form ", form); + } + len = MBstowcs(foo, xstring(d), 512); + if (len >= 0) { + clen += len + 1; + } + } + + extrafunc = (extraFunc *)malloc(sizeof(extraFunc)); + if (extrafunc) { + men = allocMenu(n, clen); + if (men) { + menubody = men->body; + /* ¥¿¥¤¥È¥ëʸ»ú¤ò¥Ç¡¼¥¿¥Ð¥Ã¥Õ¥¡¤Ë¥³¥Ô¡¼ */ + for (i = 0, wp = men->titledata, wpp = men->titles, e = cdr(form) ; + i < n ; i++, e = cdr(e)) { + len = MBstowcs(wp, xstring(car(car(e))), 512); + *wpp++ = wp; + wp += len + 1; + + menubody[i].flag = MENU_SUSPEND; + menubody[i].u.misc = (char *)car(cdr(car(e))); + } + men->nentries = n; + + /* ¥·¥ó¥Ü¥ë¤Î´Ø¿ôÃͤȤ·¤Æ¤ÎÄêµÁ */ + symbolpointer(sym)->mid = + men->modeid = CANNA_MODE_MAX_IMAGINARY_MODE + nothermodes; + symbolpointer(sym)->fid = + extrafunc->fnum = CANNA_FN_MAX_FUNC + nothermodes; + extrafunc->keyword = EXTRA_FUNC_DEFMENU; + extrafunc->display_name = (WCHAR_T *)0; + extrafunc->u.menuptr = men; + + extrafunc->next = extrafuncp; + extrafuncp = extrafunc; + nothermodes++; + (void)pop1(); + return sym; + } + free(extrafunc); + } + error("Insufficient memory", NON); + /* NOTREACHED */ +} +#endif /* NO_EXTEND_MENU */ + +static list +Lsetinifunc(int n) +{ + unsigned char fseq[256]; + int i, len; + list ret = NIL; + extern BYTE *initfunc; + + argnchk(S_SetInitFunc, 1); + + len = xfseq(S_SetInitFunc, sp[0], fseq, 256); + + if (len > 0) { + if (initfunc) free(initfunc); + initfunc = (BYTE *)malloc(len + 1); + if (!initfunc) { + error("Insufficient memory", NON); + /* NOTREACHED */ + } + for (i = 0 ; i < len ; i++) { + initfunc[i] = fseq[i]; + } + initfunc[i] = 0; + ret = T; + } + (void)pop1(); + return ret; +} + +static list +Lboundp(int n) +{ + list e; + struct atomcell *sym; + + argnchk("boundp",1); + e = pop1(); + + if (!atom(e)) { + error("boundp: bad arg ", e); + /* NOTREACHED */ + } + else if (constp(e)) { + error("boundp: bad arg ", e); + /* NOTREACHED */ + } + + if (assq(e, *esp)) { + return T; + } + else if ((sym = symbolpointer(e))->valfunc) { + return T; + } + else { + if (sym->value != (list)UNBOUND) { + return T; + } + else { + return NIL; + } + } +} + +static list +Lfboundp(int n) +{ + list e; + + argnchk("fboundp",1); + e = pop1(); + + if (!atom(e)) { + error("fboundp: bad arg ", e); + /* NOTREACHED */ + } + else if (constp(e)) { + error("fboundp: bad arg ", e); + /* NOTREACHED */ + } + if (symbolpointer(e)->ftype == UNDEF) { + return NIL; + } + else { + return T; + } +} + +static list +Lgetenv(int n) +{ + list e; + char strbuf[256], *ret; + list retval; + + argnchk("getenv",1); + e = sp[0]; + + if (!stringp(e)) { + error("getenv: bad arg ", e); + /* NOTREACHED */ + } + + strncpy(strbuf, xstring(e), xstrlen(e)); + strbuf[xstrlen(e)] = '\0'; + ret = getenv(strbuf); + if (ret) { + retval = copystring(ret, strlen(ret)); + } + else { + retval = NIL; + } + (void)pop1(); + return retval; +} + +static list +LdefEscSeq(int n) +{ + + argnchk("define-esc-sequence",3); + + if (!stringp(sp[2])) { + error("define-esc-sequence: bad arg ", sp[2]); + /* NOTREACHED */ + } + if (!stringp(sp[1])) { + error("define-esc-sequence: bad arg ", sp[1]); + /* NOTREACHED */ + } + if (!numberp(sp[0])) { + error("define-esc-sequence: bad arg ", sp[0]); + /* NOTREACHED */ + } + if (keyconvCallback) { + (*keyconvCallback)(CANNA_CTERMINAL, + xstring(sp[2]), xstring(sp[1]), xnum(sp[0])); + } + pop(3); + return NIL; +} + +static list +LdefXKeysym(int n) +{ + + argnchk("define-x-keysym",2); + + if (!stringp(sp[1])) { + error("define-esc-sequence: bad arg ", sp[1]); + /* NOTREACHED */ + } + if (!numberp(sp[0])) { + error("define-esc-sequence: bad arg ", sp[0]); + /* NOTREACHED */ + } + if (keyconvCallback) { + (*keyconvCallback)(CANNA_XTERMINAL, + xstring(sp[2]), xstring(sp[1]), xnum(sp[0])); + } + pop(2); + return NIL; +} + +static list +Lconcat(int n) +{ + list t, res; + int i, len; + char *p; + + /* ¤Þ¤ºÄ¹¤µ¤ò¿ô¤¨¤ë¡£ */ + for (len= 0, i = n ; i-- ;) { + t = sp[i]; + if (!stringp(t)) { + lisp_strerr("concat", t); + /* NOTREACHED */ + } + len += xstrlen(t); + } + res = allocstring(len); + for (p = xstring(res), i = n ; i-- ;) { + t = sp[i]; + len = xstrlen(t); + Strncpy(p, xstring(t), len); + p += len; + } + *p = '\0'; + pop(n); + return res; +} + +/* lispfuncend */ + +extern char *RkGetServerHost(); + + +/* ÊÑ¿ô¥¢¥¯¥»¥¹¤Î¤¿¤á¤Î´Ø¿ô */ + +static list +VTorNIL(BYTE *var, int setp, list arg) +{ + if (setp == VALSET) { + *var = (arg == NIL) ? 0 : 1; + return arg; + } + else { /* get */ + return *var ? T : NIL; + } +} + +static list +StrAcc(char **var, int setp, list arg) +{ + if (setp == VALSET) { + if (null(arg) || stringp(arg)) { + if (*var) { + free(*var); + } + if (stringp(arg)) { + *var = (char *)malloc(strlen(xstring(arg)) + 1); + if (*var) { + strcpy(*var, xstring(arg)); + return arg; + } + else { + error("Insufficient memory.", NON); + /* NOTREACHED */ + } + }else{ + *var = (char *)0; + return NIL; + } + } + else { + lisp_strerr((char *)0, arg); + /* NOTREACHED */ + } + } + /* else { .. */ + if (*var) { + return copystring(*var, strlen(*var)); + } + else { + return NIL; + } + /* end else .. } */ +} + +static list +NumAcc(int *var, int setp, list arg) +{ + if (setp == VALSET) { + if (numberp(arg)) { + *var = (int)xnum(arg); + return arg; + } + else { + numerr((char *)0, arg); + /* NOTREACHED */ + } + } + return (list)mknum(*var); +} + +#ifdef WIN_CANLISP +static struct RegInfo reginfo; +#endif + +/* ¤³¤³¤«¤é²¼¤¬¥«¥¹¥¿¥Þ¥¤¥º¤ÎÄɲÃÅù¤ÇÎɤ¯¤¤¤¸¤ëÉôʬ */ + +/* ¼ÂºÝ¤Î¥¢¥¯¥»¥¹´Ø¿ô */ + +#define DEFVAR(fn, acc, ty, var) \ +static list fn(int setp, list arg) { \ + extern ty var; return acc(&var, setp, arg); } + +#define DEFVAREX(fn, acc, var) \ +static list fn(int setp, list arg) { \ + extern struct CannaConfig cannaconf; return acc(&var, setp, arg); } + +static list Vnkouhobunsetsu(int setp, list arg) +{ + extern int nKouhoBunsetsu; + + arg = NumAcc(&nKouhoBunsetsu, setp, arg); +#ifdef RESTRICT_NKOUHOBUNSETSU + if (nKouhoBunsetsu < 3 || nKouhoBunsetsu > 60) + nKouhoBunsetsu = 16; +#else + if (nKouhoBunsetsu < 0) { + nKouhoBunsetsu = 0; + } +#endif + return arg; +} + +static list VProtoVer(int setp, list arg) +{ +} + +static list VServVer(int setp, list arg) +{ +} + +static list VServName(int setp, list arg) +{ +} + +static list +VCannaDir(int setp, list arg) +{ +extern char basepath[]; + + char *canna_dir = basepath; + + if (setp == VALGET) { + return StrAcc(&canna_dir, setp, arg); + } + else { + return NIL; + } +} + +static list VCodeInput(int setp, list arg) +{ + extern struct CannaConfig cannaconf; + static char *input_code[CANNA_MAX_CODE] = {"jis", "sjis", "kuten"}; + + if (setp == VALSET) { + if (null(arg) || stringp(arg)) { + if (stringp(arg)) { + int i; + char *s = xstring(arg); + + for (i = 0 ; i < CANNA_MAX_CODE ; i++) { + if (!strcmp(s, input_code[i])) { + cannaconf.code_input = i; + break; + } + } + if (i < CANNA_MAX_CODE) { + return arg; + } + else { + return NIL; + } + }else{ + cannaconf.code_input = 0; /* use default */ + return copystring(input_code[0], strlen(input_code[0])); + } + } + else { + lisp_strerr((char *)0, arg); + /* NOTREACHED */ + } + } + /* else { .. */ + if (/* 0 <= cannaconf.code_input && /* unsigned ¤Ë¤·¤¿¤Î¤Ç¾éĹ¤Ë¤Ê¤Ã¤¿ */ + cannaconf.code_input <= CANNA_CODE_KUTEN) { + return copystring(input_code[cannaconf.code_input], + strlen(input_code[cannaconf.code_input])); + } + else { + return NIL; + } + /* end else .. } */ +} + + +DEFVAR(Vromkana ,StrAcc ,char * ,RomkanaTable) +DEFVAR(Venglish ,StrAcc ,char * ,EnglishTable) + +DEFVAREX(Vnhenkan ,NumAcc ,cannaconf.kouho_threshold) +DEFVAREX(Vndisconnect ,NumAcc ,cannaconf.strokelimit) +DEFVAREX(VCannaVersion ,NumAcc ,cannaconf.CannaVersion) +DEFVAREX(VIndexSeparator,NumAcc ,cannaconf.indexSeparator) + +DEFVAREX(Vgakushu ,VTorNIL ,cannaconf.Gakushu) +DEFVAREX(Vcursorw ,VTorNIL ,cannaconf.CursorWrap) +DEFVAREX(Vselectd ,VTorNIL ,cannaconf.SelectDirect) +DEFVAREX(Vnumeric ,VTorNIL ,cannaconf.HexkeySelect) +DEFVAREX(Vbunsets ,VTorNIL ,cannaconf.BunsetsuKugiri) +DEFVAREX(Vcharact ,VTorNIL ,cannaconf.ChBasedMove) +DEFVAREX(Vreverse ,VTorNIL ,cannaconf.ReverseWidely) +DEFVAREX(VreverseWord ,VTorNIL ,cannaconf.ReverseWord) +DEFVAREX(Vquitich ,VTorNIL ,cannaconf.QuitIchiranIfEnd) +DEFVAREX(Vkakutei ,VTorNIL ,cannaconf.kakuteiIfEndOfBunsetsu) +DEFVAREX(Vstayaft ,VTorNIL ,cannaconf.stayAfterValidate) +DEFVAREX(Vbreakin ,VTorNIL ,cannaconf.BreakIntoRoman) +DEFVAREX(Vgrammati ,VTorNIL ,cannaconf.grammaticalQuestion) +DEFVAREX(Vforceka ,VTorNIL ,cannaconf.forceKana) +DEFVAREX(Vkouhoco ,VTorNIL ,cannaconf.kCount) +DEFVAREX(Vauto ,VTorNIL ,cannaconf.chikuji) +DEFVAREX(VlearnNumTy ,VTorNIL ,cannaconf.LearnNumericalType) +DEFVAREX(VBSasQuit ,VTorNIL ,cannaconf.BackspaceBehavesAsQuit) +DEFVAREX(Vinhibi ,VTorNIL ,cannaconf.iListCB) +DEFVAREX(Vkeepcupos ,VTorNIL ,cannaconf.keepCursorPosition) +DEFVAREX(VAbandon ,VTorNIL ,cannaconf.abandonIllegalPhono) +DEFVAREX(VHexStyle ,VTorNIL ,cannaconf.hexCharacterDefiningStyle) +DEFVAREX(VKojin ,VTorNIL ,cannaconf.kojin) +DEFVAREX(VIndexHankaku ,VTorNIL ,cannaconf.indexHankaku) +DEFVAREX(VAllowNext ,VTorNIL ,cannaconf.allowNextInput) +DEFVAREX(VkanaGaku ,VTorNIL ,cannaconf.doKatakanaGakushu) +DEFVAREX(VhiraGaku ,VTorNIL ,cannaconf.doHiraganaGakushu) +DEFVAREX(VChikujiContinue ,VTorNIL ,cannaconf.ChikujiContinue) +DEFVAREX(VRenbunContinue ,VTorNIL ,cannaconf.RenbunContinue) +DEFVAREX(VMojishuContinue ,VTorNIL ,cannaconf.MojishuContinue) +DEFVAREX(VcRealBS ,VTorNIL ,cannaconf.chikujiRealBackspace) +DEFVAREX(VIgnoreCase ,VTorNIL ,cannaconf.ignore_case) +DEFVAREX(VRomajiYuusen ,VTorNIL ,cannaconf.romaji_yuusen) +DEFVAREX(VAutoSync ,VTorNIL ,cannaconf.auto_sync) +DEFVAREX(VQuicklyEscape ,VTorNIL ,cannaconf.quickly_escape) +DEFVAREX(VInhibitHankana,VTorNIL ,cannaconf.InhibitHankakuKana) +#ifdef WIN_CANLISP +DEFVAR(VremoteGroup ,StrAcc ,char * ,RemoteGroup) +DEFVAR(VlocalGroup ,StrAcc ,char * ,LocalGroup) + +DEFVAREX(VcandInitWidth ,NumAcc ,reginfo.cand_init_width) +DEFVAREX(VcandInitHeight ,NumAcc ,reginfo.cand_init_height) +DEFVAREX(VcandMaxWidth ,NumAcc ,reginfo.cand_max_width) +DEFVAREX(VcandMaxHeight ,NumAcc ,reginfo.cand_max_height) +DEFVAREX(VstatusSize ,NumAcc ,reginfo.status_size) +#endif + +#ifdef DEFINE_SOMETHING +DEFVAR(Vchikuji_debug, VTorNIL, int, chikuji_debug) +#endif + +/* Lisp ¤Î´Ø¿ô¤È C ¤Î´Ø¿ô¤ÎÂбþɽ */ + +static struct atomdefs initatom[] = { + {"quote" ,SPECIAL,Lquote }, + {"setq" ,SPECIAL,Lsetq }, + {"set" ,SUBR ,Lset }, + {"equal" ,SUBR ,Lequal }, + {"=" ,SUBR ,Lequal }, + {">" ,SUBR ,Lgreaterp }, + {"<" ,SUBR ,Llessp }, + {"progn" ,SPECIAL,Lprogn }, + {"eq" ,SUBR ,Leq }, + {"cond" ,SPECIAL,Lcond }, + {"null" ,SUBR ,Lnull }, + {"not" ,SUBR ,Lnull }, + {"and" ,SPECIAL,Land }, + {"or" ,SPECIAL,Lor }, + {"+" ,SUBR ,Lplus }, + {"-" ,SUBR ,Ldiff }, + {"*" ,SUBR ,Ltimes }, + {"/" ,SUBR ,Lquo }, + {"%" ,SUBR ,Lrem }, + {"gc" ,SUBR ,Lgc }, + {"load" ,SUBR ,Lload }, + {"list" ,SUBR ,Llist }, + {"sequence" ,SUBR ,Llist }, + {"defun" ,SPECIAL,Ldefun }, + {"defmacro" ,SPECIAL,Ldefmacro }, + {"cons" ,SUBR ,Lcons }, + {"car" ,SUBR ,Lcar }, + {"cdr" ,SUBR ,Lcdr }, + {"atom" ,SUBR ,Latom }, + {"let" ,CMACRO ,Llet }, + {"if" ,CMACRO ,Lif }, + {"boundp" ,SUBR ,Lboundp }, + {"fboundp" ,SUBR ,Lfboundp }, + {"getenv" ,SUBR ,Lgetenv }, + {"copy-symbol" ,SUBR ,Lcopysym }, + {"concat" ,SUBR ,Lconcat }, + {S_FN_UseDictionary ,SUBR ,Lusedic }, + {S_SetModeDisp ,SUBR ,Lmodestr }, + {S_SetKey ,SUBR ,Lsetkey }, + {S_GSetKey ,SUBR ,Lgsetkey }, + {S_UnbindKey ,SUBR ,Lunbindkey }, + {S_GUnbindKey ,SUBR ,Lgunbindkey }, + {S_DefMode ,SPECIAL,Ldefmode }, + {S_DefSymbol ,SPECIAL,Ldefsym }, +#ifndef NO_EXTEND_MENU + {S_DefSelection ,SPECIAL,Ldefselection }, + {S_DefMenu ,SPECIAL,Ldefmenu }, +#endif + {S_SetInitFunc ,SUBR ,Lsetinifunc }, + {S_defEscSequence ,SUBR ,LdefEscSeq }, + {S_defXKeysym ,SUBR ,LdefXKeysym }, + {0 ,UNDEF ,0 }, /* DUMMY */ +}; + +static void +deflispfunc(void) +{ + struct atomdefs *p; + + for (p = initatom ; p->symname ; p++) { + struct atomcell *atomp; + list temp; + + temp = getatmz(p->symname); + atomp = symbolpointer(temp); + atomp->ftype = p->symtype; + if (atomp->ftype != UNDEF) { + atomp->func = p->symfunc; + } + } +} + + +/* ÊÑ¿ôɽ */ + +static struct cannavardefs cannavars[] = { + {S_VA_RomkanaTable ,Vromkana}, + {S_VA_EnglishTable ,Venglish}, + {S_VA_CursorWrap ,Vcursorw}, + {S_VA_SelectDirect ,Vselectd}, + {S_VA_NumericalKeySelect ,Vnumeric}, + {S_VA_BunsetsuKugiri ,Vbunsets}, + {S_VA_CharacterBasedMove ,Vcharact}, + {S_VA_ReverseWidely ,Vreverse}, + {S_VA_ReverseWord ,VreverseWord}, + {S_VA_Gakushu ,Vgakushu}, + {S_VA_QuitIfEOIchiran ,Vquitich}, + {S_VA_KakuteiIfEOBunsetsu ,Vkakutei}, + {S_VA_StayAfterValidate ,Vstayaft}, + {S_VA_BreakIntoRoman ,Vbreakin}, + {S_VA_NHenkanForIchiran ,Vnhenkan}, + {S_VA_GrammaticalQuestion ,Vgrammati}, + {"gramatical-question" ,Vgrammati}, /* °ÊÁ°¤Î¥¹¥Ú¥ë¥ß¥¹¤ÎµßºÑ */ + {S_VA_ForceKana ,Vforceka}, + {S_VA_KouhoCount ,Vkouhoco}, + {S_VA_Auto ,Vauto}, + {S_VA_LearnNumericalType ,VlearnNumTy}, + {S_VA_BackspaceBehavesAsQuit ,VBSasQuit}, + {S_VA_InhibitListCallback ,Vinhibi}, + {S_VA_nKouhoBunsetsu ,Vnkouhobunsetsu}, + {S_VA_keepCursorPosition ,Vkeepcupos}, + {S_VA_CannaVersion ,VCannaVersion}, + {S_VA_Abandon ,VAbandon}, + {S_VA_HexDirect ,VHexStyle}, + {S_VA_ProtocolVersion ,VProtoVer}, + {S_VA_ServerVersion ,VServVer}, + {S_VA_ServerName ,VServName}, + {S_VA_CannaDir ,VCannaDir}, + {S_VA_Kojin ,VKojin}, + {S_VA_IndexHankaku ,VIndexHankaku}, + {S_VA_IndexSeparator ,VIndexSeparator}, + {S_VA_AllowNextInput ,VAllowNext}, + {S_VA_doKatakanaGakushu ,VkanaGaku}, + {S_VA_doHiraganaGakushu ,VhiraGaku}, +#ifdef DEFINE_SOMETHING + {S_VA_chikuji_debug ,Vchikuji_debug}, +#endif /* DEFINE_SOMETHING */ + {S_VA_ChikujiContinue ,VChikujiContinue}, + {S_VA_RenbunContinue ,VRenbunContinue}, + {S_VA_MojishuContinue ,VMojishuContinue}, + {S_VA_ChikujiRealBackspace ,VcRealBS}, + {S_VA_nDisconnectServer ,Vndisconnect}, + {S_VA_ignoreCase ,VIgnoreCase}, + {S_VA_RomajiYuusen ,VRomajiYuusen}, + {S_VA_AutoSync ,VAutoSync}, + {S_VA_QuicklyEscape ,VQuicklyEscape}, + {S_VA_InhibitHanKana ,VInhibitHankana}, + {S_VA_CodeInput ,VCodeInput}, +#ifdef WIN_CANLISP + {"remote-group" ,VremoteGroup}, + {"local-group" ,VlocalGroup}, + {"candlist-initial-width" ,VcandInitWidth}, + {"candlist-initial-height" ,VcandInitHeight}, + {"candlist-max-width" ,VcandMaxWidth}, + {"candlist-max-height" ,VcandMaxHeight}, + {"toolbar-icon-size" ,VstatusSize}, +#endif + {0 ,0}, +}; + +static void +defcannavar(void) +{ + struct cannavardefs *p; + + for (p = cannavars ; p->varname ; p++) { + symbolpointer(getatmz(p->varname))->valfunc = p->varfunc; + } +} + + + +/* ¥â¡¼¥Éɽ */ + +static struct cannamodedefs cannamodes[] = { + {S_AlphaMode ,CANNA_MODE_AlphaMode}, + {S_YomiganaiMode ,CANNA_MODE_EmptyMode}, + {S_YomiMode ,CANNA_MODE_YomiMode}, + {S_MojishuMode ,CANNA_MODE_JishuMode}, + {S_TankouhoMode ,CANNA_MODE_TankouhoMode}, + {S_IchiranMode ,CANNA_MODE_IchiranMode}, + {S_KigouMode ,CANNA_MODE_KigoMode}, + {S_YesNoMode ,CANNA_MODE_YesNoMode}, + {S_OnOffMode ,CANNA_MODE_OnOffMode}, + {S_ShinshukuMode ,CANNA_MODE_AdjustBunsetsuMode}, + + {S_AutoYomiMode ,CANNA_MODE_ChikujiYomiMode}, + {S_AutoBunsetsuMode ,CANNA_MODE_ChikujiTanMode}, + + {S_HenkanNyuuryokuMode ,CANNA_MODE_HenkanNyuryokuMode}, + {S_HexMode ,CANNA_MODE_HexMode}, + {S_BushuMode ,CANNA_MODE_BushuMode}, + {S_ExtendMode ,CANNA_MODE_ExtendMode}, + {S_RussianMode ,CANNA_MODE_RussianMode}, + {S_GreekMode ,CANNA_MODE_GreekMode}, + {S_LineMode ,CANNA_MODE_LineMode}, + {S_ChangingServerMode ,CANNA_MODE_ChangingServerMode}, + {S_HenkanMethodMode ,CANNA_MODE_HenkanMethodMode}, + {S_DeleteDicMode ,CANNA_MODE_DeleteDicMode}, + {S_TourokuMode ,CANNA_MODE_TourokuMode}, + {S_TourokuHinshiMode ,CANNA_MODE_TourokuHinshiMode}, + {S_TourokuDicMode ,CANNA_MODE_TourokuDicMode}, + {S_QuotedInsertMode ,CANNA_MODE_QuotedInsertMode}, + {S_BubunMuhenkanMode ,CANNA_MODE_BubunMuhenkanMode}, + {S_MountDicMode ,CANNA_MODE_MountDicMode}, + {S_ZenHiraHenkanMode ,CANNA_MODE_ZenHiraHenkanMode}, + {S_HanHiraHenkanMode ,CANNA_MODE_HanHiraHenkanMode}, + {S_ZenKataHenkanMode ,CANNA_MODE_ZenKataHenkanMode}, + {S_HanKataHenkanMode ,CANNA_MODE_HanKataHenkanMode}, + {S_ZenAlphaHenkanMode ,CANNA_MODE_ZenAlphaHenkanMode}, + {S_HanAlphaHenkanMode ,CANNA_MODE_HanAlphaHenkanMode}, + {S_ZenHiraKakuteiMode ,CANNA_MODE_ZenHiraKakuteiMode}, + {S_HanHiraKakuteiMode ,CANNA_MODE_HanHiraKakuteiMode}, + {S_ZenKataKakuteiMode ,CANNA_MODE_ZenKataKakuteiMode}, + {S_HanKataKakuteiMode ,CANNA_MODE_HanKataKakuteiMode}, + {S_ZenAlphaKakuteiMode ,CANNA_MODE_ZenAlphaKakuteiMode}, + {S_HanAlphaKakuteiMode ,CANNA_MODE_HanAlphaKakuteiMode}, + {0 ,0}, +}; + +static void +defcannamode(void) +{ + struct cannamodedefs *p; + + for (p = cannamodes ; p->mdname ; p++) { + symbolpointer(getatmz(p->mdname))->mid = p->mdid; + } +} + + + +/* µ¡Ç½É½ */ + +static struct cannafndefs cannafns[] = { + {S_FN_Undefined ,CANNA_FN_Undefined}, + {S_FN_SelfInsert ,CANNA_FN_FunctionalInsert}, + {S_FN_QuotedInsert ,CANNA_FN_QuotedInsert}, + {S_FN_JapaneseMode ,CANNA_FN_JapaneseMode}, + {S_AlphaMode ,CANNA_FN_AlphaMode}, + {S_HenkanNyuuryokuMode ,CANNA_FN_HenkanNyuryokuMode}, + {S_HexMode ,CANNA_FN_HexMode}, + {S_BushuMode ,CANNA_FN_BushuMode}, + {S_KigouMode ,CANNA_FN_KigouMode}, + {S_FN_Forward ,CANNA_FN_Forward}, + {S_FN_Backward ,CANNA_FN_Backward}, + {S_FN_Next ,CANNA_FN_Next}, + {S_FN_Prev ,CANNA_FN_Prev}, + {S_FN_BeginningOfLine ,CANNA_FN_BeginningOfLine}, + {S_FN_EndOfLine ,CANNA_FN_EndOfLine}, + {S_FN_DeleteNext ,CANNA_FN_DeleteNext}, + {S_FN_DeletePrevious ,CANNA_FN_DeletePrevious}, + {S_FN_KillToEndOfLine ,CANNA_FN_KillToEndOfLine}, + {S_FN_Henkan ,CANNA_FN_Henkan}, + {S_FN_HenkanNaive ,CANNA_FN_HenkanOrInsert}, /* for compati */ + {S_FN_HenkanOrSelfInsert ,CANNA_FN_HenkanOrInsert}, + {S_FN_HenkanOrDoNothing ,CANNA_FN_HenkanOrNothing}, + {S_FN_Kakutei ,CANNA_FN_Kakutei}, + {S_FN_Extend ,CANNA_FN_Extend}, + {S_FN_Shrink ,CANNA_FN_Shrink}, + {S_ShinshukuMode ,CANNA_FN_AdjustBunsetsu}, + {S_FN_Quit ,CANNA_FN_Quit}, + {S_ExtendMode ,CANNA_FN_ExtendMode}, + {S_FN_Touroku ,CANNA_FN_Touroku}, + {S_FN_ConvertAsHex ,CANNA_FN_ConvertAsHex}, + {S_FN_ConvertAsBushu ,CANNA_FN_ConvertAsBushu}, + {S_FN_KouhoIchiran ,CANNA_FN_KouhoIchiran}, + {S_FN_BubunMuhenkan ,CANNA_FN_BubunMuhenkan}, + {S_FN_Zenkaku ,CANNA_FN_Zenkaku}, + {S_FN_Hankaku ,CANNA_FN_Hankaku}, + {S_FN_ToUpper ,CANNA_FN_ToUpper}, + {S_FN_Capitalize ,CANNA_FN_Capitalize}, + {S_FN_ToLower ,CANNA_FN_ToLower}, + {S_FN_Hiragana ,CANNA_FN_Hiragana}, + {S_FN_Katakana ,CANNA_FN_Katakana}, + {S_FN_Romaji ,CANNA_FN_Romaji}, + {S_FN_KanaRotate ,CANNA_FN_KanaRotate}, + {S_FN_RomajiRotate ,CANNA_FN_RomajiRotate}, + {S_FN_CaseRotate ,CANNA_FN_CaseRotate}, + {S_FN_BaseHiragana ,CANNA_FN_BaseHiragana}, + {S_FN_BaseKatakana ,CANNA_FN_BaseKatakana}, + {S_FN_BaseKana ,CANNA_FN_BaseKana}, + {S_FN_BaseEisu ,CANNA_FN_BaseEisu}, + {S_FN_BaseZenkaku ,CANNA_FN_BaseZenkaku}, + {S_FN_BaseHankaku ,CANNA_FN_BaseHankaku}, + {S_FN_BaseKakutei ,CANNA_FN_BaseKakutei}, + {S_FN_BaseHenkan ,CANNA_FN_BaseHenkan}, + {S_FN_BaseHiraKataToggle ,CANNA_FN_BaseHiraKataToggle}, + {S_FN_BaseZenHanToggle ,CANNA_FN_BaseZenHanToggle}, + {S_FN_BaseKanaEisuToggle ,CANNA_FN_BaseKanaEisuToggle}, + {S_FN_BaseKakuteiHenkanToggle ,CANNA_FN_BaseKakuteiHenkanToggle}, + {S_FN_BaseRotateForward ,CANNA_FN_BaseRotateForward}, + {S_FN_BaseRotateBackward ,CANNA_FN_BaseRotateBackward}, + {S_FN_Mark ,CANNA_FN_Mark}, + {S_FN_Temporary ,CANNA_FN_TemporalMode}, + {S_FN_SyncDic ,CANNA_FN_SyncDic}, + {S_RussianMode ,CANNA_FN_RussianMode}, + {S_GreekMode ,CANNA_FN_GreekMode}, + {S_LineMode ,CANNA_FN_LineMode}, + {S_FN_DefineDicMode ,CANNA_FN_DefineDicMode}, + {S_FN_DeleteDicMode ,CANNA_FN_DeleteDicMode}, + {S_FN_DicMountMode ,CANNA_FN_DicMountMode}, + {S_FN_EnterChikujiMode ,CANNA_FN_EnterChikujiMode}, + {S_FN_EnterRenbunMode ,CANNA_FN_EnterRenbunMode}, + {S_FN_DisconnectServer ,CANNA_FN_DisconnectServer}, + {S_FN_ChangeServerMode ,CANNA_FN_ChangeServerMode}, + {S_FN_ShowServer ,CANNA_FN_ShowServer}, + {S_FN_ShowGakushu ,CANNA_FN_ShowGakushu}, + {S_FN_ShowVersion ,CANNA_FN_ShowVersion}, + {S_FN_ShowPhonogramFile ,CANNA_FN_ShowPhonogramFile}, + {S_FN_ShowCannaFile ,CANNA_FN_ShowCannaFile}, + {S_FN_PageUp ,CANNA_FN_PageUp}, + {S_FN_PageDown ,CANNA_FN_PageDown}, + {S_FN_Edit ,CANNA_FN_Edit}, + {S_FN_BubunKakutei ,CANNA_FN_BubunKakutei}, + {S_FN_HenkanRegion ,CANNA_FN_HenkanRegion}, + {S_FN_PhonoEdit ,CANNA_FN_PhonoEdit}, + {S_FN_DicEdit ,CANNA_FN_DicEdit}, + {S_FN_Configure ,CANNA_FN_Configure}, + {S_FN_KanaRotate ,CANNA_FN_KanaRotate}, + {S_FN_RomajiRotate ,CANNA_FN_RomajiRotate}, + {S_FN_CaseRotate ,CANNA_FN_CaseRotate}, + {0 ,0}, +}; + +static void +defcannafunc(void) +{ + struct cannafndefs *p; + + for (p = cannafns ; p->fnname ; p++) { + symbolpointer(getatmz(p->fnname))->fid = p->fnid; + } +} + + +static void +defatms(void) +{ + deflispfunc(); + defcannavar(); + defcannamode(); + defcannafunc(); + QUOTE = getatmz("quote"); + T = getatmz("t"); + _LAMBDA = getatmz("lambda"); + _MACRO = getatmz("macro"); + COND = getatmz("cond"); + USER = getatmz(":user"); + BUSHU = getatmz(":bushu"); + RENGO = getatmz(":rengo"); + KATAKANA = getatmz(":katakana"); + HIRAGANA = getatmz(":hiragana"); + GRAMMAR = getatmz(":grammar"); + HYPHEN = getatmz("-"); + symbolpointer(T)->value = T; +} + diff --git a/src/add-ons/input_server/methods/canna/lib/lisp.h b/src/add-ons/input_server/methods/canna/lib/lisp.h new file mode 100644 index 0000000000..04981f1b04 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/lisp.h @@ -0,0 +1,163 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: lisp.h,v 1.1 2004/12/23 21:23:49 korli Exp $ */ + +#include "canna.h" + +#include +#include "symbolname.h" + +#define YES 1 +#define NO 0 + +#define VALGET 1 +#define VALSET 0 + +#ifdef WIN +#define CELLSIZE 5120 /* size of cell area (byte) */ +#else +#define CELLSIZE 10240 /* size of cell area (byte) */ +#endif + +#define STKSIZE 1024 /* the depth of value & parameter stack */ +#define BUFSIZE 256 /* universal buffer size (byte) */ + +#ifdef NIL +#undef NIL +#endif +#define NIL 0L /* internal expression of NIL */ +#define UNBOUND -2L /* unbound mark of variable */ +#define NON -1L /* the mark of No. (unable to use NO) */ + +#define UNDEF 0 +#define SPECIAL 1 +#define SUBR 2 +#define EXPR 3 +#define CMACRO 4 +#define MACRO 5 + +#define TAG_MASK 0x07000000L +#define CELL_MASK 0x00ffffffL +#define GC_MASK 0x08000000L + +#define NIL_TAG 0L +#define NUMBER_TAG 0x01000000L +#define STRING_TAG 0x02000000L +#define SYMBOL_TAG 0x03000000L +#define CONS_TAG 0x04000000L + +#define MAX_DEPTH 20 + +/* define macros */ + +#define null(x) !(x) +#define tag(x) ((x) & TAG_MASK) +#define atom(x) (tag(x) < CONS_TAG) +#define constp(x) (tag(x) < SYMBOL_TAG) +#define numberp(x) (tag(x) == NUMBER_TAG) +#define stringp(x) (tag(x) == STRING_TAG) +#define symbolp(x) (tag(x) == SYMBOL_TAG) +#define consp(x) (tag(x) == CONS_TAG) + +#define gcfield(x) (((struct gccell *)x)->tagfield) +#define mkcopied(x) ((x) | GC_MASK) +#define alreadycopied(x) (gcfield(x) & GC_MASK) +#define newaddr(x) ((x) & ~GC_MASK) + +typedef POINTERINT list; +typedef POINTERINT pointerint; + +/* cell area */ + +#define celloffset(x) ((x) & CELL_MASK) + +#define car(x) ((struct cell *)(celltop + celloffset(x)))->head +#define cdr(x) ((struct cell *)(celltop + celloffset(x)))->tail +#define caar(x) car(car(x)) +#define cadr(x) car(cdr(x)) +#define cdar(x) cdr(car(x)) +#define cddr(x) cdr(cdr(x)) + +#define symbolpointer(x) ((struct atomcell *)(celltop + celloffset(x))) + +#define mknum(x) (NUMBER_TAG | ((x) & CELL_MASK)) + +#ifdef BIGPOINTER +#define xnum(x) ((((x) & 0x00800000)) ? (x | 0xffffffffff000000) : (x & 0x00ffffff)) +#else +#define xnum(x) ((((x) & 0x00800000)) ? (x | 0xff000000) : (x & 0x00ffffff)) +#endif + +#define xstring(x) (((struct stringcell *)(celltop + celloffset(x)))->str) +#define xstrlen(x) (((struct stringcell *)(celltop + celloffset(x)))->length) + +#define argnchk(fn,x) if (n != x) argnerr(fn) + +/* data type definitions */ + +struct cell { + list tail; + list head; +}; + +struct atomcell { + list plist; + list value; + char *pname; + int ftype; + list (*func)(...); + list (*valfunc)(...); + int mid; + int fid; + list hlink; +}; + +struct stringcell { + int length; + char str[4]; /* dummy array */ +}; + +struct gccell { + list tagfield; +}; + +struct atomdefs { + char *symname; + int symtype; + list (*symfunc)(...); +}; + +struct cannafndefs { + char *fnname; + int fnid; +}; + +struct cannamodedefs { + char *mdname; + int mdid; +}; + +struct cannavardefs { + char *varname; + list (*varfunc)(...); +}; diff --git a/src/add-ons/input_server/methods/canna/lib/mode.c b/src/add-ons/input_server/methods/canna/lib/mode.c new file mode 100644 index 0000000000..aaefdac2b1 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/mode.c @@ -0,0 +1,400 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: mode.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include + +extern struct RkRxDic *romajidic, *englishdic; + +extern int howToReturnModeInfo; +static WCHAR_T numMode[2]; +static WCHAR_T *bad = (WCHAR_T *)0; +struct ModeNameRecs ModeNames[CANNA_MODE_MAX_IMAGINARY_MODE]; + +static +char * +_sModeNames[CANNA_MODE_MAX_IMAGINARY_MODE] = { + " ", /* AlphaMode */ + "[ \244\242 ]", /* ¤¢ */ /* EmptyMode */ + "[\265\255\271\346]", /* µ­¹æ *//* KigoMode */ + "[\244\350\244\337]", /* ¤è¤ß *//* YomiMode (¥â¡¼¥Éʸ»úÎóɽ¼¨¤Ë¤Ï»È¤ï¤Ê¤¤) */ + "[\273\372\274\357]", /* »ú¼ï *//* JishuMode */ + "[\264\301\273\372]", /* ´Á»ú *//* TanKouhoMode */ + "[\260\354\315\367]", /* °ìÍ÷ *//* IchiranMode */ + "[\274\301\314\344]", /* ¼ÁÌä *//* YesNoMode */ + NULL, /* OnOffMode */ + "[\312\270\300\341]", /* ʸÀá *//* AdjustBunsetsuMode */ + "[\303\340\274\241]", /* Ã༡ *//* ChikujiYomiMode Ã༡¤Î»þ¤ÎÆÉ¤ßÉôʬ */ + "[\303\340\274\241]", /* Ã༡ *//* ChikujiHenkanMode Ã༡¤Î»þ¤ÎÊÑ´¹¤ÎÉôʬ */ + + /* Imaginary Mode */ + + "[ \224\242 ]", /* ¤¢ */ /* HenkanNyuryokuMode */ + "[\301\264\244\242]", /* Á´¤¢ *//* ZenHiraHenkanMode */ + "[\310\276\244\242]", /* Ⱦ¤¢ *//* HanHiraHenkanMode */ + "[\301\264\245\242]", /* Á´¥¢ *//* ZenKataHenkanMode */ + "[\310\276\245\242]", /* Ⱦ¥¢ *//* HanKataHenkanMode */ + "[\301\264\261\321]", /* Á´±Ñ *//* ZenAlphaHenkanMode */ + "[\310\276\261\321]", /* Ⱦ±Ñ *//* HanAlphaHenkanMode */ + "<\301\264\244\242>", /* Á´¤¢ *//* ZenHiraKakuteiMode */ + "<\310\276\244\242>", /* Ⱦ¤¢ *//* HanHiraKakuteiMode */ + "<\301\264\245\242>", /* Á´¥¢ *//* ZenKataKakuteiMode */ + "<\310\276\245\242>", /* Ⱦ¥¢ *//* HanKataKakuteiMode */ + "<\301\264\261\321>", /* Á´±Ñ *//* ZenAlphaKakuteiMode */ + "<\310\276\261\321>", /* Ⱦ±Ñ *//* HanAlphaKakuteiMode */ + "[16\277\312]", /* 16¿Ê *//* HexMode */ + "[\311\364\274\363]", /* Éô¼ó *//* BushuMode */ + "[\263\310\304\245]", /* ³ÈÄ¥ *//* ExtendMode */ + "[ \245\355 ]", /* ¥í */ /* RussianMode */ + "[ \245\256 ]", /* ¥® */ /* GreekMode */ + "[\267\323\300\376]", /* ·ÓÀþ *//* LineMode */ + "[\312\321\271\271]", /* Êѹ¹ *//* ChangingServerMode */ + "[\312\321\264\271]", /* ÊÑ´¹ *//* HenkanMethodMode */ + "[\272\357\275\374]", /* ºï½ü *//* DeleteDicMode */ + "[\305\320\317\277]", /* ÅÐÏ¿ *//* TourokuMode */ + "[\311\312\273\354]", /* ÉÊ»ì *//* TourokuHinshiMode */ + "[\274\255\275\361]", /* ¼­½ñ *//* TourokuDicMode */ + "[ \243\361 ]", /* £ñ */ /* QuotedInsertMode */ + "[\312\324\275\270]", /* ÊÔ½¸ *//* BubunMuhenkanMode */ + "[\274\255\275\361]", /* ¼­½ñ *//* MountDicMode */ + }; + + +static WCHAR_T * _ModeNames[CANNA_MODE_MAX_IMAGINARY_MODE]; + +extern extraFunc *FindExtraFunc(); +#define findExtraMode(mnum) \ + FindExtraFunc((mnum) - CANNA_MODE_MAX_IMAGINARY_MODE + CANNA_FN_MAX_FUNC) + +static WCHAR_T *modestr(int mid); +static void japaneseMode(uiContext d); + +newmode * +findExtraKanjiMode(int mnum) +{ + extern extraFunc *extrafuncp; + extraFunc *extrafunc; + register int fnum = + mnum - CANNA_MODE_MAX_IMAGINARY_MODE + CANNA_FN_MAX_FUNC; + + for (extrafunc = extrafuncp; extrafunc; extrafunc = extrafunc->next) { + if (extrafunc->fnum == fnum) { + switch (extrafunc->keyword) { + case EXTRA_FUNC_DEFMODE: + return extrafunc->u.modeptr; + default: + return (newmode *)0; + } + } + } + return (newmode *)0; +} + +extern int nothermodes; + +static WCHAR_T * +modestr(int mid) +{ + if (mid < CANNA_MODE_MAX_IMAGINARY_MODE) { + return(ModeNames[mid].name); + } + else if (mid - CANNA_MODE_MAX_IMAGINARY_MODE < nothermodes) { + extraFunc *ep = findExtraMode(mid); + if (ep) { + return ep->display_name; + } + } + return (WCHAR_T *)0; +} + +void +currentModeInfo(uiContext d) +{ + coreContext cc = (coreContext)d->modec; + + if (d->current_mode->flags & CANNA_KANJIMODE_EMPTY_MODE) { + d->kanji_status_return->info |= KanjiEmptyInfo; + } + + if (howToReturnModeInfo == ModeInfoStyleIsString) { + WCHAR_T *modename, *gmodename; + if (cc->minorMode != d->minorMode) { + modename = modestr(cc->minorMode); + gmodename = modestr(d->minorMode); + d->majorMode = cc->majorMode; + d->minorMode = cc->minorMode; + if (modename && (gmodename == (WCHAR_T *)NULL || + WStrcmp(modename, gmodename))) { + d->kanji_status_return->mode = modename; + d->kanji_status_return->info |= KanjiModeInfo; + } + } + } + else { + if (cc->majorMode != d->majorMode) { + d->majorMode = cc->majorMode; + d->minorMode = cc->minorMode; + numMode[0] = (WCHAR_T)('@' + cc->majorMode); + numMode[1] = (WCHAR_T) 0; + d->kanji_status_return->info |= KanjiModeInfo; + d->kanji_status_return->mode = numMode; + } + } +} + +/* ¤³¤Î¥Õ¥¡¥¤¥ë¤Ë¤Ï¥â¡¼¥ÉÊѹ¹¤Ë´Ø¤¹¤ëÁàºî°ìÈ̤¬Æþ¤Ã¤Æ¤¤¤ë¡£¥â¡¼¥É¤ÎÊÑ + * ¹¹¤È¤Ï¡¢¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤ÎɽÌ̤˸½¤ì¤ë¥â¡¼¥É¤ÎÊѹ¹¤À¤±¤Ç¤Ï¤Ê¤¯¡¢Á´ + * ¤¯ÆÉ¤ß¤¬¤Ê¤¤¾õÂÖ¤«¤é¡¢ÆÉ¤ß¤¬¤¢¤ë¾õÂ֤˰ܤë»þ¤Ë¤âÀ¸¤¸¤ë¤â¤Î¤ò»Ø¤¹¡£ + */ + +void +initModeNames(void) +{ + int i; + + for (i = 0 ; i < CANNA_MODE_MAX_IMAGINARY_MODE ; i++) { + ModeNames[i].alloc = 0; + ModeNames[i].name = _ModeNames[i] = + _sModeNames[i] ? WString(_sModeNames[i]) : 0; + } + if (!bad) { + bad = WString("\245\341\245\342\245\352\244\254\302\255\244\352\244\336" + "\244\273\244\363"); + /* ¥á¥â¥ê¤¬Â­¤ê¤Þ¤»¤ó */ + } +} + +void +resetModeNames(void) +{ + int i; + + for (i = 0 ; i < CANNA_MODE_MAX_IMAGINARY_MODE ; i++) { + if (ModeNames[i].alloc && ModeNames[i].name) { + ModeNames[i].alloc = 0; + WSfree(ModeNames[i].name); + } + ModeNames[i].name = _ModeNames[i]; + } +} + +static void +japaneseMode(uiContext d) +{ + coreContext cc = (coreContext)d->modec; + + d->current_mode = cc->prevMode; + d->modec = cc->next; + freeCoreContext(cc); + d->status = EXIT_CALLBACK; +} + +/* cfuncdef + + JapaneseMode(d) -- ¥â¡¼¥É¤òÆüËܸìÆþÎϥ⡼¥É¤ËÊѤ¨¤ë¡£ + + ¢¨Ãí ¤³¤Î´Ø¿ô¤Ï¦Á¥â¡¼¥É¤Ç¤·¤«¸Æ¤ó¤Ç¤Ï¤¤¤±¤Ê¤¤¡£ + + */ + +JapaneseMode(uiContext d) +{ + coreContext cc = (coreContext)d->modec; + yomiContext yc = (yomiContext)cc->next; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + + japaneseMode(d); + d->kanji_status_return->length = 0; + return 0; +} + +AlphaMode(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + else { + alphaMode(d); + currentModeInfo(d); + d->kanji_status_return->length = 0; + return 0; + } +} + +HenkanNyuryokuMode(uiContext d) +{ + extern KanjiModeRec empty_mode; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + + yc->generalFlags &= (~CANNA_YOMI_ATTRFUNCS & ~CANNA_YOMI_IGNORE_USERSYMBOLS & + ~CANNA_YOMI_BASE_HANKAKU); + d->current_mode = yc->myEmptyMode = &empty_mode; + yc->majorMode = yc->minorMode = CANNA_MODE_EmptyMode; + yc->myMinorMode = 0; /* 0 ¤Ï AlphaMode ¤È½Å¤Ê¤ë¤¬ÌäÂê¤Ï¤Ê¤¤ */ + yc->romdic = romajidic; + EmptyBaseModeInfo(d, yc); + + if(yc->rCurs) + return RomajiFlushYomi(d, (WCHAR_T *)0, 0); /* ¤³¤ì¤Ï»ÃÄêŪ */ + + d->kanji_status_return->length = 0; + return 0; +} + +queryMode(uiContext d, WCHAR_T *arg) +{ + coreContext cc = (coreContext)d->modec; + WCHAR_T *mode_str = (WCHAR_T *)0; + extraFunc *ep; + + switch (howToReturnModeInfo) { + case ModeInfoStyleIsString: + if (d->minorMode < (BYTE)CANNA_MODE_MAX_IMAGINARY_MODE) { + mode_str = ModeNames[d->minorMode].name; + } + else if (d->minorMode < + (BYTE)(CANNA_MODE_MAX_IMAGINARY_MODE + nothermodes)) { + ep = findExtraMode(d->minorMode); + if (ep) { + mode_str = ep->display_name; + } + } + if (!mode_str) { + int ii; + for (ii = 0; ii < 4; ii++, arg++) { + *arg = (WCHAR_T)'\0'; + } + } + else { + WStrcpy(arg, mode_str); + } + break; + case ModeInfoStyleIsBaseNumeric: + { + coreContext ccc; + yomiContext yc; + long fl; + int res; + + arg[3] = 0; + + for (ccc = cc ; ccc && ccc->id != YOMI_CONTEXT ; ccc = ccc->next); + yc = (yomiContext)ccc; /* This must not be NULL */ + + if (yc->id == YOMI_CONTEXT) { + fl = yc->generalFlags; + + if (fl & CANNA_YOMI_ROMAJI) { + res = CANNA_MODE_ZenAlphaHenkanMode; + } + else if (fl & CANNA_YOMI_KATAKANA) { + res = CANNA_MODE_ZenKataHenkanMode; + } + else { + res = CANNA_MODE_ZenHiraHenkanMode; + } + if (fl & CANNA_YOMI_BASE_HANKAKU) { + res++; + } + if (fl & CANNA_YOMI_KAKUTEI) { + res += (CANNA_MODE_ZenHiraKakuteiMode + - CANNA_MODE_ZenHiraHenkanMode); + } + if (fl & (CANNA_YOMI_CHIKUJI_MODE | CANNA_YOMI_BASE_CHIKUJI)) + arg[3] = CANNA_MODE_ChikujiYomiMode; + }else{ + res = CANNA_MODE_HanAlphaHenkanMode; + } + arg[2] = res; + } + case ModeInfoStyleIsExtendedNumeric: + arg[1] = (WCHAR_T)('@' + (int)cc->minorMode); + case ModeInfoStyleIsNumeric: + arg[0] = (WCHAR_T)('@' + (int)cc->majorMode); + break; + default: + return(-1); + /* NOTREACHED */ + break; + } + return 0; +} + +/* + * ¤¢¤ë¥â¡¼¥É¤ËÂФ·¤Æ¥â¡¼¥Éɽ¼¨Ê¸»úÎó¤ò·èÄꤹ¤ë¡£ + * + */ + +changeModeName(int modeid, char *str) +{ + extraFunc *ep; + + if (modeid == CANNA_MODE_HenkanNyuryokuMode) + modeid = CANNA_MODE_EmptyMode; + + if (modeid >= 0) { + if (modeid < CANNA_MODE_MAX_IMAGINARY_MODE) { + if (ModeNames[modeid].alloc && ModeNames[modeid].name) { + WSfree(ModeNames[modeid].name); + } + if (str) { + ModeNames[modeid].alloc = 1; + ModeNames[modeid].name = WString(str); + }else{ + ModeNames[modeid].alloc = 0; + ModeNames[modeid].name = (WCHAR_T *)0; + } + } + else if (modeid < (CANNA_MODE_MAX_IMAGINARY_MODE + nothermodes)) { + ep = findExtraMode(modeid); + if (ep) { + if (ep->display_name) { + WSfree(ep->display_name); + } + if (str) { + ep->display_name = WString(str); + } + else { + ep->display_name = (WCHAR_T *)0; + } + }else{ + return -1; + } + } + return 0; + } + return -1; +} + diff --git a/src/add-ons/input_server/methods/canna/lib/multi.c b/src/add-ons/input_server/methods/canna/lib/multi.c new file mode 100644 index 0000000000..8b9f61df6d --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/multi.c @@ -0,0 +1,292 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char m_s_map_id[] = "@(#) 102.1 $Id: multi.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include + +#define NONE CANNA_FN_Undefined + +static unsigned char *showChar(int c); +static _DoFuncSequence(uiContext d, BYTE *keytbl, BYTE key); + +extern int askQuitKey(); +extern int checkGLineLen(); +extern int NothingChangedWithBeep(); + +static unsigned char *keyHistory; + +struct map { + KanjiMode tbl; + unsigned char key; + KanjiMode mode; + struct map *next; +}; + +extern struct map *mapFromHash(); + +static unsigned char * +showChar(int c) +{ + static unsigned char Gkey[9]; + static char *keyCharMap[] = { + "space", "DEL", "Nfer", "Xfer", "Up", + "Left", "Right", "Down", "Insert", "Rollup", + "Rolldown", "Home", "HELP", "KeyPad", "S-nfer", + "S-xfer", "S-up", "S-left", "S-right", "S-down", + "C-nfer", "C-xfer", "C-up", "C-left", "C-right", + "C-down", "F1", "F2", "F3", "F4", + "F5", "F6", "F7", "F8", "F9", + "F10", "PF1", "PF2", "PF3", "PF4", + "PF5", "PF6", "PF7", "PF8", "PF9", + "PF10", + }; + + if (c < 0x20) { + strcpy((char *)Gkey, "C-"); + if (c == 0x00 || (c > 0x1a && c < 0x20 )) + Gkey[2] = c + 0x40; + else + Gkey[2] = c + 0x60; + Gkey[3] = '\0'; + } + else if (c > ' ' && c <= '~' ) { + Gkey[0] = c; + Gkey[1] = '\0'; + } + else if (c > 0xa0 && c < 0xdf) { + Gkey[0] = 0x8e; + Gkey[1] = c; + Gkey[2] = '\0'; + } + else if (c == 0x20) + strcpy((char *)Gkey, keyCharMap[0]); + else if (c > 0x7e && c < 0x8c) + strcpy((char *)Gkey, keyCharMap[c -0x7f +1]); + else if (c > 0x8f && c < 0x9c) + strcpy((char *)Gkey, keyCharMap[c -0x90 +14]); + else if (c > 0xdf && c < 0xea) + strcpy((char *)Gkey, keyCharMap[c -0xe0 +26]); + else if (c > 0xef && c < 0xfa) + strcpy((char *)Gkey, keyCharMap[c -0xf0 +36]); + else + return 0; + return Gkey; +} + +UseOtherKeymap(uiContext d) +{ + struct map *p; + unsigned char showKey[10]; + + strcpy((char *)showKey, (char *)showChar(d->ch)); + p = mapFromHash((KanjiMode)d->current_mode->keytbl, + d->ch, (struct map ***)0); + if (p == (struct map *)NULL) + return NothingChangedWithBeep(d); + p->mode->ftbl = (struct funccfunc *)d->current_mode; + keyHistory = (unsigned char *)malloc(strlen((char *)showKey) + 1); + if (keyHistory) { + strcpy((char *)keyHistory,(char *)showKey); + makeGLineMessageFromString(d, (char *)keyHistory); + if (p->mode->keytbl == (BYTE *)NULL) { + free(keyHistory); + return NothingChangedWithBeep(d); + } + d->current_mode = p->mode; + } + return NothingForGLine(d); +} + +static +_DoFuncSequence(uiContext d, BYTE *keytbl, BYTE key) +{ + int res, total_res, ginfo = 0; + int prevEchoLen = -1, prevRevPos, prevRevLen; + int prevGEchoLen, prevGRevPos, prevGRevLen; + WCHAR_T *prevEcho, *prevGEcho; + BYTE *p; + WCHAR_T *malloc_echo = (WCHAR_T *)0, *malloc_gline = (WCHAR_T *)0; + + if (key == 0) { + key = (BYTE)d->ch; + } + if (keytbl == (BYTE *)NULL) + keytbl = d->current_mode->keytbl; + + p = actFromHash(keytbl, key); + + if (p == (BYTE *)NULL) { + return 0; + } + + total_res = 0; + for(; *p ; p++) { + /* £²²óÌܰʹߤ˰ʲ¼¤Î¥Ç¡¼¥¿¤¬¼º¤ï¤ì¤Æ¤¤¤ë¾ì¹ç¤¬¤¢¤ë¤Î¤ÇÆþ¤ìľ¤¹¡£ */ + d->ch = (unsigned)(*(d->buffer_return) = (WCHAR_T)key); + d->nbytes = 1; + res = _doFunc(d, (int)*p); /* À¸¤Î doFunc ¤ò¸Æ¤Ö¡£ */ + + if (d->kanji_status_return->length >= 0) { + prevEcho = d->kanji_status_return->echoStr; + prevEchoLen = d->kanji_status_return->length; + prevRevPos = d->kanji_status_return->revPos; + prevRevLen = d->kanji_status_return->revLen; + if (d->genbuf <= prevEcho && prevEcho < d->genbuf + ROMEBUFSIZE) { + /* ¥Ç¡¼¥¿¤Ï d->genbuf ¤Ë¤¢¤ë¤Í */ + if (!malloc_echo && + !(malloc_echo = + (WCHAR_T *)malloc(ROMEBUFSIZE * sizeof(WCHAR_T)))) { + res = -1; /* ¥¨¥é¡¼¤¬¤â¤È¤â¤ÈÊ֤äÆÍ褿¤È¤¤¤¦¤³¤È¤Ë¤¹¤ë */ + } + else { + prevEcho = malloc_echo; + WStrncpy(prevEcho, d->kanji_status_return->echoStr, prevEchoLen); + prevEcho[prevEchoLen] = (WCHAR_T)0; + d->kanji_status_return->echoStr = prevEcho; + } + } + } + if (d->kanji_status_return->info & KanjiGLineInfo) { + ginfo = 1; + prevGEcho = d->kanji_status_return->gline.line; + prevGEchoLen = d->kanji_status_return->gline.length; + prevGRevPos = d->kanji_status_return->gline.revPos; + prevGRevLen = d->kanji_status_return->gline.revLen; + if (d->genbuf <= prevGEcho && prevGEcho < d->genbuf + ROMEBUFSIZE) { + /* ¥Ç¡¼¥¿¤Ï d->genbuf ¤Ë¤¢¤ë¤Í */ + if (!malloc_gline && + !(malloc_gline = + (WCHAR_T *)malloc(ROMEBUFSIZE * sizeof(WCHAR_T)))) { + res = -1; /* ¥¨¥é¡¼¤¬¤â¤È¤â¤ÈÊ֤äÆÍ褿¤È¤¤¤¦¤³¤È¤Ë¤¹¤ë */ + } + else { + prevGEcho = malloc_gline; + WStrncpy(prevGEcho, d->kanji_status_return->gline.line, + prevGEchoLen); + prevGEcho[prevGEchoLen] = (WCHAR_T)0; + d->kanji_status_return->gline.line = prevGEcho; + d->kanji_status_return->info &= ~KanjiGLineInfo; + } + } + } + if (res < 0) { + break; + } + if (res > 0) { + total_res += res; + d->buffer_return += res; + d->n_buffer -= res; + } + } + total_res = _afterDoFunc(d, total_res); + d->flags |= MULTI_SEQUENCE_EXECUTED; + if (malloc_echo) { + WStrncpy(d->genbuf, prevEcho, prevEchoLen); + d->genbuf[prevEchoLen] = (WCHAR_T)0; + free(malloc_echo); /* ¿ʬ malloc_echo ¤¬ prevEcho ¤«¤â */ + prevEcho = d->genbuf; + } + d->kanji_status_return->echoStr = prevEcho; + d->kanji_status_return->length = prevEchoLen; + d->kanji_status_return->revPos = prevRevPos; + d->kanji_status_return->revLen = prevRevLen; + if (ginfo) { + if (malloc_gline) { + WStrncpy(d->genbuf, prevGEcho, prevGEchoLen); + d->genbuf[prevGEchoLen] = (WCHAR_T)0; + free(malloc_gline); /* ¿ʬ malloc_gline ¤¬ prevGEcho ¤«¤â */ + prevGEcho = d->genbuf; + } + d->kanji_status_return->gline.line = prevGEcho; + d->kanji_status_return->gline.length = prevGEchoLen; + d->kanji_status_return->gline.revPos = prevGRevPos; + d->kanji_status_return->gline.revLen = prevGRevLen; + d->kanji_status_return->info |= KanjiGLineInfo; + } + return total_res; +} + +DoFuncSequence(uiContext d) +{ + return _DoFuncSequence(d, (BYTE *)NULL, (BYTE)NULL); +} + +int +multiSequenceFunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum) +{ + int i; + unsigned char *p; + struct map *m; + + if (whattodo != KEY_CALL) + return 0; + + if (fnum == CANNA_FN_Kakutei || fnum == CANNA_FN_Quit || askQuitKey(key)) { + /* Kakutei ¤Ï KC_KAKUTEI ¤Ø¤ÎÂбþ */ + free(keyHistory); + GlineClear(d); + d->current_mode = (KanjiMode)(mode->ftbl); + if (d->current_mode->flags & CANNA_KANJIMODE_EMPTY_MODE) { + d->kanji_status_return->info |= KanjiEmptyInfo; + } + /* Nop ¤ò¹Ô¤¦ */ + (void)doFunc(d, CANNA_FN_Nop); + d->flags |= MULTI_SEQUENCE_EXECUTED; + return 0; + } + for (i= 0, p = mode->keytbl; *p != 255; p += 2,i+=2) { + debug_message("multiSequenceFunc:\263\254\301\330[%d]\n",i,0,0); + /* ³¬ÁØ */ + if (*p == key) { /* ¤³¤Î¥­¡¼¤ÏÅÐÏ¿¤µ¤ì¤Æ¤¤¤¿¡£ */ + keyHistory = + (unsigned char *)realloc(keyHistory, strlen((char *)keyHistory) + strlen((char *)showChar(key)) +2); + if (keyHistory) { + strcat((char *)keyHistory," "); + strcat((char *)keyHistory,(char *)showChar(key)); + + makeGLineMessageFromString(d, (char *)keyHistory); + if (*++p == CANNA_FN_UseOtherKeymap) { /* ¤Þ¤À¥­¡¼¥·¥±¥ó¥¹¤Î³¤­¤¬Â¸ºß */ + m = mapFromHash(mode, key, (struct map ***)0); + m->mode->ftbl = mode->ftbl; + d->current_mode = m->mode; + return NothingForGLine(d); + } + free(keyHistory); + } + GlineClear(d); + d->current_mode = (KanjiMode)(mode->ftbl); /* µ¡Ç½¤ò¼Â¹Ô */ + if (*p == CANNA_FN_FuncSequence) { + return _DoFuncSequence(d, (unsigned char *)mode, key); + } + return (*d->current_mode->func)(d, d->current_mode, KEY_CALL, 0, *p); + } + } + return NothingForGLineWithBeep(d); /* ÅÐÏ¿¤·¤Æ¤¤¤Ê¤¤¥­¡¼¤ò²¡¤·¤¿ */ +} diff --git a/src/add-ons/input_server/methods/canna/lib/onoff.c b/src/add-ons/input_server/methods/canna/lib/onoff.c new file mode 100644 index 0000000000..431072b200 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/onoff.c @@ -0,0 +1,323 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: onoff.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include +#include "canna.h" + +#ifndef NO_EXTEND_MENU +#define ICHISIZE 9 + +static void popOnOffMode(uiContext d); +static makeOnOffIchiran(uiContext d, int nelem, int bangomax, int currentkouho, unsigned char *status); +static OnOffSelect(uiContext d); +static OnOffKakutei(uiContext d); + +static int makeOnOffIchiran(); + +static WCHAR_T *black; +static WCHAR_T *white; +static WCHAR_T *space; + +int +initOnoffTable(void) +{ + black = WString("\241\375"); + /* ¡ý */ + white = WString("\241\373"); + /* ¡û */ + space = WString("\241\241"); + /* ¡¡ */ + + if (!black || !white || !space) { + return NG; + } + return 0; +} + +static void +popOnOffMode(uiContext d) +{ + ichiranContext oc = (ichiranContext)d->modec; + + d->modec = oc->next; + d->current_mode = oc->prevMode; + freeIchiranContext(oc); +} + +/* + * ¸õÊä°ìÍ÷¹Ô¤òºî¤ë + */ +selectOnOff(uiContext d, WCHAR_T **buf, int *ck, int nelem, int bangomax, int currentkouho, unsigned char *status, int (*everyTimeCallback )(...), int (*exitCallback )(...), int (*quitCallback )(...), int (*auxCallback )(...)) +{ + extern KanjiModeRec onoff_mode; + ichiranContext oc; + int retval = 0; + ichiranContext newIchiranContext(); + + if(pushCallback(d, d->modec, + everyTimeCallback, exitCallback, quitCallback, auxCallback) == 0) { + jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + return(NG); + } + + if ((oc = (ichiranContext)newIchiranContext()) == (ichiranContext)NULL) { + popCallback(d); + return(NG); + } + oc->next = d->modec; + d->modec = (mode_context)oc; + + oc->prevMode = d->current_mode; + d->current_mode = &onoff_mode; + + oc->allkouho = buf; + oc->curIkouho = ck; + + if((retval = makeOnOffIchiran(d, nelem, bangomax, + currentkouho, status)) == NG) { + popOnOffMode(d); + popCallback(d); + return(NG); + } + return(retval); +} + +/* + * ¸õÊä°ìÍ÷¹Ô¤òɽ¼¨ÍѤΥǡ¼¥¿¤ò¥Æ¡¼¥Ö¥ë¤ËºîÀ®¤¹¤ë + * + * ¡¦glineinfo ¤È kouhoinfo¤òºîÀ®¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static int +makeOnOffIchiran(uiContext d, int nelem, int bangomax, int currentkouho, unsigned char *status) +{ + ichiranContext oc = (ichiranContext)d->modec; + WCHAR_T **kkptr, *kptr, *gptr, *svgptr; + int ko, lnko, cn = 0, svcn, line = 0, dn = 0, svdn; + + oc->nIkouho = nelem; /* ¸õÊä¤Î¿ô */ + + /* ¥«¥ì¥ó¥È¸õÊä¤ò¥»¥Ã¥È¤¹¤ë */ + oc->svIkouho = *(oc->curIkouho); + *(oc->curIkouho) += currentkouho; + if(*(oc->curIkouho) >= oc->nIkouho) + oc->svIkouho = *(oc->curIkouho) = 0; + + if(allocIchiranBuf(d) == NG) + return(NG); + + if(d->ncolumns < 1) { + oc->tooSmall = 1; + return(0); + } + + /* glineinfo¤Èkouhoinfo¤òºî¤ë */ + /* + ¡öglineinfo¡ö + int glkosu : int glhead : int gllen : WCHAR_T *gldata + £±¹Ô¤Î¸õÊä¿ô : ÀèÆ¬¸õÊ䤬 : £±¹Ô¤ÎŤµ : ¸õÊä°ìÍ÷¹Ô¤Îʸ»úÎó + : ²¿ÈÖÌܤθõÊ䤫 : + ------------------------------------------------------------------------- + 0 | 6 : 0 : 24 : £±¿·£²¿´£³¿Ê£´¿¿£µ¿À£¶¿® + 1 | 4 : 6 : 16 : £±¿Ã£²¿²£³¿­£´¿Ä + + ¡ökouhoinfo¡ö + int khretsu : int khpoint : WCHAR_T *khdata + ¤Ê¤óÎóÌÜ¤Ë : ¹Ô¤ÎÀèÆ¬¤«¤é : ¸õÊä¤Îʸ»úÎó + ¤¢¤ë¸õÊ䤫 : ²¿¥Ð¥¤¥ÈÌܤ« : + ------------------------------------------------------------------------- + 0 | 0 : 0 : ¿· + 1 | 0 : 4 : ¿´ + : : : + 7 | 1 : 0 : ¿Ã + 8 | 1 : 4 : ¿² + */ + + kkptr = oc->allkouho; + kptr = *(oc->allkouho); + gptr = oc->glinebufp; + + /* line -- ²¿ÎóÌܤ« + ko -- Á´ÂΤÎÀèÆ¬¤«¤é²¿ÈÖÌܤθõÊ䤫 + lnko -- Îó¤ÎÀèÆ¬¤«¤é²¿ÈÖÌܤθõÊ䤫 + cn -- Îó¤ÎÀèÆ¬¤«¤é²¿¥Ð¥¤¥ÈÌܤ« */ + + for(line=0, ko=0; konIkouho; line++) { + oc->glineifp[line].gldata = gptr; /* ¸õÊä¹Ô¤òɽ¼¨¤¹¤ë¤¿¤á¤Îʸ»úÎó */ + oc->glineifp[line].glhead = ko; /* ¤³¤Î¹Ô¤ÎÀèÆ¬¸õÊä¤Ï¡¢Á´ÂΤǤÎkoÈÖÌÜ */ + + oc->tooSmall = 1; + for(lnko = cn = dn = 0; + dnncolumns - (cannaconf.kCount ? ICHISIZE + 1: 0) && + lnkonIkouho ; lnko++, ko++) { + oc->tooSmall = 0; + kptr = kkptr[ko]; + oc->kouhoifp[ko].khretsu = line; /* ²¿¹ÔÌܤ˸ºß¤¹¤ë¤«¤òµ­Ï¿ */ + oc->kouhoifp[ko].khpoint = cn + (lnko ? 1 : 0); + oc->kouhoifp[ko].khdata = kptr; /* ¤½¤Îʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ */ + svgptr = gptr; + svcn = cn; + svdn = dn; + + /* ¡ý¤«¡û¤ò¥³¥Ô¡¼¤¹¤ë */ + if(lnko) { + WStrncpy(gptr++, space, WStrlen(space)); + cn++; dn += 2; + } + if(status[ko] == 1) + WStrncpy(gptr, black, WStrlen(black)); + else + WStrncpy(gptr, white, WStrlen(white)); + cn ++; gptr++; dn +=2; + /* ¸õÊä¤ò¥³¥Ô¡¼¤¹¤ë */ + for(; *kptr && dnncolumns - (cannaconf.kCount ? ICHISIZE + 1: 0); + gptr++, kptr++, cn++) { + if (((*gptr = *kptr) & 0x8080) == 0x8080) dn++; + dn++; + } + + /* ¥«¥é¥à¿ô¤è¤ê¤Ï¤ß¤À¤·¤Æ¤·¤Þ¤¤¤½¤¦¤Ë¤Ê¤Ã¤¿¤Î¤Ç£±¤ÄÌ᤹ */ + if ((dn >= d->ncolumns - (cannaconf.kCount ? ICHISIZE + 1: 0)) + && *kptr) { + if (lnko) { + gptr = svgptr; + cn = svcn; + dn = svdn; + } + else { + oc->tooSmall = 1; + } + break; + } + } + if (oc->tooSmall) { + return 0; + } + if (cannaconf.kCount) { + for (;dn < d->ncolumns - 1; dn++) { + *gptr++ = ' '; + } + } + /* £±¹Ô½ª¤ï¤ê */ + *gptr++ = (WCHAR_T)0; + oc->glineifp[line].glkosu = lnko; + oc->glineifp[line].gllen = WStrlen(oc->glineifp[line].gldata); + } + /* ºÇ¸å¤ËNULL¤òÆþ¤ì¤ë */ + oc->kouhoifp[ko].khretsu = 0; + oc->kouhoifp[ko].khpoint = 0; + oc->kouhoifp[ko].khdata = (WCHAR_T *)NULL; + oc->glineifp[line].glkosu = 0; + oc->glineifp[line].glhead = 0; + oc->glineifp[line].gllen = 0; + oc->glineifp[line].gldata = (WCHAR_T *)NULL; + +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { + int i; + for(i=0; oc->glineifp[i].glkosu; i++) + printf("%d: %s\n", i, oc->glineifp[i].gldata); + } +#endif + + return(0); +} + +/* + * ¥«¥ì¥ó¥È¸õÊä¤ò¸½ºß¤ÈÈ¿ÂФˤ¹¤ë(ON¢ªOFF, OFF¢ªON) + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static +OnOffSelect(uiContext d) +{ + ichiranContext oc = (ichiranContext)d->modec; + mountContext mc = (mountContext)oc->next; + int point, retval = 0; + WCHAR_T *gline; + + /* mountNewStatus ¤òÊѹ¹¤¹¤ë (1¢ª0, 0¢ª1) */ + if(mc->mountNewStatus[*(oc->curIkouho)]) + mc->mountNewStatus[*(oc->curIkouho)] = 0; + else + mc->mountNewStatus[*(oc->curIkouho)] = 1; + + /* glineÍѤΥǡ¼¥¿¤ò½ñ¤­´¹¤¨¤ë (¡ý¢ª¡û, ¡û¢ª¡ý) */ + gline = oc->glineifp[oc->kouhoifp[*(oc->curIkouho)].khretsu].gldata; + point = oc->kouhoifp[*(oc->curIkouho)].khpoint; + + *(gline+point) = ((mc->mountNewStatus[*(oc->curIkouho)]) ? *black : *white); + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return(retval); +} + +/* + * status ¤ò¤½¤Î¤Þ¤ÞÊÖ¤·¡¢OnOff¥â¡¼¥É¤òPOP¤¹¤ë (EXIT_CALLBACK) + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +static +OnOffKakutei(uiContext d) +{ + ichiranContext oc = (ichiranContext)d->modec; + int retval = 0; +/* ¤¤¤é¤Ê¤¤¤Î¤Ç¤Ï unsigned char *kakuteiStrings;*/ + + /* ¸õÊä°ìÍ÷ɽ¼¨¹ÔÍѤΥ¨¥ê¥¢¤ò¥Õ¥ê¡¼¤¹¤ë */ + freeIchiranBuf(oc); + + popOnOffMode(d); + +#if defined(DEBUG) && !defined(WIN) + if(iroha_debug) { + mountContext mc = (mountContext)d->modec; + int i; + + printf("<¡úmount>\n"); + for(i= 0; mc->mountList[i]; i++) + printf("[%s][%x][%x]\n", mc->mountList[i], + mc->mountOldStatus[i], mc->mountNewStatus[i]); + printf("\n"); + } +#endif + + /* gline ¤ò¥¯¥ê¥¢¤¹¤ë */ + GlineClear(d); + + d->status = EXIT_CALLBACK; + + return(retval); +} +#endif /* NO_EXTEND_MENU */ + +#include "onoffmap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/onoffmap.h b/src/add-ons/input_server/methods/canna/lib/onoffmap.h new file mode 100644 index 0000000000..793903368a --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/onoffmap.h @@ -0,0 +1,55 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +//Modified by T.Murai + +#include "canna.h" + +#ifdef NO_EXTEND_MENU +static struct funccfunc onoff_funcs[] = {{0, 0},}; +#else +static struct funccfunc onoff_funcs[] = { + {CANNA_FN_Forward ,IchiranForwardKouho }, + {CANNA_FN_Backward ,IchiranBackwardKouho }, + {CANNA_FN_Next ,IchiranNextKouhoretsu }, + {CANNA_FN_Prev ,IchiranPreviousKouhoretsu }, + {CANNA_FN_BeginningOfLine ,IchiranBeginningOfKouho }, + {CANNA_FN_EndOfLine ,IchiranEndOfKouho }, + {CANNA_FN_DeletePrevious ,IchiranQuit }, + {CANNA_FN_Henkan ,OnOffSelect }, + {CANNA_FN_HenkanOrInsert ,OnOffSelect }, + {CANNA_FN_HenkanOrNothing ,OnOffSelect }, + {CANNA_FN_Kakutei ,OnOffKakutei }, + {CANNA_FN_Quit ,IchiranQuit }, + {CANNA_FN_Nop ,IchiranNop }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {0 ,0 }, +}; +#endif /* NO_EXTEND_MENU */ + +extern searchfunc(...); +KanjiModeRec onoff_mode = { + searchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + onoff_funcs, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/parse.c b/src/add-ons/input_server/methods/canna/lib/parse.c new file mode 100644 index 0000000000..5a749eb098 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/parse.c @@ -0,0 +1,168 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: parse.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include +#include +#include +#include "canna.h" + +extern char *CANNA_initfilename; + +#define BUF_LEN 1024 + +static char CANNA_rcfilename[BUF_LEN] = ""; + + +/* cfuncdef + + YYparse -- ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤òÆÉ¤à¡£ + + ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤òÆÉ¤ß¹þ¤à¡£ + +*/ + +extern int ckverbose; + +extern YYparse_by_rcfilename(); + +/* cfuncdef + + parse -- .canna ¥Õ¥¡¥¤¥ë¤òõ¤·¤Æ¤­¤ÆÆÉ¤ß¹þ¤à¡£ + + parse ¤Ï¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤òõ¤·¡¢¤½¤Î¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤·¥Ñ¡¼¥¹¤¹ + ¤ë¡£ + + ¥Ñ¡¼¥¹Ãæ¤Î¥Õ¥¡¥¤¥ë¤Î̾Á°¤ò CANNA_rcfilename ¤ËÆþ¤ì¤Æ¤ª¤¯¡£ + + */ + +#define NAMEBUFSIZE 1024 +#define RCFILENAME ".canna" +#define FILEENVNAME "CANNAFILE" +#define HOSTENVNAME "CANNAHOST" + +#define OBSOLETE_RCFILENAME ".iroha" +#define OBSOLETE_FILEENVNAME "IROHAFILE" +#define OBSOLETE_HOSTENVNAME "IROHAHOST" + +static DISPLAY_to_hostname(char *name, char *buf, int bufsize); + +static +make_initfilename(void) +{ + if(!CANNA_initfilename) { + CANNA_initfilename = (char *)malloc(1024); + if (!CANNA_initfilename) { + return -1; + } + strcpy(CANNA_initfilename, CANNA_rcfilename); + } + else { + strcat(CANNA_initfilename, ","); + strcat(CANNA_initfilename, CANNA_rcfilename); + } + return 0; +} + +static void +fit_initfilename(void) +{ + char *tmpstr; + + if (CANNA_initfilename) { + tmpstr = (char *)malloc(strlen(CANNA_initfilename) + 1); + if (!tmpstr) return; + strcpy(tmpstr, CANNA_initfilename); + free(CANNA_initfilename); + CANNA_initfilename = tmpstr; + } +} + + extern char *initFileSpecified; +void +parse(void) +{ + if (clisp_init() == 0) { + addWarningMesg("Can't alocate memory\n"); + goto quitparse; + } + + if (initFileSpecified) { + strcpy(CANNA_rcfilename, initFileSpecified); + if (YYparse_by_rcfilename(CANNA_rcfilename)) { + make_initfilename(); + goto quitparse; + }else { + goto error; + } + }else{ + extern char basepath[]; + sprintf(CANNA_rcfilename, "%s%s%s",basepath, "default/", RCFILENAME); + if (YYparse_by_rcfilename(CANNA_rcfilename)) { + make_initfilename(); + goto quitparse; + } + } + +error: + { + char buf[256]; + sprintf(buf, "Can't open customize file : %s", CANNA_rcfilename); + addWarningMesg(buf); + } + +quitparse: + /* CANNA_initfilename ¤ò¥¸¥ã¥¹¥È¥µ¥¤¥º¤Ë´¢¤ê¹þ¤à */ + fit_initfilename(); + clisp_fin(); +} + +#if 0 +static +DISPLAY_to_hostname(char *name, char *buf, int bufsize) +{ + if (name[0] == ':' || !strncmp(name, "unix", 4)) { + // gethostname(buf, bufsize); + } + else { + int i, len = strlen(name); + for (i = 0 ; i < len && i < bufsize ; i++) { + if (name[i] == ':') { + break; + }else{ + buf[i] = name[i]; + } + } + if (i < bufsize) { + buf[i] = '\0'; + } + } +} +#endif diff --git a/src/add-ons/input_server/methods/canna/lib/romaji.c b/src/add-ons/input_server/methods/canna/lib/romaji.c new file mode 100644 index 0000000000..8a6885e2e2 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/romaji.c @@ -0,0 +1,4836 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: romaji.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +#include +#include +#ifdef MEASURE_TIME +#include +#include +#endif + +#define DEFAULT_ROMKANA_TABLE "/dic/default.cbp" +extern struct RkRxDic *romajidic, *englishdic; + +static struct RkRxDic *OpenRoma(char *table); +static makePhonoOnBuffer(uiContext d, yomiContext yc, unsigned char key, int flag, int english); +static growDakuonP(WCHAR_T ch); +static KanaYomiInsert(uiContext d); +static howFarToGoBackward(yomiContext yc); +static howFarToGoForward(yomiContext yc); +static int YomiBackward(uiContext d); +static YomiNop(uiContext d); +static YomiForward(uiContext d); +static YomiBeginningOfLine(uiContext d); +static YomiEndOfLine(uiContext d); +static appendYomi2Yomi(yomiContext yom, yomiContext yc); +static int YomiDeletePrevious(uiContext d); +static int YomiDeleteNext(uiContext d); +static int YomiKillToEndOfLine(uiContext d); +static int YomiQuit(uiContext d); +static simplePopCallback(uiContext d, int retval, mode_context env); +static exitYomiQuotedInsert(uiContext d, int retval, mode_context env); +static YomiInsertQuoted(uiContext d); +static yomiquotedfunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum); +static ConvertAsHex(uiContext d); +static everySupkey(uiContext d, int retval, mode_context env); +static exitSupkey(uiContext d, int retval, mode_context env); +static quitSupkey(uiContext d, int retval, mode_context env); +static int YomiHenkan(uiContext d); +static int YomiHenkanNaive(uiContext d); +static int YomiHenkanOrNothing(uiContext d); +static YomiBaseHira(uiContext d); +static YomiBaseKata(uiContext d); +static YomiBaseEisu(uiContext d); +static YomiBaseZen(uiContext d); +static YomiBaseHan(uiContext d); +static YomiBaseKana(uiContext d); +static YomiBaseKakutei(uiContext d); +static YomiBaseHenkan(uiContext d); +static YomiJishu(uiContext d, int fn); +static int chikujiEndBun(uiContext d); +static void replaceEnglish(uiContext d, yomiContext yc, int start, int end, int RKflag, int engflag); +static YomiNextJishu(uiContext d); +static YomiPreviousJishu(uiContext d); +static YomiKanaRotate(uiContext d); +static YomiRomajiRotate(uiContext d); +static YomiCaseRotateForward(uiContext d); +static YomiZenkaku(uiContext d); +static YomiHankaku(uiContext d); +static YomiHiraganaJishu(uiContext d); +static YomiKatakanaJishu(uiContext d); +static YomiRomajiJishu(uiContext d); +static YomiToLower(uiContext d); +static YomiToUpper(uiContext d); +static YomiCapitalize(uiContext d); + +int forceRomajiFlushYomi (uiContext); +static int chikujiEndBun (uiContext); +extern void EWStrcat (WCHAR_T *, char *); + +extern int yomiInfoLevel; + +extern struct RkRxDic *englishdic; + +/* + * int d->rStartp; ro shu c|h shi f ¥í¡¼¥Þ»ú ¥¹¥¿¡¼¥È ¥¤¥ó¥Ç¥Ã¥¯¥¹ + * int d->rEndp; ro shu ch shi f| ¥í¡¼¥Þ»ú ¥Ð¥Ã¥Õ¥¡ ¥¤¥ó¥Ç¥Ã¥¯¥¹ + * int d->rCurs; ro shu ch| shi f ¥í¡¼¥Þ»ú ¥¨¥ó¥É ¥¤¥ó¥Ç¥Ã¥¯¥¹ + * int d->rAttr[1024]; 10 100 11 100 1 ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹ÀèÆ¬¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡ + * int d->kEndp; ¤í ¤· ch ¤å ¤· f| ¤«¤Ê ¥Ð¥Ã¥Õ¥¡ ¥¤¥ó¥Ç¥Ã¥¯¥¹ + * int d->kRStartp; ¤í ¤· c|h ¤å ¤· f ¥«¡¼¥½¥ë ¥¹¥¿¡¼¥È ¥¤¥ó¥Ç¥Ã¥¯¥¹ + * int d->kCurs; ¤í ¤· ch| ¤å ¤· f ¥«¡¼¥½¥ë ¥¨¥ó¥É ¥¤¥ó¥Ç¥Ã¥¯¥¹ + * int d->kAttr[1024]; 11 11 00 11 11 0 ¥«¥ÊÊÑ´¹¤·¤¿¥Õ¥é¥°¥Ð¥Ã¥Õ¥¡ + * int d->nrf; 1 ¥í¡¼¥Þ»úÊÑ´¹¤·¤Þ¤»¤ó¥Õ¥é¥° + */ + +/* + * ¥Õ¥é¥°¤ä¥Ý¥¤¥ó¥¿¤Îư¤­ + * + * ¤Ò¤ã¤¯ hyaku + * Àè 100010 10010 + * ÊÑ 111111 + * ¶Ø 000000 + * rStartp 1 + * rCurs 1 + * rEndp 1 + * kRstartp 1 + * kCurs 1 + * kEndp 1 + * + * ¢« + * ¤Ò¤ã¤¯ hyaku + * Àè 100010 10010 + * ÊÑ 111111 + * ¶Ø 000000 + * rStartp 1 + * rCurs 1 + * rEndp 1 + * kRstartp 1 + * kCurs 1 + * kEndp 1 + * + * ¢« + * ¤Ò¤ã¤¯ hyaku + * Àè 100010 10010 + * ÊÑ 111111 + * ¶Ø 000000 + * rStartp 1 + * rCurs 1 + * rEndp 1 + * kRstartp 1 + * kCurs 1 + * kEndp 1 + * + * ¢« + * ¤Ò¤ã¤¯ hyaku + * Àè 100010 10010 + * ÊÑ 111111 + * ¶Ø 000000 + * rStartp 1 + * rCurs 1 + * rEndp 1 + * kRstartp 1 + * kCurs 1 + * kEndp 1 + * + * ¢ª + * ¤Ò¤ã¤¯ hyaku + * Àè 100010 10010 + * ÊÑ 111111 + * ¶Ø 000000 + * rStartp 1 + * rCurs 1 + * rEndp 1 + * kRstartp 1 + * kCurs 1 + * kEndp 1 + * + * 'k' + * ¤Òk¤ã¤¯ hyakku + * Àè 1010010 100110 + * ÊÑ 1101111 + * ¶Ø 0010000 + * rStartp 1 + * rCurs 1 + * rEndp 1 + * kRstartp 1 + * kCurs 1 + * kEndp 1 + * + * 'i' + * ¤Ò¤­¤ã¤¯ hyakiku + * Àè 10100010 1001010 + * ÊÑ 11111111 + * ¶Ø 00110000 + * rStartp 1 + * rCurs 1 + * rEndp 1 + * kRstartp 1 + * kCurs 1 + * kEndp 1 + */ + +#ifdef WIN +#define KANALIMIT 127 /* This is caused by the Canna IME coding */ +#endif + +#ifndef KANALIMIT +#define KANALIMIT 255 +#endif +#define ROMAJILIMIT 255 + +#define doubleByteP(x) ((x) & 0x80) + +#ifdef DEBUG + +void debug_yomi(yomiContext x) +{ + char foo[1024]; + int len, i; + +#ifndef WIN + if (iroha_debug) { + len = WCstombs(foo, x->romaji_buffer, 1024); + foo[len] = '\0'; + printf(" %s\nÀè: ", foo); + for (i = 0 ; i <= x->rEndp ; i++) { + printf("%s", (x->rAttr[i] & SENTOU) ? "1" : " "); + } + printf("\n¥Ý: "); + for (i = 0 ; i < x->rStartp ; i++) { + printf(" "); + } + printf("^\n"); + + len = WCstombs(foo, x->kana_buffer, 1024); + foo[len] = '\0'; + printf(" %s\nÀè: ", foo); + for (i = 0 ; i <= x->kEndp ; i++) { + printf("%s ", (x->kAttr[i] & SENTOU) ? "1" : " "); + } + printf("\nºÑ: "); + for (i = 0 ; i <= x->kEndp ; i++) { + printf("%s", (x->kAttr[i] & HENKANSUMI) ? "ºÑ" : "̤"); + } + printf("\n¥Ý: "); + for (i = 0 ; i < x->kRStartp ; i++) { + printf(" "); + } + printf("¢¬\n"); + + } +#endif +} +#else /* !DEBUG */ +# define debug_yomi(x) +#endif /* !DEBUG */ + +#ifndef CALLBACK +#define kanaReplace(where, insert, insertlen, mask) \ +kanaRepl(d, where, insert, insertlen, mask) + +inline void +kanaRepl(uiContext d, int where, WCHAR_T *insert, int insertlen, int mask) +{ + yomiContext yc = (yomiContext)d->modec; + + generalReplace(yc->kana_buffer, yc->kAttr, &yc->kRStartp, + &yc->kCurs, &yc->kEndp, + where, insert, insertlen, mask); +} +#else /* CALLBACK */ +#define kanaReplace(where, insert, insertlen, mask) \ +kanaRepl(d, where, insert, insertlen, mask) + +static void +kanaRepl(uiContext d, int where, WCHAR_T *insert, int insertlen, int mask) +{ + yomiContext yc = (yomiContext)d->modec; +#ifndef WIN + WCHAR_T buf[256]; +#else + WCHAR_T *buf = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 256); + if (!buf) { + return; + } +#endif + + WStrncpy(buf, insert, insertlen); + buf[insertlen] = '\0'; + + generalReplace(yc->kana_buffer, yc->kAttr, &yc->kRStartp, + &yc->kCurs, &yc->kEndp, + where, insert, insertlen, mask); +#ifdef WIN + free(buf); +#endif +} +#endif /* CALLBACK */ + +#define romajiReplace(where, insert, insertlen, mask) \ +romajiRepl(d, where, insert, insertlen, mask) + +inline void +romajiRepl(uiContext d, int where, WCHAR_T *insert, int insertlen, int mask) +{ + yomiContext yc = (yomiContext)d->modec; + + generalReplace(yc->romaji_buffer, yc->rAttr, + &yc->rStartp, &yc->rCurs, &yc->rEndp, + where, insert, insertlen, mask); +} + +/* cfuncdef + + kPos2rPos -- ¤«¤Ê¥Ð¥Ã¥Õ¥¡¤Î¥ê¡¼¥¸¥ç¥ó¤«¤é¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¤Î¥ê¡¼¥¸¥ç¥ó¤òÆÀ¤ë + + yc : ÆÉ¤ß¥³¥ó¥Æ¥¯¥¹¥È + s : ¤«¤Ê¥Ð¥Ã¥Õ¥¡¤Î¥ê¡¼¥¸¥ç¥ó¤Î³«»Ï°ÌÃÖ + e : ¤«¤Ê¥Ð¥Ã¥Õ¥¡¤Î¥ê¡¼¥¸¥ç¥ó¤Î½ªÎ»°ÌÃÖ + rs : ¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¤ÎÂбþ¤¹¤ë³«»Ï°ÌÃÖ¤ò³ÊǼ¤¹¤ëÊÑ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿ + rs : ¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¤ÎÂбþ¤¹¤ë½ªÎ»°ÌÃÖ¤ò³ÊǼ¤¹¤ëÊÑ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿ + */ + +void +kPos2rPos(yomiContext yc, int s, int e, int *rs, int *re) +{ + int i, j, k; + + for (i = 0, j = 0 ; i < s ; i++) { + if (yc->kAttr[i] & SENTOU) { + do { + j++; + } while (!(yc->rAttr[j] & SENTOU)); + } + } + for (i = s, k = j ; i < e ; i++) { + if (yc->kAttr[i] & SENTOU) { + do { + k++; + } while (!(yc->rAttr[k] & SENTOU)); + } + } + if (rs) *rs = j; + if (re) *re = k; +} + +/* + makeYomiReturnStruct-- ÆÉ¤ß¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ËÊÖ¤¹»þ¤Î¹½Â¤ÂΤòºî¤ë´Ø¿ô + + makeYomiReturnStruct ¤Ï kana_buffer ¤òÄ´¤Ù¤ÆÅ¬Åö¤ÊÃͤòÁȤßΩ¤Æ¤ë¡£¤½ + ¤Î»þ¤Ë¥ê¥Ð¡¼¥¹¤ÎÎΰè¤âÀßÄꤹ¤ë¤¬¡¢¥ê¥Ð¡¼¥¹¤ò¤É¤Î¤¯¤é¤¤¤¹¤ë¤«¤Ï¡¢ + ReverseWidely ¤È¤¤¤¦ÊÑ¿ô¤ò¸«¤Æ·èÄꤹ¤ë¡£ + + */ + +void +makeYomiReturnStruct(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + makeKanjiStatusReturn(d, yc); +} + +extern int ckverbose; + +static struct RkRxDic * +OpenRoma(char *table) +{ +struct RkRxDic *retval = (struct RkRxDic *)0; +char *p; +char rdic[1024]; +extern char basepath[]; + + if (table || *table) { + retval = RkwOpenRoma(table); + + if (ckverbose == CANNA_FULL_VERBOSE) { + if (retval != (struct RkRxDic *)NULL) { /* ¼­½ñ¤¬¥ª¡¼¥×¥ó¤Ç¤­¤¿ */ + printf("¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Ï \"%s\" ¤òÍѤ¤¤Þ¤¹¡£\n", table); + } + } + + if (retval == (struct RkRxDic *)NULL) { + /* ¤â¤·¼­½ñ¤¬¥ª¡¼¥×¥ó¤Ç¤­¤Ê¤±¤ì¤Ð¥¨¥é¡¼ */ + extern jrUserInfoStruct *uinfo; + + rdic[0] = '\0'; + if (uinfo && uinfo->topdir && uinfo->uname) { + sprintf(rdic, "%sdic/user/%s/%s", uinfo->topdir, uinfo->uname, table); + retval = RkwOpenRoma(rdic); + }else{ + p = getenv("HOME"); + if (p) { + sprintf(rdic, "%s/%s", p, table); + retval = RkwOpenRoma(rdic); + } + } + + if (ckverbose == CANNA_FULL_VERBOSE) { + if (retval != (struct RkRxDic *)NULL) { +#ifndef WIN + printf("¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Ï \"%s\" ¤òÍѤ¤¤Þ¤¹¡£\n", rdic); +#endif + } + } + + if (retval == (struct RkRxDic *)NULL) { /* ¤³¤ì¤â¥ª¡¼¥×¥ó¤Ç¤­¤Ê¤¤ */ + extern jrUserInfoStruct *uinfo; + + rdic[0] = '\0'; + if (uinfo && uinfo->topdir) { + strcpy(rdic, uinfo->topdir); + } + else { + strcpy(rdic, basepath); + } + strcat(rdic, "dic/"); /*******************/ + strcat(rdic, table); + retval = RkwOpenRoma(rdic); + + if (ckverbose) { + if (retval != (struct RkRxDic *)NULL) { + if (ckverbose == CANNA_FULL_VERBOSE) { + printf("¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Ï \"%s\" ¤òÍѤ¤¤Þ¤¹¡£\n", rdic); + } + } + } + + if (retval == (struct RkRxDic *)NULL) { /* Á´Éô¥ª¡¼¥×¥ó¤Ç¤­¤Ê¤¤ */ + sprintf(rdic, +#ifndef WIN + "¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë(%s)¤¬¥ª¡¼¥×¥ó¤Ç¤­¤Þ¤»¤ó¡£", +#else + "\245\355\241\274\245\336\273\372\244\253\244\312" + "\312\321\264\271\245\306\241\274\245\326\245\353\50\45\163\51\244\254" + "\245\252\241\274\245\327\245\363\244\307\244\255\244\336\244\273" + "\244\363\241\243", +#endif + table); + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë(%s)¤¬¥ª¡¼¥×¥ó¤Ç¤­¤Þ¤»¤ó¡£ */ + addWarningMesg(rdic); + retval = (struct RkRxDic *)0; + goto return_ret; + } + } + } + } + return_ret: + return retval; +} + +RomkanaInit(void) +{ + extern char *RomkanaTable, *EnglishTable; + extern extraFunc *extrafuncp; + extern char basepath[]; + + extraFunc *extrafunc1, *extrafunc2; + + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Î¥ª¡¼¥×¥ó */ + if (RomkanaTable) { + romajidic = OpenRoma(RomkanaTable); + } + else { + char buf[1024]; + + sprintf(buf, "%sdic/default.kp", basepath); + romajidic = RkwOpenRoma(buf); + + if (romajidic != NULL) { + int len = strlen(buf); + RomkanaTable = (char *)malloc(len + 1); + if (RomkanaTable) { + strcpy(RomkanaTable, buf); + } + if (ckverbose == CANNA_FULL_VERBOSE) { + printf("¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Ï \"%s\" ¤òÍѤ¤¤Þ¤¹¡£\n", buf); + } + } + else { /* ¥ª¡¼¥×¥ó¤Ç¤­¤Ê¤«¤Ã¤¿ */ + if (ckverbose) { + printf("¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë \"%s\" ¤¬¥ª¡¼¥×¥ó¤Ç¤­¤Þ¤»¤ó¡£\n", + buf); + } + sprintf(buf, + "¥·¥¹¥Æ¥à¤Î¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤¬¥ª¡¼¥×¥ó¤Ç¤­¤Þ¤»¤ó¡£"); + addWarningMesg(buf); + } + } + + if (EnglishTable && (!RomkanaTable || strcmp(RomkanaTable, EnglishTable))) { + /* RomkanaTable ¤È EnglishTable ¤¬°ì½ï¤À¤Ã¤¿¤é¤À¤á */ + englishdic = OpenRoma(EnglishTable); + } + + /* ¥æ¡¼¥¶¥â¡¼¥É¤Î½é´ü²½ */ + for (extrafunc1 = extrafuncp ; extrafunc1 ; extrafunc1 = extrafunc1->next) { + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Î¥ª¡¼¥×¥ó */ + if (extrafunc1->keyword == EXTRA_FUNC_DEFMODE) { + if (extrafunc1->u.modeptr->romaji_table) { + if (RomkanaTable && + !strcmp(RomkanaTable, + (char *)extrafunc1->u.modeptr->romaji_table)) { + extrafunc1->u.modeptr->romdic = romajidic; + extrafunc1->u.modeptr->romdic_owner = 0; + } + else if (EnglishTable && + !strcmp(EnglishTable, + (char *)extrafunc1->u.modeptr->romaji_table)) { + extrafunc1->u.modeptr->romdic = englishdic; + extrafunc1->u.modeptr->romdic_owner = 0; + } + else { + for (extrafunc2 = extrafuncp ; extrafunc1 != extrafunc2 ; + extrafunc2 = extrafunc2->next) { + if (extrafunc2->keyword == EXTRA_FUNC_DEFMODE && + extrafunc2->u.modeptr->romaji_table) { + if (!strcmp((char *)extrafunc1->u.modeptr->romaji_table, + (char *)extrafunc2->u.modeptr->romaji_table)) { + extrafunc1->u.modeptr->romdic = extrafunc2->u.modeptr->romdic; + extrafunc1->u.modeptr->romdic_owner = 0; + break; + } + } + } + if (extrafunc2 == extrafunc1) { + extrafunc1->u.modeptr->romdic = + OpenRoma(extrafunc1->u.modeptr->romaji_table); + extrafunc1->u.modeptr->romdic_owner = 1; + } + } + }else{ + extrafunc1->u.modeptr->romdic = (struct RkRxDic *)0; /* nil¤Ç¤¹¤è¡ª */ + extrafunc1->u.modeptr->romdic_owner = 0; + } + } + } + + return 0; +} +#if 0 +RomkanaInit(void) +{ + extern char *RomkanaTable, *EnglishTable; + extern extraFunc *extrafuncp; + extraFunc *extrafunc1, *extrafunc2; + extern jrUserInfoStruct *uinfo; + + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Î¥ª¡¼¥×¥ó */ + if (uinfo) { + if (uinfo->romkanatable) { + if (RomkanaTable) { + free(RomkanaTable); + } + RomkanaTable = (char *)malloc(strlen(uinfo->romkanatable) + 1); + if (RomkanaTable) { + strcpy(RomkanaTable, uinfo->romkanatable); + } + } + } + if (RomkanaTable) { + romajidic = OpenRoma(RomkanaTable); + } + else { +#ifndef WIN + char buf[1024]; +#else + char *buf = malloc(1024); + if (!buf) { + return 0; + } +#endif + + buf[0] = '\0'; + if (uinfo && uinfo->topdir) { + strcpy(buf, uinfo->topdir); + } + else { + strcpy(buf, basepath); + } + strcat(buf, DEFAULT_ROMKANA_TABLE); + romajidic = RkwOpenRoma(buf); + + if (romajidic != (struct RkRxDic *)NULL) { + int len = strlen(buf); + RomkanaTable = (char *)malloc(len + 1); + if (RomkanaTable) { + strcpy(RomkanaTable, buf); + } + if (ckverbose == CANNA_FULL_VERBOSE) { +#ifndef WIN + printf("¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Ï \"%s\" ¤òÍѤ¤¤Þ¤¹¡£\n", buf); +#endif + } + } + else { /* ¥ª¡¼¥×¥ó¤Ç¤­¤Ê¤«¤Ã¤¿ */ + if (ckverbose) { +#ifndef WIN + printf("¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë \"%s\" ¤¬¥ª¡¼¥×¥ó¤Ç¤­¤Þ¤»¤ó¡£\n", + buf); +#endif + } + sprintf(buf, "\245\267\245\271\245\306\245\340\244\316\245\355\241\274" + "\245\336\273\372\244\253\244\312\312\321\264\271\245\306\241\274" + "\245\326\245\353\244\254\245\252\241\274\245\327\245\363\244\307" + "\244\255\244\336\244\273\244\363\241\243"); + /* ¥·¥¹¥Æ¥à¤Î¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤¬¥ª¡¼¥×¥ó¤Ç¤­¤Þ¤»¤ó¡£ */ + addWarningMesg(buf); + } +#ifdef WIN + free(buf); +#endif + } + +#ifndef NOT_ENGLISH_TABLE + if (EnglishTable && (!RomkanaTable || strcmp(RomkanaTable, EnglishTable))) { + /* RomkanaTable ¤È EnglishTable ¤¬°ì½ï¤À¤Ã¤¿¤é¤À¤á */ + englishdic = OpenRoma(EnglishTable); + } +#endif + + /* ¥æ¡¼¥¶¥â¡¼¥É¤Î½é´ü²½ */ + for (extrafunc1 = extrafuncp ; extrafunc1 ; extrafunc1 = extrafunc1->next) { + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Î¥ª¡¼¥×¥ó */ + if (extrafunc1->keyword == EXTRA_FUNC_DEFMODE) { + if (extrafunc1->u.modeptr->romaji_table) { + if (RomkanaTable && + !strcmp(RomkanaTable, + (char *)extrafunc1->u.modeptr->romaji_table)) { + extrafunc1->u.modeptr->romdic = romajidic; + extrafunc1->u.modeptr->romdic_owner = 0; + } +#ifndef NOT_ENGLISH_TABLE + else if (EnglishTable && + !strcmp(EnglishTable, + (char *)extrafunc1->u.modeptr->romaji_table)) { + extrafunc1->u.modeptr->romdic = englishdic; + extrafunc1->u.modeptr->romdic_owner = 0; + } +#endif + else { + for (extrafunc2 = extrafuncp ; extrafunc1 != extrafunc2 ; + extrafunc2 = extrafunc2->next) { + if (extrafunc2->keyword == EXTRA_FUNC_DEFMODE && + extrafunc2->u.modeptr->romaji_table) { + if (!strcmp((char *)extrafunc1->u.modeptr->romaji_table, + (char *)extrafunc2->u.modeptr->romaji_table)) { + extrafunc1->u.modeptr->romdic = extrafunc2->u.modeptr->romdic; + extrafunc1->u.modeptr->romdic_owner = 0; + break; + } + } + } + if (extrafunc2 == extrafunc1) { + extrafunc1->u.modeptr->romdic = + OpenRoma(extrafunc1->u.modeptr->romaji_table); + extrafunc1->u.modeptr->romdic_owner = 1; + } + } + }else{ + extrafunc1->u.modeptr->romdic = (struct RkRxDic *)0; /* nil¤Ç¤¹¤è¡ª */ + extrafunc1->u.modeptr->romdic_owner = 0; + } + } + } + + return 0; +} +#endif + +/* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Î¥¯¥í¡¼¥º */ + +extern keySupplement keysup[]; +extern void RkwCloseRoma (struct RkRxDic *); + +void +RomkanaFin(void) +{ + extern char *RomkanaTable, *EnglishTable; + extern nkeysup; + int i; + + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë¤Î¥¯¥í¡¼¥º */ + if (romajidic != (struct RkRxDic *)NULL) { + RkwCloseRoma(romajidic); + } + if (RomkanaTable) { + free(RomkanaTable); + RomkanaTable = (char *)NULL; + } +#ifndef NOT_ENGLISH_TABLE + if (englishdic != (struct RkRxDic *)NULL) { + RkwCloseRoma(englishdic); + } + if (EnglishTable) { + free(EnglishTable); + EnglishTable = (char *)NULL; + } +#endif + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥ë¡¼¥ë¤ÎÊ䭤Τ¿¤á¤ÎÎΰè¤Î²òÊü */ + for (i = 0 ; i < nkeysup ; i++) { + if (keysup[i].cand) { + free(keysup[i].cand); + keysup[i].cand = (WCHAR_T **)NULL; + } + if (keysup[i].fullword) { + free(keysup[i].fullword); + keysup[i].fullword = (WCHAR_T *)NULL; + } + } + nkeysup = 0; +} + +/* cfunc newYomiContext + + yomiContext ¹½Â¤ÂΤò°ì¤Äºî¤êÊÖ¤¹¡£ + + */ + +yomiContext +newYomiContext(WCHAR_T *buf, int bufsize, int allowedc, int chmodinhibit, int quitTiming, int hinhibit) +{ + yomiContext ycxt; + + ycxt = (yomiContext)malloc(sizeof(yomiContextRec)); + if (ycxt) { + bzero(ycxt, sizeof(yomiContextRec)); + ycxt->id = YOMI_CONTEXT; + ycxt->allowedChars = allowedc; + ycxt->generalFlags = chmodinhibit ? CANNA_YOMI_CHGMODE_INHIBITTED : 0; + ycxt->generalFlags |= quitTiming ? CANNA_YOMI_END_IF_KAKUTEI : 0; + ycxt->savedFlags = (long)0; + ycxt->henkanInhibition = hinhibit; + ycxt->n_susp_chars = 0; + ycxt->retbufp = ycxt->retbuf = buf; + ycxt->romdic = (struct RkRxDic *)0; + ycxt->myEmptyMode = (KanjiMode)0; + ycxt->last_rule = 0; + if ((ycxt->retbufsize = bufsize) == 0) { + ycxt->retbufp = 0; + } + ycxt->right = ycxt->left = (tanContext)0; + ycxt->next = (mode_context)0; + ycxt->prevMode = 0; + + /* ÊÑ´¹¤Îʬ */ + ycxt->nbunsetsu = 0; /* ʸÀá¤Î¿ô¡¢¤³¤ì¤ÇÆÉ¤ß¥â¡¼¥É¤«¤É¤¦¤«¤ÎȽÄê¤â¤¹¤ë */ + ycxt->context = -1; + ycxt->kouhoCount = 0; + ycxt->allkouho = (WCHAR_T **)0; + ycxt->curbun = 0; + ycxt->curIkouho = 0; /* ¥«¥ì¥ó¥È¸õÊä */ + ycxt->proctime = ycxt->rktime = 0; + + /* Ã༡¤Îʬ */ + ycxt->ys = ycxt->ye = ycxt->cStartp = ycxt->cRStartp = ycxt->status = 0; + } + return ycxt; +} + +/* + + GetKanjiString ¤Ï´Á»ú¤«¤Êº®¤¸¤êʸ¤ò¼è¤Ã¤Æ¤¯¤ë´Ø¿ô¤Ç¤¢¤ë¡£¼ÂºÝ¤Ë¤Ï + empty ¥â¡¼¥É¤òÀßÄꤹ¤ë¤À¤±¤Ç¥ê¥¿¡¼¥ó¤¹¤ë¡£ºÇ½ªÅª¤Ê·ë²Ì¤¬ buf ¤Ç»ØÄê + ¤µ¤ì¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì exitCallback ¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤³¤È¤Ë¤è¤Ã¤Æ¸Æ¤Ó + ½Ð¤·Â¦¤Ï´Á»ú¤«¤Êº®¤¸¤êʸ»ú¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£ + + Â裲°ú¿ô¤Î ycxt ¤ÏÄ̾ï¤Ï£°¤ò»ØÄꤹ¤ë¡£¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¥â¡¼¥É¤«¤éÆüËܸì + ¥â¡¼¥É¤Ø¤ÎÀÚ¤êÂØ¤¨¤ËºÝ¤·¤Æ¤Î¤ß¤Ï uiContext ¤ÎÄì¤ËÊݸ¤·¤Æ¤¢¤ë¥³¥ó¥Æ + ¥­¥¹¥È¤òÍѤ¤¤ë¡£¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¥â¡¼¥É¤ÈÆüËܸì¥â¡¼¥É¤È¤ÎÀÚ¤êÂØ¤¨¤Ï¥¹¥¿¥Ã + ¥¯¾å¤ËÀѤ߹þ¤Þ¤ì¤¿¥â¡¼¥É¤Î push/pop Áàºî¤Ç¤Ï¤Ê¤¯¡¢¥¹¥ï¥Ã¥×¾å¤Î¥â¡¼¥É + ¤Î°ìÈÖ¾å¤ÎÍ×ÁÇ¤ÎÆþ¤ìÂØ¤¨¤Ë¤Ê¤ë¡£ + + £³¤Ä¤Î Callback ¤Î¤¦¤Á¡¢exitCallback ¤Ï¤Ò¤ç¤Ã¤È¤·¤¿¤é»È¤ï¤ì¤Ê¤¤¤Ç¡¢ + everyTimeCallback ¤È quitCallback ¤·¤«ÍѤ¤¤Ê¤¤¤«¤âÃΤì¤Ê¤¤¡£ + + */ + +yomiContext +GetKanjiString(uiContext d, WCHAR_T *buf, int bufsize, int allowedc, int chmodinhibit, int quitTiming, int hinhibit, canna_callback_t everyTimeCallback, canna_callback_t exitCallback, canna_callback_t quitCallback) +{ + extern KanjiModeRec empty_mode; + yomiContext yc; + + if ((pushCallback(d, d->modec, everyTimeCallback, exitCallback, quitCallback, + NO_CALLBACK)) == (struct callback *)0) { + return (yomiContext)0; + } + + yc = newYomiContext(buf, bufsize, allowedc, chmodinhibit, + quitTiming, hinhibit); + if (yc == (yomiContext)0) { + popCallback(d); + return (yomiContext)0; + } + yc->romdic = romajidic; + yc->majorMode = d->majorMode; + yc->minorMode = CANNA_MODE_HenkanMode; + yc->next = d->modec; + d->modec = (mode_context)yc; + /* Á°¤Î¥â¡¼¥É¤ÎÊݸ */ + yc->prevMode = d->current_mode; + /* ¥â¡¼¥ÉÊѹ¹ */ + d->current_mode = yc->curMode = yc->myEmptyMode = &empty_mode; + return yc; +} + +/* cfuncdef + + popYomiMode -- ÆÉ¤ß¥â¡¼¥É¤ò¥Ý¥Ã¥×¥¢¥Ã¥×¤¹¤ë¡£ + + */ + +void +popYomiMode(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + d->modec = yc->next; + d->current_mode = yc->prevMode; + + if (yc->context >= 0) { + RkwCloseContext(yc->context); + yc->context = -1; + } + + freeYomiContext(yc); +} + +/* cfuncdef + + checkIfYomiExit -- ÆÉ¤ß¥â¡¼¥É¤¬½ªÎ»¤«¤É¤¦¤«¤òÄ´¤Ù¤ÆÃͤòÊÖ¤¹¥Õ¥£¥ë¥¿ + + ¤³¤Î¥Õ¥£¥ë¥¿¤ÏÆÉ¤ß¥â¡¼¥É¤Î³Æ´Ø¿ô¤ÇÃͤòÊÖ¤½¤¦¤È¤¹¤ë»þ¤Ë¸Æ¤Ö¡£ÆÉ¤ß¥â¡¼ + ¥É¤Ç¤Î½èÍý¤¬½ªÎ»¤¹¤ë¤È¤³¤í¤Ç¤¢¤ì¤Ð¡¢ÆÉ¤ß¥â¡¼¥É¤ò½ªÎ»¤·¡¢uiContext ¤Ë + ¥×¥Ã¥·¥å¤µ¤ì¤Æ¤¤¤¿¥í¡¼¥«¥ë¥Ç¡¼¥¿¤ä¥â¡¼¥É¹½Â¤ÂΤ¬¥Ý¥Ã¥×¤µ¤ì¤ë¡£ + + ¥í¡¼¥«¥ë¥Ç¡¼¥¿¤Ë exitCallback ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤¤¤«¤Ê¤ë¾ì¹ç¤Ë¤â + ¹½Â¤ÂΤΥݥåץ¢¥Ã¥×¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£ + + º£¤Î¤È¤³¤í¡¢ÆÉ¤ß¥â¡¼¥É¤Î½ªÎ»¤Ï¼¡¤Î¤è¤¦¤Ê¾ì¹ç¤¬¹Í¤¨¤é¤ì¤ë¡£ + + (1) C-m ¤¬³ÎÄêÆÉ¤ß¤ÎºÇ¸å¤Îʸ»ú¤È¤·¤ÆÊÖ¤µ¤ì¤¿»þ¡£(ÊÑ´¹µö²Ä¤Î»þ) + + (2) ³ÎÄêʸ»úÎó¤¬Â¸ºß¤¹¤ë¾ì¹ç¡£(ÊÑ´¹¶Ø»ß¤Î»þ) + + quit ¤ÇÆÉ¤ß¥â¡¼¥É¤ò½ªÎ»¤¹¤ë»þ¤Ï?¾¤Î´Ø¿ô?¤ò¸Æ¤Ö¡£ + + */ + +inline +checkIfYomiExit(uiContext d, int retval) +{ + yomiContext yc = (yomiContext)d->modec; + + if (retval <= 0) { + /* ³ÎÄêʸ»úÎ󤬤ʤ¤¤«¥¨¥é¡¼¤Î¾ì¹ç ¢á exit ¤Ç¤Ï¤Ê¤¤ */ + return retval; + } + if (yc->retbufp && yc->retbufsize - (yc->retbufp - yc->retbuf) > retval) { + /* ʸ»úÎó³ÊǼ¥Ð¥Ã¥Õ¥¡¤¬¤¢¤Ã¤Æ¡¢³ÎÄꤷ¤¿Ê¸»úÎó¤è¤ê¤â¤¢¤Þ¤Ã¤Æ¤¤¤ëÎÎ + °è¤¬Ä¹¤¤¤Î¤Ç¤¢¤ì¤Ð³ÊǼ¥Ð¥Ã¥Õ¥¡¤Ë³ÎÄꤷ¤¿Ê¸»úÎó¤ò¥³¥Ô¡¼¤¹¤ë */ + WStrncpy(yc->retbufp, d->buffer_return, retval); + yc->retbufp[retval] = (WCHAR_T)0; + yc->retbufp += retval; + } + if (yc->generalFlags & CANNA_YOMI_END_IF_KAKUTEI + || d->buffer_return[retval - 1] == '\n') { + /* ÊÑ´¹¤¬¶Ø»ß¤µ¤ì¤Æ¤¤¤ë¤È¤·¤¿¤é exit */ + /* ¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢\n ¤¬Æþ¤Ã¤Æ¤¤¤¿¤é exit */ + d->status = EXIT_CALLBACK; + if (!(d->cb && d->cb->func[EXIT_CALLBACK] == NO_CALLBACK)) { + d->status = EXIT_CALLBACK; + popYomiMode(d); + } + } + return retval; +} + +static +checkIfYomiQuit(uiContext d, int retval) +/* ARGSUSED */ +{ +#ifdef QUIT_IN_YOMI /* ¥³¥á¥ó¥È¥¢¥¦¥È¤¹¤ëÌÜŪ¤Î ifdef */ + yomiContext yc = (yomiContext)d->modec; + + if (d->cb && d->cb->func[QUIT_CALLBACK] == NO_CALLBACK) { + /* ¥³¡¼¥ë¥Ð¥Ã¥¯¤¬¤Ê¤¤¾ì¹ç + + ¤³¤ó¤Ê¥Á¥§¥Ã¥¯¤ò¿ÆÀڤ˹Ԥ¦¤Î¤Ï¡¢ÆÉ¤ß¥â¡¼¥É¤¬Èó¾ï¤Ë´ðËÜŪ¤Ê¥â¡¼¥É + ¤Ç¤¢¤ê¡¢´°Á´¤ËÈ´¤±¤ë¤È¤­¤Ë¤ï¤¶¤ï¤¶¥Ý¥Ã¥×¥¢¥Ã¥×¤·¤Æ¤â¤¹¤°¤Ë¥×¥Ã¥·¥å + ¤¹¤ë¾ì¹ç¤¬Â¿¤¤¤È¹Í¤¨¤é¤ì¤Æ½èÍý¤¬ÌµÂ̤À¤«¤é¤Ç¤¢¤ë¡£ + + */ + } + else { + d->status = QUIT_CALLBACK; + popYomiMode(d); + } +#endif /* QUIT_IN_YOMI */ + return retval; +} + +void fitmarks(yomiContext); + +void +fitmarks(yomiContext yc) +{ + if (yc->kRStartp < yc->pmark) { + yc->pmark = yc->kRStartp; + } + if (yc->kRStartp < yc->cmark) { + yc->cmark = yc->kRStartp; + } +} + +/* ľÁ°¤Ë̤ÊÑ´¹Ê¸»úÎ󤬤ʤ¤¤«¤É¤¦¤«³Îǧ */ +void +ReCheckStartp(yomiContext yc) +{ + int r = yc->rStartp, k = yc->kRStartp, i; + + do { + yc->kRStartp--; + yc->rStartp--; + } while ( yc->kRStartp >= 0 + && !(yc->kAttr[yc->kRStartp] & HENKANSUMI) + ); + yc->kRStartp++; + yc->rStartp++; + + /* ̤ÊÑ´¹Éô¤ËÀèÆ¬¥Þ¡¼¥¯¤¬ÉÕ¤¤¤Æ¤¤¤¿¾ì¹ç¤ÏÀèÆ¬¥Þ¡¼¥¯¤ò¤Ï¤º¤¹¡£ + + ̤ÊÑ´¹Éô¤ÎÀèÆ¬¤Ë´Ø¤·¤Æ¤ÏÀèÆ¬¥Þ¡¼¥¯¤òÉÕ¤±¤Æ¤ª¤¯¡£ + ̤ÊÑ´¹Éô¤¬¤¢¤Ã¤¿¾ì¹ç(kRStartp < k)¡¢¤½¤ì¤¬¡¢kCurs ¤è¤ê¤â + º¸Â¦¤Ç¤¢¤ì¤ÐÀèÆ¬¥Õ¥é¥°¤òÍî¤È¤¹¡£ */ + + if (yc->kRStartp < k && k < yc->kCurs) { + yc->kAttr[k] &= ~SENTOU; + yc->rAttr[r] &= ~SENTOU; + } + for (i = yc->kRStartp + 1 ; i < k ; i++) { + yc->kAttr[i] &= ~SENTOU; + } + for (i = yc->rStartp + 1 ; i < r ; i++) { + yc->rAttr[i] &= ~SENTOU; + } +} + +extern void setMode (uiContext d, tanContext tan, int forw); + +void +removeCurrentBunsetsu(uiContext d, tanContext tan) +{ + if (tan->left) { + tan->left->right = tan->right; + d->modec = (mode_context)tan->left; + d->current_mode = tan->left->curMode; + setMode(d, tan->left, 0); + } + if (tan->right) { + tan->right->left = tan->left; + d->modec = (mode_context)tan->right; + d->current_mode = tan->right->curMode; + setMode(d, tan->right, 1); + } + switch (tan->id) { + case YOMI_CONTEXT: + freeYomiContext((yomiContext)tan); + break; + case TAN_CONTEXT: + freeTanContext(tan); + break; + } +} + +/* tabledef + + charKind -- ¥­¥ã¥é¥¯¥¿¤Î¼ïÎà¤Î¥Æ¡¼¥Ö¥ë + + 0x20 ¤«¤é 0x7f ¤Þ¤Ç¤Î¥­¥ã¥é¥¯¥¿¤Î¼ïÎà¤òɽ¤¹¥Æ¡¼¥Ö¥ë¤Ç¤¢¤ë¡£ + + 3: ¿ô»ú + 2: £±£¶¿Ê¿ô¤È¤·¤ÆÍѤ¤¤é¤ì¤ë±Ñ»ú + 1: ¤½¤ì°Ê³°¤Î±Ñ»ú + 0: ¤½¤Î¾ + + ¤È¤Ê¤ë¡£ + + */ + +static BYTE charKind[] = { +/*sp ! " # $ % & ' ( ) * + , - . / */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +/*0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, +/*@ A B C D E F G H I J K L M N O */ + 1, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, +/*P Q R S T U V W X Y X [ \ ] ^ _ */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, +/*` a b c d e f g h i j k l m n o */ + 1, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, +/*p q r s t u v w x y z { | } ~ DEL */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, +}; + +/* + YomiInsert -- ¥í¡¼¥Þ»ú¤ò£±Ê¸»úÁÞÆþ¤¹¤ë´Ø¿ô + + */ + +void +restoreChikujiIfBaseChikuji(yomiContext yc) +{ + if (!chikujip(yc) && (yc->generalFlags & CANNA_YOMI_BASE_CHIKUJI)) { + yc->generalFlags &= ~CANNA_YOMI_BASE_CHIKUJI; + yc->generalFlags |= CANNA_YOMI_CHIKUJI_MODE; + yc->minorMode = getBaseMode(yc); + } +} + +int YomiInsert (uiContext); + +YomiInsert(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int subst, autoconvert = (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE); + int kugiri = 0; +#ifdef USE_ROMKANATABLE_FOR_KANAKEY + WCHAR_T key = 0; +#endif + + d->nbytes = 0; + if (autoconvert) { + if (yc->status & CHIKUJI_ON_BUNSETSU) { + yc->status &= ~CHIKUJI_OVERWRAP; + if (yc->kCurs != yc->kEndp) { + yc->rStartp = yc->rCurs = yc->rEndp; + yc->kRStartp = yc->kCurs = yc->kEndp; + } + } + else { + if (yc->rEndp == yc->rCurs) { + yc->status &= ~CHIKUJI_OVERWRAP; + } + if (yc->kCurs < yc->ys) { + yc->ys = yc->kCurs; + } + } + } + + if (yc->allowedChars == CANNA_NOTHING_ALLOWED)/* ¤É¤Î¥­¡¼¤â¼õÉÕ¤±¤Ê¤¤ */ + return NothingChangedWithBeep(d); + if (yc->rEndp >= ROMAJILIMIT + || yc->kEndp >= KANALIMIT + /* ½Â¤¤·×»»¤ò¤·¤Æ¤¤¤ë + || (chc && yc->rEndp + chc->hc->ycx->rEndp > ROMAJILIMIT)*/) { + return NothingChangedWithBeep(d); + } + + fitmarks(yc); + + if (0xa0 < d->ch && d->ch < 0xe0) { +#ifdef USE_ROMKANATABLE_FOR_KANAKEY + key = d->buffer_return[0]; +#else + if (yc->allowedChars == CANNA_NOTHING_RESTRICTED) { + return KanaYomiInsert(d); /* callback ¤Î¥Á¥§¥Ã¥¯¤Ï KanaYomiInsert ¤Ç! */ + } + else { + return NothingChangedWithBeep(d); + } +#endif + } + + /* (d->ch & ~0x1f) == 0x1f < (unsigned char)d->ch */ + if (!(d->ch & ~0x1f) && yc->allowedChars != CANNA_NOTHING_RESTRICTED + || (d->ch < 0x80 ? charKind[d->ch - 0x20] : 1) < yc->allowedChars) { + /* Á°¤Î¹Ô¡¢USE_ROMKANATABLE_FOR_KANAKEY ¤Î¤È¤­¤Ë¤Þ¤º¤¤ */ + /* 0x20 ¤Ï¥³¥ó¥È¥í¡¼¥ë¥­¥ã¥é¥¯¥¿¤Îʬ */ + return NothingChangedWithBeep(d); + } + + if (yc->allowedChars != CANNA_NOTHING_RESTRICTED) { + /* allowed all °Ê³°¤Ç¤Ï¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤ò¹Ô¤ï¤Ê¤¤ */ + WCHAR_T romanBuf[4]; /* £²¥Ð¥¤¥È¤Ç½½Ê¬¤À¤È»×¤¦¤±¤É¤Í */ + int len; +#ifdef USE_ROMKANATABLE_FOR_KANAKEY + WCHAR_T tempc = key ? key : (WCHAR_T)d->ch; +#else + WCHAR_T tempc = (WCHAR_T)d->ch; +#endif + romajiReplace(0, &tempc, 1, SENTOU); + + len = RkwCvtNone(romanBuf, 4, &tempc, 1); + + if (yc->generalFlags & CANNA_YOMI_KAKUTEI) { /* ³ÎÄꤷ¤Á¤ã¤¦ */ + WStrncpy(d->buffer_return + d->nbytes, yc->kana_buffer, yc->kCurs); + /* ¥í¡¼¥Þ»ú¤ÎÃÇÊÒ¤¬»Ä¤Ã¤Æ¤¤¤ë¤³¤È¤Ï¤Ê¤¤¤Î¤Ç¡¢yc->kRStartp ¤Ç¤Ê¤¯¤Æ¡¢ + yc->kCurs ¤¬»È¤¨¤ë */ + d->nbytes += yc->kCurs; + romajiReplace(-yc->rCurs, (WCHAR_T *)0, 0, 0); + kanaReplace(-yc->kCurs, (WCHAR_T *)0, 0, 0); + + WStrncpy(d->buffer_return + d->nbytes, romanBuf, len); + d->nbytes += len; + len = 0; + } + + kanaReplace(0, romanBuf, len, HENKANSUMI); + yc->kAttr[yc->kRStartp] |= SENTOU; + yc->rStartp = yc->rCurs; + yc->kRStartp = yc->kCurs; + } + else { /* ¥í¡¼¥Þ»ú¥«¥ÊÊÑ´¹¤¹¤ë¾ì¹ç */ +#ifdef USE_ROMKANATABLE_FOR_KANAKEY + WCHAR_T tempc = key ? key : (WCHAR_T)d->ch; +#else + WCHAR_T tempc = (WCHAR_T)d->ch; +#endif + int ppos; + if (cannaconf.BreakIntoRoman) + yc->generalFlags |= CANNA_YOMI_BREAK_ROMAN; + + /* ľÁ°¤Ë̤ÊÑ´¹Ê¸»úÎ󤬤ʤ¤¤«¤É¤¦¤«³Îǧ */ + + if (yc->kCurs == yc->kRStartp) { + ReCheckStartp(yc); + } + + /* ¤Þ¤º¥«¡¼¥½¥ëÉôʬ¤Ë¥í¡¼¥Þ»ú¤ò£±Ê¸»úÆþ¤ì¤ë */ + + romajiReplace(0, &tempc, 1, (yc->rStartp == yc->rCurs) ? SENTOU : 0); + + ppos = yc->kRStartp; + kanaReplace(0, &tempc, 1, (yc->kRStartp == yc->kCurs) ? SENTOU : 0); + +#ifdef USE_ROMKANATABLE_FOR_KANAKEY + kugiri = makePhonoOnBuffer(d, yc, key ? key : (unsigned char)d->ch, 0, 0); +#else + kugiri = makePhonoOnBuffer(d, yc, (unsigned char)d->ch, 0, 0); +#endif + + if (kugiri && autoconvert) { + if (ppos < yc->ys) { + yc->ys = ppos; + } + if ((subst = ChikujiSubstYomi(d)) < 0) { + makeGLineMessageFromString(d, jrKanjiError); + if (subst == -2) { + TanMuhenkan(d); + } + else { + makeYomiReturnStruct(d); + } + return 0; /* ²¼¤Þ¤Ç¹Ô¤«¤Ê¤¯¤Æ¤¤¤¤¤Î¤«¤Ê¤¢ */ + } + } + } + + debug_yomi(yc); + makeYomiReturnStruct(d); + + if (!yc->kEndp && !(autoconvert && yc->nbunsetsu)) { + if (yc->left || yc->right) { + removeCurrentBunsetsu(d, (tanContext)yc); + } + else { + /* ̤³ÎÄêʸ»úÎó¤¬Á´¤¯¤Ê¤¯¤Ê¤Ã¤¿¤Î¤Ê¤é¡¢¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + currentModeInfo(d); + } + + return d->nbytes; +} + +/* cfuncdef + + findSup -- supkey ¤ÎÃæ¤«¤é¥­¡¼¤Ë°ìÃפ¹¤ë¤â¤Î¤òõ¤¹¡£ + + ÊÖ¤ëÃÍ¤Ï supkey ¤ÎÃæ¤Ç key ¤¬°ìÃפ¹¤ë¤â¤Î¤¬²¿ÈÖÌÜ¤ËÆþ¤Ã¤Æ¤¤¤ë¤«¤òɽ¤¹¡£ + ²¿ÈÖÌܤȸÀ¤¦¤Î¤Ï£±¤«¤é»Ï¤Þ¤ëÃÍ¡£ + + ¸«¤Ä¤«¤é¤Ê¤¤»þ¤Ï£°¤òÊÖ¤¹¡£ + */ + +int findSup (WCHAR_T); + +findSup(WCHAR_T key) +{ + int i; + extern nkeysup; + + for (i = 0 ; i < nkeysup ; i++) { + if (key == keysup[i].key) { + return i + 1; + } + } + return 0; +} + +/* cfuncdef + + makePhonoOnBuffer -- yomiContext ¤Î¥Ð¥Ã¥Õ¥¡¾å¤Ç¥­¡¼ÆþÎÏ¢ªÉ½²»Ê¸»úÊÑ´¹¤ò + ¤¹¤ë + + ÊÑ´¹¤Ë¤Ò¤È¶èÀڤ꤬ÉÕ¤¤¤¿»þÅÀ¤Ç 1 ¤òÊÖ¤¹¡£¤½¤ì°Ê³°¤Î¾ì¹ç¤Ë¤Ï 0 ¤òÊÖ¤¹¡£ + + ºÇ¸å¤«¤é£²¤Ä¤á¤Î flag ¤Ï RkwMapPhonogram ¤ËÅϤ¹¥Õ¥é¥°¤Ç¡¢ + ºÇ¸å¤Î english ¤È¸À¤¦¤Î¤Ï±Ññ¸ì¥«¥ÊÊÑ´¹¤ò¤¹¤ë¤«¤É¤¦¤«¤òɽ¤¹¥Õ¥é¥° + + */ + +static +makePhonoOnBuffer(uiContext d, yomiContext yc, unsigned char key, int flag, int english) +{ + int i, n, m, t, sm, henkanflag, prevflag, cond; + int retval = 0; + int sup = 0; + int engflag = (english && englishdic); + int engdone = 0; + WCHAR_T *subp; +#ifndef WIN + WCHAR_T kana_char[1024], sub_buf[1024]; +#else + WCHAR_T *kana_char, *sub_buf; + + kana_char = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 1024); + sub_buf = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 1024); + if (!kana_char || !sub_buf) { + if (kana_char) { + free(kana_char); + } + if (sub_buf) { + free(sub_buf); + } + return 0; + } +#endif + + if (cannaconf.ignore_case) flag |= RK_IGNORECASE; + + /* ̤ÊÑ´¹¥í¡¼¥Þʸ»úÎó¤Î¤«¤ÊÊÑ´¹ */ + for (;;) { +#ifndef USE_ROMKANATABLE_FOR_KANAKEY + if ((flag & RK_FLUSH) && + yc->kRStartp != yc->kCurs && + !WIsG0(yc->kana_buffer[yc->kCurs - 1])) { + /* ¥¢¥¹¥­¡¼Ê¸»ú¤¬Æþ¤Ã¤Æ¤¤¤ë¤ï¤±¤Ç¤Ê¤«¤Ã¤¿¤é */ + kana_char[0] = yc->kana_buffer[yc->kRStartp]; + n = m = 1; t = 0; + henkanflag = HENKANSUMI; + } + /* Êä½õ¥Þ¥Ã¥Ô¥ó¥°¤ÎÄ´ºº */ + else +#endif + if ((cond = (!(yc->generalFlags & CANNA_YOMI_ROMAJI) && + !(yc->generalFlags & CANNA_YOMI_IGNORE_USERSYMBOLS) && + (yc->kCurs - yc->kRStartp) == 1 && + (sup = findSup(yc->kana_buffer[yc->kRStartp]))) ) + && keysup[sup - 1].ncand > 0) { + n = 1; t = 0; + WStrcpy(kana_char, keysup[sup - 1].cand[0]); + m = WStrlen(kana_char); + /* defsymbol ¤Î¿·¤·¤¤µ¡Ç½¤ËÂбþ¤·¤¿½èÍý */ + yc->romaji_buffer[yc->rStartp] = keysup[sup - 1].xkey; + henkanflag = HENKANSUMI | SUPKEY; + } + else { + if (cond) { /* && keysup[sup - 1].ncand == 0 */ + /* defsymbol ¤Î¿·¤·¤¤µ¡Ç½¤ËÂбþ¤·¤¿½èÍý¡£ÆþÎÏʸ»ú¼«¿È¤òÃÖ¤­´¹¤¨¤ë */ + yc->kana_buffer[yc->kRStartp] = + yc->romaji_buffer[yc->rStartp] = keysup[sup - 1].xkey; + } + if (yc->romdic != (struct RkRxDic *)NULL + && !(yc->generalFlags & CANNA_YOMI_ROMAJI)) { + if (engflag && + RkwMapPhonogram(englishdic, kana_char, 1024, + yc->kana_buffer + yc->kRStartp, + yc->kCurs - yc->kRStartp, + (WCHAR_T)key, + flag, &n, &m, &t, &yc->last_rule) && + n > 0) { + henkanflag = HENKANSUMI | GAIRAIGO; + engdone = 1; + } + else if (engflag && 0 == n /* ¾å¤Î RkwMapPhonogram ¤ÇÆÀ¤¿ÃÍ */ && + RkwMapPhonogram(englishdic, kana_char, 1024, + yc->kana_buffer + yc->kRStartp, + yc->kCurs - yc->kRStartp, + (WCHAR_T)key, + flag | RK_FLUSH, + &n, &m, &t, &yc->last_rule) && + n > 0) { + henkanflag = HENKANSUMI | GAIRAIGO; + engdone = 1; + } + else { + engflag = 0; + if (RkwMapPhonogram(yc->romdic, kana_char, 1024, + yc->kana_buffer + yc->kRStartp, + yc->kCurs - yc->kRStartp, + (WCHAR_T) key, + flag | RK_SOKON, &n, &m, &t, &yc->last_rule)) { + /* RK_SOKON ¤òÉÕ¤±¤ë¤Î¤Ïµì¼­½ñÍÑ */ + henkanflag = HENKANSUMI; + } + else { + henkanflag = 0; + } + if (n > 0 && !engdone) { + engflag = (english && englishdic); + } + } + if (n == yc->kCurs - yc->kRStartp) { + key = (unsigned char)0; + } + }else{ + t = 0; + henkanflag = (yc->generalFlags & CANNA_YOMI_ROMAJI) ? + (HENKANSUMI | STAYROMAJI) : 0; + m = n = (yc->kCurs - yc->kRStartp) ? 1 : 0; + WStrncpy(kana_char, yc->kana_buffer + yc->kRStartp, n); + } + } + + /* ¥í¡¼¥Þ»ú¤Î¤¦¤Á n ʸ»úʬ¥«¥Ê¤ËÊÑ´¹¤µ¤ì¤¿ */ + + if (n <= 0) { + break; + } + else { + int unchanged; + + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤Î·ë²Ì¤ò²Ã¹©¤¹¤ë */ + if (cannaconf.abandonIllegalPhono && !henkanflag && !yc->n_susp_chars) { + /* ÊÑ¤Ê¥í¡¼¥Þ»ú¤Ï¼Î¤Æ¤ë */ + sm = 0; subp = sub_buf; + /* t ¤¬¤¢¤ë¤Î¤Ë henkanflag ¤¬ 0 ¤Î¤³¤È¤Ã¤Æ¤Ê¤¤¤ó¤À¤±¤É¤Í */ + /* WStrncpy(subp, kana_char + m, t); */ + }else{ + sm = m; subp = kana_char; + if (yc->generalFlags & (CANNA_YOMI_KATAKANA | CANNA_YOMI_HIRAGANA)) { + int tempm; + + if (yc->generalFlags & CANNA_YOMI_KATAKANA) { + tempm = RkwCvtKana(sub_buf, 1024, subp, sm); + } + else { + tempm = RkwCvtHira(sub_buf, 1024, subp, sm); + } + /* Ťµ¥Á¥§¥Ã¥¯¤¬ËÜÅö¤Ï¤¤¤ë¤¬¡¢ÂÌÌܤΤȤ­¤Î½èÍý¤ò¹Í¤¨¤¿¤¯¤Ê¤¤ */ + WStrncpy(sub_buf + tempm, subp + sm, t); + subp = sub_buf; + sm = tempm; + } + if (yc->generalFlags & (CANNA_YOMI_ZENKAKU | CANNA_YOMI_HANKAKU)) { + int tempm; + WCHAR_T *otherp = (subp == sub_buf) ? kana_char : sub_buf; + + if (yc->generalFlags & CANNA_YOMI_ZENKAKU) { + tempm = RkwCvtZen(otherp, 1024, subp, sm); + } + else { + tempm = RkwCvtHan(otherp, 1024, subp, sm); + } + WStrncpy(otherp + tempm, subp + sm, t); + subp = otherp; + sm = tempm; + } + + if (yc->generalFlags & CANNA_YOMI_KAKUTEI) { /* ³ÎÄꤷ¤Á¤ã¤¦ */ + int off; + + chikujiEndBun(d); + WStrncpy(d->buffer_return + d->nbytes, + yc->kana_buffer, yc->kRStartp); + d->nbytes += yc->kRStartp; + + off = yc->kCurs - yc->kRStartp; + yc->kRStartp = 0; + yc->kCurs -= off; + kanaReplace(-yc->kCurs, (WCHAR_T *)0, 0, 0); + yc->kCurs += off; + + WStrncpy(d->buffer_return + d->nbytes, subp, sm); + d->nbytes += sm; + subp += sm; + sm = 0; + } + } + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤Î·ë²Ì¤ò¥«¥Ê¥Ð¥Ã¥Õ¥¡¤ËÆþ¤ì¤ë¡£ */ + + unchanged = yc->kCurs - yc->kRStartp - n; + yc->kCurs -= unchanged; + prevflag = (yc->kAttr[yc->kRStartp] & SENTOU); + kanaReplace(-n, subp, sm + t, henkanflag); + if ( prevflag ) { + yc->kAttr[yc->kRStartp] |= SENTOU; + } + yc->kRStartp += sm; + if (t == 0 && m > 0 && unchanged) { + yc->kAttr[yc->kRStartp] |= SENTOU; + } + for (i = yc->kRStartp ; i < yc->kCurs ; i++) { + yc->kAttr[i] &= ~HENKANSUMI; /* HENKANSUMI ¥Õ¥é¥°¤ò¼è¤ê½ü¤¯ */ + } + yc->kCurs += unchanged; + + if (t > 0) { + /* suspend ¤·¤Æ¤¤¤ëʸ»úĹ¤Ï¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¤È¤«¤Ê¥Ð¥Ã¥Õ¥¡¤È¤Î + ³ÆÊ¸»ú¤ÎÂбþÉÕ¤±¤Ë±Æ¶Á¤¹¤ë¤¬¡¢¤½¤ÎÄ´À°¤ò¤¹¤ë¤¿¤á¤Î·×»» */ + + if (yc->n_susp_chars) { + yc->n_susp_chars += t - n; + } + else { + yc->n_susp_chars = SUSPCHARBIAS + t - n; + } + + /* ¤Ä¤¤¤Ç¤Ë¼¡¤Î¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹ÍÑ¤Ë key ¤ò¹Í¤¨¤Æ¤ß¤ë¡£ */ + key = (unsigned char)yc->kana_buffer[yc->kRStartp + t]; + } + else if (m > 0) { /* ¥í¡¼¥Þ»ú¤È¤«¤Ê¤ÎÂбþ¤òÉÕ¤±¤ë¤¿¤á¤Î½èÍý */ + int n_cor_keys = n - + (yc->n_susp_chars ? yc->n_susp_chars - SUSPCHARBIAS : 0); + + retval = 1; /* ¤Ò¤È¶èÀڤ꤬¤Ä¤¤¤¿ */ + yc->rStartp += n_cor_keys; + if (cannaconf.abandonIllegalPhono && + !henkanflag && !yc->n_susp_chars) { + yc->rStartp -= n; + unchanged = yc->rCurs - yc->rStartp - n; + yc->rCurs -= unchanged; + romajiReplace(-n, (WCHAR_T *)0, 0, 0); + yc->rCurs += unchanged; + retval = 0; /* ¤ä¤Ã¤Ñ¤ê¶èÀڤ꤬¤Ä¤¤¤Æ¤¤¤Ê¤¤ */ + } + else if (yc->generalFlags & CANNA_YOMI_KAKUTEI) { + int offset = yc->rCurs - yc->rStartp; + + yc->rCurs -= offset; + romajiReplace(-yc->rCurs, (WCHAR_T *)0, 0, 0); + yc->rCurs += offset; + retval = 0; /* ¤ä¤Ã¤Ñ¤ê¶èÀڤ꤬¤Ä¤¤¤Æ¤¤¤Ê¤¤ */ + } + yc->rAttr[yc->rStartp] |= SENTOU; + yc->n_susp_chars = /* t ? SUSPCHARBIAS + t : (t ¤Ïɬ¤º 0)*/ 0; + } + } + } +#ifdef WIN + free(kana_char); + free(sub_buf); +#endif + return retval; +} + +#define KANAYOMIINSERT_BUFLEN 10 + +/* °Ê²¼¤Î¤¤¤¯¤Ä¤«¤Î´Ø¿ô¤ÏÈó¾ï¤ËÆüËܸì¤Ë°Í¸¤·¤Æ¤¤¤ë¡£ + ¤«¤ÊÆþÎϤˤĤ¤¤Æ¤â¥Æ¡¼¥Ö¥ë¤ò»È¤¦¤è¤¦¤Ë¤·¤Æ¡¢°Í¸Éôʬ¤ò + ÇÓ½ü¤¹¤ë¤è¤¦¤Ë¤·¤¿¤¤¤â¤Î¤À */ + +/* + dakuonP -- predicate for Japanese voiced sounds (Japanese specific) + + argument: + ch(WCHAR_T): character to be inspected + + return value: + 0: Not a voiced sound. + 1: Semi voiced sound. + 2: Full voiced sound. + */ + +#define DAKUON_HV 1 +#define DAKUON_FV 2 + +inline +dakuonP(WCHAR_T ch) +{ + static dakuon_first_time = 1; + static WCHAR_T hv, fv; + + if (dakuon_first_time) { /* ÆüËܸì¸ÇÍ­¤Î½èÍý */ + WCHAR_T buf[2]; + + dakuon_first_time = 0; + + MBstowcs(buf, "\216\336"/* Âù²» */, 2); + fv = buf[0]; + MBstowcs(buf, "\216\337"/* ȾÂù²» */, 2); + hv = buf[0]; + } + + if (ch == hv) { + return DAKUON_HV; + } + else if (ch == fv) { + return DAKUON_FV; + } + else { + return 0; + } +} + +/* + growDakuonP -- Âù²»¤¬ÉÕ¤¯¤«¤É¤¦¤« + + °ú¿ô: + ch(WCHAR_T): Ä´¤Ù¤ëÂоݤÎʸ»ú + + ÊÖ¤êÃÍ: + 0: ÉÕ¤«¤Ê¤¤ + 1: ¡Ö¤¦¡× + 2: Âù²»¤À¤±¤¬ÉÕ¤¯ + 3: ȾÂù²»¤ÈÂù²»¤¬ÉÕ¤¯ + */ + +#define GROW_U 1 +#define GROW_FV 2 +#define GROW_HV 3 + +static +growDakuonP(WCHAR_T ch) +{ + /* ÂùÅÀ¤¬Â³¤¯²ÄǽÀ­¤¬¤¢¤ëʸ»ú¤Î½èÍý (¤¦¡¢¤«¡Á¤È¡¢¤Ï¡Á¤Û) */ + static dakuon_first_time = 1; + static WCHAR_T wu, wka, wto, wha, who; + + if (dakuon_first_time) { /* ÆüËܸì¸ÇÍ­¤Î½èÍý */ + WCHAR_T buf[2]; + + dakuon_first_time = 0; + + MBstowcs(buf, "\216\263"/* ¥¦ */, 2); + wu = buf[0]; + MBstowcs(buf, "\216\266"/* ¥« */, 2); + wka = buf[0]; + MBstowcs(buf, "\216\304"/* ¥È */, 2); + wto = buf[0]; + MBstowcs(buf, "\216\312"/* ¥Ï */, 2); + wha = buf[0]; + MBstowcs(buf, "\216\316"/* ¥Û */, 2); + who = buf[0]; + } + + if (ch == wu) { + return GROW_U; + } + else if (wka <= ch && ch <= wto) { + return GROW_FV; + } + else if (wha <= ch && ch <= who) { + return GROW_HV; + } + else { + return 0; + } +} + +static +KanaYomiInsert(uiContext d) +{ + static WCHAR_T kana[3], *kanap; + WCHAR_T buf1[KANAYOMIINSERT_BUFLEN], buf2[KANAYOMIINSERT_BUFLEN]; + /* The array above is not so big (10 WCHAR_T length) 1996.6.5 kon */ + WCHAR_T *bufp, *nextbufp; + int len, replacelen, spos; + yomiContext yc = (yomiContext)d->modec; + int dakuon, grow_dakuon; + + yc->generalFlags &= ~CANNA_YOMI_BREAK_ROMAN; + kana[0] = (WCHAR_T)0; + kana[1] = d->buffer_return[0]; + kana[2] = (WCHAR_T)0; + kanap = kana + 1; + replacelen = 0; len = 1; + romajiReplace(0, kanap, 1, SENTOU); + yc->rStartp = yc->rCurs; + if ((dakuon = dakuonP(kanap[0])) != 0) { /* ÂùÅÀ¤Î½èÍý */ + if (yc->rCurs > 1) { + kana[0] = yc->romaji_buffer[yc->rCurs - 2]; + if ((grow_dakuon = growDakuonP(kana[0])) == GROW_HV || + (grow_dakuon && dakuon == DAKUON_FV)) { + kanap = kana; len = 2; replacelen = -1; + yc->rAttr[yc->rCurs - 1] &= ~SENTOU; + } + } + } +#ifdef DEBUG + if (iroha_debug) { + WCHAR_T aho[200]; + + WStrncpy(aho, kana, len); + aho[len] = 0; + fprintf(stderr, "\312\321\264\271\301\260(%s)", aho); + /* ÊÑ´¹Á° */ + } +#endif + bufp = kanap; nextbufp = buf1; + if (yc->generalFlags & CANNA_YOMI_ZENKAKU || + !(yc->generalFlags & (CANNA_YOMI_ROMAJI | CANNA_YOMI_HANKAKU))) { + len = RkwCvtZen(nextbufp, KANAYOMIINSERT_BUFLEN, bufp, len); + bufp = nextbufp; + if (bufp == buf1) { + nextbufp = buf2; + } + else { + nextbufp = buf1; + } + } + if (!(yc->generalFlags & (CANNA_YOMI_ROMAJI | CANNA_YOMI_KATAKANA))) { + /* ¤Ò¤é¤¬¤Ê¤Ë¤¹¤ë */ + len = RkwCvtHira(nextbufp, KANAYOMIINSERT_BUFLEN, bufp, len); + bufp = nextbufp; + if (bufp == buf1) { + nextbufp = buf2; + } + else { + nextbufp = buf1; + } + } + + spos = yc->kCurs + replacelen; + kanaReplace(replacelen, bufp, len, HENKANSUMI); + yc->kAttr[spos] |= SENTOU; + + yc->kRStartp = yc->kCurs; + yc->rStartp = yc->rCurs; + if (growDakuonP(yc->romaji_buffer[yc->rCurs - 1])) { + yc->kRStartp--; + yc->rStartp--; + } + + if (yc->generalFlags & CANNA_YOMI_KAKUTEI) { /* ³ÎÄê¥â¡¼¥É¤Ê¤é */ + int off, i; + + for (i = len = 0 ; i < yc->kRStartp ; i++) { + if (yc->kAttr[i] & SENTOU) { + do { + len++; + } while (!(yc->rAttr[len] & SENTOU)); + } + } + + if (yc->kRStartp < d->n_buffer) { + WStrncpy(d->buffer_return, yc->kana_buffer, yc->kRStartp); + d->nbytes = yc->kRStartp; + } + else { + d->nbytes = 0; + } + off = yc->kCurs - yc->kRStartp; + yc->kCurs -= off; + kanaReplace(-yc->kCurs, (WCHAR_T *)0, 0, 0); + yc->kCurs += off; + off = yc->rCurs - len; + yc->rCurs -= off; + romajiReplace(-yc->rCurs, (WCHAR_T *)0, 0, 0); + yc->rCurs += off; + } + else { + d->nbytes = 0; + } + + if (yc->rStartp == yc->rCurs && yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE && + ChikujiSubstYomi(d) == -1) { + makeRkError(d, "\303\340\274\241\312\321\264\271\244\313\274\272\307\324" + "\244\267\244\336\244\267\244\277"); + /* Ã༡ÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return 0; + } + + makeYomiReturnStruct(d); + + if (yc->kEndp <= yc->cStartp && + !((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && yc->nbunsetsu)) { + if (yc->left || yc->right) { + removeCurrentBunsetsu(d, (tanContext)yc); + } + else { + /* ̤³ÎÄêʸ»úÎó¤¬Á´¤¯¤Ê¤¯¤Ê¤Ã¤¿¤Î¤Ê¤é¡¢¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + currentModeInfo(d); + } + + return d->nbytes; +} + +#undef KANAYOMIINSERT_BUFLEN + +void +moveStrings(WCHAR_T *str, BYTE *attr, int start, int end, int distance) +{ + int i; + + if (distance > 0) { /* ¸å¤í¤Ë¤º¤ì¤ì¤Ð */ + for (i = end ; start <= i ; i--) { /* ¸å¤í¤«¤é¤º¤é¤¹ */ + str[i + distance] = str[i]; + attr[i + distance] = attr[i]; + } + } + else if (distance < 0) { /* Á°¤Ë¤º¤ì¤ì¤Ð */ + for (i = start ; i <= end ; i++) { /* Á°¤«¤é¤º¤é¤¹ */ + str[i + distance] = str[i]; + attr[i + distance] = attr[i]; + } + } + /* else { ¤Ê¤Ë¤â¤·¤Ê¤¤ } */ +} + +static +howFarToGoBackward(yomiContext yc) +{ + if (yc->kCurs <= yc->cStartp) { + return 0; + } + if (!cannaconf.ChBasedMove) { + BYTE *st = yc->kAttr; + BYTE *cur = yc->kAttr + yc->kCurs; + BYTE *p = cur; + + for (--p ; p > st && !(*p & SENTOU) ;) { + --p; + } + if (yc->kAttr + yc->cStartp > p) { + p = yc->kAttr + yc->cStartp; + } + return cur - p; + } + return 1; +} + +static +howFarToGoForward(yomiContext yc) +{ + if (yc->kCurs == yc->kEndp) { + return 0; + } + if (!cannaconf.ChBasedMove) { + BYTE *end = yc->kAttr + yc->kEndp; + BYTE *cur = yc->kAttr + yc->kCurs; + BYTE *p = cur; + + for (++p ; p < end && !(*p & SENTOU) ;) { + p++; + } + return p - cur; + } + return 1; +} + + +static int +YomiBackward(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int howManyMove; + + d->nbytes = 0; + if (forceRomajiFlushYomi(d)) + return(d->nbytes); + + if ((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && + !(yc->status & CHIKUJI_OVERWRAP) && yc->nbunsetsu) { + /* ¥ª¡¼¥Ð¥é¥Ã¥×¤¸¤ã¤Ê¤¤¤Ê¤é */ + yc->status |= CHIKUJI_OVERWRAP; + moveToChikujiTanMode(d); + return TanBackwardBunsetsu(d); + } + + howManyMove = howFarToGoBackward(yc); + if (howManyMove) { + yc->kCurs -= howManyMove; + + if (yc->kCurs < yc->kRStartp) + yc->kRStartp = yc->kCurs; /* ̤³ÎÄê¥í¡¼¥Þ»ú¥«¡¼¥½¥ë¤â¤º¤é¤¹ */ + + /* ¤«¤Ê¤Î¥Ý¥¤¥ó¥¿¤¬ÊÑ´¹¤µ¤ì¤¿¤È¤­¤ÎÅÓÃæ¤Î¥Ç¡¼¥¿¤Ç¤Ê¤¤¾ì¹ç + (¤Ä¤Þ¤êÊÑ´¹¤Î»þ¤ËÀèÆ¬¤Î¥Ç¡¼¥¿¤À¤Ã¤¿¾ì¹ç)¤Ë¤Ï¥í¡¼¥Þ»ú¤Î + ¥«¡¼¥½¥ë¤â¤º¤é¤¹ */ + + if (yc->kAttr[yc->kCurs] & SENTOU) { + while ( yc->rCurs > 0 && !(yc->rAttr[--yc->rCurs] & SENTOU) ) + /* EMPTY */ + ; + if (yc->rCurs < yc->rStartp) + yc->rStartp = yc->rCurs; + } + } + else if (yc->nbunsetsu) { /* ʸÀ᤬¤¢¤ë¤Ê¤é(Ã༡) */ + yc->curbun = yc->nbunsetsu - 1; + if (RkwGoTo(yc->context, yc->nbunsetsu - 1) == -1) { /* ºÇ¸åÈøÊ¸Àá¤Ø */ + return makeRkError(d, "\312\270\300\341\244\316\260\334\306\260\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + yc->kouhoCount = 0; + moveToChikujiTanMode(d); + } + else if (yc->left) { + return TbBackward(d); + } + else if (!cannaconf.CursorWrap) { + return NothingChanged(d); + } + else if (yc->right) { + return TbEndOfLine(d); + } + else { + yc->kCurs = yc->kRStartp = yc->kEndp; + yc->rCurs = yc->rStartp = yc->rEndp; + } + yc->status |= CHIKUJI_OVERWRAP; + makeYomiReturnStruct(d); + + return 0; +} + +static +YomiNop(uiContext d) +{ + /* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */ + d->majorMode = d->minorMode = CANNA_MODE_AlphaMode; + currentModeInfo(d); + makeYomiReturnStruct(d); + return 0; +} + +static +YomiForward(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int howManyMove; + + d->nbytes = 0; + if (forceRomajiFlushYomi(d)) + return(d->nbytes); + + if ((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && + !(yc->status & CHIKUJI_OVERWRAP) && yc->nbunsetsu) { + yc->status |= CHIKUJI_OVERWRAP; + moveToChikujiTanMode(d); + return TanForwardBunsetsu(d); + } + + howManyMove = howFarToGoForward(yc); + if (howManyMove) { + if (yc->kAttr[yc->kCurs] & SENTOU) { /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹»þÀèÆ¬¤À¤Ã¤¿ */ + while ( !yc->rAttr[++yc->rCurs] ) + /* EMPTY */ + ; /* ¼¡¤ÎÀèÆ¬¤Þ¤Ç¤º¤é¤¹ */ + yc->rStartp = yc->rCurs; + } + + yc->kCurs += howManyMove; /* ²èÌÌ¤ÎÆþÎϰÌÃÖ ¥«¡¼¥½¥ë¤ò±¦¤Ë¤º¤é¤¹ */ + yc->kRStartp = yc->kCurs; + yc->status &= ~CHIKUJI_ON_BUNSETSU; + } + else if (yc->right) { + return TbForward(d); + } + else if (!cannaconf.CursorWrap) { + return NothingChanged(d); + } + else if (yc->left) { + return TbBeginningOfLine(d); + } + else if (yc->nbunsetsu) { /* ʸÀ᤬¤¢¤ë(Ã༡) */ + yc->kouhoCount = 0; + yc->curbun = 0; + if (RkwGoTo(yc->context, 0) == -1) { + return makeRkError(d, "\312\270\300\341\244\316\260\334\306\260\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + moveToChikujiTanMode(d); + } + else { + yc->kRStartp = yc->kCurs = yc->rStartp = yc->rCurs = 0; + } + + yc->status |= CHIKUJI_OVERWRAP; + makeYomiReturnStruct(d); + return 0; +} + +static YomiBeginningOfLine (uiContext); + +static +YomiBeginningOfLine(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + d->nbytes = 0; + if (forceRomajiFlushYomi(d)) + return(d->nbytes); + + if (yc->left) { + return TbBeginningOfLine(d); + } + else if (yc->nbunsetsu) { /* Ã༡¤Çº¸Â¦¤ËʸÀ᤬¤¢¤ë¤Ê¤é */ + yc->kouhoCount = 0; + if (RkwGoTo(yc->context, 0) < 0) { + return makeRkError(d, "\312\270\300\341\244\316\260\334\306\260\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + yc->curbun = 0; + moveToChikujiTanMode(d); + } + else { + yc->kRStartp = yc->kCurs = yc->cStartp; + yc->rStartp = yc->rCurs = yc->cRStartp; + } + yc->status |= CHIKUJI_OVERWRAP; + makeYomiReturnStruct(d); + return(0); +} + + +static +YomiEndOfLine(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + d->nbytes = 0; + if (forceRomajiFlushYomi(d)) + return(d->nbytes); + + if (yc->right) { + return TbEndOfLine(d); + } + else { + yc->kRStartp = yc-> kCurs = yc->kEndp; + yc->rStartp = yc-> rCurs = yc->rEndp; + yc->status &= ~CHIKUJI_ON_BUNSETSU; + yc->status |= CHIKUJI_OVERWRAP; + } + makeYomiReturnStruct(d); + return 0; +} + +int +forceRomajiFlushYomi(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->kCurs != yc->kRStartp) { + d->nbytes = 0; + if (RomajiFlushYomi(d, (WCHAR_T *)NULL, 0) == 0) { /* empty mode */ + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = 0; /* ¾å¤Î ch ¤Ç¼¨¤µ¤ì¤ë½èÍý¤ò¤»¤è */ + return(1); + } + } + return(0); +} + +/* RomajiFlushYomi(d, buffer, bufsize) ¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô + * + * ¤³¤Î´Ø¿ô¤Ï¡¢(uiContext)d ¤ËÃߤ¨¤é¤ì¤Æ¤¤¤ëÆÉ¤ß¤Î¾ðÊó + * (yc->romaji_buffer ¤È yc->kana_buffer)¤òÍѤ¤¤Æ¡¢buffer ¤Ë¤½¤ÎÆÉ¤ß¤ò¥Õ + * ¥é¥Ã¥·¥å¤·¤¿·ë²Ì¤òÊÖ¤¹´Ø¿ô¤Ç¤¢¤ë¡£¥Õ¥é¥Ã¥·¥å¤·¤¿·ë²Ì¤Îʸ»úÎó¤ÎŤµ + * ¤Ï¤³¤Î´Ø¿ô¤ÎÊÖ¤êÃͤȤ·¤ÆÊÖ¤µ¤ì¤ë¡£ + * + * buffer ¤È¤·¤Æ NULL ¤¬»ØÄꤵ¤ì¤¿»þ¤Ï¡¢¥Ð¥Ã¥Õ¥¡¤ËÂФ¹¤ë³ÊǼ¤Ï¹Ô¤ï¤Ê¤¤ + * + * ¡ÚºîÍÑ¡Û + * + * ÆÉ¤ß¤ò³ÎÄꤹ¤ë + * + * ¡Ú°ú¿ô¡Û + * + * d (uiContext) ¥«¥Ê´Á»úÊÑ´¹¹½Â¤ÂÎ + * buffer (char *) ÆÉ¤ß¤òÊÖ¤¹¤¿¤á¤Î¥Ð¥Ã¥Õ¥¡ (NULL ²Ä) + * + * ¡ÚÌá¤êÃÍ¡Û + * + * buffer ¤Ë³ÊǼ¤·¤¿Ê¸»úÎó¤ÎŤµ(¥Ð¥¤¥ÈĹ) + * + * ¡ÚÉûºîÍÑ¡Û + * + */ + +RomajiFlushYomi(uiContext d, WCHAR_T *b, int bsize) +{ + int ret; + yomiContext yc = (yomiContext)d->modec; + + yc->generalFlags &= ~CANNA_YOMI_BREAK_ROMAN; + + makePhonoOnBuffer(d, yc, (unsigned char)0, RK_FLUSH, 0); + yc->n_susp_chars = 0; /* ¾å¤Î¹Ô¤ÇÊݾڤµ¤ì¤ë¤«¤âÃΤì¤Ê¤¤ */ + yc->last_rule = 0; + + ret = yc->kEndp - yc->cStartp; /* ¤½¤Î·ë²Ì¤¬¤³¤Î´Ø¿ô¤ÎÊÖ¤êÃͤˤʤë */ + if (b) { + if (bsize > ret) { + WStrncpy(b, yc->kana_buffer + yc->cStartp, ret); + b[ret] = '\0'; + } + else { + WStrncpy(b, yc->kana_buffer + yc->cStartp, bsize); + ret = bsize; + } + } + if (ret == 0) { /* ÆÉ¤ß¤¬Ìµ¤¯¤Ê¤Ã¤¿¤Î¤Ê¤é¥¨¥ó¥×¥Æ¥£¥â¡¼¥É¤Ø */ + d->current_mode = yc->curMode = yc->myEmptyMode; + /* ¤â¤Ã¤È¤¤¤í¤¤¤í¥¯¥ê¥¢¤·¤¿Êý¤¬Îɤ¤¤ó¤¸¤ã¤Ê¤¤¤Î */ + } + return ret; +} + +inline int +saveFlags(yomiContext yc) +{ + if (!(yc->savedFlags & CANNA_YOMI_MODE_SAVED)) { + yc->savedFlags = (yc->generalFlags & + (CANNA_YOMI_ATTRFUNCS | CANNA_YOMI_BASE_HANKAKU)) | + CANNA_YOMI_MODE_SAVED; + yc->savedMinorMode = yc->minorMode; + return 1; + } + else { + return 0; + } +} + +void +restoreFlags(yomiContext yc) +{ + yc->generalFlags &= ~(CANNA_YOMI_ATTRFUNCS | CANNA_YOMI_BASE_HANKAKU); + yc->generalFlags |= yc->savedFlags + & (CANNA_YOMI_ATTRFUNCS | CANNA_YOMI_BASE_HANKAKU); + yc->savedFlags = (long)0; + yc->minorMode = yc->savedMinorMode; +} + +/* + doYomiKakutei -- ÆÉ¤ß¤ò³ÎÄꤵ¤»¤ëưºî¤ò¤¹¤ë¡£ + + retval 0 -- ÌäÂê̵¤¯³ÎÄꤷ¤¿¡£ + 1 -- ³ÎÄꤷ¤¿¤é¤Ê¤¯¤Ê¤Ã¤¿¡£ + -1 -- ¥¨¥é¡¼¡© + */ + +inline int +doYomiKakutei(uiContext d) +{ + int len; + + len = RomajiFlushYomi(d, (WCHAR_T *)0, 0); + if (len == 0) { + return 1; + } + + return 0; +} + +int +xString(WCHAR_T *str, int len, WCHAR_T *s, WCHAR_T *e) +{ + if (e < s + len) { + len = e - s; + } + WStrncpy(s, str, len); + return len; +} + +inline int +xYomiKakuteiString(yomiContext yc, WCHAR_T *s, WCHAR_T *e) +{ + return xString(yc->kana_buffer + yc->cStartp, yc->kEndp - yc->cStartp, s, e); +} + +inline int +xYomiYomi(yomiContext yc, WCHAR_T *s, WCHAR_T *e) +{ + return xString(yc->kana_buffer, yc->kEndp, s, e); +} + +inline int +xYomiRomaji(yomiContext yc, WCHAR_T *s, WCHAR_T *e) +{ + return xString(yc->romaji_buffer, yc->rEndp, s, e); +} + +inline void +finishYomiKakutei(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + } +} + +int +appendTan2Yomi(tanContext tan, yomiContext yc) +{ + int klen, rlen; + + klen = WStrlen(tan->yomi); + rlen = WStrlen(tan->roma); + + if (yc->kEndp + klen < ROMEBUFSIZE && yc->rEndp + rlen < ROMEBUFSIZE) { + WStrcpy(yc->kana_buffer + yc->kEndp, tan->yomi); + WStrcpy(yc->romaji_buffer + yc->rEndp, tan->roma); + bcopy(tan->kAttr, yc->kAttr + yc->kEndp, (klen + 1) * sizeof(BYTE)); + bcopy(tan->rAttr, yc->rAttr + yc->rEndp, (rlen + 1) * sizeof(BYTE)); + yc->rEndp += rlen; + yc->kEndp += klen; + return 1; + } + return 0; +} + +static +appendYomi2Yomi(yomiContext yom, yomiContext yc) +{ + int rlen, klen; + + rlen = yom->rEndp; + klen = yom->kEndp; + if (yc->kEndp + klen < ROMEBUFSIZE && yc->rEndp + rlen < ROMEBUFSIZE) { + yom->romaji_buffer[rlen] = (WCHAR_T)'\0'; + yom->kana_buffer[klen] = (WCHAR_T)'\0'; + WStrcpy(yc->romaji_buffer + yc->rEndp, yom->romaji_buffer); + WStrcpy(yc->kana_buffer + yc->kEndp, yom->kana_buffer); + bcopy(yom->kAttr, yc->kAttr + yc->kEndp, (klen + 1) * sizeof(BYTE)); + bcopy(yom->rAttr, yc->rAttr + yc->rEndp, (rlen + 1) * sizeof(BYTE)); + yc->rEndp += rlen; + yc->kEndp += klen; + return 1; + } + return 0; +} + +yomiContext +dupYomiContext(yomiContext yc) +{ + yomiContext res; + + res = newYomiContext((WCHAR_T *)NULL, 0, /* ·ë²Ì¤Ï³ÊǼ¤·¤Ê¤¤ */ + CANNA_NOTHING_RESTRICTED, + (int)!CANNA_YOMI_CHGMODE_INHIBITTED, + (int)!CANNA_YOMI_END_IF_KAKUTEI, + CANNA_YOMI_INHIBIT_NONE); + if (res) { + res->generalFlags = yc->generalFlags; + res->status = yc->status; + res->majorMode = yc->majorMode; + res->minorMode = yc->minorMode; + res->myMinorMode = yc->myMinorMode; + res->curMode = yc->curMode; + res->myEmptyMode = yc->myEmptyMode; + res->romdic = yc->romdic; + res->next = yc->next; + res->prevMode = yc->prevMode; + appendYomi2Yomi(yc, res); + } + return res; +} + + +/* + doMuhenkan -- ̵ÊÑ´¹½èÍý¤ò¤¹¤ë¡£ + + yc ¤«¤é±¦¤Î tanContext/yomiContext ¤ò¥Ü¥Ä¤Ë¤·¤Æ¡¢¤½¤Î¤Ê¤«¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤¿ + ÆÉ¤ß¤ò yc ¤Ë¤¯¤Ã¤Ä¤±¤ë¡£ + */ + +void +doMuhenkan(uiContext d, yomiContext yc) +{ + tanContext tan, netan, st = (tanContext)yc; + yomiContext yom; + + /* ¤Þ¤ºÌµÊÑ´¹½àÈ÷½èÍý¤ò¤¹¤ë */ + for (tan = st ; tan ; tan = tan->right) { + if (tan->id == YOMI_CONTEXT) { + yom = (yomiContext)tan; + d->modec = (mode_context)yom; + if (yom->nbunsetsu || (yom->generalFlags & CANNA_YOMI_CHIKUJI_MODE)) { + tanMuhenkan(d, -1); + } + if (yom->jishu_kEndp) { + leaveJishuMode(d, yom); + } + /* else ÆÉ¤ß¥â¡¼¥É¤Ç¤Ï¤Ê¤Ë¤â¤¹¤ëɬÍפ¬¤Ê¤¤¡£ */ + } + } + + /* ¼¡¤ËÆÉ¤ß¤Ê¤É¤Îʸ»ú¤ò¼è¤ê½Ð¤¹ */ + for (tan = st ; tan ; tan = netan) { + netan = tan->right; + if (tan->id == TAN_CONTEXT) { + appendTan2Yomi(tan, yc); + freeTanContext(tan); + } + else if (tan->id == YOMI_CONTEXT) { + if ((yomiContext)tan != yc) { + appendYomi2Yomi((yomiContext)tan, yc); + freeYomiContext((yomiContext)tan); + } + } + } + yc->rCurs = yc->rStartp = yc->rEndp; + yc->kCurs = yc->kRStartp = yc->kEndp; + yc->right = (tanContext)0; + d->modec = (mode_context)yc; +} + +inline int +xTanKakuteiString(yomiContext yc, WCHAR_T *s, WCHAR_T *e) +{ + WCHAR_T *ss = s; + int i, len, nbun; + + nbun = yc->bunlen ? yc->curbun : yc->nbunsetsu; + + for (i = 0 ; i < nbun ; i++) { + RkwGoTo(yc->context, i); + len = RkwGetKanji(yc->context, s, (int)(e - s)); + if (len < 0) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\245\253\245\354\245\363\245\310\270\365\312\344\244\362" + "\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307" + "\244\267\244\277"; + /* ¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + } + else { + s += len; + } + } + RkwGoTo(yc->context, yc->curbun); + + if (yc->bunlen) { + len = yc->kEndp - yc->kanjilen; + if (((int)(e - s)) < len) { + len = (int)(e - s); + } + WStrncpy(s, yc->kana_buffer + yc->kanjilen, len); + s += len; + } + + if ((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && + yc->cStartp < yc->kEndp) { + len = xYomiKakuteiString(yc, s, e); + s += len; + } + return (int)(s - ss); +} + +inline int +doJishuKakutei(uiContext d, yomiContext yc) +{ + exitJishu(d); + yc->jishu_kEndp = 0; + return 0; +} + + +/* + doKakutei -- ³ÎÄê½èÍý¤ò¤¹¤ë¡£ + + st ¤«¤é et ¤ÎľÁ°¤Þ¤Ç¤Î tanContext/yomiContext ¤ò³ÎÄꤵ¤»¤ë + s ¤«¤é e ¤ÎÈϰϤ˳ÎÄê·ë²Ì¤¬³ÊǼ¤µ¤ì¤ë¡£ + yc_return ¤Ï yomiContext ¤ò°ì¤Ä»Ä¤·¤ÆÍߤ·¤¤¾ì¹ç¤Ë¡¢»Ä¤Ã¤¿ yomiContext + ¤ò³ÊǼ¤·¤ÆÊÖ¤¹¤¿¤á¤Î¥¢¥É¥ì¥¹¡£yc_return ¤¬¥Ì¥ë¤Ê¤é¡¢²¿¤â»Ä¤µ¤º free + ¤¹¤ë¡£ + et->left ¤Ï¸Æ¤Ó½Ð¤·¤¿¤È¤³¤í¤Ç 0 ¤Ë¤¹¤ë¤³¤È¡£ + + ³ÎÄꤷ¤¿Ê¸»ú¤ÎŤµ¤¬ÊÖ¤µ¤ì¤ë¡£ + + ¤³¤Î´Ø¿ô¤ò¸Æ¤ó¤À¤é d->modec ¤¬²õ¤ì¤Æ¤¤¤ë¤Î¤ÇÆþ¤ìľ¤µ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ + + */ + +int +doKakutei(uiContext d, tanContext st, tanContext et, WCHAR_T *s, WCHAR_T *e, yomiContext *yc_return) +{ + tanContext tan, netan; + yomiContext yc; + int len, res; + WCHAR_T *ss = s; + int katakanadef = 0, hiraganadef = 0; + extern int auto_define; +#ifndef WIN + WCHAR_T ytmpbuf[256]; +#else + WCHAR_T *ytmpbuf = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 256); + if (!ytmpbuf) { + return 0; + } +#endif + + /* ¤Þ¤º³ÎÄê½àÈ÷½èÍý¤ò¤¹¤ë */ + for (tan = st ; tan != et ; tan = tan->right) { + if (tan->id == YOMI_CONTEXT) { + yc = (yomiContext)tan; + d->modec = (mode_context)yc; + if (yc->jishu_kEndp) { + if (auto_define) { + if (yc->jishu_kc == JISHU_ZEN_KATA) + katakanadef = 1; +#ifdef HIRAGANAAUTO + if (yc->jishu_kc == JISHU_HIRA) + hiraganadef = 1; +#endif + WStrcpy(ytmpbuf, yc->kana_buffer); + } + doJishuKakutei(d, yc); + } + else if (!yc->bunlen && /* ʸÀá¿­¤Ð¤·½Ì¤áÃæ */ + (!yc->nbunsetsu || /* ´Á»ú¤¬¤Ê¤¤¤«... */ + (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE && + yc->cStartp < yc->kEndp))) { /* ÆÉ¤ß¤¬¤Þ¤À¤¢¤ë .. */ + long savedFlag = yc->generalFlags; + yc->generalFlags &= ~CANNA_YOMI_KAKUTEI; + /* base-kakutei ¤À¤È doYomiKakutei() ¤¬¸Æ¤Ó½Ð¤·¤Æ¤¤¤ë + RomajiFlushYomi() ¤ÎÃæ¤Ç³ÎÄêʸ»úÎó¤¬È¯À¸¤·¡¢ + ½èÍý¤¬ÌÌÅݤˤʤë¤Î¤Ç¤È¤ê¤¢¤¨¤º base-kakutei ¤ò¿²¤»¤ë */ + doYomiKakutei(d); + yc->generalFlags = savedFlag; + } + } + } + + /* ¼¡¤Ë³ÎÄêʸ»ú¤ò¼è¤ê½Ð¤¹ */ + for (tan = st ; tan != et ; tan = tan->right) { + if (tan->id == TAN_CONTEXT) { + len = extractTanString(tan, s, e); + } + else if (tan->id == YOMI_CONTEXT) { + yc = (yomiContext)tan; + d->modec = (mode_context)yc; + if (yc->nbunsetsu || (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE)) { + len = xTanKakuteiString(yc, s, e); + }else{ /* else ¤Ã¤Æ¤³¤È¤Ï¡¢ÆÉ¤ß¾õÂÖ¤·¤«¤Ê¤¤ */ + len = xYomiKakuteiString(yc, s, e); + } + } + s += len; + } + res = (int)(s - ss); + if (s < e) { + *s++ = (WCHAR_T)'\0'; + } + + /* yomiInfo ¤Î½èÍý¤ò¤¹¤ë */ + if (yomiInfoLevel > 0) { + d->kanji_status_return->info |= KanjiYomiInfo; + for (tan = st ; tan != et ; tan = tan->right) { + if (tan->id == TAN_CONTEXT) { + len = extractTanYomi(tan, s, e); + } + else if (tan->id == YOMI_CONTEXT) { + len = xYomiYomi((yomiContext)tan, s, e); + } + s += len; + } + if (s < e) { + *s++ = (WCHAR_T)'\0'; + } + + if (yomiInfoLevel > 1) { + for (tan = st ; tan != et ; tan = tan->right) { + if (tan->id == TAN_CONTEXT) { + len = extractTanRomaji(tan, s, e); + } + else if (tan->id == YOMI_CONTEXT) { + len = xYomiRomaji((yomiContext)tan, s, e); + } + s += len; + } + } + if (s < e) { + *s++ = (WCHAR_T)'\0'; + } + } + + /* ³ÎÄê¤Î»Ä½èÍý¤ò¹Ô¤¦ */ + if (yc_return) { + *yc_return = (yomiContext)0; + } + for (tan = st ; tan != et ; tan = netan) { + netan = tan->right; + if (tan->id == TAN_CONTEXT) { + freeTanContext(tan); + } + else { /* tan->id == YOMI_CONTEXT */ + yc = (yomiContext)tan; + d->modec = (mode_context)yc; + + if (yc->nbunsetsu || (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE)) { + if (yc->bunlen) { + leaveAdjustMode(d, yc); + } + finishTanKakutei(d); + }else{ /* ¤Ã¤Æ¤³¤È¤Ï¡¢ÆÉ¤ß¾õÂÖ¤·¤«¤Ê¤¤ */ + finishYomiKakutei(d); + } + if (yc_return && !*yc_return) { + *yc_return = yc; + }else{ + /* ¤È¤Ã¤Æ¤ª¤¯¤ä¤Ä¤¬¤â¤¦¤¢¤ë¤«¡¢¤¤¤é¤Ê¤¤¤Ê¤é¡¢º£¤Î¤Ï¼Î¤Æ¤ë */ + /* yc->context ¤Î close ¤Ï¤¤¤é¤Ê¤¤¤Î¤«¤Ê¤¢¡£1996.10.30 º£ */ + freeYomiContext(yc); + } + } + } + + if (yc_return) { + yc = *yc_return; + if (yc) { + yc->left = yc->right = (tanContext)0; + } + } + d->modec = (mode_context)0; + /* ²õ¤ì¤Æ¤¤¤ë¤«¤âÃΤì¤Ê¤¤¤Î¤Ç»È¤¤´Ö°ã¤ï¤Ê¤¤¤è¤¦¤Ë²õ¤·¿Ô¤¯¤·¤Æ¤ª¤¯ */ + + /* »ú¼ïÊÑ´¹¤ÇÁ´³Ñ¥«¥¿¥«¥Ê¤ò³ÎÄꤷ¤¿¤é¡¢¼«Æ°ÅÐÏ¿¤¹¤ë */ + if (katakanadef || hiraganadef) { + WCHAR_T line[ROMEBUFSIZE]; + int cnt; + extern int defaultContext; + extern char *kataautodic; +#ifdef HIRAGANAAUTO + extern char *hiraautodic; +#endif + + WStraddbcpy(line, ytmpbuf, ROMEBUFSIZE); + EWStrcat(line, " "); + EWStrcat(line, "#T30"); + EWStrcat(line, " "); + cnt = WStrlen(line); + WStraddbcpy(line + cnt, ss, ROMEBUFSIZE - cnt); + + if (defaultContext == -1) { + if ((KanjiInit() < 0) || (defaultContext == -1)) { + jrKanjiError = KanjiInitError(); + makeGLineMessageFromString(d, jrKanjiError); + goto return_res; + } + } + + if (katakanadef) { + if (RkwDefineDic(defaultContext, kataautodic, line) != 0) { + jrKanjiError = "\274\253\306\260\305\320\317\277\244\307\244\255" + "\244\336\244\273\244\363\244\307\244\267\244\277"; + /* ¼«Æ°ÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + makeGLineMessageFromString(d, jrKanjiError); + }else{ + if (cannaconf.auto_sync) { + (void)RkwSync(defaultContext, kataautodic); + } + } + } + if (hiraganadef) { +#ifdef HIRAGANAAUTO + if (RkwDefineDic(defaultContext, hiraautodic, line) != 0) { + jrKanjiError = "\274\253\306\260\305\320\317\277\244\307\244\255" + "\244\336\244\273\244\363\244\307\244\267\244\277"; + /* ¼«Æ°ÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + makeGLineMessageFromString(d, jrKanjiError); + }else{ + if (cannaconf.auto_sync) { + (void)RkwSync(defaultContext, hiraautodic); + } + } +#endif + } + } + return_res: +#ifdef WIN + free(ytmpbuf); +#endif + return res; +} + +/* + cutOffLeftSide -- º¸¤ÎÊý¤Î tanContext ¤ò³ÎÄꤵ¤»¤ë¡£ + + n -- º¸¤Ë n ¸Ä»Ä¤·¤Æ³ÎÄꤹ¤ë¡£ + + */ + +int +cutOffLeftSide(uiContext d, yomiContext yc, int n) +{ + int i; + tanContext tan = (tanContext)yc, st; + + for (i = 0 ; i < n && tan ; i++) { + tan = tan->left; + } + if (tan && tan->left) { + st = tan->left; + while (st->left) { + st = st->left; + } + d->nbytes = doKakutei(d, st, tan, d->buffer_return, + d->buffer_return + d->n_buffer, (yomiContext *)0); + d->modec = (mode_context)yc; + tan->left = (tanContext)0; + return 1; + } + return 0; +} + +extern KanjiModeRec cy_mode; + +int YomiKakutei (uiContext); + +int +YomiKakutei(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + tanContext leftmost; + int len, res; + WCHAR_T *s = d->buffer_return, *e = s + d->n_buffer; + mode_context next = yc->next; + KanjiMode prev = yc->prevMode; + long prevflags; + + prevflags = (yc->id == YOMI_CONTEXT) ? + yc->generalFlags : ((tanContext)yc)->generalFlags; + + d->kanji_status_return->length = 0; + d->nbytes = 0; + + leftmost = (tanContext)yc; + while (leftmost->left) { + leftmost = leftmost->left; + } + + len = doKakutei(d, leftmost, (tanContext)0, s, e, &yc); + + if (!yc) { + yc = newFilledYomiContext(next, prev); + yc->generalFlags = prevflags; + yc->minorMode = getBaseMode(yc); + } + d->modec = (mode_context)yc; + if (!yc) { + freeRomeStruct(d); + return -1; /* ËÜÅö¤Ë¤³¤ì¤Ç¤¤¤¤¤Î¤«¡©¢ª¤¤¤¤ 1994.2.23 kon */ + } + d->current_mode = yc->curMode; + d->nbytes = len; + + res = YomiExit(d, d->nbytes); + currentModeInfo(d); + return res; +} + +/* Á´¤¯ 0 ¤Ë¤¹¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¤Î¤ÇÃí°Õ */ + +void +clearYomiContext(yomiContext yc) +{ + yc->rStartp = 0; + yc->rCurs = 0; + yc->rEndp = 0; + yc->romaji_buffer[0] = (WCHAR_T)0; + yc->rAttr[0] = SENTOU; + yc->kRStartp = 0; + yc->kCurs = 0; + yc->kEndp = 0; + yc->kana_buffer[0] = (WCHAR_T)0; + yc->kAttr[0] = SENTOU; + yc->pmark = yc->cmark = 0; + yc->englishtype = CANNA_ENG_KANA; + yc->cStartp = yc->cRStartp = 0; + yc->jishu_kEndp = 0; +} + +inline int +clearChikujiContext(yomiContext yc) +{ + clearYomiContext(yc); + yc->status &= CHIKUJI_NULL_STATUS; + yc->ys = yc->ye = yc->cStartp; + clearHenkanContext(yc); + return 0; +} + + +/* RomajiClearYomi(d) ¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô + * + * ¤³¤Î´Ø¿ô¤Ï¡¢(uiContext)d ¤ËÃߤ¨¤é¤ì¤Æ¤¤¤ëÆÉ¤ß¤Î¾ðÊó + * ¤ò¥¯¥ê¥¢¤¹¤ë¡£ + * + * ¡ÚºîÍÑ¡Û + * + * ÆÉ¤ß¤ò¥¯¥ê¥¢¤¹¤ë¡£ + * + * ¡Ú°ú¿ô¡Û + * + * d (uiContext) ¥«¥Ê´Á»úÊÑ´¹¹½Â¤ÂÎ + * + * ¡ÚÌá¤êÃÍ¡Û + * + * ¤Ê¤·¡£ + * + * ¡ÚÉûºîÍÑ¡Û + * + * yc->rEndp = 0; + * yc->kEndp = 0; Åù + */ + +void +RomajiClearYomi(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) { + if (yc->context >= 0) { + RkwEndBun(yc->context, 0); + abandonContext(d, yc); + } + clearChikujiContext(yc); + } + else { + clearYomiContext(yc); + } +} + +YomiExit(uiContext d, int retval) +{ + yomiContext yc = (yomiContext)d->modec; + + RomajiClearYomi(d); + + /* ³ÎÄꤷ¤Æ¤·¤Þ¤Ã¤¿¤é¡¢ÆÉ¤ß¤¬¤Ê¤¯¤Ê¤ë¤Î¤Ç¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë¡£ */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + + return checkIfYomiExit(d, retval); +} + +/* RomajiStoreYomi(d, kana) ¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô + * + * ¤³¤Î´Ø¿ô¤Ï¡¢(uiContext)d ¤ËÆÉ¤ß¤Î¾ðÊó¤ò¥¹¥È¥¢¤¹¤ë¡£ + * + * ¡ÚºîÍÑ¡Û + * + * ÆÉ¤ß¤ò³ÊǼ¤¹¤ë¡£ + * + * ¡Ú°ú¿ô¡Û + * + * d (uiContext) ¥«¥Ê´Á»úÊÑ´¹¹½Â¤ÂÎ + * kana (WCHAR_T *) ¤«¤Êʸ»úÎó + * roma (WCHAR_T *) ¥í¡¼¥Þ»úʸ»úÎó + * ¡ÚÌá¤êÃÍ¡Û + * + * ¤Ê¤·¡£ + * + * ¡ÚÉûºîÍÑ¡Û + * + * yc->rEndp = WStrlen(kana); + * yc->kEndp = WStrlen(kana); Åù + */ + +void +RomajiStoreYomi(uiContext d, WCHAR_T *kana, WCHAR_T *roma) +{ + int i, ylen, rlen, additionalflag; + yomiContext yc = (yomiContext)d->modec; + + rlen = ylen = WStrlen(kana); + if (roma) { + rlen = WStrlen(roma); + additionalflag = 0; + } + else { + additionalflag = SENTOU; + } + WStrcpy(yc->romaji_buffer, (roma ? roma : kana)); + yc->rStartp = rlen; + yc->rCurs = rlen; + yc->rEndp = rlen; + WStrcpy(yc->kana_buffer, kana); + yc->kRStartp = ylen; + yc->kCurs = ylen; + yc->kEndp = ylen; + for (i = 0 ; i < rlen ; i++) { + yc->rAttr[i] = additionalflag; + } + yc->rAttr[0] |= SENTOU; + yc->rAttr[i] = SENTOU; + for (i = 0 ; i < ylen ; i++) { + yc->kAttr[i] = HENKANSUMI | additionalflag; + } + yc->kAttr[0] |= SENTOU; + yc->kAttr[i] = SENTOU; +} + +/* + KanaDeletePrevious -- ¿§¡¹¤Ê¤È¤³¤í¤«¤é»È¤ï¤ì¤ë¡£ + +*/ + +KanaDeletePrevious(uiContext d) +{ + int howManyDelete; + int prevflag; + yomiContext yc = (yomiContext)d->modec; + + /* ¥«¡¼¥½¥ë¤Îº¸Â¦¤òºï½ü¤¹¤ë¤Î¤À¤¬¡¢¥«¡¼¥½¥ë¤Îº¸Â¦¤¬ + + (1) ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤ÎÅÓÃæ¤Î¾õÂ֤Ǥ¢¤ê¡¢¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Ë¤Ê¤Ã¤Æ¤¤¤ë»þ¡¢ + (2) ÀèÆ¬¤Ç¤¢¤ë¤È¤­ + + ¤Ê¤É¤¬¹Í¤¨¤é¤ì¤ë¡£(ÍפÏÀ°Íý¤µ¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¤â¤Ã¤È¤¢¤ê¤½¤¦) + */ + + if (!yc->kCurs) { /* º¸Ã¼¤Î¤È¤­ */ + d->kanji_status_return->length = -1; + return 0; + } + yc->last_rule = 0; + howManyDelete = howFarToGoBackward(yc); + if (howManyDelete > 0 && (yc->generalFlags & CANNA_YOMI_BREAK_ROMAN)) { + yc->generalFlags &= ~CANNA_YOMI_BREAK_ROMAN; + yc->rStartp = yc->rCurs - 1; + while ( yc->rStartp > 0 && !(yc->rAttr[yc->rStartp] & SENTOU) ) { + yc->rStartp--; + } + romajiReplace (-1, (WCHAR_T *)NULL, 0, 0); + yc->kRStartp = yc->kCurs - 1; + while ( yc->kRStartp > 0 && !(yc->kAttr[yc->kRStartp] & SENTOU) ) + yc->kRStartp--; + prevflag = (yc->kAttr[yc->kRStartp] & SENTOU); + kanaReplace(yc->kRStartp - yc->kCurs, + yc->romaji_buffer + yc->rStartp, + yc->rCurs - yc->rStartp, + 0); + yc->kAttr[yc->kRStartp] |= prevflag; + yc->n_susp_chars = 0; /* ¤È¤ê¤¢¤¨¤º¥¯¥ê¥¢¤·¤Æ¤ª¤¯ */ + makePhonoOnBuffer(d, yc, (unsigned char)0, 0, 0); + } + else { + if ( yc->kAttr[yc->kCurs - howManyDelete] & HENKANSUMI ) { + if (yc->kAttr[yc->kCurs - howManyDelete] & SENTOU) { + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤ÎÀèÆ¬¤À¤Ã¤¿¤é */ + if (yc->kAttr[yc->kCurs] & SENTOU) { + int n; + + /* ÀèÆ¬¤À¤Ã¤¿¤é¥í¡¼¥Þ»ú¤âÀèÆ¬¥Þ¡¼¥¯¤¬Î©¤Ã¤Æ¤¤¤ë¤È¤³¤í¤Þ¤ÇÌ᤹ */ + + for (n = 1 ; yc->rCurs > 0 && !(yc->rAttr[--yc->rCurs] & SENTOU) ;) { + n++; + } + moveStrings(yc->romaji_buffer, yc->rAttr, + yc->rCurs + n, yc->rEndp,-n); + if (yc->rCurs < yc->rStartp) { + yc->rStartp = yc->rCurs; + } + yc->rEndp -= n; + } + else { + yc->kAttr[yc->kCurs] |= SENTOU; + } + } + } + else { + romajiReplace(-howManyDelete, (WCHAR_T *)NULL, 0, 0); + } + kanaReplace(-howManyDelete, (WCHAR_T *)NULL, 0, 0); + } + debug_yomi(yc); + return(0); +} + + +static int +YomiDeletePrevious(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + KanaDeletePrevious(d); + if (!yc->kEndp) { + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + } + if (yc->left || yc->right) { + removeCurrentBunsetsu(d, (tanContext)yc); + yc = (yomiContext)0; + } + else { + /* ̤³ÎÄêʸ»úÎó¤¬Á´¤¯¤Ê¤¯¤Ê¤Ã¤¿¤Î¤Ê¤é¡¢¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + currentModeInfo(d); + } + else { + if (yc->kCurs != yc->kRStartp) { + ReCheckStartp(yc); + } + } + + if (yc) { + fitmarks(yc); + } + + makeYomiReturnStruct(d); + return 0; +} + +static YomiDeleteNext (uiContext); + +static int +YomiDeleteNext(uiContext d) +{ + int howManyDelete; + yomiContext yc = (yomiContext)d->modec; + + if (chikujip(yc) && (yc->status & CHIKUJI_ON_BUNSETSU)) { + return NothingChangedWithBeep(d); + } + + if (yc->kCurs == yc->kEndp) { + /* ±¦Ã¼¤À¤«¤é¤Ê¤Ë¤â¤·¤Ê¤¤¤Î¤Ç¤·¤ç¤¦¤Í¤§ */ + d->kanji_status_return->length = -1; + return 0; + } + + fitmarks(yc); + + yc->last_rule = 0; + howManyDelete = howFarToGoForward(yc); + + if (yc->kAttr[yc->kCurs] & SENTOU) { + if (yc->kAttr[yc->kCurs + howManyDelete] & SENTOU) { + int n = 1; + while ( !(yc->rAttr[++yc->rCurs] & SENTOU) ) + n++; + moveStrings(yc->romaji_buffer, yc->rAttr, yc->rCurs, yc->rEndp, -n); + yc->rCurs -= n; + yc->rEndp -= n; + } + else { + yc->kAttr[yc->kCurs + howManyDelete] |= SENTOU; + } + } + kanaReplace(howManyDelete, (WCHAR_T *)NULL, 0, 0); + /* ¤³¤³¤Þ¤Çºï½ü½èÍý */ + + if (yc->cStartp < yc->kEndp) { /* ÆÉ¤ß¤¬¤Þ¤À¤¢¤ë */ + if (yc->kCurs < yc->ys) { + yc->ys = yc->kCurs; /* ¤³¤ó¤Ê¤â¤ó¤Ç¤¤¤¤¤Î¤Ç¤·¤ç¤¦¤«¡© */ + } + } + else if (yc->nbunsetsu) { /* ÆÉ¤ß¤Ï¤Ê¤¤¤¬Ê¸Àá¤Ï¤¢¤ë */ + if (RkwGoTo(yc->context, yc->nbunsetsu - 1) == -1) { + return makeRkError(d, "\312\270\300\341\244\316\260\334\306\260\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + yc->kouhoCount = 0; + yc->curbun = yc->nbunsetsu - 1; + moveToChikujiTanMode(d); + } + else { /* ÆÉ¤ß¤âʸÀá¤â¤Ê¤¤ */ + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + } + if (yc->left || yc->right) { + removeCurrentBunsetsu(d, (tanContext)yc); + } + else { + /* ̤³ÎÄêʸ»úÎó¤¬Á´¤¯¤Ê¤¯¤Ê¤Ã¤¿¤Î¤Ê¤é¡¢¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + currentModeInfo(d); + } + makeYomiReturnStruct(d); + return 0; +} + +static YomiKillToEndOfLine (uiContext); + +static int +YomiKillToEndOfLine(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + romajiReplace (yc->rEndp - yc->rCurs, (WCHAR_T *)NULL, 0, 0); + kanaReplace (yc->kEndp - yc->kCurs, (WCHAR_T *)NULL, 0, 0); + + fitmarks(yc); + + if (!yc->kEndp) { + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + } + if (yc->left || yc->right) { + removeCurrentBunsetsu(d, (tanContext)yc); + } + else { + /* ̤³ÎÄêʸ»úÎó¤¬Á´¤¯¤Ê¤¯¤Ê¤Ã¤¿¤Î¤Ê¤é¡¢¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + currentModeInfo(d); + } + makeYomiReturnStruct(d); + return 0; +} + +static YomiQuit (uiContext); + +static int +YomiQuit(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + /* ̤³ÎÄêʸ»úÎó¤òºï½ü¤¹¤ë */ + RomajiClearYomi(d); + + if (yc->left || yc->right) { + removeCurrentBunsetsu(d, (tanContext)yc); + } + else { + /* ̤³ÎÄêʸ»úÎó¤¬Á´¤¯¤Ê¤¯¤Ê¤Ã¤¿¤Î¤Ç¡¢¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + } + makeYomiReturnStruct(d); + currentModeInfo(d); + return checkIfYomiQuit(d, 0); +} + +coreContext +newCoreContext(void) +{ + coreContext cc; + + cc = (coreContext)malloc(sizeof(coreContextRec)); + if (cc) { + cc->id = CORE_CONTEXT; + } + return cc; +} + +static +simplePopCallback(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); + currentModeInfo(d); + return retval; +} + +alphaMode(uiContext d) +{ + extern KanjiModeRec alpha_mode; + coreContext cc; + char *bad = "\245\341\245\342\245\352\244\254\302\255\244\352\244\336" + "\244\273\244\363"; + /* ¥á¥â¥ê¤¬Â­¤ê¤Þ¤»¤ó */ + + cc = newCoreContext(); + if (cc == (coreContext)0) { + makeGLineMessageFromString(d, bad); + return 0; + } + if (pushCallback(d, d->modec, + NO_CALLBACK, simplePopCallback, + simplePopCallback, NO_CALLBACK) == 0) { + freeCoreContext(cc); + makeGLineMessageFromString(d, bad); + return 0; + } + cc->prevMode = d->current_mode; + cc->next = d->modec; + cc->majorMode = + cc->minorMode = CANNA_MODE_AlphaMode; + d->current_mode = &alpha_mode; + d->modec = (mode_context)cc; + return 0; +} + +/* Quoted Insert Mode -- °úÍÑÆþÎϥ⡼¥É¡£ + + ¤³¤Î¥â¡¼¥É¤Ç¤Ï¼¡¤Î°ìʸ»ú¤ÏÈݱþ̵¤·¤Ë¤½¤Î¤Þ¤ÞÆþÎϤµ¤ì¤ë¡£ + + */ + +static exitYomiQuotedInsert (uiContext, int, mode_context); + +static +exitYomiQuotedInsert(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); + return retval; +} + +static +YomiInsertQuoted(uiContext d) +{ + unsigned char ch; + coreContext cc = (coreContext)d->modec; + yomiContext yc; + + ch = (unsigned char)*(d->buffer_return); + + if (IrohaFunctionKey(ch)) { + d->kanji_status_return->length = -1; + d->kanji_status_return->info = 0; + return 0; + } else { + d->current_mode = cc->prevMode; + d->modec = cc->next; + free(cc); + + yc = (yomiContext)d->modec; + + romajiReplace (0, d->buffer_return, d->nbytes, 0); + kanaReplace (0, d->buffer_return, d->nbytes, HENKANSUMI); + yc->rStartp = yc->rCurs; + yc->kRStartp = yc->kCurs; + makeYomiReturnStruct(d); + currentModeInfo(d); + d->status = EXIT_CALLBACK; + return 0; + } +} + +static yomiquotedfunc (uiContext, KanjiMode, int, int, int); + +static +yomiquotedfunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum) + /* ARGSUSED */ +{ + switch (whattodo) { + case KEY_CALL: + return YomiInsertQuoted(d); + case KEY_CHECK: + return 1; + case KEY_SET: + return 0; + } + /* NOTREACHED */ +} + +static KanjiModeRec yomi_quoted_insert_mode = { + yomiquotedfunc, + 0, 0, 0, +}; + +inline void +yomiQuotedInsertMode(uiContext d) +{ + coreContext cc; + + cc = newCoreContext(); + if (cc == 0) { + NothingChangedWithBeep(d); + return; + } + cc->prevMode = d->current_mode; + cc->next = d->modec; + cc->majorMode = d->majorMode; + cc->minorMode = CANNA_MODE_QuotedInsertMode; + if (pushCallback(d, d->modec, + NO_CALLBACK, exitYomiQuotedInsert, + NO_CALLBACK, NO_CALLBACK) == (struct callback *)0) { + freeCoreContext(cc); + NothingChangedWithBeep(d); + return; + } + d->modec = (mode_context)cc; + d->current_mode = &yomi_quoted_insert_mode; + currentModeInfo(d); + return; +} + +YomiQuotedInsert(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + d->nbytes = 0; + + if (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) { + if (yc->status & CHIKUJI_ON_BUNSETSU) { + if (yc->kEndp != yc->kCurs) { + yc->rStartp = yc->rCurs = yc->rEndp; + yc->kRStartp = yc->kCurs = yc->kEndp; + } + yc->status &= ~CHIKUJI_ON_BUNSETSU; + yc->status |= CHIKUJI_OVERWRAP; + } + else if (yc->rEndp == yc->rCurs) { + yc->status &= ~CHIKUJI_OVERWRAP; + } + } + + if (forceRomajiFlushYomi(d)) + return(d->nbytes); + + fitmarks(yc); + + yomiQuotedInsertMode(d); + d->kanji_status_return->length = -1; + return 0; +} + +inline int +mapAsKuten(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int i, j, ch, len, clen, kanalen, pos; + char tmpbuf[4]; + WCHAR_T *hexbuf; + WCHAR_T buf[2]; + static allowTwoByte = 1; + + tmpbuf[0] = tmpbuf[1] = tmpbuf[2] = tmpbuf[3] = '\0'; + + if (yc->kCurs < yc->cmark) { + int tmp = yc->kCurs; + yc->kCurs = yc->cmark; + yc->cmark = tmp; + kPos2rPos(yc, 0, yc->kCurs, (int *) 0, &tmp); + yc->rCurs = tmp; + } + else if (yc->kCurs == yc->cmark) { + yc->kCurs = yc->kRStartp = yc->kEndp; + yc->rCurs = yc->rStartp = yc->rEndp; + } + + if (*yc->romaji_buffer == 'x' || *yc->romaji_buffer == 'X') + len = yc->rCurs - 1; + else + len = yc->rCurs; + if (len > 6) { + return 0; + } + hexbuf = yc->romaji_buffer + yc->rCurs - len; + + kPos2rPos(yc, 0, yc->cmark, (int *) 0, &pos); + + if (hexbuf < yc->romaji_buffer + pos) { + if (hexbuf + 6 < yc->romaji_buffer + pos) { + return 0; + } + } + for (i = 0, j = 1; i < len; i++) { + ch = *(hexbuf + i); + if ('0' <= ch && ch <= '9') + tmpbuf[j] = tmpbuf[j] * 10 + (ch - '0'); + else if (ch == '-' && j == 1) + j++; + else + return 0; + } + tmpbuf[2] = (char)((0x80 | tmpbuf[2]) + 0x20); + if (tmpbuf[1] < 0x5f) { + tmpbuf[1] = (char)((0x80 | tmpbuf[1]) + 0x20); + } + else { + tmpbuf[1] = (char)((0x80 | tmpbuf[1]) - 0x5e + 0x20); + tmpbuf[0] = (char)0x8f; /* SS3 */ + } + if ((unsigned char)tmpbuf[1] < 0xa1 || + 0xfe < (unsigned char)tmpbuf[1] || + (len > 2 && ((unsigned char)tmpbuf[2] < 0xa1 || + 0xfe < (unsigned char)tmpbuf[2]))) { + return 0; + } + if (hexbuf[-1] == 'x' || hexbuf[-1] == 'X') { + tmpbuf[0] = (char)0x8f;/*SS3*/ + len++; + } + if (tmpbuf[0]) { + clen = MBstowcs(buf, tmpbuf, 2); + } + else { + clen = MBstowcs(buf, tmpbuf + 1, 2); + } + for (i = 0, kanalen = 0 ; i < len ; i++) { + if (yc->rAttr[yc->rCurs - len + i] & SENTOU) { + do { + kanalen++; + } while (!(yc->kAttr[yc->kCurs - kanalen] & SENTOU)); + yc->rAttr[yc->rCurs - len + i] &= ~SENTOU; + } + } + yc->rAttr[yc->rCurs - len] |= SENTOU; + kanaReplace(-kanalen, buf, clen, HENKANSUMI); + yc->kAttr[yc->kCurs - clen] |= SENTOU; + yc->kRStartp = yc->kCurs; + yc->rStartp = yc->rCurs; + yc->pmark = yc->cmark; + yc->cmark = yc->kCurs; + yc->n_susp_chars = 0; /* ¥µ¥¹¥Ú¥ó¥É¤·¤Æ¤¤¤ëʸ»ú¤¬¤¢¤ë¾ì¹ç¤¬¤¢¤ë¤Î¤Ç¥¯¥ê¥¢ */ + return 1; +} + +inline int +mapAsHex(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int i, ch, len = 4, clen, kanalen, pos; + char tmpbuf[8], *a; + WCHAR_T *hexbuf; + WCHAR_T buf[2]; + static allowTwoByte = 1; + extern struct CannaConfig cannaconf; + + if (yc->kCurs < yc->cmark) { + int tmp = yc->kCurs; + yc->kCurs = yc->cmark; + yc->cmark = tmp; + kPos2rPos(yc, 0, yc->kCurs, (int *)0, &tmp); + yc->rCurs = tmp; + } + else if (yc->kCurs == yc->cmark) { + yc->kCurs = yc->kRStartp = yc->kEndp; + yc->rCurs = yc->rStartp = yc->rEndp; + } + + hexbuf = yc->romaji_buffer + yc->rCurs - 4; + + kPos2rPos(yc, 0, yc->cmark, (int *)0, &pos); + + if (hexbuf < yc->romaji_buffer + pos) { + if (!allowTwoByte || hexbuf + 2 < yc->romaji_buffer + pos) { + return 0; + } + hexbuf += 2; + len = 2; + } + retry: + for (i = 0, a = tmpbuf + 1; i < len ; i++) { + ch = *(hexbuf + i); + if ('0' <= ch && ch <= '9') + ch -= '0'; + else if ('A' <= ch && ch <= 'F') + ch -= 'A' - 10; + else if ('a' <= ch && ch <= 'f') + ch -= 'a' - 10; + else if (allowTwoByte && i < 2 && 2 < len) { + hexbuf += 2; + len = 2; + goto retry; + } + else { + return 0; + } + *a++ = ch; + } + if (cannaconf.code_input == CANNA_CODE_SJIS) { /* sjis ¥³¡¼¥É¤À¤Ã¤¿¤é */ + char eucbuf[4]; /* SS3 ¤Î¤³¤È¤¬¤¢¤ë¤¿¤á */ + + tmpbuf[1] = tmpbuf[1] * 16 + tmpbuf[2]; + if (len > 2) { + tmpbuf[2] = tmpbuf[3] * 16 + tmpbuf[4]; + tmpbuf[3] = '\0'; + } + else { + tmpbuf[2] = '\0'; + } + if ((unsigned char)tmpbuf[1] < 0x81 || + (0x9f < (unsigned char)tmpbuf[1] && (unsigned char)tmpbuf[1] < 0xe0) || + 0xfc < (unsigned char)tmpbuf[1] || + (len > 2 && ((unsigned char)tmpbuf[2] < 0x40 || + 0xfc < (unsigned char)tmpbuf[2] || + (unsigned char)tmpbuf[2] == 0x7f))) { + return 0; + } + RkCvtEuc((unsigned char *)eucbuf, sizeof(eucbuf), + (unsigned char *)tmpbuf + 1, 2); + clen = MBstowcs(buf, eucbuf, 2); + } + else { + tmpbuf[1] = 0x80 | (tmpbuf[1] * 16 + tmpbuf[2]); + if (len > 2) { + tmpbuf[2] = 0x80 | (tmpbuf[3] * 16 + tmpbuf[4]); + tmpbuf[3] = '\0'; + } + else { + tmpbuf[2] = '\0'; + } + if ((unsigned char)tmpbuf[1] < 0xa1 || + 0xfe < (unsigned char)tmpbuf[1] || + (len > 2 && ((unsigned char)tmpbuf[2] < 0xa1 || + 0xfe < (unsigned char)tmpbuf[2]))) { + return 0; + } + if (len == 2) { + tmpbuf[1] &= 0x7f; + } + if (hexbuf > yc->romaji_buffer + && len > 2 && (hexbuf[-1] == 'x' || hexbuf[-1] == 'X')) { + tmpbuf[0] = (char)0x8f;/*SS3*/ + len++; + clen = MBstowcs(buf, tmpbuf, 2); + } + else { + clen = MBstowcs(buf, tmpbuf + 1, 2); + } + } + for (i = 0, kanalen = 0 ; i < len ; i++) { + if (yc->rAttr[yc->rCurs - len + i] & SENTOU) { + do { + kanalen++; + } while (!(yc->kAttr[yc->kCurs - kanalen] & SENTOU)); + yc->rAttr[yc->rCurs - len + i] &= ~SENTOU; + } + } + yc->rAttr[yc->rCurs - len] |= SENTOU; + kanaReplace(-kanalen, buf, clen, HENKANSUMI); + yc->kAttr[yc->kCurs - clen] |= SENTOU; + yc->kRStartp = yc->kCurs; + yc->rStartp = yc->rCurs; + yc->pmark = yc->cmark; + yc->cmark = yc->kCurs; + yc->n_susp_chars = 0; /* ¥µ¥¹¥Ú¥ó¥É¤·¤Æ¤¤¤ëʸ»ú¤¬¤¢¤ë¾ì¹ç¤¬¤¢¤ë¤Î¤Ç¥¯¥ê¥¢ */ + return 1; +} + +/* ConvertAsHex -- £±£¶¿Ê¤È¤ß¤Ê¤·¤Æ¤ÎÊÑ´¹ + + ¥í¡¼¥Þ»úÆþÎϤµ¤ì¤ÆÈ¿Å¾É½¼¨¤µ¤ì¤Æ¤¤¤ëʸ»úÎó¤ò£±£¶¿Ê¤Çɽ¼¨¤µ¤ì¤Æ¤¤¤ë¥³¡¼¥É¤È + ¤ß¤Ê¤·¤ÆÊÑ´¹¤¹¤ë¡£ + + (MSB¤Ï£°¤Ç¤â£±¤Ç¤âÎɤ¤) + + */ + +static ConvertAsHex (uiContext); + +static +ConvertAsHex(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + extern struct CannaConfig cannaconf; + + if (yc->henkanInhibition & CANNA_YOMI_INHIBIT_ASHEX) { + return NothingChangedWithBeep(d); + } + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + currentModeInfo(d); + } + if (cannaconf.code_input != CANNA_CODE_KUTEN) { + if (!mapAsHex(d)) { + return NothingChangedWithBeep(d); + } + } + else { + if (!mapAsKuten(d)) { + return NothingChangedWithBeep(d); + } + } + if (yc->kCurs - 1 < yc->ys) { + yc->ys = yc->kCurs - 1; + } + makeYomiReturnStruct(d); + return 0; +} + +/* + convertAsHex £±£¶¿Ê¤Î¿ô»ú¤ò´Á»úʸ»ú¤ËÊÑ´¹ + + ¤³¤ì¤ÏÆâÉôŪ¤Ë»ÈÍѤ¹¤ë¤¿¤á¤Î¥ë¡¼¥Á¥ó¤Ç¤¢¤ë¡£d->romaji_buffer ¤Ë´Þ¤Þ + ¤ì¤ëʸ»úÎó¤ò£±£¶¿Ê¤Çɽ¤µ¤ì¤¿´Á»ú¥³¡¼¥É¤Ç¤¢¤ë¤È¤ß¤Ê¤·¤Æ¡¢¤½¤Î¥³¡¼¥É¤Ë + ¤è¤Ã¤ÆÉ½¸½¤µ¤ì¤ë´Á»úʸ»ú¤ËÊÑ´¹¤¹¤ë¡£ÊÑ´¹¤·¤¿Ê¸»úÎó¤Ï buffer_return + ¤Ë³ÊǼ¤¹¤ë¡£¥ê¥¿¡¼¥óÃͤϥ¨¥é¡¼¤¬¤Ê¤±¤ì¤Ð buffer_return ¤Ë³ÊǼ¤·¤¿Ê¸ + »úÎó¤ÎŤµ¤Ç¤¢¤ë(Ä̾ï¤Ï£²¤Ç¤¢¤ë)¡£¥¨¥é¡¼¤¬È¯À¸¤·¤Æ¤¤¤ë»þ¤Ï¡Ý£±¤¬³ÊǼ + ¤µ¤ì¤ë¡£ + + ¥â¡¼¥É¤ÎÊѹ¹Åù¤Î½èÍý¤Ï¤³¤Î´Ø¿ô¤Ç¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£ + + ¤Þ¤¿¥Ð¥Ã¥Õ¥¡¤Î¥¯¥ê¥¢¤Ê¤É¤â¹Ô¤ï¤Ê¤¤¤Î¤ÇÃí°Õ¤¹¤ë¤Ù¤­¤Ç¤¢¤ë¡£ + + <Ìá¤êÃÍ> + Àµ¤·¤¯£±£¶¿Ê¤ËÊÑ´¹¤Ç¤­¤¿¾ì¹ç¤Ï£±¤½¤¦¤Ç¤Ê¤¤»þ¤Ï£°¤¬Ê֤롣 +*/ + +#ifdef WIN +static +#endif +cvtAsHex(uiContext d, WCHAR_T *buf, WCHAR_T *hexbuf, int hexlen) +{ + int i; + char tmpbuf[5], *a, *b; + WCHAR_T rch; + + if (hexlen != 4) { /* ÆþÎϤµ¤ì¤¿Ê¸»úÎó¤ÎŤµ¤¬£´Ê¸»ú¤Ç¤Ê¤¤¤Î¤Ç¤¢¤ì¤ÐÊÑ´¹ + ¤·¤Æ¤¢¤²¤Ê¤¤ */ + d->kanji_status_return->length = -1; + return 0; + } + for (i = 0, a = tmpbuf; i < 4 ; i++) { + rch = hexbuf[i]; /* ¤Þ¤º°ìʸ»ú¼è¤ê½Ð¤·¡¢£±£¶¿Ê¤Î¿ô»ú¤Ë¤¹¤ë¡£ */ + if ('0' <= rch && rch <= '9') { + rch -= '0'; + } + else if ('A' <= rch && rch <= 'F') { + rch -= 'A' - 10; + } + else if ('a' <= rch && rch <= 'f') { + rch -= 'a' - 10; + } + else { + d->kanji_status_return->length = -1; + return 0; + } + *a++ = (char)rch; /* ¼è¤ê´º¤¨¤ºÊݸ¤·¤Æ¤ª¤¯ */ + } + b = (a = tmpbuf) + 1; + *a = (char)(0x80 | (*a * 16 + *b)); + *(tmpbuf+1) = 0x80 | (*(a += 2) * 16 + *(b += 2)); + *a = '\0'; + if ((unsigned char)*tmpbuf < 0xa1 || + 0xfe < (unsigned char)*tmpbuf || + (unsigned char)*--a < 0xa1 || + 0xfe < (unsigned char)*a) { + return 0; + } else { + MBstowcs(buf, tmpbuf, 2); + return 1; + } +} + +convertAsHex(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + return cvtAsHex(d, d->buffer_return, yc->romaji_buffer, yc->rEndp); +} + +/* + ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹Ê䭥롼¥Á¥ó´ØÏ¢ + */ + +inline void +replaceSup2(int ind, int n) +{ + int i; + WCHAR_T *temp, **p; + + if (ind < 0) + return; + + temp = (p = keysup[ind].cand)[n]; + for (i = n ; i > 0 ; i--) { + p[i] = p[i - 1]; + } + p[0] = temp; +} + +inline void +replaceSup(int ind, int n) +{ + int i, group; + extern nkeysup; + + group = keysup[ind].groupid; + for (i = 0 ; i < nkeysup ; i++) { + if (keysup[i].groupid == group) { + replaceSup2(i, n); + } + } +} + +static everySupkey (uiContext, int, mode_context); + +static +everySupkey(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + ichiranContext ic = (ichiranContext)d->modec; + WCHAR_T *cur; + + cur = ic->allkouho[*(ic->curIkouho)]; + d->kanji_status_return->revPos = 0; + d->kanji_status_return->revLen = 0; + d->kanji_status_return->echoStr = cur; + d->kanji_status_return->length = WStrlen(cur); + + return retval; +} + +static exitSupkey (uiContext, int, mode_context); + +static +exitSupkey(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + yomiContext yc; + + popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */ + + yc = (yomiContext)d->modec; + + replaceSup(findSup(yc->romaji_buffer[0]) - 1, yc->cursup); + +#ifdef NOT_KAKUTEI + yc->rCurs = yc->rStartp = yc->rEndp; + yc->kCurs = yc->kEndp; + kanaReplace(-yc->kEndp, d->buffer_return, retval, HENKANSUMI | SUPKEY); + yc->kRStartp = yc->kCurs; + yc->kAttr[0] |= SENTOU; + yc->rAttr[0] |= SENTOU | HENKANSUMI; + for (i = 1 ; i < retval ; i++) { + yc->kAttr[i] &= ~SENTOU; + } + currentModeInfo(d); + makeYomiReturnStruct(d); + return 0; +#else + /* ̤³ÎÄêʸ»úÎó¤òºï½ü¤¹¤ë */ + RomajiClearYomi(d); + + /* ̤³ÎÄêʸ»úÎó¤¬Á´¤¯¤Ê¤¯¤Ê¤Ã¤¿¤Î¤Ç¡¢¦Õ¥â¡¼¥É¤ËÁ«°Ü¤¹¤ë */ + restoreChikujiIfBaseChikuji(yc); + d->current_mode = yc->curMode = yc->myEmptyMode; + d->kanji_status_return->info |= KanjiEmptyInfo; + currentModeInfo(d); + makeYomiReturnStruct(d); + return checkIfYomiQuit(d, retval); +#endif +} + +static quitSupkey (uiContext, int, mode_context); + +static +quitSupkey(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* °ìÍ÷¤ò¥Ý¥Ã¥× */ + makeYomiReturnStruct(d); + currentModeInfo(d); + return retval; +} + +selectKeysup(uiContext d, yomiContext yc, int ind) +{ + int retval; + ichiranContext ic; + extern nkeysup; + + yc->cursup = 0; + retval = selectOne(d, keysup[ind].cand, &(yc->cursup), keysup[ind].ncand, + BANGOMAX, + (unsigned)(!cannaconf.HexkeySelect ? NUMBERING : 0), + 0, WITH_LIST_CALLBACK, + everySupkey, exitSupkey, quitSupkey, NO_CALLBACK); + + ic = (ichiranContext)d->modec; + ic->majorMode = CANNA_MODE_IchiranMode; + ic->minorMode = CANNA_MODE_IchiranMode; + + currentModeInfo(d); + *(ic->curIkouho) = 0; + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return(retval); + } + + if ( !(ic->flags & ICHIRAN_ALLOW_CALLBACK) ) { + makeGlineStatus(d); + } + + return retval; +} + +/* + ³°Íè¸ìÊÑ´¹¤ò¤¹¤ë¤è¤¦¤Ê¥ê¡¼¥¸¥ç¥ó¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤«¡© + + ¤É¤ó¤Ê¤³¤È¤òÄ´¤Ù¤ë¤«¤È¸À¤¦¤È¡¢¤Þ¤º¡¢¥ê¡¼¥¸¥ç¥óÆâ¤¬³°Íè¸ìÊÑ´¹¤µ¤ì¤Æ¤¤ + ¤ë¤«¤É¤¦¤«¤òÄ´¤Ù¤ë¡£¼¡¤Ë¡¢¥ê¡¼¥¸¥ç¥ó¤Îξü¤¬ÀèÆ¬Ê¸»ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È + ¤òÄ´¤Ù¤¿¤¤¤È¤³¤í¤À¤¬¡¢¤³¤ì¤Ï¤ä¤Ã¤Ñ¤ê¤Ï¤º¤·¤¿¡£ + + ³°Íè¸ì¤ÎÅÓÃæ¤«¤é¤È¤«ÅÓÃæ¤Þ¤Ç¤È¤«¤Ç mark ¤ò¹Ô¤Ã¤¿»þ¤Ë¤µ¤é¤Ë³°Íè¸ìÊÑ´¹ + ¤ò¹Ô¤¦¤³¤È¤òÍÞÀ©¤¹¤ë¡£ + + */ + +inline +regionGairaigo(yomiContext yc, int s, int e) +{ + if ((yc->kAttr[s] & SENTOU) && (yc->kAttr[e] & SENTOU)) { + return 1; + } + else { + return 0; + } +} + + +/* + ³°Íè¸ìÊÑ´¹ºÑ¤Î»ú¤¬Æþ¤Ã¤Æ¤¤¤ë¤«¡© + */ + +inline int +containGairaigo(yomiContext yc) +{ + int i; + + for (i = 0 ; i < yc->kEndp ; i++) { + if (yc->kAttr[i] & GAIRAIGO) { + return 1; + } + } + return 0; +} + +containUnconvertedKey(yomiContext yc) +{ + int i, s, e; + + if (containGairaigo(yc)) { + return 0; + } + + if ((s = yc->cmark) > yc->kCurs) { + e = s; + s = yc->kCurs; + } + else { + e = yc->kCurs; + } + + for (i = s ; i < e ; i++) { + if ( !(yc->kAttr[i] & HENKANSUMI) ) { + return 1; + } + } + return 0; +} + +/* + * ¤«¤Ê´Á»úÊÑ´¹¤ò¹Ô¤¤(ÊÑ´¹¥­¡¼¤¬½é¤á¤Æ²¡¤µ¤ì¤¿)¡¢TanKouhoMode¤Ë°Ü¹Ô¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ + +static YomiHenkan (uiContext); + +static int +YomiHenkan(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int len, idx; + +#ifdef MEASURE_TIME + struct tms timebuf; + long currenttime, times(); + + currenttime = times(&timebuf); +#endif + + if (yc->henkanInhibition & CANNA_YOMI_INHIBIT_HENKAN) { + return NothingChangedWithBeep(d); + } + + d->nbytes = 0; + len = RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + + if (containUnconvertedKey(yc)) { + YomiMark(d); + len = RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + } + + yc->kRStartp = yc->kCurs = yc->kEndp; + yc->rStartp = yc->rCurs = yc->rEndp; + + if (len == 0) { /* empty ¥â¡¼¥É¤Ë¹Ô¤Ã¤Æ¤·¤Þ¤Ã¤¿ */ + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = 0; /* ¾å¤Î ch ¤Ç¼¨¤µ¤ì¤ë½èÍý¤ò¤»¤è */ + return d->nbytes; + } + + if (yc->rEndp == 1 && (yc->kAttr[0] & SUPKEY) && + !yc->left && !yc->right && + (idx = findSup(yc->romaji_buffer[0])) && + keysup[idx - 1].ncand > 1) { + return selectKeysup(d, yc, idx - 1); + } + + if (!prepareHenkanMode(d)) { + makeGLineMessageFromString(d, jrKanjiError); + makeYomiReturnStruct(d); + return 0; + } + yc->minorMode = CANNA_MODE_TankouhoMode; + yc->kouhoCount = 1; + if (doHenkan(d, 0, (WCHAR_T *)0) < 0) { + makeGLineMessageFromString(d, jrKanjiError); + return TanMuhenkan(d); + } + if (cannaconf.kouho_threshold > 0 && + yc->kouhoCount >= cannaconf.kouho_threshold) { + return tanKouhoIchiran(d, 0); + } + currentModeInfo(d); + +#ifdef MEASURE_TIME + hc->time = times(&timebuf; + hc->proctime -= currenttime; +#endif + + return 0; +} + +static YomiHenkanNaive (uiContext); + +static int +YomiHenkanNaive(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & + (CANNA_YOMI_HANKAKU | CANNA_YOMI_ROMAJI | CANNA_YOMI_BASE_HANKAKU)) { + return YomiInsert(d); + } + else { + return YomiHenkan(d); + } +} + +static YomiHenkanOrNothing (uiContext); + +static int +YomiHenkanOrNothing(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & + (CANNA_YOMI_HANKAKU | CANNA_YOMI_ROMAJI | CANNA_YOMI_BASE_HANKAKU)) { + return NothingChanged(d); + } + else { + return YomiHenkan(d); + } +} + +/* ¥Ù¡¼¥¹Ê¸»ú¤ÎÀÚ¤êÂØ¤¨ */ + +extern EmptyBaseHira (uiContext), EmptyBaseKata (uiContext); +extern EmptyBaseEisu (uiContext); +extern EmptyBaseZen (uiContext), EmptyBaseHan (uiContext); + +static YomiBaseHira (uiContext); + +static +YomiBaseHira(uiContext d) +{ + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + (void)EmptyBaseHira(d); + makeYomiReturnStruct(d); + return 0; +} + +static YomiBaseKata (uiContext); + +static +YomiBaseKata(uiContext d) +{ + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + (void)EmptyBaseKata(d); + makeYomiReturnStruct(d); + return 0; +} + +static YomiBaseEisu (uiContext); + +static +YomiBaseEisu(uiContext d) +{ + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + (void)EmptyBaseEisu(d); + makeYomiReturnStruct(d); + return 0; +} + +static YomiBaseZen (uiContext); + +static +YomiBaseZen(uiContext d) +{ + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + (void)EmptyBaseZen(d); + makeYomiReturnStruct(d); + return 0; +} + +static YomiBaseHan (uiContext); + +static +YomiBaseHan(uiContext d) +{ + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + (void)EmptyBaseHan(d); + makeYomiReturnStruct(d); + return 0; +} + +static YomiBaseKana (uiContext); + +static +YomiBaseKana(uiContext d) +{ + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + (void)EmptyBaseKana(d); + makeYomiReturnStruct(d); + return 0; +} + +static YomiBaseKakutei (uiContext); + +static +YomiBaseKakutei(uiContext d) +{ + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + (void)EmptyBaseKakutei(d); + makeYomiReturnStruct(d); + return 0; +} + +static YomiBaseHenkan (uiContext); + +static +YomiBaseHenkan(uiContext d) +{ + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + (void)EmptyBaseHenkan(d); + makeYomiReturnStruct(d); + return 0; +} + +int YomiBaseHiraKataToggle (uiContext); + +YomiBaseHiraKataToggle(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + + if (yc->generalFlags & CANNA_YOMI_KATAKANA) { + (void)EmptyBaseHira(d); + } + else { + (void)EmptyBaseKata(d); + } + makeYomiReturnStruct(d); + return 0; +} + +int YomiBaseZenHanToggle (uiContext); + +YomiBaseZenHanToggle(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + + if (yc->generalFlags & CANNA_YOMI_BASE_HANKAKU) { + (void)EmptyBaseZen(d); + } + else { + (void)EmptyBaseHan(d); + } + makeYomiReturnStruct(d); + return 0; +} + +int YomiBaseRotateForw (uiContext); + +YomiBaseRotateForw(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + + if (!(yc->generalFlags & CANNA_YOMI_BASE_HANKAKU) && + ((yc->generalFlags & CANNA_YOMI_ROMAJI) || + ((yc->generalFlags & CANNA_YOMI_KATAKANA) && + !cannaconf.InhibitHankakuKana) )) { + (void)EmptyBaseHan(d); + } + else { + yc->generalFlags &= ~CANNA_YOMI_BASE_HANKAKU; + if (yc->generalFlags & CANNA_YOMI_ROMAJI) { + (void)EmptyBaseHira(d); + } + else if (yc->generalFlags & CANNA_YOMI_KATAKANA) { + (void)EmptyBaseEisu(d); + } + else { + (void)EmptyBaseKata(d); + } + } + makeYomiReturnStruct(d); + return 0; +} + +int YomiBaseRotateBack (uiContext); + +YomiBaseRotateBack(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + + if (yc->generalFlags & CANNA_YOMI_BASE_HANKAKU) { + (void)EmptyBaseZen(d); + } + else if (yc->generalFlags & CANNA_YOMI_KATAKANA) { + (void)EmptyBaseHira(d); + } + else if (yc->generalFlags & CANNA_YOMI_ROMAJI) { + if (!cannaconf.InhibitHankakuKana) { + yc->generalFlags |= CANNA_YOMI_BASE_HANKAKU; + } + (void)EmptyBaseKata(d); + } + else { + yc->generalFlags &= ~CANNA_YOMI_ZENKAKU; + yc->generalFlags |= CANNA_YOMI_BASE_HANKAKU; + (void)EmptyBaseEisu(d); + } + makeYomiReturnStruct(d); + return 0; +} + +int YomiBaseKanaEisuToggle (uiContext); + +YomiBaseKanaEisuToggle(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + + if (yc->generalFlags & CANNA_YOMI_ROMAJI) { + (void)EmptyBaseKana(d); + } + else { + (void)EmptyBaseEisu(d); + } + makeYomiReturnStruct(d); + return 0; +} + +int YomiBaseKakuteiHenkanToggle (uiContext); + +YomiBaseKakuteiHenkanToggle(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + (void)RomajiFlushYomi(d, d->genbuf, ROMEBUFSIZE); + + if (yc->generalFlags & CANNA_YOMI_KAKUTEI) { + (void)EmptyBaseHenkan(d); + } + else { /* ËÜÅö¤Ï°ì¶ÚÆì¤Ç¤Ï¹Ô¤«¤Ê¤¤ */ + (void)EmptyBaseKakutei(d); + } + makeYomiReturnStruct(d); + return 0; +} + +int YomiModeBackup (uiContext); + +YomiModeBackup(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + (void)saveFlags(yc); + return NothingChanged(d); +} + +/* »ú¼ïÊÑ´¹´ØÏ¢ */ + +/* cfuncdef + + exitJishu -- »ú¼ïÊÑ´¹¤ò³ÎÄꤵ¤»¤ë + + ¤³¤Î´Ø¿ô¤Ï»ú¼ïÊÑ´¹¤ò³ÎÄꤵ¤»¤ÆÆÉ¤ß¥â¡¼¥É¤ËÌá¤Ã¤¿¤È¤³¤í¤Ç¼Â¹Ô¤µ¤ì¤ë + ´Ø¿ô¤Ç¤¢¤ë¡£ + + ¡Ú»ú¼ïÊÑ´¹¤È¤Î¤ªÌó«»ö¡Û + + ¤³¤Î´Ø¿ô¤Ï jishu.c ¤Ë½ñ¤¤¤Æ¤¢¤ë JishuKakutei ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿¤È + ¤­¤Ê¤É¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë´Ø¿ô¤Ç¤¢¤ë¡£JishuKakutei ¤Ç¤ÏºÇ½ªÅª¤Ê»ú¼ï + ¤Î»ØÄê¤ä¤½¤ÎÈϰϤλØÄê¤ò¤·¤ÆÍè¤ë¤À¤±¤Ç¼ÂºÝ¤ÎÌÜŪ»ú¼ï¤Ø¤ÎÊÑ´¹¤Ï + ¤³¤Î´Ø¿ô¤Ç¹Ô¤ï¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£¤Ê¤¼¤«¤È¸À¤¦¤È¥í¡¼¥Þ»ú¤È¤ÎÂбþ + ¤Å¤±¤ò¤­¤Á¤ó¤ÈÊÝ»ý¤·¤Æ¤ª¤­¤¿¤¤¤«¤é¤Ç¤¢¤ë JishuKakutei ¤È¤Î´Ö¤Î + ¤ªÌó«¤Ï°Ê²¼¤ÎÄ̤ê + + (1) ºÇ½ªÅª¤Ê»ú¼ï¤Ï yc ¤Î»ú¼ï´ØÏ¢¤Î¥á¥ó¥Ð¤ËÊÖ¤µ¤ì¤ë + (2) ¶ñÂÎŪ¤Ë¤Ï°Ê²¼¤ËÆþ¤ë¡£ + jishu_kc ºÇ½ªÅª¤Ê»ú¼ï¤Î¼ïÎà (JISHU_ZEN_KATA ¤Ê¤É) + jishu_case ºÇ½ªÅª¤Ê»ú¼ï¤Î¥±¡¼¥¹ (CANNA_JISHU_UPPER ¤Ê¤É) + jishu_kEndp »ú¼ïÊÑ´¹¤ÎÂоÝÈÏ°Ï + jishu_rEndp »ú¼ïÊÑ´¹¤ÎÂоÝÈÏ°Ï¤Î¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¤Ç¤Î°ÌÃÖ + (3) yc->cmark ¤Þ¤Ç¤Ï»ú¼ï¤¬ÃÖ¤­ÊѤï¤é¤Ê¤¤¤Î¤ËÃí°Õ¤¹¤ë¡£ + (4) yc->kana_buffer ¤ÎÃÖ¤­´¹¤¨¤Ï exitJishu ¤¬¹Ô¤¦¡£ + (5) yc->kana_buffer ¤Ç»ú¼ïÊÑ´¹Èϰϰʳ°¤Î¤â¤Î¤Ï yc->romaji_buffer + ¤ò¤â¤¦°ìÅÙ¥³¥Ô¡¼¤·¤Æ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤µ¤ì¤ë¤³¤È¤ÇÉÕ¤±²Ã¤¨¤é¤ì¤ë¡£ + (6) ¤¿¤À¤·¡¢yc->kRStartp == yc->jishu_kEndp ¤Ê¤é¤Ð¾åµ­¤Î½èÍý¤Ï¹Ô¤ï¤Ê + ¤¤¡£ + (7) ¾åµ­¤ÇÊÖ¤µ¤ì¤Ê¤¤Éôʬ¤Î¥í¡¼¥Þ»ú¤Ï yc->jishu_rEndp °Ê¹ß¤Ç¤¢¤ë¡£ + (8) exitJishu ¤Ï¤½¤ÎÉôʬ¤ò yc->kana_buffer ¤Ë°Üư¤·¤â¤¦°ìÅÙ¥í¡¼¥Þ»ú + ¤«¤ÊÊÑ´¹¤ò¹Ô¤¦¡£ + */ + +exitJishu(uiContext d) +{ + yomiContext yc; + int len, srclen, i, pos; + BYTE jishu, jishu_case, head = 1; + int jishu_kEndp, jishu_rEndp; + int (*func1)(...), (*func2)(...); + long savedgf; + WCHAR_T *buf, *p; +#ifndef WIN + WCHAR_T xxxx[1024]; +#else + WCHAR_T *xxxx = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 1024); + if (!xxxx) { + return 0; + } +#endif + + /* ¤³¤³¤«¤é²¼¤Ï´°Á´¤Ê¡ØÆÉ¤ß¡Ù¥â¡¼¥É */ + + yc = (yomiContext)d->modec; + + jishu = yc->jishu_kc; + jishu_case = yc->jishu_case; + jishu_kEndp = yc->jishu_kEndp; + jishu_rEndp = yc->jishu_rEndp; + + leaveJishuMode(d, yc); + + /* ¥Æ¥ó¥Ý¥é¥ê¥â¡¼¥É¤À¤Ã¤¿¤é¸µ¤ËÌ᤹ */ + if (yc->savedFlags & CANNA_YOMI_MODE_SAVED) { + restoreFlags(yc); + } + /* Ã༡¤ÎÆÉ¤ß¥Ý¥¤¥ó¥¿¤ò¥¯¥ê¥¢ */ + yc->ys = yc->cStartp; + + /* ¤Þ¤º¡¢»ú¼ïÊÑ´¹¤µ¤ì¤¿Éôʬ¤òÊÑ´¹ */ + buf = d->genbuf; + switch (jishu) { + case JISHU_ZEN_KATA: /* Á´³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤¹¤ë */ + func1 = RkwCvtZen; + func2 = RkwCvtKana; + goto jishuKakuteiKana; + + case JISHU_HAN_KATA: /* Ⱦ³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤¹¤ë */ + func1 = RkwCvtKana; + func2 = RkwCvtHan; + goto jishuKakuteiKana; + + case JISHU_HIRA: /* ¤Ò¤é¤¬¤Ê¤ËÊÑ´¹¤¹¤ë */ + func1 = RkwCvtZen; + func2 = RkwCvtHira; + + jishuKakuteiKana: + /* ¤Þ¤º¡¢¥Ù¡¼¥¹¤¬¥í¡¼¥Þ»ú¤Î¤È¤­¤ËÆþÎϤµ¤ì¤¿¤â¤Î¤¬¤¢¤ì¤Ð¤«¤Ê¤ËÊÑ´¹¤¹¤ë */ + savedgf = yc->generalFlags; + yc->generalFlags = savedgf & CANNA_YOMI_IGNORE_USERSYMBOLS; + for (i = yc->cmark ; i < jishu_kEndp ;) { + int j = i; + while (i < jishu_kEndp && yc->kAttr[i] & STAYROMAJI) { + yc->kAttr[i++] &= ~(HENKANSUMI | STAYROMAJI); + } + if (j < i) { + kPos2rPos(yc, j, i, &yc->rStartp, &yc->rCurs); + yc->kRStartp = j; + yc->kCurs = i; + makePhonoOnBuffer(d, yc, (unsigned char)0, RK_FLUSH, 0); + jishu_kEndp += yc->kCurs - i; + i = yc->kCurs; + }else{ + i++; + } + } + yc->generalFlags = savedgf; + + /* ¤³¤³¤Ç¡¢¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹Ã±°Ì¤Ç»ú¼ïÊÑ´¹¤¹¤ë */ + for (i = yc->cmark ; i < jishu_kEndp ; i = yc->kCurs) { + int j; + + for (j = i + 1 ; !(yc->kAttr[j] & SENTOU) ;) { + j++; + } + if(j > jishu_kEndp) { + j = jishu_kEndp; + } + srclen = j - i; + + len = (*func1)(xxxx, 1024, yc->kana_buffer + i, srclen); + len = (*func2)(buf, ROMEBUFSIZE, xxxx, len); + yc->kCurs = j; + kanaReplace(-srclen, buf, len, 0); + jishu_kEndp += len - srclen; /* yc->kCurs - j ¤ÈƱ¤¸ÃÍ */ + + for (j = yc->kCurs - len ; j < yc->kCurs ; j++) { + yc->kAttr[j] = HENKANSUMI; + } + yc->kAttr[yc->kCurs - len] |= SENTOU; + } + break; + + case JISHU_ZEN_ALPHA: /* Á´³Ñ±Ñ¿ô¤ËÊÑ´¹¤¹¤ë */ + case JISHU_HAN_ALPHA: /* Ⱦ³Ñ±Ñ¿ô¤ËÊÑ´¹¤¹¤ë */ + p = yc->romaji_buffer; + kPos2rPos(yc, 0, yc->cmark, (int *)0, &pos); + + for (i = pos ; i < jishu_rEndp ; i++) { + xxxx[i - pos] = + (jishu_case == CANNA_JISHU_UPPER) ? WToupper(p[i]) : + (jishu_case == CANNA_JISHU_LOWER) ? WTolower(p[i]) : p[i]; + if (jishu_case == CANNA_JISHU_CAPITALIZE) { + if (p[i] <= ' ') { + head = 1; + } + else if (head) { + head = 0; + xxxx[i - pos] = WToupper(p[i]); + } + } + } + xxxx[i - pos] = (WCHAR_T)0; +#if 0 + if (jishu_case == CANNA_JISHU_CAPITALIZE) { + xxxx[0] = WToupper(xxxx[0]); + } +#endif + if (jishu == JISHU_ZEN_ALPHA) { + len = RkwCvtZen(buf, ROMEBUFSIZE, xxxx, jishu_rEndp - pos); + } + else { + len = RkwCvtNone(buf, ROMEBUFSIZE, xxxx, jishu_rEndp - pos); + } + yc->rCurs = jishu_rEndp; + yc->kCurs = jishu_kEndp; + kanaReplace(yc->cmark - yc->kCurs, buf, len, 0); + jishu_kEndp = yc->kCurs; + + /* ¤³¤³¤ÇÀèÆ¬¥Ó¥Ã¥È¤òΩ¤Æ¤ë */ + for (i = pos ; i < yc->rCurs ; i++) { + yc->rAttr[i] = SENTOU; + } + + len = yc->kCurs; + for (i = yc->cmark ; i < len ; i++) { + yc->kAttr[i] = HENKANSUMI | SENTOU; + } + + /* ¸å¤í¤ÎÉôʬ */ + for (i = jishu_rEndp ; i < yc->rEndp ; i++) { + yc->rAttr[i] = 0; + } + yc->rAttr[jishu_rEndp] = SENTOU; + + kanaReplace(yc->kEndp - jishu_kEndp, yc->romaji_buffer + jishu_rEndp, + yc->rEndp - jishu_rEndp, 0); + yc->rAttr[jishu_rEndp] |= SENTOU; + yc->kAttr[jishu_kEndp] |= SENTOU; + yc->rStartp = jishu_rEndp; + yc->kRStartp = jishu_kEndp; + + for (yc->kCurs = jishu_kEndp, yc->rCurs = jishu_rEndp ; + yc->kCurs < yc->kEndp ;) { + yc->kCurs++; yc->rCurs++; + if (yc->kRStartp == yc->kCurs - 1) { + yc->kAttr[yc->kRStartp] |= SENTOU; + } + makePhonoOnBuffer(d, yc, + (unsigned char)yc->kana_buffer[yc->kCurs - 1], 0, 0); + } + if (yc->kRStartp != yc->kEndp) { + if (yc->kRStartp == yc->kCurs - 1) { + yc->kAttr[yc->kRStartp] |= SENTOU; + } + makePhonoOnBuffer(d, yc, (unsigned char)0, RK_FLUSH, 0); + } + break; + + default:/* ¤É¤ì¤Ç¤â¤Ê¤«¤Ã¤¿¤éÊÑ´¹½ÐÍè¤Ê¤¤¤Î¤Ç²¿¤â¤·¤Ê¤¤ */ + jishu_rEndp = jishu_kEndp = 0; + break; + } + yc->kCurs = yc->kRStartp = yc->kEndp; + yc->rCurs = yc->rStartp = yc->rEndp; + yc->pmark = yc->cmark; + yc->cmark = yc->kCurs; + yc->jishu_kEndp = 0; +#ifdef WIN + free(xxxx); +#endif + return 0; +} + +static +YomiJishu(uiContext d, int fn) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->henkanInhibition & CANNA_YOMI_INHIBIT_JISHU) { + return NothingChangedWithBeep(d); + } + d->nbytes = 0; + if ((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && + !(yc->status & CHIKUJI_OVERWRAP) && yc->nbunsetsu) { + yc->status |= CHIKUJI_OVERWRAP; + moveToChikujiTanMode(d); + } + else if (! RomajiFlushYomi(d, (WCHAR_T *)NULL, 0)) { + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = 0; /* ¾å¤Î ch ¤Ç¼¨¤µ¤ì¤ë½èÍý¤ò¤»¤è */ + return d->nbytes; + } + else { + enterJishuMode(d, yc); + yc->minorMode = CANNA_MODE_JishuMode; + } + currentModeInfo(d); + d->more.todo = 1; + d->more.ch = d->ch; + d->more.fnum = fn; + return 0; +} + +static int +chikujiEndBun(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + int ret = 0; + + if ((yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) && yc->nbunsetsu) { + KanjiMode mdsv; +#ifndef WIN + yomiContextRec ycsv; +#else + yomiContext ycsv; + + ycsv = (yomiContext)malloc(sizeof(yomiContextRec)); + if (ycsv) { +#endif + + /* µ¿Ì䤬»Ä¤ë½èÍý */ +#ifdef WIN + * /* This is a little bit tricky source code */ +#endif + ycsv = *yc; + yc->kEndp = yc->rEndp = 0; + mdsv = d->current_mode; + ret = TanKakutei(d); + d->current_mode = mdsv; + *yc = +#ifdef WIN + * /* this is also a little bit trick source code */ +#endif + ycsv; + } +#ifdef WIN + free(ycsv); + } +#endif + return(ret); +} + +/* cfuncdef + + replaceEnglish -- ¤«¤Ê¥Ð¥Ã¥Õ¥¡¤ò¥í¡¼¥Þ»ú¤ËÌᤷ¤ÆºÆ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤¹¤ë + + d, yc : ¥³¥ó¥Æ¥¯¥¹¥È + start, end : ¥í¡¼¥Þ»ú¤ËÌ᤹ÈÏ°Ï + RKflag : RkwMapPhonogram ¤ËÍ¿¤¨¤ë¥Õ¥é¥° + engflag : ±Ññ¸ì¥«¥¿¥«¥ÊÊÑ´¹¤ò¤¹¤ë¤«¤É¤¦¤«¤Î¥Õ¥é¥° + + */ + +inline void +replaceEnglish(uiContext d, yomiContext yc, int start, int end, int RKflag, int engflag) +{ + int i; + + kanaReplace(yc->pmark - yc->cmark, + yc->romaji_buffer + start, end - start, 0); + yc->kRStartp = yc->pmark; + yc->rStartp = start; + for (i = start ; i < end ; i++) { + yc->rAttr[i] &= ~SENTOU; + } + yc->rAttr[start] |= SENTOU; + for (i = yc->pmark ; i < yc->kCurs ; i++) { + yc->kAttr[i] &= ~(SENTOU | HENKANSUMI); + } + yc->kAttr[yc->pmark] |= SENTOU; + + yc->n_susp_chars = 0; /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¤ä¤êľ¤·¤Ê¤Î¤Ç¥¯¥ê¥¢¤¹¤ë */ + makePhonoOnBuffer(d, yc, 0, (unsigned char)RKflag, engflag); + yc->kRStartp = yc->kCurs; + yc->rStartp = yc->rCurs; +} + +int YomiMark (uiContext); + +int +YomiMark(uiContext d) +{ +#ifndef NOT_ENGLISH_TABLE + int rc, rp, i; +#endif + yomiContext yc = (yomiContext)d->modec; + +#if defined(DEBUG) && !defined(WIN) + if (iroha_debug) { + fprintf(stderr,"yc->kCurs=%d yc->cmark=%d\n", yc->kCurs,yc->cmark); + } +#endif /* DEBUG */ + + if (yc->kCurs != yc->cmark) { /* ¤ª½é */ + + if (yc->cmark < yc->kCurs) { + yc->pmark = yc->cmark; + yc->cmark = yc->kCurs; + } + else { + /* °Ê²¼¡¢pmark < cmark ¤ò²¾Äꤷ¤Æ¤¤¤ë½èÍý¤¬¤¢¤ë¤Î¤Ç¡¢ + cmark < pmark ¤Î¾ì¹ç¤Ï pmark ¤â cmark ¤ÈƱ¤¸Ãͤˤ·¤Æ¤·¤Þ¤¦¡£ + ¤Á¤ç¤Ã¤ÈÁ°¤Þ¤Ç¤Ï pmark ¤È cmark ¤ÎÆþ¤ì´¹¤¨¤ò¤ä¤Ã¤Æ¤¤¤¿¤¬¡¢ + ¤½¤¦¤·¤Æ¤·¤Þ¤¦¤È¡¢¸½ºß¤Î¥Þ¡¼¥¯¤è¤ê¤âº¸¤Ø¤Ï¥Þ¡¼¥¯¤¬ÉÕ¤±¤é¤ì¤Ê¤¤ + ¤È¸À¤¦¤³¤È¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¡£ */ + yc->pmark = yc->cmark = yc->kCurs; + } + yc->englishtype = CANNA_ENG_NO; + } +#ifndef NOT_ENGLISH_TABLE + if (englishdic) { + if (regionGairaigo(yc, yc->pmark, yc->cmark)) { + yc->englishtype++; + yc->englishtype = (BYTE)((int)yc->englishtype % (int)(CANNA_ENG_NO + 1)); + if (yc->englishtype == CANNA_ENG_KANA) { + kPos2rPos(yc, yc->pmark, yc->cmark, &rp, &rc); + replaceEnglish(d, yc, rp, rc, RK_FLUSH, 1); + yc->cmark = yc->kCurs; + } + } + else { + makeYomiReturnStruct(d); + return 0; + } + + /* ¤Þ¤º¤Ï¡¢¥«¥Ê¤Ë¤Ç¤­¤ë±Ññ¸ì¤¬¤¢¤Ã¤¿¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯ */ + rp = rc = 0; + for (i = yc->pmark ; i < yc->cmark ; i++) { + if (yc->kAttr[i] & GAIRAIGO) { + rp = i; + do { + i++; + } while (!(yc->kAttr[i] & SENTOU)); + rc = i; + break; + } + } + if (rp || rc) { + int rs, re, offset; + WCHAR_T space2[2]; + + kPos2rPos(yc, rp, rc, &rs, &re); + switch (yc->englishtype) { + case CANNA_ENG_KANA: + break; + case CANNA_ENG_ENG1: + offset = yc->kCurs - rc; + yc->kCurs -= offset; + kanaReplace(rp - rc, yc->romaji_buffer + rs, re - rs, + HENKANSUMI | GAIRAIGO); + yc->kAttr[yc->kCurs - re + rs] |= SENTOU; + yc->kCurs += offset; + yc->cmark = yc->kRStartp = yc->kCurs; + break; + case CANNA_ENG_ENG2: + offset = yc->kCurs - rc; + yc->kCurs -= offset; + space2[0] = (WCHAR_T)' '; + space2[1] = (WCHAR_T)' '; + kanaReplace(rp - rc, space2, 2, HENKANSUMI | GAIRAIGO); + yc->kAttr[yc->kCurs - 2] |= SENTOU; + yc->kCurs--; + kanaReplace(0, yc->romaji_buffer + rs, re - rs, HENKANSUMI | GAIRAIGO); + yc->kAttr[yc->kCurs - re + rs] &= ~SENTOU; + yc->kCurs += offset + 1; + yc->cmark = yc->kRStartp = yc->kCurs; + break; + case CANNA_ENG_NO: + kPos2rPos(yc, yc->pmark, yc->cmark, &rs, &re); + replaceEnglish(d, yc, rs, re, 0, 0); + yc->cmark = yc->kRStartp = yc->kCurs; + break; + } + } + } +#endif + makeYomiReturnStruct(d); + debug_yomi(yc); + return 0; +} + +int +Yomisearchfunc(uiContext d, KanjiMode mode, int whattodo, int key, int fnum) +{ + yomiContext yc = (yomiContext)0; + int len; + extern KanjiModeRec yomi_mode; + + if (d) { + yc = (yomiContext)d->modec; + } + + if (yc && yc->id != YOMI_CONTEXT) { + /* ËÜÍ褢¤ê¤¨¤Ê¤¤¤¬¡¢¥Ð¥°¤Ã¤Æ¤¤¤Æ¡¢¤³¤¦¤Ê¤Ã¤Æ¤Æ¤â core ¤òÅǤ­¤µ¤¨ + ¤·¤Ê¤±¤ì¤Ð¤½¤Î¤¦¤ÁÀµ¤·¤¤¾õÂÖ¤ËÌá¤ë¤Î¤Çǰ¤Î°Ù¤¤¤ì¤Æ¤ª¤¯ */ + yc = (yomiContext)0; + } + + if (cannaconf.romaji_yuusen && yc) { /* ¤â¤·¡¢Í¥Àè¤Ê¤é */ + len = yc->kCurs - yc->kRStartp; + if (fnum == 0) { + fnum = mode->keytbl[key]; + } + if (fnum != CANNA_FN_FunctionalInsert && len > 0) { + int n, m, t, flag, prevrule; + WCHAR_T kana[128], roma[128]; + flag = cannaconf.ignore_case ? RK_IGNORECASE : 0; + + WStrncpy(roma, yc->kana_buffer + yc->kRStartp, len); + roma[len++] = (WCHAR_T)key; + + prevrule = yc->last_rule; + if ((RkwMapPhonogram(yc->romdic, kana, 128, roma, len, (WCHAR_T)key, + flag | RK_SOKON, &n, &m, &t, &prevrule) && + n == len) || n == 0) { + /* RK_SOKON ¤òÉÕ¤±¤ë¤Î¤Ïµì¼­½ñÍÑ */ + fnum = CANNA_FN_FunctionalInsert; + } + } + } + return searchfunc(d, mode, whattodo, key, fnum); +} + +/* + trimYomi -- ÆÉ¤ß¥Ð¥Ã¥Õ¥¡¤Î¤¢¤ëÎΰè°Ê³°¤òºï¤ë + + sy ey ¤«¤Ê¤ÎÉôʬ¤Ç»Ä¤¹Îΰ衢¤³¤Î³°Â¦¤Ïºï¤é¤ì¤ë¡£ + sr er ¥í¡¼¥Þ»ú ¡· + */ + +void +trimYomi(uiContext d, int sy, int ey, int sr, int er) +{ + yomiContext yc = (yomiContext)d->modec; + + yc->kCurs = ey; + yc->rCurs = er; + + romajiReplace (yc->rEndp - er, (WCHAR_T *)NULL, 0, 0); + kanaReplace (yc->kEndp - ey, (WCHAR_T *)NULL, 0, 0); + + yc->kCurs = sy; + yc->rCurs = sr; + + romajiReplace (-sr, (WCHAR_T *)NULL, 0, 0); + kanaReplace (-sy, (WCHAR_T *)NULL, 0, 0); +} + +inline int +TbBubunKakutei(uiContext d) +{ + tanContext tan, tc = (tanContext)d->modec; + WCHAR_T *s = d->buffer_return, *e = s + d->n_buffer; + int len; + + tan = tc; + while (tan->left) { + tan = tan->left; + } + + len = doKakutei(d, tan, tc, s, e, (yomiContext *)0); + d->modec = (mode_context)tc; + tc->left = (tanContext)0; + s += len; + (void)TanMuhenkan(d); + return len; +} + +int doTanConvertTb (uiContext, yomiContext); + +int TanBubunKakutei (uiContext); + +int +TanBubunKakutei(uiContext d) +{ + int len; + tanContext tan; + yomiContext yc = (yomiContext)d->modec; + WCHAR_T *s = d->buffer_return, *e = s + d->n_buffer; + + if (yc->id == YOMI_CONTEXT) { + doTanConvertTb(d, yc); + yc = (yomiContext)d->modec; + } + tan = (tanContext)yc; + while (tan->left) { + tan = tan->left; + } + len = doKakutei(d, tan, (tanContext)yc, s, e, (yomiContext *)0); + d->modec = (mode_context)yc; + yc->left = (tanContext)0; + + makeYomiReturnStruct(d); + currentModeInfo(d); + return len; +} + +#if 0 +/* + * ¥«¥ì¥ó¥ÈʸÀá¤ÎÁ°¤Þ¤Ç³ÎÄꤷ¡¢¥«¥ì¥ó¥È°Ê¹ß¤ÎʸÀá¤òÆÉ¤ß¤ËÌ᤹ + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0 °Û¾ï½ªÎ»»þ -1 + */ +TanBubunKakutei(uiContext d) +{ + extern KanjiModeRec cy_mode, yomi_mode; + WCHAR_T *ptr = d->buffer_return, *eptr = ptr + d->n_buffer; + yomiContext yc = (yomiContext)d->modec; + tanContext tan; + int i, j, n, l = 0, len, con, ret = 0; +#ifndef WIN + WCHAR_T tmpbuf[ROMEBUFSIZE]; +#else + WCHAR_T *tmpbuf = (WCHAR_T *)malloc(sizeof(WCHAR_T) * ROMEBUFSIZE); + if (!tmpbuf) { + return 0; + } +#endif + + if (yc->id != YOMI_CONTEXT) { + ret = TbBubunKakutei(d); + goto return_ret; + } + + tan = (tanContext)yc; + while (tan->left) { + tan = tan->left; + } + + len = doKakutei(d, tan, (tanContext)yc, ptr, eptr, (yomiContext *)0); + d->modec = (mode_context)yc; + yc->left = (tanContext)0; + ptr += len; + + if (yomiInfoLevel > 0) { /* ÌÌÅÝ¤Ê¤Î¤Ç yomiInfo ¤ò¼Î¤Æ¤ë */ + d->kanji_status_return->info &= ~KanjiYomiInfo; + } + + con = yc->context; + + /* ³ÎÄêʸ»úÎó ¤òºî¤ë */ + for (i = 0, n = yc->curbun ; i < n ; i++) { + if (RkwGoTo(con, i) < 0) { + ret = makeRkError(d, "\312\270\300\341\244\316\260\334\306\260\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ʸÀá¤Î°Üư¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + goto return_ret; + } + len = RkwGetKanji(con, ptr, (int)(eptr - ptr)); + if (len < 0) { + (void)makeRkError(d, "\264\301\273\372\244\316\274\350\244\352\275\320" + "\244\267\244\313\274\272\307\324\244\267\244\336\244\267\244\277"); + /* ´Á»ú¤Î¼è¤ê½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + ret = TanMuhenkan(d); + goto return_ret; + } + ptr += len; + j = RkwGetYomi(yc->context, tmpbuf, ROMEBUFSIZE); + if (j < 0) { + (void)makeRkError(d, "\245\271\245\306\245\244\245\277\245\271\244\362" + "\274\350\244\352\275\320\244\273\244\336\244\273\244\363\244\307" + "\244\267\244\277"); + /* ¥¹¥Æ¥¤¥¿¥¹¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + ret = TanMuhenkan(d); + goto return_ret; + } + l += j; + } + d->nbytes = ptr - d->buffer_return; + + for (i = j = 0 ; i < l ; i++) { + if (yc->kAttr[i] & SENTOU) { + do { + ++j; + } while (!(yc->rAttr[j] & SENTOU)); + } + } + yc->rStartp = yc->rCurs = j; + romajiReplace(-j, (WCHAR_T *)NULL, 0, 0); + yc->kRStartp = yc->kCurs = i; + kanaReplace(-i, (WCHAR_T *)NULL, 0, 0); + + if (RkwEndBun(yc->context, cannaconf.Gakushu ? 1 : 0) == -1) { + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316" + "\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267" + "\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + if (errno == EPIPE) { + jrKanjiPipeError(); + } + } + + if (yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE) { + yc->status &= CHIKUJI_NULL_STATUS; + yc->cStartp = yc->cRStartp = 0; + yc->kCurs = yc->kRStartp = yc->kEndp; + yc->rCurs = yc->rStartp = yc->rEndp; + yc->ys = yc->ye = yc->cStartp; + clearHenkanContext(yc); + d->current_mode = yc->curMode = yc->rEndp ? &cy_mode : yc->myEmptyMode; + } + else { + d->current_mode = yc->curMode = &yomi_mode; + } + yc->minorMode = getBaseMode(yc); + + yc->nbunsetsu = 0; + + /* ñ¸õÊä¾õÂÖ¤«¤éÆÉ¤ß¤ËÌá¤ë¤È¤­¤Ë¤Ï̵¾ò·ï¤Ëmark¤òÀèÆ¬¤ËÌ᤹ */ + yc->cmark = yc->pmark = 0; + + abandonContext(d, yc); + + doMuhenkan(d, yc); + + makeYomiReturnStruct(d); + currentModeInfo(d); + + ret = d->nbytes; + + return_ret: +#ifdef WIN + free(tmpbuf); +#endif + return ret; +} +#endif /* 0 */ + +/* + removeKana -- yomiContext ¤ÎÀèÆ¬¤«¤é»ú¤òºï¤ë(Ã༡¤Ç»È¤¦) + + k -- ¤«¤Ê¤Îºï¤ë¿ô + r -- ¥í¡¼¥Þ»ú¤Îºï¤ë¿ô + d ¤Ï¤¤¤é¤Ê¤¤¤è¤¦¤Ë¸«¤¨¤ë¤¬¥Þ¥¯¥í¤Ç¼Â¤Ï»È¤Ã¤Æ¤¤¤ë¤Î¤ÇɬÍס£ + + */ + +void +removeKana(uiContext d, yomiContext yc, int k, int r) +{ + int offs; + + offs = yc->kCurs - k; + yc->kCurs = k; + kanaReplace(-k, (WCHAR_T *)NULL, 0, 0); + if (offs > 0) { + yc->kCurs = offs; + } + yc->cmark = yc->kRStartp = yc->kCurs; + offs = yc->rCurs - r; + yc->rCurs = r; + romajiReplace(-r, (WCHAR_T *)NULL, 0, 0); + if (offs > 0) { + yc->rCurs = offs; + } + yc->rStartp = yc->rCurs; +} + +static YomiNextJishu (uiContext); + +static +YomiNextJishu(uiContext d) +{ + return YomiJishu(d, CANNA_FN_Next); +} + +static YomiPreviousJishu (uiContext); + +static +YomiPreviousJishu(uiContext d) +{ + return YomiJishu(d, CANNA_FN_Prev); +} + +static YomiKanaRotate (uiContext); + +static +YomiKanaRotate(uiContext d) +{ + return YomiJishu(d, CANNA_FN_KanaRotate); +} + +static YomiRomajiRotate (uiContext); + +static +YomiRomajiRotate(uiContext d) +{ + return YomiJishu(d, CANNA_FN_RomajiRotate); +} + +static YomiCaseRotateForward (uiContext); + +static +YomiCaseRotateForward(uiContext d) +{ + return YomiJishu(d, CANNA_FN_CaseRotate); +} + +static YomiZenkaku (uiContext); + +static +YomiZenkaku(uiContext d) +{ + return YomiJishu(d, CANNA_FN_Zenkaku); +} + +static YomiHankaku (uiContext); + +static +YomiHankaku(uiContext d) +{ + if (cannaconf.InhibitHankakuKana) + return NothingChangedWithBeep(d); + else + return YomiJishu(d, CANNA_FN_Hankaku); +} + +static YomiHiraganaJishu (uiContext); + +static +YomiHiraganaJishu(uiContext d) +{ + return YomiJishu(d, CANNA_FN_Hiragana); +} + +static YomiKatakanaJishu (uiContext); + +static +YomiKatakanaJishu(uiContext d) +{ + return YomiJishu(d, CANNA_FN_Katakana); +} + +static YomiRomajiJishu (uiContext); + +static +YomiRomajiJishu(uiContext d) +{ + return YomiJishu(d, CANNA_FN_Romaji); +} + +static YomiToLower (uiContext); +static +YomiToLower(uiContext d) +{ + return YomiJishu(d, CANNA_FN_ToLower); +} + +static YomiToUpper (uiContext); + +static +YomiToUpper(uiContext d) +{ + return YomiJishu(d, CANNA_FN_ToUpper); +} + +static YomiCapitalize (uiContext); + +static +YomiCapitalize(uiContext d) +{ + return YomiJishu(d, CANNA_FN_Capitalize); +} + +/* ±Ñ¸ì¥«¥¿¥«¥ÊÊÑ´¹¤Î¤ä¤ê»Ä¤· + + ¡¦³°Íè¸ìÊÑ´¹¤Ï»ú¼ïÊÑ´¹¤Ë¼è¤ê¹þ¤ß¤¿¤¤ + + ¤Ä¤¤¤Ç¤Ê¤Î¤Ç¥¨¥ó¥¸¥óÀÚ¤êÂØ¤¨¤Î¤ä¤ê»Ä¤· + + ¡¦£Ä£Ó£Ï¤¬¤Ê¤¤¾ì¹ç¤Ë¡Ö¤½¤Î¥¨¥ó¥¸¥ó¤ËÀÚ¤êÂØ¤¨¤é¤ì¤Ê¤¤¡×¤È¸À¤¤¤¿¤¤ + ¡¦¤½¤Î¾¥¨¥é¡¼¥Á¥§¥Ã¥¯ + + */ + +#include "yomimap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/t_reimap.h b/src/add-ons/input_server/methods/canna/lib/t_reimap.h new file mode 100644 index 0000000000..5477dae01a --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/t_reimap.h @@ -0,0 +1,43 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +// Modified by T.Murai + +#if !defined(lint) && !defined(__CODECENTER__) +static char t_reimap_id[] = "@(#) 102.1 $Id: t_reimap.h,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" + +static struct funccfunc tourokureibun_funcs[] = { + {CANNA_FN_FunctionalInsert ,YesNo }, + {CANNA_FN_Quit ,YesNoQuit }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {0 ,0 }, +}; + +extern searchfunc(...); +KanjiModeRec tourokureibun_mode = { + searchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + tourokureibun_funcs, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/tanmap.h b/src/add-ons/input_server/methods/canna/lib/tanmap.h new file mode 100644 index 0000000000..ddea73614e --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/tanmap.h @@ -0,0 +1,78 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +// Modified by T.Murai + +#if !defined(lint) && !defined(__CODECENTER__) +static char tanmap_id[] = "@(#) 102.1 $Id: tanmap.h,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" + +static struct funccfunc tan_funcs[] = { + {CANNA_FN_FunctionalInsert ,TanKakuteiYomiInsert }, + {CANNA_FN_Forward ,TanForwardBunsetsu }, + {CANNA_FN_Backward ,TanBackwardBunsetsu }, + {CANNA_FN_Next ,TanNextKouho }, + {CANNA_FN_Prev ,TanPreviousKouho }, + {CANNA_FN_BeginningOfLine ,TanBeginningOfBunsetsu }, + {CANNA_FN_EndOfLine ,TanEndOfBunsetsu }, + {CANNA_FN_DeletePrevious ,TanDeletePrevious }, + {CANNA_FN_KillToEndOfLine ,TanChooseHeadChar }, + {CANNA_FN_DeleteNext ,TanChooseTailChar }, + {CANNA_FN_Henkan ,TanHenkan }, + {CANNA_FN_HenkanOrInsert ,TanHenkan }, + {CANNA_FN_HenkanOrNothing ,TanHenkan }, + {CANNA_FN_Kakutei ,YomiKakutei }, + {CANNA_FN_Extend ,TanExtendBunsetsu }, + {CANNA_FN_Shrink ,TanShrinkBunsetsu }, + {CANNA_FN_AdjustBunsetsu ,TanBunsetsuMode }, + {CANNA_FN_Quit ,TanMuhenkan }, + {CANNA_FN_KouhoIchiran ,TanKouhoIchiran }, + {CANNA_FN_BubunMuhenkan ,TanBubunMuhenkan }, + {CANNA_FN_Zenkaku ,TanZenkaku }, + {CANNA_FN_Hankaku ,TanHankaku }, + {CANNA_FN_Hiragana ,TanHiragana }, + {CANNA_FN_Katakana ,TanKatakana }, + {CANNA_FN_Romaji ,TanRomaji }, + {CANNA_FN_ToUpper ,TanUpper }, + {CANNA_FN_ToLower ,TanRomaji }, + {CANNA_FN_Capitalize ,TanCapitalize }, + {CANNA_FN_KanaRotate ,TanKanaRotate }, + {CANNA_FN_RomajiRotate ,TanRomajiRotate }, + {CANNA_FN_CaseRotate ,TanCaseRotateForward }, + {CANNA_FN_BubunKakutei ,TanBubunKakutei }, +#ifdef BUNPOU_DISPLAY + {CANNA_FN_ConvertAsHex ,TanPrintBunpou }, +#endif + {CANNA_FN_Nop ,TanNop }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {0 ,0 }, +}; + +extern searchfunc(...); +KanjiModeRec tankouho_mode = { + searchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + tan_funcs, +}; diff --git a/src/add-ons/input_server/methods/canna/lib/uiutil.c b/src/add-ons/input_server/methods/canna/lib/uiutil.c new file mode 100644 index 0000000000..6f8697bbfb --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/uiutil.c @@ -0,0 +1,577 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: uiutil.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#include "canna.h" +#include "patchlevel.h" + +#ifndef NO_EXTEND_MENU + +typedef struct { + char *title; + int func; + int funcd; +} e_menuitem; + +#define MENU_NEXT_MENU 0 /* ¥¨¥ó¥È¥ê¤Ï¥á¥Ë¥å¡¼¤Ç¤¢¤ë */ +#define MENU_FUNC_NUM 1 /* ¥¨¥ó¥È¥ê¤Ï¡Ø¤«¤ó¤Ê¡Ù¤Îµ¡Ç½ÈÖ¹æ¤Ç¤¢¤ë */ + +#ifdef STANDALONE /* This is not used in Windows environment 1996.7.30 kon */ +#define MT_HELP 0 +#define MT_SONOTA 1 +#define MT_KIGO 2 +#define MT_TANGO 3 +#define MT_HENKAN 4 +#define MT_FILE 5 +#else +#define MT_HELP 0 +#define MT_SONOTA 1 +#define MT_KIGO 2 +#define MT_SERV 3 +#define MT_TANGO 4 +#define MT_HENKAN 5 +#define MT_FILE 6 +#endif + +static e_menuitem e_helptable[] = { + /* µ­¹æÆþÎÏ */ + {"\265\255\271\346\306\376\316\317", MENU_NEXT_MENU, MT_KIGO}, + /* ¥³¡¼¥ÉÆþÎÏ */ + {"\245\263\241\274\245\311\306\376\316\317", MENU_FUNC_NUM, CANNA_FN_HexMode}, + /* Éô¼óÆþÎÏ */ + {"\311\364\274\363\306\376\316\317", MENU_FUNC_NUM, CANNA_FN_BushuMode}, + /* ñ¸ìÅÐÏ¿ */ + {"\303\261\270\354\305\320\317\277", MENU_NEXT_MENU, MT_TANGO}, + /* ´Ä¶­ÀßÄê */ + {"\264\304\266\255\300\337\304\352", MENU_NEXT_MENU, MT_SONOTA}, +}; + +static e_menuitem e_uusonotatable[] = { +#ifdef WIN + {"ÊÑ´¹Êý¼°", MENU_NEXT_MENU, MT_HENKAN}, +#ifndef STANDALONE // This is not used in Windows environment + {"¥µ¡¼¥ÐÁàºî", MENU_NEXT_MENU, MT_SERV}, +#endif + {"¼­½ñ¥Þ¥¦¥ó¥È¡¿¥¢¥ó¥Þ¥¦¥ó¥È", MENU_FUNC_NUM, CANNA_FN_DicMountMode}, + {"³Ø½¬¾õÂÖɽ¼¨", MENU_FUNC_NUM, CANNA_FN_ShowGakushu}, + {"¥Ð¡¼¥¸¥ç¥óɽ¼¨", MENU_FUNC_NUM, CANNA_FN_ShowVersion}, + {"¥Õ¥¡¥¤¥ëɽ¼¨", MENU_NEXT_MENU, MT_FILE}, +#else + /* ÊÑ´¹Êý¼° */ + {"\312\321\264\271\312\375\274\260", MENU_NEXT_MENU, MT_HENKAN}, +#ifndef STANDALONE /* This is not used in Windows environment 1996.7.30 kon */ + /* ¥µ¡¼¥ÐÁàºî */ + {"\245\265\241\274\245\320\301\340\272\356", MENU_NEXT_MENU, MT_SERV}, +#endif + /* ¼­½ñ¥Þ¥¦¥ó¥È¡¿¥¢¥ó¥Þ¥¦¥ó¥È */ + {"\274\255\275\361\245\336\245\246\245\363\245\310\241\277\245\242\245\363\245\336\245\246\245\363\245\310", MENU_FUNC_NUM, CANNA_FN_DicMountMode}, + /* ³Ø½¬¾õÂÖɽ¼¨ */ + {"\263\330\275\254\276\365\302\326\311\275\274\250", MENU_FUNC_NUM, CANNA_FN_ShowGakushu}, + /* ¥Ð¡¼¥¸¥ç¥óɽ¼¨ */ + {"\245\320\241\274\245\270\245\347\245\363\311\275\274\250", MENU_FUNC_NUM, CANNA_FN_ShowVersion}, + /* ¥Õ¥¡¥¤¥ëɽ¼¨ */ + {"\245\325\245\241\245\244\245\353\311\275\274\250", MENU_NEXT_MENU, MT_FILE}, +#endif /* WIN */ +}; + +static e_menuitem e_uukigotable[] = { + /* µ­¹æÁ´ÈÌ */ + {"\265\255\271\346\301\264\310\314", MENU_FUNC_NUM, CANNA_FN_KigouMode}, + /* ¥í¥·¥¢Ê¸»ú */ + {"\245\355\245\267\245\242\312\270\273\372", MENU_FUNC_NUM, CANNA_FN_RussianMode}, + /* ¥®¥ê¥·¥ãʸ»ú */ + {"\245\256\245\352\245\267\245\343\312\270\273\372", MENU_FUNC_NUM, CANNA_FN_GreekMode}, + /* ·ÓÀþ */ + {"\267\323\300\376", MENU_FUNC_NUM, CANNA_FN_LineMode}, +}; + +#ifndef STANDALONE /* This is not used in Windows environment 1996.7.30 kon */ +static e_menuitem e_uuservertable[] = { + /* ¥µ¡¼¥Ð¤ÎÀÚ¤êÎ¥¤· */ + {"\245\265\241\274\245\320\244\316\300\332\244\352\316\245\244\267", MENU_FUNC_NUM, CANNA_FN_DisconnectServer}, + /* ¥µ¡¼¥Ð¤ÎÀÚ¤êÂØ¤¨ */ + {"\245\265\241\274\245\320\244\316\300\332\244\352\302\330\244\250", MENU_FUNC_NUM, CANNA_FN_ChangeServerMode}, + /* ¥µ¡¼¥Ð¤Îɽ¼¨ */ + {"\245\265\241\274\245\320\244\316\311\275\274\250", MENU_FUNC_NUM, CANNA_FN_ShowServer}, +}; +#endif /* STANDALONE */ + +static e_menuitem e_uutangotable[] = { + /* ñ¸ìÅÐÏ¿ */ + {"\303\261\270\354\305\320\317\277", MENU_FUNC_NUM, CANNA_FN_DefineDicMode}, + /* ñ¸ìºï½ü */ + {"\303\261\270\354\272\357\275\374", MENU_FUNC_NUM, CANNA_FN_DeleteDicMode}, + /* ¼­½ñ¥Þ¥¦¥ó¥È¡¿¥¢¥ó¥Þ¥¦¥ó¥È */ + {"\274\255\275\361\245\336\245\246\245\363\245\310\241\277\245\242\245\363\245\336\245\246\245\363\245\310", MENU_FUNC_NUM, CANNA_FN_DicMountMode}, + }; + +static e_menuitem e_uuhenkantable[] = { + /* ϢʸÀáÊÑ´¹ */ + {"\317\242\312\270\300\341\312\321\264\271", MENU_FUNC_NUM, CANNA_FN_EnterRenbunMode}, + /* Ã༡¼«Æ°ÊÑ´¹ */ + {"\303\340\274\241\274\253\306\260\312\321\264\271", MENU_FUNC_NUM, CANNA_FN_EnterChikujiMode}, +}; + +static e_menuitem e_uufiletable[] = { + /* ¥í¡¼¥Þ»ú¤«¤ÊÊÑ´¹¥Æ¡¼¥Ö¥ë */ + {"\245\355\241\274\245\336\273\372\244\253\244\312\312\321\264\271\245\306\241\274\245\326\245\353", MENU_FUNC_NUM, CANNA_FN_ShowPhonogramFile}, + /* ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë */ + {"\245\253\245\271\245\277\245\336\245\244\245\272\245\325\245\241\245\244\245\353", MENU_FUNC_NUM, CANNA_FN_ShowCannaFile}, +}; + + +#define numitems(x) ((sizeof(x)) / sizeof(e_menuitem)) + +static struct _e_menu { + e_menuitem *mi; + int ni; +} e_me[] = { /* MT_ ¤Î½ç¤È¹ç¤ï¤»¤ë¤³¤È */ + {e_helptable, numitems(e_helptable)}, /* MT_HELP */ + {e_uusonotatable, numitems(e_uusonotatable)}, /* MT_SONOTA */ + {e_uukigotable, numitems(e_uukigotable)}, /* MT_KIGO */ +#ifndef STANDALONE /* This is not used in Windows environment 1996.7.30 kon */ + {e_uuservertable, numitems(e_uuservertable)}, /* MT_SERV */ +#endif /* STANDALONE */ + {e_uutangotable, numitems(e_uutangotable)}, /* MT_TANGO */ + {e_uuhenkantable, numitems(e_uuhenkantable)}, /* MT_HENKAN */ + {e_uufiletable, numitems(e_uufiletable)}, /* MT_FILE */ +}; + +#define N_BUILTIN_MENU (sizeof(e_me) / sizeof(struct _e_menu)) + +static menustruct *me[N_BUILTIN_MENU]; + +#define MBUFSIZE 512 + +static menustruct *copystruct(struct _e_menu *eucmenu); +static makeUiUtilEchoStr(uiContext d); +static void pushmenu(uiContext d, menustruct *tab); +static uuflExitCatch(uiContext d, int retval, mode_context env); +static uuflQuitCatch(uiContext d, int retval, mode_context env); +static menuinfo *newMenuInfo(menustruct *tab); +static menuinfo *findMenuInfo(menuinfo *p, menustruct *ms); + +void +freeMenu(menustruct *m) +{ + free(m->titles); + free(m->titledata); + free(m->body); + free(m); +} + +menustruct * +allocMenu(int n, int nc) +{ + WCHAR_T *wctab, **wcs; + menuitem *menubody; + menustruct *res; + + res = (menustruct *)malloc(sizeof(menustruct)); + if (res) { + wctab = (WCHAR_T *)malloc(sizeof(WCHAR_T) * nc); + if (wctab) { + wcs = (WCHAR_T **)malloc(sizeof(WCHAR_T *) * n); + if (wcs) { + menubody = (menuitem *)malloc(sizeof(menuitem) * n); + if (menubody) { + res->titles = wcs; + res->titledata = wctab; + res->body = menubody; + return res; + } + free(wcs); + } + free(wctab); + } + free(res); + } + return (menustruct *)0; +} + +static menustruct * +copystruct(struct _e_menu *eucmenu) +{ + int i, nc, len, n = eucmenu->ni; + e_menuitem *euctable = eucmenu->mi; + menuitem *menubody; + WCHAR_T *wp, **wpp; + menustruct *res = (menustruct *)0; +#ifndef WIN + WCHAR_T buf[MBUFSIZE]; +#else + WCHAR_T *buf = (WCHAR_T *)malloc(sizeof(WCHAR_T) * MBUFSIZE); + if (!buf) { + return res; + } +#endif + + /* ¥¿¥¤¥È¥ë¤Îʸ»ú¿ô¤ò¥«¥¦¥ó¥È */ + for (i = 0, nc = 0 ; i < n ; i++) { + len = MBstowcs(buf, euctable[i].title, MBUFSIZE); + nc += len + 1; + } + + res = allocMenu(n, nc); + if (res) { + menubody = res->body; + /* ¥¿¥¤¥È¥ëʸ»ú¤ò¥Ç¡¼¥¿¥Ð¥Ã¥Õ¥¡¤Ë¥³¥Ô¡¼ */ + for (i = 0, wp = res->titledata, wpp = res->titles ; i < n ; i++) { + len = MBstowcs(wp, euctable[i].title, MBUFSIZE); + *wpp++ = wp; + wp += len + 1; + + /* ¹½Â¤ÂΤò¥³¥Ô¡¼¤¹¤ë */ + switch (euctable[i].func) { + case MENU_NEXT_MENU: + menubody[i].flag = MENU_MENU; + menubody[i].u.fnum = euctable[i].funcd; + break; + case MENU_FUNC_NUM: + menubody[i].flag = MENU_FUNC; + menubody[i].u.fnum = euctable[i].funcd; + break; + } + } + res->nentries = n; + res->modeid = CANNA_MODE_ExtendMode; + } +#ifdef WIN + free(buf); +#endif + return res; +} + +/* + * menuitem·¿¤ÎÁ´¤Æ¤Î¹½Â¤ÂΤò"unsigned char"¤«¤é"WCHAR_T"¤ËÊÑ´¹¤¹¤ë + */ +int +initExtMenu(void) +{ + int i, j; + + for (i = 0 ; i < N_BUILTIN_MENU ; i++) { + me[i] = copystruct(e_me + i); + if (!me[i]) { + for (j = 0 ; j < i ; j++) { + freeMenu(me[j]); + } + return -1; + } + } + for (i = 0 ; i < N_BUILTIN_MENU ; i++) { + menustruct *m = me[i]; + for (j = 0 ; j < m->nentries ; j++) { + if (m->body[j].flag == MENU_MENU) { + m->body[j].u.menu_next = me[m->body[j].u.fnum]; + } + } + } + + return 0; +} + +#undef numitems + +void +finExtMenu(void) +{ + int i; + for (i = 0 ; i < N_BUILTIN_MENU ; i++) { + freeMenu(me[i]); + } +} +#endif /* NO_EXTEND_MENU */ + +static +makeUiUtilEchoStr(uiContext d) +{ + ichiranContext ic = (ichiranContext)d->modec; + + d->kanji_status_return->echoStr = ic->allkouho[*(ic->curIkouho)]; + d->kanji_status_return->length = WStrlen(ic->allkouho[*(ic->curIkouho)]); + d->kanji_status_return->revPos = 0; + d->kanji_status_return->revLen = 0; + + return(0); +} + +int +uiUtilIchiranTooSmall(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + makeUiUtilEchoStr(d); + return 0; +} + +#ifndef NO_EXTEND_MENU +static void +pushmenu(uiContext d, menustruct *tab) +{ + tab->prev = d->prevMenu; + d->prevMenu = tab; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * UI¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤Î°ìÍ÷ɽ¼¨(FirstLine) * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuflExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + menustruct *mtab, *ptab; + menuitem *men; + int cur; + + d->nbytes = 0; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + cur = fc->curIkouho; + if (fc->prevcurp) { + *(fc->prevcurp) = cur; + } + men = fc->table->body + cur; + ptab = fc->table; + + popForIchiranMode(d); + popCallback(d); + + pushmenu(d, ptab); + switch (men->flag) { + case MENU_MENU: + for (mtab = d->prevMenu ; mtab ; mtab = mtab->prev) { + if (mtab == men->u.menu_next) { + killmenu(d); + jrKanjiError = "\244\263\244\316\271\340\314\334\244\316\245\341" + "\245\313\245\345\241\274\244\317\272\306\265\242\305\252\244\313" + "\301\252\302\362\244\265\244\354\244\306\244\244\244\336\244\271"; + /* ¤³¤Î¹àÌܤΥá¥Ë¥å¡¼¤ÏºÆµ¢Åª¤ËÁªÂò¤µ¤ì¤Æ¤¤¤Þ¤¹ */ + makeGLineMessageFromString(d, jrKanjiError); + currentModeInfo(d); + return 0; + } + } + return showmenu(d, men->u.menu_next); + case MENU_FUNC: + if (men->u.fnum < 0) { + jrKanjiError = "\244\263\244\316\271\340\314\334\244\317\300\265\244\267" + "\244\257\304\352\265\301\244\265\244\354\244\306\244\244\244\336" + "\244\273\244\363"; + /* ¤³¤Î¹àÌܤÏÀµ¤·¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó */ + killmenu(d); + makeGLineMessageFromString(d, jrKanjiError); + currentModeInfo(d); + return 0; + } + else { + d->more.todo = 1; + d->more.fnum = men->u.fnum; + /* °Ê²¼¤Î£²¤Ä¤ÏɬÍפ«¤É¤¦¤«Îɤ¯Ê¬¤«¤é¤Ê¤¤ */ + GlineClear(d); + echostrClear(d); + return 0; + } + } + return NothingChangedWithBeep(d); /* ¤³¤³¤Ë¤ÏÍè¤Ê¤¤¤Ï¤º */ +} + +prevMenuIfExist(uiContext d) +{ + menustruct *m = d->prevMenu; + + if (m) { + d->prevMenu = m->prev; + d->kanji_status_return->info &= ~KanjiEmptyInfo; + + return showmenu(d, m); + } + else { + return 0; + } +} + +static +uuflQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* °ìÍ÷¤ò pop */ + + popForIchiranMode(d); + popCallback(d); + currentModeInfo(d); + + return prevMenuIfExist(d); +} +#endif /* NO_EXTEND_MENU */ + +/* cfuncdef + + UiUtilMode -- UI¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥â¡¼¥É¤Ë¤Ê¤ë¤È¤­¤Ë¸Æ¤Ð¤ì¤ë¡£ + + */ +UiUtilMode(uiContext d) +{ +#ifdef NO_EXTEND_MENU + d->kanji_status_return->info |= KanjiExtendInfo; + return 0; +#else + return showmenu(d, me[MT_HELP]); +#endif +} + +#ifndef NO_EXTEND_MENU +/* + * newMenuInfo() -- ¿·¤·¤¤¥á¥Ë¥å¡¼¾ðÊó¤Î¼èÆÀ + */ + +inline menuinfo * +newMenuInfo(menustruct *tab) +{ + menuinfo *res; + + res = (menuinfo *)malloc(sizeof(menuinfo)); + if (res) { + res->mstruct = tab; + res->curnum = 0; + } + return res; +} + +void +freeAllMenuInfo(menuinfo *p) +{ + menuinfo *q; + + while (p) { + q = p->next; + free(p); + p = q; + } +} + +inline menuinfo * +findMenuInfo(menuinfo *p, menustruct *ms) +{ + while (p) { + if (p->mstruct == ms) { + return p; + } + p = p->next; + } + return (menuinfo *)0; +} + +/* + * showmenu -- ¥á¥Ë¥å¡¼¤Îɽ¼¨ + * + * °ú¿ô + * d : uiContext + * table : ¥á¥Ë¥å¡¼¼«¿È(menustruct ¤Ø¤Î¥Ý¥¤¥ó¥¿) + */ + +int +showmenu(uiContext d, menustruct *table) +{ + yomiContext yc = (yomiContext)d->modec; + forichiranContext fc; + ichiranContext ic; + unsigned inhibit = 0; + int retval = 0; + menuinfo *minfo; + int *prevcurp = (int *)0; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + + minfo = findMenuInfo(d->minfo, table); + if (!minfo) { + minfo = newMenuInfo(table); + if (minfo) { + minfo->next = d->minfo; + d->minfo = minfo; + } + } + + if (minfo) { + prevcurp = &(minfo->curnum); + } + + d->status = 0; + + if((retval = getForIchiranContext(d)) == NG) + return(GLineNGReturn(d)); + fc = (forichiranContext)d->modec; + + fc->prevcurp = prevcurp; + fc->table = table; + + /* selectOne ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */ + fc->allkouho = table->titles; + fc->curIkouho = 0; + if (!cannaconf.HexkeySelect) + inhibit |= ((unsigned char)NUMBERING | (unsigned char)CHARINSERT); + else + inhibit |= (unsigned char)CHARINSERT; + if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, table->nentries, + BANGOMAX, inhibit, 0, WITHOUT_LIST_CALLBACK, + NO_CALLBACK, uuflExitCatch, + uuflQuitCatch, uiUtilIchiranTooSmall)) == NG) { + return(GLineNGReturnFI(d)); + } + + ic = (ichiranContext)d->modec; + ic->majorMode = CANNA_MODE_ExtendMode; + ic->minorMode = table->modeid; + currentModeInfo(d); + + if (prevcurp) { + *(ic->curIkouho) = *prevcurp; + } + else { + *(ic->curIkouho) = 0; + } + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return(retval); + } + + makeGlineStatus(d); + /* d->status = ICHIRAN_EVERYTIME; */ + + return(retval); +} +#endif /* NO_EXTEND_MENU */ diff --git a/src/add-ons/input_server/methods/canna/lib/uldefine.c b/src/add-ons/input_server/methods/canna/lib/uldefine.c new file mode 100644 index 0000000000..22876e4310 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/uldefine.c @@ -0,0 +1,1052 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: uldefine.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#include +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +// static void clearTourokuContext(tourokuContext p); +static tourokuContext newTourokuContext(void); +static uuTTangoEveryTimeCatch(uiContext d, int retval, mode_context env); +static uuTTangoExitCatch(uiContext d, int retval, mode_context env); +static uuT2TangoEveryTimeCatch(uiContext d, int retval, mode_context env); +static uuT2TangoExitCatch(uiContext d, int retval, mode_context nyc); +static uuT2TangoQuitCatch(uiContext d, int retval, mode_context env); +static uuTMakeDicYesCatch(uiContext d, int retval, mode_context env); +static uuTMakeDicQuitCatch(uiContext d, int retval, mode_context env); +static uuTMakeDicNoCatch(uiContext d, int retval, mode_context env); +static dicTourokuDo(uiContext d); +static struct dicname *findUsrDic(void); +static checkUsrDic(uiContext d); +static dicTourokuTangoPre(uiContext d); +static acDicTourokuTangoPre(uiContext d, int dn, mode_context dm); +static uuTYomiEveryTimeCatch(uiContext d, int retval, mode_context env); +static uuTYomiExitCatch(uiContext d, int retval, mode_context env); +static uuTYomiQuitCatch(uiContext d, int retval, mode_context env); +static dicTourokuYomi(uiContext d); +static acDicTourokuYomi(uiContext d, int dn, mode_context dm); +static dicTourokuYomiDo(uiContext d, canna_callback_t quitfunc); +static uuTHinshiExitCatch(uiContext d, int retval, mode_context env); +static uuTHinshiQuitCatch(uiContext d, int retval, mode_context env); +extern specialfunc (uiContext, int); + +#if !defined(NO_EXTEND_MENU) && !defined(WIN) +#ifdef luna88k +extern int errno; +#endif + + +static char *shinshitbl1[] = +{ + "\314\276\273\354", /* ̾»ì */ + "\270\307\315\255\314\276\273\354", /* ¸Çͭ̾»ì */ + "\306\260\273\354", /* ư»ì */ + "\267\301\315\306\273\354", /* ·ÁÍÆ»ì */ + "\267\301\315\306\306\260\273\354", /* ·ÁÍÆÆ°»ì */ + "\311\373\273\354", /* Éû»ì */ + "\244\275\244\316\302\276", /* ¤½¤Î¾ */ +}; + +static char *shinshitbl2[] = +{ + "\303\261\264\301\273\372", /* ñ´Á»ú */ + "\277\364\273\354", /* ¿ô»ì */ + "\317\242\302\316\273\354", /* Ï¢Âλì */ + "\300\334\302\263\273\354\241\246\264\266\306\260\273\354",/* Àܳ»ì¡¦´¶Æ°»ì */ +}; + + +static int tblflag; + +#define TABLE1 1 +#define TABLE2 2 + +#define HINSHI1_SZ (sizeof(shinshitbl1) / sizeof(char *)) +#define HINSHI2_SZ (sizeof(shinshitbl2) / sizeof(char *)) + +#define SONOTA HINSHI1_SZ - 1 + +static WCHAR_T *hinshitbl1[HINSHI1_SZ]; +static WCHAR_T *hinshitbl2[HINSHI2_SZ]; + +static WCHAR_T *b1, *b2; + +int +initHinshiTable(void) +{ + int retval = 0; + + retval = setWStrings(hinshitbl1, shinshitbl1, HINSHI1_SZ); + if (retval != NG) { + retval = setWStrings(hinshitbl2, shinshitbl2, HINSHI2_SZ); + b1 = WString("\303\261\270\354?["); + /* ñ¸ì */ + b2 = WString("]"); + if (!b1 || !b2) { + retval = NG; + } + } + return retval; +} + +static void +clearTango(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + + tc->tango_buffer[0] = 0; + tc->tango_len = 0; +} + +void +clearYomi(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + + tc->yomi_buffer[0] = 0; + tc->yomi_len = 0; +} + +inline void +clearTourokuContext(tourokuContext p) +{ + p->id = TOUROKU_CONTEXT; + p->genbuf[0] = 0; + p->qbuf[0] = 0; + p->tango_buffer[0] = 0; + p->tango_len = 0; + p->yomi_buffer[0] = 0; + p->yomi_len = 0; + p->curHinshi = 0; + p->newDic = (struct dicname *)0; + p->hcode[0] = 0; + p->katsuyou = 0; + p->workDic2 = (deldicinfo *)0; + p->workDic3 = (deldicinfo *)0; + p->udic = (WCHAR_T **)0; + p->delContext = 0; + +// return(0); +} + +static tourokuContext +newTourokuContext(void) +{ + tourokuContext tcxt; + + if ((tcxt = (tourokuContext)malloc(sizeof(tourokuContextRec))) + == (tourokuContext)NULL) { +#ifndef WIN + jrKanjiError = "malloc (newTourokuContext) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (newTourokuContext) \244\307\244\255\244\336" + "\244\273\244\363\244\307\244\267\244\277"; +#endif + return (tourokuContext)NULL; + } + clearTourokuContext(tcxt); + + return tcxt; +} + +getTourokuContext(uiContext d) +{ + tourokuContext tc; + int retval = 0; + + if (pushCallback(d, d->modec, NO_CALLBACK, NO_CALLBACK, + NO_CALLBACK, NO_CALLBACK) == 0) { +#ifndef WIN + jrKanjiError = "malloc (pushCallback) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + return(NG); + } + + if((tc = newTourokuContext()) == (tourokuContext)NULL) { + popCallback(d); + return(NG); + } + tc->majorMode = d->majorMode; + tc->next = d->modec; + d->modec = (mode_context)tc; + + tc->prevMode = d->current_mode; + + return(retval); +} + +void +popTourokuMode(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + + d->modec = tc->next; + d->current_mode = tc->prevMode; + free(tc); +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤Îñ¸ì¤ÎÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTTangoEveryTimeCatch(uiContext d, int retval, mode_context env) +{ + tourokuContext tc = (tourokuContext)env; + int len, echoLen, revPos; + WCHAR_T tmpbuf[ROMEBUFSIZE]; + /* I will leave this stack located array becase this will not be + compiled in case WIN is defined. 1996.6.5 kon */ + + retval = d->nbytes = 0; + +#ifdef DEBUG + checkModec(d); +#endif + if((echoLen = d->kanji_status_return->length) < 0 || d->more.todo) + return(retval); + + if (echoLen == 0) { + d->kanji_status_return->revPos = 0; + d->kanji_status_return->revLen = 0; + } + + if(d->kanji_status_return->info & KanjiGLineInfo && + d->kanji_status_return->gline.length > 0) { + echostrClear(d); + return 0; + } + + WStrncpy(tmpbuf, d->kanji_status_return->echoStr, echoLen); + tmpbuf[echoLen] = (WCHAR_T)'\0'; + + WStrcpy(d->genbuf, b1); + WStrcat(d->genbuf, tmpbuf); + WStrcat(d->genbuf, b2); + + revPos = WStrlen(b1); + + len = revPos + echoLen + 1; + WStrcpy(d->genbuf + len, tc->genbuf); /* ¥á¥Ã¥»¡¼¥¸ */ + + len += WStrlen(tc->genbuf); + tc->genbuf[0] = 0; + d->kanji_status_return->gline.line = d->genbuf; + d->kanji_status_return->gline.length = len; + if (d->kanji_status_return->revLen) { + d->kanji_status_return->gline.revPos = + d->kanji_status_return->revPos + revPos; + d->kanji_status_return->gline.revLen = d->kanji_status_return->revLen; + } + else { /* ȿžÎΰ褬¤Ê¤¤¾ì¹ç */ + d->kanji_status_return->gline.revPos = len - WStrlen(b2); + d->kanji_status_return->gline.revLen = 1; + } + d->kanji_status_return->info |= KanjiGLineInfo; + d->kanji_status_return->length = 0; + + echostrClear(d); +#ifdef WIN + if (checkGLineLen(d) < 0) { + echostrClear(d); + } +#else + checkGLineLen(d); +#endif + + return retval; +} + +static +uuTTangoExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + tc = (tourokuContext)d->modec; + + WStrncpy(tc->tango_buffer, d->buffer_return, retval); + tc->tango_buffer[retval] = (WCHAR_T)'\0'; + tc->tango_len = retval; + + return(dicTourokuYomi(d)); +} + +uuTTangoQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + freeAndPopTouroku(d); + GlineClear(d); + currentModeInfo(d); + return prevMenuIfExist(d); +} + +static +uuT2TangoEveryTimeCatch(uiContext d, int retval, mode_context env) +{ + yomiContext nyc; + int echoLen, pos, offset; + WCHAR_T tmpbuf[ROMEBUFSIZE]; + /* I will leave this stack located array becase this will not be + compiled in case WIN is defined. 1996.6.5 kon */ + + nyc = (yomiContext)env; + +#ifdef DEBUG + checkModec(d); +#endif + if(d->kanji_status_return->info & KanjiThroughInfo) { + extern KanjiModeRec yomi_mode; + _do_func_slightly(d, 0, (mode_context)nyc, &yomi_mode); + } else if(retval > 0){ + /* ÁÞÆþ¤¹¤ë */ + generalReplace(nyc->kana_buffer, nyc->kAttr, &nyc->kRStartp, + &nyc->kCurs, &nyc->kEndp, 0, d->buffer_return, + retval, HENKANSUMI); + generalReplace(nyc->romaji_buffer, nyc->rAttr, &nyc->rStartp, + &nyc->rCurs, &nyc->rEndp, 0, d->buffer_return, + retval, 0); + nyc->rStartp = nyc->rCurs; + nyc->kRStartp = nyc->kCurs; + } + + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + if((echoLen = d->kanji_status_return->length) < 0) + return(retval); + + WStrncpy(tmpbuf, d->kanji_status_return->echoStr, echoLen); + + WStrncpy(d->genbuf, nyc->kana_buffer, pos = offset = nyc->kCurs); + + WStrncpy(d->genbuf + pos, tmpbuf, echoLen); + pos += echoLen; + WStrncpy(d->genbuf + pos, nyc->kana_buffer + offset, nyc->kEndp - offset); + pos += nyc->kEndp - offset; + if (d->kanji_status_return->revLen == 0 && /* ȿžɽ¼¨Éôʬ¤Ê¤·¤Ç... */ + nyc->kEndp - offset) { /* ¸å¤í¤Ë¤¯¤Ã¤Ä¤±¤ëÉôʬ¤¬¤¢¤ë¤Î¤Ê¤é */ + d->kanji_status_return->revLen = 1; + d->kanji_status_return->revPos = offset + echoLen; + } + else { + d->kanji_status_return->revPos += offset; + } + d->kanji_status_return->echoStr = d->genbuf; + d->kanji_status_return->length = pos; + + return retval; +} + +/************************************************ + * ñ¸ìÅÐÏ¿¥â¡¼¥É¤òÈ´¤±¤ëºÝ¤ËɬÍפʽèÍý¤ò¹Ô¤¦ * + ************************************************/ +static +uuT2TangoExitCatch(uiContext d, int retval, mode_context nyc) +/* ARGSUSED */ +{ + yomiContext yc; + + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + yc = (yomiContext)d->modec; + d->nbytes = retval = yc->kEndp; + WStrncpy(d->buffer_return, yc->kana_buffer, retval); + d->buffer_return[retval] = (WCHAR_T)'\0'; + + RomajiClearYomi(d); + popYomiMode(d); + d->status = EXIT_CALLBACK; + + return retval; +} + +static +uuT2TangoQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + popYomiMode(d); + + d->status = QUIT_CALLBACK; + + return(0); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤Î¼­½ñºîÀ® * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTMakeDicYesCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + int err = 0, perr = 0; + tourokuContext tc; + WCHAR_T **dp; + extern defaultContext; + + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + tc = (tourokuContext)d->modec; + + if(defaultContext < 0) { + if((KanjiInit() < 0) || (defaultContext < 0)) { + jrKanjiError = KanjiInitError(); + freeAndPopTouroku(d); + defineEnd(d); + return(GLineNGReturn(d)); + } + } + /* ¼­½ñ¤òºî¤ë */ + if (RkwCreateDic(defaultContext, tc->newDic->name, 0x80) < 0) { + err++; if (errno == EPIPE) perr++; + MBstowcs(d->genbuf, "\274\255\275\361\244\316\300\270\300\256\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277", 256); + /* ¼­½ñ¤ÎÀ¸À®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } else if(RkwMountDic(defaultContext, tc->newDic->name, 0) < 0) { + err++; if (errno == EPIPE) perr++; + MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\336\245\246\245\363" + "\245\310\244\313\274\272\307\324\244\267\244\336\244\267\244\277", 256); + /* ¼­½ñ¤Î¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } else if(d->contextCache != -1 && + RkwMountDic(d->contextCache, tc->newDic->name, 0) < 0) { + err++; if (errno == EPIPE) perr++; + MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\336\245\246\245\363" + "\245\310\244\313\274\272\307\324\244\267\244\336\244\267\244\277", 256); + /* ¼­½ñ¤Î¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + + if(err) { + if (perr) { + jrKanjiPipeError(); + } + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + freeAndPopTouroku(d); + defineEnd(d); + currentModeInfo(d); + return(0); + } + + tc->newDic->dicflag = DIC_MOUNTED; + + /* ¼­½ñ¤Î¸õÊä¤ÎºÇ¸å¤ËÄɲ乤ë */ + dp = tc->udic; + if (dp) { + while (*dp) { + dp++; + } + *dp++ = WString(tc->newDic->name); + *dp = 0; + } + + return(dicTourokuTango(d, uuTTangoQuitCatch)); +} + +static +uuTMakeDicQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + freeAndPopTouroku(d); + + return prevMenuIfExist(d); +} + +static +uuTMakeDicNoCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + freeAndPopTouroku(d); + defineEnd(d); + currentModeInfo(d); + + GlineClear(d); + defineEnd(d); + return(retval); +} + +/* + ¥æ¡¼¥¶¼­½ñ¤Ç¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ò¼è¤ê½Ð¤¹½èÍý + */ +WCHAR_T ** +getUserDicName(uiContext d) +/* ARGSUSED */ +{ + int nmudic; /* ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¥æ¡¼¥¶¼­½ñ¤Î¿ô */ + struct dicname *p; + WCHAR_T **tourokup, **tp; + extern defaultContext; + + if(defaultContext < 0) { + if((KanjiInit() < 0) || (defaultContext < 0)) { + jrKanjiError = KanjiInitError(); + return (WCHAR_T **)0; + } + } + + for (nmudic = 0, p = kanjidicnames ; p ; p = p->next) { + if (p->dictype == DIC_USER && p->dicflag == DIC_MOUNTED) { + nmudic++; + } + } + + /* return BUFFER ¤Î alloc */ + if ((tourokup = (WCHAR_T **)calloc(nmudic + 2, sizeof(WCHAR_T *))) + == (WCHAR_T **)NULL) { + /* + 2 ¤Ê¤Î¤Ï 1 ¸ÄÁý¤¨¤ë²ÄǽÀ­¤¬¤¢¤ë¤Î¤ÈÂǤÁ»ß¤á¥Þ¡¼¥¯¤ò¤¤¤ì¤ë¤¿¤á */ +#ifndef WIN + jrKanjiError = "malloc (getUserDicName) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (getUserDicName) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + return (WCHAR_T **)0; + } + + for (tp = tourokup + nmudic, p = kanjidicnames ; p ; p = p->next) { + if (p->dictype == DIC_USER && p->dicflag == DIC_MOUNTED) { + *--tp = WString(p->name); + } + } + tourokup[nmudic] = (WCHAR_T *)0; + + return (WCHAR_T **)tourokup; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤Îñ¸ì¤ÎÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* »Ï¤á¤Ë¸Æ¤Ð¤ì¤ë´Ø¿ô */ + +dicTouroku(uiContext d) +{ + tourokuContext tc; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + if(dicTourokuDo(d) < 0) { + defineEnd(d); + return(GLineNGReturn(d)); + } + + tc = (tourokuContext)d->modec; + + /* ¼­½ñ¤¬Ìµ¤±¤ì¤Ð¼­½ñ¤òºî¤ë */ + if(!*tc->udic) { + checkUsrDic(d); + return(0); /* ¼­½ñ¤òºî¤ë¤«¤É¤¦¤«¤ò¼ÁÌ䤹¤ë¥â¡¼¥É¤ËÆþ¤ë(¤«¤â)¡£ + ¡Ö¤«¤â¡×¤Ã¤Æ¤Î¤Ï¡¢checkUsrDic ¤Ç¤Ê¤Ë¤¬¤·¤«¤ÎÌäÂ꤬ + ȯÀ¸¤·¤¿¾ì¹ç¤ÏÆþ¤é¤Ê¤¤¤³¤È¤òɽ¤¹¡£ */ + } + tblflag = TABLE1; + return(dicTourokuTango(d, uuTTangoQuitCatch)); +} + +static +dicTourokuDo(uiContext d) +{ + tourokuContext tc; + WCHAR_T **up; + + d->status = 0; + + /* ¥æ¡¼¥¶¼­½ñ¤Ç¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ò¼è¤Ã¤Æ¤¯¤ë */ + if((up = getUserDicName(d)) == 0) { + return(NG); + } + + if (getTourokuContext(d) < 0) { + if (up) { + WCHAR_T **p = up; + + for ( ; *p; p++) { + WSfree(*p); + } + free(up); + } + return(NG); + } + + tc = (tourokuContext)d->modec; + + tc->udic = up; + + return(0); +} + +/* + * ñ¸ìÅÐÏ¿ÍѼ­½ñ¤Î¥µ¡¼¥Á + * ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Ç°ìÈֻϤá¤Ë»ØÄꤵ¤ì¤Æ¤¤¤ë + * ñ¸ìÅÐÏ¿ÍѼ­½ñ¤ò¸«ÉÕ¤±¤ë + */ +static struct dicname * +findUsrDic(void) +{ + struct dicname *res = (struct dicname *)0, *p; + + for (p = kanjidicnames ; p ; p = p->next) { + if (p->dictype == DIC_USER) { + res = p; + } + } + return res; +} + +/* + * ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¼­½ñ¤Î¥Á¥§¥Ã¥¯ + * ¡¦¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Çñ¸ìÅÐÏ¿ÍѼ­½ñ¤È¤·¤Æ»ØÄꤵ¤ì¤Æ¤¤¤Æ¡¢ + * ¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Æ¤¤¤ë¼­½ñ¤¬¤¢¤ë + * ¢ª ¼­½ñ¤òºî¤ë(ºî¤ë¼­½ñ¤Ï£±¤Ä¤À¤±) + * ¡¦¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Çñ¸ìÅÐÏ¿ÍѼ­½ñ¤È¤·¤Æ»ØÄꤵ¤ì¤Æ¤¤¤ë¼­½ñ¤¬¤Ê¤¤ + * ¡¦¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Çñ¸ìÅÐÏ¿ÍѼ­½ñ¤È¤·¤Æ»ØÄꤵ¤ì¤Æ¤¤¤Æ¡¢ + * ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¼­½ñ¤¬¤Ê¤¤ + */ +static +checkUsrDic(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + coreContext ync; + struct dicname *u; + WCHAR_T xxxx[512]; + /* I will leave this stack located array becase this will not be + compiled in case WIN is defined. 1996.6.5 kon */ + + u = findUsrDic(); + + /* ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Ç¡¢Ã±¸ìÅÐÏ¿ÍѼ­½ñ¤Ï»ØÄꤵ¤ì¤Æ¤¤¤ë¤¬¡¢ + ¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Æ¤¤¤ë¤È¤­ */ + if (u) { + if (u->dicflag == DIC_MOUNT_FAILED) { + char tmpbuf[1024]; + sprintf(tmpbuf, "\303\261\270\354\305\320\317\277\315\321\274\255" + "\275\361\244\254\244\242\244\352\244\336\244\273\244\363\241\243" + "\274\255\275\361(%s)\244\362\272\356\300\256\244\267\244\336\244" + "\271\244\253?(y/n)", + u->name); + /* ñ¸ìÅÐÏ¿ÍѼ­½ñ¤¬¤¢¤ê¤Þ¤»¤ó¡£¼­½ñ(%s)¤òºîÀ®¤·¤Þ¤¹¤« */ + makeGLineMessageFromString(d, tmpbuf); + tc->newDic = u; /* ºî¤ë¼­½ñ */ + if(getYesNoContext(d, + NO_CALLBACK, uuTMakeDicYesCatch, + uuTMakeDicQuitCatch, uuTMakeDicNoCatch) < 0) { + defineEnd(d); + return(GLineNGReturn(d)); + } + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + ync = (coreContext)d->modec; + ync->majorMode = CANNA_MODE_ExtendMode; + ync->minorMode = CANNA_MODE_TourokuMode; + } + } + + /* ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤Ç¡¢Ã±¸ìÅÐÏ¿ÍѼ­½ñ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¤«¡¢ + »ØÄê¤Ï¤µ¤ì¤Æ¤¤¤ë¤¬¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤­ */ + if (!u || u->dicflag == DIC_NOT_MOUNTED) { + MBstowcs(xxxx, "\303\261\270\354\305\320\317\277\315\321\274\255\275\361" + "\244\254\273\330\304\352\244\265\244\354\244\306\244\244\244\336" + "\244\273\244\363", 512); + /* ñ¸ìÅÐÏ¿ÍѼ­½ñ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó */ + WStrcpy(d->genbuf, xxxx); + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + freeAndPopTouroku(d); + defineEnd(d); + currentModeInfo(d); + } + + return(0); +} + +dicTourokuTango(uiContext d, canna_callback_t quitfunc) +{ + tourokuContext tc = (tourokuContext)d->modec; + yomiContext yc, yc2; + int retval = 0; + + yc = GetKanjiString(d, (WCHAR_T *)0, 0, + CANNA_NOTHING_RESTRICTED, + (int)CANNA_YOMI_CHGMODE_INHIBITTED, + (int)CANNA_YOMI_END_IF_KAKUTEI, + CANNA_YOMI_INHIBIT_NONE, + uuTTangoEveryTimeCatch, uuTTangoExitCatch, + quitfunc); + if (yc == (yomiContext)0) { + freeAndPopTouroku(d); + defineEnd(d); + currentModeInfo(d); + return NoMoreMemory(); + } + yc2 = GetKanjiString(d, (WCHAR_T *)0, 0, + CANNA_NOTHING_RESTRICTED, + (int)CANNA_YOMI_CHGMODE_INHIBITTED, + (int)!CANNA_YOMI_END_IF_KAKUTEI, + CANNA_YOMI_INHIBIT_NONE, + uuT2TangoEveryTimeCatch, uuT2TangoExitCatch, + uuT2TangoQuitCatch); + if (yc2 == (yomiContext)0) { + popYomiMode(d); /* yc1 ¤ò pop ¤¹¤ë */ + popCallback(d); + freeAndPopTouroku(d); + defineEnd(d); + currentModeInfo(d); + return NoMoreMemory(); + } + yc2->generalFlags |= CANNA_YOMI_DELETE_DONT_QUIT; + + yc2->majorMode = CANNA_MODE_ExtendMode; + yc2->minorMode = CANNA_MODE_TourokuMode; + currentModeInfo(d); + + return(retval); +} + +static +dicTourokuTangoPre(uiContext d) +{ + return dicTourokuTango(d, uuTTangoQuitCatch); +} + +static +acDicTourokuTangoPre(uiContext d, int dn, mode_context dm) +/* ARGSUSED */ +{ + popCallback(d); + return dicTourokuTangoPre(d); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤ÎÆÉ¤ß¤ÎÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTYomiEveryTimeCatch(uiContext d, int retval, mode_context env) +{ + tourokuContext tc = (tourokuContext)env; + int len, echoLen, revPos; + WCHAR_T tmpbuf[ROMEBUFSIZE]; + + retval = d->nbytes = 0; + + if((echoLen = d->kanji_status_return->length) < 0) + return(retval); + + if (echoLen == 0) { + d->kanji_status_return->revPos = 0; + d->kanji_status_return->revLen = 0; + } + + /* ¼è¤ê¤¢¤¨¤º echoStr ¤¬ d->genbuf ¤«¤â¤·¤ì¤Ê¤¤¤Î¤Ç copy ¤·¤Æ¤ª¤¯ */ + WStrncpy(tmpbuf, d->kanji_status_return->echoStr, echoLen); + + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + revPos = MBstowcs(d->genbuf, "\303\261\270\354[", ROMEBUFSIZE); + /* ñ¸ì */ + WStrcpy(d->genbuf + revPos, tc->tango_buffer); + revPos += WStrlen(tc->tango_buffer); + revPos += MBstowcs(d->genbuf + revPos, "] \306\311\244\337?[", ROMEBUFSIZE - revPos); + /* ÆÉ¤ß */ + WStrncpy(d->genbuf + revPos, tmpbuf, echoLen); + len = echoLen + revPos; + d->genbuf[len++] = (WCHAR_T) ']'; + WStrcpy(d->genbuf + len, tc->genbuf); + len += WStrlen(tc->genbuf); + tc->genbuf[0] = 0; + d->kanji_status_return->gline.line = d->genbuf; + d->kanji_status_return->gline.length = len; + if (d->kanji_status_return->revLen) { + d->kanji_status_return->gline.revPos = + d->kanji_status_return->revPos + revPos; + d->kanji_status_return->gline.revLen = d->kanji_status_return->revLen; + } + else { /* ȿžÎΰ褬¤Ê¤¤¾ì¹ç */ + d->kanji_status_return->gline.revPos = len - 1; + d->kanji_status_return->gline.revLen = 1; + } + d->kanji_status_return->info |= KanjiGLineInfo; + echostrClear(d); +#ifdef WIN + if (checkGLineLen(d) < 0) { + echostrClear(d); + } +#else + checkGLineLen(d); +#endif + + return retval; +} + +static +uuTYomiExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + tc = (tourokuContext)d->modec; + + WStrncpy(tc->yomi_buffer, d->buffer_return, retval); + tc->yomi_buffer[retval] = (WCHAR_T)'\0'; + tc->yomi_len = retval; + + return(dicTourokuHinshi(d)); +} + +static uuTYomiQuitCatch (uiContext, int, mode_context); + +static +uuTYomiQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + clearTango(d); + clearYomi(d); + + return(dicTourokuTango(d, uuTTangoQuitCatch)); +} + +static +dicTourokuYomi(uiContext d) +{ + return(dicTourokuYomiDo(d, uuTYomiQuitCatch)); +} + +static +acDicTourokuYomi(uiContext d, int dn, mode_context dm) +/* ARGSUSED */ +{ + popCallback(d); + return dicTourokuYomi(d); +} + +static +dicTourokuYomiDo(uiContext d, canna_callback_t quitfunc) +{ + yomiContext yc; + tourokuContext tc = (tourokuContext)d->modec; + int retval = 0; + + if(tc->tango_len < 1) { + clearTango(d); + return canna_alert(d, "\303\261\270\354\244\362\306\376\316\317\244\267\244\306\244\257\244\300\244\265\244\244", acDicTourokuTangoPre); + /* ñ¸ì¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤ */ + } + + yc = GetKanjiString(d, (WCHAR_T *)0, 0, + CANNA_NOTHING_RESTRICTED, + (int)CANNA_YOMI_CHGMODE_INHIBITTED, + (int)CANNA_YOMI_END_IF_KAKUTEI, + (CANNA_YOMI_INHIBIT_HENKAN | CANNA_YOMI_INHIBIT_ASHEX | + CANNA_YOMI_INHIBIT_ASBUSHU), + uuTYomiEveryTimeCatch, uuTYomiExitCatch, + quitfunc); + if (yc == (yomiContext)0) { + freeAndPopTouroku(d); + defineEnd(d); + currentModeInfo(d); + return NoMoreMemory(); + } + yc->majorMode = CANNA_MODE_ExtendMode; + yc->minorMode = CANNA_MODE_TourokuMode; + currentModeInfo(d); + + return(retval); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤ÎÉÊ»ì¤ÎÁªÂò * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTHinshiExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + tourokuContext tc; + int cur; + + d->nbytes = 0; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + cur = fc->curIkouho; + + popForIchiranMode(d); + popCallback(d); + + if (tblflag == TABLE1 && cur == SONOTA) { + tblflag = TABLE2; + return dicTourokuHinshi(d); + } + + if (tblflag == TABLE2) { + cur += SONOTA; + } + + tc = (tourokuContext)d->modec; + + tc->curHinshi = cur; + + return(dicTourokuHinshiDelivery(d)); +} + +static +uuTHinshiQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* °ìÍ÷¤ò pop */ + + popForIchiranMode(d); + popCallback(d); + + if (tblflag == TABLE2) { + tblflag = TABLE1; + return dicTourokuHinshi(d); + } + + clearYomi(d); + + return(dicTourokuYomi(d)); +} + +dicTourokuHinshi(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + forichiranContext fc; + ichiranContext ic; + unsigned inhibit = 0; + int currentkouho, retval = 0, numkouho; + + d->status = 0; + + if(tc->yomi_len < 1) { + return canna_alert(d, "\306\311\244\337\244\362\306\376\316\317\244\267" + "\244\306\244\257\244\300\244\265\244\244", acDicTourokuYomi); + /* ÆÉ¤ß¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤ */ + } + + if((retval = getForIchiranContext(d)) < 0) { + freeDic(tc); + defineEnd(d); + return(GLineNGReturnTK(d)); + } + + fc = (forichiranContext)d->modec; + + /* selectOne ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */ + if (tblflag == TABLE2) { + fc->allkouho = hinshitbl2; + numkouho = HINSHI2_SZ; + } + else { + fc->allkouho = hinshitbl1; + numkouho = HINSHI1_SZ; + } + + fc->curIkouho = 0; + currentkouho = 0; + if (!cannaconf.HexkeySelect) + inhibit |= ((unsigned char)NUMBERING | (unsigned char)CHARINSERT); + else + inhibit |= (unsigned char)CHARINSERT; + + if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, numkouho, + BANGOMAX, inhibit, currentkouho, WITH_LIST_CALLBACK, + NO_CALLBACK, uuTHinshiExitCatch, + uuTHinshiQuitCatch, uiUtilIchiranTooSmall)) < 0) { + popForIchiranMode(d); + popCallback(d); + freeDic(tc); + defineEnd(d); + return(GLineNGReturnTK(d)); + } + + ic = (ichiranContext)d->modec; + ic->majorMode = CANNA_MODE_ExtendMode; + ic->minorMode = CANNA_MODE_TourokuHinshiMode; + currentModeInfo(d); + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return(retval); + } + + if ( !(ic->flags & ICHIRAN_ALLOW_CALLBACK) ) { + makeGlineStatus(d); + } + + /* d->status = ICHIRAN_EVERYTIME; */ + + return(retval); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * jrKanjiControl ÍÑ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +dicTourokuControl(uiContext d, WCHAR_T *tango, canna_callback_t quitfunc) +{ + tourokuContext tc; + + if(dicTourokuDo(d) < 0) { + return(GLineNGReturn(d)); + } + + tc = (tourokuContext)d->modec; + + if(!*tc->udic) { + if(checkUsrDic(d) < 0) + return(GLineNGReturn(d)); + else + return(0); + } + + if(tango == 0 || tango[0] == 0) { + return(dicTourokuTango(d, quitfunc)); + } + + WStrcpy(tc->tango_buffer, tango); + tc->tango_len = WStrlen(tc->tango_buffer); + + return(dicTourokuYomiDo(d, quitfunc)); +} +#endif /* NO_EXTEND_MENU */ diff --git a/src/add-ons/input_server/methods/canna/lib/uldelete.c b/src/add-ons/input_server/methods/canna/lib/uldelete.c new file mode 100644 index 0000000000..f9977f96ec --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/uldelete.c @@ -0,0 +1,1195 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: uldelete.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + + +#if !defined(NO_EXTEND_MENU) && !defined(WIN) +#include +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +static uuSYomiEveryTimeCatch(uiContext d, int retval, mode_context env); +static uuSYomiExitCatch(uiContext d, int retval, mode_context env); +static uuSYomiQuitCatch(uiContext d, int retval, mode_context env); +static dicSakujoYomi(uiContext d); +static acDicSakujoYomi(uiContext d, int dn, mode_context dm); +static acDicSakujoDictionary(uiContext d, int dn, mode_context dm); +static WCHAR_T **getMountDicName(uiContext d, int *num_return); +static void CloseDeleteContext(tourokuContext tc); +static getEffectDic(tourokuContext tc); +static uuSTangoExitCatch(uiContext d, int retval, mode_context env); +static uuSTangoQuitCatch(uiContext d, int retval, mode_context env); +static dicSakujoBgnBun(uiContext d, RkStat *st); +static dicSakujoEndBun(uiContext d); +static dicSakujoTango(uiContext d); +static getDeleteDic(mountContext mc); +static uuSDicExitCatch(uiContext d, int retval, mode_context env); +static uuSDicQuitCatch(uiContext d, int retval, mode_context env); +static dicSakujoDictionary(uiContext d); +static uuSDeleteYesCatch(uiContext d, int retval, mode_context env); +static uuSDeleteQuitCatch(uiContext d, int retval, mode_context env); +static uuSDeleteNoCatch(uiContext d, int retval, mode_context env); +static dicSakujoDo(uiContext d); + +extern int RkwGetServerVersion (int *, int *); +extern int RkwChmodDic (int, char *, int); + +static int dicSakujoYomi (uiContext), + dicSakujoEndBun (uiContext), + dicSakujoTango (uiContext), + dicSakujoDictionary (uiContext), + dicSakujoDo (uiContext); + +void +freeWorkDic3(tourokuContext tc) +{ + if (tc->workDic3) { + free(tc->workDic3); + tc->workDic3 = (deldicinfo *)0; + } +} + +void +freeWorkDic(tourokuContext tc) +{ + if (tc->workDic2) { + free(tc->workDic2); + tc->workDic2 = (deldicinfo *)0; + } + freeWorkDic3(tc); +} + +void +freeDic(tourokuContext tc) +{ + if (tc->udic) { + WCHAR_T **p = tc->udic; + + for ( ; *p; p++) { + WSfree(*p); + } + free(tc->udic); + } + freeWorkDic(tc); +} + +void +freeAndPopTouroku(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + + freeDic(tc); + popTourokuMode(d); + popCallback(d); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìºï½ü¤ÎÆÉ¤ß¤ÎÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +static +uuSYomiEveryTimeCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + int len, echoLen, revPos; + WCHAR_T tmpbuf[ROMEBUFSIZE]; + + retval = 0; + if((echoLen = d->kanji_status_return->length) < 0) + return(retval); + + if (echoLen == 0) { + d->kanji_status_return->revPos = 0; + d->kanji_status_return->revLen = 0; + } + + /* ¼è¤ê¤¢¤¨¤º echoStr ¤¬ d->genbuf ¤«¤â¤·¤ì¤Ê¤¤¤Î¤Ç copy ¤·¤Æ¤ª¤¯ */ + WStrncpy(tmpbuf, d->kanji_status_return->echoStr, echoLen); + + revPos = MBstowcs(d->genbuf, "\306\311\244\337?[", ROMEBUFSIZE); + /* ÆÉ¤ß */ + WStrncpy(d->genbuf + revPos, tmpbuf, echoLen); + *(d->genbuf + revPos + echoLen) = (WCHAR_T) ']'; + len = revPos + echoLen + 1; + *(d->genbuf + len) = (WCHAR_T) '\0'; + d->kanji_status_return->gline.line = d->genbuf; + d->kanji_status_return->gline.length = len; + if (d->kanji_status_return->revLen) { + d->kanji_status_return->gline.revPos = + d->kanji_status_return->revPos + revPos; + d->kanji_status_return->gline.revLen = d->kanji_status_return->revLen; + } + else { /* ȿžÎΰ褬¤Ê¤¤¾ì¹ç */ + d->kanji_status_return->gline.revPos = len - 1; + d->kanji_status_return->gline.revLen = 1; + } + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + d->kanji_status_return->info |= KanjiGLineInfo; + echostrClear(d); + checkGLineLen(d); + + return retval; +} + +static +uuSYomiExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + tc = (tourokuContext)d->modec; + + WStrncpy(tc->yomi_buffer, d->buffer_return, retval); + tc->yomi_buffer[retval] = (WCHAR_T)'\0'; + tc->yomi_len = WStrlen(tc->yomi_buffer); + + return dicSakujoTango(d); +} + +static +uuSYomiQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + clearYomi(d); + + freeAndPopTouroku(d); + GlineClear(d); + currentModeInfo(d); + + return prevMenuIfExist(d); +} + +static +dicSakujoYomi(uiContext d) +{ + yomiContext yc; + + d->status = 0; + + yc = GetKanjiString(d, (WCHAR_T *)NULL, 0, + CANNA_NOTHING_RESTRICTED, + (int)CANNA_YOMI_CHGMODE_INHIBITTED, + (int)CANNA_YOMI_END_IF_KAKUTEI, + (CANNA_YOMI_INHIBIT_HENKAN | CANNA_YOMI_INHIBIT_ASHEX | + CANNA_YOMI_INHIBIT_ASBUSHU), + uuSYomiEveryTimeCatch, uuSYomiExitCatch, + uuSYomiQuitCatch); + if (yc == (yomiContext)0) { + deleteEnd(d); + return NoMoreMemory(); + } + yc->majorMode = CANNA_MODE_ExtendMode; + yc->minorMode = CANNA_MODE_DeleteDicMode; + currentModeInfo(d); + + return 0; +} + +static +acDicSakujoYomi(uiContext d, int dn, mode_context dm) +/* ARGSUSED */ +{ + popCallback(d); + return dicSakujoYomi(d); +} + +static +acDicSakujoDictionary(uiContext d, int dn, mode_context dm) +/* ARGSUSED */ +{ + popCallback(d); + return dicSakujoDictionary(d); +} + +/* + * ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¼­½ñ¤«¤é WRITE ¸¢¤Î¤¢¤ë¤â¤Î¤ò¼è¤ê½Ð¤¹ + */ +static +WCHAR_T ** +getMountDicName(uiContext d, int *num_return) +/* ARGSUSED */ +{ + int nmmdic, check, majv, minv; + struct dicname *p; + WCHAR_T **tourokup, **tp; + extern defaultContext; + + if (defaultContext < 0) { + if ((KanjiInit() < 0) || (defaultContext < 0)) { +#ifdef STANDALONE +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363"; +#endif +#else +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\245\265" + "\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336" + "\244\273\244\363"; /* ¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó */ +#endif +#endif /* STANDALONE */ + return 0; + } + } + + /* ¥µ¡¼¥Ð¤Î Version ¤Ë¤è¤Ã¤Æ¼è¤ê½Ð¤¹¼­½ñ¤òʬ¤±¤ë */ + RkwGetServerVersion(&majv, &minv); + + if (canna_version(majv, minv) < canna_version(3, 2)) { + /* Version3.2 ¤è¤êÁ°¤Î¥µ¡¼¥Ð¤Î¾ì¹ç */ + for (nmmdic = 0, p = kanjidicnames; p; p = p->next) { + if (p->dicflag == DIC_MOUNTED && p->dictype == DIC_USER) { + nmmdic++; + } + } + } + else { + /* Version3.2 °Ê¹ß¤Î¥µ¡¼¥Ð¤Î¾ì¹ç */ + for (nmmdic = 0, p = kanjidicnames ; p ; p = p->next) { + if (p->dicflag == DIC_MOUNTED) { + check = RkwChmodDic(defaultContext, p->name, 0); + if (check >= 0 && (check & RK_ENABLE_WRITE)) { + nmmdic++; + } + } + } + } + + /* return BUFFER ¤Î alloc */ + if ((tourokup = (WCHAR_T **)calloc(nmmdic + 1, sizeof(WCHAR_T *))) + == (WCHAR_T **)NULL) { + /* + 1 ¤Ê¤Î¤ÏÂǤÁ»ß¤á¥Þ¡¼¥¯¤ò¤¤¤ì¤ë¤¿¤á */ + jrKanjiError = "malloc (getMountDicName) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + return 0; + } + + if (canna_version(majv, minv) < canna_version(3, 2)) { + /* Version3.2 ¤è¤êÁ°¤Î¥µ¡¼¥Ð¤Î¾ì¹ç */ + for (tp = tourokup + nmmdic, p = kanjidicnames ; p ; p = p->next) { + if (p->dicflag == DIC_MOUNTED && p->dictype == DIC_USER) { + *--tp = WString(p->name); + } + } + } + else { + /* Version3.2 °Ê¹ß¤Î¥µ¡¼¥Ð¤Î¾ì¹ç */ + for (tp = tourokup + nmmdic, p = kanjidicnames ; p ; p = p->next) { + if (p->dicflag == DIC_MOUNTED) { + check = RkwChmodDic(defaultContext, p->name, 0); + if (check >= 0 && (check & RK_ENABLE_WRITE)) { + *--tp = WString(p->name); + } + } + } + } + tourokup[nmmdic] = (WCHAR_T *)0; + *num_return = nmmdic; + + return tourokup; +} + +dicSakujo(uiContext d) +{ + WCHAR_T **mp, **p; + tourokuContext tc; + int num; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + + /* ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¼­½ñ¤Ç WRITE ¸¢¤Î¤¢¤ë¤â¤Î¤ò¼è¤Ã¤Æ¤¯¤ë */ + if ((mp = getMountDicName(d, &num)) != 0) { + if (getTourokuContext(d) != NG) { + tc = (tourokuContext)d->modec; + + tc->udic = mp; + if(!*mp) { + makeGLineMessageFromString(d, "\303\261\270\354\272\357\275\374" + "\262\304\307\275\244\312\274\255\275\361\244\254\302\270\272\337" + "\244\267\244\336\244\273\244\363"); + /* ñ¸ìºï½ü²Äǽ¤Ê¼­½ñ¤¬Â¸ºß¤·¤Þ¤»¤ó */ + + freeAndPopTouroku(d); + deleteEnd(d); + currentModeInfo(d); + return 0; + } + tc->nudic = num; + return dicSakujoYomi(d); + } + for ( p = mp; *p; p++) { + WSfree(*p); + } + free(mp); + } + deleteEnd(d); + return GLineNGReturn(d); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìºï½ü¤Îñ¸ì¤ÎÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static void +CloseDeleteContext(tourokuContext tc) +{ + if(tc->delContext >= 0) { + if (RkwCloseContext(tc->delContext) < 0) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + } + } +#ifdef DEBUG + else + printf("ERROR: delContext < 0\n"); +#endif +} + +/* + * »ØÄꤵ¤ì¤¿Ã±¸ì¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¼­½ñ¤ò¼è¤ê½Ð¤¹ + */ +static +getEffectDic(tourokuContext tc) +{ + int workContext, currentkouho, nbunsetsu, nelem = tc->nudic; + WCHAR_T **mdic, **cands, **work; + char dicname[1024], tmpbuf[64]; + RkLex lex[5]; + deldicinfo *dic; + + dic = (deldicinfo *)malloc((nelem + 1) * sizeof(deldicinfo)); + if (dic == (deldicinfo *)NULL) { +#ifndef WIN + jrKanjiError = "malloc (getEffectDic) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (getEffectDic) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + return NG; + } + tc->workDic2 = dic; + + if ((workContext = RkwCreateContext()) == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } +#ifndef WIN + jrKanjiError = "¼­½ñ¸¡º÷ÍÑ¥³¥ó¥Æ¥¯¥¹¥È¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "\274\255\275\361\270\241\272\367\315\321\245\263\245\363" + "\245\306\245\257\245\271\245\310\244\362\272\356\300\256\244\307" + "\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; +#endif + return NG; + } + +#ifdef STANDALONE + if ((RkwSetDicPath(workContext, "iroha")) == NG) { +#ifndef WIN + jrKanjiError = "¼­½ñ¥Ç¥£¥ì¥¯¥È¥ê¤òÀßÄê¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "\274\255\275\361\245\307\245\243\245\354\245\257\245\310\245\352\244\362\300\337\304\352\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; +#endif + CloseDeleteContext(tc); + return NG; + } +#endif /* STANDALONE */ + + for (mdic = tc->udic; *mdic; mdic++) { + WCstombs(dicname, *mdic, sizeof(dicname)); + if (RkwMountDic(workContext, dicname, 0) == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\274\255\275\361\270\241\272\367\315\321\245\263\245\363" + "\245\306\245\257\245\271\245\310\244\313\274\255\275\361\244\362" + "\245\336\245\246\245\363\245\310\244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¼­½ñ¸¡º÷ÍÑ¥³¥ó¥Æ¥¯¥¹¥È¤Ë¼­½ñ¤ò¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + RkwCloseContext(workContext); + return NG; + } + + nbunsetsu = RkwBgnBun(workContext, tc->yomi_buffer, tc->yomi_len, 0); + if (nbunsetsu == 1) { + if ((cands = getIchiranList(workContext, &nelem, ¤tkouho)) != 0) { + work = cands; + while (*work) { + if (WStrcmp(*work, tc->tango_buffer) == 0) { + dic->name = *mdic; + if (RkwXfer(workContext, currentkouho) == NG) { + if (errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\245\253\245\354\245\363\245\310\270\365\312\344" + "\244\362\274\350\244\352\275\320\244\273\244\336" + "\244\273\244\363\244\307\244\267\244\277"; + /* ¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + freeGetIchiranList(cands); + RkwEndBun(workContext, 0); + RkwUnmountDic(workContext, dicname); + RkwCloseContext(workContext); + return NG; + } + if (RkwGetLex(workContext, lex, 5) <= 0) { + if (errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\267\301\302\326\301\307\276\360\312\363\244\362" + "\274\350\244\352\275\320\244\273\244\336\244\273\244\363" + "\244\307\244\267\244\277"; + /* ·ÁÂÖÁǾðÊó¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + freeGetIchiranList(cands); + RkwEndBun(workContext, 0); + RkwUnmountDic(workContext, dicname); + RkwCloseContext(workContext); + return NG; + } + sprintf((char *)tmpbuf, "#%d#%d", lex[0].rownum, lex[0].colnum); + MBstowcs(dic->hcode, tmpbuf, 16); + dic++; + break; + } + work++; + } + freeGetIchiranList(cands); + } + } + + if (RkwEndBun(workContext, 0) == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316" + "\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267" + "\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + RkwUnmountDic(workContext, dicname); + RkwCloseContext(workContext); + return NG; + } + + if (RkwUnmountDic(workContext, dicname) == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\274\255\275\361\270\241\272\367\315\321\244\316\274\255" + "\275\361\244\362\245\242\245\363\245\336\245\246\245\363\245\310" + "\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; + /* ¼­½ñ¸¡º÷ÍѤμ­½ñ¤ò¥¢¥ó¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + RkwCloseContext(workContext); + return NG; + } + } + + if (RkwCloseContext(workContext) < 0) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\274\255\275\361\270\241\272\367\315\321\244\316\245\263" + "\245\363\245\306\245\257\245\271\245\310\244\362\245\257\245\355" + "\241\274\245\272\244\307\244\255\244\336\244\273\244\363\244\307" + "\244\267\244\277"; + /* ¼­½ñ¸¡º÷ÍѤΥ³¥ó¥Æ¥¯¥¹¥È¤ò¥¯¥í¡¼¥º¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + return NG; + } + + dic->name = (WCHAR_T *)0; + tc->nworkDic2 = dic - tc->workDic2; + return 0; +} + +static +uuSTangoExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + tourokuContext tc; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + freeGetIchiranList(fc->allkouho); + + popForIchiranMode(d); + popCallback(d); + + tc = (tourokuContext)d->modec; + WStrcpy(tc->tango_buffer, d->buffer_return); + tc->tango_buffer[d->nbytes] = 0; + tc->tango_len = d->nbytes; + + d->nbytes = 0; + + if (getEffectDic(tc) == NG) { + freeDic(tc); + deleteEnd(d); + return GLineNGReturnTK(d); + } + + return dicSakujoDictionary(d); +} + +static +uuSTangoQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + freeGetIchiranList(fc->allkouho); + + popForIchiranMode(d); + popCallback(d); + + clearYomi(d); + return dicSakujoYomi(d); +} + +/* + * ÆÉ¤ß¤ò»ØÄꤵ¤ì¤¿¼­½ñ¤«¤éÊÑ´¹¤¹¤ë + */ +static +dicSakujoBgnBun(uiContext d, RkStat *st) +{ + tourokuContext tc = (tourokuContext)d->modec; + int nbunsetsu; + char dicname[1024]; + WCHAR_T **mdic; + + if(!tc) { +#if !defined(DEBUG) && !defined(WIN) + printf("tc = NULL\n"); +#endif + } + if(!tc->udic) { +#if !defined(DEBUG) && !defined(WIN) + printf("tc->udic = NULL\n"); +#endif + } + + if((tc->delContext = RkwCreateContext())== NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\303\261\270\354\272\357\275\374\315\321\244\316\245\263" + "\245\363\245\306\245\257\245\271\245\310\244\362\272\356\300\256" + "\244\307\244\255\244\336\244\273\244\363"; + /* ñ¸ìºï½üÍѤΥ³¥ó¥Æ¥¯¥¹¥È¤òºîÀ®¤Ç¤­¤Þ¤»¤ó */ + return(NG); + } + +#ifdef STANDALONE + if ((RkwSetDicPath(tc->delContext, "iroha")) == NG) { +#ifndef WIN + jrKanjiError = "¼­½ñ¥Ç¥£¥ì¥¯¥È¥ê¤òÀßÄê¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "\274\255\275\361\245\307\245\243\245\354\245\257\245\310\245\352\244\362\300\337\304\352\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; +#endif + CloseDeleteContext(tc); + return NG; + } +#endif /* STANDALONE */ + + for (mdic = tc->udic; *mdic; mdic++) { + WCstombs(dicname, *mdic, sizeof(dicname)); + if (RkwMountDic(tc->delContext, dicname, 0) == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\303\261\270\354\272\357\275\374\315\321\244\316\274" + "\255\275\361\244\362\245\336\245\246\245\363\245\310\244\307\244" + "\255\244\336\244\273\244\363\244\307\244\267\244\277"; + /* ñ¸ìºï½üÍѤμ­½ñ¤ò¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + CloseDeleteContext(tc); + return(NG); + } + } + + if((nbunsetsu = RkwBgnBun(tc->delContext, tc->yomi_buffer, tc->yomi_len, 0)) + == -1) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + CloseDeleteContext(tc); + return(NG); + } + + if(RkwGetStat(tc->delContext, st) == -1) { + RkwEndBun(tc->delContext, 0); /* 0:³Ø½¬¤·¤Ê¤¤ */ + if(errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\245\271\245\306\245\244\245\277\245\271\244\362\274\350" + "\244\352\275\320\244\273\244\336\244\273\244\363\244\307\244\267" + "\244\277"; + /* ¥¹¥Æ¥¤¥¿¥¹¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿ */ + /* ¥¢¥ó¥Þ¥¦¥ó¥È¤·¤Æ¤Ê¤¤ */ + CloseDeleteContext(tc); + return(NG); + } + + return(nbunsetsu); +} + +static +dicSakujoEndBun(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + + if(RkwEndBun(tc->delContext, 0) == -1) { /* 0:³Ø½¬¤·¤Ê¤¤ */ + if(errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\316" + "\275\252\316\273\244\313\274\272\307\324\244\267\244\336\244\267" + "\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Î½ªÎ»¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return(NG); + } + + return(0); +} + +static +dicSakujoTango(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + forichiranContext fc; + ichiranContext ic; + WCHAR_T **allDelCands; + BYTE inhibit = 0; + int nbunsetsu, nelem, currentkouho, retval = 0; + RkStat st; + + if(tc->yomi_len < 1) { + return canna_alert(d, "\306\311\244\337\244\362\306\376\316\317\244\267" + "\244\306\244\257\244\300\244\265\244\244", acDicSakujoYomi); + /* ÆÉ¤ß¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤ */ + } + + if((nbunsetsu = dicSakujoBgnBun(d, &st)) == NG) { + freeDic(tc); + deleteEnd(d); + return(GLineNGReturnTK(d)); + } + if((nbunsetsu != 1) || (st.maxcand == 0)) { + /* ¸õÊ䤬¤Ê¤¤ */ + if(dicSakujoEndBun(d) == NG) { + freeDic(tc); + CloseDeleteContext(tc); + deleteEnd(d); + return(GLineNGReturnTK(d)); + } + + makeGLineMessageFromString(d, "\244\263\244\316\306\311\244\337\244\307" + "\305\320\317\277\244\265\244\354\244\277\303\261\270\354\244\317" + "\302\270\272\337\244\267\244\336\244\273\244\363"); + /* ¤³¤ÎÆÉ¤ß¤ÇÅÐÏ¿¤µ¤ì¤¿Ã±¸ì¤Ï¸ºß¤·¤Þ¤»¤ó */ + CloseDeleteContext(tc); + freeAndPopTouroku(d); + deleteEnd(d); + currentModeInfo(d); + return(0); + } + + /* ¤¹¤Ù¤Æ¤Î¸õÊä¤ò¼è¤ê½Ð¤¹ */ + if((allDelCands = + getIchiranList(tc->delContext, &nelem, ¤tkouho)) == 0) { + freeDic(tc); + dicSakujoEndBun(d); + CloseDeleteContext(tc); + deleteEnd(d); + return(GLineNGReturnTK(d)); + } + + if (dicSakujoEndBun(d) == NG) { + freeDic(tc); + CloseDeleteContext(tc); + deleteEnd(d); + return GLineNGReturnTK(d); + } + CloseDeleteContext(tc); + + if(getForIchiranContext(d) == NG) { + freeDic(tc); + freeGetIchiranList(allDelCands); + deleteEnd(d); + return(GLineNGReturnTK(d)); + } + + fc = (forichiranContext)d->modec; + fc->allkouho = allDelCands; + + if (!cannaconf.HexkeySelect) + inhibit |= ((BYTE)NUMBERING | (BYTE)CHARINSERT); + else + inhibit |= (BYTE)CHARINSERT; + + fc->curIkouho = currentkouho; /* ¸½ºß¤Î¥«¥ì¥ó¥È¸õÊäÈÖ¹æ¤òÊݸ¤¹¤ë */ + currentkouho = 0; /* ¥«¥ì¥ó¥È¸õÊ䤫¤é²¿ÈÖÌܤò¥«¥ì¥ó¥È¸õÊä¤È¤¹¤ë¤« */ + + /* ¸õÊä°ìÍ÷¤Ë°Ü¹Ô¤¹¤ë */ + if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, nelem, BANGOMAX, + inhibit, currentkouho, WITHOUT_LIST_CALLBACK, + NO_CALLBACK, uuSTangoExitCatch, + uuSTangoQuitCatch, uiUtilIchiranTooSmall)) == NG) { + freeDic(tc); + freeGetIchiranList(fc->allkouho); + deleteEnd(d); + return(GLineNGReturnTK(d)); + } + + ic = (ichiranContext)d->modec; + ic->majorMode = CANNA_MODE_ExtendMode; + ic->minorMode = CANNA_MODE_DeleteDicMode; + currentModeInfo(d); + + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return(retval); + } + + makeGlineStatus(d); + /* d->status = EVERYTIME_CALLBACK; */ + + return(retval); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìºï½ü¤Î¼­½ñ°ìÍ÷ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +getDeleteDic(mountContext mc) +{ + tourokuContext tc = (tourokuContext)mc->next; + int i, num = 0; + deldicinfo *dic, *srcp; + + /* ¤Þ¤º¡¢Ã±¸ìºï½ü¤¹¤ë¼­½ñ¤Î¿ô¤ò¿ô¤¨¤ë */ + for (i = 0; mc->mountList[i]; i++) { + if (mc->mountOldStatus[i] != mc->mountNewStatus[i]) { + num++; + } + } + + dic = (deldicinfo *)malloc((num + 1) * sizeof(deldicinfo)); + if (dic != (deldicinfo *)NULL) { + tc->workDic3 = dic; + + /* ¤É¤Î¼­½ñ¤«¤éñ¸ì¤òºï½ü¤¹¤ë¤« */ + srcp = tc->workDic2; + for (i = 0; mc->mountList[i]; i++, srcp++) { + if (mc->mountOldStatus[i] != mc->mountNewStatus[i]) { + *dic++ = *srcp; + } + } + dic->name = (WCHAR_T *)0; + tc->nworkDic3 = dic - tc->workDic3; + return 0; + } + jrKanjiError ="malloc (uuSDicExitCatch) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + return NG; +} + + +static +uuSDicExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + mountContext mc; + tourokuContext tc; + + d->nbytes = 0; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + mc = (mountContext)d->modec; + + if (getDeleteDic(mc) == NG) { + popMountMode(d); + popCallback(d); + tc = (tourokuContext)d->modec; + freeDic(tc); + deleteEnd(d); + return GLineNGReturnTK(d); + } + + popMountMode(d); + popCallback(d); + + tc = (tourokuContext)d->modec; + /* ¼­½ñ¤¬ÁªÂò¤µ¤ì¤Ê¤«¤Ã¤¿¤È¤­¤Ï¡¢¥á¥Ã¥»¡¼¥¸¤ò½Ð¤·¡¢ + ²¿¤«¤Î¥­¡¼¤¬ÆþÎϤµ¤ì¤¿¤é¡¢ ¼­½ñÁªÂò¤ËÌá¤ë¡£ */ + if (tc->nworkDic3 == 0) { + return canna_alert(d, "\274\255\275\361\244\362\301\252\302\362\244\267" + "\244\306\244\257\244\300\244\265\244\244", acDicSakujoDictionary); + /* ¼­½ñ¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤ */ + } + + return dicSakujoDo(d); +} + +static +uuSDicQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* °ìÍ÷¤ò pop */ + + popMountMode(d); + popCallback(d); + + freeWorkDic((tourokuContext)d->modec); + return dicSakujoTango(d); +} + +static +dicSakujoDictionary(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + mountContext mc; + ichiranContext ic; + deldicinfo *work; + BYTE inhibit = 0; + int retval, i, upnelem = tc->nworkDic2; + char *dicLbuf, **dicLp, *wptr; + BYTE *soldp, *snewp; + WCHAR_T *xxxx[100]; + + retval = d->nbytes = 0; + d->status = 0; + + if (upnelem == 1) { + work + = (deldicinfo *)malloc((1 /* upnelem(==1) */ + 1) * sizeof(deldicinfo)); + if (work != (deldicinfo *)NULL) { + tc->workDic3 = work; + *work++ = *tc->workDic2; /* ¹½Â¤ÂΤÎÂåÆþ */ + work->name = (WCHAR_T *)0; + tc->nworkDic3 = 1; /* work - tc->workDic3 == 1 */ + return dicSakujoDo(d); + } + jrKanjiError = "malloc (dicSakujoDictionary) \244\307\244\255\244\336" + "\244\273\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + freeDic(tc); + deleteEnd(d); + return GLineNGReturnTK(d); + } + + if ((dicLbuf = (char *)malloc(ROMEBUFSIZE)) != (char *)NULL) { + if ((dicLp = (char **)calloc(upnelem + 1, sizeof(char *))) + != (char **)NULL) { + wptr = dicLbuf; + for (work = tc->workDic2; work->name; work++) { + i = WCstombs(wptr, work->name, ROMEBUFSIZE); + wptr += i; + *wptr++ = '\0'; + } + for (wptr = dicLbuf, i = 0; i < upnelem ; i++) { + dicLp[i] = wptr; + while (*wptr++) + /* EMPTY */ + ; + } + dicLp[i] = (char *)NULL; + + /* ¸½ºß¤Î¾õÂ֤Ϥ¹¤Ù¤Æ off ¤Ë¤·¤Æ¤ª¤¯ */ + if ((soldp = (BYTE *)calloc(upnelem + 1, sizeof(BYTE))) + != (BYTE *)NULL) { + if ((snewp = (BYTE *)calloc(upnelem + 1, sizeof(BYTE))) + != (BYTE *)NULL) { + if ((retval = getMountContext(d)) != NG) { + mc = (mountContext)d->modec; + mc->mountOldStatus = soldp; + mc->mountNewStatus = snewp; + mc->mountList = dicLp; + + /* selectOnOff ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */ + + mc->curIkouho = 0; + if (!cannaconf.HexkeySelect) + inhibit |= ((BYTE)NUMBERING | (BYTE)CHARINSERT); + else + inhibit |= (BYTE)CHARINSERT; + + retval = setWStrings(xxxx, mc->mountList, 0); + if (retval == NG) { + popMountMode(d); + popCallback(d); + deleteEnd(d); + return GLineNGReturnTK(d); + } + if ((retval = selectOnOff(d, xxxx, &mc->curIkouho, upnelem, + BANGOMAX, 0, mc->mountOldStatus, + NO_CALLBACK, uuSDicExitCatch, + uuSDicQuitCatch, uiUtilIchiranTooSmall)) == NG) { + popMountMode(d); + popCallback(d); + deleteEnd(d); + return GLineNGReturnTK(d); + } + + ic = (ichiranContext)d->modec; + ic->majorMode = CANNA_MODE_ExtendMode; + ic->minorMode = CANNA_MODE_DeleteDicMode; + currentModeInfo(d); + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if (ic->tooSmall) { + jrKanjiError = "\274\255\275\361\260\354\315\367\315\321\244\316" + "\311\375\244\254\266\271\244\244\244\316\244\307\274\255" + "\275\361\244\316\301\252\302\362\244\254\244\307\244\255" + "\244\336\244\273\244\363"; + /* ¼­½ñ°ìÍ÷ÍѤÎÉý¤¬¶¹¤¤¤Î¤Ç¼­½ñ¤ÎÁªÂò¤¬¤Ç¤­¤Þ¤»¤ó */ + ichiranFin(d); + popCallback(d); /* OnOff ¤ò¥Ý¥Ã¥× */ + popMountMode(d); + popCallback(d); + currentModeInfo(d); + freeDic(tc); + deleteEnd(d); + return GLineNGReturnTK(d); + } + + makeGlineStatus(d); + /* d->status = ICHIRAN_EVERYTIME; */ + + return(retval); + } + free(snewp); + } + free(soldp); + } + free(dicLp); + } + free(dicLbuf); + } + jrKanjiError = "malloc (dicSakujoDictionary) \244\307\244\255\244\336" + "\244\273\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + freeDic(tc); + deleteEnd(d); + return GLineNGReturnTK(d); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìºï½ü * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuSDeleteYesCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + char dicname[1024]; + deldicinfo *dic; + int bufcnt, l; + extern defaultContext; + + deleteEnd(d); + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + tc = (tourokuContext)d->modec; + + if(defaultContext == -1) { + if((KanjiInit() < 0) || (defaultContext == -1)) { +#ifdef STANDALONE +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363"; +#endif +#else +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\245\265" + "\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336" + "\244\273\244\363"; +#endif +#endif + freeAndPopTouroku(d); + return(GLineNGReturn(d)); + } + } + + /* ¼­½ñ¤«¤éñ¸ì¤òºï½ü¤¹¤ë */ + /* ñ¸ìºï½üÍѤΰì¹Ô¤òºî¤ë(³Æ¼­½ñ¶¦ÄÌ) */ + WStraddbcpy(d->genbuf, tc->yomi_buffer, ROMEBUFSIZE); + l = WStrlen(tc->yomi_buffer); + d->genbuf[l] = (WCHAR_T)' '; + l += 1; + for (dic = tc->workDic3; dic->name; dic++) { + /* ñ¸ìºï½üÍѤΰì¹Ô¤òºî¤ë(³Æ¼­½ñ¸ÇÍ­) */ + WStrcpy(d->genbuf + l, dic->hcode); + bufcnt = l + WStrlen(dic->hcode); + d->genbuf[bufcnt] = (WCHAR_T)' '; + bufcnt += 1; + WStraddbcpy(d->genbuf + bufcnt, tc->tango_buffer, + ROMEBUFSIZE - bufcnt); + + WCstombs(dicname, dic->name, sizeof(dicname)); + if (RkwDeleteDic(defaultContext, dicname, d->genbuf) == NG) { + if (errno == EPIPE) + jrKanjiPipeError(); + MBstowcs(d->genbuf, "\303\261\270\354\272\357\275\374\244\307\244\255" + "\244\336\244\273\244\363\244\307\244\267\244\277", 512); + /* ñ¸ìºï½ü¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + goto close; + } + if (cannaconf.auto_sync) { + RkwSync(defaultContext, dicname); + } + } + + /* ºï½ü¤Î´°Î»¤òɽ¼¨¤¹¤ë */ + l = MBstowcs(d->genbuf, "\241\330", ROMEBUFSIZE); + /* ¡Ø */ + WStrcpy(d->genbuf + l, tc->tango_buffer); + l += WStrlen(tc->tango_buffer); + l += MBstowcs(d->genbuf + l, "\241\331(", ROMEBUFSIZE - l); + /* ¡Ù */ + WStrcpy(d->genbuf + l, tc->yomi_buffer); + l += WStrlen(tc->yomi_buffer); + l += MBstowcs(d->genbuf + l, ")\244\362\274\255\275\361 ", ROMEBUFSIZE - l); + /* ¤ò¼­½ñ */ + dic = tc->workDic3; + WStrcpy(d->genbuf + l, dic->name); + l += WStrlen(dic->name); + for (dic++; dic->name; dic++) { + l += MBstowcs(d->genbuf + l, " \244\310 ", ROMEBUFSIZE - l); + /* ¤È */ + WStrcpy(d->genbuf + l, dic->name); + l += WStrlen(dic->name); + } + l += MBstowcs(d->genbuf + l, " \244\253\244\351\272\357\275\374\244\267" + "\244\336\244\267\244\277", ROMEBUFSIZE - l); + /* ¤«¤éºï½ü¤·¤Þ¤·¤¿ */ + + close: + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + + freeAndPopTouroku(d); + + currentModeInfo(d); + + return(0); +} + +static +uuSDeleteQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc = (tourokuContext)env; + + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + if (tc->nworkDic2 == 1) { + freeWorkDic(tc); + return dicSakujoTango(d); + } + freeWorkDic3(tc); + return dicSakujoDictionary(d); +} + +static +uuSDeleteNoCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + freeAndPopTouroku(d); + deleteEnd(d); + currentModeInfo(d); + + GlineClear(d); + + return(retval); +} + +static +dicSakujoDo(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + int l; + deldicinfo *dic; + + l = MBstowcs(d->genbuf, "\241\330", ROMEBUFSIZE); + /* ¡Ø */ + WStrcpy(d->genbuf + l, tc->tango_buffer); + l += WStrlen(tc->tango_buffer); + l += MBstowcs(d->genbuf + l, "\241\331(", ROMEBUFSIZE - l); + /* ¡Ù */ + WStrcpy(d->genbuf + l, tc->yomi_buffer); + l += WStrlen(tc->yomi_buffer); + l += MBstowcs(d->genbuf + l, ")\244\362\274\255\275\361 ", ROMEBUFSIZE - l); + /* ¤ò¼­½ñ */ + dic = tc->workDic3; + WStrcpy(d->genbuf + l, dic->name); + l += WStrlen(dic->name); + for (dic++; dic->name; dic++) { + l += MBstowcs(d->genbuf + l, " \244\310¤È ", ROMEBUFSIZE - l); + /* ¤È */ + WStrcpy(d->genbuf + l, dic->name); + l += WStrlen(dic->name); + } + l += MBstowcs(d->genbuf + l, " \244\253\244\351\272\357\275\374\244\267" + "\244\336\244\271\244\253?(y/n)", ROMEBUFSIZE - l); + /* ¤«¤éºï½ü¤·¤Þ¤¹¤« */ + if (getYesNoContext(d, + NO_CALLBACK, uuSDeleteYesCatch, + uuSDeleteQuitCatch, uuSDeleteNoCatch) == NG) { + freeDic(tc); + deleteEnd(d); + return(GLineNGReturnTK(d)); + } + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + + return(0); +} +#endif /* !NO_EXTEND_MENU && !WIN */ diff --git a/src/add-ons/input_server/methods/canna/lib/ulhinshi.c b/src/add-ons/input_server/methods/canna/lib/ulhinshi.c new file mode 100644 index 0000000000..ebfbb4bfe9 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/ulhinshi.c @@ -0,0 +1,1089 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: ulhinshi.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#include +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +#ifndef NO_EXTEND_MENU +#ifdef luna88k +extern int errno; +#endif + +static void WSprintf(WCHAR_T *to_buf, WCHAR_T *x1, WCHAR_T *x2, WCHAR_T *from_buf); +static void EWStrcpy(WCHAR_T *buf, char *xxxx); +static int EWStrcmp(WCHAR_T *buf, char *xxxx); +static int EWStrncmp(WCHAR_T *buf, char *xxxx, int len); +static uuTHinshiYNQuitCatch(uiContext d, int retval, mode_context env); +static uuTHinshi2YesCatch(uiContext d, int retval, mode_context env); +static uuTHinshi2NoCatch(uiContext d, int retval, mode_context env); +static uuTHinshi1YesCatch(uiContext d, int retval, mode_context env); +static uuTHinshi1NoCatch(uiContext d, int retval, mode_context env); +static uuTHinshiQYesCatch(uiContext d, int retval, mode_context env); +static uuTHinshiQNoCatch(uiContext d, int retval, mode_context env); +static int makeHinshi(uiContext d); +static tourokuYes(uiContext d); +static tourokuNo(uiContext d); +static void makeDoushi(uiContext d); +static uuTDicExitCatch(uiContext d, int retval, mode_context env); +static uuTDicQuitCatch(uiContext d, int retval, mode_context env); +static tangoTouroku(uiContext d); + +static char *e_message[] = { +//#ifndef WIN +#ifdef WIN + /*0*/"¤µ¤é¤ËºÙ¤«¤¤ÉÊ»ìʬ¤±¤Î¤¿¤á¤Î¼ÁÌä¤ò¤·¤Æ¤âÎɤ¤¤Ç¤¹¤«?(y/n)", + /*1*/"ÆÉ¤ß¤È¸õÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£", + /*2*/"ÆÉ¤ß¤È¸õÊä¤Î ³èÍѤ¬°ã¤¤¤Þ¤¹¡£ÆþÎϤ·¤Ê¤ª¤·¤Æ¤¯¤À¤µ¤¤¡£", + /*3*/"ÆÉ¤ß¤È¸õÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Îã) Áᤤ", + /*4*/"ÆÉ¤ß¤È¸õÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Îã) ÀŤ«¤À", + /*5*/"¡Ö", + /*6*/"¤¹¤ë¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)", + /*7*/"¤Ê¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)", + /*8*/"¡×¤Ï¿Í̾¤Ç¤¹¤«?(y/n)", + /*9*/"¡×¤ÏÃÏ̾¤Ç¤¹¤«?(y/n)", + /*10*/"¤Ê¤¤¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)", + /*11*/"¡×¤Ï̾»ì¤È¤·¤Æ»È¤¤¤Þ¤¹¤«?(y/n)", + /*12*/"¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)", + /*13*/"¤È¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤«?(y/n)", +#ifdef STANDALONE + /*14*/"¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó", +#else + /*14*/"¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó", +#endif + /*15*/"ñ¸ìÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿", + /*16*/"¡Ø", + /*17*/"¡Ù", + /*18*/"¡Ê", + /*19*/"¡Ë¤òÅÐÏ¿¤·¤Þ¤·¤¿", + /*20*/"ñ¸ìÅÐÏ¿¤Ë¼ºÇÔ¤·¤Þ¤·¤¿", +#else + /*0*/"\244\265\244\351\244\313\272\331\244\253\244\244\311\312\273\354\312\254\244\261\244\316\244\277\244\341\244\316\274\301\314\344\244\362\244\267\244\306\244\342\316\311\244\244\244\307\244\271\244\253?(y/n)", + /* ¤µ¤é¤ËºÙ¤«¤¤ÉÊ»ìʬ¤±¤Î¤¿¤á¤Î¼ÁÌä¤ò¤·¤Æ¤âÎɤ¤¤Ç¤¹¤« */ + + /*1*/"\306\311\244\337\244\310\270\365\312\344\244\362\40\275\252\273\337\267\301\244\307\306\376\316\317\244\267\244\306\244\257\244\300\244\265\244\244\241\243", + /* ÆÉ¤ß¤È¸õÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£*/ + + /*2*/"\306\311\244\337\244\310\270\365\312\344\244\316\40\263\350\315\321\244\254\260\343\244\244\244\336\244\271\241\243\306\376\316\317\244\267\244\312\244\252\244\267\244\306\244\257\244\300\244\265\244\244\241\243", + /* ÆÉ¤ß¤È¸õÊä¤Î ³èÍѤ¬°ã¤¤¤Þ¤¹¡£ÆþÎϤ·¤Ê¤ª¤·¤Æ¤¯¤À¤µ¤¤¡£*/ + + /*3*/"\306\311\244\337\244\310\270\365\312\344\244\362\40\275\252\273\337\267\301\244\307\306\376\316\317\244\267\244\306\244\257\244\300\244\265\244\244\241\243\316\343) \301\341\244\244", + /* ÆÉ¤ß¤È¸õÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Îã) Áᤤ */ + + /*4*/"\306\311\244\337\244\310\270\365\312\344\244\362\40\275\252\273\337\267\301\244\307\306\376\316\317\244\267\244\306\244\257\244\300\244\265\244\244\241\243\316\343) \300\305\244\253\244\300", + /* ÆÉ¤ß¤È¸õÊä¤ò ½ª»ß·Á¤ÇÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£Îã) ÀŤ«¤À */ + + /*5*/"\241\326", /* ¡Ö */ + + /*6*/"\244\271\244\353\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)", + /* ¤¹¤ë¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */ + + /*7*/"\244\312\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)", + /* ¤Ê¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */ + + /*8*/"\241\327\244\317\277\315\314\276\244\307\244\271\244\253?(y/n)", + /* ¡×¤Ï¿Í̾¤Ç¤¹¤« */ + + /*9*/"\241\327\244\317\303\317\314\276\244\307\244\271\244\253?(y/n)", + /* ¡×¤ÏÃÏ̾¤Ç¤¹¤« */ + + /*10*/"\244\312\244\244\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)", + /* ¤Ê¤¤¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */ + + /*11*/"\241\327\244\317\314\276\273\354\244\310\244\267\244\306\273\310\244\244\244\336\244\271\244\253?(y/n)", + /* ¡×¤Ï̾»ì¤È¤·¤Æ»È¤¤¤Þ¤¹¤« */ + + /*12*/"\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)", + /* ¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */ + + /*13*/"\244\310\241\327\244\317\300\265\244\267\244\244\244\307\244\271\244\253?(y/n)", + /* ¤È¡×¤ÏÀµ¤·¤¤¤Ç¤¹¤« */ + +#ifdef STANDALONE + /*14*/"\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363", + /* ¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó */ +#else + /*14*/"\244\253\244\312\264\301\273\372\312\321\264\271\245\265\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336\244\273\244\363", + /* ¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó */ +#endif + + /*15*/"\303\261\270\354\305\320\317\277\244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277", + /* ñ¸ìÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + + /*16*/"\241\330", /* ¡Ø */ + + /*17*/"\241\331", /* ¡Ù */ + + /*18*/"\241\312", /* ¡Ê */ + + /*19*/"\241\313\244\362\305\320\317\277\244\267\244\336\244\267\244\277", + /* ¡Ë¤òÅÐÏ¿¤·¤Þ¤·¤¿ */ + + /*20*/"\303\261\270\354\305\320\317\277\244\313\274\272\307\324\244\267\244\336\244\267\244\277", + /* ñ¸ìÅÐÏ¿¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ +#endif +}; + +#define message_num (sizeof(e_message) / sizeof(char *)) +static WCHAR_T *message[message_num]; + +#ifdef WIN +static char sgyouA[] = "¤«¤¬¤µ¤¿¤Ê¤Ð¤Þ¤é¤ï"; +static char sgyouI[] = "¤­¤®¤·¤Á¤Ë¤Ó¤ß¤ê¤¤"; +static char sgyouU[] = "¤¯¤°¤¹¤Ä¤Ì¤Ö¤à¤ë¤¦"; +#else +static char sgyouA[] = "\244\253\244\254\244\265\244\277\244\312\244\320\244\336\244\351\244\357"; + /* ¤«¤¬¤µ¤¿¤Ê¤Ð¤Þ¤é¤ï */ + +static char sgyouI[] = "\244\255\244\256\244\267\244\301\244\313\244\323\244\337\244\352\244\244"; + /* ¤­¤®¤·¤Á¤Ë¤Ó¤ß¤ê¤¤ */ + +static char sgyouU[] = "\244\257\244\260\244\271\244\304\244\314\244\326\244\340\244\353\244\246"; + /* ¤¯¤°¤¹¤Ä¤Ì¤Ö¤à¤ë¤¦ */ +#endif + + +#define KAGYOU 0 +#define GAGYOU 1 +#define SAGYOU 2 +#define TAGYOU 3 +#define NAGYOU 4 +#define BAGYOU 5 +#define MAGYOU 6 +#define RAGYOU 7 +#define WAGYOU 8 + + +static WCHAR_T *gyouA; +static WCHAR_T *gyouI; +static WCHAR_T *gyouU; + +/* Á´¤Æ¤Î¥á¥Ã¥»¡¼¥¸¤ò"unsigned char"¤«¤é"WCHAR_T"¤ËÊÑ´¹¤¹¤ë */ +int +initHinshiMessage(void) +{ + int i; + + for(i = 0; i < message_num; i++) { + message[i] = WString(e_message[i]); + if(!message[i]) { + return(-1); + } + } + return 0; +} + +/* WSprintf(to_buf, x1, x2, from_buf) + :WSprintf(to_buf,"x1%sx2",from_buf); + */ +static void +WSprintf(WCHAR_T *to_buf, WCHAR_T *x1, WCHAR_T *x2, WCHAR_T *from_buf) +{ + WStrcpy(to_buf, x1); + WStrcat(to_buf, from_buf); + WStrcat(to_buf, x2); +} +#endif /* NO_EXTEND_MENU */ + +#ifndef WIN +void +EWStrcat(WCHAR_T *buf, char *xxxx) +{ + WCHAR_T x[1024]; + + MBstowcs(x, xxxx, 1024); + WStrcat(buf, x); +} +#endif + +#ifndef NO_EXTEND_MENU +static void +EWStrcpy(WCHAR_T *buf, char *xxxx) +{ + WCHAR_T x[1024]; + int len; + + len = MBstowcs(x, xxxx, 1024); + WStrncpy(buf, x, len); + buf[len] = (WCHAR_T)0; +} + +static int +EWStrcmp(WCHAR_T *buf, char *xxxx) +{ + WCHAR_T x[1024]; + + MBstowcs(x, xxxx, 1024); + return(WStrncmp(buf, x, WStrlen(x))); +} + +static int +EWStrncmp(WCHAR_T *buf, char *xxxx, int len) +/* ARGSUSED */ +{ + WCHAR_T x[1024]; + + MBstowcs(x, xxxx, 1024); + return(WStrncmp(buf, x, WStrlen(x))); +} + +int +initGyouTable(void) +{ + gyouA = WString(sgyouA); + gyouI = WString(sgyouI); + gyouU = WString(sgyouU); + + if (!gyouA || !gyouI || !gyouU) { + return NG; + } + return 0; +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìÁªÂò ¡ÁYes/No ¶¦ÄÌ Quit¡Á * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTHinshiYNQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); + + return(dicTourokuHinshi(d)); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìÁªÂò ¡ÁYes/No Â裲Ãʳ¬ ¶¦ÄÌ¥³¡¼¥ë¥Ð¥Ã¥¯¡Á * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTHinshi2YesCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + tourokuYes(d); /* Éʻ줬·è¤Þ¤ì¤Ð tc->hcode ¤Ë¥»¥Ã¥È¤¹¤ë */ + + tc = (tourokuContext)d->modec; + + if (!tc->qbuf[0]) { + if (tc->hcode[0]) { + /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */ + return(dicTourokuDictionary(d, uuTDicExitCatch, uuTDicQuitCatch)); + } + } + return(retval); +} + +static +uuTHinshi2NoCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + tourokuNo(d); /* Éʻ줬·è¤Þ¤ì¤Ð tc->hcode ¤Ë¥»¥Ã¥È¤¹¤ë */ + + tc = (tourokuContext)d->modec; + + if (!tc->qbuf[0]) { + if (tc->hcode[0]) { + /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */ + return(dicTourokuDictionary(d, uuTDicExitCatch, uuTDicQuitCatch)); + } + } + + return(retval); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìÁªÂò ¡ÁYes/No Â裱Ãʳ¬ ¥³¡¼¥ë¥Ð¥Ã¥¯¡Á * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTHinshi1YesCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + coreContext ync; + + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + tourokuYes(d); /* Éʻ줬·è¤Þ¤ì¤Ð tc->hcode ¤Ë¥»¥Ã¥È¤¹¤ë */ + + tc = (tourokuContext)d->modec; + + if(tc->qbuf[0]) { + /* ¼ÁÌ䤹¤ë */ + makeGLineMessage(d, tc->qbuf, WStrlen(tc->qbuf)); + if((retval = getYesNoContext(d, + NO_CALLBACK, uuTHinshi2YesCatch, + uuTHinshiYNQuitCatch, uuTHinshi2NoCatch)) == NG) { + defineEnd(d); + return(GLineNGReturnTK(d)); + } + ync = (coreContext)d->modec; + ync->majorMode = CANNA_MODE_ExtendMode; + ync->minorMode = CANNA_MODE_TourokuHinshiMode; + } else if(tc->hcode[0]) { + /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */ + return(dicTourokuDictionary(d, uuTDicExitCatch, uuTDicQuitCatch)); + } + + return(retval); +} + +static +uuTHinshi1NoCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + coreContext ync; + + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + tourokuNo(d); /* Éʻ줬·è¤Þ¤ì¤Ð tc->hcode ¤Ë¥»¥Ã¥È¤¹¤ë */ + + tc = (tourokuContext)d->modec; + + if(tc->qbuf[0]) { + /* ¼ÁÌ䤹¤ë */ + makeGLineMessage(d, tc->qbuf, WStrlen(tc->qbuf)); + if((retval = getYesNoContext(d, + NO_CALLBACK, uuTHinshi2YesCatch, + uuTHinshiYNQuitCatch, uuTHinshi2NoCatch)) == NG) { + defineEnd(d); + return(GLineNGReturnTK(d)); + } + ync = (coreContext)d->modec; + ync->majorMode = CANNA_MODE_ExtendMode; + ync->minorMode = CANNA_MODE_TourokuHinshiMode; + } else if(tc->hcode[0]) { + /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */ + return(dicTourokuDictionary(d, uuTDicExitCatch, uuTDicQuitCatch)); + } + + return(retval); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìʬ¤±¤¹¤ë¡© * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTHinshiQYesCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + tourokuContext tc; + coreContext ync; + + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + tc = (tourokuContext)d->modec; + + makeGLineMessage(d, tc->qbuf, WStrlen(tc->qbuf)); /* ¼ÁÌä */ + if((retval = getYesNoContext(d, + NO_CALLBACK, uuTHinshi1YesCatch, + uuTHinshiYNQuitCatch, uuTHinshi1NoCatch)) == NG) { + defineEnd(d); + return(GLineNGReturnTK(d)); + } + ync = (coreContext)d->modec; + ync->majorMode = CANNA_MODE_ExtendMode; + ync->minorMode = CANNA_MODE_TourokuHinshiMode; + + return(retval); +} + +static +uuTHinshiQNoCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* yesNo ¤ò¥Ý¥Ã¥× */ + + return(dicTourokuDictionary(d, uuTDicExitCatch, uuTDicQuitCatch)); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ñ¸ìÅÐÏ¿¤ÎÉÊ»ìÁªÂò * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static int makeHinshi(); + +dicTourokuHinshiDelivery(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + coreContext ync; + int retval = 0; + + makeHinshi(d); /* Éʻ졢¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¡¢¼ÁÌä¤ò¥»¥Ã¥È¤·¤Æ¤¯¤ë */ + +#if defined(DEBUG) && !defined(WIN) + if(iroha_debug) { + printf("tc->genbuf=%s, tc->qbuf=%s, tc->hcode=%s\n", tc->genbuf, tc->qbuf, + tc->hcode); + } +#endif + if(tc->genbuf[0]) { + /* ÆþÎϤµ¤ì¤¿¥Ç¡¼¥¿¤Ë¸í¤ê¤¬¤¢¤Ã¤¿¤Î¤Ç¡¢ + ¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤·¤ÆÆÉ¤ßÆþÎϤËÌá¤ë */ + clearYomi(d); + return(dicTourokuTango(d, uuTTangoQuitCatch)); + } else if(tc->qbuf[0] && cannaconf.grammaticalQuestion) { + /* ºÙ¤«¤¤ÉÊ»ìʬ¤±¤Î¤¿¤á¤Î¼ÁÌä¤ò¤¹¤ë */ + WStrcpy(d->genbuf, message[0]); + if((retval = getYesNoContext(d, + NO_CALLBACK, uuTHinshiQYesCatch, + uuTHinshiYNQuitCatch, uuTHinshiQNoCatch)) == NG) { + defineEnd(d); + return(GLineNGReturnTK(d)); + } + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + ync = (coreContext)d->modec; + ync->majorMode = CANNA_MODE_ExtendMode; + ync->minorMode = CANNA_MODE_TourokuHinshiMode; + return(retval); + } else if(tc->hcode[0]) { + /* Éʻ줬·è¤Þ¤Ã¤¿¤Î¤Ç¡¢ÅÐÏ¿¤¹¤ë¥æ¡¼¥¶¼­½ñ¤Î»ØÄê¤ò¹Ô¤¦ */ + return(dicTourokuDictionary(d, uuTDicExitCatch, uuTDicQuitCatch)); + } + return 0; +} + +/* + * ÁªÂò¤µ¤ì¤¿Éʻ줫¤é¼¡¤Îưºî¤ò¹Ô¤¦ + * + * tc->hcode ÉÊ»ì + * tc->qbuf ¼ÁÌä + * tc->genbuf ¥¨¥é¡¼ + */ +static int +makeHinshi(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + int tlen, ylen, yomi_katsuyou; + WCHAR_T tmpbuf[256]; + + tc->hcode[0] = 0; + tc->qbuf[0] = 0; + tc->genbuf[0] = 0; + + tlen = tc->tango_len; + ylen = tc->yomi_len; + + switch(tc->curHinshi) { + case MEISHI: + EWStrcpy(tc->hcode, "#T35"); + tc->katsuyou = 0; + WSprintf(tc->qbuf, message[5], message[6], tc->tango_buffer); + break; + + case KOYUMEISHI: + EWStrcpy(tc->hcode, "#KK"); + WSprintf(tc->qbuf, message[5], message[8], tc->tango_buffer); + break; + + case DOSHI: + + /* ÆþÎϤ¬½ª»ß·Á¤«¡© */ + tc->katsuyou = 0; + while (tc->katsuyou < GOBISUU && + tc->tango_buffer[tlen - 1] != gyouU[tc->katsuyou]) { + tc->katsuyou++; + } + yomi_katsuyou = 0; + while (yomi_katsuyou < GOBISUU && + tc->yomi_buffer[ylen - 1] != gyouU[yomi_katsuyou]) { + yomi_katsuyou++; + } + if((tc->katsuyou == GOBISUU) || (yomi_katsuyou == GOBISUU)){ + WStrcpy(tc->genbuf, message[1]); + return(0); + } + if(tc->katsuyou != yomi_katsuyou){ + WStrcpy(tc->genbuf, message[2]); + return(0); + } + + makeDoushi(d); /* ¾ÜºÙ¤ÎÉÊ»ì¤òɬÍפȤ·¤Ê¤¤¾ì¹ç */ + if (tc->katsuyou == RAGYOU) { + tc->curHinshi = RAGYODOSHI; + /* ̤Á³·Á¤ò¤Ä¤¯¤ë */ + WStrncpy(tmpbuf, tc->tango_buffer, tlen-1); + tmpbuf[tlen - 1] = gyouA[tc->katsuyou]; + tmpbuf[tlen] = (WCHAR_T)0; + WSprintf(tc->qbuf, message[5], message[10], tmpbuf); + } + else { + tc->curHinshi = GODAN; + WStrncpy(tmpbuf, tc->tango_buffer, tlen - 1); + tmpbuf[tlen - 1] = gyouI[tc->katsuyou]; + tmpbuf[tlen] = (WCHAR_T)'\0'; + WSprintf(tc->qbuf, message[5], message[11], tmpbuf); + } + break; + + case KEIYOSHI: + tc->katsuyou = 1; + if(tlen >= 1 && ylen >= 1 && + ((EWStrncmp(tc->tango_buffer+tlen-1, "\244\244", 1) != 0) || + (EWStrncmp(tc->yomi_buffer+ylen-1, "\244\244", 1) != 0))) { + /* ¤¤ */ + WStrcpy(tc->genbuf, message[3]); + return(0); + } + + EWStrcpy(tc->hcode, "#KY"); /* ¾ÜºÙ¤ÎÉÊ»ì¤òɬÍפȤ·¤Ê¤¤¾ì¹ç */ + WStrncpy(tmpbuf, tc->tango_buffer, tlen-1); + tmpbuf[tlen-1] = 0; + WSprintf(tc->qbuf, message[5], message[11], tmpbuf); + break; + + case KEIYODOSHI: + tc->katsuyou = 1; + if(tlen >= 1 && ylen >= 1 && + ((EWStrncmp(tc->tango_buffer+tlen-1, "\244\300", 1)) || + (EWStrncmp(tc->yomi_buffer+ylen-1, "\244\300", 1)))) { + /* ¤À */ + WStrcpy(tc->genbuf, message[4]); + return(0); + } + EWStrcpy(tc->hcode, "#T05"); /* ¾ÜºÙ¤ÎÉÊ»ì¤òɬÍפȤ·¤Ê¤¤¾ì¹ç */ + WStrncpy(tmpbuf, tc->tango_buffer, tlen-1); + tmpbuf[tlen-1] = 0; + WSprintf(tc->qbuf, message[5], message[6], tmpbuf); + break; + + case FUKUSHI: + EWStrcpy(tc->hcode, "#F14"); /* ¾ÜºÙ¤ÎÉÊ»ì¤òɬÍפȤ·¤Ê¤¤¾ì¹ç */ + tc->katsuyou = 0; + WSprintf(tc->qbuf, message[5], message[6], tc->tango_buffer); + break; + + case TANKANJI: + EWStrcpy(tc->hcode, "#KJ"); + break; + + case SUSHI: + EWStrcpy(tc->hcode, "#NN"); + break; + + case RENTAISHI: + EWStrcpy(tc->hcode, "#RT"); + break; + + case SETSUZOKUSHI: /* Àܳ»ì¡¦´¶Æ°»ì */ + EWStrcpy(tc->hcode, "#CJ"); + break; + + case SAHENMEISHI: + case MEISHIN: + tc->katsuyou = 0; + WSprintf(tc->qbuf, message[5], message[7], tc->tango_buffer); + break; + + case JINMEI: + case KOYUMEISHIN: + WSprintf(tc->qbuf, message[5], message[9], tc->tango_buffer); + break; + + case RAGYOGODAN: + WStrncpy(tmpbuf, tc->tango_buffer, tlen - 1); + tmpbuf[tlen - 1] = gyouI[tc->katsuyou]; + tmpbuf[tlen] = (WCHAR_T)'\0'; + WSprintf(tc->qbuf, message[5], message[11], tmpbuf); + break; + + case KAMISHIMO: + WStrncpy(tmpbuf, tc->tango_buffer, tlen - 1); + tmpbuf[tlen - 1] = (WCHAR_T)'\0'; + WSprintf(tc->qbuf, message[5], message[11], tmpbuf); + break; + + case KEIYODOSHIY: + case KEIYODOSHIN: + WStrncpy(tmpbuf, tc->tango_buffer, tlen - 1); + tmpbuf[tlen - 1] = 0; + WSprintf(tc->qbuf, message[5], message[11], tmpbuf); + break; + + case FUKUSHIY: + case FUKUSHIN: + WSprintf(tc->qbuf, message[5], message[13], tc->tango_buffer); + break; + } + + return(0); +} + +static +tourokuYes(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + + tc->hcode[0] = 0; + tc->qbuf[0] = 0; + tc->genbuf[0] = 0; + + switch(tc->curHinshi) { + case MEISHI: + tc->curHinshi = SAHENMEISHI; + makeHinshi(d); + break; + + case KOYUMEISHI: + tc->curHinshi = JINMEI; + makeHinshi(d); + break; + + case GODAN: /* ¥é¹Ô°Ê³°¤Î¸ÞÃʳèÍÑÆ°»ì */ + makeDoushi(d); + EWStrcat(tc->hcode, "r"); /* ½ñ¤¯¡¢µÞ¤°¡¢°Ü¤¹ */ + break; + + case RAGYODOSHI: + tc->curHinshi = RAGYOGODAN; + makeHinshi(d); + break; + + case KEIYOSHI: + EWStrcpy(tc->hcode, "#KYT"); /* ¤­¤¤¤í¤¤ */ + break; + + case KEIYODOSHI: + tc->curHinshi = KEIYODOSHIY; + makeHinshi(d); + break; + + case FUKUSHI: + tc->curHinshi = FUKUSHIY; + makeHinshi(d); + break; + + case MEISHIN: + EWStrcpy(tc->hcode, "#T15"); /* ¿§¡¹¡¢¶¯ÎÏ */ + break; + + case SAHENMEISHI: + EWStrcpy(tc->hcode, "#T10"); /* °Â¿´¡¢Éⵤ */ + break; + + case KOYUMEISHIN: + EWStrcpy(tc->hcode, "#CN"); /* Åìµþ */ + break; + + case JINMEI: + EWStrcpy(tc->hcode, "#JCN"); /* Ê¡Åç */ + break; + + case RAGYOGODAN: + EWStrcpy(tc->hcode, "#R5r"); /* ¼Õ¤ë */ + break; + + case KAMISHIMO: + EWStrcpy(tc->hcode, "#KSr"); /* À¸¤­¤ë¡¢Í¤±¤ë */ + break; + + case KEIYODOSHIY: + EWStrcpy(tc->hcode, "#T10"); /* ´Ø¿´¤À */ + break; + + case KEIYODOSHIN: + EWStrcpy(tc->hcode, "#T15"); /* °Õ³°¤À¡¢²Äǽ¤À */ + break; + + case FUKUSHIY: + EWStrcpy(tc->hcode, "#F04"); /* ¤Õ¤Ã¤¯¤é */ + break; + + case FUKUSHIN: + EWStrcpy(tc->hcode, "#F06"); /* ÆÍÁ³ */ + break; + } + + return(0); +} + +static +tourokuNo(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + int ylen; + + tc->hcode[0] = 0; + tc->qbuf[0] = 0; + tc->genbuf[0] = 0; + + switch( tc->curHinshi ) { + case MEISHI: + tc->curHinshi = MEISHIN; + makeHinshi(d); + break; + + case KOYUMEISHI: + tc->curHinshi = KOYUMEISHIN; + makeHinshi(d); + break; + + case GODAN: /* ¥é¹Ô°Ê³°¤Î¸ÞÃʳèÍÑÆ°»ì */ + makeDoushi(d); + break; + + case RAGYODOSHI: + ylen = tc->yomi_len; + if (ylen >= 2 && !(EWStrcmp(tc->yomi_buffer + ylen - 2, "\244\257\244\353"))) { /* ¤¯¤ë */ + EWStrcpy(tc->hcode, "#KX"); /* Íè¤ë */ + } + else if (ylen >=2 && !(EWStrcmp(tc->yomi_buffer + ylen - 2, "\244\271\244\353"))) { /* ¤¹¤ë */ + EWStrcpy(tc->hcode, "#SX"); /* ¤¹¤ë */ + } + else if (ylen >=2 && !(EWStrcmp(tc->yomi_buffer + ylen - 2, "\244\272\244\353"))) { /* ¤º¤ë */ + EWStrcpy(tc->hcode, "#ZX"); /* ½à¤º¤ë */ + } + else { + tc->curHinshi = KAMISHIMO; + makeHinshi(d); + } + break; + + case KEIYOSHI: + EWStrcpy(tc->hcode, "#KY"); /* Èþ¤·¤¤¡¢Áᤤ */ + break; + + case KEIYODOSHI: + tc->curHinshi = KEIYODOSHIN; + makeHinshi(d); + break; + + case FUKUSHI: + tc->curHinshi = FUKUSHIN; + makeHinshi(d); + break; + + case MEISHIN: + EWStrcpy(tc->hcode, "#T35"); /* »³¡¢¿å */ + break; + + case SAHENMEISHI: + EWStrcpy(tc->hcode, "#T30"); /* ÅØÎÏ¡¢¸¡ºº */ + break; + + case KOYUMEISHIN: + EWStrcpy(tc->hcode, "#KK"); /* ÆüËÜÅŵ¤ */ + break; + + case JINMEI: + EWStrcpy(tc->hcode, "#JN"); /* »°´È */ + break; + + case RAGYOGODAN: + EWStrcpy(tc->hcode, "#R5"); /* °ÒÄ¥¤ë */ + break; + + case KAMISHIMO: + EWStrcpy(tc->hcode, "#KS"); /* ¹ß¤ê¤ë¡¢Í¿¤¨¤ë */ + break; + + case KEIYODOSHIY: + EWStrcpy(tc->hcode, "#T13"); /* ¿¹²¤Æ¤À */ + break; + + case KEIYODOSHIN: + EWStrcpy(tc->hcode, "#T18"); /* ÊØÍø¤À¡¢ÀŤ«¤À */ + break; + + case FUKUSHIY: + EWStrcpy(tc->hcode, "#F12"); /* ¤½¤Ã¤È */ + break; + + case FUKUSHIN: + EWStrcpy(tc->hcode, "#F14"); /* ˰¤¯¤Þ¤Ç */ + break; + } + return(0); +} + +static void +makeDoushi(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + + switch(tc->katsuyou){ + case KAGYOU: + EWStrcpy( tc->hcode, "#K5" ); /* ÃÖ¤¯ */ + break; + case GAGYOU: + EWStrcpy( tc->hcode, "#G5" ); /* ¶Ä¤° */ + break; + case SAGYOU: + EWStrcpy( tc->hcode, "#S5" ); /* ÊÖ¤¹ */ + break; + case TAGYOU: + EWStrcpy( tc->hcode, "#T5" ); /* Àä¤Ä */ + break; + case NAGYOU: + EWStrcpy( tc->hcode, "#N5" ); /* »à¤Ì */ + break; + case BAGYOU: + EWStrcpy( tc->hcode, "#B5" ); /* ž¤Ö */ + break; + case MAGYOU: + EWStrcpy( tc->hcode, "#M5" ); /* ½»¤à */ + break; + case RAGYOU: + EWStrcpy( tc->hcode, "#R5" ); /* °ÒÄ¥¤ë */ + break; + case WAGYOU: + EWStrcpy( tc->hcode, "#W5" ); /* ¸À¤¦ */ + break; + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ¼­½ñ¤Î°ìÍ÷ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuTDicExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + int cur; + tourokuContext tc; + + d->nbytes = 0; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + cur = fc->curIkouho; + + popForIchiranMode(d); + popCallback(d); + + tc = (tourokuContext)d->modec; + + tc->workDic = cur; + + return(tangoTouroku(d)); +} + +static +uuTDicQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* °ìÍ÷¤ò pop */ + + popForIchiranMode(d); + popCallback(d); + + return(dicTourokuHinshi(d)); +} + +dicTourokuDictionary(uiContext d, int (*exitfunc )(...), int (*quitfunc )(...)) +{ + tourokuContext tc = (tourokuContext)d->modec; + forichiranContext fc; + ichiranContext ic; + WCHAR_T **work; + unsigned inhibit = 0; + int retval, upnelem = 0; + + retval = d->nbytes = 0; + d->status = 0; + + for(work = tc->udic; *work; work++) + upnelem++; + + if((retval = getForIchiranContext(d)) == NG) { + freeDic(tc); + defineEnd(d); + return(GLineNGReturnTK(d)); + } + fc = (forichiranContext)d->modec; + + /* selectOne ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */ + + fc->allkouho = tc->udic; + + fc->curIkouho = 0; + if (!cannaconf.HexkeySelect) + inhibit |= ((unsigned char)NUMBERING | (unsigned char)CHARINSERT); + else + inhibit |= (unsigned char)CHARINSERT; + + if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, upnelem, + BANGOMAX, inhibit, 0, WITHOUT_LIST_CALLBACK, + NO_CALLBACK, exitfunc, quitfunc, uiUtilIchiranTooSmall)) + == NG) { + if(fc->allkouho) + free(fc->allkouho); + popForIchiranMode(d); + popCallback(d); + defineEnd(d); + return(GLineNGReturnTK(d)); + } + + ic = (ichiranContext)d->modec; + ic->majorMode = CANNA_MODE_ExtendMode; + ic->minorMode = CANNA_MODE_TourokuDicMode; + currentModeInfo(d); + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return(retval); + } + + makeGlineStatus(d); + /* d->status = ICHIRAN_EVERYTIME; */ + + return(retval); +} + +/* + * ñ¸ìÅÐÏ¿¤ò¹Ô¤¦ + */ +static +tangoTouroku(uiContext d) +{ + tourokuContext tc = (tourokuContext)d->modec; + WCHAR_T ktmpbuf[256]; + WCHAR_T ttmpbuf[256]; + WCHAR_T line[ROMEBUFSIZE], line2[ROMEBUFSIZE]; + WCHAR_T xxxx[1024]; + char dicname[1024]; + extern int defaultContext; + int linecnt; + + defineEnd(d); + if(tc->katsuyou || (EWStrncmp(tc->hcode, "#K5", 3) == 0)) { + WStrncpy(ttmpbuf, tc->tango_buffer, tc->tango_len - 1); + ttmpbuf[tc->tango_len - 1] = (WCHAR_T)0; + WStrncpy(ktmpbuf, tc->yomi_buffer, tc->yomi_len - 1); + ktmpbuf[tc->yomi_len - 1] = 0; + } else { + WStrcpy(ttmpbuf, tc->tango_buffer); + WStrcpy(ktmpbuf, tc->yomi_buffer); + } + + /* ¼­½ñ½ñ¤­¹þ¤ßÍѤΰì¹Ô¤òºî¤ë */ + WStraddbcpy(line, ktmpbuf, ROMEBUFSIZE); + linecnt = WStrlen(line); + line[linecnt] = (WCHAR_T)' '; + linecnt++; + WStrcpy(line + linecnt, tc->hcode); + linecnt += WStrlen(tc->hcode); + line[linecnt] = (WCHAR_T)' '; + linecnt++; + WStraddbcpy(line + linecnt, ttmpbuf, ROMEBUFSIZE - linecnt); + + if(defaultContext == -1) { + if((KanjiInit() < 0) || (defaultContext == -1)) { + jrKanjiError = (char *)e_message[14]; + freeAndPopTouroku(d); + return(GLineNGReturn(d)); + } + } + /* ¼­½ñ¤ËÅÐÏ¿¤¹¤ë */ + WCstombs(dicname, tc->udic[tc->workDic], sizeof(dicname)); + + if (RkwDefineDic(defaultContext, dicname, line) != 0) { + /* Éʻ줬 #JCN ¤Î¤È¤­¤Ï¡¢ÅÐÏ¿¤Ë¼ºÇÔ¤·¤¿¤é¡¢#JN ¤È #CN ¤ÇÅÐÏ¿¤¹¤ë */ + if (EWStrncmp(tc->hcode, "#JCN", 4) == 0) { + WCHAR_T xxx[3]; + + /* ¤Þ¤º #JN ¤ÇÅÐÏ¿¤¹¤ë */ + EWStrcpy(xxx, "#JN"); + WStraddbcpy(line, ktmpbuf, ROMEBUFSIZE); + EWStrcat(line, " "); + WStrcat(line, xxx); + EWStrcat(line, " "); + linecnt = WStrlen(line); + WStraddbcpy(line + linecnt, ttmpbuf, ROMEBUFSIZE - linecnt); + + if (RkwDefineDic(defaultContext, dicname, line) == 0) { + /* #JN ¤ÇÅÐÏ¿¤Ç¤­¤¿¤È¤­¡¢¼¡¤Ë #CN ¤ÇÅÐÏ¿¤¹¤ë */ + EWStrcpy(xxx, "#CN"); + WStraddbcpy(line2, ktmpbuf, ROMEBUFSIZE); + EWStrcat(line2, " "); + WStrcat(line2, xxx); + EWStrcat(line2, " "); + linecnt = WStrlen(line2); + WStraddbcpy(line2 + linecnt, ttmpbuf, ROMEBUFSIZE - linecnt); + + if (RkwDefineDic(defaultContext, dicname, line2) == 0) { + goto success; + } + + /* #CN ¤ÇÅÐÏ¿¤Ç¤­¤Ê¤«¤Ã¤¿¤È¤­¡¢#JN ¤òºï½ü¤¹¤ë */ + if (RkwDeleteDic(defaultContext, dicname, line) == NG) { + /* #JN ¤¬ºï½ü¤Ç¤­¤Ê¤«¤Ã¤¿¤é¡¢"¼ºÇÔ¤·¤Þ¤·¤¿" */ + if (errno == EPIPE) + jrKanjiPipeError(); + WStrcpy(d->genbuf, message[20]); + goto close; + } + } + } + /* #JCN °Ê³°¤Î¤È¤­ + #JN ¤¬ÅÐÏ¿¤Ç¤­¤Ê¤«¤Ã¤¿¤È¤­ + #CN ¤¬ÅÐÏ¿¤Ç¤­¤º¡¢#JN ¤¬ºï½ü¤Ç¤­¤¿¤È¤­ */ + if (errno == EPIPE) + jrKanjiPipeError(); + WStrcpy(d->genbuf, message[15]); + goto close; + } + + success: + if (cannaconf.auto_sync) { + RkwSync(defaultContext, dicname); + } + /* ÅÐÏ¿¤Î´°Î»¤òɽ¼¨¤¹¤ë */ + WSprintf(d->genbuf, message[16], message[17], tc->tango_buffer); + WSprintf(xxxx, message[18], message[19], tc->yomi_buffer); + WStrcat(d->genbuf, xxxx); + + close: + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + + freeAndPopTouroku(d); + currentModeInfo(d); + + return(0); /* ñ¸ìÅÐÏ¿´°Î» */ +} +#endif /* NO_EXTEND_MENU */ diff --git a/src/add-ons/input_server/methods/canna/lib/ulkigo.c b/src/add-ons/input_server/methods/canna/lib/ulkigo.c new file mode 100644 index 0000000000..1dabf89fb5 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/ulkigo.c @@ -0,0 +1,382 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: ulkigo.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#include +#include "canna.h" + +#ifndef NO_EXTEND_MENU +extern int uiUtilIchiranTooSmall(); + +static +char *srussia_data[] = +{ + /*"§¡", "§¢", "§£", "§¤", "§¥", "§¦", "§§", "§¨",*/ + "\247\241", "\247\242", "\247\243", "\247\244", "\247\245", "\247\246", "\247\247", "\247\250", + + /*"§©", "§ª", "§«", "§¬", "§­", "§®", "§¯", "§°", */ + "\247\251", "\247\252", "\247\253", "\247\254", "\247\255", "\247\256", "\247\257", "\247\260", + + /*"§±", "§²", "§³", "§´", "§µ", "§¶", "§·", "§¸",*/ + "\247\261", "\247\262", "\247\263", "\247\264", "\247\265", "\247\266", "\247\267", "\247\270", + + /*"§¹", "§º", "§»", "§¼", "§½", "§¾", "§¿", "§À", */ + "\247\271", "\247\272", "\247\273", "\247\274", "\247\275", "\247\276", "\247\277", "\247\300", + + /*"§Á", "§Ñ", "§Ò", "§Ó", "§Ô", "§Õ", "§Ö", "§×",*/ + "\247\301", "\247\321", "\247\322", "\247\323", "\247\324", "\247\325", "\247\326", "\247\327", + + /*"§Ø", "§Ù", "§Ú", "§Û", "§Ü", "§Ý", "§Þ", "§ß",*/ + "\247\330", "\247\331", "\247\332", "\247\333", "\247\334", "\247\335", "\247\336", "\247\337", + + /*"§à", "§á", "§â", "§ã", "§ä", "§å", "§æ", "§ç",*/ + "\247\340", "\247\341", "\247\342", "\247\343", "\247\344", "\247\345", "\247\346", "\247\347", + + /*"§è", "§é", "§ê", "§ë", "§ì", "§í", "§î", "§ï",*/ + "\247\350", "\247\351", "\247\352", "\247\353", "\247\354", "\247\355", "\247\356", "\247\357", + + /*"§ð", "§ñ", */ + "\247\360", "\247\361", +}; + +#define UURD_SZ (sizeof(srussia_data) / sizeof(char *)) + +static +char *sgreek_data[] = +{ + /* "¦¡", "¦¢", "¦£", "¦¤", "¦¥", "¦¦", "¦§", "¦¨", */ + "\246\241", "\246\242", "\246\243", "\246\244", "\246\245", "\246\246", "\246\247", "\246\250", + + /* "¦©", "¦ª", "¦«", "¦¬", "¦­", "¦®", "¦¯", "¦°", */ + "\246\251", "\246\252", "\246\253", "\246\254", "\246\255", "\246\256", "\246\257", "\246\260", + + /* "¦±", "¦²", "¦³", "¦´", "¦µ", "¦¶", "¦·", "¦¸", */ + "\246\261", "\246\262", "\246\263", "\246\264", "\246\265", "\246\266", "\246\267", "\246\270", + + /* "¦Á", "¦Â", "¦Ã", "¦Ä", "¦Å", "¦Æ", "¦Ç", "¦È", */ + "\246\301", "\246\302", "\246\303", "\246\304", "\246\305", "\246\306", "\246\307", "\246\310", + + /* "¦É", "¦Ê", "¦Ë", "¦Ì", "¦Í", "¦Î", "¦Ï", "¦Ð", */ + "\246\311", "\246\312", "\246\313", "\246\314", "\246\315", "\246\316", "\246\317", "\246\320", + + /* "¦Ñ", "¦Ò", "¦Ó", "¦Ô", "¦Õ", "¦Ö", "¦×", "¦Ø", */ + "\246\321", "\246\322", "\246\323", "\246\324", "\246\325", "\246\326", "\246\327", "\246\330", +}; + +#define UUGD_SZ (sizeof(sgreek_data) / sizeof(char *)) + +static uuKigoExitDo(uiContext d, int retval); +static uuKigoRExitCatch(uiContext d, int retval, mode_context env); +static uuKigoGExitCatch(uiContext d, int retval, mode_context env); +static uuKigoKExitCatch(uiContext d, int retval, mode_context env); +static uuKigoQuitCatch(uiContext d, int retval, mode_context env); +static kigoZenpan(uiContext d); + +static WCHAR_T *russia_data[UURD_SZ]; +static WCHAR_T *greek_data[UUGD_SZ]; + +int +initUlKigoTable(void) +{ + int retval; + + retval = setWStrings(russia_data, srussia_data, UURD_SZ); + if (retval != NG) { + retval = setWStrings(greek_data, sgreek_data, UUGD_SZ); + } + return retval; +} + +#ifdef pcux_r32 +static +char *skeisen_data[] = +{ + /* "¬¤", "¬¥", "¬¦", "¬§", "¬¨", "¬©", "¬ª", "¬«", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬¬", "¬­", "¬®", "¬¯", "¬°", "¬±", "¬²", "¬³", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬´", "¬µ", "¬¶", "¬·", "¬¸", "¬¹", "¬º", "¬»", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬¼", "¬½", "¬¾", "¬¿", "¬À", "¬Á", "¬Â", "¬Ã", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬Ä", "¬Å", "¬Æ", "¬Ç", "¬È", "¬É", "¬Ê", "¬Ë", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬Ì", "¬Í", "¬Î", "¬Ï", "¬Ð", "¬Ñ", "¬Ò", "¬Ó", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬Ô", "¬Õ", "¬Ö", "¬×", "¬Ø", "¬Ù", "¬Ú", "¬Û", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬Ü", "¬Ý", "¬Þ", "¬ß", "¬à", "¬á", "¬â", "¬ã", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬ä", "¬å", "¬æ", "¬ç", "¬è", "¬é", "¬ê", "¬ë", */ + "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", + + /* "¬ì", "¬í", "¬î", "¬ï", */ + "\254\244", "\254\244", "\254\244", "\254\244", +}; +#else /* EWS-UX/V */ +static +char *skeisen_data[] = +{ + /* "¨¡", "¨¢", "¨£", "¨¤", "¨¥", "¨¦", "¨§", "¨¨", */ + "\250\241", "\250\242", "\250\243", "\250\244", "\250\245", "\250\246", "\250\247", "\250\250", + + /* "¨©", "¨ª", "¨«", "¨¬", "¨­", "¨®", "¨¯", "¨°", */ + "\250\251", "\250\252", "\250\253", "\250\254", "\250\255", "\250\256", "\250\257", "\250\260", + + /* "¨±", "¨²", "¨³", "¨´", "¨µ", "¨¶", "¨·", "¨¸", */ + "\250\261", "\250\262", "\250\263", "\250\264", "\250\265", "\250\266", "\250\267", "\250\270", + + /* "¨¹", "¨º", "¨»", "¨¼", "¨½", "¨¾", "¨¿", "¨À", */ + "\250\271", "\250\272", "\250\273", "\250\274", "\250\275", "\250\276", "\250\277", "\250\300", +}; +#endif + + +#define UUKD_SZ (sizeof(skeisen_data) / sizeof(char *)) + +static WCHAR_T *keisen_data[UUKD_SZ]; + +int +initUlKeisenTable(void) +{ + return setWStrings(keisen_data, skeisen_data, UUKD_SZ); +} + +static +uuKigoExitDo(uiContext d, int retval) +{ + popForIchiranMode(d); + popCallback(d); + retval = YomiExit(d, retval); + currentModeInfo(d); + + killmenu(d); + + return(retval); +} + +static +uuKigoRExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + d->currussia = fc->curIkouho; + + return(uuKigoExitDo(d, retval)); +} + +static +uuKigoGExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + d->curgreek = fc->curIkouho; + + return(uuKigoExitDo(d, retval)); +} + +static +uuKigoKExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + d->curkeisen = fc->curIkouho; + + return(uuKigoExitDo(d, retval)); +} + +uuKigoGeneralExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + forichiranContext fc; + + popCallback(d); /* °ìÍ÷¤ò pop */ + + fc = (forichiranContext)d->modec; + if (fc->prevcurp) { + *(fc->prevcurp) = fc->curIkouho; + } + + return(uuKigoExitDo(d, retval)); +} + +static +uuKigoQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* °ìÍ÷¤ò pop */ + + popForIchiranMode(d); + popCallback(d); + currentModeInfo(d); + + return prevMenuIfExist(d); +} + +uuKigoMake(uiContext d, WCHAR_T **allkouho, int size, char cur, char mode, int (*exitfunc )(...), int *posp) +{ + forichiranContext fc; + ichiranContext ic; + unsigned inhibit = 0; + int retval = 0; + + d->status = 0; + + if((retval = getForIchiranContext(d)) == NG) { + return(GLineNGReturn(d)); + } + fc = (forichiranContext)d->modec; + + /* selectOne ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */ + fc->allkouho = allkouho; + fc->curIkouho = 0; + fc->prevcurp = posp; + inhibit |= (unsigned char)NUMBERING; + + if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, size, + KIGOBANGOMAX, inhibit, 0, WITH_LIST_CALLBACK, + NO_CALLBACK, exitfunc, + uuKigoQuitCatch, uiUtilIchiranTooSmall)) == NG) { + return(GLineNGReturnFI(d)); + } + + ic = (ichiranContext)d->modec; + ic->minorMode = mode; + ic->flags |= cannaconf.quickly_escape ? 0 : ICHIRAN_STAY_LONG; + currentModeInfo(d); + + *(ic->curIkouho) = (int)cur; + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if(ic->tooSmall) { + d->status = AUX_CALLBACK; + return(retval); + } + + if ( !(ic->flags & ICHIRAN_ALLOW_CALLBACK) ) { + makeGlineStatus(d); + } + + /* d->status = ICHIRAN_EVERYTIME; */ + + return(retval); +} + +#if 0 +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * µ­¹æ°ìÍ÷ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +kigoZenpan(uiContext d) +{ + if(makeKigoIchiran(d, CANNA_MODE_ExtendMode) == NG) /* 0 ¤Ï³ÈÄ¥¤Îµ­¹æ°ìÍ÷ */ + return(GLineNGReturn(d)); + else + return(0); +} +#endif + +#endif /* NO_EXTEND_MENU */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ¥í¥·¥¢Ê¸»ú¤ÎÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +kigoRussia(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } +#ifdef NO_EXTEND_MENU + d->kanji_status_return->info |= KanjiRussianInfo; + return 0; +#else + return(uuKigoMake(d, (WCHAR_T **)russia_data, UURD_SZ, + d->currussia, CANNA_MODE_RussianMode, uuKigoRExitCatch, (int *)0)); +#endif +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ¥®¥ê¥·¥ãʸ»ú¤ÎÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +kigoGreek(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } +#ifdef NO_EXTEND_MENU + d->kanji_status_return->info |= KanjiGreekInfo; + return 0; +#else + return(uuKigoMake(d, (WCHAR_T **)greek_data, UUGD_SZ, + d->curgreek, CANNA_MODE_GreekMode, uuKigoGExitCatch, (int *)0)); +#endif +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ·ÓÀþ¤ÎÆþÎÏ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +kigoKeisen(uiContext d) +{ + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } +#ifdef NO_EXTEND_MENU + d->kanji_status_return->info |= KanjiLineInfo; + return 0; +#else + return(uuKigoMake(d, (WCHAR_T **)keisen_data, UUKD_SZ, + d->curkeisen, CANNA_MODE_LineMode, uuKigoKExitCatch, (int *)0)); +#endif +} diff --git a/src/add-ons/input_server/methods/canna/lib/ulmount.c b/src/add-ons/input_server/methods/canna/lib/ulmount.c new file mode 100644 index 0000000000..1b2da34cdf --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/ulmount.c @@ -0,0 +1,580 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: ulmount.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#ifndef NO_EXTEND_MENU +#include +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +static mountContext newMountContext(void); +static void freeMountContext(mountContext mc); +static struct dicname *findDic(char *s); +static uuMountExitCatch(uiContext d, int retval, mode_context env); +static uuMountQuitCatch(uiContext d, int retval, mode_context env); +static getDicList(uiContext d); + +/* cfunc mountContext + * + * mountContext + * + */ +static mountContext +newMountContext(void) +{ + mountContext mcxt; + + if ((mcxt = (mountContext)calloc(1, sizeof(mountContextRec))) + == (mountContext)NULL) { +#ifndef WIN + jrKanjiError = "malloc (newMountContext) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (newMountContext) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + return (mountContext)NULL; + } + mcxt->id = MOUNT_CONTEXT; + + return mcxt; +} + +static void +freeMountContext(mountContext mc) +{ + if (mc) { + if (mc->mountList) { + if (*(mc->mountList)) { + free(*(mc->mountList)); + } + free(mc->mountList); + } + if (mc->mountOldStatus) { + free(mc->mountOldStatus); + } + if (mc->mountNewStatus) { + free(mc->mountNewStatus); + } + free(mc); + } +} + +/* + * ¸õÊä°ìÍ÷¹Ô¤òºî¤ë + */ +getMountContext(uiContext d) +{ + mountContext mc; + int retval = 0; + + if (pushCallback(d, d->modec, + NO_CALLBACK, NO_CALLBACK, + NO_CALLBACK, NO_CALLBACK) == 0) { +#ifndef WIN + jrKanjiError = "malloc (pushCallback) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + return(NG); + } + + if((mc = newMountContext()) == (mountContext)NULL) { + popCallback(d); + return(NG); + } + mc->majorMode = d->majorMode; + mc->next = d->modec; + d->modec = (mode_context)mc; + + mc->prevMode = d->current_mode; + + return(retval); +} + +void +popMountMode(uiContext d) +{ + mountContext mc = (mountContext)d->modec; + + d->modec = mc->next; + d->current_mode = mc->prevMode; + freeMountContext(mc); +} + +static struct dicname * +findDic(char *s) +{ + extern struct dicname *kanjidicnames; + struct dicname *dp; + + for (dp = kanjidicnames ; dp ; dp = dp->next) { + if (!strcmp(s, dp->name)) { + return dp; + } + } + return (struct dicname *)0; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ¼­½ñ¤Î¥Þ¥¦¥ó¥È¡¿¥¢¥ó¥Þ¥¦¥ó¥È * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +static +uuMountExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + mountContext mc; + int i, nmount = 0; + extern defaultContext; + struct dicname *dp; + + killmenu(d); + popCallback(d); /* OnOff ¤ò¥Ý¥Ã¥× */ + + if(defaultContext == -1) { + if((KanjiInit() != 0) || (defaultContext == -1)) { +#ifdef STANDALONE +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363"; +#endif +#else +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\245\265" + "\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336" + "\244\273\244\363"; +#endif +#endif + popMountMode(d); + popCallback(d); + return(GLineNGReturn(d)); + } + } + + mc = (mountContext)d->modec; + for(i=0; mc->mountList[i]; i++) { + if(mc->mountOldStatus[i] != mc->mountNewStatus[i]) { + if(mc->mountNewStatus[i]) { + /* ¥Þ¥¦¥ó¥È¤¹¤ë */ + nmount++; + if((retval = RkwMountDic(defaultContext, (char *)mc->mountList[i], + cannaconf.kojin ? PL_ALLOW : PL_INHIBIT)) == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\336\245\246" + "\245\363\245\310\244\313\274\272\307\324\244\267\244\336" + "\244\267\244\277", 512); + /* ¼­½ñ¤Î¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + else if(d->contextCache != -1 && + (retval = RkwMountDic(d->contextCache, (char *)mc->mountList[i], + cannaconf.kojin ? PL_ALLOW : PL_INHIBIT)) == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\336\245\246" + "\245\363\245\310\244\313\274\272\307\324\244\267\244\336" + "\244\267\244\277", 512); + /* ¼­½ñ¤Î¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + else { /* À®¸ù */ + dp = findDic((char *)mc->mountList[i]); + if (!dp) { + dp = (struct dicname *)malloc(sizeof(struct dicname)); + if (dp) { + dp->name = (char *)malloc(strlen((char *)mc->mountList[i]) + 1); + if (dp->name) { + /* ¥Þ¥¦¥ó¥È¤·¤¿¤ä¤Ä¤Ï¥ê¥¹¥È¤Ë¤Ä¤Ê¤° */ + strcpy(dp->name, (char *)mc->mountList[i]); + dp->dictype = DIC_PLAIN; + /* dp->dicflag = DIC_NOT_MOUNTED; will be rewritten below */ + dp->next = kanjidicnames; + kanjidicnames = dp; + } + else { /* (char *)malloc failed */ + free(dp); + dp = (struct dicname *)0; + } + } + } + if (dp) { + dp->dicflag = DIC_MOUNTED; + } + } + } else { + /* ¥¢¥ó¥Þ¥¦¥ó¥È¤¹¤ë */ + nmount++; + if((retval = RkwUnmountDic(defaultContext, (char *)mc->mountList[i])) + == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\242\245\363" + "\245\336\245\246\245\363\245\310\244\313\274\272\307\324" + "\244\267\244\336\244\267\244\277", 512); + /* ¼­½ñ¤Î¥¢¥ó¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + else if(d->contextCache != -1 && + (retval = RkwUnmountDic(d->contextCache, (char *)mc->mountList[i])) + == NG) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\242\245\363" + "\245\336\245\246\245\363\245\310\244\313\274\272\307\324" + "\244\267\244\336\244\267\244\277", 512); + /* ¼­½ñ¤Î¥¢¥ó¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + } + else { + dp = findDic((char *)mc->mountList[i]); + if (dp) { /* ¤«¤Ê¤é¤º°Ê²¼¤òÄ̤ë¤Ï¤º */ + dp->dicflag = DIC_NOT_MOUNTED; + } + } + } + } + } + + if(nmount) + makeAllContextToBeClosed(1); + + if(retval != NG) + MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\336\245\246\245\363" + "\245\310\241\277\245\242\245\363\245\336\245\246\245\363\245\310" + "\244\362\271\324\244\244\244\336\244\267\244\277", 512); + /* ¼­½ñ¤Î¥Þ¥¦¥ó¥È¡¿¥¢¥ó¥Þ¥¦¥ó¥È¤ò¹Ô¤¤¤Þ¤·¤¿ */ + else + MBstowcs(d->genbuf, "\274\255\275\361\244\316\245\336\245\246\245\363" + "\245\310\241\277\245\242\245\363\245\336\245\246\245\363\245\310" + "\244\313\274\272\307\324\244\267\244\336\244\267\244\277", 512); + /* ¼­½ñ¤Î¥Þ¥¦¥ó¥È¡¿¥¢¥ó¥Þ¥¦¥ó¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + + popMountMode(d); + popCallback(d); + currentModeInfo(d); + + return(0); +} + +static +uuMountQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* OnOff ¤ò¥Ý¥Ã¥× */ + + popMountMode(d); + popCallback(d); + currentModeInfo(d); + + return prevMenuIfExist(d); +} + +/* + * dicLbuf dicLp soldp snewp + * ¨£¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¤ ¨£¨¡¨¡¨¡¨¤ ¨£¨¡¨¤ ¨£¨¡¨¤ + * ¨¢iroha\@fuzokugo\@k¨¢ ¨¢*iroha¨¢ ¨¢1 ¨¢ ¨¢1 ¨¢ + * ¨¢atakana\@satoko\@s¨¢ ¨¢*fuzo ¨¢ ¨¢1 ¨¢ ¨¢1 ¨¢ + * ¨¢oft\@\@... ¨¢ ¨¢*kata ¨¢ ¨¢0 ¨¢ ¨¢0 ¨¢ + * ¨¢ ¨¢ ¨¢ : ¨¢ ¨¢: ¨¢ ¨¢: ¨¢ + * ¨¦¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¥ ¨¦¨¡¨¡¨¡¨¥ ¨¦¨¡¨¥ ¨¦¨¡¨¥ + * dicMbuf dicMp + * ¨£¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¤ ¨£¨¡¨¡¨¡¨¤ + * ¨¢iroha\@fuzokugo\@s¨¢ ¨¢*iroha¨¢ + * ¨¢atoko\@\@... ¨¢ ¨¢*fuzo ¨¢ + * ¨¢ ¨¢ ¨¢*sato ¨¢ + * ¨¢ ¨¢ ¨¢ : ¨¢ + * ¨¦¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¡¨¥ ¨¦¨¡¨¡¨¡¨¥ + */ +static +getDicList(uiContext d) +{ + mountContext mc = (mountContext)d->modec; + char *dicLbuf, dicMbuf[ROMEBUFSIZE]; + char **dicLp, *dicMp[ROMEBUFSIZE/2]; + char *wptr, **Lp, **Mp; + BYTE *sop, *snp, *soldp, *snewp; + int dicLc, dicMc, i; + extern defaultContext; + + if((dicLbuf = (char *)malloc(ROMEBUFSIZE)) == (char *)NULL) { +#ifndef WIN + jrKanjiError = "malloc (getDicList) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (getDicList) \244\307\244\255\244\336\244\273"; +#endif + return(NG); + } + if(defaultContext == -1) { + if((KanjiInit() != 0) || (defaultContext == -1)) { +#ifdef STANDALONE +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363"; +#endif +#else +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271" + "\245\265\241\274\245\320\244\310\304\314\277\256\244\307\244\255" + "\244\336\244\273\244\363"; +#endif +#endif + free(dicLbuf); + return(NG); + } + } + if((dicLc = RkwGetDicList(defaultContext, (char *)dicLbuf, ROMEBUFSIZE)) + < 0) { + if(errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\245\336\245\246\245\363\245\310\262\304\307\275\244\312" + "\274\255\275\361\244\316\274\350\244\352\275\320\244\267\244\313" + "\274\272\307\324\244\267\244\336\244\267\244\277"; + /* ¥Þ¥¦¥ó¥È²Äǽ¤Ê¼­½ñ¤Î¼è¤ê½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + free(dicLbuf); + return(NG); + } + if (dicLc == 0) { + jrKanjiError = "\245\336\245\246\245\363\245\310\262\304\307\275\244\312" + "\274\255\275\361\244\254\302\270\272\337\244\267\244\336\244\273" + "\244\363"; + /* ¥Þ¥¦¥ó¥È²Äǽ¤Ê¼­½ñ¤¬Â¸ºß¤·¤Þ¤»¤ó */ + free(dicLbuf); + return NG; + } + if((dicLp = (char **)calloc(dicLc + 1, sizeof(char *))) == (char **)NULL) { +#ifndef WIN + jrKanjiError = "malloc (getDicList) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (getDicList) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + free(dicLbuf); + return(NG); + } + if((soldp = (BYTE *)malloc(dicLc + 1)) == (BYTE *)NULL) { +#ifndef WIN + jrKanjiError = "malloc (getDicList) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (getDicList) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + free(dicLbuf); + free(dicLp); + return(NG); + } + if((snewp = (BYTE *)malloc(dicLc + 1)) == (BYTE *)NULL) { +#ifndef WIN + jrKanjiError = "malloc (getDicList) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (getDicList) \244\307\244\255\244\336\244\273" + "\244\363\244\307\244\267\244\277"; +#endif + free(dicLbuf); + free(dicLp); + free(soldp); + return(NG); + } + for(i = 0, wptr = dicLbuf; i < dicLc; i++) { /* buf ¤òºî¤ë */ + dicLp[i] = wptr; + while(*wptr++) + /* EMPTY */ + ; /* NULL ¤Þ¤Ç¥¹¥­¥Ã¥×¤·¡¢NULL ¤Î¼¡¤Þ¤Ç¥Ý¥¤¥ó¥¿¤ò¿Ê¤á¤ë */ + } + dicLp[i] = (char *)NULL; + + if(defaultContext == -1) { + if((KanjiInit() != 0) || (defaultContext == -1)) { +#ifdef STANDALONE +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363"; +#endif +#else +#ifndef WIN + jrKanjiError = "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó"; +#else + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271" + "\245\265\241\274\245\320\244\310\304\314\277\256\244\307\244\255" + "\244\336\244\273\244\363"; +#endif +#endif + free(dicLbuf); + free(dicLp); + free(soldp); + return(NG); + } + } + if((dicMc = RkwGetMountList(defaultContext, (char *)dicMbuf, ROMEBUFSIZE)) < + 0) { + if(errno == EPIPE) + jrKanjiPipeError(); + jrKanjiError = "\245\336\245\246\245\363\245\310\244\267\244\306\244\244" + "\244\353\274\255\275\361\244\316\274\350\244\352\275\320\244\267" + "\244\313\274\272\307\324\244\267\244\336\244\267\244\277"; + /* ¥Þ¥¦¥ó¥È¤·¤Æ¤¤¤ë¼­½ñ¤Î¼è¤ê½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + free(dicLbuf); + free(dicLp); + free(soldp); + free(snewp); + return(NG); + } + + for(i = 0, wptr = dicMbuf ; i < dicMc ; i++) { /* buf ¤òºî¤ë */ + dicMp[i] = wptr; + while (*wptr++) + /* EMPTY */ + ; /* NULL ¤Þ¤Ç¥¹¥­¥Ã¥×¤·¡¢NULL ¤Î¼¡¤Þ¤Ç¥Ý¥¤¥ó¥¿¤ò¿Ê¤á¤ë */ + } + dicMp[i] = (char *)NULL; + + for(i=0, sop=soldp, snp=snewp; imountList = dicLp; + mc->mountOldStatus = soldp; + mc->mountNewStatus = snewp; + + return(dicLc); +} + +dicMount(uiContext d) +{ + ichiranContext oc; + mountContext mc; + int retval = 0, currentkouho = 0, nelem; + WCHAR_T *xxxx[100]; + yomiContext yc = (yomiContext)d->modec; + + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + + if((retval = getMountContext(d)) == NG) { + killmenu(d); + return(GLineNGReturn(d)); + } + + /* ¼­½ñ¥ê¥¹¥È¤È¥Þ¥¦¥ó¥È¡¿¥¢¥ó¥Þ¥¦¥ó¥È¤Î¾õÂÖ¤ò montContext ¤Ë¤È¤Ã¤Æ¤¯¤ë */ + if((nelem = getDicList(d)) == NG) { + popMountMode(d); + popCallback(d); + killmenu(d); + return(GLineNGReturn(d)); + } + + mc = (mountContext)d->modec; +#if defined(DEBUG) && !defined(WIN) + if(iroha_debug) { + int i; + + printf("<¡úmount>\n"); + for(i= 0; mc->mountList[i]; i++) + printf("[%s][%x][%x]\n", mc->mountList[i], + mc->mountOldStatus[i], mc->mountNewStatus[i]); + printf("\n"); + } +#endif + + /* selectOnOff ¤ò¸Æ¤Ö¤¿¤á¤Î½àÈ÷ */ + mc->curIkouho = currentkouho = 0; + + retval = setWStrings(xxxx, mc->mountList, 0); + if (retval == NG) { + popMountMode(d); + popCallback(d); + killmenu(d); + return GLineNGReturn(d); + } + if((retval = selectOnOff(d, xxxx, &mc->curIkouho, nelem, + BANGOMAX, currentkouho, mc->mountOldStatus, + NO_CALLBACK, uuMountExitCatch, + uuMountQuitCatch, uiUtilIchiranTooSmall)) == NG) { + popMountMode(d); + popCallback(d); + killmenu(d); + return GLineNGReturn(d); + } + + oc = (ichiranContext)d->modec; + oc->majorMode = CANNA_MODE_ExtendMode; + oc->minorMode = CANNA_MODE_MountDicMode; + currentModeInfo(d); + + /* ¸õÊä°ìÍ÷¹Ô¤¬¶¹¤¯¤Æ¸õÊä°ìÍ÷¤¬½Ð¤»¤Ê¤¤ */ + if(oc->tooSmall) { +#ifndef WIN + WCHAR_T p[512]; +#else + WCHAR_T p[64]; +#endif + + ichiranFin(d); + popCallback(d); /* OnOff ¤ò¥Ý¥Ã¥× */ + popMountMode(d); + popCallback(d); + currentModeInfo(d); + MBstowcs(p ,"\274\255\275\361\260\354\315\367\315\321\244\316\311\375" + "\244\254\266\271\244\244\244\316\244\307\274\255\275\361" + "\245\336\245\246\245\363\245\310\241\277\245\242\245\363" + "\245\336\245\246\245\363\245\310\244\307\244\255\244\336" + "\244\273\244\363",64); + /* ¼­½ñ°ìÍ÷ÍѤÎÉý¤¬¶¹¤¤¤Î¤Ç¼­½ñ¥Þ¥¦¥ó¥È¡¿¥¢¥ó¥Þ¥¦¥ó¥È¤Ç¤­¤Þ¤»¤ó */ + makeGLineMessage(d, p, WStrlen(p)); + killmenu(d); + return(0); + } + + makeGlineStatus(d); + /* d->status = ICHIRAN_EVERYTIME; */ + + return(retval); +} +#endif /* NO_EXTEND_MENU */ diff --git a/src/add-ons/input_server/methods/canna/lib/ulserver.c b/src/add-ons/input_server/methods/canna/lib/ulserver.c new file mode 100644 index 0000000000..ced383fcc2 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/ulserver.c @@ -0,0 +1,266 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: ulserver.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif + +#ifndef NO_EXTEND_MENU +#include +#include "canna.h" + +#ifdef luna88k +extern int errno; +#endif + +static uuServerChangeEveryTimeCatch(uiContext d, int retval, mode_context env); +static uuServerChangeExitCatch(uiContext d, int retval, mode_context env); +static uuServerChangeQuitCatch(uiContext d, int retval, mode_context env); +static serverChangeDo(uiContext d, int len); + +static int serverChangeDo(); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ¥µ¡¼¥Ð¤ÎÀÚ¤êÎ¥¤· * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +serverFin(uiContext d) +{ + int retval = 0; + yomiContext yc = (yomiContext)d->modec; + +#ifndef STANDALONE + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + killmenu(d); + + jrKanjiPipeError(); + + makeGLineMessageFromString(d, "\244\253\244\312\264\301\273\372\312\321\264\271\245\265\241\274\245\320\244\310\244\316\300\334\302\263\244\362\300\332\244\352\244\336\244\267\244\277"); + /* ¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤È¤ÎÀܳ¤òÀÚ¤ê¤Þ¤·¤¿ */ + currentModeInfo(d); +#endif /* STANDALONE */ + + return(retval); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * ¥µ¡¼¥Ð¤ÎÀڤ괹¤¨ * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef STANDALONE + +static +uuServerChangeEveryTimeCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + int len, echoLen, revPos; + static int lmachinename; + static WCHAR_T *wmachinename; + + if (!wmachinename) { + WCHAR_T xxx[30]; /* 30 ¤Ã¤Æ¤Î¤Ï "¥Þ¥·¥ó̾?[" ¤è¤ê¤ÏŤ¤¤Ù¤È¤¤¤¦¤³¤È */ + lmachinename = MBstowcs(xxx, "\245\336\245\267\245\363\314\276?[", 30); + /* ¥Þ¥·¥ó̾ */ + wmachinename = (WCHAR_T *)malloc((lmachinename + 1)* sizeof(WCHAR_T)); + if (!wmachinename) { + return -1; + } + WStrcpy(wmachinename, xxx); + } + + if((echoLen = d->kanji_status_return->length) < 0) + return(retval); + + if (echoLen == 0) { + d->kanji_status_return->revPos = 0; + d->kanji_status_return->revLen = 0; + } + + WStrncpy(d->genbuf + lmachinename, + d->kanji_status_return->echoStr, echoLen); + /* echoStr == d->genbuf ¤À¤È¤Þ¤º¤¤¤Î¤ÇÀè¤Ëư¤«¤¹ */ + WStrncpy(d->genbuf, wmachinename, lmachinename); + revPos = len = lmachinename; + len += echoLen; + d->genbuf[len++] = (WCHAR_T)']'; + + d->kanji_status_return->gline.line = d->genbuf; + d->kanji_status_return->gline.length = len; + if (d->kanji_status_return->revLen) { + d->kanji_status_return->gline.revPos = + d->kanji_status_return->revPos + revPos; + d->kanji_status_return->gline.revLen = d->kanji_status_return->revLen; + } + else { /* ȿžÎΰ褬¤Ê¤¤¾ì¹ç */ + d->kanji_status_return->gline.revPos = len - 1; + d->kanji_status_return->gline.revLen = 1; + } + d->kanji_status_return->info &= ~(KanjiThroughInfo | KanjiEmptyInfo); + d->kanji_status_return->info |= KanjiGLineInfo; + echostrClear(d); + checkGLineLen(d); + + return retval; +} + +static +uuServerChangeExitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + return(serverChangeDo(d, retval)); +} + +static +uuServerChangeQuitCatch(uiContext d, int retval, mode_context env) +/* ARGSUSED */ +{ + popCallback(d); /* ÆÉ¤ß¤ò pop */ + + return prevMenuIfExist(d); +} + +extern exp(char *) RkwGetServerName(); +#endif /* STANDALONE */ + +serverChange(uiContext d) +{ + int retval = 0; + WCHAR_T *w; + extern KanjiModeRec yomi_mode; + extern defaultContext; + yomiContext yc = (yomiContext)d->modec; + +#ifndef STANDALONE + if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) { + return NothingChangedWithBeep(d); + } + d->status = 0; + + if ((yc = GetKanjiString(d, (WCHAR_T *)NULL, 0, + CANNA_ONLY_ASCII, + (int)CANNA_YOMI_CHGMODE_INHIBITTED, + (int)CANNA_YOMI_END_IF_KAKUTEI, + CANNA_YOMI_INHIBIT_ALL, + uuServerChangeEveryTimeCatch, uuServerChangeExitCatch, + uuServerChangeQuitCatch)) + == (yomiContext)0) { + killmenu(d); + return NoMoreMemory(); + } + yc->minorMode = CANNA_MODE_ChangingServerMode; + if(defaultContext != -1) { + char *servname; + servname = RkwGetServerName(); + if (servname && (w = WString(servname)) != (WCHAR_T *)0) { + RomajiStoreYomi(d, w, (WCHAR_T *)0); + WSfree(w); + yc->kRStartp = yc->kCurs = 0; + yc->rStartp = yc->rCurs = 0; + d->current_mode = &yomi_mode; + makeYomiReturnStruct(d); + } + } + currentModeInfo(d); +#endif /* STANDALONE */ + + return(retval); +} + +#ifndef STANDALONE +static +serverChangeDo(uiContext d, int len) +{ +/* WCHAR_T ¤ÇÎɤ¤¤«¡© 256 ¤ÇÎɤ¤¤«¡© */ + WCHAR_T newServerName[256]; + WCHAR_T w1[512]; + char tmpServName[256]; + extern defaultContext; + char *p; + + d->status = 0; + + if(!len) + return(serverChange(d)); + + WStrncpy(newServerName, d->buffer_return, len); + newServerName[len] = 0; +#if defined(DEBUG) && !defined(WIN) + if(iroha_debug) + printf("iroha_server_name = [%s]\n", newServerName); +#endif + + jrKanjiPipeError(); + WCstombs(tmpServName, newServerName, 256); + if (RkSetServerName(tmpServName) && (p = index((char *)tmpServName, '@'))) { +#ifdef WIN + char xxxx[512]; +#else + char xxxx[1024]; +#endif + *p = '\0'; + sprintf(xxxx, "\244\253\244\312\264\301\273\372\312\321\264\271\245\250\245\363\245\270\245\363 %s \244\317\315\370\315\321\244\307\244\255\244\336\244\273\244\363\n", + tmpServName); + /* ¤«¤Ê´Á»úÊÑ´¹¥¨¥ó¥¸¥ó %s ¤ÏÍøÍѤǤ­¤Þ¤»¤ó */ + makeGLineMessageFromString(d, xxxx); + + RkSetServerName((char *)0); + currentModeInfo(d); + killmenu(d); + return 0; + } + + if(defaultContext == -1) { + if((KanjiInit() != 0) || (defaultContext == -1)) { + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\245\265\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336\244\273\244\363"; + /* ¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó */ + killmenu(d); + return(GLineNGReturn(d)); + } + d->contextCache = -1; + } + + p = RkwGetServerName(); + if (p) { /* ÀäÂÐÀ®¸ù¤¹¤ë¤ó¤À¤±¤É¤Í */ + if ((int)strlen(p) < 256) { + MBstowcs(newServerName, p, 256); + } + } + + MBstowcs(w1, " \244\316\244\253\244\312\264\301\273\372\312\321\264\271\245\265\241\274\245\320\244\313\300\334\302\263\244\267\244\336\244\267\244\277", 512); + /* ¤Î¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ËÀܳ¤·¤Þ¤·¤¿ */ + WStrcpy((WCHAR_T *)d->genbuf, (WCHAR_T *)newServerName); + WStrcat((WCHAR_T *)d->genbuf, (WCHAR_T *)w1); + + makeGLineMessage(d, d->genbuf, WStrlen(d->genbuf)); + killmenu(d); + currentModeInfo(d); + + return(0); +} + +#endif /* STANDALONE */ +#endif /* NO_EXTEND_MENU */ diff --git a/src/add-ons/input_server/methods/canna/lib/util.c b/src/add-ons/input_server/methods/canna/lib/util.c new file mode 100644 index 0000000000..11989e0786 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/util.c @@ -0,0 +1,1615 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +/* filedef + + util.c -- ¥æ¡¼¥Æ¥£¥ê¥Æ¥£´Ø¿ô¤ò½¸¤á¤¿¡£ + + °Ê²¼¤Î´Ø¿ô¤¬¤¢¤ë¡£(Äɲä·¤¿¿Í¤Ï¤Á¤ã¤ó¤È½ñ¤¤¤È¤¤¤Æ¤è) + + GlineClear ¥¬¥¤¥É¥é¥¤¥ó¤¬¾Ã¤µ¤ì¤ë¤è¤¦¤Ê¥ê¥¿¡¼¥óÃͤòºî¤ë + Gline2echostr ¥¬¥¤¥É¥é¥¤¥ó¤ÇÊÖ¤½¤¦¤È¤·¤¿¤â¤Î¤ò¤½¤Î¾ì¤ÇÊÖ¤¹ + echostrClear ¤½¤Î¾ì¤¬Á´¤¯¾Ã¤µ¤ì¤ë¤è¤¦¤Ê¥ê¥¿¡¼¥óÃͤòºî¤ë + checkGLineLen ¥¬¥¤¥É¥é¥¤¥ó¤Ëɽ¼¨¤·¤­¤ì¤ë¤«¤É¤¦¤«¤Î¥Á¥§¥Ã¥¯ + NothingChanged ²¿¤âÊѲ½¤¬¤Ê¤¤¤³¤È¤ò¼¨¤¹¥ê¥¿¡¼¥óÃͤòºî¤ë + NothingForGLine ¥¬¥¤¥É¥é¥¤¥ó¤Ë´Ø¤·¤Æ¤Ï²¿¤âÊѲ½¤¬¤Ê¤¤ + NothingChangedWithBeep + NothingChange ¤ò¤·¤Æ¤µ¤é¤Ë¥Ó¡¼¥×²»¤òÌĤ餹 + NothingForGLineWithBeep + NothingForGLine ¤ò¤·¤Æ¤µ¤é¤Ë¥Ó¡¼¥×²»¤òÌĤ餹 + CannaBeep ¥Ó¡¼¥×²»¤ò¤Ê¤é¤¹¡£ + makeGLineMessage °ú¿ô¤Îʸ»úÎó¤òGLine¤Ëɽ¼¨¤¹¤ë¤è¤¦¤Ê¥ê¥¿¡¼¥óÃͤòºî¤ë + makeGLineMessageFromString + °ú¿ô¤Îeucʸ»úÎó¤òGLine¤Ëɽ¼¨¤¹¤ë¤è¤¦¤Ê¥ê¥¿¡¼¥óÃͤòºî¤ë + setWStrings ʸ»úÇÛÎó¤Î½é´ü²½¤ò¹Ô¤¦ + NoMoreMemory ¥á¥â¥ê¤¬¤Ê¤¤¤«¤é¥¨¥é¡¼¤À¤è¤È¤¤¤¦¥¨¥é¡¼ÃͤòÊÖ¤¹ + GLineNGReturn ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò¥¬¥¤¥É¥é¥¤¥ó¤Ë°Ü¤¹ + GLineNGReturnFI °ìÍ÷¥â¡¼¥É¤òÈ´¤±¤Æ GLineNGReturn ¤ò¤¹¤ë¡£ + GLineNGReturnTK ÅÐÏ¿¥â¡¼¥É¤òÈ´¤±¤Æ GLineNGReturn ¤ò¤¹¤ë¡£ + WStrlen ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤ÎŤµ¤òµá¤á¤ë (cf. strlen) + WStrcat ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤ò²Ã¤¨¤ë¡£(cf. strcat) + WStrcpy ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤ò¥³¥Ô¡¼¤¹¤ë¡£(cf. strcpy) + WStrncpy ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤ò£îʸ»ú¥³¥Ô¡¼¤¹¤ë¡£(cf. strncpy) + WStraddbcpy ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤ò¶õÇòʸ»ú¡¢¥¿¥Ö¡¢¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å + ¤ÎÁ°¤Ë¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤òÆþ¤ì¤Ê¤¬¤é¥³¥Ô¡¼¤¹¤ë¡£ + WStrcmp ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤òÈæ³Ó¤¹¤ë¡£(cf. strcmp) + WStrncmp ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤ò£îʸ»úÈæ³Ó¤¹¤ë¡£(cf. strncmp) + WWhatGPlain ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿£±Ê¸»ú¤Î°¤¹¤ë¥°¥é¥Õ¥£¥Ã¥¯¥×¥ì¡¼¥ó¤òÊÖ¤¹ + WIsG0 G0¤Î¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»ú¤«¡© + WIsG1 G1¤Î¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»ú¤«¡© + WIsG2 G2¤Î¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»ú¤«¡© + WIsG3 G3¤Î¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»ú¤«¡© + CANNA_mbstowcs EUC ¤ò¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Ê¸»úÎó¤ËÊÑ´¹ + CNvW2E ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤ò EUC ¤ËÊÑ´¹(¥Á¥§¥Ã¥¯ÉÕ¤­) + CANNA_wcstombs ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤ò EUC ¤ËÊÑ´¹ + WSfree WString¤Ç³ÎÊݤ·¤¿Îΰè¤ò³«Êü¤¹¤ë + WString EUC ¤ò¥ï¥¤¥É¤ËÊÑ´¹¤·¤Æ malloc ¤Þ¤Ç¤·¤ÆÊÖ¤¹(free ÉÔÍ×) + WStringOpen ¾åµ­´Ø¿ô¤Î½é´ü²½½èÍý + WStringClose ¾åµ­´Ø¿ô¤Î½ªÎ»½èÍý + WToupper °ú¿ô¤Îʸ»ú¤òÂçʸ»ú¤Ë¤¹¤ë + WTolower °ú¿ô¤Îʸ»ú¤ò¾®Ê¸»ú¤Ë¤¹¤ë + key2wchar ¥­¡¼¥Ü¡¼¥ÉÆþÎϤò¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤Ë¤¹¤ë¡£ + US2WS Ushort ¤ò WCHAR_T ¤ËÊÑ´¹¤¹¤ë¡£ + WS2US WCHAR_T ¤ò Ushort ¤ËÊÑ´¹¤¹¤ë¡£ + confirmContext yc->context ¤¬»È¤¨¤ë¤â¤Î¤«³Îǧ¤¹¤ë + makeRkError Rk ¤Î´Ø¿ô¤Ç¥¨¥é¡¼¤¬¤Ç¤¿¤È¤­¤Î½èÍý¤ò¤¹¤ë¡£ + canna_alert ¥á¥Ã¥»¡¼¥¸¤ò Gline ¤Ë½ñ¤¤¤Æ key ¤òÂԤġ£ + + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: util.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" +#include +#include "RK.h" +#include "RKintern.h" +#include + +#ifdef HAVE_WCHAR_OPERATION +#include +#if defined(__STDC__) || defined(SVR4) +#include +#endif +#endif + +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 5 /* 5 ¤â¹Ô¤«¤Ê¤¤¤À¤í¤¦¤È¤Ï»×¤¦ */ +#endif + +static wait_anykey_func(uiContext d, KanjiMode mode, int whattodo, int key, int fnum); + +/* arraydef + + tmpbuf -- ¤Á¤ç¤Ã¤È²¾¤Ë»È¤ï¤ì¤ë¥Ð¥Ã¥Õ¥¡ + + */ + +/* + * Gline ¤ò¥¯¥ê¥¢¤¹¤ë + * + * °ú¤­¿ô uiContext + * Ìá¤êÃÍ ¤Ê¤· + */ +void +GlineClear(uiContext d) +{ + d->kanji_status_return->info |= KanjiGLineInfo; + d->kanji_status_return->gline.line = (WCHAR_T *)NULL; + d->kanji_status_return->gline.length = 0; + d->kanji_status_return->gline.revPos = 0; + d->kanji_status_return->gline.revLen = 0; +} + +/* cfuncdef + + Gline2echostr -- °ìÍ÷¹Ô¤ÎÆâÍÆ¤ò¤½¤Î¾ì¤Ë°Üư + + */ + +inline void +Gline2echostr(uiContext d) +{ + d->kanji_status_return->echoStr = + d->kanji_status_return->gline.line; + d->kanji_status_return->length = + d->kanji_status_return->gline.length; + d->kanji_status_return->revPos = + d->kanji_status_return->gline.revPos; + d->kanji_status_return->revLen = + d->kanji_status_return->gline.revLen; + GlineClear(d); +} + +void +echostrClear(uiContext d) +{ + d->kanji_status_return->echoStr = (WCHAR_T *)NULL; + d->kanji_status_return->length = + d->kanji_status_return->revPos = d->kanji_status_return->revLen = 0; +} + +/* + * ʸ»úÎ󤫤饳¥é¥àÉý¤ò¼è¤Ã¼êÍè¤ë´Ø¿ô + */ + +inline +colwidth(WCHAR_T *s, int len) +{ + int ret = 0; + WCHAR_T *es = s + len; + + for (; s < es ; s++) { + switch (WWhatGPlain(*s)) { + case 0: + case 2: + ret ++; + break; + case 1: + case 3: + ret += 2; + break; + } + } + return ret; +} + + +/* cfuncdef + + checkGLineLen -- °ìÍ÷¹Ô¤Ëɽ¼¨¤Ç¤­¤ëŤµ¤ò±Û¤¨¤Æ¤¤¤ë¤«¤ò¥Á¥§¥Ã¥¯ + + Ťµ¤¬±Û¤¨¤Æ¤¤¤¿¤é¡¢¥«¡¼¥½¥ëÉôʬ¤Ëɽ¼¨¤µ¤ì¤ë¤è¤¦¤Ë¤¹¤ë¡£ + + */ + +int +checkGLineLen(uiContext d) +{ + if (d->kanji_status_return->info & KanjiGLineInfo) { + if (colwidth(d->kanji_status_return->gline.line, + d->kanji_status_return->gline.length) > d->ncolumns) { + Gline2echostr(d); + return -1; + } + } + return 0; +} + +/* cfuncdef + + NothingChanged -- ÆÉ¤ß¤Ë¤Ä¤¤¤Æ¤Ï²¿¤âÊѤ¨¤Ê¤¤¤è¤¦¤Ë¤¹¤ë + + */ + +int +NothingChanged(uiContext d) +{ + d->kanji_status_return->length = -1; /* ÊѤï¤é¤Ê¤¤¡£ */ + d->kanji_status_return->revPos + = d->kanji_status_return->revLen = 0; + d->kanji_status_return->info = 0; + return 0; +} + +NothingForGLine(uiContext d) +{ + d->kanji_status_return->length = -1; /* ÊѤï¤é¤Ê¤¤¡£ */ + d->kanji_status_return->revPos + = d->kanji_status_return->revLen = 0; + return 0; +} + +void +CannaBeep(void) +{ + extern int (*jrBeepFunc) (void); + + if (jrBeepFunc) { + jrBeepFunc(); + } +} + +int +NothingChangedWithBeep(uiContext d) +{ + CannaBeep(); + return NothingChanged(d); +} + +int +NothingForGLineWithBeep(uiContext d) +{ + CannaBeep(); + return NothingForGLine(d); +} + +#ifdef SOMEONE_USE_THIS +/* ï¤â»È¤Ã¤Æ¤¤¤Ê¤¤¤ß¤¿¤¤¡£ */ +Insertable(unsigned char ch) +{ + if ((0x20 <= ch && ch <= 0x7f) || (0xa0 <= ch && ch <= 0xff)) { + return 1; + } + else { + return 0; + } +} +#endif /* SOMEONE_USE_THIS */ + + +/* + extractSimpleYomiString -- yomiContext ¤ÎÆÉ¤ßÉôʬ¤À¤±¤ò¼è¤ê½Ð¤¹ + + °ú¿ô + yc -- yomiContext + s -- ¼è¤ê½Ð¤¹Àè¤Î¥¢¥É¥ì¥¹ + e -- ¤³¤³¤ò±Û¤¨¤Æ¼è¤ê½Ð¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡¢¤È¸À¤¦¥¢¥É¥ì¥¹ + sr -- ȿžÎΰè¤Î³«»Ï°ÌÃÖ¤òÊÖ¤¹¥¢¥É¥ì¥¹ + er -- ȿžÎΰè¤Î½ªÎ»°ÌÃÖ¤òÊÖ¤¹¥¢¥É¥ì¥¹ + pat -- pointer to an attribute buffer. + focused -- indicates yc is focused or not + */ + +inline int +extractSimpleYomiString(yomiContext yc, WCHAR_T *s, WCHAR_T *e, WCHAR_T **sr, WCHAR_T **er, wcKanjiAttributeInternal *pat, int focused) +{ + int len = yc->kEndp - yc->cStartp; + + if (yc->jishu_kEndp) { + int len = extractJishuString(yc, s, e, sr, er); + char target = focused ? + CANNA_ATTR_TARGET_NOTCONVERTED : CANNA_ATTR_CONVERTED; + if (pat && pat->sp + len < pat->ep) { + char *ap = pat->sp, *ep = ap + len; + char *mp1 = ap + (*sr - s), *mp2 = ap + (*er - s); + while (ap < mp1) { + *ap++ = CANNA_ATTR_INPUT; + } + while (ap < mp2) { + *ap++ = target; + } + while (ap < ep) { + *ap++ = CANNA_ATTR_INPUT; + } + pat->sp = ap; + } + return len; + } + + if (s + len >= e) { + len = (int)(e - s); + } + WStrncpy(s, yc->kana_buffer + yc->cStartp, len); + if (pat && pat->sp + len < pat->ep) { + char *ap = pat->sp, *ep = ap + len; + + if (focused) { + pat->u.caretpos = (ap - pat->u.attr) + yc->kCurs - yc->cStartp; + /* ¾åµ­¤Î·×»»¤Î²òÀâ: ¥­¥ã¥ì¥Ã¥È¤Î°ÌÃ֤ϡ¢º£¤«¤é½ñ¤­¹þ¤ß¤ò¤·¤è¤¦¤È + ¤·¤Æ¤¤¤ë°ÌÃÖ¤«¤é¤ÎÁêÂФǡ¢·×»»¤·¡¢yc->kCurs - yc->cStartp ¤Î°Ì + Ã֤Ǥ¢¤ë¡£ */ + } + + while (ap < ep) { + *ap++ = CANNA_ATTR_INPUT; + } + pat->sp = ap; + } + if (cannaconf.ReverseWidely) { + *sr = s; + *er = s + yc->kCurs - yc->cStartp; + } + else if (yc->kCurs == yc->kEndp && !yc->right) { + *sr = *er = s + yc->kCurs - yc->cStartp; + } + else { + *sr = s + yc->kCurs - yc->cStartp; + *er = *sr + 1; + } + return len; +} + +/* + extractKanjiString -- yomiContext ¤Î´Á»ú¸õÊä¤ò¼è¤ê½Ð¤¹ + + °ú¿ô + yc -- yomiContext + s -- ¼è¤ê½Ð¤¹Àè¤Î¥¢¥É¥ì¥¹ + e -- ¤³¤³¤ò±Û¤¨¤Æ¼è¤ê½Ð¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡¢¤È¸À¤¦¥¢¥É¥ì¥¹ + b -- ʸÀá¶èÀÚ¤ê¤ò¤¹¤ë¤«¤É¤¦¤« + sr -- ȿžÎΰè¤Î³«»Ï°ÌÃÖ¤òÊÖ¤¹¥¢¥É¥ì¥¹ + er -- ȿžÎΰè¤Î½ªÎ»°ÌÃÖ¤òÊÖ¤¹¥¢¥É¥ì¥¹ + pat -- wcKanjiAttributeInternal structure to store attribute information + focused -- focus is on this yc. + */ + +inline int +extractKanjiString(yomiContext yc, WCHAR_T *s, WCHAR_T *e, int b, WCHAR_T **sr, WCHAR_T **er, wcKanjiAttributeInternal *pat, int focused) +{ + WCHAR_T *ss = s; + int i, len, nbun; + + nbun = yc->bunlen ? yc->curbun : yc->nbunsetsu; + + for (i = 0 ; i < nbun ; i++) { + if (i && b && s < e) { + *s++ = (WCHAR_T)' '; + if (pat && pat->sp < pat->ep) { + *pat->sp++ = CANNA_ATTR_CONVERTED; + } + } + RkwGoTo(yc->context, i); + len = RkwGetKanji(yc->context, s, (int)(e - s)); + if (len < 0) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "¥«¥ì¥ó¥È¸õÊä¤ò¼è¤ê½Ð¤»¤Þ¤»¤ó¤Ç¤·¤¿"; + } + else { + char curattr; + if (i == yc->curbun && !yc->bunlen && focused) { /* focused */ + *sr = s; *er = s + len; + curattr = CANNA_ATTR_TARGET_CONVERTED; + }else{ + curattr = CANNA_ATTR_CONVERTED; + } + if (pat && pat->sp + len < pat->ep) { + char *ap = pat->sp, *ep = ap + len; + while (ap < ep) { + *ap++ = curattr; + } + pat->sp = ap; + } + s += len; + } + } + + if (yc->bunlen) { + if (i && b && s < e) { + *s++ = (WCHAR_T)' '; + if (pat && pat->sp < pat->ep) { + *pat->sp++ = CANNA_ATTR_CONVERTED; + } + } + len = yc->kEndp - yc->kanjilen; + if ((int)(e - s) < len) { + len = (int)(e - s); + } + WStrncpy(s, yc->kana_buffer + yc->kanjilen, len); + if (pat && pat->sp + len < pat->ep) { + char *ap = pat->sp, *mp = ap + yc->bunlen, *ep = ap + len; + char target = focused ? + CANNA_ATTR_TARGET_NOTCONVERTED : CANNA_ATTR_CONVERTED; + while (ap < mp) { + *ap++ = target; + } + while (ap < ep) { + *ap++ = CANNA_ATTR_INPUT; + } + pat->sp = ap; + } + if (b) { + *er = (*sr = s + yc->bunlen) + + ((yc->kanjilen + yc->bunlen == yc->kEndp) ? 0 : 1); + } + else { + *sr = s; *er = s + yc->bunlen; + } + s += len; + } + + if (s < e) { + *s = (WCHAR_T)'\0'; + } + + RkwGoTo(yc->context, yc->curbun); + return (int)(s - ss); +} + +/* + extractYomiString -- yomiContext ¤Îʸ»ú¤ò¼è¤ê½Ð¤¹ + + °ú¿ô + yc -- yomiContext + s -- ¼è¤ê½Ð¤¹Àè¤Î¥¢¥É¥ì¥¹ + e -- ¤³¤³¤ò±Û¤¨¤Æ¼è¤ê½Ð¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡¢¤È¸À¤¦¥¢¥É¥ì¥¹ + b -- ʸÀá¶èÀÚ¤ê¤ò¤¹¤ë¤«¤É¤¦¤« + sr -- ȿžÎΰè¤Î³«»Ï°ÌÃÖ¤òÊÖ¤¹¥¢¥É¥ì¥¹ + er -- ȿžÎΰè¤Î½ªÎ»°ÌÃÖ¤òÊÖ¤¹¥¢¥É¥ì¥¹ + pat -- wcKanjiAttributeInternal structure to store attribute information + focused -- The yc is now focused. + */ + +inline int +extractYomiString(yomiContext yc, WCHAR_T *s, WCHAR_T *e, int b, WCHAR_T **sr, WCHAR_T **er, wcKanjiAttributeInternal *pat, int focused) +{ + int autoconvert = yc->generalFlags & CANNA_YOMI_CHIKUJI_MODE, len; + WCHAR_T *ss = s; + + if (autoconvert) { + int OnBunsetsu = ((yc->status & CHIKUJI_ON_BUNSETSU) || + (yc->nbunsetsu && !(yc->status & CHIKUJI_OVERWRAP))); + len = extractKanjiString(yc, s, e, b, sr, er, pat, focused && OnBunsetsu); + s += len; + if (yc->kEndp - yc->cStartp > 0) { + WCHAR_T *ssr, *eer; + + if (b && len && s < e) { + *s++ = (WCHAR_T)' '; + if (pat && pat->sp < pat->ep) { + *pat->sp++ = CANNA_ATTR_CONVERTED; + } + } + len = extractSimpleYomiString(yc, s, e, &ssr, &eer, pat, + focused && !OnBunsetsu); +/* ºÇ¸å¤Î !OnBunsetsu ¤Ã¤Æ¤È¤³¤í¤Ï¡¢°Ê²¼¤Î¤è¤¦¤Ë¤·¤¿Êý¤¬É½¼¨¤¬¥­¥ã¥ì¥Ã¥È + ¤Ä¤­¤Ç¡¢È¿Å¾Ê¸À᤬½Ð¤Æ¤â¥­¥ã¥ì¥Ã¥È¤¬¥«¡¼¥½¥ë¥Ý¥¸¥·¥ç¥ó¤Ç¤¢¤ë¤³¤È¤¬¤ï + ¤«¤ê¤ä¤¹¤¤¤Î¤À¤¬¡¢OVERWRAP ¥Õ¥é¥°¤¬¤Á¤ã¤ó¤È¥â¡¼¥ÉÅù¤È¤ÎÂбþ¤¬¤µ¤ì¤Æ¤¤ + ¤Ê¤¤¤è¤¦¤Ê¤Î¤Ç¡¢¤È¤ê¤¢¤¨¤º¾åµ­¤Î¤Þ¤Þ¤È¤¹¤ë¡£ + (!yc->nbunsetsu || + (yc->status & CHIKUJI_OVERWRAP))); + */ + s += len; + if (!OnBunsetsu) { + *sr = ssr; *er = eer; + if (pat && focused) { + pat->u.caretpos = pat->sp - pat->u.attr - (s - *sr); + /* ¾åµ­¤Î·×»»¤Î²òÀâ: ¥­¥ã¥ì¥Ã¥È°ÌÃ֤ϡ¢º£¸å¥¢¥È¥ê¥Ó¥å¡¼¥È + ¤ò½ñ¤­¹þ¤à°ÌÃÖ¤«¤éÌá¤Ã¤¿°ÌÃ֤ˤ¢¤ë¡£¤É¤Î¤¯¤é¤¤Ìá¤ë¤«¤È + ¸À¤¦¤È¡¢¼¡¤Ëʸ»úÎó¤ò½ñ¤­¹þ¤à°ÌÃÖ¤«¤é¡¢È¿Å¾³«»Ï°ÌÃÖ¤Þ¤Ç + Ìá¤ëÎ̤À¤±Ìá¤ë */ + } + } + } + } + else if (yc->nbunsetsu) { /* ñ¸õÊä¥â¡¼¥É */ + len = extractKanjiString(yc, s, e, b, sr, er, pat, focused); + s += len; + } + else { + len = extractSimpleYomiString(yc, s, e, sr, er, pat, focused); + s += len; + } + if (s < e) { + *s = (WCHAR_T)'\0'; + } + return (int)(s - ss); +} + +inline +extractString(WCHAR_T *str, WCHAR_T *s, WCHAR_T *e) +{ + int len; + + len = WStrlen(str); + if (s + len < e) { + WStrcpy(s, str); + return len; + } + else { + WStrncpy(s, str, (int)(e - s)); + return (int)(e - s); + } +} + +/* + extractTanString -- tanContext ¤Îʸ»ú¤ò¼è¤ê½Ð¤¹ + + °ú¿ô + tan -- tanContext + s -- ¼è¤ê½Ð¤¹Àè¤Î¥¢¥É¥ì¥¹ + e -- ¤³¤³¤ò±Û¤¨¤Æ¼è¤ê½Ð¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡¢¤È¸À¤¦¥¢¥É¥ì¥¹ + */ + +int +extractTanString(tanContext tan, WCHAR_T *s, WCHAR_T *e) +{ + return extractString(tan->kanji, s, e); +} + +/* + extractTanYomi -- tanContext ¤Îʸ»ú¤ò¼è¤ê½Ð¤¹ + + °ú¿ô + tan -- tanContext + s -- ¼è¤ê½Ð¤¹Àè¤Î¥¢¥É¥ì¥¹ + e -- ¤³¤³¤ò±Û¤¨¤Æ¼è¤ê½Ð¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡¢¤È¸À¤¦¥¢¥É¥ì¥¹ + */ + +int +extractTanYomi(tanContext tan, WCHAR_T *s, WCHAR_T *e) +{ + return extractString(tan->yomi, s, e); +} + +/* + extractTanRomaji -- tanContext ¤Îʸ»ú¤ò¼è¤ê½Ð¤¹ + + °ú¿ô + tan -- tanContext + s -- ¼è¤ê½Ð¤¹Àè¤Î¥¢¥É¥ì¥¹ + e -- ¤³¤³¤ò±Û¤¨¤Æ¼è¤ê½Ð¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡¢¤È¸À¤¦¥¢¥É¥ì¥¹ + */ + +int +extractTanRomaji(tanContext tan, WCHAR_T *s, WCHAR_T *e) +{ + return extractString(tan->roma, s, e); +} + +void +makeKanjiStatusReturn(uiContext d, yomiContext yc) +{ + int len; + WCHAR_T *s = d->genbuf, *e = s + ROMEBUFSIZE, *sr, *er, *sk, *ek; + tanContext tan = (tanContext)yc; + long truecaret = -1; + + if (d->attr) { + d->attr->sp = d->attr->u.attr; + d->attr->ep = d->attr->u.attr + d->attr->len; + } + + /* ºÇ½é¤ÏÊÑ´¹¤µ¤ì¤Æ¤¤¤ëÉôʬ¤ò¼è¤ê½Ð¤¹ */ + while (tan->left) { + tan = tan->left; + } + + while (tan) { + if (d->attr) d->attr->u.caretpos = -1; + switch (tan->id) { + case TAN_CONTEXT: + len = extractTanString(tan, s, e); + sk = s; ek = s + len; + if (d->attr && + d->attr->sp + len < d->attr->ep) { + char *ap = d->attr->sp, *ep = ap + len; + char curattr = + ((mode_context)tan == (mode_context)yc) ? + CANNA_ATTR_TARGET_CONVERTED : CANNA_ATTR_CONVERTED; + for (; ap < ep ; ap++) { + *ap = curattr; + } + d->attr->sp = ap; + } + break; + case YOMI_CONTEXT: + len = extractYomiString((yomiContext)tan, s, e, cannaconf.BunsetsuKugiri, + &sk, &ek, d->attr, + (mode_context)tan == (mode_context)yc); + break; + default: + break; + } + + if ((mode_context)tan == (mode_context)yc) { + sr = sk; + er = ek; + if (d->attr) truecaret = d->attr->u.caretpos; + } + s += len; + tan = tan->right; + if (cannaconf.BunsetsuKugiri && tan && s < e) { + *s++ = (WCHAR_T)' '; + if (d->attr && d->attr->sp < d->attr->ep) { + *d->attr->sp++ = CANNA_ATTR_CONVERTED; + } + } + } + + if (s < e) { + *s = (WCHAR_T)'\0'; + } + + d->kanji_status_return->length = (int)(s - d->genbuf); + d->kanji_status_return->echoStr = d->genbuf; + d->kanji_status_return->revPos = (int)(sr - d->genbuf); + d->kanji_status_return->revLen = (int)(er - sr); + if (d->attr) { + d->attr->u.caretpos = truecaret; + if (d->kanji_status_return->length < d->attr->len) { + d->attr->u.attr[d->kanji_status_return->length] = '\0'; + } + d->kanji_status_return->info |= KanjiAttributeInfo; + } +} + +#ifdef WIN +#define MESSBUFSIZE 128 +#else +#define MESSBUFSIZE 256 +#endif + +/* + * ¥ê¥Ð¡¼¥¹¤Ê¤·¤Î¥á¥Ã¥»¡¼¥¸¤ò¥¬¥¤¥É¥é¥¤¥ó¤Ëɽ¼¨¤¹¤ë + * ¼¡¤ÎÆþÎϤ¬¤¢¤Ã¤¿¤È¤­¤Ë¾Ã¤¨¤ë¤è¤¦¤Ë¥Õ¥é¥°¤òÀßÄꤹ¤ë + */ +void +makeGLineMessage(uiContext d, WCHAR_T *msg, int sz) +{ + static WCHAR_T messbuf[MESSBUFSIZE]; + int len = sz < MESSBUFSIZE ? sz : MESSBUFSIZE - 1; + + WStrncpy(messbuf, msg, len); + messbuf[len] = (WCHAR_T)0; + d->kanji_status_return->gline.line = messbuf; + d->kanji_status_return->gline.length = len; + d->kanji_status_return->gline.revPos = 0; + d->kanji_status_return->gline.revLen = 0; + d->kanji_status_return->info |= KanjiGLineInfo; + + d->flags &= ~PCG_RECOGNIZED; + d->flags |= PLEASE_CLEAR_GLINE; + checkGLineLen(d); +} + +void +makeGLineMessageFromString(uiContext d, char *msg) +{ + int len; + + len = MBstowcs(d->genbuf, msg, ROMEBUFSIZE); + makeGLineMessage(d, d->genbuf, len); +} + +setWStrings(WCHAR_T **ws, char **s, int sz) +{ + int f = sz; + + for (; (f && sz) || (!f && *s); ws++, s++, sz--) { + *ws = WString(*s); + if (!*ws) { + return NG; + } + } + return 0; +} + +#ifdef DEBUG +dbg_msg(char *fmt, int x, int y, int z) +{ + if (iroha_debug) { + fprintf(stderr, fmt, x, y, z); + } +} + +checkModec(uiContext d) +{ + coreContext c; + struct callback *cb; + int depth = 0, cbDepth = 0; + int callbacks = 0; + + for (c = (coreContext)d->modec ; c ; c = (coreContext)c->next) + depth++; + for (cb = d->cb ; cb ; cb = cb->next) { + int i; + + cbDepth++; + for (i = 0 ; i < 4 ; i++) { + callbacks <<= 1; + if (cb->func[i]) { + callbacks++; + } + } + } + if (depth != cbDepth) { + fprintf(stderr, "¢£¢£¢£¢£¢£¡ª¡ª¡ª¿¼¤µ¤¬°ã¤¦¤¾¡ª¡ª¡ª¢£¢£¢£¢£¢£\n"); + } + debug_message("\242\243\40\277\274\244\265: d->modec:%d d->cb:%d callbacks:0x%08x ", + depth, cbDepth, callbacks); + /* ¢£ ¿¼¤µ */ + debug_message("EXIT_CALLBACK = 0x%x\n", d->cb->func[EXIT_CALLBACK],0,0); + { + extern KanjiModeRec yomi_mode; + if (d->current_mode == &yomi_mode) { + yomiContext yc = (yomiContext)d->modec; + if (yc->kana_buffer[yc->kEndp]) { + fprintf(stderr, "¢£¢£¢£¢£¢£ ¥«¥Ê¥Ð¥Ã¥Õ¥¡¤Ë¥´¥ß¤¬Æþ¤Ã¤Æ¤¤¤ë¤¾¡ª\n"); + } + } + } +} + +static char pbufstr[] = " o|do?b%"; + +showRomeStruct(unsigned int dpy, unsigned int win) +{ + uiContext d, keyToContext(); + extern defaultContext; + static int n = 0; + int i; + char buf[1024]; + + n++; + fprintf(stderr, "\n¡Ú¥Ç¥Ð¥°¥á¥Ã¥»¡¼¥¸(%d)¡Û\n", n); + d = keyToContext((unsigned int)dpy, (unsigned int)win); + fprintf(stderr, "buffer(0x%x), bytes(%d)\n", + d->buffer_return, d->n_buffer); + fprintf(stderr, "nbytes(%d), ch(0x%x)\n", d->nbytes, d->ch); + fprintf(stderr, "¥â¡¼¥É: %d\n", ((coreContext)d->modec)->minorMode); + /* ¥³¥ó¥Æ¥¯¥¹¥È */ + fprintf(stderr, "¥³¥ó¥Æ¥¯¥¹¥È(%d)\n", d->contextCache); + fprintf(stderr, "¥Ç¥Õ¥©¥ë¥È¥³¥ó¥Æ¥¯¥¹¥È(%d)\n", defaultContext); + + /* ¥í¡¼¥Þ»ú¤«¤Ê´ØÏ¢ */ + if (((coreContext)d->modec)->id == YOMI_CONTEXT) { + yomiContext yc = (yomiContext)d->modec; + + fprintf(stderr, "r: Start(%d), Cursor(%d), End(%d)\n", + yc->rStartp, yc->rCurs, yc->rEndp); + fprintf(stderr, "k: ̤ÊÑ´¹Start(%d), Cursor(%d), End(%d)\n", + yc->kRStartp, yc->kCurs, yc->kEndp); + WStrncpy(buf, yc->romaji_buffer, yc->rEndp); + buf[yc->rEndp] = '\0'; + fprintf(stderr, "romaji_buffer(%s)\n", buf); + fprintf(stderr, "romaji_attrib("); + for (i = 0 ; i <= yc->rEndp ; i++) { + fprintf(stderr, "%1x", yc->rAttr[i]); + } + fprintf(stderr, ")\n"); + fprintf(stderr, "romaji_pointr("); + for (i = 0 ; i <= yc->rEndp ; i++) { + int n = 0; + if (i == yc->rStartp) + n |= 1; + if (i == yc->rCurs) + n |= 2; + if (i == yc->rEndp) + n |= 4; + fprintf(stderr, "%c", pbufstr[n]); + } + fprintf(stderr, ")\n"); + WStrncpy(buf, yc->kana_buffer, yc->kEndp); + buf[yc->kEndp] = '\0'; + fprintf(stderr, "kana_buffer(%s)\n", buf); + fprintf(stderr, "kana_attrib("); + for (i = 0 ; i <= yc->kEndp ; i++) { + fprintf(stderr, "%1x", yc->kAttr[i]); + } + fprintf(stderr, ")\n"); + fprintf(stderr, "kana_pointr("); + for (i = 0 ; i <= yc->kEndp ; i++) { + int n = 0; + if (i == yc->kRStartp) + n |= 1; + if (i == yc->kCurs) + n |= 2; + if (i == yc->kEndp) + n |= 4; + fprintf(stderr, "%c", pbufstr[n]); + } + fprintf(stderr, ")\n"); + fprintf(stderr, "\n"); + } +/* RkPrintDic(0, "kon"); */ +} +#endif /* DEBUG */ + +extern char *jrKanjiError; + +NoMoreMemory(void) +{ + jrKanjiError = "\245\341\245\342\245\352\244\254\311\324\302\255\244\267\244\306\244\244\244\336\244\271\241\243"; + /* ¥á¥â¥ê¤¬ÉÔ­¤·¤Æ¤¤¤Þ¤¹¡£ */ + return NG; +} + +GLineNGReturn(uiContext d) +{ + int len; + len = MBstowcs(d->genbuf, jrKanjiError, ROMEBUFSIZE); + makeGLineMessage(d, d->genbuf, len); + currentModeInfo(d); + + return(0); +} + +GLineNGReturnFI(uiContext d) +{ + popForIchiranMode(d); + popCallback(d); + GLineNGReturn(d); + return(0); +} + +#ifdef WIN + +specialfunc(uiContext d, int fn) +{ + static WCHAR_T fnbuf[2]; + + fnbuf[0] = fn; + d->kanji_status_return->echoStr = fnbuf; + d->kanji_status_return->length = 0; + d->kanji_status_return->info = KanjiSpecialFuncInfo | KanjiEmptyInfo; + return 0; +} + +#endif /* WIN */ + +#ifndef NO_EXTEND_MENU + +GLineNGReturnTK(uiContext d) +{ + extern void popTourokuMode (uiContext); + + popCallback(d); + GLineNGReturn(d); + return(0); +} + +#endif /* NO_EXTEND_MENU */ + +#ifdef USE_COPY_ATTRIBUTE +copyAttribute(BYTE *dest, BYTE *src, int n) +{ + if (dest > src && dest < src + n) { + dest += n; + src += n; + while (n-- > 0) { + *--dest = *--src; + } + } + else { + while (n-- > 0) { + *dest++ = *src++; + } + } +} +#endif + +#ifdef DEBUG_ALLOC +int fail_malloc = 0; + +#undef malloc + +char * +debug_malloc(int n) +{ + if (fail_malloc) + return (char *)0; + else + return malloc(n); +} +#endif /* DEBUG_ALLOC */ + +/* + * ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¥ª¥Ú¥ì¡¼¥·¥ç¥ó + * + */ + +static int wchar_type; /* ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤Î¥¿¥¤¥×(²¼¤ò¸«¤è) */ + +#define CANNA_WCTYPE_16 0 /* 16¥Ó¥Ã¥Èɽ¸½ */ +#define CANNA_WCTYPE_32 1 /* 32¥Ó¥Ã¥Èɽ¸½ */ +#define CANNA_WCTYPE_OT 99 /* ¤½¤Î¾¤Îɽ¸½ */ + +/* + WCinit() -- ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤È¤·¤Æ¤É¤ì¤¬»È¤ï¤ì¤Æ¤¤¤ë¤«¤ò³Îǧ¤¹¤ë + + ¤³¤Î´Ø¿ô¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤Þ¤¨¤Ë setlocale ¤¬¤Ê¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ + */ + +#define TYPE16A 0x0000a4a2 +#define TYPE32A 0x30001222 + +int +WCinit(void) +{ +#if defined(HAVE_WCHAR_OPERATION) && !defined(WIN) + extern int locale_insufficient; + WCHAR_T wc[24]; + char *a = "\244\242"; /* ¤¢ */ /* 0xa4a2 */ + + locale_insufficient = 0; + if (mbstowcs(wc, a, sizeof(wc) / sizeof(WCHAR_T)) != 1) { + /* ¿ʬ setlocale ¤¬¤Ê¤µ¤ì¤Æ¤¤¤Ê¤¤ */ + setlocale(LC_CTYPE, ""); + if (mbstowcs(wc, a, sizeof(wc) / sizeof(WCHAR_T)) != 1) { + setlocale(LC_CTYPE, JAPANESE_LOCALE); + if (mbstowcs(wc, a, sizeof(wc) / sizeof(WCHAR_T)) != 1) { + locale_insufficient = 1; + return -1; + } + } + } + switch (wc[0]) { + case TYPE16A: + wchar_type = CANNA_WCTYPE_16; + break; + case TYPE32A: + wchar_type = CANNA_WCTYPE_32; + break; + default: + wchar_type = CANNA_WCTYPE_OT; + break; + } +#else /* !HAVE_WCHAR_OPERATION || WIN */ +# ifdef WCHAR16 + + wchar_type = CANNA_WCTYPE_16; + +# else /* !WCHAR16 */ + + if (sizeof(WCHAR_T) == 2) { + /* NOTREACHED */ + wchar_type = CANNA_WCTYPE_16; + } + else { + /* NOTREACHED */ + wchar_type = CANNA_WCTYPE_32; + } + +# endif /* !WCHAR16 */ +#endif /* !HAVE_WCHAR_OPERATION || WIN */ + + return 0; +} + + +int +WStrlen(WCHAR_T *ws) +{ + int res = 0; + while (*ws++) { + res++; + } + return res; +} + +WCHAR_T * +WStrcpy(WCHAR_T *ws1, WCHAR_T *ws2) +{ +WCHAR_T *ws; +int len; + + ws = ws2; + while (*ws) { + ws++; + } + + len = ws - ws2; + memmove(ws1, ws2, len * sizeof(WCHAR_T)); + ws1[len] = (WCHAR_T)0; + return ws1; +} + +WCHAR_T * +WStrncpy(WCHAR_T *ws1, WCHAR_T *ws2, int cnt) +{ + if (!ws2){ + return((WCHAR_T *)0); + }else{ + return (WCHAR_T *)memmove(ws1, ws2, cnt * sizeof(WCHAR_T)); + } +} + +WCHAR_T * +WStraddbcpy(WCHAR_T *ws1, WCHAR_T *ws2, int cnt) +{ + WCHAR_T *strp = ws1, *endp = ws1 + cnt - 1; + + while (*ws2 != (WCHAR_T)'\0' && ws1 < endp) { + if (*ws2 == (WCHAR_T)' ' || *ws2 == (WCHAR_T)'\t' || *ws2 == (WCHAR_T)'\\') + *ws1++ = (WCHAR_T)'\\'; + *ws1++ = *ws2++; + } + if (ws1 == endp) { + ws1--; + } + *ws1 = (WCHAR_T)'\0'; + return(strp); +} + +WCHAR_T * +WStrcat(WCHAR_T *ws1, WCHAR_T *ws2) +{ + WCHAR_T *ws; + + ws = ws1; + while (*ws) { + ws++; + } + WStrcpy(ws, ws2); + return ws1; +} + +int +WStrcmp(WCHAR_T *w1, WCHAR_T *w2) +{ + while (*w1 && *w1 == *w2) { + w1++; + w2++; + } + return(*w1 - *w2); +} + +int +WStrncmp(WCHAR_T *w1, WCHAR_T *w2, int n) +{ + if (n == 0) return(0); + while (--n && *w1 && *w1 == *w2) { + w1++; + w2++; + } + return *w1 - *w2; +} + +/* WWhatGPlain -- ¤É¤Î¥°¥é¥Õ¥£¥Ã¥¯¥×¥ì¡¼¥ó¤Îʸ»ú¤«¡© + + Ìá¤êÃÍ: + 0 : G0 ASCII + 1 : G1 ´Á»ú(JISX0208) + 2 : G2 Ⱦ³Ñ¥«¥¿¥«¥Ê(JISX0201) + 3 : G3 ³°»ú(Êä½õ´Á»ú JISX0212) + */ + +int +WWhatGPlain(WCHAR_T wc) +{ + static char plain[4] = {0, 2, 3, 1}; + + switch (wchar_type) { + case CANNA_WCTYPE_16: + switch (((unsigned long)wc) & 0x8080) { + case 0x0000: + return 0; + case 0x8080: + return 1; + case 0x0080: + return 2; + case 0x8000: + return 3; + } + break; + case CANNA_WCTYPE_32: + return plain[(((unsigned long)wc) >> 28) & 3]; + default: + return 0; /* ¤É¤¦¤·¤è¤¦ */ + } + /* NOTREACHED */ +} + +int +WIsG0(WCHAR_T wc) +{ + return (WWhatGPlain(wc) == 0); +} + +int +WIsG1(WCHAR_T wc) +{ + return (WWhatGPlain(wc) == 1); +} + +int +WIsG2(WCHAR_T wc) +{ + return (WWhatGPlain(wc) == 2); +} + +int +WIsG3(WCHAR_T wc) +{ + return (WWhatGPlain(wc) == 3); +} + +#ifndef HAVE_WCHAR_OPERATION +int +CANNA_mbstowcs(WCHAR_T *dest, char *src, int destlen) +{ + register int i, j; + register unsigned ec; + + for (i = 0, j = 0 ; + (ec = (unsigned)(unsigned char)src[i]) != 0 && j < destlen ; i++) { + if (ec & 0x80) { + switch (ec) { + case 0x8e: /* SS2 */ + dest[j++] = (WCHAR_T)(0x80 | ((unsigned)src[++i] & 0x7f)); + break; + case 0x8f: /* SS3 */ + dest[j++] = (WCHAR_T)(0x8000 + | (((unsigned)src[i + 1] & 0x7f) << 8) + | ((unsigned)src[i + 2] & 0x7f)); + i += 2; + break; + default: + dest[j++] = (WCHAR_T)(0x8080 | (((unsigned)src[i] & 0x7f) << 8) + | ((unsigned)src[i + 1] & 0x7f)); + i++; + break; + } + }else{ + dest[j++] = (WCHAR_T)ec; + } + } + if (j < destlen) + dest[j] = (WCHAR_T)0; + return j; +} + +#endif /* HAVE_WCHAR_OPERATION */ + +int +CNvW2E(WCHAR_T *src, int srclen, char *dest, int destlen) +{ + int i, j; + +// case CANNA_WCTYPE_16: + for (i = 0, j = 0 ; i < srclen && j + 2 < destlen ; i++) { + WCHAR_T wc = src[i]; + switch (wc & 0x8080) { + case 0: + /* ASCII */ + dest[j++] = (char)((unsigned)wc & 0x7f); + break; + case 0x0080: + /* Ⱦ³Ñ¥«¥Ê */ + dest[j++] = (char)0x8e; /* SS2 */ + dest[j++] = (char)(((unsigned)wc & 0x7f) | 0x80); + break; + case 0x8000: + /* ³°»ú */ + dest[j++] = (char)0x8f; /* SS3 */ + dest[j++] = (char)((((unsigned)wc & 0x7f00) >> 8) | 0x80); + dest[j++] = (char)(((unsigned)wc & 0x7f) | 0x80); + break; + case 0x8080: + /* ´Á»ú */ + dest[j++] = (char)((((unsigned)wc & 0x7f00) >> 8) | 0x80); + dest[j++] = (char)(((unsigned)wc & 0x7f) | 0x80); + break; + } + } + dest[j] = (char)0; + return j; +} + +#ifndef HAVE_WCHAR_OPERATION +int +CANNA_wcstombs(char *dest, WCHAR_T *src, int destlen) +{ + return CNvW2E(src, WStrlen(src), dest, destlen); +} + +#endif /* HAVE_WCHAR_OPERATION */ + + +/* cfuncdef + + WString -- EUC¤«¤é¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤Ø¤Î¥Þ¥Ã¥Ô¥ó¥°¤ª¤è¤Ó malloc + + WString ¤Ï°ú¿ô¤Îʸ»úÎó¤ò¥ï¥¤¥É¥­¥ã¥é¥¯¥¿¤ËÊÑ´¹¤·¡¢¤½¤Îʸ»úÎ󤬼ý¤Þ¤ë + ¤À¤±¤Î¥á¥â¥ê¤ò malloc ¤·¡¢¤½¤Îʸ»úÎó¤òǼ¤áÊÖ¤¹¡£ + + ÍøÍѼԤϤ³¤Î´Ø¿ô¤ÇÆÀ¤¿¥Ý¥¤¥ó¥¿¤ò free ¤¹¤ëɬÍפϤ¢¤Þ¤ê¤Ê¤¤¡£ + + ¤¹¤Ê¤ï¤Á¡¢¤³¤Î´Ø¿ô¤ÇÆÀ¤¿¥á¥â¥ê¤Ï¸å¤Ç WStringClose ¤ò¸Æ¤Ó½Ð¤·¤¿¤È¤­¤Ë + free ¤µ¤ì¤ë¡£ + + ¤½¤¦¤¤¤¦»ö¾ð¤Ê¤Î¤Ç¤³¤Î´Ø¿ô¤òÉÑÈˤ˸ƤӽФ·¤Æ¤Ï¤¤¤±¤Ê¤¤¡£º£¤Þ¤ÇEUC¤Ç + ½é´üÄêµÁ¤Ç¤­¤Æ¤¤¤¿Ê¸»úÎó¤Ê¤É¤Ëα¤á¤ë¤Ù¤­¤Ç¤¢¤ë¡£ + + ¤³¤Îµ¡Ç½¤ò»È¤¦¿Í¤ÏºÇ½é¤Ë WStringOpen ¤ò¸Æ¤Ó½Ð¤µ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤¬¡¢ + ¥æ¡¼¥¶¥¤¥ó¥¿¥Õ¥§¡¼¥¹¥é¥¤¥Ö¥é¥ê¤Ç¤Ï¥·¥¹¥Æ¥à¤¬¼«Æ°Åª¤ËÆÉ¤ó¤Ç¤¯¤ì¤ë¤Î + ¤Ç¤½¤ÎɬÍפϤʤ¤¡£ + + */ + +static WCHAR_T **wsmemories = (WCHAR_T **)NULL; +static int nwsmemories = 0; + +#define WSBLOCKSIZE 128 + +int +WStringOpen(void) +{ + return 0; +} + +WCHAR_T * +WString(char *s) +{ + int i, len; + WCHAR_T *temp, **wm; + + if (wsmemories == (WCHAR_T **)NULL) { + nwsmemories = WSBLOCKSIZE; + if (!(wsmemories = (WCHAR_T **)calloc(nwsmemories, sizeof(WCHAR_T *)))) + return((WCHAR_T *)0) ; + /* calloc ¤µ¤ì¤¿¥á¥â¥ê¤Ï¥¯¥ê¥¢¤µ¤ì¤Æ¤¤¤ë */ + } + + for (i = 0 ; i < nwsmemories && wsmemories[i] ;) { + i++; + } + + if (i == nwsmemories) { /* »È¤¤Àڤ俤ΤÇÁý¤ä¤¹ */ + if (!(wm = (WCHAR_T **)realloc(wsmemories, + (nwsmemories + WSBLOCKSIZE) + * sizeof(WCHAR_T *)))) + return((WCHAR_T *)0); + wsmemories = wm; + for (; i < nwsmemories + WSBLOCKSIZE ; i++) + wsmemories[i] = (WCHAR_T *)0; + i = nwsmemories; + nwsmemories += WSBLOCKSIZE; + } + + /* ¤È¤ê¤¢¤¨¤ºÂ礭¤¯¤È¤Ã¤Æ¤ª¤¤¤Æ¡¢¤½¤Î¥µ¥¤¥º¤ò¸«¤ÆÃúÅ٤Υµ¥¤¥º¤Ë + ľ¤·¤ÆÊÖ¤¹ */ + + len = strlen(s); + if (!(temp = (WCHAR_T *)malloc((len + 1) * WCHARSIZE))) + return((WCHAR_T *)0); + len = MBstowcs(temp, s, len + 1); + if (!(wsmemories[i] = (WCHAR_T *)malloc((len + 1) * WCHARSIZE))) { + free(temp); + return((WCHAR_T *) 0); + } + WStrncpy(wsmemories[i], temp, len); + wsmemories[i][len] = (WCHAR_T)0; + free(temp); + return(wsmemories[i]); +} + +void +WStringClose(void) +{ + int i; + + for (i = 0 ; i < nwsmemories ; i++) + if (wsmemories[i]) + free(wsmemories[i]); + free(wsmemories); + wsmemories = (WCHAR_T **)0; + nwsmemories = 0; +} + +WSfree(WCHAR_T *s) +{ + int i; + WCHAR_T **t; + + for (t = wsmemories, i = nwsmemories; s != *t && i;) { + t++; + i--; + } + if (s != *t) + return(-1); + free(*t); + *t = (WCHAR_T *) 0; + return(0); +} + +/* + generalReplace -- ¥«¥Ê¥Ð¥Ã¥Õ¥¡¤Ë¤â¥í¡¼¥Þ»ú¥Ð¥Ã¥Õ¥¡¤Ë¤â»È¤¨¤ëÃÖ´¹¥ë¡¼¥Á¥ó + + ¤³¤ÎÃÖ´¹¥ë¡¼¥Á¥ó¤Ïʸ»úÎó¤Î¥á¥â¥ê¾å¤ÎÃÖ´¹¤ò¹Ô¤¦¤¿¤á¤Î¥é¥¤¥Ö¥é¥ê¥ë¡¼¥Á + ¥ó¤Ç¤¢¤ë¡£¥á¥â¥ê¾å¤Ëʸ»úÎó¤òÊÝ»ý¤·¤Æ¤ª¤¯»ÅÁȤߤϼ¡¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë + ¤â¤Î¤È¤¹¤ë¡£ + + ¡¦Ê¸»úÎóÍѤΥХåե¡ + ¡¦Ê¸»ú¤Î°À­ÍѤΥХåե¡ + ¡¦¥«¡¼¥½¥ë(¥¤¥ó¥Ç¥Ã¥¯¥¹(¥Ý¥¤¥ó¥¿¤Ç¤Ï¤Ê¤¤)) + ¡¦Ê¸»úÎó¤Î½ª¤ï¤ê¤ò»Ø¤¹¥¤¥ó¥Ç¥Ã¥¯¥¹ + ¡¦É¬¤º¥«¡¼¥½¥ë¤è¤êº¸¤Ë¸ºß¤¹¤ë¥¤¥ó¥Ç¥Ã¥¯¥¹(̤ÊÑ´¹Ê¸»ú¤Ø¤Î¥¤¥ó¥Ç¥Ã + ¥¯¥¹¤Ë»È¤Ã¤¿¤ê¤¹¤ë) + + ¾åµ­¤Ë¼¨¤µ¤ì¤ë¥Ð¥Ã¥Õ¥¡¾å¤Î¥«¡¼¥½¥ë¤ÎÁ°¤«¸å¤í¤Î»ØÄꤵ¤ì¤¿Ä¹¤µ¤Îʸ»úÎó + ¤òÊ̤˻ØÄꤵ¤ì¤ëʸ»úÎó¤ÇÃÖ¤­´¹¤¨¤ë½èÍý¤ò¤¹¤ë¡£ + + ¥È¡¼¥¿¥ë¤Î¥Ð¥¤¥È¿ô¤¬ÊѲ½¤¹¤ë¾ì¹ç¤Ïʸ»úÎó¤Î½ª¤ï¤ê¤ò»Ø¤¹¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î + ÃͤâÊѲ½¤µ¤»¤ë¡£¤Þ¤¿¡¢¥«¡¼¥½¥ë¤ÎÁ°¤ÎÉôʬ¤ËÂФ·¤ÆÊ¸»úÎó¤ÎÃÖ´¹¤ò¹Ô¤¦¾ì + ¹ç¤Ë¤Ï¥«¡¼¥½¥ë¥Ý¥¸¥·¥ç¥ó¤ÎÃͤâÊѲ½¤µ¤»¤ë¡£¥«¡¼¥½¥ë¤òÊѲ½¤µ¤»¤¿·ë²Ì¡¢ + ̤ÊÑ´¹Ê¸»úÅù¤Ø¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤è¤ê¤â¾®¤µ¤¯¤Ê¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢Ì¤ÊÑ´¹Ê¸»úÅù + ¤Ø¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤ÎÃͤò¥«¡¼¥½¥ë¤ÎÃͤ˹ç¤ï¤»¤Æ¾®¤µ¤¯¤¹¤ë¡£ + + ¤³¤Î´Ø¿ô¤ÎºÇ½ª°ú¿ô¤Ë¤Ï¿·¤¿¤ËÁÞÆþ¤¹¤ëʸ»úÎó¤Î°À­¤Ë´Ø¤¹¤ë¥Ò¥ó¥È¤¬µ­½Ò + ¤Ç¤­¤ë¡£¿·¤¿¤ËÁÞÆþ¤µ¤ì¤ëʸ»úÎó¤Î³ÆÊ¸»ú¤ËÂФ·¤Æ¡¢¥Ò¥ó¥È¤ÇÍ¿¤¨¤é¤ì¤¿ÃÍ + ¼«¿È¤¬Â°À­ÃͤȤ·¤Æ³ÊǼ¤µ¤ì¤ë¡£ + + ¡Ú°ú¿ô¡Û + buf ¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿ + attr °À­¥Ð¥Ã¥Õ¥¡¤Ø¤Î¥Ý¥¤¥ó¥¿ + startp ¥Ð¥Ã¥Õ¥¡¤Î̤³ÎÄêʸ»úÎó¤Ê¤É¤Ø¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò¼ý¤á¤Æ¤¤¤ëÊÑ + ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿ + cursor ¥«¡¼¥½¥ë°ÌÃÖ¤ò¼ý¤á¤Æ¤¤¤ëÊÑ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿ + endp ʸ»úÎó¤ÎºÇ½ª°ÌÃÖ¤ò»Ø¤·¼¨¤·¤Æ¤¤¤ëÊÑ¿ô¤Ø¤Î¥Ý¥¤¥ó¥¿ + + bytes ²¿¥Ð¥¤¥ÈÃÖ´¹¤¹¤ë¤«¡©Éé¤Î¿ô¤¬»ØÄꤵ¤ì¤ë¤È¥«¡¼¥½¥ë¤ÎÁ°¤ÎÉô + ʬ¤Î |bytes| ʬ¤Îʸ»úÎó¤¬ÃÖ´¹¤ÎÂоݤȤʤꡢÀµ¤Î¿ô¤¬»ØÄê + ¤µ¤ì¤ë¤È¥«¡¼¥½¥ë¤Î¸å¤í¤ÎÉôʬ¤Î bytes ʬ¤Îʸ»úÎó¤¬ÂÐ¾Ý¤È + ¤Ê¤ë¡£ + rplastr ¿·¤·¤¯ÃÖ¤¯Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + len ¿·¤·¤¯ÃÖ¤¯Ê¸»úÎó¤ÎŤµ + attrmask ¿·¤·¤¯ÃÖ¤¯Ê¸»úÎó¤Î°À­¤Î¥Ò¥ó¥È + + ¼ÂºÝ¤Ë¤Ï¤³¤Î´Ø¿ô¤òľÀܤ˻Ȥ鷺¤Ë¡¢bytes, rplastr, len, attrmask ¤À¤± + ¤òÍ¿¤¨¤ë¤À¤±¤Ç¤¹¤à¥Þ¥¯¥í¡¢kanaReplace, romajiReplace ¤ò»È¤¦¤Î¤¬Îɤ¤¡£ +*/ + +void +generalReplace(WCHAR_T *buf, BYTE *attr, int *startp, int *cursor, int *endp, int bytes, WCHAR_T *rplastr, int len, int attrmask) +{ + int idou, begin, end, i; + int cursorMove; + + if (bytes > 0) { + cursorMove = 0; + begin = *cursor; + end = *endp; + } + else { + bytes = -bytes; + cursorMove = 1; + begin = *cursor - bytes; + end = *endp; + } + + idou = len - bytes; + + moveStrings(buf, attr, begin + bytes, end, idou); + *endp += idou; + if (cursorMove) { + *cursor += idou; + if (*cursor < *startp) + *startp = *cursor; + } + + WStrncpy(buf + begin, rplastr, len); + for (i = 0 ; i < len ; i++) { + attr[begin + i] = attrmask; + } +/* if (len) + attr[begin] |= attrmask; */ +} + +WToupper(WCHAR_T w) +{ + if ('a' <= w && w <= 'z') + return((WCHAR_T) (w - 'a' + 'A')); + else + return(w); +} + +WTolower(WCHAR_T w) +{ + if ('A' <= w && w <= 'Z') { + return (WCHAR_T)(w - 'A' + 'a'); + } + else { + return w; + } +} + +/* + ¥­¡¼¤ò wchar ¤Îʸ»ú¤ËÊÑ´¹¤¹¤ë¡£ + + °ú¿ô: + key ÆþÎϤµ¤ì¤¿¥­¡¼ + check WCHAR_T ¤ËÊÑ´¹¤µ¤ì¤¿¤«¤É¤¦¤«¤ò³ÊǼ¤¹¤ë¤¿¤á¤ÎÊÑ¿ô¤Î¥¢¥É¥ì¥¹ + ÊÖÃÍ: + ´Ø¿ô¤ÎÊÖÃÍ ÊÑ´¹¤µ¤ì¤¿ WCHAR_T ¤Îʸ»ú + check ¤¦¤Þ¤¯ÊÑ´¹¤Ç¤­¤¿¤«¤É¤¦¤« + Ãí°Õ: + check ¤Ïɬ¤ºÍ­¸ú¤ÊÊÑ¿ô¤Î¥¢¥É¥ì¥¹¤ò¥Ý¥¤¥ó¥È¤¹¤ë¤³¤È¡£ + check ¤Î¥Ý¥¤¥ó¥ÈÀè¤ÎÍ­¸úÀ­¤Ï key2wchar ¤Ç¤Ï¥Á¥§¥Ã¥¯¤·¤Ê¤¤¡£ + */ + +WCHAR_T +key2wchar(int key, int *check) +{ + *check = 1; /* Success as default */ + if (161 <= key && key <= 223) { /* ¥«¥¿¥«¥Ê¤ÎÈϰϤÀ¤Ã¤¿¤é */ + char xxxx[4]; + WCHAR_T yyyy[4]; + int nchars; + + xxxx[0] = (char)0x8e; /* SS2 */ + xxxx[1] = (char)key; + xxxx[2] = '\0'; + nchars = MBstowcs(yyyy, xxxx, 4); + if (nchars != 1) { + *check = 0; + return 0; /* ¥¨¥é¡¼ */ + } + return yyyy[0]; + } + else { + return (WCHAR_T)key; + } +} + +int +confirmContext(uiContext d, yomiContext yc) +{ + extern defaultContext; + + if (yc->context < 0) { + if (d->contextCache >= 0) { + yc->context = d->contextCache; + d->contextCache = -1; + } + else { + if (defaultContext == -1) { + if (KanjiInit() < 0 || defaultContext == -1) { + jrKanjiError = KanjiInitError(); + return -1; + } + } + yc->context = RkwDuplicateContext(defaultContext); + if (yc->context < 0) { + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = "\244\253\244\312\264\301\273\372\312\321\264\271\244\313\274\272\307\324\244\267\244\336\244\267\244\277"; + /* ¤«¤Ê´Á»úÊÑ´¹¤Ë¼ºÇÔ¤·¤Þ¤·¤¿ */ + return -1; + } + } + } + return yc->context; +} + +int +abandonContext(uiContext d, yomiContext yc) +{ + extern defaultContext; + + if (yc->context >= 0) { + if (d->contextCache >= 0) { + RkwCloseContext(yc->context); + } + else { + d->contextCache = yc->context; + } + yc->context = -1; + } + return 0; +} + +int +makeRkError(uiContext d, char *str) +{ + if (errno == EPIPE) { + jrKanjiPipeError(); + } + jrKanjiError = str; + makeGLineMessageFromString(d, jrKanjiError); + return -1; +} + +/* °Ê²¼¥á¥Ã¥»¡¼¥¸¤ò gline ¤Ë½Ð¤¹¤¿¤á¤Î»ÅÁÈ¤ß */ + +inline +ProcAnyKey(uiContext d) +{ + coreContext cc = (coreContext)d->modec; + + d->current_mode = cc->prevMode; + d->modec = cc->next; + freeCoreContext(cc); + + d->status = EXIT_CALLBACK; + return 0; +} + +static wait_anykey_func (uiContext, KanjiMode, int, int, int); + +static +wait_anykey_func(uiContext d, KanjiMode mode, int whattodo, int key, int fnum) +/* ARGSUSED */ +{ + switch (whattodo) { + case KEY_CALL: + return ProcAnyKey(d); + case KEY_CHECK: + return 1; + case KEY_SET: + return 0; + } + /* NOTREACHED */ +} + +static KanjiModeRec canna_message_mode = { + wait_anykey_func, + 0, 0, 0, +}; + +inline void +cannaMessageMode(uiContext d, canna_callback_t cnt) +{ + coreContext cc; + extern coreContext newCoreContext (void); + + + cc = newCoreContext(); + if (cc == 0) { + NothingChangedWithBeep(d); + return; + } + cc->prevMode = d->current_mode; + cc->next = d->modec; + cc->majorMode = d->majorMode; + cc->minorMode = d->minorMode; + if (pushCallback(d, d->modec, NO_CALLBACK, cnt, + NO_CALLBACK, NO_CALLBACK) == (struct callback *)0) { + freeCoreContext(cc); + NothingChangedWithBeep(d); + return; + } + d->modec = (mode_context)cc; + d->current_mode = &canna_message_mode; + return; +} + +/* + canna_alert(d, message, cnt) -- ¥á¥Ã¥»¡¼¥¸¤ò gline ¤Ë½Ð¤¹ + + ²¿¤«¥­¡¼¤¬ÆþÎϤµ¤ì¤¿¤é cnt ¤È¸À¤¦´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¡£ + + °ú¿ô: + d UI Context + message ¥á¥Ã¥»¡¼¥¸ + cnt ¼¡¤Î½èÍý¤ò¹Ô¤¦´Ø¿ô + + cnt ¤Ç¤Ï popCallback(d) ¤ò¤ä¤é¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤³¤È¤ËÃí°Õ¡ª + + */ + +canna_alert(uiContext d, char *message, canna_callback_t cnt) +{ + d->nbytes = 0; + + makeGLineMessageFromString(d, message); + cannaMessageMode(d, cnt); + return 0; +} + +char * +KanjiInitError(void) +{ + extern standalone; + + if (standalone) { + return "\244\253\244\312\264\301\273\372\312\321\264\271\244\307\244\255\244\336\244\273\244\363"; + /* "¤«¤Ê´Á»úÊÑ´¹¤Ç¤­¤Þ¤»¤ó" */ + } + else { + return "\244\253\244\312\264\301\273\372\312\321\264\271\245\265" + "\241\274\245\320\244\310\304\314\277\256\244\307\244\255\244\336" + "\244\273\244\363"; + /* "¤«¤Ê´Á»úÊÑ´¹¥µ¡¼¥Ð¤ÈÄÌ¿®¤Ç¤­¤Þ¤»¤ó" */ + } +} + diff --git a/src/add-ons/input_server/methods/canna/lib/yesno.c b/src/add-ons/input_server/methods/canna/lib/yesno.c new file mode 100644 index 0000000000..f281dc9ab8 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/yesno.c @@ -0,0 +1,167 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "@(#) 102.1 $Id: yesno.c,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include +#include "canna.h" + +#ifdef luna88k +extern int errno; +#endif + +static coreContext newYesNoContext(void); +static void freeYesNoContext(coreContext qc); +static void popYesNoMode(uiContext d); +static YesNoNop(uiContext d); +static YesNo(uiContext d); +static YesNoQuit(uiContext d); + +/* cfunc yesNoContext + * + * yesNoContext + * + */ +static coreContext +newYesNoContext(void) +{ + coreContext ccxt; + + if ((ccxt = (coreContext)malloc(sizeof(coreContextRec))) + == (coreContext)NULL) { +#ifndef WIN + jrKanjiError = "malloc (newcoreContext) ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿"; +#else + jrKanjiError = "malloc (newcoreContext) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; +#endif + return (coreContext)NULL; + } + ccxt->id = CORE_CONTEXT; + + return ccxt; +} + +static void +freeYesNoContext(coreContext qc) +{ + free(qc); +} + +/* + * ¸õÊä°ìÍ÷¹Ô¤òºî¤ë + */ +getYesNoContext(uiContext d, canna_callback_t everyTimeCallback, canna_callback_t exitCallback, canna_callback_t quitCallback, canna_callback_t auxCallback) +{ + extern KanjiModeRec tourokureibun_mode; + coreContext qc; + int retval = 0; + + if(pushCallback(d, d->modec, + everyTimeCallback, exitCallback, quitCallback, auxCallback) == 0) { + jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277"; + /* ¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿ */ + return(NG); + } + + if((qc = newYesNoContext()) == (coreContext)NULL) { + popCallback(d); + return(NG); + } + qc->majorMode = d->majorMode; + qc->minorMode = CANNA_MODE_HenkanMode; + qc->next = d->modec; + d->modec = (mode_context)qc; + + qc->prevMode = d->current_mode; + d->current_mode = &tourokureibun_mode; + + return(retval); +} + +static void +popYesNoMode(uiContext d) +{ + coreContext qc = (coreContext)d->modec; + + d->modec = qc->next; + d->current_mode = qc->prevMode; + freeYesNoContext(qc); +} + +#if DOYESNONOP +/* + Nop ¤òºî¤í¤¦¤È¤·¤¿¤¬¡¢ getYesNoContext ¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤ë¤È¤³¤í¤Ç¡¢ + everyTimeCallback ¤òÀßÄꤷ¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢²¼¤Î½èÍý¤¬¤¦¤Þ¤¯Æ°¤«¤Ê¤¤ + */ + +static +YesNoNop(uiContext d) +{ + /* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */ + d->majorMode = d->minorMode = CANNA_MODE_AlphaMode; + currentModeInfo(d); + return 0; +} +#endif /* DOYESNONOP */ + +/* + * EveryTimeCallback ... y/n °Ê³°¤Îʸ»ú¤¬ÆþÎϤµ¤ì¤¿ + * ExitCallback ... y ¤¬ÆþÎϤµ¤ì¤¿ + * quitCallback ... quit ¤¬ÆþÎϤµ¤ì¤¿ + * auxCallback ... n ¤¬ÆþÎϤµ¤ì¤¿ + */ + +static int YesNo (uiContext); + +static +YesNo(uiContext d) +{ + if((d->ch == 'y') || (d->ch == 'Y')) { + popYesNoMode(d); + d->status = EXIT_CALLBACK; + } else if((d->ch == 'n') || (d->ch == 'N')) { + popYesNoMode(d); + d->status = AUX_CALLBACK; + } else { + /* d->status = EVERYTIME_CALLBACK; */ + return(NothingChangedWithBeep(d)); + } + + return(0); +} + +static int YesNoQuit (uiContext); + +static +YesNoQuit(uiContext d) +{ + int retval = 0; + + popYesNoMode(d); + d->status = QUIT_CALLBACK; + + return(retval); +} + +#include "t_reimap.h" diff --git a/src/add-ons/input_server/methods/canna/lib/yomimap.h b/src/add-ons/input_server/methods/canna/lib/yomimap.h new file mode 100644 index 0000000000..2a4f774379 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/lib/yomimap.h @@ -0,0 +1,89 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char yomimap_id[] = "@(#) 102.1 $Id: yomimap.h,v 1.1 2004/12/23 21:23:49 korli Exp $"; +#endif /* lint */ + +#include "canna.h" + +static struct funccfunc yomi_funcs[] = { + {CANNA_FN_FunctionalInsert ,YomiInsert }, + {CANNA_FN_QuotedInsert ,YomiQuotedInsert }, + {CANNA_FN_Forward ,YomiForward }, + {CANNA_FN_Backward ,YomiBackward }, + {CANNA_FN_Next ,YomiNextJishu }, + {CANNA_FN_Prev ,YomiPreviousJishu }, + {CANNA_FN_BeginningOfLine ,YomiBeginningOfLine }, + {CANNA_FN_EndOfLine ,YomiEndOfLine }, + {CANNA_FN_DeleteNext ,YomiDeleteNext }, + {CANNA_FN_DeletePrevious ,YomiDeletePrevious }, + {CANNA_FN_KillToEndOfLine ,YomiKillToEndOfLine }, + {CANNA_FN_Henkan ,YomiHenkan }, + {CANNA_FN_HenkanOrInsert ,YomiHenkanNaive }, + {CANNA_FN_HenkanOrNothing ,YomiHenkanOrNothing }, + {CANNA_FN_Kakutei ,YomiKakutei }, + {CANNA_FN_Quit ,YomiQuit }, + {CANNA_FN_ConvertAsHex ,ConvertAsHex }, + {CANNA_FN_ConvertAsBushu ,ConvertAsBushu }, + {CANNA_FN_KouhoIchiran ,ConvertAsBushu }, + {CANNA_FN_ToUpper ,YomiToUpper }, + {CANNA_FN_ToLower ,YomiToLower }, + {CANNA_FN_Capitalize ,YomiCapitalize }, + {CANNA_FN_Zenkaku ,YomiZenkaku }, + {CANNA_FN_Hankaku ,YomiHankaku }, + {CANNA_FN_Hiragana ,YomiHiraganaJishu }, + {CANNA_FN_Katakana ,YomiKatakanaJishu }, + {CANNA_FN_Romaji ,YomiRomajiJishu }, + {CANNA_FN_KanaRotate ,YomiKanaRotate }, + {CANNA_FN_RomajiRotate ,YomiRomajiRotate }, + {CANNA_FN_CaseRotate ,YomiCaseRotateForward }, + {CANNA_FN_Mark ,YomiMark }, + {CANNA_FN_BubunKakutei ,YomiBubunKakutei }, + {CANNA_FN_BaseHiragana ,YomiBaseHira }, + {CANNA_FN_BaseKatakana ,YomiBaseKata }, + {CANNA_FN_BaseKana ,YomiBaseKana }, + {CANNA_FN_BaseEisu ,YomiBaseEisu }, + {CANNA_FN_BaseZenkaku ,YomiBaseZen }, + {CANNA_FN_BaseHankaku ,YomiBaseHan }, + {CANNA_FN_BaseKakutei ,YomiBaseKakutei }, + {CANNA_FN_BaseHenkan ,YomiBaseHenkan }, + {CANNA_FN_BaseHiraKataToggle ,YomiBaseHiraKataToggle }, + {CANNA_FN_BaseZenHanToggle ,YomiBaseZenHanToggle }, + {CANNA_FN_BaseKanaEisuToggle ,YomiBaseKanaEisuToggle }, + {CANNA_FN_BaseKakuteiHenkanToggle ,YomiBaseKakuteiHenkanToggle }, + {CANNA_FN_BaseRotateForward ,YomiBaseRotateForw }, + {CANNA_FN_BaseRotateBackward ,YomiBaseRotateBack }, + {CANNA_FN_TemporalMode ,YomiModeBackup }, + {CANNA_FN_Nop ,YomiNop }, + {CANNA_FN_FuncSequence ,DoFuncSequence }, + {CANNA_FN_UseOtherKeymap ,UseOtherKeymap }, + {0 ,0 }, +}; + +KanjiModeRec yomi_mode = { + Yomisearchfunc, + default_kmap, + CANNA_KANJIMODE_TABLE_SHARED, + yomi_funcs, +}; + diff --git a/src/add-ons/input_server/methods/canna/rk/Jamfile b/src/add-ons/input_server/methods/canna/rk/Jamfile new file mode 100644 index 0000000000..0221ea9997 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/Jamfile @@ -0,0 +1,25 @@ +SubDir OBOS_TOP src add-ons input_server methods canna rk ; + +SubDirCcFlags -x c++ -ansi -trigraphs -funsigned-char -funsigned-bitfields -Wall -Wno-multichar -Wno-ctor-dtor-privacy -pedantic -Wno-long-long -Woverloaded-virtual -D_BUILDING_CANNALIB -D_WCHAR_T ; + +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) canna ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) lib ] ; +SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ; + +StaticLibrary rk : + RKutil.c + bits.c + bun.c + context.c + dd.c + dic.c + dicsw.c + fq.c +# kana.c + ngram.c + ncache.c + nword.c + permdic.c + tempdic.c +; + diff --git a/src/add-ons/input_server/methods/canna/rk/RKintern.h b/src/add-ons/input_server/methods/canna/rk/RKintern.h new file mode 100644 index 0000000000..637cf6f1bd --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/RKintern.h @@ -0,0 +1,1207 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* LINTLIBRARY */ +/* $Id: RKintern.h,v 1.1 2004/12/23 21:23:49 korli Exp $ */ +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR kanBe BY T.MURAI 1997 +/************************************************************************/ +#ifndef _RKintern_h +#define _RKintern_h + +#define BUNMATU + +/* BUNMATU ¥Þ¥¯¥í¤ò define ¤¹¤ë¤È¡¢ËÌΦÀèü²Ê³Øµ»½ÑÂç³Ø±¡Âç³Ø¾ðÊó²Ê³Ø + ¸¦µæ²Ê¤ÎÆ£»ÞϹ¨(fujieda@jaist.ac.jp)¤µ¤ó¤¬¡¢¡Ø¤«¤ó¤Ê¡Ù¤Î¤«¤Ê´Á»úÊÑ + ´¹¸úΨ¸þ¾å¤Î¤¿¤á¤Ë¡¢1994 ÅߤËÁȤ߹þ¤ó¤À¡Öʸ¾ÏËöµ­¹æ¡×¤¬Í­¸ú¤Ë¤Ê¤ê¤Þ + ¤¹¡£¤³¤ì¤Ë¤è¤êʸ¾ÏËö¤Ë¤·¤«¸½¤ì¤Ê¤¤Ê¸»ú¤¬Ê¸Àá¤ÎÅÓÃæ¤Ë½Ð¤ÆÍè¤ë¤³¤È¤¬ + ¤Ê¤¯¤Ê¤êÊÑ´¹¸úΨ¤¬¸þ¾å¤·¤Þ¤¹¡£¤³¤Î¥³¡¼¥É¤ò¤«¤¤¤Æ²¼¤µ¤¤¤Þ¤·¤¿Æ£»Þ¤µ + ¤ó¤Ë´¶¼Õ¤·¤Þ¤¹¡£ */ + +//#define FUJIEDA_HACK +/* Æ£»Þ¡÷£Ê£Á£É£Ó£Ô¤Î¥Ï¥Ã¥¯¤òÍ­¸ú¤Ë¤¹¤ë */ + +#define EXTENSION_NEW + +#include "cannaconf.h" +#include "cannabuild.h" + +#if defined(__STDC__) || !DONT_HAVE_RENAME +#define HAVE_RENAME +#endif + +#include "widedef.h" +#define RK_INTERNAL +#include "canna/RK.h" + +#include + +#ifdef NOT_DEF +#include +int Rk_errno; +#define RkSetErrno(number) {\ + if (number) + Rk_errno = (number); + else + Rk_errno = errno; +} +#else +#define RkSetErrno(number) +#endif + +#ifndef RK_DEBUG +#define RkDebug(fmt, p, q, r) +#endif + +#define MKDIR_MODE 0775 +#define CREAT_MODE 0664 + +typedef unsigned char *pointer; +typedef unsigned char Wrec; + +#define WMASK (~0x0303) +#define RK_WMASK WMASK +#define WNILL (unsigned short)0x0000 +#define WNULL (unsigned short *)0 +#define us_iscodeG0(wc) (((wc) & 0x8080) == 0x0000) +#define us_iscodeG1(wc) (((wc) & 0x8080) == 0x8080) +#define us_iscodeG2(wc) (((wc) & 0x8080) == 0x0080) +#define us_iscodeG3(wc) (((wc) & 0x8080) == 0x8000) + +#define RK_SS2 (unsigned char)0x8e +#define RK_SS3 (unsigned char)0x8f + +#define RK_ESC_CHAR ((WCHAR_T)'\\') + +//#ifndef isascii +//#define isascii(c) (((c) >= 0 && (c) <= 256)) +//#endif + +#define euc_iscodeG0(c) isascii(c) +#define euc_iscodeG1(c) (((c) & 0x80) && !((c) & RK_SS2) && !((c) & RK_SS3)) +#define euc_iscodeG2(c) ((c) & RK_SS2) +#define euc_iscodeG3(c) ((c) & RK_SS3) + +/* RkUnion + * private data at each class. + */ +typedef union _rkunion { + pointer ptr; + long var; + unsigned long uvar; +} RkUnion; + +/* kana kanji henkan jisho + * MS 870713 + * + * +---------------+ + * | HEADER | jisho header (256 byte) + * +---------------+256L + * | | yomigana no index + * | DIRECTORY | + * +---------------+ + * | | tango jouhou + * | | yomi, {(row, col), tsuduri, hindo}... + * | WORD | + * | | + * | | + * +---------------+ + * | | setuzoku jouhou(swd nomi) + * | CONJUNCT | row... + * | | + * +---------------+ + */ + +/* BASIC TYPE: + * subete no data ha MSB first(Motorolla order) de tenkai sareru + * unsigned char w + * unsigned short wx + * unsigned long wxyz + */ +#define LOMASK(x) ((x)&255) +/* #include "type.h" */ +/* + * byte stream <=> long or short + */ +#define l_to_bst4(src, dst) {\ + dst[0] = (unsigned char)(((long)(src) >> 24) & 0xff);\ + dst[1] = (unsigned char)(((long)(src) >> 16) & 0xff);\ + dst[2] = (unsigned char)(((long)(src) >> 8) & 0xff);\ + dst[3] = (unsigned char)( (long)(src) & 0xff);\ +} + +#define bst4_to_l(src) \ + (unsigned long)(((long)(src)[0] << 24) |\ + ((long)(src)[1] << 16) |\ + ((long)(src)[2] << 8) |\ + (long)(src)[3]) + +#define l_to_bst3(src, dst) {\ + dst[0] = (unsigned char)(((long)(src) >> 16) & 0xff);\ + dst[1] = (unsigned char)(((long)(src) >> 8) & 0xff);\ + dst[2] = (unsigned char)( (long)(src) & 0xff);\ +} + +#define bst3_to_l(src) \ + (unsigned long)(((long)(src)[0] << 16) | ((long)(src)[1] << 8) | (long)(src)[2]) + +#define s_to_bst2(src, dst) {\ + (dst)[0] = (unsigned char)((src >> 8) & 0xff);\ + (dst)[1] = (unsigned char)(src & 0xff);\ +} + +#define bst2_to_s(src) \ + (unsigned short)(((unsigned short)(src)[0] << 8) | (src)[1]) + +#define l_to_bst l_to_bst4 +#define bst_to_l bst4_to_l +#define s_to_bst s_to_bst2 + +#define L4TOL(l4)\ + (((((((unsigned long)(l4)[0]<<8)|(l4)[1])<<8) | (l4)[2])<<8)|(l4)[3]) +#define L3TOL(l3)\ + (((((unsigned long)(l3)[0]<<8)|(l3)[1])<<8) | (l3)[2]) +#define S2TOS(s2) (((unsigned short)(s2)[0]<<8)|(s2)[1]) +#define LTOL4(l, l4) {\ + (l4)[0] = LOMASK((l)>>24); (l4)[1] = LOMASK((l)>>16);\ + (l4)[2] = LOMASK((l)>> 8); (l4)[3] = LOMASK((l));\ + } +#define LTOL3(l, l3) {\ + (l3)[0] = LOMASK((l)>>16);\ + (l3)[1] = LOMASK((l)>> 8);\ + (l3)[2] = LOMASK((l));\ + } +#define STOS2(s, s2) {\ + (s2)[0] = LOMASK((s)>> 8);\ + (s2)[1] = LOMASK((s));\ + } + +#define RkNumber(ary) (sizeof(ary)/sizeof(ary[0])) + +#define rk_isdigit(c) (!((c) & ~0xff) ? isdigit((int)(c)) : 0) +#define rk_isascii(c) (!((c) & ~0xff) ? isascii((int)(c)) : 0) +#define rk_isspace(c) (!((c) & ~0xff) ? isspace((int)(c)) : 0) + +#define HD_MAG 0 +#define HD_VER 1 +#define HD_TIME 2 +#define HD_REC 3 +#define HD_CAN 4 +#define HD_L2P 5 +#define HD_L2C 6 +#define HD_PAG 7 +#define HD_LND 8 +#define HD_SND 9 +#define HD_SIZ 10 +#define HD_HSZ 11 +#define HD_DROF 12 +#define HD_PGOF 13 +#define HD_DMNM 14 +#define HD_CODM 15 +#define HD_LANG 16 +#define HD_WWID 17 +#define HD_WTYP 18 +#define HD_COPY 19 +#define HD_NOTE 20 +#define HD_TYPE 21 + +#define HD_MAXTAG (HD_TYPE + 1) + +#define HD_TAGSIZ (sizeof(long)) +#define HD_MIN_TAGSIZ (3 * HD_TAGSIZ) + +struct HD { + RkUnion data[HD_MAXTAG]; + int flag[HD_MAXTAG]; +}; + +#define isEndTag(s) (s[0] == 0 && s[1] == 0 && s[2] == 0 && s[3] == 0) + +#define HD_TAG_MAG "MAG#" +#define HD_TAG_VER "VER#" +#define HD_TAG_TIME "TIME" +#define HD_TAG_REC "#REC" +#define HD_TAG_CAN "#CAN" +#define HD_TAG_L2P "L2P#" +#define HD_TAG_L2C "L2C#" +#define HD_TAG_PAG "#PAG" +#define HD_TAG_LND "#LND" +#define HD_TAG_SND "#SND" +#define HD_TAG_SIZ "#SIZ" +#define HD_TAG_HSZ "#HSZ" +#define HD_TAG_DROF "DROF" +#define HD_TAG_PGOF "PGOF" +#define HD_TAG_DMNM "DMNM" +#define HD_TAG_CODM "CODM" +#define HD_TAG_LANG "LANG" +#define HD_TAG_WWID "WWID" +#define HD_TAG_WTYP "WTYP" +#define HD_TAG_COPY "(C) " +#define HD_TAG_NOTE "NOTE" +#define HD_TAG_TYPE "TYPE" + +#define JMWD 1 +#define JSWD 2 +#define JPRE 3 +#define JSUC 4 + +#define BYTE2 2 +#define BYTE4 4 + +#define DEF_WWID 2 + +#define WORD_NODE (0x80) +#define LAST_NODE (0x40) +const unsigned int BIT_UNIT = 8; + +#define NOLOCALE "NOLOCALE" +#define DEF_WTYP "W16 " +#define DEF_TYPE "jmwd" + +#define RK_PG_LOADED 0x01 +#define RK_PG_USED 0x02 + +#define isLoadedPage(p) ((p)->flags & RK_PG_LOADED) +#define isUsedPage(p) ((p)->flags & RK_PG_USED) + +#define thisPWO(p) (unsigned long)((((unsigned long ) *(p) << 6) & 0x3fc0) \ + | ((*((p)+1) >> 2) & 0x3f)) +#define thisLVO(p) (unsigned long)((((unsigned long) *((p)+1) << 13) & 0x6000) \ + | (((unsigned long) *((p)+2) << 5) & 0x1fe0) \ + | ((*((p)+3) >> 3) & 0x1f)) +#define thisCSN(p) (unsigned long)((((unsigned long) *((p)+3) << 8) & 0x700) | *((p)+4)) + +struct NP { + unsigned ndsz; + unsigned lnksz; + unsigned long lvo; + unsigned long csn; + unsigned flags; + int count; + unsigned char *buf; +}; + +/* + * definition of off_t added by Kenji Rikitake 27-MAR-1995 + * + * Include necessary headers for lseek() here. + * note: sys/types.h only applies for BSD/OS 2.0. + * Use the appropriate files for other systems. + */ + +#include + +struct ND { + unsigned long time; + unsigned long rec; + unsigned long can; + unsigned long sz; + off_t doff; + unsigned long drsz; + unsigned long pgsz; + unsigned long ttlpg; + int fd; + unsigned char *buf; + struct NP *pgs; +}; + +/* HEADER: + * unsigned char magic[2]; + * unsigned char pakeuc; key ga asshuku sareteiru + * unsigned char name[]; jisho mei + * xxx.mwd xxx.swd xxx.pre xxx.suc + * \n de shuuryou + */ +#define ND_HDMAGICSIZ 4 +#define ND_HDRSIZ 256 /* header size */ +#if 0 /* iranai? */ +#define ND_HDRMAG (('H'<<8)|'N')/* magic number */ +#endif +/* jisho class */ +#define ND_MWD RK_MWD +#define ND_SWD RK_SWD +#define ND_PRE RK_PRE +#define ND_SUC RK_SUC +#define ND_EMP 4 /* kuugo */ +#define ND_OPN 5 /* hiraki kakko */ +#define ND_CLS 6 /* toji kakko */ +#define ND_PUN 7 /* kutouten */ + + +struct wcand { + unsigned char *addr; + unsigned short row; + unsigned char klen; +}; + +struct RkXwrec { + unsigned ncands, wrecsz; + unsigned char *wrec; +}; + +/* DIRECTORY: + * xxxx NODE.... + * xxxx niha, DIRECTORY no ookisa ga byte de hairu. + * + * 4 byte no NODE kara kousei + * + * +--+--+--+--+ + * |KY|X1 X2 X3| + * +--+--+--+--+ + * ! ! + * ! +------------- X1 + * ! word record/directory offset + * ! (X1<<16) | (X2<<8) | (X3) + * ! + * +---------------- yomi (ascii/euc hiragara lower byte) + * 0 + */ +#define ND_NODSIZ 6 /* node size in byte */ +#define ND_DSPENT 189 /* #entry in the dispatch table */ +/* mask values */ +#define ND_OFFMASK 0x00ffffffL /* offset mask (24 bit) */ +/* X1 bit flags */ + +#define ND_NULLOFF ND_OFFMASK /* tango ga sakujo sareta */ +#define VMASK 0x7fffffL + +/* predicators */ +#define ND_LAST 0x0080L /* directory no saishuu node (entry) */ +#define ND_WORD 0x0040L /* offset ha tango joushou wo sasu */ +#define ND_RFU 0x0020L /* Mishiyou (offset ni tuika ?) */ +#define ISLASTNOD(flag) ((flag)&ND_LAST) +#define ISWORDNOD(flag) ((flag)&ND_WORD) + + +#define HN (unsigned long) 256 +#define HashFunc(key) (unsigned long)((key) % HN) + +struct WRT{ + unsigned long sz; + unsigned long cs; + unsigned long frst; + unsigned long tm; + unsigned char *buf; +}; + +struct CTdata{ + struct CTdata *next; + unsigned long ct[2]; +}; + +struct RUT{ + unsigned long sz; + unsigned long cs; + unsigned long frst; + unsigned long tm; + struct CTdata **dp; +}; + +#define a_csn(x) (unsigned long) \ +(((((unsigned long)(x)[0] << 8) | (x)[1]) << 4) | (((unsigned long)(x)[2] & 0xf0) >> 4)) + +#define a_tick(x) (unsigned long) \ +((((((unsigned long)(x)[2] & 0x0f) << 8) | (unsigned long)(x)[3]) << 8) | (x)[4]) + +#define WriteVal(csn, tick, buf){\ + (buf)[0] = (unsigned char)(((csn)>>12) & 0xff);\ + (buf)[1] = (unsigned char)(((csn)>>4) & 0xff);\ + (buf)[2] = (unsigned char)((((csn)<< 4) & 0xf0)|(((tick)>>16) & 0x0f));\ + (buf)[3] = (unsigned char)(((tick)>>8) & 0xff);\ + (buf)[4] = (unsigned char)((tick) & 0xff);\ +} + +#define WriteCT(csn, tick, arr){\ + (arr)[0] = (unsigned long) (csn);\ + (arr)[1] = (unsigned long) (tick);\ +} + +#define freeWRT(wruc) {\ + free(wruc->buf);\ + free(wruc);\ +} + +#define RKmaxDN (unsigned long) 0xff +#define RKmaxCN (unsigned long) 0xffffff + + +/* WORD: + * xxxx {yomi nkouho {flags row col freq kouho}...}... + * xxxx niha, WORD no ookisa ga byte de hairu. + * + * tango: + * unsigned char yomi[]; yomigana + * unsigned char nkouho; kouho no kazu + * unsigned char flags; kouho no nagasa + flags + * unsigned char row; kouho no row bangou + * unsigned char col; kouho no col bangou + * unsigned char freq kouho no shiyou hindo + * unsigned char kouho[]; + * + */ + +#define NW_PREFIX 2 /* the length of kouho prefix in byte */ + +/* flags */ +#define NW_RC256 0x80 /* set when rowcol >= 256 */ +#define NW_LEN 0x7f /* kouho no nagasa ( zenkaku 31 moji) */ +#define rowcol256(flag) ((flag) & NW_RC256) + +#define candlen(flag) ((flag) & NW_LEN) +#define wordlen(flag) ((candlen(flag) << 1) + NW_PREFIX) +/* RkWcand + * data structure used to handle the word record + */ +typedef struct RkWcand { + Wrec *addr; /* houho sentou address */ + short rcnum; /* row column number */ + unsigned char klen; /* kouho no nagasa */ +} Candidate; + +/* CONJUNCT: + * xxxx rrcc + row_0 row_1 ... row_rr-1 + * name_0 name_1 ... name_rr-1 + * xxxx niha, CONJUNCT no ookisa ga byte de hairu. + * rr, cc ha sorezore, row, col no kosuu wo simesu. + * row_i ha byte kyoukai kara hajimaru cc bit karanaru bit retu + * name_i ha EOS de owaru mojiretu + * + */ + +#define crpair(row, col) ((long)(row)) +/* ngram + * tango kan no setuzoku wo simesu gyouretu + * SWD ga open sareruto douji ni yomikomareru + */ +struct RkKxGram { +/* setuzoku jouhou */ + int ng_rowcol; /* row no kazu */ + int ng_rowbyte; /* row atari no byte suu */ + char *ng_conj; /* setuzoku gyouretu/code table */ + char **ng_strtab; +}; + +#define GetGramRow(g, r) ((g)->ng_conj + (r)*(g)->ng_rowbyte) +#define TestGram(cnj, col) ((cnj) && ((cnj)[((col)>>3)]&(0x80>>(col&7)))) + +/* hinshi no bunrui + * renbunsetu henkan de siyou sareru + */ +#define IsShuutan(g, r) TestGram(GetGramRow(g, r), 0) +#ifdef BUNMATU +#define IsBunmatu(g, r) TestGram(GetGramRow(g, r), 1) +#endif +#define IsTaigen(g, r) TestGram(GetGramRow(g, R_TAIGEN), r) +#define IsYougen(g, r) TestGram(GetGramRow(g, R_YOUGEN), r) +#define IsKakujs(g, r) TestGram(GetGramRow(g, R_KAKUJS), r) +#define is_row_num(g, n) ((0 <= (n)) && ((n) < ((g)->ng_rowcol))) + +/* RkGram -- grammatical information + */ + +struct RkGram { + int refcount; /* reference counter */ + struct RkKxGram *gramdic; /* grammar dictionary */ + int P_BB, P_NN, P_T00, P_T30, P_T35; /* hinshi codes */ +#ifdef FUJIEDA_HACK + int P_KJ; /* tankanji */ +#endif +}; + +extern struct RkGram SG; + + +/* ncache + * tango record no caching list + * ncache ha, jisho kara itido yomikomareta tango record wo cache kanri suru + * tameno jouhou kouzou dearu. + * tango record ha key (dicnum, address) de skibetu sareru. + * taiou suru tango record ha nc_word ni yori simesareru HEAP ryouiki ni aru. + * +------------+ + * | nc_dicnum | key part + * | nc_address | + * +------------+ + * | nc_word | value part + * +------------+ + * ncache ha 2tu no souhoukou list hash/free list ni tunagareru. + * (* koreha UNIX i/o system no buffer cache kara hint wo eta *) + * hash list ha key no kensaku wo kousoku ka suru tame ni shiyou sareru. + * free list ha kaihou sareta cache ga tunagareru. + */ +struct ncache { + struct ncache *nc_hnext; /* hash list */ + struct ncache *nc_hprev; + struct ncache *nc_anext; /* free list */ + struct ncache *nc_aprev; + Wrec *nc_word; /* heap jouno tango record */ + struct DM *nc_dic; /* yomikomareta jisho */ + unsigned short nc_flags; + unsigned long nc_count; /* word karano sanshou dosuu */ + long nc_address; /* word record no file address */ +}; +/* flags */ +#define NC_DIRTY 1 /* word no naiyou ga henkou sareta */ +#define NC_ERROR 2 /* cache no naiyou ga tadasiku nai */ +#define NC_NHEAP 4 /* word ha heap wo sasite inai */ + +struct nread { + struct ncache *cache; + unsigned long offset; + unsigned long csn; + int nk; +}; + +/* nword + * bunsetsu kaiseki kekka + * jisho kara no tango yomidasi kekka + * nword ha, jisho kara search sareta tango record wo kirokusi, + * bunsetsu kaiseki ni yori sakusei sareru bunsetsu tree wo hyougen suru. + */ +struct nword { + struct ncache *nw_cache; /* tango record wo fukumu cache */ + short nw_rowcol; /* setsuzoku jouhou */ + unsigned char nw_ylen; /* #chars in yomi */ + unsigned char nw_klen; /* #chars in kanji */ + unsigned char nw_class; /* word class */ + unsigned char nw_flags; /* word flags (see below) */ + unsigned char nw_lit; /* literal conversion */ + unsigned long nw_prio; /* kouzou ni yoru priority */ /* True ? by tamano */ + unsigned long nw_csn; + struct nword *nw_left; /* hidari ni tunagaru word */ + struct nword *nw_next; /* onaji nw_len wo motu list */ + unsigned char *nw_kanji; /* kanji kouho ichi/douteki na kouho */ +/* nw_klen ha fuyou ni naru kanousei ari */ + struct DM *nw_freq; /* pointer to frequncy file */ +}; +/* + * word flags + */ +#define NW_MWD 0x80 +#define NW_SWD 0x40 +#define NW_PRE 0x20 +#define NW_SUC 0x10 +#ifdef FUJIEDA_HACK +#define NW_DUMMY 0x08 +#endif +#ifdef BUNMATU +#define NW_BUNMATU 0x04 +#endif +#define NW_FOLLOW 0x02 /* has some words following to me */ +#define NW_NEVER_SPLIT 0x01 /* cannot terminate here */ +/* accessor & predicates */ +#define IsFollowed(w) ((w)->nw_flags&NW_FOLLOW) +#define DontSplitWord(w) ((w)->nw_flags |= NW_NEVER_SPLIT) +#define CanSplitWord(w) (!((w)->nw_flags&NW_NEVER_SPLIT)) +#ifdef BUNMATU +#define OnlyBunmatu(w) ((w)->nw_flags & NW_BUNMATU) +#endif + +/* conversion number */ +#define LIT2GRP(cn) ((cn)>>4) +#define LIT2MEM(cn) ((cn)&15) +#define MAKELIT(g, w) (((g)<<4)|(w)) +#define MAXLIT 16 + +#define LIT_NONE 0 +#define LIT_NUM 1 +#define LIT_ALPHA 2 +#define LIT_HIRA 3 + +/* nbun + * bunsetsu queue + * renbunsetsu henkan kekka wo kiroku + */ +struct nbun { + struct nword *nb_cand; /* kouho wo kousei suru word + * nw_next niyori sort sareru */ + unsigned short nb_yoff; /* yomigana offset in buffer */ + unsigned short nb_curlen; /* current candidate length in char */ + unsigned short nb_maxcand; /* number of candidates */ + unsigned short nb_curcand; /* current candidate */ + unsigned short nb_flags; /* ?? */ +}; + +/* DM/DF/DD + */ +/* MS1214 + * now DM supports frequency files as well + */ +typedef struct DM { +/* pointers for the file structure */ + struct DM *dm_next; + struct DM *dm_prev; + struct DF *dm_file; /* ptr to the file containing this */ +/* attributes */ + char *dm_dicname; + char *dm_nickname; + unsigned dm_class; /* MWD/SWD/PRE/SUC */ + unsigned dm_flags; /* flags */ + unsigned char dm_packbyte; /* shouryaku sareta joui byte */ +/* reference count from MD */ + int dm_rcount; +/* setuzoku jouhou (SWD nomi) */ + struct RkGram *dm_gram; + RkUnion dm_extdata; + unsigned char *dm_qbits; /* MS1214 gakushuu jouhou */ +/* */ + struct DDT *dm_line; /* pointer to dd line */ + long dm_offset; + struct RUT *dm_rut; + struct NV *dm_nv; +} DM; +/* flag values */ +#define DM_EXIST 0x01 /* member exists */ +#define DM_WRITABLE (DM_EXIST << 1) /* jisho ga write dekiru */ +#define DM_LOADWORD (DM_EXIST << 2) /* word rec wo memory ni yomi */ +#define DM_UPDATED (DM_EXIST << 4) /* member changed */ +#define DM_READOK (DM_EXIST << 5) /* jisho no read ken */ +#define DM_WRITEOK (DM_EXIST << 6) /* jisho no write ken */ + +typedef struct DF { +/* DF doubly linked list */ + struct DF *df_next; + struct DF *df_prev; + struct DD *df_direct; /* backward pointer to the directory */ + struct DM df_members; /* the header of the dictionary */ +/* attributes */ + char *df_link; /* link name of the file */ + unsigned df_type; /* type of file */ + unsigned df_flags; /* access mode */ + int df_rcount; /* # the mounted members */ + RkUnion df_extdata; + long df_size; +} DF; +#define DM2TYPE(dm) ((dm)->dm_file->df_type) +/* jisho no shurui */ +#define DF_PERMDIC 0 /* file ni aru jisho */ +#define DF_TEMPDIC 1 /* zantei jisho */ +#define DF_FREQDIC 2 /* gakushuu hindo jisho MS1214 */ +#define DF_RUCDIC 3 /* gakushuu hindo jisho MS1214 */ + +/* flag values */ +#define DF_EXIST 1 /* file exists */ +#define DF_WRITABLE 2 /* file is writable */ + +/* + * DD + */ +struct DDT { + struct DDT *ddt_next; + struct DDT *ddt_prev; + int ddt_status; + char *ddt_spec; +}; + +typedef struct DD { +/* DD doubly linked list */ + struct DD *dd_next; + struct DD *dd_prev; + char *dd_path; /* path name of the directory */ + char *dd_name; /* unique name of the directory */ + int dd_rcount; /* # opened files+reference from DDP */ + struct DF dd_files; /* the header of the file list */ + unsigned dd_flags; /* flag */ +/* dics.dir file */ + struct DDT dd_text; +} DD, *DDP; + +#define DD_WRITEOK 1 /* directory is allowed to write */ +#define DD_READOK 2 + +/* MD ---------------------------------------------------------------- + * context ni mount sareta jisho/jisho wo mount siteiru jisho list no taiou + * ---------------------------------------------------------------- */ +typedef struct MD { + struct MD *md_next; /* dictionary list */ + struct MD *md_prev; + struct DM *md_dic; /* jisho heno pointer */ + struct DM *md_freq; /* MS1214 gakushuu jisho heno pointer */ + int md_flags; /* mount flags */ +} MD, *MDP; +#define MD_WRITE 1 /* gakushuu shitei */ +#define MD_MPEND 2 /* mount pending */ +#define MD_UPEND 4 /* unmount pending */ + +/* RkParam + * common parameter block + */ +struct RkParam { +/* cache */ + struct ncache *cache; + int maxcache; +/* heap */ + unsigned char *heap; + int maxheap; + unsigned char *ham; + int maxham; +/* word */ + struct nword *word; /* henkyaku sareta word wo tunageru */ + struct nword *page; /* word page list */ + int word_in_use; + int page_in_use; +/* jisho */ + struct DD dd; + char *ddhome; /* dictionary home directory */ + struct DD **ddpath; /* system ddpath */ +/* flags */ + unsigned flag; /* checks initialize */ +/* */ +}; + +extern struct RkParam SX; + +#define SX_INITED 1 + +#define RK_REARRANGED 0x01 + +struct NVE { + unsigned char *data; + struct NVE *left; + struct NVE *right; + struct NVE *next; +}; + +struct NV { + unsigned long sz; + unsigned long tsz; + long csz; + long cnt; +/* int lst; delete by tamano(tajima) */ + struct NVE head; + struct NVE **buf; +}; + +struct nstore { + WCHAR_T *yomi; /* yomigana buffer */ + unsigned nyomi; /* number of yomigana chars */ + unsigned maxyomi; /* maximum number of yomigana chars */ + struct nbun *bunq; /* ʸÀᥭ¥å¡¼ */ + unsigned maxbunq; /* saidai bunnsetu suu */ + unsigned maxbun; /* saidai bunsetsu suu */ + int curbun; /* ¥«¥ì¥ó¥ÈʸÀá */ + int maxxq; /* saidai queue == bunsetu moji suu */ + struct nqueue *xq; /* henkan queue */ + struct nword **xqh; /* used in _RkparseBun() */ + int word_in_use; /* #words used in context */ +}; + +/* context + * ncontext ha rennbunnsetu hennkann client wo seigyo suru jouhou + * jisho kankyou + * renbunsetsu henkan sagyou ryouiki + */ +struct nqueue { + struct nword *tree; + short maxlen; + short status; +}; + +typedef struct RkContext { + struct nstore *store; + struct MD *md[4]; /* mwd/swd/pre/suc */ + struct DD **ddpath; /* dictionary search path */ + struct DM *dmprev; /* dictionary search path : dic */ + struct DM *qmprev; /* dictionary search path : freq */ + unsigned long time; /* tic */ + unsigned flags; /* context control flags */ + unsigned long kouhomode; /* kana kouho mode */ + unsigned long *litmode; /* literal conversion table */ + int concmode; /* connect words mode */ + int poss_cont; /* */ + RkUnion cx_extdata; /* etc data */ + struct NV *nv; + struct RkGram *gram; +} RkContext; + +/* Extension Data in DM */ +typedef struct TD { + struct TN *td_node; /* array of node TN */ + unsigned td_n; /* # effective nodes */ + unsigned td_max; /* # maximum nodes in the array */ +} TD; + +struct TW { + Wrec *word; + unsigned long lucks[2]; +}; + +typedef struct TN { + unsigned char tn_flags; /* type of node (see blow) */ + WCHAR_T tn_key; + union { + struct TD *tree; + struct TW *word; + } tn_value; /* type specific data */ + /* syntax sugar */ +#define tn_tree tn_value.tree +#define tn_word tn_value.word +} TN; +/* flags values */ +#define TN_WORD 1 /* is a word */ +#define TN_WDEF 2 /* wrec has been defined */ +#define TN_WDEL 4 /* wrec has been deleted */ +#define IsWordNode(tn) ((tn)->tn_flags&TN_WORD) + +/* td_and_n structure + * + * tupple of td and n for RkGetWordTextDic() + */ +struct td_n_tupple { + char *td; /* in fact this type is (struct TD *) */ + int n; + struct td_n_tupple *next; +}; + +/* jishowo 1gyouzutu yomu tokino pointer :used in RkGetWordTextDic */ +typedef struct _rec { + int gwt_cx; + unsigned char *gwt_dicname; + struct td_n_tupple *tdn; +} GWT; + +/* flag values */ +#define CTX_LIVE 1 /* allocate sareta */ +#define CTX_XFER 2 /* bunsetu henkann chuu */ +#define CTX_XAUT 4 /* jidou henkan chuu */ +#define CTX_XFSH 010 +#define CTX_NODIC 020 /* have never tried to mount dic */ + +#define MAX_CONTEXT 256 +#define INIT_CONTEXT 32 +#define ADD_CONTEXT 32 + +#ifndef SYSTEM_DDHOME_NAME +#define SYSTEM_DDHOME_NAME "canna" +#endif + +#define USER_DIC_DIR "user" +#define GROUP_DIC_DIR "group" + +#define IS_LIVECTX(cx) ((cx)->flags & CTX_LIVE) +#define IS_XFERCTX(cx) (IS_LIVECTX(cx) && ((cx)->flags & CTX_XFER)) +#define IS_XAUTCTX(cx) (IS_LIVECTX(cx) && ((cx)->flags & CTX_XAUT)) +#define RK_CONNECT_WORD 0x01 +#define IsCxNum(cn) (0<=((unsigned long)cn)&&((unsigned long)cn)concmode & RK_CONNECT_WORD) == RK_CONNECT_WORD)) +#define Is_Word_Make(cx)\ + ((cx) && (((cx)->concmode & RK_MAKE_WORD) == RK_MAKE_WORD)) + + +/* RkDST + * dictionary switch table + */ +struct RkDST { + int (*d_open) /* jisho ga open sareta toki */ + (struct DM *, char *, int, struct RkKxGram *); + int (*d_close) /* jisho ga close sareta toki */ + (struct DM *, char *, struct RkKxGram *); + int (*d_search) /* jisho kara tango wo search suru */ + (struct RkContext *, struct DM *, WCHAR_T *, + int, struct nread *, int, int *); + int (*d_io) /* jisho he tango to cache no io */ + (struct DM *, struct ncache *, int); + int (*d_ctl) /* jisho koyuuno sousa */ + (struct DM *, struct DM *, int, WCHAR_T *, struct RkKxGram *); + int (*d_sync) /* jisho sync suru */ + (struct RkContext *, struct DM *, struct DM *); +}; +extern struct RkDST _RkDST[]; + +#define _RkEnrefCache(a) ((a)->nc_count++) +#define DST_PROC(dm) _RkDST[DM2TYPE(dm)] +#define DST_OPEN(dm, file, mode, gram)\ + (DST_PROC(dm).d_open)(dm, file, mode, gram) +#define DST_CLOSE(dm, file, gram) (DST_PROC(dm).d_close)(dm, file, gram) +#define DST_SEARCH(cx, dm, k, n, cp, max, cf)\ + (DST_PROC(dm).d_search)(cx, dm, k, n, cp, max, cf) +#define DST_IO(dm, cp, io) (DST_PROC(dm).d_io)(dm, cp, io) +#define DST_READ(dm, cp) DST_IO(dm, cp, 0) +#define DST_WRITE(dm, cp) DST_IO(dm, cp, 1) +#define DST_CTL(dm, qm, what, arg, gram)\ + (DST_PROC(dm).d_ctl)(dm, qm, what, arg, gram) +#define DST_SYNC(cx, dm, qm) (DST_PROC(dm).d_sync)(cx, dm, qm) + +/* ctl command */ +#define DST_DoDefine 0 /* define words */ +#define DST_DoDelete 1 /* delete words */ +/* more commands (not implemented) */ +#define DST_DoQuery 2 /* query on the dictionary info */ + +#define DST_DoPrint 9999 /* print debug information */ + +/* Internal Functions */ +struct RkParam *RkGetSystem(); +struct DD *RkGetSystemDD(); +struct DD *RkGetUserDD(); +struct RkContext *RkGetContext(int cx_num); +struct RkContext *RkGetXContext(int cx_num); + +struct RkKxGram *RkReadGram(int fd); +struct RkKxGram *RkOpenGram(char *mydic); +struct RkKxGram *RkDuplicateGram(struct RkKxGram *ogram); +void RkCloseGram(struct RkKxGram *gram); + +int _RkInitializeCache(int size); +void _RkFinalizeCache(void); +struct ncache *_RkFindCache(struct DM *dm, long addr); +struct ncache *_RkReadCache(struct DM *dm, long addr); +void _RkFreeCache(); +void _RkDerefCache(struct ncache *cache); +void _RkPurgeCache(struct ncache *cache); +void _RkKillCache(struct DM *dm); + +int _RkRenbun2(struct RkContext *cx, int firstlen); +void _RkLearnBun(struct RkContext *cx, int cur, int mode); + +int RkScanWcand(Wrec *wrec, struct RkWcand *word, int maxword); +int RkUniqWcand(struct RkWcand *wc, int nwc); +int RkUnionWcand(struct RkWcand *wc1, int nc1, int wlen1, struct RkWcand *wc2, int nc2); +int RkSubtractWcand(struct RkWcand *wc1, int nc1, struct RkWcand *wc2, int nc2, unsigned long *lucks); + +unsigned char *RkGetGramName(struct RkKxGram *gram, int row); +int RkGetGramNum(struct RkKxGram *gram, char *name); +WCHAR_T *RkUparseWrec(); +WCHAR_T *_RkUparseWrec(struct RkKxGram *gram, Wrec *src, WCHAR_T *dst, int maxdst, unsigned long *lucks, int add); +Wrec *RkParseWrec(struct RkKxGram *gram, WCHAR_T *src, unsigned left, unsigned char *dst, unsigned maxdst); +Wrec *RkParseOWrec(struct RkKxGram *gram, WCHAR_T *src, unsigned char *dst, unsigned maxdst, unsigned long *lucks); +WCHAR_T *RkUparseGramNum(struct RkKxGram *gram, int row, WCHAR_T *dst, int maxdst); +WCHAR_T *RkParseGramNum(struct RkKxGram *gram, WCHAR_T *src, int *row); + +/* Context */ +void _RkEndBun(struct RkContext *cx); +void freeDF(); + +int _RkCandNumber(unsigned char *wrec); +int _RkWordLength(unsigned char *wrec); +int _RkCalcLog2(int n); +int _RkCalcUnlog2(int x); + +/* etc. */ + + +/* lang dep part */ +#define IS_WC_G1_HYPHEN(wc) ((wc) == 0xa1bc) +#define IS_HYPHEN(wc) (IS_WC_G1_HYPHEN(wc) || ((wc) == '-')) +/* space ¤â¸õÊä¤È¤·¤Æ»È¤¤¤¿¤¤¤¬º£¤Î½ê¤Ï space */ +#define IS_DIC_PUNCT(euc) isspace(euc) + +int _RkRealizeDF(); + +struct DM *_RkSearchDDQ(struct DD **dd, char *name, int type); +struct DM *_RkSearchDDP(struct DD **ddp, char *name); +struct DM *_RkSearchUDDP(struct DD **ddp, unsigned char *name); +struct DM *_RkSearchDDMEM(struct DD **ddp, char *name); + +int _RkIsinDDP(); +struct DD ** _RkCopyDDP(struct DD **ddp); +struct DD **_RkCreateDDP(char *ddpath); +void _RkFreeDDP(struct DD **ddp); + +struct DM *DMcreate(struct DD *dd,char *spec); +int DMremove(struct DM *dm); +int DMrename(struct DM *dm,unsigned char *nickname); + +int _RkMountMD(struct RkContext *cx,struct DM *dm,struct DM *qm,int mode,int firsttime); +void _RkUmountMD( struct RkContext *cx, struct MD *md); + +char *_RkCreatePath(struct DD *dd, char *name); +char *_RkCreateUniquePath(struct DD *dd, char *proto); +char *_RkMakePath(struct DF *df); + +unsigned char *_RkCreateHeader(struct HD *hd, unsigned *size); +int _RkReadHeader(int fd, struct HD *hd, off_t off_from_top); +void _RkClearHeader(struct HD *hd); +void _RkRehashCache(struct ncache *cache, long addr); + +/* + * limits + */ +/* + * NOTE: The following number does not includes EOS at the end of string. + * RK_PATH_BMAX maximum path name length + * RK_LINK_BMAX maximum file name length + * RK_MEMBER_BMAX maximum member name length + * RK_NICK_BMAX maximum nickname length + */ +#ifdef PATH_MAX +#define RK_PATH_BMAX PATH_MAX +#else +#define RK_PATH_BMAX 1024 +#endif +#ifdef NAME_MAX +#define RK_LINK_BMAX NAME_MAX +#else +#ifdef MAXNAMLEN +#define RK_LINK_BMAX MAXNAMLEN +#else +#define RK_LINK_BMAX 14 +#endif +#endif +#define RK_MEMBER_BMAX 255 +#define RK_NICK_BMAX 255 + +#define RK_LINE_BMAX 1024 +#define RK_BUFFER_SIZE 1024 + +/* + * RK_KEY_WMAX <= RK_LEN_WMAX + */ +#define RK_KEY_WMAX 0x7f +#define RK_LEFT_KEY_WMAX 0x3f +const unsigned long RK_LEN_WMAX=0x7f; +/* + * RK_CAND_WMAX <= RK_LEN_WMAX + */ +/* ¸õÊä¿ô */ +#define NW_MAXCAND 0x07 /* 7 */ +#define EX_NW_MAXCAND 0xfff /* 4096 */ + +/* ¸õÊäĹ */ +#define NW_MAXCANDLEN 0x7f +#define RK_CAND_WMAX 0x7f +#define RK_CAND_NMAX 0xfff /* 4095 */ + +/* wrec len */ +#define NW_MAXWREC 0x3f /* 63 */ +#define EX_NW_MAXWREC 0x1fff /* 8191 */ + +#define RK_RCNAME_BMAX 16 /* essential ?! */ + +#define RK_DIV_NMAX 2048 +#define RK_WREC_BMAX EX_NW_MAXWREC +#define RK_MAX_TEXT_LEN MAX_WREC_BMAX + +#define RK_CONC_NMAX 16 /* Àܳ¤¹¤ëÉÕ°¸ì¤Î¿ô(¸ú¤¤¤Æ¤ë¤Î¤«¤Ê¡©) */ + +#define RK_MAX_HDRSIZ 1024 + + +/* bits.c */ +long _RkPackBits(unsigned char *dst_bits, long dst_offset, int bit_size, unsigned *src_ints, int count); +long _RkUnpackBits(unsigned *dst_ints, unsigned char *src_bits, long src_offset, int bit_size, int count); +long _RkCopyBits(unsigned char *dst_bits, long dst_offset, int bit_size, unsigned char *src_bits, long src_offset, int count); +int _RkSetBitNum(unsigned char *dst_bits, unsigned long dst_offset, int bit_size, int n, int val); +int _RkCalcFqSize(int n); +int _RkPrintPackedBits(unsigned char *bits, int offset, int bit_size, int count); + +/* bun.c */ +struct nstore *_RkReallocBunStorage(struct nstore *src, unsigned len); +int RkeResize (int cx_num, int len); +int RkeGetStat (int cx_num, RkStat *st); +int RkeGetLex (int cx_num, RkLex *dst, int maxdst); +int RkwStoreRange(int cx_num, WCHAR_T *yomi, int maxyomi); +int RkwSetLocale(int cx_num, unsigned char *locale); + +int _RkResize(int cx_num, int len, int t); +int _RkwSync(struct RkContext *cx, char *dicname); + +/* context.c */ +struct RkParam *RkGetSystem(void); +struct DD *RkGetSystemDD(void); +struct RkContext *RkGetContext(int cx_num); +struct RkContext *RkGetXContext(int cx_num); +int RkwSetAppName(int Context, char *name); +int RkwGetProtocolVersion(int *majorp, int *minorp); + +/* dd.c */ +int DMcheck(char *spec, char *name); +int DMchmod(struct DM *dm, int mode); +int DDchmod(struct DD *dd, int mode); + +int _RkRealizeDF(struct DF *df); +int _RkRealizeDD(struct DD *dd); +struct DM *_RkSearchDicWithFreq (struct DD **, char *, struct DM **); +int _RkIsInDDP(struct DD **ddp, struct DD *dd); + +/* dic.c */ +int copyFile(struct DM *src, struct DM *dst); +void freeTdn(struct RkContext *cx); + +/* fq.c */ +struct RUT *allocRUT(unsigned long hn); +unsigned long searchRut(struct RUT *ruc, unsigned long csn); +int entryRut(struct RUT *ruc, unsigned long csn, unsigned long tick); +struct RUT *LoadRUC(int fr); +int FQopen(struct DM *dm, struct DM *qm, char *file, int mode); +void FQclose(struct RkContext *cx, struct DM *dm, struct DM *qm, char *file); +int FQsync(struct RkContext *cx, struct DM *dm, struct DM *qm, char *file); + +/* ncache.c */ +int _RkRelease(void); + +/* ngram.c */ +int RkGetGramNum(struct RkKxGram *gram, char *name); +unsigned char *RkGetGramName(struct RkKxGram *gram, int row); +WCHAR_T *RkUparseWrec(struct RkKxGram *gram, Wrec *src, WCHAR_T *dst, int maxdst, unsigned long *lucks); +struct TW *RkCopyWrec(struct TW *src); +struct TW *RkSubtractWrec(struct TW *tw1, struct TW *tw2); +struct TW *RkUnionWrec(struct TW *tw1, struct TW *tw2); + +int _RkRowNumber(unsigned char *wrec); + +/* nword.c */ +void _RkFreeBunq(struct nstore *st); +void _RkFreeQue(struct nstore *st, int s, int e); +int _RkRegisterNV(struct NV *nv, Wrec *yomi, int len, int half); +WCHAR_T *_RkGetKanji(struct nword *cw, WCHAR_T *key, unsigned long mode); +int _RkSubstYomi(struct RkContext *cx, int ys, int ye, WCHAR_T *yomi, int newLen); +int _RkFlushYomi(struct RkContext *cx); + +/* permdic.c */ +int _Rkpopen(struct DM *dm, char *dfnm, int mode, struct RkKxGram *gram); +int _Rkpclose(struct DM *dm, char *dfnm, struct RkKxGram *gram); +int _RkEql(WCHAR_T *a, unsigned char *b, int n); +int _Rkpsearch(struct RkContext *cx, struct DM *dm, WCHAR_T *key, int n, struct nread *nread, int mc, int *cf); +int _Rkpio(struct DM *dm, struct ncache *cp, int io); +int _Rkpctl(struct DM *dm, struct DM *qm, int what, WCHAR_T *arg, struct RkKxGram *gram); +int _Rkpsync(struct RkContext *cx, struct DM *dm, struct DM *qm); +int _Rktopen(struct DM *dm,char *file,int mode,struct RkKxGram *gram); +int _Rktclose(struct DM *dm,char *file,struct RkKxGram *gram); +int _Rktsearch(struct RkContext *cx,struct DM *dm,WCHAR_T *key,int n,struct nread *nread,int maxcache,int *cf); +int _Rktio( struct DM *dm,struct ncache *cp,int io); +int _Rktctl(struct DM *dm,struct DM *qm,int what,WCHAR_T *arg,struct RkKxGram *gram); +int _Rktsync(struct RkContext *cx, struct DM *dm, struct DM *qm); + +/* util.c */ +int uslen(WCHAR_T *us); +void usncopy(WCHAR_T *dst, WCHAR_T *src, int len); +unsigned char *ustoeuc(WCHAR_T *src, int srclen, unsigned char *dest, int destlen); +WCHAR_T *euctous(unsigned char *src, int srclen, WCHAR_T *dest, int destlen); +void _Rkpanic(char *fmt, int p, int q, int r); +WCHAR_T uniqAlnum(WCHAR_T c); +int set_hdr_var(struct HD *hd, int n, unsigned long var); +int HowManyChars(WCHAR_T *yomi, int len); +int HowManyBytes(WCHAR_T *yomi, int len); +int printWord(struct nword *w); +int showWord(struct nword *w); + +int _RkCalcLog2(int n); +unsigned char *_RkCreateHeader(struct HD *hd, unsigned *size); +unsigned long _RkGetTick(int mode); +int _RkGetLink(struct ND *dic, long pgno, unsigned long off, unsigned long *lvo, unsigned long *csn); +unsigned long _RkGetOffset(struct ND *dic, unsigned char *pos); +#endif /* _RKintern_h */ +/* don't add stuff after this line */ diff --git a/src/add-ons/input_server/methods/canna/rk/RKrename.h b/src/add-ons/input_server/methods/canna/rk/RKrename.h new file mode 100644 index 0000000000..79c1161278 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/RKrename.h @@ -0,0 +1,65 @@ +/* Copyright 1992 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: RKrename.h,v 1.1 2004/12/23 21:23:50 korli Exp $ */ + +#define RkGetProtocolVersion wRkGetProtocolVersion +#define RkGetServerName wRkGetServerName +#define RkGetServerVersion wRkGetServerVersion +#define RkwInitialize wRkwInitialize +#define RkwFinalize wRkwFinalize +#define RkwCreateContext wRkwCreateContext +#define RkwDuplicateContext wRkwDuplicateContext +#define RkwCloseContext wRkwCloseContext +#define RkwSetDicPath wRkwSetDicPath +#define RkwCreateDic wRkwCreateDic +#define RkwGetDicList wRkwGetDicList +#define RkwGetMountList wRkwGetMountList +#define RkwMountDic wRkwMountDic +#define RkwRemountDic wRkwRemountDic +#define RkwUnmountDic wRkwUnmountDic +#define RkwDefineDic wRkwDefineDic +#define RkwDeleteDic wRkwDeleteDic +#define RkwGetHinshi wRkwGetHinshi +#define RkwGetKanji wRkwGetKanji +#define RkwGetYomi wRkwGetYomi +#define RkwGetLex wRkwGetLex +#define RkwGetStat wRkwGetStat +#define RkwGetKanjiList wRkwGetKanjiList +#define RkwFlushYomi wRkwFlushYomi +#define RkwGetLastYomi wRkwGetLastYomi +#define RkwRemoveBun wRkwRemoveBun +#define RkwSubstYomi wRkwSubstYomi +#define RkwBgnBun wRkwBgnBun +#define RkwEndBun wRkwEndBun +#define RkwGoTo wRkwGoTo +#define RkwLeft wRkwLeft +#define RkwRight wRkwRight +#define RkwNext wRkwNext +#define RkwPrev wRkwPrev +#define RkwNfer wRkwNfer +#define RkwXfer wRkwXfer +#define RkwResize wRkwResize +#define RkwEnlarge wRkwEnlarge +#define RkwShorten wRkwShorten +#define RkwStoreYomi wRkwStoreYomi +#define RkwSetAppName wRkwSetAppName diff --git a/src/add-ons/input_server/methods/canna/rk/RKutil.c b/src/add-ons/input_server/methods/canna/rk/RKutil.c new file mode 100644 index 0000000000..504840c48c --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/RKutil.c @@ -0,0 +1,428 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="@(#)$Id: RKutil.c,v 1.1 2004/12/23 21:23:50 korli Exp $ $Author: korli $ $Revision: 1.1 $ $Data$"; +#endif + +#include +#include +#include +#include +#include + +#include "RKintern.h" +// There is Exported Symbols !! + +static char *Hdrtag[] = { + HD_TAG_MAG, + HD_TAG_VER, + HD_TAG_TIME, + HD_TAG_REC, + HD_TAG_CAN, + HD_TAG_L2P, + HD_TAG_L2C, + HD_TAG_PAG, + HD_TAG_LND, + HD_TAG_SND, + HD_TAG_SIZ, + HD_TAG_HSZ, + HD_TAG_DROF, + HD_TAG_PGOF, + HD_TAG_DMNM, + HD_TAG_CODM, + HD_TAG_LANG, + HD_TAG_WWID, + HD_TAG_WTYP, + HD_TAG_COPY, + HD_TAG_NOTE, + HD_TAG_TYPE, + 0, +}; + +static char essential_tag[] = { + HD_TIME, + HD_DMNM, + HD_LANG, + HD_WWID, + HD_WTYP, + HD_TYPE, +}; + +static unsigned char localbuffer[RK_MAX_HDRSIZ]; + +int +uslen(WCHAR_T *us) +{ + WCHAR_T *ous = us; + + if (!us) + return 0; + while (*us & RK_WMASK) + us++; + return (us - ous); +} + +void +usncopy(WCHAR_T *dst, WCHAR_T *src, int len) +{ + while (len-- > 0 && (*dst++ = *src++)) /* EMPTY */; +} + +unsigned char * +ustoeuc(WCHAR_T *src, int srclen, unsigned char *dest, int destlen) +{ + if (!src || !dest || !srclen || !destlen) + return dest; + while (*src && --srclen >= 0 && --destlen >= 0) { + if (us_iscodeG0(*src)) { + *dest++ = (unsigned char)*src++; + } else if (us_iscodeG2(*src)) { + *dest++ = RK_SS2; + *dest++ = (unsigned char)*src++; + destlen--; + } else if (destlen > 2) { + if (us_iscodeG3(*src)) { + *dest++ = RK_SS3; + } + *dest++ = (unsigned char)(*src >> 8); + *dest++ = (unsigned char)(*src++ | 0x80); + destlen--; + }; + }; + *dest = (unsigned char)0; + return dest; +} + +WCHAR_T * +euctous(unsigned char *src, int srclen, WCHAR_T *dest, int destlen) +{ + WCHAR_T *a = dest; + + if (!src || !dest || !srclen || !destlen) + return(a); + while (*src && (srclen-- > 0) && (destlen-- > 0)) { + if (!(*src & 0x80) ) { + *dest++ = (WCHAR_T)*src++; + } else if (srclen-- > 0) { + if (*src == RK_SS2) { + src++; + *dest++ = (WCHAR_T)(0x0080 | (*src++ & 0x7f)); + } else if ((*src == RK_SS3) && (srclen-- > 0)) { + src++; + *dest++ = (WCHAR_T)(0x8000 | ((src[0] & 0x7f) << 8) | (src[1] & (0x7f))); + src += 2; + } else { + *dest++ = (WCHAR_T)(0x8080 | ((src[0] & 0x7f) << 8) | (src[1] & 0x7f)); + src += 2; + } + } else { + break; + } + } + if (destlen-- > 0) + *dest = (WCHAR_T)0; + return dest; +} + +#ifndef WIN +static FILE *logfile = (FILE *)0; +#endif + +void +_Rkpanic(char *fmt, int p, int q, int r) +/* VARARGS2 */ +{ +#ifndef WIN + char msg[RK_LINE_BMAX]; + + (void)sprintf(msg, fmt, p, q, r); + (void)fprintf(logfile ? logfile : stderr, "%s\n", msg); + (void)fflush(logfile); +#endif + /* The following exit() must be removed. 1996.6.5 kon */ + exit(1); +} + +int +_RkCalcUnlog2(int x) +{ + return((1 << x) - 1); +} + +int +_RkCalcLog2(int n) +{ + int lg2; + + n--; + for (lg2 = 0; n > 0; lg2++) + n >>= 1; + return(lg2); +} + +WCHAR_T +uniqAlnum(WCHAR_T c) +{ + return((0xa3a0 < c && c < 0xa3ff) ? (WCHAR_T)(c & 0x7f) : c); +} + +void +_RkClearHeader(struct HD *hd) +{ + if (hd) { + for (int i = 0; i < HD_MAXTAG; i++) { + if (hd->flag[i] > 0) { + free(hd->data[i].ptr); + } + } + } +} + +int +_RkReadHeader(int fd, struct HD *hd, off_t off_from_top) +{ + unsigned char *src; + unsigned long len, off; + int i, tmpres; + long hdrsize; +#ifdef WIN + DWORD readsize; +#endif + + for (i = 0; i < HD_MAXTAG; i++) { + hd->data[i].var = 0; + hd->flag[i] = 0; + } + /* ¼¡¤Î off_from_top ¤Î·×»»¤¬¤¦¤µ¤ó¤¯¤µ¤¤¤¾ */ + tmpres = lseek(fd, off_from_top, 0); + if (tmpres < 0) { + RkSetErrno(RK_ERRNO_EACCES); + goto read_err; + } + + hdrsize = read(fd, (char *)localbuffer, RK_MAX_HDRSIZ); + if (hdrsize <= ((long) 0)) { + RkSetErrno(RK_ERRNO_EACCES); + goto read_err; + } + for (src = localbuffer; src < (localbuffer + hdrsize);) { + if (isEndTag(src)) + break; + for (i = 0; i < HD_MAXTAG; i++) { + if (!strncmp((char *)src, Hdrtag[i], HD_TAGSIZ)) + break; + } + if (i == HD_MAXTAG) + goto read_err; + src += HD_TAGSIZ; + len = bst4_to_l(src); + src += HD_TAGSIZ; + off = bst4_to_l(src); + src += HD_TAGSIZ; + if (hd->flag[i] != 0) + goto read_err; + if (len == 0) { + hd->flag[i] = -1; + hd->data[i].var = off; + } else { + hd->flag[i] = len; + if (!(hd->data[i].ptr = (unsigned char *)malloc((size_t) (len + 1)))) { + RkSetErrno(RK_ERRNO_NOMEM); + goto read_err; + } + if (off < (unsigned long)hdrsize) { + memcpy(hd->data[i].ptr, localbuffer + off, (size_t) len); + } else { + tmpres = lseek(fd, off_from_top + off, 0); + if (tmpres < 0) { + RkSetErrno(RK_ERRNO_EACCES); + goto read_err; + } + tmpres = read(fd, (char *)hd->data[i].ptr, (unsigned)len); + if (tmpres != (int)len) { + RkSetErrno(RK_ERRNO_EACCES); + goto read_err; + } + } + hd->data[i].ptr[len] = 0; + } + } + if (hd->data[HD_MAG].var != (long)bst4_to_l("CDIC")) { + goto read_err; + } + return 0; + read_err: + for (i = 0; i < HD_MAXTAG; i++) { + if (hd->flag[i] > 0) + free(hd->data[i].ptr); + hd->flag[i] = 0; + hd->data[i].var = 0; + } + return -1; +} + +unsigned char * +_RkCreateHeader(struct HD *hd, unsigned *size) +{ + unsigned char *tagdst, *datadst, *ptr; + int i, j; + unsigned long len, off; + + if (!hd) + return 0; + tagdst = localbuffer; + datadst = localbuffer + HD_MAXTAG * HD_MIN_TAGSIZ; + datadst += sizeof(long); + for (i = 0; i < HD_MAXTAG; i++) { + for (j = 0; j < sizeof(essential_tag); j++) { + if (essential_tag[j] == i) { + break; + } + } + memcpy(tagdst, Hdrtag[i], HD_TAGSIZ); + tagdst += HD_TAGSIZ; + if (hd->flag[i] == -1) { + len = 0; + off = hd->data[i].var; + } else if (hd->flag[i] > 0) { + len = hd->flag[i]; + off = datadst - localbuffer; + memcpy(datadst, hd->data[i].ptr, (size_t) len); + datadst += len; + } else { + len = 0; + off = 0; + } + l_to_bst4(len, tagdst); tagdst += HD_TAGSIZ; + l_to_bst4(off, tagdst); tagdst += HD_TAGSIZ; + } + *tagdst++ = 0; *tagdst++ = 0; *tagdst++ = 0; *tagdst++ = 0; + *size = datadst - localbuffer; + if (!(ptr = (unsigned char *)malloc(*size))) { + return 0; + } + memcpy(ptr, localbuffer, *size); + return ptr; +} + +unsigned long +_RkGetTick(int mode) +{ + static unsigned long time = 10000; + return(mode ? time++ : time); +} + +int +set_hdr_var(struct HD *hd, int n, unsigned long var) +{ + if (!hd) + return -1; + hd->data[n].var = var; + hd->flag[n] = -1; + return 0; +} + +int +_RkGetLink(struct ND *dic, long pgno, unsigned long off, unsigned long *lvo, unsigned long *csn) +{ + struct NP *pg = dic->pgs + pgno; + unsigned char *p; + unsigned i; + + for (i = 0, p = pg->buf + 14 + 4 * pg->ndsz; i < pg->lnksz; i++, p += 5) { + if (thisPWO(p) == off) { + *lvo = pg->lvo + thisLVO(p); + *csn = pg->csn + thisCSN(p); + return(0); + } + } + return(-1); +} + +unsigned long +_RkGetOffset(struct ND *dic, unsigned char *pos) +{ + struct NP *pg; + unsigned char *p; + unsigned i; + unsigned long lvo; + + for (i = 0; i < dic->ttlpg; i++) { + if (dic->pgs[i].buf) { + if (dic->pgs[i].buf < pos && pos < dic->pgs[i].buf + dic->pgsz) + break; + } + } + if (i == dic->ttlpg) { + return(0); + } + pg = dic->pgs + i; + for (i = 0, p = pg->buf + 14 + 4 * pg->ndsz; i < pg->lnksz; i++, p += 5) { + if ((unsigned long) (pos - pg->buf) == thisPWO(p)) { + lvo = pg->lvo + thisLVO(p); + return(lvo); + } + } + _Rkpanic("Cannot get Offset", 0, 0, 0); +} + +int +HowManyChars(WCHAR_T *yomi, int len) +{ + int chlen, bytelen; + + for (chlen = 0, bytelen = 0; bytelen < len; chlen++) { + WCHAR_T ch = yomi[chlen]; + + if (us_iscodeG0(ch)) + bytelen++; + else if (us_iscodeG3(ch)) + bytelen += 3; + else + bytelen += 2; + } + return(chlen); +} + +int +HowManyBytes(WCHAR_T *yomi, int len) +{ + int chlen, bytelen; + + for (chlen = 0, bytelen = 0; chlen < len; chlen++) { + WCHAR_T ch = yomi[chlen]; + + if (us_iscodeG0(ch)) + bytelen++; + else if (us_iscodeG3(ch)) + bytelen += 3; + else { + bytelen += 2; + } + } + return(bytelen); +} diff --git a/src/add-ons/input_server/methods/canna/rk/bits.c b/src/add-ons/input_server/methods/canna/rk/bits.c new file mode 100644 index 0000000000..9a0231bd5a --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/bits.c @@ -0,0 +1,324 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="$Id: bits.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif +/* LINTLIBRARY */ + +#include "RKintern.h" +// There is Exported Symbols !! +/************************************************************ + * PackBits +************************************************************/ +/* + ³Ø½¬¥Õ¥¡¥¤¥ëÍѥӥåÈÁàºî½èÍý + + ³Ø½¬¥ª¥Õ¥»¥Ã¥È¤Î¾ðÊó¤ò¡¢¤Ç¤­¤ë¤À¤±¾®¤µ¤¤¥Ó¥Ã¥È¤ÎÇÛÎó¤È¤·¤ÆÊÝ»ý¤¹¤ë¡£ + + ¸õÊä¿ô 1 2 3 4 5 6 7 8 9 ... n + ¥Ó¥Ã¥ÈÉý 2 3 3 4 4 4 4 5 5 log(n) + 1 + + RkPackBits ¤Ï unsigned ¤ÎÇÛÎó¤Î¿ô¤ò dst_bits ¤Î dst_offset(¥Ó¥Ã¥È¤Ç + ¥«¥¦¥ó¥È)¤ÎÀ褫¤é³ÊǼ¤¹¤ë¡£Ã¼¿ô¤¬½Ð¤¿¾ì¹ç¤Ï²¼°Ì¥Ó¥Ã¥È¤«¤é»È¤ï¤ì¤ë¡£ + + °ú¿ô + dst_bits -- ¥Ó¥Ã¥ÈÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + dst_offset -- ¼ÂºÝ¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤È¤³¤í¤Þ¤Ç¤Î¥ª¥Õ¥»¥Ã¥È(¥Ó¥Ã¥È¤Ç¥«¥¦¥ó¥È) + bit_size -- ¥Ó¥Ã¥ÈÇÛÎó¤Î£±¤Ä¤ÎÍ×ÁǤΥӥåÈÉý + src_ints -- ³ÊǼ¤·¤¿¤¤¿ôÃͤÎÇÛÎó + count -- ³ÊǼ¤·¤¿¤¤¿ô + + Ìá¤êÃÍ + + */ + +long +_RkPackBits(unsigned char *dst_bits, long dst_offset, int bit_size, unsigned *src_ints, int count) +{ + unsigned char *dstB; + unsigned dstQ; + unsigned dstCount; + unsigned bitMask; + + dstB = dst_bits + dst_offset / BIT_UNIT; + dstCount = (dst_offset % BIT_UNIT); + + /* ÅÓÃæ¤Ê¤Î¤Ç¡¢¼ê¤òÉÕ¤±¤Ê¤¤Éôʬ¤¬¤¢¤ë¤³¤È¤ËÃí°Õ */ + dstQ = *dstB & ((1 << dstCount) - 1); + bitMask = (1 << bit_size) - 1; + while (count-- > 0) { + dstQ |= (*src_ints++ & bitMask) << dstCount; + dstCount += bit_size; + dst_offset += bit_size; + while (dstCount >= BIT_UNIT) { + *dstB++ = dstQ & ((1 << BIT_UNIT) - 1); + dstQ >>= BIT_UNIT; + dstCount -= BIT_UNIT; + } + } + if (dstCount) { + *dstB = (*dstB & ~((1 << dstCount) - 1)) | (dstQ & ((1 << dstCount) - 1)); + } + return dst_offset; +} + +/* + UnpackBits + + RkUnpackBits ¤Ï dst_bits ¤Î dst_offset(¥Ó¥Ã¥È¤Ç¥«¥¦¥ó¥È)¤Ë³ÊǼ¤µ¤ì¤Æ + ¤¤¤ë¥Ó¥Ã¥È¤ÎÇÛÎó¤ò unsigned ¤ÎÇÛÎó¤Ë¼è¤ê½Ð¤¹¡£offset ¤Ëü¿ô¤¬½Ð¤¿¾ì + ¹ç¤Ï²¼°Ì¥Ó¥Ã¥È¤«¤é»È¤ï¤ì¤ë¡£ + + °ú¿ô + dst_ints -- ¼è¤ê½Ð¤·¤¿¿ôÃͤò³ÊǼ¤¹¤ëÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + src_bits -- ¥Ó¥Ã¥ÈÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + src_offset -- ¼ÂºÝ¤Ë³ÊǼ¤¹¤ë¤È¤³¤í¤Þ¤Ç¤Î¥ª¥Õ¥»¥Ã¥È(¥Ó¥Ã¥È¤Ç¥«¥¦¥ó¥È) + bit_size -- ¥Ó¥Ã¥ÈÇÛÎó¤Î£±¤Ä¤ÎÍ×ÁǤΥӥåÈÉý + count -- ¼è¤ê½Ð¤·¤¿¤¤¿ô + + Ìá¤êÃÍ + + */ + +long +_RkUnpackBits(unsigned *dst_ints, unsigned char *src_bits, long src_offset, int bit_size, int count) +{ + unsigned char *srcB; + unsigned srcQ; + unsigned srcCount; + unsigned bitMask; + + srcB = src_bits + src_offset / BIT_UNIT; + srcCount = BIT_UNIT - (src_offset % BIT_UNIT); + srcQ = *srcB++ >> (src_offset % BIT_UNIT); + bitMask = (1 << bit_size) - 1; + while (count-- > 0) { + while (srcCount < (unsigned)bit_size) { + srcQ |= (*srcB++ << srcCount); + srcCount += BIT_UNIT; + } + *dst_ints++ = srcQ & bitMask; + srcQ >>= bit_size; + srcCount -= bit_size; + src_offset += bit_size; + } + return src_offset; +} + +/* + CopyBits + + RkCopyBits ¤Ï src_bits ¤Î src_offset ¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¥Ó¥Ã¥ÈÇÛÎó¤ò + count ¸Ä¤À¤± dst_bits ¤Î dst_offset¤Ë°Üư¤µ¤»¤ë¡£ + + °ú¿ô + dst_bits -- °ÜưÀè¥Ó¥Ã¥ÈÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + dst_offset -- ¼ÂºÝ¤Ë³ÊǼ¤¹¤ë¤È¤³¤í¤Þ¤Ç¤Î¥ª¥Õ¥»¥Ã¥È(¥Ó¥Ã¥È¤Ç¥«¥¦¥ó¥È) + bit_size -- ¥Ó¥Ã¥ÈÇÛÎó¤Î£±¤Ä¤ÎÍ×ÁǤΥӥåÈÉý + src_bits -- °Üư¸µ¥Ó¥Ã¥ÈÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + src_offset -- ¼è¤ê½Ð¤¹¤È¤³¤í¤Þ¤Ç¤Î¥ª¥Õ¥»¥Ã¥È(¥Ó¥Ã¥È¤Ç¥«¥¦¥ó¥È) + count -- °Üư¤·¤¿¤¤¿ô + + Ìá¤êÃÍ + + */ + +long +_RkCopyBits(unsigned char *dst_bits, long dst_offset, int bit_size, unsigned char *src_bits, long src_offset, int count) +{ + unsigned char *dstB; + unsigned dstQ; + unsigned dstCount; + unsigned char *srcB; + unsigned srcQ; + unsigned srcCount; + unsigned bitMask; + unsigned bits; + + dstB = dst_bits + dst_offset / BIT_UNIT; + dstCount = (dst_offset % BIT_UNIT); + dstQ = *dstB & ((1 << dstCount) - 1); + srcB = src_bits + src_offset / BIT_UNIT; + srcCount = BIT_UNIT - (src_offset % BIT_UNIT); + srcQ = *srcB++ >> (src_offset % BIT_UNIT); + bitMask = (1 << bit_size) - 1; + while (count-- > 0) { + /* unpack */ + while (srcCount < (unsigned)bit_size) { + srcQ |= (*srcB++ << srcCount); + srcCount += BIT_UNIT; + } + bits = srcQ & bitMask; + srcQ >>= bit_size; + srcCount -= bit_size; + src_offset += bit_size; + /* pack */ + dstQ |= bits << dstCount; + dstCount += bit_size; + dst_offset += bit_size; + while (dstCount >= BIT_UNIT) { + *dstB++ = dstQ & ((1 << BIT_UNIT) - 1); + dstQ >>= BIT_UNIT; + dstCount -= BIT_UNIT; + } + } + if (dstCount) { + *dstB = (*dstB & ~((1 << dstCount) - 1)) | (dstQ & ((1 << dstCount) - 1)); + } + return dst_offset; +} + +/* + _RkSetBitNum + + _RkSetBitNum ¤Ï bit ÇÛÎó¤Î offset °ÌÃÖ¤«¤é n ÈÖÌܤÎÃͤȤ·¤Æ val ¤ò³Ê + Ǽ¤¹¤ë´Ø¿ô¤Ç¤¢¤ë¡£ + + °ú¿ô + dst_bits -- ¥Ó¥Ã¥ÈÇÛÎó¤Ø¤Î¥Ý¥¤¥ó¥¿ + dst_offset -- ¼ÂºÝ¤Ë³ÊǼ¤¹¤ë¤È¤³¤í¤Þ¤Ç¤Î¥ª¥Õ¥»¥Ã¥È(¥Ó¥Ã¥È¤Ç¥«¥¦¥ó¥È) + bit_size -- ¥Ó¥Ã¥ÈÇÛÎó¤Î£±¤Ä¤ÎÍ×ÁǤΥӥåÈÉý + n -- ÀèÆ¬¤«¤é²¿ÈÖÌܤÎÍ×ÁǤ«¤òÍ¿¤¨¤ë¡£ + val -- ³ÊǼ¤¹¤ëÃͤòÍ¿¤¨¤ë¡£ + + Ìá¤êÃÍ + + */ + +int +_RkSetBitNum(unsigned char *dst_bits, unsigned long dst_offset, int bit_size, int n, int val) +{ + unsigned char *dstB; + unsigned dstQ, dstCount, bitMask; + + dst_offset += bit_size * n; + + dstB = dst_bits + dst_offset / BIT_UNIT; + dstCount = (dst_offset % BIT_UNIT); + + /* ÅÓÃæ¤Ê¤Î¤Ç¡¢¼ê¤òÉÕ¤±¤Ê¤¤Éôʬ¤¬¤¢¤ë¤³¤È¤ËÃí°Õ */ + dstQ = *dstB & ((1 << dstCount) - 1); + bitMask = (1 << bit_size) - 1; + + dstQ |= (val & bitMask) << dstCount; + dstCount += bit_size; + dst_offset += bit_size; + while (dstCount >= BIT_UNIT) { + *dstB++ = dstQ & ((1 << BIT_UNIT) - 1); + dstQ >>= BIT_UNIT; + dstCount -= BIT_UNIT; + } + if (dstCount) { + *dstB = (*dstB & ~((1 << dstCount) - 1)) | (dstQ & ((1 << dstCount) - 1)); + } + return dst_offset; +} + +int +_RkCalcFqSize(int n) +{ + return n*(_RkCalcLog2(n) + 1); +} + +#ifdef __BITS_DEBUG__ +#include +_RkPrintPackedBits(unsigned char *bits, int offset, int bit_size, int count) +{ + fprintf(stderr, "%d <", count); + while ( count-- > 0 ) { + unsigned w; + + offset = _RkUnpackBits(&w, bits, offset, bit_size, 1); + fprintf(stderr, " %d", w/2); + }; + fprintf(stderr, ">\n"); +} + +int +_RkCalcLog2(int n) +{ + int lg2; + + n--; + for (lg2 = 0; n > 0; lg2++) + n >>= 1; + return(lg2); +} + +main(void) +{ + int offset; + int bit_size; + int size; + unsigned char bits[1024*8]; + unsigned char Bits[1024*8]; + int c, i; + int ec; + int o; + + /* create test run */ + for ( size = 1; size <= 32; size++ ) { + bit_size = _RkCalcLog2(size) + 1; + printf("#%4d/%2d\t", size, bit_size); + /* pack 'em all */ + o = 0; + for ( i = 0; i < size; i++ ) + o = _RkPackBits(Bits, o, bit_size, &i, 1); + printf("PK "); + for ( i = 0; i < (bit_size*size+7)/8; i++ ) + printf(" %02x", Bits[i]); + printf("\n"); + + + for ( offset = 0; offset < 16; offset++ ) { + /* copybits */ + o = _RkCopyBits(bits, offset, bit_size, Bits, 0, size); + printf("%d ", offset); + for ( i = 0; i < (o + 7)/8; i++ ) + printf(" %02x", bits[i]); + printf("\n"); + + /* unpack 'em again */ + ec = 0; + o = offset; + for ( i = 0; i < size; i++ ) { + unsigned w; + + o = _RkUnpackBits(&w, bits, o, bit_size, 1); + if ( w != i ) + ec++; + }; + if ( ec ) + printf(" %d", offset); + else + printf("."); + }; + printf("\n"); + }; +} +#endif diff --git a/src/add-ons/input_server/methods/canna/rk/bun.c b/src/add-ons/input_server/methods/canna/rk/bun.c new file mode 100644 index 0000000000..7b150041f3 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/bun.c @@ -0,0 +1,1299 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[] = "$Id: bun.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif + +/* LINTLIBRARY */ + +#include +#include "RKintern.h" + + +#define NEED_DEF +#ifdef RkSetErrno +#undef RkSetErrno +#define RkSetErrno(no) +#endif + +const unsigned OVERRUN_MARGIN = 0; + +#define STRCMP(d, s) strcmp((char *)(d), (char *)(s)) + +inline void +usncopy(WCHAR_T *dst, WCHAR_T *src, int len) +{ + memcpy(dst, src, len * sizeof(WCHAR_T)); +} + +static void +freeBunStorage(struct nstore *s) +{ + if (s) { + if (s->yomi) + free((s->yomi-OVERRUN_MARGIN)); + if (s->bunq) + free((s->bunq-OVERRUN_MARGIN)); + if (s->xq) + free((s->xq-OVERRUN_MARGIN)); + if (s->xqh) + free((s->xqh-OVERRUN_MARGIN)); + free(s); + } +} + +static struct nstore * +allocBunStorage(unsigned len) +{ + struct nstore *s; + + s = (struct nstore *)malloc((unsigned)sizeof(struct nstore)); + if (s) { + WCHAR_T *p, *q, pat; + int i; + + s->yomi = (WCHAR_T *)0; + s->bunq = (struct nbun *)0; + s->xq = (struct nqueue *)0; + s->xqh = (struct nword **)0; + s->nyomi = (unsigned)0; + s->maxyomi = (unsigned)len; + + s->yomi = (WCHAR_T *)calloc((s->maxyomi+1+2*OVERRUN_MARGIN), sizeof(WCHAR_T)); + s->maxbunq = (unsigned)len; + s->maxbun = (unsigned)0; + s->curbun = 0; + s->bunq = (struct nbun *)calloc((unsigned)(s->maxbunq+1+2*OVERRUN_MARGIN), + sizeof(struct nbun)); + s->maxxq = len; + s->xq = (struct nqueue *)calloc((unsigned)(s->maxxq+1+2*OVERRUN_MARGIN), + sizeof(struct nqueue)); + s->xqh = (struct nword **)calloc((unsigned)(s->maxxq+1+2*OVERRUN_MARGIN), + sizeof(struct nword *)); + if (!s->yomi || !s->bunq || !s->xq || !s->xqh) { + RkSetErrno(RK_ERRNO_ENOMEM); + freeBunStorage(s); + return (struct nstore *)0; + } + s->yomi += OVERRUN_MARGIN; + s->bunq += OVERRUN_MARGIN; + s->xq += OVERRUN_MARGIN; + s->xqh += OVERRUN_MARGIN; + p = (WCHAR_T*)&s->yomi[0]; + q = (WCHAR_T*)&s->yomi[s->maxyomi+1]; + for (i = 0; pat = (WCHAR_T)~i, i < OVERRUN_MARGIN; i++) + p[-i-1] = q[i] = pat; + p = (WCHAR_T*)&s->bunq[0]; + q = (WCHAR_T*)&s->bunq[s->maxbunq+1]; + for (i = 0; pat = (WCHAR_T)~i, i < OVERRUN_MARGIN; i++) + p[-i-1] = q[i] = pat; + p = (WCHAR_T*)&s->xq[0]; + q = (WCHAR_T*)&s->xq[s->maxxq+1]; + for (i = 0; pat = (WCHAR_T)~i, i < OVERRUN_MARGIN; i++) + p[-i-1] = q[i] = pat; + p = (WCHAR_T*)&s->xqh[0]; + q = (WCHAR_T*)&s->xqh[s->maxxq+1]; + for (i = 0; pat = (WCHAR_T)~i, i < OVERRUN_MARGIN; i++) + p[-i-1] = q[i] = pat; + s->word_in_use = 0; + }; + if (!s) /* EMPTY */RkSetErrno(RK_ERRNO_ENOMEM); + return s; +} + +struct nstore * +_RkReallocBunStorage(struct nstore *src, unsigned len) +{ + struct nstore *dst = allocBunStorage(len); + + if (dst) { + int i; + + if (src->yomi) { + for (i = 0; i <= (int)src->maxyomi; i++) + dst->yomi[i] = src->yomi[i]; + free((src->yomi-OVERRUN_MARGIN)); + }; + dst->nyomi = src->nyomi; + if (src->bunq) { + for (i = 0; i <= (int)src->maxbun; i++) + dst->bunq[i] = src->bunq[i]; + free((src->bunq-OVERRUN_MARGIN)); + }; + dst->maxbun = src->maxbun; + dst->curbun = src->curbun; + if (src->xq) { + for (i = 0; i <= src->maxxq; i++) + dst->xq[i] = src->xq[i]; + free((src->xq-OVERRUN_MARGIN)); + }; + if (src->xqh) { + for (i = 0; i <= src->maxxq; i++) + dst->xqh[i] = src->xqh[i]; + free((src->xqh-OVERRUN_MARGIN)); + }; + dst->word_in_use = src->word_in_use; + free(src); + return(dst); + } + return((struct nstore *)0); +} + +inline struct nbun * +getCurrentBun(struct nstore *store) +{ + if (store && 0 <= store->curbun && store->curbun < (int)store->maxbun) + return &store->bunq[store->curbun]; + return (struct nbun *)0; +} + +/* RkBgnBun + * renbunsetu henkan wo kaishi surutameno shokisettei wo okonau + * reuturns: + * # >=0 shoki bunsetsu no kosuu + * -1 shoki ka sippai + * RK_ERRNO_ECTXNO + * RK_ERRNO_EINVAL + * RK_ERRNO_ENOMEM + */ +int +RkwBgnBun(int cx_num, WCHAR_T *yomi, int n, int kouhomode) +{ + struct RkContext *cx; + unsigned long mask1, mask2; + int asset = 0; + + if (!(cx = RkGetContext(cx_num))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(-1); + } + if (IS_XFERCTX(cx)) { + RkSetErrno(0); + return(-1); + } + for (mask1 = (unsigned long) kouhomode, mask2 = 0L; + mask1; mask1 >>= RK_XFERBITS) { + if ((mask1 & (unsigned long)RK_XFERMASK) == (unsigned long)RK_CTRLHENKAN) { + mask1 >>= RK_XFERBITS; + asset = 1; + break; + } + mask2 = (mask2 << RK_XFERBITS) | ((unsigned long)RK_XFERMASK); + } + if (!(cx->store = allocBunStorage((unsigned)n))) { + RkSetErrno(RK_ERRNO_ENOMEM); + return(-1); + } + cx->flags |= (unsigned)CTX_XFER; + cx->concmode = (RK_CONNECT_WORD + | (asset ? ((int)mask1 & ~RK_TANBUN) : + (RK_MAKE_KANSUUJI | RK_MAKE_WORD | RK_MAKE_EISUUJI))); + cx->kouhomode = ((unsigned long)kouhomode) & mask2; + if (yomi) { + int i; + + if (n <= 0) { + RkSetErrno(RK_ERRNO_EINVAL); + RkwEndBun(cx_num, 0); + return(-1); + }; + for (i = 0; i < n; i++) + cx->store->yomi[i] = yomi[i]; + cx->store->yomi[n] = 0; + cx->store->nyomi = n; + cx->store->bunq[0].nb_yoff = 0; + i = _RkRenbun2(cx, mask1 & RK_TANBUN ? n : 0); + return(i); + } else { + cx->concmode |= RK_MAKE_WORD; + cx->flags |= (unsigned) CTX_XAUT; + if (n < 0) { + RkSetErrno(RK_ERRNO_EINVAL); + RkwEndBun(cx_num, 0); + return(-1); + }; + return(0); + } +} + +/* RkEndBun + * bunsetsu henkan wo shuuryou suru + * hituyou ni oujite, henkan kekka wo motoni gakushuu wo okonau + * + * return 0 + * -1(RK_ERRNO_ECTX) + */ +int +RkwEndBun(int cx_num, int mode) +{ +struct RkContext *cx; +struct nstore *store; +int i; +const int DO_LEARN = 1; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store)) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(-1); + } + if (mode) { + if (mode != DO_LEARN) { + RkSetErrno(RK_ERRNO_EINVAL); + return -1; + }; + } + for (i = 0; i < (int)store->maxbun; i++) + (void)_RkLearnBun(cx, i, mode); + if (cx->flags & CTX_XAUT) + _RkFreeQue(store, 0, store->maxxq + 1); + cx->concmode &= ~(RK_CONNECT_WORD | RK_MAKE_WORD | + RK_MAKE_KANSUUJI | RK_MAKE_EISUUJI); + _RkEndBun(cx); + freeBunStorage(store); + return(0); +} + +/* RkRemoveBun + * current bunsetu made wo sakujo suru + * current bunsetu ha 0 ni naru. + */ + +int +RkwRemoveBun(int cx_num, int mode) +{ + struct RkContext *cx; + struct nstore *store; + int i, c; + + if (!(cx = RkGetXContext(cx_num)) + || !(store = cx->store) + || !IS_XFERCTX(cx) + || store->maxbun <= 0) { + RkSetErrno(RK_ERRNO_ECTXNO); + return -1; + } + for (i = 0; i <= store->curbun; i++) + _RkLearnBun(cx, i, mode); + c = store->bunq[store->curbun + 1].nb_yoff; + for (i = store->curbun + 1; i <= (int)store->maxbun; i++) { + store->bunq[i - store->curbun - 1] = store->bunq[i]; + store->bunq[i - store->curbun - 1].nb_yoff -= c; + } + store->nyomi -= c; + usncopy(store->yomi, store->yomi + c, (unsigned)store->nyomi); + store->maxbun -= store->curbun + 1; + store->curbun = 0; + return(store->maxbun); +} + +/* RkSubstYomi + * change the contents of hiragana buffer + * returns: + * # bunsetu + */ + +int +RkwSubstYomi(int cx_num, int ys, int ye, WCHAR_T *yomi, int newLen) +{ + struct RkContext *cx; + struct nstore *store; + struct nbun *bun; + + if (!(cx = RkGetContext(cx_num))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(-1); + } + if (!(store = cx->store) || + !(bun = &store->bunq[store->maxbun]) || + !IS_XFERCTX(cx) || + !IS_XAUTCTX(cx) || + !(0 <= ys && ys <= ye && ye <= (int)(store->nyomi - bun->nb_yoff)) || + (newLen < 0)) { + RkSetErrno(RK_ERRNO_EINVAL); + return -1; + } + return _RkSubstYomi(cx, ys, ye, yomi, newLen); +} + +/* RkFlushYomi + * force to convert the remaining hiragana + * returns: + * # bunsetu + */ + +int +RkwFlushYomi(int cx_num) +{ + struct RkContext *cx; + if (!(cx = RkGetContext(cx_num)) || + !IS_XFERCTX(cx) || + !IS_XAUTCTX(cx)) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(-1); + } + return(_RkFlushYomi(cx)); +} + +/* RkResize/RkEnlarge/RkShorten + * current bunsetsu no ookisa wo henkou + */ +int +_RkResize(int cx_num, int len, int t) +{ + struct RkContext *cx; + struct nbun *bun; + struct nstore *store; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !(bun = getCurrentBun(store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(-1); + } + if (t) + len = HowManyChars(store->yomi + store->bunq[store->curbun].nb_yoff, len); + if (0 < len && (unsigned)(bun->nb_yoff + len) <= store->nyomi) { + bun->nb_flags |= RK_REARRANGED; + return(_RkRenbun2(cx, len)); + } + return(store->maxbun); +} + +int +RkwResize(int cx_num, int len) +{ + return(_RkResize(cx_num, len, 0)); +} + +int +RkeResize(int cx_num, int len) +{ + return(_RkResize(cx_num, len, 1)); +} + +int +RkwEnlarge(int cx_num) +{ + struct RkContext *cx; + struct nstore *store; + struct nbun *bun; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store)|| + !(bun = getCurrentBun(store))) { + RkSetErrno(RK_ERRNO_ENOMEM); + return(0); + } + if (store->nyomi > (unsigned)(bun->nb_yoff + bun->nb_curlen) && + store->yomi[bun->nb_yoff + bun->nb_curlen]) { + bun->nb_flags |= RK_REARRANGED; + return(_RkRenbun2(cx, (int)(bun->nb_curlen + 1))); + } + return(store->maxbun); +} + +int +RkwShorten(int cx_num) +{ + struct RkContext *cx; + struct nstore *store; + struct nbun *bun; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !(bun = getCurrentBun(store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return 0; + } + if (bun->nb_curlen > 1) { + bun->nb_flags |= RK_REARRANGED; + return(_RkRenbun2(cx, (int)(bun->nb_curlen - 1))); + } + return(store->maxbun); +} + +/* RkStoreYomi + * current bunsetu no yomi wo sitei sareta mono to okikaeru + * okikaeta noti, saihen kan suru + */ + +int +RkwStoreYomi(int cx_num, WCHAR_T *yomi, int nlen) +{ + unsigned nmax, omax, cp; + WCHAR_T *s, *d, *e; + int i, olen, diff; + struct RkContext *cx; + struct nstore *store; + struct nbun *bun; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !(bun = getCurrentBun(store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return -1; + } + if (!yomi || nlen < 0 || uslen(yomi) < nlen) { + RkSetErrno(RK_ERRNO_EINVAL); + return -1; + } + nmax = store->nyomi + (diff = nlen - (olen = bun->nb_curlen)); + omax = store->nyomi; + /* nobiru */ + if (nlen > olen) { + if (!(store = _RkReallocBunStorage(store, store->maxyomi + diff))) { + RkSetErrno(RK_ERRNO_ENOMEM); + return -1; + } + cx->store = store; + bun = getCurrentBun(store); + /* shift yomi */ + s = store->yomi + omax; + d = store->yomi + nmax; + e = store->yomi + bun->nb_yoff + olen; + while (s > e) + *--d = *--s; + } else if (nlen < olen) { /* chizimu */ + s = store->yomi + bun->nb_yoff + olen; + d = store->yomi + bun->nb_yoff + nlen; + e = store->yomi + omax; + while (s < e) + *d++ = *s++; + } + store->yomi[nmax] = (WCHAR_T)0; + store->nyomi = nmax; + for (i = store->curbun + 1; i <= (int)store->maxbun; i++) + store->bunq[i].nb_yoff += diff; + cp = store->curbun; + if (!nlen) { + _RkFreeBunq(store); + for (i = store->curbun; i < (int)store->maxbun; i++) + store->bunq[i] = store->bunq[i + 1]; + store->maxbun--; + cp = store->curbun; + if (cp >= store->maxbun && cp > 0) + cp -= 1; + } else + usncopy((store->yomi + bun->nb_yoff), yomi, (unsigned)nlen); + if ((i = _RkRenbun2(cx, 0)) != -1) + store->curbun = cp; + return(i); +} + +/* RkGoTo/RkLeft/RkRight + * current bunsetu no idou + */ + +int +RkwGoTo(int cx_num, int bnum) +{ + struct RkContext *cx; + struct nstore *store; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !store->maxbun) { + RkSetErrno(RK_ERRNO_ECTXNO); + return 0; + } + if ((0 <= bnum) && (bnum < (int)store->maxbun)) + store->curbun = bnum; + return(store->curbun); +} + +int +RkwLeft(int cx_num) +{ + struct RkContext *cx; + struct nstore *store; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !store->maxbun) { + RkSetErrno(RK_ERRNO_ECTXNO); + return 0; + } + if (--store->curbun < 0) + store->curbun = store->maxbun - 1; + return store->curbun; +} + +int +RkwRight(int cx_num) +{ + struct RkContext *cx; + struct nstore *store; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !store->maxbun) { + RkSetErrno(RK_ERRNO_ECTXNO); + return 0; + } + if (++store->curbun >= (int)store->maxbun) + store->curbun = 0; + return(store->curbun); +} + +/* RkXfer/RkNfer/RkNext/RkPrev + * current kouho wo henkou + */ +static int +countCand(struct RkContext *cx) +{ + struct nbun *bun; + int maxcand = 0; + unsigned long mask; + + bun = getCurrentBun(cx->store); + if (bun) { + maxcand = bun->nb_maxcand; + for (mask = cx->kouhomode; mask; mask >>= RK_XFERBITS) + maxcand++; + }; + return(maxcand); +} + +static int +getXFER(struct RkContext *cx, int cnum) +{ + struct nbun *bun = getCurrentBun(cx->store); + + cnum -= ((int)bun->nb_maxcand); + return(cnum < 0 ? RK_NFER : (cx->kouhomode>>(RK_XFERBITS*cnum))&RK_XFERMASK); +} + +int +RkwXfer(int cx_num, int knum) +{ + struct RkContext *cx; + struct nbun *bun; + + if (!(cx = RkGetXContext(cx_num)) || + !(cx->store) || + !(bun = getCurrentBun(cx->store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return 0; + } + if (0 <= knum && knum < countCand(cx)) + bun->nb_curcand = knum; + return(bun->nb_curcand); +} + +int +RkwNfer(int cx_num) +{ + struct RkContext *cx; + struct nbun *bun; + + if (!(cx = RkGetXContext(cx_num)) || + !(cx->store) || + !(bun = getCurrentBun(cx->store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(0); + } + return(bun->nb_curcand = bun->nb_maxcand); +} + +int RkwNext (int); + +int +RkwNext(int cx_num) +{ + struct RkContext *cx; + struct nbun *bun; + + if (!(cx = RkGetXContext(cx_num)) || + !(cx->store) || + !(bun = getCurrentBun(cx->store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(0); + } + if (++bun->nb_curcand >= (WCHAR_T)countCand(cx)) + bun->nb_curcand = 0; + return(bun->nb_curcand); +} + +int +RkwPrev(int cx_num) +{ + struct RkContext *cx; + struct nbun *bun; + + if (!(cx = RkGetXContext(cx_num)) || + !(cx->store) || + !(bun = getCurrentBun(cx->store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(0); + } + + if (!bun->nb_curcand) + bun->nb_curcand = countCand(cx); + return(--bun->nb_curcand); +} + +/* findBranch + * shiteisareta kouho wo fukumu path wo motomeru + */ +static struct nword * +findBranch(struct nstore *store, int cnum) +{ + struct nbun *bun; + struct nword *w; + + if (!(bun = getCurrentBun(store)) || + (0 > cnum) || + (cnum >= (int)bun->nb_maxcand)) + return((struct nword *)0); + for (w = bun->nb_cand; w; w = w->nw_next) { + if (CanSplitWord(w) && bun->nb_curlen == w->nw_ylen) { + if (cnum-- <= 0) + return(w); + } + } + return((struct nword *)0); +} + +/* RkGetStat + */ +int +RkwGetStat(int cx_num, RkStat *st) +{ + struct RkContext *cx; + struct nstore *store; + struct nbun *bun; + struct nword *cw, *lw; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !(bun = getCurrentBun(store)) || + !st) { + RkSetErrno(RK_ERRNO_ECTXNO); + return -1; + } + /* set up void values */ + st->bunnum = st->candnum = st->maxcand = + st->diccand = st->ylen = st->klen = st->tlen = 0; + st->bunnum = store->curbun; + st->candnum = bun->nb_curcand; + + st->maxcand = countCand(cx); + st->diccand = bun->nb_maxcand; + st->ylen = bun->nb_curlen; + st->klen = bun->nb_curlen; + st->tlen = 1; + /* look up the word node containing the current candidate */ + cw = findBranch(store, (int)bun->nb_curcand); + if (cw) { + st->klen = st->tlen = 0; + for (; cw; cw = cw->nw_left) { + if (!(lw = cw->nw_left)) + break; + if (cw->nw_klen == lw->nw_klen) + st->klen += (cw->nw_ylen - lw->nw_ylen); + else + st->klen += (cw->nw_klen - lw->nw_klen); + st->tlen++; + } + } else { + WCHAR_T *yomi = store->yomi + bun->nb_yoff; + switch(getXFER(cx, (int)bun->nb_curcand)) { + default: + case RK_XFER: + st->klen = RkwCvtHira((WCHAR_T *)0, 0, yomi, st->ylen); + break; + case RK_KFER: + st->klen = RkwCvtKana((WCHAR_T *)0, 0, yomi, st->ylen); + break; + case RK_HFER: + st->klen = RkwCvtHan((WCHAR_T *)0, 0, yomi, st->ylen); + break; + case RK_ZFER: + st->klen = RkwCvtZen((WCHAR_T *)0, 0, yomi, st->ylen); + break; + } + } + return 0; +} + +/* RkGetStat + */ +int +RkeGetStat(int cx_num, RkStat *st) +{ + struct RkContext *cx; + struct nstore *store; + WCHAR_T *yomi; + int res, klen; + WCHAR_T *kanji = (WCHAR_T *)malloc(sizeof(WCHAR_T) * (RK_LEN_WMAX + 1)); + if (!kanji) { + return -1; + } + + if (!(cx = RkGetXContext(cx_num)) || !(store = cx->store)) { + RkSetErrno(RK_MSG_ECTXNO); + res = -1; + goto return_res; + } + + yomi = store->yomi + store->bunq[store->curbun].nb_yoff; + klen = RkwGetKanji(cx_num, kanji, RK_LEN_WMAX + 1); + res = RkwGetStat(cx_num, st); + if (res < 0 || klen != st->klen) { + res = -1; + goto return_res; + } + if (st) { + st->ylen = HowManyBytes(yomi, st->ylen); + st->klen = HowManyBytes(kanji, klen); + } + return_res: + free(kanji); + return res; +} + +static int +addIt(struct nword * cw, WCHAR_T * key, int (*proc) (...), WCHAR_T * dst, int ind, int maxdst, unsigned long mode, RkContext * cx) +{ + struct nword *lw; + WCHAR_T *y; + RkLex lex; + + lw = cw->nw_left; + if (lw) { + ind = addIt(lw, key, proc, dst, ind, maxdst, mode, cx); + y = key + lw->nw_ylen; + lex.ylen = cw->nw_ylen - lw->nw_ylen; + lex.klen = cw->nw_klen - lw->nw_klen; + lex.rownum = cw->nw_rowcol; +#ifdef NEED_DEF + lex.colnum = cw->nw_rowcol; +#endif + lex.dicnum = cw->nw_class; + ind = (*proc) (dst, ind, maxdst, y, _RkGetKanji(cw, y, mode), &lex, cx); + } + return ind; +} + + +inline int +getIt(RkContext * cx, int cnum, int (*proc) (...), WCHAR_T * dst, int max) +{ + struct nstore *store = cx->store; + struct nbun *bun; + struct nword *w; + + if (!(bun = getCurrentBun(store)) || + !(w = findBranch(store, cnum))) + return (-1); + return addIt(w, store->yomi + bun->nb_yoff, proc, dst, 0, max, + cx->concmode, cx); +} + +/*ARGSUSED*/ +inline int +addYomi(WCHAR_T *dst, int ind, int max, WCHAR_T *yomi, WCHAR_T *kanji, RkLex *lex) +{ + int ylen; + + ylen = lex->ylen; + while (ylen--) { + if (ind < max) { + if (dst) + dst[ind] = *yomi++; + ind++; + } + } + return ind; +} +/* RkGetYomi + * current bunsetu no yomi wo toru + */ + +int RkwGetYomi (int, WCHAR_T *, int); + +int +RkwGetYomi(int cx_num, WCHAR_T *yomi, int maxyomi) +{ + struct RkContext *cx; + struct nbun *bun; + RkLex lex; + int i; + struct nstore *store; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !(bun = getCurrentBun(store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return -1; + }; + if (!yomi) { + RkSetErrno(RK_ERRNO_EINVAL); + return -1; + }; + lex.ylen = bun->nb_curlen; + i = addYomi(yomi, 0, maxyomi - 1, + store->yomi + bun->nb_yoff, + store->yomi+bun->nb_yoff, + &lex); + if (yomi && i < maxyomi) + yomi[i] = (WCHAR_T)0; + return i; +} + +int +RkwGetLastYomi(int cx_num, WCHAR_T *yomi, int maxyomi) +{ + struct RkContext *cx; + struct nbun *bun; + struct nstore *store; + int nyomi; + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store) || + !(bun = &store->bunq[store->maxbun])) { + RkSetErrno(RK_ERRNO_ECTXNO); + return -1; + } + if (!(cx->flags & CTX_XAUT) || maxyomi < 0) { + RkSetErrno(RK_ERRNO_EINVAL); + return -1; + } + nyomi = store->nyomi - bun->nb_yoff; + if (yomi) { + usncopy(yomi, store->yomi + bun->nb_yoff, (unsigned)(maxyomi)); + if (nyomi + 1 < maxyomi) { + yomi[nyomi] = (WCHAR_T)0; + } else { + yomi[maxyomi - 1] = (WCHAR_T)0; + }; + } + return nyomi; +} + +/*ARGSUSED*/ +static int +addKanji(WCHAR_T *dst, int ind, int max, WCHAR_T *yomi, WCHAR_T *kanji, RkLex *lex, struct RkContext *cx) /* ARGSUSED */ +{ + int klen; + + klen = lex->klen; + while (klen-- > 0) { + if (ind < max) { + if (dst) + dst[ind] = *kanji++; + ind++; + } + } + return ind; +} + +static int +getKanji(struct RkContext *cx, int cnum, WCHAR_T *dst, int maxdst) +{ + struct nbun *bun = getCurrentBun(cx->store); + WCHAR_T *yomi; + int i, ylen; + + i = getIt(cx, cnum, addKanji, dst, maxdst - 1); + if (i < 0) { + yomi = cx->store->yomi + bun->nb_yoff; + ylen = bun->nb_curlen; + switch(getXFER(cx, cnum)) { + default: + case RK_XFER: + i = RkwCvtHira(dst, maxdst, yomi, ylen); break; + case RK_KFER: + i = RkwCvtKana(dst, maxdst, yomi, ylen); break; + case RK_HFER: + i = RkwCvtHan(dst, maxdst, yomi, ylen); break; + case RK_ZFER: + i = RkwCvtZen(dst, maxdst, yomi, ylen); break; + } + } + if (dst && i < maxdst) + dst[i] = (WCHAR_T)0; + return i; +} + +/* RkGetKanji + * current bunsetu no kanji tuduri wo toru + */ + +int +RkwGetKanji(int cx_num, WCHAR_T *dst, int maxdst) +{ + RkContext *cx; + struct nbun *bun; + int i; + + if (!(cx = RkGetXContext(cx_num)) || + !(cx->store) || + !(bun = getCurrentBun(cx->store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return -1; + } + + i = getKanji(cx, (int)bun->nb_curcand, dst, maxdst); + if (dst && i < maxdst) + dst[i] = 0; + return i; +} + +/* RkGetKanjiList + * genzai sentaku sareta kouho mojiretu wo toridasu + */ +int +RkwGetKanjiList(int cx_num, WCHAR_T *dst, int maxdst) +{ + struct RkContext *cx; + int i, len, ind = 0, num = 0; + int maxcand; + + if (!(cx = RkGetXContext(cx_num)) || + !(cx->store)) { + RkSetErrno(RK_ERRNO_ECTXNO); + return -1; + } + maxcand = countCand(cx); + for (i = 0; i < maxcand; i++) { + if (dst) + len = getKanji(cx, i, dst + ind, maxdst - ind - 1); + else + len = getKanji(cx, i, dst, maxdst - ind - 1); + if (0 < len && ind + len + 1 < maxdst - 1) { + if (dst) + dst[ind + len] = (WCHAR_T)0; + ind += len + 1; + num++; + } + } + if (dst && ind < maxdst) + dst[ind] = (WCHAR_T)0; + return num; +} + +/* RkGetLex + * current bunsetu no hishi jouhou wo toru + */ +/*ARGSUSED*/ +static int +addLex(RkLex *dst, int ind, int max, WCHAR_T *yomi, WCHAR_T *kanji, RkLex *lex, struct RkContext *cx) /* ARGSUSED */ +{ + if (ind + 1 <= max) { + if (dst) + dst[ind] = *lex; + ind++; + } + return ind; +} + +int +RkwGetLex(int cx_num, RkLex *dst, int maxdst) +{ + RkContext *cx; + struct nbun *bun; + int i; + + if (!(cx = RkGetXContext(cx_num)) || + !(cx->store) || + !(bun = getCurrentBun(cx->store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return -1; + } + i = getIt(cx, (int)bun->nb_curcand, addLex, (WCHAR_T *)dst, maxdst - 1); + if (i < 0) { + if (dst && 1 < maxdst) { + dst[0].ylen = bun->nb_curlen; + dst[0].klen = bun->nb_curlen; + dst[0].rownum = cx->gram->P_BB; /* ʸÀá */ + dst[0].colnum = cx->gram->P_BB; /* ʸÀá */ + dst[0].dicnum = ND_EMP; + } + i = 1; + } + return i; +} + +/* RkeGetLex -- ¤Û¤Ü RkwGetLex ¤ÈƱ¤¸¤À¤¬Ä¹¤µ¤Ï¥Ð¥¤¥ÈŤÇÊÖ¤ë */ + +int +RkeGetLex(int cx_num, RkLex *dst, int maxdst) +{ + struct RkContext *cx; + struct nstore *store; + WCHAR_T *yomi, *kp; + int nwords, i; + WCHAR_T *kanji = (WCHAR_T *)malloc(sizeof(WCHAR_T) * (RK_LEN_WMAX + 1)); + if (!kanji) { + return -1; + } + + if (!(cx = RkGetXContext(cx_num)) || + !(store = cx->store)) { + RkSetErrno(RK_MSG_ECTXNO); + nwords = -1; + goto return_nwords; + } + + yomi = store->yomi + store->bunq[store->curbun].nb_yoff; + (void)RkwGetKanji(cx_num, kanji, RK_LEN_WMAX + 1); + kp = kanji; + nwords = RkwGetLex(cx_num, dst, maxdst); + if (dst) { + for (i = 0; i < nwords; i++) { + int tmp; + tmp = dst[i].ylen; + dst[i].ylen = HowManyBytes(yomi, tmp); yomi += tmp; + tmp = dst[i].klen; + dst[i].klen = HowManyBytes(kp, tmp); kp += tmp; + } + } + return_nwords: + free(kanji); + return nwords; +} + +/*ARGSUSED*/ +static int +addHinshi(WCHAR_T *dst, int ind, int max, WCHAR_T *yomi, WCHAR_T *kanji, RkLex *lex, struct RkContext *cx) +{ + int bytes; + WCHAR_T *p; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + WCHAR_T hinshi[256]; +#else + WCHAR_T *hinshi = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 256); + if (!hinshi) { + return ind; + } +#endif + + if (cx) { + p = RkUparseGramNum(cx->gram->gramdic, lex->rownum, hinshi, 256); + if (p) { + bytes = p - hinshi; + if (ind + bytes < max) { + if (dst) + usncopy(dst + ind, hinshi, bytes); + ind += bytes; + } + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(hinshi); +#endif + return ind; +} + +/* RkGetHinshi + * current bunsetu no hinshi mojiretu wo toru + */ +int +RkwGetHinshi(int cx_num, WCHAR_T *dst, int maxdst) +{ + struct RkContext *cx; + struct nbun *bun; + int i; + + if (!(cx = RkGetXContext(cx_num)) || + !(cx->store) || + !(bun = getCurrentBun(cx->store))) { + RkSetErrno(RK_ERRNO_ECTXNO); + return(-1); + } + i = getIt(cx, (int)bun->nb_curcand, addHinshi, dst, maxdst - 1); + if (i < 0) { + if (dst && 1 < maxdst) + dst[0] = (WCHAR_T)0; + i = 1; + } + return(i); +} + +#include +#include + +#define CloseContext(a) {if ((a) != cx_num) RkwCloseContext(a);} + +int +RkwQueryDic(int cx_num, char *dirname, char *dicname, struct DicInfo *status) +{ + struct RkContext *cx; + int new_cx_num, size; + unsigned char *buff; + char *file; + struct DM *dm; + struct DF *df; + struct stat st; + + if (!(cx = RkGetContext(cx_num)) + || !status || !dirname || !dicname || !dicname[0]) + return(-1); + size = strlen(dicname) + 1; + if (!(buff = (unsigned char *)malloc(size))) + return(-1); + (void)strcpy((char *)buff, dicname); + if (*dirname && strcmp(dirname, cx->ddpath[0]->dd_name) + && strcmp(dirname, (char *)SYSTEM_DDHOME_NAME)) { + if((new_cx_num = RkwCreateContext()) < 0) { + free(buff); + return BADCONT; + } + if(RkwSetDicPath(new_cx_num, dirname) < 0) { + CloseContext(new_cx_num); + free(buff); + return NOTALC; + } + if (!(cx = RkGetContext(new_cx_num))) { + free(buff); + return(-1); + } + } else { + if (!strcmp(dirname, (char *)SYSTEM_DDHOME_NAME)) + dirname = SYSTEM_DDHOME_NAME; + else + dirname = cx->ddpath[0]->dd_name; + new_cx_num = cx_num; + } + if (!strcmp(dirname, (char *)SYSTEM_DDHOME_NAME)) { + if (!(dm = _RkSearchDDP(cx->ddpath, dicname))) { + CloseContext(new_cx_num); + free(buff); + return NOENT; + } + } else { + if (!(dm = _RkSearchUDDP(cx->ddpath, (unsigned char *)dicname))) { + CloseContext(new_cx_num); + free(buff); + return NOENT; + } + } + df = dm->dm_file; + if (df) { + file = _RkCreatePath(df->df_direct, df->df_link); + if (file) { + status->di_dic = (unsigned char *)dm->dm_nickname; + status->di_file = (unsigned char *)df->df_link; + status->di_form = (DM2TYPE(dm) == DF_TEMPDIC) ? RK_TXT : RK_BIN; + status->di_kind = dm->dm_class; + status->di_count = stat(file, &st) >= 0 ? st.st_size : 0; + status->di_time = stat(file, &st) >= 0 ? st.st_ctime : 0; + status->di_mode = 0; + CloseContext(new_cx_num); + free(file); + free(buff); + return(0); + } + } + free(buff); + CloseContext(new_cx_num); + return(-1); +} + +int +_RkwSync(struct RkContext *cx, char *dicname) +{ + struct DM *dm, *qm; + + dm = _RkSearchDicWithFreq(cx->ddpath, dicname, &qm); + + if (dm) + return(DST_SYNC(cx, dm, qm)); + else + return (-1); +} + + +int +RkwSync(int cx_num, char *dicname) +{ + struct RkContext *cx; + int ret = -1; + const off_t DL_SIZE = 1024; + + if (!(cx = RkGetContext(cx_num))) + return (-1); + + if (!dicname || !*dicname) { + int i, rv; + char *p; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + char diclist[DL_SIZE]; +#else + char *diclist = (char *)malloc(DL_SIZE); + if (!diclist) { + return -1; + } +#endif + + if (!(i = RkwGetDicList(cx_num, diclist, DL_SIZE))) { + ret = 0; + } + else { + if (i > 0) { + for (p = diclist, rv = 0; *p;) { + rv += _RkwSync(cx, p); + p += strlen(p) + 1; + } + if (!rv) { + ret = 0; + goto return_ret; + } + } + ret = -1; + } + return_ret:; +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(diclist); +#endif + } else { + ret = _RkwSync(cx, dicname); + } + return ret; +} + +/*ARGSUSED*/ +RkwGetSimpleKanji(int cxnum, char *dicname, WCHAR_T *yomi, int maxyomi, WCHAR_T *kanjis, int maxkanjis, char *hinshis, int maxhinshis) +{ + return -1; +} + +/*ARGSUSED*/ +int +RkwStoreRange(int cx_num, WCHAR_T *yomi, int maxyomi) +{ + return(0); +} + +/*ARGSUSED*/ +int +RkwSetLocale(int cx_num, unsigned char *locale) +{ + return(0); +} diff --git a/src/add-ons/input_server/methods/canna/rk/context.c b/src/add-ons/input_server/methods/canna/rk/context.c new file mode 100644 index 0000000000..6f3b8944bb --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/context.c @@ -0,0 +1,949 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="$Id: context.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif +/*LINTLIBRARY*/ + +#include "RKintern.h" +#include "patchlevel.h" +#include + +#include +#include +#include +#include + +static unsigned long now_context = 0L; + +#define cx_gwt cx_extdata.ptr +#define STRCMP(d, s) strcmp((char *)(d), (char *)(s)) + +struct RkGram SG; +struct RkParam SX; + +/* RkInitialize: Renbunsetsu Henkan shokika + * subeteno Renbunsetsu henkan kannsuu wo siyou suru maeni + * itido dake call suru koto. + * returns: -1/0 + */ +static struct RkContext *CX; + +#ifdef MMAP +/* If you compile with Visual C++, then please comment out the next 3 lines. */ +#include /* mmap */ +#include /* mmap */ +#include /* mmap */ +int fd_dic = -1; /* mmap */ +#endif + +#define DEFAULTGRAMDIC "/canna/fuzokugo.cbd" + +static int _RkInitialize(char *ddhome, int numCache); +static void _RkFinalizeWord(void); +static int fillContext(int cx_num); +static int diccmp(const struct dics *a, const struct dics *b); + +static int +_RkInitialize(char *ddhome, int numCache) +{ + int i = strlen(ddhome); + struct RkParam *sx = &SX; + struct DD *dd = &sx->dd; + char path[B_PATH_NAME_LENGTH]; + int con; + +#ifdef MMAP + if((fd_dic == -1) && (fd_dic = open("/dev/zero", O_RDWR)) < 0) { + /* leave open as it was, because WIN does not come here. 1996.6 kon */ + con = -1; + goto return_con; + } +#endif + + if (sx->flag & SX_INITED) { + con = -1; + goto return_con; + } + +// gramdic = (char *)malloc(strlen(DEFAULTGRAMDIC) + i + 1); + if (1) { + sprintf(path, "%s%s", ddhome, DEFAULTGRAMDIC); + SG.gramdic = RkOpenGram(path); +// free(gramdic); + if (SG.gramdic) { + /* confirm user/ and group/ directory */ + if (1) { + sprintf(path, "%s/%s", ddhome, USER_DIC_DIR); + if (close(open(path, 0, 0664)) < 0 && + mkdir(path, MKDIR_MODE) < 0) { + } else { + + if (1) { + sprintf(path, "%s/%s", ddhome, GROUP_DIC_DIR); + if (close(open(path, 0, 0664)) < 0 && + mkdir(path, MKDIR_MODE) < 0) { + } + else { + sx->word = (struct nword *)0; + dd->dd_next = dd->dd_prev = dd; + sx->ddhome = strdup(ddhome); + if (sx->ddhome) { + SG.P_BB = RkGetGramNum(SG.gramdic, "BB"); + SG.P_NN = RkGetGramNum(SG.gramdic, "NN"); + SG.P_T00 = RkGetGramNum(SG.gramdic, "T00"); + SG.P_T30 = RkGetGramNum(SG.gramdic, "T30"); + SG.P_T35 = RkGetGramNum(SG.gramdic, "T35"); +#ifdef FUJIEDA_HACK + SG.P_KJ = RkGetGramNum(SG.gramdic, "KJ"); +#endif + CX = (struct RkContext *) + calloc(INIT_CONTEXT, sizeof(struct RkContext)); + if (CX) { + now_context += INIT_CONTEXT; + if (_RkInitializeCache(numCache) == 0) { + sx->ddpath = _RkCreateDDP(SYSTEM_DDHOME_NAME); + if (sx->ddpath) { + con = RkwCreateContext(); + if (con >= 0) { + sx->flag |= SX_INITED; + goto return_con; + } + _RkFreeDDP(sx->ddpath); + sx->ddpath = (struct DD **)0; + } + _RkFinalizeCache(); + } + free(CX); + now_context = 0L; + } + free(sx->ddhome); + } + } + } + } + } + RkCloseGram(SG.gramdic); + } + } + con = -1; + return_con: + return con; +} + +int +RkwInitialize(char *ddhome) +{ + /* + * Word: ???? + * Cache: 36B*512 = 20KB + * Heap: 30*1024B = 30KB + */ +#ifdef WIN + return(ddhome ? _RkInitialize(ddhome, 512*3) : -1); +#else + return(ddhome ? _RkInitialize(ddhome, 512*10) : -1); +#endif +} + +/* RkFinalize: Renbunsetu henkan shuuryou shori + * + */ +static void +_RkFinalizeWord(void) /* finalize free word list */ +{ + struct nword *w, *t; + + /* dispose each page in list */ + for (w = SX.page; w; w = t) { + t = w->nw_next; + free(w); + } + SX.word = (struct nword *)0; + SX.page = (struct nword *)0; + SX.word_in_use = 0; + SX.page_in_use = 0; +} + +void +RkwFinalize(void) +{ + struct RkParam *sx = &SX; + int i; + + /* already initialized */ + if (!(sx->flag & SX_INITED)) + return; + /* houchi sareta context wo close */ + for(i = 0; (unsigned long)i < now_context; i++) + if (IS_LIVECTX(&CX[i])) + RkwCloseContext(i); + free(CX); + now_context = 0L; + /* sonohoka no shuuryou shori */ + _RkFinalizeWord(); + _RkFinalizeCache(); + free(sx->ddhome); + sx->ddhome = (char *)0; + _RkFreeDDP(sx->ddpath); + RkCloseGram(SG.gramdic); + sx->flag &= ~SX_INITED; + +#ifdef MMAP + close(fd_dic); + fd_dic = -1; +#endif + + return; +} + +/* RkGetSystem: System heno pointer wo motomeru + */ +struct RkParam * +RkGetSystem(void) +{ + return(&SX); +} + +/* RkGetSystemDD: System heno pointer wo motomeru + */ +struct DD * +RkGetSystemDD(void) +{ + struct RkParam *sx; + return(((sx = RkGetSystem()) && sx->ddpath) ? sx->ddpath[0] : (struct DD *)0); +} + +/* RkGetContext: Context heno pointer wo motomeru + * -> RKintern.h + */ +struct RkContext * +RkGetContext(int cx_num) +{ + return(IsLiveCxNum(cx_num) ? &CX[cx_num] : (struct RkContext *)0); +} + +struct RkContext * +RkGetXContext(int cx_num) +{ + struct RkContext *cx; + + cx = RkGetContext(cx_num); + if (cx) + if (!IS_XFERCTX(cx)) + cx = (struct RkContext *)0; + return(cx); +} + +void +_RkEndBun(struct RkContext *cx) +{ + struct DD **ddp = cx->ddpath; + int c; + + cx->flags &= ~(CTX_XFER|CTX_XAUT); + cx->concmode &= ~(RK_CONNECT_WORD | RK_MAKE_WORD | + RK_MAKE_KANSUUJI | RK_MAKE_EISUUJI); + for (c = 0; c < 4; c++) { + struct MD *head, *md, *nd; + + head = cx->md[c]; + for (md = head->md_next; md != head; md = nd) { + struct DM *dm = md->md_dic; + struct DF *df = dm->dm_file; + struct DD *dd = df->df_direct; + + nd = md->md_next; + if (md->md_flags & MD_MPEND) /* release pending */ + md->md_flags &= ~MD_MPEND; + if (md->md_flags & MD_UPEND) /* unmount pending */ + _RkUmountMD(cx, md); + else + if (!_RkIsInDDP(ddp, dd)) /* unreachable */ + _RkUmountMD(cx, md); + }; + }; +} + +/* RkSetDicPath + * + */ + +int +RkwSetDicPath(int cx_num, char *path) +{ + struct RkContext *cx = RkGetContext(cx_num); + struct DD **newc; + + newc = _RkCreateDDP(path); + if (newc) { + _RkFreeDDP(cx->ddpath); + cx->ddpath = newc; + return(0); + }; + return(-1); +} + +/* + fillContext -- ¥³¥ó¥Æ¥¯¥¹¥È¹½Â¤ÂΤηè¤Þ¤Ã¤¿¤È¤³¤í¤ËÃͤòËä¤á¤Æ¤ä¤ë¡£ + + return value: + 0 OK + -1 ¥À¥á + */ + +static int +fillContext(int cx_num) +{ + struct RkContext *cx = &CX[cx_num]; + int i; + + /* create mount list headers */ + for (i = 0; i < 4; i++) { + struct MD *mh; + + if (!(mh = (struct MD *)calloc(1, sizeof(struct MD)))) { + int j; + + for (j = 0 ; j < i; j++) { + free(cx->md[i]); + } + return -1; + } + mh->md_next = mh->md_prev = mh; + mh->md_dic = (struct DM *)0; + mh->md_flags = 0; + cx->md[i] = mh; + } + cx->dmprev = (struct DM *)0; + cx->qmprev = (struct DM *)0; + cx->nv = (struct NV *)0; + cx->ddpath = (struct DD **)0; + cx->kouhomode = (unsigned long)0; + cx->concmode = 0; + cx->litmode = (unsigned long *)calloc(MAXLIT, sizeof(unsigned long)); + cx->gram = &SG; + if (cx->litmode) { + for (i = 0; i < MAXLIT; i++) { + cx->litmode[i] = 0x87654321; + } + cx->poss_cont = 0; +#ifdef EXTENSION_NEW + cx->cx_gwt = (pointer)calloc(1, sizeof(struct _rec)); + if (cx->cx_gwt) { + struct _rec *gwt = (struct _rec *)cx->cx_gwt; + gwt->gwt_cx = -1; /* means no GetWordTextdic context + is available */ + gwt->gwt_dicname = (unsigned char *)0; + cx->flags = CTX_LIVE | CTX_NODIC; + return 0; + } + free(cx->litmode); +#else + cx->flags = CTX_LIVE | CTX_NODIC; + return 0; +#endif + } + return -1; +} + +int +RkwCreateContext(void) +{ + int cx_num, i; + struct RkContext *newcx; + + /* saisho no aki context wo mitsukeru */ + for(cx_num = 0; cx_num < (int)now_context; cx_num++) { + if(!CX[cx_num].flags) { + /* create mount list headers */ + if (fillContext(cx_num) == 0) { + return cx_num; + } + } + } + newcx = (RkContext *)realloc(CX, (size_t) sizeof(RkContext) + * (now_context+ADD_CONTEXT)); + if (newcx) { + CX = newcx; + for (i = now_context ; i < (int)now_context + ADD_CONTEXT ; i++) { + CX[i].flags = (unsigned)0; + } + cx_num = now_context; + now_context += ADD_CONTEXT; + if (fillContext(cx_num) == 0) { + return cx_num; + } + } + return(-1); +} + +int +RkwCloseContext(int cx_num) +{ + struct RkContext *cx; + int i; + + if (!(cx = RkGetContext(cx_num))) + return(-1); +/* terminate bunsetu henkan */ + if (IS_XFERCTX(cx)) + RkwEndBun(cx_num, 0); + _RkFreeDDP(cx->ddpath); + cx->ddpath = (struct DD **)0; + /* subete no jisho wo MD suru */ + for (i = 0; i < 4; i++) { + struct MD *mh, *m, *n; + + /* destroy mount list */ + mh = cx->md[i]; + if (mh) { + for (m = mh->md_next; m != mh; m = n) { + n = m->md_next; + (void)_RkUmountMD(cx, m); + }; + free(mh); + cx->md[i] = (struct MD *)0; + }; + }; + cx->dmprev = (struct DM *)0; + cx->qmprev = (struct DM *)0; + /* convertion table */ + if (cx->litmode) { + free(cx->litmode); + cx->litmode = (unsigned long *)0; + } + cx->flags = 0; + + /* free grammatical dictionary */ + cx->gram->refcount--; + if (cx->gram->refcount == 0 && cx->gram != &SG) { + RkCloseGram(cx->gram->gramdic); + free(cx->gram); + } + cx->gram = (struct RkGram *)0; + +#ifdef EXTENSION_NEW + if (cx->cx_gwt) { + struct _rec *gwt = (struct _rec *)cx->cx_gwt; + if (gwt) { + (void)RkwCloseContext(gwt->gwt_cx); + if (gwt->gwt_dicname) + free(gwt->gwt_dicname); + free(gwt); + }; + cx->cx_gwt = (pointer)0; + }; + freeTdn(cx); +#endif + return 0; +} +/* RkDuplicateContext + * onaji naiyou no context wo sakuseisuru + */ + +int +RkwDuplicateContext(int cx_num) +{ + struct RkContext *sx; + int dup = -1; + + dup = RkwCreateContext(); + if (dup >= 0) { + int i; + struct RkContext *dx; + + sx = RkGetContext(cx_num); + if (sx) { + dx = RkGetContext(dup); + + /* use the same grammatical information */ + dx->gram = sx->gram; + dx->gram->refcount++; + if (!(sx->flags & CTX_NODIC)) { + dx->flags &= ~CTX_NODIC; + } + + /* copy the mount list */ + for (i = 0; i < 4; i++) { + struct MD *mh, *md; + + /* should mount dictionaries in reverse order */ + mh = sx->md[i]; + for (md = mh->md_prev; md != mh; md = md->md_prev) + (void)_RkMountMD(dx, md->md_dic, md->md_freq, + md->md_flags & MD_WRITE, 0); + }; + dx->ddpath = _RkCopyDDP(sx->ddpath); + if (sx->litmode && dx->litmode) + for (i = 0; i < MAXLIT; i++) + dx->litmode[i] = sx->litmode[i]; + } else { + RkwCloseContext(dup); + return -1; + } + } + return(dup); +} + +/* RkMountDic: append the specified dictionary at the end of the mount list */ +int +RkwMountDic(int cx_num, char *name, int mode) /* mount mode */ +{ + struct RkContext *cx; + int firsttime; + + if (!name) + return(-1); + cx = RkGetContext(cx_num); + if (cx) { + struct DM *dm, *qm; + + firsttime = (cx->flags & CTX_NODIC) ? 1 : 0; + if (firsttime) { /* ºÇ½é¤Ë¥Þ¥¦¥ó¥È*¤·¤è¤¦¤È*¤·¤¿¤é¹ß¤í¤¹ */ + cx->flags &= ~CTX_NODIC; + } + + dm = _RkSearchDicWithFreq(cx->ddpath, name, &qm); + if (dm) { + struct MD *mh = cx->md[dm->dm_class]; + struct MD *md, *nd; + int count = 0; + + /* search the dictionary */ + for (md = mh->md_next; md != mh; md = nd) { + nd = md->md_next; + if (md->md_dic == dm) { /* already mounted */ + /* cancel the previous unmount */ + if (md->md_flags & MD_UPEND) + md->md_flags &= ~MD_UPEND; + count++; + }; + }; + if (!count) { + return _RkMountMD(cx, dm, qm, mode, firsttime); + } + } + } + return(-1); +} +/* RkUnmountDic: removes the specified dictionary from the mount list */ +int +RkwUnmountDic(int cx_num, char *name) +{ + struct RkContext *cx; + int i; + + if (!name) + return(-1); + cx = RkGetContext(cx_num); + if (cx) { + for (i = 0; i < 4; i++) { + struct MD *mh = cx->md[i]; + struct MD *md, *nd; + + for (md = mh->md_next; md != mh; md = nd) { + struct DM *dm = md->md_dic; + char *ename; + + ename = md->md_freq ? md->md_freq->dm_nickname : dm->dm_nickname; + nd = md->md_next; + if (!STRCMP(ename, name)) { + _RkUmountMD(cx, md); + } + } + } + return(0); + } + return(-1); +} + +/* RkRemountDic: relocate the specified dictionary among the mount list */ +int +RkwRemountDic(int cx_num, char *name, int mode) /* mount mode */ +{ + struct RkContext *cx; + int i, isfound = 0; + char *ename; + + if (!name) + return(-1); + cx = RkGetContext(cx_num); + if (cx) { + for (i = 0; i < 4; i++) { + struct MD *mh = cx->md[i]; + struct MD *md, *pd; + + /* do in reverse order */ + for (md = mh->md_prev; md != mh; md = pd) { + struct DM *dm = md->md_dic; + + ename = md->md_freq ? md->md_freq->dm_nickname : dm->dm_nickname; + pd = md->md_prev; + if (!STRCMP(ename, name)) { + /* remove from mount list */ + md->md_prev->md_next = md->md_next; + md->md_next->md_prev = md->md_prev; + /* insert according to the mode */ + if (!mode) { /* sentou he */ + md->md_next = mh->md_next; + md->md_prev = mh; + mh->md_next->md_prev = md; + mh->md_next = md; + } else { /* saigo he */ + md->md_next = mh; + md->md_prev = mh->md_prev; + mh->md_prev->md_next = md; + mh->md_prev = md; + }; + isfound++; + }; + }; + }; + if (isfound) + return(0); + }; + return(-1); +} + +/* RkGetDicList: collects the names of the mounted dictionaies */ +int +RkwGetMountList(int cx_num, char *mdname, int maxmdname) +{ + struct RkContext *cx; + struct MD *mh, *md; + int p, i, j; + int count = -1; + + cx = RkGetContext(cx_num); + if (cx) { + i = count = 0; + for (p = 0; p < 4; p++) { + mh = cx->md[p]; + for (md = mh->md_next; md != mh; md = md->md_next) { + struct DM *dm = md->md_dic; + char *name; + + if (md->md_flags & (MD_MPEND|MD_UPEND)) { + continue; + }; + name = md->md_freq ? md->md_freq->dm_nickname : dm->dm_nickname; + j = i + strlen(name) + 1; + if (j + 1 < maxmdname) { + if (mdname) { + (void)strcpy(mdname + i, name); + } + i = j; + count++; + }; + }; + }; + if (i + 1 < maxmdname && mdname) + mdname[i++] = (char)0; + }; + return(count); +} + +/* RkGetDicList: collects the names of dictionary */ + +struct dics { + char *nickname, *dicname; + int dictype; +}; + + +static int +diccmp(const struct dics *a, const struct dics *b) +{ + int res; + + res = strcmp(a->nickname, b->nickname); + if (res == 0) { + res = strcmp(a->dicname, b->dicname); + if (res == 0) { + if (a->dictype == b->dictype) { + res = 0; + } + else if (a->dictype == DF_FREQDIC) { + res = -1; + } + else if (b->dictype == DF_FREQDIC) { + res = 1; + } + else if (a->dictype == DF_PERMDIC) { + res = -1; + } + else if (b->dictype == DF_PERMDIC) { + res = 1; + }else{ + res = 0; + } + } + } + return res; +} + +int +RkwGetDicList(int cx_num, char *mdname, int maxmdname) +{ + struct RkContext *cx; + struct DD **ddp, *dd; + struct DF *df, *fh; + struct DM *dm, *mh; + int i, j, k, n; + int count = -1; + struct dics *diclist; + + /* ¤Þ¤º¿ô¤ò¿ô¤¨¤ë */ + if ((cx = RkGetContext(cx_num)) && (ddp = cx->ddpath)) { + count = 0; + for (i = 0; (dd = ddp[i]) != (struct DD *)0 ; i++) { + fh = &dd->dd_files; + for (df = fh->df_next; df != fh; df = df->df_next) { + mh = &df->df_members; + for (dm = mh->dm_next; dm != mh; dm = dm->dm_next) { + count++; + } + } + } + /* ¼­½ñ¥ê¥¹¥È¤ÎÇÛÎó¤ò (char *)malloc ¤¹¤ë */ + diclist = (struct dics *)malloc(count * sizeof(struct dics)); + if (diclist) { + struct dics *dicp = diclist, *prevdicp = (struct dics *)0; + + for (i = 0 ; (dd = ddp[i]) != (struct DD *)0 ; i++) { + fh = &dd->dd_files; + for (df = fh->df_next; df != fh; df = df->df_next) { + mh = &df->df_members; + for (dm = mh->dm_next; dm != mh; dm = dm->dm_next) { + dicp->nickname = dm->dm_nickname; + dicp->dicname = dm->dm_dicname; + dicp->dictype = df->df_type; + dicp++; + } + } + } + qsort(diclist, count, sizeof(struct dics), + (int (*)(const void *, const void *))diccmp); + + n = count; + for (i = j = 0, dicp = diclist ; i < n ; i++, dicp++) { + if (prevdicp && !strcmp(prevdicp->nickname, dicp->nickname)) { + /* prev ¤Èº£¤Î¼­½ñ¤È¤Ç nickname ¤¬°ìÃפ·¤Æ¤¤¤ë¾ì¹ç */ + count--; + } + else { + k = j + strlen(dicp->nickname) + 1; + if (k + 1 < maxmdname) { + if (mdname) { + (void)strcpy(mdname + j, dicp->nickname); + j = k; + } + } + prevdicp = dicp; + } + } + if (j + 1 < maxmdname && mdname) { + mdname[j++] = 0; + } + free(diclist); + } + else { + count = -1; /* ¤ä¤Ã¤Ñ¤êÀµ³Î¤Ê¿ô¤¬Ê¬¤«¤é¤Ê¤«¤Ã¤¿ */ + } + } + return(count); +} + +/* RkGetDirList: collects the names of directories */ +int +RkwGetDirList(int cx_num, char *ddname, int maxddname) +{ + struct RkContext *cx; + struct DD **ddp, *dd; + int p, i, j; + int count = -1; + + if ((cx = RkGetContext(cx_num)) && (ddp = cx->ddpath)) { + i = count = 0; + for (p = 0; (dd = ddp[p]) != (struct DD *)0 ; p++) { + j = i + strlen(dd->dd_name) + 1; + if (j + 1 < maxddname) { + if (ddname) + (void)strcpy(ddname + i, dd->dd_name); + i = j; + count++; + }; + }; + if (i + 1 < maxddname && ddname) + ddname[i++] = (char)0; + }; + return(count); +} + +/* RkDefineDic + * mount the dictionary onto the specified context. + */ +int +RkwDefineDic(int cx_num, char *name, WCHAR_T *word) +{ + struct RkContext *cx; + int i; + + if ((cx = RkGetContext(cx_num)) && word && name) { + char *prevname = (char *)0; + + if (cx->dmprev) + prevname = cx->dmprev->dm_nickname; + if (cx->qmprev) + prevname = cx->qmprev->dm_nickname; + + if (prevname && !STRCMP(prevname, name)) + return(DST_CTL(cx->dmprev, cx->qmprev, DST_DoDefine, word, + cx->gram->gramdic)); + else { + for (i = 0; i < 4; i++) { + struct MD *mh = cx->md[i]; + struct MD *md, *nd; + + for (md = mh->md_next; md != mh; md = nd) { + struct DM *dm = md->md_dic; + struct DM *qm = md->md_freq; + char *dname = (char *)0; + + if (dm) + dname = dm->dm_nickname; + if (qm) + dname = qm->dm_nickname; + + if (dname) { + if (!STRCMP(dname, name)) { + cx->dmprev = dm; + cx->qmprev = qm; + return(DST_CTL(dm, qm, DST_DoDefine, word, cx->gram->gramdic)); + } + } + nd = md->md_next; + } + } + } + } + return(-1); +} + + +/* RkDeleteDic + * mount the dictionary onto the specified context. + */ +int +RkwDeleteDic(int cx_num, char *name, WCHAR_T *word) +{ + struct RkContext *cx; + int i; + + if ((cx = RkGetContext(cx_num)) && name) { + char *prevname = (char *)0; + + if (cx->dmprev) + prevname = cx->dmprev->dm_nickname; + if (cx->qmprev) + prevname = cx->qmprev->dm_nickname; + + if (prevname && !STRCMP(prevname, name)) + return(DST_CTL(cx->dmprev, cx->qmprev, DST_DoDelete, word, + cx->gram->gramdic)); + else { + for (i = 0; i < 4; i++) { + struct MD *mh = cx->md[i]; + struct MD *md, *nd; + + for (md = mh->md_next; md != mh; md = nd) { + struct DM *dm = md->md_dic; + struct DM *qm = md->md_freq; + char *dname = (char *)0; + + if (dm) + dname = dm->dm_nickname; + if (qm) + dname = qm->dm_nickname; + + if (dname) { + if (!STRCMP(dname, name)) { + cx->dmprev = dm; + cx->qmprev = qm; + return(DST_CTL(dm, qm, DST_DoDelete, word, cx->gram->gramdic)); + } + } + nd = md->md_next; + } + } + } + } + return(-1); +} + +#ifdef STANDALONE /* The following code is as simulating the code in + lib/RKC API. In case STANDALONE, it becomes possible for libRK to be + linked with libcanna directly. */ + + +int +RkwSetAppName(int Context, char *name) +{ + return 0; +} + + +char * +RkwGetServerName(void) +{ + return (char *)NULL; +} + + +int +RkwGetProtocolVersion(int *majorp, int *minorp) +{ + *majorp = CANNA_MAJOR_MINOR / 1000; + *minorp = CANNA_MAJOR_MINOR % 1000; + return 0; +} + +int RkwGetServerVersion(int *, int *); + +int +RkwGetServerVersion(int *majorp, int *minorp) +{ + *majorp = CANNA_MAJOR_MINOR / 1000; + *minorp = CANNA_MAJOR_MINOR % 1000; + return 0; +} + +int +RkwSetUserInfo(char *user, char *group, char *topdir) +{ + return 1; +} + +#endif /* STANDALONE */ + diff --git a/src/add-ons/input_server/methods/canna/rk/dd.c b/src/add-ons/input_server/methods/canna/rk/dd.c new file mode 100644 index 0000000000..cb5251686a --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/dd.c @@ -0,0 +1,1522 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. +* +* Permission to use, copy, modify, distribute and sell this software +* and its documentation for any purpose is hereby granted without +* fee, provided that the above copyright notice appear in all copies +* and that both that copyright notice and this permission notice +* appear in supporting documentation, and that the name of NEC +* Corporation not be used in advertising or publicity pertaining to +* distribution of the software without specific, written prior +* permission. NEC Corporation makes no representations about the +* suitability of this software for any purpose. It is provided "as +* is" without express or implied warranty. +* +* NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN +* NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR +* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +* OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +* PERFORMANCE OF THIS SOFTWARE. +*/ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) + static char rcsid[]="$Id: dd.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif +/*LINTLIBRARY*/ + +#include "RKintern.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#define cx_gwt cx_extdata.ptr +#define STRCMP(d, s) strcmp((char *)(d), (char *)(s)) + +#define RK_READABLE 'r' +#define RK_WRITABLE 'w' + +static void _RkFreeDM(struct DM *dm); +static struct DM *_RkAllocDM(struct DF *df, unsigned char *dicname, unsigned char *nickname, int iclass); +static struct DF *_RkCreateDF(struct DD *dd, unsigned char *lnk, int type); +static void _RkFreeDF(struct DF *df); +static struct DF *_RkAllocDF(struct DD *dd, unsigned char *lnk, int type); +static int _RkParseDicsDir(char *line, char *lnk, char *member, char *nickname, int *dftype, int *dmclass, int *r_return, int *w_return); +static void _RkFreeDD(struct DD *dd); + +/* +* DM +*/ +inline +struct DM * +_RkCreateDM(struct DF *df, unsigned char *dicname, unsigned char *nickname, int iclass) +{ + struct DM *dm; + + dm = (struct DM *)calloc(1, sizeof(struct DM)); + if (dm) { + dm->dm_next = dm->dm_prev = dm; + dm->dm_file = df; + dm->dm_dicname = strdup((char *)dicname); + if (dm->dm_dicname) { + dm->dm_nickname = strdup((char *)nickname); + if (dm->dm_nickname) { + dm->dm_class = iclass; + dm->dm_flags = dm->dm_packbyte = dm->dm_rcount = 0; + dm->dm_gram = (struct RkGram *)0; + dm->dm_extdata.ptr = (pointer)0; + dm->dm_rut = (struct RUT *)0; + dm->dm_nv = (struct NV *)0; + return dm; + } + free(dm->dm_dicname); + } + free(dm); + } + return 0; +} + +static +void +_RkFreeDM(struct DM *dm) +{ +if (dm) { + dm->dm_next->dm_prev = dm->dm_prev; + dm->dm_prev->dm_next = dm->dm_next; + if (dm->dm_dicname) + free(dm->dm_dicname); + if (dm->dm_nickname) + free(dm->dm_nickname); + free(dm); +}; +} + +inline +struct DM * +_RkAllocDM(struct DF *df, unsigned char *dicname, unsigned char *nickname, int iclass) +{ + struct DM *m, *mh = &df->df_members; + + for (m = mh->dm_next; m != mh; m = m->dm_next) { + if (!STRCMP(m->dm_dicname, dicname)) { + return m; + } + } + m = _RkCreateDM(df, dicname, nickname, iclass); + if (m) { + m->dm_next = mh; + m->dm_prev = mh->dm_prev; + mh->dm_prev = m; + m->dm_prev->dm_next = m; + } + return(m); +} + +/* +* DF +*/ +inline +struct DF * +_RkCreateDF(struct DD *dd, unsigned char *lnk, int type) +{ + struct DF *df; + + df = (struct DF *)calloc(1, sizeof(struct DF)); + if (df) { + struct DM *dm = &df->df_members; + + df->df_next = df->df_prev = df; + df->df_direct = dd; + dm->dm_next = dm->dm_prev = dm; + + if (!(df->df_link = strdup((char *)lnk))) { + free(df); + return(0); + }; + df->df_rcount = 0; + df->df_type = type; + df->df_extdata.ptr = (pointer)0; + }; + return(df); +} + +static +void +_RkFreeDF(struct DF *df) +{ + struct DM *m, *n; + + if (df) { + struct DM *mh = &df->df_members; + + /* remove all members in this file */ + for (m = mh->dm_next; m != mh; m = n) { + n = m->dm_next; + _RkFreeDM(m); + }; + /* unlink from directory list */ + df->df_next->df_prev = df->df_prev; + df->df_prev->df_next = df->df_next; + if (df->df_link) + free(df->df_link); + free(df); + }; +} + +static +struct DF * +_RkAllocDF(struct DD *dd, unsigned char *lnk, int type) +{ + struct DF *f; + struct DF *fh = &dd->dd_files; + + for (f = fh->df_next; f != fh; f = f->df_next) { + if (!STRCMP(f->df_link, lnk)) { + return(f); + } + } + f = _RkCreateDF(dd, lnk, type); + if (f) { + f->df_next = fh; + f->df_prev = fh->df_prev; + fh->df_prev = f; + f->df_prev->df_next = f; + }; + return(f); +} + +int +_RkRealizeDF(struct DF *df) +{ + struct DD *dd = df->df_direct; + char *pathname; +#ifdef WIN + int oldmask; +#else + unsigned long oldmask; +#endif + int t; + + _RkRealizeDD(dd); + /* create path filename */ + pathname = _RkCreatePath(df->df_direct, df->df_link); + if (pathname) { + oldmask = umask(2); + /* create a file */ +#ifdef WIN +{ + HANDLE fd; + fd = CreateFile(pathname, GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (fd == INVALID_HANDLE_VALUE) { + t = -1; + }else{ + CloseHandle(fd); + t = 0; + } +} +#else + t = close(creat(pathname, CREAT_MODE)); +#endif + free(pathname); + (void)umask(oldmask); + if (t >= 0) { + return 0; + } + } + return -1; +} + +static int +_RkParseDicsDir(char *line, char *lnk, char *member, char *nickname, int *dftype, int *dmclass, int *r_return, int *w_return) /* ¥¢¥¯¥»¥¹¸¢¤òÊÖ¤¹½ê */ +{ + char *s, *d, *t, par, ch; + int count; + + *dftype = -1; + *dmclass = -1; + *r_return = *w_return = 0; /* ¸¢ÍøÌµ¤· */ + if (!isalpha(line[0])) + return -1; + + /* parse line %s.s(%s.%s) -%s--%c%c- */ + + for (s = line; *s && isspace(*s);) { + s++; + } + if (!*s) + return -1; + + /* link name */ + for (d = lnk, count = 0; *s && *s != '('; count++) { + if (count < RK_LINK_BMAX) { + *d++ = *s++; + } else { + return -1; + } + } + if (!count) + return -1; + if (count++ < RK_LINK_BMAX) { + *d = 0; + } + if (!*s++) + return -1; + if (count > RK_LINK_BMAX) + return -1; + if (!(t = (char *)strrchr(lnk, '.'))) + return -1; + if (!STRCMP(t, ".d") || !STRCMP(t, ".cbd")) + *dftype = DF_PERMDIC; + else if (!STRCMP(t, ".t") || !STRCMP(t, ".ctd")) + *dftype = DF_TEMPDIC; + else if (!STRCMP(t, ".fq") || !STRCMP(t, ".cld")) + *dftype = DF_FREQDIC; + else if (!STRCMP(t, ".ruc")) + *dftype = DF_RUCDIC; + else + return -1; + /* member name */ + for (d = member, count = 0; *s && *s != ')'; count++) { + if (count < RK_MEMBER_BMAX) { + *d++ = *s++; + } else { + return -1; + } + } + if (!count) + return -1; + if (count++ < RK_MEMBER_BMAX) + *d = 0; + if (!*s++) + return -1; + if (count > RK_MEMBER_BMAX) + return -1; + if (!(t = (char *)strrchr(member, '.'))) + return -1; + if (!STRCMP(t, ".mwd")) + *dmclass = ND_MWD; + else if (!STRCMP(t, ".swd")) + *dmclass = ND_SWD; + else if (!STRCMP(t, ".pre")) + *dmclass = ND_PRE; + else if (!STRCMP(t, ".suc")) + *dmclass = ND_SUC; + else + return -1; + /* nickname */ + for (; *s && isspace(*s);) { + s++; + } + if (!(par = *s++)) + return -1; + + for (d = nickname, count = 0; *s && *s != par; count++) { + if (count < RK_NICK_BMAX) { + *d++ = *s++; + } else { + return -1; + } + } + if (!count) + return -1; + if (count++ < RK_NICK_BMAX) + *d = 0; + if (!*s++) + return -1; + if (count > RK_NICK_BMAX) + return -1; + + *w_return = 1; /* ²¼°Ì¸ß´¹¤Î¤¿¤á¤³¤³¤Þ¤Ç¤·¤«¤Ê¤¤¾ì¹ç¤Ï writable ¤Ë¤¹¤ë */ + + while ((ch = *s) && ch != par) { + s++;/* 1 ¥Õ¥£¡¼¥ë¥ÉÆÉ¤ßÈô¤Ð¤· */ + } + + if (*s++ /* == par ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤ï¤± */) { + /* ¥¢¥¯¥»¥¹¸¢´ØÏ¢ */ + *w_return = 0; + while ((ch = *s) && ch != par) { + if (ch == RK_READABLE) { + *r_return = 1; + } +else if (ch == RK_WRITABLE) { + *w_return = 1; + } else { + return -1; +} + s++; + } + } + + return 0; +} + +/* +* DD - dictonary directory record +*/ +inline +struct DD * +_RkCreateDD(unsigned char *path, unsigned char *name) +{ + struct DD *dd; + + dd = (struct DD *)calloc(1, sizeof(struct DD)); + if (dd) { + dd->dd_next = dd->dd_prev = dd; + dd->dd_path = strdup((char *)path); + if (dd->dd_path) { + dd->dd_name = strdup((char *)name); + if (dd->dd_name) { + dd->dd_rcount = 0; + dd->dd_files.df_next = dd->dd_files.df_prev = &dd->dd_files; + dd->dd_flags = 0; + dd->dd_text.ddt_next = dd->dd_text.ddt_prev = &dd->dd_text; + return dd; + } + free(dd->dd_path); + } + free(dd); + } + return (struct DD *)0; +} + +static +void +_RkFreeDD(struct DD *dd) +{ + struct DF *f, *g; + struct DF *fh = &dd->dd_files; + struct DDT *ddLines; + struct DDT *p, *q; + + if (dd) { + for (f = fh->df_next; f != fh; f = g) { + g = f->df_next; + _RkFreeDF(f); + }; + dd->dd_next->dd_prev = dd->dd_prev; + dd->dd_prev->dd_next = dd->dd_next; + if (dd->dd_path) + free(dd->dd_path); + if (dd->dd_name) + free(dd->dd_name); + + ddLines = &dd->dd_text; + for (p = ddLines->ddt_next; p != ddLines; p = q) { + q = p->ddt_next; + p->ddt_next->ddt_prev = p->ddt_prev; + p->ddt_prev->ddt_next = p->ddt_next; + if (p->ddt_spec) + free(p->ddt_spec); + free(p); + }; + free(dd); + }; +} + +inline struct DD * +_RkLookupDD(struct DD *dd, unsigned char *name) +{ + struct DD *d; + + for (d = dd->dd_next; d != dd; d = d->dd_next) + if (!STRCMP(d->dd_name, name)) + return d; + return (struct DD *)0; +} + +/* _RkReadDD +* read a DD directory using dics.dir file. +*/ +inline struct DD * +_RkReadDD(char *name) +{ + char *dics_dir = "/dics.dir"; + struct DD *dd = (struct DD *)0; + struct DF *df; + struct DM *dm; + struct DDT *ddLines; + struct DDT *ddt; + struct RkParam *sx = RkGetSystem(); + int r, w; + int fdes; + FILE *fp; + +#ifndef USE_MALLOC_FOR_BIG_ARRAY + char direct[RK_PATH_BMAX]; + char file[RK_PATH_BMAX]; + char path[RK_PATH_BMAX]; + unsigned char line[RK_LINE_BMAX]; + unsigned char lnk[RK_LINK_BMAX+1]; + unsigned char member[RK_MEMBER_BMAX+1]; + unsigned char nickname[RK_NICK_BMAX+1]; +#else + char *direct, *file, *path; + unsigned char *line, *lnk, *member, *nickname; + direct = (char *)malloc(RK_PATH_BMAX); + file = (char *)malloc(RK_PATH_BMAX); + path = (char *)malloc(RK_PATH_BMAX); + line = (unsigned char *)malloc(RK_LINE_BMAX); + lnk = (unsigned char *)malloc(RK_LINK_BMAX + 1); + member = (unsigned char *)malloc(RK_MEMBER_BMAX + 1); + nickname = (unsigned char *)malloc(RK_NICK_BMAX + 1); + if (!direct || !file || !path || !line || !lnk || !member || !nickname) { + if (direct) free(direct); + if (file) free(file); + if (path) free(path); + if (line) free(line); + if (lnk) free(lnk); + if (member) free(member); + if (nickname) free(nickname); + return dd; + } +#endif + + /* create dd even if there is no directory or dics.dir file */ + sprintf(path, "%s/%s", sx->ddhome, name); + dd = _RkCreateDD((unsigned char *)path, (unsigned char *)name); + if (!dd) { + goto return_dd; + } + /* jisho table ga aruka ? */ + if (strlen(path) + strlen(dics_dir) + 1 >= RK_PATH_BMAX) { + dd = (struct DD *)0; + goto return_dd; + } + sprintf(direct, "%s%s", path, dics_dir); + + /* check for accessing right */ + if ((fdes = open(direct, 0)) < 0) { /* no file? */ + dd->dd_flags |= DD_WRITEOK; + } +else { + struct stat buf; + + if (fstat(fdes, &buf) == 0) { + if (buf.st_mode & 004) { /* if readable for others */ + dd->dd_flags |= DD_READOK; + } + } + close(fdes); + if (!close(open(direct, 2))) { + dd->dd_flags |= DD_WRITEOK; + } +} + + fp = fopen(direct, "r"); +if (!fp) { + goto return_dd; +} + ddLines = &dd->dd_text; + /* read dics_dir lines */ + while (fgets((char *)line, RK_LINE_BMAX, fp)) +{ + int dftype, dmclass; + + ddt = (struct DDT *)malloc(sizeof(struct DDT)); + if (!ddt) + continue; + + ddt->ddt_spec = (char *)malloc(strlen((char *)line) + 2); /* 2 for \n\0 */ + if (!ddt->ddt_spec) + { + free(ddt); + continue; + }; +{ + int len = strlen((char *)line); + if (line[len - 1] == '\n') { + line[len - 1] = '\0'; + } +} + strcpy(ddt->ddt_spec, (char *)line); + ddt->ddt_next = ddLines; + ddt->ddt_prev = ddLines->ddt_prev; + ddt->ddt_status = 1; + ddLines->ddt_prev = ddt; + ddt->ddt_prev->ddt_next = ddt; + + if (_RkParseDicsDir(ddt->ddt_spec, (char *)lnk, (char *)member, + (char *)nickname, &dftype, &dmclass, &r, &w) < 0) { + continue; + } + + if (strlen((char *)path) + strlen((char *)lnk) + 1 >= RK_PATH_BMAX) + continue; + sprintf(file, "%s/%s", path, (char *)lnk); + if (close(open(file, 0)) < 0) + continue; + df = _RkAllocDF(dd, lnk, dftype); + if (df) { + dm = _RkAllocDM(df, member, nickname, dmclass); + if (dm) { + dm->dm_line = ddt; + if (r) { + dm->dm_flags |= DM_READOK; + } + if (w) { + dm->dm_flags |= DM_WRITEOK; + } + ddt->ddt_status = 0; + }; + }; +}; + (void)fclose(fp); + +return_dd: +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(direct); + free(file); + free(path); + free(line); + free(lnk); + free(member); + free(nickname); +#endif + return dd; +} + +inline +struct DD * +_RkOpenDD(char *name) +{ + struct RkParam *sx = RkGetSystem(); + struct DD *dd; + struct DD *knownDD = &sx->dd; + + dd = _RkLookupDD(knownDD, (unsigned char *)name); + if (dd) + return dd; + dd = _RkReadDD(name); + /* link to the known list */ + if (dd) { + dd->dd_next = knownDD; + dd->dd_prev = knownDD->dd_prev; + knownDD->dd_prev = dd; + dd->dd_prev->dd_next = dd; + }; + return dd; +} + +char * +_RkCreatePath(struct DD *dd, char *name) +{ + unsigned sz; + char *ddname; + + if (!dd || !dd->dd_path || !name) + return (char *)0; + sz = strlen(dd->dd_path) + strlen(name) + 2; + ddname = (char *)malloc(sz); + if (ddname) { + sprintf(ddname, "%s/%s", dd->dd_path, name); + }; + return ddname; +} + +char * +_RkCreateUniquePath(struct DD *dd, char *proto) +{ + static char newLinkName[RK_LINK_BMAX]; + unsigned i; + + /* now checking ... */ + if (!dd || !dd->dd_path || !proto) + return (char *)0; + /* create directory */ + if (_RkRealizeDD(dd) < 0) + return (char *)0; + /* try at most 100 times */ + for (i = 1; i < 100; i++) { + int count; + struct DF *f; + struct DF *fh = &dd->dd_files; + unsigned long oldmask; + char *filename; + + count = 0; + sprintf(newLinkName, proto, i); + for (f = fh->df_next; f != fh; f = f->df_next) + if (!STRCMP(f->df_link, newLinkName)) + count++; + if (count) + continue; + filename = _RkCreatePath(dd, newLinkName); + if (filename) { + oldmask = umask(2); + + if (close(creat(filename, CREAT_MODE)) < 0) + count++; + free(filename); + (void)umask(oldmask); + if (!count) + return newLinkName; + }; + }; + return (char *)0; +} + +char * +_RkMakePath(struct DF *df) +{ + if (df) + return _RkCreatePath(df->df_direct, df->df_link); + else + return (char *)0; +} + +int +_RkRealizeDD(struct DD *dd) +{ + struct DDT *ddLines; + struct DDT *ddt; + int n; + int ret = -1; + int tmpres; + int fdes; + long tloc; + + char *whattime, *header, *dicsdir, *backup; + whattime = (char *)malloc(RK_LINE_BMAX); + header = (char *)malloc(RK_LINE_BMAX); + dicsdir = (char *)malloc(RK_PATH_BMAX); + backup = (char *)malloc(RK_PATH_BMAX); + if (!whattime || !header || !dicsdir || !backup) { + if (whattime) free(whattime); + if (header) free(header); + if (dicsdir) free(dicsdir); + if (backup) free(backup); + return ret; + } + /* create directory if needed */ + if (close(open(dd->dd_path, 0, 0664)) < 0) { + if (mkdir(dd->dd_path, MKDIR_MODE) < 0) { + goto return_ret; + } + /* change owner + if (pw) + chown(dd->dd_path, getuid(), pw->pw_gid); + */ + } + + /* dics.dir */ + sprintf(dicsdir, "%s/dics.dir", dd->dd_path); + backup[0] = 0; + tmpres = close(open(dicsdir, 0)); + if (tmpres >= 0) { + sprintf(backup, "%s/#dics.dir", dd->dd_path); + if (rename(dicsdir, backup)) { + goto return_ret; + } + }; + /* create dics.dir */ + + if ((fdes = creat(dicsdir, CREAT_MODE)) < 0) + { + if (backup[0]) { + rename(backup, dicsdir); + } + goto return_ret; + }; + /* header */ + tloc = time(0); + strcpy(whattime, ctime(&tloc)); + whattime[strlen(whattime)-1] = 0; + n = sprintf(header, "#CANNA dics.dir [%s] %s\n", whattime, dd->dd_name); + // n = strlen(header); + tmpres = write(fdes, header, n); + if (tmpres != n) { + if (backup[0]) { + rename(backup, dicsdir); + } + else + unlink(dicsdir); + close(fdes); + goto return_ret; + }; + /* fill up bodies */ + ddLines = &dd->dd_text; + for (ddt = ddLines->ddt_next; ddt != ddLines; ddt = ddt->ddt_next) + if (strncmp(ddt->ddt_spec, "#CANNA ", 7)) { + n = strlen(ddt->ddt_spec); + ddt->ddt_spec[n] = '\n'; + tmpres = write(fdes, ddt->ddt_spec, n + 1); + if (tmpres > 0) { + tmpres--; /* for \n */ + } + + + ddt->ddt_spec[n] = '\0'; + + if (tmpres != n) { + if (backup[0]) { + rename(backup, dicsdir); + } + else + unlink(dicsdir); + close(fdes); + goto return_ret; + }; + }; + close(fdes); + /* change owner + if (pw) + chown(dicsdir, getuid(), pw->pw_gid); + */ + ret = 0; + +return_ret: + free(whattime); + free(header); + free(dicsdir); + free(backup); + return ret; +} + +/* +* DDP +*/ +int +_RkIsInDDP(struct DD **ddp, struct DD *dd) +{ + while (*ddp) + if (*ddp++ == dd) + return 1; + return 0; +} + +static +int +_RkCountDDP( + struct DD **ddp) +{ + int count = 0; + + if (ddp) + while (ddp[count]) count++; + return count; +} + +struct DD ** +_RkCopyDDP( + struct DD **ddp) +{ + struct DD **newc = (struct DD **)0; + int i; + struct DD *dd; + + if (ddp) { + int count = _RkCountDDP(ddp); + + newc = (struct DD **)calloc(count + 1, (unsigned)sizeof(struct DD *)); + if (newc) + for (i = 0; (dd = newc[i] = ddp[i]) != (struct DD *)0 ; i++) + dd->dd_rcount++; + }; + return newc; +} + +inline +struct DD ** +_RkAppendDDP( + struct DD **ddp, + struct DD *dd) +{ + struct DD **newc; + int i; + int count = _RkCountDDP(ddp); + + newc = (struct DD **)calloc(count + 2, (unsigned)sizeof(struct DD *)); + if (newc) { + if (ddp) { + for (i = 0; i < count; i++) newc[i] = ddp[i]; + free(ddp); + }; + newc[count++] = dd; + newc[count] = (struct DD *)0; + dd->dd_rcount++; + } else + newc = ddp; + return newc; +} + +struct DD ** +_RkCreateDDP( + char *ddpath) +{ + char *d, *s; + struct DD *dd; + struct DD **ddp = (struct DD **)0; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + char dir[RK_PATH_BMAX + 1]; +#else + char *dir = (char *)malloc(RK_PATH_BMAX + 1); + if (!dir) { + return ddp; + } +#endif + + for (s = ddpath; *s; ) { + int count; + + for (;*s && isspace(*s);) { + s++; + } + if (!*s) + break; + for (d = dir, count = 0; *s; count++) + if (*s == ':') { + s++; + break; + } else { + if (count < RK_PATH_BMAX) + *d++ = *s; + s++; + }; + *d = 0; + dd = _RkOpenDD(dir); + if (dd) + ddp = _RkAppendDDP(ddp, dd); + }; +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(dir); +#endif + return ddp; +} + +void +_RkFreeDDP( + struct DD **ddp) +{ + struct DD *dd; + int i; + + if (ddp) { + for (i = 0; (dd = ddp[i]) != (struct DD *)0 ; i++) + if (--dd->dd_rcount == 0) { + _RkFreeDD(dd); + }; + free(ddp); + }; +} + +/* _RkSearchDDP/Q +* search dictionary file by nickname +*/ +struct DM * +_RkSearchDDP( + struct DD **ddp, + char *name) +{ + struct DD *dd; + struct DF *f, *fh; + struct DM *m, *mh; + int i; + + if (ddp) { + for (i = 0; (dd = ddp[i]) != (struct DD *)0 ; i++) { + fh = &dd->dd_files; + for (f = fh->df_next; f && (f != fh); f = f->df_next) { + if (f->df_type == DF_FREQDIC) { + /* Ʊ¤¸¥Ç¥£¥ì¥¯¥È¥ê³¬ÁØ¤Ç¤Ï .fq ¤«¤éõ¤¹ */ + mh = &f->df_members; + for (m = mh->dm_next; m != mh; m = m->dm_next) { + if (!STRCMP(m->dm_nickname, name)) { + return m; + } + } + } + } + fh = &dd->dd_files; + for (f = fh->df_next; f && (f != fh); f = f->df_next) { + if (f->df_type != DF_RUCDIC && f->df_type != DF_FREQDIC) { + mh = &f->df_members; + for (m = mh->dm_next ; m != mh; m = m->dm_next) { + if (!STRCMP(m->dm_nickname, name)) { + return m; + } + } + } + } + } + } + return (struct DM *)0; +} + +/* _RkSearchDDQ +¤¢¤ë¥¿¥¤¥×¤Î¼­½ñ¤À¤±Ãµ¤·¤ÆÊÖ¤¹ +*/ + +struct DM * +_RkSearchDDQ( + struct DD **ddp, + char *name, + int type) +{ + struct DD *dd; + struct DF *f, *fh; + struct DM *m, *mh; + int i; + + if (ddp) { + for (i = 0; (dd = ddp[i]) != (struct DD *)0 ; i++) { + fh = &dd->dd_files; + for (f = fh->df_next; f && (f != fh); f = f->df_next) + if (f->df_type == (unsigned)type) { + mh = &f->df_members; + for (m = mh->dm_next; m != mh; m = m->dm_next) { + if (!STRCMP(m->dm_nickname, name)) + return(m); + }; + }; + }; + }; + return((struct DM *)0); +} + +/* +_RkSearchUDDP() + ºÇ½é¤Ë¸«ÉÕ¤«¤ë¤Î¤¬¥·¥¹¥Æ¥à¼­½ñ¤Ë¤¢¤ë¤ä¤Ä¤«¤É¤¦¤«¤òȽÃǤ·¤Ê¤¬¤éÊÖ¤¹ +*/ + +struct DM * +_RkSearchUDDP( + struct DD **ddp, + unsigned char *name) +{ + struct DM *dm = _RkSearchDDP(ddp, (char *)name); + + if (dm && STRCMP(dm->dm_file->df_direct->dd_name, SYSTEM_DDHOME_NAME)) { + return dm; + } + return((struct DM *)0); +} + +/* ¼­½ñ¥á¥ó¥Ð̾¤Ç¼­½ñ¤òõ¤¹ + +³Ø½¬¥Õ¥¡¥¤¥ë¤Ï½ü³°¤·¤ÆÃµ¤¹ +*/ + +struct DM * +_RkSearchDDMEM( + struct DD **ddp, + char *name) +{ + struct DD *dd; + struct DF *f, *fh; + struct DM *m, *mh; + int i; + + if (ddp) { + for (i = 0; (dd = ddp[i]) != (struct DD *)0 ; i++) { + fh = &dd->dd_files; + for (f = fh->df_next; f && (f != fh); f = f->df_next) { + if (f->df_type != DF_FREQDIC && f->df_type != DF_RUCDIC) { + mh = &f->df_members; + for (m = mh->dm_next; m != mh; m = m->dm_next) { + if (!STRCMP(m->dm_dicname, name)) { + return m; + } + } + } + } + } + } + return (struct DM *)0; +} + +/* +_RkSearchDicWithFreq -- ¼­½ñ(³Ø½¬¼­½ñ¤ò´Þ¤à)¤òõ¤·ÊÖ¤¹¡£ + +ddpath ¤ÎÀèÆ¬¤«¤é½ç¤Ë³Ø½¬¥Õ¥¡¥¤¥ë¤¢¤ë¤¤¤Ï¼­½ñ¤ò¤µ¤¬¤·¡¢¤ß¤Ä¤«¤Ã¤¿¤Î +¤òÊÖ¤¹¡£³Ø½¬¥Õ¥¡¥¤¥ë¤¬¤ß¤Ä¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï³Ø½¬¥Õ¥¡¥¤¥ë¤Î¸µ¼­½ñ¤òõ¤·¤Æ +¤½¤ì¤ò dm ¤ËÊÖ¤·¡¢³Ø½¬¥Õ¥¡¥¤¥ë¼«¿È¤Ï qmp ¤ÎÀè¤Ë³ÊǼ¤·¤ÆÊÖ¤¹¡£ + +*/ + +struct DM * +_RkSearchDicWithFreq( + struct DD **ddpath, + char *name, + struct DM **qmp) +{ + struct DD *udd[2]; + struct DM *dm, *qm; + + udd[1] = (struct DD *)0; + + *qmp = (struct DM *)0; + while (*ddpath) { + udd[0] = *ddpath; + qm = _RkSearchDDQ(udd, name, DF_FREQDIC); + if (qm) { + *qmp = qm; + return _RkSearchDDMEM(ddpath, qm->dm_dicname); + } + dm = _RkSearchDDP(udd, name); + if (dm) { + return dm; + } + ddpath++; + } + return (struct DM *)0; +} + +/* DMcheck + +DMcreate ¤Ç name ¤òÂ裳°ú¿ô¤ËÉÕ¤±¤Æ¤¤¤¿»þ¤Î¥Á¥§¥Ã¥¯¤òÆÈΩ¤µ¤»¤¿¡£ + +return value; +1: OK +0: bad +*/ + +int +DMcheck(char *spec, char *name) +{ + int dftype, dmclass; + int r, w, ret; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + char lnk[RK_LINK_BMAX+1]; + char member[RK_MEMBER_BMAX+1]; + char nickname[RK_NICK_BMAX+1]; +#else + char *lnk, *member, *nickname; + lnk = (char *)malloc(RK_LINK_BMAX + 1); + member = (char *)malloc(RK_MEMBER_BMAX + 1); + nickname = (char *)malloc(RK_NICK_BMAX + 1); + if (!lnk || !member || !nickname) { + if (lnk) free(lnk); + if (member) free(member); + if (nickname) free(nickname); + return 0; + } +#endif + + if (_RkParseDicsDir(spec, lnk, member, nickname, &dftype, &dmclass, + &r, &w) < 0 || + STRCMP(nickname, name)) { + ret = 0; + } +else { + ret = 1; +} +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(lnk); + free(member); + free(nickname); +#endif + return ret; +} + +/* DMcreate +* create a newc member under dd +* DMcreate does not create an actual dictionary file. +*/ +struct DM * +DMcreate( + struct DD *dd, + char *spec) +{ + int dftype, dmclass; + struct DF *df; + struct DM *dm = (struct DM *)0; + struct DDT *ddt; + struct DDT *ddLines = &dd->dd_text; + int r, w; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + char lnk[RK_LINK_BMAX+1]; + char member[RK_MEMBER_BMAX+1]; + char nickname[RK_NICK_BMAX+1]; +#else + char *lnk, *member, *nickname; + lnk = (char *)malloc(RK_LINK_BMAX + 1); + member = (char *)malloc(RK_MEMBER_BMAX + 1); + nickname = (char *)malloc(RK_NICK_BMAX + 1); + if (!lnk || !member || !nickname) { + if (lnk) free(lnk); + if (member) free(member); + if (nickname) free(nickname); + return dm; + } +#endif + + if (_RkParseDicsDir(spec, lnk, member, nickname, &dftype, &dmclass, + &r, &w) >= 0) { + int len = strlen(spec); + if (spec[len - 1] == '\n') { + spec[len - 1] = '\0'; + } + + ddt = (struct DDT *)malloc(sizeof(struct DDT)); + if (ddt) { + ddt->ddt_spec = (char *)malloc(strlen(spec) + 3); /* 3 for \r\n\0 */ + if (ddt->ddt_spec) { + strcpy(ddt->ddt_spec, spec); + df = _RkAllocDF(dd, (unsigned char *)lnk, dftype); + if (df) { + dm = _RkAllocDM(df, (unsigned char *)member, + (unsigned char *)nickname, dmclass); + if (dm) { + ddt->ddt_next = ddLines; + ddt->ddt_prev = ddLines->ddt_prev; + ddLines->ddt_prev = ddt; + ddt->ddt_prev->ddt_next = ddt; + ddt->ddt_status = 0; + dm->dm_line = ddt; + dm->dm_flags |= DM_WRITEOK; /* default access right */ + goto return_dm; + } + _RkFreeDF(df); + } + free(ddt->ddt_spec); + } + free(ddt); + } + } +return_dm: +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(lnk); + free(member); + free(nickname); +#endif + return(dm); +} + +int +DMremove( + struct DM *dm) +{ + struct DF *df = dm->dm_file; + struct DDT *ddt = dm->dm_line; + + + /* free up dirs.dic line */ + if (ddt) { + ddt->ddt_next->ddt_prev = ddt->ddt_prev; + ddt->ddt_prev->ddt_next = ddt->ddt_next; + if (ddt->ddt_spec) + free(ddt->ddt_spec); + free(ddt); + }; + /* free dm itself */ + _RkFreeDM(dm); + if (df) { + struct DM *mh = &df->df_members; + + if (mh == mh->dm_next) + _RkFreeDF(df); + }; + return 0; +} + +int +DMrename( + struct DM *dm, + unsigned char *nickname) +{ + struct DF *df = dm->dm_file; + struct DDT *ddt = dm->dm_line; + char *new_spec; + char *new_nick; + char member[5]; + char *dicname = (char *)0; + int ret = -1; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + char spec[RK_LINE_BMAX]; +#else + char *spec = (char *)malloc(RK_LINE_BMAX); + if (!spec) { + return ret; + } +#endif + + if (!df || !df->df_link || !dm->dm_file || !ddt || !ddt->ddt_spec) + goto return_ret; + if (df->df_type == DF_FREQDIC) { + dicname = dm->dm_dicname; + } + switch (dm->dm_class) { + default: + case ND_MWD: + (void)strcpy(member, ".mwd"); + break; + case ND_SWD: + (void)strcpy(member, ".swd"); + break; + case ND_PRE: + (void)strcpy(member, ".pre"); + break; + case ND_SUC: + (void)strcpy(member, ".suc"); + break; + }; + (void)sprintf(spec, "%s(%s) -%s--%s%s-", df->df_link, + dicname ? dicname : member, nickname, + (dm->dm_flags & DM_READOK) ? "r" : "", + (dm->dm_flags & DM_WRITEOK) ? "w" : ""); + new_spec = (char *)malloc(strlen(spec) + 3); /* 3 for \r\n\0 */ + if (!new_spec) { + goto return_ret; + } + strcpy(new_spec, spec); + if (!(new_nick = strdup((char *)nickname))) { + free(new_spec); + goto return_ret; + }; + free(ddt->ddt_spec); + ddt->ddt_spec = new_spec; + free(dm->dm_nickname); + dm->dm_nickname = new_nick; + ret = 0; + +return_ret: +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(spec); +#endif + return ret; +} + +int +DMchmod(struct DM *dm, int mode) +{ + struct DF *df = dm->dm_file; + struct DDT *ddt = dm->dm_line; + char *new_spec; + unsigned newflags = dm->dm_flags; + int ret = -1; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + char spec[RK_LINE_BMAX]; +#else + char *spec = (char *)malloc(RK_LINE_BMAX); + if (!spec) { + return ret; + } +#endif + + if (!df || !df->df_link || !ddt || !ddt->ddt_spec) + goto return_ret; + + /* READ ¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ÎÁàºî */ + if ((mode & (RK_ENABLE_READ | RK_DISABLE_READ)) == RK_ENABLE_READ) { + newflags |= DM_READOK; + } +else if ((mode & (RK_ENABLE_READ | RK_DISABLE_READ)) == RK_DISABLE_READ) { + newflags &= ~DM_READOK; +} + + /* WRITE ¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ÎÁàºî */ + if ((mode & (RK_ENABLE_WRITE | RK_DISABLE_WRITE)) == RK_ENABLE_WRITE) { + newflags |= DM_WRITEOK; + } +else if ((mode & (RK_ENABLE_WRITE | RK_DISABLE_WRITE)) == RK_DISABLE_WRITE) { + newflags &= ~DM_WRITEOK; +} + + if (newflags != dm->dm_flags) { + if (df->df_direct->dd_flags & DD_WRITEOK) { + dm->dm_flags = newflags; + (void)sprintf(spec, "%s(%s) -%s--%s%s-", + df->df_link, dm->dm_dicname, dm->dm_nickname, + (dm->dm_flags & DM_READOK) ? "r" : "", + (dm->dm_flags & DM_WRITEOK) ? "w" : ""); + new_spec = (char *)malloc(strlen(spec) + 3); /* 3 for \r\n\0 */ + if (!new_spec) { + ret = NOTALC; + goto return_ret; + } + strcpy(new_spec, spec); + free(ddt->ddt_spec); + ddt->ddt_spec = new_spec; + } + } + ret = (((dm->dm_flags & DM_WRITEOK) ? RK_ENABLE_WRITE : RK_DISABLE_WRITE) | + ((dm->dm_flags & DM_READOK) ? RK_ENABLE_READ : RK_DISABLE_READ)); + +return_ret: +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(spec); +#endif + return ret; +} + +int +DDchmod(struct DD *dd, int mode) +{ + char *dicsdir; + unsigned newflags = dd->dd_flags; + + /* READ ¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ÎÁàºî */ + if ((mode & (RK_ENABLE_READ | RK_DISABLE_READ)) == RK_ENABLE_READ) { + newflags |= DD_READOK; + } +else if ((mode & (RK_ENABLE_READ | RK_DISABLE_READ)) == RK_DISABLE_READ) { + newflags &= ~DD_READOK; +} + + /* WRITE ¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ÎÁàºî */ + if ((mode & (RK_ENABLE_WRITE | RK_DISABLE_WRITE)) == RK_ENABLE_WRITE) { + newflags |= DD_WRITEOK; + } +else if ((mode & (RK_ENABLE_WRITE | RK_DISABLE_WRITE)) == RK_DISABLE_WRITE) { + newflags &= ~DD_WRITEOK; +} + + if (newflags != dd->dd_flags) { + dicsdir = (char *)malloc(strlen(dd->dd_path + strlen("/dics.dir") + 1)); + if (dicsdir) { + int filemode; + + sprintf(dicsdir, "%s/dics.dir", dd->dd_path); + + filemode = ((newflags & DD_WRITEOK) ? 0640 : 0440) + | ((newflags & DD_READOK) ? 04 : 0); + + if (chmod(dicsdir, filemode) == 0) { + dd->dd_flags = newflags; + } + free(dicsdir); + } + } + newflags = dd->dd_flags; + return (((newflags & DD_WRITEOK) ? RK_ENABLE_WRITE : RK_DISABLE_WRITE) | + ((newflags & DD_READOK) ? RK_ENABLE_READ : RK_DISABLE_READ)); +} + +int +_RkMountMD( + struct RkContext *cx, + struct DM *dm, + struct DM *qm, + int mode, + int firsttime) +{ + struct MD *md, *head; + struct DF *df; + struct DD *dd; + char *file; + int status; + + if (!dm || !(md = (struct MD *)calloc(1, sizeof(struct MD)))) + return -1; + /* increment the reference counter */ + if (dm->dm_rcount == 0) { + df = dm->dm_file; + dd = df->df_direct; + if (!(file = _RkCreatePath(dd, df->df_link))) { + free(md); + return -1; + }; + status = DST_OPEN(dm, file, DM_WRITABLE, cx->gram->gramdic); + free(file); + if (status) { + free(md); + return -1; + }; + }; + if (qm && qm->dm_rcount == 0) { + df = qm->dm_file; + dd = df->df_direct; + if (!(file = _RkCreatePath(dd, df->df_link))) { + free(md); + return -1; + }; + status = FQopen(dm, qm, file, DM_WRITABLE); + free(file); + if (status) { + free(md); + return -1; + }; + }; + /* use the dic as the default grammatical dic if it contains */ + if (firsttime && DM2TYPE(dm) == DF_PERMDIC && dm->dm_gram) { + cx->gram = dm->dm_gram; + cx->gram->refcount++; + } + /* increment the reference counter */ + dm->dm_rcount++; + if (qm) { + qm->dm_rcount++; + if (!cx->nv && qm->dm_nv) + cx->nv = qm->dm_nv; + } + /* put it at the end of the mount list */ + head = cx->md[dm->dm_class]; + md->md_next = head; + md->md_prev = head->md_prev; + head->md_prev = md; + md->md_prev->md_next = md; + md->md_dic = dm; + md->md_freq = qm; + md->md_flags = mode&MD_WRITE; + /* wait for the translation to finish */ + if (IS_XFERCTX(cx)) + md->md_flags |= MD_MPEND; + return 0; +} + +void +_RkUmountMD( + struct RkContext *cx, + struct MD *md) +{ + struct DM *dm = md->md_dic; + struct DM *qm = md->md_freq; + struct DF *df; + struct DD *dd; + char *file; + + cx->dmprev = (struct DM *)0; + cx->qmprev = (struct DM *)0; + if (IS_XFERCTX(cx)) + md->md_flags |= MD_UPEND; + else { + md->md_prev->md_next = md->md_next; + md->md_next->md_prev = md->md_prev; + free(md); + if (qm) { + df = qm->dm_file; + dd = df->df_direct; + if (cx->nv == qm->dm_nv) + cx->nv = (struct NV *)0; + if (qm->dm_rcount > 0 && --qm->dm_rcount == 0) { + file = _RkCreatePath(dd, df->df_link); + if (file) { + FQclose(cx, dm, qm, file); + if (!df->df_rcount) { + if (dd->dd_rcount > 0 && --dd->dd_rcount == 0) + _RkFreeDD(dd); + }; + free(file); + }; + }; + }; + if (dm->dm_rcount > 0 && --dm->dm_rcount == 0) { + df = dm->dm_file; + dd = df->df_direct; + file = _RkCreatePath(dd, df->df_link); + if (file) { + (void)DST_CLOSE(dm, file, cx->gram->gramdic); + if (df->df_rcount == 0) { + if (dd->dd_rcount > 0 && --dd->dd_rcount == 0) + _RkFreeDD(dd); + }; + free(file); + }; + }; + }; +} diff --git a/src/add-ons/input_server/methods/canna/rk/dic.c b/src/add-ons/input_server/methods/canna/rk/dic.c new file mode 100644 index 0000000000..15fe52ab42 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/dic.c @@ -0,0 +1,1056 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="@(#) 102.1 $Id: dic.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif +/*LINTLIBRARY*/ + +#include "RKintern.h" + +#include /* for sprintf */ +#include +#include +#include + +#define dm_td dm_extdata.ptr +#define cx_gwt cx_extdata.ptr +#define Is_Gwt_CTX(cx) + +#define ND2RK(s) ((0x80 >> (int)(s)) & 0xff) +#define STRCMP(d, s) strcmp((char *)(d), (char *)(s)) + +#define FREQ_TEMPLATE "frq%d.cld" +#define USER_TEMPLATE "usr%d.ctd" +#define PERM_TEMPLATE "bin%d.cbd" + +#define DEFAULT_PERMISSION "w" + +static int locatepath(struct DD *userDDP[], struct DD *ddpath[], int mode); +static struct td_n_tupple *pushTdn(struct RkContext *cx, struct TD *tdp); + +/* locatepath -- ¼­½ñ¥µ¡¼¥Á¥Ñ¥¹¤ò mode ¤Ë±þ¤¸¤ÆÄ¥¤ë + + return value: + 0: À®¸ù + ACCES: ¥¨¥é¡¼(¥°¥ë¡¼¥×¤ò»ØÄꤷ¤¿¤Î¤Ë DDPATH ¤Ë¸ºß¤·¤Ê¤¤) + */ + +static int +locatepath(struct DD *userDDP[], struct DD *ddpath[], int mode) +{ + /* find dictionary under system and user/group directory */ + if (mode & RK_SYS_DIC) { + if (ddpath[2]) { + userDDP[0] = ddpath[2]; + } + else { + return ACCES; + } + } else + if (mode & RK_GRP_DIC) { + if (ddpath[1] && ddpath[2]) { + /* ¥°¥ë¡¼¥×¼­½ñ¤È¥·¥¹¥Æ¥à¼­½ñ¤¬¤Á¤ã¤ó¤È¤¢¤ì¤Ð */ + userDDP[0] = ddpath[1]; + } + else { + return ACCES; + } + } + else { /* ¥æ¡¼¥¶¼­½ñ */ + userDDP[0] = ddpath[0]; + } + userDDP[1] = (struct DD*)0; + return 0; +} + + +/* int + * RkwCreateDic(cx_num, dicname, mode) + * + * °ú¤­¿ô + * int cx_num ¥³¥ó¥Æ¥¯¥¹¥È¥Ê¥ó¥Ð¡¼ + * unsigned char *dicname ¼­½ñ¤Ø¤Î¥Ý¥¤¥ó¥¿ + * int mode ¼­½ñ¤Î¼ïÎà¤È¶¯À©¥â¡¼¥É¤ÎOR + * ¼­½ñ¤Î¼ïÎà + * #define Rk_MWD 0x80 + * #define Rk_SWD 0x40 + * #define Rk_PRE 0x20 + * #define Rk_SUC 0x10 + * ¶¯À©¥â¡¼¥É + * #define KYOUSEI 0x01 + * ¶¯À©¤·¤Ê¤¤¾ì¹ç 0x00 +#define PL_DIC (0x0100) +#define PL_ALLOW (PL_DIC << 1) +#define PL_INHIBIT (PL_DIC << 2) +#define PL_FORCE (PL_DIC << 3) + * + * ¥ê¥¿¡¼¥óÃÍ + * À®¸ù¤·¤¿¾ì¹ç 0 + * À®¸ù¤·¤¿¾ì¹ç(¾å½ñ¤­¤·¤¿¾ì¹ç) 1 + * ¥¢¥í¥±¡¼¥·¥ç¥ó¤Ë¼ºÇÔ¤·¤¿¾ì¹ç -6 NOTALC + * ¼­½ñ¤¬¥Ð¥¤¥Ê¥ê¼­½ñ¤Ç¤¢¤Ã¤¿¾ì¹ç -9 BADF + * dics.dir¤Ë°Û¾ï¤¬¤¢¤Ã¤¿¾ì¹ç -10 BADDR + * GetDicFilenameÊÖ¤êÃͤ¬-1¤Î¾ì¹ç -13 ACCES + * MakeDicFile¤Ë¼ºÇÔ¤·¤¿¾ì¹ç -13 ACCES + * CreatDic¤Ë¼ºÇÔ¤·¤¿¾ì¹ç -13 ACCES + * ¼­½ñ¤¬¥Þ¥¦¥ó¥ÈÃæ¤Ç¤¢¤Ã¤¿¾ì¹ç -16 MOUNT + * ¼­½ñ¤¬¤¹¤Ç¤Ë¤¢¤ë¾ì¹ç(¶¯À©¤Ç¤Ê¤¤¾ì¹ç) -17 EXIST + * ¼­½ñ¤¬»ÈÍÑÃæ¤Ç¤¢¤Ã¤¿¾ì¹ç -26 TXTBSY + * mode¤¬°Û¾ïÃͤǤ¢¤Ã¤¿¾ì¹ç -99 BADARG + * ¥³¥ó¥Æ¥¯¥¹¥È¹½Â¤ÂΤ¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -100 BADCONT + */ + +int +RkwCreateDic(int cx_num, char *dicname, int mode) +{ + struct RkParam *sx = RkGetSystem(); + + struct RkContext *cx = RkGetContext(cx_num); + struct DM *sm, *um, *tm; + int type; + struct DD *userDDP[2], *systemDDP[2]; + char *filename, extent[5]; + int ret; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + char spec[RK_LINE_BMAX]; +#else + char *spec = (char *)malloc(RK_LINE_BMAX); + if (!spec) { + return NOTALC; + } +#endif + + if(!dicname || !dicname[0]) { + ret = ACCES; + goto return_ret; + } + if (strlen(dicname) >= (unsigned)RK_NICK_BMAX) { + ret = INVAL; + goto return_ret; + } + if ( !cx || !cx->ddpath || !cx->ddpath[0] ) { + ret = BADCONT; + goto return_ret; + } + if ( !sx || !sx->ddpath || !sx->ddpath[0] ) { + ret = BADCONT; + goto return_ret; + } +#ifndef STANDALONE /* Is it true ? */ + if ( cx->ddpath[0] == sx->ddpath[0] ) { + ret = BADCONT; + goto return_ret; + } +#endif + + if (locatepath(userDDP, cx->ddpath, mode) < 0) { + ret = ACCES; + goto return_ret; + } + if (!(userDDP[0]->dd_flags & DD_WRITEOK)) { + ret = ACCES; + goto return_ret; + } + + systemDDP[0] = sx->ddpath[0]; + systemDDP[1] = (struct DD *)0; + + type = (mode & PL_DIC) ? DF_FREQDIC : DF_TEMPDIC; +/* find dictionary in current mount list */ + sm = _RkSearchDDQ(systemDDP, dicname, type); + um = _RkSearchDDQ(userDDP, dicname, type); + + if (um && !(mode & KYOUSEI)) { + ret = EXIST; + goto return_ret; + } + + if (mode & PL_DIC) { + if (!sm) { + if(_RkSearchDDQ(systemDDP, dicname, DF_TEMPDIC)) { + ret = BADF; + goto return_ret; + } + ret = NOENT; + goto return_ret; + } + if (!um) { + struct DM *dm; + + if (!(filename = _RkCreateUniquePath(userDDP[0], FREQ_TEMPLATE))) { + ret = ACCES; + goto return_ret; + } + (void)sprintf(spec, "%s(%s) -%s--%s-\n", + filename, sm->dm_dicname, sm->dm_nickname, + DEFAULT_PERMISSION); + if (!DMcheck(spec, dicname)) { + ret = NOENT; + goto return_ret; + } + if (!(dm = DMcreate(userDDP[0], spec))) { + ret = NOTALC; + goto return_ret; + } + if (copyFile(sm, dm)) { + ret = ACCES; + goto return_ret; + }else{ + ret = 0; + goto return_ret; + } + } else { + if (!(ND2RK(um->dm_class) & mode)) { + ret = INVAL; + goto return_ret; + } + if ( um->dm_rcount > 0 ) { + ret = TXTBSY; + goto return_ret; + } + if ( !um->dm_file ) { + ret = BADCONT; /* INVAL SHOULD BE REPLACED... MAKO 1225 */ + goto return_ret; + } + + if(_RkRealizeDF(um->dm_file)) {/* ¤³¤ì¤¤¤é¤Ê¤¤¤ó¤¸¤ã¤Ê¤¤¡© kon 1993.11 */ + ret = ACCES; + goto return_ret; + } + if ( copyFile(sm, um) ) { + ret = ACCES; + goto return_ret; + }else{ + ret = 1; + goto return_ret; + } + } + } else { + /* um = _RkSearchDDQ(userDDP, dicname, DF_TEMPDIC);*/ + tm = _RkSearchDDP(userDDP, dicname); + if (tm != um) { + ret = BADF; + goto return_ret; + } + if (!um) { + if (!(filename = _RkCreateUniquePath(userDDP[0], USER_TEMPLATE))) { + ret = ACCES; + goto return_ret; + } + if (mode & Rk_MWD) { + (void)strcpy(extent, "mwd"); + } else if (mode & Rk_SWD) { + (void)strcpy(extent, "swd"); + } else if (mode & Rk_PRE) { + (void)strcpy(extent, "pre"); + } else if (mode & Rk_SUC) { + (void)strcpy(extent, "suc"); + } else { + /* return INVAL; */ + (void)strcpy(extent, "mwd"); + }; + (void)sprintf(spec, "%s(.%s) -%s--%s-\n", filename, extent, dicname, + DEFAULT_PERMISSION); + if (!DMcheck(spec, dicname)) { + ret = NOENT; + goto return_ret; + } + if (!DMcreate(userDDP[0], spec)) { + ret = NOTALC; + goto return_ret; + } + _RkRealizeDD(userDDP[0]); + ret = 0; + goto return_ret; + } else { + if ( um->dm_rcount > 0 ) { + ret = TXTBSY; + goto return_ret; + } + if ( !um->dm_file ) { + ret = BADCONT; /* INVAL SHOULD BE REPLACED... MAKO 1225 */ + goto return_ret; + } + sprintf(spec, "%s(%s) -%s--%s%s-\n", + um->dm_file->df_link, um->dm_dicname, um->dm_nickname, + (um->dm_flags & DM_READOK) ? "r" : "", + (um->dm_flags & DM_WRITEOK) ? "w" : ""); + if(_RkRealizeDF(um->dm_file)) { + ret = ACCES; + goto return_ret; + } + ret = 1; /* backward compatiblity ... 1224 Xmas */ + } + } + return_ret: +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(spec); +#endif + return ret; +} + +copyFile(struct DM *src, struct DM *dst) +{ + struct DF *srcF = src->dm_file; + struct DD *srcD = srcF->df_direct; + struct DF *dstF = dst->dm_file; + struct DD *dstD = dstF->df_direct; + char *srcN, *dstN; +#ifndef WIN + int srcFd, dstFd; + int n; +#else + HANDLE srcFd, dstFd; + DWORD n, nextn; +#endif + int ecount = 0; + + srcN = _RkCreatePath(srcD, srcF->df_link); + if (srcN) { +#ifdef WIN + srcFd = CreateFile(srcN, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +#else + srcFd = open(srcN, 0); +#endif + free(srcN); + if +#ifdef WIN + (srcFd != INVALID_HANDLE_VALUE) +#else + (srcFd >= 0) +#endif + { + dstN = _RkCreatePath(dstD, dstF->df_link); + if (dstN) { +#ifdef WIN + dstFd = CreateFile(dstN, GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); +#else + dstFd = creat(dstN, 0666); +#endif + free(dstN); + + if +#ifdef WIN + (dstFd != INVALID_HANDLE_VALUE) +#else + (dstFd >= 0) +#endif + { + char b[RK_BUFFER_SIZE]; + /* I will leave this array on the stack because it may be a rare + case to use this function. 1996.6.5 kon */ + + _RkRealizeDD(dstD); + + while +#ifdef WIN + (ReadFile(srcFd, b, RK_BUFFER_SIZE, &n, NULL) && n > 0) +#else + ((n = read(srcFd, b, RK_BUFFER_SIZE)) > 0) +#endif + { /* do copy */ + if +#ifdef WIN + (!WriteFile(dstFd, b, n, &nextn, NULL) || nextn != n) +#else + ( write(dstFd, b, n) != n ) +#endif + { + ecount++; + break; + } + } + if ( +#ifdef WIN + !CloseHandle(dstFd) +#else + close(dstFd) < 0 +#endif + || n < 0) + { + ecount++; + } + } + } +#ifdef WIN + CloseHandle(srcFd); +#else + close(srcFd); +#endif + } + } + return ecount ? -1 : 0; +} + +/* + * RkwListDic(cx_num, dirname, buf, size) + * int cx_num; ¥³¥ó¥Æ¥¯¥¹¥È¥Ê¥ó¥Ð¡¼ + * unsigned char *dirname; ¼­½ñ¥ê¥¹¥È¤ò½ÐÎϤ·¤¿¤¤¥Ç¥£¥ì¥¯¥È¥ê̾ + * unsigned char *buf; ¼­½ñ¥ê¥¹¥È¤¬Ê֤äƤ¯¤ë¥Ð¥Ã¥Õ¥¡ + * int size; ¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º + * + * ¥ê¥¿¡¼¥óÃÍ + * À®¸ù¤·¤¿¾ì¹ç ¼­½ñ¤Î¿ô + * ¥³¥ó¥Æ¥¯¥¹¥È¥Ê¥ó¥Ð¡¼¤¬Éé¤Î¾ì¹ç BADCONT + * RkwCreateContext¤Ë¼ºÇÔ¤·¤¿¾ì¹ç BADCONT + * RkwSetDicPath¤Ë¼ºÇÔ¤·¤¿¾ì¹ç NOTALC + */ +int +RkwListDic(int cx_num, char *dirname, char *buf, int size) +{ + int dicscnt; + int new_cx_num; + + if(!dirname || !strlen(dirname)) + return 0; + if (cx_num < 0) + return BADCONT; + if((new_cx_num = RkwCreateContext()) < 0) + return BADCONT; + if (RkwSetDicPath(new_cx_num, dirname) == -1) { + RkwCloseContext(new_cx_num); + return NOTALC; + } + dicscnt = RkwGetDicList(new_cx_num, buf, size); + (void)RkwCloseContext(new_cx_num); + return (dicscnt); +} + +/* int + * RkwRemoveDic(cx_num, dicname, mode) + * + * »ØÄꤵ¤ì¤¿¥³¥ó¥Æ¥¯¥¹¥È¤Ë»ØÄꤵ¤ì¤¿¼­½ñ¤¬Â¸ºß¤¹¤ì¤Ð + * ¤½¤Î¼­½ñ¤òºï½ü¤¹¤ë¡£ + * + * °ú¤­¿ô + * int cx_num ¥³¥ó¥Æ¥¯¥¹¥È¥Ê¥ó¥Ð¡¼ + * unsigned char *dicname ¼­½ñ̾ + * + * ¥ê¥¿¡¼¥óÃÍ + * À®¸ù¤·¤¿¾ì¹ç 0 + * ¼­½ñ¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -2 NOENT + * ¼­½ñ¤¬¥Ð¥¤¥Ê¥ê¼­½ñ¤Ç¤¢¤Ã¤¿¾ì¹ç -9 BADF + * RemoveDic¤ÎÊÖ¤êÃͤ¬-1¤Î¾ì¹ç -13 ACCES + * ¥Þ¥¦¥ó¥È¤·¤Æ¤¤¤¿¾ì¹ç -26 TXTBSY + * ¥³¥ó¥Æ¥¯¥¹¥È¹½Â¤ÂΤ¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -100 BADCONT + */ +int +RkwRemoveDic(int cx_num, char *dicname, int mode) +{ + struct RkContext *cx = RkGetContext(cx_num); +/* struct RkParam *sx = RkGetSystem(); */ + struct DD *userDDP[2], *dum_direct; + struct DM *dm; + char *path; + int res; + + if(!dicname) + return NOENT; + if ( !cx || !cx->ddpath || !cx->ddpath[0] ) + return BADCONT; + + if (locatepath(userDDP, cx->ddpath, mode) < 0) { + return ACCES; + } + + /* find dictionary in current mount list */ + dm = _RkSearchDDP(userDDP, (char *)dicname); + if (!dm || ((mode & PL_DIC) && dm->dm_file->df_type != DF_FREQDIC)) { + return NOENT; + } + if ( dm->dm_rcount > 0 ) + return TXTBSY; + if ( !dm->dm_file ) /* ? */ + return BADCONT; + if (!(dm->dm_file->df_direct->dd_flags & DD_WRITEOK) || + (!(dm->dm_flags & DM_WRITEOK) && !(mode & KYOUSEI))) { + return ACCES; + } + if (!(path = _RkMakePath(dm->dm_file))) + return NOTALC; + res = unlink(path); + free(path); + if(res) + return ACCES; + dum_direct = dm->dm_file->df_direct; + DMremove(dm); + (void)_RkRealizeDD(dum_direct); + return 0; +} + +/* int + * RkwRenameDic(cx_num, oldnick, newnick, mode) + * + * »ØÄꤵ¤ì¤¿¥³¥ó¥Æ¥¯¥¹¥È¤Ë»ØÄꤵ¤ì¤¿¼­½ñ¤¬Â¸ºß¤¹¤ì¤Ð + * ¤½¤Î¼­½ñ¤Î̾Á°¤òÊѹ¹¤¹¤ë¡£ + * + * °ú¤­¿ô + * int cx_num ¥³¥ó¥Æ¥¯¥¹¥È¥Ê¥ó¥Ð¡¼ + * unsigned char *oldnick Êѹ¹¸µ¼­½ñ̾ + * unsigned char *newnick Êѹ¹Àè¼­½ñ̾ + * int mode ¶¯À©¥â¡¼¥É + * + * ÊÖ¤êÃÍ (RKdic.h»²¾È) + * À®¸ù¤·¤¿¾ì¹ç 0 + * oldnick¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -2 NOENT + * RemoveDic¤ÎÊÖ¤êÃͤ¬-1¤Î¾ì¹ç -2 NOENT + * ¼­½ñ¤¬¥Ð¥¤¥Ê¥ê¼­½ñ¤Ç¤¢¤Ã¤¿¾ì¹ç -9 BADF + * RenameDicFile¤ÎÊÖ¤êÃͤ¬-1¤Î¾ì¹ç -13 ACCES + * newnick¤¬Â¸ºß¤¹¤ë¾ì¹ç -17 EXIST + * oldnick¤ò¥Þ¥¦¥ó¥È¤·¤Æ¤¤¤¿¾ì¹ç -26 TXTBSY + * newnick¤ò¥Þ¥¦¥ó¥È¤·¤Æ¤¤¤¿¾ì¹ç -26 TXTBSY + * ¥³¥ó¥Æ¥¯¥¹¥È¹½Â¤ÂΤ¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -100 BADCONT + */ +int +RkwRenameDic(int cx_num, char *old, char *newc, int mode) +{ + struct RkContext *cx = RkGetContext(cx_num); + struct DD *userDDP[2], *dd; + struct DM *dm1, *dm2; + char *path; + char spec[RK_LINE_BMAX]; + /* I leave this array on the stack because this will not glow so big. + 1996.6.5 kon */ + + if(!old || !*old) + return NOENT; + if(!newc || !*newc) + return ACCES; + if (!cx || !cx->ddpath || !cx->ddpath[0]) + return BADCONT; + if (strlen((char *)newc) >= (unsigned)RK_NICK_BMAX) { + return INVAL; + } + + if (locatepath(userDDP, cx->ddpath, mode) < 0) { + return ACCES; + } + + dm1 = _RkSearchDDP(userDDP, (char *)old); + if (!dm1) { + return NOENT; + } + + dd = dm1->dm_file->df_direct; + if (!(dd->dd_flags & DD_WRITEOK)) { + return ACCES; + } + + dm2 = _RkSearchDDP(userDDP, (char *)newc); + + if (dm1->dm_rcount > 0) + return TXTBSY; + if (dm2) { /* ¿·¤·¤¤Ì¾Á°¤¬¡¢´û¤Ë¼­½ñ¤È¤·¤ÆÂ¸ºß¤¹¤ì¤Ð */ + if (dm2->dm_rcount > 0) + return TXTBSY; + if (!(mode & KYOUSEI)) + return EXIST; + if (!(path = _RkMakePath(dm2->dm_file))) + return NOTALC; + (void)unlink(path); + free(path); + DMremove(dm2); + DMrename(dm1, (unsigned char *)newc); + (void)_RkRealizeDD(dd); + return 1; + } else { + (void)sprintf(spec, "%s(.%s) -%s--%s%s-\n", "tmp.ctd", "mwd", newc, + (dm1->dm_flags & DM_READOK) ? "r" : "", + (dm1->dm_flags & DM_WRITEOK) ? "w" : ""); + if (!DMcheck(spec, newc)) + return NOENT; /* ¤Ê¤ó¤Ê¤ó¤À¤«Îɤ¯Ê¬¤«¤é¤Ê¤¤ (1993.11 º£) */ + /* ¤¿¤á¤·¤Ë¤ä¤Ã¤Æ¤ß¤Æ¤¤¤ë¤Î¤«¤Ê¡© (1993.11 º£) */ + DMrename(dm1, (unsigned char *)newc); + (void)_RkRealizeDD(dd); + return 0; + } +} + +/* int + * RkwCopyDic(cx, dir, from, to, mode) + * + * ¼­½ñ¤ò¥³¥Ô¡¼¤¹¤ë¡£ + * + * °ú¤­¿ô + * int cx ¥³¥ó¥Æ¥¯¥¹¥È¥Ê¥ó¥Ð¡¼ + * char *dir ¥Ç¥£¥ì¥¯¥È¥ê̾ + * char *from ¥³¥Ô¡¼¸µ¼­½ñ̾ + * char *to ¥³¥Ô¡¼Àè¼­½ñ̾ + * int mode ¥â¡¼¥É + * + * ÊÖ¤êÃÍ (RKdic.h»²¾È) + * À®¸ù¤·¤¿¾ì¹ç 0 + * oldnick¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -2 NOENT + * RemoveDic¤ÎÊÖ¤êÃͤ¬-1¤Î¾ì¹ç -2 NOENT + * ¥Ç¥£¥ì¥¯¥È¥ê¤Î»ØÄ꤬¤ª¤«¤·¤¤¾ì¹ç -9 BADF + * RenameDicFile¤ÎÊÖ¤êÃͤ¬-1¤Î¾ì¹ç -13 ACCES + * ¥á¥â¥ê¤¬Â­¤ê¤Ê¤«¤Ã¤¿¾ì¹ç NOTALC + * ¼­½ñ̾¤¬Ä¹¤¹¤®¤ë¾ì¹ç INVAL + * newnick¤¬Â¸ºß¤¹¤ë¾ì¹ç -17 EXIST + * oldnick¤ò¥Þ¥¦¥ó¥È¤·¤Æ¤¤¤¿¾ì¹ç -26 TXTBSY + * newnick¤ò¥Þ¥¦¥ó¥È¤·¤Æ¤¤¤¿¾ì¹ç -26 TXTBSY + * ¥³¥ó¥Æ¥¯¥¹¥È¹½Â¤ÂΤ¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -100 BADCONT + */ + +int +RkwCopyDic(int co, char *dir, char *from, char *to, int mode) +{ + struct RkContext *cx; + struct DD *userDDP[2]; + struct DM *dm1, *dm2; + char *path, *perm = DEFAULT_PERMISSION; + char *myddname; + int res, v, con; + + if (!dir || !*dir) { + return BADF; + } + if (!from || !*from) + return NOENT; + if (!to || !*to) + return ACCES; + if (strlen((char *)to) >= (unsigned)RK_NICK_BMAX) { + return INVAL; + } + + res = BADCONT; + con = RkwCreateContext(); + + cx = RkGetContext(co); + if (!cx || !cx->ddpath || !cx->ddpath[0]) { + if (con >= 0) + RkwCloseContext(con); + return BADCONT; + } + + if (con >= 0) { + int n = 2; /* for system dic */ + switch (mode & (RK_GRP_DIC | RK_SYS_DIC)) { + case RK_GRP_DIC: + n = 1; /* for group dic */ + case RK_SYS_DIC: + if (!cx->ddpath[2]) { + return BADCONT; + } + myddname = cx->ddpath[n]->dd_name; + break; + default: + myddname = cx->ddpath[0]->dd_name; + break; + } + + res = NOTALC; + path = (char *)malloc(strlen(dir) + 1 + strlen(myddname) + 1); + if (path) { + sprintf(path, "%s:%s", dir, myddname); + + res = NOTALC; + v = RkwSetDicPath(con, path); + free(path); + if (v >= 0) { + struct RkContext *cy = RkGetContext(con); + + res = ACCES; + if (cy->ddpath[1]->dd_flags & DD_WRITEOK) { + userDDP[0] = cy->ddpath[0]; + userDDP[1] = (struct DD *)0; + + res = NOENT; + dm1 = _RkSearchDDP(userDDP, from); + if (dm1) { + int type = dm1->dm_file->df_type; + + res = BADF; + if (type != DF_RUCDIC) { + userDDP[0] = cy->ddpath[1]; + userDDP[1] = (struct DD *)0; + + dm2 = _RkSearchDDP(userDDP, to); + if (dm2) { /* to ¤¬¤¢¤Ã¤Æ¡¢¶¯À©¥â¡¼¥É¤Ê¤é¾Ã¤¹ */ + if (dm2->dm_rcount > 0) { + res = TXTBSY; + goto newdicUsed; + } + if (!(mode & KYOUSEI)) { + res = EXIST; + goto newdicUsed; + } + if (!(path = _RkMakePath(dm2->dm_file))) { + res = NOTALC; + goto newdicUsed; + } + (void)unlink(path); + free(path); + switch (dm2->dm_flags & (DM_READOK | DM_WRITEOK)) { + case (DM_READOK | DM_WRITEOK): + perm = "rw"; + break; + case DM_READOK: + perm = "r"; + break; + case DM_WRITEOK: + perm = "w"; + break; + default: + perm = ""; + break; + } + DMremove(dm2); + } + + { /* ¤¤¤è¤¤¤è¼­½ñ¤òºî¤ë */ + char *ptemplate, *filename; + + RkwSync(co, from); /* sometimes, this failes to an error */ + ptemplate = + (type == DF_FREQDIC) ? FREQ_TEMPLATE : + (type == DF_TEMPDIC) ? USER_TEMPLATE : + PERM_TEMPLATE; + + res = ACCES; + filename = _RkCreateUniquePath(userDDP[0], ptemplate); + if (filename) { + char spec[RK_LINE_BMAX]; + /* I leave this array on the stack because this will not glow so big. + 1996.6.5 kon */ + + (void)sprintf(spec, "%s(%s) -%s--%s-\n", + filename, dm1->dm_dicname, to, perm); + res = NOTALC; + dm2 = DMcreate(userDDP[0], spec); + if (dm2) { + res = ACCES; + if (copyFile(dm1, dm2) == 0) { + (void)_RkRealizeDD(userDDP[0]); + res = 0; + } + else { + DMremove(dm2); + } + } + } + } + } + } + newdicUsed:; + } + } + } + RkwCloseContext(con); + } + return res; +} + +/* int + * RkwChmodDic(cx_num, dicname, mode) + * + * ¼­½ñ¤Î¥â¡¼¥É¤òÊѹ¹¤¹¤ë¡£ + * + * °ú¤­¿ô + * int cx_num ¥³¥ó¥Æ¥¯¥¹¥È + * char dicname ¼­½ñ̾ + * int mode ¥â¡¼¥É + * + * ÊÖ¤êÃÍ (RKdic.h»²¾È) + * À®¸ù¤·¤¿¾ì¹ç 0 + * dicname¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -2 NOENT + * DMchmod ¤ÎÊÖ¤êÃͤ¬-1¤Î¾ì¹ç -13 ACCES + * ¥³¥ó¥Æ¥¯¥¹¥È¹½Â¤ÂΤ¬Â¸ºß¤·¤Ê¤¤¾ì¹ç -100 BADCONT + */ +int +RkwChmodDic(int cx_num, char *dicname, int mode) +{ + struct RkContext *cx = RkGetContext(cx_num); + struct DD *dd, *userDDP[2]; + struct DM *dm; + int res; + unsigned dirmode; + + res = BADCONT; + if (cx && cx->ddpath && cx->ddpath[0]) { + dirmode = mode & RK_DIRECTORY; + if (dirmode != 0) { /* ¥Ç¥£¥ì¥¯¥È¥ê */ + switch (dirmode) { + case RK_SYS_DIR: + dd = (struct DD *)0; /* or SX.ddpath[0] */ + break; + case RK_GRP_DIR: + if (cx->ddpath[1] && cx->ddpath[2]) { + dd = cx->ddpath[1]; + } + break; + default: /* RK_USR_DIR */ + dd = cx->ddpath[0]; + break; + } + res = dd ? DDchmod(dd, mode) : ACCES; + } + else { /* ¥Õ¥¡¥¤¥ë */ + res = ACCES; + if (locatepath(userDDP, cx->ddpath, mode) == 0) { + res = NOENT; + if(dicname && *dicname) { + dm = _RkSearchDDP(userDDP, dicname); + res = NOENT; + if (dm) { + struct DD *dd = dm->dm_file->df_direct; + + res = DMchmod(dm, mode); + if (res >= 0) { + (void)_RkRealizeDD(dd); + } + else { + res = ACCES; + } + } + } + } + } + } + return res; +} + +/* + * GetLine(cx, gram, tdp, line) + * struct RkContext *cx + * struct RkKxGram *gram + * struct TD *tdp + * WCHAR_T *line + * + * ÊÖ¤êÃÍ À®¸ù 0 + * ¼ºÇÔ -1 + */ +static struct td_n_tupple * +pushTdn(struct RkContext *cx, struct TD *tdp) +{ + struct td_n_tupple *newtd; + struct _rec *gwt; + if (!cx || !(gwt = (struct _rec *)cx->cx_gwt) || + !(newtd = (struct td_n_tupple *)malloc(sizeof(struct td_n_tupple)))) { + return (struct td_n_tupple *)0; + } + newtd->td = (char *)tdp; + newtd->n = 0; + newtd->next = (struct td_n_tupple *)gwt->tdn; + gwt->tdn = (struct td_n_tupple *)newtd; + return newtd; +} + +void +freeTdn(struct RkContext *cx) +{ + struct td_n_tupple *work; + struct _rec *gwt = (struct _rec *)cx->cx_gwt; + if (gwt) { + while((work = gwt->tdn) != (struct td_n_tupple *)0) { + gwt->tdn = work->next; + free(work); + }; + }; +} + +inline void +popTdn(struct RkContext *cx) +{ + struct td_n_tupple *work; + struct _rec *gwt = (struct _rec *)cx->cx_gwt; + work = gwt->tdn; + if (work) { + gwt->tdn = work->next; + free(work); + } +} + +inline +GetLine(struct RkContext *cx, struct RkKxGram *gram, struct TD *tdp, WCHAR_T *line, int size) +{ + struct TD *vtd; + struct TN *vtn; + struct _rec *gwt = (struct _rec *)cx->cx_gwt; + + if (tdp) { + if (gwt->tdn) + freeTdn(cx); + if(!pushTdn(cx, tdp)) + return NOTALC; + } + while (gwt->tdn && gwt->tdn->n >= (int)((struct TD *)gwt->tdn->td)->td_n) + popTdn(cx); + if (gwt->tdn == (struct td_n_tupple *)0) + return -1; + vtd = (struct TD *)gwt->tdn->td; + vtn = vtd->td_node + gwt->tdn->n; + while ( !IsWordNode(vtn) ) { + gwt->tdn->n++; + if(!pushTdn(cx, vtn->tn_tree)) + return NOTALC; + vtd = (struct TD *)gwt->tdn->td; + vtn = vtd->td_node; + } + if (RkUparseWrec(gram, vtn->tn_word->word, line, size, vtn->tn_word->lucks)) { + gwt->tdn->n++; + return 0; + } else + return -1; +} + +/* + * RkwGetWordTextDic(cx_num, dirname, dicname, info, infolen) + * + * int cx_num ¥³¥ó¥Æ¥¯¥¹¥ÈNO + * unsigned char *dirname ¥Ç¥£¥ì¥¯¥È¥ê̾ + * unsigned char *dicname ¼­½ñ̾ + * unsigned char *info ¥Ð¥Ã¥Õ¥¡ + * int infolen ¥Ð¥Ã¥Õ¥¡¤ÎŤµ + * + * ÊÖ¤êÃÍ : ¼ÂºÝ¤Ëinfo¤ËÆþ¤Ã¤¿Ä¹¤µ + * ºÇ¸å¤Þ¤ÇÆÉ¤ó¤Ç¤¤¤¿¤é £°¤òÊÖ¤¹ + * RkwCreateContext¤Ë¼ºÇÔ¤·¤¿ BADCONT + * RkwDuplicateContext¤Ë¼ºÇÔ¤·¤¿ BADCONT + * RkGetContext¤Ë¼ºÇÔ¤·¤¿ BADCONT + * RkwSetDicPath¤Ë¼ºÇÔ¤·¤¿ NOTALC + * RkwMountDic¤Ë¼ºÇÔ¤·¤¿ NOENT + * SearchUDDP¤Ë¼ºÇÔ¤·¤¿ NOENT + * ¥Ð¥¤¥Ê¥ê¼­½ñ¤À¤Ã¤¿ -9 BADF + * dics.dir¤Ë°Û¾ï¤¬¤¢¤Ã¤¿¾ì¹ç -10 BADDR + */ +int +RkwGetWordTextDic(int cx_num, unsigned char *dirname, unsigned char *dicname, WCHAR_T *info, int infolen) +{ + struct RkContext *new_cx, *cx; + struct DM *dm; + int new_cx_num; + struct TD *initial_td; + unsigned size; + unsigned char *buff = 0; + struct _rec *gwt; + + if (!dicname || !dirname || !info || !(cx = RkGetContext(cx_num)) || + !(gwt = (struct _rec *)cx->cx_gwt)) + return BADCONT; + + if(dicname[0] != '\0') { + size = strlen((char *)dicname) + 1; + if (!(buff = (unsigned char *)malloc(size))) + return (NOTALC); + (void)strcpy((char *)buff, (char *)dicname); + + if(dirname[0] != '\0') { + if((new_cx_num = RkwCreateContext()) < 0) { + free(buff); + return BADCONT; + } + if(RkwSetDicPath(new_cx_num, (char *)dirname) < 0) { + RkwCloseContext(new_cx_num); + free(buff); + return NOTALC; + } + } else { + if ((new_cx_num = RkwDuplicateContext(cx_num)) < 0) { + free(buff); + return BADCONT; + } + } + if (!(cx = RkGetContext(cx_num)) || !(gwt = (struct _rec *)cx->cx_gwt)) { + RkwCloseContext(new_cx_num); + free(buff); + return BADCONT; + } + + if (!(new_cx = RkGetContext(new_cx_num))) { + if(dirname[0] != '\0') { + RkwCloseContext(new_cx_num); + free(buff); + return BADCONT; + } + } + if (gwt->gwt_cx >= 0) { + RkwCloseContext(gwt->gwt_cx); + gwt->gwt_cx = -1; + } + + if(!STRCMP(dirname, SYSTEM_DDHOME_NAME)) { + if (!(dm = _RkSearchDDP(new_cx->ddpath, (char *)dicname))) { + if (dirname[0] != '\0') { + RkwCloseContext(new_cx_num); + } + free(buff); + return NOENT; + } + } else { + if (!(dm = _RkSearchUDDP(new_cx->ddpath, dicname))) { + if(dirname[0] != '\0') { + RkwCloseContext(new_cx_num); + } + free(buff); + return NOENT; + } + } + if (DM2TYPE(dm) != DF_TEMPDIC ) { + if(dirname[0] != '\0') { + RkwCloseContext(new_cx_num); + } + free(buff); + return BADF; + } + if(RkwMountDic(new_cx_num, (char *)dicname,0) == -1) { + RkwCloseContext(new_cx_num); + free(buff); + return NOMOUNT; + } + + if (!_RkSearchDDP(new_cx->ddpath, (char *)dicname)) { + RkwCloseContext(new_cx_num); + free(buff); + return BADDR; + } + gwt->gwt_cx = new_cx_num; + if (gwt->gwt_dicname) + free(gwt->gwt_dicname); + gwt->gwt_dicname = buff; + initial_td = (struct TD *)dm->dm_td; + } + else { + if ((new_cx_num = gwt->gwt_cx) < 0 + || !(new_cx = RkGetContext(new_cx_num))) { + if (gwt->gwt_dicname) + free(gwt->gwt_dicname); + gwt->gwt_dicname = (unsigned char *)0; + return BADCONT; + } + initial_td = (struct TD *)0; + } + if (GetLine(new_cx, cx->gram->gramdic, (struct TD *)initial_td, + info, infolen) < 0) { + RkwUnmountDic(new_cx_num, (char *)gwt->gwt_dicname); + RkwCloseContext(new_cx_num); + gwt->gwt_cx = -1; + return 0; + } + infolen = uslen((WCHAR_T *)info); + return infolen; +} diff --git a/src/add-ons/input_server/methods/canna/rk/dicsw.c b/src/add-ons/input_server/methods/canna/rk/dicsw.c new file mode 100644 index 0000000000..dea4fc6137 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/dicsw.c @@ -0,0 +1,33 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="$Id: dicsw.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif +/*LINTLIBRARY*/ + +#include "RKintern.h" + +struct RkDST _RkDST[] = { +/* PERMDIC */ { _Rkpopen, _Rkpclose, _Rkpsearch, _Rkpio, _Rkpctl, _Rkpsync, }, +/* TEMPDIC */ { _Rktopen, _Rktclose, _Rktsearch, _Rktio, _Rktctl, _Rktsync, }, +}; diff --git a/src/add-ons/input_server/methods/canna/rk/fq.c b/src/add-ons/input_server/methods/canna/rk/fq.c new file mode 100644 index 0000000000..9726ac6c49 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/fq.c @@ -0,0 +1,843 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="$Id: fq.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif + +#include "RKintern.h" + +#include +#include +#include + +#ifdef WIN +#include +#include +#include +#endif + +#define dm_xdm dm_extdata.ptr + + +static int WrToRut(struct RUT *ruc, unsigned long csn, unsigned long tick); +static unsigned long UpdateFrst(struct RUT *ruc); +static struct WRT *allocWRT(unsigned long size); +static int writeNV(int fd, struct NV *nv); +static void freeRUT(struct RUT *ruc); +static int SaveRUC(int fr, struct RUT *ruc); + +struct xqm { + off_t ex_boff; + long ex_bsiz; +}; + +struct RUT * +allocRUT(unsigned long hn) +{ + struct RUT *tempo; + + if (!(tempo = (struct RUT *)calloc(1, sizeof(struct RUT)))) + return((struct RUT *) 0); + if (!(tempo->dp = (struct CTdata **)calloc((size_t) hn, sizeof(struct CTdata *)))){ + free(tempo); + return((struct RUT *) 0); + } + return tempo; +} + +inline int +WrToRut(struct RUT *ruc, unsigned long csn, unsigned long tick) +{ + unsigned long whn; + struct CTdata *wd, **pwd; + + whn = HashFunc(csn); + for (pwd = ruc->dp+whn, wd = *pwd ; wd; pwd = &wd->next, wd = *pwd) { + if (wd->ct[0] == csn) { + WriteCT(csn, tick, wd->ct); + return 0; + } + } + if (!(wd = (struct CTdata *)calloc(1, sizeof(struct CTdata)))) + return -1; + *pwd = wd; + WriteCT(csn, tick, wd->ct); + return 1; +} + +static +unsigned long +UpdateFrst(struct RUT *ruc) +{ + unsigned long wmin, wtick, frst, lc; + struct CTdata *wd; + + wmin = 0xffffffffL; + frst = 0xfffffL; + + for (lc = 0; lc < HN; lc++) { + for (wd = *(ruc->dp+lc) ; wd; wd = wd->next) { + if (wmin > (wtick = wd->ct[1])) { + frst = wd->ct[0]; + wmin = wtick; + } + } + } + if(frst == (unsigned long) 0xffffffff) + return (unsigned long) 0L; + return frst; +} + +inline int +deleteCT(struct RUT *ruc, unsigned long csn) +{ + unsigned long whn; + struct CTdata *wd, **pre; + + whn = HashFunc(csn); + + for (pre = ruc->dp+whn, wd = *pre; ; pre = &wd->next, wd = *pre){ + if (!wd) + return 0; + if (wd->ct[0] == csn) + break; + } + *pre = wd->next; + free(wd); + return 1; +} + +unsigned long +searchRut(struct RUT *ruc, unsigned long csn) +{ + unsigned long whn; + struct CTdata *wd; + + whn = HashFunc(csn); + for (wd = *(ruc->dp+whn) ; wd; wd = wd->next) { + if (wd->ct[0] == csn) + return wd->ct[1]; + } + return (unsigned long) 0L; +} + +inline +struct CTdata * +searchCTadd(struct RUT *ruc, unsigned long csn) +{ + unsigned long whn; + struct CTdata *wd; + + whn = HashFunc(csn); + for (wd = *(ruc->dp+whn) ; wd; wd = wd->next) { + if (wd->ct[0] == csn) + return wd; + } + return (struct CTdata *) 0; +} + +int +entryRut(struct RUT *ruc, unsigned long csn, unsigned long tick) +{ + struct CTdata *wpadd; + int retval; + + retval = 1; + if (ruc->cs < ruc->sz) + switch (WrToRut(ruc, csn, tick)) { + case 0: + break; + case 1: + if (++(ruc->cs) == ruc->sz) + ruc->frst = UpdateFrst(ruc); + break; + case -1: + return (int) 0; + } + else { + wpadd = searchCTadd(ruc, csn); + if (wpadd) { + WriteCT(csn, tick, wpadd->ct); + if (csn == ruc->frst) + ruc->frst = UpdateFrst(ruc); + } + else { + if (deleteCT(ruc, ruc->frst)){ + if (WrToRut(ruc, csn, tick) < 0){ + ruc->cs -= 1L; + retval = 0; + } + } + else + retval = 0; + ruc->frst = UpdateFrst(ruc); + } + } + return retval; +} + +static +struct WRT * +allocWRT(unsigned long size) +{ + struct WRT *tempo; + + if (!(tempo = (struct WRT *)calloc(1, sizeof(struct WRT)))) + return((struct WRT *) 0); + if (!(tempo->buf = (unsigned char *)calloc(1, (int) 5*size))){ + free(tempo); + return((struct WRT *) 0); + } + tempo->sz = size; + return tempo; +} + +inline +struct WRT * +readWRT(int fr) +{ + unsigned long wsz, wcs, wfrst, wtm; + unsigned char ll[4]; + struct WRT *wrt; +#ifdef WIN + DWORD dummy; +#endif + +#ifndef WIN + if (read(fr, (char *)ll, 4) != 4) + return (struct WRT *) 0; + wsz = (unsigned long) bst4_to_l(ll); + if (read(fr, (char *)ll, 4) != 4) + return (struct WRT *) 0; + wcs = (unsigned long) bst4_to_l(ll); + if (read(fr, (char *)ll, 4) != 4) + return (struct WRT *) 0; + wfrst = (unsigned long) bst4_to_l(ll); + if (read(fr, (char *)ll, 4) != 4) + return (struct WRT *) 0; + wtm = (unsigned long) bst4_to_l(ll); + if (!(wrt = allocWRT(wsz))) + return (struct WRT *) 0; +#else + if (!ReadFile(fr, (char *)ll, 4, &dummy, NULL) || dummy != 4) + return (struct WRT *) 0; + wsz = (unsigned long) bst4_to_l(ll); + if (!ReadFile(fr, (char *)ll, 4, &dummy, NULL) || dummy != 4) + return (struct WRT *) 0; + wcs = (unsigned long) bst4_to_l(ll); + if (!ReadFile(fr, (char *)ll, 4, &dummy, NULL) || dummy != 4) + return (struct WRT *) 0; + wfrst = (unsigned long) bst4_to_l(ll); + if (!ReadFile(fr, (char *)ll, 4, &dummy, NULL) || dummy != 4) + return (struct WRT *) 0; + wtm = (unsigned long) bst4_to_l(ll); + if (!(wrt = allocWRT(wsz))) + return (struct WRT *) 0; +#endif + + wrt->cs = wcs; + wrt->frst = wfrst; + wrt->tm = wtm; + if (wsz) { + if +#ifndef WIN + (read(fr, wrt->buf, (unsigned) 5*wsz) != 5*(int)wsz) +#else + (!ReadFile(fr, wrt->buf, (unsigned) 5*wsz, &dummy, NULL) || + dummy != (unsigned)5*(int)wsz) +#endif + { + freeWRT(wrt); + return (struct WRT *) 0; + } + } + return wrt; +} + +inline int +writeToWRT(int fr, struct WRT *wrt) +{ + unsigned char ll[4]; + +#ifndef WIN + l_to_bst4(wrt->sz, ll); + if (write(fr, (char *)ll, 4) != 4) + return 0; + l_to_bst4(wrt->cs, ll); + if (write(fr, (char *)ll, 4) != 4) + return 0; + l_to_bst4(wrt->frst, ll); + if (write(fr, (char *)ll, 4) != 4) + return 0; + l_to_bst4(wrt->tm, ll); + if (write(fr, (char *)ll, 4) != 4) + return 0; + if (wrt->sz) { + if (write(fr, wrt->buf, (unsigned) 5*wrt->sz) != 5*(int)wrt->sz) + return 0; + } + return 1; +#else + DWORD written; + + l_to_bst4(wrt->sz, ll); + if (WriteFile(fr, (char *)ll, 4, &written, NULL) && written == 4){ + l_to_bst4(wrt->cs, ll); + if (WriteFile(fr, (char *)ll, 4, &written, NULL) && written == 4) { + l_to_bst4(wrt->frst, ll); + if (WriteFile(fr, (char *)ll, 4, &written, NULL) && written == 4) { + l_to_bst4(wrt->tm, ll); + if (WriteFile(fr, (char *)ll, 4, &written, NULL) && written == 4) { + if (wrt->sz) { + if (WriteFile(fr, wrt->buf, (unsigned)5*wrt->sz, &written, NULL) && + written == 5*wrt->sz) { + return 1; + } + } + } + } + } + } + return 0; +#endif +} + +inline void +abolishNV(struct NV *nv) + +{ + struct NVE *p, **q, *r; + unsigned i; + + if (nv && nv->tsz && nv->buf) { + for (i = 0, q = nv->buf + i; i < nv->tsz; i++, q = nv->buf + i) { + for (p = *q; p; p = r) { + r = p->next; + if (p->data) + free(p->data); + free(p); + } + } + free(nv->buf); + free(nv); + } + return; +} + +inline struct NV * +readNV(int fd) +{ + struct NV nv, *vn; + unsigned char ll[4], *buf, *p; + long i, cnt; + + vn = (struct NV *)malloc(sizeof(struct NV)); + if (vn) { +#ifndef WIN + if (read(fd, (char *)ll, 4) == 4) { + nv.sz = bst4_to_l(ll); + if (read(fd, (char *)ll, 4) == 4) { + cnt = bst4_to_l(ll); + if (read(fd, (char *)ll, 4) == 4) { + nv.tsz = bst4_to_l(ll); + if (read(fd, (char *)ll, 4) == 4) { + goto read_ok; + } + } + } + } +#else + if (ReadFile(fd, (char *)ll, 4, &dummy, NULL) && dummy == 4) { + nv.sz = bst4_to_l(ll); + if (ReadFile(fd, (char *)ll, 4, &dummy, NULL) && dummy == 4) { + cnt = bst4_to_l(ll); + if (ReadFile(fd, (char *)ll, 4, &dummy, NULL) && dummy == 4) { + nv.tsz = bst4_to_l(ll); + if (ReadFile(fd, (char *)ll, 4, &dummy, NULL) && dummy == 4) { + goto read_ok; + } + } + } + } +#endif + free(vn); + } + return (struct NV *)0; + + read_ok: + + nv.cnt = nv.csz = 0L; + nv.head.left = nv.head.right = &nv.head; + if (nv.sz) { + if (!(nv.buf = (struct NVE **)calloc((size_t)nv.tsz, sizeof(struct NVE *)))) { + free(vn); + return((struct NV *)0); + } + if +#ifndef WIN + (!(buf = (unsigned char *)malloc((size_t)nv.sz)) || + read(fd, buf, (unsigned int)nv.sz) != (int)nv.sz) +#else + (!(buf = (unsigned char *)malloc((size_t)nv.sz)) || + !ReadFile(fd, buf, (unsigned int)nv.sz, &dummy, NULL) || + dummy != (int)nv.sz) +#endif + { + free(nv.buf); + if (buf) + free(buf); + free(vn); + return((struct NV *)0); + } + for (p = buf, i = 0L; i < cnt; i++, p += *p*2 + 2) + if ((unsigned long) (p - buf) + *p * 2 + 2 < nv.sz) + _RkRegisterNV(&nv, p + 2, (int)*p, (int)*(p + 1)); + free(buf); + } else { + free(vn); + return((struct NV *)0); + } + *vn = nv; + vn->head.right->left = &vn->head; + vn->head.left->right = &vn->head; + return(vn); +} + +static int +writeNV(int fd, struct NV *nv) +{ + unsigned char ll[4]; + unsigned char *buf = (unsigned char *)0, *r; + struct NVE *p, **q; + unsigned long i; +#ifdef WIN + DWORD dummy; +#endif + + if (!nv) + return(-1); + if (nv->buf) { + if (!(buf = (unsigned char *)malloc((size_t)nv->sz))) + return(-1); + for (r = buf, i = 0L, q = nv->buf; i < nv->tsz; i++, q = nv->buf + i) { + for (p = *q; p; q = &p->next, p = *q) { + if ((unsigned long) (r - buf) + *(p->data)*2 + 2 < nv->sz) { + memcpy(r, p->data, *(p->data)*2+2); + r += *(p->data)*2+2; + } else { + i = nv->tsz; + break; + } + } + } + } + +#ifndef WIN + l_to_bst4(nv->sz, ll); + if (write(fd, (char *)ll, 4) == 4) { + l_to_bst4(nv->cnt, ll); + if (write(fd, (char *)ll, 4) == 4) { + l_to_bst4(nv->tsz, ll); + if (write(fd, (char *)ll, 4) == 4) { + l_to_bst4((unsigned long)0, ll); + if (write(fd, (char *)ll, 4) == 4) { + if (!nv->sz || + (buf && write(fd, buf, (int) nv->sz) == (int)nv->sz)) { + goto write_ok; + } + } + } + } + } +#else + l_to_bst4(nv->sz, ll); + if (WriteFile(fd, (char *)ll, 4, &dummy, NULL) && dummy == 4) { + l_to_bst4(nv->cnt, ll); + if (WriteFile(fd, (char *)ll, 4, &dummy, NULL) && dummy == 4) { + l_to_bst4(nv->tsz, ll); + if (WriteFile(fd, (char *)ll, 4, &dummy, NULL) && dummy == 4) { + l_to_bst4((unsigned long)0, ll); + if (WriteFile(fd, (char *)ll, 4, &dummy, NULL) && dummy == 4) { + if (!nv->sz || + (buf && WriteFile(fd, buf, (int) nv->sz, &dummy, NULL) && + dummy == (int)nv->sz)) { + goto write_ok; + } + } + } + } + } +#endif + if (buf) free(buf); + return(-1); + + write_ok: + if (buf) free(buf); + return(0); +} + +static void +freeRUT(struct RUT *ruc) +{ + struct CTdata *wd, *nex; + unsigned long lc; + + for (lc = 0; lc < HN; lc++) { + for (wd = *(ruc->dp+lc); wd; wd = nex) { + nex = wd->next; + free(wd); + } + } + free(ruc->dp); + free(ruc); +} + +struct RUT * +LoadRUC(int fr) +{ + struct WRT *wruc; + struct RUT *ruc; + unsigned long lc, csn, tick; + + if (!(wruc = readWRT(fr))) + return (struct RUT *) 0; + + if (!(ruc = allocRUT(HN))) { + freeWRT(wruc); + return (struct RUT *) 0; + } + + ruc->sz = wruc->sz; + ruc->cs = 0L; + ruc->frst = wruc->frst; + ruc->tm = wruc->tm; + + for (lc = 0; lc < wruc->cs; lc++) { + unsigned char *tmp = wruc->buf + 5 * lc; + csn = a_csn(tmp); + tick = _RkGetTick(0) - a_tick(wruc->buf+5*lc); + if (!entryRut(ruc, csn, tick)) { + freeRUT(ruc); + ruc = (struct RUT *) 0; + } + } + freeWRT(wruc); + return ruc; +} + +#ifndef WIN +static int SaveRUC (int, struct RUT *); +#else +static int SaveRUC (HANDLE, struct RUT *); +#endif + +static int +SaveRUC(int fr, struct RUT *ruc) +{ + struct WRT *wruc; + struct CTdata *wdp; + unsigned long lc, count; + int retval; + + if (!ruc) + return (int) 0; + retval = 1; + if (!(wruc = allocWRT(ruc->sz))){ + freeRUT(ruc); + return (int) 0; + } + wruc->sz = ruc->sz; + wruc->cs = ruc->cs; + wruc->frst = ruc->frst; + wruc->tm = ruc->tm; + + count = 0L; + for (lc = 0L; lc < HN; lc++) { + for (wdp = *(ruc->dp+lc) ; wdp; wdp = wdp->next) { + WriteVal(wdp->ct[0], _RkGetTick(0) - wdp->ct[1], wruc->buf+5*count); + count ++; + } + } + if (count != ruc->cs) { + retval = (int) 0; + } + if (!writeToWRT(fr, wruc)) + retval = 0; + freeWRT(wruc); + return retval; +} + +inline int +FQscan(struct DF *df, struct DM *codm, char *file, int *w) +{ + int count = 0; + struct HD hd; + struct DM *dm, *dmh; + unsigned char ll[4]; + unsigned long bitsiz, bitoff; + off_t off; + int fd; + + *w = 1; + if ((fd = open(file, 2)) < 0) { + *w = 0; + if ((fd = open(file, 0)) < 0) + return -1; + } + + for (off = 0; _RkReadHeader(fd, &hd, off) >= 0;) { + long start = off; + + if (!hd.data[HD_DMNM].ptr || + (strncmp(".fq", + (char *)hd.data[HD_DMNM].ptr + + strlen((char *)hd.data[HD_DMNM].ptr) - (sizeof(".fq") - 1), + sizeof(".fq") - 1) && + strncmp(".cld", + (char *)hd.data[HD_DMNM].ptr + + strlen((char *)hd.data[HD_DMNM].ptr) - (sizeof(".cld") - 1), + sizeof(".cld") - 1)) ) { + break; + } + if (!codm->dm_xdm + || (long)((struct ND *)codm->dm_xdm)->time != hd.data[HD_TIME].var + || (long)((struct ND *)codm->dm_xdm)->rec != hd.data[HD_REC].var + || (long)((struct ND *)codm->dm_xdm)->can != hd.data[HD_CAN].var) + break; + off += hd.data[HD_HSZ].var; + (void)lseek(fd, off, 0); + (void)read(fd, (char *)ll, 4); + off += 4; + bitsiz = L4TOL(ll); + bitoff = off; + off += bitsiz; + (void)lseek(fd, off, 0); + dmh = &df->df_members; + for (dm = dmh->dm_next; dm != dmh; dm = dm->dm_next) { + if (!strcmp((char *)dm->dm_dicname, (char *)hd.data[HD_CODM].ptr)) { + struct xqm *xqm; + + if (!(xqm = (struct xqm *)malloc(sizeof(struct xqm)))) + break; + dm->dm_extdata.ptr = (pointer)xqm; + xqm->ex_boff = bitoff; + xqm->ex_bsiz = bitsiz; + dm->dm_flags |= DM_EXIST; + dm->dm_offset = start; + count++; + break; + } + } + _RkClearHeader(&hd); + } + _RkClearHeader(&hd); + if (!count) { + (void)close(fd); + return -1; + } + df->df_size = off; + df->df_extdata.var = (long)fd; + return fd; +} + +int +FQopen(struct DM *dm, struct DM *qm, char *file, int mode) +{ + struct DF *df; + struct DD *dd; + struct xqm *xqm; + int writable; +#ifndef WIN + int fd; +#else + HANDLE fd; +#endif + + /* missing file info ? */ + if (!(df = qm->dm_file) || !(dd = df->df_direct)) + return -1; + /* initialize df */ + if (!df->df_rcount) { + df->df_extdata.var = (long)FQscan(df, dm, file, &writable); + if (df->df_extdata.var < 0) + return -1; + if (writable) + df->df_flags |= DF_WRITABLE; + else + df->df_flags &= ~DF_WRITABLE; + df->df_flags |= DF_EXIST; + dd->dd_rcount++; + } + /* + * this member is not included. + */ + if (!(qm->dm_flags & DM_EXIST)) + return -1; + if (strcmp(dm->dm_dicname, qm->dm_dicname)) + return -1; + /* */ + xqm = (struct xqm *)qm->dm_extdata.ptr; +#ifndef WIN + fd = df->df_extdata.var; +#else + fd = df->df_extdata.hnd; +#endif + + qm->dm_rut = (struct RUT *)0; + qm->dm_nv = (struct NV *)0; + /* dispatch */ + qm->dm_qbits = (unsigned char *)malloc((unsigned)xqm->ex_bsiz); + if (!qm->dm_qbits) + return -1; +#ifndef WIN + (void)lseek(fd, xqm->ex_boff, 0); + (void)read(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz); +#else + { + DWORD dummy; + + (void)SetFilePointer(fd, xqm->ex_boff, NULL, FILE_BEGIN); + (void)ReadFile(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz, + &dummy, NULL); + } +#endif + qm->dm_rut = LoadRUC(fd); + qm->dm_nv = readNV(fd); + df->df_rcount++; + if ((mode & DM_WRITABLE) && (df->df_flags & DF_WRITABLE)) { + qm->dm_flags |= DM_WRITABLE; + } + return 0; +} + +/* + * CLOSE + */ +/*ARGSUSED*/ +void +FQclose(struct RkContext *cx, struct DM *dm, struct DM *qm, char *file) +{ + struct DF *df = qm->dm_file; + struct xqm *xqm; +#ifndef WIN + int fd = (int)df->df_extdata.var; +#else + HANDLE fd = df->df_extdata.hnd; +#endif + + xqm = (struct xqm *)qm->dm_extdata.ptr; + if (xqm) { + if (qm->dm_qbits) { + if (qm->dm_flags & DM_UPDATED) { +#ifndef WIN + (void)lseek(fd, xqm->ex_boff, 0); + (void)write(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz); +#else + DWORD dummy; + + (void)SetFilePointer(fd, xqm->ex_boff, NULL, FILE_BEGIN); + (void)ReadFile(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz, + &dummy, NULL); +#endif + }; + free(qm->dm_qbits); + qm->dm_qbits = (unsigned char *)0; + } + } + if (qm->dm_rut) { + if (qm->dm_flags & DM_UPDATED) + SaveRUC(fd, qm->dm_rut); + freeRUT(qm->dm_rut); + qm->dm_rut = (struct RUT *)0; + } + if (qm->dm_nv) { + if (qm-> dm_flags & DM_UPDATED) + writeNV(fd, qm->dm_nv); + abolishNV(qm->dm_nv); + qm->dm_nv = (struct NV *)0; + } + qm->dm_flags &= ~DM_UPDATED; + if (--df->df_rcount == 0) { + struct DM *dmh, *ddm; + +#ifndef WIN + (void)close(fd); +#else + (void)CloseHandle(fd); +#endif + dmh = &df->df_members; + for (ddm = dmh->dm_next; ddm != dmh; ddm = ddm->dm_next) { + xqm = (struct xqm *)ddm->dm_extdata.ptr; + if (xqm) { + free(xqm); + ddm->dm_extdata.ptr = (pointer)0; + } + } + } +} + +int +FQsync(struct RkContext *cx, struct DM *dm, struct DM *qm, char *file) +/* ARGSUSED */ +{ + struct DF *df = qm->dm_file; + struct xqm *xqm; + int rv; +#ifndef WIN + int fd = (int)df->df_extdata.var; +#else + HANDLE fd = df->df_extdata.hnd; +#endif + + rv = 0; + xqm = (struct xqm *)qm->dm_extdata.ptr; + if (xqm) { + if (qm->dm_qbits) { + if (qm->dm_flags & DM_UPDATED) { +#ifndef WIN + (void)lseek(fd, xqm->ex_boff, 0); + if (write(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz) != + (int) xqm->ex_bsiz) + rv = -1; +#else + DWORD dummy; + + (void)SetFilePointer(fd, xqm->ex_boff, NULL, FILE_BEGIN); + if (!WriteFile(fd, (char *)qm->dm_qbits, (int)xqm->ex_bsiz, + &dummy, NULL) || (DWORD)xqm->ex_bsiz != dummy) { + rv = -1; + } +#endif + if (qm->dm_rut) + rv = SaveRUC(fd, qm->dm_rut) - 1; + if (qm->dm_nv) + rv = writeNV(fd, qm->dm_nv); + } + if (!rv) + qm->dm_flags &= ~DM_UPDATED; + } + } + return (rv); +} + + diff --git a/src/add-ons/input_server/methods/canna/rk/kana.c b/src/add-ons/input_server/methods/canna/rk/kana.c new file mode 100644 index 0000000000..a1cf8e803f --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/kana.c @@ -0,0 +1,1120 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="@(#) 102.1 $Id: kana.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif + +/* LINTLIBRARY */ +#include "RKintern.h" + +#define SUUJI_THROUGH 0 +#define SUUJI_HANKAKU 1 +#define SUUJI_ZENKAKU 2 +#define SUUJI_SIMPLEKANJI 3 +#define SUUJI_FULLKANJI 4 +#define SUUJI_FULLKANJITRAD 5 +#define SUUJI_WITHKANJIUNIT 6 +#define SUUJI_WITHCOMMA 7 + +#if 0 +/* RkCvtZen + * hankaku moji wo zenkaku moji ni suru + */ +static +WCHAR_T +hiragana[] = +{ +/* 0x00 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/* 0x10 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/* 0x20 */ + 0xa1a1, 0xa1aa, 0xa1ed, 0xa1f4, 0xa1f0, 0xa1f3, 0xa1f5, 0xa1c7, + 0xa1ca, 0xa1cb, 0xa1f6, 0xa1dc, 0xa1a4, 0xa1dd, 0xa1a5, 0xa1bf, +/* 0x30 */ + 0xa3b0, 0xa3b1, 0xa3b2, 0xa3b3, 0xa3b4, 0xa3b5, 0xa3b6, 0xa3b7, + 0xa3b8, 0xa3b9, 0xa1a7, 0xa1a8, 0xa1e3, 0xa1e1, 0xa1e4, 0xa1a9, +/* 0x40 */ + 0xa1f7, 0xa3c1, 0xa3c2, 0xa3c3, 0xa3c4, 0xa3c5, 0xa3c6, 0xa3c7, + 0xa3c8, 0xa3c9, 0xa3ca, 0xa3cb, 0xa3cc, 0xa3cd, 0xa3ce, 0xa3cf, +/* 0x50 */ + 0xa3d0, 0xa3d1, 0xa3d2, 0xa3d3, 0xa3d4, 0xa3d5, 0xa3d6, 0xa3d7, + 0xa3d8, 0xa3d9, 0xa3da, 0xa1ce, 0xa1ef, 0xa1cf, 0xa1b0, 0xa1b2, +/* 0x60 */ + 0xa1c6, 0xa3e1, 0xa3e2, 0xa3e3, 0xa3e4, 0xa3e5, 0xa3e6, 0xa3e7, + 0xa3e8, 0xa3e9, 0xa3ea, 0xa3eb, 0xa3ec, 0xa3ed, 0xa3ee, 0xa3ef, +/* 0x70 */ + 0xa3f0, 0xa3f1, 0xa3f2, 0xa3f3, 0xa3f4, 0xa3f5, 0xa3f6, 0xa3f7, + 0xa3f8, 0xa3f9, 0xa3fa, 0xa1d0, 0xa1c3, 0xa1d1, 0xa1c1, 0xa2a2, +/*0x80 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x90 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0xa0 */ + 0xa1a1, 0xa1a3, 0xa1d6, 0xa1d7, 0xa1a2, 0xa1a6, 0xa4f2, 0xa4a1, + 0xa4a3, 0xa4a5, 0xa4a7, 0xa4a9, 0xa4e3, 0xa4e5, 0xa4e7, 0xa4c3, +/*0xb0 */ + 0xa1bc, 0xa4a2, 0xa4a4, 0xa4a6, 0xa4a8, 0xa4aa, 0xa4ab, 0xa4ad, + 0xa4af, 0xa4b1, 0xa4b3, 0xa4b5, 0xa4b7, 0xa4b9, 0xa4bb, 0xa4bd, +/*0xc0 */ + 0xa4bf, 0xa4c1, 0xa4c4, 0xa4c6, 0xa4c8, 0xa4ca, 0xa4cb, 0xa4cc, + 0xa4cd, 0xa4ce, 0xa4cf, 0xa4d2, 0xa4d5, 0xa4d8, 0xa4db, 0xa4de, +/*0xd0 */ + 0xa4df, 0xa4e0, 0xa4e1, 0xa4e2, 0xa4e4, 0xa4e6, 0xa4e8, 0xa4e9, + 0xa4ea, 0xa4eb, 0xa4ec, 0xa4ed, 0xa4ef, 0xa4f3, 0xa1ab, 0xa1ac, +/* 0xe0 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/* 0xf0 */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +}; + +static +WCHAR_T +hankaku[] = { +/*0x00*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x10*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x20*/ + 0x0000, ' ', 0x8ea4, 0x8ea1, ',', '.', 0x8ea5, ':', + ';', '?', '!', 0x8ede, 0x8edf, 0x0000, 0x0000, 0x0000, +/*0x30*/ + '^', 0x0000, '_', 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x8eb0, 0x0000, 0x0000, '/', +/*0x40*/ + 0x0000, '~', 0x0000, '|', 0x0000, 0x0000, '\'', '\'', + '"', '"', '(', ')', '[', ']', '[', ']', +/*0x50*/ + '{', '}', 0x0000, 0x0000, 0x0000, 0x0000, 0x8ea2, 0x8ea3, + 0x0000, 0x0000, 0x0000, 0x0000, '+', '-', 0x0000, 0x0000, +/*0x60*/ + 0x0000, '=', 0x0000, '<', '>', 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, '\\', +/*0x70*/ + '$',0x0000, 0x0000, '%', '#', '&', '*', '@', + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x80*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0x90*/ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +/*0xa0*/ + 0x0020, 0x00a7, 0x00b1, 0x00a8, 0x00b2, 0x00a9, 0x00b3, 0x00aa, + 0x00b4, 0x00ab, 0x00b5, 0x00b6, 0xb6de, 0x00b7, 0xb7de, 0x00b8, +/*0xb0*/ + 0xb8de, 0x00b9, 0xb9de, 0x00ba, 0xbade, 0x00bb, 0xbbde, 0x00bc, + 0xbcde, 0x00bd, 0xbdde, 0x00be, 0xbede, 0x00bf, 0xbfde, 0x00c0, +/*0xc0*/ + 0xc0de, 0x00c1, 0xc1de, 0x00af, 0x00c2, 0xc2de, 0x00c3, 0xc3de, + 0x00c4, 0xc4de, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, +/*0xd0*/ + 0xcade, 0xcadf, 0x00cb, 0xcbde, 0xcbdf, 0x00cc, 0xccde, 0xccdf, + 0x00cd, 0xcdde, 0xcddf, 0x00ce, 0xcede, 0xcedf, 0x00cf, 0x00d0, +/*0xe0*/ + 0x00d1, 0x00d2, 0x00d3, 0x00ac, 0x00d4, 0x00ad, 0x00d5, 0x00ae, + 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dc, +/*0xf0*/ + 0x00b2, 0x00b4, 0x00a6, 0x00dd, 0xb3de, 0x00b6, 0x00b9, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, +}; + +#endif + +#ifdef OBSOLETE_RKKANA + +#define ADDCODE(dst, maxdst, count, code, length) {\ + if ( (unsigned long)(length) <= (unsigned long)(maxdst) ) {\ + (maxdst) -= (length); (count) += (length);\ + if ( (dst) ) {\ + (dst) += (length);\ + switch((length)) {\ + case 4: *--(dst) = (code)&255; (code) >>= 8;\ + case 3: *--(dst) = (code)&255; (code) >>= 8;\ + case 2: *--(dst) = (code)&255; (code) >>= 8;\ + case 1: *--(dst) = (code)&255; (code) >>= 8;\ + };\ + (dst) += (length);\ + };\ + };\ +} + +#else /* !OBSOLETE_RKKANA */ + +#include "RKproto.h" +static int _ADDCODE(unsigned char *dst, int maxdst, int count, unsigned long code, int length); +static int euccharlen(unsigned char *s, int bytelen); +static int Wcstosjis(char *dst, int dstlen, WCHAR_T *src, int srclen); + +static int +_ADDCODE(unsigned char *dst, int maxdst, int count, unsigned long code, int length) +{ + if ((unsigned long)length <= (unsigned long)maxdst) { + maxdst -= length; + count += length; + if (dst) { + dst += length; + switch (length) { + case 4: *--dst = (unsigned char)code; code >>= 8; + case 3: *--dst = (unsigned char)code; code >>= 8; + case 2: *--dst = (unsigned char)code; code >>= 8; + case 1: *--dst = (unsigned char)code; code >>= 8; + } + } + return length; + } + return 0; +} + +#define ADDCODE(dst, maxdst, count, code, length) \ +{ int llen = _ADDCODE(dst, maxdst, count, (unsigned long) code, length); \ + if (llen > 0 && (dst)) { (dst) += llen; (maxdst) -= llen; (count) += llen; }} + +#endif /* !OBSOLETE_RKKANA */ + +#define ADDWCODE(dst, maxdst, count, code) {\ + if ( (maxdst) > 0 ) {\ + (maxdst)-- ; (count)++ ;\ + if ( (dst) ) {\ + *(dst)++ = (code);\ + }\ + }\ +} + +#if 0 + +static int +euccharlen(unsigned char *s, int bytelen) +{ + unsigned char ch; + int res = 0; + + while ((ch = *s++) && bytelen--) { + res++; + if (ch & 0x80) { + if (ch == RK_SS3) { + s++; + bytelen--; + } + s++; + bytelen--; + } + } + return res; +} + +/* RkCvtZen + * hankaku moji(ASCII+katakana) wo taiou suru zenkaku moji ni suru + * dakuten,handakuten shori mo okonau. + */ +int RkCvtZen (unsigned char *, int, unsigned char *, int); + +int +RkCvtZen(unsigned char *zen, int maxzen, unsigned char *han, int maxhan) +{ + unsigned char *z = zen; + unsigned char *h = han; + unsigned char *H = han + maxhan; + WCHAR_T hi, lo; + unsigned byte; + int count = 0; + unsigned long code; + + if ( --maxzen <= 0 ) + return count; + while ( h < H ) { + hi = *h++; + byte = 2; + if ( hi == 0x8e ) { /* hankaku katakana */ + if ( !(code = hiragana[lo = *h++]) ) + code = (hi<<8)|lo; + byte = (code>>8) ? 2 : 1; + if ( (code>>8) == 0xa4 ) { + code |= 0x100; + /* dakuten/handakuten ga tuku baai */ + if ( h + 1 < H && h[0] == 0x8e ) { + lo = h[1]; + switch( LOMASK(code) ) { + case 0xa6: /* u */ + if ( lo == 0xde ) code = 0xa5f4, h += 2; + break; + /* ha */case 0xcf: case 0xd2: case 0xd5: case 0xd8: case 0xdb: + if ( lo == 0xdf ) { + code += 2, h += 2; + break; + }; + case 0xab: case 0xad: case 0xaf: case 0xb1: case 0xb3: /* ka */ + case 0xb5: case 0xb7: case 0xb9: case 0xbb: case 0xbd: /* sa */ + case 0xbf: case 0xc1: case 0xc4: case 0xc6: case 0xc8: /* ta */ + if ( lo == 0xde ) { + code += 1, h += 2; + break; + }; + }; + }; + }; + } + else if (hi == 0x8f) { + ADDCODE(z, maxzen, count, hi, 1); + code = (((WCHAR_T) h[0]) << 8) | ((WCHAR_T) h[1]); h += 2; + byte = 2; + } else if ( hi & 0x80 ) + code = (hi<<8)|*h++; + else { + if ( !(code = hiragana[hi]) ) + code = hi; + byte = (code>>8) ? 2 : 1; + } + ADDCODE(z, maxzen, count, code, byte); + }; + if ( z ) + *z = 0; + return count; +} + +/* RkCvtHan + * zenkaku kana moji wo hankaku moji ni suru + */ +int RkCvtHan (unsigned char *, int, unsigned char *, int); + +int +RkCvtHan(unsigned char *han, int maxhan, unsigned char *zen, int maxzen) +{ + unsigned char *h = han; + unsigned char *z = zen; + unsigned char *Z = zen + maxzen; + WCHAR_T hi, lo; + WCHAR_T byte; + int count = 0; + unsigned long code; + + if ( --maxhan <= 0 ) + return 0; + while ( z < Z ) { + hi = *z++; + byte = 1; + switch(hi) { + case 0xa1: /* kigou */ + lo = *z++; + if ( !(code = hankaku[lo&0x7f]) ) + code = (hi<<8)|lo; + byte = (code>>8) ? 2 : 1; + break; + case 0xa3: /* eisuuji */ + lo = *z++; + if ( 0xb0 <= lo && lo <= 0xb9 ) code = (lo - 0xb0) + '0'; + else + if ( 0xc1 <= lo && lo <= 0xda ) code = (lo - 0xc1) + 'A'; + else + if ( 0xe1 <= lo && lo <= 0xfa ) code = (lo - 0xe1) + 'a'; + else + code = (hi<<8)|lo, byte = 2; + break; + case 0xa4: /* hiragana */ + case 0xa5: /* katakana */ + lo = *z++; + if ( (code = hankaku[lo]) && + (lo <= (WCHAR_T)(hi == 0xa4 ? 0xf3 : 0xf6)) ) { + if ( code>>8 ) { + code = 0x8e000000|((code>>8)<<16)|0x00008e00|LOMASK(code); + byte = 4; + } + else { + code = 0x00008e00|LOMASK(code); + byte = 2; + }; + } + else + code = (hi<<8)|lo, byte = 2; + break; + default: + if (hi == 0x8f) { + ADDCODE(h, maxhan, count, hi, 1); + code = (((WCHAR_T) z[0]) << 8) | ((WCHAR_T) z[1]); z += 2; + byte = 2; + } + else if ( hi & 0x80 ) { /* kanji */ + code = (hi<<8)|(*z++); + byte = 2; + } + else + switch(hi) { + /* + case ',': code = 0x8ea4; byte = 2; break; + case '-': code = 0x8eb0; byte = 2; break; + case '.': code = 0x8ea1; byte = 2; break; + */ + default: code = hi; break; + }; + break; + }; + ADDCODE(h, maxhan, count, code, byte); + }; + if ( h ) + *h = 0; + return count; +} + +/* RkCvtKana/RkCvtHira + * zenkaku hiragana wo katakana ni suru + */ +int RkCvtKana (unsigned char *, int, unsigned char *, int); + +int +RkCvtKana(unsigned char *kana, int maxkana, unsigned char *hira, int maxhira) +{ + unsigned char *k = kana; + unsigned char *h = hira; + unsigned char *H = hira + maxhira; + WCHAR_T hi; + WCHAR_T byte; + int count = 0; + unsigned long code; + + if ( --maxkana <= 0 ) + return 0; + while ( h < H ) { + hi = *h++; + if (hi == 0x8f) { + ADDCODE(k, maxkana, count, hi, 1); + code = (((WCHAR_T) h[0]) << 8) | ((WCHAR_T) h[1]); h += 2; + byte = 2; + } + else if ( hi & 0x80 ) { + int dakuon; + + code = (hi == 0xa4) ? (0xa500|(*h++)) : ((hi<<8)|(*h++)); + byte = 2; + /* hiragana U + " */ + dakuon = ( h + 1 < H && ((((WCHAR_T) h[0])<<8)| ((WCHAR_T) h[1])) == 0xa1ab ); + if ( hi == 0xa4 && code == 0xa5a6 && dakuon ) { + code = 0xa5f4; + h += 2; + }; + } else + code = hi, byte = 1; + ADDCODE(k, maxkana, count, code, byte); + }; + if ( k ) + *k = 0; + return count; +} + +int RkCvtHira (unsigned char *, int, unsigned char *, int); + +int +RkCvtHira(unsigned char *hira, int maxhira, unsigned char *kana, int maxkana) +{ + unsigned char *h = hira; + unsigned char *k = kana; + unsigned char *K = kana + maxkana; + WCHAR_T hi; + WCHAR_T byte; + int count = 0; + unsigned long code; + + if ( --maxhira <= 0 ) + return 0; + while ( k < K ) { + hi = *k++; + if (hi == 0x8f) { + ADDCODE(h, maxhira, count, hi, 1); + code = (((WCHAR_T) k[0]) << 8) | ((WCHAR_T) k[1]); k += 2; + byte = 2; + } else if ( hi & 0x80 ) { + code = (hi == 0xa5) ? (0xa400|(*k++)) : ((hi<<8)|(*k++)); + byte = 2; + /* katakana U + " */ + if ( code == 0xa4f4 ) { /* u no dakuon */ + code = 0xa4a6a1ab; + byte = 4; + } else if ( code == 0xa4f5 ) + code = 0xa4ab; + else if ( code == 0xa4f6 ) + code = 0xa4b1; + } else + code = hi, byte = 1; + ADDCODE(h, maxhira, count, code, byte); + }; + if ( h ) + *h = 0; + return count; +} + +int RkCvtNone (unsigned char *, int, unsigned char *, int); + +int +RkCvtNone(unsigned char *dst, int maxdst, unsigned char *src, int maxsrc) +{ + unsigned char *d = dst; + unsigned char *s = src; + unsigned char *S = src + maxsrc; + WCHAR_T byte; + int count = 0; + unsigned long code; + + if ( --maxdst <= 0 ) + return 0; + while ( s < S ) { + code = *s++; + byte = 1; + if (code == 0x8f) { + ADDCODE(d, maxdst, count, code, 1); + code = (((WCHAR_T) s[0]) << 8) | ((WCHAR_T) s[1]); s += 2; + byte = 2; + } else if ( code & 0x80 ) + code = (code<<8)|(*s++), byte = 2; + ADDCODE(d, maxdst, count, code, byte); + }; + if ( d ) + *d = 0; + return count; +} + +#ifdef USE_SJIS_TEXT_DIC +exp(int maxwc) +{ + WCHAR_T *e = wc_return, *ee = wc_return + maxwc; + unsigned char *s = (unsigned char *)sj; + unsigned char *S = (unsigned char *)sj + maxsj; + unsigned short hi, lo; + unsigned short byte; + int count = 0; + unsigned long code; + + if ( --maxwc <= 0 ) + return 0; + + while ( s < S ) { + hi = *s++; + if ( hi <= 0x7f ) /* ascii */ + code = hi, byte = 1; + else + if ( 0xa0 <= hi && hi <= 0xdf ) /* hankaku katakana */ + code = hi, byte = 2; + else + if (0xf0 <= hi && hi <= 0xfc) { /* gaiji */ + hi -= 0xf0; + hi = 2*hi + 0x21; + if ((lo = *s++) <= 0x9e) { + if (lo < 0x80) + lo++; + lo -= 0x20; + } + else { + hi++; + lo -= 0x7e; + } + code = 0x8000 | (hi<<8) | lo, byte = 3; + } + else { + hi -= (hi <= 0x9f) ? 0x80 : 0xc0; + hi = 2*hi + 0x20; + if ( (lo = *s++) <= 0x9e ) { /* kisuu ku */ + hi--; + if ( 0x80 <= lo ) lo--; + lo -= (0x40 - 0x21); + } + else /* guusuu ku */ + lo -= (0x9f - 0x21); + code = 0x8080|(hi<<8)|lo, byte = 2; + }; + if (wc_return && e < ee) { + *e++ = (WCHAR_T)code; + } + }; + if (wc_return && e && e < ee) { + *e = 0; + } + return count; +} +#endif /* USE_SJIS_TEXT_DIC */ + +/* RkCvtWide + * + */ +int +RkCvtWide(WCHAR_T *dst, int maxdst, char *src, int maxsrc) +{ +#ifdef USE_SJIS_TEXT_DIC + return SJistowcs(dst, maxdst, src, maxsrc); +#else /* !USE_SJIS_TEXT_DIC, that is, EUC */ + WCHAR_T *d = dst; + unsigned char *s = (unsigned char *)src; + unsigned char *S = (unsigned char *)src + maxsrc; + int count = 0; + unsigned long code; + + if ( --maxdst <= 0 ) + return count; + while ( s < S ) + { + code = *s++; + if ( code & 0x80 ) + { + switch(code) + { + case RK_SS2: /* hankaku katakana */ + code = 0x0080|(s[0]&0x7f); + s++; + break; + case RK_SS3: /* gaiji */ + code = 0x8000|(((s[0]<<8)|s[1])&0x7f7f); + s += 2; + break; + default: + code = 0x8080|(((s[-1]<<8)|s[0])&0x7f7f); + s += 1; + }; + }; + ADDWCODE(d, maxdst, count, (WCHAR_T)code); + }; + if ( d ) + *d = 0; + return count; +#endif /* !USE_SJIS_TEXT_DIC */ +} + +#ifdef USE_SJIS_TEXT_DIC +/* + Wcstosjis -- To convert WCHAR_T string to SJIS string. + + This function should not copy after NULL character even if + the srclen is too large + */ + +static int +Wcstosjis(char *dst, int dstlen, WCHAR_T *src, int srclen) +{ + register int i, j; + unsigned char *sjise_kanjip, sjise_area[2]; + WCHAR_T codeset; + register WCHAR_T wc; + + sjise_kanjip = sjise_area; + + for (i = 0, j = 0; src[i] != (WCHAR_T)0 && j < dstlen && i < srclen ; i++) { + wc = src[i]; + codeset = wc & 0x8080; /* to know what codeset is `wc' */ + + switch (codeset) { + case 0x0000: /* ASCII */ + /* continue to the following line ... */ + case 0x0080: /* Codeset 2, that is Katakana */ + if (dst) dst[j++] = (unsigned char)wc; + break; + + case 0x8080: /* Codeset 1, that is Kanji */ + if (j + 2 > dstlen) { + return j; /* overflow */ + } + sjise_kanjip[0] = ((wc >> 8) & 0x7f); + sjise_kanjip[1] = (wc & 0x7f); + sjise_kanjip[1] = ((sjise_kanjip[0] % 2) ? + (sjise_kanjip[1] + 0x1f + + ((sjise_kanjip[1] < 0x60) ? 0 : 1)) : + (sjise_kanjip[1] + 0x7e)); + sjise_kanjip[0] = ((sjise_kanjip[0] < 0x5f) ? + ((sjise_kanjip[0] - 0x21) / 2 + 0x81) : + ((sjise_kanjip[0] - 0x5f) / 2 + 0xe0)); + if (dst) { + dst[j++] = sjise_kanjip[0]; + dst[j++] = sjise_kanjip[1]; + } + break; + + case 0x8000: /* Codeset 3 */ + if (j + 2 > dstlen) { + return j; /* overflow */ + } + sjise_kanjip[0] = ((wc >> 8) & 0x7f); + sjise_kanjip[1] = (wc & 0x7fb); + sjise_kanjip[1] = ((sjise_kanjip[0] % 2) ? + (sjise_kanjip[1] + 0x1f + + ((sjise_kanjip[1] < 0x60) ? 0 : 1)) : + (sjise_kanjip[1] + 0x7e)); + sjise_kanjip[0] = ((sjise_kanjip[0] - 0x21) / 2 + 0xf0); + if (dst) { + dst[j++] = sjise_kanjip[0]; + dst[j++] = sjise_kanjip[1]; + } + break; + } + } + if (j < dstlen && dst) { + dst[j] = '\0'; + } + return j; +} +#endif /* USE_SJIS_TEXT_DIC */ + +/* RkCvtNarrow + * + */ +int +RkCvtNarrow(char *dst, int maxdst, WCHAR_T *src, int maxsrc) +{ +#ifdef USE_SJIS_TEXT_DIC + return Wcstosjis(dst, maxdst, src, maxsrc); +#else /* !USE_SJIS_TEXT_DIC */ + unsigned char *d = (unsigned char *)dst; + WCHAR_T *s = src; + WCHAR_T *S = src + maxsrc; + int count = 0; + long code; + int byte; + + if ( --maxdst <= 0 ) + return count; + while ( s < S ) + { + code = *s++; + switch(code&0x8080) + { + case 0x0000: + code &= 0xff; + byte = 1; + break; + case 0x0080: + code &= 0xff; + code |= 0x8e00; + byte = 2; + break; + case 0x8000: + code &= 0xffff; + code |= 0x8f8080; + byte = 3; + break; + case 0x8080: + code &= 0xffff; + byte = 2; + break; + }; + ADDCODE(d, maxdst, count, code, byte); + }; + if ( d ) + *d = 0; + return count; +#endif /* !USE_SJIS_TEXT_DIC */ +} + +#ifdef notdef +/* RkEuc + * shift jis --> euc + */ +int +RkCvtEuc(unsigned char *euc, int maxeuc, unsigned char *sj, int maxsj) +{ + unsigned char *e = euc; + unsigned char *s = sj; + unsigned char *S = sj + maxsj; + WCHAR_T hi, lo; + WCHAR_T byte; + int count = 0; + unsigned long code; + + if ( --maxeuc <= 0 ) + return 0; + + while ( s < S ) { + hi = *s++; + if ( hi <= 0x7f ) /* ascii */ + code = hi, byte = 1; + else + if ( 0xa0 <= hi && hi <= 0xdf ) /* hankaku katakana */ + code = 0x8e00|hi, byte = 2; + else { + hi -= (hi <= 0x9f) ? 0x80 : 0xc0; + hi = 2*hi + 0x20; + if ( (lo = *s++) <= 0x9e ) { /* kisuu ku */ + hi--; + if ( 0x80 <= lo ) lo--; + lo -= (0x40 - 0x21); + } else /* guusuu ku */ + lo -= (0x9f - 0x21); + code = 0x8080|(hi<<8)|lo, byte = 2; + }; + ADDCODE(e, maxeuc, count, code, byte); + }; + if ( e ) + *e = 0; + return count; +} +#endif /* notdef */ + +/* RkCvtSuuji + * arabia suuji wo kansuuji ni kaeru + */ +static WCHAR_T suujinew[] = { + 0xa1bb, 0xb0ec, 0xc6f3, 0xbbb0, 0xbbcd, + 0xb8de, 0xcfbb, 0xbcb7, 0xc8ac, 0xb6e5, +}; +static WCHAR_T suujiold[] = { + 0xa1bb, 0xb0ed, 0xc6f5, 0xbbb2, 0xbbcd, + 0xb8e0, 0xcfbb, 0xbcb7, 0xc8ac, 0xb6e5, +}; +static WCHAR_T kurai4[] = { + 0, 0xcbfc, 0xb2af, 0xc3fb, 0xb5fe, 0, +}; + +static WCHAR_T kurai3new[] = { 0, 0xbdbd, 0xc9b4, 0xc0e9, }; +static WCHAR_T kurai3old[] = { 0, 0xbdbd, 0xc9b4, 0xc0e9, }; + +int +RkwCvtSuuji(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format) +{ + int count; + int i, j, k; + int digit[4], pend; + WCHAR_T code, tmp; + WCHAR_T *d = dst; + WCHAR_T *s = src + maxsrc - 1; + + if ( --maxdst <= 0 ) + return 0; + /* Í­¸ú¤Ê·å¿ô¤ò¿ô¤¨¤ë */ + pend = 0; + for ( count = k = 0; s >= src; k++ ) { + int dec, thru = *s; + + if ( thru & 0x8080 ) { + if ( !((WCHAR_T)0xa3b0 <= *s && *s <= (WCHAR_T)0xa3b9) ) + break; + dec = *s-- - 0xa3b0; + } + else { + if ( !((WCHAR_T)'0' <= *s && *s <= (WCHAR_T)'9') ) + break; + dec = *s-- - '0'; + } + + switch(format) { + /* simple */ + case SUUJI_THROUGH: /* sanyou suuji */ + code = thru; + ADDWCODE(d, maxdst, count, code); + break; + case SUUJI_HANKAKU: /* sanyou suuji */ + code = dec + '0'; + if (code == thru) { + return 0; + } + ADDWCODE(d, maxdst, count, code); + break; + case SUUJI_ZENKAKU: /* sanyou suuji */ + code = hiragana[dec + '0']; + if (code == thru) { + return 0; + } + ADDWCODE(d, maxdst, count, code); + break; + /* kanji kurai dori */ + case SUUJI_SIMPLEKANJI: /* kanji suuji */ + code = suujinew[dec]; + ADDWCODE(d, maxdst, count, code); + break; + case SUUJI_FULLKANJI: + case SUUJI_FULLKANJITRAD: + case SUUJI_WITHKANJIUNIT: /* 12 O 3456 M 7890 */ + digit[pend++] = dec; + if ( pend == 4 ) { + while ( pend > 0 && digit[pend - 1] == 0 ) + pend--; + if ( pend ) { + /* kurai wo shuturyoku */ + code = kurai4[k/4]; + if (code) + ADDWCODE(d, maxdst, count, code) + else + if ( k >= 4 ) + return 0; + + for ( i = 0; i < pend; i++ ) + switch(format) { + case SUUJI_FULLKANJI: + if ( digit[i] ) { + code = kurai3new[i]; + if (code) + ADDWCODE(d, maxdst, count, code); + if ( i == 0 || (digit[i] > 1) ) { + code = suujinew[digit[i]]; + ADDWCODE(d, maxdst, count, code); + } + } + break; + case SUUJI_FULLKANJITRAD: + if ( digit[i] ) { + code = kurai3old[i]; + if (code) + ADDWCODE(d, maxdst, count, code); + code = suujiold[digit[i]]; + ADDWCODE(d, maxdst, count, code); + }; + break; + case SUUJI_WITHKANJIUNIT: + code = hiragana[digit[i]+'0']; + ADDWCODE(d, maxdst, count, code); + break; + } + } + pend = 0; + } + break; + case SUUJI_WITHCOMMA: /* 1,234,567,890 */ + if ( k && k%3 == 0 ) { + code = hiragana[',']; + ADDWCODE(d, maxdst, count, code); + } + code = hiragana[dec + '0']; + ADDWCODE(d, maxdst, count, code); + break; + default: + return 0; + }; + }; + + if (format == SUUJI_FULLKANJI || format == SUUJI_FULLKANJITRAD || + format == SUUJI_WITHKANJIUNIT) { + while ( pend > 0 && digit[pend - 1] == 0 ) + pend--; + if ( pend ) { + code = kurai4[k/4]; + if (code) + ADDWCODE(d, maxdst, count, code) + else + if ( k >= 4 ) + return 0; + for ( i = 0; i < pend; i++ ) + switch(format) { + case SUUJI_FULLKANJI: + if ( digit[i] ) { + code = kurai3new[i]; + if (code) + ADDWCODE(d, maxdst, count, code); + if ( i == 0 || (digit[i] > 1) ) { + code = suujinew[digit[i]]; + ADDWCODE(d, maxdst, count, code); + }; + }; + break; + case SUUJI_FULLKANJITRAD: + if ( digit[i] ) { + code = kurai3old[i]; + if (code) + ADDWCODE(d, maxdst, count, code); + code = suujiold[digit[i]]; + ADDWCODE(d, maxdst, count, code); + }; + break; + case SUUJI_WITHKANJIUNIT: + code = hiragana[digit[i]+'0']; + ADDWCODE(d, maxdst, count, code); + break; + } + } + } + + if ( dst ) { + *d = 0; + for ( i = 0, j = count - 1; i < j; i++, j-- ) { + tmp = dst[i]; dst[i] = dst[j]; dst[j] = tmp; + } + } + return count; +} + +/* ¥ï¥¤¥É¥­¥ã¥é¥¯¥¿Âбþ´Ø¿ô */ + +#define CBUFSIZE 512 +unsigned char *ustoeuc(); +WCHAR_T *euctous(); + +int RkwCvtHan (WCHAR_T *, int, WCHAR_T *, int); + +int +RkwCvtHan(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int len; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + unsigned char cbuf[CBUFSIZE], cbuf2[CBUFSIZE]; +#else + unsigned char *cbuf, *cbuf2; + cbuf = (unsigned char *)malloc(CBUFSIZE); + cbuf2 = (unsigned char *)malloc(CBUFSIZE); + if (!cbuf || !cbuf2) { + if (cbuf) (void)free((char *)cbuf); + if (cbuf2) (void)free((char *)cbuf2); + return 0; + } +#endif + + len = ustoeuc(src, srclen, cbuf, CBUFSIZE) - cbuf; + len = RkCvtHan(cbuf2, CBUFSIZE, cbuf, len); + if (len > 0) { + if (dst) { + len = euctous(cbuf2, len, dst, maxdst) - dst; + } + else { + len = euccharlen(cbuf2, len); + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + (void)free((char *)cbuf); + (void)free((char *)cbuf2); +#endif + return len; +} + +int RkwCvtHira (WCHAR_T *, int, WCHAR_T *, int); + +int +RkwCvtHira(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int len; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + unsigned char cbuf[CBUFSIZE], cbuf2[CBUFSIZE]; +#else + unsigned char *cbuf, *cbuf2; + cbuf = (unsigned char *)malloc(CBUFSIZE); + cbuf2 = (unsigned char *)malloc(CBUFSIZE); + if (!cbuf || !cbuf2) { + if (cbuf) (void)free((char *)cbuf); + if (cbuf2) (void)free((char *)cbuf2); + return 0; + } +#endif + + len = ustoeuc(src, srclen, cbuf, CBUFSIZE) - cbuf; + len = RkCvtHira(cbuf2, CBUFSIZE, cbuf, len); + if (len > 0) { + if (dst) { + len = euctous(cbuf2, len, dst, maxdst) - dst; + } + else { + len = euccharlen(cbuf2, len); + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + (void)free((char *)cbuf); + (void)free((char *)cbuf2); +#endif + return len; +} + +int RkwCvtKana (WCHAR_T *, int, WCHAR_T *, int); + +int +RkwCvtKana(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + unsigned int len; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + unsigned char cbuf[CBUFSIZE], cbuf2[CBUFSIZE]; +#else + unsigned char *cbuf, *cbuf2; + cbuf = (unsigned char *)malloc(CBUFSIZE); + cbuf2 = (unsigned char *)malloc(CBUFSIZE); + if (!cbuf || !cbuf2) { + if (cbuf) (void)free((char *)cbuf); + if (cbuf2) (void)free((char *)cbuf2); + return 0; + } +#endif + + len = ustoeuc(src, srclen, cbuf, CBUFSIZE) - cbuf; + len = RkCvtKana(cbuf2, CBUFSIZE, cbuf, len); + if (len > 0) { + if (dst) { + len = euctous(cbuf2, len, dst, maxdst) - dst; + } + else { + len = euccharlen(cbuf2, len); + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + (void)free((char *)cbuf); + (void)free((char *)cbuf2); +#endif + return len; +} + +int RkwCvtZen (WCHAR_T *, int, WCHAR_T *, int); + +int +RkwCvtZen(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int len; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + unsigned char cbuf[CBUFSIZE], cbuf2[CBUFSIZE]; +#else + unsigned char *cbuf, *cbuf2; + cbuf = (unsigned char *)malloc(CBUFSIZE); + cbuf2 = (unsigned char *)malloc(CBUFSIZE); + if (!cbuf || !cbuf2) { + if (cbuf) (void)free((char *)cbuf); + if (cbuf2) (void)free((char *)cbuf2); + return 0; + } +#endif + + len = ustoeuc(src, srclen, cbuf, CBUFSIZE) - cbuf; + len = RkCvtZen(cbuf2, CBUFSIZE, cbuf, len); + if (len > 0) { + if (dst) { + len = euctous(cbuf2, len, dst, maxdst) - dst; + } + else { + len = euccharlen(cbuf2, len); + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + (void)free((char *)cbuf); + (void)free((char *)cbuf2); +#endif + return len; +} + +int RkwCvtNone (WCHAR_T *, int, WCHAR_T *, int); + +int +RkwCvtNone(WCHAR_T *dst, int maxdst, WCHAR_T *src, int srclen) +{ + int i; + int len = (maxdst < srclen) ? maxdst : srclen; + + if (dst) { + for (i = 0 ; i < len ; i++) { + *dst++ = *src++; + } + *dst = *src; + } + return len; +} +#endif diff --git a/src/add-ons/input_server/methods/canna/rk/ncache.c b/src/add-ons/input_server/methods/canna/rk/ncache.c new file mode 100644 index 0000000000..4c625eab18 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/ncache.c @@ -0,0 +1,326 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +/* +static char rcsid[]="$Id: ncache.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +*/ +#include "canna.h" +#include "RK.h" +#include "RKintern.h" + +#define NCHASH 101UL +#define hash(x) ((int)(((ulong)x)%NCHASH)) + +static struct ncache Nchash[NCHASH]; +static struct ncache Ncfree; + +inline void +ainserttop(struct ncache *p) +{ + p->nc_anext = Ncfree.nc_anext; + p->nc_aprev = &Ncfree; + Ncfree.nc_anext->nc_aprev = p; + Ncfree.nc_anext = p; +} + +inline void +ainsertbottom(struct ncache *p) +{ + p->nc_anext = &Ncfree; + p->nc_aprev = Ncfree.nc_aprev; + Ncfree.nc_aprev->nc_anext = p; + Ncfree.nc_aprev = p; +} + +inline void +aremove(struct ncache *p) +{ + p->nc_anext->nc_aprev = p->nc_aprev; + p->nc_aprev->nc_anext = p->nc_anext; + p->nc_anext = p->nc_aprev = p; +} + +inline void +hremove(struct ncache *p) +{ + p->nc_hnext->nc_hprev = p->nc_hprev; + p->nc_hprev->nc_hnext = p->nc_hnext; + p->nc_hnext = p->nc_hprev = p; +} + +static int flushCache(struct DM *dm, struct ncache *cache); + +int +_RkInitializeCache(int size) +{ + struct RkParam *sx = &SX; + int i; + + sx->maxcache = size; + if (!(sx->cache = (struct ncache *)calloc((unsigned)size, sizeof(struct ncache)))) + return -1; + for (i = 0; i < size ; i++) { + sx->cache[i].nc_anext = &sx->cache[i+1]; + sx->cache[i].nc_aprev = &sx->cache[i-1]; + sx->cache[i].nc_hnext = sx->cache[i].nc_hprev = &sx->cache[i]; + sx->cache[i].nc_count = 0; + }; + Ncfree.nc_anext = &sx->cache[0]; + sx->cache[sx->maxcache - 1].nc_anext = &Ncfree; + Ncfree.nc_aprev = &sx->cache[sx->maxcache - 1]; + sx->cache[0].nc_aprev = &Ncfree; + for (i = 0; i < NCHASH; i++) + Nchash[i].nc_hnext = Nchash[i].nc_hprev = &Nchash[i]; + return 0; +} + +void +_RkFinalizeCache(void) +{ + struct RkParam *sx = &SX; + + if (sx->cache) + free(sx->cache); + sx->cache = (struct ncache *)0; +} + +static int +flushCache(struct DM *dm, struct ncache *cache) +{ + if (cache->nc_word) { + if (dm && (cache->nc_flags & NC_DIRTY)) { + DST_WRITE(dm, cache); + }; + cache->nc_flags &= ~NC_DIRTY; + return 0; + }; + return -1; +} + +inline struct ncache +*newCache(struct DM *ndm, long address) +{ + struct ncache *newc; + + if ((newc = Ncfree.nc_anext) != &Ncfree) { + (void)flushCache(newc->nc_dic, newc); + aremove(newc); + hremove(newc); + newc->nc_dic = ndm; + newc->nc_word = (unsigned char *)NULL; + newc->nc_flags = 0; + newc->nc_address = address; + newc->nc_count = 0; + return(newc); + }; + return (struct ncache *)0; +} + +int +_RkRelease(void) +{ + struct ncache *newc; + + for (newc = Ncfree.nc_anext; newc != &Ncfree; newc = newc->nc_anext) { + if (!newc->nc_word || (newc->nc_flags & NC_NHEAP)) + continue; + (void)flushCache(newc->nc_dic, newc); + hremove(newc); + newc->nc_dic = (struct DM *)0; + newc->nc_flags = (unsigned short)0; + newc->nc_word = (unsigned char *)0; + newc->nc_address = (long)0; + newc->nc_count = (unsigned long)0; + return 1; + }; + return 0; +} + +/* +int +_RkEnrefCache(cache) + struct ncache *cache; +{ + static int count = 0; + fprintf(stderr, "_RkEnrefCache(0x%08x), %d\n", cache, ++count); + return(cache->nc_count++); +} +*/ + +void +_RkDerefCache(struct ncache *cache) +{ + struct DM *dm = cache->nc_dic; +/* + static int count = 0; + fprintf(stderr, "_RkDeref(0x%08x), %d\n", cache, ++count); +*/ + +// if (cache->nc_count <= 0) { +// _Rkpanic("wrong cache count %s %d#%d", +// dm ? dm->dm_dicname : "-", cache->nc_address, cache->nc_count); +// }; + + if (--cache->nc_count == 0) { + aremove(cache); + if (cache->nc_flags & NC_ERROR) { + ainserttop(cache); + } else { + ainsertbottom(cache); + }; + }; + return; +} + +void +_RkPurgeCache(struct ncache *cache) +{ + hremove(cache); + aremove(cache); + ainserttop(cache); +} + +void +_RkKillCache(struct DM *dm) +{ + struct ncache *cache; + int i; + + for (i = 0, cache = SX.cache; i < SX.maxcache; i++, cache++) { + if (dm == cache->nc_dic) { + (void)flushCache(dm, cache); + _RkPurgeCache(cache); + }; + }; +} + +#if defined(MMAP) || defined(WIN) +int +_RkDoInvalidateCache(long addr, unsigned long size) +{ + struct ncache *head, *cache, *tmp; + int i; + int found = 0; + + for(i = 0; i < NCHASH; i ++) { + head = &Nchash[i]; + for (cache = head->nc_hnext; cache != head; ) { + tmp = cache->nc_hnext; + if (cache->nc_address >= addr && + cache->nc_address < (long)(addr + size)) { + found = 1; + if (cache->nc_count) return(0); + + } + cache = tmp; + } + } + + if (found == 0) return(1); + + for(i = 0; i < NCHASH; i ++) { + head = &Nchash[i]; + for (cache = head->nc_hnext; cache != head; ) { + tmp = cache->nc_hnext; + if (cache->nc_address >= addr && + cache->nc_address < (long)(addr + size)) { + cache->nc_flags |= NC_ERROR; + hremove(cache); + aremove(cache); + ainserttop(cache); + } + cache = tmp; + } + } + return(1); +} +#endif + +struct ncache * +_RkFindCache(struct DM *dm, long addr) +{ + struct ncache *head, *cache; + + head = &Nchash[hash(addr)]; + for (cache = head->nc_hnext; cache != head; cache = cache->nc_hnext) + if (cache->nc_dic == dm && cache->nc_address == addr) + return cache; + return (struct ncache *)0; +} + +void +_RkRehashCache(struct ncache *cache, long addr) +{ + struct ncache *head; + + if ((head = &Nchash[hash(addr)]) != &Nchash[hash(cache->nc_address)]) { + hremove(cache); + cache->nc_hnext = head->nc_hnext; + cache->nc_hprev = head; + head->nc_hnext->nc_hprev = cache; + head->nc_hnext = cache; + }; + cache->nc_address = addr; +} + +struct ncache * +_RkReadCache(struct DM *dm, long addr) +{ + struct ncache *head, *cache; + + head = &Nchash[hash(addr)]; + for (cache = head->nc_hnext; cache != head; cache = cache->nc_hnext) { + if (cache->nc_dic == dm && cache->nc_address == addr) { + aremove(cache); + if (cache != head->nc_hnext) { + hremove(cache); + cache->nc_hnext = head->nc_hnext; + cache->nc_hprev = head; + head->nc_hnext->nc_hprev = cache; + head->nc_hnext = cache; + } + _RkEnrefCache(cache); + return(cache); + }; + }; + cache = newCache(dm, addr); + if (cache) { + if (DST_READ(dm, cache)) { + ainserttop(cache); + return (struct ncache *)0; + } else { + cache->nc_hnext = head->nc_hnext; + cache->nc_hprev = head; + head->nc_hnext->nc_hprev = cache; + head->nc_hnext = cache; + _RkEnrefCache(cache); + return(cache); + }; + } else { + return (struct ncache *)0; + }; +} diff --git a/src/add-ons/input_server/methods/canna/rk/ngram.c b/src/add-ons/input_server/methods/canna/rk/ngram.c new file mode 100644 index 0000000000..3f1e403759 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/ngram.c @@ -0,0 +1,978 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="$Id: ngram.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif + +#include +#include +#include +#include +#include +#include +#include + + +#include "RKintern.h" +// There is Exported Symbols !! +static char **gram_to_tab(struct RkKxGram *gram); +static WCHAR_T *skip_space(WCHAR_T *src); +static skip_until_space(WCHAR_T *src, WCHAR_T **next); +static int wstowrec(struct RkKxGram *gram, WCHAR_T *src, Wrec *dst, unsigned maxdst, unsigned *yomilen, unsigned *wlen, unsigned long *lucks); +static Wrec *fil_wc2wrec_flag(Wrec *wrec, unsigned *wreclen, unsigned ncand, WCHAR_T *yomi, unsigned ylen, unsigned left); +static struct TW *RkWcand2Wrec(Wrec *key, struct RkWcand *wc, int nc, unsigned long *lucks); + + +void +RkCloseGram(struct RkKxGram *gram) +{ + if (gram->ng_conj) + free(gram->ng_conj); + if (gram->ng_strtab) + free(gram->ng_strtab); + free(gram); +} + +static +char ** +gram_to_tab(struct RkKxGram *gram) +{ + char **top, *str; + int i; + + if (!(top = (char **) calloc(gram->ng_rowcol + 1, sizeof(char *)))) { + RkSetErrno(RK_ERRNO_ENOMEM); + return 0; + } + str = gram->ng_conj + (gram->ng_rowbyte * gram->ng_rowcol); + for (i = 0; i < gram->ng_rowcol; i++) { + top[i] = str; + str += strlen(str) + 1; + }; + top[gram->ng_rowcol] = (char *)0; + return top; +} + +/* RkGetGramSize -- gram_conj ¤ËÆþ¤ì¤Æ¤¤¤ë¥á¥â¥ê¤ÎÂ礭¤µ¤òÊÖ¤¹ */ +inline int +RkGetGramSize(struct RkKxGram *gram) +{ + char *str; + int i; + + str = gram->ng_conj + (gram->ng_rowbyte * gram->ng_rowcol); + for (i = 0; i < gram->ng_rowcol; i++) { + str += strlen(str) + 1; + } + return str - gram->ng_conj; +} + +struct RkKxGram * +RkReadGram(int fd) +{ + struct RkKxGram *gram = (struct RkKxGram *)0; + unsigned char l4[4]; + unsigned long sz, rc; + int errorres; + unsigned long size; + + RkSetErrno(RK_ERRNO_EACCES); + errorres = (read(fd, (char *)l4, 4) < 4 || (sz = L4TOL(l4)) < 5 + || read(fd, (char *)l4, 4) < 4 || (rc = L4TOL(l4)) < 1); + if (!errorres) { + gram = (struct RkKxGram *)calloc(1, sizeof(struct RkKxGram)); + RkSetErrno(RK_ERRNO_ENOMEM); + if (gram) { + gram->ng_conj = (char *)malloc((size_t)(sz - 4)); + if (gram->ng_conj) { + size = (unsigned long) read(fd, gram->ng_conj, (unsigned)(sz - 4)); + if (size <= (sz - 4)) { + gram->ng_rowcol = rc; + gram->ng_rowbyte = (gram->ng_rowcol + 7) / 8; + gram->ng_strtab = gram_to_tab(gram); + if (gram->ng_strtab) { + return gram; + } + } + else { + /* EMPTY */ + RkSetErrno(0); + } + free(gram->ng_conj); + } + free(gram); + } + } + return (struct RkKxGram *)0; +} + +struct RkKxGram * +RkOpenGram(char *mydic) +{ + struct RkKxGram *gram; + struct HD hd; + off_t off; + int lk; + int tmpres; + int fd; + + if ((fd = open(mydic, 0)) < 0) + return (struct RkKxGram *)0; + + for (off = 0, lk = 1; lk && _RkReadHeader(fd, &hd, off) >= 0;) { + off += hd.data[HD_SIZ].var; + if (!strncmp(".swd", + (char *)(hd.data[HD_DMNM].ptr + + strlen((char *)hd.data[HD_DMNM].ptr) - 4), + 4)) { + lk = 0; + + tmpres = lseek(fd, off, 0); + + if (tmpres < 0) { + lk = 1; + RkSetErrno(RK_ERRNO_EACCES); + } + break; + } + _RkClearHeader(&hd); + } + _RkClearHeader(&hd); + if (lk) { + close(fd); + return((struct RkKxGram *)0); + } + gram = RkReadGram(fd); + (void)close(fd); + return gram; +} + +struct RkKxGram * +RkDuplicateGram(struct RkKxGram *ogram) +{ + struct RkKxGram *gram = (struct RkKxGram *)0; + + gram = (struct RkKxGram *)calloc(1, sizeof(struct RkKxGram)); + if (gram) { + int siz = RkGetGramSize(ogram); + gram->ng_rowcol = ogram->ng_rowcol; + gram->ng_rowbyte = ogram->ng_rowbyte; + gram->ng_conj = (char *)malloc(siz); + if (gram->ng_conj) { + bcopy(ogram->ng_conj, gram->ng_conj, siz); + gram->ng_strtab = gram_to_tab(gram); + if (gram->ng_strtab) { + return gram; + } + free(gram->ng_conj); + } + free(gram); + } + RkSetErrno(RK_ERRNO_ENOMEM); + return (struct RkKxGram *)0; +} + +int +_RkWordLength(unsigned char *wrec) +{ + int wl; + + wl = ((wrec[0] << 5) & 0x20) | ((wrec[1] >> 3) & 0x1f); + if (wrec[0] & 0x80) + wl |= ((wrec[2] << 5) & 0x1fc0); + return(wl); +} + +int +_RkCandNumber(unsigned char *wrec) +{ + int nc; + + nc = (wrec)[1] & 0x07; + if (wrec[0] & 0x80) + nc |= ((wrec[3] << 3) & 0x0ff8); + return(nc); +} + +int +RkGetGramNum(struct RkKxGram *gram, char *name) +{ + int row; + int max = gram->ng_rowcol; + + if (gram->ng_strtab) { + for (row = 0; row < max; row++) { + if (!strcmp(gram->ng_strtab[row], (char *)name)) + return(row); + } + } + return(-1); +} + +static WCHAR_T * +skip_space(WCHAR_T *src) +{ + while (*src) { + if (!rk_isspace(*src)) + break; + src++; + } + return(src); +} + +static int +skip_until_space(WCHAR_T *src, WCHAR_T **next) +{ + int len = 0; + + while (*src) { + if (rk_isspace(*src)) { + break; + } + else if (*src == RK_ESC_CHAR) { + if (!*++src) { + break; + } + } + src++; + len++; + } + *next = src; + return len; +} + +static int +wstowrec(struct RkKxGram *gram, WCHAR_T *src, Wrec *dst, unsigned maxdst, unsigned *yomilen, unsigned *wlen, unsigned long *lucks) +{ + Wrec *odst = dst; + WCHAR_T *yomi, *kanji; + int klen, ylen, ncand, row = 0, step = 0, spec = 0; + unsigned frq; + + lucks[0] = lucks[1] = 0L; + ncand = 0; + *yomilen = *wlen = 0; + yomi = skip_space(src); + ylen = skip_until_space(yomi, &src); + if (!ylen || ylen > RK_LEFT_KEY_WMAX) + return(0); + while (*src) { + if (*src == (WCHAR_T)'\n') + break; + if (*(src = skip_space(src)) == (WCHAR_T)'#') { + src = RkParseGramNum(gram, src, &row); + if (!is_row_num(gram, row)) + break; + if (*src == (WCHAR_T)'#') + continue; + if (*src == (WCHAR_T)'*') { + for (src++, frq = 0; (WCHAR_T)'0' <= *src && *src <= (WCHAR_T)'9'; src++) + frq = 10 * frq + *src - (WCHAR_T)'0'; + if (step < 2 && frq < 6000) + lucks[step] = _RkGetTick(0) - frq; + } + src = skip_space(src); + spec++; + } + if (!spec) + return(0); + kanji = src; + klen = skip_until_space(src, &src); + if (klen == 1 && *kanji == (WCHAR_T)'@') { + klen = ylen; + kanji = yomi; + } + if (!klen || klen > RK_LEN_WMAX) + return(0); + if (dst + klen * sizeof(WCHAR_T) > odst + maxdst) + return(0); + step++; + *dst++ = (Wrec)(((klen << 1) & 0xfe) | ((row >> 8) & 0x01)); + *dst++ = (Wrec)(row & 0xff); + for (; klen > 0 ; klen--, kanji++) { + if (*kanji == RK_ESC_CHAR) { + if (!*++kanji) { + break; + } + } + *dst++ = (Wrec)((*kanji >> 8) & 0xff); + *dst++ = (Wrec)(*kanji & 0xff); + } + ncand++; + } + if (ncand) { + *wlen = (unsigned)(dst - odst); + *yomilen= ylen; + } + return ncand; +} + +static Wrec * +fil_wc2wrec_flag(Wrec *wrec, unsigned *wreclen, unsigned ncand, WCHAR_T *yomi, unsigned ylen, unsigned left) +{ + Wrec *owrec = wrec; + WCHAR_T tmp; + int wlen = *wreclen, i; + + if ((ncand > 7) || (wlen > 0x3f)) { + wlen += 2; + *wrec = 0x80; + } else { + *wrec = 0; + } + *wrec++ |= (Wrec)(((left << 1) & 0x7e) | ((wlen >> 5) & 0x01)); + *wrec++ = (Wrec)(((wlen << 3) & 0xf8) | (ncand & 0x07)); + if (*owrec & 0x80) { + *wrec++ = (Wrec)(((wlen >> 5) & 0xfe) | (ncand >> 11) & 0x01); + *wrec++ = (Wrec)((ncand >> 3) & 0xff); + } + if (left) { + int offset = ylen - left; /* ¥Ç¥£¥ì¥¯¥È¥êÉô¤ËÆþ¤Ã¤Æ¤¤¤ëÆÉ¤ß¤ÎŤµ */ + if (offset < 0) + return((Wrec *)0); + for (i = 0 ; i < offset ; i++) { + if (*yomi == RK_ESC_CHAR) { + yomi++; + } + yomi++; + } + for (i = 0 ; i < (int)left ; i++) { + tmp = *yomi++; + if (tmp == RK_ESC_CHAR) { + tmp = *yomi++; + } + tmp = uniqAlnum(tmp); + *wrec++ = (tmp >> 8) & 0xff; + *wrec++ = tmp & 0xff; + } + } + *wreclen = wlen; + return wrec; +} + +inline Wrec * +fil_wrec_flag(Wrec *wrec, unsigned *wreclen, unsigned ncand, Wrec *yomi, unsigned ylen, unsigned left) +{ + Wrec *owrec = wrec; + WCHAR_T tmp; + int wlen = *wreclen, i; + + if ((ncand > 7) || (wlen > 0x3f)) { + wlen += 2; + *wrec = 0x80; + } else { + *wrec = 0; + } + *wrec++ |= (Wrec)(((left << 1) & 0x7e) | ((wlen >> 5) & 0x01)); + *wrec++ = (Wrec)(((wlen << 3) & 0xf8) | (ncand & 0x07)); + if (*owrec & 0x80) { + *wrec++ = (Wrec)(((wlen >> 5) & 0xfe) | (ncand >> 11) & 0x01); + *wrec++ = (Wrec)((ncand >> 3) & 0xff); + } + if (left) { + if (ylen < left) + return((Wrec *)0); + yomi += (ylen - left) * sizeof(WCHAR_T); + for (i = 0; i < (int)left; i++) { + tmp = uniqAlnum((WCHAR_T)((yomi[2*i] << 8) | yomi[2*i + 1])); + *wrec++ = (tmp >> 8) & 0xff; + *wrec++ = tmp & 0xff; + } + } + *wreclen = wlen; + return wrec; +} + +Wrec * +RkParseWrec(struct RkKxGram *gram, WCHAR_T *src, unsigned left, unsigned char *dst, unsigned maxdst) +{ + unsigned wreclen, wlen, ylen, nc; + unsigned long lucks[2]; + unsigned char *ret = (unsigned char *)0; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + unsigned char localbuffer[RK_WREC_BMAX]; +#else + unsigned char *localbuffer = (unsigned char *)malloc(RK_WREC_BMAX); + if (!localbuffer) { + return ret; + } +#endif + + if (!(nc = wstowrec(gram, src, localbuffer, RK_WREC_BMAX/sizeof(WCHAR_T), + &ylen, &wlen, lucks))) { + /* I don't know why the RK_WREC_BMAX should be divided by sizeof(WCHAR_T). + the divider should be removed. 1996.6.5 kon */ + ; /* return 0 */ + } + else if ((wreclen = 2 + (left * sizeof(WCHAR_T)) + wlen) > maxdst) { + ; /* return (unsigned char *)0; */ + } + else if (left > ylen) { + ; /* return (unsigned char *)0; */ + } + else { + dst = fil_wc2wrec_flag(dst, &wreclen, nc, src, ylen, left); + if (dst) { + memcpy((char *)dst, (char *)localbuffer, wlen); + ret = dst + wlen; + } + else { + ret = dst; + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(localbuffer); +#endif + return ret; +} + +Wrec * +RkParseOWrec(struct RkKxGram *gram, WCHAR_T *src, unsigned char *dst, unsigned maxdst, unsigned long *lucks) +{ + unsigned wreclen, wlen, ylen, nc; + unsigned char *ret = (unsigned char *)0; + Wrec *localbuffer = (Wrec *)malloc(sizeof(Wrec) * RK_WREC_BMAX); + if (!localbuffer) { + return ret; + } + + nc = wstowrec(gram, src, localbuffer, RK_WREC_BMAX/sizeof(WCHAR_T), + &ylen, &wlen, lucks); + /* I don't know why the RK_WREC_BMAX should be divided by sizeof(WCHAR_T). + the divider should be removed. 1996.6.5 kon */ + + if (nc) { + wreclen = 2 + (ylen * sizeof(WCHAR_T)) + wlen; + if (wreclen <= maxdst) { + dst = fil_wc2wrec_flag(dst, &wreclen, nc, src, ylen, ylen); + if (dst) { + memcpy((char *)dst, (char *)localbuffer, wlen); + ret = dst + wlen; + }else{ + ret = dst; + } + } + } + free(localbuffer); + return ret; +} + +WCHAR_T * +RkParseGramNum(struct RkKxGram *gram, WCHAR_T *src, int *row) +{ + int rnum; + WCHAR_T *ws; + unsigned char *str; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + WCHAR_T wcode[RK_LINE_BMAX]; + unsigned char code[RK_LINE_BMAX]; +#else + WCHAR_T *wcode = (WCHAR_T *)malloc(sizeof(WCHAR_T) * RK_LINE_BMAX); + unsigned char *code = (unsigned char *)malloc(RK_LINE_BMAX); + if (!wcode || !code) { + if (wcode) free(wcode); + if (code) free(code); + return src; + } +#endif + + code[0] = 0; + *row = -1; + if (*src++ != (WCHAR_T)'#') { + src--; + } + else if (rk_isdigit(*src)) { + for (ws = wcode; *src; *ws++ = *src++) { + if (!rk_isdigit(*src) || rk_isspace(*src)) + break; + } + *ws = (WCHAR_T)0; + str = ustoeuc(wcode, (int) (ws - wcode), code, RK_LINE_BMAX); + code[str - code] = (unsigned char)0; + rnum = atoi((char *)code); + if (is_row_num(gram, rnum)) + *row = rnum; + } + else if (rk_isascii(*src)) { + for (ws = wcode; *src; *ws++ = *src++) { + if (!rk_isascii(*src) || rk_isspace(*src) || *src == (WCHAR_T)'*') + break; + } + *ws = (unsigned char)0; + str = ustoeuc(wcode, (int) (ws - wcode), code, RK_LINE_BMAX); + code[str - code] = (unsigned char)0; + rnum = RkGetGramNum(gram, (char *)code); + if (is_row_num(gram, rnum)) + *row = rnum; + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(wcode); + free(code); +#endif + return src; +} + +unsigned char * +RkGetGramName(struct RkKxGram *gram, int row) +{ + if (gram && gram->ng_strtab) + if (is_row_num(gram, row)) + return (unsigned char *)gram->ng_strtab[row]; + return 0; +} + +WCHAR_T * +RkUparseGramNum(struct RkKxGram *gram, int row, WCHAR_T *dst, int maxdst) +{ + unsigned char *name, *p; + + name = (unsigned char *)RkGetGramName(gram, row); + if (name) { + int len = strlen((char *)name); + if (len + 1 < maxdst) { + *dst++ = (WCHAR_T)'#'; + p = name; + while (*p) { + *dst++ = (WCHAR_T)*p++; + } + *dst = (WCHAR_T)0; + return dst; + } + return (WCHAR_T *)0; + } else { + int keta, uni, temp = row; + + for (keta = 1, uni = 1; temp > 9; keta++) { + temp /= 10; + uni *= 10; + } + if (dst + keta + 1 < (dst + maxdst)) { + *dst++ = '#'; + while (keta--) { + temp = row / uni; + *dst++ = ('0' + temp); + row -= temp * uni; + uni /= 10; + } + *dst = (WCHAR_T)0; + return dst; + } + return (WCHAR_T *)0; + } +} + +int +_RkRowNumber(unsigned char *wrec) +{ + int row; + + row = (int)wrec[1]; + if (wrec[0] & 0x01) + row += 256; + return row; +} + +WCHAR_T * +_RkUparseWrec(struct RkKxGram *gram, Wrec *src, WCHAR_T *dst, int maxdst, unsigned long *lucks, int add) +{ + unsigned long luck = _RkGetTick(0), val; + unsigned char *wrec = src; + int num, ncnd, ylen, row, oldrow, i, l, oh = 0; + WCHAR_T *endp = dst + maxdst, *endt, luckw[5], wch; + + endt = (WCHAR_T *)0; + ylen = (*wrec >> 1) & 0x3f; + ncnd = _RkCandNumber(wrec); + if (*wrec & 0x80) + wrec += 2; + wrec += 2; + for (i = 0; i < ylen; i++) { + if (endp <= dst) + return(endt); + wch = (WCHAR_T)((wrec[0] << 8) | wrec[1]); + if (wch == RK_ESC_CHAR || wch == (WCHAR_T)' ' || wch == (WCHAR_T)'\t') { + *dst++ = RK_ESC_CHAR; + } + *dst++ = wch; + wrec += 2; + } + oldrow = -1; + for (i = 0; i < ncnd; i++, oh = 0) { + unsigned clen; + + clen = (*wrec >> 1) & 0x7f; + row = _RkRowNumber(wrec); + wrec += NW_PREFIX; + if (oldrow != row) { + *dst++ = (WCHAR_T)' '; + if (!(dst = RkUparseGramNum(gram, (int)row, dst, (int)(endp - dst)))) + break; + oldrow = row; + if (endp <= dst) + break; + oh++; + } + if (add && i < 2 && lucks[i]) { + if (!oh) { + *dst++ = (WCHAR_T)' '; + if (!(dst = RkUparseGramNum(gram, (int)row, dst, (int)(endp - dst)))) + break; + oh++; + } + if (endp <= dst) + break; + if (luck - lucks[i] < (unsigned long)6000) { + *dst++ = (WCHAR_T)'*'; + val = luck - lucks[i]; + for (l = 0; val && l < 5; l++, val /= 10) { + num = val % 10; + luckw[l] = (WCHAR_T)(num + '0'); + } + if (!l) { + luckw[l] = (WCHAR_T)'0'; + l++; + } + if (endp <= dst + l + 1) + break; + while (l) + *dst++ = luckw[--l]; + } + } + if (endp <= dst) + break; + *dst++ = (WCHAR_T)' '; + if (clen != 0) { + if (endp <= (dst + clen + 1)) + break; + while (clen--) { + wch = bst2_to_s(wrec); + if (wch == RK_ESC_CHAR || wch == (WCHAR_T)' ' || wch == (WCHAR_T)'\t') { + *dst++ = RK_ESC_CHAR; + } + *dst++ = wch; + wrec += sizeof(WCHAR_T); + } + } else { + if (endp <= dst) + break; + *dst++ = (WCHAR_T)'@'; + } + if (dst < endp - 1) + endt = dst; + } + + if (add && i == ncnd || !add && endt && endt < endp - 1) { + *endt = (WCHAR_T)0; + return(endt); + } + return((WCHAR_T *)0); +} + +WCHAR_T * +RkUparseWrec(struct RkKxGram *gram, Wrec *src, WCHAR_T *dst, int maxdst, unsigned long *lucks) +{ + return(_RkUparseWrec(gram, src, dst, maxdst, lucks, 0)); +} + +struct TW * +RkCopyWrec(struct TW *src) +{ + struct TW *dst; + unsigned int sz; + + sz = _RkWordLength(src->word); + if (sz) { + dst = (struct TW *)malloc(sizeof(struct TW)); + if (dst) { + dst->word = (unsigned char *)malloc(sz); + if (dst->word) { + memcpy(dst->word, src->word, sz); + dst->lucks[0] = src->lucks[0]; + dst->lucks[1] = src->lucks[1]; + } else { + free(dst); + dst = (struct TW *)0; + } + } + } + return(dst); +} + +int +RkScanWcand(Wrec *wrec, struct RkWcand *word, int maxword) +{ + int i, l, nc, ns = 0; + + nc = _RkCandNumber(wrec); + l = (*wrec >> 1) & 0x3f; + if (*wrec & 0x80) + wrec += 2; + wrec += 2 + l * 2; + for (i = 0; i < nc; i++) { + int rcnum; + int klen; + + klen = (*wrec >> 1) & 0x7f; + rcnum = _RkRowNumber(wrec); + if (i < maxword) { + word[i].addr = wrec; + word[i].rcnum = rcnum; + word[i].klen = klen; + ns++; + }; + wrec += 2 * klen + 2; + } + return ns; +} + + +int +RkUniqWcand(struct RkWcand *wc, int nwc) +{ + int i, j, nu; + Wrec *a; + unsigned k, r; + + for (nu = 0, j = 0; j < nwc; j++) { + k = wc[j].klen; + r = wc[j].rcnum; + a = wc[j].addr + NW_PREFIX; + for (i = 0; i < nu; i++) + if (wc[i].klen == k && wc[i].rcnum == (short)r && + !memcmp(wc[i].addr + NW_PREFIX, a, 2 * k)) + break; + if (nu <= i) + wc[nu++] = wc[j]; + } + return(nu); +} + +static struct TW * +RkWcand2Wrec(Wrec *key, struct RkWcand *wc, int nc, unsigned long *lucks) +{ + int i, j; + unsigned ylen, sz; + struct TW *tw = (struct TW *)0; + Wrec *wrec, *a; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + unsigned char localbuffer[RK_WREC_BMAX], *dst = localbuffer; +#else + unsigned char *localbuffer, *dst; + localbuffer = (unsigned char *)malloc(RK_WREC_BMAX); + if (!localbuffer) { + return tw; + } + dst = localbuffer; +#endif + + if ((ylen = (*key >> 1) & 0x3f) <= 0) + ; /* return tw; */ + else if (nc <= 0 || RK_CAND_NMAX < nc) + ; /* return tw; */ + else { + for (i = sz = 0; i < nc; i++) { + if (wc[i].rcnum > 511) + return(tw); + if (wc[i].klen > NW_LEN) + return(tw); + sz += (wc[i].klen * 2) + NW_PREFIX; + }; + if (*key & 0x80) + key += 2; + key += 2; + sz += 2 + ylen * 2; + tw = (struct TW *)malloc(sizeof(struct TW)); + if (tw) { + dst = fil_wrec_flag(dst, &sz, (unsigned)nc, key, ylen, ylen); + if (dst) { + wrec = (Wrec *)malloc((unsigned)(sz)); + if (wrec) { + memcpy((char *)wrec, (char *)localbuffer, + (size_t)(dst - localbuffer)); + dst = wrec + (dst - localbuffer); + for ( i = 0; i < nc; i++ ) { + *dst++ = (Wrec)(((wc[i].klen << 1) & 0xfe) + | ((wc[i].rcnum >> 8) & 0x01)); + *dst++ = (Wrec)(wc[i].rcnum & 0xff); + a = wc[i].addr + NW_PREFIX; + for (j = wc[i].klen * 2; j--;) + *dst++ = *a++; + } + tw->lucks[0] = lucks[0]; + tw->lucks[1] = lucks[1]; + tw->word = wrec; + } else { + free(tw); + tw = (struct TW *)0; + } + } + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(localbuffer); +#endif + return tw; +} + +int +RkUnionWcand(struct RkWcand *wc1, int nc1, int wlen1, struct RkWcand *wc2, int nc2) +{ + int i, j, nu; + Wrec *a; + unsigned k, r; + + nc1 = RkUniqWcand(wc1, nc1); + nu = nc1; + for (j = 0; j < nc2 && nu < wlen1; j++) { + k = wc2[j].klen; + r = wc2[j].rcnum; + a = wc2[j].addr + NW_PREFIX; + for (i = 0; i < nu; i++) { + if (wc1[i].klen == k && wc1[i].rcnum == (short)r && + !memcmp(wc1[i].addr + NW_PREFIX, a, 2 * k)) + break; + } + if (nu <= i) + wc1[nu++] = wc2[j]; + } + return(nu); +} + +int +RkSubtractWcand(struct RkWcand *wc1, int nc1, struct RkWcand *wc2, int nc2, unsigned long *lucks) +{ + int i, j, nu; + Wrec *a; + unsigned k, r; + + nc1 = RkUniqWcand(wc1, nc1); + for (nu = i = 0; i < nc1; i++) { + k = wc1[i].klen; + r = wc1[i].rcnum; + a = wc1[i].addr + NW_PREFIX; + for (j = 0; j < nc2; j++) { + if (wc2[j].klen == k && wc2[j].rcnum == (short)r && + !memcmp(wc2[j].addr + NW_PREFIX, a, 2 * k)) + break; + } + if (nc2 <= j) { + if (nu == 0 && i == 1) { + lucks[0] = lucks[1]; + lucks[1] = 0L; + } + wc1[nu++] = wc1[i]; + } else { + if (nu < 2) { + lucks[0] = lucks[1]; + lucks[1] = 0L; + } + } + } + return(nu); +} + +struct TW * +RkSubtractWrec(struct TW *tw1, struct TW *tw2) +{ + struct RkWcand *wc1, *wc2; + int nc1, nc2, nc, ylen; + Wrec *a, *b, *wrec1 = tw1->word, *wrec2 = tw2->word; + + wc1 = (struct RkWcand *) malloc(sizeof(struct RkWcand) * RK_CAND_NMAX); + if (!wc1) return((struct TW *)0); + wc2 = (struct RkWcand *) malloc(sizeof(struct RkWcand) * RK_CAND_NMAX); + if (!wc2) { + free(wc1); + return((struct TW *)0); + } + + if ((ylen = (*wrec1 >> 1) & 0x3f) != ((*wrec2 >> 1) & 0x3f)) { + free(wc1); free(wc2); + return((struct TW *)0); + } + if (*(a = wrec1) & 0x80) + a += 2; + a += 2; + if (*(b = wrec2) & 0x80) + b += 2; + b += 2; + while (ylen--) { + if (*a++ != *b++ || *a++ != *b++) { + free(wc1); free(wc2); + return((struct TW *)0); + } + } + nc1 = RkScanWcand(wrec1, wc1, RK_CAND_NMAX); + nc2 = RkScanWcand(wrec2, wc2, RK_CAND_NMAX); + nc = RkSubtractWcand(wc1, nc1, wc2, nc2, tw1->lucks); + if (nc <= 0) { + free(wc1); free(wc2); + return((struct TW *)0); + } + else { + struct TW *wc3 = RkWcand2Wrec(wrec1, wc1, nc, tw1->lucks); + free(wc1); free(wc2); + return(wc3); + } +} + +struct TW * +RkUnionWrec(struct TW *tw1, struct TW *tw2) +{ + struct RkWcand *wc1, *wc2; + Wrec *wrec2 = tw2->word; + Wrec *wrec1 = tw1->word; + int nc1, nc2, nc; + + wc1 = (struct RkWcand *) malloc(sizeof(struct RkWcand) * RK_CAND_NMAX); + if (!wc1) return((struct TW *)0); + wc2 = (struct RkWcand *) malloc(sizeof(struct RkWcand) * RK_CAND_NMAX); + if (!wc2) { + free(wc1); + return((struct TW *)0); + } + + if (((*wrec1 >> 1) & 0x3f) != ((*wrec2 >> 1) & 0x3f)) { + free(wc1); free(wc2); + return (struct TW *)0; + } + nc1 = RkScanWcand(wrec1, wc1, RK_CAND_NMAX); + nc2 = RkScanWcand(wrec2, wc2, RK_CAND_NMAX); + nc = RkUnionWcand(wc1, nc1, RK_CAND_NMAX, wc2, nc2); + if (RK_CAND_NMAX < nc) { + free(wc1); free(wc2); + return (struct TW *)0; + } + else { + struct TW *wc3 = RkWcand2Wrec(wrec1, wc1, nc, tw1->lucks); + free(wc1); free(wc2); + return(wc3); + } +} + + diff --git a/src/add-ons/input_server/methods/canna/rk/nword.c b/src/add-ons/input_server/methods/canna/rk/nword.c new file mode 100644 index 0000000000..ee2550c50e --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/nword.c @@ -0,0 +1,2051 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/************************************************************************/ +/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 +/************************************************************************/ + + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcsid[]="$Id: nword.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif + +/* LINTLIBRARY */ +#include "RKintern.h" + +#define rk_debug(file, fmt, a, b, c) + +static struct nword *allocWord(struct nstore *st, int bb); +static void derefWord(struct nword *word); +static void killWord(struct nstore *st, struct nword *word); +static void freeWord(struct nstore *st, struct nword *word); +static int cvtNum(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format); +static int cvtAlpha(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format); +static int cvtHira(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format); +static int cvtLit(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format, unsigned long mode); +static void cancelNVE(struct NV *nv, struct NVE *p); +static int parseWord(struct RkContext *cx, int yy, int ys, int ye, int iclass, struct nword *xqh[], int maxclen, int doflush, int douniq); +static int doParse(struct RkContext *cx, int yy, int ys, int ye, struct nword *xqh[], int maxclen, int doflush, int douniq); +static struct nword *height2list(struct nword *height[], int maxclen); +static void list2height(struct nword *height[], int maxclen, struct nword *parse); +static void storeBun(struct RkContext *cx, int yy, int ys, int ye, struct nbun *bun); +static void evalSplit(struct nword *suc, struct splitParm *ul); +static int calcSplit(struct RkContext *cx, int yy, struct nword *top, struct nqueue xq[], int maxclen, int flush); +static void parseQue(struct RkContext *cx, int maxq, int yy, int ys, int ye, int doflush); +static int IsStableQue(struct RkContext *cx, int c, int doflush); +static int Que2Bun(struct RkContext *cx, int yy, int ys, int ye, int doflush); +static void doLearn(struct RkContext *cx, struct nword *thisW); + +inline void +usncopy(WCHAR_T *dst, WCHAR_T *src, int len) +{ + memcpy(dst, src, len * sizeof(WCHAR_T)); +} + +inline void +clearWord(struct nword *w, int bb) +{ + if (w) { + w->nw_cache = (struct ncache *)0; + w->nw_rowcol = bb; /* ʸÀá */ + w->nw_klen = w->nw_ylen = 0; + w->nw_class = ND_EMP; + w->nw_flags = 0; + w->nw_lit = 0; + w->nw_prio = 0L; + w->nw_left = w->nw_next = (struct nword *)0; + w->nw_kanji = (Wrec *)0; + } +} + +/*ARGSUSED*/ +inline void +setWord(struct nword *w, int rc, int lit, WCHAR_T *yomi, int ylen, Wrec *kanji, int klen, int bb) +{ + clearWord(w, bb); + w->nw_rowcol = rc; + w->nw_klen = klen; + w->nw_ylen = ylen; + w->nw_class = 0; + w->nw_flags = 0; + w->nw_lit = lit; + w->nw_kanji = kanji; +} + +/* allocWord + * allocate a fresh word + */ +/*ARGSUSED*/ +static +struct nword * +allocWord(struct nstore *st, int bb) +{ +struct nword *new_word; +const size_t NW_PAGESIZE = 1024; + + if (!SX.word) { + struct nword *new_page; + int i; + new_page = (struct nword *)malloc(sizeof(struct nword)*NW_PAGESIZE); + if (new_page) { + SX.page_in_use++; + new_page[0].nw_next = SX.page; + SX.page = &new_page[0]; + SX.word = &new_page[1]; + for (i = 1; i + 1 < NW_PAGESIZE; i++) + new_page[i].nw_next = &new_page[i + 1]; + new_page[i].nw_next = (struct nword *)0; + }; + }; + new_word = SX.word; + if (new_word) { + SX.word = new_word->nw_next; + clearWord(new_word, bb); + st->word_in_use++; + SX.word_in_use++; + }; + return new_word; +} + +static void +derefWord(struct nword *word) +{ + for (; word; word = word->nw_next) + if (word->nw_cache) + (void)_RkDerefCache(word->nw_cache); +} + +/*ARGSUSED*/ +static void +killWord(struct nstore *st, struct nword *word) +{ + struct nword *p, *q; + + if (word) { + for (p = q = word; p; q = p, p = p->nw_next) { + if (!p->nw_cache && p->nw_kanji) { + _Rkpanic("killWord this would never happen addr ", 0, 0, 0); + free(p->nw_kanji); + }; + st->word_in_use--; + SX.word_in_use--; + } + q->nw_next = SX.word; + SX.word = word; + } +} + +static void +freeWord(struct nstore *st, struct nword *word) +{ + derefWord(word); + killWord(st, word); +} + +void +_RkFreeBunq(struct nstore *st) +{ + struct nbun *bunq = &st->bunq[st->curbun]; + + freeWord(st, bunq->nb_cand); + bunq->nb_cand = (struct nword *)0; + bunq->nb_yoff = 0; + bunq->nb_curlen = bunq->nb_maxcand = bunq->nb_curcand = 0; + bunq->nb_flags = (unsigned short)0; + return; +} + +extern unsigned searchRut(); +extern int entryRut(); + +inline +struct nword * +concWord(struct nstore *st, struct nword *p, struct nword *q, int loc, int bb) +{ + struct nword conc; + struct nword *pq; + struct nword *t; + int count; + +/* check limit conditions */ + count = 0; + for (t = p; t; t = t->nw_left) + count++; + if (((unsigned long)(p->nw_klen + q->nw_klen) > RK_LEN_WMAX) || + ((unsigned long)(p->nw_ylen + q->nw_ylen) > RK_LEN_WMAX) || + (count >= RK_CONC_NMAX)) + return (struct nword *)0; +/* create a concatinated word temoprally */ + conc = *q; + conc.nw_klen += p->nw_klen; + conc.nw_ylen += p->nw_ylen; +#ifdef FUJIEDA_HACK + conc.nw_flags = p->nw_flags&(NW_PRE|NW_SUC|NW_SWD|NW_DUMMY); +#else + conc.nw_flags = p->nw_flags&(NW_PRE|NW_SUC|NW_SWD); +#endif + conc.nw_prio = p->nw_prio; + conc.nw_next = (struct nword *)0; + conc.nw_left = p; + switch(q->nw_class) { +/* kakko, kutouten ha setuzoku kankei ni eikyou sinai */ + case ND_OPN: + case ND_CLS: + conc.nw_rowcol = p->nw_rowcol; + if (p->nw_class != ND_EMP) { + conc.nw_class = p->nw_class; + conc.nw_flags = p->nw_flags; + } else { + conc.nw_class = q->nw_class; + conc.nw_flags = q->nw_flags; + }; + break; + case ND_PUN: + /* avoid punctionations where prohibited */ + if (!CanSplitWord(p)) + return (struct nword *)0; + /* don't remove loc check or you get stuck when a punctionation comes */ + if (loc > 0 && p->nw_class == ND_EMP) + return (struct nword *)0; + conc.nw_rowcol = p->nw_rowcol; + conc.nw_class = ND_SWD; + break; + case ND_MWD: + conc.nw_flags |= NW_MWD; +#ifdef FUJIEDA_HACK + conc.nw_flags |= (q->nw_flags & NW_DUMMY); +#endif + conc.nw_prio = q->nw_prio; + break; + case ND_SWD: + if (!(conc.nw_flags&NW_SWD)) + conc.nw_flags |= NW_SWD; + break; + case ND_PRE: + conc.nw_flags |= NW_PRE; + break; + case ND_SUC: + conc.nw_flags |= NW_SUC; + break; + }; +/* cache no sanshoudo wo kousinn suru */ + pq = allocWord(st, bb); + if (pq) { + *pq = conc; + p->nw_flags |= NW_FOLLOW; + if (pq->nw_cache) + _RkEnrefCache(pq->nw_cache); + }; + return pq; +} + +/* clearQue + * clear word tree queue + */ +inline void +clearQue(struct nqueue *xq) +{ + xq->tree = (struct nword *)0; + xq->maxlen = 0; + xq->status = 0; +} +/* RkFreeQue + * free word tree stored in [s, e) + */ +void +_RkFreeQue(struct nstore *st, int s, int e) +{ + struct nqueue *xq = st->xq; + + while (s < e) { + if (xq[s].tree) + freeWord(st, xq[s].tree); + clearQue(&xq[s]); + s++; + }; +} + +/* + * Literal + */ +inline +int +cvtNum(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format) +{ + return RkwCvtSuuji(dst, maxdst, src, maxsrc, format - 1); +} + +inline int +cvtAlpha(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format) +{ + switch(format) { +#ifdef ALPHA_CONVERSION + case 1: return RkwCvtZen(dst, maxdst, src, maxsrc); + case 2: return RkwCvtHan(dst, maxdst, src, maxsrc); + case 3: return -1; +#else + case 1: return RkwCvtNone(dst, maxdst, src, maxsrc); + case 2: return -1; +#endif + default: return 0; + } +} + +inline int +cvtHira(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format) +{ + switch(format) { + case 1: return RkwCvtHira(dst, maxdst, src, maxsrc); + case 2: return RkwCvtKana(dst, maxdst, src, maxsrc); + default: return 0; + } +} + +static +int +cvtLit(WCHAR_T *dst, int maxdst, WCHAR_T *src, int maxsrc, int format, unsigned long mode) +{ + switch(format >> 4) { + case LIT_NUM: + if (mode & RK_MAKE_KANSUUJI) + return cvtNum(dst, maxdst, src, maxsrc, format&15); + else + return RkwCvtNone(dst, maxdst, src, maxsrc); + case LIT_ALPHA: return cvtAlpha(dst, maxdst, src, maxsrc, format&15); + case LIT_HIRA: return cvtHira(dst, maxdst, src, maxsrc, format&15); + default: return 0; + } +} + +/* setLit + * create the literals as many as the context requires + */ +inline +struct nword * +setLit(struct RkContext *cx, struct nword *word, int maxword, int rc, WCHAR_T *src, int srclen, int format) +{ + struct nword *w = word; + int dstlen; + unsigned long mode; + + if (!cx->litmode) + return 0; + for (mode = cx->litmode[format]; mode; mode >>= RK_XFERBITS) + if (w < word + maxword) { + int code = MAKELIT(format, mode&RK_XFERMASK); + + dstlen = cvtLit((WCHAR_T *)0, 9999, src, srclen, code, (unsigned long)cx->concmode); + if (0 < dstlen && dstlen <= RK_LEN_WMAX) + setWord(w++, rc, code, src, srclen, (Wrec *)0, dstlen, cx->gram->P_BB); + if (dstlen < 0) + setWord(w++, rc, code, src, srclen, (Wrec *)0, srclen, cx->gram->P_BB); + } + return (struct nword *) w; +} + +#define READWORD_MAXCACHE 128 +inline +struct nword * +readWord(struct RkContext *cx, int yy, int ys, int ye, int iclass, struct nword *nword, int maxword, int doflush, int douniq) +{ + WCHAR_T *key = cx->store->yomi + yy; + struct nword *wrds; + struct MD *head = cx->md[iclass], *md; + int maxcache = READWORD_MAXCACHE; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + unsigned permutation[RK_CAND_NMAX]; + unsigned char *candidates[RK_CAND_NMAX]; + struct nread nread[READWORD_MAXCACHE]; +#else + unsigned *permutation; + unsigned char **candidates; + struct nread *nread; + + permutation = (unsigned *)malloc(sizeof(unsigned) * RK_CAND_NMAX); + candidates = (unsigned char **) + malloc(sizeof(unsigned char *) * RK_CAND_NMAX); + nread = (struct nread *)malloc(sizeof(struct nread) * READWORD_MAXCACHE); + if (!permutation || !candidates || !nread) { + if (permutation) free(permutation); + if (candidates) free(candidates); + if (nread) free(nread); + return nword; + } +#endif + + wrds = nword; + for (md = head->md_next; md != head; md = md->md_next) { + struct DM *dm = md->md_dic; + struct DM *qm = md->md_freq; + struct nword *pp, *qq; + int c, nc, num, cf = 0, nl; + + if (maxword <= 0) + break; + if (!dm) + continue; + if (qm && !qm->dm_qbits) + qm = (struct DM *)0; + nc = DST_SEARCH(cx, dm, key, ye, nread, maxcache, &cf); + for (c = 0; c < nc; c++) { + struct nread *thisRead = nread + c; + struct ncache *thisCache = thisRead->cache; + unsigned char *wp = thisCache->nc_word; + unsigned long offset; + int nk, cnt = 1; + unsigned long csnb; + int bitSize; + + nk = _RkCandNumber(wp); + nl = (*wp >> 1) & 0x3f; + if (!doflush && (cf || thisRead->nk > ye || thisRead->nk > RK_KEY_WMAX)) + cx->poss_cont++; + if (*wp & 0x80) + wp += 2; + wp += 2 + nl *2; + csnb = thisRead->csn; + offset = thisRead->offset; + if (ys < thisRead->nk && thisRead->nk <= ye && thisRead->nk <= RK_KEY_WMAX) { + for (num = 0; num < nk; num++) { + candidates[num] = wp; + wp += 2 * ((*wp >> 1) & 0x7f) + 2; + }; + if (qm) { + int ecount, cval, i; + + bitSize = _RkCalcLog2(nk + 1) + 1; + _RkUnpackBits(permutation, qm->dm_qbits, offset, bitSize, nk); + for (ecount = cval = i = 0; i < nk; i++) { + if ((int)permutation[i]/2 > nk) { + ecount++; + break; + }; + cval += permutation[i]; + } + if (ecount || cval < (nk-1)*(nk-2)) { + for (i = 0; i < nk; i++) + permutation[i] = 2*i; + _RkPackBits(qm->dm_qbits, offset, bitSize, permutation, nk); + }; + }; + pp = wrds; + for (num = 0; num < nk; num++) { + unsigned permed; + + if (maxword <= 0) + break; + if (qm) { + permed = permutation[num]/2; + if ((int)permed > nk) { + break; + } else if ((int)permed == nk) + continue; + } else + permed = num; + wp = candidates[permed]; + clearWord(wrds, cx->gram->P_BB); + wrds->nw_kanji = wp; + wrds->nw_freq = qm; + wrds->nw_rowcol = _RkRowNumber(wp); + wrds->nw_cache = thisCache; + wrds->nw_ylen = thisRead->nk; + wrds->nw_klen = (*wp >> 1) & 0x7f; + wrds->nw_class = iclass; + wrds->nw_csn = csnb + permed; + wrds->nw_prio = 0L; + if (iclass == ND_MWD) { + if (qm && qm->dm_rut) { + if (cnt) + cnt = wrds->nw_prio = searchRut(qm->dm_rut, wrds->nw_csn); + } else if (DM2TYPE(dm)) { + if (num < 2) + wrds->nw_prio = ((struct TW *)thisCache->nc_address)->lucks[num]; + } + if (wrds->nw_prio) { + long t; + + t = _RkGetTick(0) - wrds->nw_prio; + wrds->nw_prio = (0 <= t && t < 0x2000) ? (0x2000 - t) << 4 : 0; + }; + switch(num) { + case 0: wrds->nw_prio += 15L; break; + case 1: wrds->nw_prio += 11L; break; + case 2: wrds->nw_prio += 7L; break; + case 3: wrds->nw_prio += 3L; break; + }; + wrds->nw_prio |= 0x01; + }; + if (douniq) { + for (qq = pp; qq < wrds; qq++) + if (qq->nw_rowcol == wrds->nw_rowcol) + break; + if (qq < wrds) + continue; + } + _RkEnrefCache(thisCache); + wrds++; + maxword--; + }; + }; + _RkDerefCache(thisCache); + }; + maxcache -= nc; + }; +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(permutation); + free(candidates); + free(nread); +#endif + return(wrds); +} + +/* makeWord + * jisho ni nai katakana, suuji, tokushu moji wo tango to minasu + */ +/*ARGSUSED*/ +inline +struct nword * +makeWord(struct RkContext *cx, int yy, int ys, int ye, int iclass, struct nword *word, int maxword, int doflush, int douniq) +{ + struct nstore *st = cx->store; + WCHAR_T *key = st->yomi + yy; + WCHAR_T *k, *z; + struct nword *w = word; + WCHAR_T c; + int clen; + int hinshi = cx->gram->P_BB; + int literal = -1; + int punct = 0; + int gobeyond = 0; + + if (ye <= 0) + return w; + z = (k = key) + ye; + /* sentou moji wo yomu */ + c = *k++; + clen = 1; + if (us_iscodeG0(c)) { /* ascii string */ + if ('0' <= c && '9' >= c) { /* numeral */ + if (!(cx->concmode & RK_MAKE_EISUUJI)) { + doflush++; + } else { + for (; k < z; k++, clen++) + if (clen >= RK_KEY_WMAX || !('0' <= *k && *k <= '9')) { + doflush++; + break; + }; + } + hinshi = cx->gram->P_NN; literal = LIT_NUM; + } else { /* others */ + if (!(cx->concmode & RK_MAKE_EISUUJI)) { + doflush++; + } else { + for (; k < z; k++, clen++) + if (clen >= RK_KEY_WMAX || !us_iscodeG0(*k)) { + doflush++; + break; + }; + } + hinshi = cx->gram->P_T35; literal = LIT_ALPHA; + } + } else if (us_iscodeG1(c)) { + if (0xb000 <= c) { /* kanji string */ + for (; k < z; k++, clen++) + if (clen >= RK_KEY_WMAX || *k < 0xb000) { + doflush++; + break; + }; + hinshi = cx->gram->P_T00; + } else if (0xa1a2 <= c && c <= 0xa1db) { + /* + * now multiple punctiation characters constitute a single punct + */ + for (; k < z; k++, clen++) + if (clen >= RK_KEY_WMAX || !(0xa1a2 <= *k && *k <= 0xa1db)) { + doflush++; + break; + }; + switch(c) { + case 0xa1a2: case 0xa1a3: case 0xa1a4: + case 0xa1a5: case 0xa1a6: case 0xa1a7: + case 0xa1a8: case 0xa1a9: case 0xa1aa: + case 0xa1c4: + punct = ND_PUN; + break; + case 0xa1c6: case 0xa1c8: case 0xa1ca: + case 0xa1cc: case 0xa1ce: + case 0xa1d0: case 0xa1d2: case 0xa1d4: + case 0xa1d6: case 0xa1d8: case 0xa1da: + punct = ND_OPN; + break; + case 0xa1c7: case 0xa1c9: case 0xa1cb: + case 0xa1cd: case 0xa1cf: case 0xa1d1: + case 0xa1d3: case 0xa1d5: case 0xa1d7: + case 0xa1d9: case 0xa1db: + punct = ND_CLS; + break; + default: + hinshi = cx->gram->P_T00; + doflush++; + }; + } else if (0xa3b0 <= c && c <= 0xa3b9) { /* suuji */ + if (!(cx->concmode & RK_MAKE_EISUUJI)) { + doflush++; + } else { + for (; k < z; k++, clen++) + if (clen >= RK_KEY_WMAX || !(0xa3b0 <= *k && *k <= 0xa3b9)) { + doflush++; + break; + }; + } + hinshi = cx->gram->P_NN; literal = LIT_NUM; + } else if ((0xa3c1 <= c && c <= 0xa3da) + || (0xa3e1 <= c && c <= 0xa3fa)) { /* eiji */ + if (!(cx->concmode & RK_MAKE_EISUUJI)) { + doflush++; + } else { + for (; k < z; k++, clen++) + if (clen >= RK_KEY_WMAX + || !((0xa3c1 <= (c = *k) && c <= 0xa3da) + || (0xa3e1 <= c && c <= 0xa3fa))) { + doflush++; + break; + }; + } + hinshi = cx->gram->P_T35; literal = LIT_ALPHA; + } else if (0xa5a1 <= c && c <= 0xa5f6) { /* zenkaku katakana */ + for (; k < z; k++, clen++) + if (clen >= RK_KEY_WMAX || + ((0xa5a1 > (c = *k) || c > 0xa5f6) && + (0xa1a1 > c || c > 0xa1f6))) { + doflush++; + break; + }; + hinshi = cx->gram->P_T30; + } else if (0xa4a1 <= c && c <= 0xa4f3) { /* hiragana */ + for (; k < z; k++, clen++) { + if (clen >= RK_KEY_WMAX) { + doflush++; + break; + }; + switch (*k) { +#ifndef FUJIEDA_HACK + case 0xa4a1: case 0xa4a3: case 0xa4a5: + case 0xa4a7: case 0xa4a9: + case 0xa4e3: case 0xa4e5: case 0xa4e7: + case 0xa4c3: case 0xa4f3: +#endif + case 0xa1ab: case 0xa1ac: case 0xa1b3: + case 0xa1b4: case 0xa1b5: case 0xa1b6: + case 0xa1bc: + continue; + default: + doflush++; + gobeyond++; + goto hira; + }; + }; + hira: + hinshi = cx->gram->P_T35; + } else { + doflush++; + hinshi = cx->gram->P_T35; + }; + } else if (us_iscodeG2(c)) { /* hankaku katakana */ + for (; k < z; k++, clen++) + if (clen >= RK_KEY_WMAX || !us_iscodeG2(*k)) { + doflush++; + break; + }; + hinshi = cx->gram->P_T30; + } else { + doflush++; + hinshi = cx->gram->P_T35; + } + if ((ys <= clen && clen <= ye) || gobeyond) { + if (iclass == ND_MWD || punct) { + if (!doflush && !gobeyond) + cx->poss_cont++; + if (literal != -1) { + if (doflush) + w= setLit(cx, w, maxword, hinshi, key, clen, literal); + } else if (w < word + maxword) { + if (doflush) { + setWord(w++, hinshi, 0, key, clen, (Wrec *)0, + clen, cx->gram->P_BB); + if (punct) + w[-1].nw_class = punct; +#ifdef FUJIEDA_HACK + w[-1].nw_flags |= NW_DUMMY; +#endif + }; + } + } + } + return w; +} + +inline int +determinate(Wrec *y1, Wrec *y2, int l) +{ + if ((int)*y1 > l) + return(0); + for (l = *y1, y1 += 2; l; l--) { + WCHAR_T *wy = (WCHAR_T *) y2; + Wrec c1 = (Wrec) ((*wy & 0xff00) >> 8); + Wrec c2 = (Wrec) (*wy & 0xff); + + y2 += 2; + if (*y1++ != c1 || *y1++ != c2) { + return(0); + } + } + return(1); +} + +inline +int +positive(Wrec *y1, Wrec *y2, int l) +{ + l = (int)*y1 < l ? (int)*y1 : l; + for (y1 += 2; l; l--) { + if (*y1++ != *y2++ || *y1++ != *y2++) { + return(0); + } + } + return(1); +} + +inline +int +positiveRev(Wrec *y1, Wrec *y2, int l) +{ + l = (int)*y1 < l ? (int)*y1 : l; + for (y1 += 2; l; l--) { + WCHAR_T *wy = (WCHAR_T *) y2; + Wrec c1 = (Wrec) ((*wy & 0xff00) >> 8); + Wrec c2 = (Wrec) (*wy & 0xff); + + y2 += 2; + if (*y1++ != c1 || *y1++ != c2) { + return(0); + } + } + return(1); +} + +static +void +cancelNVE(struct NV *nv, struct NVE *p) +{ + unsigned char *s = p->data; + + nv->csz -= *s * 2 + 2; + nv->cnt--; + p->right->left = p->left; + p->left->right = p->right; + free(s); + free(p); +} + +inline +struct NVE * +newNVE(struct NV *nv, Wrec *y, int l, int v) +{ + unsigned short w; + struct NVE *p, **q, *r; + struct NVE *nve; + unsigned char *s; + + nve = (struct NVE *)calloc(1, sizeof(struct NVE)); + if (nve) { + s = (unsigned char *)malloc(l * 2 + 2); + if (s) { + nve->data = s; + *s++ = l; + *s++ = v; + + memcpy(s, y, l * 2); + nv->csz += l * 2 + 2; + nv->cnt++; + while ((p = nv->head.right) != &nv->head && nv->csz >= (long)nv->sz) { + w = bst2_to_s(p->data + 2); + q = nv->buf + w % nv->tsz; + while ((r = *q) != (struct NVE *)0) { + if (r == p) { + *q = r->next; + cancelNVE(nv, p); + break; + } else + q = &r->next; + } + } + if (nv->csz >= (long)nv->sz) { + nv->csz -= l * 2 + 2; + nv->cnt--; + free(nve->data); + free(nve); + return((struct NVE *)0); + } + } else { + free(nve); + nve = (struct NVE *)0; + } + } + return(nve); +} + +int +_RkRegisterNV(struct NV *nv, Wrec *yomi, int len, int half) +{ + unsigned short v; + struct NVE *p, **q, **r; + + if (nv && nv->tsz && nv->buf) { + v = bst2_to_s(yomi); + q = r = nv->buf + v % nv->tsz; + for (p = *q; p; p = *q) { + if (positive(p->data, yomi, len)) { + *q = p->next; + cancelNVE(nv, p); + } else { + q = &p->next; + } + } + p = newNVE(nv, yomi, len, half); + if (p) { + p->next = *r; + *r = p; + p->left = nv->head.left; + p->left->right = p; + p->right = &nv->head; + nv->head.left = p; + } + } + return(0); +} + +#define TAILSIZE 256 +#define RIGHTSIZE (64 * 16) + +/* parseWord + * bunsestu no ki wo seichou saseru. + */ +static int +parseWord(struct RkContext *cx, int yy, int ys, int ye, int iclass, struct nword *xqh[], int maxclen, int doflush, int douniq) +{ + struct RkKxGram *gram = cx->gram->gramdic; + int clen; + static unsigned classmask[] = { /* ¸å¤í¤Ë¤Ä¤Ê¤¬¤ë¥¯¥é¥¹ */ + (1 << ND_SWD) | (1 << ND_SUC), /* MWD --> SUC | SWD */ + (1 << ND_SWD), /* SWD --> SWD */ + (1 << ND_MWD) | (1 << ND_SWD), /* PRE --> MWD | SWD */ + (1 << ND_SWD), /* SUC --> SWD */ + (1 << ND_MWD) | (1 << ND_SWD) | (1 << ND_PRE),/* EMP --> MWD | SWD | PRE */ + }; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + struct nword *tail[TAILSIZE]; + struct nword right[RIGHTSIZE]; +#else + struct nword **tail, *right; + tail = (struct nword **)malloc(sizeof(struct nword *) * TAILSIZE); + right = (struct nword *)malloc(sizeof(struct nword) * RIGHTSIZE); + if (!tail || !right) { + if (tail) free(tail); + if (right) free(right); + return maxclen; + } +#endif + + for (clen = 0; (clen <= maxclen && clen < ye); clen++) { + int sameLen; + int t; + struct nword *p, *q, *r; + int ys1, ye1; + + /* ÆÉ¤ß¤ÎŤµ clen ¤Îñ¸ì¤Î¤¦¤Á¡¢¸å¤í¤Ë iclass ¤Ç»ØÄꤵ¤ì¤¿Ã±¸ì¤¬ + ¤Ä¤Ê¤¬¤ë²ÄǽÀ­¤¬¤¢¤ë¤â¤Î¤ò¥ê¥¹¥È¥¢¥Ã¥×¤·¡¢tail ¤Ëµ­Ï¿¤¹¤ë */ + for (p = xqh[clen], sameLen = 0; p; p = p->nw_next) { + if (classmask[p->nw_class] & (1<nw_rowcol) : 0); + for (q = right; q < r; q++) + if (Is_Word_Connect(cx) && + (q->nw_class >= ND_OPN || !cj || TestGram(cj, q->nw_rowcol))) { + struct nword *pq = concWord(cx->store, p, q, clen, cx->gram->P_BB); + if (pq) { + struct nword *s; + if (gram && !IsShuutan(gram, pq->nw_rowcol)) { +#ifdef BUNMATU + /* ʸ¾ÏËö¤Ë¤·¤«¤Ê¤é¤Ê¤¤ */ + if (IsBunmatu(gram, pq->nw_rowcol)) { + /* ¶çÆÉÅÀ¤½¤Î¾¤Î¾ì¹ç¤Ë¤Ïʸ¾ÏËö¸¡ºº¤ÏÉÔÍ× */ + if (q->nw_class >= ND_OPN) + pq->nw_flags &= ~NW_BUNMATU; + else + pq->nw_flags |= NW_BUNMATU; + } else +#endif + DontSplitWord(pq); + } + if ((unsigned long)maxclen < (unsigned long)pq->nw_ylen) { + while (++maxclen < (int)pq->nw_ylen) + xqh[maxclen] = (struct nword *)0; + xqh[maxclen] = pq; + } + else { + s = xqh[pq->nw_ylen]; + if (s) { + while (s->nw_next) + s = s->nw_next; + s->nw_next = pq; + } + else + xqh[pq->nw_ylen] = pq; + } + pq->nw_next = (struct nword *)0; + } + } + } + for (q = right; q < r; q++) + if (q->nw_cache) + _RkDerefCache(q->nw_cache); + if (!gram) + goto done; + } + done: +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(tail); + free(right); +#endif + return maxclen; +} + +/*ARGSUSED*/ +static int +doParse(struct RkContext *cx, int yy, int ys, int ye, struct nword *xqh[], int maxclen, int doflush, int douniq) +{ + maxclen = parseWord(cx, yy, ys, ye, ND_PRE, xqh, maxclen, doflush, douniq); + maxclen = parseWord(cx, yy, ys, ye, ND_MWD, xqh, maxclen, doflush, douniq); + maxclen = parseWord(cx, yy, ys, ye, ND_SUC, xqh, maxclen, doflush, douniq); + maxclen = parseWord(cx, yy, ys, ye, ND_SWD, xqh, maxclen, doflush, douniq); + return maxclen; +} + +/* getKanji + * get kanji in reverse order + */ +WCHAR_T * +_RkGetKanji(struct nword *cw, WCHAR_T *key, unsigned long mode) +{ + Wrec *str; + static WCHAR_T tmp[RK_LEN_WMAX+1]; /* static! */ + WCHAR_T *p = tmp; + int klen, ylen; + struct nword *lw = cw->nw_left; + + klen = cw->nw_klen - lw->nw_klen; + ylen = cw->nw_ylen - lw->nw_ylen; +/* nw_cache --> nw_kanji !nw_lit */ +/* !nw_cache --> !nw_kanji nw_lit */ + + if (cw->nw_cache) { + if ((*(cw->nw_kanji) >> 1) & 0x7f) { + str = cw->nw_kanji + NW_PREFIX; + for (; klen-- ; str += 2) + *p++ = S2TOS(str); + return tmp; + } else + return key; + } else if (cw->nw_kanji) { + _Rkpanic("_RkGetKanji\n", 0, 0, 0); + str = cw->nw_kanji + NW_PREFIX; + for (; klen-- ; str += 2) + *p++ = S2TOS(str); + return tmp; + } else if (cw->nw_lit) { + if (cvtLit(tmp, klen + 1, key, ylen, cw->nw_lit, mode) > 0) + return tmp; + else + return key; + } else + return key; +} + +inline +int +getKanji(struct nword *w, WCHAR_T *key, WCHAR_T *d, unsigned long mode) +{ + struct nword *cw, *lw; + int hash, klen; + + hash = 0; + for (cw = w; cw; cw = lw) { + WCHAR_T *s, *t; + + if (!(lw = cw->nw_left)) + continue; + klen = (cw->nw_klen - lw->nw_klen); + s = _RkGetKanji(cw, key + lw->nw_ylen, mode); + t = s + klen; + /* copy */ + while (s < t) { + *d++ = *--t; + hash += *t; + } + } + return hash; +} + +#define HEAPSIZE 512 + +/* uniqWord + * unique word list + */ +inline void +uniqWord(WCHAR_T *key, struct nword *words, unsigned ylen, unsigned long mode) +{ + struct nword *p; + long hp = 0; + long uniq[16]; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + long heap[HEAPSIZE]; +#else + long *heap = (long *)malloc(sizeof(long) * HEAPSIZE); + if (!heap) { + return; + } +#endif + + if (!(!key || ylen <= 0)) { + /* clear hash table */ + uniq[ 0] = uniq[ 1] = uniq[ 2] = uniq[ 3] = + uniq[ 4] = uniq[ 5] = uniq[ 6] = uniq[ 7] = + uniq[ 8] = uniq[ 9] = uniq[10] = uniq[11] = + uniq[12] = uniq[13] = uniq[14] = uniq[15] = -1; + for (p = words; p; p = p->nw_next) { + if (CanSplitWord(p) && p->nw_ylen == ylen) { + int wsize; + /* compute word size */ + wsize = (2*p->nw_klen + sizeof(long)-1)/sizeof(long); + if (hp + 1 + wsize < HEAPSIZE) { + long hno, h; + /* put kanji string without EOS */ + heap[hp + wsize] = 0; + hno = getKanji(p, key, (WCHAR_T *)&heap[hp + 1], mode)&15; + /* search on the hash list */ + for (h = uniq[hno]; h >= 0; h = heap[h&0xffff]) + if ((h >> 16) == p->nw_klen) { /* same length */ + long *p1 = &heap[(h&0xffff) + 1]; + long *p2 = &heap[hp + 1]; + int i; + /* compare by word */ + switch(wsize) { + case 3: if (*p1++ != *p2++) goto next; + case 2: if (*p1++ != *p2++) goto next; + case 1: if (*p1++ != *p2++) goto next; + case 0: break; + default: + for (i = wsize; i--;) + if (*p1++ != *p2++) goto next; + break; + } + /* match */ + DontSplitWord(p); + goto done; + next: + continue; + } + /* enter new entry */ + heap[hp + 0] = uniq[hno]; + uniq[hno] = (((unsigned long) (p->nw_klen))<<16)|hp; + hp += 1 + wsize; + } + done: + continue; + } + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(heap); +#endif +} + +/* sortWord + * word list wo sort suru + */ +struct compRec { + struct nword *word; + long prio; +}; + + +static +int +compword(const struct compRec *x, const struct compRec *y) +{ + long d = ((long) y->word->nw_prio) - ((long) (x->word->nw_prio)); + + if (d > 0) return(1); + else if(d < 0) return(-1); + else { + long dd = x->prio - y->prio; + + if (dd > 0) return(1); + else if (dd < 0) return(-1); + else return(0); + } +} + +inline +struct nword * +sortWord(struct nword *words) +{ + unsigned long nwords, pos, neg; + long i, p, n; + struct compRec *wptr; + struct nword *w; +/* count number of words */ + pos = neg = 0L; + for (w = words; w; w = w->nw_next) + if (w->nw_prio > 0) + pos++; + else + neg++; + nwords = pos + neg; + if (nwords <= 0) + return words; + /* sort word list using work space if possible */ + wptr = (struct compRec *)malloc(sizeof(struct compRec)*nwords); + if (wptr) { + p = 0L; + n = pos; + /* store pointers */ + for (w = words; w; w = w->nw_next) + if (w->nw_prio > 0) { /* positive list */ + wptr[p].word = w; + wptr[p].prio = p; + p++; + } else { /* negative list && null word */ + wptr[n].word = w; + n++; + } + /* positive list no sakusei */ + if (pos > 1) + (void)qsort((char *)wptr, (int)pos, sizeof(struct compRec), + (int (*) (const void *, const void *))compword); + for (i = 1; i < (int)nwords; i++) + wptr[i - 1].word->nw_next = wptr[i].word; + words = wptr[0].word; + free(wptr); + } + return words; +} + +static +struct nword * +height2list(struct nword *height[], int maxclen) +{ + int i; + struct nword *e, *p, *head, *tail; + + e = height[0]; + tail = (struct nword *)0; + for (i = 1; i <= maxclen; i++) + if (height[i]) { + for (p = height[i] ; p->nw_next ;) { + p = p->nw_next; + } + if (tail) + tail->nw_next = height[i]; + else + head = height[i]; + tail = p; + } + if (tail) + tail->nw_next = e; + else + head = e; + return head; +} +static +void +list2height(struct nword *height[], int maxclen, struct nword *parse) +{ + int i; + struct nword *p, *q; + + for (i = 0; i <= maxclen; i++) + height[i] = (struct nword *)0; + for (p = parse; p; p = p->nw_next) + if ((unsigned long)p->nw_ylen <= (unsigned long)maxclen && !height[p->nw_ylen]) + height[p->nw_ylen] = p; + for (i = 0; i <= maxclen; i++) + if (height[i]) { + for (p = height[i] ; (q = p->nw_next) != (struct nword *)0; p = q) { + if (q->nw_ylen != i) { + p->nw_next = (struct nword *)0; + break; + } + } + } +} + +/* parseBun + * key yori hajimaru bunsetsu wo kaiseki suru + */ +inline +struct nword * +parseBun(struct RkContext *cx, int yy, int ys, int ye, int doflush, int douniq, int *maxclen) /* bunsetu saidai moji suu */ +{ + struct nstore *st = cx->store; + struct nword **xqh = st->xqh; + +#ifdef TEST + printf("parseBun[yy = %d, ys = %d, ye = %d]\n", yy, ys, ye); +#endif + + xqh[0] = allocWord(st, cx->gram->P_BB); + if (xqh[0]) { + *maxclen = doParse(cx, yy, ys, ye, xqh, 0, doflush, douniq); + return height2list(xqh, *maxclen); + } else { /* kaiseki funou */ + *maxclen = 0; + return (struct nword *)0; + } +} + +static +void +storeBun(struct RkContext *cx, int yy, int ys, int ye, struct nbun *bun) +{ + struct nword *full; + struct nword *w; + int maxclen; + + full = sortWord(parseBun(cx, yy, ys, ye, 1, 0, &maxclen)); + bun->nb_cand = full; + bun->nb_yoff = yy; +/* kouho wo unique ni suru */ + uniqWord(cx->store->yomi + yy, full, bun->nb_curlen, cx->concmode); + bun->nb_curcand = (unsigned short)0; + bun->nb_maxcand = (unsigned short)0; + for (w = full; w; w = w->nw_next) { + if (CanSplitWord(w) && w->nw_ylen == bun->nb_curlen) + bun->nb_maxcand++; + } +} + +/* + * SPLIT + */ +struct splitParm { + unsigned long u2; + int l2; +}; + +#ifdef FUJIEDA_HACK +static +void +evalSplit( + struct RkContext *cx, + struct nword *suc, + struct splitParm *ul +) +{ + struct nword *p; + unsigned l2; + unsigned long u2; + + l2 = 0; + u2 = 0L; + for (p = suc; p; p = p->nw_next) + { + if (!CanSplitWord(p) || /* ʸÀá¤Ë¤Ê¤é¤Ê¤¤ */ + OnlyBunmatu(p) || /* ¥ê¥Æ¥é¥ë¤ÎľÁ°¤Ç¤·¤«Ê¸Àá¤Ë¤Ê¤ì¤Ê¤¤ */ + (p->nw_rowcol == cx->gram->P_KJ) || /* ñ´Á»ú */ + (p->nw_flags & NW_DUMMY) || /* ÙÔ¤¤µ¤ì¤¿Ì¾»ì */ + (p->nw_flags & NW_SUC)) + continue; + if (l2 <= p->nw_ylen) { + l2 = p->nw_ylen; + if (u2 < p->nw_prio) + u2 = p->nw_prio; + } + } + ul->l2 = l2; + ul->u2 = u2; +} +#else /* FUJIEDA_HACK */ +static +void +evalSplit(struct nword *suc, struct splitParm *ul) +{ + struct nword *p; + int l2; + unsigned long u2; + + l2 = 0; + u2 = 0L; + for (p = suc; p; p = p->nw_next) + { + if (!CanSplitWord(p) || (p->nw_flags & NW_SUC)) + continue; + if ((unsigned long)l2 < (unsigned long)p->nw_ylen) + l2 = p->nw_ylen; + if (u2 < p->nw_prio) + u2 = p->nw_prio; + }; + ul->l2 = l2; + ul->u2 = u2; +} +#endif /* FUJIEDA_HACK */ + +#define PARMSIZE 256 + +static +int +calcSplit(struct RkContext *cx, int yy, struct nword *top, struct nqueue xq[], int maxclen, int flush) +{ +#ifdef FUJIEDA_HACK + int L, L1 = 0, L2; + unsigned long U; +#else + unsigned L, L1 = 0, L2; + unsigned U2; +#endif + struct nword *w; + int i; + int maxary = PARMSIZE - 1; + struct nstore *st = cx->store; + struct NVE *p, **r; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + struct splitParm ul2[PARMSIZE]; +#else + struct splitParm *ul2 = (struct splitParm *) + malloc(sizeof(struct splitParm) * PARMSIZE); + if (!ul2) { + return L1; + } +#endif + + L2 = st->nyomi - yy; + if (cx->nv && cx->nv->tsz && cx->nv->buf) { + r = cx->nv->buf + *(st->yomi + yy) % cx->nv->tsz; + for (p = *r; p; p = p->next) { + if (determinate(p->data, (Wrec *)(st->yomi + yy), (int)L2)) { + if (*(p->data+1) > L1) + L1 = *(p->data + 1); + } + } + } + if (L1 == 0) { + L = (L1 = 1)+ (L2 = 0); +#ifdef FUJIEDA_HACK + U = 0L; +#else + U2 = (unsigned)0; +#endif + if (maxary > maxclen) + maxary = maxclen; + for (i = 0; i <= maxary; i++) + ul2[i].l2 = ul2[i].u2 = 0L; + for (w = top; w; w = w->nw_next) { + int l, l1; +#ifdef FUJIEDA_HACK + unsigned long u; +#endif + struct splitParm ul; + /* ʸÀá¤Ë¤Ê¤é¤Ê¤¤ */ + if (!CanSplitWord(w)) { + continue; + } + if ((w->nw_flags & NW_PRE) && (w->nw_flags & NW_SUC)) { + continue; + } + /* ÆÉ¤ß¤ò¾ÃÈñ¤·¤Æ¤¤¤Ê¤¤ */ + l1 = w->nw_ylen; + if (l1 <= 0) { + continue; + } + /* °ìʸÀá¤Ë¤¹¤ë¤Î¤¬ºÇĹ */ + if (flush && (unsigned)yy + w->nw_ylen == cx->store->nyomi) { + L1 = l1; + break; + } +#ifdef BUNMATU + /* ³¤¯Ê¸À᤬¥ê¥Æ¥é¥ë¤Ç¤Ê¤¤¤Ê¤éʸ¾ÏËöÉÊ»ì¤Ïʸ¤ÎÅÓÃæ¤Ë¤Ê¤é¤Ê¤¤ */ + else if (OnlyBunmatu(w) && xq[l1].tree->nw_lit == 0) { + DontSplitWord(w); + continue; + } +#endif +#ifdef FUJIEDA_HACK + /* ñ´Á»ú¤Ïʸ¤ÎÅÓÃæ¤ËÅо줷¤Ê¤¤ */ + if (w->nw_rowcol == cx->gram->P_KJ) { + DontSplitWord(w); + continue; + } +#endif + /* ±¦ÎÙ¤ÎʸÀá¤ò²òÀÏ */ + if (l1 <= maxary) { + if (!ul2[l1].l2) +#ifdef FUJIEDA_HACK + evalSplit(cx, xq[l1].tree, &ul2[l1]); +#else + evalSplit(xq[l1].tree, &ul2[l1]); +#endif + ul = ul2[l1]; + } + else { +#ifdef FUJIEDA_HACK + evalSplit(cx, xq[l1].tree, &ul); +#else + evalSplit(xq[l1].tree, &ul); +#endif + } + /* hikaku */ + l = l1 + ul.l2; +#ifdef FUJIEDA_HACK + u = w->nw_prio + ul.u2; + if ((L < l) || /* ÆóʸÀáºÇĹ */ + ((L == l) && + (U < u || /* Í¥ÀèÅ٤ιç·× */ + (U == u && (L2 < ul.l2))))) { /* ÆóʸÀáÌܤÎŤµ */ + L = l; + U = u; + L1 = l1; + L2 = ul.l2; + } +#else + if ((((int)L < l)) || + (((int)L == l) && (U2 < ul.u2)) || + (((int)L == l) && (U2 == ul.u2) && ((int)L2 < ul.l2)) + ) { + L = l; + L1 = l1; + L2 = ul.l2; + U2 = ul.u2; + } +#endif + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + (void)free((char *)ul2); +#endif + return L1; +} + +inline +int +splitBun(struct RkContext *cx, int yy, int ys, int ye) +{ + struct nstore *st = cx->store; + struct nqueue *xq = st->xq; + struct nword *w; + int maxclen; + int i, count, junk; + +/* create the initial bun-tree table */ + xq[0].tree = parseBun(cx, yy, ys, ye, 1, 1, &maxclen); + +#ifdef TEST + { + printf("show splitBun [yy = %d, ys = %d, ye = %d, clen = %d]\n", + yy, ys, ye, maxclen); +#if 1 + showWord(xq[0].tree); +#endif + } +#endif + + for (i = 1; i <= maxclen; i++) + clearQue(&xq[i]); +/* create the following buns from every possible position */ + for (w = xq[0].tree; w; w = w->nw_next) { + if (CanSplitWord(w) && !xq[w->nw_ylen].tree) { + int len = w->nw_ylen; + int ys1 = (ys >= len) ? (ys - len) : 0; + int ye1 = (ye - len); + + xq[w->nw_ylen].tree = parseBun(cx, yy+len, ys1, ye1, 1, 1, &junk); + }; + }; + +/* compute the proper bunsetu length */ + count = calcSplit(cx, yy, xq[0].tree, xq, maxclen, 1); + _RkFreeQue(st, 0, st->maxxq + 1); + +#ifdef TEST + printf("End SplitBun\n"); +#endif + + return count; +} + +/* parseQue + * queue jou de bunsetu wo kaiseki suru. + */ + +static void parseQue (struct RkContext *, int, int, int, int, int); + +static void +parseQue(struct RkContext *cx, int maxq, int yy, int ys, int ye, int doflush) +{ + struct nstore *st = cx->store; + struct nqueue *xq = st->xq; + struct nword **xqh = st->xqh; + int i, j; + +/* put a new seed to start an analysis. */ + if (!xq[0].tree) { + xq[0].tree = allocWord(st, cx->gram->P_BB); + xq[0].maxlen = 0; + xq[0].status = 0; + } +/* try to extend each tree in the queue. */ + for (i = 0; i <= maxq; i++) { + if (xq[i].tree) { + int old = cx->poss_cont; + list2height(xqh, xq[i].maxlen, xq[i].tree); + xq[i].maxlen = doParse(cx, yy, ys, ye, xqh, xq[i].maxlen, doflush, 1); + /* set up new analysis points */ + for (j = 0; j <= xq[i].maxlen; j++) + if (xqh[j] && !xq[i+j].tree) { + xq[i+j].tree = allocWord(st, cx->gram->P_BB); + xq[i+j].maxlen = 0; + xq[i+j].status = 0; + xq[i+j].status = 0x80; + } + xq[i].tree = height2list(xqh, xq[i].maxlen); + if (cx->poss_cont != old) + xq[i].status |= 0x80; + else + xq[i].status &= ~0x80; + } + ++yy; + if (--ys < 0) ys = 0; + --ye; + } +} + +/* Que2Bun + * queue kara bunsetu wo toridasu. + */ +static +int +IsStableQue(struct RkContext *cx, int c, int doflush) +{ + struct nqueue *xq = cx->store->xq; + struct nword *w; + + if (doflush) + { + if (xq[c].maxlen <= 0) + return 0; + else + return 1; + }; + if (xq[c].maxlen <= 0) + return(!c ? 0 : 1); + + for (w = xq[c].tree; w; w = w->nw_next) + { + if (xq[c + w->nw_ylen].status) + return 0; + if (!c && w->nw_ylen && !IsStableQue(cx, c + w->nw_ylen, doflush)) + return 0; + }; + return 1; +} + +static +int +Que2Bun(struct RkContext *cx, int yy, int ys, int ye, int doflush) +{ + struct nstore *st = cx->store; + struct nqueue *xq = st->xq; + unsigned i; + struct NVE *p, **r; + + if (doflush) + for (i = 0; (int)i <= st->maxxq; i++) + xq[i].status = 0; + while (IsStableQue(cx, 0, doflush)) { + struct nbun *bun = &st->bunq[st->maxbun]; + int count; + + i = 0; + if (!doflush) { + if (cx->nv && cx->nv->tsz && cx->nv->buf) { + r = cx->nv->buf + *(st->yomi + yy) % cx->nv->tsz; + for (p = *r; p; p = p->next) { + if (positiveRev(p->data, (Wrec *)(st->yomi + yy), st->nyomi - yy)) { + if (*(p->data + 1) > i) + i = *(p->data + 1); + } + } + } + if (i > st->nyomi - yy) + break; + } + if ((count = calcSplit(cx, yy, xq[0].tree, xq, xq[0].maxlen, 1)) > 0) { + /* shift queue to left */ + _RkFreeQue(st, 0, count); + for (i = count; (int)i <= st->maxxq; i++) { + xq[i-count] = xq[i]; + clearQue(&xq[i]); + }; + bun->nb_curlen = count; + storeBun(cx, (int)bun->nb_yoff, 0, ye, bun); + st->maxbun++; + st->bunq[st->maxbun].nb_yoff = yy + bun->nb_curlen; + } + yy = yy + bun->nb_curlen; + ys = ys - bun->nb_curlen; + ye = ye - bun->nb_curlen; + } + return st->maxbun; +} + +/* _RkRenbun2 + * current bunsetsu kara migi wo saihenkan suru + */ +int +_RkRenbun2(struct RkContext *cx, int firstlen) /* bunsetsu chou sitei(ow 0) */ +{ + struct nstore *st = cx->store; + struct nbun *bun = &st->bunq[st->curbun]; + int count; + int yy, ys, ye; /* yomi kensaku hani */ + int oldcurbun = st->curbun; + int uyomi; + int i; + + yy = bun->nb_yoff; + ys = 0; + ye = st->nyomi - bun->nb_yoff; +/* release queue */ + uyomi = st->nyomi - st->bunq[st->maxbun].nb_yoff; + if (IS_XAUTCTX(cx)) { + if (uyomi >= 0) + _RkFreeQue(st, 0, uyomi+1); + }; +/* + * + */ + for (count = 0; ye > 0; count++) + { +/* sudeni kaiseki zumi deareba, sono kekka wo mochiiru */ + if (count && !uyomi) + { + int b, c; + for (b = st->curbun; b < (int)st->maxbun; b++) + if (st->bunq[b].nb_yoff == yy) { + /* dispose inbetween bun-trees */ + for (c = st->curbun; c < b; c++) { + freeWord(st, st->bunq[c].nb_cand); + st->bunq[c].nb_cand = (struct nword *)0; + } + /* shift bunq forward */ + while (b < (int)st->maxbun) + st->bunq[st->curbun++] = st->bunq[b++]; + goto exit; + } + } +/* dispose the current bun-tree */ + if (st->curbun < (int)st->maxbun) { + freeWord(st, bun->nb_cand); + bun->nb_cand = (struct nword *)0; + } + /* compute the length of bun */ + if (st->curbun >= (int)st->maxbunq) /* too many buns */ + bun->nb_curlen = ye; + else { + if (firstlen) { /* length specified */ + bun->nb_curlen = firstlen; + firstlen = 0; + } else { + /* destroy */ + bun->nb_curlen = splitBun(cx, yy, ys, ye); + if (!bun->nb_curlen) /* fail to split */ + bun->nb_curlen = ye; + } + } +/* set up bun (xqh is destroyed */ + storeBun(cx, yy, ys, ye, bun); +#if defined(TEST) && 0 + showWord(bun->nb_cand); +#endif + yy += bun->nb_curlen; + if ((ys -= (int)bun->nb_curlen) < 0) + ys = 0; + ye -= bun->nb_curlen; + bun++; + st->curbun++; + } +/* free the remaining bun-trees */ + while ((int)st->maxbun > st->curbun) { + freeWord(st, st->bunq[--st->maxbun].nb_cand); + st->bunq[st->maxbun].nb_cand = (struct nword *)0; + } +/* do final settings */ + exit: + st->maxbun = st->curbun; + st->curbun = oldcurbun; + st->bunq[st->maxbun].nb_yoff = 0; +/* i hate this fake, ... */ + for (i = 0; i < (int)st->maxbun; i++) + st->bunq[st->maxbun].nb_yoff += st->bunq[i].nb_curlen; +/* this case will never happen */ + if (0 != (st->nyomi - st->bunq[st->maxbun].nb_yoff)) + _Rkpanic("Renbun2: uyomi destroyed %d %d\n", + st->nyomi, st->bunq[st->maxbun].nb_yoff, 0); + bun = &st->bunq[st->maxbun]; + if (IS_XAUTCTX(cx) && uyomi > 0) + { + _RkSubstYomi(cx, 0, uyomi, st->yomi + bun->nb_yoff, uyomi); + st->curbun = oldcurbun; + }; + return st->maxbun; +} + +/* RkSubstYomi + */ +int +_RkSubstYomi(struct RkContext *cx, int ys, int ye, WCHAR_T *yomi, int newLen) +{ + struct nstore *st = cx->store; + struct nbun *bun; + struct nqueue *xq; + struct nword **xqh; + int i, j; + int count; + int yf; + int cs, ce, cf; + WCHAR_T *d, *s, *be; + int nbun; + int new_size; + + yf = ys + newLen; + cs = ys; + ce = ye; + /* + * STEP 0: reallocate resources if needed + * youmigana buffer should be reallocated as well. + */ + new_size = st->nyomi + (newLen - (ye - ys)); + if (new_size > (int)st->maxyomi || new_size > (int)st->maxbunq || + new_size > (int)st->maxxq) + { + st = _RkReallocBunStorage(st, (int)(new_size*1.2+10)); + if (!st) + return -1; + cx->store = st; + }; + /* + * STEP 1: update yomigana buffer + */ + /* move unchanged text portion [ye, ...) */ + bun = &st->bunq[st->maxbun]; + be = st->yomi + bun->nb_yoff; + xq = st->xq; + xqh = st->xqh; + count = (st->nyomi - bun->nb_yoff) - ye; + if (yf < ye) { /* shrunk */ + d = be + yf; + s = be + ye; + while (count--) *d++ = *s++; + } else if (ye < yf) { /* enlarged */ + d = (s = st->yomi + st->nyomi) + count; + while (count--) + *--d = *--s; + } + /* replace the new text in [ys, yf) */ + usncopy(be + ys, yomi, newLen); + st->nyomi += (yf - ye); + cf = yf; + /* + * STEP 2: remove affected words from XQ + */ +/* Trim the words which terminate in [cs, ...) */ + + for (i = 0; i < cs; i++) + if (xq[i].tree && cs - i <= xq[i].maxlen) { + list2height(xqh, xq[i].maxlen, xq[i].tree); + for (j = cs - i; j < xq[i].maxlen; j++) + if (xqh[j + 1]) { + freeWord(st, xqh[j + 1]); + xqh[j + 1] = (struct nword *)0; + } + xq[i].maxlen = 0; + for (j = cs - i ; j >= 0 && !xqh[j] ;) { + j--; + } + if (j > 0) + xq[i].maxlen = j; + else { + xq[i].maxlen = 0; + if (!j) { + freeWord(st, xqh[0]); + xqh[0] = (struct nword *)0; + } + } + xq[i].tree = height2list(xqh, xq[i].maxlen); + xq[i].status = 0; + } + /* Kill the whole trees in [cs, ce) and shift XQ to fill it. */ + _RkFreeQue(st, cs, ce); + if (cf < ce) + for (i = cf, j = ce; j <= st->maxxq; i++, j++) { + xq[i] = xq[j]; + clearQue(&xq[j]); + } + if (ce < cf) + for (i = st->maxxq, j = st->maxxq - (cf - ce); j >= ce; i--, j--) { + xq[i] = xq[j]; + clearQue(&xq[j]); + } + /* + * STEP 3 restore queues by parsing yomigana after ys. + */ + nbun = st->maxbun; + count = (st->nyomi - bun->nb_yoff) - ys; + while (count > 0) { + int yy; + yy = st->bunq[st->maxbun].nb_yoff; + ys = st->nyomi - yy - count; + parseQue(cx, cf-1, yy, ys, ys + 1, 0); + nbun = Que2Bun(cx, yy, ys, ys + 1, 0); + ys++; + count--; + } + st->curbun = 0; + return nbun; +} + +/* RkFlushYomi + */ +int +_RkFlushYomi(struct RkContext *cx) +{ + int yy = cx->store->bunq[cx->store->maxbun].nb_yoff; + int ys = cx->store->nyomi - yy; + int ret; + + parseQue(cx, cx->store->maxxq, yy, ys, ys, 1); + if ((ret = Que2Bun(cx, yy, ys, ys, 1)) != -1) + cx->store->curbun = 0; + return(ret); +} + +/* _RkLearnBun + * bunsetu jouho wo motoni gakushuu suru + * sarani, word wo kaihou suru + */ +inline +void blkcpy(unsigned char *d, unsigned char *s, unsigned char *e) +{ while (s < e) *d++ = *s++; } + +static +void +doLearn(struct RkContext *cx, struct nword *thisW) +{ + struct nword *leftW; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + unsigned char *candidates[RK_CAND_NMAX]; + unsigned permutation[RK_CAND_NMAX]; + unsigned char tmp[RK_WREC_BMAX]; +#else + unsigned char **candidates, *tmp; + unsigned *permutation; + candidates = (unsigned char **) + malloc(sizeof(unsigned char *) * RK_CAND_NMAX); + permutation = (unsigned *)malloc(sizeof(unsigned) * RK_CAND_NMAX); + tmp = (unsigned char *)malloc(RK_WREC_BMAX); + if (!candidates || !permutation || !tmp) { + if (candidates) free(candidates); + if (permutation) free(permutation); + if (tmp) free(tmp); + return; + } +#endif + + for (; (leftW = thisW->nw_left) != (struct nword *)0 ; thisW = leftW) { + struct ncache *thisCache = thisW->nw_cache; + + if (thisCache) { + struct DM *dm = thisCache->nc_dic; + struct DM *qm = thisW->nw_freq; + unsigned char *wp; + int ncands; + int nl; + unsigned long offset; + int i; + int current; + + cx->time = _RkGetTick(1); + if (thisCache->nc_flags & NC_ERROR) + continue; + if (!(wp = thisCache->nc_word)) + continue; + ncands = _RkCandNumber(wp); + nl = (*wp >> 1) & 0x3f; + if (qm && qm->dm_qbits) + offset = _RkGetOffset((struct ND *)dm->dm_extdata.var, wp); + else + offset = 0L; + if (*wp & 0x80) + wp += 2; + wp += 2 + nl * 2; + for (i = 0; i < ncands; i++) { + candidates[i] = wp; + wp += 2 * ((*wp >> 1) & 0x7f) + 2; + }; + if (thisCache->nc_count) + continue; + if (qm && qm->dm_qbits) { + int bits; + + if (!(qm->dm_flags & DM_WRITABLE)) + continue; + bits = _RkCalcLog2(ncands + 1) + 1; + _RkUnpackBits(permutation, qm->dm_qbits, offset, bits, ncands); + for (current = 0; current < ncands; current++) + if (ncands > (int)permutation[current]/2 && + candidates[permutation[current]/2] == thisW->nw_kanji) + break; + if (current < ncands) { + entryRut(qm->dm_rut, thisW->nw_csn, cx->time); + if (0 < current) { + _RkCopyBits(tmp, (unsigned long) 0L, bits, + qm->dm_qbits, (unsigned long) offset, current); + _RkCopyBits(qm->dm_qbits, (unsigned long) (offset + 0L), bits, + qm->dm_qbits, (unsigned long) (offset + current*bits), + 1); + _RkCopyBits(qm->dm_qbits, (unsigned long) (offset + bits), bits, + tmp, (unsigned long) 0L, current); + + }; + qm->dm_flags |= DM_UPDATED; + } + } else { + if (!(dm->dm_flags & DM_WRITABLE)) + continue; + for (current = 0; current < ncands; current++) + if (candidates[current] == thisW->nw_kanji) + break; + if (DM2TYPE(dm)) { + if (current) { + unsigned char *t = candidates[0]; + unsigned char *l = candidates[current]; + unsigned char *c = l + 2 * ((*l >> 1) & 0x7f) + 2; + + ((struct TW *)thisCache->nc_address)->lucks[1] + = ((struct TW *)thisCache->nc_address)->lucks[0]; + blkcpy(tmp, t, l); + blkcpy(t, l, c); + blkcpy(t + (int)(c - l), tmp, tmp + (int)(l - t)); + thisCache->nc_flags |= NC_DIRTY; + } + ((struct TW *)thisCache->nc_address)->lucks[0] = cx->time; + dm->dm_flags |= DM_UPDATED; + } + } + } + } +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(candidates); + free(permutation); + free(tmp); +#endif +} + +void +_RkLearnBun(struct RkContext *cx, int cur, int mode) +{ + struct nstore *st = cx->store; + struct nbun *bun = &st->bunq[cur]; + struct nword *w; + int count = bun->nb_curcand; + WCHAR_T *yomi = st->yomi + bun->nb_yoff; + int ylen; + int pos; + + derefWord(bun->nb_cand); + if (mode) { + if (bun->nb_flags & RK_REARRANGED) { + ylen = bun->nb_curlen + + (cur < (int)st->maxbun - 1 ? (bun + 1)->nb_curlen : 0); + pos = bun->nb_curlen; + if (ylen < 32) { + WCHAR_T *ey = yomi + ylen, *p; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + Wrec yomwrec[32 * sizeof(WCHAR_T)]; + Wrec *dp = yomwrec; +#else + Wrec *dp; + Wrec *yomwrec = (Wrec *)malloc(sizeof(Wrec) * 32 * sizeof(WCHAR_T)); + if (!yomwrec) { + return; + } + dp = yomwrec; +#endif + for (p = yomi ; p < ey ; p++) { + *dp++ = (unsigned)*p >> 8; + *dp++ = (unsigned)*p & 0x0ff; + } + _RkRegisterNV(cx->nv, yomwrec, ylen, pos); +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(yomwrec); +#endif + } + } + for (w = bun->nb_cand; w; w = w->nw_next) { + if (CanSplitWord(w) && w->nw_ylen == bun->nb_curlen) { + if (count-- <= 0) { + doLearn(cx, w); + break; + } + } + } + } + killWord(st, bun->nb_cand); +} + diff --git a/src/add-ons/input_server/methods/canna/rk/permdic.c b/src/add-ons/input_server/methods/canna/rk/permdic.c new file mode 100644 index 0000000000..7616457852 --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/permdic.c @@ -0,0 +1,828 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. + * + * Permission to use, copy, modify, distribute and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of NEC + * Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. NEC Corporation makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#if !defined(lint) && !defined(__CODECENTER__) +static char rcs_id[] = "$Id: permdic.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif + +#include +#include +#include "RKintern.h" +#include + +#define dm_xdm dm_extdata.ptr +#ifndef WIN +#define df_fdes df_extdata.var +#else +#define df_fdes df_extdata.hnd +#endif + +extern unsigned _RkCalcLVO(); + +#ifdef MMAP +/* If you compile with Visual C++, then please comment out the next 3 lines. */ +#include /* mmap */ +#include /* mmap */ +#include /* mmap */ +extern int fd_dic; /* mmap */ +#endif + +static unsigned char *assurep(struct ND *dic, int id); +static readThisCache(struct DM *dm, struct ND *xdm, long pgno, unsigned long val, WCHAR_T *key, int cur, int ylen, struct nread *nread, int mc, int nc, int *cf); +static int SearchInPage(struct DM *dm, struct ND *xdm, long pgno, unsigned char *buf, unsigned long val, WCHAR_T *key, int cur, int ylen, struct nread *nread, int mc, int nc, int *cf); +static int SearchInDir(struct DM *dm, struct ND *xdm, unsigned char *pos, WCHAR_T *key, int cur, int ylen, struct nread *nread, int mc, int nc, int *cf); +static void ch_perm(struct DM *qm, unsigned offset, int size, int num); + +inline int +openDF(struct DF *df, char *dfnm, int *w) +{ + struct HD hd; + struct ND nd, *xnd; + struct DM *dm, *dmh; + off_t off; + unsigned char ll[4]; + int count = 0, err; +#ifdef WIN + HANDLE fd; + DWORD readsize; + HANDLE errres = INVALID_HANDLE_VALUE; +#else + int fd; + int errres = -1; +#endif + + *w = 0; +#ifdef WIN + fd = CreateFile(dfnm, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (fd == INVALID_HANDLE_VALUE) { + return fd; + } +#else + if ((fd = open(dfnm, 0)) == -1) + return errres; +#endif + + for (off = 0, err = 0; !err && _RkReadHeader(fd, &hd, off) >= 0;) { + + if (hd.flag[HD_CODM] > 0) { + _RkClearHeader(&hd); + break; + } + nd.time = hd.data[HD_TIME].var; + nd.rec = hd.data[HD_REC].var; + nd.can = hd.data[HD_CAN].var; + nd.doff = off + hd.data[HD_HSZ].var; + nd.sz = hd.data[HD_SIZ].var; + nd.drsz = hd.data[HD_PGOF].var - hd.data[HD_DROF].var; + nd.pgsz = _RkCalcUnlog2(hd.data[HD_L2P].var) + 1; + nd.ttlpg = hd.data[HD_PAG].var; + nd.fd = fd; + nd.buf = (unsigned char *)0; + nd.pgs = (struct NP *)0; + off += hd.data[HD_SIZ].var; + if (!strncmp(".swd", + (char *)(hd.data[HD_DMNM].ptr + + strlen((char *)hd.data[HD_DMNM].ptr) - 4), + 4)) { +#ifndef WIN + if (lseek(fd, off, 0) < 0 || read(fd, (char *)ll, 4) != 4) + err++; +#else + if (SetFilePointer(fd, off, NULL, FILE_BEGIN) == 0xFFFFFFFF || + !ReadFile(fd, (char *)ll, 4, &readsize, NULL) || readsize != 4) { + err++; + } +#endif + off += bst4_to_l(ll) + 4; + } + dmh = &df->df_members; + for (dm = dmh->dm_next; dm != dmh; dm = dm->dm_next) { + if (!strcmp((char *)dm->dm_dicname, (char *)hd.data[HD_DMNM].ptr)) { + if (!dm->dm_xdm) { + if (!(xnd = (struct ND *)malloc(sizeof(struct ND)))) + break; + dm->dm_xdm = (pointer)xnd; + *xnd = nd; + dm->dm_flags |= DM_EXIST; + dm->dm_offset = xnd->doff; + count++; + break; + } + } + } + _RkClearHeader(&hd); + } + _RkClearHeader(&hd); + df->df_size = off; + if (!count) { +#ifndef WIN + (void)close(fd); +#else + CloseHandle(fd); +#endif + return errres; + } + return (df->df_fdes = fd); +} + +int +_Rkpopen(struct DM *dm, char *dfnm, int mode, struct RkKxGram *gram) /* ARGSUSED */ +{ + struct DF *df; + struct DD *dd; + struct ND *xdm; + int writable, i, readsize; +#ifndef WIN + int fd; +#else + HANDLE fd; +#endif + + if (!(df = dm->dm_file) || !(dd = df->df_direct)) + return -1; + if (!df->df_rcount) { +#ifndef WIN + if ((df->df_fdes = (long)openDF(df, dfnm, &writable)) < 0) + return -1; +#else + if ((df->df_fdes = openDF(df, dfnm, &writable)) == INVALID_HANDLE_VALUE) { + return -1; + } +#endif + if (writable) + df->df_flags |= DF_WRITABLE; + else + df->df_flags &= ~DF_WRITABLE; + df->df_flags |= DF_EXIST; + dd->dd_rcount++; + } + if (!(dm->dm_flags & DM_EXIST)) + return -1; + df->df_rcount++; + xdm = (struct ND *)dm->dm_xdm; + fd = df->df_fdes; + + if (!(xdm->buf = (unsigned char *)malloc((size_t)xdm->drsz))) { + return(-1); + } + if (!(xdm->pgs + = (struct NP *)malloc((size_t)(sizeof(struct NP) * xdm->ttlpg)))) { + free(xdm->buf); + xdm->buf = (unsigned char *)0; + return(-1); + } + for (i = 0; i < (int)xdm->ttlpg; i++) { + xdm->pgs[i].lnksz = (unsigned) 0; + xdm->pgs[i].ndsz = (unsigned) 0; + xdm->pgs[i].lvo = (unsigned long) 0; + xdm->pgs[i].csn = (unsigned long) 0; + xdm->pgs[i].flags = (unsigned) 0; + xdm->pgs[i].count = 0; + xdm->pgs[i].buf = (unsigned char *) 0; + } + +#ifndef WIN + (void)lseek(fd, xdm->doff, 0); + readsize = read(fd, (char *)xdm->buf, (unsigned int) xdm->drsz); +#else + SetFilePointer(fd, xdm->doff, NULL, FILE_BEGIN); + if (!ReadFile(fd, (char *)xdm->buf, (unsigned int)xdm->drsz, + &readsize, NULL)) { + readsize = 0; + } +#endif + if (readsize != ((int) xdm->drsz)) { + free(xdm->pgs); + free(xdm->buf); + xdm->buf = (unsigned char *)0; + xdm->pgs = (struct NP *)0; + return(-1); + } + if (dm->dm_class == ND_SWD) { + struct RkKxGram *gram; + +#ifndef WIN + lseek(fd, xdm->doff + xdm->drsz + xdm->ttlpg * xdm->pgsz, 0); +#else + SetFilePointer(fd, xdm->doff + xdm->drsz + xdm->ttlpg * xdm->pgsz, NULL, + FILE_BEGIN); +#endif + gram = RkReadGram(fd); + if (gram) { + dm->dm_gram = (struct RkGram *)malloc(sizeof(struct RkGram)); + if (dm->dm_gram) { + dm->dm_gram->gramdic = gram; + dm->dm_gram->P_BB = RkGetGramNum(gram, "BB"); + dm->dm_gram->P_NN = RkGetGramNum(gram, "NN"); + dm->dm_gram->P_T00 = RkGetGramNum(gram, "T00"); + dm->dm_gram->P_T30 = RkGetGramNum(gram, "T30"); + dm->dm_gram->P_T35 = RkGetGramNum(gram, "T35"); +#ifdef FUJIEDA_HACK + dm->dm_gram->P_KJ = RkGetGramNum(gram, "KJ"); +#endif + dm->dm_gram->refcount = 1; + goto next; + } + RkCloseGram(gram); + } + } + + next: + if ((mode & DM_WRITABLE) && (df->df_flags & DF_WRITABLE)) { + dm->dm_flags |= DM_WRITABLE; + } + return 0; +} + +int +_Rkpclose(struct DM *dm, char *dfnm, struct RkKxGram *gram) /* ARGSUSED */ +{ + struct DF *df = dm->dm_file; + struct ND *xdm = (struct ND *)dm->dm_xdm; + int i; + + _RkKillCache(dm); + if (dm->dm_gram) { + dm->dm_gram->refcount--; + if (dm->dm_gram->refcount == 0) { + (void)RkCloseGram(dm->dm_gram->gramdic); + free(dm->dm_gram); + } + } + if (xdm) { + if (xdm->pgs) { + for (i = 0; i < (int)xdm->ttlpg; i++) + if (xdm->pgs[i].flags & RK_PG_LOADED) { +#ifdef MMAP + if (((int) (xdm->pgs[i].buf)) != -1) + munmap((caddr_t)xdm->pgs[i].buf, xdm->pgsz); +#else + if (xdm->pgs[i].buf) { + free(xdm->pgs[i].buf); + } +#endif + xdm->pgs[i].flags &= ~RK_PG_LOADED; + } + free(xdm->pgs); + xdm->pgs = (struct NP *)0; + } + if (xdm->buf) { + free( xdm->buf); + xdm->buf = (unsigned char *)0; + } + } + + if (--df->df_rcount == 0) { +#ifndef WIN + int fd; +#else + HANDLE fd; +#endif + struct DM *dmh, *ddm; + + fd = df->df_fdes; + +#ifndef WIN + (void)close(fd); +#else + CloseHandle(fd); +#endif + dmh = &df->df_members; + for (ddm = dmh->dm_next; ddm != dmh; ddm = ddm->dm_next) { + xdm = (struct ND *)ddm->dm_xdm; + if (xdm) { + free(xdm); + ddm->dm_xdm = (pointer)0; + } + } + } + return 0; +} + +static +unsigned char * +assurep(struct ND *dic, int id) +{ + off_t off = dic->doff + dic->drsz + dic->pgsz * id; + unsigned size = dic->pgsz; + unsigned char *buf; + int i; +#ifndef WIN + int fd; +#else + HANDLE fd; +#endif + + fd = dic->fd; + if (!dic->pgs) + return((unsigned char *)0); + if ((unsigned)id >= dic->ttlpg) + return((unsigned char *)0); + if (!isLoadedPage(dic->pgs + id)) { +#ifdef WIN + for(i = 0; i < (int)dic->ttlpg; i++) { + if (dic->pgs[i].flags & RK_PG_LOADED) { + if (_RkDoInvalidateCache((long)dic->pgs[i].buf, dic->pgsz) == 1) { + if (dic->pgs[i].buf) { + free(dic->pgs[i].buf); + } + + dic->pgs[i].buf = (unsigned char *)0; + + dic->pgs[i].lnksz = (unsigned) 0; + dic->pgs[i].ndsz = (unsigned) 0; + dic->pgs[i].lvo = (unsigned) 0; + dic->pgs[i].csn = (unsigned) 0; + dic->pgs[i].flags = (unsigned) 0; + dic->pgs[i].count = 0; + } + } + } +#endif + +#ifdef MMAP + buf = (unsigned char *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd_dic, 0); + if ((int)buf == -1) + return((unsigned char *)0); +#else + if (!(buf = (unsigned char *)malloc(size))) + return((unsigned char *)0); +#endif +#ifndef WIN + (void)lseek(fd, off, 0); + if (read(fd, (char *)buf, size) != (int)size) { + free(buf); + return((unsigned char *)0); + } +#else + SetFilePointer(fd, off, NULL, FILE_BEGIN); + { + DWORD foo; + + if (!ReadFile(fd, (char *)buf, size, &foo, NULL) || + foo != size) { + free(buf); + return (unsigned char *)0; + } + } +#endif + + dic->pgs[id].buf = buf; + dic->pgs[id].count = 0; + dic->pgs[id].flags |= RK_PG_LOADED; + dic->pgs[id].ndsz = bst2_to_s(buf + 2); + dic->pgs[id].lnksz = bst2_to_s(buf + 4); + dic->pgs[id].lvo = bst3_to_l(buf + 7); + dic->pgs[id].csn = bst3_to_l(buf + 10); + return(buf); + } else { + return(dic->pgs[id].buf); + } +} + +int +_RkEql(WCHAR_T *a, unsigned char *b, int n) +{ + WCHAR_T c, d; + for (; n-- > 0; b += 2) { + c = uniqAlnum(*a++); + d = (*b << 8) | *(b+1); + if (c != d) + return(0); + } + return(1); +} + +static +readThisCache(struct DM *dm, struct ND *xdm, long pgno, unsigned long val, WCHAR_T *key, int cur, int ylen, struct nread *nread, int mc, int nc, int *cf) +{ + int remlen; + unsigned char *wrec1, *wrec; + + if (xdm->pgs[pgno].buf) { + if (*(wrec1 = wrec = xdm->pgs[pgno].buf + val) & 0x80) + wrec1 += 2; + wrec1 += 2; + remlen = (*wrec >> 1) & 0x3f; + if (_RkEql(key + cur, (unsigned char *)wrec1, remlen)) { + if (remlen + cur > ylen) + (*cf)++; + else if (nc < mc) { + nread[nc].cache = _RkReadCache(dm, (long)wrec); + if (nread[nc].cache) { + if (_RkGetLink(xdm, pgno, val, &nread[nc].offset, &nread[nc].csn) < 0) { + _RkDerefCache(nread[nc].cache); + return(0); + } + nread[nc].nk = cur + remlen; + nc++; + } else + (*cf)++; + } else + (*cf)++; + } + } + return(nc); +} + +static int +SearchInPage(struct DM *dm, struct ND *xdm, long pgno, unsigned char *buf, unsigned long val, WCHAR_T *key, int cur, int ylen, struct nread *nread, int mc, int nc, int *cf) +{ + WCHAR_T kv, wc; + unsigned char *pos = buf + val; + + if (!*pos && !*(pos + 1)) { + val = ((*(pos + 2) & 0x3f) << BIT_UNIT) | *(pos + 3); + nc = readThisCache(dm, xdm, pgno, val, key, + cur, ylen, nread, mc, nc, cf); + if (*(pos + 2) & LAST_NODE) + return(nc); + pos += 4; + } + if (cur == ylen) { + (*cf)++; + return(nc); + } + kv = uniqAlnum(*(key + cur)); + for (wc = bst2_to_s(pos); wc != kv; pos += 4, wc = bst2_to_s(pos)) { + if (*(pos + 2) & LAST_NODE) + return(nc); + } + val = ((*(pos + 2) & 0x3f) << BIT_UNIT) | *(pos + 3); + cur++; + if (*(pos + 2) & WORD_NODE) + nc = readThisCache(dm, xdm, pgno, val, key, + cur, ylen, nread, mc, nc, cf); + else + nc = SearchInPage(dm, xdm, pgno, buf, val, key, + cur, ylen, nread, mc, nc, cf); + return(nc); +} + +static int +SearchInDir(struct DM *dm, struct ND *xdm, unsigned char *pos, WCHAR_T *key, int cur, int ylen, struct nread *nread, int mc, int nc, int *cf) +{ + WCHAR_T kv, wc, nw; + unsigned long val; + long next, pgno, iw; + unsigned char *p; + + nw = bst2_to_s(pos); + pos += 5; + if (!*pos && !*(pos + 1)) { + val = bst3_to_l(pos + 2); + if (val & ~VMASK) { + val &= VMASK; + pgno = (val - xdm->drsz) / xdm->pgsz; + val -= pgno * xdm->pgsz + xdm->drsz; + if (assurep(xdm, pgno)) + nc = readThisCache(dm, xdm, pgno, val, key, + cur, ylen, nread, mc, nc, cf); + } + } + if (cur == ylen) { + (*cf)++; + return(nc); + } + kv = uniqAlnum(*(key + cur)); + next = (int)(kv % nw); + do { + p = pos + (((WCHAR_T) next++) % nw) * 5; + if ((wc = bst2_to_s(p)) == 0xffff) + return(nc); + } while (wc != kv); + val = bst3_to_l(p + 2); + cur++; + iw = (val & ~VMASK); + val &= VMASK; + if (iw) { + pgno = (val - xdm->drsz) / xdm->pgsz; + val -= pgno * xdm->pgsz + xdm->drsz; + if (assurep(xdm, pgno)) + nc = readThisCache(dm, xdm, pgno, val, key, + cur, ylen, nread, mc, nc, cf); + } else { + if (val < xdm->drsz) + nc = SearchInDir(dm, xdm, xdm->buf + val, key, + cur, ylen, nread, mc, nc, cf); + else { + pgno = (val - xdm->drsz) / xdm->pgsz; + val -= pgno * xdm->pgsz + xdm->drsz; + p = assurep(xdm, pgno); + if (p) + nc = SearchInPage(dm, xdm, pgno, p, val, key, + cur, ylen, nread, mc, nc, cf); + } + } + return(nc); +} + +int +_Rkpsearch(struct RkContext *cx, struct DM *dm, WCHAR_T *key, int n, struct nread *nread, int mc, int *cf) +/* ARGSUSED */ +{ + struct ND *xdm; + + *cf = 0; + xdm = (struct ND *)dm->dm_xdm; + if (xdm) { + if (xdm->buf) + return(SearchInDir(dm, xdm, xdm->buf, key, 0, n, nread, mc, 0, cf)); + } + return(0); +} + +int +_Rkpio(struct DM *dm, struct ncache *cp, int io) +/* ARGSUSED */ +{ + if (io == 0) { + cp->nc_word = (Wrec *)cp->nc_address; + cp->nc_flags |= NC_NHEAP; + } + return 0; +} + +#if 0 /* »È¤ï¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¤È¤ê¤¢¤¨¤º¥³¥á¥ó¥È¤Ë¤¹¤ë */ +static void +ch_perm(struct DM *qm, unsigned offset, int size, int num) +{ + unsigned char tmp[8192]; + /* I leave this stack located array because of it is not used */ + + if (num > 0) { + _RkCopyBits(tmp, 0, size, qm->dm_qbits, offset, num); + _RkCopyBits(qm->dm_qbits, offset + 0, size, + qm->dm_qbits, offset + num*size, 1); + _RkCopyBits(qm->dm_qbits, offset + size, size, tmp, 0, num); + } +} +#endif + +#define PERM_WRECSIZE 2048 +#define PERM_NREADSIZE 128 + +int +_Rkpctl(struct DM *dm, struct DM *qm, int what, WCHAR_T *arg, struct RkKxGram *gram) +{ + int nc, cf = 0, ret = -1; + struct ND *xdm; + unsigned long lucks[2]; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + Wrec wrec[PERM_WRECSIZE]; + WCHAR_T key[64]; + struct nread nread[PERM_NREADSIZE]; + unsigned permutation[RK_CAND_NMAX]; +#else + Wrec *wrec; + WCHAR_T *key; + struct nread *nread; + unsigned *permutation; + wrec = (Wrec *)malloc(sizeof(Wrec) * PERM_WRECSIZE); + key = (WCHAR_T *)malloc(sizeof(WCHAR_T) * 64); + nread = (struct nread *)malloc(sizeof(struct nread) * PERM_NREADSIZE); + permutation = (unsigned *)malloc(sizeof(unsigned) * RK_CAND_NMAX); + if (!wrec || !key || !nread || !permutation) { + if (wrec) free(wrec); + if (key) free(key); + if (nread) free(nread); + if (permutation) free(permutation); + return ret; + } +#endif + + if (!dm || !qm || (qm && !qm->dm_qbits)) { + goto done; + } + + if ((qm->dm_flags & (DM_WRITABLE | DM_WRITEOK)) == + (DM_WRITABLE | DM_WRITEOK)) { + /* (writable and write ok) */ + + if (RkParseOWrec(gram, arg, wrec, PERM_WRECSIZE, lucks)) { + Wrec *p, *q, *kanji; + WCHAR_T *wkey; + int maxcache = PERM_NREADSIZE; + int ylen, klen, cnum, y_off = 2, k_off; + + + ylen = (wrec[0] >> 1) & 0x3f; + if (wrec[0] & 0x80) + y_off += 2; + p = wrec + y_off; + q = p + (ylen * 2); + for (wkey = key; p < q ; wkey++) { + *wkey = (*p << 8) | *(p + 1); + p += 2; + } + *(key+ylen) = 0; + + /* Éʻ졢´Á»ú¾ðÊó¤Î¼è¤ê½Ð¤· */ + k_off = y_off + ylen * 2; + klen = (wrec[k_off] >> 1) & 0x7f; + cnum = ((wrec[k_off] & 0x01) << 8) | wrec[k_off+1]; + kanji = wrec + k_off + 2; + + nc = -1; + xdm = (struct ND *)dm->dm_xdm; + if (xdm) { + if (xdm->buf) + nc = SearchInDir(dm, xdm, xdm->buf, key, 0, ylen, nread, + maxcache, 0, &cf); + } + + if (nc > 0) { + struct nread *thisRead; + struct ncache *thisCache; + unsigned char *wp; + int nk, nl, pre; + unsigned long offset; + int bitSize, fnum = -1, nnum, i; + + for (i = 0 ; i < nc ; i++) { + if (nread[i].nk == ylen) { + break; + } + } + /* »È¤ï¤Ê¤¤Ã±¸ì¸õÊä¤Ï¤¢¤é¤«¤¸¤á _RkDerefCache ¤¹¤ë */ + for (pre = 0 ; pre < nc ; pre++) { + if (pre != i) { + thisRead = nread + pre; + thisCache = thisRead->cache; + _RkDerefCache(thisCache); + } + } + + if (i < nc) { + thisRead = nread + i; + thisCache = thisRead->cache; + wp = thisCache->nc_word; + + nk = _RkCandNumber(wp); + nl = (*wp >> 1) & 0x3f; + if (*wp & 0x80) + wp += 2; + wp += 2 + nl *2; + + /* ¤³¤³¤ÎÉôʬ¤Ç¼­½ñ¤Î²¿ÈÖÌܤˤǤƤ¯¤ë¤« (fnum) ¤òõ¤¹ */ + for (i = 0; i < nk; i++) { + unsigned char *kp; + + nl = (*wp >> 1) & 0x7f; /* ¸õÊäĹ */ + nnum = ((*wp & 0x01) << 8) | *(wp+1); /* ÉÊ»ìÈÖ¹æ */ + if (nl == klen && nnum == cnum) { + int lc; + + for (lc = 0, kp = wp + 2; lc < klen*2; lc++) { + if (*(kanji+lc) != *(kp+lc)) + break; + } + if (lc == klen*2) { + fnum = i; + break; + } + } + wp += 2 + nl*2; + } + + offset = thisRead->offset; + if (fnum >= 0 && fnum < nk && 0 < thisRead->nk && + thisRead->nk <= ylen && thisRead->nk <= RK_KEY_WMAX) { + int ecount, cval, i, dn = -1, ndel = 0; + + bitSize = _RkCalcLog2(nk + 1) + 1; + _RkUnpackBits(permutation, qm->dm_qbits, offset, bitSize, nk); + switch (what) { + case DST_DoDefine: + for (ecount = cval = i = 0; i < nk; i++) { + if ((int)permutation[i]/2 > nk) { + ecount++; + break; + }; + cval += permutation[i]; + if ((unsigned)nk == permutation[i]/2 && dn < 0) + dn = i; + if ((unsigned)fnum == permutation[i]/2) { + ndel = -1; + dn = i; + } + } + break; + case DST_DoDelete: + for (ecount = cval = i = 0; i < nk; i++) { + if ((int)permutation[i]/2 > nk) { + ecount++; + break; + }; + cval += permutation[i]; + if ((unsigned)fnum == permutation[i]/2) + dn = i; + }; + break; + } + if (ecount || cval < (nk-1)*(nk-2)) { + for (i = 0; i < nk; i++) + permutation[i] = 2*i; + _RkPackBits(qm->dm_qbits, offset, bitSize, permutation, nk); + } else { + if (dn >= 0) { + if (!ndel) { + switch (what) { + case DST_DoDefine: + _RkSetBitNum(qm->dm_qbits, offset, bitSize, dn, fnum*2); +/* ¤³¤³¤Ïʤӽç¤òÊѹ¹¤¹¤ë´Ø¿ô¤À¤¬¤È¤ê¤¢¤¨¤º¥³¥á¥ó¥È¤Ë¤¹¤ë¡£ + ch_perm(qm, offset, bitSize, dn); +*/ + break; + case DST_DoDelete: + _RkSetBitNum(qm->dm_qbits, offset, bitSize, dn, nk*2); + break; + } + qm->dm_flags |= DM_UPDATED; + } + _RkDerefCache(thisCache); + ret = 0; + goto done; + } + } + } + _RkDerefCache(thisCache); + } + } + } + } + done: +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(wrec); + free(key); + free(nread); + free(permutation); +#endif + return ret; +} + +int +_Rkpsync(struct RkContext *cx, struct DM *dm, struct DM *qm) +{ + struct DF *df; + struct DD *dd; +#ifdef MMAP + struct ND *dic; +#endif + char *file; + + if (qm) { + df = qm->dm_file; + dd = df->df_direct; + file = _RkCreatePath(dd, df->df_link); + if (file) { + int i; +#ifdef MMAP + int j; +#endif + i = FQsync(cx, dm, qm, file); + free(file); +#ifdef MMAP + dic = (struct ND *)dm->dm_xdm; + if(dic) + for(j=0;jttlpg;j++) { + if (isLoadedPage(dic->pgs + j)) + if (_RkDoInvalidateCache(dic->pgs[j].buf, dic->pgsz) == 1) { + if (((int) (dic->pgs[j].buf)) != -1) + munmap((caddr_t)dic->pgs[j].buf, dic->pgsz); + dic->pgs[j].buf = (unsigned char *)0; + dic->pgs[j].lnksz = (unsigned) 0; + dic->pgs[j].ndsz = (unsigned) 0; + dic->pgs[j].lvo = (unsigned) 0; + dic->pgs[j].csn = (unsigned) 0; + dic->pgs[j].flags = (unsigned) 0; + dic->pgs[j].count = 0; + } + } +#endif + return (i); + } + } + return (0); +} diff --git a/src/add-ons/input_server/methods/canna/rk/tempdic.c b/src/add-ons/input_server/methods/canna/rk/tempdic.c new file mode 100644 index 0000000000..6d6a9c53ff --- /dev/null +++ b/src/add-ons/input_server/methods/canna/rk/tempdic.c @@ -0,0 +1,787 @@ +/* Copyright 1994 NEC Corporation, Tokyo, Japan. +* +* Permission to use, copy, modify, distribute and sell this software +* and its documentation for any purpose is hereby granted without +* fee, provided that the above copyright notice appear in all copies +* and that both that copyright notice and this permission notice +* appear in supporting documentation, and that the name of NEC +* Corporation not be used in advertising or publicity pertaining to +* distribution of the software without specific, written prior +* permission. NEC Corporation makes no representations about the +* suitability of this software for any purpose. It is provided "as +* is" without express or implied warranty. +* +* NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN +* NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR +* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +* OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +* PERFORMANCE OF THIS SOFTWARE. +*/ + +#if !defined(lint) && !defined(__CODECENTER__) + static char rcsid[]="$Id: tempdic.c,v 1.1 2004/12/23 21:23:50 korli Exp $"; +#endif +/*LINTLIBRARY*/ + +#include "RKintern.h" + +#include +#include +#include +#include +#include +#include + +#define dm_td dm_extdata.ptr + +static void freeTD(struct TD *td); +static TD *newTD(void); +static TN *extendTD(struct TD *tdic, WCHAR_T key, struct TW *tw); +static yomi_equal(Wrec *x, Wrec *y, int n); +static WCHAR_T nthKey(Wrec *w, int n); +static TN *defineTD(struct DM *dm, struct TD *tab, int n, struct TW *newTW, int nlen); +static enterTD(struct DM *dm, struct TD *td, struct RkKxGram *gram, WCHAR_T *word); +static void shrinkTD(struct TD *td, WCHAR_T key); +static int deleteTD(struct DM *dm, struct TD **tab, int n, Wrec *newW); + +static void +freeTD(struct TD *td) +{ + int i; + for (i = 0; i < (int)td->td_n; i++) { + struct TN *tn = &td->td_node[i]; + if (IsWordNode(tn)) { + free(tn->tn_word->word); + free(tn->tn_word); + } else + freeTD(tn->tn_tree); + } + if (td) { + if (td->td_node) + free(td->td_node); + free(td); + } +} + +/* newTD: allocates a fresh node */ +static TD * +newTD(void) +{ + struct TD *td; + + td = (struct TD *)malloc(sizeof(struct TD)); + if (td) { + td->td_n = 0; + td->td_max = 1; + if (!(td->td_node = (struct TN *)calloc(td->td_max, sizeof(struct TN)))) { + freeTD(td); + return((struct TD *)0); + } + } + return(td); +} + +/* +* INSERT +*/ +static TN * +extendTD(struct TD *tdic, WCHAR_T key, struct TW *tw) +{ + int i, j; + struct TN *tp; + struct TW *ntw; + + if (!(ntw = RkCopyWrec(tw))) + return (struct TN *)0; + tp = tdic->td_node; + if (tdic->td_n >= tdic->td_max) { + if (!(tp = (struct TN *)calloc(tdic->td_max + 1, sizeof(struct TN)))) { + free(ntw->word); + free(ntw); + return (struct TN *)0; + } + for (i = 0; i < (int)tdic->td_n; i++) + tp[i] = tdic->td_node[i]; + free(tdic->td_node); + tdic->td_max++; + tdic->td_node = tp; + } + for (i = 0; i < (int)tdic->td_n; i++) + if (key < tp[i].tn_key) + break; + for (j = tdic->td_n; j > i; j--) + tp[j] = tp[j - 1]; + tp[i].tn_flags = TN_WORD|TN_WDEF; + tp[i].tn_key = key; + tp[i].tn_word = ntw; + tdic->td_n++; + return(tp + i); +} + +static +yomi_equal(Wrec *x, Wrec *y, int n) +{ + int l; + + if ((l = (*y >> 1) & 0x3f) == ((*x >> 1) & 0x3f)) { + if (*y & 0x80) + y += 2; + if (*x & 0x80) + x += 2; + x += (n << 1) + 2; + y += (n << 1) + 2; + for (; n < l ; n++) { + if (*x++ != *y++ || *x++ != *y++) + return(0); + } + return(1); + } + return(0); +} + +static +WCHAR_T +nthKey(Wrec *w, int n) +{ +if (n < (int)((*w >> 1) & 0x3f)) { + if (*w & 0x80) + w += 2; + w += (n << 1) + 2; + return((WCHAR_T)((w[0] << 8) | w[1])); +} else + return((WCHAR_T)0); +} + +/* +* defineTD -- ¥Æ¥­¥¹¥È¼­½ñ¤ËÄêµÁ¤¹¤ë +* +* °ú¿ô +* dm ¼­½ñ +* tab ¥Æ¥­¥¹¥È¼­½ñ¥Ý¥¤¥ó¥¿ +* n ²¿Ê¸»úÌܤ«(ñ°Ì:ʸ»ú) + * newW ÅÐÏ¿¤¹¤ë¥ï¡¼¥É¥ì¥³¡¼¥É +* nlen ÉÔÌÀ +*/ + +static TN * +defineTD(struct DM *dm, struct TD *tab, int n, struct TW *newTW, int nlen) +{ + int i; + WCHAR_T key; + struct TN *tn; + struct ncache *cache; + struct TW *mergeTW, *oldTW; + Wrec *oldW, *newW = newTW->word; + + key = nthKey(newW, n); n++; + tn = tab->td_node; + for (i = 0; i < (int)tab->td_n && tn->tn_key <= key; i++, tn++) { + if (key == tn->tn_key) { + if (IsWordNode(tn)) { + struct TD *td; + + oldTW = tn->tn_word; + oldW = oldTW->word; + if (!key|| yomi_equal(newW, oldW, n)) { + if ((cache = _RkFindCache(dm, (long)oldTW)) && cache->nc_count > 0) + return((struct TN *)0); + if (!(mergeTW = RkUnionWrec(newTW, oldTW))) + return((struct TN *)0); + tn->tn_word = mergeTW; + free(oldW); + free(oldTW); + tn->tn_flags |= TN_WDEF; + if (cache) { + _RkRehashCache(cache, (long)tn->tn_word); + cache->nc_word = mergeTW->word; + } + return tn; + } + if (!(td = newTD())) + return((struct TN *)0); + td->td_n = 1; + key = nthKey(oldW, n); + td->td_node[0].tn_key = key; + td->td_node[0].tn_flags |= TN_WORD; + td->td_node[0].tn_word = oldTW; + tn->tn_flags &= ~TN_WORD; + tn->tn_tree = td; + } + return defineTD(dm, tn->tn_tree, n, newTW, nlen); + } + } + return extendTD(tab, key, newTW); +} + +static +enterTD(struct DM *dm, struct TD *td, struct RkKxGram *gram, WCHAR_T *word) +{ + struct TW tw; + int ret = -1; +#ifndef USE_MALLOC_FOR_BIG_ARRAY + Wrec wrec[RK_LINE_BMAX*10]; +#else + Wrec *wrec = (Wrec *)malloc(sizeof(Wrec) * RK_LINE_BMAX * 10); + if (!wrec) { + return ret; + } +#endif + + if (word[0] == (WCHAR_T)'#') { + ret = 1; + } +else if (RkParseOWrec(gram, word, wrec, RK_LINE_BMAX * 10, tw.lucks)) { + struct TN *tn; + + tw.word = wrec; + tn = defineTD(dm, td, 0, &tw, RK_LINE_BMAX * 10); + if (tn) { + tn->tn_flags &= ~(TN_WDEF|TN_WDEL); + ret = 0; + } else { + ret = -1; + } +} +else { +ret = 1; +} +#ifdef USE_MALLOC_FOR_BIG_ARRAY + free(wrec); +#endif + return ret; +} + +/* +* DELETE +*/ +static void +shrinkTD(struct TD *td, WCHAR_T key) +{ + int i; + struct TN *tn = td->td_node; + + for (i = 0; i < (int)td->td_n; i++) { + if (key == tn[i].tn_key) { + while (++i < (int)td->td_n) tn[i - 1] = tn[i]; + td->td_n--; + break; + } + } +} + +/* +* deleteTD -- ¥Æ¥­¥¹¥È¼­½ñ¤«¤éñ¸ìÄêµÁ¤ò¼è¤ê½ü¤¯ +* +* °ú¿ô +* dm ¼­½ñ +* tab ¥Æ¥­¥¹¥È¼­½ñ +* n ²¿Ê¸»úÌܤ« +* newW ÄêµÁ¤¹¤ë¥ï¡¼¥É¥ì¥³¡¼¥É +*/ +static int +deleteTD(struct DM *dm, struct TD **tab, int n, Wrec *newW) +{ + struct TD *td = *tab; + int i; + WCHAR_T key; + + key = nthKey(newW, n); n ++; + for (i = 0; i < (int)td->td_n; i++) { + struct TN *tn = &td->td_node[i]; + + if (key == tn->tn_key ) { + if (IsWordNode(tn)) { + struct TW *oldTW = tn->tn_word; + Wrec *oldW = oldTW->word; + + if (!key || yomi_equal(newW, oldW, n)) { + struct ncache *cache = _RkFindCache(dm, (long)oldTW); + + if (!cache || cache->nc_count <= 0) { + struct TW *subW, newTW; + + newTW.word = newW; + subW = RkSubtractWrec(oldTW, &newTW); + free(oldW); + free(oldTW); + if (subW) { + tn->tn_word = subW; + tn->tn_flags |= TN_WDEL; + if (cache) { + _RkRehashCache(cache, (long)subW); + cache->nc_word = subW->word; + } + return(0); + } else { + if (cache) + _RkPurgeCache(cache); + shrinkTD(td, key); + } + } + } + } else + if (deleteTD(dm, &tn->tn_tree, n, newW)) + shrinkTD(td, key); + if (td->td_n <= 0) { + free((td->td_node)); + free(td); + *tab = (struct TD *)0; + return(1); + } else + return(0); + } + } + return(0); +} + +/* +* OPEN +*/ +/*ARGSUSED*/ +int +_Rktopen( + struct DM *dm, + char *file, + int mode, + struct RkKxGram *gram) +{ + struct DF *df = dm->dm_file; + struct DD *dd = df->df_direct; + struct TD *xdm; + FILE *f; + long offset = 0L; + int ecount = 0; + int ret = -1; + char *line = (char *)malloc(RK_LINE_BMAX * 10); + WCHAR_T *wcline = (WCHAR_T *)malloc(sizeof(WCHAR_T) * RK_LINE_BMAX * 10); + if (!line || !wcline) { + if (line) free(line); + if (wcline) free(wcline); + return ret; + } + + if (!df->df_rcount) { + if (close(open(file, 0))) + goto return_ret; + df->df_flags |= DF_EXIST; + dm->dm_flags |= DM_EXIST; + if (!close(open(file, 2))) + dm->dm_flags |= DM_WRITABLE; + } + if (!(dm->dm_flags & DM_EXIST)) + ; + else if (!(f = fopen(file, "r"))) { + df->df_flags &= ~DF_EXIST; + dm->dm_flags &= ~DM_EXIST; + } +else if (!(xdm = newTD())) { + fclose(f); +} +else { +while (fgets((char *)line, RK_LINE_BMAX*10, f)) +{ + int sz; + + offset += strlen(line); + sz = RkCvtWide(wcline, RK_LINE_BMAX*10, line, strlen(line)); + if (sz < RK_LINE_BMAX*10 - 1) { + if ( enterTD(dm, xdm, gram, wcline) < 0 ) + ecount++; + } else + ecount++; +} +(void)fclose(f); +dm->dm_offset = 0L; +df->df_size = offset; +if (ecount) { + freeTD((struct TD *)xdm); + dm->dm_td = (pointer)0; + dm->dm_flags &= ~DM_EXIST; + ret = -1; + } else { + dm->dm_td = (pointer)xdm; + if (df->df_rcount++ == 0) + dd->dd_rcount++; + ret = 0; +}; +} +return_ret: + free(wcline); + free(line); + return ret; +} + +/* +* CLOSE +*/ +static int writeTD (struct TD *, struct RkKxGram *, int); + +static int +writeTD( + struct TD *td, + struct RkKxGram *gram, + int fdes +) +{ + int i, tmpres; + int ecount = 0; + WCHAR_T *wcline = (WCHAR_T *)0; + + wcline = (WCHAR_T *)malloc(RK_WREC_BMAX * sizeof(WCHAR_T)); + if (wcline) { + for (i = 0; i < (int)td->td_n; i++) { + struct TN *tn = &td->td_node[i]; + unsigned char *line; + WCHAR_T *wc; + int sz; + + if (IsWordNode(tn)) { + wc = _RkUparseWrec(gram, tn->tn_word->word, wcline, + RK_LINE_BMAX * sizeof(WCHAR_T), tn->tn_word->lucks, 1); + if (wc) { + sz = RkCvtNarrow((char *)0, 9999, wcline, (int)(wc - wcline)); + if (sz > RK_LINE_BMAX + && !(wc = _RkUparseWrec(gram, tn->tn_word->word, wcline, + RK_LINE_BMAX * sizeof(WCHAR_T), tn->tn_word->lucks, 0))) + ecount++; + else { + line = (unsigned char *)malloc( RK_LINE_BMAX*3 ); + if(line) { + sz = RkCvtNarrow((char *)line, RK_LINE_BMAX, + wcline, (int)(wc - wcline)); + line[sz++] = '\n'; + line[sz] = 0; + tmpres = write(fdes, line, sz); + if (tmpres != sz) + ecount++; + free(line); + } else + ecount++; + } + } else + ecount++; + } else + ecount += writeTD(tn->tn_tree, gram, fdes); + } + free(wcline); + return(ecount); + } + return 0; +} + +int +_Rktclose( + struct DM *dm, + char *file, + struct RkKxGram *gram) +{ + struct DF *df = dm->dm_file; + struct TD *xdm = (struct TD *)dm->dm_td; + int ecount; + int fdes; + char *backup, *header, *whattime; + backup = (char *)malloc(RK_PATH_BMAX); + header = (char *)malloc(RK_LINE_BMAX); + whattime = (char *)malloc(RK_LINE_BMAX); + if (!backup || !header || !whattime) { + if (backup) free(backup); + if (header) free(header); + if (whattime) free(whattime); + return 0; + } + + _RkKillCache(dm); + if (dm->dm_flags & DM_UPDATED) { + char *p = rindex(file, '/'); + + if (p) { + strcpy(backup, file); + p++; + backup[(int)(p - file)] = '#'; + strcpy(&backup[(int)(p-file) + 1], p); + }; + + fdes = creat(backup, (unsigned)0666); + ecount = 0; + if + (fdes >= 0) + { + int n; + + time_t tloc; + + tloc = time(0); + strcpy(whattime, ctime(&tloc)); + whattime[strlen(whattime)-1] = 0; + n = sprintf(header, "#*DIC %s [%s]\n", dm->dm_nickname, whattime); + //n = strlen(header); + if + (write(fdes, header, n) != n) + { + ecount++; + } + ecount += writeTD(xdm, gram, fdes); + (void)close(fdes); + } else + ecount++; + + if (!ecount) { + rename(backup, file); + } + dm->dm_flags &= ~DM_UPDATED; + }; + freeTD((struct TD *)xdm); + + --df->df_rcount; + free(backup); + free(header); + free(whattime); + return 0; +} + +int +_Rktsearch( + struct RkContext *cx, + struct DM *dm, + WCHAR_T *key, + int n, + struct nread *nread, + int maxcache, + int *cf) +{ + struct TD *xdm = (struct TD *)dm->dm_td; + int nc = 0; + int i, j; + + *cf = 0; + for (j = 0; j < n;) { + WCHAR_T k = uniqAlnum(key[j++]); + struct TN *tn; + + tn = xdm->td_node; + for (i = 0; i < (int)xdm->td_n && tn->tn_key <= k; i++, tn++) { + if (k == tn->tn_key) { + if (IsWordNode(tn)) { + Wrec *w; + int l; + + w = tn->tn_word->word; + l = (*w >> 1) & 0x3f; + if (*w & 0x80) + w += 2; + w += 2; + if (_RkEql(key, w, l)) { + if (l > n) + (*cf)++; + else if (nc < maxcache) { + nread[nc].cache = _RkReadCache(dm, (long)tn->tn_word); + if (nread[nc].cache) { + nread[nc].nk = l; + nread[nc].csn = 0L; + nread[nc].offset = 0L; + nc++; + } else + (*cf)++; + } else + (*cf)++; + } + return nc; + } else { + struct TD *ct = tn->tn_tree; + struct TN *n0 = &ct->td_node[0]; + + if (ct->td_n && !n0->tn_key) { + unsigned char *w; + int l; + w = n0->tn_word->word; + l = (*w >> 1) & 0x3f; + if (*w & 0x80) + w += 2; + w += 2; + if (_RkEql(key, w, l)) { + if (l > n) + (*cf)++; + else if (nc < maxcache) { + nread[nc].cache = _RkReadCache(dm, (long)n0->tn_word); + if (nread[nc].cache) { + nread[nc].nk = l; + nread[nc].csn = 0L; + nread[nc].offset = 0L; + nc++; + } else + (*cf)++; + } else + (*cf)++; + } + } + xdm = ct; + goto cont; + } + } + } + break; + cont: + ; + } + if (n <= 0) + cx->poss_cont++; + return nc; +} + +/* +* IO +*/ +/*ARGSUSED*/ +int +_Rktio( + struct DM *dm, + struct ncache *cp, + int io) +{ +if (io == 0) { + cp->nc_word = ((struct TW *)cp->nc_address)->word; + cp->nc_flags |= NC_NHEAP; +} + return 0; +} + +#define TEMPDIC_WRECSIZE 2048 + +/* +* CTL +*/ +int +_Rktctl( + struct DM *dm, + struct DM *qm, /* no use : dummy*/ + int what, + WCHAR_T *arg, + struct RkKxGram *gram) + /* ARGSUSED */ + { + struct TD *xdm = (struct TD *)dm->dm_td; + int status = 0; + struct TW tw; + unsigned long lucks[2]; + Wrec *wrec = (Wrec *)malloc(sizeof(Wrec) * TEMPDIC_WRECSIZE); + if (!wrec) { + return status; + } + + switch(what) { + case DST_DoDefine: + if ((dm->dm_flags & (DM_WRITABLE | DM_WRITEOK)) != + (DM_WRITABLE | DM_WRITEOK)) /* !(writable and write ok) */ + status = -1; + else if (!RkParseOWrec(gram, arg, wrec, TEMPDIC_WRECSIZE, lucks)) + status = -1; + else { + tw.word = wrec; + status = defineTD(dm, xdm, 0, &tw, TEMPDIC_WRECSIZE) ? 0 : -1; + dm->dm_flags |= DM_UPDATED; + } + break; + case DST_DoDelete: + if ((dm->dm_flags & (DM_WRITABLE | DM_WRITEOK)) != + (DM_WRITABLE | DM_WRITEOK)) /* !(writable and write ok) */ + status = -1; + else if (!RkParseOWrec(gram, arg, wrec, TEMPDIC_WRECSIZE, lucks)) + status = -1; + else if (deleteTD(dm, &xdm, 0, wrec)) { + xdm = newTD(); + dm->dm_td = (pointer)xdm; + } + dm->dm_flags |= DM_UPDATED; + break; + } + free(wrec); + return status; + } + +int +_Rktsync( + struct RkContext *cx, + struct DM *dm, + struct DM *qm) + /* ARGSUSED */ + { + struct RkKxGram *gram = cx->gram->gramdic; + struct DF *df_p; + struct DD *dd_p; + struct TD *xdm = (struct TD *)dm->dm_td; + int ecount; + char *file; + int ret = -1; + + int fdes; + + char *backup, *header, *whattime; + backup = (char *)malloc(RK_PATH_BMAX); + header = (char *)malloc(RK_LINE_BMAX); + whattime = (char *)malloc(RK_LINE_BMAX); + if (!backup || !header || !whattime) { + if (backup) free(backup); + if (header) free(header); + if (whattime) free(whattime); + return ret; + } + + df_p = dm->dm_file; + dd_p = df_p->df_direct; + file = _RkCreatePath(dd_p, df_p->df_link); + if (file) { + if (dm->dm_flags & DM_UPDATED) { + char *p = rindex(file, '/'); + + if (p) { + strcpy(backup, file); + p++; + backup[(int)(p - file)] = '#'; + strcpy(&backup[(int)(p-file) + 1], p); + }; + + fdes = creat(backup, (unsigned)0666); + ecount = 0; + if + (fdes >= 0) + { + int n; + time_t tloc; + + tloc = time(0); + strcpy(whattime, ctime(&tloc)); + whattime[strlen(whattime)-1] = 0; + n = sprintf(header, "#*DIC %s [%s]\n", dm->dm_nickname, whattime); + // n = strlen(header); + if + (write(fdes, header, n) != n) + { + ecount++; + } + ecount += writeTD(xdm, gram, fdes); + (void)close(fdes); + } else + ecount++; + + if (!ecount) { + rename(backup, file); + dm->dm_flags &= ~DM_UPDATED; + } else { + free(file); + ret = -1; + goto return_ret; + } + }; + free(file); + ret = 0; + } + return_ret: + + free(backup); + free(header); + free(whattime); + + return ret; + }