フォーラム


ゲスト  

ようこそ ゲスト さん。このフォーラムに投稿するには 登録が必要です。

ページ: [1]
トピック: SynEdit(Kylix port)のMBCS対応
DEKO
管理者
投稿数: 2691
SynEdit(Kylix port)のMBCS対応
on: 2013/04/06 08:44 Sat

以下に変更箇所を示す(ソースは2.0.3)。

[SynEdit.pas]

uses
...
{$IFDEF SYN_MBCSSUPPORT}
// MOD DEKO
{$IFDEF MSWINDOWS}
Imm,
{$ENDIF}
{$IFDEF LINUX} // ADD DEKO
ImmDmy, // ADD DEKO
{$ENDIF} // ADD DEKO
{$ENDIF}
  TCustomSynEdit = class(TCustomControl)
private
...
{$IFDEF SYN_MBCSSUPPORT}
{$IFDEF MSWINDOWS} // ADD DEKO
procedure WMImeComposition(var Msg: TMessage); message WM_IME_COMPOSITION;
procedure WMImeNotify(var Msg: TMessage); message WM_IME_NOTIFY;
{$ENDIF}
{$ENDIF}
procedure TCustomSynEdit.UpdateCaret;
var
CX, CY: Integer;
{$IFDEF SYN_MBCSSUPPORT}
{$IFDEF MSWINDOWS} // ADD DEKO
cf: TCompositionForm;
{$ENDIF} // ADD DEKO
{$ENDIF}
...
{$IFDEF SYN_MBCSSUPPORT}
{$IFDEF MSWINDOWS} // ADD DEKO
cf.dwStyle := CFS_POINT;
cf.ptCurrentPos := Point(CX, CY);
ImmSetCompositionWindow(ImmGetContext(Handle), @cf);
{$ENDIF} // ADD DEKO
{$ENDIF}
procedure TCustomSynEdit.KeyDown(var Key: Word; Shift: TShiftState);
...
{$IFDEF SYN_LINUX}
// uniform Keycode: key has the same value wether Shift is pressed or not
//if Key <= 255 then // MOD DEKO
if Char(Key) in ['a'..'z'] then // MOD DEKO
begin
Code := XKeysymToKeycode(Xlib.PDisplay(QtDisplay), Key);
Key := XKeycodeToKeysym(Xlib.PDisplay(QtDisplay), Code, 0);
if Char(Key) in ['a'..'z'] then Key := Ord(UpCase(Char(Key)));
end;
{$ENDIF}
...
{$IFDEF SYN_MBCSSUPPORT}
{$IFDEF MSWINDOWS} // ADD DEKO
procedure TCustomSynEdit.WMImeComposition(var Msg: TMessage);
...
procedure TCustomSynEdit.WMImeNotify(var Msg: TMessage);
...
{$ENDIF} // ADD DEKO
{$ENDIF}

 
[SynEdit.Inc]

{------------------------------------------------------------------------------}
{ Please change this to suit your needs }
{------------------------------------------------------------------------------}
...
//{$IFNDEF SYN_CLX} // DEL DEKO
{$DEFINE SYN_MBCSSUPPORT}
//{$ENDIF} // DEL DEKO

 
[SynEditMiscProcs.pas]

uses
{$IFDEF SYN_CLX}
...
ImmDmy, // ADD DEKO
{$ELSE}

 
要は imm.pas に依存する部分を削除しているだけだ。そして、MBCS キャレットのキモである GetStringTypeEx() をどうにかするために、ImmDmy.pas を新規に追加する。
 
[ImmDmy.pas]

unit ImmDmy;

interface

uses
Classes, SysUtils;

const
{ CType 3 Flag Bits. }

