继上一篇 node webkit 用javascript打造web native之后,终于算是可以做出一个atom编辑器,只是这里是为了记念一下Nokia的Lumia手机,最后代码见
# alias to nw alias nw="/Applications/node-webkit.app/Contents/MacOS/node-webkit"
应用一下
source ~/.bash_profile
启动应用的方式是
nw app.nw
启动之前需要
zip -r app.nw *
这样我们就有了一个基本的框架了
<body style="background:#fff"><div class="workspace" background="#fff"><div class="horizontal"><div class="vertical"><div class="panes"><div class="pane" style="min-width:100%;"><ul tabindex="-1" class="list-inline tab-bar inset-panel"><li class="tab active"><div class="title" id="title">untitled</div><div class="close-icon"></div></li></ul><div class="editor"><div id="editor"></div></div></div></div><div class="status-bar tool-panel panel-bottom"><div class="flexbox-repaint-hack"><div class="status-bar-left"><div class="cursor-position inline-block" id="mode"></a><div class="status-image inline-block"><span class="image-size" style="display: none;"></span></div></div></div></div></div></div><input style="display:none;" id="newFile" type="file" /><input style="display:none;" id="openFile" type="file" /><input style="display:none;" id="saveFile" type="file" nwsaveas /></div><div style="display:none"><button style="display:none;" id="new">New</button><button style="display:none;" id="open">Open</button><button style="display:none;" id="save">Save</button></div></body>
.tab-bar .tab:before {content:'';position: absolute;top: -1px;left: -16px;height: 26px;width: 30px;border-top-left-radius: 3px;border-left: 1px solid #b9b9b9;box-shadow: inset 1px -1px 1px rgba(0, 0, 0, 0.05);-webkit-transform: skewX(133deg);}.tab-bar:after {content:"";position: absolute;bottom: 0;height: 5px;left: 0px;width: 100%;background-color: #f0f0f0;border-bottom: 1px solid #dddddd;border-top: 1px solid #b9b9b9;}
onload = function() {newButton = ElementById("new");openButton = ElementById("open");saveButton = ElementById("save");newButton.addEventListener("click", handleNewButton);openButton.addEventListener("click", handleOpenButton);saveButton.addEventListener("click", handleSaveButton);$("#saveFile").change(function(evt) {onChosenFileToSave($(this).val());});$("#openFile").change(function(evt) {onChosenFileToOpen($(this).val());}); editor = ElementById("editor"), {lineNumbers: true,keyMap: "sublime",autoCloseBrackets: true,matchBrackets: true,showCursorWhenSelecting: true,extraKeys: {"Cmd-N": function(instance) {handleNewButton()},"Ctrl-N": function(instance) {handleNewButton()},"Cmd-O": function(instance) {handleOpenButton()},"Ctrl-O": function(instance) {handleOpenButton()},"Cmd-S": function(instance) {handleSaveButton()},"Ctrl-S": function(instance) {handleSaveButton()},"Cmd-Shift-P": function(instance) {console.log("hello".green)}}});newFile();onresize();().show();};
function handleDocumentChange(title) {var mode = "javascript";var modeName = "JavaScript";if (title) {title = title.match(/[^/]+$/)[0];ElementById("title").innerHTML = title;document.title ="Lumia"+title;_.each(m.allmodes, function(modes) {if (S(title).contains(modes["filename"])) {mode = modes["mode"];modeName = modes["modeName"];console.log(mode);}});} else {ElementById("title").innerHTML = "[no document loaded]";}editor.setOption("mode", mode);ElementById("mode").innerHTML = modeName;}
var m = require('./allmodes')
本文发布于:2024-02-05 07:38:49,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170727573064561.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |