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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE a_modes.inc}
17 {.$MODE OBJFPC}
20 interface
35 // get last line
37 // move one line up; `sp` and `ep` MUST be valid values from previous call to `cbufLastLine()`
42 var
47 implementation
50 // ////////////////////////////////////////////////////////////////////////// //
51 //const ConBufSize = 64;
54 // each line in buffer ends with '\n'; we don't keep offsets or lengthes, as
55 // it's fairly easy to search in buffer, and drawing console is not a common
56 // thing, so it doesn't have to be superfast.
57 var
67 // ////////////////////////////////////////////////////////////////////////// //
68 var
72 var
75 begin
77 begin
79 begin
81 begin
83 begin
94 begin
100 begin
101 // we have to make some room; delete top line for this
103 begin
117 begin
122 // ////////////////////////////////////////////////////////////////////////// //
123 // warning! don't modify conbuf while the range is active!
126 procedure cbufPrev (var pos: LongWord); inline; begin pos := (pos+ConBufSize-1) mod ConBufSize; end;
129 function cbufAt (const pos: LongWord): Char; inline; begin result := cbuf[pos mod ConBufSize]; end;
132 // ////////////////////////////////////////////////////////////////////////// //
134 var
136 begin
138 begin
141 exit;
146 begin
156 var
158 begin
161 if (pos = cbufhead) or (cbuf[pos] <> #10) then begin sp := cbufhead; ep := cbufhead+1; result := false; exit; end;
164 begin
175 begin
184 begin