Home Download Buy Blog Forum Support

zoom plugin

zoom plugin

Postby vim on Mon Dec 22, 2008 1:56 pm

i made zoom out/in plugin which actually increase/decrease the current font size.
if you want just make a new file named: Zoom.py under %appdata%\Sublime Text\Packages\User, which contains:
Code: Select all
import sublime, sublimeplugin

class ZoomInCommand(sublimeplugin.TextCommand):
   def run(self, view, args):
      current_font = view.options().get('font')
      (font, sep, size) = current_font.rpartition(" ")
      new_size = int(size) + 1
      new_font = font + " " + str(new_size)
      view.options().set('font', new_font)
      print "set new font to: " + new_font
     
   def isEnabled(self, view, args):
      return True


class ZoomOutCommand(sublimeplugin.TextCommand):
   def run(self, view, args):
      current_font = view.options().get('font')
      (font, sep, size) = current_font.rpartition(" ")
      new_size = int(size) - 1
      new_font = font + " " + str(new_size)
      view.options().set('font', new_font)
      print "set new font to: " + new_font
      
   def isEnabled(self, view, args):
      return True


also add key binding on Default.sublime-keymap under %appdata%\Sublime Text\Packages\User
Code: Select all
<bindings>
...
   <binding key="ctrl+equals" command="zoomIn"/>
   <binding key="ctrl+minus" command="zoomOut"/>
...
</bindings>


after that pressing control and plus or minus next to the backspace will do the trick(not the keypad :roll: )
vim
 
Posts: 298
Joined: Tue May 27, 2008 6:51 pm

Re: zoom plugin

Postby gpfsmurf on Fri Jan 02, 2009 5:18 am

Someone else already posted a similar plug-in: http://www.sublimetext.com/forum/viewtopic.php?f=4&t=56

It also also has a ctrl-0 shortcut that returns the font size to the default.


I wonder, is there a way to bind a command to ctrl-mousewheel up/down?
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: zoom plugin

Postby jps on Thu Feb 12, 2009 12:48 am

Mouse buttons aren't yet bindable, no - has been requested before though.
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: zoom plugin

Postby mvm on Thu Feb 12, 2009 11:41 am

vim: thanks for good work! So now Sublime have something like Intellipad's font resizing. Though not so smooth and cool, it does its work.
One problem, though: it will happily zoom out font to size < 0. When it happens, font size jumps to some standard value, and then changes to small size when zooming in.
mvm
 
Posts: 26
Joined: Mon Mar 31, 2008 6:11 pm


Return to Plugin Announcements

Who is online

Users browsing this forum: Google [Bot] and 3 guests