-zooming on editor

todo: editor is taking whole dialog
This commit is contained in:
thelastWallE 2021-04-11 00:17:19 +02:00
parent 05b5926101
commit 58c26ca9ae
4 changed files with 50 additions and 11 deletions

View File

@ -129,7 +129,8 @@ class KlipperPlugin(
logpath="/tmp/klippy.log",
reload_command="RESTART",
navbar=True,
parse_check=False
parse_check=False,
fontsize=9
)
)
@ -374,7 +375,7 @@ class KlipperPlugin(
if "FIRMWARE_VERSION" in printerInfo:
self.log_info("Firmware version: {}".format(
printerInfo["FIRMWARE_VERSION"]))
elif "// probe" in line:
elif "// probe" in line or "// Failed to verify BLTouch" in line:
msg = line.strip('/')
self.log_info(msg)
write_parsing_response_buffer()
@ -452,9 +453,9 @@ class KlipperPlugin(
self._settings.set(["config"], data["config"])
# self.send_message("reload", "config", "", data["config"])
# send the configdata to frontend to update ace editor
if sys.version_info[0] < 3:
data["config"] = data["config"].decode('utf-8')
return flask.jsonify(data=data["config"])
if sys.version_info[0] < 3:
data["config"] = data["config"].decode('utf-8')
return flask.jsonify(data=data["config"])
elif command == "checkConfig":
if "config" in data:
if not self.validate_configfile(data["config"]):

View File

@ -104,7 +104,15 @@ div#settings_plugin_klipper.tab-pane.active form.form-horizontal div.tab-content
div#settings_plugin_klipper.tab-pane.active form.form-horizontal div.tab-content div#conf.tab-pane.active div.control-group div.conf-editor {
height: 100%;
overflow: auto;
width: 100%;
}
div#settings_plugin_klipper.tab-pane.active form.form-horizontal div.tab-content div#conf.tab-pane.active div.control-group div.conf-editor div#plugin-klipper-config {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
div#settings_plugin_klipper.tab-pane.active form.form-horizontal div.tab-content div#conf.tab-pane.active div.control-group button.btn.btn-small {

View File

@ -107,6 +107,28 @@ $(function() {
}
}
self.minusFontsize = function () {
self.settings.settings.plugins.klipper.configuration.fontsize(self.settings.settings.plugins.klipper.configuration.fontsize() - 1);
if (self.settings.settings.plugins.klipper.configuration.fontsize() < 9) {
self.settings.settings.plugins.klipper.configuration.fontsize(9);
}
if (editor) {
editor.setFontSize(self.settings.settings.plugins.klipper.configuration.fontsize());
editor.resize();
}
}
self.plusFontsize = function () {
self.settings.settings.plugins.klipper.configuration.fontsize(self.settings.settings.plugins.klipper.configuration.fontsize() + 1);
if (self.settings.settings.plugins.klipper.configuration.fontsize() > 20) {
self.settings.settings.plugins.klipper.configuration.fontsize(20);
}
if (editor) {
editor.setFontSize(self.settings.settings.plugins.klipper.configuration.fontsize());
editor.resize();
}
}
self.loadLastSession = function () {
if (self.settings.settings.plugins.klipper.configuration.old_config() != "") {
self.klipperViewModel.consoleMessage("info","lastSession:" + self.settings.settings.plugins.klipper.configuration.old_config())
@ -156,6 +178,8 @@ $(function() {
obKlipperConfig = config.withSilence();
if (editor) {
editor.setValue(obKlipperConfig());
editor.setFontSize(self.settings.settings.plugins.klipper.configuration.fontsize());
editor.resize();
editor.clearSelection();
}
return obKlipperConfig;
@ -166,13 +190,16 @@ $(function() {
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/klipper_config");
editor.setOptions({
autoScrollEditorIntoView: true,
maxLines: "Infinity"
hScrollBarAlwaysVisible: true,
vScrollBarAlwaysVisible: true,
autoScrollEditorIntoView: true,
//maxLines: "Infinity"
})
editor.session.on('change', function(delta) {
if (obKlipperConfig) {
obKlipperConfig.silentUpdate(editor.getValue());
editor.resize();
}
});

View File

@ -196,7 +196,7 @@
</div>
<div class="control-group">
<div class="controls">
<a href='#' data-bind='click: addProbePoint' class="fa fa-plus-circle"></a> {{ _('Add Point') }}
<a href='#' data-bind="click: addProbePoint" class="fa fa-plus-circle"></a> {{ _('Add Point') }}
</div>
</div>
</div>
@ -206,14 +206,17 @@
<script src="plugin/klipper/static/js/lib/ace/ace.min.js" type="text/javascript" charset="utf-8"></script>
<script src="plugin/klipper/static/js/lib/ace/theme-monokai.min.js" type="text/javascript" charset="utf-8"></script>
<script src="plugin/klipper/static/js/lib/ace/mode-klipper_config.js" type="text/javascript"></script>
<button class="btn btn-small" data-bind='click: loadLastSession'
<button class="btn btn-small" data-bind="click: loadLastSession"
title="Reloads the last changes">
<i class="fas fa-redo"></i> {{ _('Reload last changes') }}
</button>
<button class="btn btn-small" data-bind='click: reloadFromFile'>
<i class="fas fa-upload"></i></a> {{ _('Reload from file') }}
<i class="fas fa-upload"></i> {{ _('Reload from file') }}
</button>
<label class="inline"><input class="inline-checkbox" type="checkbox" data-bind="checked: settings.settings.plugins.klipper.configuration.parse_check"> {{ _('Check parsing on save') }}</label>
&nbsp;&nbsp;
<a href='#' data-bind="click: minusFontsize" class="fas fa-search-minus"></a>
<a href='#' data-bind="click: plusFontsize" class="fas fa-search-plus"></a>
<div class="conf-editor">
<input id="hdnLoadKlipperConfig" type="hidden" data-bind="value: configBound(settings.settings.plugins.klipper.config)" />
<div id="plugin-klipper-config"></div>