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

Re: Tab Aliases, Numbered Tabs

Postby tadfry on Wed Mar 11, 2015 12:51 pm

I’m not trying to necro an old thread, but I do have a strong interest in this feature.

I would love to prepend to or rename the labels of the tabs. I’ve written a plugin that gets the views and iterates over them to build tab numbers, but nowhere to put them :/

I like to use cmd+n to get around the tabs, so having the tab numbers would be helpful.

Thanks!
tadfry
 
Posts: 1
Joined: Wed Mar 11, 2015 12:45 pm

Re: Tab Aliases, Numbered Tabs

Postby adzenith on Tue Mar 17, 2015 4:35 pm

plugin idea:
if the buffer is unmodified, mark it as a scratch buffer so it won't show up as unsaved.
change the view name with view.set_name.
on_modified, clear the scratch flag.
on_pre_save, rename the view.
on_post_save, set the scratch flag again and rename it back.

Seems like it should work?
adzenith
 
Posts: 1329
Joined: Mon Oct 19, 2009 9:12 pm

Re: Tab Aliases, Numbered Tabs

Postby adzenith on Tue Mar 17, 2015 4:40 pm

After I wrote the previous post, I felt strongly like I remembered having done that exact thing before.
Turns out I had:
https://github.com/adzenith/Sublime-plu ... folding.py
Back before Sublime Text had code folding, I wrote a code folding plugin that did the same trick to show the buffer as unmodified. It worked great.
adzenith
 
Posts: 1329
Joined: Mon Oct 19, 2009 9:12 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Exabot [Bot] and 7 guests