aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Console/ConsoleBase.cs
diff options
context:
space:
mode:
authorMelanie Thielker2009-02-13 20:49:23 +0000
committerMelanie Thielker2009-02-13 20:49:23 +0000
commita8f3d625cb3ac61b00c01e3f5af015b3d6c88105 (patch)
treec46694a2db0d4da6f161a7e1303d218182b7596d /OpenSim/Framework/Console/ConsoleBase.cs
parent* Change static field "initialized" in RestInterregionComms to an instance field (diff)
downloadopensim-SC-a8f3d625cb3ac61b00c01e3f5af015b3d6c88105.zip
opensim-SC-a8f3d625cb3ac61b00c01e3f5af015b3d6c88105.tar.gz
opensim-SC-a8f3d625cb3ac61b00c01e3f5af015b3d6c88105.tar.bz2
opensim-SC-a8f3d625cb3ac61b00c01e3f5af015b3d6c88105.tar.xz
Guard the values used to set the cursor position in the real time console
Diffstat (limited to 'OpenSim/Framework/Console/ConsoleBase.cs')
-rw-r--r--OpenSim/Framework/Console/ConsoleBase.cs52
1 files changed, 39 insertions, 13 deletions
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs
index 0f0b3a6..bd19800 100644
--- a/OpenSim/Framework/Console/ConsoleBase.cs
+++ b/OpenSim/Framework/Console/ConsoleBase.cs
@@ -554,13 +554,39 @@ namespace OpenSim.Framework.Console
554 WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Gray, format, args); 554 WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Gray, format, args);
555 } 555 }
556 556
557 private int SetCursorTop(int top)
558 {
559 if (top >= 0 && top < System.Console.BufferHeight)
560 {
561 System.Console.CursorTop = top;
562 return top;
563 }
564 else
565 {
566 return System.Console.CursorTop;
567 }
568 }
569
570 private int SetCursorLeft(int left)
571 {
572 if (left >= 0 && left < System.Console.BufferWidth)
573 {
574 System.Console.CursorLeft = left;
575 return left;
576 }
577 else
578 {
579 return System.Console.CursorLeft;
580 }
581 }
582
557 private void WriteNewLine(ConsoleColor senderColor, string sender, ConsoleColor color, string format, params object[] args) 583 private void WriteNewLine(ConsoleColor senderColor, string sender, ConsoleColor color, string format, params object[] args)
558 { 584 {
559 lock (cmdline) 585 lock (cmdline)
560 { 586 {
561 if (y != -1) 587 if (y != -1)
562 { 588 {
563 System.Console.CursorTop = y; 589 y=SetCursorTop(y);
564 System.Console.CursorLeft = 0; 590 System.Console.CursorLeft = 0;
565 591
566 int count = cmdline.Length; 592 int count = cmdline.Length;
@@ -569,7 +595,7 @@ namespace OpenSim.Framework.Console
569 while (count-- > 0) 595 while (count-- > 0)
570 System.Console.Write(" "); 596 System.Console.Write(" ");
571 597
572 System.Console.CursorTop = y; 598 y=SetCursorTop(y);
573 System.Console.CursorLeft = 0; 599 System.Console.CursorLeft = 0;
574 } 600 }
575 WritePrefixLine(senderColor, sender); 601 WritePrefixLine(senderColor, sender);
@@ -585,7 +611,7 @@ namespace OpenSim.Framework.Console
585 { 611 {
586 if (y != -1) 612 if (y != -1)
587 { 613 {
588 System.Console.CursorTop = y; 614 y=SetCursorTop(y);
589 System.Console.CursorLeft = 0; 615 System.Console.CursorLeft = 0;
590 616
591 int count = cmdline.Length; 617 int count = cmdline.Length;
@@ -594,7 +620,7 @@ namespace OpenSim.Framework.Console
594 while (count-- > 0) 620 while (count-- > 0)
595 System.Console.Write(" "); 621 System.Console.Write(" ");
596 622
597 System.Console.CursorTop = y; 623 y=SetCursorTop(y);
598 System.Console.CursorLeft = 0; 624 System.Console.CursorLeft = 0;
599 } 625 }
600 WriteConsoleLine(color, format, args); 626 WriteConsoleLine(color, format, args);
@@ -695,7 +721,7 @@ namespace OpenSim.Framework.Console
695 System.Console.WriteLine(" "); 721 System.Console.WriteLine(" ");
696 } 722 }
697 723
698 System.Console.CursorTop = y; 724 y=SetCursorTop(y);
699 System.Console.CursorLeft = 0; 725 System.Console.CursorLeft = 0;
700 726
701 if (echo) 727 if (echo)
@@ -703,8 +729,8 @@ namespace OpenSim.Framework.Console
703 else 729 else
704 System.Console.Write("{0}", prompt); 730 System.Console.Write("{0}", prompt);
705 731
706 System.Console.CursorLeft = new_x; 732 SetCursorLeft(new_x);
707 System.Console.CursorTop = new_y; 733 SetCursorTop(new_y);
708 } 734 }
709 } 735 }
710 736
@@ -715,7 +741,7 @@ namespace OpenSim.Framework.Console
715 { 741 {
716 if (y != -1) 742 if (y != -1)
717 { 743 {
718 System.Console.CursorTop = y; 744 y = SetCursorTop(y);
719 System.Console.CursorLeft = 0; 745 System.Console.CursorLeft = 0;
720 746
721 int count = cmdline.Length + prompt.Length; 747 int count = cmdline.Length + prompt.Length;
@@ -723,7 +749,7 @@ namespace OpenSim.Framework.Console
723 while (count-- > 0) 749 while (count-- > 0)
724 System.Console.Write(" "); 750 System.Console.Write(" ");
725 751
726 System.Console.CursorTop = y; 752 y = SetCursorTop(y);
727 System.Console.CursorLeft = 0; 753 System.Console.CursorLeft = 0;
728 754
729 } 755 }
@@ -754,7 +780,7 @@ namespace OpenSim.Framework.Console
754 return; 780 return;
755 } 781 }
756 782
757 System.Console.CursorTop = y; 783 y = SetCursorTop(y);
758 System.Console.CursorLeft = 0; 784 System.Console.CursorLeft = 0;
759 785
760 int count = cmdline.Length + prompt.Length; 786 int count = cmdline.Length + prompt.Length;
@@ -762,7 +788,7 @@ namespace OpenSim.Framework.Console
762 while (count-- > 0) 788 while (count-- > 0)
763 System.Console.Write(" "); 789 System.Console.Write(" ");
764 790
765 System.Console.CursorTop = y; 791 y = SetCursorTop(y);
766 System.Console.CursorLeft = 0; 792 System.Console.CursorLeft = 0;
767 793
768 System.Console.WriteLine(text); 794 System.Console.WriteLine(text);
@@ -915,7 +941,7 @@ namespace OpenSim.Framework.Console
915 cp--; 941 cp--;
916 942
917 System.Console.CursorLeft = 0; 943 System.Console.CursorLeft = 0;
918 System.Console.CursorTop = y; 944 y = SetCursorTop(y);
919 945
920 System.Console.Write("{0}{1} ", prompt, cmdline); 946 System.Console.Write("{0}{1} ", prompt, cmdline);
921 947
@@ -963,7 +989,7 @@ namespace OpenSim.Framework.Console
963 break; 989 break;
964 case ConsoleKey.Enter: 990 case ConsoleKey.Enter:
965 System.Console.CursorLeft = 0; 991 System.Console.CursorLeft = 0;
966 System.Console.CursorTop = y; 992 y = SetCursorTop(y);
967 993
968 System.Console.WriteLine("{0}{1}", prompt, cmdline); 994 System.Console.WriteLine("{0}{1}", prompt, cmdline);
969 995