Модераторы: Vitalik
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> strange error when using UniHighlighter 
:(
    Опции темы
Vit
Дата 27.10.2006, 21:25 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Vitaly Nevzorov
****


Профиль
Группа: Экс. модератор
Сообщений: 10964
Регистрация: 25.3.2002
Где: Chicago

Репутация: нет
Всего: 207



Hi

I wanted to provide some feedback for UniHighlighter but got an error on 
the feedback page.
So I do it now by email.

I did have a strange error when using UniHighlighter. The last token on 
a line would be printed twice.
I tracked the problem down and found that the there was an error in the 
Next function.
When end of line is detected, the current token position is not 
forwarded to the end of the previous token.

I solved this by adding the following line:
    fTokenPos := Run;

At line 331 in SynUniHighlighter.pas, just before the exit upon EOL.

Anyway thanks for this fine component, it did solve the problem I had 
with the regular highlighter which made it impossible
to handle both a // and a /* */ comment (because both start with a /).

Regards

Frans Bouwmans



--------------------
With the best wishes, Vit
I have done so much with so little for so long that I am now qualified to do anything with nothing
Самый большой Delphi FAQ на русском языке здесь: www.drkb.ru
PM MAIL WWW ICQ   Вверх
DavidCl0nel
Дата 30.10.2006, 15:59 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



>>the problem I had 
with the regular highlighter which made it impossible
to handle both a // and a /* */ comment (because both start with a /).


Yes, a little bit. The SynGen-Output didnt work, but you can tweak it:

Код
  //                        /* Comment */  , // Comment         , #define some   , "text"
  TRangeState = (rsUnKnown, rsCStyleComment, rsCStyleLineComment, rsCPreprocessor, rsString);


....


procedure TSynMySyn.CStyleCommentOpenProc;
begin
  Inc(Run);
  if (fLine[Run] = '*') then
  begin
    fRange := rsCStyleComment;
    CStyleCommentMultiLineProc;
  end
  else if (fLine[Run] = '/') then
  begin
    fRange := rsCStyleLineComment;
    CStyleCommentLineProc;
  end
  else
    fTokenID := tkIdentifier;
end;

procedure TSynMySyn.CStyleCommentLineProc;
begin
  case fLine[Run] of
     #0: NullProc;
    #10: LFProc;
    #13: CRProc;
  else
    begin
      fTokenID := tkComment;
      repeat 
        Inc(Run);
      until fLine[Run] in [#0, #10, #13];
      fRange := rsUnKnown;
    end; //else
  end; //case
end;

procedure TSynMySyn.CStyleCommentMultiLineProc;
var
  iNestedComment: Integer;
begin
  iNestedComment := 0;
  case fLine[Run] of
     #0: NullProc;
    #10: LFProc;
    #13: CRProc;
    else begin
      fTokenID := tkComment;
      repeat
        if (fLine[Run] = '/') and (fLine[Run + 1] = '*') then begin
          Inc(iNestedComment);
          Inc(Run, 2);
        end;
        if (fLine[Run] = '*') and (fLine[Run + 1] = '/') and not (fLine[Run - 1] = '/') {ignore /*/} then begin
          Inc(Run, 2);
          if (iNestedComment = 0) then begin
            fRange := rsUnKnown;
            Exit;
          end else begin
            Dec(iNestedComment);
          end;
        end;
        if not (fLine[Run] in [#0, #10, #13]) then Inc(Run);
      until fLine[Run] in [#0, #10, #13];
    end; //else
  end; //case
end;




It isnt very clean to use the same function twice, but it works - also for nested comments. I use it such way in my highlighter, I don't use the unihighlighter, because I don't need this functionality.
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Rules and hints for the forum "SynUniHighlighter"
Vit
Vitalik

Hello, dear user!

This is official forum for SynUniHighlighter component and unofficial forum for SynEdit, Codefolding and all related projects.


Some rules for the forum:

1. Do not create new topic if exactly the same already exists.

2. Don't ask several questions in the same topic. One topic - one question.

3. If discussion changes to far from original topic context, then create a separate thread for new discussion subject.


If you already registered then click here to log in.


If you havent't registered yet then click here and register. You need to type username, password (twice), email (twice) and security code.

Next you need go here and choose English language instead of Russian and press Enter.


Some hints for enghlish-speaking users:

- create new topic;     - create new vote;     - answer to the topic.


With regards, Vit, Vitalik.

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | SynUniHighlighter and SynEdit (English Language) | Следующая тема »


 




[ Время генерации скрипта: 0.0565 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.