11 |
12 |
13 | This package, unless otherwise stated in the particular source code file,
14 | is distributed under Mozilla Public License Version 1.1 (the "License").
15 | You may obtain a copy of the License at
16 | http://www.mozilla.org/MPL/
17 |
18 |
19 | Software distributed under the License is distributed on an "AS IS"
20 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
21 | License for the specific language governing rights and limitations
22 | under the License.
23 |
24 |
11 |
12 |
13 | The current component version is not thread safe. But if you need to use it in a multi-thread
14 | application, the following hint should help to use it right. For example, you need
15 | to call Open method from several threads. Don't do this, instead do it in message way:
16 | all threads should send a message (it may be some Windows message not used in your application,
17 | e.g. EM_DISPLAYBAND) to main thread, informing it that a filename should be opened.
18 | Pointer to a filename can be passed as message parameter.
19 | So the main message handler calls Open.
20 |
21 |
22 | Note: this may be a risk of receiving messages from several threads at almost the same time,
23 | so additional boolean "Busy flag" should be set on message-handler start and reset on exit.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/history.txt:
--------------------------------------------------------------------------------
1 | 2024.07.01
2 | + add: props MarkerStart, MarkerLength, MarkerLineWidth, TextColorMarker
3 |
4 | 2023.12.01
5 | * change: disabled selection with UTF8 encoding, to hide wrong selection with UTF8
6 | * change: support proportional fonts, but now rendering is slower due to call of TCanvas.TextWidth for each char
7 | + add: DoubleBuffered property, it now allows correct rendering on macOS Retina if set to False
8 | - fix: TextWrap is now working
9 |
10 | 2019.09.19
11 | * change: require package EncConv (in github.com/alexey-t) instead of LConvEncoding
12 |
13 | 2018.04.10
14 | - fix: double-click worked wrong (must react in MouseUp, not in DblClick)
15 | - fix: wrong find of whole words
16 |
17 | 2018.04.07
18 | + add: update resource pic for "middle mouse click scroll" for hi-dpi
19 | + add: rewritten other resource files
20 |
21 | 2017.12.18
22 | + add: use unicode middle-dot U+00B7 for special chars
23 |
24 | 2017.12.15
25 | + big rework. ATStreamSearch works now. ATBinHex methods FindFirst/FindNext work now. Only case-insensitive search don't work for non-ascii text. Hard todo.
26 | + add: buttons Find/FindNext in demo
27 | + add: keys Home/End to goto file begin/end, in fixed modes
28 | + add: hide v-scrollbar in fixed modes (hex/ binary/ u-hex)
29 | - fix: OnScroll wasn't called in many cases
30 | - fix: huge file, if v-scrollbar dragged to end, file must also scroll to end
31 |
--------------------------------------------------------------------------------
/help_delphi/source/AddLibraries.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
13 | Additional optional libraries used in ATBinHex are:
14 |
15 |
16 |
17 |
DIRegEx: used for RegEx (regular expressions) search.
18 | asoRegEx search option is available only when this library is compiled in.
19 | After you install this library, enable its usage in
20 | ATBinHexOptions.inc and ATStreamSearchOptions.inc files, uncomment the "REGEX" define.
21 |
22 |
23 |
24 |
Tnt Unicode Controls: used for search in Unicode-named files (TTntFileStream class is used).
25 | After you install this library, enable its
26 | usage in file ATStreamSearchOptions.inc, uncomment the "TNT" define.
27 |
28 |
29 |
30 |
ATPrintPreview: used to show the "Print preview" form before the actual printing in
31 | Print and PrintPreview methods.
32 | After you install this library, enable its
33 | usage in file ATBinHexOptions.inc, uncomment the "PREVIEW" define.
34 |
11 |
12 |
13 | ATBinHex is a control that implements the quick file (stream) viewer.
14 | Only visible part of file (or stream) is loaded into viewer, so it's suitable
15 | to show files of unlimited size. Features:
16 |
17 |
18 |
Support for huge file sizes (of type Int64)
19 |
Support for Unicode file names
20 |
Support for multiple codepages: ANSI, OEM, EBCDIC, KOI8, ISO, Mac etc.
21 |
Many service methods implemented: copying to Clipboard, printing, search etc.
22 |
23 |
24 |
25 | There are 5 view modes available:
26 |
27 |
Text: file is shown in text form
28 |
Binary: file is shown in binary form, with fixed line length
29 |
Hex: file is shown in hex dump
30 |
Unicode: Unicode contents of file is shown
31 |
Unicode/Hex: combined Hex and Unicode modes
32 |
33 |
34 |
35 |
Text mode
36 |
Binary mode
37 |
Hex mode
38 |
Unicode mode
39 |
Unicode/Hex mode
40 |
41 |
42 |
43 | There is extended version of this component available,
44 | ATViewer,
45 | which can show files in such modes as RTF, Image, Multimedia, Internet and WLX Plugins.
46 | But if you just need to show a plain file dump, ATBinHex should be enough.
47 |
48 |
49 | There is also FreePascal/Lazarus version (ported from original version),
50 | which is maintained by independent developer.
51 | This version is currently in beta stage, some features are not yet implemented.
52 | Refer to LuiPack page.
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/help_delphi/source/Table of Contents.hhc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
14 |
15 |
19 |
23 |
27 |
28 |
31 |
32 |
36 |
40 |
44 |
48 |
52 |
53 |
56 |
57 |
61 |
65 |
69 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/atbinhex/atbinhex_hexproc.pas:
--------------------------------------------------------------------------------
1 | unit atbinhex_hexproc;
2 |
3 | interface
4 |
5 | //Conversion from hex encoded string (e.g. '10 20 AA FF': 4 chars) to normal string.
6 | //Hex string must contain 2*N hex digits. Spaces are ignored.
7 | function SHexToNormal(const HexStr: string; var ResStr: string): Boolean;
8 |
9 | //Conversion of string to hex form, digits are separated with spaces.
10 | function SToHex(const S: AnsiString): AnsiString;
11 |
12 | //Conversion from hex to Integer.
13 | function HexToIntDef(const S: string; const Default: Int64): Int64;
14 |
15 |
16 | implementation
17 |
18 | uses
19 | SysUtils, atbinhex_strproc;
20 |
21 | function SHexDigitToInt(Hex: char; var Int: LongWord): Boolean;
22 | var
23 | ch: char;
24 | begin
25 | Result := True;
26 | Int := 0;
27 | ch := UpCase(Hex);
28 | case ch of
29 | '0'..'9':
30 | Int := Ord(ch) - Ord('0');
31 | 'A'..'F':
32 | Int := Ord(ch) - Ord('A') + 10;
33 | else
34 | Result := False;
35 | end;
36 | end;
37 |
38 |
39 | function SHexWordToInt(const Hex: string; var Int: LongWord): Boolean;
40 | var
41 | Int1, Int2: LongWord;
42 | begin
43 | Result := False;
44 | if Length(Hex) = 1 then
45 | Result := SHexDigitToInt(Hex[1], Int)
46 | else
47 | if Length(Hex) = 2 then
48 | begin
49 | Result :=
50 | SHexDigitToInt(Hex[1], Int1) and
51 | SHexDigitToInt(Hex[2], Int2);
52 | if Result then
53 | Int := Int1 * 16 + Int2;
54 | end;
55 | end;
56 |
57 |
58 | function SHexToNormal(const HexStr: string; var ResStr: string): Boolean;
59 | var
60 | S: string;
61 | Int: LongWord;
62 | i: Integer;
63 | begin
64 | ResStr := '';
65 | Result := False;
66 |
67 | S := StringReplace(HexStr, ' ', '', [rfReplaceAll]);
68 |
69 | if (Length(S) mod 2) > 0 then Exit;
70 |
71 | for i := 1 to Length(S) div 2 do
72 | begin
73 | if not SHexWordToInt(S[2 * i - 1] + S[2 * i], Int) then Exit;
74 | ResStr := ResStr + Chr(Int);
75 | end;
76 |
77 | Result := True;
78 | end;
79 |
80 |
81 | function SToHex(const S: AnsiString): AnsiString;
82 | var
83 | i: Integer;
84 | begin
85 | Result := '';
86 |
87 | for i := 1 to Length(S) do
88 | Result := Result + IntToHex(Ord(S[i]), 2) + ' ';
89 |
90 | if Result <> '' then
91 | Delete(Result, Length(Result), 1);
92 | end;
93 |
94 |
95 | function HexToIntDef(const S: string; const Default: Int64): Int64;
96 | var
97 | i: Integer;
98 | N: LongWord;
99 | begin
100 | Result := 0;
101 | for i := 1 to Length(S) do
102 | begin
103 | if not SHexDigitToInt(S[i], N) then
104 | begin Result := Default; Exit end;
105 | Result := Result * $10 + N;
106 | end;
107 | end;
108 |
109 | end.
110 |
--------------------------------------------------------------------------------
/atbinhex/atbinhex_package.lpk:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | <_ExternHelp Items="Count"/>
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/help_delphi/source/Usage Hints.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Usage: Hints and FAQ
6 |
7 |
8 |
9 |
10 |
Hints and FAQ
11 |
12 |
13 |
14 | Q1: How can I load the contents of an AnsiString or WideString?
15 |
16 |
17 | A: You should do it using OpenStream method, giving it a TMemoryStream as
18 | a parameter. Sample procedures for AnsiString and WideString are shown
19 | below. Note that you should free stream only after calling
20 | Viewer.OpenStream(nil), otherwise control will try to read deallocated
21 | memory on scrolling!
22 |
23 |
24 |
25 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | Q2: I have an issue with horizontal scrollbar. Even when text becomes
76 | short enough, scrollbar doesn't disappear...
77 |
78 |
79 | A: This is done as workaround for Windows XP bug: when scrollbar is about
80 | to disappear, this may cause both scrollbars and window border to disappear.
81 | You can disable this workaround by commenting the "HSCROLLBAR_WORKAROUND"
82 | define in ATBinHexOptions.inc.
83 |
84 |
85 | The RichEdit control doesn't have this problem because it precalculates widths for all strings
86 | and sets scrollbar size to the max value.
87 | We cannot do this in ATBinHex control, so the scrollbar size is calculated dinamically.
88 |
89 |
90 |
91 |
92 |
93 |
94 | Q3: After changing a property, it is not applied.
95 |
96 |
Fired after file auto-reload complete (when AutoReload = True).
18 |
19 |
20 |
21 |
OnSelectionChange
22 |
Fired on text selection change.
23 |
24 |
25 |
26 |
OnOptionsChange
27 |
Fired after an option has been changed by user.
28 | Examples of such changable options:
29 |
30 |
Text encoding can be changed using right-click menu.
31 |
Font size can be changed using Ctrl + Mouse wheel.
32 |
33 |
34 |
35 |
36 |
37 |
OnSearchProgress
38 |
Fired on text search progress.
39 | It is of type:
40 |
41 | TATStreamSearchProgress = procedure(
42 | const ACurrentPos, AMaximalPos: Int64;
43 | var AContinueSearching: Boolean) of object;
44 | Parameters:
45 |
46 |
ACurrentPos: Current search position.
47 |
AMaximalPos: Maximal search position.
48 |
AContinueSearching: Initially set to True.
49 | If changed to False then search will be stopped.
50 |
51 |
52 |
53 |
54 |
55 |
OnDrawLine
56 |
Fired before a line is to be drawn in variable length modes (Text, Unicode).
57 | You can use it to color the entire line or to disable line drawing.
58 | It is of type:
59 |
ACanvas: Canvas which parameters you can change.
71 | It is allowed to change ACanvas.Font.Color and ACanvas.Brush.Color only.
72 |
AStr: String part (counting word wrap) which is to be drawn.
73 |
AStrAll: String (entire, w/o counting word wrap).
74 |
ARect: Rectangle in which string is to be drawn.
75 |
ATextPnt: Point after gutter.
76 |
ADone: Initially False; if set to True, string will not be drawn.
77 |
78 |
79 |
80 |
81 |
82 |
OnDrawLine2
83 |
Fired after a line has been drawn in variable length modes (Text, Unicode).
84 | You can use it to color some parts of the line.
85 | It is of type:
86 |
Added: Tabs (#9) have correct dynamic size (currently only for monospaced fonts).
97 |
Fixed: AutoReload option could not apply sometimes.
98 |
Fixed: Trailing spaces showing on word wrap.
99 |
100 |
101 | 1.9.2 (28 Oct 2007)
102 |
103 |
Added: TextOemSpecial property.
104 |
Added: TextNonPrintable property.
105 |
Changed: Msg* properties changed to single TextPopupCaption[] property.
106 |
107 |
108 | 1.9.0 (20 Oct 2007):
109 |
110 |
Added: Many codepages added, see complete list in ATxCodepages.pas.
111 | See notes for TextEncoding property.
112 | Note: RegEx search for custom codepages is not yet implemented.
113 |
Added: TextEncodingName property.
114 |
Added: TextEncodingsMenu method.
115 |
Added: "Encodings menu" popup menu item.
116 |
Added: Mouse shortcut for zoom: left button + wheel.
117 |
Changed: Redraw procedure refactored so now it's possible to use DrawTo
137 | to draw control contents on other bitmaps, not only on screen.
138 |
Changed: Print method rewritten, it uses DrawTo, so control prints itself
139 | in exactly the same form as it's shown on screen (but grayscaled).
140 | The printing is now possible in all modes, including Unicode!
141 |
Added: ATPrintPreview component is used to show print preview form.
142 | It's enabled by "PREVIEW" define in ATBinHexOptions.inc.
143 |
Added: PrintPreview method.
144 |
145 |
Added: Only chars missed in the current font are replaced with dots.
146 |
Added: Visual indication of Enabled property (grayed text).
147 |
Added: OnScroll event.
148 |
Changed: Property ScrollPageSize renamed to VariableScrollbar, it's default value is False now.
149 |
150 |
151 | 1.6.2 (16 Jun 2007):
152 |
153 |
Added: Auto-scroll when mouse is lefter/righter than client area
154 |
Added: Shift + Mouse Wheel scrolls text horizontally
155 |
Added: Ctrl + Mouse Wheel changes font size
156 |
Added: OnScaleChange event
157 |
Changed: ATStreamSearch updated for DIRegEx 4.1.1 release
158 |
Fixed: Possible AV on text selection under Multi-Byte locales
159 |
160 |
161 | 1.6.0 (28 Mar 2007):
162 |
163 |
Changed: License updated to MPL 1.1
164 |
Added: ATStreamSearch helper component
165 |
Added: RegEx search option (DIRegEx library must be used)
166 |
Changed: FindFirst/FindNext methods added instead of FindText method
167 |
Added: Feature like in RichEdit: triple click selects current line
168 |
Added: MaxClipboardDataSizeMb property
169 |
Changed: TextSearchIndent property renamed to TextSearchIndentVert
170 |
Changed: OnSearchProgress event added instead of SearchCallback property
171 |
Changed: ATBinHexDef.inc file renamed to ATBinHexOptions.inc,
172 | several options added to it
173 |
174 |
175 | 1.5.8 (24 Feb 2007):
176 |
177 |
Changed: Files are not locked for deletion anymore (Note: not supported in Win9x)
178 |
Added: IncreaseFontSize method
179 |
Added: OnFileReload event
180 |
181 |
182 | 1.5.6 (14 Dec 2006):
183 |
184 |
Added: FindText method works also in Unicode mode
185 |
Added: Scroll method
186 |
Added: TextSearchIndentHorz property
187 |
Added: Feature similar to RichEdit's: selection can be changed by performing
188 | Click at block start and Shift+Click at end
189 |
Changed: Declaration of SetSelection method
190 |
Removed: AutoCopy property: it can be done via OnSelectionChange event
191 |
Changed: Most of units renamed to AT*.* to avoid name confusions
212 |
Added: Thread safety note in the help
213 |
214 |
215 | 1.5.1 (04 Aug 2006):
216 |
217 |
Added: OpenStream method
218 |
Added: Feature similar to RichEdit's: double click selects word under cursor
219 |
220 |
221 | 1.5.0 (22 Jul 2006):
222 |
223 |
Added: Implemented Text mode (with variable line length)
224 |
Added: Unicode mode is now also has variable line length
225 |
Added: Select/Copy commands work in Unicode mode too
226 |
Added: FontOEM, ScrollPageSize properties
227 |
228 |
229 | ...
230 |
231 |
232 | 1.3.2 (17 Jun 2006):
233 |
234 |
Initial release (previous versions were included in the ATViewer pack)
235 |
236 |
237 |
238 |
239 |
--------------------------------------------------------------------------------
/atbinhex/atbinhex_strproc.pas:
--------------------------------------------------------------------------------
1 | unit atbinhex_strproc;
2 |
3 | interface
4 |
5 | uses
6 | SysUtils, atbinhex_stringproc;
7 |
8 | function SetStringW(Buf: Pointer; Len: Integer; SwapUnicode: boolean): UnicodeString;
9 | function SFileExtensionMatch(const FN, ExtList: string): boolean;
10 |
11 | type
12 | TStringDecodeRecW = record
13 | SFrom, STo: UnicodeString;
14 | end;
15 |
16 | TStringTabOptions = record
17 | TabSize: Integer;
18 | TabPosition: Integer;
19 | FontMonospaced: Boolean;
20 | NonPrintableShow: Boolean;
21 | NonPrintableChar: WideChar;
22 | end;
23 |
24 | function SDecodeW(const S: UnicodeString; const Decode: array of TStringDecodeRecW): UnicodeString;
25 | procedure SReplaceZeros(var S: AnsiString);
26 | procedure SReplaceZerosW(var S: UnicodeString);
27 | procedure SDelLastSpace(var S: AnsiString);
28 | procedure SDelLastSpaceW(var S: UnicodeString);
29 | function STabReplacement(const TabOptions: TStringTabOptions): UnicodeString;
30 | procedure SReplaceTabsW(var S: UnicodeString; var TabOptions: TStringTabOptions);
31 | function SCharCR(ch: WideChar): Boolean;
32 | function SLastCharCR(const S: UnicodeString): Boolean;
33 |
34 | function SFindText(const F, S: string; fForward, fWholeWords, fCaseSens, fLastBlock: Boolean): Integer;
35 | function SFindTextW(const F, S: UnicodeString; fForward, fWholeWords, fCaseSens, fLastBlock: Boolean): Integer;
36 |
37 | procedure ILimitMin(var N: Integer; Value: Integer);
38 | procedure ILimitMax(var N: Integer; Value: Integer);
39 | procedure I64LimitMin(var N: Int64; const Value: Int64);
40 | procedure I64LimitMax(var N: Int64; const Value: Int64);
41 |
42 | implementation
43 |
44 | function SDecodeW(const S: UnicodeString; const Decode: array of TStringDecodeRecW): UnicodeString;
45 | var
46 | i, j: Integer;
47 | DoDecode: Boolean;
48 | begin
49 | Result := '';
50 | i := 1;
51 | repeat
52 | if i > Length(S) then Break;
53 | DoDecode := False;
54 | for j := Low(Decode) to High(Decode) do
55 | with Decode[j] do
56 | if SFrom = Copy(S, i, Length(SFrom)) then
57 | begin
58 | DoDecode := True;
59 | Result := Result + STo;
60 | Inc(i, Length(SFrom));
61 | Break
62 | end;
63 | if DoDecode then Continue;
64 | Result := Result + S[i];
65 | Inc(i);
66 | until False;
67 | end;
68 |
69 |
70 | function SDefaultDelimiters: string;
71 | const
72 | cChars = ':;<=>?' + '@[\]^' + '`{|}~';
73 | var
74 | i: Integer;
75 | begin
76 | Result := '';
77 | for i := 0 to Ord('/') do
78 | Result := Result + Chr(i);
79 | Result := Result + cChars;
80 | end;
81 |
82 | //--------------------------------------------------
83 | function SFindText(const F, S: string; fForward, fWholeWords, fCaseSens, fLastBlock: Boolean): Integer;
84 | var
85 | SBuf, FBuf, Delimiters: string;
86 | Match: Boolean;
87 | LastPos, LengthF, i: Integer;
88 | begin
89 | Result := 0;
90 |
91 | if (S = '') or (F = '') then Exit;
92 |
93 | Delimiters := SDefaultDelimiters;
94 |
95 | SBuf := S;
96 | FBuf := F;
97 | if not fCaseSens then
98 | begin
99 | SBuf := LowerCase(SBuf);
100 | FBuf := LowerCase(FBuf);
101 | end;
102 |
103 | LengthF := Length(F);
104 | LastPos := Length(S) - LengthF + 1;
105 |
106 | if fForward then
107 | //Search forward
108 | for i := 1 to LastPos do
109 | begin
110 | Match := CompareMem(@FBuf[1], @SBuf[i], LengthF);
111 |
112 | if fWholeWords then
113 | Match := Match
114 | and (fLastBlock or (i < LastPos))
115 | and ((i <= 1) or (Pos(S[i - 1], Delimiters) > 0))
116 | and ((i >= LastPos) or (Pos(S[i + LengthF], Delimiters) > 0));
117 |
118 | if Match then
119 | begin
120 | Result := i;
121 | Break
122 | end;
123 | end
124 | else
125 | //Search backward
126 | for i := LastPos downto 1 do
127 | begin
128 | Match := CompareMem(@FBuf[1], @SBuf[i], LengthF);
129 |
130 | if fWholeWords then
131 | Match := Match
132 | and (fLastBlock or (i > 1))
133 | and ((i <= 1) or (Pos(S[i - 1], Delimiters) > 0))
134 | and ((i >= LastPos) or (Pos(S[i + LengthF], Delimiters) > 0));
135 |
136 | if Match then
137 | begin
138 | Result := i;
139 | Break
140 | end;
141 | end;
142 | end;
143 |
144 | //--------------------------------------------------
145 | function SFindTextW(const F, S: UnicodeString; fForward, fWholeWords, fCaseSens, fLastBlock: Boolean): Integer;
146 | var
147 | SBuf, FBuf, Delimiters: UnicodeString;
148 | Match: Boolean;
149 | LastPos, LengthF, i: Integer;
150 | begin
151 | Result := 0;
152 |
153 | if (S = '') or (F = '') then Exit;
154 |
155 | Delimiters := SDefaultDelimiters;
156 |
157 | SBuf := S;
158 | FBuf := F;
159 | if not fCaseSens then
160 | begin
161 | SBuf := UnicodeLowerCase(SBuf);
162 | FBuf := UnicodeLowerCase(FBuf);
163 | end;
164 |
165 | LengthF := Length(F);
166 | LastPos := Length(S) - LengthF + 1;
167 |
168 | if fForward then
169 | //Search forward
170 | for i := 1 to LastPos do
171 | begin
172 | Match := CompareMem(@FBuf[1], @SBuf[i], LengthF * 2);
173 |
174 | if fWholeWords then
175 | Match := Match
176 | and (fLastBlock or (i < LastPos))
177 | and ((i <= 1) or (Pos(S[i - 1], Delimiters) > 0))
178 | and ((i >= LastPos) or (Pos(S[i + LengthF], Delimiters) > 0));
179 |
180 | if Match then
181 | begin
182 | Result := i;
183 | Break
184 | end;
185 | end
186 | else
187 | //Search backward
188 | for i := LastPos downto 1 do
189 | begin
190 | Match := CompareMem(@FBuf[1], @SBuf[i], LengthF * 2);
191 |
192 | if fWholeWords then
193 | Match := Match
194 | and (fLastBlock or (i > 1))
195 | and ((i <= 1) or (Pos(S[i - 1], Delimiters) > 0))
196 | and ((i >= LastPos) or (Pos(S[i + LengthF], Delimiters) > 0));
197 |
198 | if Match then
199 | begin
200 | Result := i;
201 | Break
202 | end;
203 | end;
204 | end;
205 |
206 | procedure ILimitMin(var N: Integer; Value: Integer);
207 | begin
208 | if N < Value then
209 | N := Value;
210 | end;
211 |
212 | procedure ILimitMax(var N: Integer; Value: Integer);
213 | begin
214 | if N > Value then
215 | N := Value;
216 | end;
217 |
218 | procedure I64LimitMin(var N: Int64; const Value: Int64);
219 | begin
220 | if N < Value then
221 | N := Value;
222 | end;
223 |
224 | procedure I64LimitMax(var N: Int64; const Value: Int64);
225 | begin
226 | if N > Value then
227 | N := Value;
228 | end;
229 |
230 |
231 | procedure SReplaceZeros(var S: AnsiString);
232 | var
233 | i: Integer;
234 | begin
235 | for i := 1 to Length(S) do
236 | if S[i] = #0 then
237 | S[i] := ' ';
238 | end;
239 |
240 | procedure SReplaceZerosW(var S: UnicodeString);
241 | var
242 | i: Integer;
243 | begin
244 | for i := 1 to Length(S) do
245 | if S[i] = #0 then
246 | S[i] := ' ';
247 | end;
248 |
249 | procedure SDelLastSpaceW(var S: UnicodeString);
250 | begin
251 | if (S <> '') and ((S[Length(S)] = ' ') or (S[Length(S)] = #9)) then
252 | SetLength(S, Length(S) - 1);
253 | end;
254 |
255 | procedure SDelLastSpace(var S: AnsiString);
256 | begin
257 | if (S <> '') and (S[Length(S)] = ' ') then
258 | SetLength(S, Length(S) - 1);
259 | end;
260 |
261 |
262 | function STabReplacement(const TabOptions: TStringTabOptions): UnicodeString;
263 | var
264 | ASize: Integer;
265 | APos: Integer;
266 | begin
267 | with TabOptions do
268 | begin
269 | Assert(TabSize > 0, 'Tab size too small');
270 | if FontMonospaced then
271 | ASize := TabSize - (TabPosition - 1) mod TabSize
272 | else
273 | ASize := TabSize;
274 | Result := StringOfChar(' ', ASize);
275 | APos := Length(Result) div 2 + 1;
276 | if NonPrintableShow then
277 | Result[APos] := NonPrintableChar;
278 | end;
279 | end;
280 |
281 | procedure SReplaceTabsW(var S: UnicodeString; var TabOptions: TStringTabOptions);
282 | var
283 | N: Integer;
284 | begin
285 | repeat
286 | N := Pos(#9, S);
287 | if N = 0 then Break;
288 | TabOptions.TabPosition := N;
289 | S := StringReplace(S, #9, STabReplacement(TabOptions), [rfReplaceAll]);
290 | until False;
291 | end;
292 |
293 |
294 | procedure SDeleteFromStrA(var S: AnsiString; const SubStr: AnsiString);
295 | var
296 | N: Integer;
297 | begin
298 | N := Pos(SubStr, S);
299 | if N > 0 then
300 | SetLength(S, N - 1);
301 | end;
302 |
303 | procedure SDeleteFromStrW(var S: UnicodeString; const SubStr: UnicodeString);
304 | var
305 | N: Integer;
306 | begin
307 | N := Pos(SubStr, S);
308 | if N > 0 then
309 | SetLength(S, N - 1);
310 | end;
311 |
312 | function SCharCR(ch: WideChar): Boolean;
313 | begin
314 | Result := (ch = #13) or (ch = #10);
315 | end;
316 |
317 | function SLastCharCR(const S: UnicodeString): Boolean;
318 | begin
319 | Result := (S <> '') and SCharCR(S[Length(S)]);
320 | end;
321 |
322 | function SetStringW(Buf: Pointer; Len: Integer; SwapUnicode: boolean): UnicodeString;
323 | begin
324 | Result:= '';
325 | if Len<2 then Exit;
326 |
327 | SetLength(Result, Len div 2);
328 | Move(Buf^, Result[1], Len);
329 | if SwapUnicode then
330 | Result:= SSwapEndian(Result);
331 | end;
332 |
333 | function SFileExtensionMatch(const FN, ExtList: string): boolean;
334 | begin
335 | Result:= false;
336 | end;
337 |
338 | end.
339 |
--------------------------------------------------------------------------------
/help_delphi/source/Usage Methods.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Usage: Methods
6 |
7 |
8 |
9 |
10 |
Methods
11 |
12 |
13 |
14 |
15 |
function Open(const AFileName: WideString; ARedraw: Boolean = True): Boolean;
16 | Opens a file and optionally redraws control.
17 | Result is True if file was successfully opened
18 | or False if file was not found or other open error occured.
19 | Pass the empty AFileName string to close the currently open file.
20 | Note:
21 |
22 |
ARedraw parameter must be set to False in the case you create ATBinHex
23 | object at run-time and then call Open('')/OpenStream(nil) in your destructor
24 | to free data. In this case the control must not be redrawn
25 | because this will cause its parent access error.
26 |
27 |
28 |
29 |
30 |
function OpenStream(AStream: TStream; ARedraw: Boolean = True): Boolean;
31 | Opens a stream and optionally redraws control.
32 | Result is True if stream was successfully opened.
33 | Pass nil to stop use the currently used stream.
34 | Notes:
35 |
36 |
See note for Open.
37 |
Stream is not freed automatically, you should free it by yourself,
38 | but only after you call OpenStream(nil).
39 |
In Delphi 5 TStream.Size is declared as Longint,
40 | so if you are going to open streams larger than 2 Gb, you should
41 | use newer Delphi versions which declare TStream.Size as Int64.
42 |
43 |
44 |
45 |
46 |
procedure Reload;
47 | Reloads current file or stream.
48 |
49 |
50 |
51 |
function FindFirst(const AText: WideString; AOptions: TATStreamSearchOptions): Boolean;
52 | Starts text search.
53 | AText: text to search (Note: Unicode string must be in the Little-Endian format).
54 | AOptions: search options that are set of flags:
55 |
56 |
asoWholeWords: Search for whole words only
57 |
asoCaseSens: Case-sensitive search
58 |
asoBackward: Backward search (Note: not supported for RegEx search)
59 |
asoRegEx: RegEx (regular expressions) search
60 |
asoRegExMLine: Multiline regex search (used with asoRegEx)
61 |
asoFromPage: Starts search from the current page, otherwise in entire file
62 |
asoShowAll: Highlights all occurances of search string
63 |
64 | Result is True if text was found.
65 | Match position and length are saved in SearchResultStart and SearchResultLength properties.
66 | You should manually highlight found match using SetSelection method.
67 | Notes:
68 |
69 |
RegEx search (asoRegEx option) is available only when RegEx library is compiled in.
70 | See ATStreamSearchOptions.inc file.
71 |
Unicode-named files can be handled during search only when Tnt Unicode
72 | Controls are compiled in. See ATStreamSearchOptions.inc file.
73 |
When non-RegEx search is performed, two
74 | different search functions are used: one for 1-byte Text/Binary/Hex
75 | modes and other for Unicode modes; they give different search results.
76 |
77 |
78 |
79 |
80 |
function FindNext(AFindPrevious: Boolean = False): Boolean;
81 | Continues text search.
82 | AFindPrevious: continue search in reverse direction (Note: not supported for RegEx search).
83 | Result is the same as for FindFirst method.
84 | Note:
85 |
86 |
After you change view mode or reload a file, you cannot continue search immediately,
87 | you must first call FindFirst.
88 |
89 |
90 |
91 |
92 |
procedure CopyToClipboard(AsHex: Boolean = False);
93 | Copies current selection (AnsiString or WideString depending on current view mode)
94 | to Clipboard.
95 | AsHex may be True in Text/Binary/Hex modes, in this case
96 | the hex-encoded string (bytes in the hex form separated by spaces) will be
97 | copied.
98 | Notes:
99 |
100 |
This procedure may fail and show an error message if selection is too big to fit in memory.
101 |
To prevent visual "hanging" during copying of too large block,
102 | data size is internally limited by MaxClipboardDataSizeMb value.
103 |
104 |
105 |
106 |
107 |
procedure SetSelection(const AStart, ALength: Int64; AScroll: Boolean; AFireEvent: Boolean = True; ARedraw: Boolean = True);
108 | Sets selection and optionally scrolls control to selection start.
109 | AStart: selection start (0-based),
110 | ALength: selection length,
111 | AScroll: scroll control to selection start afterwards,
112 | AFireEvent: fire the OnSelectionChange event afterwards,
113 | ARedraw: redraw control afterwards.
114 | Note:
115 |
116 |
If AScroll = True, control will be scrolled using the code:
117 |
procedure Scroll(const APos: Int64; AIndentVert, AIndentHorz: integer; ARedraw: Boolean = True);
123 | Scrolls control to specified position.
124 | Control will be scrolled vertically so that position APos (0-based) is visible
125 | by AIndentVert lines lower than top border;
126 | if after that the position is still out of screen, control will be
127 | scrolled horizontally so that position is visible by AIndentHorz chars righter than left border.
128 | ARedraw: allow to redraw control afterwards.
129 |
prPageNums: prints pages from AFromPage to AToPage.
154 |
155 | ACopies: number of print copies,
156 | ACaption: caption of print job.
157 | Notes:
158 |
159 |
This method shows "Print preview" form only when ATPrintPreview component
160 | is used by enabling the "PREVIEW" define in ATBinHexOptions.inc.
161 | Otherwise it just prints the text without questions.
162 |
Resulting page sizes are affected by Margin* properties
163 | and printer page sizes, not by visible control size.
164 |
165 |
166 |
167 |
168 |
procedure PrintPreview;
169 | Shows "Print preview" dialog for current selection.
170 | When text is selected (SelLength <> 0), this method calls
171 | Print(prSelection), otherwise it calls Print(prAllPages).
172 | Note:
173 |
174 |
This method works only when ATPrintPreview component is used
175 | by enabling the "PREVIEW" define in ATBinHexOptions.inc.
176 | Otherwise it does nothing.
177 |
178 |
179 |
180 |
181 |
function IncreaseFontSize(AIncrement: Boolean): Boolean;
182 | Increases (AIncrement = True) or decreases current font size.
183 | Result is True if font size was changed or False if minimal
184 | or maximal size value is already set.
185 | Note:
186 |
187 |
For raster fonts (the default OEM font is raster)
188 | this size change is not simple increment by one.
189 |
190 |
191 |
192 |
193 |
procedure TextEncodingsMenu(AX, AY: Integer);
194 | Shows menu of all available encodings for the current mode.
195 | Menu is shown at point (AX, AY).
196 | Note:
197 |
198 |
In Unicode modes this method displays the special Unicode menu,
199 | which contains only "UTF-16 LE" and "UTF-16 BE" items.
200 |
Current text encoding.
30 | Used in non-Unicode modes.
31 | Possible values:
32 |
33 |
vencANSI: ANSI (locale dependent)
34 |
vencOEM: OEM (locale dependent)
35 |
vencEBCDIC: IBM EBCDIC US
36 |
vencKOI8: KOI8-R
37 |
vencISO: ISO (locale dependent)
38 |
vencMac: Mac (locale dependent)
39 |
plus many others, see the complete list in ATxCodepages.pas.
40 |
41 | Notes:
42 |
43 |
When encoding is OEM, text may be drawn using different font, see FontOEM.
44 |
Technical notes:
45 |
46 |
ANSI, OEM, EBCDIC, KOI8, ISO, Mac encodings are always available.
47 |
EBCDIC, KOI8, ISO, Mac encodings are used via MultiByteToWideChar API, if possible.
48 | But if they are not installed on OS (for example, on Win9x),
49 | then the hardcoded codepages are used.
50 |
All other encodings are used via MultiByteToWideChar API,
51 | they are available only when installed on OS.
52 |
53 |
54 |
55 |
56 |
57 |
TextEncodingName (public, read-only)
58 |
Name of current text encoding.
59 | Note:
60 |
61 |
It can be read in all modes, even in Unicode.
62 | In Unicode modes is will show "UTF-16 LE" or "UTF-16 BE".
63 |
64 |
65 |
66 |
67 |
TextWrap
68 |
Enables word wrap.
69 | Works in Text and Unicode modes.
70 |
Enables width auto-fit in fixed-length modes.
93 |
94 |
TextWidthFit: Binary mode.
95 |
TextWidthFitHex: Hex mode.
96 |
TextWidthFitUHex: Unicode/Hex mode.
97 |
98 | Note:
99 |
100 |
These properties work correctly only with monospaced fonts.
101 | With fonts of variable width you can get text partially
102 | not fitting in the control.
103 |
Text indents, used when text is highlighted with successfull FindText / FindNext methods call.
112 |
113 |
TextSearchIndentVert: number of lines above selection.
114 |
TextSearchIndentHorz: average number of chars lefter than selection.
115 |
116 |
117 |
118 |
119 |
TextTabSize
120 |
Tabulation (#9) size.
121 |
122 |
123 |
124 |
TextOemSpecial
125 |
Enables usage of special OEM font (when TextEncoding = vencOEM).
126 | Note:
127 |
128 |
This property should be set to True only on older Win9x systems.
129 | NT systems support displaying of OEM text in Unicode
130 | (using MultiByteToWideChar API and Unicode fonts),
131 | so special OEM font is not needed.
132 |
Enables repositioning at the file end, if previous view position was also at the end.
255 |
Sets "simple" notification mode. In this mode
256 | file is just checked by timer, no FindFirstChangeNotification API is used.
257 | This is recommended for network files (API doesn't work for this case).
258 |
Timer interval for "simple" notification mode, default is 1000 msec.
259 |
260 |
261 |
262 |
263 |
264 |
TextPopupCommands
265 |
Set of commands visible in the popup (right-click) menu.
266 | Commands available:
267 |
268 |
vpCmdCopy: Copy selection to Clipboard.
269 |
vpCmdCopyHex: Copy selection in hex form in Hex mode.
270 |
Captions of popup (right-click) menu items.
279 | For possible values of AIndex see TextPopupCommands.
280 |
281 |
282 |
283 |
284 |
MaxLengths[AIndex: TATBinHexMode] (public)
285 |
Maximal line lengths.
286 | These values are for all view modes of ATBinHex control: Text, Binary, Hex, Unicode.
287 | They set internal values that define the maximal length of a single string in a file.
288 | Values are 300 by default.
289 | For example, you may set MaxLengths[vbmodeText] to 1000 if user needs to work
290 | with strings of length 1000 in Text mode. Notes:
291 |
292 |
Larger values increase size of memory buffer for a file, and slow down file reading.
293 |
Values are applied after file reopening, e.g. after calling Open/OpenStream/Reload methods
294 | and after changing Mode property.
295 |
296 |
297 |
298 |
MaxClipboardDataSizeMb (public)
299 |
Maximal data size (in Mb) for copying to Clipboard.
300 | Default value is 16 (Mb), which prevents visual "hanging" when too large block
301 | is selected accidentally before copying.
302 |
Line number (1-based, 0 if line number is not found).
346 |
347 | Notes for line numbers:
348 |
349 |
Lines are separated by: #13#10, #13, #10.
350 |
Line numbers are counted only for the first portion of file
351 | (see TextGutterLines*).
352 |
Line numbers are counted for the "current" copy of file,
353 | they may be incorrect if file was changed (and not reloaded)
354 | since the last display.
355 |