diff --git a/css/main.css b/css/main.css index 23e34fdffa02f48f4a7a34b6a9b69461ee1407c2..51164b9326056cb2f3b065f3eda7593309eb061c 100644 --- a/css/main.css +++ b/css/main.css @@ -192,7 +192,7 @@ hr { width: 100%; background-color: rgba(255,255,255,0.5); white-space: pre-wrap; - padding: 15px 0 15px 20px; + padding: 15px 0 15px 13px; overflow: auto; } @@ -518,4 +518,9 @@ label { padding: 5px 10px 20px 10px; font-size: 14px; font-family: Courier, monospace; +} + +.gCodeLineNum { + margin-right: 20px; + color: #B7B6B6; } \ No newline at end of file diff --git a/js/menus/MenuWrapperView.js b/js/menus/MenuWrapperView.js index 2e2e0e6634df8a15701c65acdf57c33135e71ec0..0c6a8bffa6d0444452677cf75c3a35ade1aaa1d0 100644 --- a/js/menus/MenuWrapperView.js +++ b/js/menus/MenuWrapperView.js @@ -114,6 +114,11 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice', 'appState', 'tex }, _setNumber: function($target, newVal){ + var min = $target.data("min"); + var max = $target.data("max"); + if (min !== undefined && (min > newVal)) newVal = min; + else if (max !== undefined && (max < newVal)) newVal = max; + var property = $target.data("property"); if (!property) { console.warn("no property associated with number input"); diff --git a/js/menus/SendMenuView.js b/js/menus/SendMenuView.js index 85a50f13f7853f6265399b835b69a070fc7fb848..af30e434d6357935da097d00799c1bd5a1367bb9 100644 --- a/js/menus/SendMenuView.js +++ b/js/menus/SendMenuView.js @@ -20,6 +20,8 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s _initialize: function(){ + this.gcode = ""; + this.listenTo(serialComm, "change", this._renderControls); this.listenTo(cam, "change", this._renderControls); this.listenTo(cam, "change:simLineNumber", this._lineNumChanged); @@ -76,9 +78,9 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s }, _drawGcodeHighlighter: function(lineNum){ - var code = cam.get("dataOut").split("\n"); + var code = this.gcode.split("\n"); code[lineNum] = "<span id='gcodeHighlighter'>" + code[lineNum] + " </span>"; - var newText = code.join("\n"); + var newText = code.join('\n'); var $editor = $('#gcodeEditor'); $editor.html(newText); var $highlighter = $("#gcodeHighlighter"); @@ -111,6 +113,12 @@ define(['jquery', 'underscore', 'menuParent', 'serialComm', 'commPlist', 'text!s _render: function(){ this._setEditorHeight(); + var code = cam.get("dataOut").split("\n"); + var newText = ""; + _.each(code, function(line, num){ + newText += '<span class="gCodeLineNum">' + num + '</span>' + line + '\n'; + }); + this.gcode = newText; this._drawGcodeHighlighter(cam.get("simLineNumber")); this._renderControls(); }, diff --git a/js/menus/templates/SendControlPanel.html b/js/menus/templates/SendControlPanel.html index f13bb2d373e90812a6c70a2fd8fe5fe48934b8e5..3d5a81e41a1d993889974db5fa2438e2b0e25262 100644 --- a/js/menus/templates/SendControlPanel.html +++ b/js/menus/templates/SendControlPanel.html @@ -9,6 +9,6 @@ <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span> Single step mode</label> <a href="#" id="openSerialMonitor" class="btn btn-block btn-lg btn-default">Open Serial Monitor</a><br/> -Next Line: <input id="nextLine" data-property="simLineNumber" value="<%= simLineNumber %>" placeholder="##" class="intInput form-control cam" type="text"> +Next Line: <input id="nextLine" data-property="simLineNumber" data-min="0" data-max="<%= dataOut.split('\n').length-1 %>" value="<%= simLineNumber %>" placeholder="##" class="intInput form-control cam" type="text"> <a href="#" id="previousLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-up"></span></a> <a href="#" id="nextLineButton" class="btn btn-lg btn-default"><span class="fui-triangle-down"></span></a><br/><br/> \ No newline at end of file diff --git a/js/menus/templates/SendMenuView.html b/js/menus/templates/SendMenuView.html index 57ff76fea48de81518174544bfc51967e219afd5..4544f88199ec161d5eb6a847b6ac9a4e9b7e58f2 100644 --- a/js/menus/templates/SendMenuView.html +++ b/js/menus/templates/SendMenuView.html @@ -3,7 +3,7 @@ You need to go through the Assemble workflow to setup your machine and create <%= allCamProcesses[camProcess] %> first. <% }else{ %> <div id="sendControls"></div> - <div id="gcodeEditor"><%= dataOut %></div><br/> + <div id="gcodeEditor"></div><br/> <% } %> <% } else { %> Not connected, go back to setup tab and connect to Node server.