Automatic generation produced by ISE Eiffel
note description: "[ Read only text with cursor and selection. ]" legal: "See notice at end of class." status: "See notice at end of class." author: "Etienne Amodeo" date: "$Date: 2022-06-28 06:09:22 -0800 (Tue, 28 Jun 2022) $" revision: "$Revision: 106318 $" class interface SELECTABLE_TEXT create make -- create an empty text -- (from TEXT) require -- from B_345_TREE True require -- from TEXT_OBSERVER_MANAGER True feature -- Initialization make -- create an empty text -- (from TEXT) require -- from B_345_TREE True require -- from TEXT_OBSERVER_MANAGER True reset_text -- reset the text to its original, empty state feature -- Access attached_cursor: like cursor -- Attached `cursor`. require not_is_empty: not is_empty and then has_cursor attached_selection_cursor: like cursor -- Attached `selection_cursor`. require not_is_empty: not is_empty number_of_lines: INTEGER_32 -- (from B_345_TREE) current_char: CHARACTER_32 -- Current character at cursor position require text_is_not_empty: not is_empty current_class: DOCUMENT_CLASS -- Current document class -- (from DOCUMENT_TYPE_MANAGER) require -- from DOCUMENT_TYPE_MANAGER current_class_set: current_class_set current_line: like line -- current line -- (from TEXT) current_line_number: INTEGER_32 -- Current line number. require text_is_not_empty: not is_empty cursor: TEXT_CURSOR -- Current cursor. Default_document_class: DOCUMENT_CLASS -- Default text class -- (from DOCUMENT_TYPE_MANAGER) ev_application: EV_APPLICATION -- Current application if created yet. -- (from EV_SHARED_APPLICATION) require -- from EV_SHARED_APPLICATION application_exists: attached Shared_environment.application same_processor_as_application: Shared_environment.is_application_processor ev_separate_application: separate EV_APPLICATION -- Current application if created yet. -- (from EV_SHARED_APPLICATION) require -- from EV_SHARED_APPLICATION application_exists: attached Shared_environment.application first_line: EDITOR_LINE -- (from TEXT) first_read_block_size: INTEGER_32 -- size in lines of the first block of text that -- will be read. -- (from TEXT) generating_type: TYPE [SELECTABLE_TEXT] -- Type of current object -- (type of which it is a direct instance) -- (from ANY) ensure -- from ANY generating_type_not_void: Result /= Void generator: STRING_8 -- Name of current object's generating class -- (base class of the type of which it is a direct instance) -- (from ANY) ensure -- from ANY generator_not_void: Result /= Void generator_not_empty: not Result.is_empty line (i: INTEGER_32): like first_line -- (from B_345_TREE) require -- from B_345_TREE i_is_valid: i >= 1 and i <= number_of_lines last_line: like first_line -- (from B_345_TREE) selected_wide_string: STRING_32 require text_is_not_empty: not is_empty selection_cursor: like cursor -- Position where the user has started to select -- the text. This position can be below the current -- cursor (and therefore represent the end of the -- selection) selection_end: like cursor -- End of the selection (always > than -- `selection_start`). require text_is_not_empty: not is_empty ensure result_cursor_position_greater: Result >= selection_start selection_start: like cursor -- Beginning of the selection (always < than -- `selection_end`). require text_is_not_empty: not is_empty ensure result_cursor_position_lesser: Result <= selection_end Shared_environment: EV_ENVIRONMENT -- Shared EV_ENVIRONMENT object. -- (from EV_SHARED_APPLICATION) tabulation_size: INTEGER_32 -- Tabulation size in characters. -- (from TEXT) text_loaded: STRING_8 -- Text in UTF-8 loaded by `load_string` -- (from TEXT) wide_text: STRING_32 -- Image of text in Current. -- In UTF-32. -- (from TEXT) require -- from TEXT text_loaded: reading_text_finished feature -- Comparison frozen deep_equal (a: ANY; b: like arg #1): BOOLEAN -- Are a and b either both void -- or attached to isomorphic object structures? -- (from ANY) ensure -- from ANY instance_free: class shallow_implies_deep: standard_equal (a, b) implies Result both_or_none_void: (a = Void) implies (Result = (b = Void)) same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b)) symmetric: Result implies deep_equal (b, a) frozen equal (a: ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached -- to objects considered equal? -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b)) frozen is_deep_equal alias "≡≡≡" (other: SELECTABLE_TEXT): BOOLEAN -- Are Current and other attached to isomorphic object structures? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY shallow_implies_deep: standard_is_equal (other) implies Result same_type: Result implies same_type (other) symmetric: Result implies other.is_deep_equal (Current) is_equal (other: SELECTABLE_TEXT): BOOLEAN -- Is other attached to an object considered -- equal to current object? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY symmetric: Result implies other ~ Current consistent: standard_is_equal (other) implies Result frozen standard_equal (a: ANY; b: like arg #1): BOOLEAN -- Are a and b either both void or attached to -- field-by-field identical objects of the same type? -- Always uses default object comparison criterion. -- (from ANY) ensure -- from ANY instance_free: class definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b)) frozen standard_is_equal alias "≜" (other: SELECTABLE_TEXT): BOOLEAN -- Is other attached to an object of the same type -- as current object, and field-by-field identical to it? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY same_type: Result implies same_type (other) symmetric: Result implies other.standard_is_equal (Current) feature -- Status report conforms_to (other: ANY): BOOLEAN -- Does type of current object conform to type -- of other (as per Eiffel: The Language, chapter 13)? -- (from ANY) require -- from ANY other_not_void: other /= Void has_cursor: BOOLEAN -- is `cursor` set? has_selection: BOOLEAN -- Is there a selection? is_empty: BOOLEAN -- Is there no text loaded in the editor ? -- (from TEXT) is_modified: BOOLEAN -- Has the text been modified since it was opened? -- (from TEXT_OBSERVER_MANAGER) is_notifying: BOOLEAN -- Is the manager in the process of notifying its observers -- of a change ? -- (from TEXT_OBSERVER_MANAGER) is_removing_block: BOOLEAN -- (from TEXT_OBSERVER_MANAGER) is_windows_eol_style: BOOLEAN -- Is the text windows eol style? -- (from TEXT) reading_text_finished: BOOLEAN -- Is text completely read? -- (from TEXT) same_type (other: ANY): BOOLEAN -- Is type of current object identical to type of other? -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY definition: Result = (conforms_to (other) and other.conforms_to (Current)) selection_is_empty: BOOLEAN -- Is the selection empty ? require text_is_not_empty: not is_empty text_being_processed: BOOLEAN -- is the text currently processed? -- (from TEXT) feature -- Status setting disable_selection -- Set that text cannot be selected in the editor require text_is_not_empty: not is_empty ensure no_selection: not has_selection enable_selection -- Set that text can be selected in the editor require text_is_not_empty: not is_empty internal_has_selection: BOOLEAN -- here for debugging set_changed (value: BOOLEAN; directly_edited: BOOLEAN) -- Assign value to changed -- (from TEXT_OBSERVER_MANAGER) feature -- Removal wipe_out -- Erase data. -- (from B_345_TREE) feature -- Duplication copy (other: SELECTABLE_TEXT) -- Update current object using fields of object attached -- to other, so as to yield equal objects. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_equal: Current ~ other frozen deep_copy (other: SELECTABLE_TEXT) -- Effect equivalent to that of: -- `copy` (other . `deep_twin`) -- (from ANY) require -- from ANY other_not_void: other /= Void ensure -- from ANY deep_equal: deep_equal (Current, other) frozen deep_twin: SELECTABLE_TEXT -- New object structure recursively duplicated from Current. -- (from ANY) ensure -- from ANY deep_twin_not_void: Result /= Void deep_equal: deep_equal (Current, Result) frozen standard_copy (other: SELECTABLE_TEXT) -- Copy every field of other onto corresponding field -- of current object. -- (from ANY) require -- from ANY other_not_void: other /= Void type_identity: same_type (other) ensure -- from ANY is_standard_equal: standard_is_equal (other) frozen standard_twin: SELECTABLE_TEXT -- New object field-by-field identical to other. -- Always uses default copying semantics. -- (from ANY) ensure -- from ANY standard_twin_not_void: Result /= Void equal: standard_equal (Result, Current) frozen twin: SELECTABLE_TEXT -- New object equal to Current -- `twin` calls `copy`; to change copying/twinning semantics, redefine `copy`. -- (from ANY) ensure -- from ANY twin_not_void: Result /= Void is_equal: Result ~ Current feature -- Basic operations frozen default: SELECTABLE_TEXT -- Default value of object's type -- (from ANY) frozen default_pointer: POINTER -- Default value of type POINTER -- (Avoid the need to write p.`default` for -- some p of type POINTER.) -- (from ANY) ensure -- from ANY instance_free: class default_rescue -- Process exception for routines with no Rescue clause. -- (Default: do nothing.) -- (from ANY) frozen do_nothing -- Execute a null action. -- (from ANY) ensure -- from ANY instance_free: class feature -- Content Change load_string (a_string: STRING_8) -- Scan a_string and fill the object with resulting -- lines and tokens -- a_string must be in UTF8. -- (from TEXT) require -- from TEXT string_not_void: a_string /= Void text_has_been_reinitialized: is_empty ensure -- from TEXT read_enough_lines: number_of_lines >= first_read_block_size or else reading_text_finished feature -- Element Change append_line (tl: like first_line) -- add tl at the end of the tree. -- (from B_345_TREE) require -- from B_345_TREE tl_not_linked: tl.next = Void and then tl.previous = Void ensure -- from B_345_TREE tl_linked: tl /= first_line implies (attached tl.previous as l_previous and then l_previous.next = tl) tl_has_key: tl.key /= Void tl_has_tree: tl.tree /= Void forth -- move `current_line` to the next line -- (from TEXT) require -- from TEXT not_after: not after go_i_th (i: INTEGER_32) -- set the i-th line as `current_line` -- (from TEXT) require -- from TEXT valid_i: i >= 1 and then i <= number_of_lines ensure -- from TEXT not_after: not after prepend_line (tl: like first_line) -- add tl at the beginning of the tree. -- (from B_345_TREE) require -- from B_345_TREE tl_not_linked: tl.next = Void and then tl.previous = Void ensure -- from B_345_TREE tl_linked: tl /= last_line implies (attached tl.next as l_next and then l_next.previous = tl) tl_has_key: tl.key /= Void tl_has_tree: tl.tree /= Void register_document (a_type_name: STRING_8; a_class: DOCUMENT_CLASS) -- Register new document type -- (from DOCUMENT_TYPE_MANAGER) set_first_data (tl: like first_line) -- (from B_345_TREE) set_last_data (tl: like first_line) -- (from B_345_TREE) start -- set the first line as `current_line` -- (from TEXT) require -- from TEXT number_of_lines >= 1 update_line (a_line: INTEGER_32) -- Update line tokens -- (from TEXT) require -- from TEXT line_index_valid: a_line > 0 and a_line <= number_of_lines feature -- Memory management recycle -- Recycle Current, but leave Current in an unstable state, -- so that we know whether we're still referenced or not. -- Not necessary to dereference the container, as they are wiped out. -- (from TEXT) feature -- Operations add_cursor_observer (a_text_observer: TEXT_OBSERVER) -- Add an observer an_text_observer to the "cursor observers" list. -- (from TEXT_OBSERVER_MANAGER) require -- from TEXT_OBSERVER_MANAGER not_in_loop: not is_notifying add_edition_observer (a_text_observer: TEXT_OBSERVER) -- Add an observer an_text_observer to the "edition observers" list. -- (from TEXT_OBSERVER_MANAGER) require -- from TEXT_OBSERVER_MANAGER not_in_loop: not is_notifying add_lines_observer (a_text_observer: TEXT_OBSERVER) -- Add an observer an_text_observer to the "lines observers" list. -- (from TEXT_OBSERVER_MANAGER) require -- from TEXT_OBSERVER_MANAGER not_in_loop: not is_notifying add_selection_observer (a_text_observer: TEXT_OBSERVER) -- Add an observer an_text_observer to the "selection observers" list. -- (from TEXT_OBSERVER_MANAGER) require -- from TEXT_OBSERVER_MANAGER not_in_loop: not is_notifying execute_post_notify_actions -- Execute actions in post_notify_acions -- (from TEXT_OBSERVER_MANAGER) post_notify_actions: ARRAYED_LIST [ROUTINE] -- Actions to call after other notifications -- (from TEXT_OBSERVER_MANAGER) remove_observer (a_text_observer: TEXT_OBSERVER) -- Remove the observer 'an_text_observer' from the list. -- (from TEXT_OBSERVER_MANAGER) require -- from TEXT_OBSERVER_MANAGER not_in_loop: not is_notifying feature -- Output Io: STD_FILES -- Handle to standard file setup -- (from ANY) ensure -- from ANY instance_free: class io_not_void: Result /= Void out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY out_not_void: Result /= Void print (o: ANY) -- Write terse external representation of o -- on standard output. -- (from ANY) ensure -- from ANY instance_free: class frozen tagged_out: STRING_8 -- New string containing terse printable representation -- of current object -- (from ANY) ensure -- from ANY tagged_out_not_void: Result /= Void feature -- Platform Operating_environment: OPERATING_ENVIRONMENT -- Objects available from the operating system -- (from ANY) ensure -- from ANY instance_free: class operating_environment_not_void: Result /= Void feature -- Query after: BOOLEAN -- Is the `current_line` beyond the end of the text ? -- (from TEXT) current_class_set: BOOLEAN -- Is `current_class` set? -- (from DOCUMENT_TYPE_MANAGER) first_non_blank_token (a_line: like line): EDITOR_TOKEN -- First non blank token in a_line. -- (from TEXT) require -- from TEXT a_line_not_void: a_line /= Void get_class_from_type (a_type: READABLE_STRING_GENERAL): DOCUMENT_CLASS -- Get the document class from the type -- (from DOCUMENT_TYPE_MANAGER) require -- from DOCUMENT_TYPE_MANAGER known_type: known_document_type (a_type) ensure -- from DOCUMENT_TYPE_MANAGER has_result: Result /= Void initialized: BOOLEAN -- Have preferences been set and ready to be used? -- (from SHARED_EDITOR_DATA) known_document_type (a_type: READABLE_STRING_GENERAL): BOOLEAN -- Is a_type a known document type? -- (from DOCUMENT_TYPE_MANAGER) line_pos_in_chars (a_line: like line): INTEGER_32 -- Position in chars of start of a_line. -- (from TEXT) require -- from TEXT line_not_void: a_line /= Void ensure -- from TEXT line_pos_in_chars_positive: Result > 0 text_length: INTEGER_32 -- Length of displayed text -- (from TEXT) feature -- Resources editor_preferences: EDITOR_DATA -- Editor preferences -- (from SHARED_EDITOR_DATA) Panel_manager: TEXT_PANEL_MANAGER -- List of open panels -- (from SHARED_EDITOR_DATA) feature -- Search found_string_character_position: INTEGER_32 -- Position of the first character within the line of the last string. -- Valid only if `successful_search` is set. -- (from TEXT) found_string_line: INTEGER_32 -- Line number of the last found string. -- Valid only if `successful_search` is set. -- (from TEXT) found_string_total_character_position: INTEGER_32 -- Position of the first character within the complete text. -- Valid only if `successful_search` is set. -- (from TEXT) search_string (searched_string: READABLE_STRING_GENERAL) -- Search the text for the string searched_string. -- If the search was successful, `successful_search` is -- set to True and `found_string_line` & -- `found_string_character_position` are set. -- searched_string should be in UTF-32 as STRING_32 or compatible STRING_8. -- (from TEXT) require -- from TEXT text_is_not_empty: not is_empty search_string_from_cursor (searched_string: STRING_8) -- Search the text for the string searched_string. -- Begin search from position of cursor. -- If the search was successful, `successful_search` is -- set to True and `found_string_line` & -- `found_string_character_position` are set. require text_is_not_empty: not is_empty successful_search: BOOLEAN -- Was the last call to `search_string` successful? -- (from TEXT) feature -- Selection Changes forget_selection -- Unselect all. require text_is_not_empty: not is_empty ensure no_selection: not has_selection select_all -- Select the entire text. require text_is_not_empty: not is_empty ensure selection: has_selection cursor_positioned: attached last_line as l_last_line and then attached_cursor.line = l_last_line and then attached_cursor.token = l_last_line.eol_token selection_cursor_positioned: attached first_line as l_first_line and then attached_selection_cursor.line = l_first_line and then attached_selection_cursor.token = l_first_line.first_token select_region (start_pos, end_pos: INTEGER_32) -- Select characters between indexes start_pos and end_pos. require text_is_not_empty: not is_empty text_loading_completed: reading_text_finished right_order: start_pos <= end_pos set_selection_cursor (c: like cursor) -- Set the selection to be from c to `cursor`. -- Allows empty selections. Be careful about this. require text_is_not_empty: not is_empty cursor_not_void: c /= Void ensure selection_cursor_set: attached selection_cursor as l_c and then l_c.is_equal (c) feature -- Status Setting highlight_line (a_line: INTEGER_32) -- Highlight line. Do not move cursor to this line. -- (from TEXT) require -- from TEXT valid_i: a_line >= 1 and then a_line <= number_of_lines set_current_document_class (doc_class: like current_class) -- Update the current document class to reflect type of text loaded in text panel -- (from DOCUMENT_TYPE_MANAGER) set_first_read_block_size (a_size: INTEGER_32) -- set the size in lines of the first block of text -- that will be read. -- (from TEXT) require -- from TEXT valid_size: a_size >= 0 set_is_windows_eol_style (a_windows_style: BOOLEAN) -- Set is_unix_style with a_style. -- (from TEXT) ensure -- from TEXT is_windows_eol_style_set: is_windows_eol_style = a_windows_style set_tabulation_size (a_size: INTEGER_32) -- Set thet tabulation size. Overrides preferences default value. -- (from TEXT) require -- from TEXT a_size_big_enough: a_size > 0 unhighlight_line (a_line: INTEGER_32) -- Highlight line. Do not move cursor to this line. -- (from TEXT) require -- from TEXT valid_i: a_line >= 1 and then a_line <= number_of_lines feature -- String string_between_cursor (a_start_cursor, a_end_cursor: like cursor): STRING_32 -- String between cursors a_start_cursor and a_end_cursor. require attached_cursors: a_start_cursor /= Void and then a_end_cursor /= Void right_order: a_start_cursor <= a_end_cursor string_between_pos_in_text (a_start_pos, a_end_pos: INTEGER_32): STRING_32 -- String between pos_in_text a_start_pos and a_end_pos. require pos_valid: a_start_pos > 0 and a_end_pos > 0 right_order: a_start_pos <= a_end_pos invariant valid_selection: has_selection implies selection_cursor /= Void -- from TEXT current_line_valid: attached current_line as l_line implies l_line.is_valid positive_current_pos: current_pos > 0 -- from B_345_TREE first_data_valid: attached first_line as l_first_data implies l_first_data.is_valid last_data_valid: attached last_line as l_last_data implies l_last_data.is_valid -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) note copyright: "Copyright (c) 1984-2022, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class SELECTABLE_TEXT -- Generated by Eiffel Studio --
For more details: eiffel.org