Home Download Buy Blog Forum Support

Auto-hide scrollbars

Auto-hide scrollbars

Postby toggleViews on Tue Oct 19, 2010 12:51 pm

Simple plugin that shows the scrollbars only when they are needed.

Code: Select all
import sublime, sublimeplugin

class toggleScrollbarPlugin(sublimeplugin.Plugin):
  def onActivated(self, view):
    verticalScrollBar = view.options().get('wantVerticalScrollBar')
    if view.size() == view.visibleRegion().size():
      if verticalScrollBar:
        view.options().set('wantVerticalScrollBar', False)
    else:
      if not verticalScrollBar:
        view.options().set('wantVerticalScrollBar', True)

A saved a copy here: http://pastebin.com/z1HKNNpP
toggleViews
 
Posts: 5
Joined: Fri Oct 15, 2010 11:35 am

Re: Auto-hide scrollbars

Postby toggleViews on Tue Oct 19, 2010 3:03 pm

Update: Changed the triggering event from onActivated to onSelectionModified.

Code: Select all
import sublime, sublimeplugin

class toggleScrollbarPlugin(sublimeplugin.Plugin):
  def onSelectionModified(self, view):
    verticalScrollBar = view.options().get('wantVerticalScrollBar')
    if view.size() == view.visibleRegion().size():
      if verticalScrollBar:
        view.options().set('wantVerticalScrollBar', False)
    else:
      if not verticalScrollBar:
        view.options().set('wantVerticalScrollBar', True)

And another copy can be found here: http://pastebin.com/ZneARMDN
toggleViews
 
Posts: 5
Joined: Fri Oct 15, 2010 11:35 am

Re: Auto-hide scrollbars

Postby toggleViews on Thu Oct 21, 2010 8:14 pm

Update: Changed my mind about removing onActivated.

Code: Select all
import sublime, sublimeplugin

class toggleScrollbarPlugin(sublimeplugin.Plugin):
  def toggleScrollbar(self, view):
    verticalScrollBar = view.options().get('wantVerticalScrollBar')
    if view.size() == view.visibleRegion().size():
      if verticalScrollBar:
        view.options().set('wantVerticalScrollBar', False)
    else:
      if not verticalScrollBar:
        view.options().set('wantVerticalScrollBar', True)
  def onSelectionModified(self, view):
    self.toggleScrollbar(view)
  def onActivated(self, view):
    self.toggleScrollbar(view)

Copy: http://pastebin.com/mP4x04Lk
toggleViews
 
Posts: 5
Joined: Fri Oct 15, 2010 11:35 am


Return to Plugin Announcements

Who is online

Users browsing this forum: antenando and 14 guests