Home Download Buy Blog Forum Support

Tab Aliases, Numbered Tabs

Tab Aliases, Numbered Tabs

Postby EJ12N on Wed Sep 30, 2009 7:03 pm

I would like to assign aliases to tabs something like view.setAlias()
I believed that view.setName() was for this but is NOT. If I change the buffer name sublime thinks the file is a new file and it marks it as unsaved.

Purpose of this is because sometimes I have files that have same ending filename like style.css, so I sublime I would alias them like "{sitename} style.css" "{sitename2} style.css", etc... is also useful for other purposes, at least in my opinion.

Also if we could get an option for tabs to show numbered tabs that would be better :D that way we just enable the option (temporarily) with the api then disabled it when we don't need numbered tabs.
(1) filename.css, (2) filename.html, (3) filename.php

Let me know what you guys think :)
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm

Re: Tab Aliases, Numbered Tabs

Postby vim on Wed Sep 30, 2009 8:41 pm

i think the ability to add comments or marks on tabs can be very useful. so i like your proposal to support alias for tab
vim
 
Posts: 298
Joined: Tue May 27, 2008 6:51 pm

Re: Tab Aliases, Numbered Tabs

Postby mry on Sat Oct 31, 2009 1:30 pm

Another vote for this. Here is the simplest example I could think of - this marks read-only files on the tab:

Code: Select all
class ReadOnlyTracker(sublimeplugin.Plugin):
    def onLoad(self, view):
        if not os.access(view.fileName(), os.W_OK):
            view.setName(os.path.basename(view.fileName()) + ' [R]')

The problem here is that it marks the buffer as dirty and changes the filename. I tried to temporarily do setScratch(True) but the end result was same. So basically what is needed is an API that can change the label of a tab without doing anything else such as marking the file changed or modifying the filename. As a bonus it would be nice (but low priority) if we could add icons/images to tabs :D
mry
 
Posts: 10
Joined: Fri Oct 30, 2009 5:42 am

Re: Tab Aliases, Numbered Tabs

Postby EJ12N on Wed Nov 04, 2009 9:02 pm

Or if your doing your own plugins you can append the current working mode on the tab
filename.php [selection_mode], filename.php [insert_mode]

there's many many uses for it...

And from the coding side of it, maybe something like this,

view.setAlias(str[, start=0])

str:
The desired alias that will get attached the the current view.filename() OR view.setName() value, depending on the start paramater.

start (optional) -- 0 by default:
If start is omitted or with a value of zero, the str is then appended to the beginning.

If start is non-negative, the returned string will start at the start'th position in string , counting from zero.

If start is negative, the returned string will start at the start 'th character from the end of string, counting from zero (so -1 would be the end of the str)


examples:
Code: Select all
view.setAlias("[R]") == [R]yahooStyle.css
view.setAlias("[R]", 0) == [R]yahooStyle.css
view.setAlias("[R]", 1) == b[R]oo.css
view.setAlias("[R]", 5) == yahoo[R]Style.css
view.setAlias("[R]", 6) == google[R]Style.css
view.setAlias("[R]", -1) == site.css[R]
view.setAlias("[R]", -5) == site[R].css


And taking from example above:
Code: Select all
class ReadOnlyTracker(sublimeplugin.Plugin):
  def onLoad(self, view):
    if not os.access(view.fileName(), os.W_OK):
      view.setAlias('[R]', -1)


Jon any input on this?
EJ12N
 
Posts: 281
Joined: Tue Apr 21, 2009 5:23 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 9 guests