Desktop::Editor again



Hi,

New version after comments. There's one problem with this
one, but I'm not sure how to fix that. Several processes
can get the same EditorView object. This means the cursor
position/selection could change between calls from one
component. I'm really no locking expert, so please
give me some hints :)

cya,
Martijn



module Desktop {

	interface EditorStream;
	interface EditorView;
	interface Editor;

	/* This interface is intended as an add-on to GNOME::Stream
	 */
	interface EditorStream : GNOME::Unknown {
		typedef long SearchOption;
		/* whether to ignore case while searching */
		const SearchOption SEARCH_ICASE = 1;
		/* whether to search backwards */
		const SearchOption SEARCH_REVERSE = 2;
		/* whether the search-string is a regexp */
		const SearchOption SEARCH_REGEX = 4;

		/**
		 * search:
		 * @regexp: the string or regexp to find
		 * @whence: search from where
		 * @flags: Options modifying the search
		 *
		 * lets you search for a string in the stream. The read/write
		 * pointer for the Stream is set to the position of the
		 * found string. The search-string can optionally be a
		 * regular expression (Editors do not have to support this)
		 *
		 * Returns the position of the read/write pointer for the
		 * Stream.
		 */
		 long search (in string                  regexp,
		              in GNOME::Stream::SeekType whence,
		              in SearchOption            flags);
	};


	interface EditorView {

		exception OutOfRange {};

		struct Position {
			long character;
			long row;
			long column;
		};

		struct Range {
			Position start;
			Position end;
		};

		/**
		 * get_pos:
		 *
		 * Returns the current position of the cursor in the
		 * Editor view.
		 */
		Position get_pos ();
		/**
		 * scroll_pos:
		 * @offset: how much to scroll
		 * @whence: scroll from where
		 *
		 * This method allows you change the position of the cursor
		 * in the editor window. If @offset's character field is non-zero, 
		 * that will be used to scroll on a character basis. Otherwise
		 * the line field will be used to scroll on a line basis.
		 * the column field is ignored.
		 *
		 * Returns the cursor position after the scroll.
		 */
		Position scroll (in Position                offset,
		                 in GNOME::Stream::SeekType whence) raises (OutOfRange);
		/**
		 * get_selection:
		 *
		 * Returns the range of the current selection.
		 */
		Range get_selection ();

		/**
		 * set_selection:
		 * @selection: A Range indicating what to select
		 *
		 * Sets the current selection in the view to @selection
		 */
		void set_selection (in Range selection);
	};


	/* This interface should also implement the GNOME::PersistFile
	 * and GNOME::PersistStream interfaces
	 */
	interface Editor : GNOME::Unknown {
		/**
		 * access_as_stream:
		 *
		 * Returns a GNOME::Stream object through which you can
		 * manipulate the contents of the editor.
		 */
		GNOME::Stream access_as_stream ();

		/**
		 * new_view:
		 * @repo_id: The repo_id of the type of view requested
		 * @use_existing: Use an already existing view if available
		 *
		 * Returns a view of type @repo_id
		 */
		Object get_view(in string repo_id, in boolean use_existing);

		/**
		 * convert_pos:
		 * @position: a character-based position
		 *
		 * Converts @position into a Desktop::EditorViewer::Position
		 * so you can see what the corresponding line and column are.
		 */
		EditorView::Position convert_pos (in long position);
	};

};

-- 
Martijn van Beers  <martijn@earthling.net>

'Don't worry if it sounds odd. Believe me, you are talking to
someone who has seen a lot of stuff that is odd. And I don't
mean biscuits.' --- Arthur Dent



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]