iup_text_caret.e 2.7 KB

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