官方下载到uniSynedit的压缩包后,只有for2009的版本,用2010打开,也是没有问题的。编译的时候,在SynEditHighlighter.pas报错:

function TSynCustomHighlighter.IsWordBreakChar(AChar: WideChar): Boolean;
begin
  case AChar of
    #0..#32, '.', ',', ';', ':', '"', '''', '?, '`', '?, '^', '!', '?', '&',
    '$', '@', '?, '%', '#', '~', '[', ']', '(', ')', '{', '}', '<', '>',
    '-', '=', '+', '*', '/', '', '|':
      Result := True;
    else
      Result := False;
  end;
end;

就是多出了好几个的?,而无法编译通过。

其实,就是因为这些里面有些utf8字符,而Delphi默认的用cp936的文件格式打开,导致的错误。正确的应该是

function TSynCustomHighlighter.IsWordBreakChar(AChar: WideChar): Boolean;
begin
  case AChar of
    #0..#32, '.', ',', ';', ':', '"', '''', '´', '`', '°', '^', '!', '?', '&',
    '$', '@', '§', '%', '#', '~', '[', ']', '(', ')', '{', '}', '<', '>',
    '-', '=', '+', '*', '/', '', '|':
      Result := True;
    else
      Result := False;
  end;
end;

用正确的代码粘贴修改后,保存,Delphi2010会提示包含utf8字符,是否保存为utf8,选择“是”即可。

 

同样的,有几个文件,如synedit.pas,syneditsearch.pas也有相同的一段,做同样的修改。

另外:synhighlighterjava有一段

function TSynJavaSyn.IsIdentChar(AChar: WideChar): Boolean;
begin
  case AChar of
    '_', '$', '0'..'9', 'a'..'z', 'A'..'Z', 'À'..'Ö', 'Ø'..'ö', 'ø'..'ÿ':
    '_', '$', '0'..'9', 'a'..'z', 'A'..'Z', '?..'?, '?..'?, '?..'':
      Result := True;
    else
      Result := False;
  end;
end;


红色为错误的。

synhighlighterxml有:

function TSynXMLSyn.IsNameChar: Boolean;
begin
  case fLine[Run] of
    '0'..'9', 'a'..'z', 'A'..'Z', '_', '.', ':', '-':
      Result := True;
    else if fLine[Run] > 'À' then // TODO: this here is very vague, see above
    else if fLine[Run] > '? then // TODO: this here is very vague, see above
      Result := True
    else
      Result := False;
  end;
end;

把编译错误和warning处理完后,编译就很顺利了。

附上修改后的安装包文件: