mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-27 03:09:45 +02:00
add darkmode themes, clean up
This commit is contained in:
@ -1,11 +0,0 @@
|
||||
coffee_files = extensions/extensions.coffee extensions/RemoteRunExtension.coffee main.coffee
|
||||
|
||||
jsfiles =
|
||||
|
||||
cssfiles = main.css
|
||||
|
||||
copyfiles = scheme.html package.json
|
||||
|
||||
|
||||
PKG_NAME=NotePad
|
||||
include ../pkg.mk
|
@ -1,68 +0,0 @@
|
||||
class RemoteRunExtension extends BaseExtension
|
||||
constructor: () ->
|
||||
super "RemoteRunExtension"
|
||||
|
||||
init: () ->
|
||||
@_gui.htmlToScheme RemoteRunExtension.scheme, @, @host
|
||||
|
||||
main: () ->
|
||||
me = @
|
||||
@output = @find "output"
|
||||
(@find "log-clear").set "onbtclick", (e) ->
|
||||
me.log "clean"
|
||||
(@find "restart").set "onbtclick", (e) ->
|
||||
me.run()
|
||||
@socket = null
|
||||
# Now run the file
|
||||
@run()
|
||||
|
||||
log: (t, m) ->
|
||||
return $(@output).empty() if t is "clean"
|
||||
p = ($ "<p>").attr("class", t.toLowerCase())[0]
|
||||
$(p).html "#{t}: #{m.__()}"
|
||||
($ @output).append p
|
||||
($ @output).scrollTop @output.scrollHeight
|
||||
|
||||
run: () ->
|
||||
me = @
|
||||
return @log "ERROR", __("No target file found") unless @data
|
||||
@gateway = @gw()
|
||||
return @log "ERROR", __("No backend found for file: {0}", @data.path) unless @gateway
|
||||
$((@find "stat")).html(@data.path)
|
||||
@socket.close() if @socket
|
||||
proto = if window.location.protocol is "https:" then "wss://" else "ws://"
|
||||
@socket = new WebSocket proto + @_api.HOST + @gateway
|
||||
@socket.onopen = () ->
|
||||
#send data to server
|
||||
me.socket.send( JSON.stringify {path:me.data.path} )
|
||||
|
||||
@socket.onmessage = (e) -> me.log "INFO", e.data if e.data
|
||||
@socket.onclose = () ->
|
||||
me.socket = null
|
||||
console.log "socket closed"
|
||||
|
||||
gw: () ->
|
||||
return unless @data
|
||||
for k,v of RemoteRunExtension.backends
|
||||
if @data.info.mime.match (new RegExp k, "g") then return v
|
||||
return null
|
||||
|
||||
cleanup: (e)->
|
||||
@socket.close() if @socket
|
||||
|
||||
RemoteRunExtension.backends = {
|
||||
"text/lua": "/system/apigateway?ws=1"
|
||||
}
|
||||
|
||||
RemoteRunExtension.scheme = """
|
||||
<afx-app-window apptitle="RemoteRun Ouput" width="300" height="450" data-id="win-remote-run">
|
||||
<afx-vbox >
|
||||
<afx-hbox data-height="20" data-id="bottom-vbox">
|
||||
<afx-button data-id = "restart" data-width="25" iconclass="fa fa-repeat"></afx-button>
|
||||
<afx-button data-id = "log-clear" data-width="25" iconclass="fa fa-trash"></afx-button>
|
||||
<div data-id="stat"></div>
|
||||
</afx-hbox>
|
||||
<div data-id="output"></div>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
||||
"""
|
@ -1,4 +0,0 @@
|
||||
class BaseExtension extends this.OS.GUI.BaseDialog
|
||||
constructor: (name) ->
|
||||
super name
|
||||
|
@ -1,331 +0,0 @@
|
||||
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
|
||||
|
||||
# AnTOS Web desktop is is licensed under the GNU General Public
|
||||
# License v3.0, see the LICENCE file for more information
|
||||
|
||||
# This program is free software: you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of
|
||||
# the License, or (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
#along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
class NotePad extends this.OS.GUI.BaseApplication
|
||||
constructor: ( args ) ->
|
||||
super "NotePad", args
|
||||
main: () ->
|
||||
me = @
|
||||
@scheme.set "apptitle", "NotePad"
|
||||
@sidebar = @find "sidebar"
|
||||
@location = @find "location"
|
||||
@fileview = @find "fileview"
|
||||
div = @find "datarea"
|
||||
ace.require "ace/ext/language_tools"
|
||||
@currfile = if @args and @args.length > 0 then @args[0].asFileHandler() else "Untitled".asFileHandler()
|
||||
@.editor = ace.edit div
|
||||
@.editor.setOptions {
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: true,
|
||||
fontSize: "9pt"
|
||||
}
|
||||
@.editor.completers.push { getCompletions: ( editor, session, pos, prefix, callback ) -> }
|
||||
@.editor.getSession().setUseWrapMode true
|
||||
|
||||
@fileview.contextmenuHandler = (e, m) ->
|
||||
m.set "items", me.contextMenu()
|
||||
m.set "onmenuselect", (evt) ->
|
||||
me.contextAction evt
|
||||
m.show e
|
||||
|
||||
@mlist = @find "modelist"
|
||||
@modes = ace.require "ace/ext/modelist"
|
||||
ldata = []
|
||||
f = (m, i) ->
|
||||
ldata.push {
|
||||
text: m.name,
|
||||
mode: m.mode,
|
||||
selected: if m.mode is 'ace/mode/text' then true else false
|
||||
}
|
||||
m.idx = i
|
||||
f(m, i) for m, i in @modes.modes
|
||||
@mlist.set "items", ldata
|
||||
@mlist.set "onlistselect", (e) ->
|
||||
me.editor.session.setMode e.data.mode
|
||||
|
||||
themelist = @find "themelist"
|
||||
themes = ace.require "ace/ext/themelist"
|
||||
ldata = []
|
||||
ldata.push {
|
||||
text: m.caption,
|
||||
mode: m.theme,
|
||||
selected: if m.theme is "ace/theme/monokai" then true else false
|
||||
} for k, m of themes.themesByName
|
||||
themelist.set "onlistselect", (e) ->
|
||||
me.editor.setTheme e.data.mode
|
||||
themelist.set "items", ldata
|
||||
|
||||
stat = @find "editorstat"
|
||||
#status
|
||||
stup = (e) ->
|
||||
c = me.editor.session.selection.getCursor()
|
||||
l = me.editor.session.getLength()
|
||||
stat.set "text", __("Row {0}, col {1}, lines: {2}", c.row, c.column, l)
|
||||
stup(0)
|
||||
@.editor.getSession().selection.on "changeCursor", (e) -> stup(e)
|
||||
@editormux = false
|
||||
@editor.on "input", () ->
|
||||
if me.editormux
|
||||
me.editormux = false
|
||||
return false
|
||||
if not me.currfile.dirty
|
||||
me.currfile.dirty = true
|
||||
me.currfile.text += "*"
|
||||
me.tabarea.update()
|
||||
|
||||
@on "resize", () -> me.editor.resize()
|
||||
@on "focus", () -> me.editor.focus()
|
||||
|
||||
@fileview.set "chdir", (d) -> me.chdir d
|
||||
@fileview.set "fetch", (e, f) ->
|
||||
return unless e.child
|
||||
return if e.child.filename is "[..]"
|
||||
e.child.path.asFileHandler().read (d) ->
|
||||
return me.error __("Resource not found {0}", e.child.path) if d.error
|
||||
f d.result
|
||||
@fileview.set "onfileopen", (e) ->
|
||||
return if e.type is "dir"
|
||||
me.open e.path.asFileHandler()
|
||||
@subscribe "VFS", (d) ->
|
||||
p = (me.fileview.get "path").asFileHandler()
|
||||
me.chdir p.path if d.data.file.hash() is p.hash() or d.data.file.parent().hash() is p.hash()
|
||||
@location.set "onlistselect", (e) ->
|
||||
me.chdir e.data.path
|
||||
@location.set "items", ( i for i in @systemsetting.VFS.mountpoints when i.type isnt "app" )
|
||||
@location.set "selected", 0 unless @location.get "selected"
|
||||
@tabarea = @find "tabarea"
|
||||
@tabarea.set "ontabselect", (e) ->
|
||||
me.selecteTab e.idx
|
||||
@tabarea.set "onitemclose", (e) ->
|
||||
it = e.item.item
|
||||
return false unless it
|
||||
return me.closeTab it unless it.dirty
|
||||
me.openDialog "YesNoDialog", (d) ->
|
||||
return me.closeTab it if d
|
||||
me.editor.focus()
|
||||
, __("Close tab"), { text: __("Close without saving ?") }
|
||||
return false
|
||||
#@tabarea.set "closable", true
|
||||
@bindKey "ALT-N", () -> me.actionFile "#{me.name}-New"
|
||||
@bindKey "ALT-O", () -> me.actionFile "#{me.name}-Open"
|
||||
@bindKey "CTRL-S", () -> me.actionFile "#{me.name}-Save"
|
||||
@bindKey "ALT-W", () -> me.actionFile "#{me.name}-Saveas"
|
||||
@bindKey "ALT-R", () -> me.actionFile "#{me.name}-Run"
|
||||
@open @currfile
|
||||
|
||||
open: (file) ->
|
||||
#find tab
|
||||
i = @findTabByFile file
|
||||
return @tabarea.set "selected", i if i isnt -1
|
||||
return @newtab file if file.path.toString() is "Untitled"
|
||||
me = @
|
||||
file.read (d) ->
|
||||
file.cache = d or ""
|
||||
me.newtab file
|
||||
|
||||
contextMenu: () ->
|
||||
[
|
||||
{ text: __("New file"), dataid: "#{@name}-mkf" },
|
||||
{ text: __("New folder"), dataid: "#{@name}-mkd" },
|
||||
{ text: __("Delete"), dataid: "#{@name}-rm" }
|
||||
{ text: __("Refresh"), dataid: "#{@name}-refresh" }
|
||||
]
|
||||
|
||||
contextAction: (e) ->
|
||||
me = @
|
||||
file = @fileview.get "selectedFile"
|
||||
dir = if file then file.path.asFileHandler() else (@fileview.get "path").asFileHandler()
|
||||
console.log dir
|
||||
dir = dir.parent().asFileHandler() if file and file.type isnt "dir"
|
||||
switch e.item.data.dataid
|
||||
|
||||
when "#{@name}-mkd"
|
||||
@openDialog "PromptDialog",
|
||||
(d) ->
|
||||
dir.mk d, (r) ->
|
||||
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
|
||||
, "__(New folder)"
|
||||
|
||||
when "#{@name}-mkf"
|
||||
@openDialog "PromptDialog",
|
||||
(d) ->
|
||||
fp = "#{dir.path}/#{d}".asFileHandler()
|
||||
fp.write "", (r) ->
|
||||
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
|
||||
, "__(New file)"
|
||||
when "#{@name}-rm"
|
||||
return unless file
|
||||
@openDialog "YesNoDialog",
|
||||
(d) ->
|
||||
return unless d
|
||||
file.path.asFileHandler()
|
||||
.remove (r) ->
|
||||
me.error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
|
||||
, "__(Delete)" ,
|
||||
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete: {0}?", file.filename) }
|
||||
when "#{@name}-refresh"
|
||||
@.chdir ( @fileview.get "path" )
|
||||
|
||||
save: (file) ->
|
||||
me = @
|
||||
file.write "text/plain", (d) ->
|
||||
return me.error __("Error saving file {0}", file.basename) if d.error
|
||||
file.dirty = false
|
||||
file.text = file.basename
|
||||
me.tabarea.update()
|
||||
|
||||
findTabByFile: (file) ->
|
||||
lst = @tabarea.get "items"
|
||||
its = ( i for d, i in lst when d.hash() is file.hash() )
|
||||
return -1 if its.length is 0
|
||||
return its[0]
|
||||
|
||||
closeTab: (it) ->
|
||||
@tabarea.remove it, false
|
||||
cnt = @tabarea.get "count"
|
||||
if cnt is 0
|
||||
@open "Untitled".asFileHandler()
|
||||
return false
|
||||
@tabarea.set "selected", cnt - 1
|
||||
return false
|
||||
|
||||
newtab: (file) ->
|
||||
file.text = if file.basename then file.basename else file.path
|
||||
file.cache = "" unless file.cache
|
||||
file.um = new ace.UndoManager()
|
||||
@currfile.selected = false
|
||||
file.selected = true
|
||||
#console.log cnt
|
||||
@tabarea.push file, true
|
||||
#@currfile = @file
|
||||
#TODO: fix problem : @tabarea.set "selected", cnt
|
||||
|
||||
selecteTab: (i) ->
|
||||
#return if i is @tabarea.get "selidx"
|
||||
file = (@tabarea.get "items")[i]
|
||||
return unless file
|
||||
@fileview.set "preventUpdate", true
|
||||
@scheme.set "apptitle", file.text.toString()
|
||||
#return if file is @currfile
|
||||
if @currfile isnt file
|
||||
@currfile.cache = @editor.getValue()
|
||||
@currfile.cursor = @editor.selection.getCursor()
|
||||
@currfile = file
|
||||
|
||||
m = "ace/mode/text"
|
||||
m = (@modes.getModeForPath file.path) if file.path.toString() isnt "Untitled"
|
||||
@mlist.set "selected", m.idx
|
||||
|
||||
@editormux = true
|
||||
@editor.setValue file.cache, -1
|
||||
@editor.session.setMode m.mode
|
||||
@editor.session.setUndoManager file.um
|
||||
if file.cursor
|
||||
@editor.renderer.scrollCursorIntoView { row: file.cursor.row, column: file.cursor.column }, 0.5
|
||||
@editor.selection.moveTo file.cursor.row, file.cursor.column
|
||||
@editor.focus()
|
||||
|
||||
chdir: (pth) ->
|
||||
#console.log "called", @_api.throwe("FCK")
|
||||
return unless pth
|
||||
me = @
|
||||
dir = pth.asFileHandler()
|
||||
dir.read (d) ->
|
||||
if(d.error)
|
||||
return me.error __("Resource not found {0}", p)
|
||||
if not dir.isRoot()
|
||||
p = dir.parent().asFileHandler()
|
||||
p.filename = "[..]"
|
||||
p.type = "dir"
|
||||
#p.size = 0
|
||||
d.result.unshift p
|
||||
($ me.navinput).val dir.path
|
||||
me.fileview.set "path", pth
|
||||
me.fileview.set "data", d.result
|
||||
|
||||
menu: () ->
|
||||
me = @
|
||||
menu = [{
|
||||
text: "__(File)",
|
||||
child: [
|
||||
{ text: "__(New)", dataid: "#{@name}-New", shortcut: "A-N" },
|
||||
{ text: "__(Open)", dataid: "#{@name}-Open", shortcut: "A-O" },
|
||||
{ text: "__(Save)", dataid: "#{@name}-Save", shortcut: "C-S" },
|
||||
{ text: "__(Save as)", dataid: "#{@name}-Saveas", shortcut: "A-W" },
|
||||
{ text: "__(Run)", dataid: "#{@name}-Run", shortcut: "A-R" }
|
||||
],
|
||||
onmenuselect: (e) -> me.actionFile e.item.data.dataid
|
||||
}]
|
||||
menu
|
||||
|
||||
actionFile: (e) ->
|
||||
me = @
|
||||
saveas = () ->
|
||||
me.openDialog "FileDiaLog", (d, n) ->
|
||||
file = "#{d}/#{n}".asFileHandler()
|
||||
file.cache = me.currfile.cache
|
||||
file.dirty = me.currfile.dirty
|
||||
file.um = me.currfile.um
|
||||
file.cursor = me.currfile.cursor
|
||||
file.selected = me.currfile.selected
|
||||
file.text = me.currfile.text
|
||||
me.tabarea.replaceItem me.currfile, file, false
|
||||
me.currfile = file
|
||||
me.save me.currfile
|
||||
, "__(Save as)", { file: me.currfile }
|
||||
switch e
|
||||
when "#{@name}-Open"
|
||||
@openDialog "FileDiaLog", ( d, f ) ->
|
||||
me.open "#{d}/#{f}".asFileHandler()
|
||||
, "__(Open file)"
|
||||
when "#{@name}-Save"
|
||||
@currfile.cache = @editor.getValue()
|
||||
return @save @currfile if @currfile.basename
|
||||
saveas()
|
||||
when "#{@name}-Saveas"
|
||||
@currfile.cache = @editor.getValue()
|
||||
saveas()
|
||||
when "#{@name}-New"
|
||||
@open "Untitled".asFileHandler()
|
||||
when "#{@name}-Run"
|
||||
if @currfile.dirty
|
||||
return @notify __("Please save the file before running it")
|
||||
else
|
||||
if @dialog then @dialog.quit()
|
||||
@openDialog new RemoteRunExtension(), null, null, @currfile
|
||||
cleanup: (evt) ->
|
||||
dirties = ( v for v in @tabarea.get "items" when v.dirty )
|
||||
return if dirties.length is 0
|
||||
me = @
|
||||
evt.preventDefault()
|
||||
@.openDialog "YesNoDialog", (d) ->
|
||||
if d
|
||||
v.dirty = false for v in dirties
|
||||
me.quit()
|
||||
, "__(Quit)", { text: __("Ignore all {0} unsaved files ?", dirties.length) }
|
||||
|
||||
NotePad.singleton = false
|
||||
NotePad.dependencies = [
|
||||
"ace/ace",
|
||||
"ace/ext-language_tools",
|
||||
"ace/ext-modelist",
|
||||
"ace/ext-themelist"
|
||||
]
|
||||
NotePad.extensions = {}
|
||||
this.OS.register "NotePad", NotePad
|
@ -1,79 +0,0 @@
|
||||
afx-app-window[data-id="notepad"] afx-list-view {
|
||||
margin: 2px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="notepad"] afx-list-view div.list-container{
|
||||
z-index: 10;
|
||||
}
|
||||
afx-app-window[data-id="notepad"] afx-resizer{
|
||||
z-index: 11;
|
||||
background-color: transparent;
|
||||
border-right: 1px solid #a6a6a6;
|
||||
}
|
||||
afx-app-window[data-id="notepad"] afx-label[data-id="editorstat"]{
|
||||
padding:5px;
|
||||
display: inline-block;
|
||||
}
|
||||
afx-app-window[data-id="notepad"] afx-vbox[data-id="bottom-vbox"]{
|
||||
background-color: #dfdfdf;
|
||||
}
|
||||
afx-app-window[data-id="notepad"] .afx-window-content {
|
||||
background-color: #f6F6F6;
|
||||
}
|
||||
|
||||
afx-tab-bar[data-id="tabarea"] afx-list-view > div.list-container > ul > li {
|
||||
background-color: #dfdfdf;
|
||||
color:#272822;
|
||||
border: 0;
|
||||
border-top: 1px solid #a6a6a6;
|
||||
border-right: 1px solid #a6a6a6;
|
||||
border-radius: 0;
|
||||
}
|
||||
afx-tab-bar[data-id="tabarea"] afx-list-view{
|
||||
padding:0;
|
||||
margin: 0;
|
||||
border-left: 0;
|
||||
border-bottom: 1px solid #a6a6a6;
|
||||
}
|
||||
/*afx-tab-bar[data-id="tabarea"] afx-list-view i.closable:before{
|
||||
color: white;
|
||||
}*/
|
||||
afx-tab-bar[data-id="tabarea"] afx-list-view > div.list-container > ul > li.selected {
|
||||
background-color: #f6F6F6;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
afx-app-window[data-id="win-remote-run"] div[data-id="output"] p{
|
||||
margin:0;
|
||||
padding:0;
|
||||
font-family: "HermitLight";
|
||||
text-align: left;
|
||||
}
|
||||
afx-app-window[data-id="win-remote-run"] div[data-id="output"]{
|
||||
background-color: #2f3129;
|
||||
padding: 10px;
|
||||
color:white;
|
||||
overflow: auto;
|
||||
}
|
||||
afx-app-window[data-id="win-remote-run"] div[data-id="stat"]{
|
||||
background-color: #2f3129;
|
||||
padding: 5px;
|
||||
color:white;
|
||||
font-weight: bold;
|
||||
font-size: 10px;
|
||||
}
|
||||
afx-app-window[data-id="win-remote-run"] afx-resizer{
|
||||
border-top: 1px solid #a6a6a6;
|
||||
background-color: #2f3129;
|
||||
border-right: 0;
|
||||
}
|
||||
afx-app-window[data-id="win-remote-run"] afx-hbox[data-id="bottom-vbox"] {
|
||||
background-color:#2f3129;
|
||||
}
|
||||
afx-app-window[data-id="win-remote-run"] afx-hbox[data-id="bottom-vbox"] afx-button button{
|
||||
background-color:#2f3129;
|
||||
color:white;
|
||||
border:0;
|
||||
border-radius: 0;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"app":"NotePad",
|
||||
"name":"NotePad editor",
|
||||
"description":"Basic application for text editing",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.0.2-a",
|
||||
"category":"System",
|
||||
"iconclass":"fa fa-pencil-square-o",
|
||||
"mimes":[
|
||||
"text/.*",
|
||||
"[^/]*/json.*",
|
||||
"[^/]*/.*ml",
|
||||
"[^/]*/javascript"
|
||||
]
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<afx-app-window apptitle="" width="600" height="400" data-id="notepad">
|
||||
<afx-hbox>
|
||||
<afx-vbox data-width = "155" data-id = "sidebar" min-width="155">
|
||||
<afx-list-view data-id = "location" dropdown = "true" data-height= "30" width = "150"></afx-list-view>
|
||||
<afx-file-view data-id = "fileview" view='tree' status = false></afx-file-view>
|
||||
</afx-vbox>
|
||||
<afx-resizer data-width = "3" ></afx-resizer>
|
||||
<afx-vbox>
|
||||
<afx-tab-bar data-id="tabarea" data-height="23" closable = true></afx-tab-bar>
|
||||
<div data-id="datarea"></div>
|
||||
<afx-hbox data-height="30" data-id="bottom-vbox">
|
||||
<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-hbox>
|
||||
</afx-app-window>
|
Reference in New Issue
Block a user