Different left-and-right margins per line


I started making a web app to write screenplays with the goal being a compromise between WYSIWYG and portability. I am using Codemirror (demo halfway down page at http://louissimons.com/scriptjr/), and I realized that I shouldn’t reinvent the wheel on text editor features, and would like to instead build it as a set of tools for Atom.

Most of the features I need seem to be there, like the ability to change the font-size of a line, or make custom editor user-interface panels for scene listing. Before I get too far, though, the only thing I haven’t found an example of is setting the left and right margins custom for a set of lines. In Fountain.io syntax, this is helpful for recognizing dialogue. It would look something like the following:

I'm a descriptive text.

                                  CHARACTER 1
                     I'm a bunch of dialogue for a
                     character with a soft line-wrap that
                     is a smaller width then general text.

And back to descriptive scene text.

I have read a few discussions saying that messing with padding can cause cursor issues, so I was wondering is this possible?


Check out @braver’s typewriter package. It might have some clues on how to achieve what you’re looking for.


I’m afraid it doesn’t. All that does is center the entire atom-text-editor. It does that to make sure all decorations, overlays and what not stay in place. Preventing the cursor issues @superlou mentions. You can’t really move text around with padding without messing up the cursor, as far as I know at least. text-align: center doesn’t work with the way text is positioned in Atom.

So, while I think typewriter would be neat for writing fountain, it doesn’t solve your problem. The things you were able to do in CodeMirror don’t work in Atom and I don’t know any alternatives. Brackets uses CodeMirror, but IIRC they also changed the cursor and it probably won’t work there either.


I’m still learning about the Atom architecture, but it sounds like it’s something that wouldn’t be possible then until the core functionality can handle lines with different alignments, something beyond what plugins can do?

As an alternative, is it possible to implement my own hard-wrapping+hard-indenting to achieve something similar if the font is fixed width? Would there be any big performance gotchas about watching the text for changes and adding spaces and newlines to the text as it’s changed to address the alignment? The downside is that it would then persist in the final file, but that wouldn’t be terrible.


Reading about the work being done on text-document, particularly the new ideas for measuring characters, is per line height/padding transformations something that might be available down the road? Are the current limitations a matter of improving performance? Using Atom with some of the features of a rich-text editor may be beyond the scope of the project, but it sure would be cool.


I think, in the near term, the idea is to improve the performance of the editor with regard to the capabilities it already has rather than add major new features. I think the only real answer for “the current limitations” is “all of the above”? It’s partially performance and partially scoping the project to what is needed and achievable for a programmer’s editor and probably some other things tossed in besides.

I suspect we might get a better idea of what the Atom team is thinking about for v2.0 after v1.0 is declared and they get a chance to catch their breath :laughing: And beyond v2.0 is really anybody’s guess at this point.

split this topic #7

4 posts were split to a new topic: Tabletop Simulator and Lua

Tabletop Simulator and Lua