This commit is contained in:
mysticbbs 2013-05-06 13:19:20 -04:00
parent 0eb4d5760f
commit de20817ca8
5 changed files with 181 additions and 30 deletions

View File

@ -125,7 +125,7 @@ Procedure TNLOG (Str: String);
Var Var
T : Text; T : Text;
Begin Begin
Assign (T, 'tnlog.txt'); Assign (T, 'sockdebug.txt');
{$I-} Append(T); {$I+} {$I-} Append(T); {$I+}
If IoResult <> 0 Then ReWrite(T); If IoResult <> 0 Then ReWrite(T);
@ -579,7 +579,15 @@ Begin
SIN.sin_addr.s_addr := 0; SIN.sin_addr.s_addr := 0;
SIN.sin_port := htons(Port); SIN.sin_port := htons(Port);
fpBind(FSocketHandle, @SIN, SizeOf(SIN)); {$IFDEF TNDEBUG}
TNLOG('WaitInit Bind');
If fpBind(FSocketHandle, @SIN, SizeOf(SIN)) <> 0 Then
TNLOG('WaitInit Bind Failed')
Else
TNLOG('Bind OK');
{$ELSE}
fpBind(FSocketHandle, @SIN, SizeOf(SIN));
{$ENDIF}
SetBlocking(True); SetBlocking(True);
End; End;

View File

@ -14,7 +14,7 @@ Const
Type Type
TSTDIO = Class(TIOBase) TSTDIO = Class(TIOBase)
Constructor Create; Constructor Create; Override;
Destructor Destroy; Override; Destructor Destroy; Override;
Function DataWaiting : Boolean; Override; Function DataWaiting : Boolean; Override;
Function WriteBuf (Var Buf; Len: LongInt) : LongInt; Override; Function WriteBuf (Var Buf; Len: LongInt) : LongInt; Override;

View File

