ITextValidateProvider.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. namespace Terminal.Gui.Views;
  2. /// <summary>TextValidateField Providers Interface. All TextValidateField are created with a ITextValidateProvider.</summary>
  3. public interface ITextValidateProvider
  4. {
  5. /// <summary>Gets the formatted string for display.</summary>
  6. string DisplayText { get; }
  7. /// <summary>Set that this provider uses a fixed width. e.g. Masked ones are fixed.</summary>
  8. bool Fixed { get; }
  9. /// <summary>True if the input is valid, otherwise false.</summary>
  10. bool IsValid { get; }
  11. /// <summary>Set the input text and get the current value.</summary>
  12. string Text { get; set; }
  13. /// <summary>Set Cursor position to <paramref name="pos"/>.</summary>
  14. /// <param name="pos"></param>
  15. /// <returns>Return first valid position.</returns>
  16. int Cursor (int pos);
  17. /// <summary>Find the last valid character position.</summary>
  18. /// <returns>New cursor position.</returns>
  19. int CursorEnd ();
  20. /// <summary>First valid position before <paramref name="pos"/>.</summary>
  21. /// <param name="pos"></param>
  22. /// <returns>New cursor position if any, otherwise returns <paramref name="pos"/></returns>
  23. int CursorLeft (int pos);
  24. /// <summary>First valid position after <paramref name="pos"/>.</summary>
  25. /// <param name="pos">Current position.</param>
  26. /// <returns>New cursor position if any, otherwise returns <paramref name="pos"/></returns>
  27. int CursorRight (int pos);
  28. /// <summary>Find the first valid character position.</summary>
  29. /// <returns>New cursor position.</returns>
  30. int CursorStart ();
  31. /// <summary>Deletes the current character in <paramref name="pos"/>.</summary>
  32. /// <param name="pos"></param>
  33. /// <returns>true if the character was successfully removed, otherwise false.</returns>
  34. bool Delete (int pos);
  35. /// <summary>Insert character <paramref name="ch"/> in position <paramref name="pos"/>.</summary>
  36. /// <param name="ch"></param>
  37. /// <param name="pos"></param>
  38. /// <returns>true if the character was successfully inserted, otherwise false.</returns>
  39. bool InsertAt (char ch, int pos);
  40. /// <summary>Method that invoke the <see cref="TextChanged"/> event if it's defined.</summary>
  41. /// <param name="oldValue">The previous text before replaced.</param>
  42. /// <returns>Returns the <see cref="EventArgs{T}"/></returns>
  43. void OnTextChanged (EventArgs<string> oldValue);
  44. /// <summary>
  45. /// Changed event, raised when the text has changed.
  46. /// <remarks>
  47. /// This event is raised when the <see cref="Text"/> changes. The passed <see cref="EventArgs"/> is a
  48. /// <see cref="string"/> containing the old value.
  49. /// </remarks>
  50. /// </summary>
  51. event EventHandler<EventArgs<string>> TextChanged;
  52. }