X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fshared%2Fconbuf.pas;h=bc7a8f7d7054803327859f9522af7e5ac138b4be;hb=987c4a835a103345b59937e8e1be8524a6228712;hp=57ed64431cab091c167ee4052c82f239446909ff;hpb=cd1240f995a9e5be94fe308e9b52b0cc7763d843;p=d2df-sdl.git diff --git a/src/shared/conbuf.pas b/src/shared/conbuf.pas index 57ed644..bc7a8f7 100644 --- a/src/shared/conbuf.pas +++ b/src/shared/conbuf.pas @@ -1,9 +1,8 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * the Free Software Foundation, version 3 of the License ONLY. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,7 +12,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . *) -{$MODE OBJFPC} +{$INCLUDE a_modes.inc} +{.$MODE OBJFPC} unit conbuf; interface @@ -26,10 +26,10 @@ function cbufLastChange (): LongWord; function cbufWalkStart (): LongWord; function cbufWalkEnd (pos: LongWord): LongWord; -procedure cbufPrev (var pos: LongWord); -procedure cbufNext (var pos: LongWord); +procedure cbufPrev (var pos: LongWord); inline; +procedure cbufNext (var pos: LongWord); inline; -function cbufAt (const pos: LongWord): Char; +function cbufAt (const pos: LongWord): Char; inline; // get last line procedure cbufLastLine (var sp: LongWord; var ep: LongWord); @@ -38,6 +38,10 @@ function cbufLineUp (var sp: LongWord; var ep: LongWord): Boolean; procedure cbufClear (); +var + conbufDumpToStdOut: Boolean = false; + conbufConPrefix: Boolean = true; + implementation @@ -60,10 +64,9 @@ function cbufLastChange (): LongWord; begin result := changeCount; end; // ////////////////////////////////////////////////////////////////////////// // -{$IFDEF HEADLESS} var needCon: Boolean = true; -{$ENDIF} + procedure cbufPutChars (buf: PChar; count: Integer); var np: LongWord; @@ -71,15 +74,19 @@ var begin if count > 0 then begin -{$IFDEF HEADLESS} - //write(stderr, 'CON: '); - for np := 0 to count-1 do + if conbufDumpToStdOut then begin - if needCon then begin write(stdout, 'CON: '); needCon := false; end; - write(stdout, buf[np]); - needCon := (buf[np] = #10); + for np := 0 to count-1 do + begin + if needCon then + begin + if conbufConPrefix then write(stdout, 'CON: '); + needCon := false; + end; + write(stdout, buf[np]); + needCon := (buf[np] = #10); + end; end; -{$ENDIF} Inc(changeCount); if changeCount = 0 then changeCount := 1; while count > 0 do @@ -115,10 +122,10 @@ end; // warning! don't modify conbuf while the range is active! function cbufWalkStart (): LongWord; begin result := cbuftail; end; function cbufWalkEnd (pos: LongWord): LongWord; begin result := cbufhead; end; -procedure cbufPrev (var pos: LongWord); begin pos := (pos+ConBufSize-1) mod ConBufSize; end; -procedure cbufNext (var pos: LongWord); begin pos := (pos+1) mod ConBufSize; end; +procedure cbufPrev (var pos: LongWord); inline; begin pos := (pos+ConBufSize-1) mod ConBufSize; end; +procedure cbufNext (var pos: LongWord); inline; begin pos := (pos+1) mod ConBufSize; end; -function cbufAt (const pos: LongWord): Char; begin result := cbuf[pos mod ConBufSize]; end; +function cbufAt (const pos: LongWord): Char; inline; begin result := cbuf[pos mod ConBufSize]; end; // ////////////////////////////////////////////////////////////////////////// //