mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-02-22 01:42:47 +01:00
app launcher
This commit is contained in:
parent
ec09e07eb7
commit
91a0d0a6b6
@ -191,6 +191,31 @@ class YesNoDialog extends BasicDialog
|
||||
}
|
||||
this.OS.register "YesNoDialog", YesNoDialog
|
||||
|
||||
class SelectionDialog extends BasicDialog
|
||||
constructor: () ->
|
||||
super "SelectionDialog", {
|
||||
tag: "afx-list-view",
|
||||
att: "",
|
||||
width: 250,
|
||||
height: 300,
|
||||
resizable: false,
|
||||
buttons: [
|
||||
{
|
||||
label: "Ok", onclick: (d) ->
|
||||
el = d.find "content"
|
||||
it = el.get "selected"
|
||||
return unless it
|
||||
d.handler it if d.handler
|
||||
d.quit()
|
||||
},
|
||||
{ label: "Cancel", onclick: (d) -> d.quit() }
|
||||
],
|
||||
filldata: (d) ->
|
||||
return unless d.data
|
||||
(d.find "content").set "items", d.data
|
||||
}
|
||||
this.OS.register "SelectionDialog", SelectionDialog
|
||||
|
||||
class AboutDialog extends BaseDialog
|
||||
constructor: () ->
|
||||
super "AboutDialog"
|
||||
|
@ -2,9 +2,10 @@ class BaseModel
|
||||
constructor: (@name, @args) ->
|
||||
@observable = riot.observable()
|
||||
@_api = self.OS.API
|
||||
@_gui = self.OS.GUI
|
||||
me = @
|
||||
@on "exit", () -> me.quit()
|
||||
@host = "#desktop"
|
||||
@host = "#workingenv"
|
||||
@dialog = undefined
|
||||
|
||||
render: (p) ->
|
||||
@ -35,10 +36,10 @@ class BaseModel
|
||||
if @dialog
|
||||
@dialog.show()
|
||||
return
|
||||
if not _GUI.dialog[d]
|
||||
if not _GUI.dialogs[d]
|
||||
@error "Dialog #{d} not found"
|
||||
return
|
||||
@dialog = new _GUI.dialog[d]()
|
||||
@dialog = new _GUI.dialogs[d]()
|
||||
@dialog.parent = @
|
||||
@dialog.handler = f
|
||||
@dialog.pid = @pid
|
||||
|
@ -117,5 +117,5 @@ self.OS.API =
|
||||
catch e
|
||||
err = e
|
||||
return "" if not err
|
||||
return err.stack
|
||||
return err
|
||||
|
||||
|
@ -8,6 +8,7 @@ self.OS or=
|
||||
setting:
|
||||
user: {}
|
||||
applications: {}
|
||||
desktop: {}
|
||||
appearance: {}
|
||||
courrier:
|
||||
observable: riot.observable()
|
||||
@ -22,6 +23,8 @@ self.OS or=
|
||||
_courrier.ostrigger "fail", { m: m, e: e, s: s }
|
||||
oserror: (m, e, s) ->
|
||||
_courrier.ostrigger "error", { m: m, e: e, s: s }
|
||||
osinfo: (m) ->
|
||||
_courrier.ostrigger "info", { m: m, e: null, s: null }
|
||||
ostrigger: (e, d) ->
|
||||
_courrier.trigger e, { id: 0, data: d, name: "OS" }
|
||||
unregister: (app) ->
|
||||
@ -33,7 +36,7 @@ self.OS or=
|
||||
_courrier.quota += 1
|
||||
_courrier.quota
|
||||
register: (name, x) ->
|
||||
if x.type is 3 then self.OS.GUI.dialog[name] = x else _OS.APP[name] = x
|
||||
if x.type is 3 then self.OS.GUI.dialogs[name] = x else _OS.APP[name] = x
|
||||
|
||||
PM:
|
||||
pidalloc: 0
|
||||
|
@ -1,5 +1,6 @@
|
||||
self.OS.GUI =
|
||||
dialog: new Object()
|
||||
dialogs: new Object()
|
||||
dialog: undefined
|
||||
htmlToScheme: (html, app, parent) ->
|
||||
scheme = $.parseHTML html
|
||||
($ parent).append scheme
|
||||
@ -19,7 +20,8 @@ self.OS.GUI =
|
||||
$ "head link#ostheme"
|
||||
.attr "href", ""
|
||||
|
||||
loadTheme: (name) ->
|
||||
loadTheme: (name, force) ->
|
||||
_GUI.clearTheme() if force
|
||||
path = "resources/themes/#{name}/#{name}.css"
|
||||
$ "head link#ostheme"
|
||||
.attr "href", path
|
||||
@ -31,6 +33,21 @@ self.OS.GUI =
|
||||
srvs.splice 0, 1
|
||||
f i for i in srvs
|
||||
|
||||
openDialog: (d, f, title, data) ->
|
||||
if _GUI.dialog
|
||||
_GUI.dialog.show()
|
||||
return
|
||||
if not _GUI.dialogs[d]
|
||||
ex = _API.throwe "Dialog"
|
||||
return _courrier.oserror "Dialog #{d} not found", ex, null
|
||||
_GUI.dialog = new _GUI.dialogs[d]()
|
||||
_GUI.dialog.parent = _GUI
|
||||
_GUI.dialog.handler = f
|
||||
_GUI.dialog.pid = -1
|
||||
_GUI.dialog.data = data
|
||||
_GUI.dialog.title = title
|
||||
_GUI.dialog.init()
|
||||
|
||||
pushService: (ph) ->
|
||||
arr = ph.split "/"
|
||||
srv = arr[1]
|
||||
@ -43,6 +60,32 @@ self.OS.GUI =
|
||||
_courrier.trigger "srvroutineready", srv
|
||||
_courrier.osfail "Cannot read service script: #{srv} ", e, s
|
||||
|
||||
appsByMime: (mime) ->
|
||||
metas = ( a.meta for k, a of _OS.APP when a.type is 1)
|
||||
mimes = ( m.mimes for m in metas )
|
||||
apps = []
|
||||
# search app by mimes
|
||||
f = ( arr, idx ) ->
|
||||
arr.filter (m, i) ->
|
||||
if mime.match (new RegExp m, "g")
|
||||
apps.push metas[idx]
|
||||
return false
|
||||
return false
|
||||
|
||||
f m, i for m, i in mimes
|
||||
return apps
|
||||
|
||||
openWith: (it) ->
|
||||
return unless it
|
||||
console.log "open #{it.path}"
|
||||
apps = _GUI.appsByMime ( if it.type is "dir" then "dir" else it.mime )
|
||||
return OS.info "No application available to open #{it.filename}" if apps.length is 0
|
||||
return _GUI.launch apps[0].app, [it.path] if apps.length is 1
|
||||
list = ( { text: e.app, icon: e.icon, iconclass: e.iconclass } for e in apps )
|
||||
_GUI.openDialog "SelectionDialog", ( d ) ->
|
||||
_GUI.launch d.text, [it.path]
|
||||
, "Open width", list
|
||||
|
||||
forceLaunch: (app, args) ->
|
||||
console.log "This method is used for developing only, please use the launch method instead"
|
||||
_PM.killAll app
|
||||
@ -129,19 +172,71 @@ self.OS.GUI =
|
||||
return null unless x
|
||||
scheme = $.parseHTML x
|
||||
($ "#wrapper").append scheme
|
||||
|
||||
# system menu and dock
|
||||
riot.mount ($ "#syspanel", $ "#wrapper")
|
||||
riot.mount ($ "#sysdock", $ "#wrapper"), { items: [] }
|
||||
|
||||
# context menu
|
||||
riot.mount ($ "#contextmenu")
|
||||
($ "#workspace").contextmenu (e) -> _GUI.bindContextMenu e
|
||||
#desktop
|
||||
desktop = ($ "#desktop")
|
||||
desktop.on "click", (e) ->
|
||||
return if e.target isnt desktop.get(0)
|
||||
($ "#sysdock").get(0).set "selectedApp", null
|
||||
desktop.get(0).contextmenuHandler = (e, m) ->
|
||||
console.log "context menu handler for desktop"
|
||||
# system menu
|
||||
riot.mount ($ "#syspanel", $ "#wrapper")
|
||||
riot.mount ($ "#sysdock", $ "#wrapper"), { items: [] }
|
||||
|
||||
# desktop default file manager
|
||||
desktop = $ "#desktop"
|
||||
desktop[0].fetch = () ->
|
||||
fp = _OS.setting.desktop.path.asFileHandler()
|
||||
fn = () ->
|
||||
fp.read (d) ->
|
||||
return _courrier.osfail d.error, (_API.throwe "OS.VFS"), d.error if d.error
|
||||
items = []
|
||||
$.each d.result, (i, v) ->
|
||||
return if v.filename[0] is '.' and not _OS.setting.desktop.showhidden
|
||||
v.text = v.filename
|
||||
#v.text = v.text.substring(0,9) + "..." ifv.text.length > 10
|
||||
v.iconclass = v.type
|
||||
items.push(v)
|
||||
desktop[0].set "items", items
|
||||
desktop[0].refresh()
|
||||
|
||||
fp.onready () ->
|
||||
fn()
|
||||
, ( e ) -> # try to create the path
|
||||
console.log "#{fp.path} not found"
|
||||
name = fp.basename
|
||||
fp.parent().asFileHandler().mk name, (r) ->
|
||||
ex = _API.throwe "OS.VFS"
|
||||
if r.error then _courrier.osfail d.error, ex, d.error else fn()
|
||||
|
||||
desktop[0].ready = (e) ->
|
||||
e.observable = _courrier
|
||||
window.onresize = () ->
|
||||
_courrier.trigger "desktopresize"
|
||||
e.refresh()
|
||||
|
||||
desktop[0].set "onlistselect", (d) ->
|
||||
($ "#sysdock").get(0).set "selectedApp", null
|
||||
|
||||
desktop[0].set "onlistdbclick", ( d ) ->
|
||||
($ "#sysdock").get(0).set "selectedApp", null
|
||||
it = desktop[0].get "selected"
|
||||
_GUI.openWith it
|
||||
|
||||
($ "#workingenv").on "click", (e) ->
|
||||
desktop[0].set "selected", -1
|
||||
|
||||
desktop.on "click", (e) ->
|
||||
($ "#sysdock").get(0).set "selectedApp", null
|
||||
desktop[0].set "selected", -1 if e.target is desktop[0]
|
||||
console.log "desktop clicked"
|
||||
|
||||
desktop[0].contextmenuHandler = (e, m) ->
|
||||
desktop[0].set "selected", -1 if e.target is desktop[0]
|
||||
console.log "context menu handler for desktop"
|
||||
|
||||
desktop[0].fetch()
|
||||
_courrier.trigger "desktoploaded"
|
||||
# mount it
|
||||
riot.mount desktop
|
||||
, (e, s) ->
|
||||
alert "System fall: Cannot init desktop manager"
|
||||
|
||||
@ -161,16 +256,25 @@ self.OS.GUI =
|
||||
alert "System fall: Cannot init login screen"
|
||||
|
||||
startAntOS: (conf) ->
|
||||
# clean up things
|
||||
_OS.cleanup()
|
||||
# get setting from conf
|
||||
_OS.setting.desktop = conf.desktop if conf.desktop
|
||||
_OS.setting.applications = conf.applications if conf.applications
|
||||
_OS.setting.appearance = conf.appearance if conf.appearance
|
||||
_OS.setting.user = conf.user
|
||||
# get setting from conf
|
||||
# load packages list
|
||||
_OS.setting.desktop.path = "home:///.desktop" unless _OS.setting.desktop.path
|
||||
# load theme
|
||||
# initDM
|
||||
_GUI.loadTheme "antos"
|
||||
# initDM
|
||||
_GUI.initDM()
|
||||
_courrier.observable.one "syspanelloaded", () ->
|
||||
#_GUI.loadApp "CoreServices", (a) ->
|
||||
# TODO load packages list then build system menu
|
||||
# push startup services
|
||||
# TODO: get services list from user setting
|
||||
_GUI.pushServices ["CoreServices/PushNotification", "CoreServices/Spotlight", "CoreServices/Calendar"]
|
||||
|
||||
# startup application here
|
||||
_courrier.observable.one "desktoploaded", () ->
|
||||
_GUI.launch "Files"
|
||||
_GUI.launch "NotePad"
|
@ -3,7 +3,7 @@
|
||||
<!--div class = "afx-clear"></div-->
|
||||
<div id = "workspace">
|
||||
<afx-apps-dock id="sysdock"></afx-apps-dock>
|
||||
<div id = "desktop">
|
||||
</div>
|
||||
<afx-float-list id = "desktop" ></afx-float-list>
|
||||
<div id = "workingenv"></div>
|
||||
</div>
|
||||
<afx-menu id="contextmenu" context="true" style="display:none;"></afx-menu>
|
||||
|
@ -50,8 +50,10 @@
|
||||
}
|
||||
this.on('mount', function() {
|
||||
var left,top
|
||||
left = 20 + Math.floor(Math.random() * ($("#desktop").width() - width))
|
||||
top = 20 + Math.floor(Math.random() * ($("#desktop").height() - height))
|
||||
//left = 20 + Math.floor(Math.random() * ($("#desktop").width() - width))
|
||||
//top = 20 + Math.floor(Math.random() * ($("#desktop").height() - height))
|
||||
left = ($("#desktop").width() - width)/2
|
||||
top = ($("#desktop").height() - height)/2
|
||||
$(self.refs.window)
|
||||
.css("position",'absolute')
|
||||
.css("left",left + "px")
|
||||
|
@ -1,8 +1,176 @@
|
||||
<afx-float-list>
|
||||
<div>
|
||||
|
||||
<afx-float-list ref = "container">
|
||||
<div each={item,i in items } class={float_list_item:true, float_list_item_selected: parent._autoselect(item,i)} ondblclick = {parent._dbclick} onmousedown = {parent._select} oncontextmenu = {parent._select}>
|
||||
<afx-label color = {item.color} iconclass = {item.iconclass} icon = {item.icon} text = {item.text}></afx-label>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
<script>
|
||||
this.items = opts.items || []
|
||||
var self = this
|
||||
self.selidx = -1
|
||||
self.onlistselect = opts.onlistselect
|
||||
self.onlistdbclick = opts.onlistdbclick
|
||||
self.fetch = undefined
|
||||
this.root.observable = opts.observable || riot.observable()
|
||||
this.rid = $(self.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1
|
||||
self.dir = opts.dir || "horizontal"
|
||||
|
||||
self.root.set = function(k,v)
|
||||
{
|
||||
if(k == "selected")
|
||||
{
|
||||
if(self.selidx != -1)
|
||||
self.items[self.selidx].selected =false
|
||||
if(self.items[v]) self.items[v].selected = true
|
||||
}
|
||||
else if(k == "*")
|
||||
for(var i in v)
|
||||
self[i] = v[i]
|
||||
else
|
||||
self[k] = v
|
||||
self.update()
|
||||
}
|
||||
self.root.get = function(k)
|
||||
{
|
||||
if(k == "selected")
|
||||
if(self.selidx == -1)
|
||||
return undefined
|
||||
else
|
||||
return self.items[self.selidx]
|
||||
return self[k]
|
||||
}
|
||||
self.root.push = function(e,u)
|
||||
{
|
||||
self.items.push(e)
|
||||
if(u) self.update()
|
||||
}
|
||||
self.root.unshift = function(e,u)
|
||||
{
|
||||
self.items.unshift(e)
|
||||
if(u) self.update()
|
||||
}
|
||||
self.root.remove = function(e,u)
|
||||
{
|
||||
var i = self.items.indexOf(e)
|
||||
if(i >= 0)
|
||||
{
|
||||
if(self.selidx != -1)
|
||||
{
|
||||
self.items[self.selidx].selected =false
|
||||
self.selidx = -1
|
||||
}
|
||||
self.items.splice(i, 1)
|
||||
if(u)
|
||||
self.update()
|
||||
}
|
||||
}
|
||||
|
||||
self.root.refresh = function()
|
||||
{
|
||||
_refresh()
|
||||
}
|
||||
|
||||
this.on("mount", function(){
|
||||
if(self.root.ready)
|
||||
self.root.ready(self.root)
|
||||
// now refresh the list
|
||||
_refresh()
|
||||
})
|
||||
|
||||
var _refresh = function()
|
||||
{
|
||||
var ctop = 20
|
||||
var cleft = 20
|
||||
var gw = $(self.refs.container).width()
|
||||
var gh = $(self.refs.container).height()
|
||||
$(self.refs.container)
|
||||
.children()
|
||||
.each(function(e)
|
||||
{
|
||||
$(this).unbind("mousedown")
|
||||
_enable_drag($(this))
|
||||
var w = $(this).width()
|
||||
var h = $(this).height()
|
||||
$(this).css("top", ctop + "px").css("left", cleft + "px")
|
||||
if(self.dir == "horizontal")
|
||||
{
|
||||
ctop += h + 20
|
||||
if(ctop > gh)
|
||||
{
|
||||
ctop = 20
|
||||
cleft += w + 20
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cleft += w + 20
|
||||
if(cleft > gw )
|
||||
{
|
||||
cleft = 20
|
||||
ctop += h + 20
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var _enable_drag = function(el)
|
||||
{
|
||||
var globalof = $(self.refs.container).offset()
|
||||
el
|
||||
.css("user-select","none")
|
||||
.css("cursor","default")
|
||||
.css("position",'absolute')
|
||||
.on("mousedown", function(e){
|
||||
e.preventDefault()
|
||||
offset = el.offset()
|
||||
offset.top = e.clientY - offset.top
|
||||
offset.left = e.clientX - offset.left
|
||||
$(window).on("mousemove", function(e){
|
||||
var top,left
|
||||
top = e.clientY - offset.top - globalof.top
|
||||
left = e.clientX - globalof.top - offset.left
|
||||
left = left < 0?0:left
|
||||
top = top < 0?0:top
|
||||
el.css("top", top +"px").css("left",left + "px")
|
||||
})
|
||||
$(window).on("mouseup", function(e){
|
||||
//console.log("unbind mouse up")
|
||||
$(window).unbind("mousemove", null)
|
||||
})
|
||||
})
|
||||
}
|
||||
_autoselect(it,i)
|
||||
{
|
||||
if(!it.selected || it.selected == false) return false
|
||||
var data = {
|
||||
id:self.rid,
|
||||
data:it,
|
||||
idx:i}
|
||||
//if(self.selidx != -1)
|
||||
// self.items[self.selidx].selected =false
|
||||
self.selidx = i
|
||||
|
||||
if(self.onlistselect)
|
||||
self.onlistselect(data)
|
||||
this.root.observable.trigger('listselect',data)
|
||||
return true
|
||||
}
|
||||
_select(event)
|
||||
{
|
||||
if(self.selidx != -1 && self.selidx < self.items.length)
|
||||
self.items[self.selidx].selected =false
|
||||
event.item.item.selected = true
|
||||
//self.update()
|
||||
}
|
||||
|
||||
_dbclick(event)
|
||||
{
|
||||
data = {
|
||||
id:self.rid,
|
||||
data:event.item.item,
|
||||
idx: event.item.i}
|
||||
if(self.onlistdbclick)
|
||||
self.onlistdbclick(data)
|
||||
self.root.observable.trigger('listdbclick', data)
|
||||
}
|
||||
</script>
|
||||
</afx-float-list>
|
@ -35,7 +35,10 @@
|
||||
self.root.get = function(k)
|
||||
{
|
||||
if(k == "selected")
|
||||
return self.items[self.selidx]
|
||||
if(self.selidx != -1)
|
||||
return self.items[self.selidx]
|
||||
else
|
||||
return undefined
|
||||
return self[k]
|
||||
}
|
||||
self.root.push = function(e,u)
|
||||
|
@ -39,12 +39,13 @@ class BasicFileHandler
|
||||
return @ if @isRoot()
|
||||
return (@protocol + ":///" + (@genealogy.slice 0 , @genealogy.length - 1).join "/")
|
||||
|
||||
onready: (f) ->
|
||||
onready: (f, err) ->
|
||||
# read meta data
|
||||
return f() if @ready
|
||||
me = @
|
||||
me.meta (d) ->
|
||||
return _courrier.osfail d.error, (_API.throwe "OS.VFS"), d.error if d.error
|
||||
if d.error
|
||||
return if err then err d else _courrier.osfail d.error, (_API.throwe "OS.VFS"), d.error
|
||||
me.meta = d.result
|
||||
me.ready = true
|
||||
f()
|
||||
|
@ -27,10 +27,11 @@ class PushNotification extends this.OS.GUI.BaseService
|
||||
@nzone = @find "notifyzone"
|
||||
@fzone = @find "feedzone"
|
||||
(@find "btclear").set "onbtclick", (e) -> me.mlist.set "items", []
|
||||
#mlist.set "onlistselect", (e) -> console.log e
|
||||
@subscribe "fail", (e) -> console.log e
|
||||
@subscribe "notification", (o) -> me.pushout 'INFO', o
|
||||
@subscribe "fail", (o) -> me.pushout 'FAIL', o
|
||||
@subscribe "error", (o) -> me.pushout 'ERROR', o
|
||||
@subscribe "info", (o) -> me.pushout 'INFO', o
|
||||
|
||||
@subscribe "loading", (o) ->
|
||||
me.pending.push o.id
|
||||
@ -59,6 +60,8 @@ class PushNotification extends this.OS.GUI.BaseService
|
||||
icon: o.data.icon,
|
||||
iconclass: o.data.iconclass,
|
||||
closable: true }
|
||||
console.log o.data.s
|
||||
console.log o.data.e
|
||||
@mlist.unshift d, true
|
||||
@notifeed d
|
||||
|
||||
|
@ -8,7 +8,7 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
@view = @find "fileview"
|
||||
@navinput = @find "navinput"
|
||||
@navbar = @find "nav-bar"
|
||||
@currdir = undefined
|
||||
@currdir = if @args and @args.length > 0 then @args[0].asFileHandler() else "home:///".asFileHandler()
|
||||
@favo = @find "favouri"
|
||||
@clipboard = undefined
|
||||
|
||||
@ -17,7 +17,9 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
m.show(e)
|
||||
#@on "fileselect", (d) -> console.log d
|
||||
@on "filedbclick", (e) ->
|
||||
#if e.data.type is 'dir' then me.chdir e.data.path, true
|
||||
return unless e.data
|
||||
return if e.data.type is "dir"
|
||||
me._gui.openWith e.data
|
||||
@favo.set "onlistselect", (e) -> me.chdir e.data.path
|
||||
|
||||
($ @find "btback").click () ->
|
||||
@ -38,15 +40,17 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
|
||||
@setting.favorite = [
|
||||
{ text: "Applications", path: 'app:///', iconclass: "fa fa-adn" },
|
||||
{ text: "Home", path: 'home:///', iconclass: "fa fa-home", selected: true },
|
||||
{ text: "Home", path: 'home:///', iconclass: "fa fa-home" },
|
||||
{ text: "OS", path: 'os:///', iconclass: "fa fa-inbox" },
|
||||
{ text: "Desktop", path: 'home:///.desktop', iconclass: "fa fa-desktop" },
|
||||
] if not @setting.favorite
|
||||
@setting.sidebar = true if @setting.sidebar is undefined
|
||||
@setting.nav = true if @setting.nav is undefined
|
||||
@setting.showhidden = false if @setting.showhidden is undefined
|
||||
@favo.set "items", @setting.favorite
|
||||
|
||||
@favo.set "items", $.extend true, {}, @setting.favorite
|
||||
@applySetting()
|
||||
@chdir null
|
||||
|
||||
applySetting: (k) ->
|
||||
# view setting
|
||||
|
@ -9,5 +9,5 @@
|
||||
"version":"0.1a",
|
||||
"category":"System",
|
||||
"iconclass":"fa fa-hdd-o",
|
||||
"mimes":["*"]
|
||||
"mimes":["dir"]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
class NotePad extends this.OS.GUI.BaseApplication
|
||||
constructor: (args) ->
|
||||
constructor: ( args ) ->
|
||||
super "NotePad", args
|
||||
main: () ->
|
||||
me = @
|
||||
@ -9,6 +9,7 @@ class NotePad extends this.OS.GUI.BaseApplication
|
||||
@fileview = @find "fileview"
|
||||
div = @find "datarea"
|
||||
ace.require "ace/ext/language_tools"
|
||||
@currfile = if @args and @args.length > 0 then @args[0].asFileHandler() else undefined
|
||||
@.editor = ace.edit div
|
||||
@.editor.setOptions {
|
||||
enableBasicAutocompletion: true,
|
||||
@ -16,7 +17,7 @@ class NotePad extends this.OS.GUI.BaseApplication
|
||||
enableLiveAutocompletion: true,
|
||||
fontSize: "9pt"
|
||||
}
|
||||
@.editor.completers.push {getCompletions:(editor, session, pos, prefix, callback)->}
|
||||
@.editor.completers.push { getCompletions: ( editor, session, pos, prefix, callback ) -> }
|
||||
@.editor.getSession().setUseWrapMode true
|
||||
|
||||
list = @find "modelist"
|
||||
@ -64,11 +65,20 @@ class NotePad extends this.OS.GUI.BaseApplication
|
||||
|
||||
@location.set "onlistselect", (e) -> me.chdir e.data.path
|
||||
@location.set "items", [
|
||||
{ text: "Home", path: 'home:///', iconclass:"fa fa-home", selected:true},
|
||||
{ text: "OS", path: 'os:///', iconclass:"fa fa-inbox" },
|
||||
{ text: "Home", path: 'home:///', iconclass: "fa fa-home", selected: true },
|
||||
{ text: "OS", path: 'os:///', iconclass: "fa fa-inbox" },
|
||||
{ text: "Desktop", path: 'home:///.desktop', iconclass: "fa fa-desktop" },
|
||||
]
|
||||
|
||||
@open @currfile if @currfile
|
||||
|
||||
open: (file) ->
|
||||
me = @
|
||||
file.read (d) ->
|
||||
return unless d
|
||||
me.scheme.set "apptitle", file.basename
|
||||
me.editor.setValue d, -1
|
||||
|
||||
chdir: (p) ->
|
||||
me = @
|
||||
me._api.handler.scandir p,
|
||||
@ -82,10 +92,10 @@ class NotePad extends this.OS.GUI.BaseApplication
|
||||
|
||||
menu: ()->
|
||||
menu = [{
|
||||
text:"File",
|
||||
child:[
|
||||
{text:"Open", dataid:"#{@name}-Open"},
|
||||
{text:"Close", dataid:"#{@name}-Close"}
|
||||
text: "File",
|
||||
child: [
|
||||
{ text: "Open", dataid: "#{@name}-Open" },
|
||||
{ text: "Close", dataid: "#{@name}-Close" }
|
||||
]
|
||||
}]
|
||||
menu
|
||||
|
@ -9,5 +9,5 @@
|
||||
"version":"0.1a",
|
||||
"category":"System",
|
||||
"iconclass":"fa fa-pencil-square-o",
|
||||
"mimes":["*"]
|
||||
"mimes":[".*"]
|
||||
}
|
@ -64,6 +64,7 @@ class wTerm extends this.OS.GUI.BaseApplication
|
||||
@socket.onmessage = (e) -> me.term.write e.data if me.term and e.data
|
||||
@socket.onclose = () ->
|
||||
me.socket = null
|
||||
me.quit()
|
||||
console.log "socket closed"
|
||||
#el.style.display = "block"
|
||||
cleanup: (e)->
|
||||
|
@ -42,6 +42,48 @@ html,body{
|
||||
cursor: default;
|
||||
padding:0px;
|
||||
}
|
||||
#desktop > div.float_list_item {
|
||||
display:block;
|
||||
background-color:transparent;
|
||||
text-align: center;
|
||||
width: 70px;
|
||||
color: white;
|
||||
padding:3px;
|
||||
}
|
||||
|
||||
#desktop > div.float_list_item_selected {
|
||||
display:block;
|
||||
background-color: #116cd6;
|
||||
color:white;
|
||||
border-radius: 6px;
|
||||
text-align: center;
|
||||
width: 70px;
|
||||
color: white;
|
||||
padding:3px;
|
||||
}
|
||||
|
||||
#desktop > div.float_list_item i.file:before{
|
||||
content: "\f15b\a";
|
||||
font-family: "FontAwesome";
|
||||
font-size: 32px;
|
||||
display: block;
|
||||
color: white;
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
}
|
||||
#desktop > div.float_list_item span{
|
||||
width: 100%;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
#desktop > div.float_list_item i.dir:before{
|
||||
display: block;
|
||||
content: "\f07b\a";
|
||||
font-family: "FontAwesome";
|
||||
font-size: 32px;
|
||||
color: #76D2F9;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
input {
|
||||
outline: none;
|
||||
padding: 2px;
|
||||
|
Loading…
x
Reference in New Issue
Block a user