Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions spyder_terminal/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ class TerminalMainWidgetActions:

class TermViewMenus:
Context = 'context_menu'

class TerminalMainWidgetMenus:
Remote = 'remote_menu'
1 change: 0 additions & 1 deletion spyder_terminal/server/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
</head>
<body>
<div id="terminal-container"></div>
<script type="text/javascript" src="/static/build/main.bundle.js"></script>
</body>
</html>
9 changes: 8 additions & 1 deletion spyder_terminal/server/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ function createTerminal(){
}

window.onresize = (event) => {
fitAddon.fit();
if(fitAddon){
fitAddon.fit();
}
}

function searchNext(regex, options) {
Expand Down Expand Up @@ -156,6 +158,10 @@ function exec(cmd){
socket.send('' + cmd + lineEnd);
}

function exec_delayed(cmd, delay){
setTimeout(() => { exec(cmd) }, delay)
}

function pasteText(cmd){
socket.send('' + cmd);
}
Expand Down Expand Up @@ -257,6 +263,7 @@ const term_functions = {
chdir: chdir,
clearTerm: clearTerm,
exec: exec,
exec_delayed: exec_delayed,
closeTerm: closeTerm,
consoleReady: consoleReady,
scrollTerm: scrollTerm,
Expand Down
38 changes: 36 additions & 2 deletions spyder_terminal/terminalplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
"""Terminal Plugin."""

# Standard imports
from functools import cached_property
import os
import os.path as osp

# Third party imports
from qtpy.QtCore import Signal
from spyder.api.fonts import SpyderFontType
from spyder.api.plugins import Plugins, SpyderDockablePlugin
from spyder.api.plugin_registration.decorators import on_plugin_available
from spyder.api.plugin_registration.decorators import (
on_plugin_available,
on_plugin_teardown,
)
from spyder.config.base import get_translation

# Local imports
Expand All @@ -38,7 +42,12 @@ class TerminalPlugin(SpyderDockablePlugin):
"""
NAME = 'terminal'
REQUIRES = [Plugins.Preferences]
OPTIONAL = [Plugins.Projects, Plugins.Editor, Plugins.WorkingDirectory]
OPTIONAL = [
Plugins.Projects,
Plugins.Editor,
Plugins.WorkingDirectory,
Plugins.RemoteClient,
]
TABIFY = [Plugins.IPythonConsole]
CONF_SECTION = NAME
WIDGET_CLASS = TerminalMainWidget
Expand Down Expand Up @@ -102,6 +111,27 @@ def on_preferences_available(self):
preferences = self.get_plugin(Plugins.Preferences)
preferences.register_plugin_preferences(self)

@on_plugin_available(plugin=Plugins.RemoteClient)
def on_remoteclient_available(self):
"""Connect when preferences available."""
remoteclient = self.get_plugin(Plugins.RemoteClient)
widget = self.get_widget()

remoteclient.sig_server_changed.connect(
widget.setup_remote_terminals_menu
)
widget.setup_remote_terminals_menu()

@on_plugin_teardown(plugin=Plugins.RemoteClient)
def on_remoteclient_teardown(self):
"""Connect when preferences available."""
remoteclient = self.get_plugin(Plugins.RemoteClient)
widget = self.get_widget()

remoteclient.sig_server_changed.disconnect(
widget.setup_remote_terminals_menu
)

def update_font(self):
"""Update font from Preferences."""
font = self.get_font(SpyderFontType.Monospace)
Expand Down Expand Up @@ -148,3 +178,7 @@ def set_current_opened_file(self, filename, _language):

def create_new_term(self, **kwargs):
self.get_widget().create_new_term(**kwargs)

@cached_property
def _remote_client(self):
return self.get_plugin(Plugins.RemoteClient)
Loading
Loading