秋·风

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

       lazarus在实际使用中还存在一些问题,特别是在linux下lazarus代码编辑时不能输入中文/combobox/lazarus Object Inspector下拉时不显示文字/日期分隔符乱码(还会引起pas文件中的中文乱码等严重的问题),如果不对fpc/lazarus进行修复,会影响开发效率和使用,经以下修改后的lazarus已能比较顺利开发应用.

这个链接已包含以下修复内容,用解压后的文件替换原文件,重新编译fpc、lazarus就可以:https://pan.baidu.com/s/1oeozSMa3-WLZ_pM5haxc1w?pwd=rcfu
提取码:rcfu
一.修复lazarus中文输入

修改方法很简单,这4个文件开始位置添加:
lazarus/components/synedit/lazsyngtk2imm.pas
lazarus/lcl/interfaces/gtk2/gtk2globals.pp
lazarus/lcl/interfaces/gtk2/gtk2widgetset.inc
lazarus/lcl/interfaces/gtk2/gtk2proc.inc

{$ifdef linux}
{$define WITH_GTK2_IM}
{$endif}

lazarus/components/synedit/synedit.inc添加

{$ifdef linux}
{$define Gtk2IME}
{$endif}

二.FPC/lazrus支持中文变量/过程和函数

fpcsrc/compiler/scanner.pas
修改scanner.pas以下4个位置:
1、第4054行:

'A'..'Z':
修改为:
'A'..'Z',#$80..#255 :

2、第4729行:

if c in ['A'..'Z','a'..'z','_'] then

改为:

if (c in ['A'..'Z','a'..'z','_',#$80..#255]) then

3、第4822行:

if not (c in ['_','A'..'Z','a'..'z']) then
message2(scan_f_syn_expected,tokeninfo^[_ID].str,c);

改为:

if not ((c in ['_','A'..'Z','a'..'z',#$80..#255])) then
message2(scan_f_syn_expected,tokeninfo^[_ID].str,c);

4、第5456行:

'a'..'z' :

改为:

'a'..'z' , #$80..#255:

修改后重新编译fpcsrc

修改lazarus\components\codetools\keywordfunclists.pas
将第852行:

IsIdentChar[c]:=c in ['a'..'z','A'..'Z','_','0'..'9'];

改为:

IsIdentChar[c]:=c in ['a'..'z','A'..'Z','_','0'..'9',#$80..#255];

 

重新编译lazarus

三.lazarus/lcl/interfaces/gtk2:
1.lazarus/lcl/interfaces/gtk2/gtk2widgetset.inc:
文件开始添加以下代码:

{$ifdef linux}
{$define WITH_GTK2_IM}
{$endif}

将第1386~-1393行注释

{ //2022.07.11 LBZ 防止打开frx报表设计器出错
else
if ALogLevel and G_LOG_LEVEL_CRITICAL <> 0
then begin
   Level := 'CRITICAL';
   Ex := EInterfaceCritical;
end
}

2.lazarus/lcl/interfaces/gtk2/gtk2winapi.inc:

在第9601行添加:

gtk_widget_realize(PGtkWidget(GtkWindow));

在第9610行添加:

if Aflags and GDK_WINDOW_STATE_MAXIMIZED = 0 then//2022.10.18 LBZ

3.lazarus/lcl/interfaces/gtk2/gtk2wsforms.pp

在第409添加以下代码

case ACustomForm.WindowState of
  wsMaximized: gtk_window_maximize(PGtkWindow(P));
  wsMinimized: gtk_window_iconify(PGtkWindow(P));
  wsFullscreen: gtk_window_fullscreen(PGtkWindow(P));
else
end;

4.lazarus/lcl/interfaces/gtk2/gtk2devicecontext.inc

在第736行添加:

Self.BkMode:=ASource.BkMode;//2022.12.05 LBZ

四.lazarus/lcl/include/

1.修复combobox类item列表背景颜色和文字颜色相同的问题
lazarus/lcl/include/customcombobox.inc
第113行加上以下5行:
//2022.05.28 LBZ 修复combobox类item列表背景颜色和文字颜色相同的问题

{$ifdef linux}// LCLgtk2}
FCanvas.FillRect(ARect);
{$endif}
//2022.05.28 LBZ

五.修复linux lazarus Object Inspector下拉列表文字颜色和背景颜色相同导致不显示的问题(2022.12.06 已验证lazarus 2.2.4已修复此Bug,无需按以下方法修复)
修复lazarus在linux(ubuntu、银河麒麟等) Object Inspector下拉文字不显示的问题。
打开lazarus\components\ideintf\objectinspector.pp(3489行开始),按红字的修改后重新编译lazarus就可以。
第3517行添加以下代码:

    {$ifdef windows}
      ValueComboBox.Canvas.Font.Color := clWindowText;
    {$else}
      ValueComboBox.Canvas.Font.Color := clHighlightText;//2022.5.24 LBZ 字体颜色与背景颜色相同的Bug
    {$endif}

六.lazarus/components

1.汉化打印对话框
lazarus/components/printers/printer4lazstrconst.pas

{
*****************************************************************************
This file is part of the Printer4Lazarus package

See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************

Abstract: Resourcestrings.
}
unit Printer4LazStrConst;

{$mode objfpc}{$H+}

interface

resourcestring
p4lrsCancel = '取消';
p4lrsPrinterProperties = '打印机属性';
p4lrsOk = '确定';
p4lrsGeneral = '常规';
p4lrsPaperSize = '纸张尺寸';
p4lrsPaperType = '纸张类型';
p4lrsPaperSource = '纸张来源';
p4lrsResolution = '分辨率';
p4lrsOrientation = '方向';
p4lrsPortrait = '纵向';
p4lrsLandscape = '横向';
p4lrsReverseLandscape = '横向反转';
p4lrsReversePortrait = '纵向反转';
p4lrsBanners = '横幅(Banners)';
p4lrsStart = '开始';
p4lrsEnd = '结束';
p4lrsPagesPerSheet = '每页页数';
p4lrsMargins = '边距';
p4lrsAdvanced = '高级';
p4lrsNoDefaultPrinter = '未找到默认打印机.';
p4lrsShortUnitsMm = '(mm)';
p4lrsShortUnitsInches = '(英寸)';
p4lrsButtonMoreArrow = '更多 >>';
p4lrsButtonLessArrow = '<< 较少';
p4lrsJobStateReady = '已准备好';
p4lrsJobStatePrinting = '打印';
p4lrsJobStateStopped = '停止';
p4lrsJobStateAccepting = '(接受作业)';
p4lrsJobStateRejecting = '(拒绝作业)';
p4lrsAllPages = '全部';
p4lrsPageOdd = '奇数';
p4lrsPageEven = '偶数';
p4lrsNotAvailable = '不可用';
p4lrsAbbrevUnitsMm = 'mm';
p4lrsAbbrevUnitsInches = '"';

implementation

end.

七.lazarus调整界面

1.lazarus/components/ide/projectwizarddlg.pas
2.lazarus/components/ide/projectinspector.pas

posted on 2022-12-06 11:12  秋·风  阅读(979)  评论(0编辑  收藏  举报