Plugins 升华文本3-在我的当前布局底部添加一个窗格
我想为ST3制作一个简单的插件,在屏幕底部添加一个带有简单键盘快捷键的窗格。我知道,TBH会将它用于这样的任务,但我这样做更多的是为了尝试制作ST3插件 注意:我不想更改布局。无论有什么,在底部添加一个窗格 例如,如果我当前的屏幕选项卡是这样排列的:Plugins 升华文本3-在我的当前布局底部添加一个窗格,plugins,sublimetext3,Plugins,Sublimetext3,我想为ST3制作一个简单的插件,在屏幕底部添加一个带有简单键盘快捷键的窗格。我知道,TBH会将它用于这样的任务,但我这样做更多的是为了尝试制作ST3插件 注意:我不想更改布局。无论有什么,在底部添加一个窗格 例如,如果我当前的屏幕选项卡是这样排列的: ---------- | tab 1 | | | ---------- | tab 2 | | | ---------- ---------- | tab 1 | | | ---------- |
----------
| tab 1 |
| |
----------
| tab 2 |
| |
----------
----------
| tab 1 |
| |
----------
| tab 2 |
----------
| tab 3 |
----------
{
"cells": [[0,0,1,1],[1,0,2,2]],
"cols": [0.0, 0.5, 1],
"rows", [0.0, 1.0]
}
然后我想添加一个选项卡3,使其定位如下:
----------
| tab 1 |
| |
----------
| tab 2 |
| |
----------
----------
| tab 1 |
| |
----------
| tab 2 |
----------
| tab 3 |
----------
{
"cells": [[0,0,1,1],[1,0,2,2]],
"cols": [0.0, 0.5, 1],
"rows", [0.0, 1.0]
}
还有一些例子:
----------------- ------------------
| tab 1 | tab 2 | | tab 1 | tab 2 |
| | | | | |
| | | --- > ------------------
| | | | tab 3 |
----------------- ------------------
----------------- ------------------
| tab 1 | tab 2 | | tab 1 | tab 2 |
| | | | | |
----------------- --- > ------------------
| tab 3 | tab 4 | | tab 3 | tab 4 |
| | | ------------------
----------------- | tab 5 |
------------------
以下是我的代码:
import sublime
import sublime_plugin
import subprocess
class CreateBottomTabCommand(sublime_plugin.WindowCommand):
def run(self):
layout = self.window.get_layout()
newLayout = calculate_new_layout_with_extra_pannel_at_bottom() # How do I do this?
self.window.run_command("set_layout", newLayout)
调用
window.get\u layout()
返回如下对象:
----------
| tab 1 |
| |
----------
| tab 2 |
| |
----------
----------
| tab 1 |
| |
----------
| tab 2 |
----------
| tab 3 |
----------
{
"cells": [[0,0,1,1],[1,0,2,2]],
"cols": [0.0, 0.5, 1],
"rows", [0.0, 1.0]
}
cells
属性有一个列表列表,其中每个内部列表都是该单元格的坐标
cols
包含从每个位置(0-1)开始垂直分割屏幕的相对Y位置
行
与cols
类似,但用于水平分隔符
为了保持简短,我将向您介绍更多信息
现在,我们要做的是,在最后一行的中间插入1行,(在屏幕的底部):
我们还想给这个它的Cooridate:terminalCoords = [0, len(layout["rows"]) - 1 , len(layout["cols"]) - 1, len(layout["rows"])]
然后你可以把它们放在物体的正确位置,然后开始!你完了
以下是完整的代码:
import sublime
import sublime_plugin
import subprocess
class CreateTerminalCommand(sublime_plugin.WindowCommand):
def run(self):
layout = self.window.get_layout()
terminalPos = round(1 - ((1 - layout["rows"][-2]) / 2), 1)
terminalCoords = [0, len(layout["rows"]) - 1 , len(layout["cols"]) - 1, len(layout["rows"])]
newLayout = layout
newLayout["rows"].insert(-1, terminalPos)
newLayout["cells"].append(terminalCoords)
self.window.run_command("set_layout", newLayout)