1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE a_modes.inc}
16 {.$MODE OBJFPC}
19 interface
34 // get last line
36 // move one line up; `sp` and `ep` MUST be valid values from previous call to `cbufLastLine()`
41 var
46 implementation
49 // ////////////////////////////////////////////////////////////////////////// //
50 //const ConBufSize = 64;
53 // each line in buffer ends with '\n'; we don't keep offsets or lengthes, as
54 // it's fairly easy to search in buffer, and drawing console is not a common
55 // thing, so it doesn't have to be superfast.
56 var
66 // ////////////////////////////////////////////////////////////////////////// //
67 var
71 var
74 begin
76 begin
78 begin
80 begin
82 begin
95 begin
101 begin
102 // we have to make some room; delete top line for this
104 begin
118 begin
123 // ////////////////////////////////////////////////////////////////////////// //
124 // warning! don't modify conbuf while the range is active!
127 procedure cbufPrev (var pos: LongWord); inline; begin pos := (pos+ConBufSize-1) mod ConBufSize; end;
130 function cbufAt (const pos: LongWord): Char; inline; begin result := cbuf[pos mod ConBufSize]; end;
133 // ////////////////////////////////////////////////////////////////////////// //
135 var
137 begin
139 begin
142 exit;
147 begin
157 var
159 begin
162 if (pos = cbufhead) or (cbuf[pos] <> #10) then begin sp := cbufhead; ep := cbufhead+1; result := false; exit; end;
165 begin
176 begin
185 begin