diff --git a/mystic/nodespy_common.pas b/mystic/nodespy_common.pas new file mode 100644 index 0000000..39962df --- /dev/null +++ b/mystic/nodespy_common.pas @@ -0,0 +1,156 @@ +Unit NodeSpy_Common; + +{$I M_OPS.PAS} + +Interface + +Uses + Math, + m_Input, + m_Output, + m_Term_Ansi, + m_MenuBox, + m_MenuInput; + +Function ShowMsgBox (BoxType: Byte; Str: String) : Boolean; +Function GetStr (Header, Text, Def: String; Len, MaxLen: Byte) : String; + +{$I RECORDS.PAS} + +Var + Screen : TOutput; + Keyboard : TInput; + Term : TTermAnsi; + ConfigFile : File of RecConfig; + Config : RecConfig; + +Implementation + +Function ShowMsgBox (BoxType: Byte; Str: String) : Boolean; +Var + Len : Byte; + Len2 : Byte; + Pos : Byte; + MsgBox : TMenuBox; + Offset : Byte; + SavedX : Byte; + SavedY : Byte; + SavedA : Byte; +Begin + ShowMsgBox := True; + SavedX := Screen.CursorX; + SavedY := Screen.CursorY; + SavedA := Screen.TextAttr; + + MsgBox := TMenuBox.Create(TOutput(Screen)); + + Len := (80 - (Length(Str) + 2)) DIV 2; + Pos := 1; + + MsgBox.FrameType := 6; + MsgBox.Header := ' Info '; + MsgBox.HeadAttr := 1 + 7 * 16; + + MsgBox.Box3D := True; + + If Screen.ScreenSize = 50 Then Offset := 12 Else Offset := 0; + + If BoxType < 2 Then + MsgBox.Open (Len, 10 + Offset, Len + Length(Str) + 3, 15 + Offset) + Else + MsgBox.Open (Len, 10 + Offset, Len + Length(Str) + 3, 14 + Offset); + + Screen.WriteXY (Len + 2, 12 + Offset, 112, Str); + + Case BoxType of + 0 : Begin + Len2 := (Length(Str) - 4) DIV 2; + + Screen.WriteXY (Len + Len2 + 2, 14 + Offset, 30, ' OK '); + + Repeat + Keyboard.ReadKey; + Until Not Keyboard.KeyPressed; + End; + 1 : Repeat + Len2 := (Length(Str) - 9) DIV 2; + + Screen.WriteXY (Len + Len2 + 2, 14 + Offset, 113, ' YES '); + Screen.WriteXY (Len + Len2 + 7, 14 + Offset, 113, ' NO '); + + If Pos = 1 Then + Screen.WriteXY (Len + Len2 + 2, 14 + Offset, 30, ' YES ') + Else + Screen.WriteXY (Len + Len2 + 7, 14 + Offset, 30, ' NO '); + + Case UpCase(Keyboard.ReadKey) of + #00 : Case Keyboard.ReadKey of + #75 : Pos := 1; + #77 : Pos := 0; + End; + #13 : Begin + ShowMsgBox := Boolean(Pos); + Break; + End; + #32 : If Pos = 0 Then Inc(Pos) Else Pos := 0; + 'N' : Begin + ShowMsgBox := False; + Break; + End; + 'Y' : Begin + ShowMsgBox := True; + Break; + End; + End; + Until False; + End; + + If BoxType < 2 Then MsgBox.Close; + + MsgBox.Free; + + Screen.CursorXY (SavedX, SavedY); + + Screen.TextAttr := SavedA; +End; + +Function GetStr (Header, Text, Def: String; Len, MaxLen: Byte) : String; +Var + Box : TMenuBox; + Input : TMenuInput; + Offset : Byte; + Str : String; + WinSize : Byte; +Begin + WinSize := (80 - Max(Len, Length(Text)) + 2) DIV 2; + + Box := TMenuBox.Create(TOutput(Screen)); + Input := TMenuInput.Create(TOutput(Screen)); + + Box.FrameType := 6; + Box.Header := ' ' + Header + ' '; + Box.HeadAttr := 1 + 7 * 16; + Box.Box3D := True; + + Input.Attr := 15 + 4 * 16; + Input.FillAttr := 7 + 4 * 16; + Input.LoChars := #13#27; + + If Screen.ScreenSize = 50 Then Offset := 12 Else Offset := 0; + + Box.Open (WinSize, 10 + Offset, WinSize + Max(Len, Length(Text)) + 2, 15 + Offset); + + Screen.WriteXY (WinSize + 2, 12 + Offset, 112, Text); + Str := Input.GetStr(WinSize + 2, 13 + Offset, Len, MaxLen, 1, Def); + + Box.Close; + + If Input.ExitCode = #27 Then Str := ''; + + Input.Free; + Box.Free; + + Result := Str; +End; + +End.