Word wrapping in editor?

I made an ordinary, plain-text editor for a concept. This concept is designed to house very large pieces of text. Is it possible to somehow tell MPS to perform basic work wrapping (e.g., wrap on a space), perhaps using the Text Width setting as a guide? I'm using 2.0.6. Thanks!
10 comments
Comment actions Permalink
Hello? Anyone out there?
0
Comment actions Permalink
Dmitri,

Seems like it's not possible now to do word wrapping for a property of type string. The only thing you can do is to make your text consist of words (delimited by spaces) and use the indent-layout in editor.
I'll ask our editor guru and maybe he'll offer another solution, but most probably he won't.

Regards,
Mihail
0
Comment actions Permalink
Hi, Dmitri!

As Michael properly described, one possible option is to reflect document model in mps. In this case each "word" will be stored as property of separate node, so you can use indent layout to let MPS editor automatically wrap words if necessary.

Another option would be using native control in editor, so it will be responsible for wrapping text. Please let me know if you need more detail about it.
0
Comment actions Permalink
Thanks for the reply! My concern with having 'words' as separate entities is that I'd have to add each word separately instead of being able to type in a whole sentence. Please correct me if I'm wrong about this.

Actually, the idea of a native control is interesting, as I would see benefit in having specialized controls for various elements. Would you be so kind as to point me to the documentation that will help me get acquainted with this?
0
Comment actions Permalink
My concern with having 'words' as separate entities is that I'd have to add each word separately instead of being able to type in a whole sentence.

Well, I suppose you can create number of right-transforms creating a separate word (new node) if you type "space" and number of handlers processing "backspace" actions and merging two separate words into a single node. Nevertheless, this is not trivial task, but it looks doable with current state of MPS editor.

Actually, the idea of a native control is interesting, as I would see benefit in having specialized controls for various elements.

Unfortunately, there is not documentation covering this aspect of MPS editor now. On the other side, you can try it just by creating new cell of type "swing component" in for editor. To complete native cell definition you just need to open inspector of "swing component" cell and write a code constructing/returning new instance of JCoponent there.
0
Comment actions Permalink

Is this still something that's not doable inside simple string properties? I've been looking into implementing it using this word node method, but the more I look into it, the worse the end results I can think of look like. Selection in particular looks and feels terrible compared to simple string editing.

1
Comment actions Permalink

You can use the multiline property cell included in MPS-extensions, or available separately in this plugin: https://plugins.jetbrains.com/plugin/13253-mps-multiline-property-editor-component/

1
Comment actions Permalink

Thank you for the answer!

Is there any documentation explaining how to use that? I managed to import and use it in my editors, but I can't find out how to manage the width at which the lines of text wrap.

It seems to be drawn as a vertical bar by default in MPS, even without the plugin installed, but it is independent of the editor's actual width, which is kind of the whole point. 

The problem, of course, is when the window is smaller than this fixed width, in which case a horizontal scrolling bar is created anyway and the text wraps off-screen.

0
Comment actions Permalink

This is expected, you can change the text width in preferences, Editor -> General. It doesn't adjust with the window size.

1
Comment actions Permalink

Huh, I swear I tried this one before. Maybe I didn't apply the changes or something. Thanks for the help.

I assume it is not possible to force it to change according to the window size in any way? I can't find access points for getting window size and changing text width looking through the documentation.

0

Please sign in to leave a comment.