PSAttack.PSAttackProcessing.AttackState.getCursorXY C# (CSharp) Method

getCursorXY() public method

public getCursorXY ( ) : List
return List
        public List<int> getCursorXY()
        {
            // figure out if we've dropped down a line
            int cursorYDiff = this.cursorPos / Console.WindowWidth;
            int cursorY = this.promptPos + this.cursorPos / Console.WindowWidth;
            int cursorX = this.cursorPos - Console.WindowWidth * cursorYDiff;

            // if X is < 0, set cursor to end of line
            if (cursorX < 0) {
                cursorX = Console.WindowWidth - 1;
            }
            List<int> cursorXY = new List<int>();
            cursorXY.Add(cursorX);
            cursorXY.Add(cursorY);
            return cursorXY;
        }

Usage Example

Beispiel #1
0
        public static void Output(AttackState attackState)
        {
            if (attackState.cmdComplete)
            {
                printPrompt(attackState);
            }
            int currentCusorPos = Console.CursorTop;
            string prompt = createPrompt(attackState);

            // This is where we juggle things to make sure the cursor ends up where
            // it's expected to be. I'm sure this could be improved on.

            // Clear out typed text after prompt
            Console.SetCursorPosition(prompt.Length, attackState.promptPos);
            Console.Write(new string(' ', Console.WindowWidth));

            // Clear out any lines below the prompt
            int cursorDiff = attackState.consoleWrapCount();
            while (cursorDiff > 0)
            {
                Console.SetCursorPosition(0, attackState.promptPos + cursorDiff);
                Console.Write(new string(' ', Console.WindowWidth));
                cursorDiff -= 1;
            }
            Console.SetCursorPosition(prompt.Length, attackState.promptPos);

            // Re-print the command
            Console.Write(attackState.displayCmd);

            List<int> cursorXY = attackState.getCursorXY();
            Console.SetCursorPosition(cursorXY[0], cursorXY[1]);
        }