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
93 begin
99 begin
100 // we have to make some room; delete top line for this
102 begin
116 begin
121 // ////////////////////////////////////////////////////////////////////////// //
122 // warning! don't modify conbuf while the range is active!
125 procedure cbufPrev (var pos: LongWord); inline; begin pos := (pos+ConBufSize-1) mod ConBufSize; end;
128 function cbufAt (const pos: LongWord): Char; inline; begin result := cbuf[pos mod ConBufSize]; end;
131 // ////////////////////////////////////////////////////////////////////////// //
133 var
135 begin
137 begin
140 exit;
145 begin
155 var
157 begin
160 if (pos = cbufhead) or (cbuf[pos] <> #10) then begin sp := cbufhead; ep := cbufhead+1; result := false; exit; end;
163 begin
174 begin
183 begin