{$EXTERNALSYM C3_NONSPACING}
C3_NONSPACING = 1; { nonspacing character }
{$EXTERNALSYM C3_DIACRITIC}
C3_DIACRITIC = 2; { diacritic mark }
{$EXTERNALSYM C3_VOWELMARK}
C3_VOWELMARK = 4; { vowel mark }
{$EXTERNALSYM C3_SYMBOL}
C3_SYMBOL = 8; { symbols }
{$EXTERNALSYM C3_KATAKANA}
C3_KATAKANA = $0010; { katakana character }
{$EXTERNALSYM C3_HIRAGANA}
C3_HIRAGANA = $0020; { hiragana character }
{$EXTERNALSYM C3_HALFWIDTH}
C3_HALFWIDTH = $0040; { half width character }
{$EXTERNALSYM C3_FULLWIDTH}
C3_FULLWIDTH = $0080; { full width character }
{$EXTERNALSYM C3_IDEOGRAPH}
C3_IDEOGRAPH = $0100; { ideographic character }
{$EXTERNALSYM C3_KASHIDA}
C3_KASHIDA = $0200; { Arabic kashida character }
{$EXTERNALSYM C3_LEXICAL}
C3_LEXICAL = $0400; { lexical character }
{$EXTERNALSYM C3_ALPHA}
C3_ALPHA = $8000; { any linguistic char (C1_ALPHA) }
{$EXTERNALSYM C3_NOTAPPLICABLE}
C3_NOTAPPLICABLE = 0; { ctype 3 is not applicable }

{ Primary language IDs. }

LANG_NEUTRAL = $00;
{$EXTERNALSYM LANG_NEUTRAL}

LANG_AFRIKAANS = $36;
{$EXTERNALSYM LANG_AFRIKAANS}
LANG_ALBANIAN = $1c;
{$EXTERNALSYM LANG_ALBANIAN}
LANG_ARABIC = $01;
{$EXTERNALSYM LANG_ARABIC}
LANG_BASQUE = $2d;
{$EXTERNALSYM LANG_BASQUE}
LANG_BELARUSIAN = $23;
{$EXTERNALSYM LANG_BELARUSIAN}
LANG_BULGARIAN = $02;
{$EXTERNALSYM LANG_BULGARIAN}
LANG_CATALAN = $03;
{$EXTERNALSYM LANG_CATALAN}
LANG_CHINESE = $04;
{$EXTERNALSYM LANG_CHINESE}
LANG_CROATIAN = $1a;
{$EXTERNALSYM LANG_CROATIAN}
LANG_CZECH = $05;
{$EXTERNALSYM LANG_CZECH}
LANG_DANISH = $06;
{$EXTERNALSYM LANG_DANISH}
LANG_DUTCH = $13;
{$EXTERNALSYM LANG_DUTCH}
LANG_ENGLISH = $09;
{$EXTERNALSYM LANG_ENGLISH}
LANG_ESTONIAN = $25;
{$EXTERNALSYM LANG_ESTONIAN}
LANG_FAEROESE = $38;
{$EXTERNALSYM LANG_FAEROESE}
LANG_FARSI = $29;
{$EXTERNALSYM LANG_FARSI}
LANG_FINNISH = $0b;
{$EXTERNALSYM LANG_FINNISH}
LANG_FRENCH = $0c;
{$EXTERNALSYM LANG_FRENCH}
LANG_GERMAN = $07;
{$EXTERNALSYM LANG_GERMAN}
LANG_GREEK = $08;
{$EXTERNALSYM LANG_GREEK}
LANG_HEBREW = $0d;
{$EXTERNALSYM LANG_HEBREW}
LANG_HUNGARIAN = $0e;
{$EXTERNALSYM LANG_HUNGARIAN}
LANG_ICELANDIC = $0f;
{$EXTERNALSYM LANG_ICELANDIC}
LANG_INDONESIAN = $21;
{$EXTERNALSYM LANG_INDONESIAN}
LANG_ITALIAN = $10;
{$EXTERNALSYM LANG_ITALIAN}
LANG_JAPANESE = $11;
{$EXTERNALSYM LANG_JAPANESE}
LANG_KOREAN = $12;
{$EXTERNALSYM LANG_KOREAN}
LANG_LATVIAN = $26;
{$EXTERNALSYM LANG_LATVIAN}
LANG_LITHUANIAN = $27;
{$EXTERNALSYM LANG_LITHUANIAN}
LANG_NORWEGIAN = $14;
{$EXTERNALSYM LANG_NORWEGIAN}
LANG_POLISH = $15;
{$EXTERNALSYM LANG_POLISH}
LANG_PORTUGUESE = $16;
{$EXTERNALSYM LANG_PORTUGUESE}
LANG_ROMANIAN = $18;
{$EXTERNALSYM LANG_ROMANIAN}
LANG_RUSSIAN = $19;
{$EXTERNALSYM LANG_RUSSIAN}
LANG_SERBIAN = $1a;
{$EXTERNALSYM LANG_SERBIAN}
LANG_SLOVAK = $1b;
{$EXTERNALSYM LANG_SLOVAK}
LANG_SLOVENIAN = $24;
{$EXTERNALSYM LANG_SLOVENIAN}
LANG_SPANISH = $0a;
{$EXTERNALSYM LANG_SPANISH}
LANG_SWEDISH = $1d;
{$EXTERNALSYM LANG_SWEDISH}
LANG_THAI = $1e;
{$EXTERNALSYM LANG_THAI}
LANG_TURKISH = $1f;
{$EXTERNALSYM LANG_TURKISH}
LANG_UKRAINIAN = $22;
{$EXTERNALSYM LANG_UKRAINIAN}
LANG_VIETNAMESE = $2a;
{$EXTERNALSYM LANG_VIETNAMESE}


