Object which represents a document. It has methods for file operations and manipulating document text.
gtk.GObject
|
+-- moo.Edit
after-save()
This signal is emitted after the document has been successfully saved on disk.
before-save(file)
This signal is emitted when the document is going to be saved on disk. Callbacks should return SAVE_RESPONSE_CANCEL if document should not be saved, and SAVE_RESPONSE_CONTINUE otherwise. For example, if before saving the file must be checked out from a version control system, a callback can do that and return SAVE_RESPONSE_CANCEL if checkout failed. Callbacks should not modify document content. If you need to modify it before saving, use will-save signal instead.
|
the |
Returns: SAVE_RESPONSE_CANCEL to cancel saving, SAVE_RESPONSE_CONTINUE otherwise.
will-save(file)
This signal is emitted when the document is going to be saved on disk, after before-save signal. Callbacks may modify document content at this point.
|
the |
doc.delete_selected_lines()
Delete selected lines. Similar to delete_selected_text() but selection is extended to include whole lines. If no text is selected then line at cursor is deleted.
doc.get_cursor_pos()
Returns: Iterator which points to the current cursor (insertion point) position. In the case when text selection is not empty, it points to one of the ends of the selection.
doc.get_end_pos()
Returns: Iterator which points to the end of the document, i.e. the position past the last character in the document.
doc.get_lang_id()
Returns: id of language currently used in the document. If no language is used, then string "none" is returned.
doc.get_line_at_pos(pos)
|
Returns: -based number of the line at the given position.1
doc.get_line_text(line=0)
|
|
Returns: text at line line, not including line end characters. If line is missing, returns text at cursor line.
doc.get_line_text_at_pos(pos)
|
Returns: text at line which contains position pos, not including the line end character(s).
doc.get_n_views()
Get the number of views which belong to this document.
Returns: integer
doc.get_pos_at_line(line)
|
|
Returns: Iterator which points to the beginning of the given line.
doc.get_pos_at_line_end(line)
|
|
Returns: Iterator which points to the end of the given line (i.e. the position before the line end character(s)).
doc.get_selected_lines()
Returns selected lines as a list of strings, one string for each line, line terminator characters not included. If nothing is selected, then line at cursor is returned.
Returns: list of strings
doc.get_selection_end_pos()
Returns: Iterator which points to the end of the current text selection. If the selection is empty, it returns the current cursor position.
doc.get_selection_start_pos()
Returns: Iterator which points to the beginning of the current text selection. If the selection is empty, it returns the current cursor position.
doc.get_start_pos()
Returns: Iterator which points to the beginning of the document.
doc.get_text(start=nil, end=nil)
|
|
|
|
Returns: text between start and end. If end is missing then it returns text from start to the end of document; and if both start and end are missing then it returns whole document content.
doc.get_views()
Get the list of views which belong to this document.
Returns: list of moo.EditView objects
doc.insert_text(text, where=nil)
Insert text at position where or at cursor position if where is .nil
|
|
|
|
doc.is_empty()
This function returns whether the document is "empty", i.e. is not modified, is untitled, and contains no text.
Returns: bool
doc.reload(info=nil)
Reload document from disk
|
|
Returns: whether document was successfully reloaded
doc.replace_selected_lines(replacement)
replace selected lines with replacement. Similar to replace_selected_text(), but selection is extended to include whole lines. If nothing is selected, then line at cursor is replaced.
|
list of lines to replace selected lines with, maybe empty |
doc.replace_selected_text(replacement)
Replace selected text with string replacement. If nothing is selected, then replacement is inserted at cursor.
|
|
doc.replace_text(start, end, text)
|
|
|
|
|
|
doc.save_as(info)
Save document with new filename and/or encoding. If info is missing or then the user is asked for a new filename first.nil
|
|
Returns: bool
doc.select_lines(start, end=0)
|
|
|
|
doc.select_lines_at_pos(start, end=nil)
Select lines which span the range from start to end (including end position). If end is , then it selects single line which contains position nilstart.
|
|
|
|
doc.select_range(start, end)
Select text from start to end.
|
|
|
doc.set_cursor_pos(pos)
Move the text cursor to the given position. No text is selected after this operation, use one of the select* methods if you need to select a range of text.
|