You've already forked lazarus-ccr
aarre
applications
bindings
components
Comba_Animation
aboutcomponent
acs
beepfp
callite
chelper
chemtext
cmdline
cmdlinecfg
colorpalette
cryptini
csvdocument
epiktimer
extrasyn
fpexif
fpsound
fpspreadsheet
fractions
freetypepascal
geckoport
gradcontrols
grid_semaphor
industrialstuff
iosdesigner
iphonelazext
jujiboutils
jvcllaz
kcontrols
lazautoupdate
lazbarcodes
lazmapviewer
lclextensions
longtimer
manualdock
mbColorLib
mplayer
multithreadprocs
nvidia-widgets
onguard
orpheus
playsoundpackage
poweredby
powerpdf
rgbgraphics
richmemo
richview
rtfview
rx
scrolltext
smnetgradient
spktoolbar
svn
systools
examples
1d array
2d array
3d array
astronomy_calculator
barcode
barcode (postnet)
bcd_calculator
bits
collection
data_merge
double_ended_queue
eclipses
expression
financial_calculator
grid_fill
html
jupiter_moons
money_calculator
nonvisual
patterns
priority_queue
random
regex
text
extext.lpi
extext.lpr
extextu.lfm
extextu.pas
tree
virtual_matrix
windows-only
images
source
laz_systools.lpk
laz_systools.pas
laz_systools_all.lpg
laz_systools_design.lpk
laz_systools_design.pas
laz_systoolsdb.lpk
laz_systoolsdb.pas
laz_systoolsdb_design.lpk
laz_systoolsdb_design.pas
laz_systoolswin.lpk
laz_systoolswin.pas
laz_systoolswin_design.lpk
laz_systoolswin_design.pas
readme-orig.txt
readme.txt
readme404pre.txt
tdi
thtmlport
tparadoxdataset
tvplanit
xdev_toolkit
zlibar
zmsql
examples
image_sources
lclbindings
wst
231 lines
4.5 KiB
ObjectPascal
231 lines
4.5 KiB
ObjectPascal
![]() |
(* ***** BEGIN LICENSE BLOCK *****
|
||
|
* Version: MPL 1.1
|
||
|
*
|
||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||
|
* the License. You may obtain a copy of the License at
|
||
|
* http://www.mozilla.org/MPL/
|
||
|
*
|
||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||
|
* for the specific language governing rights and limitations under the
|
||
|
* License.
|
||
|
*
|
||
|
* The Original Code is TurboPower SysTools
|
||
|
*
|
||
|
* The Initial Developer of the Original Code is
|
||
|
* TurboPower Software
|
||
|
*
|
||
|
* Portions created by the Initial Developer are Copyright (C) 1996-2002
|
||
|
* the Initial Developer. All Rights Reserved.
|
||
|
*
|
||
|
* Contributor(s):
|
||
|
*
|
||
|
* ***** END LICENSE BLOCK ***** *)
|
||
|
|
||
|
unit ExTextU;
|
||
|
|
||
|
{$IFDEF FPC}
|
||
|
{$mode DELPHI}
|
||
|
{$ENDIF}
|
||
|
|
||
|
interface
|
||
|
|
||
|
uses
|
||
|
{$IFNDEF FPC}
|
||
|
Windows, Messages,
|
||
|
{$ENDIF}
|
||
|
SysUtils, Classes, Graphics, Controls,
|
||
|
Forms, Dialogs, StdCtrls;
|
||
|
|
||
|
type
|
||
|
TSTDlg = class(TForm)
|
||
|
Memo1: TMemo;
|
||
|
OD1: TOpenDialog;
|
||
|
LoadBtn: TButton;
|
||
|
SeekBtn: TButton;
|
||
|
FlushBtn: TButton;
|
||
|
Label1: TLabel;
|
||
|
Edit1: TEdit;
|
||
|
Label2: TLabel;
|
||
|
Edit2: TEdit;
|
||
|
Label3: TLabel;
|
||
|
Edit3: TEdit;
|
||
|
Edit4: TEdit;
|
||
|
CloseFBtn: TButton;
|
||
|
procedure LoadBtnClick(Sender: TObject);
|
||
|
procedure SeekBtnClick(Sender: TObject);
|
||
|
procedure Memo1KeyUp(Sender: TObject; var Key: Word;
|
||
|
Shift: TShiftState);
|
||
|
procedure Memo1MouseUp(Sender: TObject; Button: TMouseButton;
|
||
|
Shift: TShiftState; X, Y: Integer);
|
||
|
procedure FlushBtnClick(Sender: TObject);
|
||
|
procedure CloseFBtnClick(Sender: TObject);
|
||
|
procedure FormCreate(Sender: TObject);
|
||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
|
private
|
||
|
{ Private declarations }
|
||
|
public
|
||
|
{ Public declarations }
|
||
|
procedure UpdatePos;
|
||
|
procedure UpdateButtons(FOK : Boolean);
|
||
|
end;
|
||
|
|
||
|
var
|
||
|
STDlg: TSTDlg;
|
||
|
|
||
|
implementation
|
||
|
|
||
|
{$R *.lfm}
|
||
|
|
||
|
uses
|
||
|
StConst,
|
||
|
StBase,
|
||
|
StText;
|
||
|
|
||
|
|
||
|
var
|
||
|
F : TextFile;
|
||
|
AFO : Boolean;
|
||
|
|
||
|
|
||
|
procedure TSTDlg.UpdateButtons(FOK : Boolean);
|
||
|
begin
|
||
|
CloseFBtn.Enabled := FOK;
|
||
|
SeekBtn.Enabled := FOK;
|
||
|
FlushBtn.Enabled := FOK;
|
||
|
end;
|
||
|
|
||
|
procedure TSTDlg.FormCreate(Sender: TObject);
|
||
|
begin
|
||
|
UpdateButtons(False);
|
||
|
AFO := False;
|
||
|
end;
|
||
|
|
||
|
procedure TSTDlg.LoadBtnClick(Sender: TObject);
|
||
|
var
|
||
|
S : string;
|
||
|
// hC : HCursor;
|
||
|
begin
|
||
|
if (OD1.Execute) then
|
||
|
begin
|
||
|
if (AFO) then
|
||
|
CloseFile(F);
|
||
|
AFO := False;
|
||
|
|
||
|
AssignFile(F, OD1.FileName);
|
||
|
Reset(F);
|
||
|
|
||
|
Memo1.Enabled := True;
|
||
|
Memo1.Lines.BeginUpdate;
|
||
|
Screen.Cursor := crHourglass;
|
||
|
try
|
||
|
// Memo1.Perform(WM_SETREDRAW,0,0);
|
||
|
// hC := SetCursor(LoadCursor(0,IDC_WAIT));
|
||
|
|
||
|
while NOT EOF(F) do
|
||
|
begin
|
||
|
Readln(F,S);
|
||
|
Memo1.Lines.Add(S);
|
||
|
end;
|
||
|
|
||
|
finally
|
||
|
Screen.Cursor := crDefault;
|
||
|
Memo1.Lines.EndUpdate;
|
||
|
end;
|
||
|
// Memo1.Perform(WM_SETREDRAW,1,0);
|
||
|
// Memo1.Update;
|
||
|
Memo1.SelStart := 0;
|
||
|
Memo1.SelLength := 0;
|
||
|
|
||
|
Reset(F);
|
||
|
|
||
|
Edit1.Text := OD1.FileName;
|
||
|
Edit2.Text := IntToStr(TextFileSize(F));
|
||
|
Edit3.Text := IntToStr(TextPos(F));
|
||
|
|
||
|
// SetCursor(hC);
|
||
|
Memo1.SetFocus;
|
||
|
AFO := True;
|
||
|
end;
|
||
|
UpdateButtons(AFO);
|
||
|
end;
|
||
|
|
||
|
procedure TSTDlg.CloseFBtnClick(Sender: TObject);
|
||
|
begin
|
||
|
CloseFile(F);
|
||
|
Memo1.Clear;
|
||
|
AFO := False;
|
||
|
UpdateButtons(False);
|
||
|
end;
|
||
|
|
||
|
|
||
|
procedure TSTDlg.SeekBtnClick(Sender: TObject);
|
||
|
var
|
||
|
NP : LongInt;
|
||
|
begin
|
||
|
NP := StrToInt(Edit4.Text);
|
||
|
Memo1.SetFocus;
|
||
|
if (NP < 0) OR (NP >= TextFileSize(F)) then
|
||
|
begin
|
||
|
ShowMessage('Value out of range');
|
||
|
Exit;
|
||
|
end;
|
||
|
|
||
|
if TextSeek(F,NP) then
|
||
|
begin
|
||
|
NP := TextPos(F);
|
||
|
Memo1.SelStart := NP;
|
||
|
Memo1.SelLength := 0;
|
||
|
Edit3.Text := IntToStr(NP);
|
||
|
end else
|
||
|
begin
|
||
|
ShowMessage('Unable to seek to position');
|
||
|
Memo1.SetFocus;
|
||
|
end;
|
||
|
end;
|
||
|
|
||
|
procedure TSTDlg.Memo1KeyUp(Sender: TObject; var Key: Word;
|
||
|
Shift: TShiftState);
|
||
|
begin
|
||
|
UpdatePos;
|
||
|
end;
|
||
|
|
||
|
procedure TSTDlg.Memo1MouseUp(Sender: TObject; Button: TMouseButton;
|
||
|
Shift: TShiftState; X, Y: Integer);
|
||
|
begin
|
||
|
UpdatePos;
|
||
|
end;
|
||
|
|
||
|
|
||
|
procedure TSTDlg.UpdatePos;
|
||
|
var
|
||
|
CP : LongInt;
|
||
|
begin
|
||
|
CP := Memo1.SelStart;
|
||
|
|
||
|
if NOT TextSeek(F,CP) then
|
||
|
begin
|
||
|
ShowMessage('Unable to update file pointer');
|
||
|
Exit;
|
||
|
end;
|
||
|
|
||
|
Edit3.Text := IntToStr(TextPos(F));
|
||
|
end;
|
||
|
|
||
|
procedure TSTDlg.FlushBtnClick(Sender: TObject);
|
||
|
begin
|
||
|
if NOT (TextFlush(F)) then
|
||
|
begin
|
||
|
ShowMessage('Unable to flush file');
|
||
|
end;
|
||
|
Memo1.SetFocus;
|
||
|
end;
|
||
|
|
||
|
procedure TSTDlg.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
|
begin
|
||
|
if AFO then CloseFile(F);
|
||
|
end;
|
||
|
|
||
|
end.
|