Home Download Buy Blog Forum Support

API Requests

API Requests

Postby tito on Fri Apr 06, 2012 4:40 pm

Some APIs I need to provide better plugins.

sublime_plugin.EventListener.on_reload
This will allow me to restore scroll and other view properties such bookmarks, selections, folds, etc for views that are reloaded.

sublime_plugin.EventListener.on_application_close
This will allow to flush to disk some data collected in a session when sublime is closed. There is no need to flush to disk everytime a view lose focus or change of properties. I just need to flush when the application is closed.

sublime_plugin.EventListener.on_viewport_change and sublime_plugin.EventListener.on_viewport_extent_change
This will allow to do some magic scroll between cloned views when you just scroll one of these.

sublime.View.has_clones
This will allow to apply (if appropriated) some magic to cloned views. Without this we need to iterate every window and foreach window every view to see if there is some clone for a view. This should return true even if the cloned view is located in other window.

sublime.View.clones
This should return the clones of a view.

sublime.View.get_history
This should return a history object of the view. This is useful for when a file is renamed, we currently lose undo when renaming.

sublime.View.set_history
This should allow to set history object of the view.

sublime_plugin.on_project_close
I hope you can add this, and dispatch the event before the project is closed, then we will be able to save some data related to the view that is going to be closed. Or just send on_close for each view when we switch to another project.

sublime.View.file.settings
This should return a persistent settings object on which the id is the file_name. This will allow to save settings based on file names instead of views. Also, this setting should be persistent between sessions.

sublime.Window.project.settings
This should return a persistent settings object on which the data is saved at the project file. This will allow to have settings for projects.

_

Also, If you wish please fix the API set_viewport_position which is currently broken for xml/html files. Details in: viewtopic.php?f=3&t=6237
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 866
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: API Requests

Postby weslly on Fri Apr 06, 2012 5:09 pm

My request: add folders to sidebar via API

viewtopic.php?f=6&t=4596
weslly
 
Posts: 203
Joined: Sun Aug 28, 2011 3:57 am
Location: Brazil

Re: API Requests

Postby facelessuser on Fri Apr 06, 2012 5:37 pm

My request: Request where the project file is located via the API.

Useful if you want to just store project specific things in the same place, but not modify the the project settings file.

viewtopic.php?f=4&t=6297&start=0&hilit=project+api
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: API Requests

Postby tito on Sat Apr 07, 2012 4:31 pm

sEgsdg sgGs gds
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 866
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: API Requests

Postby NEOhidra on Fri Apr 13, 2012 10:32 am

Bump and +1

I would really like to see these APIs being available to the plugins authors - if not all alt least
    sublime_plugin.EventListener.on_reload
    sublime_plugin.EventListener.on_viewport_change
    sublime_plugin.EventListener.on_viewport_extent_change
NEOhidra
 
Posts: 1
Joined: Fri Apr 13, 2012 10:18 am
Location: BG

Re: API Requests

Postby sublimator on Fri Apr 13, 2012 1:17 pm

tito wrote:
sublime.View.get_history
This should return a history object of the view. This is useful for when a file is renamed, we currently lose undo when renaming.

sublime.View.set_history
This should allow to set history object of the view.



Look in Packages/Default/side_bar.py paying attention to `v.retarget(new)`:
Code: Select all
class RenamePathCommand(sublime_plugin.WindowCommand):
    def run(self, paths):
        branch, leaf = os.path.split(paths[0])
        v = self.window.show_input_panel("New Name:", leaf, functools.partial(self.on_done, paths[0], branch), None, None)
        name, ext = os.path.splitext(leaf)

        v.sel().clear()
        v.sel().add(sublime.Region(0, len(name)))

    def on_done(self, old, branch, leaf):
        new = os.path.join(branch, leaf)

        try:
            os.rename(old, new)

            v = self.window.find_open_file(old)
            if v:
                v.retarget(new)
        except:
            sublime.status_message("Unable to rename")

    def is_visible(self, paths):
        return len(paths) == 1
(auto extracted so may be nonsensical)
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: API Requests

Postby tito on Fri Apr 13, 2012 2:07 pm

Ok, got it.

BTW, Copy and set history will allow to restore history after a restart.
I think this software can benefice a lot by providing more APIs instead of adding semihalfworkingfeatures.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 866
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 29 guests