/src/wrappers/gtk/library/gtk_text_view.e

http://github.com/tybor/Liberty · Specman e · 1259 lines · 388 code · 290 blank · 581 comment · 3 complexity · 33c403c97cdeddb952181dc974e46acb MD5 · raw file

  1. indexing
  2. description: "Multiline text view widget"
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. date: "$Date:$"
  19. revision: "$Revision:$"
  20. gtk_description: "[
  21. You may wish to begin by reading the text widget conceptual overview
  22. which gives an overview of all the objects and data types related to
  23. the text widget and how they work together.
  24. ]"
  25. class GTK_TEXT_VIEW
  26. inherit GTK_CONTAINER rename window as widget_window end
  27. -- TODO: GtkTextView implements AtkImplementorIface.
  28. insert
  29. GTK_TEXT_VIEW_EXTERNALS
  30. G_OBJECT_FACTORY [GTK_TEXT_BUFFER]
  31. GTK_TEXT_WINDOW_TYPE
  32. GTK_WRAP_MODE
  33. creation
  34. make, make_with_buffer, from_external_pointer
  35. feature {} -- Creation
  36. make is
  37. -- Creates a new GTK_TEXT_VIEW. If you don't call
  38. -- `set_buffer' before using the text view, an empty
  39. -- default buffer will be created for you. Get
  40. -- the buffer with `get_buffer'. If you want to
  41. -- specify your own buffer, consider `make_with_buffer'.
  42. require
  43. gtk_initialized: gtk.is_initialized
  44. do
  45. from_external_pointer (gtk_text_view_new)
  46. end
  47. make_with_buffer (a_buffer: GTK_TEXT_BUFFER) is
  48. -- Creates a new GTK_TEXT_VIEW widget displaying the buffer
  49. -- `a_buffer'. One buffer can be shared among many widgets.
  50. -- The text view adds its own reference count to the buffer;
  51. -- it does not take over an existing reference.
  52. require
  53. gtk_initialized: gtk.is_initialized
  54. buffer_not_void: a_buffer /= Void
  55. do
  56. from_external_pointer (gtk_text_view_new_with_buffer (a_buffer.handle))
  57. end
  58. feature -- Queries
  59. has_scrolled: BOOLEAN
  60. -- Has last `scroll_to_iter' have produced a scrolling?
  61. have_been_cursor_moved: BOOLEAN
  62. -- Had last feature call moved the cursor?
  63. was_iter_moved: BOOLEAN
  64. -- was iter moved? Used in `forward_display_line'
  65. feature -- Operations
  66. set_buffer (a_buffer: GTK_TEXT_BUFFER) is
  67. -- Sets `a_buffer' as the buffer being displayed.
  68. -- The previous buffer displayed by the text view is unreferenced,
  69. -- and a reference is added to `a_buffer'.
  70. -- If you owned a reference to `a_buffer' before passing it
  71. -- to this function, you must remove that reference yourself;
  72. -- GTK_TEXT_VIEW will not "adopt" it.
  73. require
  74. buffer_not_null: a_buffer /= Void
  75. do
  76. gtk_text_view_set_buffer (handle, a_buffer.handle)
  77. cached_buffer := Void
  78. ensure
  79. buffer_is_set: buffer /= Void -- XXX: is this ok?
  80. end
  81. feature -- Access
  82. buffer: GTK_TEXT_BUFFER is
  83. -- The GTK_TEXT_BUFFER being displayed by this text view.
  84. local
  85. c_buff: POINTER
  86. do
  87. if cached_buffer = Void then
  88. -- The reference count on the buffer returned by
  89. -- gtk_text_view_get_buffer is not incremented; the caller
  90. -- of this function won't own a new reference.
  91. cached_buffer:= unreffed_wrapper (gtk_text_view_get_buffer (handle))
  92. else
  93. check
  94. cached_buffer_doesnt_change:
  95. cached_buffer.handle = gtk_text_view_get_buffer (handle)
  96. end
  97. end
  98. Result := cached_buffer
  99. end
  100. feature {} -- Auxiliar
  101. cached_buffer: GTK_TEXT_BUFFER
  102. -- This buffer is used as a cache for values returned from `buffer'.
  103. -- If you don't use this the GtkTextView seems to (sometimes) switch
  104. -- it's buffer without warning, breaking callbacks and other code.
  105. feature -- Properties
  106. -- "accepts-tab" gboolean : Read / Write
  107. -- "buffer" GtkTextBuffer : Read / Write
  108. -- NOTE: already wrapped "cursor-visible"
  109. -- NOTE: already wrapped "editable
  110. -- "indent" gint : Read / Write
  111. -- "justification" GtkJustification : Read / Write
  112. -- "left-margin" gint : Read / Write
  113. -- NOTE: already wrapped "overwrite"
  114. -- "pixels-above-lines" gint : Read / Write
  115. -- "pixels-below-lines" gint : Read / Write
  116. -- "pixels-inside-wrap" gint : Read / Write
  117. -- "right-margin" gint : Read / Write
  118. -- "tabs" PangoTabArray : Read / Write
  119. -- "wrap-mode" GtkWrapMode : Read / Write
  120. feature -- Style properties:
  121. -- "error-underline-color" GdkColor : Read
  122. feature
  123. scroll_to_mark (a_mark: GTK_TEXT_MARK; within_margin: REAL;
  124. use_align: BOOLEAN; an_x_align, an_y_align: REAL) is
  125. -- Scrolls Current so that `a_mark' is on the screen in the
  126. -- position indicated by `an_x_align' and `an_y_align'. An
  127. -- alignment of 0.0 indicates left or top, 1.0 indicates
  128. -- right or bottom, 0.5 means center. If use_align is False,
  129. -- the text scrolls the minimal distance to get the mark
  130. -- onscreen, possibly not scrolling at all. The effective
  131. -- screen for purposes of this function is reduced by a
  132. -- margin of size within_margin.
  133. -- `within_margin' : margin as a [0.0,0.5) fraction of screen size
  134. -- `use_align' : whether to use alignment arguments (if
  135. -- FALSE, just get the mark onscreen)
  136. -- `an_x_align' horizontal alignment of mark within visible
  137. -- area.
  138. -- `an_y_align' vertical alignment of mark within visible
  139. -- area
  140. require mark_not_void: a_mark /= Void
  141. do
  142. gtk_text_view_scroll_to_mark (handle, a_mark.handle, within_margin,
  143. use_align.to_integer, an_x_align, an_y_align)
  144. end
  145. scroll_to_iter (an_iter: GTK_TEXT_ITER; within_margin: REAL;
  146. use_align: BOOLEAN; an_x_align, an_y_align: REAL) is
  147. -- Scrolls text_view so that iter is on the screen in the
  148. -- position indicated by xalign and yalign. An alignment of
  149. -- 0.0 indicates left or top, 1.0 indicates right or bottom,
  150. -- 0.5 means center. If use_align is FALSE, the text scrolls
  151. -- the minimal distance to get the mark onscreen, possibly
  152. -- not scrolling at all. The effective screen for purposes of
  153. -- this function is reduced by a margin of size
  154. -- within_margin. NOTE: This function uses the
  155. -- currently-computed height of the lines in the text
  156. -- buffer. Note that line heights are computed in an idle
  157. -- handler; so this function may not have the desired effect
  158. -- if it's called before the height computations. To avoid
  159. -- oddness, consider using `scroll_to_mark' which saves a
  160. -- point to be scrolled to after line validation.
  161. -- `within_margin' : margin as a [0.0,0.5) fraction of screen size
  162. -- `use_align': whether to use alignment arguments (if FALSE,
  163. -- just get the mark onscreen)
  164. -- `an_x_align': horizontal alignment of mark within visible
  165. -- area.
  166. -- `an_y_align': vertical alignment of mark within visible
  167. -- area
  168. -- `has_scrolled' will be True if scrolling occurred
  169. require iter_not_void: an_iter /= Void
  170. do
  171. has_scrolled := ( gtk_text_view_scroll_to_iter
  172. (handle, an_iter.handle, within_margin,
  173. use_align.to_integer, an_x_align, an_y_align) ).to_boolean
  174. end
  175. mark_onscreen (a_mark: GTK_TEXT_MARK) is
  176. -- Scrolls text view the minimum distance such that `a_mark'
  177. -- is contained within the visible area of the widget.
  178. require mark_not_void: a_mark /= Void
  179. do
  180. gtk_text_view_scroll_mark_onscreen (handle, a_mark.handle)
  181. end
  182. move_mark_onscreen (a_mark: GTK_TEXT_MARK): BOOLEAN is
  183. -- Moves a mark within the buffer so that it's located within
  184. -- the currently-visible text area.
  185. -- Returns : TRUE if the mark moved (wasn't already onscreen)
  186. require mark_not_void: a_mark /= Void
  187. do
  188. Result := (gtk_text_view_move_mark_onscreen (handle, a_mark.handle)).to_boolean
  189. end
  190. place_cursor_onscreen is
  191. -- Moves the cursor to the currently visible region of the
  192. -- buffer, if it isn't there already.
  193. -- `have_been_cursor_moved' will be true if the cursor had to
  194. -- be moved.
  195. do
  196. have_been_cursor_moved:= gtk_text_view_place_cursor_onscreen (handle).to_boolean
  197. end
  198. visible_rect: GDK_RECTANGLE is
  199. -- the currently-visible region of the buffer, in buffer
  200. -- coordinates. Convert to window coordinates with
  201. -- `buffer_to_window_coords'.
  202. do
  203. create Result.make
  204. gtk_text_view_get_visible_rect (handle, Result.handle)
  205. end
  206. iter_location (an_iterator: GTK_TEXT_ITER): GDK_RECTANGLE is
  207. -- A rectangle which roughly contains the character at
  208. -- `an_iterator'. The rectangle position is in buffer
  209. -- coordinates; use `buffer_to_window_coords' to convert
  210. -- these coordinates to coordinates for one of the windows in
  211. -- the text view.
  212. require iterator_not_void: an_iterator/=Void
  213. do
  214. create Result.make
  215. gtk_text_view_get_iter_location (handle, an_iterator.handle, Result.handle)
  216. end
  217. set_iter_line_at_y (an_iterator: GTK_TEXT_ITER; a_y: INTEGER) is
  218. -- Sets `an_iterator' at the start of the line containing the
  219. -- coordinate `an_y'. `an_y' is in buffer coordinates,
  220. -- convert from window coordinates with
  221. -- `window_to_buffer_coords'.
  222. -- TODO: retrieve the location for top coordinate of the line
  223. require iterator_not_void: an_iterator/=Void
  224. do
  225. gtk_text_view_get_line_at_y (handle, an_iterator.handle, a_y,
  226. default_pointer -- gint *line_top
  227. )
  228. -- Gets the GtkTextIter at the start of the line containing
  229. -- the coordinate y. y is in buffer coordinates, convert from
  230. -- window coordinates with
  231. -- gtk_text_view_window_to_buffer_coords(). If non-NULL,
  232. -- line_top will be filled with the coordinate of the top
  233. -- edge of the line.
  234. end
  235. -- TODO: uncomment this once the TUPLE bug get solved.
  236. -- line_y_range (an_iterator): TUPLE [INTEGER, INTEGER] is
  237. -- -- Gets the y coordinate of the top of the line containing
  238. -- -- iter, and the height of the line. The coordinate is a
  239. -- -- buffer coordinate; convert to window coordinates with
  240. -- -- `buffer_to_window_coords'.
  241. -- require iterator_not_void: an_iterator/=Void
  242. -- local y,height: INTEGER
  243. -- do
  244. -- gtk_text_view_get_line_yrange (handle, an_iterator.handle,
  245. -- $y, $height)
  246. -- create Result.make_2 (y,height)
  247. -- end
  248. iter_at_location (an_x, an_y: INTEGER): GTK_TEXT_ITER is
  249. -- Retrieves the iterator at buffer coordinates `an_x' and
  250. -- `an_y'. Buffer coordinates are coordinates for the entire
  251. -- buffer, not just the currently-displayed portion. If you
  252. -- have coordinates from an event, you have to convert those
  253. -- to buffer coordinates with `window_to_buffer_coords'.
  254. do
  255. create Result.make
  256. gtk_text_view_get_iter_at_location (handle, Result.handle, an_x, an_y)
  257. ensure result_not_void: Result /= Void
  258. end
  259. iter_at_position (an_x, an_y: INTEGER): TUPLE[GTK_TEXT_ITER,INTEGER] is
  260. -- the iterator pointing to the character at buffer
  261. -- coordinates `an_x' and `an_y' and the number of characters
  262. -- in the grapheme (0 represents the trailing edge of the
  263. -- grapheme) Buffer coordinates are coordinates for the
  264. -- entire buffer, not just the currently-displayed
  265. -- portion. If you have coordinates from an event, you have
  266. -- to convert those to buffer coordinates with
  267. -- `window_to_buffer_coords'.
  268. -- Note that this is different from `iter_at_location', which
  269. -- returns cursor locations, i.e. positions between
  270. -- characters.
  271. local an_iter: GTK_TEXT_ITER; a_trailing: INTEGER
  272. do
  273. create an_iter.make
  274. gtk_text_view_get_iter_at_position (handle, an_iter.handle,
  275. $a_trailing, an_x, an_y)
  276. create Result.make_2(an_iter, a_trailing)
  277. ensure
  278. not_void: Result /= Void
  279. iter_not_void: Result.item_1 /= Void
  280. end
  281. buffer_to_window_coords (a_window_type: INTEGER;
  282. buffer_x, buffer_y: INTEGER): TUPLE[INTEGER, INTEGER] is
  283. -- Converts coordinate (buffer_x, buffer_y) to coordinates
  284. -- for the window of `a_widndow_type' (except gtk_text_window_private). Result is
  285. -- [window_x,window_y].
  286. -- Note that you can't convert coordinates for a nonexisting
  287. -- window (see `set_border_window_size').
  288. -- win : a GtkTextWindowType
  289. require
  290. valid_window_type: is_valid_gtk_text_window_type (a_window_type)
  291. window_type_is_not_private: a_window_type /= gtk_text_window_private
  292. local window_x, window_y: INTEGER
  293. do
  294. gtk_text_view_buffer_to_window_coords
  295. (handle, a_window_type, buffer_x, buffer_y, $window_x, $window_y)
  296. create Result.make_2 (window_x, window_y)
  297. end
  298. window_to_buffer_coords (a_window_type: INTEGER;
  299. window_x, window_y: INTEGER): TUPLE[INTEGER, INTEGER] is
  300. -- Converts coordinates on the window identified by win to
  301. -- buffer coordinates, storing the result in
  302. -- (buffer_x,buffer_y).
  303. -- Note that you can't convert coordinates for a nonexisting
  304. -- window (see `set_border_window_size').
  305. require
  306. valid_window_type: is_valid_gtk_text_window_type (a_window_type)
  307. window_type_is_not_private: a_window_type /= gtk_text_window_private
  308. local buffer_x, buffer_y: INTEGER
  309. do
  310. gtk_text_view_window_to_buffer_coords
  311. (handle, a_window_type, window_x, window_y, $buffer_x, $buffer_y)
  312. create Result.make_2 (buffer_x, buffer_y)
  313. end
  314. window (a_text_window_type: INTEGER) : GDK_WINDOW is
  315. -- The GDK_WINDOW corresponding to an area of the text view;
  316. -- possible windows include the overall widget window, child
  317. -- windows on the left, right, top, bottom, and the window
  318. -- that displays the text buffer. Windows are Void and
  319. -- nonexistent if their width or height is 0, and are
  320. -- nonexistent before the widget has been realized.
  321. require valid_window_type: is_valid_gtk_text_window_type (a_text_window_type)
  322. local factory: G_OBJECT_EXPANDED_FACTORY [GDK_WINDOW]
  323. do
  324. Result := factory.wrapper (gtk_text_view_get_window (handle, a_text_window_type))
  325. end
  326. window_type (a_window: GDK_WINDOW): INTEGER is
  327. -- Usually used to find out which window an event corresponds
  328. -- to. If you connect to an event signal on text_view, this
  329. -- function should be called on event->window to see which
  330. -- window it was.
  331. do
  332. Result := gtk_text_view_get_window_type (handle, a_window.handle)
  333. ensure is_valid_gtk_text_window_type (Result)
  334. end
  335. set_border_window_size (a_window_type: INTEGER; a_size: INTEGER) is
  336. -- Sets the width of `gtk_text_window_left' or
  337. -- `gtk_text_window_right', or the height of
  338. -- `gtk_text_window_top' or
  339. -- `gtk_text_window_bottom'. Automatically destroys the
  340. -- corresponding window if the size is set to 0, and creates
  341. -- the window if the size is set to non-zero. This function
  342. -- can only be used for the "border windows," it doesn't work
  343. -- with `gtk_text_window_widget', `gtk_text_window_text', or
  344. -- `gtk_text_window_private'.
  345. require
  346. valid_type: is_valid_gtk_text_window_type (a_window_type)
  347. correct_type: ((a_window_type /= gtk_text_window_widget) and
  348. (a_window_type /= gtk_text_window_text) and
  349. (a_window_type /= gtk_text_window_private))
  350. do
  351. gtk_text_view_set_border_window_size (handle, a_window_type, a_size)
  352. end
  353. border_window_size (a_window_type: INTEGER): INTEGER is
  354. -- the width of the specified border window. See
  355. -- `set_border_window_size'.
  356. require
  357. valid_type: is_valid_gtk_text_window_type (a_window_type)
  358. do
  359. Result := gtk_text_view_get_border_window_size (handle, a_window_type)
  360. end
  361. feature -- Iterator moving command
  362. forward_display_line (an_iterator: GTK_TEXT_ITER) is
  363. -- Moves `an_iterator' forward by one display (wrapped)
  364. -- line. A display line is different from a
  365. -- paragraph. Paragraphs are separated by newlines or other
  366. -- paragraph separator characters. Display lines are created
  367. -- by line-wrapping a paragraph. If wrapping is turned off,
  368. -- display lines and paragraphs will be the same. Display
  369. -- lines are divided differently for each view, since they
  370. -- depend on the view's width; paragraphs are the same in all
  371. -- views, since they depend on the contents of the
  372. -- GtkTextBuffer.
  373. -- `was_iter_moved' will be True if iter was moved and is not
  374. -- on the end iterator
  375. require iterator_not_void: an_iterator/=Void
  376. do
  377. was_iter_moved := gtk_text_view_forward_display_line (handle, an_iterator.handle).to_boolean
  378. end
  379. backward_display_line (an_iter: GTK_TEXT_ITER) is
  380. -- Moves `an_iter' backward by one display (wrapped) line. A
  381. -- display line is different from a paragraph. Paragraphs are
  382. -- separated by newlines or other paragraph separator
  383. -- characters. Display lines are created by line-wrapping a
  384. -- paragraph. If wrapping is turned off, display lines and
  385. -- paragraphs will be the same. Display lines are divided
  386. -- differently for each view, since they depend on the view's
  387. -- width; paragraphs are the same in all views, since they
  388. -- depend on the contents of the GtkTextBuffer.
  389. -- `was_iter_moved' will be True if iter was moved and is not
  390. -- on the end iterator
  391. require iterator_not_void: an_iter/=Void
  392. do
  393. was_iter_moved := gtk_text_view_backward_display_line(handle,an_iter.handle).to_boolean
  394. end
  395. forward_display_line_end (an_iter: GTK_TEXT_ITER) is
  396. -- Moves `an_iter' forward to the next display line end. A
  397. -- display line is different from a paragraph. Paragraphs are
  398. -- separated by newlines or other paragraph separator
  399. -- characters. Display lines are created by line-wrapping a
  400. -- paragraph. If wrapping is turned off, display lines and
  401. -- paragraphs will be the same. Display lines are divided
  402. -- differently for each view, since they depend on the view's
  403. -- width; paragraphs are the same in all views, since they
  404. -- depend on the contents of the GtkTextBuffer.
  405. -- `was_iter_moved' will be True if iter was moved and is not
  406. -- on the end iterator.
  407. require iterator_not_void: an_iter/=Void
  408. do
  409. was_iter_moved:=gtk_text_view_forward_display_line_end(handle,an_iter.handle).to_boolean
  410. end
  411. backward_display_line_start (an_iter: GTK_TEXT_ITER) is
  412. -- Moves `an_iter' backward to the next display line start. A
  413. -- display line is different from a paragraph. Paragraphs are
  414. -- separated by newlines or other paragraph separator
  415. -- characters. Display lines are created by line-wrapping a
  416. -- paragraph. If wrapping is turned off, display lines and
  417. -- paragraphs will be the same. Display lines are divided
  418. -- differently for each view, since they depend on the view's
  419. -- width; paragraphs are the same in all views, since they
  420. -- depend on the contents of the GtkTextBuffer.
  421. -- `was_iter_moved' will be True if iter was moved and is not
  422. -- on the end iterator.
  423. require iterator_not_void: an_iter/=Void
  424. do
  425. was_iter_moved:=gtk_text_view_backward_display_line_start(handle,an_iter.handle).to_boolean
  426. end
  427. feature -- Iterator queries
  428. does_start_display_line (an_iter: GTK_TEXT_ITER): BOOLEAN is
  429. -- Does `an_iter' begin a display (wrapped) line? See
  430. -- `forward_display_line' for an explanation of display lines
  431. -- vs. paragraphs.
  432. do
  433. Result:=gtk_text_view_starts_display_line(handle, an_iter.handle).to_boolean
  434. end
  435. -- gtk_text_view_move_visually ()
  436. -- gboolean gtk_text_view_move_visually (GtkTextView *text_view,
  437. -- GtkTextIter *iter,
  438. -- gint count);
  439. -- Move the iterator a given number of characters visually, treating it as
  440. -- the strong cursor position. If count is positive, then the new strong
  441. -- cursor position will be count positions to the right of the old cursor
  442. -- position. If count is negative then the new strong cursor position will
  443. -- be count positions to the left of the old cursor position.
  444. -- In the presence of bidirection text, the correspondence between logical
  445. -- and visual order will depend on the direction of the current run, and
  446. -- there may be jumps when the cursor is moved off of the end of a run.
  447. -- text_view : a GtkTextView
  448. -- iter : a GtkTextIter
  449. -- count : number of characters to move (negative moves left, positive
  450. -- moves right)
  451. -- Returns : TRUE if iter moved and is not on the end iterator
  452. -- -----------------------------------------------------------------------
  453. -- gtk_text_view_add_child_at_anchor ()
  454. -- void gtk_text_view_add_child_at_anchor
  455. -- (GtkTextView *text_view,
  456. -- GtkWidget *child,
  457. -- GtkTextChildAnchor *anchor);
  458. -- Adds a child widget in the text buffer, at the given anchor.
  459. -- text_view : a GtkTextView
  460. -- child : a GtkWidget
  461. -- anchor : a GtkTextChildAnchor in the GtkTextBuffer for text_view
  462. -- -----------------------------------------------------------------------
  463. -- gtk_text_view_add_child_in_window ()
  464. -- void gtk_text_view_add_child_in_window
  465. -- (GtkTextView *text_view,
  466. -- GtkWidget *child,
  467. -- GtkTextWindowType which_window,
  468. -- gint xpos,
  469. -- gint ypos);
  470. -- Adds a child at fixed coordinates in one of the text widget's windows.
  471. -- The window must have nonzero size (see
  472. -- gtk_text_view_set_border_window_size()). Note that the child
  473. -- coordinates are given relative to the GdkWindow in question, and that
  474. -- these coordinates have no sane relationship to scrolling. When placing
  475. -- a child in GTK_TEXT_WINDOW_WIDGET, scrolling is irrelevant, the child
  476. -- floats above all scrollable areas. But when placing a child in one of
  477. -- the scrollable windows (border windows or text window), you'll need to
  478. -- compute the child's correct position in buffer coordinates any time
  479. -- scrolling occurs or buffer changes occur, and then call
  480. -- gtk_text_view_move_child() to update the child's position.
  481. -- Unfortunately there's no good way to detect that scrolling has
  482. -- occurred, using the current API; a possible hack would be to update all
  483. -- child positions when the scroll adjustments change or the text buffer
  484. -- changes. See bug 64518 on bugzilla.gnome.org for status of fixing this
  485. -- issue.
  486. -- text_view : a GtkTextView
  487. -- child : a GtkWidget
  488. -- which_window : which window the child should appear in
  489. -- xpos : X position of child in window coordinates
  490. -- ypos : Y position of child in window coordinates
  491. -- -----------------------------------------------------------------------
  492. -- gtk_text_view_move_child ()
  493. -- void gtk_text_view_move_child (GtkTextView *text_view,
  494. -- GtkWidget *child,
  495. -- gint xpos,
  496. -- gint ypos);
  497. -- Updates the position of a child, as for
  498. -- gtk_text_view_add_child_in_window().
  499. -- text_view : a GtkTextView
  500. -- child : child widget already added to the text view
  501. -- xpos : new X position in window coordinates
  502. -- ypos : new Y position in window coordinates
  503. -- -----------------------------------------------------------------------
  504. feature -- Wrap mode
  505. set_wrap_mode (a_mode: INTEGER) is
  506. -- Sets the line wrapping for the view.
  507. require valid_mode: is_valid_gtk_wrap_mode (a_mode)
  508. do
  509. gtk_text_view_set_wrap_mode (handle, a_mode)
  510. end
  511. wrap_mode: INTEGER is
  512. -- the line wrapping for the view.
  513. do
  514. Result := gtk_text_view_get_wrap_mode (handle)
  515. ensure valid_mode: is_valid_gtk_wrap_mode (Result)
  516. end
  517. feature -- Editabilty
  518. set_editable is
  519. -- Makes Current GtkTextView editable. You can override this
  520. -- default setting with tags in the buffer, using the
  521. -- "editable" attribute of tags.
  522. do
  523. gtk_text_view_set_editable (handle, 1)
  524. ensure editable: is_editable
  525. end
  526. set_uneditable is
  527. -- Makes Current GtkTextView not editable. You can override this
  528. -- default setting with tags in the buffer, using the
  529. -- "editable" attribute of tags.
  530. do
  531. gtk_text_view_set_editable (handle, 0)
  532. ensure uneditable: not is_editable
  533. end
  534. is_editable: BOOLEAN is
  535. -- Is Current GTK_TEXT_VIEW editable? Tags in the buffer may
  536. -- override this setting for some ranges of text.
  537. do
  538. Result := (gtk_text_view_get_editable (handle).to_boolean)
  539. end
  540. feature -- Cursor visibility
  541. set_cursor_visible is
  542. -- Displays the insertion point.
  543. do
  544. gtk_text_view_set_cursor_visible (handle, 1)
  545. ensure visible_cursor: is_cursor_visible
  546. end
  547. set_cursor_invisible is
  548. -- Hides the insertion point. A buffer with no editable text
  549. -- probably shouldn't have a visible cursor, so you may want
  550. -- to turn the cursor off.
  551. do
  552. gtk_text_view_set_cursor_visible (handle, 0)
  553. ensure invisible_cursor: not is_cursor_visible
  554. end
  555. is_cursor_visible: BOOLEAN is
  556. -- Is the cursor being displayed?
  557. do
  558. Result := gtk_text_view_get_cursor_visible (handle).to_boolean
  559. end
  560. feature
  561. set_overwrite is
  562. -- Turns the GtkTextView overwrite mode on.
  563. do
  564. gtk_text_view_set_overwrite (handle, 1)
  565. ensure overwrite_set: is_overwrite_set
  566. end
  567. unset_overwrite is
  568. -- Turns the GtkTextView overwrite mode off.
  569. do
  570. gtk_text_view_set_overwrite (handle, 0)
  571. ensure overwrite_unset: not is_overwrite_set
  572. end
  573. is_overwrite_set: BOOLEAN is
  574. -- Is the GtkTextView is in overwrite mode?
  575. do
  576. Result := gtk_text_view_get_overwrite (handle).to_boolean
  577. end
  578. feature -- Pixels above and below lines
  579. set_pixels_above_lines (a_setting: INTEGER) is
  580. -- Sets the default number of blank pixels above paragraphs
  581. -- in text_view. Tags in the buffer may override the
  582. -- defaults.
  583. do
  584. gtk_text_view_set_pixels_above_lines (handle, a_setting)
  585. ensure
  586. set: pixels_above_lines = a_setting
  587. end
  588. pixels_above_lines: INTEGER is
  589. -- the default number of pixels to put above paragraphs.
  590. do
  591. Result:=gtk_text_view_get_pixels_above_lines(handle)
  592. end
  593. set_pixels_below_lines (a_setting: INTEGER) is
  594. -- Sets the default number of pixels of blank space to put
  595. -- below paragraphs in text_view. May be overridden by tags
  596. -- applied to text_view's buffer.
  597. do
  598. gtk_text_view_set_pixels_below_lines(handle,a_setting)
  599. ensure
  600. set: pixels_below_lines = a_setting
  601. end
  602. pixels_below_lines: INTEGER is
  603. -- default number of blank pixels below paragraphs
  604. do
  605. Result := gtk_text_view_get_pixels_below_lines(handle)
  606. end
  607. set_pixels_inside_wrap (a_setting: INTEGER) is
  608. -- Sets the default number of pixels of blank space to leave
  609. -- between display/wrapped lines within a paragraph. May be
  610. -- overridden by tags in text_view's buffer.
  611. do
  612. gtk_text_view_set_pixels_inside_wrap(handle,a_setting)
  613. ensure
  614. set: pixels_inside_wrap = a_setting
  615. end
  616. pixels_inside_wrap: INTEGER is
  617. -- the default number of pixels of blank space between
  618. -- wrapped lines
  619. do
  620. Result:=gtk_text_view_get_pixels_inside_wrap(handle)
  621. end
  622. set_justification (a_justification: INTEGER) is
  623. -- Sets the default justification of text in text view. Tags
  624. -- in the view's buffer may override the default.
  625. require valid_justification: is_valid_gtk_justification(a_justification)
  626. do
  627. gtk_text_view_set_justification (handle,a_justification)
  628. ensure set: a_justification = justification
  629. end
  630. justification: INTEGER is
  631. -- the default justification of paragraphs in text view. Tags
  632. -- in the buffer may override the default.
  633. do
  634. Result:=gtk_text_view_get_justification(handle)
  635. ensure valid: is_valid_gtk_justification(Result)
  636. end
  637. set_left_margin (a_left_margin: INTEGER) is
  638. -- Sets the default left margin for text in text view. Tags
  639. -- in the buffer may override the default. Margin in
  640. -- expressed in pixels.
  641. do
  642. gtk_text_view_set_left_margin (handle, a_left_margin)
  643. ensure set: a_left_margin = left_margin
  644. end
  645. left_margin: INTEGER is
  646. -- the default left margin size of paragraphs in the text
  647. -- view. Tags in the buffer may override the default. Margin
  648. -- is expressed in pixels.
  649. do
  650. Result:=gtk_text_view_get_left_margin(handle)
  651. end
  652. set_right_margin (a_right_margin: INTEGER) is
  653. -- Sets the default right margin for text in text view. Tags
  654. -- in the buffer may override the default. Margin in
  655. -- expressed in pixels.
  656. do
  657. gtk_text_view_set_right_margin (handle, a_right_margin)
  658. ensure set: a_right_margin = right_margin
  659. end
  660. right_margin: INTEGER is
  661. -- the default right margin size of paragraphs in the text
  662. -- view. Tags in the buffer may override the default. Margin
  663. -- is expressed in pixels.
  664. do
  665. Result:=gtk_text_view_get_right_margin(handle)
  666. end
  667. set_indent (an_indent: INTEGER) is
  668. -- Sets the default indentation (in pixels) for paragraphs in
  669. -- text view. Tags in the buffer may override the default.
  670. do
  671. gtk_text_view_set_indent(handle, an_indent)
  672. end
  673. indent: INTEGER is
  674. -- The default indentation (in pixels) of paragraphs in text
  675. -- view. Tags in the view's buffer may override the
  676. -- default. The indentation may be negative.
  677. do
  678. Result:=gtk_text_view_get_indent(handle)
  679. end
  680. -- gtk_text_view_set_tabs ()
  681. -- void gtk_text_view_set_tabs (GtkTextView *text_view,
  682. -- PangoTabArray *tabs);
  683. -- Sets the default tab stops for paragraphs in text_view. Tags in the
  684. -- buffer may override the default.
  685. -- text_view : a GtkTextView
  686. -- tabs : tabs as a PangoTabArray
  687. -- -----------------------------------------------------------------------
  688. -- gtk_text_view_get_tabs ()
  689. -- PangoTabArray* gtk_text_view_get_tabs (GtkTextView *text_view);
  690. -- Gets the default tabs for text_view. Tags in the buffer may override
  691. -- the defaults. The returned array will be NULL if "standard" (8-space)
  692. -- tabs are used. Free the return value with pango_tab_array_free().
  693. -- text_view : a GtkTextView
  694. -- Returns : copy of default tab array, or NULL if "standard" tabs are
  695. -- used; must be freed with pango_tab_array_free().
  696. -- -----------------------------------------------------------------------
  697. -- gtk_text_view_set_accepts_tab ()
  698. -- void gtk_text_view_set_accepts_tab (GtkTextView *text_view,
  699. -- gboolean accepts_tab);
  700. -- Sets the behavior of the text widget when the Tab key is pressed. If
  701. -- accepts_tab is TRUE a tab character is inserted. If accepts_tab is
  702. -- FALSE the keyboard focus is moved to the next widget in the focus
  703. -- chain.
  704. -- text_view : A GtkTextView
  705. -- accepts_tab : TRUE if pressing the Tab key should insert a tab
  706. -- character, FALSE, if pressing the Tab key should move the
  707. -- keyboard focus.
  708. -- Since 2.4
  709. -- -----------------------------------------------------------------------
  710. -- gtk_text_view_get_accepts_tab ()
  711. -- gboolean gtk_text_view_get_accepts_tab (GtkTextView *text_view);
  712. -- Returns whether pressing the Tab key inserts a tab characters.
  713. -- gtk_text_view_set_accepts_tab().
  714. -- text_view : A GtkTextView
  715. -- Returns : TRUE if pressing the Tab key inserts a tab character, FALSE
  716. -- if pressing the Tab key moves the keyboard focus.
  717. -- Since 2.4
  718. -- -----------------------------------------------------------------------
  719. default_attributes: GTK_TEXT_ATTRIBUTES is
  720. -- Obtains a copy of the default text attributes. These are the attributes
  721. -- used for text unless a tag overrides them. You'd typically pass the
  722. -- default attributes in to TEXT_ITER:attributes() in order to get
  723. -- the attributes in effect at a given text position.
  724. --
  725. -- The return value is a copy owned by the caller of this function, and
  726. -- should be freed.
  727. -- text_view : a GtkTextView
  728. -- Returns : a new GtkTextAttributes
  729. do
  730. create Result.from_external_pointer (gtk_text_view_get_default_attributes (handle))
  731. end
  732. -- -----------------------------------------------------------------------
  733. -- GTK_TEXT_VIEW_PRIORITY_VALIDATE
  734. -- #define GTK_TEXT_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
  735. -- The priority at which the text view validates onscreen lines in an idle
  736. -- job in the background.
  737. feature -- TODO: Property Details
  738. -- The "accepts-tab" property
  739. -- "accepts-tab" gboolean : Read / Write
  740. -- Whether Tab will result in a tab character being entered.
  741. -- Default value: TRUE
  742. -- -----------------------------------------------------------------------
  743. -- The "buffer" property
  744. -- "buffer" GtkTextBuffer : Read / Write
  745. -- The buffer which is displayed.
  746. -- -----------------------------------------------------------------------
  747. -- The "cursor-visible" property
  748. -- "cursor-visible" gboolean : Read / Write
  749. -- If the insertion cursor is shown.
  750. -- Default value: TRUE
  751. -- -----------------------------------------------------------------------
  752. -- The "editable" property
  753. -- "editable" gboolean : Read / Write
  754. -- Whether the text can be modified by the user.
  755. -- Default value: TRUE
  756. -- -----------------------------------------------------------------------
  757. -- The "indent" property
  758. -- "indent" gint : Read / Write
  759. -- Amount to indent the paragraph, in pixels.
  760. -- Allowed values: >= 0
  761. -- Default value: 0
  762. -- -----------------------------------------------------------------------
  763. -- The "justification" property
  764. -- "justification" GtkJustification : Read / Write
  765. -- Left, right, or center justification.
  766. -- Default value: GTK_JUSTIFY_LEFT
  767. -- -----------------------------------------------------------------------
  768. -- The "left-margin" property
  769. -- "left-margin" gint : Read / Write
  770. -- Width of the left margin in pixels.
  771. -- Allowed values: >= 0
  772. -- Default value: 0
  773. -- -----------------------------------------------------------------------
  774. -- The "overwrite" property
  775. -- "overwrite" gboolean : Read / Write
  776. -- Whether entered text overwrites existing contents.
  777. -- Default value: FALSE
  778. -- -----------------------------------------------------------------------
  779. -- The "pixels-above-lines" property
  780. -- "pixels-above-lines" gint : Read / Write
  781. -- Pixels of blank space above paragraphs.
  782. -- Allowed values: >= 0
  783. -- Default value: 0
  784. -- -----------------------------------------------------------------------
  785. -- The "pixels-below-lines" property
  786. -- "pixels-below-lines" gint : Read / Write
  787. -- Pixels of blank space below paragraphs.
  788. -- Allowed values: >= 0
  789. -- Default value: 0
  790. -- -----------------------------------------------------------------------
  791. -- The "pixels-inside-wrap" property
  792. -- "pixels-inside-wrap" gint : Read / Write
  793. -- Pixels of blank space between wrapped lines in a paragraph.
  794. -- Allowed values: >= 0
  795. -- Default value: 0
  796. -- -----------------------------------------------------------------------
  797. -- The "right-margin" property
  798. -- "right-margin" gint : Read / Write
  799. -- Width of the right margin in pixels.
  800. -- Allowed values: >= 0
  801. -- Default value: 0
  802. -- -----------------------------------------------------------------------
  803. -- The "tabs" property
  804. -- "tabs" PangoTabArray : Read / Write
  805. -- Custom tabs for this text.
  806. -- -----------------------------------------------------------------------
  807. -- The "wrap-mode" property
  808. -- "wrap-mode" GtkWrapMode : Read / Write
  809. -- Whether to wrap lines never, at word boundaries, or at character
  810. -- boundaries.
  811. -- Default value: GTK_WRAP_NONE
  812. -- Style Property Details
  813. -- The "error-underline-color" style property
  814. -- "error-underline-color" GdkColor : Read
  815. -- Color with which to draw error-indication underlines.
  816. feature {} -- TODO: Signals
  817. -- The "backspace" signal
  818. -- void user_function (GtkTextView *textview,
  819. -- gpointer user_data) : Run last / Action
  820. -- textview : the object which received the signal.
  821. -- user_data : user data set when the signal handler was connected.
  822. -- -----------------------------------------------------------------------
  823. -- The "copy-clipboard" signal
  824. -- void user_function (GtkTextView *textview,
  825. -- gpointer user_data) : Run last / Action
  826. -- textview : the object which received the signal.
  827. -- user_data : user data set when the signal handler was connected.
  828. -- -----------------------------------------------------------------------
  829. -- The "cut-clipboard" signal
  830. -- void user_function (GtkTextView *textview,
  831. -- gpointer user_data) : Run last / Action
  832. -- textview : the object which received the signal.
  833. -- user_data : user data set when the signal handler was connected.
  834. -- -----------------------------------------------------------------------
  835. -- The "delete-from-cursor" signal
  836. -- void user_function (GtkTextView *textview,
  837. -- GtkDeleteType *arg1,
  838. -- gint arg2,
  839. -- gpointer user_data) : Run last / Action
  840. -- textview : the object which received the signal.
  841. -- arg1 :
  842. -- arg2 :
  843. -- user_data : user data set when the signal handler was connected.
  844. -- -----------------------------------------------------------------------
  845. feature -- The "insert-at-cursor" signal
  846. connect_agent_to_insert_at_cursor_signal (a_procedure: PROCEDURE[ANY, TUPLE [STRING, GTK_TEXT_VIEW]]) is
  847. -- textview : the object which received the signal.
  848. -- arg1 :
  849. require
  850. valid_procedure: a_procedure /= Void
  851. wrapper_is_stored: is_eiffel_wrapper_stored
  852. local
  853. insert_at_cursor_callback: INSERT_AT_CURSOR_CALLBACK
  854. do
  855. create insert_at_cursor_callback.make
  856. insert_at_cursor_callback.connect (Current, a_procedure)
  857. end
  858. -- -----------------------------------------------------------------------
  859. feature -- The "move-cursor" signal
  860. connect_agent_to_move_cursor_signal (a_procedure: PROCEDURE[ANY, TUPLE [INTEGER, INTEGER, BOOLEAN, GTK_TEXT_VIEW]]) is
  861. -- The ::move-cursor signal is a keybinding signal which gets emitted when
  862. -- the user initiates a cursor movement.
  863. -- Applications should not connect to it, but may emit it with
  864. -- g_signal_emit_by_name() if they need to control scrolling
  865. -- programmatically.
  866. -- widget : the object which received the signal
  867. -- step : the granularity of the move, as a GtkMovementStep
  868. -- count : the number of step units to move
  869. -- extend_selection : True if the move should extend the selection
  870. require
  871. valid_procedure: a_procedure /= Void
  872. wrapper_is_stored: is_eiffel_wrapper_stored
  873. local
  874. move_cursor_callback: MOVE_CURSOR_CALLBACK
  875. do
  876. create move_cursor_callback.make
  877. move_cursor_callback.connect (Current, a_procedure)
  878. end
  879. -- -----------------------------------------------------------------------
  880. -- The "move-focus" signal
  881. -- void user_function (GtkTextView *textview,
  882. -- GtkDirectionType *arg1,
  883. -- gpointer user_data) : Run last / Action
  884. -- textview : the object which received the signal.
  885. -- arg1 :
  886. -- user_data : user data set when the signal handler was connected.
  887. -- -----------------------------------------------------------------------
  888. -- The "move-viewport" signal
  889. -- void user_function (GtkTextView *textview,
  890. -- GtkScrollStep *arg1,
  891. -- gint arg2,
  892. -- gpointer user_data) : Run last / Action
  893. -- textview : the object which received the signal.
  894. -- arg1 :
  895. -- arg2 :
  896. -- user_data : user data set when the signal handler was connected.
  897. -- -----------------------------------------------------------------------
  898. -- The "page-horizontally" signal
  899. -- void user_function (GtkTextView *textview,
  900. -- gint arg1,
  901. -- gboolean arg2,
  902. -- gpointer user_data) : Run last / Action
  903. -- textview : the object which received the signal.
  904. -- arg1 :
  905. -- arg2 :
  906. -- user_data : user data set when the signal handler was connected.
  907. -- -----------------------------------------------------------------------
  908. feature -- The "paste-clipboard" signal
  909. connect_agent_to_paste_clipboard_signal (a_procedure: PROCEDURE[ANY, TUPLE [GTK_TEXT_VIEW]]) is
  910. -- The ::paste-clipboard signal is a keybinding signal which gets
  911. -- emitted to paste the contents of the clipboard into the text view.
  912. --
  913. -- The default bindings for this signal are Ctrl-v and Shift-Insert.
  914. --
  915. -- textview : the object which received the signal.
  916. -- user_data : user data set when the signal handler was connected.
  917. require
  918. valid_procedure: a_procedure /= Void
  919. wrapper_is_stored: is_eiffel_wrapper_stored
  920. local
  921. paste_clipboard_callback: PASTE_CLIPBOARD_CALLBACK
  922. do
  923. create paste_clipboard_callback.make
  924. paste_clipboard_callback.connect (Current, a_procedure)
  925. end
  926. -- -----------------------------------------------------------------------
  927. -- The "populate-popup" signal
  928. -- void user_function (GtkTextView *textview,
  929. -- GtkMenu *arg1,
  930. -- gpointer user_data) : Run last
  931. -- textview : the object which received the signal.
  932. -- arg1 :
  933. -- user_data : user data set when the signal handler was connected.
  934. -- -----------------------------------------------------------------------
  935. -- The "select-all" signal
  936. -- void user_function (GtkTextView *textview,
  937. -- gboolean arg1,
  938. -- gpointer user_data) : Run last / Action
  939. -- textview : the object which received the signal.
  940. -- arg1 :
  941. -- user_data : user data set when the signal handler was connected.
  942. -- -----------------------------------------------------------------------
  943. -- The "set-anchor" signal
  944. -- void user_function (GtkTextView *textview,
  945. -- gpointer user_data) : Run last / Action
  946. -- textview : the object which received the signal.
  947. -- user_data : user data set when the signal handler was connected.
  948. -- -----------------------------------------------------------------------
  949. -- The "set-scroll-adjustments" signal
  950. -- void user_function (GtkTextView *textview,
  951. -- GtkAdjustment *arg1,
  952. -- GtkAdjustment *arg2,
  953. -- gpointer user_data) : Run last / Action
  954. -- textview : the object which received the signal.
  955. -- arg1 :
  956. -- arg2 :
  957. -- user_data : user data set when the signal handler was connected.
  958. -- -----------------------------------------------------------------------
  959. -- The "toggle-overwrite" signal
  960. -- void user_function (GtkTextView *textview,
  961. -- gpointer user_data) : Run last / Action
  962. -- textview : the object which received the signal.
  963. -- user_data : user data set when the signal handler was connected.
  964. feature -- struct size
  965. struct_size: INTEGER is
  966. external "C inline use <gtk/gtk.h>"
  967. alias "sizeof(GtkTextView)"
  968. end
  969. end -- class GTK_TEXT_VIEW