Home Download Buy Blog Forum Support

Sublime Writer

Sublime Writer

Postby charlesroper on Fri Feb 04, 2011 7:18 pm

I've been using the excellent distraction free mode in Sublime and I love it. I also created some user prefs for Markdown mode that attempts to mimic Writer on the iPad. I can get pretty close. It's really nice. BUT, I can't get the current line to stay centered on the screen like writer does. Is this something that is possible via the API or some hidden setting. Also, the way lines fade out above and below the current line in Writer is nice. Again, possible in Sublime somehow? I thought a species syntax might do it...?
charlesroper
 
Posts: 107
Joined: Thu Feb 18, 2010 7:30 am

Re: Sublime Writer

Postby guillermooo on Fri Feb 04, 2011 7:43 pm

I'm not familiar with Writer, but this may approximate what you're after regarding the cursor.

Bind this to "enter" in your user keybindings.

Note that it only keeps the cursor centered in the screen; you have to place it there first.

Code: Select all
import sublime_plugin

class SublimeWriter(sublime_plugin.TextCommand):
   def run(self, edit):
      self.view.insert(edit, self.view.sel()[0].begin(), "\n")
      self.view.run_command("scroll_lines", {"amount": -1.0})



And this will give you the middle point:

Code: Select all
v = view.visible_region()
a = view.rowcol(v.begin())[0]
b = view.rowcol(v.end())[0]
middle = (b + a)/2



HTH,
G
Last edited by guillermooo on Fri Feb 04, 2011 7:55 pm, edited 2 times in total.
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Sublime Writer

Postby guillermooo on Fri Feb 04, 2011 7:53 pm

In v1 it used to be possible to issue a sequence of commands in a single key binding. That would eliminate the need for the plugin, but I haven't figured out yet how to do this in v2...
guillermooo
 
Posts: 729
Joined: Thu Jul 23, 2009 9:06 am

Re: Sublime Writer

Postby jps on Sat Feb 05, 2011 10:33 am

When I implement distraction free mode in Sublime Text 2, I'll see what I can do to get some of these incorporated.
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: Sublime Writer

Postby jbrooksuk on Sat Feb 05, 2011 11:02 am

jps wrote:When I implement distraction free mode in Sublime Text 2, I'll see what I can do to get some of these incorporated.

I thought that there was something important missing :oops:
jbrooksuk
 
Posts: 782
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: Sublime Writer

Postby quodlibet on Sat Jun 18, 2011 6:27 pm

Hi all,

I, too, am hoping to get Sublime Text 2 to behave more like WriterRoom or iA's Writer.

I failed to use the code snippets provided by guillermooo. (I use ST for CSS, HTML and regular text; I haven't programmed in a decade.) I'd be grateful for any help implementing them.

Since ST's API has a show_at_center(point) function, it seems fairly straightforward (for someone who can write Python) to implement the centering effect. The code would be the python equivalent of: after each keypress, show_at_center(where there cursor is). This might break ST's more advanced features, but if all you're doing is writing text, I think it should work okay.

The fade out effect is more complicated, because iA's Writer doesn't just highlight the line, it highlights the sentence. (See http://www.geekosity.org/wp-content/uploads/2011/06/iA-Writer.png) Implementing this would break compatibility with TextMate's themes, which presumably is undesirable.

A rather complicated plugin might be able to grab the text between the two punctuation points (. ? ! for English) before and after the cursor's position and call that regular text, while making everything else styled as a comment (which tend to be themed so that they fade into the background). Of course, this would stumble on a text like "Did you know? St. Jerome was a saint." (It would think that "St." was a complete sentence.)

I hope that the above is not too muddled. I also was not sure whether I should reply here or post a new topic under the Ideas & Feature Requests section. (I'm not activate on forums that much, except when I love the app!)
quodlibet
 
Posts: 561
Joined: Sat Jun 18, 2011 5:53 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 9 guests