From 58916e9882644d824e508f59ad306b7ad3a5be5c Mon Sep 17 00:00:00 2001 From: Anna Bulenkova Date: Tue, 9 Dec 2014 19:00:57 +0100 Subject: [PATCH] [md] Editor - get content --- tutorials/working_with_editor.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tutorials/working_with_editor.md b/tutorials/working_with_editor.md index 1b9625010..ada1a32d1 100644 --- a/tutorials/working_with_editor.md +++ b/tutorials/working_with_editor.md @@ -33,6 +33,33 @@ object is available object is available ```final Editor editor = actionEvent.getData(CommonDataKeys.EDITOR); ``` +##Obtaining content: document, caret, selection, and more +##Document. +[Document.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/openapi/editor/Document.java) +represents the contents of a text file loaded into memory, and possibly opened in an IDEA +text editor. Line breaks in the document text are always normalized as single \n characters, +and are converted to proper format when the document is saved. +[Document] (https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/openapi/editor/Document.java) +can be obtained by calling +```Document document = editor.getDocument(); +``` + +##Models +Different services for controlling and getting information about visible areas the editor can be accessible set of getters, e.g. +```final SelectionModel selectionModel = editor.getSelectionModel(); +``` + +Editor model classes are located in +[editor] (https://github.com/JetBrains/intellij-community/tree/master/platform/editor-ui-api/src/com/intellij/openapi/editor) +subpackage of the +[editor-ui-api] (https://github.com/JetBrains/intellij-community/tree/master/platform/editor-ui-api) +package and include: +[CaretModel.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java), +[FoldingModel.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/FoldingModel.java), +[IndentsModel.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentsModel.java), +[ScrollingModel.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/ScrollingModel.java), +[ScrollingModel.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/ScrollingModel.java), +[SoftWrapModel.java] (https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/SoftWrapModel.java) Please see [EditorIllustration.java] (https://github.com/JetBrains/intellij-sdk/blob/master/code_samples/editor_basics/src/org/jetbrains/plugins/editor/basics/EditorIllustration.java)