Moved / cleaned up CheckNodeMessages function

This commit is contained in:
mysticbbs 2012-02-22 02:31:05 -05:00
parent 2d8602426f
commit bba8ac7cd9
6 changed files with 185 additions and 148 deletions

View File

@ -248,14 +248,15 @@ Begin
Else Begin Else Begin
Inc (CurY); Inc (CurY);
Inc (CurLine); Inc (CurLine);
UpdatePosition; UpdatePosition;
End; End;
End; End;
Procedure keyUpArrow (EOL: Boolean); Procedure keyUpArrow (MoveToEOL: Boolean);
Begin Begin
If CurLine > 1 Then Begin If CurLine > 1 Then Begin
If EOL then begin If MoveToEOL Then Begin
CurX := Length(Session.Msgs.MsgText[CurLine - 1]) + 1; CurX := Length(Session.Msgs.MsgText[CurLine - 1]) + 1;
If CurX > WrapPos Then CurX := WrapPos + 1; If CurX > WrapPos Then CurX := WrapPos + 1;
End; End;
@ -265,6 +266,7 @@ Begin
Else Begin Else Begin
Dec (CurY); Dec (CurY);
Dec (CurLine); Dec (CurLine);
UpdatePosition; UpdatePosition;
End; End;
End; End;
@ -272,12 +274,14 @@ End;
Procedure keyBackspace; Procedure keyBackspace;
Var Var
A : Integer; Count : Integer;
Begin Begin
If CurX > 1 Then Begin If CurX > 1 Then Begin
Session.io.OutBS(1, True); Session.io.OutBS(1, True);
Dec (CurX); Dec (CurX);
Delete (Session.Msgs.MsgText[CurLine], CurX, 1); Delete (Session.Msgs.MsgText[CurLine], CurX, 1);
If CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Then Begin If CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Then Begin
Print (Copy(Session.Msgs.MsgText[CurLine], CurX, Length(Session.Msgs.MsgText[CurLine])) + ' '); Print (Copy(Session.Msgs.MsgText[CurLine], CurX, Length(Session.Msgs.MsgText[CurLine])) + ' ');
UpdatePosition; UpdatePosition;
@ -285,22 +289,31 @@ Begin
End Else End Else
If CurLine > 1 Then Begin If CurLine > 1 Then Begin
If Length(Session.Msgs.MsgText[CurLine - 1]) + Length(Session.Msgs.MsgText[CurLine]) <= WrapPos Then Begin If Length(Session.Msgs.MsgText[CurLine - 1]) + Length(Session.Msgs.MsgText[CurLine]) <= WrapPos Then Begin
CurX := Length(Session.Msgs.MsgText[CurLine - 1]) + 1; CurX := Length(Session.Msgs.MsgText[CurLine - 1]) + 1;
Session.Msgs.MsgText[CurLine - 1] := Session.Msgs.MsgText[CurLine - 1] + Session.Msgs.MsgText[CurLine]; Session.Msgs.MsgText[CurLine - 1] := Session.Msgs.MsgText[CurLine - 1] + Session.Msgs.MsgText[CurLine];
DeleteLine (CurLine); DeleteLine (CurLine);
Dec (CurLine); Dec (CurLine);
Dec (CurY); Dec (CurY);
If CurY < WinStart Then TextRefreshFull Else TextRefreshPart; If CurY < WinStart Then TextRefreshFull Else TextRefreshPart;
End Else End Else
If Pos(' ', Session.Msgs.MsgText[CurLine]) > 0 Then Begin If Pos(' ', Session.Msgs.MsgText[CurLine]) > 0 Then Begin
For A := Length(Session.Msgs.MsgText[CurLine]) DownTo 1 Do
If (Session.Msgs.MsgText[CurLine][A] = ' ') and (Length(Session.Msgs.MsgText[CurLine - 1]) + A - 1 <= WrapPos) Then Begin For Count := Length(Session.Msgs.MsgText[CurLine]) DownTo 1 Do
If (Session.Msgs.MsgText[CurLine][Count] = ' ') and (Length(Session.Msgs.MsgText[CurLine - 1]) + Count - 1 <= WrapPos) Then Begin
CurX := Length(Session.Msgs.MsgText[CurLine - 1]) + 1; CurX := Length(Session.Msgs.MsgText[CurLine - 1]) + 1;
Session.Msgs.MsgText[CurLine - 1] := Session.Msgs.MsgText[CurLine - 1] + Copy(Session.Msgs.MsgText[CurLine], 1, A - 1);
Delete (Session.Msgs.MsgText[CurLine], 1, A); Session.Msgs.MsgText[CurLine - 1] := Session.Msgs.MsgText[CurLine - 1] + Copy(Session.Msgs.MsgText[CurLine], 1, Count - 1);
Delete (Session.Msgs.MsgText[CurLine], 1, Count);
Dec (CurLine); Dec (CurLine);
Dec (CurY); Dec (CurY);
If CurY < WinStart Then TextRefreshFull Else TextRefreshPart; If CurY < WinStart Then TextRefreshFull Else TextRefreshPart;
Exit; Exit;
End; End;
@ -310,25 +323,62 @@ Begin
End; End;
Procedure keyLeftArrow; Procedure keyLeftArrow;
begin Begin
if curx > 1 then Begin If CurX > 1 Then Begin
Dec (CurX); Dec (CurX);
UpdatePosition; UpdatePosition;
end else End Else
keyUpArrow(true); keyUpArrow(True);
End; End;
Procedure keyRightArrow; Procedure keyRightArrow;
Begin Begin
If CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Then Begin If CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Then Begin
Inc (CurX); Inc (CurX);
UpdatePosition; UpdatePosition;
End Else Begin End Else Begin
If CurY < TotalLine Then CurX := 1; If CurY < TotalLine Then CurX := 1;
keyDownArrow; keyDownArrow;
End; End;
End; End;
Procedure keyPageUp;
Begin
If CurLine > 1 Then Begin
If LongInt(CurLine - (WinEnd - WinStart)) >= 1 Then
Dec (CurLine, (WinEnd - WinStart))
Else
CurLine := 1;
TextRefreshFull;
End;
End;
Procedure keyPageDown;
Begin
If CurLine < TotalLine Then Begin
If CurLine + (WinEnd - WinStart) <= TotalLine Then
Inc (CurLine, (WinEnd - WinStart))
Else
CurLine := TotalLine;
TextRefreshFull;
End;
End;
Procedure keyEnd;
Begin
CurX := Length(Session.Msgs.MsgText[CurLine]) + 1;
If CurX > WrapPos Then CurX := WrapPos + 1;
UpdatePosition;
End;
Procedure AddChar (Ch: Char); Procedure AddChar (Ch: Char);
Begin Begin
If InsertMode Then Begin If InsertMode Then Begin
@ -376,7 +426,7 @@ End;
Procedure Quote; Procedure Quote;
Var Var
InFile : Text; InFile : Text;
Start, Start : Integer;
Finish : Integer; Finish : Integer;
NumLines : Integer; NumLines : Integer;
Text : Array[1..mysMaxMsgLines] of String[80]; Text : Array[1..mysMaxMsgLines] of String[80];
@ -431,6 +481,7 @@ Begin
For NumLines := Start to Finish Do Begin For NumLines := Start to Finish Do Begin
If TotalLine = mysMaxMsgLines Then Break; If TotalLine = mysMaxMsgLines Then Break;
If Session.Msgs.MsgText[CurLine] <> '' Then Begin If Session.Msgs.MsgText[CurLine] <> '' Then Begin
Inc (CurLine); Inc (CurLine);
InsertLine (CurLine); InsertLine (CurLine);
@ -466,15 +517,17 @@ Var
Procedure UpdateWindow; Procedure UpdateWindow;
Var Var
A : Integer; Count : Integer;
Begin Begin
Session.io.AnsiGotoXY (1, Session.io.ScreenInfo[2].Y); Session.io.AnsiGotoXY (1, Session.io.ScreenInfo[2].Y);
Session.io.AnsiColor (Session.io.ScreenInfo[2].A); Session.io.AnsiColor (Session.io.ScreenInfo[2].A);
For A := QuoteTopPage to QuoteTopPage + 5 Do Begin For Count := QuoteTopPage to QuoteTopPage + 5 Do Begin
If A <= QuoteLines Then Print (QText[A]); If Count <= QuoteLines Then Print (QText[Count]);
Session.io.AnsiClrEOL; Session.io.AnsiClrEOL;
If A <= QuoteLines Then PrintLn('');
If Count <= QuoteLines Then PrintLn('');
End; End;
UpdateBar(True); UpdateBar(True);
@ -490,6 +543,7 @@ Begin
Assign (InFile, Session.TempPath + 'msgtmp'); Assign (InFile, Session.TempPath + 'msgtmp');
{$I-} Reset(InFile); {$I+} {$I-} Reset(InFile); {$I+}
If IoResult <> 0 Then Exit; If IoResult <> 0 Then Exit;
QuoteLines := 0; QuoteLines := 0;
@ -507,9 +561,12 @@ Begin
If CurY >= Session.io.ScreenInfo[1].Y Then Begin If CurY >= Session.io.ScreenInfo[1].Y Then Begin
Session.io.AnsiColor(WinText); Session.io.AnsiColor(WinText);
Temp1 := WinEnd; Temp1 := WinEnd;
WinEnd := Session.io.ScreenInfo[1].Y; WinEnd := Session.io.ScreenInfo[1].Y;
TextRefreshFull; TextRefreshFull;
WinEnd := Temp1; WinEnd := Temp1;
End; End;
@ -595,7 +652,9 @@ Begin
If QuoteTopPage + QuoteCurLine = QuoteLines Then NoMore := True; If QuoteTopPage + QuoteCurLine = QuoteLines Then NoMore := True;
InsertLine (CurLine); InsertLine (CurLine);
Session.Msgs.MsgText[CurLine] := QText[QuoteTopPage + QuoteCurLine]; Session.Msgs.MsgText[CurLine] := QText[QuoteTopPage + QuoteCurLine];
Inc (CurLine); Inc (CurLine);
Session.io.AnsiColor(WinText); Session.io.AnsiColor(WinText);
@ -605,10 +664,13 @@ Begin
If CurLine - Scroll + WinStart + 4 >= WinEnd Then Begin If CurLine - Scroll + WinStart + 4 >= WinEnd Then Begin
TextRefreshFull; TextRefreshFull;
Scroll := CurLine; Scroll := CurLine;
End Else Begin End Else Begin
Dec (CurLine); Dec (CurLine);
TextRefreshPart; TextRefreshPart;
Inc (CurLine); Inc (CurLine);
Inc (CurY); Inc (CurY);
End; End;
@ -618,10 +680,13 @@ Begin
If QuoteTopPage + QuoteCurLine < QuoteLines Then If QuoteTopPage + QuoteCurLine < QuoteLines Then
If QuoteCurLine = 5 Then Begin If QuoteCurLine = 5 Then Begin
Inc (QuoteTopPage); Inc (QuoteTopPage);
UpdateWindow; UpdateWindow;
End Else Begin End Else Begin
UpdateBar(False); UpdateBar(False);
Inc (QuoteCurLine); Inc (QuoteCurLine);
UpdateBar(True); UpdateBar(True);
End; End;
End; End;
@ -688,40 +753,6 @@ Begin
Until Done; Until Done;
End; End;
Procedure keyPageUp;
Begin
If CurLine > 1 Then Begin
If LongInt(CurLine - (WinEnd - WinStart)) >= 1 Then
Dec (CurLine, (WinEnd - WinStart)) {scroll one page up}
Else
CurLine := 1;
TextRefreshFull;
End;
End;
Procedure keyPageDown;
Begin
If CurLine < TotalLine Then Begin
If CurLine + (WinEnd - WinStart) <= TotalLine Then
Inc (CurLine, (WinEnd - WinStart))
Else
CurLine := TotalLine;
TextRefreshFull;
End;
End;
Procedure keyEnd;
Begin
CurX := Length(Session.Msgs.MsgText[CurLine]) + 1;
If CurX > WrapPos Then CurX := WrapPos + 1;
UpdatePosition;
End;
Var Var
A : Integer; A : Integer;
Begin Begin
@ -848,10 +879,6 @@ Begin
UpdatePosition; UpdatePosition;
End; End;
^W : While (CurX > 1) Do Begin
keyBackSpace;
If Session.Msgs.MsgText[CurLine][CurX] = ' ' Then Break;
End;
^U : Begin ^U : Begin
While CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Do Begin While CurX < Length(Session.Msgs.MsgText[CurLine]) + 1 Do Begin
Inc (CurX); Inc (CurX);
@ -865,10 +892,13 @@ Begin
UpdatePosition; UpdatePosition;
End; End;
^V : ToggleInsert (True); ^V : ToggleInsert (True);
// ^W : ; // delete word left ^W : While (CurX > 1) Do Begin
keyBackSpace;
If Session.Msgs.MsgText[CurLine][CurX] = ' ' Then Break;
End;
^X : keyDownArrow; ^X : keyDownArrow;
^Y : Begin ^Y : Begin
DeleteLine (curline); DeleteLine (CurLine);
TextRefreshPart; TextRefreshPart;
End; End;
^[ : Begin ^[ : Begin

View File

@ -40,7 +40,6 @@ Procedure Voting_Booth (Forced: Boolean; Num: Integer);
Procedure Voting_Result (Data : Integer); Procedure Voting_Result (Data : Integer);
Procedure Voting_Booth_New; Procedure Voting_Booth_New;
Procedure View_History (LastDays: Word); Procedure View_History (LastDays: Word);
Function Check_Node_Message : Boolean;
Procedure View_Directory (Data: String; ViewType: Byte); Procedure View_Directory (Data: String; ViewType: Byte);
Implementation Implementation
@ -892,56 +891,6 @@ Begin
End; End;
End; End;
Function Check_Node_Message : Boolean;
Var
Res : Boolean;
Str : String;
Begin
Check_Node_Message := False;
Res := False;
Assign (NodeMsgFile, Session.TempPath + 'chat.tmp');
FileMode := 66;
{$I-} Reset (NodeMsgFile); {$I+}
If IoResult <> 0 Then Exit;
{ checks for non-teleconference node messages:
2 = system broadcast message (ie, not from user, from mystic)
3 = user to user node message }
While Not Eof(NodeMsgFile) Do Begin
Res := True;
Read (NodeMsgFile, NodeMsg);
Session.io.PromptInfo[1] := NodeMsg.FromWho;
Session.io.PromptInfo[2] := strI2S(NodeMsg.FromNode);
Case NodeMsg.MsgType of
2 : Begin
Session.io.OutFullLn (Session.GetPrompt(179) + NodeMsg.Message);
Session.io.OutFullLn (Session.GetPrompt(180));
End;
3 : Begin
Session.io.OutFullLn (Session.GetPrompt(144) + '|CR' + NodeMsg.Message);
Session.io.OutFull (Session.GetPrompt(145));
End;
End;
End;
Close (NodeMsgFile);
Erase (NodeMsgFile);
If Res And (NodeMsg.MsgType = 3) Then
If Session.io.OneKey(#13 + 'R', True) = 'R' Then Begin
Session.io.OutFullLn(Session.GetPrompt(360));
Str := Session.io.GetInput(79, 79, 11, '');
If Str <> '' Then Send_Node_Message(3, Session.io.PromptInfo[2] + ';' + Str, 0);
End;
Check_Node_Message := Res;
End;
Procedure View_Directory (Data: String; ViewType: Byte); Procedure View_Directory (Data: String; ViewType: Byte);
Const Const
vtMaxList = 1000; vtMaxList = 1000;

View File

@ -1460,7 +1460,7 @@ Var
ReDraw; ReDraw;
End; End;
Procedure Add_Char (Ch : Char); Procedure AddChar (Ch : Char);
Begin Begin
If CurPos > Field then ScrollRight; If CurPos > Field then ScrollRight;
@ -1487,8 +1487,13 @@ Begin
xPos := Screen.CursorX; xPos := Screen.CursorX;
FieldCh := ' '; FieldCh := ' ';
// this is poorly implemented but to expand on it will require MPL
// programs to change. :( we are stuck at the cap for input types
// because of this.
If Mode > 10 Then Begin If Mode > 10 Then Begin
Dec (Mode, 10); Dec (Mode, 10);
If UseInField and (Graphics = 1) Then Begin If UseInField and (Graphics = 1) Then Begin
FieldCh := TBBSCore(Core).Lang.FieldChar; FieldCh := TBBSCore(Core).Lang.FieldChar;
AnsiColor (TBBSCore(Core).Lang.FieldCol2); AnsiColor (TBBSCore(Core).Lang.FieldCol2);
@ -1523,6 +1528,7 @@ Begin
Repeat Repeat
Ch := GetKey; Ch := GetKey;
If IsArrow Then Begin If IsArrow Then Begin
Case Ch of Case Ch of
#71 : If StrPos > 1 Then Begin #71 : If StrPos > 1 Then Begin
@ -1588,6 +1594,7 @@ Begin
#08 : If StrPos > 1 Then Begin #08 : If StrPos > 1 Then Begin
Dec (StrPos); Dec (StrPos);
Delete (S, StrPos, 1); Delete (S, StrPos, 1);
If CurPos = 1 Then If CurPos = 1 Then
ScrollLeft ScrollLeft
Else Else
@ -1613,44 +1620,45 @@ Begin
#32.. #32..
#254: If Length(S) < Max Then #254: If Length(S) < Max Then
Case Mode of Case Mode of
1 : Add_Char (Ch); 1 : AddChar (Ch);
2 : Add_Char (UpCase(Ch)); 2 : AddChar (UpCase(Ch));
3 : Begin 3 : Begin
If (CurPos = 1) or (S[StrPos-1] in [' ', '.']) Then If (CurPos = 1) or (S[StrPos-1] in [' ', '.']) Then
Ch := UpCase(Ch) Ch := UpCase(Ch)
Else Else
Ch := LoCase(Ch); Ch := LoCase(Ch);
Add_Char(Ch);
AddChar(Ch);
End; End;
4 : If (Ord(Ch) > 47) and (Ord(Ch) < 58) Then 4 : If (Ord(Ch) > 47) and (Ord(Ch) < 58) Then
Case StrPos of Case StrPos of
4,8 : Begin 4,8 : Begin
Add_Char ('-'); AddChar ('-');
Add_Char (Ch); AddChar (Ch);
End; End;
3,7 : Begin 3,7 : Begin
Add_Char (Ch); AddChar (Ch);
Add_Char ('-'); AddChar ('-');
End; End;
Else Else
Add_Char(Ch); AddChar(Ch);
End; End;
5 : If (Ord(Ch) > 47) and (Ord(Ch) < 58) Then 5 : If (Ord(Ch) > 47) and (Ord(Ch) < 58) Then
Case StrPos of Case StrPos of
2,5 : Begin 2,5 : Begin
Add_Char (Ch); AddChar (Ch);
Add_Char ('/'); AddChar ('/');
End; End;
3,6 : Begin 3,6 : Begin
Add_Char ('/'); AddChar ('/');
Add_Char (Ch); AddChar (Ch);
End; End;
Else Else
Add_Char (Ch); AddChar (Ch);
End; End;
6 : Add_Char(UpCase(Ch)); 6 : AddChar(UpCase(Ch));
7 : Add_Char(LoCase(Ch)); 7 : AddChar(LoCase(Ch));
9 : Add_Char(Ch); 9 : AddChar(Ch);
End; End;
End; End;
Until False; Until False;

View File

@ -790,7 +790,7 @@ Begin
Set_Node_Action (Session.GetPrompt(346)); Set_Node_Action (Session.GetPrompt(346));
Check_Node_Message; CheckNodeMessages;
Keys := #13; Keys := #13;
ExtKeys := ''; ExtKeys := '';

View File

@ -1400,7 +1400,7 @@ Var
Ansi_View_Message := False; Ansi_View_Message := False;
Repeat Repeat
Check_Node_Message; CheckNodeMessages;
Set_Node_Action (Session.GetPrompt(348)); Set_Node_Action (Session.GetPrompt(348));
@ -1688,7 +1688,7 @@ Var
Procedure FullReDraw; Procedure FullReDraw;
Begin Begin
Check_Node_Message; CheckNodeMessages;
Session.io.OutFile ('ansimlst', True, 0); Session.io.OutFile ('ansimlst', True, 0);
@ -2017,7 +2017,7 @@ end;
Session.io.AllowPause := False; Session.io.AllowPause := False;
Repeat Repeat
Check_Node_Message; CheckNodeMessages;
Session.io.PromptInfo[1] := strI2S(MsgBase^.GetMsgNum); Session.io.PromptInfo[1] := strI2S(MsgBase^.GetMsgNum);
Session.io.PromptInfo[2] := strI2S(MsgBase^.GetHighMsgNum); Session.io.PromptInfo[2] := strI2S(MsgBase^.GetHighMsgNum);

View File

@ -8,6 +8,7 @@ Function Is_User_Online (Name : String) : Word;
Procedure Set_Node_Action (Action: String); Procedure Set_Node_Action (Action: String);
Procedure Show_Whos_Online; Procedure Show_Whos_Online;
Procedure Send_Node_Message (MsgType: Byte; Data: String; Room: Byte); Procedure Send_Node_Message (MsgType: Byte; Data: String; Room: Byte);
Function CheckNodeMessages : Boolean;
Implementation Implementation
@ -193,4 +194,53 @@ Begin
End; End;
End; End;
Function CheckNodeMessages : Boolean;
Var
Str : String;
Begin
Result := False;
FileMode := 66;
Assign (NodeMsgFile, Session.TempPath + 'chat.tmp');
{$I-} Reset (NodeMsgFile); {$I+}
If IoResult <> 0 Then Exit;
// 2 = system broadcast message (ie, not from user, from mystic)
// 3 = user to user node message
While Not Eof(NodeMsgFile) Do Begin
Result := True;
Read (NodeMsgFile, NodeMsg);
Session.io.PromptInfo[1] := NodeMsg.FromWho;
Session.io.PromptInfo[2] := strI2S(NodeMsg.FromNode);
Case NodeMsg.MsgType of
2 : Begin
Session.io.OutFullLn (Session.GetPrompt(179) + NodeMsg.Message);
Session.io.OutFullLn (Session.GetPrompt(180));
End;
3 : Begin
Session.io.OutFullLn (Session.GetPrompt(144) + '|CR' + NodeMsg.Message);
Session.io.OutFull (Session.GetPrompt(145));
End;
End;
End;
Close (NodeMsgFile);
Erase (NodeMsgFile);
If Result And (NodeMsg.MsgType = 3) Then
If Session.io.OneKey(#13 + 'R', True) = 'R' Then Begin
Session.io.OutFullLn(Session.GetPrompt(360));
Str := Session.io.GetInput(79, 79, 11, '');
If Str <> '' Then Send_Node_Message(3, Session.io.PromptInfo[2] + ';' + Str, 0);
End;
End;
End. End.