Remove Canna input method.
It is outsourced now.
This commit is contained in:
parent
4f978fe4db
commit
80891f9253
@ -1,5 +1,4 @@
|
||||
SubDir HAIKU_TOP src add-ons input_server methods ;
|
||||
|
||||
SubInclude HAIKU_TOP src add-ons input_server methods canna ;
|
||||
SubInclude HAIKU_TOP src add-ons input_server methods pen ;
|
||||
SubInclude HAIKU_TOP src add-ons input_server methods t9 ;
|
||||
|
@ -1,25 +0,0 @@
|
||||
#include <GraphicsDefs.h>
|
||||
|
||||
const int32 kSmallIconWidth = 16;
|
||||
const int32 kSmallIconHeight = 16;
|
||||
const color_space kSmallIconColorSpace = B_CMAP8;
|
||||
|
||||
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
|
||||
};
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _CANNACOMMON_H
|
||||
#define _CANNACOMMON_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
#include <Point.h>
|
||||
//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
|
@ -1,783 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#include "CannaInterface.h"
|
||||
#include <UTF8.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <Debug.h>
|
||||
#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;
|
||||
case B_DOWN_ARROW:
|
||||
return CANNA_KEY_Cntrl_Down;
|
||||
case B_RIGHT_ARROW:
|
||||
return CANNA_KEY_Cntrl_Right;
|
||||
case B_LEFT_ARROW:
|
||||
return CANNA_KEY_Cntrl_Left;
|
||||
default:
|
||||
return 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;
|
||||
|
||||
case B_INSERT:
|
||||
return CANNA_KEY_Insert;
|
||||
case B_PAGE_UP:
|
||||
return CANNA_KEY_Rollup;
|
||||
case B_PAGE_DOWN:
|
||||
return CANNA_KEY_Rolldown;
|
||||
case B_UP_ARROW:
|
||||
if (mod & B_SHIFT_KEY /* shifted */ )
|
||||
return CANNA_KEY_Shift_Up;
|
||||
return CANNA_KEY_Up;
|
||||
|
||||
case B_DOWN_ARROW:
|
||||
if (mod & B_SHIFT_KEY /* shifted */ )
|
||||
return CANNA_KEY_Shift_Down;
|
||||
return CANNA_KEY_Down;
|
||||
|
||||
case B_RIGHT_ARROW:
|
||||
if (mod & B_SHIFT_KEY /* shifted */ )
|
||||
return CANNA_KEY_Shift_Right;
|
||||
return CANNA_KEY_Right;
|
||||
|
||||
case B_LEFT_ARROW:
|
||||
if (mod & B_SHIFT_KEY /* shifted */ )
|
||||
return CANNA_KEY_Shift_Left;
|
||||
return CANNA_KEY_Left;
|
||||
|
||||
case B_END:
|
||||
return CANNA_KEY_Help;
|
||||
case B_HOME:
|
||||
return CANNA_KEY_Home;
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
CannaInterface::ConvertArrowKey(int key)
|
||||
{
|
||||
switch (key) {
|
||||
case CANNA_KEY_Up:
|
||||
return CANNA_KEY_Left;
|
||||
case CANNA_KEY_Down:
|
||||
return CANNA_KEY_Right;
|
||||
case CANNA_KEY_Shift_Up:
|
||||
return CANNA_KEY_Up;
|
||||
case CANNA_KEY_Shift_Down:
|
||||
return CANNA_KEY_Down;
|
||||
case CANNA_KEY_Right:
|
||||
return (uint8)B_RETURN;
|
||||
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 (3 bytes)
|
||||
memmove(kouhoUTF, kouhoUTF + 3, kouhoUTFLen - 2);
|
||||
|
||||
// convert full width space and following 3 bytes index to LF
|
||||
while ((index = strstr(kouhoUTF, "\xe3\x80\x80")) != NULL) {
|
||||
*index = '\x0a';
|
||||
len = strlen(index);
|
||||
memmove(index + 1, index + 6, len - 5);
|
||||
}
|
||||
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")) != NULL) {
|
||||
*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();
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _CANNA_INTERFACE_H
|
||||
#define _CANNA_INTERFACE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <Message.h>
|
||||
#include <View.h>
|
||||
#include <StorageDefs.h>
|
||||
|
||||
#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
|
@ -1,492 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#include "CannaLooper.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <Debug.h>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Input.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Messenger.h>
|
||||
#include <Path.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include "CannaCommon.h"
|
||||
#include "CannaMethod.h"
|
||||
#include "KouhoWindow.h"
|
||||
#include "PaletteWindow.h"
|
||||
|
||||
|
||||
CannaLooper::CannaLooper(CannaMethod* method)
|
||||
: BLooper("Canna Looper"),
|
||||
fOwner(method),
|
||||
fCanna(NULL),
|
||||
fKouhoWindow(NULL),
|
||||
fPaletteWindow(NULL)
|
||||
{
|
||||
fMenu = new BMenu(B_EMPTY_STRING);
|
||||
fMenu->SetFont(be_plain_font);
|
||||
fMenu->AddItem(new BMenuItem("About CannaIM" B_UTF8_ELLIPSIS,
|
||||
new BMessage( B_ABOUT_REQUESTED)));
|
||||
fMenu->AddSeparatorItem();
|
||||
fMenu->AddItem(new BMenuItem("Convert arrow keys",
|
||||
new BMessage(ARROW_KEYS_FLIPPED)));
|
||||
fMenu->AddItem(new BMenuItem("Reload Init file",
|
||||
new BMessage(RELOAD_INIT_FILE)));
|
||||
|
||||
if (gSettings.convert_arrowkey) {
|
||||
BMenuItem* item = fMenu->FindItem(ARROW_KEYS_FLIPPED);
|
||||
item->SetMarked(true);
|
||||
}
|
||||
|
||||
Run();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
CannaLooper::Init()
|
||||
{
|
||||
char basePath[B_PATH_NAME_LENGTH + 1];
|
||||
status_t err = ReadSettings(basePath);
|
||||
if (err != B_NO_ERROR)
|
||||
return err;
|
||||
|
||||
fCanna = new CannaInterface(basePath);
|
||||
|
||||
return fCanna->InitCheck();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::Quit()
|
||||
{
|
||||
// delete palette here
|
||||
SERIAL_PRINT(("CannaLooper: destructor called.\n"));
|
||||
delete fCanna;
|
||||
|
||||
if (fKouhoWindow != NULL) {
|
||||
SERIAL_PRINT(("CannaLooper: Sending QUIT to kouho window...\n"));
|
||||
|
||||
fKouhoWindow->Lock();
|
||||
fKouhoWindow->Quit();
|
||||
}
|
||||
|
||||
if (fPaletteWindow) {
|
||||
SERIAL_PRINT(("CannaLooper: Sending QUIT to palette...\n"));
|
||||
|
||||
fPaletteWindow->Lock();
|
||||
fPaletteWindow->Quit();
|
||||
}
|
||||
|
||||
fOwner->SetMenu(NULL, BMessenger());
|
||||
delete fMenu;
|
||||
BLooper::Quit();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
CannaLooper::ReadSettings(char* basePath)
|
||||
{
|
||||
BPath path;
|
||||
status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
path.Append("Canna");
|
||||
|
||||
strlcpy(basePath, path.Path(), B_PATH_NAME_LENGTH);
|
||||
strlcat(basePath, "/", B_PATH_NAME_LENGTH);
|
||||
|
||||
font_family family;
|
||||
font_style style;
|
||||
strcpy(family, "VL PGothic");
|
||||
strcpy(style, "regular");
|
||||
|
||||
fKouhoFont.SetFamilyAndStyle(family, style);
|
||||
fKouhoFont.SetSize(12);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::EnqueueMessage(BMessage* msg)
|
||||
{
|
||||
fOwner->EnqueueMessage(msg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::MessageReceived(BMessage* msg)
|
||||
{
|
||||
SERIAL_PRINT(("CannaLooper: Entering MessageReceived() what=%.4s\n",
|
||||
(char*)&msg->what));
|
||||
|
||||
switch (msg->what) {
|
||||
case B_KEY_DOWN:
|
||||
case NUM_SELECTED_FROM_KOUHO_WIN:
|
||||
_HandleKeyDown(msg);
|
||||
break;
|
||||
|
||||
case B_INPUT_METHOD_EVENT:
|
||||
uint32 opcode, result;
|
||||
msg->FindInt32("be:opcode", (int32*)&opcode);
|
||||
|
||||
switch (opcode) {
|
||||
case B_INPUT_METHOD_LOCATION_REQUEST:
|
||||
_HandleLocationReply(msg);
|
||||
break;
|
||||
|
||||
case B_INPUT_METHOD_STOPPED:
|
||||
SERIAL_PRINT(("CannaLooper: B_INPUT_METHOD_STOPPED "
|
||||
"received\n"));
|
||||
_ForceKakutei();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CANNA_METHOD_ACTIVATED:
|
||||
SERIAL_PRINT(("CannaLooper: CANNA_METHOD_ACTIVATED received\n"));
|
||||
_HandleMethodActivated(msg->HasBool("active"));
|
||||
break;
|
||||
|
||||
case MODE_CHANGED_FROM_PALETTE:
|
||||
_ForceKakutei();
|
||||
int32 mode;
|
||||
msg->FindInt32("mode", &mode);
|
||||
result = fCanna->ChangeMode(mode);
|
||||
_ProcessResult(result);
|
||||
break;
|
||||
|
||||
case B_ABOUT_REQUESTED:
|
||||
{
|
||||
SERIAL_PRINT(("CannaLooper: B_ABOUT_REQUESTED received\n"));
|
||||
|
||||
BAlert* panel = new BAlert( "", "Canna Input Method\n"
|
||||
" by Masao Kawamura 1999\n\n"
|
||||
"Canna\n"
|
||||
" Copyright 1992 NEC Corporation, Tokyo, Japan\n"
|
||||
" Special thanks to T.Murai for porting\n",
|
||||
"OK");
|
||||
panel->SetFlags(panel->Flags() | B_CLOSE_ON_ESCAPE);
|
||||
panel->Go();
|
||||
break;
|
||||
}
|
||||
|
||||
case RELOAD_INIT_FILE:
|
||||
_ForceKakutei();
|
||||
fCanna->Reset();
|
||||
break;
|
||||
|
||||
case ARROW_KEYS_FLIPPED:
|
||||
{
|
||||
BMenuItem* item = fMenu->FindItem(ARROW_KEYS_FLIPPED);
|
||||
gSettings.convert_arrowkey = !gSettings.convert_arrowkey;
|
||||
item->SetMarked(gSettings.convert_arrowkey);
|
||||
fCanna->SetConvertArrowKey(gSettings.convert_arrowkey);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BLooper::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::_HandleKeyDown(BMessage* msg)
|
||||
{
|
||||
uint32 modifier;
|
||||
int32 key;
|
||||
msg->FindInt32("modifiers", (int32*)&modifier);
|
||||
msg->FindInt32("key", &key);
|
||||
|
||||
if ((modifier & B_COMMAND_KEY) != 0) {
|
||||
EnqueueMessage(DetachCurrentMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
char character;
|
||||
msg->FindInt8("byte", (int8*)&character);
|
||||
|
||||
// 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.
|
||||
if ((character & 0x80) != 0) {
|
||||
if (fCanna->MikakuteiLength() != 0)
|
||||
delete DetachCurrentMessage();
|
||||
else
|
||||
EnqueueMessage(DetachCurrentMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: HandleKeyDown() calling "
|
||||
"CannaInterface::KeyIn()...\n"));
|
||||
|
||||
uint32 result = fCanna->KeyIn(character, modifier, key);
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: HandleKeyDown() received result = %d from "
|
||||
"CannaInterface.\n", result));
|
||||
|
||||
_ProcessResult(result);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::_ProcessResult(uint32 result)
|
||||
{
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing result = %d\n",
|
||||
result));
|
||||
|
||||
if ((result & GUIDELINE_APPEARED) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"GUIDELINE_APPEARED\n"));
|
||||
|
||||
if (fCanna->MikakuteiLength() != 0) {
|
||||
// usual guideline i.e. kouho
|
||||
|
||||
BMessage* msg = new BMessage(B_INPUT_METHOD_EVENT);
|
||||
msg->AddInt32("be:opcode", B_INPUT_METHOD_LOCATION_REQUEST);
|
||||
fOwner->EnqueueMessage(msg);
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: B_INPUT_METHOD_LOCATION_REQUEST has "
|
||||
"been sent\n"));
|
||||
} else {
|
||||
// guideline exists, but no mikakutei string - means extend mode
|
||||
// and such.
|
||||
SERIAL_PRINT((" GUIDELINE_APPEARED: calling "
|
||||
"GenerateKouho()...\n"));
|
||||
|
||||
fKouhoWindow->PostMessage(fCanna->GenerateKouhoString());
|
||||
SERIAL_PRINT((" GUIDELINE_APPEARED: posting KouhoMsg to "
|
||||
"KouhoWindow %x...\n", fKouhoWindow));
|
||||
|
||||
fKouhoWindow->PostMessage(KOUHO_WINDOW_SHOW_ALONE);
|
||||
}
|
||||
}
|
||||
|
||||
if ((result & GUIDELINE_DISAPPEARED) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"GUIDELINE_DISAPPEARED\n"));
|
||||
fKouhoWindow->PostMessage(KOUHO_WINDOW_HIDE);
|
||||
}
|
||||
|
||||
if ((result & MODE_CHANGED) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"MODE_CHANGED\n"));
|
||||
|
||||
BMessage message(PALETTE_WINDOW_BUTTON_UPDATE);
|
||||
message.AddInt32("mode", fCanna->GetMode());
|
||||
fPaletteWindow->PostMessage(&message);
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: PALETTE_BUTTON_UPDATE has been sent. "
|
||||
"mode = %d\n", fCanna->GetMode()));
|
||||
}
|
||||
|
||||
if ((result & GUIDELINE_CHANGED) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"GUIDELINE_CHANGED\n"));
|
||||
fKouhoWindow->PostMessage(fCanna->GenerateKouhoString());
|
||||
}
|
||||
|
||||
if ((result & THROUGH_INPUT) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"THROUGH_INPUT\n"));
|
||||
EnqueueMessage(DetachCurrentMessage());
|
||||
}
|
||||
|
||||
if ((result & NEW_INPUT_STARTED) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"NEW_INPUT_STARTED\n"));
|
||||
SendInputStarted();
|
||||
}
|
||||
|
||||
if ((result & KAKUTEI_EXISTS) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"KAKUTEI_EXISTS\n"));
|
||||
|
||||
BMessage* msg = new BMessage(B_INPUT_METHOD_EVENT);
|
||||
msg->AddInt32("be:opcode", B_INPUT_METHOD_CHANGED);
|
||||
|
||||
msg->AddString("be:string", fCanna->GetKakuteiStr());
|
||||
msg->AddInt32("be:clause_start", 0);
|
||||
msg->AddInt32("be:clause_end", fCanna->KakuteiLength());
|
||||
msg->AddInt32("be:selection", fCanna->KakuteiLength());
|
||||
msg->AddInt32("be:selection", fCanna->KakuteiLength());
|
||||
msg->AddBool("be:confirmed", true);
|
||||
fOwner->EnqueueMessage(msg);
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: B_INPUT_METHOD_CHANGED (confired) has "
|
||||
"been sent\n"));
|
||||
|
||||
// if both kakutei and mikakutei exist, do not send B_INPUT_STOPPED
|
||||
if (!(result & MIKAKUTEI_EXISTS))
|
||||
SendInputStopped();
|
||||
}
|
||||
|
||||
if ((result & MIKAKUTEI_EXISTS) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"MIKAKUTEI_EXISTS\n" ));
|
||||
|
||||
int32 start, finish;
|
||||
BMessage* msg = new BMessage(B_INPUT_METHOD_EVENT);
|
||||
msg->AddInt32("be:opcode", B_INPUT_METHOD_CHANGED);
|
||||
msg->AddString("be:string", fCanna->GetMikakuteiStr());
|
||||
|
||||
if (fCanna->HasRev()) {
|
||||
fCanna->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", fCanna->MikakuteiLength());
|
||||
} else {
|
||||
start = finish = fCanna->MikakuteiLength();
|
||||
msg->AddInt32("be:clause_start", 0);
|
||||
msg->AddInt32("be:clause_end", fCanna->MikakuteiLength());
|
||||
}
|
||||
|
||||
msg->AddInt32("be:selection", start);
|
||||
msg->AddInt32("be:selection", finish);
|
||||
//msg->AddBool("be:confirmed", false);
|
||||
fOwner->EnqueueMessage(msg);
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: B_INPUT_METHOD_CHANGED (non-confirmed) "
|
||||
"has been sent\n"));
|
||||
}
|
||||
|
||||
if ((result & MIKAKUTEI_BECOME_EMPTY) != 0) {
|
||||
SERIAL_PRINT(("CannaLooper: _ProcessResult() processing "
|
||||
"MIKAKUTEI_BECOME_EMPTY\n" ));
|
||||
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);
|
||||
fOwner->EnqueueMessage(msg);
|
||||
|
||||
SERIAL_PRINT(( "CannaLooper: B_INPUT_METHOD_CHANGED (NULL, confired) "
|
||||
"has been sent\n"));
|
||||
|
||||
SendInputStopped();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::_HandleLocationReply(BMessage* msg)
|
||||
{
|
||||
BPoint where = B_ORIGIN;
|
||||
float height = 0.0;
|
||||
int32 start;
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: B_INPUT_METHOD_LOCATION_REQUEST received\n"));
|
||||
|
||||
start = fCanna->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);
|
||||
|
||||
fKouhoWindow->PostMessage(fCanna->GenerateKouhoString());
|
||||
fKouhoWindow->PostMessage(&m);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::_HandleMethodActivated(bool active)
|
||||
{
|
||||
if (active) {
|
||||
if (!fPaletteWindow) {
|
||||
// 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);
|
||||
fPaletteWindow = new PaletteWindow(frame, this);
|
||||
fPaletteWindow->Show();
|
||||
fKouhoWindow = new KouhoWindow(&fKouhoFont, this);
|
||||
fKouhoWindow->Run();
|
||||
}
|
||||
|
||||
fPaletteWindow->PostMessage(PALETTE_WINDOW_SHOW);
|
||||
fOwner->SetMenu(fMenu, this);
|
||||
} else {
|
||||
_ForceKakutei();
|
||||
fCanna->ChangeMode(CANNA_MODE_HenkanMode);
|
||||
BMessage m(PALETTE_WINDOW_BUTTON_UPDATE);
|
||||
m.AddInt32("mode", CANNA_MODE_HenkanMode);
|
||||
fPaletteWindow->PostMessage(&m);
|
||||
fPaletteWindow->PostMessage(PALETTE_WINDOW_HIDE);
|
||||
fKouhoWindow->PostMessage(KOUHO_WINDOW_HIDE);
|
||||
fOwner->SetMenu(NULL, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::_ForceKakutei()
|
||||
{
|
||||
SERIAL_PRINT(( "CannaLooper: _ForceKakutei() called\n" ));
|
||||
|
||||
uint32 result = fCanna->Kakutei();
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: returned from Kakutei(). result = %d\n",
|
||||
result));
|
||||
|
||||
if (result != NOTHING_TO_KAKUTEI)
|
||||
_ProcessResult(result);
|
||||
else
|
||||
SendInputStopped();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CannaLooper::SendInputStopped()
|
||||
{
|
||||
BMessage* msg = new BMessage(B_INPUT_METHOD_EVENT);
|
||||
msg->AddInt32("be:opcode", B_INPUT_METHOD_STOPPED);
|
||||
EnqueueMessage(msg);
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: B_INPUT_METHOD_STOPPED has been sent\n"));
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
SERIAL_PRINT(("CannaLooper: B_INPUT_METHOD_STARTED has been sent\n"));
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007-2009 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CANNA_LOOPER_H
|
||||
#define CANNA_LOOPER_H
|
||||
|
||||
|
||||
#include <Messenger.h>
|
||||
#include <Font.h>
|
||||
#include <Looper.h>
|
||||
#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();
|
||||
virtual void MessageReceived(BMessage* msg);
|
||||
|
||||
void EnqueueMessage(BMessage* msg);
|
||||
status_t Init();
|
||||
status_t ReadSettings(char* basePath);
|
||||
|
||||
void SendInputStopped();
|
||||
void SendInputStarted();
|
||||
|
||||
private:
|
||||
void _HandleKeyDown(BMessage* msg);
|
||||
void _HandleLocationReply(BMessage* msg);
|
||||
void _HandleMethodActivated(bool active);
|
||||
void _ProcessResult(uint32 result);
|
||||
void _ForceKakutei();
|
||||
|
||||
CannaMethod* fOwner;
|
||||
CannaInterface* fCanna;
|
||||
BFont fKouhoFont;
|
||||
KouhoWindow* fKouhoWindow;
|
||||
PaletteWindow* fPaletteWindow;
|
||||
BMenu* fMenu;
|
||||
};
|
||||
|
||||
#endif // CANNA_LOOPER_H
|
@ -1,147 +0,0 @@
|
||||
//
|
||||
// CannaIM - Canna-based Input Method Add-on for BeOS R4
|
||||
//
|
||||
|
||||
#include <List.h>
|
||||
#include <Looper.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Path.h>
|
||||
#include <File.h>
|
||||
|
||||
#include "CannaCommon.h"
|
||||
#include "CannaMethod.h"
|
||||
#include "CannaLooper.h"
|
||||
|
||||
#include "Bitmaps.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <Debug.h>
|
||||
#endif
|
||||
|
||||
Preferences gSettings;
|
||||
|
||||
BInputServerMethod*
|
||||
instantiate_input_method()
|
||||
{
|
||||
return new CannaMethod();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
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->Init();
|
||||
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
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
//
|
||||
// CannaIM - Canna-based Input Method Add-on for BeOS R4
|
||||
//
|
||||
|
||||
#ifndef _CANNAMETHOD_H
|
||||
#define _CANNAMETHOD_H
|
||||
|
||||
#include <Messenger.h>
|
||||
#include <InputServerMethod.h>
|
||||
|
||||
#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
|
@ -1,23 +0,0 @@
|
||||
SubDir HAIKU_TOP src add-ons input_server methods canna ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
UsePrivateHeaders interface ;
|
||||
|
||||
SubDirSysHdrs $(SUBDIR) ;
|
||||
SubDirHdrs [ FDirName $(SUBDIR) canna ] ;
|
||||
|
||||
if $(TARGET_PLATFORM) != haiku {
|
||||
SubDirC++Flags -fmultiple-symbol-spaces ;
|
||||
}
|
||||
|
||||
Addon canna :
|
||||
CannaInterface.cpp
|
||||
CannaLooper.cpp
|
||||
CannaMethod.cpp
|
||||
KouhoWindow.cpp
|
||||
PaletteWindow.cpp
|
||||
: be textencoding input_server libcanna.a librk.a [ TargetLibsupc++ ] ;
|
||||
|
||||
SubInclude HAIKU_TOP src add-ons input_server methods canna lib ;
|
||||
SubInclude HAIKU_TOP src add-ons input_server methods canna rk ;
|
@ -1,373 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <Screen.h>
|
||||
#ifdef DEBUG
|
||||
#include <Debug.h>
|
||||
#endif
|
||||
#include "WindowPrivate.h"
|
||||
|
||||
#include "KouhoWindow.h"
|
||||
|
||||
|
||||
KouhoWindow::KouhoWindow(BFont *font, BLooper *looper)
|
||||
:BWindow( DUMMY_RECT,
|
||||
"kouho", B_MODAL_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, "VL PGothic");
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// 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() - 1)
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KouhoView::HighlightPartial(int32 begin, int32 end)
|
||||
{
|
||||
BRegion region;
|
||||
GetTextRegion(begin, end, ®ion);
|
||||
highlightRect = region.RectAt(0);
|
||||
Invalidate(highlightRect);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KouhoView::Draw(BRect rect)
|
||||
{
|
||||
BTextView::Draw(rect);
|
||||
// rgb_color viewcolor = ViewColor();
|
||||
SetHighColor(selection_color);
|
||||
SetDrawingMode(B_OP_MIN);
|
||||
FillRect(highlightRect);
|
||||
// SetViewColor(viewcolor);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KouhoView::MouseDown(BPoint point)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#ifndef KOUHOWINDOW_H
|
||||
#define KOUHOWINDOW_H
|
||||
|
||||
#include <Window.h>
|
||||
#include <TextView.h>
|
||||
#include <Region.h>
|
||||
#include <Box.h>
|
||||
#include <View.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#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
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,297 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#include "CannaCommon.h"
|
||||
#include "PaletteWindow.h"
|
||||
#include "canna/mfdef.h"
|
||||
#include "PaletteIconImages.h"
|
||||
#include <Bitmap.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include "WindowPrivate.h"
|
||||
|
||||
PaletteWindow::PaletteWindow( BRect rect, BLooper *looper )
|
||||
:BWindow( rect, B_EMPTY_STRING, kLeftTitledWindowLook,
|
||||
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;
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 1999 M.Kawamura
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PALETTEWINDOW_H
|
||||
#define PALETTEWINDOW_H
|
||||
|
||||
#include <Looper.h>
|
||||
#include <Window.h>
|
||||
#include <PictureButton.h>
|
||||
#include <Box.h>
|
||||
|
||||
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
|
@ -1,270 +0,0 @@
|
||||
/* Copyright 1993 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: RK.h 10527 2004-12-23 22:08:39Z korli $ */
|
||||
|
||||
/************************************************************************/
|
||||
/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997 */
|
||||
/************************************************************************/
|
||||
|
||||
#ifndef _RK_h
|
||||
#define _RK_h
|
||||
|
||||
typedef struct {
|
||||
int ylen; /* yomigana no nagasa (in byte) */
|
||||
int klen; /* kanji no nagasa (in byte) */
|
||||
int rownum; /* row number */
|
||||
int colnum; /* column number */
|
||||
int dicnum; /* dic number */
|
||||
}RkLex;
|
||||
|
||||
typedef struct {
|
||||
int bunnum; /* bunsetsu bangou */
|
||||
int candnum; /* kouho bangou */
|
||||
int maxcand; /* sou kouho suu */
|
||||
int diccand; /* jisho ni aru kouho suu */
|
||||
int ylen; /* yomigana no nagasa (in byte) */
|
||||
int klen; /* kanji no nagasa (in byte) */
|
||||
int tlen; /* tango no kosuu */
|
||||
} RkStat;
|
||||
|
||||
struct DicInfo {
|
||||
unsigned char *di_dic;
|
||||
unsigned char *di_file;
|
||||
int di_kind;
|
||||
int di_form;
|
||||
unsigned di_count;
|
||||
int di_mode;
|
||||
long di_time;
|
||||
};
|
||||
|
||||
/* romaji/kanakanji henkan code */
|
||||
const unsigned long RK_XFERBITS = 4; /* bit-field width */
|
||||
#define RK_XFERMASK ((1<<RK_XFERBITS)-1)
|
||||
#define RK_NFER 0 /* muhenkan */
|
||||
#define RK_XFER 1 /* hiragana henkan */
|
||||
#define RK_HFER 2 /* hankaku henkan */
|
||||
#define RK_KFER 3 /* katakana henkan */
|
||||
#define RK_ZFER 4 /* zenkaku henkan */
|
||||
|
||||
#define RK_CTRLHENKAN 0xf
|
||||
#define RK_HENKANMODE(flags) (((flags)<<RK_XFERBITS)|RK_CTRLHENKAN)
|
||||
|
||||
#define RK_TANBUN 0x01
|
||||
#define RK_MAKE_WORD 0x02
|
||||
#define RK_MAKE_EISUUJI 0x04
|
||||
#define RK_MAKE_KANSUUJI 0x08
|
||||
|
||||
/* RkRxDic
|
||||
* romaji/kana henkan jisho
|
||||
*/
|
||||
struct RkRxDic {
|
||||
int dic; /* dictionary version: see below */
|
||||
unsigned char *nr_string; /* romaji/kana taiou hyou */
|
||||
int nr_strsz; /* taiou hyou no size */
|
||||
unsigned char **nr_keyaddr; /* romaji key no kaishi iti */
|
||||
int nr_nkey; /* romaji/kana taiou suu */
|
||||
unsigned char *nr_bchars; /* backtrack no trigger moji */
|
||||
unsigned char *nr_brules; /* backtrack no kanouseino aru rule */
|
||||
};
|
||||
|
||||
#define RX_KPDIC 0 /* new format dictionary */
|
||||
#define RX_RXDIC 1 /* old format dictionary */
|
||||
|
||||
/* kanakanji henkan */
|
||||
|
||||
/* romaji hennkan code */
|
||||
#define RK_FLUSH 0x8000 /* flush */
|
||||
#define RK_SOKON 0x4000 /* sokuon shori */
|
||||
#define RK_IGNORECASE 0x2000 /* ignore case */
|
||||
|
||||
#define RK_BIN 0
|
||||
#define RK_TXT 0x01
|
||||
|
||||
#define RK_MWD 0
|
||||
#define RK_SWD 1
|
||||
#define RK_PRE 2
|
||||
#define RK_SUC 3
|
||||
|
||||
#define KYOUSEI 0x01 /* jisho_overwrite_mode */
|
||||
|
||||
#define Rk_MWD 0x80 /* jiritsugo_jisho */
|
||||
#define Rk_SWD 0x40 /* fuzokugo_jisho */
|
||||
#define Rk_PRE 0x20 /* settougo_jisho */
|
||||
#define Rk_SUC 0x10 /* setsubigo_jisho */
|
||||
|
||||
/* permission for RkwChmod() */
|
||||
#define RK_ENABLE_READ 0x01
|
||||
#define RK_DISABLE_READ 0x02
|
||||
#define RK_ENABLE_WRITE 0x04
|
||||
#define RK_DISABLE_WRITE 0x08
|
||||
/* chmod for directories */
|
||||
#define RK_USR_DIR 0x3000
|
||||
#define RK_GRP_DIR 0x1000
|
||||
#define RK_SYS_DIR 0x2000
|
||||
#define RK_DIRECTORY (RK_USR_DIR | RK_GRP_DIR | RK_SYS_DIR)
|
||||
/* chmod for dictionaries */
|
||||
#define RK_USR_DIC 0 /* specify user dic */
|
||||
#define RK_GRP_DIC 0x4000 /* specify group dic */
|
||||
#define RK_SYS_DIC 0x8000 /* specify system dic */
|
||||
|
||||
#define PL_DIC 0x0100
|
||||
#define PL_ALLOW 0x0200
|
||||
#define PL_INHIBIT 0x0400
|
||||
#define PL_FORCE 0x0800
|
||||
|
||||
#define NOENT -2 /* No such file or directory */
|
||||
#define IO -5 /* I/O error */
|
||||
#define NOTALC -6 /* Cann't alloc. */
|
||||
#define BADF -9 /* irregal argument */
|
||||
#define BADDR -10 /* irregal dics.dir */
|
||||
#define ACCES -13 /* Permission denied */
|
||||
#define NOMOUNT -15 /* cannot mount */
|
||||
#define MOUNT -16 /* file already mounted */
|
||||
#define EXIST -17 /* file already exits */
|
||||
#define INVAL -22 /* irregal argument */
|
||||
#define TXTBSY -26 /* text file busy */
|
||||
#define BADARG -99 /* Bad Argment */
|
||||
#define BADCONT -100 /* Bad Context */
|
||||
#define OLDSRV -110
|
||||
#define NOTUXSRV -111
|
||||
#define NOTOWNSRV -112
|
||||
|
||||
/* kanakanji henkan */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
canna_export void RkwFinalize(void);
|
||||
canna_export int RkwInitialize(char *);
|
||||
canna_export int RkwCreateContext(void);
|
||||
canna_export int RkwCloseContext(int);
|
||||
canna_export int RkwDuplicateContext(int);
|
||||
canna_export int RkwSetDicPath(int, char *);
|
||||
canna_export int RkwGetDirList(int, char *,int);
|
||||
canna_export int RkwGetDicList(int, char *,int);
|
||||
canna_export int RkwMountDic(int, char *, int);
|
||||
canna_export int RkwUnmountDic(int, char *);
|
||||
canna_export int RkwRemountDic(int, char *, int);
|
||||
canna_export int RkwSync(int, char *);
|
||||
canna_export int RkwGetMountList(int, char *, int);
|
||||
canna_export int RkwDefineDic(int, char *, WCHAR_T *);
|
||||
canna_export int RkwDeleteDic(int, char *, WCHAR_T *);
|
||||
canna_export int RkwBgnBun(int, WCHAR_T *, int, int);
|
||||
canna_export int RkwEndBun(int, int);
|
||||
canna_export int RkwGoTo(int, int);
|
||||
canna_export int RkwLeft(int);
|
||||
canna_export int RkwRight(int);
|
||||
canna_export int RkwXfer(int, int);
|
||||
canna_export int RkwNfer(int);
|
||||
canna_export int RkwNext(int);
|
||||
canna_export int RkwPrev(int);
|
||||
canna_export int RkwResize(int, int);
|
||||
canna_export int RkwEnlarge(int);
|
||||
canna_export int RkwShorten(int);
|
||||
canna_export int RkwSubstYomi(int, int, int, WCHAR_T *, int);
|
||||
canna_export int RkwStoreYomi(int, WCHAR_T *, int);
|
||||
canna_export int RkwGetLastYomi(int, WCHAR_T *, int);
|
||||
canna_export int RkwFlushYomi(int);
|
||||
canna_export int RkwRemoveBun(int, int);
|
||||
canna_export int RkwGetStat(int, RkStat *);
|
||||
canna_export int RkwGetYomi(int, WCHAR_T *, int);
|
||||
canna_export int RkwGetHinshi(int, WCHAR_T *, int);
|
||||
canna_export int RkwGetKanji(int, WCHAR_T *, int);
|
||||
canna_export int RkwGetKanjiList(int, WCHAR_T *, int);
|
||||
canna_export int RkwGetLex(int, RkLex *, int);
|
||||
canna_export int RkwCvtHira(WCHAR_T *, int, WCHAR_T *, int);
|
||||
canna_export int RkwCvtKana(WCHAR_T *, int, WCHAR_T *, int);
|
||||
canna_export int RkwCvtHan(WCHAR_T *, int, WCHAR_T *, int);
|
||||
canna_export int RkwCvtZen(WCHAR_T *, int, WCHAR_T *, int);
|
||||
canna_export int RkwCvtEuc(WCHAR_T *, int, WCHAR_T *, int);
|
||||
canna_export int RkwCvtSuuji(WCHAR_T *, int , WCHAR_T *, int , int );
|
||||
canna_export int RkwCvtNone(WCHAR_T *, int , WCHAR_T *, int );
|
||||
canna_export int RkwCreateDic(int, char *, int);
|
||||
canna_export int RkwQueryDic(int, char *, char *, struct DicInfo *);
|
||||
canna_export void RkwCloseRoma(struct RkRxDic *);
|
||||
canna_export struct RkRxDic * RkwOpenRoma(char *);
|
||||
canna_export int RkwSetUserInfo(char *, char *, char *);
|
||||
canna_export char * RkwGetServerName(void);
|
||||
canna_export int RkwGetServerVersion(int *, int *);
|
||||
canna_export int RkwListDic(int, char *, char *, int);
|
||||
canna_export int RkwCopyDic(int, char *, char *, char *, int);
|
||||
canna_export int RkwRemoveDic(int, char *, int);
|
||||
canna_export int RkwRenameDic(int, char *, char *, int);
|
||||
canna_export int RkwChmodDic(int, char *, int);
|
||||
canna_export int RkwGetWordTextDic(int, unsigned char *, unsigned char *, WCHAR_T *, int);
|
||||
canna_export int RkwGetSimpleKanji(int, char *, WCHAR_T *, int, WCHAR_T *, int, char *, int);
|
||||
|
||||
void RkFinalize(void);
|
||||
int RkInitialize(char *);
|
||||
int RkCreateContext(void);
|
||||
int RkCloseContext(int);
|
||||
int RkDuplicateContext(int);
|
||||
int RkSetDicPath(int, char *);
|
||||
int RkGetDirList(int, char *,int);
|
||||
int RkGetDicList(int, char *,int);
|
||||
int RkMountDic(int, char *, int);
|
||||
int RkUnmountDic(int, char *);
|
||||
int RkRemountDic(int, char *, int);
|
||||
int RkSync(int, char *);
|
||||
int RkGetMountList(int, char *, int);
|
||||
int RkDefineDic(int, char *, char *);
|
||||
int RkDeleteDic(int, char *, char *);
|
||||
int RkBgnBun(int, char *, int, int);
|
||||
int RkEndBun(int, int);
|
||||
int RkGoTo(int, int);
|
||||
int RkLeft(int);
|
||||
int RkRight(int);
|
||||
int RkXfer(int, int);
|
||||
int RkNfer(int);
|
||||
int RkNext(int);
|
||||
int RkPrev(int);
|
||||
int RkResize(int, int);
|
||||
int RkEnlarge(int);
|
||||
int RkShorten(int);
|
||||
int RkSubstYomi(int, int, int, char *, int);
|
||||
int RkStoreYomi(int, char *, int);
|
||||
int RkGetLastYomi(int, char *, int);
|
||||
int RkFlushYomi(int);
|
||||
int RkRemoveBun(int, int);
|
||||
int RkGetStat(int, RkStat *);
|
||||
int RkGetYomi(int, unsigned char *, int);
|
||||
int RkGetHinshi(int, unsigned char *, int);
|
||||
int RkGetKanji(int, unsigned char *, int);
|
||||
int RkGetKanjiList(int, unsigned char *, int);
|
||||
int RkGetLex(int, RkLex *, int);
|
||||
int RkCvtHira(unsigned char *, int, unsigned char *, int);
|
||||
int RkCvtKana(unsigned char *, int, unsigned char *, int);
|
||||
int RkCvtHan(unsigned char *, int, unsigned char *, int);
|
||||
int RkCvtZen(unsigned char *, int, unsigned char *, int);
|
||||
int RkCvtNone(unsigned char *, int, unsigned char *, int);
|
||||
int RkCvtEuc(unsigned char *, int, unsigned char *, int);
|
||||
int RkCvtWide(WCHAR_T *, int , char *, int );
|
||||
int RkCvtNarrow(char *, int , WCHAR_T *, int );
|
||||
int RkQueryDic(int, char *, char *, struct DicInfo *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _RK_h */
|
||||
/* don't add stuff after this line */
|
@ -1,18 +0,0 @@
|
||||
//////////////////////////////////////////////////////
|
||||
// Header file for emport / import gloval symbols.
|
||||
// Valid for BeOS Releas 3 or later.
|
||||
// 1998.5.4 by T.Murai
|
||||
//
|
||||
|
||||
#ifndef CANNABUILD_H
|
||||
#define CANNABUILD_H
|
||||
|
||||
//#define _BUILDING_CANNALIB
|
||||
|
||||
#ifdef _BUILDING_CANNALIB
|
||||
#define canna_export // __declspec(dllexport)
|
||||
#else
|
||||
#define canna_export // __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif // CANNABUILD_H
|
@ -1,21 +0,0 @@
|
||||
// CanBe:Canna for Be
|
||||
|
||||
#define CANNA_WCHAR
|
||||
#define HAVE_RENAME
|
||||
#define WCHAR16
|
||||
#define CANNA_WCHAR
|
||||
#define USE_MALLOC_FOR_BIG_ARRAY
|
||||
#define STANDALONE
|
||||
#define CANNA_LIGHT 1
|
||||
|
||||
|
||||
#undef SYSTEM_DDHOME_NAME
|
||||
|
||||
//#define CANNALIBDIR "/boot/home/KanBe/"
|
||||
//#define DICHOME "/boot/KanBe/canna/dic"
|
||||
//#define DICHOME "/boot/home/config/KanBe/canna/dic"
|
||||
//#define DICHOMEDIR "/boot/home/config/KanBe/dic"
|
||||
//#define CANNALIBDIR "/boot/home/config/KanBe/"
|
||||
|
||||
|
||||
#define DP(a) puts(a)
|
@ -1,264 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* 8/16 bit String Manipulations.
|
||||
*
|
||||
* "@(#)kanji.h 2.3 88/10/03 10:25:34"
|
||||
* "@(#) 102.1 $Id: jrkanji.h 10527 2004-12-23 22:08:39Z korli $"
|
||||
*/
|
||||
|
||||
#ifndef _JR_KANJI_H_
|
||||
#define _JR_KANJI_H_
|
||||
|
||||
#include <canna/keydef.h>
|
||||
#include <canna/mfdef.h>
|
||||
#include <canna/cannabuild.h>
|
||||
#include "widedef.h"
|
||||
/* どのような情報があるかを示すフラグ */
|
||||
|
||||
#define KanjiModeInfo 0x1
|
||||
#define KanjiGLineInfo 0x2
|
||||
#define KanjiYomiInfo 0x4
|
||||
#define KanjiThroughInfo 0x8
|
||||
#define KanjiEmptyInfo 0x10
|
||||
|
||||
#define KanjiExtendInfo 0x20
|
||||
#define KanjiKigoInfo 0x40
|
||||
#define KanjiRussianInfo 0x80
|
||||
#define KanjiGreekInfo 0x100
|
||||
#define KanjiLineInfo 0x200
|
||||
|
||||
#define KanjiAttributeInfo 0x400
|
||||
#define KanjiSpecialFuncInfo 0x800
|
||||
|
||||
/* KanjiControl 関係 */
|
||||
|
||||
#define KC_INITIALIZE 0
|
||||
#define KC_FINALIZE 1
|
||||
#define KC_CHANGEMODE 2
|
||||
#define KC_SETWIDTH 3
|
||||
#define KC_SETUNDEFKEYFUNCTION 4
|
||||
#define KC_SETBUNSETSUKUGIRI 5
|
||||
#define KC_SETMODEINFOSTYLE 6
|
||||
#define KC_SETHEXINPUTSTYLE 7
|
||||
#define KC_INHIBITHANKAKUKANA 8
|
||||
#define KC_DEFINEKANJI 9
|
||||
#define KC_KAKUTEI 10
|
||||
#define KC_KILL 11
|
||||
#define KC_MODEKEYS 12
|
||||
#define KC_QUERYMODE 13
|
||||
#define KC_QUERYCONNECTION 14
|
||||
#define KC_SETSERVERNAME 15
|
||||
#define KC_PARSE 16
|
||||
#define KC_YOMIINFO 17
|
||||
#define KC_STOREYOMI 18
|
||||
#define KC_SETINITFILENAME 19
|
||||
#define KC_DO 20
|
||||
#define KC_GETCONTEXT 21
|
||||
#define KC_CLOSEUICONTEXT 22
|
||||
#define KC_INHIBITCHANGEMODE 23
|
||||
#define KC_LETTERRESTRICTION 24
|
||||
#define KC_QUERYMAXMODESTR 25
|
||||
#define KC_SETLISTCALLBACK 26
|
||||
#define KC_SETVERBOSE 27
|
||||
#define KC_LISPINTERACTION 28
|
||||
#define KC_DISCONNECTSERVER 29
|
||||
#define KC_SETAPPNAME 30
|
||||
#define KC_DEBUGMODE 31
|
||||
#define KC_DEBUGYOMI 32
|
||||
#define KC_KEYCONVCALLBACK 33
|
||||
#define KC_QUERYPHONO 34
|
||||
#define KC_CHANGESERVER 35
|
||||
#define KC_SETUSERINFO 36
|
||||
#define KC_QUERYCUSTOM 37
|
||||
#define KC_CLOSEALLCONTEXT 38
|
||||
#define KC_ATTRIBUTEINFO 39
|
||||
|
||||
#define MAX_KC_REQUEST (KC_ATTRIBUTEINFO + 1)
|
||||
|
||||
#define kc_normal 0
|
||||
#define kc_through 1
|
||||
#define kc_kakutei 2
|
||||
#define kc_kill 3
|
||||
|
||||
#define CANNA_NOTHING_RESTRICTED 0
|
||||
#define CANNA_ONLY_ASCII 1
|
||||
#define CANNA_ONLY_ALPHANUM 2
|
||||
#define CANNA_ONLY_HEX 3
|
||||
#define CANNA_ONLY_NUMERIC 4
|
||||
#define CANNA_NOTHING_ALLOWED 5
|
||||
|
||||
#ifdef IROHA_BC
|
||||
#define IROHA_NOTHING_RESTRICTED CANNA_NOTHING_RESTRICTED
|
||||
#define IROHA_ONLY_ASCII CANNA_ONLY_ASCII
|
||||
#define IROHA_ONLY_ALPHANUM CANNA_ONLY_ALPHANUM
|
||||
#define IROHA_ONLY_HEX CANNA_ONLY_HEX
|
||||
#define IROHA_ONLY_NUMERIC CANNA_ONLY_NUMERIC
|
||||
#define IROHA_NOTHING_ALLOWED CANNA_NOTHING_ALLOWED
|
||||
#endif
|
||||
|
||||
#define CANNA_ATTR_INPUT ((char)'.')
|
||||
#define CANNA_ATTR_TARGET_CONVERTED ((char)'O')
|
||||
#define CANNA_ATTR_CONVERTED ((char)'_')
|
||||
#define CANNA_ATTR_TARGET_NOTCONVERTED ((char)'x')
|
||||
#define CANNA_ATTR_INPUT_ERROR ((char)'E')
|
||||
|
||||
#define CANNA_MAXAPPNAME 256
|
||||
|
||||
typedef struct {
|
||||
unsigned char *echoStr; /* local echo string */
|
||||
int length; /* length of echo string */
|
||||
int revPos; /* reverse position */
|
||||
int revLen; /* reverse length */
|
||||
unsigned long info; /* その他の情報 */
|
||||
unsigned char *mode; /* モード情報 */
|
||||
struct {
|
||||
unsigned char *line;
|
||||
int length;
|
||||
int revPos;
|
||||
int revLen;
|
||||
} gline; /* 一覧表示のための情報 */
|
||||
} jrKanjiStatus;
|
||||
|
||||
typedef struct {
|
||||
int val;
|
||||
unsigned char *buffer;
|
||||
int bytes_buffer;
|
||||
jrKanjiStatus *ks;
|
||||
} jrKanjiStatusWithValue;
|
||||
|
||||
typedef struct {
|
||||
char *uname; /* ユーザ名 */
|
||||
char *gname; /* グループ名 */
|
||||
char *srvname; /* サーバ名 */
|
||||
char *topdir; /* インストールディレクトリ */
|
||||
char *cannafile; /* カスタマイズファイル名 */
|
||||
char *romkanatable; /* ローマ字かな変換テーブル名 */
|
||||
char *appname; /* アプリケーション名 */
|
||||
} jrUserInfoStruct;
|
||||
|
||||
typedef struct {
|
||||
char *codeinput; /* コード種別 */
|
||||
int quicklyescape; /* 記号連続入力 flag */
|
||||
int indexhankaku; /* ガイドラインのインデックス指定 */
|
||||
int indexseparator; /* ガイドラインのインデックス指定 */
|
||||
int selectdirect; /* 数字キーによる選択 flag */
|
||||
int numericalkeysel; /* 数字キーによる候補選択指定 */
|
||||
int kouhocount; /* 候補数表示 */
|
||||
} jrCInfoStruct;
|
||||
|
||||
#ifdef _WCHAR_T
|
||||
|
||||
typedef struct {
|
||||
WCHAR_T *echoStr; /* local echo string */
|
||||
int length; /* length of echo string */
|
||||
int revPos; /* reverse position */
|
||||
int revLen; /* reverse length */
|
||||
unsigned long info; /* その他の情報 */
|
||||
WCHAR_T *mode; /* モード情報 */
|
||||
struct {
|
||||
WCHAR_T *line;
|
||||
int length;
|
||||
int revPos;
|
||||
int revLen;
|
||||
} gline; /* 一覧表示のための情報 */
|
||||
} wcKanjiStatus;
|
||||
|
||||
typedef struct {
|
||||
int val;
|
||||
WCHAR_T *buffer;
|
||||
int n_buffer;
|
||||
wcKanjiStatus *ks;
|
||||
} wcKanjiStatusWithValue;
|
||||
|
||||
typedef struct {
|
||||
char *client_data;
|
||||
int (*callback_func) (char *, int, WCHAR_T **, int, int *);
|
||||
} jrListCallbackStruct;
|
||||
|
||||
typedef struct {
|
||||
char *attr;
|
||||
long caretpos;
|
||||
} wcKanjiAttribute;
|
||||
|
||||
#define listCallbackStruct jrListCallbackStruct
|
||||
|
||||
#define CANNA_LIST_Start 0
|
||||
#define CANNA_LIST_Select 1
|
||||
#define CANNA_LIST_Quit 2
|
||||
#define CANNA_LIST_Forward 3
|
||||
#define CANNA_LIST_Backward 4
|
||||
#define CANNA_LIST_Next 5
|
||||
#define CANNA_LIST_Prev 6
|
||||
#define CANNA_LIST_BeginningOfLine 7
|
||||
#define CANNA_LIST_EndOfLine 8
|
||||
#define CANNA_LIST_Query 9
|
||||
#define CANNA_LIST_Bango 10
|
||||
#define CANNA_LIST_PageUp 11
|
||||
#define CANNA_LIST_PageDown 12
|
||||
#define CANNA_LIST_Convert 13
|
||||
#define CANNA_LIST_Insert 14
|
||||
|
||||
#endif /* _WCHAR_T */
|
||||
|
||||
#define CANNA_NO_VERBOSE 0
|
||||
#define CANNA_HALF_VERBOSE 1
|
||||
#define CANNA_FULL_VERBOSE 2
|
||||
|
||||
#define CANNA_CTERMINAL 0
|
||||
#define CANNA_XTERMINAL 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern char *jrKanjiError;
|
||||
}
|
||||
#else
|
||||
extern char *jrKanjiError;
|
||||
#endif
|
||||
|
||||
#define wcBeepFunc jrBeepFunc
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
canna_export int jrKanjiString (const int, const int, char *, const int, jrKanjiStatus *);
|
||||
canna_export int jrKanjiControl (const int, const int, char *);
|
||||
canna_export int kanjiInitialize (char ***);
|
||||
canna_export int kanjiFinalize (char ***);
|
||||
canna_export int createKanjiContext (void);
|
||||
canna_export int jrCloseKanjiContext (const int, jrKanjiStatusWithValue *);
|
||||
canna_export void setBasePath(const char *path);
|
||||
#ifdef _WCHAR_T
|
||||
canna_export int wcKanjiString (const int, const int, WCHAR_T *, const int, wcKanjiStatus *);
|
||||
canna_export int wcKanjiControl (const int, const int, char *);
|
||||
canna_export int wcCloseKanjiContext (const int, wcKanjiStatusWithValue *);
|
||||
#endif /* _WCHAR_T */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _JR_KANJI_H_ */
|
||||
|
@ -1,218 +0,0 @@
|
||||
/* 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: keydef.h 10527 2004-12-23 22:08:39Z korli $ */
|
||||
/* normal function keys */
|
||||
|
||||
#define CANNA_KEY_Nfer 0x80
|
||||
#define CANNA_KEY_Xfer 0x81
|
||||
#define CANNA_KEY_Up 0x82
|
||||
#define CANNA_KEY_Left 0x83
|
||||
#define CANNA_KEY_Right 0x84
|
||||
#define CANNA_KEY_Down 0x85
|
||||
#define CANNA_KEY_Insert 0x86
|
||||
#define CANNA_KEY_Rollup 0x87
|
||||
#define CANNA_KEY_PageDown CANNA_KEY_Rollup
|
||||
#define CANNA_KEY_Rolldown 0x88
|
||||
#define CANNA_KEY_PageUp CANNA_KEY_Rolldown
|
||||
#define CANNA_KEY_Home 0x89
|
||||
#define CANNA_KEY_Help 0x8a
|
||||
#define CANNA_KEY_KP_Key 0x8b /* どういう意味で入れたんだっけ? */
|
||||
#define CANNA_KEY_End 0x8c
|
||||
|
||||
/* shifted function keys */
|
||||
|
||||
#define CANNA_KEY_Shift_Nfer 0x90
|
||||
#define CANNA_KEY_Shift_Xfer 0x91
|
||||
#define CANNA_KEY_Shift_Up 0x92
|
||||
#define CANNA_KEY_Shift_Left 0x93
|
||||
#define CANNA_KEY_Shift_Right 0x94
|
||||
#define CANNA_KEY_Shift_Down 0x95
|
||||
|
||||
/* control-shifted function keys */
|
||||
|
||||
#define CANNA_KEY_Cntrl_Nfer 0x96
|
||||
#define CANNA_KEY_Cntrl_Xfer 0x97
|
||||
#define CANNA_KEY_Cntrl_Up 0x98
|
||||
#define CANNA_KEY_Cntrl_Left 0x99
|
||||
#define CANNA_KEY_Cntrl_Right 0x9a
|
||||
#define CANNA_KEY_Cntrl_Down 0x9b
|
||||
|
||||
/* The followings should have special translation rule */
|
||||
#define CANNA_KEY_KP_Separator 0x9c
|
||||
#define CANNA_KEY_KP_Decimal 0x9d
|
||||
#define CANNA_KEY_KP_Divide 0x9e
|
||||
#define CANNA_KEY_KP_Subtract 0x9f
|
||||
#define CANNA_KEY_Shift_Space 0xa0
|
||||
|
||||
/* application keypad mode keys */
|
||||
|
||||
#ifdef DoNotConflictWithKatakanaKeys
|
||||
|
||||
/* 以下のキーはカタカナ文字とぶつかってしまうため使えない。*/
|
||||
|
||||
#define CANNA_KEY_KP_Up 0xc0 /* \eOA */
|
||||
#define CANNA_KEY_KP_Left 0xc1 /* \eOB */
|
||||
#define CANNA_KEY_KP_Right 0xc2 /* \eOC */
|
||||
#define CANNA_KEY_KP_Down 0xc3 /* \eOD */
|
||||
#define CANNA_KEY_KP_Tab 0xc4 /* \eOI */
|
||||
#define CANNA_KEY_KP_Enter 0xc5 /* \eOM */
|
||||
#define CANNA_KEY_KP_Equal 0xc6 /* \eOX */
|
||||
#define CANNA_KEY_KP_Multiply 0xc7 /* \eOj */
|
||||
#define CANNA_KEY_KP_Add 0xc8 /* \eOk */
|
||||
#define CANNA_KEY_KP_Separator 0xc9 /* \eOl */
|
||||
#define CANNA_KEY_KP_Subtract 0xca /* \eOm */
|
||||
#define CANNA_KEY_KP_Decimal 0xcb /* \eOn */
|
||||
#define CANNA_KEY_KP_Divide 0xcc /* \eOo */
|
||||
#define CANNA_KEY_KP_0 0xd0 /* \eOp */
|
||||
#define CANNA_KEY_KP_1 0xd1 /* \eOq */
|
||||
#define CANNA_KEY_KP_2 0xd2 /* \eOr */
|
||||
#define CANNA_KEY_KP_3 0xd3 /* \eOs */
|
||||
#define CANNA_KEY_KP_4 0xd4 /* \eOt */
|
||||
#define CANNA_KEY_KP_5 0xd5 /* \eOu */
|
||||
#define CANNA_KEY_KP_6 0xd6 /* \eOv */
|
||||
#define CANNA_KEY_KP_7 0xd7 /* \eOw */
|
||||
#define CANNA_KEY_KP_8 0xd8 /* \eOx */
|
||||
#define CANNA_KEY_KP_9 0xd9 /* \eOy */
|
||||
|
||||
#endif
|
||||
|
||||
/* numeral-function keys */
|
||||
|
||||
#define CANNA_KEY_F1 0xe0
|
||||
#define CANNA_KEY_F2 0xe1
|
||||
#define CANNA_KEY_F3 0xe2
|
||||
#define CANNA_KEY_F4 0xe3
|
||||
#define CANNA_KEY_F5 0xe4
|
||||
#define CANNA_KEY_F6 0xe5
|
||||
#define CANNA_KEY_F7 0xe6
|
||||
#define CANNA_KEY_F8 0xe7
|
||||
#define CANNA_KEY_F9 0xe8
|
||||
#define CANNA_KEY_F10 0xe9
|
||||
#define CANNA_KEY_PF1 0xf0
|
||||
#define CANNA_KEY_PF2 0xf1
|
||||
#define CANNA_KEY_PF3 0xf2
|
||||
#define CANNA_KEY_PF4 0xf3
|
||||
#define CANNA_KEY_PF5 0xf4
|
||||
#define CANNA_KEY_PF6 0xf5
|
||||
#define CANNA_KEY_PF7 0xf6
|
||||
#define CANNA_KEY_PF8 0xf7
|
||||
#define CANNA_KEY_PF9 0xf8
|
||||
#define CANNA_KEY_PF10 0xf9
|
||||
|
||||
#define CANNA_KEY_HIRAGANA 0xfa
|
||||
#define CANNA_KEY_KATAKANA 0xfb
|
||||
#define CANNA_KEY_HANKAKUZENKAKU 0xfc
|
||||
#define CANNA_KEY_EISU 0xfd
|
||||
|
||||
#define CANNA_KEY_Undefine 0xff
|
||||
|
||||
#ifdef IROHA_BC
|
||||
|
||||
#define IROHA_KEY_Nfer CANNA_KEY_Nfer
|
||||
#define IROHA_KEY_Xfer CANNA_KEY_Xfer
|
||||
#define IROHA_KEY_Up CANNA_KEY_Up
|
||||
#define IROHA_KEY_Left CANNA_KEY_Left
|
||||
#define IROHA_KEY_Right CANNA_KEY_Right
|
||||
#define IROHA_KEY_Down CANNA_KEY_Down
|
||||
#define IROHA_KEY_Insert CANNA_KEY_Insert
|
||||
#define IROHA_KEY_Rollup CANNA_KEY_Rollup
|
||||
#define IROHA_KEY_Rolldown CANNA_KEY_Rolldown
|
||||
#define IROHA_KEY_Home CANNA_KEY_Home
|
||||
#define IROHA_KEY_Help CANNA_KEY_Help
|
||||
#define IROHA_KEY_KP_Key CANNA_KEY_KP_Key
|
||||
|
||||
/* shifted function keys */
|
||||
|
||||
#define IROHA_KEY_Shift_Nfer CANNA_KEY_Shift_Nfer
|
||||
#define IROHA_KEY_Shift_Xfer CANNA_KEY_Shift_Xfer
|
||||
#define IROHA_KEY_Shift_Up CANNA_KEY_Shift_Up
|
||||
#define IROHA_KEY_Shift_Left CANNA_KEY_Shift_Left
|
||||
#define IROHA_KEY_Shift_Right CANNA_KEY_Shift_Right
|
||||
#define IROHA_KEY_Shift_Down CANNA_KEY_Shift_Down
|
||||
|
||||
/* control-shifted function keys */
|
||||
|
||||
#define IROHA_KEY_Cntrl_Nfer CANNA_KEY_Cntrl_Nfer
|
||||
#define IROHA_KEY_Cntrl_Xfer CANNA_KEY_Cntrl_Xfer
|
||||
#define IROHA_KEY_Cntrl_Up CANNA_KEY_Cntrl_Up
|
||||
#define IROHA_KEY_Cntrl_Left CANNA_KEY_Cntrl_Left
|
||||
#define IROHA_KEY_Cntrl_Right CANNA_KEY_Cntrl_Right
|
||||
#define IROHA_KEY_Cntrl_Down CANNA_KEY_Cntrl_Down
|
||||
|
||||
/* application keypad mode keys */
|
||||
|
||||
#ifdef DoNotConflictWithKatakanaKeys
|
||||
|
||||
/* 以下のキーはカタカナ文字とぶつかってしまうため使えない。*/
|
||||
|
||||
#define IROHA_KEY_KP_Up CANNA_KEY_KP_Up
|
||||
#define IROHA_KEY_KP_Left CANNA_KEY_KP_Left
|
||||
#define IROHA_KEY_KP_Right CANNA_KEY_KP_Right
|
||||
#define IROHA_KEY_KP_Down CANNA_KEY_KP_Down
|
||||
#define IROHA_KEY_KP_Tab CANNA_KEY_KP_Tab
|
||||
#define IROHA_KEY_KP_Enter CANNA_KEY_KP_Enter
|
||||
#define IROHA_KEY_KP_Equal CANNA_KEY_KP_Equal
|
||||
#define IROHA_KEY_KP_Multiply CANNA_KEY_KP_Multiply
|
||||
#define IROHA_KEY_KP_Add CANNA_KEY_KP_Add
|
||||
#define IROHA_KEY_KP_Separator CANNA_KEY_KP_Separator
|
||||
#define IROHA_KEY_KP_Subtract CANNA_KEY_KP_Subtract
|
||||
#define IROHA_KEY_KP_Decimal CANNA_KEY_KP_Decimal
|
||||
#define IROHA_KEY_KP_Divide CANNA_KEY_KP_Divide
|
||||
#define IROHA_KEY_KP_0 CANNA_KEY_KP_0
|
||||
#define IROHA_KEY_KP_1 CANNA_KEY_KP_1
|
||||
#define IROHA_KEY_KP_2 CANNA_KEY_KP_2
|
||||
#define IROHA_KEY_KP_3 CANNA_KEY_KP_3
|
||||
#define IROHA_KEY_KP_4 CANNA_KEY_KP_4
|
||||
#define IROHA_KEY_KP_5 CANNA_KEY_KP_5
|
||||
#define IROHA_KEY_KP_6 CANNA_KEY_KP_6
|
||||
#define IROHA_KEY_KP_7 CANNA_KEY_KP_7
|
||||
#define IROHA_KEY_KP_8 CANNA_KEY_KP_8
|
||||
#define IROHA_KEY_KP_9 CANNA_KEY_KP_9
|
||||
|
||||
#endif
|
||||
|
||||
/* numeral-function keys */
|
||||
|
||||
#define IROHA_KEY_F1 CANNA_KEY_F1
|
||||
#define IROHA_KEY_F2 CANNA_KEY_F2
|
||||
#define IROHA_KEY_F3 CANNA_KEY_F3
|
||||
#define IROHA_KEY_F4 CANNA_KEY_F4
|
||||
#define IROHA_KEY_F5 CANNA_KEY_F5
|
||||
#define IROHA_KEY_F6 CANNA_KEY_F6
|
||||
#define IROHA_KEY_F7 CANNA_KEY_F7
|
||||
#define IROHA_KEY_F8 CANNA_KEY_F8
|
||||
#define IROHA_KEY_F9 CANNA_KEY_F9
|
||||
#define IROHA_KEY_F10 CANNA_KEY_F10
|
||||
#define IROHA_KEY_PF1 CANNA_KEY_PF1
|
||||
#define IROHA_KEY_PF2 CANNA_KEY_PF2
|
||||
#define IROHA_KEY_PF3 CANNA_KEY_PF3
|
||||
#define IROHA_KEY_PF4 CANNA_KEY_PF4
|
||||
#define IROHA_KEY_PF5 CANNA_KEY_PF5
|
||||
#define IROHA_KEY_PF6 CANNA_KEY_PF6
|
||||
#define IROHA_KEY_PF7 CANNA_KEY_PF7
|
||||
#define IROHA_KEY_PF8 CANNA_KEY_PF8
|
||||
#define IROHA_KEY_PF9 CANNA_KEY_PF9
|
||||
#define IROHA_KEY_PF10 CANNA_KEY_PF10
|
||||
#define IROHA_KEY_Undefine CANNA_KEY_Undefine
|
||||
|
||||
#endif /* IROHA_BC */
|
@ -1,359 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef _MFDEF_H_
|
||||
#define _MFDEF_H_
|
||||
|
||||
/* @(#) 102.1 $Id: mfdef.h 10527 2004-12-23 22:08:39Z korli $ */
|
||||
|
||||
/*
|
||||
このヘッダファイルではモードに割り振られた番号や、関数に割り振られた
|
||||
番号を管理する。
|
||||
|
||||
*/
|
||||
|
||||
/* モード */
|
||||
|
||||
/* real modes */
|
||||
/* 実モード(real mode)はキーマップの実体を持っているモード */
|
||||
|
||||
#define CANNA_MODE_AlphaMode 0 /* アルファベットモード */
|
||||
#define CANNA_MODE_EmptyMode 1 /* 読み入力がない状態 */
|
||||
#define CANNA_MODE_KigoMode 2 /* 記号一覧表示状態 */
|
||||
#define CANNA_MODE_YomiMode 3 /* 読み入力している状態 */
|
||||
#define CANNA_MODE_JishuMode 4 /* 文字種変換している状態 */
|
||||
#define CANNA_MODE_TankouhoMode 5 /* 単一候補表示状態 */
|
||||
#define CANNA_MODE_IchiranMode 6 /* 候補一覧表示状態 */
|
||||
#define CANNA_MODE_YesNoMode 7 /* 単語登録の例文表示状態 */
|
||||
#define CANNA_MODE_OnOffMode 8 /* 単語登録の例文表示状態 */
|
||||
#define CANNA_MODE_AdjustBunsetsuMode 9 /* 文節伸縮モード */
|
||||
#define CANNA_MODE_ChikujiYomiMode 10 /* 逐次変換モードの読み部分 */
|
||||
#define CANNA_MODE_ChikujiTanMode 11 /* 逐次変換モードの候補部分 */
|
||||
|
||||
#define CANNA_MODE_MAX_REAL_MODE (CANNA_MODE_ChikujiTanMode + 1)
|
||||
|
||||
/* imaginary modes */
|
||||
/* 虚モード(imaginary mode)はキーマップの実体を持っていないモード */
|
||||
|
||||
#define CANNA_MODE_HenkanMode CANNA_MODE_EmptyMode
|
||||
#define CANNA_MODE_HenkanNyuryokuMode 12
|
||||
|
||||
#define CANNA_MODE_ZenHiraHenkanMode 13
|
||||
#define CANNA_MODE_HanHiraHenkanMode 14
|
||||
#define CANNA_MODE_ZenKataHenkanMode 15
|
||||
#define CANNA_MODE_HanKataHenkanMode 16
|
||||
#define CANNA_MODE_ZenAlphaHenkanMode 17
|
||||
#define CANNA_MODE_HanAlphaHenkanMode 18
|
||||
|
||||
#define CANNA_MODE_ZenHiraKakuteiMode 19
|
||||
#define CANNA_MODE_HanHiraKakuteiMode 20
|
||||
#define CANNA_MODE_ZenKataKakuteiMode 21
|
||||
#define CANNA_MODE_HanKataKakuteiMode 22
|
||||
#define CANNA_MODE_ZenAlphaKakuteiMode 23
|
||||
#define CANNA_MODE_HanAlphaKakuteiMode 24
|
||||
|
||||
#define CANNA_MODE_HexMode 25 /* 16進コード入力モード */
|
||||
#define CANNA_MODE_BushuMode 26 /* 部首の読みの入力状態 */
|
||||
#define CANNA_MODE_ExtendMode 27 /* 拡張機能選択 */
|
||||
#define CANNA_MODE_RussianMode 28 /* ロシア文字選択 */
|
||||
#define CANNA_MODE_GreekMode 29 /* ギリシア文字選択 */
|
||||
#define CANNA_MODE_LineMode 30 /* 罫線選択 */
|
||||
#define CANNA_MODE_ChangingServerMode 31 /* サーバ変更 */
|
||||
#define CANNA_MODE_HenkanMethodMode 32 /* 変換方式選択 */
|
||||
#define CANNA_MODE_DeleteDicMode 33 /* 単語削除 */
|
||||
#define CANNA_MODE_TourokuMode 34 /* 単語登録モード */
|
||||
#define CANNA_MODE_TourokuEmptyMode CANNA_MODE_TourokuMode
|
||||
#define CANNA_MODE_TourokuHinshiMode 35 /* 単語登録の品詞選択状態 */
|
||||
#define CANNA_MODE_TourokuDicMode 36 /* 単語登録の辞書選択状態 */
|
||||
#define CANNA_MODE_QuotedInsertMode 37 /* 引用入力モード */
|
||||
#define CANNA_MODE_BubunMuhenkanMode 38 /* 部分無変換状態 */
|
||||
#define CANNA_MODE_MountDicMode 39 /* 辞書のmount,unmount状態 */
|
||||
|
||||
#define CANNA_MODE_MAX_IMAGINARY_MODE (CANNA_MODE_MountDicMode + 1)
|
||||
|
||||
#ifdef IROHA_BC
|
||||
/* real modes */
|
||||
/* 実モード(real mode)はキーマップの実体を持っているモード */
|
||||
|
||||
#define IROHA_MODE_AlphaMode CANNA_MODE_AlphaMode
|
||||
#define IROHA_MODE_EmptyMode CANNA_MODE_EmptyMode
|
||||
#define IROHA_MODE_KigoMode CANNA_MODE_KigoMode
|
||||
#define IROHA_MODE_YomiMode CANNA_MODE_YomiMode
|
||||
#define IROHA_MODE_JishuMode CANNA_MODE_JishuMode
|
||||
#define IROHA_MODE_TankouhoMode CANNA_MODE_TankouhoMode
|
||||
#define IROHA_MODE_IchiranMode CANNA_MODE_IchiranMode
|
||||
#define IROHA_MODE_YesNoMode CANNA_MODE_YesNoMode
|
||||
#define IROHA_MODE_OnOffMode CANNA_MODE_OnOffMode
|
||||
#define IROHA_MODE_AdjustBunsetsuMode CANNA_MODE_AdjustBunsetsuMode
|
||||
|
||||
#define IROHA_MODE_MAX_REAL_MODE CANNA_MODE_MAX_REAL_MODE
|
||||
|
||||
/* imaginary modes */
|
||||
/* 虚モード(imaginary mode)はキーマップの実体を持っていないモード */
|
||||
|
||||
#define IROHA_MODE_HenkanMode CANNA_MODE_HenkanMode
|
||||
#define IROHA_MODE_HenkanNyuryokuMode CANNA_MODE_HenkanNyuryokuMode
|
||||
#define IROHA_MODE_HexMode CANNA_MODE_HexMode
|
||||
#define IROHA_MODE_BushuMode CANNA_MODE_BushuMode
|
||||
#define IROHA_MODE_ExtendMode CANNA_MODE_ExtendMode
|
||||
#define IROHA_MODE_RussianMode CANNA_MODE_RussianMode
|
||||
#define IROHA_MODE_GreekMode CANNA_MODE_GreekMode
|
||||
#define IROHA_MODE_LineMode CANNA_MODE_LineMode
|
||||
#define IROHA_MODE_ChangingServerMode CANNA_MODE_ChangingServerMode
|
||||
#define IROHA_MODE_HenkanMethodMode CANNA_MODE_HenkanMethodMode
|
||||
#define IROHA_MODE_DeleteDicMode CANNA_MODE_DeleteDicMode
|
||||
#define IROHA_MODE_TourokuMode CANNA_MODE_TourokuMode
|
||||
#define IROHA_MODE_TourokuEmptyMode CANNA_MODE_TourokuEmptyMode
|
||||
#define IROHA_MODE_TourokuHinshiMode CANNA_MODE_TourokuHinshiMode
|
||||
#define IROHA_MODE_TourokuDicMode CANNA_MODE_TourokuDicMode
|
||||
#define IROHA_MODE_QuotedInsertMode CANNA_MODE_QuotedInsertMode
|
||||
#define IROHA_MODE_BubunMuhenkanMode CANNA_MODE_BubunMuhenkanMode
|
||||
#define IROHA_MODE_MountDicMode CANNA_MODE_MountDicMode
|
||||
|
||||
#define IROHA_MODE_ZenHiraHenkanMode CANNA_MODE_ZenHiraHenkanMode
|
||||
#define IROHA_MODE_HanHiraHenkanMode CANNA_MODE_HanHiraHenkanMode
|
||||
#define IROHA_MODE_ZenKataHenkanMode CANNA_MODE_ZenKataHenkanMode
|
||||
#define IROHA_MODE_HanKataHenkanMode CANNA_MODE_HanKataHenkanMode
|
||||
#define IROHA_MODE_ZenAlphaHenkanMode CANNA_MODE_ZenAlphaHenkanMode
|
||||
#define IROHA_MODE_HanAlphaHenkanMode CANNA_MODE_HanAlphaHenkanMode
|
||||
|
||||
#define IROHA_MODE_ZenHiraKakuteiMode CANNA_MODE_ZenHiraKakuteiMode
|
||||
#define IROHA_MODE_HanHiraKakuteiMode CANNA_MODE_HanHiraKakuteiMode
|
||||
#define IROHA_MODE_ZenKataKakuteiMode CANNA_MODE_ZenKataKakuteiMode
|
||||
#define IROHA_MODE_HanKataKakuteiMode CANNA_MODE_HanKataKakuteiMode
|
||||
#define IROHA_MODE_ZenAlphaKakuteiMode CANNA_MODE_ZenAlphaKakuteiMode
|
||||
#define IROHA_MODE_HanAlphaKakuteiMode CANNA_MODE_HanAlphaKakuteiMode
|
||||
|
||||
#define IROHA_MODE_MAX_IMAGINARY_MODE CANNA_MODE_MAX_IMAGINARY_MODE
|
||||
|
||||
#endif /* IROHA_BC */
|
||||
|
||||
/* キー関数 */
|
||||
|
||||
/* 未定義にする */
|
||||
|
||||
#define DEFAULTBEHAVIOR 0
|
||||
#define CANNA_FN_Undefined 0 /* 未定義 */
|
||||
|
||||
/* 文字挿入 */
|
||||
|
||||
#define CANNA_FN_SelfInsert 1 /* 押されたキーをそのまま挿入 */
|
||||
#define CANNA_FN_FunctionalInsert 2 /* 押されたキーの挿入 */
|
||||
#define CANNA_FN_QuotedInsert 3 /* 次の文字をそのまま挿入 */
|
||||
|
||||
/* 基本的モード切り換え */
|
||||
|
||||
#define CANNA_FN_JapaneseMode 4 /* 日本語入力モードへ移行 */
|
||||
#define CANNA_FN_AlphaMode 5 /* アルファベット入力モードへ移行 */
|
||||
#define CANNA_FN_HenkanNyuryokuMode 6 /* 変換入力モードへ移行 */
|
||||
|
||||
/* 編集 */
|
||||
|
||||
#define CANNA_FN_Forward 7 /* 右 */
|
||||
#define CANNA_FN_Backward 8 /* 左 */
|
||||
#define CANNA_FN_Next 9 /* 次の行 */
|
||||
#define CANNA_FN_Prev 10 /* 前の行 */
|
||||
#define CANNA_FN_BeginningOfLine 11 /* 行頭 */
|
||||
#define CANNA_FN_EndOfLine 12 /* 行末 */
|
||||
#define CANNA_FN_DeleteNext 13 /* 右削除 */
|
||||
#define CANNA_FN_DeletePrevious 14 /* 左削除 */
|
||||
#define CANNA_FN_KillToEndOfLine 15 /* 行末まで削除 */
|
||||
|
||||
/* カナ漢字変換機能 */
|
||||
|
||||
#define CANNA_FN_Henkan 16 /* 変換 */
|
||||
#define CANNA_FN_Kakutei 17 /* 確定 */
|
||||
#define CANNA_FN_Extend 18 /* 伸ばし */
|
||||
#define CANNA_FN_Shrink 19 /* 縮め */
|
||||
#define CANNA_FN_AdjustBunsetsu 20 /* 文節伸縮モードに入る */
|
||||
#define CANNA_FN_Quit 21 /* 取りやめ */
|
||||
#define CANNA_FN_ConvertAsHex 22 /* 16進コードとして変換 */
|
||||
#define CANNA_FN_ConvertAsBushu 23 /* 部首名として変換 */
|
||||
#define CANNA_FN_KouhoIchiran 24 /* 候補一覧 */
|
||||
#define CANNA_FN_BubunMuhenkan 25 /* 部分無変換 */
|
||||
|
||||
/* 文字種変換だけに使われる機能 */
|
||||
|
||||
#define CANNA_FN_Zenkaku 26 /* 全角 */
|
||||
#define CANNA_FN_Hankaku 27 /* 半角 */
|
||||
#define CANNA_FN_ToUpper 28 /* 大文字 */
|
||||
#define CANNA_FN_Capitalize 29 /* 先頭だけ大文字に */
|
||||
#define CANNA_FN_ToLower 30 /* 小文字 */
|
||||
#define CANNA_FN_Hiragana 31 /* ひらがな */
|
||||
#define CANNA_FN_Katakana 32 /* カタカナ */
|
||||
#define CANNA_FN_Romaji 33 /* ローマ字 */
|
||||
|
||||
/* 読みモードでのベース文字の切り替え */
|
||||
|
||||
#define CANNA_FN_BaseHiragana 34 /* ひらがなモード */
|
||||
#define CANNA_FN_BaseKatakana 35 /* カタカナモード */
|
||||
#define CANNA_FN_BaseEisu 36 /* 英数モード */
|
||||
#define CANNA_FN_BaseZenkaku 37 /* 全角モード */
|
||||
#define CANNA_FN_BaseHankaku 38 /* 半角モード */
|
||||
#define CANNA_FN_BaseKana 39 /* かなモード */
|
||||
#define CANNA_FN_BaseKakutei 40 /* 確定入力モード */
|
||||
#define CANNA_FN_BaseHenkan 41 /* 変換入力モード */
|
||||
#define CANNA_FN_BaseHiraKataToggle 42 /* ひらがなモード/カタカナモード */
|
||||
#define CANNA_FN_BaseZenHanToggle 43 /* 全角モード/半角モード */
|
||||
#define CANNA_FN_BaseKanaEisuToggle 44 /* かなモード/英数モード */
|
||||
#define CANNA_FN_BaseKakuteiHenkanToggle 45 /* 確定入力モード/変換入力モード */
|
||||
#define CANNA_FN_BaseRotateForward 46 /* モードを順繰りに切り替える */
|
||||
#define CANNA_FN_BaseRotateBackward 47 /* モードを逆繰りに切り替える */
|
||||
|
||||
/* その他のモード切り替え */
|
||||
|
||||
#define CANNA_FN_ExtendMode 48 /* 拡張モード */
|
||||
#define CANNA_FN_Touroku CANNA_FN_ExtendMode /* 旧互換 */
|
||||
|
||||
#define CANNA_FN_HexMode 49 /* 16進入力モード */
|
||||
#define CANNA_FN_BushuMode 50 /* 部首入力モード */
|
||||
#define CANNA_FN_KigouMode 51 /* 記号入力モード */
|
||||
|
||||
#define CANNA_FN_Mark 52 /* マーク */
|
||||
#define CANNA_FN_TemporalMode 53 /* モードの一時的セーブ */
|
||||
#define CANNA_FN_UserMode 54 /* ユーザ定義モード */
|
||||
|
||||
/* 現在の表示を返して欲しいときに使う機能 */
|
||||
|
||||
#define CANNA_FN_Nop 55 /* 何もしない */
|
||||
|
||||
/* Version 2.1 には入っていない機能 */
|
||||
|
||||
#define CANNA_FN_HenkanOrInsert 56 /* 変換もしくはそのまま入力 */
|
||||
#define CANNA_FN_HenkanNaive CANNA_FN_HenkanOrInsert
|
||||
|
||||
/* Version 2.2 には入っていない機能 */
|
||||
|
||||
#define CANNA_FN_HenkanOrNothing 57 /* 変換もしくはなにもしない */
|
||||
#define CANNA_FN_RussianMode 58 /* ロシア文字モード */
|
||||
#define CANNA_FN_GreekMode 59 /* ギリシャ文字モード */
|
||||
#define CANNA_FN_LineMode 60 /* 罫線モード */
|
||||
#define CANNA_FN_DicMountMode 61 /* 辞書選択モード */
|
||||
#define CANNA_FN_ChangeServerMode 62 /* サーバ選択モード */
|
||||
#define CANNA_FN_DisconnectServer 63 /* サーバ切り離し */
|
||||
#define CANNA_FN_ShowServer 64 /* サーバ表示 */
|
||||
#define CANNA_FN_ShowGakushu 65 /* 学習状況表示 */
|
||||
#define CANNA_FN_ShowVersion 66 /* バージョン表示 */
|
||||
#define CANNA_FN_ShowPhonogramFile 67 /* ローマ字ファイル表示 */
|
||||
#define CANNA_FN_ShowCannaFile 68 /* カスタマイズファイル表示 */
|
||||
#define CANNA_FN_DefineDicMode 69 /* 単語登録 */
|
||||
#define CANNA_FN_DeleteDicMode 70 /* 単語削除 */
|
||||
#define CANNA_FN_SyncDic 71 /* 辞書書き込み */
|
||||
#define CANNA_FN_EnterChikujiMode 72 /* 逐次自動変換モード */
|
||||
#define CANNA_FN_EnterRenbunMode 73 /* 連文節変換モード */
|
||||
|
||||
/* Version 3.5 で追加されたもの */
|
||||
#define CANNA_FN_PageUp 74 /* ページアップ */
|
||||
#define CANNA_FN_PageDown 75 /* ページダウン */
|
||||
#define CANNA_FN_Edit 76 /* 編集 */
|
||||
#define CANNA_FN_BubunKakutei 77 /* カーソル以前確定 */
|
||||
|
||||
#define CANNA_FN_HenkanRegion 78 /* 選択領域の変換 */
|
||||
#define CANNA_FN_PhonoEdit 79 /* ローマ字エディタ */
|
||||
#define CANNA_FN_DicEdit 80 /* 辞書エディタ */
|
||||
#define CANNA_FN_Configure 81 /* Canna の設定 */
|
||||
|
||||
#define CANNA_FN_KanaRotate 82 /* カナ字種変換 */
|
||||
#define CANNA_FN_RomajiRotate 83 /* 英数字種変換 */
|
||||
#define CANNA_FN_CaseRotate 84 /* 大文字小文字変換 */
|
||||
|
||||
/* 以下の2つは必ず最後に置くこと。ccustom がらみの理由から */
|
||||
|
||||
#define CANNA_FN_FuncSequence 85 /* 複数の機能の割り当て */
|
||||
#define CANNA_FN_UseOtherKeymap 86 /* キーシーケンスの対応 */
|
||||
|
||||
#define CANNA_FN_MAX_FUNC (CANNA_FN_UseOtherKeymap + 1)
|
||||
|
||||
#ifdef IROHA_BC
|
||||
|
||||
#define IROHA_FN_Undefined CANNA_FN_Undefined
|
||||
|
||||
/* 文字挿入 */
|
||||
|
||||
#define IROHA_FN_SelfInsert CANNA_FN_SelfInsert
|
||||
#define IROHA_FN_FunctionalInsert CANNA_FN_FunctionalInsert
|
||||
#define IROHA_FN_QuotedInsert CANNA_FN_QuotedInsert
|
||||
|
||||
/* 基本的モード切り換え */
|
||||
|
||||
#define IROHA_FN_JapaneseMode CANNA_FN_JapaneseMode
|
||||
#define IROHA_FN_AlphaMode CANNA_FN_AlphaMode
|
||||
#define IROHA_FN_HenkanNyuryokuMode CANNA_FN_HenkanNyuryokuMode
|
||||
|
||||
|
||||
/* 編集 */
|
||||
|
||||
#define IROHA_FN_Forward CANNA_FN_Forward
|
||||
#define IROHA_FN_Backward CANNA_FN_Backward
|
||||
#define IROHA_FN_Next CANNA_FN_Next
|
||||
#define IROHA_FN_Prev CANNA_FN_Prev
|
||||
#define IROHA_FN_BeginningOfLine CANNA_FN_BeginningOfLine
|
||||
#define IROHA_FN_EndOfLine CANNA_FN_EndOfLine
|
||||
#define IROHA_FN_DeleteNext CANNA_FN_DeleteNext
|
||||
#define IROHA_FN_DeletePrevious CANNA_FN_DeletePrevious
|
||||
#define IROHA_FN_KillToEndOfLine CANNA_FN_KillToEndOfLine
|
||||
|
||||
/* カナ漢字変換機能 */
|
||||
|
||||
#define IROHA_FN_Henkan CANNA_FN_Henkan
|
||||
#define IROHA_FN_Kakutei CANNA_FN_Kakutei
|
||||
#define IROHA_FN_Extend CANNA_FN_Extend
|
||||
#define IROHA_FN_Shrink CANNA_FN_Shrink
|
||||
#define IROHA_FN_AdjustBunsetsu CANNA_FN_AdjustBunsetsu
|
||||
#define IROHA_FN_Quit CANNA_FN_Quit
|
||||
#define IROHA_FN_ConvertAsHex CANNA_FN_ConvertAsHex
|
||||
#define IROHA_FN_ConvertAsBushu CANNA_FN_ConvertAsBushu
|
||||
#define IROHA_FN_KouhoIchiran CANNA_FN_KouhoIchiran
|
||||
#define IROHA_FN_BubunMuhenkan CANNA_FN_BubunMuhenkan
|
||||
|
||||
/* 文字種変換だけに使われる機能 */
|
||||
|
||||
#define IROHA_FN_Zenkaku CANNA_FN_Zenkaku
|
||||
#define IROHA_FN_Hankaku CANNA_FN_Hankaku
|
||||
#define IROHA_FN_ToUpper CANNA_FN_ToUpper
|
||||
#define IROHA_FN_Capitalize CANNA_FN_Capitalize
|
||||
#define IROHA_FN_ToLower CANNA_FN_ToLower
|
||||
#define IROHA_FN_Hiragana CANNA_FN_Hiragana
|
||||
#define IROHA_FN_Katakana CANNA_FN_Katakana
|
||||
#define IROHA_FN_Romaji CANNA_FN_Romaji
|
||||
|
||||
/* その他のモード切り替え */
|
||||
|
||||
#define IROHA_FN_ExtendMode CANNA_FN_ExtendMode
|
||||
#define IROHA_FN_Touroku CANNA_FN_Touroku
|
||||
|
||||
#define IROHA_FN_HexMode CANNA_FN_HexMode
|
||||
#define IROHA_FN_BushuMode CANNA_FN_BushuMode
|
||||
#define IROHA_FN_KigouMode CANNA_FN_KigouMode
|
||||
|
||||
#define IROHA_FN_UserMode CANNA_FN_UserMode
|
||||
|
||||
/* 複雑な機能 */
|
||||
|
||||
#define IROHA_FN_FuncSequence CANNA_FN_FuncSequence
|
||||
#define IROHA_FN_UseOtherKeymap CANNA_FN_UseOtherKeymap
|
||||
|
||||
#define IROHA_FN_MAX_FUNC CANNA_FN_MAX_FUNC
|
||||
|
||||
#endif /* IROHA_BC */
|
||||
|
||||
#endif /* _MFDEF_H_ */
|
@ -1,26 +0,0 @@
|
||||
/* 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: patchlevel.h 10527 2004-12-23 22:08:39Z korli $ */
|
||||
|
||||
#define CANNA_MAJOR_MINOR 3005
|
||||
#define CANNA_PATCH_LEVEL " beta 2"
|
@ -1,197 +0,0 @@
|
||||
/* Copyright 1993 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: protodefs.h 10527 2004-12-23 22:08:39Z korli $ */
|
||||
|
||||
#define canna_version(majv, minv) ((majv) * 1024 + (minv))
|
||||
|
||||
/* 以下は rkcw.h 内のと同じ定義 */
|
||||
#ifndef CBUFSIZE
|
||||
typedef unsigned short Ushort;
|
||||
typedef unsigned char BYTE;
|
||||
#define CBUFSIZE 512
|
||||
#define CBIGBUFSIZE 4096
|
||||
#endif
|
||||
/* ここまで */
|
||||
|
||||
#define OLD_MAX_CX 100
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
/* #define SERVER_VERSION "3.5" */
|
||||
#define E_VERSION "1.2"
|
||||
#define W_VERSION "3.3"
|
||||
|
||||
#define IR_SERVICE_NAME "canna"
|
||||
#define IR_DEFAULT_PORT 5680
|
||||
#define IR_UNIX_DIR "/tmp/.iroha_unix"
|
||||
#define IR_UNIX_PATH "/tmp/.iroha_unix/IROHA"
|
||||
#define NAME_LENGTH 15
|
||||
#define HOST_NAME 15
|
||||
|
||||
#define LOMASK(x) ((x)&255)
|
||||
#define L4TOL(l4)\
|
||||
((((((((unsigned long) ((unsigned char)(l4)[0])) << 8) | \
|
||||
((unsigned long) ((unsigned char)(l4)[1]))) << 8) | \
|
||||
((unsigned long) ((unsigned char)(l4)[2]))) << 8) | \
|
||||
((unsigned long) ((unsigned char)(l4)[3])))
|
||||
|
||||
#define L3TOL(l3)\
|
||||
((unsigned long)(((((unsigned char)(l3)[0]<<8)|\
|
||||
(unsigned char)(l3)[1])<<8) | (unsigned char)(l3)[2]))
|
||||
#define S2TOS(s2) ((unsigned short)(((unsigned char)(s2)[0]<<8)|\
|
||||
(unsigned char)(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));\
|
||||
}
|
||||
|
||||
/* IXXtoIXX は必要性を考えてあとで削れるなら削る */
|
||||
#if 0
|
||||
#define I16toI32(x) (((x) & 0x8000) ? ((x) | 0xffff8000) : (x))
|
||||
#endif
|
||||
#define I16toI32(x) (x)
|
||||
#define I8toI32(x) (((x) & 0x80) ? ((x) | 0xffffff80) : (x))
|
||||
|
||||
#if defined(__bsdi__) || defined(__FreeBSD__)
|
||||
#include <machine/endian.h>
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN( n, m ) ( ((unsigned)(n) > (unsigned)(m)) ? (m) : (n) )
|
||||
#endif
|
||||
|
||||
#define BUFSIZE 4096
|
||||
#define MAXDATA 1024
|
||||
|
||||
/* かんなサーバプロトコル */
|
||||
|
||||
#define wInitialize 0x01
|
||||
#define wFinalize 0x02
|
||||
#define wCreateContext 0x03
|
||||
#define wDuplicateContext 0x04
|
||||
#define wCloseContext 0x05
|
||||
#define wGetDictionaryList 0x06
|
||||
#define wGetDirectoryList 0x07
|
||||
#define wMountDictionary 0x08
|
||||
#define wUnmountDictionary 0x09
|
||||
#define wRemountDictionary 0x0a
|
||||
#define wGetMountDictionaryList 0x0b
|
||||
#define wQueryDictionary 0x0c
|
||||
#define wDefineWord 0x0d
|
||||
#define wDeleteWord 0x0e
|
||||
#define wBeginConvert 0x0f
|
||||
#define wEndConvert 0x10
|
||||
#define wGetCandidacyList 0x11
|
||||
#define wGetYomi 0x12
|
||||
#define wSubstYomi 0x13
|
||||
#define wStoreYomi 0x14
|
||||
#define wStoreRange 0x15
|
||||
#define wGetLastYomi 0x16
|
||||
#define wFlushYomi 0x17
|
||||
#define wRemoveYomi 0x18
|
||||
#define wGetSimpleKanji 0x19
|
||||
#define wResizePause 0x1a
|
||||
#define wGetHinshi 0x1b
|
||||
#define wGetLex 0x1c
|
||||
#define wGetStatus 0x1d
|
||||
#define wSetLocale 0x1e
|
||||
#define wAutoConvert 0x1f
|
||||
#define wQueryExtensions 0x20
|
||||
#define wSetApplicationName 0x21
|
||||
#define wNoticeGroupName 0x22
|
||||
#define wThrough 0x23
|
||||
#define wKillServer 0x24
|
||||
|
||||
#define W_REALREQUEST 0x24 /* same as the max number */
|
||||
#define W_MAXREQUESTNO (W_REALREQUEST + 1)
|
||||
|
||||
#ifdef EXTENSION
|
||||
#define wGetServerInfo 0x01
|
||||
#define wGetAccessControlList 0x02
|
||||
#define wCreateDictionary 0x03
|
||||
#define wDeleteDictionary 0x04
|
||||
#define wRenameDictionary 0x05
|
||||
#define wGetWordTextDictionary 0x06
|
||||
#define wListDictionary 0x07
|
||||
#define wSync 0x08
|
||||
#define wChmodDictionary 0x09
|
||||
#define wCopyDictionary 0x0a
|
||||
#endif /* EXTENSION */
|
||||
|
||||
#define W_MAXEXTREQUESTNO 0x0b /* the max number plus 1 */
|
||||
|
||||
|
||||
/* いろはサーバプロトコル */
|
||||
#define OLD_MAXREQUESTNO 0x18
|
||||
|
||||
#define MAXREQUESTNO 0x1b
|
||||
#define REALREQUEST 0x1a
|
||||
|
||||
#define IR_INIT 0x01
|
||||
#define IR_FIN 0x02
|
||||
#define IR_CRE_CON 0x03
|
||||
#define IR_DUP_CON 0x04
|
||||
#define IR_CLO_CON 0x05
|
||||
#define IR_DIC_LIST 0x06
|
||||
#define IR_GET_YOMI 0x07
|
||||
#define IR_DEF_DIC 0x08
|
||||
#define IR_UNDEF_DIC 0x09
|
||||
#define IR_DIC_PATH 0x0a
|
||||
#define IR_DIR_LIST 0x0b
|
||||
#define IR_MNT_DIC 0x0c
|
||||
#define IR_UMNT_DIC 0x0d
|
||||
#define IR_RMNT_DIC 0x0e
|
||||
#define IR_MNT_LIST 0x0f
|
||||
#define IR_CONVERT 0x10
|
||||
#define IR_CONV_END 0x11
|
||||
#define IR_KAN_LST 0x12
|
||||
#define IR_RESIZE 0x13
|
||||
#define IR_STO_YOMI 0x14
|
||||
#define IR_GET_LEX 0x15
|
||||
#define IR_GET_STA 0x16
|
||||
#define IR_SER_STAT 0x17
|
||||
#define IR_SER_STAT2 0x18
|
||||
#define IR_HOST_CTL 0x19
|
||||
#define IR_QUERY_EXT 0x1a
|
||||
|
||||
#ifdef EXTENSION
|
||||
#define EXTBASEPROTONO 0x00010000
|
||||
#define MAXEXTREQUESTNO 0x04
|
||||
|
||||
#define REMOTE_DIC_UTIL "remote_dictionary_maintenance"
|
||||
#define IR_LIST_DIC 0x00
|
||||
#define IR_CREAT_DIC 0x01
|
||||
#define IR_DEST_DIC 0x02
|
||||
#define IR_RENAME_DIC 0x03
|
||||
#define IR_GET_WORD_DIC 0x04
|
||||
#else /* !EXTENSION */
|
||||
#define EXTBASEPROTONO 0x00000000
|
||||
#define MAXEXTREQUESTNO 0xff
|
||||
#endif /* !EXTENSION */
|
@ -1,232 +0,0 @@
|
||||
/* 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: symbolname.h 10527 2004-12-23 22:08:39Z korli $
|
||||
*/
|
||||
|
||||
#define S_HenkanNyuuryokuMode "henkan-nyuuryoku-mode"
|
||||
#define S_ZenHiraHenkanMode "zen-hira-henkan-mode"
|
||||
#define S_HanHiraHenkanMode "han-hira-henkan-mode"
|
||||
#define S_ZenKataHenkanMode "zen-kata-henkan-mode"
|
||||
#define S_HanKataHenkanMode "han-kata-henkan-mode"
|
||||
#define S_ZenAlphaHenkanMode "zen-alpha-henkan-mode"
|
||||
#define S_HanAlphaHenkanMode "han-alpha-henkan-mode"
|
||||
#define S_ZenHiraKakuteiMode "zen-hira-kakutei-mode"
|
||||
#define S_HanHiraKakuteiMode "han-hira-kakutei-mode"
|
||||
#define S_ZenKataKakuteiMode "zen-kata-kakutei-mode"
|
||||
#define S_HanKataKakuteiMode "han-kata-kakutei-mode"
|
||||
#define S_ZenAlphaKakuteiMode "zen-alpha-kakutei-mode"
|
||||
#define S_HanAlphaKakuteiMode "han-alpha-kakutei-mode"
|
||||
#define S_AlphaMode "alpha-mode"
|
||||
#define S_YomiganaiMode "empty-mode"
|
||||
#define S_YomiMode "yomi-mode"
|
||||
#define S_MojishuMode "mojishu-mode"
|
||||
#define S_TankouhoMode "tankouho-mode"
|
||||
#define S_IchiranMode "ichiran-mode"
|
||||
#define S_ShinshukuMode "shinshuku-mode"
|
||||
#define S_HexMode "hex-mode"
|
||||
#define S_BushuMode "bushu-mode"
|
||||
#define S_YesNoMode "yes-no-mode"
|
||||
#define S_OnOffMode "on-off-mode"
|
||||
#define S_ExtendMode "extend-mode"
|
||||
#define S_RussianMode "russian-mode"
|
||||
#define S_GreekMode "greek-mode"
|
||||
#define S_LineMode "line-mode"
|
||||
#define S_ChangingServerMode "changing-server-mode"
|
||||
#define S_HenkanMethodMode "henkan-method-mode"
|
||||
#define S_DeleteDicMode "delete-dic-mode"
|
||||
#define S_TourokuMode "touroku-mode"
|
||||
#define S_TourokuHinshiMode "touroku-hinshi-mode"
|
||||
#define S_TourokuDicMode "touroku-dic-mode"
|
||||
#define S_QuotedInsertMode "quoted-insert-mode"
|
||||
#define S_BubunMuhenkanMode "bubun-muhenkan-mode"
|
||||
#define S_MountDicMode "mount-dic-mode"
|
||||
#define S_KigouMode "kigou-mode"
|
||||
#define S_AutoYomiMode "chikuji-yomi-mode"
|
||||
#define S_AutoBunsetsuMode "chikuji-bunsetsu-mode"
|
||||
#define S_UnbindKey "unbind-key-function"
|
||||
#define S_GUnbindKey "global-unbind-key-function"
|
||||
#define S_SetKey "set-key"
|
||||
#define S_GSetKey "global-set-key"
|
||||
#define S_SetModeDisp "set-mode-display"
|
||||
#define S_DefMode "defmode"
|
||||
#define S_DefSymbol "defsymbol"
|
||||
#define S_DefSelection "defselection"
|
||||
#define S_DefMenu "defmenu"
|
||||
#define S_SetInitFunc "initialize-function"
|
||||
#define S_FN_UseDictionary "use-dictionary"
|
||||
#define S_defEscSequence "define-esc-sequence"
|
||||
#define S_defXKeysym "define-x-keysym"
|
||||
|
||||
#define S_FN_Undefined "undefined"
|
||||
#define S_FN_SelfInsert "self-insert"
|
||||
#define S_FN_FunctionalInsert "self-insert"
|
||||
#define S_FN_QuotedInsert "quoted-insert"
|
||||
#define S_FN_JapaneseMode "japanese-mode"
|
||||
#define S_FN_AlphaMode S_AlphaMode
|
||||
#define S_FN_HenkanNyuryokuMode S_HenkanNyuuryokuMode
|
||||
#define S_FN_ZenHiraKakuteiMode S_ZenHiraKakuteiMode
|
||||
#define S_FN_ZenKataKakuteiMode S_ZenKataKakuteiMode
|
||||
#define S_FN_HanKataKakuteiMode S_HanKataKakuteiMode
|
||||
#define S_FN_ZenAlphaKakuteiMode S_ZenAlphaKakuteiMode
|
||||
#define S_FN_HanAlphaKakuteiMode S_HanAlphaKakuteiMode
|
||||
#define S_FN_HexMode S_HexMode
|
||||
#define S_FN_BushuMode S_BushuMode
|
||||
#define S_FN_KigouMode S_KigouMode
|
||||
#define S_FN_Forward "forward"
|
||||
#define S_FN_Backward "backward"
|
||||
#define S_FN_Next "next"
|
||||
#define S_FN_Prev "previous"
|
||||
#define S_FN_BeginningOfLine "beginning-of-line"
|
||||
#define S_FN_EndOfLine "end-of-line"
|
||||
#define S_FN_DeleteNext "delete-next"
|
||||
#define S_FN_DeletePrevious "delete-previous"
|
||||
#define S_FN_KillToEndOfLine "kill-to-end-of-line"
|
||||
#define S_FN_Henkan "henkan"
|
||||
#define S_FN_HenkanNaive "henkan-naive"
|
||||
#define S_FN_HenkanOrSelfInsert "henkan-or-self-insert"
|
||||
#define S_FN_HenkanOrDoNothing "henkan-or-do-nothing"
|
||||
#define S_FN_Kakutei "kakutei"
|
||||
#define S_FN_Extend "extend"
|
||||
#define S_FN_Shrink "shrink"
|
||||
#define S_FN_AdjustBunsetsu S_ShinshukuMode
|
||||
#define S_FN_Quit "quit"
|
||||
#define S_FN_ExtendMode S_ExtendMode
|
||||
#define S_FN_Touroku "touroku"
|
||||
#define S_FN_ConvertAsHex "convert-as-hex"
|
||||
#define S_FN_ConvertAsBushu "convert-as-bushu"
|
||||
#define S_FN_KouhoIchiran "kouho-ichiran"
|
||||
#define S_FN_BubunMuhenkan "henshu"
|
||||
#define S_FN_Zenkaku "zenkaku"
|
||||
#define S_FN_Hankaku "hankaku"
|
||||
#define S_FN_ToUpper "to-upper"
|
||||
#define S_FN_Capitalize "capitalize"
|
||||
#define S_FN_ToLower "to-lower"
|
||||
#define S_FN_Hiragana "hiragana"
|
||||
#define S_FN_Katakana "katakana"
|
||||
#define S_FN_Romaji "romaji"
|
||||
#define S_FN_BaseHiragana "base-hiragana"
|
||||
#define S_FN_BaseKatakana "base-katakana"
|
||||
#define S_FN_BaseKana "base-kana"
|
||||
#define S_FN_BaseEisu "base-eisu"
|
||||
#define S_FN_BaseZenkaku "base-zenkaku"
|
||||
#define S_FN_BaseHankaku "base-hankaku"
|
||||
#define S_FN_BaseKakutei "base-kakutei"
|
||||
#define S_FN_BaseHenkan "base-henkan"
|
||||
#define S_FN_BaseHiraKataToggle "base-hiragana-katakana-toggle"
|
||||
#define S_FN_BaseKanaEisuToggle "base-kana-eisu-toggle"
|
||||
#define S_FN_BaseZenHanToggle "base-zenkaku-hankaku-toggle"
|
||||
#define S_FN_BaseKakuteiHenkanToggle "base-kakutei-henkan-toggle"
|
||||
#define S_FN_BaseRotateForward "base-rotate-forward"
|
||||
#define S_FN_BaseRotateBackward "base-rotate-backward"
|
||||
#define S_FN_Mark "mark"
|
||||
#define S_FN_Temporary "temporary"
|
||||
#define S_FN_SyncDic "sync-dictionary"
|
||||
#define S_FN_FuncSequence "XXXXXXXXXXXXXX"
|
||||
#define S_FN_UseOtherKeymap "XXXXXXXXXXXXXX"
|
||||
#define S_FN_DefineDicMode S_TourokuMode
|
||||
#define S_FN_DeleteDicMode S_DeleteDicMode
|
||||
#define S_FN_DicMountMode "jisho-ichiran"
|
||||
#define S_FN_EnterChikujiMode "chikuji-mode"
|
||||
#define S_FN_EnterRenbunMode "renbun-mode"
|
||||
#define S_FN_DisconnectServer "disconnect-server"
|
||||
#define S_FN_ChangeServerMode "switch-server"
|
||||
#define S_FN_ShowServer "show-server-name"
|
||||
#define S_FN_ShowGakushu "show-gakushu"
|
||||
#define S_FN_ShowVersion "show-canna-version"
|
||||
#define S_FN_ShowPhonogramFile "show-romkana-table"
|
||||
#define S_FN_ShowCannaFile "show-canna-file"
|
||||
#define S_FN_KanaRotate "kana-rotate-forward"
|
||||
#define S_FN_RomajiRotate "romaji-rotate-forward"
|
||||
#define S_FN_CaseRotate "case-rotate-forward"
|
||||
|
||||
#define S_VA_RomkanaTable "romkana-table"
|
||||
#define S_VA_EnglishTable "english-table"
|
||||
#define S_VA_InitMode "initial-mode"
|
||||
#define S_VA_CursorWrap "cursor-wrap"
|
||||
#define S_VA_SelectDirect "select-direct"
|
||||
#define S_VA_NumericalKeySelect "numerical-key-select"
|
||||
#define S_VA_BunsetsuKugiri "bunsetsu-kugiri"
|
||||
#define S_VA_CharacterBasedMove "character-based-move"
|
||||
#define S_VA_ReverseWidely "reverse-widely"
|
||||
#define S_VA_ReverseWord "reverse-word"
|
||||
#define S_VA_Gakushu "gakushu"
|
||||
#define S_VA_QuitIfEOIchiran "quit-if-end-of-ichiran"
|
||||
#define S_VA_KakuteiIfEOBunsetsu "kakutei-if-end-of-bunsetsu"
|
||||
#define S_VA_StayAfterValidate "stay-after-validate"
|
||||
#define S_VA_BreakIntoRoman "break-into-roman"
|
||||
#define S_VA_NHenkanForIchiran "n-henkan-for-ichiran"
|
||||
#define S_VA_nKouhoBunsetsu "n-kouho-bunsetsu"
|
||||
#define S_VA_keepCursorPosition "keep-cursor-position"
|
||||
#define S_VA_GrammaticalQuestion "grammatical-question"
|
||||
#define S_VA_ForceKana "force-kana"
|
||||
#define S_VA_KouhoCount "kouho-count"
|
||||
#define S_VA_Auto "auto"
|
||||
#define S_VA_LearnNumericalType "learn-numerical-type"
|
||||
#define S_VA_BackspaceBehavesAsQuit "backspace-behaves-as-quit"
|
||||
#define S_VA_InhibitListCallback "inhibit-list-callback"
|
||||
#define S_VA_CannaVersion "canna-version"
|
||||
#define S_VA_ProtocolVersion "protocol-version"
|
||||
#define S_VA_ServerVersion "server-version"
|
||||
#define S_VA_ServerName "server-name"
|
||||
#define S_VA_Abandon "abandon-illegal-phonogram"
|
||||
#define S_VA_HexDirect "hex-direct"
|
||||
#define S_VA_Kojin "kojin"
|
||||
#define S_VA_IndexHankaku "index-hankaku"
|
||||
#define S_VA_IndexSeparator "index-separator"
|
||||
#define S_VA_AllowNextInput "allow-next-input"
|
||||
#define S_VA_KeepCursorPosition "keep-cursor"
|
||||
#define S_VA_ChikujiContinue "chikuji-continue"
|
||||
#define S_VA_RenbunContinue "renbun-continue"
|
||||
#define S_VA_MojishuContinue "mojishu-continue"
|
||||
#define S_VA_ChikujiRealBackspace "chikuji-force-backspace"
|
||||
#define S_VA_doKatakanaGakushu "katakana-touroku"
|
||||
#define S_VA_doHiraganaGakushu "hiragana-touroku"
|
||||
#define S_VA_chikuji_debug "chikuji-debug"
|
||||
#define S_VA_nDisconnectServer "n-keys-to-disconnect"
|
||||
#define S_VA_ignoreCase "ignore-case"
|
||||
#define S_VA_RomajiYuusen "romaji-yuusen"
|
||||
#define S_VA_CannaDir "canna-directory"
|
||||
#define S_VA_AutoSync "auto-sync"
|
||||
#define S_VA_QuicklyEscape "quickly-escape-from-kigo-input"
|
||||
#define S_VA_InhibitHanKana "inhibit-hankaku-kana"
|
||||
#define S_VA_CodeInput "code-input"
|
||||
|
||||
#define S_IF_HenkanNyuryoku "(japanese-mode)"
|
||||
#define S_IF_ZenHiraKakutei "(japanese-mode base-kakutei)"
|
||||
#define S_IF_ZenKataKakutei "(japanese-mode base-kakutei base-katakana)"
|
||||
#define S_IF_ZenAlphaKakutei "(japanese-mode base-kakutei base-eisu base-zenkaku)"
|
||||
#define S_IF_HanKataKakutei "(japanese-mode base-kakutei base-katakana base-hankaku)"
|
||||
#define S_IF_HanAlphaKakutei "(japanese-mode base-kakutei base-eisu base-hankaku)"
|
||||
#define S_IF_ZenKataHenkan "(japanese-mode base-katakana)"
|
||||
#define S_IF_ZenAlphaHenkan "(japanese-mode base-eisu base-zenkaku)"
|
||||
#define S_IF_HanKataHenkan "(japanese-mode base-katakana base-hankaku)"
|
||||
#define S_IF_HanAlphaHenkan "(japanese-mode hase-eisu base-hankaku)"
|
||||
|
||||
#define S_FN_PageUp "page-up"
|
||||
#define S_FN_PageDown "page-down"
|
||||
#define S_FN_Edit "edit"
|
||||
#define S_FN_BubunKakutei "bubun-kakutei"
|
||||
#define S_FN_HenkanRegion "henkan-region"
|
||||
#define S_FN_PhonoEdit "phono-edit"
|
||||
#define S_FN_DicEdit "dic-edit"
|
||||
#define S_FN_Configure "configure"
|
@ -1,36 +0,0 @@
|
||||
/* 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: widedef.h 10527 2004-12-23 22:08:39Z korli $
|
||||
*/
|
||||
// Modified by T.Murai for BeOS
|
||||
|
||||
#ifndef _WIDEDEF_H_
|
||||
#define _WIDEDEF_H_
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
//#define HAVE_WCHAR_OPERATION
|
||||
//#define _WCHAR_T
|
||||
typedef uint16 WCHAR_T;
|
||||
#endif /* _WIDEDEF_H_ */
|
@ -1,50 +0,0 @@
|
||||
SubDir HAIKU_TOP src add-ons input_server methods canna lib ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
# filter warnings we don't want here
|
||||
TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)
|
||||
= [ FFilter $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH))
|
||||
: -Wmissing-prototypes ] ;
|
||||
|
||||
SubDirCcFlags -x c++ -ansi -trigraphs -funsigned-char -funsigned-bitfields -w -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 ] ;
|
||||
SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ;
|
||||
|
||||
StaticLibrary libcanna.a :
|
||||
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
|
||||
;
|
File diff suppressed because it is too large
Load Diff
@ -1,715 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#endif
|
||||
|
||||
#include "canna.h"
|
||||
// There is Exported Symbols !!
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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;
|
||||
}
|
@ -1,317 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#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,
|
||||
};
|
@ -1,62 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
extern int DoFuncSequence();
|
||||
extern int UseOtherKeymap();
|
||||
extern int TanNop (uiContext);
|
||||
extern int 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 int searchfunc(...);
|
||||
KanjiModeRec bunsetsu_mode = {
|
||||
searchfunc,
|
||||
default_kmap,
|
||||
CANNA_KANJIMODE_TABLE_SHARED,
|
||||
bun_funcs,
|
||||
};
|
||||
|
@ -1,225 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#endif /* lint */
|
||||
|
||||
#include <errno.h>
|
||||
#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"
|
||||
|
||||
/* »Ä¤Ã¤Æ¤¤¤ë¤ª»Å»ö
|
||||
|
||||
¡¦Ã༡¼«Æ°ÊÑ´¹Ãæ¤ÎʸÀ´̥⡼¥É
|
||||
*/
|
@ -1,781 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include <errno.h>
|
||||
#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 int vBushuMode(uiContext d, int major_mode);
|
||||
static int vBushuIchiranQuitCatch(uiContext d, int retval, mode_context env);
|
||||
static int vBushuExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int bushuEveryTimeCatch(uiContext d, int retval, mode_context env);
|
||||
static int bushuExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int bushuQuitCatch(uiContext d, int retval, mode_context env);
|
||||
static int convBushuQuitCatch(uiContext d, int retval, mode_context env);
|
||||
static int bushuHenkan(uiContext d, int flag, int ext, int cur, int (*quitfunc )(uiContext, int, mode_context ));
|
||||
static int 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;
|
||||
}
|
||||
|
||||
int
|
||||
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 int
|
||||
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 int
|
||||
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 int
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
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 int bushuEveryTimeCatch (uiContext, int, mode_context);
|
||||
|
||||
static int
|
||||
bushuEveryTimeCatch(uiContext d, int retval, mode_context env)
|
||||
/* ARGSUSED */
|
||||
{
|
||||
makeBushuEchoStr(d);
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
static int bushuExitCatch (uiContext, int, mode_context);
|
||||
|
||||
static int
|
||||
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 int
|
||||
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 int
|
||||
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);
|
||||
|
||||
int
|
||||
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 int 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 int
|
||||
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 int 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 int
|
||||
makeBushuIchiranQuit(uiContext d, int flag)
|
||||
{
|
||||
extern int 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);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,790 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
|
||||
#include "canna.h"
|
||||
#include "RK.h"
|
||||
#include "RKintern.h"
|
||||
|
||||
#ifdef MEASURE_TIME
|
||||
#include <sys/types.h>
|
||||
#ifdef WIN
|
||||
#include <sys/timeb.h>
|
||||
#else
|
||||
/* If you compile with Visual C++, then please comment out the next line. */
|
||||
#include <sys/times.h>
|
||||
#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 int 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);
|
||||
}
|
||||
|
||||
int
|
||||
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, (int(*)(...))YomiInsert);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
ChikujiHenkanOrNothing(uiContext d)
|
||||
{
|
||||
return generalNaive(d, (int(*)(...))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"
|
@ -1,93 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#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
|
||||
};
|
@ -1,258 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#endif /* lint */
|
||||
|
||||
#include "canna.h"
|
||||
#include <canna/mfdef.h>
|
||||
#include "patchlevel.h"
|
||||
#include <Beep.h>
|
||||
|
||||
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;
|
||||
}
|
@ -1,473 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include "canna.h"
|
||||
#include <canna/mfdef.h>
|
||||
|
||||
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 (int (*)(...))p->cfunc;
|
||||
}
|
||||
}
|
||||
return (int (*)(...))0;
|
||||
}
|
||||
|
||||
static int
|
||||
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,
|
||||
};
|
@ -1,358 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
|
||||
#include "canna.h"
|
||||
// There is Exported Symbols !!
|
||||
extern int howToReturnModeInfo;
|
||||
|
||||
static WCHAR_T *inbuf = 0;
|
||||
static int inbufsize = 0;
|
||||
|
||||
|
||||
static int
|
||||
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 int
|
||||
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);
|
||||
}
|
@ -1,781 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include "canna.h"
|
||||
#include "patchlevel.h"
|
||||
#include "RK.h"
|
||||
#include "RKintern.h"
|
||||
|
||||
extern struct RkRxDic *romajidic, *englishdic;
|
||||
|
||||
static int inEmptySelfInsert(uiContext d);
|
||||
static int EmptySelfInsert(uiContext d);
|
||||
static int EmptyYomiInsert(uiContext d);
|
||||
static int EmptyQuotedInsert(uiContext d);
|
||||
static int AlphaSelfInsert(uiContext d);
|
||||
static int AlphaNop(uiContext d);
|
||||
static int EmptyQuit(uiContext d);
|
||||
static int EmptyKakutei(uiContext d);
|
||||
static int EmptyDeletePrevious(uiContext d);
|
||||
static int UserMode(uiContext d, extraFunc *estruct);
|
||||
static int UserSelect(uiContext d, extraFunc *estruct);
|
||||
static int UserMenu(uiContext d, extraFunc *estruct);
|
||||
static int ProcExtraFunc(uiContext d, int fnum);
|
||||
static int HenkanRegion(uiContext d);
|
||||
static int PhonoEdit(uiContext d);
|
||||
static int DicEdit(uiContext d);
|
||||
static int 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 int
|
||||
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 int
|
||||
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 int
|
||||
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 int
|
||||
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 int
|
||||
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 int
|
||||
AlphaNop(uiContext d)
|
||||
{
|
||||
/* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */
|
||||
d->majorMode = d->minorMode = CANNA_MODE_KigoMode;
|
||||
currentModeInfo(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
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 int
|
||||
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 int
|
||||
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 int
|
||||
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 int
|
||||
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, (int(*)(...))uuKigoGeneralExitCatch, posp);
|
||||
}
|
||||
|
||||
static int
|
||||
UserMenu(uiContext d, extraFunc *estruct)
|
||||
{
|
||||
return showmenu(d, estruct->u.menuptr);
|
||||
}
|
||||
#endif /* NO_EXTEND_MENU */
|
||||
|
||||
/* ¥Ç¥Õ¥©¥ë¥È°Ê³°¤Î¥â¡¼¥É»ÈÍÑ»þ¤Ë¸Æ¤Ó½Ð¤¹´Ø¿ô¤òÀÚ¤êʬ¤±¤ë */
|
||||
|
||||
static int
|
||||
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);
|
||||
}
|
||||
|
||||
int
|
||||
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);
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
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 int 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"
|
@ -1,368 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#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,
|
||||
};
|
@ -1,58 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
|
||||
#include "canna.h"
|
||||
|
||||
#define CANNA_SERVER_NAME_LEN 128
|
||||
static char iroha_server_name[CANNA_SERVER_NAME_LEN] = {0, 0};
|
||||
|
||||
int
|
||||
RkSetServerName(char *s)
|
||||
{
|
||||
strlcpy(iroha_server_name, s, CANNA_SERVER_NAME_LEN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
RkGetServerHost(void)
|
||||
{
|
||||
// if (iroha_server_name[0]) {
|
||||
// return iroha_server_name;
|
||||
// }
|
||||
// else {
|
||||
return (char *)0;
|
||||
// }
|
||||
}
|
||||
|
||||
void
|
||||
close_engine(void)
|
||||
{
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,161 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#ifndef NO_EXTEND_MENU
|
||||
#include "canna.h"
|
||||
|
||||
#define HEXPROMPT "\245\263\241\274\245\311: "
|
||||
#define HEXPROMPTLEN 5 /* "¥³¡¼¥É: " ¤ÎŤµ¤Ï5¥Ð¥¤¥È */
|
||||
|
||||
static int hexEveryTimeCatch(uiContext d, int retval, mode_context env);
|
||||
static int exitHex(uiContext d, int retval, mode_context env);
|
||||
static int quitHex(uiContext d, int retval, mode_context env);
|
||||
static int hexMode(uiContext d, int major_mode);
|
||||
|
||||
static int quitHex();
|
||||
|
||||
/* cfuncdef
|
||||
|
||||
hexEveryTimeCatch -- Æɤߤò£±£¶¿ÊÆþÎϥ⡼¥É¤Çɽ¼¨¤¹¤ë´Ø¿ô
|
||||
|
||||
*/
|
||||
|
||||
static int
|
||||
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 int
|
||||
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 int
|
||||
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 -- £±£¶¿ÊÆþÎϥ⡼¥É¤Ë¤Ê¤ë¤È¤¤Ë¸Æ¤Ð¤ì¤ë¡£
|
||||
|
||||
*/
|
||||
|
||||
int 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 */
|
File diff suppressed because it is too large
Load Diff
@ -1,79 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#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 int searchfunc(...);
|
||||
KanjiModeRec ichiran_mode = {
|
||||
searchfunc,
|
||||
default_kmap,
|
||||
CANNA_KANJIMODE_TABLE_SHARED,
|
||||
ichiran_funcs,
|
||||
};
|
@ -1,958 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include "canna.h"
|
||||
#include <ctype.h>
|
||||
|
||||
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 int inhibittedJishu(uiContext d);
|
||||
static int nextJishu(uiContext d);
|
||||
static int previousJishu(uiContext d);
|
||||
static int JishuNextJishu(uiContext d);
|
||||
static int JishuPreviousJishu(uiContext d);
|
||||
static int JishuRotateWithInhibition(uiContext d, unsigned inhibit);
|
||||
static int JishuKanaRotate(uiContext d);
|
||||
static int JishuRomajiRotate(uiContext d);
|
||||
static int JishuShrink(uiContext d);
|
||||
static int JishuNop(uiContext d);
|
||||
static int JishuExtend(uiContext d);
|
||||
static void jishuAdjustRome(uiContext d);
|
||||
static void myjishuAdjustRome(uiContext d);
|
||||
static int JishuZenkaku(uiContext d);
|
||||
static int JishuHankaku(uiContext d);
|
||||
static int exitJishuAndDoSomething(uiContext d, int fnum);
|
||||
static int JishuYomiInsert(uiContext d);
|
||||
static int JishuQuit(uiContext d);
|
||||
static int JishuToUpper(uiContext d);
|
||||
static int JishuCapitalize(uiContext d);
|
||||
static int JishuToLower(uiContext d);
|
||||
static int JishuHiragana(uiContext d);
|
||||
static int JishuKatakana(uiContext d);
|
||||
static int JishuRomaji(uiContext d);
|
||||
static void nextCase(yomiContext yc);
|
||||
static int JishuCaseRotateForward(uiContext d);
|
||||
static int JishuKanjiHenkan(uiContext d);
|
||||
static int JishuKanjiHenkanOInsert(uiContext d);
|
||||
static int 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int 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
|
||||
int 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
|
||||
int 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
|
||||
int 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 int JishuNextJishu (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuPreviousJishu (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuRotateWithInhibition (uiContext, unsigned);
|
||||
|
||||
static
|
||||
int 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 int JishuKanaRotate (uiContext);
|
||||
|
||||
static
|
||||
int JishuKanaRotate(uiContext d)
|
||||
{
|
||||
return JishuRotateWithInhibition(d, INHIBIT_ALPHA);
|
||||
}
|
||||
|
||||
static int JishuRomajiRotate (uiContext);
|
||||
|
||||
static
|
||||
int JishuRomajiRotate(uiContext d)
|
||||
{
|
||||
return JishuRotateWithInhibition(d, INHIBIT_KANA | INHIBIT_HIRA);
|
||||
}
|
||||
|
||||
static void myjishuAdjustRome (uiContext);
|
||||
static int JishuShrink (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuNop (uiContext);
|
||||
|
||||
static
|
||||
int JishuNop(uiContext d)
|
||||
{
|
||||
/* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */
|
||||
d->majorMode = d->minorMode = CANNA_MODE_AlphaMode;
|
||||
currentModeInfo(d);
|
||||
|
||||
makeKanjiStatusReturn(d, (yomiContext)d->modec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int JishuExtend (uiContext);
|
||||
|
||||
static
|
||||
int 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
|
||||
int 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 int JishuYomiInsert (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuQuit (uiContext);
|
||||
|
||||
static
|
||||
int JishuQuit(uiContext d)
|
||||
{
|
||||
leaveJishuMode(d, (yomiContext)d->modec);
|
||||
makeKanjiStatusReturn(d, (yomiContext)d->modec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Âçʸ»ú¤Ë¤¹¤ë´Ø¿ô */
|
||||
|
||||
static int JishuToUpper (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuCapitalize (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuToLower (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuHiragana (uiContext);
|
||||
|
||||
static
|
||||
int JishuHiragana(uiContext d)
|
||||
{
|
||||
yomiContext yc = (yomiContext)d->modec;
|
||||
|
||||
yc->jishu_kc = JISHU_HIRA;
|
||||
makeKanjiStatusReturn(d, yc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int JishuKatakana (uiContext);
|
||||
|
||||
static
|
||||
int JishuKatakana(uiContext d)
|
||||
{
|
||||
yomiContext yc = (yomiContext)d->modec;
|
||||
|
||||
yc->jishu_kc = JISHU_ZEN_KATA;
|
||||
makeKanjiStatusReturn(d, yc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int JishuRomaji (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuCaseRotateForward (uiContext);
|
||||
|
||||
static
|
||||
int 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 int JishuKanjiHenkan (uiContext);
|
||||
|
||||
static
|
||||
int JishuKanjiHenkan(uiContext d)
|
||||
{
|
||||
return exitJishuAndDoSomething(d, CANNA_FN_Henkan);
|
||||
}
|
||||
|
||||
static int JishuKanjiHenkanOInsert (uiContext);
|
||||
|
||||
static
|
||||
int JishuKanjiHenkanOInsert(uiContext d)
|
||||
{
|
||||
return exitJishuAndDoSomething(d, CANNA_FN_HenkanOrInsert);
|
||||
}
|
||||
|
||||
static int JishuKanjiHenkanONothing (uiContext);
|
||||
|
||||
static
|
||||
int JishuKanjiHenkanONothing(uiContext d)
|
||||
{
|
||||
return exitJishuAndDoSomething(d, CANNA_FN_HenkanOrNothing);
|
||||
}
|
||||
|
||||
#include "jishumap.h"
|
@ -1,70 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#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 int searchfunc(...);
|
||||
|
||||
KanjiModeRec jishu_mode = {
|
||||
searchfunc,
|
||||
default_kmap,
|
||||
CANNA_KANJIMODE_TABLE_SHARED,
|
||||
jishu_funcs,
|
||||
};
|
@ -1,381 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include "canna.h"
|
||||
#include <canna/mfdef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#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);
|
||||
|
||||
int 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;
|
||||
};
|
||||
|
||||
struct map *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
|
File diff suppressed because it is too large
Load Diff
@ -1,874 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include "canna.h"
|
||||
#include <canna/mfdef.h>
|
||||
#include <canna/keydef.h>
|
||||
|
||||
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 int specialen(unsigned char *block);
|
||||
static int 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() -- ¥¡¼¥Æ¡¼¥Ö¥ë¤ò½é´ü²½¤¹¤ë´Ø¿ô¡£
|
||||
|
||||
¥Ç¥Õ¥©¥ë¥È¤Î¥¡¼¥Æ¡¼¥Ö¥ë¤òµÏ¿¤·¤Æ¤ª¤¡¢¼Â»ÈÍѤΥơ¼¥Ö¥ë¤ò ¥Ç¥Õ¥©¥ë
|
||||
¥È¥Æ¡¼¥Ö¥ë¤«¤é¥³¥Ô¡¼¤¹¤ë½èÍý¤ò¹Ô¤¦¡£
|
||||
|
||||
*/
|
||||
|
||||
int 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;
|
||||
|
||||
int 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Á´¤Æ¤Î¥â¡¼¥É¤Î¡¢¤¢¤ë¥¡¼¤ËÂФ·¤Æ´Ø¿ô¤ò³ä¤êÅö¤Æ¤ë½èÍý
|
||||
*
|
||||
*/
|
||||
|
||||
int 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
|
||||
int 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
|
||||
int 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);
|
||||
}
|
||||
|
||||
int askQuitKey(unsigned key)
|
||||
{
|
||||
if (defaultmap[key] == CANNA_FN_Quit) {
|
||||
return 1; /* ¼õ¤±¼è¤Ã¤¿key¤Ïquit¤À¤Ã¤¿¡£ */
|
||||
}
|
||||
return 0; /* ¼õ¤±¼è¤Ã¤¿key¤Ïquit¤Ç¤Ê¤«¤Ã¤¿¡£ */
|
||||
}
|
@ -1,702 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#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 int makeKigoInfo(uiContext d, int headkouho);
|
||||
static int kigoIchiranExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int kigoIchiranQuitCatch(uiContext d, int retval, mode_context env);
|
||||
static int KigoNop(uiContext d);
|
||||
static int KigoForwardKouho(uiContext d);
|
||||
static int KigoBackwardKouho(uiContext d);
|
||||
static int KigoPreviousKouhoretsu(uiContext d);
|
||||
static int KigoNextKouhoretsu(uiContext d);
|
||||
static int KigoBeginningOfKouho(uiContext d);
|
||||
static int KigoEndOfKouho(uiContext d);
|
||||
static int KigoKakutei(uiContext d);
|
||||
static int KigoBangoKouho(uiContext d);
|
||||
static int 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
|
||||
int 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
|
||||
int 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++; i<NKCODECHARS; i++)
|
||||
*gptr++ = ' ';
|
||||
MBstowcs(gptr++, "\241\317", 1);
|
||||
/* ¡Ï */
|
||||
|
||||
for(cn=NKCODEALLCHARS, lnko=0;
|
||||
b1<BYTE1 && lnko<kc->nIkouho && (headkouho+lnko)<KIGOSU ; b1++) {
|
||||
for(; b2<BYTE2 && lnko<kc->nIkouho && (headkouho+lnko)<KIGOSU; b2++, lnko++) {
|
||||
|
||||
/* ¶èÀÚ¤ê¤Ë¤Ê¤ë¶õÇò¤ò¥³¥Ô¡¼¤¹¤ë */
|
||||
if(lnko != 0) {
|
||||
MBstowcs(gptr++, "\241\241", 1);
|
||||
/* ¡¡ */
|
||||
cn ++;
|
||||
}
|
||||
|
||||
kc->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
|
||||
int kigoIchiranExitCatch(uiContext d, int retval, mode_context env)
|
||||
/* ARGSUSED */
|
||||
{
|
||||
popCallback(d);
|
||||
retval = YomiExit(d, retval);
|
||||
currentModeInfo(d);
|
||||
|
||||
killmenu(d);
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
static
|
||||
int kigoIchiranQuitCatch(uiContext d, int retval, mode_context env)
|
||||
/* ARGSUSED */
|
||||
{
|
||||
popCallback(d);
|
||||
currentModeInfo(d);
|
||||
|
||||
return prevMenuIfExist(d);
|
||||
}
|
||||
#endif /* NO_EXTEND_MENU */
|
||||
|
||||
int 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
|
||||
*/
|
||||
int 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
|
||||
int KigoNop(uiContext d)
|
||||
{
|
||||
/* currentModeInfo ¤Ç¥â¡¼¥É¾ðÊó¤¬É¬¤ºÊÖ¤ë¤è¤¦¤Ë¥À¥ß¡¼¤Î¥â¡¼¥É¤òÆþ¤ì¤Æ¤ª¤¯ */
|
||||
d->majorMode = d->minorMode = CANNA_MODE_AlphaMode;
|
||||
currentModeInfo(d);
|
||||
|
||||
makeKigoGlineStatus(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* µ¹æ°ìÍ÷¹ÔÃæ¤Î¼¡¤Îµ¹æ¤Ë°ÜÆ°¤¹¤ë
|
||||
*
|
||||
* °ú¤¿ô uiContext
|
||||
* Ìá¤êÃÍ Àµ¾ï½ªÎ»»þ 0
|
||||
*/
|
||||
static
|
||||
int 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
|
||||
int 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
|
||||
int 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
|
||||
int 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
|
||||
int 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
|
||||
int 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
|
||||
int 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
|
||||
int 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"
|
@ -1,62 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#ifdef NO_EXTEND_MENU
|
||||
static struct funccfunc kigo_funcs[] = {{0, 0},};
|
||||
#else
|
||||
extern int DoFuncSequence();
|
||||
extern int 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 int searchfunc(...);
|
||||
|
||||
KanjiModeRec kigo_mode = {
|
||||
searchfunc,
|
||||
default_kmap,
|
||||
CANNA_KANJIMODE_TABLE_SHARED,
|
||||
kigo_funcs,
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,163 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $ */
|
||||
|
||||
#include "canna.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#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)(...);
|
||||
};
|
@ -1,400 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include "canna.h"
|
||||
#include <canna/mfdef.h>
|
||||
|
||||
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) -- ¥â¡¼¥É¤òÆüËܸìÆþÎϥ⡼¥É¤ËÊѤ¨¤ë¡£
|
||||
|
||||
¢¨Ãí ¤³¤Î´Ø¿ô¤Ï¦Á¥â¡¼¥É¤Ç¤·¤«¸Æ¤ó¤Ç¤Ï¤¤¤±¤Ê¤¤¡£
|
||||
|
||||
*/
|
||||
|
||||
int 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;
|
||||
}
|
||||
|
||||
int 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;
|
||||
}
|
||||
}
|
||||
|
||||
int 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;
|
||||
}
|
||||
|
||||
int 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* ¤¢¤ë¥â¡¼¥É¤ËÂФ·¤Æ¥â¡¼¥Éɽ¼¨Ê¸»úÎó¤ò·èÄꤹ¤ë¡£
|
||||
*
|
||||
*/
|
||||
|
||||
int 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;
|
||||
}
|
||||
|
@ -1,292 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include "canna.h"
|
||||
#include <canna/mfdef.h>
|
||||
|
||||
#define NONE CANNA_FN_Undefined
|
||||
|
||||
static unsigned char *showChar(int c);
|
||||
static int _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;
|
||||
}
|
||||
|
||||
int 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
|
||||
int _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;
|
||||
}
|
||||
|
||||
int 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); /* ÅÐÏ¿¤·¤Æ¤¤¤Ê¤¤¥¡¼¤ò²¡¤·¤¿ */
|
||||
}
|
@ -1,326 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include <errno.h>
|
||||
#include "canna.h"
|
||||
|
||||
#ifndef NO_EXTEND_MENU
|
||||
#define ICHISIZE 9
|
||||
|
||||
static void popOnOffMode(uiContext d);
|
||||
static int makeOnOffIchiran(uiContext d, int nelem, int bangomax, int currentkouho, unsigned char *status);
|
||||
static int OnOffSelect(uiContext d);
|
||||
static int 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);
|
||||
}
|
||||
|
||||
/*
|
||||
* ¸õÊä°ìÍ÷¹Ô¤òºî¤ë
|
||||
*/
|
||||
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 )(...))
|
||||
{
|
||||
extern KanjiModeRec onoff_mode;
|
||||
ichiranContext oc;
|
||||
int retval = 0;
|
||||
ichiranContext newIchiranContext();
|
||||
|
||||
if(pushCallback(d, d->modec,
|
||||
(int(*)(_uiContext*, int, _coreContextRec*))everyTimeCallback,
|
||||
(int(*)(_uiContext*, int, _coreContextRec*))exitCallback,
|
||||
(int(*)(_uiContext*, int, _coreContextRec*))quitCallback,
|
||||
(int(*)(_uiContext*, int, _coreContextRec*))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; ko<oc->nIkouho; line++) {
|
||||
oc->glineifp[line].gldata = gptr; /* ¸õÊä¹Ô¤òɽ¼¨¤¹¤ë¤¿¤á¤Îʸ»úÎó */
|
||||
oc->glineifp[line].glhead = ko; /* ¤³¤Î¹Ô¤ÎÀèƬ¸õÊä¤Ï¡¢Á´ÂΤǤÎkoÈÖÌÜ */
|
||||
|
||||
oc->tooSmall = 1;
|
||||
for(lnko = cn = dn = 0;
|
||||
dn<d->ncolumns - (cannaconf.kCount ? ICHISIZE + 1: 0) &&
|
||||
lnko<bangomax && ko<oc->nIkouho ; 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 && dn<d->ncolumns - (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
|
||||
int 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
|
||||
int 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"
|
@ -1,55 +0,0 @@
|
||||
/* 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 int searchfunc(...);
|
||||
KanjiModeRec onoff_mode = {
|
||||
searchfunc,
|
||||
default_kmap,
|
||||
CANNA_KANJIMODE_TABLE_SHARED,
|
||||
onoff_funcs,
|
||||
};
|
@ -1,168 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "canna.h"
|
||||
|
||||
extern char *CANNA_initfilename;
|
||||
|
||||
#define BUF_LEN 1024
|
||||
|
||||
static char CANNA_rcfilename[BUF_LEN] = "";
|
||||
|
||||
|
||||
/* cfuncdef
|
||||
|
||||
YYparse -- ¥«¥¹¥¿¥Þ¥¤¥º¥Õ¥¡¥¤¥ë¤òÆɤࡣ
|
||||
|
||||
¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤à¡£
|
||||
|
||||
*/
|
||||
|
||||
extern int ckverbose;
|
||||
|
||||
extern int 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 int DISPLAY_to_hostname(char *name, char *buf, int bufsize);
|
||||
|
||||
static
|
||||
int 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
|
File diff suppressed because it is too large
Load Diff
@ -1,43 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#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 int searchfunc(...);
|
||||
KanjiModeRec tourokureibun_mode = {
|
||||
searchfunc,
|
||||
default_kmap,
|
||||
CANNA_KANJIMODE_TABLE_SHARED,
|
||||
tourokureibun_funcs,
|
||||
};
|
@ -1,78 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#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 int searchfunc(...);
|
||||
KanjiModeRec tankouho_mode = {
|
||||
searchfunc,
|
||||
default_kmap,
|
||||
CANNA_KANJIMODE_TABLE_SHARED,
|
||||
tan_funcs,
|
||||
};
|
@ -1,577 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#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 int makeUiUtilEchoStr(uiContext d);
|
||||
static void pushmenu(uiContext d, menustruct *tab);
|
||||
static int uuflExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int 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
|
||||
int 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
|
||||
int 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); /* ¤³¤³¤Ë¤ÏÍè¤Ê¤¤¤Ï¤º */
|
||||
}
|
||||
|
||||
int 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
|
||||
int 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¥æ¡¼¥Æ¥£¥ê¥Æ¥£¥â¡¼¥É¤Ë¤Ê¤ë¤È¤¤Ë¸Æ¤Ð¤ì¤ë¡£
|
||||
|
||||
*/
|
||||
int 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 */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,384 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#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 int uuKigoExitDo(uiContext d, int retval);
|
||||
static int uuKigoRExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int uuKigoGExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int uuKigoKExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int uuKigoQuitCatch(uiContext d, int retval, mode_context env);
|
||||
static int 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
|
||||
int uuKigoExitDo(uiContext d, int retval)
|
||||
{
|
||||
popForIchiranMode(d);
|
||||
popCallback(d);
|
||||
retval = YomiExit(d, retval);
|
||||
currentModeInfo(d);
|
||||
|
||||
killmenu(d);
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
static
|
||||
int 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
|
||||
int 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
|
||||
int 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));
|
||||
}
|
||||
|
||||
int 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
|
||||
int uuKigoQuitCatch(uiContext d, int retval, mode_context env)
|
||||
/* ARGSUSED */
|
||||
{
|
||||
popCallback(d); /* °ìÍ÷¤ò pop */
|
||||
|
||||
popForIchiranMode(d);
|
||||
popCallback(d);
|
||||
currentModeInfo(d);
|
||||
|
||||
return prevMenuIfExist(d);
|
||||
}
|
||||
|
||||
int 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, (int (*)(_uiContext*, int, _coreContextRec*))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 */
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ¥í¥·¥¢Ê¸»ú¤ÎÆþÎÏ *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
int 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,
|
||||
(int(*)(...))uuKigoRExitCatch, (int *)0));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ¥®¥ê¥·¥ãʸ»ú¤ÎÆþÎÏ *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
int 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, (int(*)(...))uuKigoGExitCatch, (int *)0));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ·ÓÀþ¤ÎÆþÎÏ *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
int 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, (int(*)(...))uuKigoKExitCatch, (int *)0));
|
||||
#endif
|
||||
}
|
@ -1,580 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
|
||||
#ifndef NO_EXTEND_MENU
|
||||
#include <errno.h>
|
||||
#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 int uuMountExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int uuMountQuitCatch(uiContext d, int retval, mode_context env);
|
||||
static int 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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ¸õÊä°ìÍ÷¹Ô¤òºî¤ë
|
||||
*/
|
||||
int 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
|
||||
int uuMountExitCatch(uiContext d, int retval, mode_context env)
|
||||
/* ARGSUSED */
|
||||
{
|
||||
mountContext mc;
|
||||
int i, nmount = 0;
|
||||
extern int 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
|
||||
int 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
|
||||
int 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 int 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; i<dicLc; i++, sop++, snp++) {
|
||||
*sop = 0;
|
||||
*snp = 0;
|
||||
}
|
||||
for(Lp=dicLp, sop=soldp, snp=snewp; *Lp; Lp++, sop++, snp++) {
|
||||
for(Mp=dicMp; *Mp; Mp++) {
|
||||
if(!strcmp((char *)*Lp, (char *)*Mp)) {
|
||||
*sop = *snp = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
mc->mountList = dicLp;
|
||||
mc->mountOldStatus = soldp;
|
||||
mc->mountNewStatus = snewp;
|
||||
|
||||
return(dicLc);
|
||||
}
|
||||
|
||||
int 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,
|
||||
(int(*)(...))NO_CALLBACK, (int(*)(...))uuMountExitCatch,
|
||||
(int(*)(...))uuMountQuitCatch, (int(*)(...))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 */
|
@ -1,266 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
|
||||
#ifndef NO_EXTEND_MENU
|
||||
#include <errno.h>
|
||||
#include "canna.h"
|
||||
|
||||
#ifdef luna88k
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
static int uuServerChangeEveryTimeCatch(uiContext d, int retval, mode_context env);
|
||||
static int uuServerChangeExitCatch(uiContext d, int retval, mode_context env);
|
||||
static int uuServerChangeQuitCatch(uiContext d, int retval, mode_context env);
|
||||
static int serverChangeDo(uiContext d, int len);
|
||||
|
||||
static int serverChangeDo();
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* ¥µ¡¼¥Ð¤ÎÀÚ¤êÎ¥¤· *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
int 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 */
|
||||
|
||||
int serverChange(uiContext d)
|
||||
{
|
||||
int retval = 0;
|
||||
WCHAR_T *w;
|
||||
extern KanjiModeRec yomi_mode;
|
||||
extern int 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 */
|
File diff suppressed because it is too large
Load Diff
@ -1,167 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif /* lint */
|
||||
|
||||
#include <errno.h>
|
||||
#include "canna.h"
|
||||
|
||||
#ifdef luna88k
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
static coreContext newYesNoContext(void);
|
||||
static void freeYesNoContext(coreContext qc);
|
||||
static void popYesNoMode(uiContext d);
|
||||
static int YesNoNop(uiContext d);
|
||||
static int YesNo(uiContext d);
|
||||
static int 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);
|
||||
}
|
||||
|
||||
/*
|
||||
* ¸õÊä°ìÍ÷¹Ô¤òºî¤ë
|
||||
*/
|
||||
int 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
|
||||
int 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
|
||||
int YesNoQuit(uiContext d)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
popYesNoMode(d);
|
||||
d->status = QUIT_CALLBACK;
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
#include "t_reimap.h"
|
@ -1,89 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#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,
|
||||
};
|
||||
|
@ -1,32 +0,0 @@
|
||||
SubDir HAIKU_TOP src add-ons input_server methods canna rk ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
# filter warnings we don't want here
|
||||
TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)
|
||||
= [ FFilter $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH))
|
||||
: -Wmissing-prototypes ] ;
|
||||
|
||||
SubDirCcFlags -x c++ -ansi -trigraphs -funsigned-char -funsigned-bitfields -w -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 ] ;
|
||||
SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ;
|
||||
|
||||
StaticLibrary librk.a :
|
||||
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
|
||||
;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,65 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $ */
|
||||
|
||||
#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
|
@ -1,428 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $ $Author: korli $ $Revision: 1.1 $ $Data$";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#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);
|
||||
}
|
@ -1,324 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#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 <stdio.h>
|
||||
_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
|
File diff suppressed because it is too large
Load Diff
@ -1,949 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#endif
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include "RKintern.h"
|
||||
#include "patchlevel.h"
|
||||
#include <canna/jrkanji.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <StorageDefs.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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 <sys/types.h> /* mmap */
|
||||
#include <sys/mman.h> /* mmap */
|
||||
#include <fcntl.h> /* 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 */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,33 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#endif
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include "RKintern.h"
|
||||
|
||||
struct RkDST _RkDST[] = {
|
||||
/* PERMDIC */ { _Rkpopen, _Rkpclose, _Rkpsearch, _Rkpio, _Rkpctl, _Rkpsync, },
|
||||
/* TEMPDIC */ { _Rktopen, _Rktclose, _Rktsearch, _Rktio, _Rktctl, _Rktsync, },
|
||||
};
|
@ -1,843 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
#endif
|
||||
|
||||
#include "RKintern.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef WIN
|
||||
#include <fcntl.h>
|
||||
#include <sys\types.h>
|
||||
#include <sys\stat.h>
|
||||
#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);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,326 +0,0 @@
|
||||
/* 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 10525 2004-12-23 21:23:50Z korli $";
|
||||
*/
|
||||
#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;
|
||||
};
|
||||
}
|
@ -1,978 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <bsd_mem.h>
|
||||
|
||||
|
||||
#include "RKintern.h"
|
||||
// There is Exported Symbols !!
|
||||
static char **gram_to_tab(struct RkKxGram *gram);
|
||||
static WCHAR_T *skip_space(WCHAR_T *src);
|
||||
static int 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,828 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "RKintern.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
#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 <sys/types.h> /* mmap */
|
||||
#include <sys/mman.h> /* mmap */
|
||||
#include <fcntl.h> /* mmap */
|
||||
extern int fd_dic; /* mmap */
|
||||
#endif
|
||||
|
||||
static unsigned char *assurep(struct ND *dic, int id);
|
||||
static int 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
|
||||
int 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;j<dic->ttlpg;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);
|
||||
}
|
@ -1,787 +0,0 @@
|
||||
/* 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 14875 2005-11-12 21:25:31Z bonefish $";
|
||||
#endif
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include "RKintern.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <bsd_mem.h>
|
||||
|
||||
#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 int 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 int 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
|
||||
int 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
|
||||
int 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user