add services

This commit is contained in:
Xuan Sang LE
2017-08-15 02:56:04 +02:00
parent 2985689217
commit 16074ac3f8
39 changed files with 7912 additions and 188 deletions

View File

@ -0,0 +1,34 @@
coffee_files = main.coffee
jsfiles = xterm.js
cssfiles = xterm.css main.css
copyfiles = scheme.html package.json
BLUE=\033[1;34m
NC=\033[0m
main: title clean js css copy
title:
@echo "$(BLUE)======= Package wTerm =======$(NC)"
- rm -rf build/*
coffee:
- mkdir build
for f in $(coffee_files); do (coffee -cs < $$f >build/"$$f.js");done
for f in build/*.coffee.js; do (cat "$${f}"; echo) >> build/main.js; done
- rm build/*.coffee.js
js: coffee
for f in $(jsfiles); do (cat "$${f}"; echo) >> build/main.js; done
css:
for f in $(cssfiles); do (cat "$${f}"; echo) >> build/main.css; done
copy:
cp -rf $(copyfiles) build/
clean:
- rm -rf build/*

View File

@ -0,0 +1,71 @@
class wTerm extends this.OS.GUI.BaseApplication
constructor: () ->
super "wTerm"
main: () ->
me = @
@scheme.set "apptitle", "Terminal"
@mterm = @find "myterm"
@term = new Terminal { cursorBlink: true }
@term.on "key", (d, e) ->
me.socket.send "i#{d}" if me.socket
@term.on 'title', () -> console.log "title change"
@term.open @mterm
@socket = null
#@on "resize", () -> me.resizeContent()
@on "focus", () -> me.term.focus()
# handle the paste event
area = ($ ".xterm-helper-textarea", @mterm)[0]
area.onpaste = (e) ->
#ifreturn false unless @socket
pastedText = undefined
if window.clipboardData and window.clipboardData.getData #IE
pastedText = window.clipboardData.getData 'Text'
else if e.clipboardData and e.clipboardData.getData
pastedText = e.clipboardData.getData 'text/plain'
return false unless pastedText
# send by chunk, to ease the handle on server side
len = pastedText.length
chunklen = len / 1000 + if (len % 1000 == 0) then 0 else 1
for i in [0..(len - 1)]
end = if (i + 1) * 1000 > len then len else (i + 1) * 1000
me.term.write pastedText.substring i * 1000, end
#self.socket.send("i"+ substr.replace(/\n/g,"\r\n"))
@openSession()
@on "vboxchange", (e) -> me.resizeContent e.w, e.h
resizeContent: (w, h) ->
ex = @term.rowContainer.firstElementChild
oldhtml = ($ ex).html()
($ ex).css "display", "inline"
($ ex).html "W"
ncol = parseInt (w / ($ ex).width())
nrow = parseInt (h / ($ ex).height())
($ ex).css "display", ""
($ ex).html oldhtml
@term.resize ncol, nrow
return if not @socket or (@socket.readyState isnt @socket.OPEN)
#initialGeometry = @.term.proposeGeometry()
#cols = initialGeometry.cols
#rows = initialGeometry.rows
#console.log "send", "s#{ncol}:#{nrow}"
@socket.send "s#{ncol}:#{nrow}"
openSession: () ->
me = @
@term.clear()
@term.focus()
@socket = new WebSocket "ws://" + window.location.host + "/wterm"
@socket.onopen = () ->
#el.style.display = "none"
me.resizeContent (($ me.mterm).width()) , (($ me.mterm).height())
me.term.focus()
@socket.onmessage = (e) -> me.term.write e.data if me.term and e.data
@socket.onclose = () ->
me.socket = null
console.log "socket closed"
#el.style.display = "block"
exit: (e)->
@socket.close() if @socket
this.OS.register "wTerm",wTerm

View File

View File

@ -0,0 +1,12 @@
{
"app":"wTerm",
"name":"Unix terminal like",
"description":"Access Unix terminal from web",
"author":{
"name": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"category":"System",
"iconclass":"fa fa-terminal",
"mimes":["*"]
}

View File

@ -0,0 +1,5 @@
<afx-app-window apptitle="Preview" width="600" height="400">
<afx-vbox data-id = "mybox">
<div data-id="myterm" ></div>
</afx-vbox>
</afx-app-window>

2261
src/packages/wTerm/xterm.css Executable file

File diff suppressed because it is too large Load Diff

5132
src/packages/wTerm/xterm.js Executable file

File diff suppressed because it is too large Load Diff