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