Recent

Author Topic: [SOLVED] TSynCompletion Close on '$' keypress!  (Read 3995 times)

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
[SOLVED] TSynCompletion Close on '$' keypress!
« on: August 08, 2016, 10:54:04 pm »
Hi everybody,
I'm about to design a Firebird management tools with lazarus, In Firebird there are system tables that starts with 'RDB$' and on code completion where I press $ to complete the word BOMB, The completion call Validate and first word on the list inserted on the editor!

Even I did some triks on line(11)
Code: Pascal  [Select][+][-]
  1. procedure TSynBaseCompletionForm.UTF8KeyPress(var UTF8Key: TUTF8Char);
  2. begin
  3.   {$IFDEF VerboseKeys}
  4.   debugln('TSynBaseCompletionForm.UTF8KeyPress A UTF8Key="',DbgStr(UTF8Key),'" ',dbgsName(TObject(TMethod(OnUTF8KeyPress).Data)));
  5.   {$ENDIF}
  6.   if Assigned(OnUTF8KeyPress) then
  7.     OnUTF8KeyPress(Self, UTF8Key);
  8.   if UTF8Key='' then
  9.     exit;
  10.  
  11.   //if UTF8Key=#8 then
  12.   if (UTF8Key=#8) or (UTF8Key = '$') then
  13.   begin
  14.     // backspace
  15.   end
  16.   else
  17.   if (Length(UTF8Key)>=1) and (not IsIdentifierChar(@UTF8Key[1])) then
  18.   begin
  19.     // non identifier character
  20.     // if it is special key then eat it
  21.     if (Length(UTF8Key) = 1) and (UTF8Key[1] < #32) then
  22.     begin
  23.       if Assigned(OnCancel) then
  24.         OnCancel(Self);
  25.     end
  26.     else
  27.     if Assigned(OnValidate) then
  28.       OnValidate(Self, UTF8Key, []);
  29.     UTF8Key := '';
  30.   end
  31.   else
  32.   if (UTF8Key<>'') then
  33.   begin
  34.     // identifier character
  35.     AddCharAtCursor(UTF8Key);
  36.     UTF8Key := '';
  37.   end;
  38.   {$IFDEF VerboseKeys}
  39.   debugln('TSynBaseCompletionForm.UTF8KeyPress END UTF8Key="',DbgStr(UTF8Key),'"');
  40.   {$ENDIF}
  41. end;
  42.  
That prevent closing the completion, another thing appears to me, Just in case:
rdb$   -> what typed before [CTRL+Space] to show completion list
And select 'RDB$DATABASE' from list and pressing the [Enter] key make result as line below:
rdb$RDB$DATABASE
Actually it must replace the currentword to what selected, like another case:
tbl_ -> what typed before [CTRL+Space] to show completion
And select 'TBL_DOCUMENT' from list and pressing the [Enter] key make result as line below:
TBL_DOCUMENT

It's seems $ key make the completion action like "EndOfTokenChr" of TSynCompletion.

Is there any way to describe the '$' key as a normal key for TSynCompletion?

----------------


I did this simple patch and everything works:
Code: Pascal  [Select][+][-]
  1. // ->lazarus/components/synedit/synhighlightersql.pas   Line(1665)
  2. //Lazarus 1.7 r52786M FPC 3.0.0 x86_64-linux-gtk 2
  3. function TSynSQLSyn.GetIdentChars: TSynIdentChars;
  4. begin
  5.   Result := TSynValidStringChars;
  6.   if (fDialect = sqlInterbase6) then   ///Here solves the problem
  7.     Include(Result, '$');
  8.   if (fDialect = sqlMSSQL7) or (fDialect = sqlMSSQL2K) then
  9.     Include(Result, '@')
  10. {begin}                                                                         // DJLP 2000-08-11
  11.   else if fDialect = sqlOracle then begin
  12.     Include(Result, '#');
  13.     Include(Result, '$');
  14.   end;
  15. {end}                                                                           // DJLP 2000-08-11
  16. end;
  17.  
  18.  
« Last Edit: August 08, 2016, 11:29:15 pm by ϻαϻɾΣɀО »
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

guest58172

  • Guest
Re: TSynCompletion Close on '$' keypress!
« Reply #1 on: August 08, 2016, 11:24:03 pm »
If you have an highlighter class, try to override the function GetIdentChars to get something like

Code: Pascal  [Select][+][-]
  1. function TMyHlClass.GetIdentChars: TSynIdentChars;
  2. begin
  3.   Result := inherited GetIdentChars() + ['$'];
  4. end;
  5.  

it looks a bit to a problem i've encountered last year after a new Laz release (see the conversation I had here http://forum.lazarus.freepascal.org/index.php/topic,30663.msg196537.html#msg196537)


off topic: What do you use as component to get themed controls ? I'm interested.

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: TSynCompletion Close on '$' keypress!
« Reply #2 on: August 09, 2016, 12:00:23 am »
If you have an highlighter class, try to override the function GetIdentChars to get something like

Code: Pascal  [Select][+][-]
  1. function TMyHlClass.GetIdentChars: TSynIdentChars;
  2. begin
  3.   Result := inherited GetIdentChars() + ['$'];
  4. end;
  5.  

it looks a bit to a problem i've encountered last year after a new Laz release (see the conversation I had here http://forum.lazarus.freepascal.org/index.php/topic,30663.msg196537.html#msg196537)


off topic: What do you use as component to get themed controls ? I'm interested.

Thanks for replay,
No I just use TSynCompletion, Something like this patch must be applied globally for the future of lazarus  ::)
And as I said in the first of my post, the first trick also needed!

--

And about the theme, This is ubuntu 16.04 with "Arc-Darker" theme
And the remains of what you seen is customized TSynSQLSyn colors and custom paint of TSynCompletion  ;D
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

 

TinyPortal © 2005-2018