/// <summary> /// Draws a character to the screen while no connection is established. /// </summary> /// <param name="ch">The character to draw.</param> /// <param name="modifier">The existing screen modifier.</param> /// <param name="echo">A value indicating whether to draw the character to the terminal in plain text (<see cref="false"/> for password input with * characters).</param> private void DrawLocalModeChar(char ch, IScreenModifier modifier, bool echo) { ScreenCellFormat defaultFormat = new ScreenCellFormat(); switch (ch) { case '\r': modifier.CursorColumn = 0; break; case '\n': modifier.CursorRowIncreaseWithScroll(null, null); break; default: modifier.CursorCharacter = echo ? ch : '*'; modifier.ApplyFormatToCursor(defaultFormat); if (modifier.CursorColumn + 1 >= this.Screen.ColumnCount) { modifier.CursorColumn = 0; modifier.CursorRowIncreaseWithScroll(scrollTop: null, scrollBottom: null); } else { modifier.CursorColumn++; } break; } }
////private static Color? XParseColor(string colorString) ////{ //// if (colorString.StartsWith("rgb:", StringComparison.Ordinal) && colorString.Length > 4) //// { //// string[] rgbStrings = colorString.Substring(4).Split('/'); //// if (rgbStrings.Length != 3) //// { //// return null; //// } //// byte[] rgbValues = new byte[3]; //// for (int i = 0; i < 3; i++) //// { //// if (rgbStrings[i].Length == 0 || rgbStrings.Length > 4) //// { //// return null; //// } //// int value; //// try //// { //// value = Convert.ToInt32(rgbStrings[i], 16); //// double scale = 256d / Math.Pow(2d, rgbStrings[i].Length * 4d); //// rgbValues[i] = (byte)(value * scale); //// } //// catch (Exception) //// { //// return null; //// } //// } //// return Color.FromArgb(255, rgbValues[0], rgbValues[1], rgbValues[2]); //// } //// return null; ////} /// <summary> /// Jumps the cursor to the next (default) horizontal tab stop. /// </summary> /// <param name="modifier">The screen modifier.</param> private void JumpToNextHorizontalTabStop(IScreenModifier modifier) { var previousTabStop = ((modifier.CursorColumn / DefaultTabStopWidth) * DefaultTabStopWidth); var nextTabStop = previousTabStop + DefaultTabStopWidth; modifier.CursorColumn = Math.Min(nextTabStop, this.Columns - 1); }