{ Sublanguage IDs. }

{ The name immediately following SUBLANG_ dictates which primary
language ID that sublanguage ID can be combined with to form a
valid language ID. }

SUBLANG_NEUTRAL = $00; { language neutral }
{$EXTERNALSYM SUBLANG_NEUTRAL}
SUBLANG_DEFAULT = $01; { user default }
{$EXTERNALSYM SUBLANG_DEFAULT}
SUBLANG_SYS_DEFAULT = $02; { system default }
{$EXTERNALSYM SUBLANG_SYS_DEFAULT}

SUBLANG_ARABIC_SAUDI_ARABIA = $01; { Arabic (Saudi Arabia) }
{$EXTERNALSYM SUBLANG_ARABIC_SAUDI_ARABIA}
SUBLANG_ARABIC_IRAQ = $02; { Arabic (Iraq) }
{$EXTERNALSYM SUBLANG_ARABIC_IRAQ}
SUBLANG_ARABIC_EGYPT = $03; { Arabic (Egypt) }
{$EXTERNALSYM SUBLANG_ARABIC_EGYPT}
SUBLANG_ARABIC_LIBYA = $04; { Arabic (Libya) }
{$EXTERNALSYM SUBLANG_ARABIC_LIBYA}
SUBLANG_ARABIC_ALGERIA = $05; { Arabic (Algeria) }
{$EXTERNALSYM SUBLANG_ARABIC_ALGERIA}
SUBLANG_ARABIC_MOROCCO = $06; { Arabic (Morocco) }
{$EXTERNALSYM SUBLANG_ARABIC_MOROCCO}
SUBLANG_ARABIC_TUNISIA = $07; { Arabic (Tunisia) }
{$EXTERNALSYM SUBLANG_ARABIC_TUNISIA}
SUBLANG_ARABIC_OMAN = $08; { Arabic (Oman) }
{$EXTERNALSYM SUBLANG_ARABIC_OMAN}
SUBLANG_ARABIC_YEMEN = $09; { Arabic (Yemen) }
{$EXTERNALSYM SUBLANG_ARABIC_YEMEN}
SUBLANG_ARABIC_SYRIA = $0a; { Arabic (Syria) }
{$EXTERNALSYM SUBLANG_ARABIC_SYRIA}
SUBLANG_ARABIC_JORDAN = $0b; { Arabic (Jordan) }
{$EXTERNALSYM SUBLANG_ARABIC_JORDAN}
SUBLANG_ARABIC_LEBANON = $0c; { Arabic (Lebanon) }
{$EXTERNALSYM SUBLANG_ARABIC_LEBANON}
SUBLANG_ARABIC_KUWAIT = $0d; { Arabic (Kuwait) }
{$EXTERNALSYM SUBLANG_ARABIC_KUWAIT}
SUBLANG_ARABIC_UAE = $0e; { Arabic (U.A.E) }
{$EXTERNALSYM SUBLANG_ARABIC_UAE}
SUBLANG_ARABIC_BAHRAIN = $0f; { Arabic (Bahrain) }
{$EXTERNALSYM SUBLANG_ARABIC_BAHRAIN}
SUBLANG_ARABIC_QATAR = $10; { Arabic (Qatar) }
{$EXTERNALSYM SUBLANG_ARABIC_QATAR}
SUBLANG_CHINESE_TRADITIONAL = $01; { Chinese (Taiwan) }
{$EXTERNALSYM SUBLANG_CHINESE_TRADITIONAL}
SUBLANG_CHINESE_SIMPLIFIED = $02; { Chinese (PR China) }
{$EXTERNALSYM SUBLANG_CHINESE_SIMPLIFIED}
SUBLANG_CHINESE_HONGKONG = $03; { Chinese (Hong Kong) }
{$EXTERNALSYM SUBLANG_CHINESE_HONGKONG}
SUBLANG_CHINESE_SINGAPORE = $04; { Chinese (Singapore) }
{$EXTERNALSYM SUBLANG_CHINESE_SINGAPORE}
SUBLANG_DUTCH = $01; { Dutch }
{$EXTERNALSYM SUBLANG_DUTCH}
SUBLANG_DUTCH_BELGIAN = $02; { Dutch (Belgian) }
{$EXTERNALSYM SUBLANG_DUTCH_BELGIAN}
SUBLANG_ENGLISH_US = $01; { English (USA) }
{$EXTERNALSYM SUBLANG_ENGLISH_US}
SUBLANG_ENGLISH_UK = $02; { English (UK) }
{$EXTERNALSYM SUBLANG_ENGLISH_UK}
SUBLANG_ENGLISH_AUS = $03; { English (Australian) }
{$EXTERNALSYM SUBLANG_ENGLISH_AUS}
SUBLANG_ENGLISH_CAN = $04; { English (Canadian) }
{$EXTERNALSYM SUBLANG_ENGLISH_CAN}
SUBLANG_ENGLISH_NZ = $05; { English (New Zealand) }
{$EXTERNALSYM SUBLANG_ENGLISH_NZ}
SUBLANG_ENGLISH_EIRE = $06; { English (Irish) }
{$EXTERNALSYM SUBLANG_ENGLISH_EIRE}
SUBLANG_ENGLISH_SOUTH_AFRICA = $07; { English (South Africa) }
{$EXTERNALSYM SUBLANG_ENGLISH_SOUTH_AFRICA}
SUBLANG_ENGLISH_JAMAICA = $08; { English (Jamaica) }
{$EXTERNALSYM SUBLANG_ENGLISH_JAMAICA}
SUBLANG_ENGLISH_CARIBBEAN = $09; { English (Caribbean) }
{$EXTERNALSYM SUBLANG_ENGLISH_CARIBBEAN}
SUBLANG_ENGLISH_BELIZE = $0a; { English (Belize) }
{$EXTERNALSYM SUBLANG_ENGLISH_BELIZE}
SUBLANG_ENGLISH_TRINIDAD = $0b; { English (Trinidad) }
{$EXTERNALSYM SUBLANG_ENGLISH_TRINIDAD}
SUBLANG_FRENCH = $01; { French }
{$EXTERNALSYM SUBLANG_FRENCH}
SUBLANG_FRENCH_BELGIAN = $02; { French (Belgian) }
{$EXTERNALSYM SUBLANG_FRENCH_BELGIAN}
SUBLANG_FRENCH_CANADIAN = $03; { French (Canadian) }
{$EXTERNALSYM SUBLANG_FRENCH_CANADIAN}
SUBLANG_FRENCH_SWISS = $04; { French (Swiss) }
{$EXTERNALSYM SUBLANG_FRENCH_SWISS}
SUBLANG_FRENCH_LUXEMBOURG = $05; { French (Luxembourg) }
{$EXTERNALSYM SUBLANG_FRENCH_LUXEMBOURG}
SUBLANG_GERMAN = $01; { German }
{$EXTERNALSYM SUBLANG_GERMAN}
SUBLANG_GERMAN_SWISS = $02; { German (Swiss) }
{$EXTERNALSYM SUBLANG_GERMAN_SWISS}
SUBLANG_GERMAN_AUSTRIAN = $03; { German (Austrian) }
{$EXTERNALSYM SUBLANG_GERMAN_AUSTRIAN}
SUBLANG_GERMAN_LUXEMBOURG = $04; { German (Luxembourg) }
{$EXTERNALSYM SUBLANG_GERMAN_LUXEMBOURG}
SUBLANG_GERMAN_LIECHTENSTEIN = $05; { German (Liechtenstein) }
{$EXTERNALSYM SUBLANG_GERMAN_LIECHTENSTEIN}
SUBLANG_ITALIAN = $01; { Italian }
{$EXTERNALSYM SUBLANG_ITALIAN}
SUBLANG_ITALIAN_SWISS = $02; { Italian (Swiss) }
{$EXTERNALSYM SUBLANG_ITALIAN_SWISS}
SUBLANG_KOREAN = $01; { Korean (Extended Wansung) }
{$EXTERNALSYM SUBLANG_KOREAN}
SUBLANG_KOREAN_JOHAB = $02; { Korean (Johab) }
{$EXTERNALSYM SUBLANG_KOREAN_JOHAB}
SUBLANG_NORWEGIAN_BOKMAL = $01; { Norwegian (Bokmal) }
{$EXTERNALSYM SUBLANG_NORWEGIAN_BOKMAL}
SUBLANG_NORWEGIAN_NYNORSK = $02; { Norwegian (Nynorsk) }
{$EXTERNALSYM SUBLANG_NORWEGIAN_NYNORSK}
SUBLANG_PORTUGUESE = $02; { Portuguese }
{$EXTERNALSYM SUBLANG_PORTUGUESE}
SUBLANG_PORTUGUESE_BRAZILIAN = $01; { Portuguese (Brazilian) }
{$EXTERNALSYM SUBLANG_PORTUGUESE_BRAZILIAN}
SUBLANG_SERBIAN_LATIN = $02; { Serbian (Latin) }
{$EXTERNALSYM SUBLANG_SERBIAN_LATIN}
SUBLANG_SERBIAN_CYRILLIC = $03; { Serbian (Cyrillic) }
{$EXTERNALSYM SUBLANG_SERBIAN_CYRILLIC}
SUBLANG_SPANISH = $01; { Spanish (Castilian) }
{$EXTERNALSYM SUBLANG_SPANISH}
SUBLANG_SPANISH_MEXICAN = $02; { Spanish (Mexican) }
{$EXTERNALSYM SUBLANG_SPANISH_MEXICAN}
SUBLANG_SPANISH_MODERN = $03; { Spanish (Modern) }
{$EXTERNALSYM SUBLANG_SPANISH_MODERN}
SUBLANG_SPANISH_GUATEMALA = $04; { Spanish (Guatemala) }
{$EXTERNALSYM SUBLANG_SPANISH_GUATEMALA}
SUBLANG_SPANISH_COSTA_RICA = $05; { Spanish (Costa Rica) }
{$EXTERNALSYM SUBLANG_SPANISH_COSTA_RICA}
SUBLANG_SPANISH_PANAMA = $06; { Spanish (Panama) }
{$EXTERNALSYM SUBLANG_SPANISH_PANAMA}
SUBLANG_SPANISH_DOMINICAN_REPUBLIC = $07; { Spanish (Dominican Republic) }
{$EXTERNALSYM SUBLANG_SPANISH_DOMINICAN_REPUBLIC}
SUBLANG_SPANISH_VENEZUELA = $08; { Spanish (Venezuela) }
{$EXTERNALSYM SUBLANG_SPANISH_VENEZUELA}
SUBLANG_SPANISH_COLOMBIA = $09; { Spanish (Colombia) }
{$EXTERNALSYM SUBLANG_SPANISH_COLOMBIA}
SUBLANG_SPANISH_PERU = $0a; { Spanish (Peru) }
{$EXTERNALSYM SUBLANG_SPANISH_PERU}
SUBLANG_SPANISH_ARGENTINA = $0b; { Spanish (Argentina) }
{$EXTERNALSYM SUBLANG_SPANISH_ARGENTINA}
SUBLANG_SPANISH_ECUADOR = $0c; { Spanish (Ecuador) }
{$EXTERNALSYM SUBLANG_SPANISH_ECUADOR}
SUBLANG_SPANISH_CHILE = $0d; { Spanish (Chile) }
{$EXTERNALSYM SUBLANG_SPANISH_CHILE}
SUBLANG_SPANISH_URUGUAY = $0e; { Spanish (Uruguay) }
{$EXTERNALSYM SUBLANG_SPANISH_URUGUAY}
SUBLANG_SPANISH_PARAGUAY = $0f; { Spanish (Paraguay) }
{$EXTERNALSYM SUBLANG_SPANISH_PARAGUAY}
SUBLANG_SPANISH_BOLIVIA = $10; { Spanish (Bolivia) }
{$EXTERNALSYM SUBLANG_SPANISH_BOLIVIA}
SUBLANG_SPANISH_EL_SALVADOR = $11; { Spanish (El Salvador) }
{$EXTERNALSYM SUBLANG_SPANISH_EL_SALVADOR}
SUBLANG_SPANISH_HONDURAS = $12; { Spanish (Honduras) }
{$EXTERNALSYM SUBLANG_SPANISH_HONDURAS}
SUBLANG_SPANISH_NICARAGUA = $13; { Spanish (Nicaragua) }
{$EXTERNALSYM SUBLANG_SPANISH_NICARAGUA}
SUBLANG_SPANISH_PUERTO_RICO = $14; { Spanish (Puerto Rico) }
{$EXTERNALSYM SUBLANG_SPANISH_PUERTO_RICO}
SUBLANG_SWEDISH = $01; { Swedish }
{$EXTERNALSYM SUBLANG_SWEDISH}
SUBLANG_SWEDISH_FINLAND = $02; { Swedish (Finland) }
{$EXTERNALSYM SUBLANG_SWEDISH_FINLAND}

