Compare commits
No commits in common. "18b32f088e0e8cd1c5d8770ff81e2e108abe68ac" and "6b883721bd54c070313f08edd8be652ef139cfdc" have entirely different histories.
18b32f088e
...
6b883721bd
21 changed files with 93 additions and 1438 deletions
|
|
@ -23,7 +23,6 @@ test -f ~/.profile.js && chmod +x ~/.profile.js && ~/.profile.js | grep -v undef
|
||||||
|
|
||||||
## forward not-found commands to javascript (via jsh)
|
## forward not-found commands to javascript (via jsh)
|
||||||
command_not_found_handle(){
|
command_not_found_handle(){
|
||||||
set +e
|
|
||||||
echo "[!] '$1' not found, did you mean $1(...) (javascript?)"
|
echo "[!] '$1' not found, did you mean $1(...) (javascript?)"
|
||||||
test -n "$ONBOARDING" && echo "[i] type 'help' for handy commands"
|
test -n "$ONBOARDING" && echo "[i] type 'help' for handy commands"
|
||||||
test -n "$ONBOARDING" || help_tips
|
test -n "$ONBOARDING" || help_tips
|
||||||
|
|
@ -66,21 +65,15 @@ which screen &> /dev/null && {
|
||||||
test -n "$STY" || {
|
test -n "$STY" || {
|
||||||
resize # call twice
|
resize # call twice
|
||||||
resize # otherwise COLUMNS/ROWS is 0
|
resize # otherwise COLUMNS/ROWS is 0
|
||||||
# resize # call twice
|
# add URL-hash as extra screen session
|
||||||
# resize # otherwise COLUMNS/ROWS is 0
|
test -z "$HASH" || {
|
||||||
# # add URL-hash as extra screen session
|
grep 'screen -t #' /root/.screenrc || {
|
||||||
# test -z "$HASH" || {
|
echo "screen -t xrsh+URL 3 /bin/sh -c '${HASH}; sh'" | sed "s/'#/'/g" >> /root/.screenrc
|
||||||
# grep 'screen -t #' /root/.screenrc || {
|
}
|
||||||
# echo "screen -t xrsh+URL 3 /bin/sh -c 'source /etc/profile.sh; ${HASH}; sh'" | sed "s/'#/'/g" >> /root/.screenrc
|
}
|
||||||
# }
|
screen -Aa -R -T screen-256color -c /root/.screenrc
|
||||||
# }
|
|
||||||
# execute URL hash or GNU screen
|
|
||||||
test -n "$HASH" && hook URI/fragment "${HASH:1}"
|
|
||||||
test -z "$HASH" && screen -Aa -R -T screen-256color -c /root/.screenrc
|
|
||||||
}
|
}
|
||||||
test -n "$STY" && {
|
test -n "$STY" && {
|
||||||
resize # call twice
|
|
||||||
resize # otherwise COLUMNS/ROWS is 0
|
|
||||||
test -f /root/motd && cat /root/motd || cat /etc/motd;
|
test -f /root/motd && cat /root/motd || cat /etc/motd;
|
||||||
say "welcome to eex r, shell. For an optimal user experience, connect a Bluetooth keyboard." &
|
say "welcome to eex r, shell. For an optimal user experience, connect a Bluetooth keyboard." &
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ hook(){
|
||||||
logger " |+ hook $hook $*"
|
logger " |+ hook $hook $*"
|
||||||
{ $hook "$@" || true; } | awk '{ gsub(/\/root\/\//,"",$1); $1 = sprintf("%-40s", $1)} 1'
|
{ $hook "$@" || true; } | awk '{ gsub(/\/root\/\//,"",$1); $1 = sprintf("%-40s", $1)} 1'
|
||||||
done
|
done
|
||||||
} | tee -a ~/hook.d/log.txt
|
} &> ~/hook.d/log.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
alert(){
|
alert(){
|
||||||
|
|
@ -46,7 +46,6 @@ console(){
|
||||||
#
|
#
|
||||||
# info: adds javascript/css url/script to DOM
|
# info: adds javascript/css url/script to DOM
|
||||||
require(){
|
require(){
|
||||||
test -n "$1" || { echo "usage: require <url>"; exit 0; }
|
|
||||||
file=$(basename "$1")
|
file=$(basename "$1")
|
||||||
ext="${file/*\./}"
|
ext="${file/*\./}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ test -d /dev/browser || {
|
||||||
setup_mounts(){
|
setup_mounts(){
|
||||||
mkdir /mnt/helloworld /mnt/THREE
|
mkdir /mnt/helloworld /mnt/THREE
|
||||||
fusescript /root/fs/helloworld /mnt/helloworld
|
fusescript /root/fs/helloworld /mnt/helloworld
|
||||||
fusescript /root/fs/THREE /mnt/THREE
|
fusescript /root/fs/THREE.js /mnt/THREE
|
||||||
}
|
}
|
||||||
|
|
||||||
modprobe fuse # load fuse
|
modprobe fuse # load fuse
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,5 @@ exitVR
|
||||||
exitAR
|
exitAR
|
||||||
tail -n1 -f /dev/browser/console /var/log/messages
|
tail -n1 -f /dev/browser/console /var/log/messages
|
||||||
require https://snips.sh/f/VBz-iWm8so?r=1
|
require https://snips.sh/f/VBz-iWm8so?r=1
|
||||||
a-gltf-model https://xrfragment.org/example/assets/index.glb
|
require https://xrfragment.org/example/assets/index.glb
|
||||||
a-gltf-model https://coderofsalvation.github.io/xrsh-media/assets/background.glb
|
require https://coderofsalvation.github.io/xrsh-media/assets/background.glb
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,6 @@ cd(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# get latest xrfragments to support interactive models
|
|
||||||
require https://xrfragment.org/dist/xrfragment.aframe.js
|
|
||||||
|
|
||||||
# start index.js if /dev/browser/js filesize is not great than 0
|
# start index.js if /dev/browser/js filesize is not great than 0
|
||||||
if [ ! -s /dev/browser/js ]; then
|
if [ ! -s /dev/browser/js ]; then
|
||||||
chmod +x /mnt/root/index.js && /mnt/root/index.js | grep -v undefined
|
chmod +x /mnt/root/index.js && /mnt/root/index.js | grep -v undefined
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
test -n "$1" || { echo "usage: a-gltf-model <gltf-file>"; exit; }
|
test -n "$1" || { echo "usage: a-gltf-model <gltf-file>"; exit; }
|
||||||
|
|
||||||
file="$1"
|
file="$(readlink -f "$1")"
|
||||||
echo "$file" | grep -q http || {
|
file="${file#/}" # strip leading slash if present
|
||||||
file="$(readlink -f "$1")"
|
|
||||||
file="${file#/}" # strip leading slash if present
|
|
||||||
file="file://xrsh/$file"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "<a-gltf-model src='$file'></a-gltf-model>" >> /root/index.html
|
echo "<a-gltf-model src='file://xrsh/$file'></a-gltf-model>" >> /root/index.html
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
test -n "$1" || { echo "usage: teleport <http://...foo.glb>"; exit 0; }
|
|
||||||
echo "" > ~/index.html # empty scene
|
|
||||||
a-gltf-model $*
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# virtual file interface for THREE
|
|
||||||
|
|
||||||
STATE=/run/THREE
|
|
||||||
LOG=~/.fuse.log
|
|
||||||
|
|
||||||
update(){
|
|
||||||
js '
|
|
||||||
|
|
||||||
let fuse_dir = () => '16877 2 0 0 4096 8'
|
|
||||||
let fuse_file = (size) => `33188 1 0 0 ${size||1} 1`
|
|
||||||
|
|
||||||
function traverseScene(object, path = '/', result = '') {
|
|
||||||
const objectName = object.name? object.name : object.id;
|
|
||||||
result += `${path}${objectName} ${fuse_dir()}\n`;
|
|
||||||
result += `${path}${objectName}/position ${fuse_dir()}\n`;
|
|
||||||
result += `${path}${objectName}/position/x ${fuse_file()}\n`;
|
|
||||||
result += `${path}${objectName}/position/y ${fuse_file()}\n`;
|
|
||||||
result += `${path}${objectName}/position/z ${fuse_file()}\n`;
|
|
||||||
result += `${path}${objectName}/rotation ${fuse_dir()}\n`;
|
|
||||||
result += `${path}${objectName}/rotation/x ${fuse_file()}\n`;
|
|
||||||
result += `${path}${objectName}/rotation/y ${fuse_file()}\n`;
|
|
||||||
result += `${path}${objectName}/rotation/z ${fuse_file()}\n`;
|
|
||||||
if( object.userData ){
|
|
||||||
result += `${path}${objectName}/userData 1 1 1 1\n`;
|
|
||||||
for( let k in object.userData )
|
|
||||||
result += `${path}${objectName}/userData/${k} 1 1 1 1\n`;
|
|
||||||
}
|
|
||||||
object.children.forEach(child => {
|
|
||||||
result = traverseScene(child, `${path}${objectName}/`, result);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return traverseScene( document.querySelector('a-scene').object3D );
|
|
||||||
' > $STATE
|
|
||||||
}
|
|
||||||
|
|
||||||
readdir(){ # print first column [filename] from header
|
|
||||||
test -f $STATE || update
|
|
||||||
awk '/^#\'$1'/ {
|
|
||||||
gsub("^#'$1'[/]?","",$1); # strip dirname
|
|
||||||
gsub("\\/.*","",$1); # strip subdirs/files
|
|
||||||
if( $1 ) print $1
|
|
||||||
}' $STATE | uniq
|
|
||||||
}
|
|
||||||
|
|
||||||
getattr(){ # print column 2 till 7 from header
|
|
||||||
awk '$1 == "#'$1'" { print $2" "$3" "$4" "$5" "$6" "$7 }' $STATE
|
|
||||||
grep -qE '#$1' $0 || return 2 # FUSE expects -NOENT if file does not exist
|
|
||||||
}
|
|
||||||
|
|
||||||
read(){ # print everything (data) after 7th column
|
|
||||||
awk '$1 == "#'$1'" { $1=$2=$3=$4=$5=$6=$7=""; sub(/^ +/, ""); print $0 }' $0
|
|
||||||
}
|
|
||||||
|
|
||||||
getxattr(){ # print xattr value from commentheader
|
|
||||||
awk '$1 == "#xattr:'$1'" && $2 == "'$2'" { print $3 }' $STATE
|
|
||||||
}
|
|
||||||
|
|
||||||
setxattr(){ # save xattr value from commentheader
|
|
||||||
file=$1 ; key=$2 ; shift; shift
|
|
||||||
sed -i "s/^#xattr:\\$key .*/#xattr:\\$key $*" $STATE || echo "#xattr:$file $key $*" >> $0
|
|
||||||
}
|
|
||||||
|
|
||||||
listxattr(){ # list xattr keys
|
|
||||||
awk '$1 == "#xattr:'$1'" { printf("%s\0",$2) }' $STATE
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "> $0 $*" >> $LOG
|
|
||||||
"$@" | tee -a $LOG
|
|
||||||
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
#!/bin/js
|
#!/bin/js
|
||||||
|
|
||||||
// Function to handle getattr command
|
// Function to handle getattr command
|
||||||
function getattr(path,opts){
|
function getattr(path,obj) {
|
||||||
let size = 1
|
let size = 1
|
||||||
if (path === '/' || opts.obj ){
|
if (path === '/' || path.match(/\/[0-9]+$/) ) {
|
||||||
return "16877 2 0 0 4096 8\n"
|
return "16877 2 1000 1000 4096 8\n"
|
||||||
} else {
|
} else {
|
||||||
return `33188 1 0 0 ${size} 1\n`
|
return `33188 1 1000 1000 ${size} 1\n`
|
||||||
}
|
}
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPath(str){
|
function getPath(str){
|
||||||
|
|
@ -17,23 +18,22 @@ function getPath(str){
|
||||||
const parent = path.pop()
|
const parent = path.pop()
|
||||||
let obj = name == ""
|
let obj = name == ""
|
||||||
? scene
|
? scene
|
||||||
: scene.getObjectByName( name ) ||
|
: scene.getObjectById( parseInt(name.substr(1)) )
|
||||||
scene.getObjectById( parseInt(name.substr(1)) )
|
const propvalue = ""
|
||||||
console.dir({parent,name,obj})
|
if( obj && obj[ name ] ) propvalue = obj[name]
|
||||||
|
return {obj,propname:name,propvalue}
|
||||||
return {obj,propname:name}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main function to handle commands
|
// Main function to handle commands
|
||||||
function main(args) {
|
function main(args) {
|
||||||
console.log( 'fs/THREE '+args.join(' ') )
|
console.log( 'fs/THREE '+args.join(' ') )
|
||||||
let children = ''
|
let children = ''
|
||||||
let props = ['uuid','position','rotation']
|
let props = ['name','uuid','position','rotation']
|
||||||
|
|
||||||
|
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case 'readdir':{
|
case 'readdir':{
|
||||||
const {obj} = getPath( args[1] )
|
const {obj,propvalue,propname} = getPath( args[1] )
|
||||||
if( obj && obj.children ){
|
if( obj && obj.children ){
|
||||||
children = obj.children.map( (n) => n.name || n.id )
|
children = obj.children.map( (n) => n.name || n.id )
|
||||||
.join("\n")
|
.join("\n")
|
||||||
|
|
@ -43,14 +43,14 @@ function main(args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'getattr':{
|
case 'getattr':{
|
||||||
const opts = getPath( args[1] )
|
const {obj,propvalue,propname} = getPath( args[1] )
|
||||||
return getattr(args[1],{...opts, args});
|
return getattr(args[1],{args,obj,propvalue,propname});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'read':{
|
case 'read':{
|
||||||
const {obj,propname} = getPath( args[1] )
|
const {propvalue,propname} = getPath( args[1] )
|
||||||
return obj[propname];
|
return propvalue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,4 +62,3 @@ function main(args) {
|
||||||
// Run the main function
|
// Run the main function
|
||||||
return main(args.slice(1));
|
return main(args.slice(1));
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ echo "$0 $*" >> $LOG
|
||||||
# format: mode nlink uid gid size block
|
# format: mode nlink uid gid size block
|
||||||
case "$2" in
|
case "$2" in
|
||||||
/)
|
/)
|
||||||
echo "16877 2 0 0 4096 8" && exit 0 # dir (mode 0755)
|
echo "16877 2 1000 1000 4096 8" && exit 0 # dir (mode 0755)
|
||||||
;;
|
;;
|
||||||
/file1)
|
/file1)
|
||||||
echo "33188 1 0 0 ${#file1} 1" && exit 0 # file (mode 0644, size 6)
|
echo "33188 1 1000 1000 ${#file1} 1" && exit 0 # file (mode 0644, size 6)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ function log_command() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_getattr(p) {
|
function print_getattr(p) {
|
||||||
if (p == "/") print "16877 2 0 0 4096 8"
|
if (p == "/") print "16877 2 1000 1000 4096 8"
|
||||||
else if (p == "/file1") print "33188 1 0 0 " length(file1) " 1"
|
else if (p == "/file1") print "33188 1 1000 1000 " length(file1) " 1"
|
||||||
else exit 1
|
else exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ const file1 = "hello world";
|
||||||
// Function to handle getattr command
|
// Function to handle getattr command
|
||||||
function getattr(path) {
|
function getattr(path) {
|
||||||
if (path === '/') {
|
if (path === '/') {
|
||||||
return "16877 2 0 0 4096 8"
|
return "16877 2 1000 1000 4096 8"
|
||||||
} else if (path === '/file1') {
|
} else if (path === '/file1') {
|
||||||
return `33188 1 0 0 ${file1.length} 1`
|
return `33188 1 1000 1000 ${file1.length} 1`
|
||||||
} else {
|
} else {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ local function log_command(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getattr(path)
|
local function getattr(path)
|
||||||
if path == "/" then print("16877 2 0 0 4096 8")
|
if path == "/" then print("16877 2 1000 1000 4096 8")
|
||||||
elseif path == "/file1" then print(string.format("33188 1 0 0 %d 1", #file1))
|
elseif path == "/file1" then print(string.format("33188 1 1000 1000 %d 1", #file1))
|
||||||
else os.exit(1) end
|
else os.exit(1) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ LOG_PATH = os.path.join(os.getenv("HOME", "/tmp"), ".fuse.log")
|
||||||
file1 = "hello world"
|
file1 = "hello world"
|
||||||
|
|
||||||
def log(msg): open(LOG_PATH, "a").write(msg + "\n")
|
def log(msg): open(LOG_PATH, "a").write(msg + "\n")
|
||||||
def getattr(path): return {"16877 2 0 0 4096 8" if path == "/" else f"33188 1 0 0 {len(file1)} 1"} if path in ["/", "/file1"] else None
|
def getattr(path): return {"16877 2 1000 1000 4096 8" if path == "/" else f"33188 1 1000 1000 {len(file1)} 1"} if path in ["/", "/file1"] else None
|
||||||
def readdir(): print("file1")
|
def readdir(): print("file1")
|
||||||
def read(path): print(file1) if path == "/file1" else sys.exit(1)
|
def read(path): print(file1) if path == "/file1" else sys.exit(1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
source /etc/profile.sh # expose xrsh cmds like require etc
|
|
||||||
|
|
||||||
echo "" # clear line
|
|
||||||
$* # simply execute
|
|
||||||
echo "$*" >> /tmp/frag.log
|
|
||||||
|
|
@ -8,7 +8,6 @@ logger "$0: extracting $file"
|
||||||
mkdir -p "/root/$dir"
|
mkdir -p "/root/$dir"
|
||||||
cd "/root/$dir"
|
cd "/root/$dir"
|
||||||
unzip "$file"
|
unzip "$file"
|
||||||
cd "/root/$dir" # trigger auto-env (.env file)
|
|
||||||
|
|
||||||
test -f .env && test "$(cat ~/.config/autoenv/package)" = 1 && {
|
test -f .env && test "$(cat ~/.config/autoenv/package)" = 1 && {
|
||||||
logger "$0: detected $(pwd)/.env [autoenv]"
|
logger "$0: detected $(pwd)/.env [autoenv]"
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
../../../../bin/ziprun
|
|
||||||
|
|
@ -1,17 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
test -n "$1" || { echo "usage: codemirror <file> <x> <y> <z>"; exit 0; }
|
test -n "$1" || { echo "usage: codemirror <file>"; exit 0; }
|
||||||
|
|
||||||
me="$(dirname $(readlink -f $0))"
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [[ "$1" =~ ^http ]]; then
|
me="$(dirname $(readlink -f $0))"
|
||||||
file="$(basename "$1")"
|
file="$(readlink -f "$1")"
|
||||||
test -f $file && rm $file # *TODO* ask permission
|
|
||||||
wget "${1/*:\/\/}"
|
$me/codemirror.js "$file"
|
||||||
else
|
|
||||||
file="$(readlink -f "$1")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
$me/codemirror.js "$file" $2 $3 $4
|
|
||||||
echo "press ctrl-Q to exit editor"
|
echo "press ctrl-Q to exit editor"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/js
|
#!/bin/js
|
||||||
|
|
||||||
if( args[1] == undefined ) return "usage: codemirror <file>"
|
if( args[1] == undefined ) return "usage: codemirror <file>"
|
||||||
let keymap = "default" // "vim"
|
|
||||||
|
|
||||||
if( AFRAME.components.codemirror ) delete AFRAME.components.codemirror
|
if( AFRAME.components.codemirror ) delete AFRAME.components.codemirror
|
||||||
AFRAME.registerComponent('codemirror', {
|
AFRAME.registerComponent('codemirror', {
|
||||||
|
|
@ -9,7 +9,6 @@ AFRAME.registerComponent('codemirror', {
|
||||||
term: { type:"selector", default: "[isoterminal]" },
|
term: { type:"selector", default: "[isoterminal]" },
|
||||||
width: { type:"number", default:700},
|
width: { type:"number", default:700},
|
||||||
height: { type:"number", default:500},
|
height: { type:"number", default:500},
|
||||||
keymap: { type:"string", default:"default"}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
|
|
@ -41,34 +40,34 @@ AFRAME.registerComponent('codemirror', {
|
||||||
css: (me) => `.CodeMirror{
|
css: (me) => `.CodeMirror{
|
||||||
width: ${me.com.data.width}px !important;
|
width: ${me.com.data.width}px !important;
|
||||||
height: ${me.com.data.height-30}px !important;
|
height: ${me.com.data.height-30}px !important;
|
||||||
}
|
}
|
||||||
.cm-s-shadowfox .CodeMirror-cursor {
|
.cm-s-shadowfox .CodeMirror-cursor {
|
||||||
border-left: 10px solid #a5f !important;
|
border-left: 10px solid #a5f !important;
|
||||||
visibility: visible !important;
|
visibility: visible !important;
|
||||||
}
|
}
|
||||||
.codemirror *{
|
.codemirror *{
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-family: "Cousine",Liberation Mono,DejaVu Sans Mono,Courier New,monospace;
|
font-family: "Cousine",Liberation Mono,DejaVu Sans Mono,Courier New,monospace;
|
||||||
font-weight:500 !important;
|
font-weight:500 !important;
|
||||||
letter-spacing: 0 !important;
|
letter-spacing: 0 !important;
|
||||||
text-shadow: 0px 0px 10px #F075;
|
text-shadow: 0px 0px 10px #F075;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wb-body:has(> .codemirror){
|
.wb-body:has(> .codemirror){
|
||||||
overflow:hidden;
|
overflow:hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
margin-top:18px;
|
margin-top:18px;
|
||||||
}
|
}
|
||||||
.cm-s-shadowfox.CodeMirror {
|
.cm-s-shadowfox.CodeMirror {
|
||||||
background:transparent !important;
|
background:transparent !important;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
},
|
},
|
||||||
|
|
||||||
createEditor: function(value){
|
createEditor: function(value){
|
||||||
this.el.setAttribute("window", `title: codemirror; uid: ${this.el.dom.id}; attach: #overlay; dom: #${this.el.dom.id}; width: ${this.data.width}px; height: ${this.data.height}px; class: no-full, no-max, no-resize`)
|
this.el.setAttribute("window", `title: codemirror; uid: ${this.el.dom.id}; attach: #overlay; dom: #${this.el.dom.id}; width: ${this.data.width}px; height: ${this.data.height}px; class: no-full, no-resize`)
|
||||||
this.editor = CodeMirror( this.el.dom, {
|
this.editor = CodeMirror( this.el.dom, {
|
||||||
value,
|
value,
|
||||||
mode: this.data.file.match(/\.js$/) ? "text/javascript" :
|
mode: this.data.file.match(/\.js$/) ? "text/javascript" :
|
||||||
|
|
@ -81,7 +80,6 @@ AFRAME.registerComponent('codemirror', {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
styleActiveLine: true,
|
styleActiveLine: true,
|
||||||
matchBrackets: true,
|
matchBrackets: true,
|
||||||
keyMap: this.data.keymap,
|
|
||||||
Tab: "indentMore",
|
Tab: "indentMore",
|
||||||
defaultTab: function(cm) {
|
defaultTab: function(cm) {
|
||||||
if (cm.somethingSelected()) cm.indentSelection("add");
|
if (cm.somethingSelected()) cm.indentSelection("add");
|
||||||
|
|
@ -94,17 +92,15 @@ AFRAME.registerComponent('codemirror', {
|
||||||
this.el.emit('close',true) // window.js will react accordingly
|
this.el.emit('close',true) // window.js will react accordingly
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.editor.updateFile = (file,str) => {
|
this.editor.updateFile = AFRAME.utils.throttle( (file,str) => {
|
||||||
clearTimeout( this.editor.updateFile.tid)
|
this.updateFile(file,str)
|
||||||
setTimeout( (file,str) => {
|
}, 1500)
|
||||||
this.updateFile(file,str)
|
|
||||||
},500, file,str)
|
|
||||||
}
|
|
||||||
this.editor.on('change', (instance,changeObj) => {
|
this.editor.on('change', (instance,changeObj) => {
|
||||||
this.editor.updateFile( this.data.file, instance.getValue() )
|
this.editor.updateFile( this.data.file, instance.getValue() )
|
||||||
})
|
})
|
||||||
|
|
||||||
this.handleFocus()
|
this
|
||||||
|
.handleFocus()
|
||||||
|
|
||||||
setTimeout( () => {
|
setTimeout( () => {
|
||||||
this.el.setAttribute("html-as-texture-in-xr", `domid: #${this.el.dom.id}`) // only show aframe-html in xr
|
this.el.setAttribute("html-as-texture-in-xr", `domid: #${this.el.dom.id}`) // only show aframe-html in xr
|
||||||
|
|
@ -141,15 +137,15 @@ AFRAME.registerComponent('codemirror', {
|
||||||
DOMready: function(e){
|
DOMready: function(e){
|
||||||
|
|
||||||
this.isoterminal.worker.read_file(this.data.file)
|
this.isoterminal.worker.read_file(this.data.file)
|
||||||
.then( this.isoterminal.convert.Uint8ArrayToString )
|
.then( this.isoterminal.convert.Uint8ArrayToString )
|
||||||
.then( (str) => {
|
.then( (str) => {
|
||||||
console.log("creating editor: "+this.data.file)
|
console.log("creating editor: "+this.data.file)
|
||||||
this.createEditor( str )
|
this.createEditor( str )
|
||||||
})
|
})
|
||||||
.catch( (e) => {
|
.catch( (e) => {
|
||||||
console.log("error opening "+this.data.file+", creating new one")
|
console.log("error opening "+this.data.file+", creating new one")
|
||||||
this.createEditor("")
|
this.createEditor("")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -202,39 +198,33 @@ This is a help file which describes the application.
|
||||||
It will be rendered thru troika text, and will contain
|
It will be rendered thru troika text, and will contain
|
||||||
headers based on non-punctualized lines separated by linebreaks,
|
headers based on non-punctualized lines separated by linebreaks,
|
||||||
in above's case "\nHelloworld application\n" will qualify as header.
|
in above's case "\nHelloworld application\n" will qualify as header.
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
AFRAME.utils.require({
|
AFRAME.utils.require({
|
||||||
codemirrorjs: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.js",
|
codemirrorjs: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.1/codemirror.js",
|
||||||
codemirrorcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/codemirror.css",
|
codemirrorcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/codemirror.css",
|
||||||
cmtheme: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/theme/shadowfox.css"
|
cmtheme: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/theme/shadowfox.css"
|
||||||
})
|
})
|
||||||
.then( () => {
|
.then( () => AFRAME.utils.require({
|
||||||
|
|
||||||
let extras = {
|
|
||||||
cmxml: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/xml/xml.js",
|
cmxml: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/xml/xml.js",
|
||||||
cmjavascript: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/javascript/javascript.js",
|
cmjavascript: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/javascript/javascript.js",
|
||||||
cmcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/css/css.js",
|
cmcss: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/css/css.js",
|
||||||
cmlua: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/lua/lua.js",
|
cmlua: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/lua/lua.js",
|
||||||
cmpython: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/python/python.js",
|
cmpython: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/python/python.js",
|
||||||
cmmarkdown: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/markdown/markdown.js",
|
cmmarkdown: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/markdown/markdown.js",
|
||||||
highlight: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/htmlmixed/htmlmixed.js"
|
highlight: "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/mode/htmlmixed/htmlmixed.js",
|
||||||
}
|
})
|
||||||
if( keymap == "vim" ) extras.cmvim = "https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/keymap/vim.js";
|
)
|
||||||
return AFRAME.utils.require(extras)
|
|
||||||
})
|
|
||||||
.then( () => {
|
.then( () => {
|
||||||
let el = document.createElement("a-entity")
|
let el = document.createElement("a-entity")
|
||||||
el.setAttribute("codemirror", `file: ${args[1]}`)
|
el.setAttribute("codemirror", `file: ${args[1]}`)
|
||||||
if( args.length == 5 ){
|
document.querySelector("a-scene").appendChild(el)
|
||||||
el.setAttribute("position",`${args[2]} ${args[3]} ${args[4]}`)
|
|
||||||
}
|
|
||||||
document.querySelector("a-scene").appendChild(el)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return "" // empty stdout(put)
|
return "" // empty stdout(put)
|
||||||
|
|
||||||
|
// for shellscript-equivalent see bin/codemirror
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
BIN
dist/v86-linux.iso
vendored
BIN
dist/v86-linux.iso
vendored
Binary file not shown.
Loading…
Add table
Reference in a new issue