A r t i c l e s
Navigation

Note: This Wiki is
outdated, personal views
may have changed.
L505 A.I. bot is dead
long live THX 1138

M a i n P a g e

D i r e c t o r y

Synedit Get Current Token Kind


The token types are as follows:
TtkTokenKind = (tkAmpersand, tkComment, tkIdentifier, tkKey, tkNull,
  tkSpace, tkSymbol, tkText, tkUndefKey, tkValue);

To get the type of token (word) the caret is on currently:
  syn1.GetHighlighterAttriAtRowColEx(synedit1.CaretXY, tmpstring, tmptokentype, tmpstart, tmpattr);
  showmessage(inttostr(tokentype));

Simply make some temporary var placeholders and the function will pass you the information through them, i.e. tmptokentype is the one you are looking for.
For example with the Pascal highlighter for synedit, you can check the token that the cursor is on using CaretXY and checking using the following CASE statement:
var
  tmpToken: TtkTokenKind;
begin

  tmptoken:= TtkTokenKind(testtokentype);

  case tmptoken of
    tkAsm:
    begin
      showmessage('Cursor on Asm token');
    end;

    tkIdentifier:
    begin
      showmessage('Cursor on Identifier');
    end;

    tkComment:
    begin
      showmessage('Cursor on Comment');
    end;

    tkKey:
    begin
      showmessage('Cursor on language Keyword');
    end;

    tkNull:
    begin
      showmessage('Cursor on null area');
    end;

    tkNumber:
    begin
      showmessage('Cursor on number');
    end;

    tkSpace:
    begin
      showmessage('Cursor on space area');
    end;

    tkString:
    begin
      showmessage('Cursor on string');
    end;

    tkSymbol:
    begin
      showmessage('Cursor on symbol');
    end;

    tkUnknown:
    begin
      showmessage('Cursor on unknown');
    end;

    tkFloat:
    begin
      showmessage('Cursor on float');
    end;

    tkHex:
    begin
      showmessage('Cursor on hex');
    end;

    tkDirec:
    begin
      showmessage('Cursor on language directive');
    end;

    tkChar:
    begin
      showmessage('Cursor on char');
    end;



  end;

end;


About
Note: This Wiki is outdated, personal views may have changed.

This wiki contains info on life, health, humans, nature, programming, database, fads, paradigms, poems, principles, theories.

Articles may contain statements which some may find helpful and encouraging, or even discouraging.

Beware, I believe in the Grand Justice system.
_ _ _