/// <summary> /// Requests the user input, without sending it to the ssh connection. /// </summary> /// <returns>The user input.</returns> /// <param name="prompt">Prompt.</param> /// <param name="echo">Echo char. If null, the keypress will be displayed</param> public String RequestUserInput(String prompt, char?echoChar = null) { UserInputMode = true; Write(prompt); String input = ""; while (userkeypress.WaitOne()) { if (LastKeyPress == Gdk.Key.BackSpace) { if (input.Length > 0) { input = input.Substring(0, input.Length - 1); if (echoChar.HasValue) { Write("\b \b"); } } } else if (LastKeyPress == Gdk.Key.Return) { Write("\r\n"); break; } else { Write(echoChar.HasValue ? echoChar.Value.ToString() : LastKeyPress.ToString()); input += LastKeyPress; } } UserInputMode = false; return(input); }
/// <summary> /// Requests the user input, without sending it to the ssh connection. /// </summary> /// <returns>The user input.</returns> /// <param name="prompt">Prompt.</param> /// <param name="echo">Echo char. If null, the keypress will be displayed</param> public String RequestUserInput(String prompt, char?echoChar = null) { UserInputMode = true; Write(prompt); String input = ""; while (UserInputMode && userkeypress.WaitOne()) { switch (LastKeyPress) { case Gdk.Key.BackSpace: { if (input.Length > 0) { input = input.Substring(0, input.Length - 1); if (echoChar.HasValue) { Write("\b \b"); } } } break; case Gdk.Key.Return: case Gdk.Key.KP_Enter: { Write(Environment.NewLine); UserInputMode = false; //Stop Input break; } case Gdk.Key.Shift_L: case Gdk.Key.Shift_R: case Gdk.Key.ISO_Level3_Shift: //Alt Gr { //Do nothing } break; default: { var keyValue = LastKeyPress.GetChar(); Write(echoChar.HasValue ? echoChar.Value.ToString() : keyValue.ToString()); input += keyValue; } break; } } UserInputMode = false; return(input); }
/// <summary> /// Keep track of how many keypresses the user has done and returns whether Snow Effect should be activated for each change. /// </summary> /// <returns>True if Snow Effect should be activated for this change. False if Snow Effect should be ignored for this change.</returns> private bool ComboCheck() { if (TypingConfig.ComboActivationThreshold == 0) { LastKeyPress = DateTime.Now; return(true); } var now = DateTime.Now; ComboStreak++; if (LastKeyPress.AddMilliseconds(TypingConfig.ComboTimeout) < now) // More than x ms since last key-press. Combo has been broken. { ComboStreak = 1; } LastKeyPress = now; var activateSnowEffect = ComboStreak >= TypingConfig.ComboActivationThreshold; // Activate SnowEffect if number of keypresses exceeds the threshold for activation return(activateSnowEffect); // Perhaps different levels for Snow-Effect intensity? First just particles, then screen shake? }