mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-27 11:19:47 +02:00
set ace as defaut editor
This commit is contained in:
11
src/packages/CodePad/Makefile
Normal file
11
src/packages/CodePad/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
coffee_files = coffees/CommandPalette.coffee coffees/main.coffee
|
||||
|
||||
jsfiles =
|
||||
|
||||
cssfiles = css/main.css
|
||||
|
||||
copyfiles = assets/scheme.html package.json
|
||||
|
||||
|
||||
PKG_NAME=CodePad
|
||||
include ../pkg.mk
|
16
src/packages/CodePad/assets/scheme.html
Normal file
16
src/packages/CodePad/assets/scheme.html
Normal file
@ -0,0 +1,16 @@
|
||||
<afx-app-window apptitle="Code" width="600" height="400" data-id="notepad">
|
||||
<afx-vbox>
|
||||
<afx-hbox>
|
||||
<afx-file-view data-width = "155" min-width="155" data-id = "fileview" view="tree" status = "false">
|
||||
</afx-file-view>
|
||||
<afx-resizer data-width = "3" ></afx-resizer>
|
||||
<div data-id="datarea"></div>
|
||||
</afx-hbox>
|
||||
<afx-hbox data-height="20" data-id="bottom-hbox">
|
||||
<afx-label data-id="editorstat"></afx-label>
|
||||
<!-- <afx-list-view data-width="160" data-id = "themelist" dropdown = "true" width="135"></afx-list-view>
|
||||
<afx-list-view data-width="125" data-id = "modelist" dropdown = "true" width="100"></afx-list-view>
|
||||
-->
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
30
src/packages/CodePad/coffees/CommandPalette.coffee
Normal file
30
src/packages/CodePad/coffees/CommandPalette.coffee
Normal file
@ -0,0 +1,30 @@
|
||||
class CommandPalette extends this.OS.GUI.BasicDialog
|
||||
constructor: () ->
|
||||
super "CommandPalete", CommandPalette.scheme
|
||||
|
||||
init: () ->
|
||||
me = @
|
||||
offset = $(".afx-window-content", @parent.scheme).offset()
|
||||
pw = @parent.scheme.get("width") / 5
|
||||
@scheme.set "width", 3 * pw
|
||||
$(@scheme).offset { top: offset.top, left: offset.left + pw }
|
||||
cb = (e) ->
|
||||
if ($ e.target).closest(me.scheme).length > 0
|
||||
$(me.find "searchbox").focus()
|
||||
else
|
||||
$(document).unbind "mousedown", cb
|
||||
me.quit()
|
||||
|
||||
$(document).on "mousedown", cb
|
||||
$(me.find "searchbox").focus()
|
||||
|
||||
CommandPalette.scheme = """
|
||||
<afx-app-window data-id = "cmd-win"
|
||||
apptitle="" minimizable="false"
|
||||
resizable = "false" width="200" height="200">
|
||||
<afx-vbox>
|
||||
<input data-height="25" type = "text" data-id="searchbox"/>
|
||||
<afx-list-view data-id="container"></afx-list-view>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
||||
"""
|
60
src/packages/CodePad/coffees/main.coffee
Normal file
60
src/packages/CodePad/coffees/main.coffee
Normal file
@ -0,0 +1,60 @@
|
||||
class CodePad extends this.OS.GUI.BaseApplication
|
||||
constructor: (args) ->
|
||||
super "CodePad", args
|
||||
|
||||
main: () ->
|
||||
me = @
|
||||
@fileview = @find("fileview")
|
||||
@fileview.set "fetch", (path) ->
|
||||
new Promise (resolve, reject) ->
|
||||
dir = path
|
||||
dir = path.asFileHandle() if typeof path is "string"
|
||||
dir.read().then (d) ->
|
||||
return reject d.error if d.error
|
||||
me.currdir = dir
|
||||
resolve d.result
|
||||
@fileview.set "path", "desktop://"
|
||||
@setup()
|
||||
|
||||
setup: () ->
|
||||
me = @
|
||||
ace.config.set('basePath', '/scripts/ace')
|
||||
ace.require "ace/ext/language_tools"
|
||||
@editor = ace.edit @find("datarea")
|
||||
@editor.setOptions {
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: true,
|
||||
highlightActiveLine: true,
|
||||
useWrapMode: true,
|
||||
fontSize: "9pt"
|
||||
}
|
||||
#themes = ace.require "ace/ext/themelist"
|
||||
#console.log themes.themesByName.monokai.theme
|
||||
@editor.setTheme "ace/theme/monokai"
|
||||
#console.log themes
|
||||
@editor.completers.push { getCompletions: ( editor, session, pos, prefix, callback ) -> }
|
||||
@editor.getSession().setUseWrapMode true
|
||||
@on "resize", () -> me.editor.resize()
|
||||
@on "focus", () -> me.editor.focus()
|
||||
@find("datarea").contextmenuHandle = (e, m) ->
|
||||
m.set "items", [{
|
||||
text: __("Command palete"),
|
||||
onmenuselect: (e) ->
|
||||
me.showCmdPalette()
|
||||
}]
|
||||
m.show e
|
||||
@editor.resize()
|
||||
|
||||
showCmdPalette: () ->
|
||||
@openDialog(new CommandPalette(), {
|
||||
|
||||
}).then (d) ->
|
||||
|
||||
CodePad.dependencies = [
|
||||
"ace/ace",
|
||||
"ace/ext-language_tools",
|
||||
"ace/ext-modelist",
|
||||
"ace/ext-themelist"
|
||||
]
|
||||
this.OS.register "CodePad", CodePad
|
55
src/packages/CodePad/css/main.css
Normal file
55
src/packages/CodePad/css/main.css
Normal file
@ -0,0 +1,55 @@
|
||||
afx-app-window[data-id = "notepad"] .afx-window-wrapper afx-file-view{
|
||||
background-color:#272822;
|
||||
}
|
||||
afx-app-window[data-id = "notepad"] afx-resizer {
|
||||
background-color:#272822;
|
||||
border-right: 1px solid #37373d;
|
||||
}
|
||||
afx-app-window[data-id = "notepad"] .afx-window-wrapper .treecontainer{
|
||||
padding-top: 10px;
|
||||
}
|
||||
afx-app-window[data-id = "notepad"] .afx-window-wrapper afx-tree-view{
|
||||
color: white;
|
||||
padding: 0;
|
||||
}
|
||||
afx-app-window[data-id = "notepad"] .afx-window-wrapper afx-tree-view afx-tree-view-item ul li{
|
||||
padding-left: 10px;
|
||||
}
|
||||
afx-app-window[data-id = "notepad"] .afx-window-wrapper .afx_tree_item_selected ul{
|
||||
background-color: #116cd6;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "notepad"] afx-file-view afx-tree-view .afx-tree-view-item:before{
|
||||
color: white;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "notepad"] .afx-window-wrapper afx-hbox[data-id="bottom-hbox"]{
|
||||
color: white;
|
||||
background-color: #007acc;
|
||||
}
|
||||
|
||||
|
||||
afx-app-window[data-id = "cmd-win"] .afx-window-wrapper{
|
||||
border-radius: 0px;
|
||||
border: 0;
|
||||
/*border: 1px solid #37373d;*/
|
||||
background-color: transparent;
|
||||
box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.65);
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "cmd-win"] .afx-window-top{
|
||||
height: 0;
|
||||
border:0;
|
||||
}
|
||||
afx-app-window[data-id = "cmd-win"] input{
|
||||
border: 1px solid #007acc;
|
||||
border-radius: 0;
|
||||
font-size: 12px;
|
||||
color:#afafaf;
|
||||
background-color:#272822;
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "cmd-win"] .afx-window-content{
|
||||
background-color:#272822;
|
||||
}
|
19
src/packages/CodePad/package.json
Normal file
19
src/packages/CodePad/package.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"app":"CodePad",
|
||||
"name": "Code",
|
||||
"description":"Code editor",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com",
|
||||
"licences": "GPLv3"
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Developments",
|
||||
"iconclass":"fa fa-pencil-square-o",
|
||||
"mimes":[
|
||||
"text/.*",
|
||||
"[^/]*/json.*",
|
||||
"[^/]*/.*ml",
|
||||
"[^/]*/javascript"
|
||||
]
|
||||
}
|
@ -78,6 +78,7 @@ class PushNotification extends this.OS.GUI.BaseService
|
||||
icon: o.data.icon,
|
||||
iconclass: o.data.iconclass,
|
||||
closable: true }
|
||||
console.log o
|
||||
@mlist.unshift d
|
||||
@notifeed d
|
||||
|
||||
|
Reference in New Issue
Block a user