-
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/user_config/usr/share/newton/context_path/resources/css/newton/main.css b/user_config/usr/share/newton/context_path/resources/css/newton/main.css
index 45f15c6..7cdd1e8 100644
--- a/user_config/usr/share/newton/context_path/resources/css/newton/main.css
+++ b/user_config/usr/share/newton/context_path/resources/css/newton/main.css
@@ -1,5 +1,10 @@
/* IDs */
+#editor,
+#preview-editor {
+ background-color: #00000000;
+}
+
#editor {
background-color: #00000000;
margin: 0;
@@ -28,8 +33,30 @@
}
+#preview-editor {
+ height: -webkit-fill-available;
+ width: -webkit-fill-available;
+ max-height: calc(100% - 200px);
+}
+
+#buffers-selection {
+ max-height: 565px;
+ min-height: 565px;
+ overflow-y: auto;
+}
+
/* CLASSES */
+
+.max-height-800 {
+ max-height: 800px;
+}
+
+
+.margin-bottom-neg-200 {
+ margin-bottom: -200px;
+}
+
.ace_status-indicator {
color: gray;
position: absolute;
diff --git a/user_config/usr/share/newton/context_path/resources/css/newton/overrides.css b/user_config/usr/share/newton/context_path/resources/css/newton/overrides.css
index 093c813..3e9122e 100644
--- a/user_config/usr/share/newton/context_path/resources/css/newton/overrides.css
+++ b/user_config/usr/share/newton/context_path/resources/css/newton/overrides.css
@@ -11,4 +11,14 @@ body {
ul, li {
list-style: none;
+}
+
+.modal-header,
+.modal-footer {
+ background-color: rgba(0, 0, 0, 0.64);
+}
+
+.modal-content {
+ background-color: rgba(50, 56, 62, 0.74);
+ border-color: rgba(249, 148, 6, 0.74);
}
\ No newline at end of file
diff --git a/user_config/usr/share/newton/context_path/resources/js/newton/events.js b/user_config/usr/share/newton/context_path/resources/js/newton/events.js
index f0928d3..379c637 100644
--- a/user_config/usr/share/newton/context_path/resources/js/newton/events.js
+++ b/user_config/usr/share/newton/context_path/resources/js/newton/events.js
@@ -1,8 +1,9 @@
window.onload = (eve) => {
- loadEditor();
- loadInitialSessionTab();
-
console.log("Window Loaded...");
+
+ loadEditor();
+ loadPreviewEditor();
+ loadInitialSession();
}
window.onerror = function(msg, url, line, col, error) {
@@ -16,4 +17,63 @@ window.onerror = function(msg, url, line, col, error) {
// If you return true, then error alerts (like in older versions of Internet Explorer) will be suppressed.
return suppressErrorAlert;
-};
\ No newline at end of file
+};
+
+
+document.addEventListener("keyup", (eve) => {
+ switch (eve.key) {
+ case "ArrowUp":
+ break;
+ case "ArrowDown":
+ break;
+ case "ArrowLeft":
+ break;
+ case "ArrowRight":
+ break;
+ case "Enter":
+ if ( isNotNullOrUndefined(previewSel) ) {
+ let event = new MouseEvent('dblclick', {
+ 'view': window,
+ 'bubbles': true,
+ 'cancelable': true
+ });
+
+ previewSel.dispatchEvent(event);
+ }
+ case "Control":
+ isControlDown = false;
+ case "b":
+ if (isControlDown) {
+ $('#buffers-modal').modal("toggle");
+ }
+ break;
+ default:
+ break
+ }
+});
+
+
+document.addEventListener("keydown", (eve) => {
+ switch (eve.key) {
+ case "ArrowUp":
+ if ( isNotNullOrUndefined(previewSel) ) {
+ eve.preventDefault();
+ selectPriorPreview();
+ }
+ break;
+ case "ArrowDown":
+ if ( isNotNullOrUndefined(previewSel) ) {
+ eve.preventDefault();
+ selectNextPreview();
+ }
+ break;
+ case "ArrowLeft":
+ break;
+ case "ArrowRight":
+ break;
+ case "Control":
+ isControlDown = true;
+ default:
+ break
+ }
+});
diff --git a/user_config/usr/share/newton/context_path/resources/js/newton/globals.js b/user_config/usr/share/newton/context_path/resources/js/newton/globals.js
index 2b277d4..6a4c785 100644
--- a/user_config/usr/share/newton/context_path/resources/js/newton/globals.js
+++ b/user_config/usr/share/newton/context_path/resources/js/newton/globals.js
@@ -3,5 +3,8 @@ const messenger = (window.webkit) ? window.webkit.messageHandlers : (message) =
};
let editor = null;
+let previewEditor = null;
let aceSessions = {};
let currentSession = null;
+let previewSel = null;
+let isControlDown = false;
\ No newline at end of file
diff --git a/user_config/usr/share/newton/context_path/resources/js/newton/keybinding-newton.js b/user_config/usr/share/newton/context_path/resources/js/newton/keybinding-newton.js
index 13797d8..f8c5272 100644
--- a/user_config/usr/share/newton/context_path/resources/js/newton/keybinding-newton.js
+++ b/user_config/usr/share/newton/context_path/resources/js/newton/keybinding-newton.js
@@ -17,6 +17,13 @@ const editorCommands = [
editor.showKeyboardShortcuts();
})
}
+ }, {
+ name: "listBuffers",
+ bindKey: {win: "ctrl-b", mac: "ctrl-b"},
+ exec: function(editor) {
+ listOpenBuffers();
+ },
+ readOnly: true
}, {
name: "saveSession",
bindKey: {win: "ctrl-s", mac: "ctrl-s"},
diff --git a/user_config/usr/share/newton/context_path/resources/js/newton/ui-logic.js b/user_config/usr/share/newton/context_path/resources/js/newton/ui-logic.js
index 16fa91b..3ac9885 100644
--- a/user_config/usr/share/newton/context_path/resources/js/newton/ui-logic.js
+++ b/user_config/usr/share/newton/context_path/resources/js/newton/ui-logic.js
@@ -1,3 +1,30 @@
+
+const loadPreviewEditor = () => {
+ ace.require("ace/ext/language_tools");
+
+ previewEditor = ace.edit("preview-editor");
+ // Note: https://github.com/ajaxorg/ace/wiki/Configuring-Ace
+ previewEditor.setOptions({
+ printMarginColumn: 80,
+ enableBasicAutocompletion: true,
+ enableInlineAutocompletion: true,
+ enableSnippets: true,
+ enableLiveAutocompletion: true,
+ highlightActiveLine: true,
+ useSoftTabs: true,
+ tabSize: 4,
+ tooltipFollowsMouse: true,
+ useWrapMode: false,
+ scrollPastEnd: 0.5,
+ mergeUndoDeltas: false
+ });
+
+ // Note: https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts
+ previewEditor.commands.addCommands(editorCommands);
+
+ previewEditor.setTheme("ace/theme/one_dark");
+}
+
const loadEditor = () => {
ace.require("ace/ext/language_tools");
@@ -24,7 +51,7 @@ const loadEditor = () => {
editor.setTheme("ace/theme/one_dark");
}
-const loadInitialSessionTab = () => {
+const loadInitialSession = () => {
newSession(null, editor.getSession());
}
@@ -93,3 +120,83 @@ const saveSession = (fhash) => {
sendMessage("save", ftype, fhash, fpath, content);
}
+
+
+
+
+const listOpenBuffers = () => {
+ $('#buffers-modal').modal("toggle");
+
+ let ulElm = document.getElementById('buffers-selection');
+ let keys = Object.keys(aceSessions);
+
+ clearChildNodes(ulElm);
+ for (var i = 0; i < keys.length; i++) {
+ let session = aceSessions[keys[i]];
+ let liElm = document.createElement("li");
+ let fname = aceSessions[keys[i]]["fname"];
+ let fhash = keys[i];
+
+ liElm.innerText = ( fname === "" ) ? "buffer" : fname;
+ liElm.classList.add("list-group-item");
+ liElm.setAttribute("fhash", fhash);
+
+ if (fhash === currentSession) {
+ previewSel = liElm;
+ liElm.classList.add("bg-success");
+ liElm.classList.add("bg-info");
+ }
+
+
+ liElm.addEventListener("click", (elm) => {
+ previewSel.classList.remove("bg-info");
+
+ let fhash = elm.target.getAttribute("fhash");
+ let ftype = aceSessions[fhash]["ftype"];
+ let session = aceSessions[fhash]["session"];
+ previewSel = elm.target;
+
+ previewEditor.setSession(session);
+
+ if (ftype !== "buffer") {
+ previewEditor.session.setMode("ace/mode/" + ftype);
+ }
+
+ previewSel.classList.add("bg-info");
+ })
+
+ liElm.addEventListener("dblclick", (elm) => {
+ let fhash = elm.target.getAttribute("fhash");
+ let ftype = aceSessions[fhash]["ftype"];
+ let session = aceSessions[fhash]["session"];
+ previewSel = null;
+
+ setSession(ftype, fhash, session);
+ $('#buffers-modal').modal("toggle");
+ })
+
+ ulElm.appendChild(liElm);
+ }
+
+}
+
+
+const selectPriorPreview = () => {
+ let selectedElm = previewSel.previousElementSibling;
+ if ( !isNotNullOrUndefined(selectedElm) ) {
+ let childrenElms = previewSel.parentElement.children;
+ selectedElm = childrenElms[childrenElms.length - 1];
+ }
+
+ selectedElm.click();
+}
+
+const selectNextPreview = () => {
+ let selectedElm = previewSel.nextElementSibling;
+ if ( !isNotNullOrUndefined(selectedElm) ) {
+ let childrenElms = previewSel.parentElement.children;
+ selectedElm = childrenElms[0];
+ }
+
+ selectedElm.click();
+}
\ No newline at end of file