iup_clipboard.e 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. class IUP_CLIPBOARD
  2. inherit
  3. ANY
  4. create {IUP_INTERFACE}
  5. init
  6. feature {IUP_INTERFACE}
  7. init (interface: IUP_INTERFACE)
  8. -- Init the interface system
  9. do
  10. --io.put_string("Create Clipboard %N")
  11. int := interface.iup_open
  12. end
  13. feature {ANY}
  14. clean
  15. -- Clears the clipboard data.
  16. local
  17. p: POINTER
  18. do
  19. p := int_clipboard
  20. int.set_attribute_null_in_handle(p, "TEXT")
  21. int_destroy(p)
  22. end
  23. is_text_available: BOOLEAN
  24. -- Informs if there is a text available at the clipboard.
  25. local
  26. p: POINTER
  27. s: STRING
  28. do
  29. p := int_clipboard
  30. s := int.get_attribute_from_handle(p, "TEXTAVAILABLE")
  31. int_destroy(p)
  32. if s.is_equal("YES") then
  33. Result := True
  34. else
  35. Result := False
  36. end
  37. end
  38. add_text (value: STRING)
  39. -- Copy text to the clipboard.
  40. local
  41. p: POINTER
  42. do
  43. p := int_clipboard
  44. int.set_attribute_in_handle(p, "TEXT", value)
  45. int_destroy(p)
  46. end
  47. get_text: STRING
  48. -- Paste text from the clipboard.
  49. local
  50. p: POINTER
  51. s: STRING
  52. do
  53. p := int_clipboard
  54. s := int.get_attribute_from_handle(p, "TEXT")
  55. int_destroy(p)
  56. Result := s
  57. end
  58. feature {NONE}
  59. int: IUP
  60. int_clipboard: POINTER
  61. external
  62. "C inline use %"eiffel-iup.h%""
  63. alias
  64. "return IupClipboard()"
  65. end
  66. int_destroy (p: POINTER)
  67. external
  68. "C inline use %"eiffel-iup.h%""
  69. alias
  70. "IupDestroy ($p);"
  71. end
  72. end
  73. -- The MIT License (MIT)
  74. -- Copyright (c) 2018, 2019, 2020 by German A. Arias
  75. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  76. -- of this software and associated documentation files (the "Software"), to deal
  77. -- in the Software without restriction, including without limitation the rights
  78. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  79. -- copies of the Software, and to permit persons to whom the Software is
  80. -- furnished to do so, subject to the following conditions:
  81. --
  82. -- The above copyright notice and this permission notice shall be included in
  83. -- all copies or substantial portions of the Software.
  84. --
  85. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  86. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  87. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  88. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  89. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  90. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  91. -- SOFTWARE.