@ -64,10 +64,12 @@
{$IMPLICITEXCEPTIONS OFF} {$IMPLICITEXCEPTIONS OFF}
{$OBJECTCHECKS OFF} {$OBJECTCHECKS OFF}
{$IFDEF CPUX86_64 {$IFDEF CPU386}
{$FPUTYPE SSE64} {$IFDEF CPUX86_64
{$ELSE} {$FPUTYPE SSE64}
{$FPUTYPE SSE} {$ELSE}
{$FPUTYPE SSE}
{$ENDIF}
{$ENDIF} {$ENDIF}
{$IFDEF DEBUG} {$IFDEF DEBUG}

View File

@ -131,6 +131,7 @@ End;
Const Const
AnsiTable : String[8] = '04261537'; AnsiTable : String[8] = '04261537';
(*
Function TOutputLinux.AttrToAnsi (Attr: Byte) : String; Function TOutputLinux.AttrToAnsi (Attr: Byte) : String;
Var Var
Str : String[16]; Str : String[16];
@ -187,6 +188,66 @@ Begin
FTextAttr := FG + BG * 16; FTextAttr := FG + BG * 16;
AttrToAnsi := #27 + '[' + Str + 'm'; AttrToAnsi := #27 + '[' + Str + 'm';
End; End;
*)
Function TOutputLinux.AttrToAnsi (Attr: Byte) : String;
Var
OldFG : LongInt;
OldBG : LongInt;
FG : LongInt;
BG : LongInt;
Procedure AddSep (Ch: Char);
Begin
If Length(Result) > 0 Then
Result := Result + ';';
Result := Result + Ch;
End;
Begin
Result := '';
If Attr = FTextAttr Then Exit;
FG := Attr and $F;
BG := Attr shr 4;
OldFG := FTextAttr and $F;
OldBG := FTextAttr shr 4;
If (OldFG <> 7) or (FG = 7) or ((OldFG > 7) and (FG < 8)) or ((OldBG > 7) and (BG < 8)) Then Begin
Result := '0';
OldFG := 7;
OldBG := 0;
End;
If (FG > 7) and (OldFG < 8) Then Begin
AddSep('1');
OldFG := OldFG or 8;
End;
If (BG and 8) <> (OldBG and 8) Then Begin
AddSep('5');
OldBG := OldBG or 8;
End;
If (FG <> OldFG) Then Begin
AddSep('3');
Result := Result + AnsiTable[(FG and 7) + 1];
End;
If (BG <> OldBG) Then Begin
AddSep('4');
Result := Result + AnsiTable[(BG and 7) + 1];
End;
FTextAttr := FG + BG * 16;
Result := #27 + '[' + Result + 'm';
End;
Procedure TOutputLinux.BufFlush; Procedure TOutputLinux.BufFlush;
Begin Begin
@ -213,7 +274,7 @@ Begin
BufAddStr(AttrToAnsi(Attr)); BufAddStr(AttrToAnsi(Attr));
FTextAttr := Attr; // FTextAttr := Attr;
End; End;
Procedure TOutputLinux.CursorXYRaw (X, Y: Byte); Procedure TOutputLinux.CursorXYRaw (X, Y: Byte);
@ -362,10 +423,14 @@ Begin
If FCursorY < FWinBot Then If FCursorY < FWinBot Then
Inc (FCursorY) Inc (FCursorY)
Else Else Begin
ScrollWindow; ScrollWindow;
BufFlush;
End;
// Else
// ScrollWindow;
BufFlush; // BufFlush;
End; End;
End; End;
End; End;

View File

@ -1,7 +1,7 @@
{$I M_OPS.PAS}
Unit m_Output_Windows; Unit m_Output_Windows;
{$I M_OPS.PAS}
Interface Interface
Uses Uses
@ -107,6 +107,7 @@ Begin
50 : ScreenSize := 50; 50 : ScreenSize := 50;
Else Else
SetScreenSize(25); SetScreenSize(25);
ScreenSize := 25; ScreenSize := 25;
End; End;
@ -167,6 +168,22 @@ Begin
SetConsoleCursorPosition(ConOut, Cursor); SetConsoleCursorPosition(ConOut, Cursor);
End; End;
Procedure TOutputWindows.ClearEOL;
Var
Count : Byte;
Res : LongInt;
Begin
Count := Window.Right - Cursor.X + 1;
FillDWord (Buffer[Cursor.Y + 1][Cursor.X + 1], Count, (Word(TextAttr) SHL 16) OR Word($0020));
If Active Then Begin
FillConsoleOutputCharacter (ConOut, ' ', Count, Cursor, @Res);
FillConsoleOutputAttribute (ConOut, TextAttr, Count, Cursor, @Res);
End;
End;
(*
Procedure TOutputWindows.ClearEOL; Procedure TOutputWindows.ClearEOL;
Var Var
Buf : Array[1..80] of TCharInfo; Buf : Array[1..80] of TCharInfo;
@ -191,7 +208,7 @@ Begin
FillConsoleOutputAttribute (ConOut, TextAttr, Count, Cursor, @Res); FillConsoleOutputAttribute (ConOut, TextAttr, Count, Cursor, @Res);
End; End;
End; End;
*)
Procedure TOutputWindows.ClearScreenNoUpdate; Procedure TOutputWindows.ClearScreenNoUpdate;
Var Var
Res : ULong; Res : ULong;
@ -261,7 +278,6 @@ Begin
Inc (Count); Inc (Count);
End; End;
// add to screen buffer
Move (Buf[1], Buffer[Y][X], (Count - 1) * SizeOf(TCharInfo)); Move (Buf[1], Buffer[Y][X], (Count - 1) * SizeOf(TCharInfo));
If Active Then Begin If Active Then Begin
@ -342,6 +358,7 @@ Begin
If (Code = '00') or ((CodeNum > 0) and (CodeNum < 24) and (Code[1] <> '$') and (Code[1] <> '&')) Then Begin If (Code = '00') or ((CodeNum > 0) and (CodeNum < 24) and (Code[1] <> '$') and (Code[1] <> '&')) Then Begin
Inc (Count, 2); Inc (Count, 2);
If CodeNum in [00..15] Then If CodeNum in [00..15] Then
Attr := CodeNum + ((Attr SHR 4) AND 7) * 16 Attr := CodeNum + ((Attr SHR 4) AND 7) * 16
Else Else
@ -388,6 +405,76 @@ Begin
CursorY := Cursor.Y + 1; CursorY := Cursor.Y + 1;
End; End;
Procedure TOutputWindows.WriteChar (Ch: Char);
Var
BufferSize,
BufferCoord : TCoord;
WriteRegion : TSmallRect;
OneCell : TCharInfo;
// Res : LongInt;
Begin
Case Ch of
#08 : If Cursor.X > Window.Left Then Begin
Dec(Cursor.X);
If Active Then SetConsoleCursorPosition(ConOut, Cursor);
End;
#10 : Begin
If Cursor.Y = Window.Bottom Then
ScrollWindow
Else Begin
Inc (Cursor.Y);
Cursor.X := Window.Left;
End;
If Active Then SetConsoleCursorPosition(ConOut, Cursor);
End;
#13 : Cursor.X := Window.Left;
Else
If Active Then Begin
OneCell.UnicodeChar := Ch;
OneCell.Attributes := TextAttr;
BufferSize.X := 1;
BufferSize.Y := 1;
BufferCoord.X := 0;
BufferCoord.Y := 0;
WriteRegion.Left := Cursor.X;
WriteRegion.Top := Cursor.Y;
WriteRegion.Right := Cursor.X;
WriteRegion.Bottom := Cursor.Y;
// FillConsoleOutputCharacter (ConOut, Ch, 1, Cursor, @Res);
// FillConsoleOutputAttribute (ConOut, TextAttr, 1, Cursor, @Res);
WriteConsoleOutput (ConOut, @OneCell, BufferSize, BufferCoord, WriteRegion);
End;
Buffer[Cursor.Y + 1][Cursor.X + 1].UnicodeChar := Ch;
Buffer[Cursor.Y + 1][Cursor.X + 1].Attributes := TextAttr;
If Cursor.X < Window.Right Then
Inc (Cursor.X)
Else Begin
If (Cursor.X = Window.Right) And (Cursor.Y = Window.Bottom - 1) Then Begin
Inc (Cursor.X);
Exit;
End;
Cursor.X := Window.Left;
If Cursor.Y = Window.Bottom Then
ScrollWindow
Else
Inc (Cursor.Y);
End;
If Active Then SetConsoleCursorPosition(ConOut, Cursor);
End;
End;
(*
Procedure TOutputWindows.WriteChar (Ch: Char); Procedure TOutputWindows.WriteChar (Ch: Char);
Var Var
BufferSize, BufferSize,
@ -451,6 +538,7 @@ Begin
If Active Then SetConsoleCursorPosition(ConOut, Cursor); If Active Then SetConsoleCursorPosition(ConOut, Cursor);
End; End;
End; End;
*)
Procedure TOutputWindows.WriteLine (Str: String); Procedure TOutputWindows.WriteLine (Str: String);
Var Var
@ -470,32 +558,20 @@ End;
Procedure TOutputWindows.ScrollWindow; Procedure TOutputWindows.ScrollWindow;
Var Var
ClipRect,
ScrollRect : TSmallRect;
DestCoord : TCoord; DestCoord : TCoord;
Fill : TCharInfo; Fill : TCharInfo;
Begin Begin
Fill.UnicodeChar := ' '; Fill.UnicodeChar := ' ';
// Fill.Attributes := TextAttr; Fill.Attributes := 7;
Fill.Attributes := 7;
ScrollRect.Left := Window.Left;
ScrollRect.Top := Window.Top;
ScrollRect.Right := Window.Right;
ScrollRect.Bottom := Window.Bottom;
// might not need cliprect... might be able to pass scrollrect twice
ClipRect := ScrollRect;
DestCoord.X := Window.Left; DestCoord.X := Window.Left;
DestCoord.Y := Window.Top - 1; DestCoord.Y := Window.Top - 1;
If Active Then If Active Then
ScrollConsoleScreenBuffer(ConOut, ScrollRect, ClipRect, DestCoord, PCharInfo(@Fill)^); ScrollConsoleScreenBuffer(ConOut, Window, Window, DestCoord, Fill);
Move (Buffer[2][1], Buffer[1][1], SizeOf(TConsoleLineRec) * 49); Move (Buffer[2][1], Buffer[1][1], SizeOf(TConsoleLineRec) * 49);
FillChar(Buffer[Window.Bottom + 1][1], SizeOf(TConsoleLineRec), #0); FillChar (Buffer[Window.Bottom + 1][1], SizeOf(TConsoleLineRec), #0);
End; End;
Procedure TOutputWindows.GetScreenImage (X1, Y1, X2, Y2: Byte; Var Image: TConsoleImageRec); Procedure TOutputWindows.GetScreenImage (X1, Y1, X2, Y2: Byte; Var Image: TConsoleImageRec);