{ Sorting IDs. }

SORT_DEFAULT = $0; { sorting default }
{$EXTERNALSYM SORT_DEFAULT}

SORT_JAPANESE_XJIS = $0; { Japanese XJIS order }
{$EXTERNALSYM SORT_JAPANESE_XJIS}
SORT_JAPANESE_UNICODE = $1; { Japanese Unicode order }
{$EXTERNALSYM SORT_JAPANESE_UNICODE}

SORT_CHINESE_BIG5 = $0; { Chinese BIG5 order }
{$EXTERNALSYM SORT_CHINESE_BIG5}
SORT_CHINESE_PRCP = $0; { PRC Chinese Phonetic order }
{$EXTERNALSYM SORT_CHINESE_PRCP}
SORT_CHINESE_UNICODE = $1; { Chinese Unicode order }
{$EXTERNALSYM SORT_CHINESE_UNICODE}
SORT_CHINESE_PRC = $2; { PRC Chinese Stroke Count order }
{$EXTERNALSYM SORT_CHINESE_PRC}

SORT_KOREAN_KSC = $0; { Korean KSC order }
{$EXTERNALSYM SORT_KOREAN_KSC}
SORT_KOREAN_UNICODE = $1; { Korean Unicode order }
{$EXTERNALSYM SORT_KOREAN_UNICODE}

