X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fshared%2Fconbuf.pas;h=a3a7ecde8c1a53f7ee7da6e1849b69f5618e1dfb;hb=7301e8529da2fdfdae50653f91c1f9597df65541;hp=581a8818b5f1672a6a5047e9ea1d0e2d87bf2c02;hpb=5472594f32e33da0c66606ec9eebc8f798ef6b54;p=d2df-sdl.git diff --git a/src/shared/conbuf.pas b/src/shared/conbuf.pas index 581a881..a3a7ecd 100644 --- a/src/shared/conbuf.pas +++ b/src/shared/conbuf.pas @@ -1,4 +1,4 @@ -(* 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 @@ -13,7 +13,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 +27,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 +39,10 @@ function cbufLineUp (var sp: LongWord; var ep: LongWord): Boolean; procedure cbufClear (); +var + conbufDumpToStdOut: Boolean = false; + conbufConPrefix: Boolean = true; + implementation @@ -60,6 +65,9 @@ function cbufLastChange (): LongWord; begin result := changeCount; end; // ////////////////////////////////////////////////////////////////////////// // +var + needCon: Boolean = true; + procedure cbufPutChars (buf: PChar; count: Integer); var np: LongWord; @@ -67,6 +75,19 @@ var begin if count > 0 then begin + if conbufDumpToStdOut then + begin + 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; Inc(changeCount); if changeCount = 0 then changeCount := 1; while count > 0 do @@ -102,10 +123,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; // ////////////////////////////////////////////////////////////////////////// //