ITextValidateProvider.cs 2.8 KB

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