SORT_GERMAN_PHONE_BOOK = $1; { German Phone Book order }
{$EXTERNALSYM SORT_GERMAN_PHONE_BOOK}

{ Default System and User IDs for language and locale. }

LANG_SYSTEM_DEFAULT = (SUBLANG_SYS_DEFAULT shl 10) or LANG_NEUTRAL;
{$EXTERNALSYM LANG_SYSTEM_DEFAULT}
LANG_USER_DEFAULT = (SUBLANG_DEFAULT shl 10) or LANG_NEUTRAL;
{$EXTERNALSYM LANG_USER_DEFAULT}

LOCALE_SYSTEM_DEFAULT = (SORT_DEFAULT shl 16) or LANG_SYSTEM_DEFAULT;
{$EXTERNALSYM LOCALE_SYSTEM_DEFAULT}
LOCALE_USER_DEFAULT = (SORT_DEFAULT shl 16) or LANG_USER_DEFAULT;
{$EXTERNALSYM LOCALE_USER_DEFAULT}

{ Character Type Flags. }

{$EXTERNALSYM CT_CTYPE1}
CT_CTYPE1 = 1; { ctype 1 information }
{$EXTERNALSYM CT_CTYPE2}
CT_CTYPE2 = 2; { ctype 2 information }
{$EXTERNALSYM CT_CTYPE3}
CT_CTYPE3 = 4; { ctype 3 information }

LeadBytes = [#$A1..#$FE]; // EUC-JP

function GetStringTypeEx(Locale: Cardinal; dwInfoType: Cardinal; lpSrcStr: PAnsiChar;
cchSrc: Integer; var pCharType: array of word): LongBool;

implementation

function GetStringTypeEx(Locale: Cardinal; dwInfoType: Cardinal; lpSrcStr: PAnsiChar;
cchSrc: Integer; var pCharType: array of word): LongBool;
// http://msdn.microsoft.com/library/ja/default.asp?url=/library/ja/jpwinui/html/_win32_getstringtypeex.asp
var
i:Integer;
s:String;
w:WideString;
begin
// ロケール(Locale)を元に
// テキスト処理情報を取得(CT_CTYPE3)する。 -> 完全無視(^^;
// Ansi文字列(lpSrcStr)を
// Unicodeの配列(pCharType)へ格納。
w := StrPas(lpSrcStr);
for i:=0 to Length(w)-1 do
pCharType[i] := Word(w[i+1]);
result := True;
end;

end.

EUC 完全依存だが GetStringTypeEx() が呼び出される事はまずない (では何故実装したかと言うと、主にエラー回避^^;)し、最悪ここだけどうにかすればいい訳で…。

日本語のみを対象、しかも IBConsole専用ならこの実装で充分だろう。テキスト中に2バイト文字が含まれていても文字単位で削除、移動が可能だ。選択時のキャレットが若干おかしい事があるが、 これは SynEdit が文字幅の取得を間違っているのだろう…あまり気にならないとは思うが。

ページ: [1]
WP Forum Server by ForumPress | LucidCrew
バージョン: 1.7.5 ; ページロード: 0.026 sec.