Menu

#19 SynEdit 2.0.3 MBCS support

open
None
5
2015-02-16
2006-07-20
Do-wan Kim
No

SynEdit 2.0.3 MBCS diff

and unisyn support.

see attached diff file.

======================================================
Index: SynEdit.pas
======================================================
=============
RCS
file: /cvsroot/synedit/SynEdit/Source/SynEdit.pas,v
retrieving revision 1.438
diff -u -r1.438 SynEdit.pas
--- SynEdit.pas 25 Jan 2006 13:16:23 -0000 1.438
+++ SynEdit.pas 20 Jul 2006 03:58:20 -0000
@@ -342,6 +342,10 @@
{$IFDEF SYN_MBCSSUPPORT}
procedure WMImeComposition(var Msg: TMessage);
message WM_IME_COMPOSITION;
procedure WMImeNotify(var Msg: TMessage);
message WM_IME_NOTIFY;
+ // DW
+ procedure WMImeSetContext(var Msg: TMessage);
message WM_IME_SETCONTEXT;
+ procedure WMImeEndComposition(var Msg:
TMessage); message WM_IME_ENDCOMPOSITION;
+ procedure SetCustomCompo(Value : boolean);
{$ENDIF}
procedure WMKillFocus(var Msg: TWMKillFocus);
message WM_KILLFOCUS;
procedure WMMouseWheel(var Msg: TMessage);
message WM_MOUSEWHEEL;
@@ -364,6 +368,9 @@
{$IFDEF SYN_MBCSSUPPORT}
fImeCount: Integer;
fMBCSStepAside: Boolean;
+ fPbuffer : pchar;
+ fCustomComposition : Boolean;
+ fOldContext : Cardinal;
{$ENDIF}
fInserting: Boolean;
fLines: TStrings;
@@ -858,6 +865,9 @@
property UndoList: TSynEditUndoList read
fUndoList;
property RedoList: TSynEditUndoList read
fRedoList;
public
+// DW - for Unisyn Bug fix
+ UseUniSyn : boolean;
+
property OnProcessCommand: TProcessCommandEvent
read FOnProcessCommand write FOnProcessCommand;

@@ -933,11 +943,20 @@
read fOnPaintTransient write fOnPaintTransient;
property OnScroll: TScrollEvent
read fOnScroll write fOnScroll;
+// For Custom Composition User setting flag, Do-wan
Kim
+{$IFDEF SYN_MBCSSUPPORT}
+ property CustomComposition : boolean read
FCustomComposition write SetCustomCompo;
+{$ENDIF}
published
property Cursor default crIBeam;
end;

TSynEdit = class(TCustomSynEdit)
+// For Custom Composition User setting flag, Do-wan
Kim
+{$IFDEF SYN_MBCSSUPPORT}
+ public
+ property CustomComposition;
+{$ENDIF}
published
// inherited properties
property Align;
@@ -1298,6 +1317,8 @@
constructor TCustomSynEdit.Create(AOwner:
TComponent);
begin
inherited Create(AOwner);
+ // DW
+ UseUniSyn := false;
fLines := TSynEditStringList.Create;
fOrigLines := fLines;
with TSynEditStringList(fLines) do
@@ -1389,6 +1410,8 @@
{$IFDEF SYN_MBCSSUPPORT}
fImeCount := 0;
fMBCSStepAside := False;
+ Getmem(fPBuffer,100);
+ fCustomComposition := True;
{$ENDIF}
fWantReturns := True;
fWantTabs := False;
@@ -1507,7 +1530,10 @@
RemoveLinesPointer;

inherited Destroy;
-
+// DW
+{$IFDEF SYN_MBCSSUPPORT}
+ FreeMem(fPbuffer,100);
+{$ENDIF}
// free listeners while other fields are still
valid
if Assigned(fHookedCommandHandlers) then
begin
@@ -1797,24 +1823,91 @@
end;

{$IFDEF SYN_MBCSSUPPORT}
+// added for Setup Composition mode
+procedure TCustomSynEdit.SetCustomCompo(Value :
boolean);
+begin
+ FCustomComposition := Value;
+ SendMessage
(handle,WM_IME_SETCONTEXT,1,FOldContext);
+end;
+
+// added for Delete Composition gabage at
WM_IME_ENDCOMPOSITION
+// by Do-wan Kim
+procedure TCustomSynEdit.WMImeEndComposition(var
Msg: TMessage);
+begin
+ if not ReadOnly then
+ if FCustomComposition then begin
+ fpBuffer[0] := #0;
+ CommandProcessor(ecImeStr, #0, fpBuffer);
+ end;
+ inherited;
+end;
+// added for Don't Show Composition window
+// by Do-wan Kim
+procedure TCustomSynEdit.WMImeSetContext(var Msg:
TMessage);
+begin
+ if FCustomComposition then
+ Msg.LParam := Msg.LParam and (not
ISC_SHOWUICOMPOSITIONWINDOW)
+ else
+ Msg.LParam := Msg.LParam or longint
(ISC_SHOWUICOMPOSITIONWINDOW);
+ FOldContext := Msg.LParam;
+ inherited;
+end;
+
+// modified for own draw , Do-wan Kim
+// by Do-wan Kim
procedure TCustomSynEdit.WMImeComposition(var Msg:
TMessage);
var
imc: HIMC;
- p: PChar;
+ //p: PChar;
+ //oldFont : TFont;
+ px : TPoint;
+ bl : TColor;
+ pl : tagCompositionForm;
begin
- if ((Msg.LParam and GCS_RESULTSTR) <> 0) then
- begin
+ if ((Msg.LParam and (GCS_RESULTSTR or
GCS_COMPSTR)) <> 0) then begin
+
imc := ImmGetContext(Handle);
try
+ if (msg.LParam and GCS_RESULTSTR)<>0 then begin
fImeCount := ImmGetCompositionString(imc,
GCS_RESULTSTR, nil, 0);
- GetMem(p, fImeCount + 1);
+ //GetMem(p, fImeCount + 1);
try
- ImmGetCompositionString(imc, GCS_RESULTSTR,
p, fImeCount + 1);
- p[fImeCount] := #0;
- CommandProcessor(ecImeStr, #0, p);
+ ImmGetCompositionString(imc, GCS_RESULTSTR,
fpBuffer, fImeCount + 1);
+ fpBuffer[fImeCount] := #0;
+ CommandProcessor(ecImeStr, #0, fpBuffer);
finally
- FreeMem(p, fImeCount + 1);
+ //FreeMem(p, fImeCount + 1);
+ end;
+ end;
+ if not ReadOnly then begin
+ if FCustomComposition then begin
+ // Not Use ImmGetCompositionString. It cause
getting incorret string.
+ // May it not Over 2 byte string?
+ //fImeCount := 3;
+ fpBuffer[0] := char(Msg.WParam shr 8);
+ fpBuffer[1] := char(Msg.WParam and $00ff);
+ fpBuffer[2] := #0;
+ GetCaretPos(px);
+ //oldfont := Canvas.Font;
+ Canvas.Font := Font;
+ Canvas.Font.Color := clHighlightText;
+ bl := Canvas.Brush.Color;
+ Canvas.Brush.Color := clHighlight;
+ Canvas.TextOut(px.x, px.y-1, fpBuffer);
+ Canvas.Brush.Color := bl;
+ //Canvas.Font := OldFont;
+ sendmessage(handle,WM_PAINT,0,0);
+ end else begin
+ // It place Composition Window at
WM_IME_STARTCOMPOSITION
+ // First Composition Window position is 0,0
on Screen,
+ // It Fix that bug.
+ ImmGetCompositionWindow(imc,@pl);
+ GetCaretPos(px);
+ pl.dwStyle := CFS_POINT;
+ pl.ptCurrentPos := px;
+ ImmSetCompositionWindow(imc,@pl);
end;
+ end; // if not ReadOnly
finally
ImmReleaseContext(Handle, imc);
end;
@@ -3355,6 +3448,9 @@
if nTokenPos >= vLastChar then
break;
nTokenLen := vLastChar - nTokenPos -
1;
+{$IFDEF SYN_MBCSSUPPORT}
+ if ByteType(sToken,nTokenLen)
<>mbSingleByte then inc(nTokenLen);
+{$ENDIF}
end;
// Remove offset generated by tokens
already displayed (in previous rows)
Dec( nTokenPos, vFirstChar -
FirstCol );
@@ -3375,6 +3471,8 @@
if (attr = nil) or (attr <>
fHighlighter.CommentAttribute) then
attr :=
fHighlighter.WhitespaceAttribute;
// Draw text that couldn't be parsed by
the highlighter, if any.
+ // DW = Unisyn Bug fix
+ if not UseUniSyn then
if fHighlighter.GetTokenPos < Length
(sLine) then
begin
sToken := Copy(sLine, vFirstChar,
vLastChar - vFirstChar);
@@ -4502,9 +4600,13 @@
HideCaret;
end;
{$IFDEF SYN_MBCSSUPPORT}
+ // In ime98, composition window appeares at
ImmSetCompositonWindow.
+ // Cause disabled when CustomComposition mode
+ if not FCustomComposition then begin
cf.dwStyle := CFS_POINT;
cf.ptCurrentPos := Point(CX, CY);
ImmSetCompositionWindow(ImmGetContext(Handle),
@cf);
+ end;
{$ENDIF}
end;
end;

Discussion

  • Do-wan Kim

    Do-wan Kim - 2006-07-20
     
  • Flávio Etrusco

    Flávio Etrusco - 2007-03-14

    Logged In: YES
    user_id=99702
    Originator: NO

    Hi, is this fix only useful for Win98?

     
  • Flávio Etrusco

    Flávio Etrusco - 2007-03-14
    • assigned_to: nobody --> etrusco
     
  • Flávio Etrusco

    Flávio Etrusco - 2007-03-14

    Logged In: YES
    user_id=99702
    Originator: NO

    Or otherwise, please forgive my ignorance, what is custom composition good for?
    And if your other patch obsoletes this one, please close this and I'll assign the other one.

    Thanks,
    Flávio

    PS. I've fixed in the CVS the bug regarding UniSyn, it will be included in next release.

     

Log in to post a comment.