"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "app/formconsole.pas" between
CudaText-1.92.0.tar.gz and CudaText-1.93.0.tar.gz

About: CudaText is a cross-platform text editor (written in Lazarus).

formconsole.pas  (CudaText-1.92.0):formconsole.pas  (CudaText-1.93.0)
skipping to change at line 27 skipping to change at line 27
PythonEngine, PythonEngine,
ATSynEdit, ATSynEdit,
ATSynEdit_Edits, ATSynEdit_Edits,
ATSynEdit_Commands, ATSynEdit_Commands,
ATSynEdit_Adapter_Simple, ATSynEdit_Adapter_Simple,
ATStringProc, ATStringProc,
ec_SyntAnal, ec_SyntAnal,
ec_syntax_format, ec_syntax_format,
proc_str, proc_str,
proc_colors, proc_colors,
proc_globdata; proc_globdata,
proc_msg;
type type
TAppStrEvent = procedure(const Str: string) of object; TAppStrEvent = procedure(const Str: string) of object;
TAppConsoleEvent = function(const Str: string): boolean of object; TAppConsoleEvent = function(const Str: string): boolean of object;
TAppConsoleCommandEvent = procedure(ACommand: integer; const AText: string; va r AHandled: boolean) of object; TAppConsoleCommandEvent = procedure(ACommand: integer; const AText: string; va r AHandled: boolean) of object;
type type
{ TfmConsole } { TfmConsole }
TfmConsole = class(TForm) TfmConsole = class(TForm)
panelConsole: TPanel; panelConsole: TPanel;
PopupMenu1: TPopupMenu;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure MemoClickDbl(Sender: TObject; var AHandled: boolean);
private private
{ private declarations } { private declarations }
FAdapter: TATAdapterSimple; FAdapter: TATAdapterSimple;
FOnNavigate: TAppConsoleEvent; FOnNavigate: TAppConsoleEvent;
mnuTextClear: TMenuItem;
mnuTextNav: TMenuItem;
mnuTextWrap: TMenuItem;
procedure ComboCommand(Sender: TObject; ACmd: integer; const AText: string; var AHandled: boolean); procedure ComboCommand(Sender: TObject; ACmd: integer; const AText: string; var AHandled: boolean);
procedure DoGetLineColor(Ed: TATSynEdit; ALineIndex: integer; var AColorFont , AColorBg: TColor); procedure DoGetLineColor(Ed: TATSynEdit; ALineIndex: integer; var AColorFont , AColorBg: TColor);
function GetWrap: boolean; procedure MemoClickDbl(Sender: TObject; var AHandled: boolean);
procedure MemoCommand(Sender: TObject; ACmd: integer; const AText: string; v ar AHandled: boolean); procedure MemoCommand(Sender: TObject; ACmd: integer; const AText: string; v ar AHandled: boolean);
procedure MemoContextPopup(Sender: TObject; MousePos: TPoint; var Handled: B oolean);
procedure DoClearMemo(Sender: TObject); procedure DoClearMemo(Sender: TObject);
procedure DoNavigate(Sender: TObject); procedure DoNavigate(Sender: TObject);
procedure DoToggleWrap(Sender: TObject); procedure DoToggleWrap(Sender: TObject);
procedure SetIsDoubleBuffered(AValue: boolean); procedure SetIsDoubleBuffered(AValue: boolean);
procedure SetWrap(AValue: boolean); function GetWordWrap: boolean;
procedure SetWordWrap(AValue: boolean);
procedure DoRunLine(Str: string); procedure DoRunLine(Str: string);
public public
{ public declarations } { public declarations }
ed: TATComboEdit; ed: TATComboEdit;
memo: TATSynEdit; memo: TATSynEdit;
mnuTextClear: TMenuItem;
mnuTextNav: TMenuItem;
mnuTextWrap: TMenuItem;
ShowError: boolean;
property OnConsoleNav: TAppConsoleEvent read FOnNavigate write FOnNavigate; property OnConsoleNav: TAppConsoleEvent read FOnNavigate write FOnNavigate;
procedure DoAddLine(const Str: string); procedure DoAddLine(const Str: string);
procedure DoUpdate; procedure DoUpdate;
procedure DoScrollToEnd(AllowProcessMsg: boolean); procedure DoScrollToEnd(AllowProcessMsg: boolean);
property IsDoubleBuffered: boolean write SetIsDoubleBuffered; property IsDoubleBuffered: boolean write SetIsDoubleBuffered;
property Wordwrap: boolean read GetWrap write SetWrap; property MemoWordWrap: boolean read GetWordWrap write SetWordWrap;
end; end;
var var
fmConsole: TfmConsole; fmConsole: TfmConsole;
const const
cPyConsoleMaxLines = 1000; cPyConsoleMaxLines = 1000;
cPyConsoleMaxComboItems: integer = 20; cPyConsoleMaxComboItems: integer = 20;
cPyConsolePrompt = '>>> '; cPyConsolePrompt = '>>> ';
cPyCharPrint = '='; cPyCharPrint = '=';
skipping to change at line 99 skipping to change at line 99
Str: string; Str: string;
fmt: TecSyntaxFormat; fmt: TecSyntaxFormat;
begin begin
Str:= Ed.Strings.LinesUTF8[ALineIndex]; Str:= Ed.Strings.LinesUTF8[ALineIndex];
if SBeginsWith(Str, cPyConsolePrompt) then if SBeginsWith(Str, cPyConsolePrompt) then
begin begin
fmt:= AppStyleId2; fmt:= AppStyleId2;
AColorFont:= fmt.Font.Color AColorFont:= fmt.Font.Color
end end
else else
if (Str='Traceback (most recent call last):') or if SBeginsWith(Str, 'NOTE: ') or
(Str='Traceback (most recent call last):') or
SRegexMatchesString(Str, '^[a-zA-Z][\w\.]*Error: .+', true) then SRegexMatchesString(Str, '^[a-zA-Z][\w\.]*Error: .+', true) then
begin begin
fmt:= AppStyleError; fmt:= AppStyleError;
AColorFont:= fmt.Font.Color; AColorFont:= fmt.Font.Color;
AColorBg:= fmt.BgColor; AColorBg:= fmt.BgColor;
end; end;
end; end;
procedure TfmConsole.DoAddLine(const Str: string); procedure TfmConsole.DoAddLine(const Str: string);
begin begin
skipping to change at line 240 skipping to change at line 241
memo.OptUnprintedVisible:= false; memo.OptUnprintedVisible:= false;
memo.OptMarginRight:= 2000; memo.OptMarginRight:= 2000;
memo.OptCaretVirtual:= false; memo.OptCaretVirtual:= false;
memo.ModeReadOnly:= true; memo.ModeReadOnly:= true;
memo.OptMouseRightClickMovesCaret:= true; memo.OptMouseRightClickMovesCaret:= true;
memo.OptMouseWheelZooms:= false; memo.OptMouseWheelZooms:= false;
memo.OptShowMouseSelFrame:= false; memo.OptShowMouseSelFrame:= false;
memo.OnClickDouble:= @MemoClickDbl; memo.OnClickDouble:= @MemoClickDbl;
memo.OnCommand:= @MemoCommand; memo.OnCommand:= @MemoCommand;
memo.OnContextPopup:= @MemoContextPopup;
//menu items
mnuTextClear:= TMenuItem.Create(Self);
mnuTextClear.Caption:= 'Clear';
mnuTextClear.OnClick:= @DoClearMemo;
memo.PopupTextDefault.Items.Add(mnuTextClear);
mnuTextWrap:= TMenuItem.Create(Self);
mnuTextWrap.Caption:= 'Toggle word wrap';
mnuTextWrap.OnClick:= @DoToggleWrap;
memo.PopupTextDefault.Items.Add(mnuTextWrap);
mnuTextNav:= TMenuItem.Create(Self);
mnuTextNav.Caption:= 'Navigate';
mnuTextNav.OnClick:= @DoNavigate;
memo.PopupTextDefault.Items.Add(mnuTextNav);
end; end;
procedure TfmConsole.ComboCommand(Sender: TObject; ACmd: integer; procedure TfmConsole.ComboCommand(Sender: TObject; ACmd: integer;
const AText: string; var AHandled: boolean); const AText: string; var AHandled: boolean);
var var
s: string; s: string;
begin begin
if ACmd=cCommand_KeyEnter then if ACmd=cCommand_KeyEnter then
begin begin
s:= UTF8Encode(ed.Text); s:= UTF8Encode(ed.Text);
skipping to change at line 279 skipping to change at line 265
ed.DoCaretSingle(0, 0); ed.DoCaretSingle(0, 0);
AHandled:= true; AHandled:= true;
Exit Exit
end; end;
//if Assigned(FOnEditCommand) then //if Assigned(FOnEditCommand) then
// FOnEditCommand(ACmd, AText, AHandled); // FOnEditCommand(ACmd, AText, AHandled);
end; end;
function TfmConsole.GetWrap: boolean; function TfmConsole.GetWordWrap: boolean;
begin begin
Result:= memo.OptWrapMode=cWrapOn; Result:= memo.OptWrapMode=cWrapOn;
end; end;
procedure TfmConsole.DoClearMemo(Sender: TObject); procedure TfmConsole.DoClearMemo(Sender: TObject);
begin begin
memo.ModeReadOnly:= false; memo.ModeReadOnly:= false;
memo.Text:= ''; memo.Text:= '';
memo.DoCaretSingle(0, 0); memo.DoCaretSingle(0, 0);
memo.ModeReadOnly:= true; memo.ModeReadOnly:= true;
skipping to change at line 308 skipping to change at line 294
begin begin
N:= Memo.Carets[0].PosY; N:= Memo.Carets[0].PosY;
if not Memo.Strings.IsIndexValid(N) then exit; if not Memo.Strings.IsIndexValid(N) then exit;
S:= Memo.Strings.LinesUTF8[N]; S:= Memo.Strings.LinesUTF8[N];
FOnNavigate(S); FOnNavigate(S);
end; end;
end; end;
procedure TfmConsole.DoToggleWrap(Sender: TObject); procedure TfmConsole.DoToggleWrap(Sender: TObject);
begin begin
WordWrap:= not WordWrap; MemoWordWrap:= not MemoWordWrap;
end;
procedure TfmConsole.MemoContextPopup(Sender: TObject; MousePos: TPoint; var Han
dled: Boolean);
begin
if mnuTextClear=nil then
begin
mnuTextClear:= TMenuItem.Create(Self);
mnuTextClear.OnClick:= @DoClearMemo;
memo.PopupTextDefault.Items.Add(mnuTextClear);
mnuTextWrap:= TMenuItem.Create(Self);
mnuTextWrap.OnClick:= @DoToggleWrap;
memo.PopupTextDefault.Items.Add(mnuTextWrap);
mnuTextNav:= TMenuItem.Create(Self);
mnuTextNav.OnClick:= @DoNavigate;
memo.PopupTextDefault.Items.Add(mnuTextNav);
end;
mnuTextClear.Caption:= msgConsoleClear;
mnuTextWrap.Caption:= msgConsoleToggleWrap;
mnuTextNav.Caption:= msgConsoleNavigate;
mnuTextWrap.Checked:= MemoWordWrap;
Handled:= false;
end; end;
procedure TfmConsole.SetIsDoubleBuffered(AValue: boolean); procedure TfmConsole.SetIsDoubleBuffered(AValue: boolean);
begin begin
ed.DoubleBuffered:= AValue; ed.DoubleBuffered:= AValue;
memo.DoubleBuffered:= AValue; memo.DoubleBuffered:= AValue;
end; end;
procedure TfmConsole.SetWrap(AValue: boolean); procedure TfmConsole.SetWordWrap(AValue: boolean);
begin begin
if AValue then if AValue then
fmConsole.memo.OptWrapMode:= cWrapOn fmConsole.memo.OptWrapMode:= cWrapOn
else else
fmConsole.memo.OptWrapMode:= cWrapOff; fmConsole.memo.OptWrapMode:= cWrapOff;
//fmConsole.memo.OptAllowScrollbarHorz:= not AValue; //fmConsole.memo.OptAllowScrollbarHorz:= not AValue;
fmConsole.memo.Update; fmConsole.memo.Update;
mnuTextWrap.Checked:= AValue;
end; end;
procedure TfmConsole.MemoCommand(Sender: TObject; ACmd: integer; procedure TfmConsole.MemoCommand(Sender: TObject; ACmd: integer;
const AText: string; var AHandled: boolean); const AText: string; var AHandled: boolean);
begin begin
if ACmd=cCommand_KeyEnter then if ACmd=cCommand_KeyEnter then
begin begin
MemoClickDbl(nil, AHandled); MemoClickDbl(nil, AHandled);
AHandled:= true; AHandled:= true;
end; end;
 End of changes. 15 change blocks. 
32 lines changed or deleted 42 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)