Sublime Forum

API Requests

#1

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: Please fixme: A reproducible bug in set_viewport_position

1 Like

#2

My request: add folders to sidebar via API

0 Likes

#3

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

0 Likes

#4

sEgsdg sgGs gds

0 Likes

#5

Bump and [size=150]+1[/size]

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

0 Likes

#6

[quote=“tito”]

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.[/quote]

Look in Packages/Default/side_bar.py paying attention to v.retarget(new):

[code]
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[/code][size=50](auto extracted so may be nonsensical)[/size]
0 Likes

#7

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.

0 Likes

#8

++This…

I need a way to restore regions for files that have been reloaded (very common when using git pull for instance)

0 Likes