SLKTextInput.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // SlackTextViewController
  3. // https://github.com/slackhq/SlackTextViewController
  4. //
  5. // Copyright 2014-2016 Slack Technologies, Inc.
  6. // Licence: MIT-Licence
  7. //
  8. #import <UIKit/UIKit.h>
  9. /**
  10. Classes that adopt the SLKTextInput protocol interact with the text input system and thus acquire features such as text processing.
  11. All these methods are already implemented in SLKTextInput+Implementation.m
  12. */
  13. @protocol SLKTextInput <UITextInput>
  14. @optional
  15. /**
  16. Searches for any matching string prefix at the text input's caret position. When nothing found, the completion block returns nil values.
  17. This implementation is internally performed on a background thread and forwarded to the main thread once completed.
  18. @param prefixes A set of prefixes to search for.
  19. @param completion A completion block called whenever the text processing finishes, successfuly or not. Required.
  20. */
  21. - (void)lookForPrefixes:(NSSet<NSString *> *)prefixes
  22. completion:(void (^)(NSString *prefix, NSString *word, NSRange wordRange))completion;
  23. /**
  24. Finds the word close to the caret's position, if any.
  25. @param range Returns the range of the found word.
  26. @returns The found word.
  27. */
  28. - (NSString *)wordAtCaretRange:(NSRangePointer)range;
  29. /**
  30. Finds the word close to specific range.
  31. @param range The range to be used for searching the word.
  32. @param rangePointer Returns the range of the found word.
  33. @returns The found word.
  34. */
  35. - (NSString *)wordAtRange:(NSRange)range rangeInText:(NSRangePointer)rangePointer;
  36. @end