iup_widget_text_caret.e 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. deferred class IUP_WIDGET_TEXT_CARET
  2. -- Commands to handle the attributes related with caret.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. feature {ANY}
  6. set_caret (pos: INTEGER)
  7. -- (non inheritable): Character position of the insertion point.
  8. -- The first position is "1". When pos is greater than the number of
  9. -- characters in the given line, the caret is placed after the last
  10. -- character of the line.
  11. -- In Windows, if the element does not have the focus the returned value
  12. -- is the position of the first character of the current selection. The
  13. -- caret is only displayed if the element has the keyboard focus, but its
  14. -- position can be changed even if not visible. When changed it will also
  15. -- change the selection.
  16. -- See the Notes above if using UTF-8 strings in GTK.
  17. require
  18. pos > 0
  19. do
  20. iup_open.set_attribute(Current, "CARET", pos.out)
  21. end
  22. get_caret: INTEGER
  23. -- The caret.
  24. local
  25. str: STRING
  26. do
  27. str := iup_open.get_attribute(Current, "CARET")
  28. if str.is_integer then
  29. Result := str.to_integer
  30. end
  31. end
  32. set_caret_pos (pos: INTEGER)
  33. -- (non inheritable): Also the character position of the insertion point,
  34. -- but using a zero based character unique index "pos". Useful for
  35. -- indexing the VALUE string. See the Notes below if using UTF-8 strings
  36. -- in GTK.
  37. require
  38. pos > 0
  39. do
  40. iup_open.set_attribute(Current, "CARETPOS", pos.out)
  41. end
  42. get_caret_pos: INTEGER
  43. -- The caret position.
  44. local
  45. str: STRING
  46. do
  47. str := iup_open.get_attribute(Current, "CARETPOS")
  48. if str.is_integer then
  49. Result := str.to_integer
  50. end
  51. end
  52. end
  53. -- The MIT License (MIT)
  54. -- Copyright (c) 2016, 2017, 2019 by German A. Arias
  55. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  56. -- of this software and associated documentation files (the "Software"), to deal
  57. -- in the Software without restriction, including without limitation the rights
  58. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59. -- copies of the Software, and to permit persons to whom the Software is
  60. -- furnished to do so, subject to the following conditions:
  61. --
  62. -- The above copyright notice and this permission notice shall be included in
  63. -- all copies or substantial portions of the Software.
  64. --
  65. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  66. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  68. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  69. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  70. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  71. -- SOFTWARE.