diff options
| author | epoch <epoch@thebackupbox.net> | 2022-08-17 21:34:02 -0500 | 
|---|---|---|
| committer | epoch <epoch@thebackupbox.net> | 2022-08-17 21:34:02 -0500 | 
| commit | 6492ba6b4107a4da228e18db4fc5fc871bfb0579 (patch) | |
| tree | 11301c4e20d9a1448337e73b62a16ab1bfeba457 /share/hackvr/examples | |
| parent | 49d54d7582bdcbdcff5637e72e9f29bb5cc571bd (diff) | |
| download | hackvr-6492ba6b4107a4da228e18db4fc5fc871bfb0579.tar.gz hackvr-6492ba6b4107a4da228e18db4fc5fc871bfb0579.zip | |
updated README to show that everything that got deleted went to an -extras repo. also, hackvr script updated to be better bashHEADmaster
Diffstat (limited to 'share/hackvr/examples')
84 files changed, 0 insertions, 3101 deletions
| diff --git a/share/hackvr/examples/anonet_map.sh b/share/hackvr/examples/anonet_map.sh deleted file mode 100755 index 188dd78..0000000 --- a/share/hackvr/examples/anonet_map.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -cat <(printf "%s move 0 0 -270\n" "$USER") \ -    <(wget http://hacking.allowed.org/cgi-bin/map_hackvr.cgi -qO- 2>/dev/null) \ -    /dev/stdin \ - | slowcat 0 \ - | hackvr "$USER" | tee -a /dev/stderr \ - | grep --line-buffered action \ - | stdbuf -oL cut '-d ' -f3 \ - | xargs -r -L1 printf "whois://hacking.allowed.org/AS%s\n" \ - | tee /dev/stderr \ - | xargs -r -L1 urlstart - diff --git a/share/hackvr/examples/anonet_map/map b/share/hackvr/examples/anonet_map/map deleted file mode 100755 index 51a9e59..0000000 --- a/share/hackvr/examples/anonet_map/map +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -echo $USER set title anonet_AS_map - -paths="$(ncat --recv-only 21.41.41.1 64777 | sort | uniq | tee ${PREFIX}/var/cache/hackvr/anonet_data.new)" - -MAP=${PREFIX}/var/cache/hackvr/anonet_map.hackvr -mkdir -p ${PREFIX}/var/cache/hackvr/ - -#see if the data actually changed before regenerating this shit... -if cmp ${PREFIX}/var/cache/hackvr/anonet_data.new ${PREFIX}/var/cache/hackvr/anonet_data.old ; then -  cat $MAP -  exit 0 -fi - -mv ${PREFIX}/var/cache/hackvr/anonet_data.new ${PREFIX}/var/cache/hackvr/anonet_data.old - -> $MAP - -nodes=$(printf "%s\n" "$paths" | tr ' ' '\n' | sort | uniq) -nodes_count="$(printf "%s\n" "$nodes" | tr ' ' '\n' | wc -l | tr -cd '0-9')" -#echo $nodes -#echo $nodes_count -echo $USER move 0 0 -20 -coords="$( (for node in $nodes;do -  printf "AS%s addshape 4 2  0 8 0  0 0 0\n" "$node" -  printf "AS* rotate 0 0 +%d\n" "$[360 / ${nodes_count} ]" -  printf "AS* flatten\n" -done  -printf "* export *\n" -) | hackvr_headless 2>/dev/null | sed 's/^*_AS//g' | cut '-d ' -f5,6)" -#printf "%s\n" "$coords" -xcoords="$(printf "%s\n" "$coords" | cut '-d ' -f1)" -ycoords="$(printf "%s\n" "$coords" | cut '-d ' -f2)" - -#echo $xcoords -#echo $ycoords - -edges=$(printf "%s\n" "$paths" | tr '\n' '\0' | xargs -n1 -0 ./paths-to-edges | sort | uniq | tr ' ' '_') - -index_of() { -  printf "%s\n" "$nodes" | grep -n '^'"$1"'$' | cut -d: -f1 -} - -xcoord_by_ASN() { -  printf "%s\n" "$xcoords" | head -n "$(index_of $1)" | tail -n1 -} - -ycoord_by_ASN() { -  printf "%s\n" "$ycoords" | head -n "$(index_of $1)" | tail -n1 -} - -line_between_nodes() { -  a=$(printf "%s\n" "$1" | cut -d_ -f1) -  b=$(printf "%s\n" "$1" | cut -d_ -f2) -  printf "%s->%s addshape 2 2 %s %s 0 %s %s 0\n" "$a" "$b" $(xcoord_by_ASN $a) $(ycoord_by_ASN $a) $(xcoord_by_ASN $b) $(ycoord_by_ASN $b) -} - -for node in $nodes;do -  printf "<//whois.ano/AS%s> addshape 5 4  -1 8 0  -1 10 0  1 10 0  1 8 0\n" "$node" -  printf "<//whois.ano/AS* rotate 0 0 +%d\n" "$[360 / ${nodes_count} ]" -  printf "<//whois.ano/AS* flatten\n" -  makelabel.sh AS$node $( echo | awk "{print $(xcoord_by_ASN $node) * 13}" ) $( echo | awk "{print $(ycoord_by_ASN $node) * 13}" ) -19 <<< $node -  printf "AS%s scale .1 .1 .1\n" "$node" -done | tee -a $MAP - -for i in $edges;do -  line_between_nodes "$i" -done | tee -a $MAP - -#for i in ${!nodes[@]};do -#  echo $i -#  echo ${nodes[$i]} -#  node=$(printf "%s\n" "${nodes}" | head -n${i} | tail -n1) -#done diff --git a/share/hackvr/examples/anonet_map/paths-to-edges b/share/hackvr/examples/anonet_map/paths-to-edges deleted file mode 100755 index 38fc488..0000000 --- a/share/hackvr/examples/anonet_map/paths-to-edges +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -arr=($*) -for i in ${!arr[@]};do -  echo ${arr[$i]} ${arr[$i+1]} -done | grep ' ' diff --git a/share/hackvr/examples/anonet_map/run b/share/hackvr/examples/anonet_map/run deleted file mode 100755 index c4c1c05..0000000 --- a/share/hackvr/examples/anonet_map/run +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -nonblocktail <(./map) /dev/stdin \ -  | hackvr \ -  | while read group action target;do -      if [ $action = "action" ];then -        printf "%s\n" "$target" | tee /dev/stderr | grep '^<\(.*\)>$' | sed 's/^<\(.*\)>$/\1/g' | tr '\n' '\0' | xargs -n1 -0 copy_start_nevermind.sh & -      fi -    done  diff --git a/share/hackvr/examples/calendar/Makefile b/share/hackvr/examples/calendar/Makefile deleted file mode 100644 index 1646279..0000000 --- a/share/hackvr/examples/calendar/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -PREFIX:=/usr/local - -all: calvr -	@echo using PREFIX: $(PREFIX) - -install: -	install -t $(PREFIX)/bin calvr diff --git a/share/hackvr/examples/calendar/calvr b/share/hackvr/examples/calendar/calvr deleted file mode 100755 index afef593..0000000 --- a/share/hackvr/examples/calendar/calvr +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env bash -#draw a 7x7 grid -#top row gets the day names -#figure out what the first day of the week for that month is -#then looping is easy after that -#use date with format string of day-of-week for an alternate time of the viewing month's first day - -### :D atq in my calendar? -# atq files are stored in: /var/spool/cron/atjobs/ -# filename format: %1c %5x %8x -# order: queue, job number, time / 60 - -set -eo pipefail -current_year=$(date +%Y) -current_month=$(date +%m | sed 's/^0//') -current_day=$(date +%d | sed 's/^0//') - -year=$current_year -month=$current_month -day=$current_day - -### we're testing this weirdness -#year=1752 -#month=9 -#day=1 - -cw=30 -ch=30 - -yoff=51 -xoff=105 -backup=238 - -WORKING_DIR=~/.local/var/cal -mkdir -p $WORKING_DIR - -cd "${WORKING_DIR}" -#git pull - -### hack to load in clock widget? -hackvr-clock init | sed 's/_clock_face_digit[^ ]* /_clock_face_ /g' -clock_left=15 -printf "_clock_face_hand_hour_ move -%s 0 0\n" $clock_left -printf "_clock_face_hand_minute_ move -%s 0 0\n" $clock_left -printf "_clock_face_hand_second_ move -%s 0 0\n" $clock_left -printf "_clock_face_ move -%s 0 0\n" $clock_left -while true;do -  hackvr-clock set -  sleep 1 -done & -### - -printf "%s move %s 0 -%s\n" "$USER" "$xoff" "$backup" - -refresh="yep" - -stdbuf -oL grep -v '^#' | while true;do -  if [ "$refresh" ];then -    unset refresh -#    first_dow="$(date -d $month/1/$year +%w)" - -### this doesn't work for august 2020. outputs 4, should output 6 -    first_dow=$[$(cal -d "${year}-${month}" | tail -n+3 | head -n1 | cut -d1 -f1 | wc -c) / 3] -    monthname="$(date -d $month/1/2000 +%B)" #year isn't important -    dow=$first_dow -    row=0 -    d=1 - -### current month and its "button" -    printf "_cal_MONTH_ addshape 1 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \ -           $[0]                    $[1*$ch + $yoff] \ -           $[(($cw * 7 ) / 2) - 1] $[1*$ch + $yoff] \ -           $[(($cw * 7 ) / 2) - 1] $[1*$ch+($ch/2) + $yoff - 1] \ -           $[0]                    $[1*$ch+($ch/2) + $yoff - 1] -    printf "%s\n" "${monthname}" | makelabel.sh "_cal_MONTH_" $[$xoff / 3] $[$yoff + $ch + 5] 0 - -### current year and its "button" -    printf "_cal_YEAR_ addshape 1 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \ -           $[($cw * 7 ) / 2 ]      $[1*$ch + $yoff] \ -           $[$cw * 7 - 1]          $[1*$ch + $yoff] \ -           $[$cw * 7 - 1]          $[1*$ch+($ch/2) + $yoff - 1] \ -           $[($cw * 7 ) / 2 ]      $[1*$ch+($ch/2) + $yoff - 1] -    printf "%s\n" "${year}" | makelabel.sh "_cal_YEAR_" $[$xoff + 5] $[$yoff + $ch + 5] 0 - -### the <== button -    printf "_cal_prevmonth_ addshape 1 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \ -           $[-$cw] $[1*$ch + $yoff] \ -           $[-1]   $[1*$ch + $yoff] \ -           $[-1]   $[1*$ch+($ch/2) + $yoff - 1] \ -           $[-$cw] $[1*$ch+($ch/2) + $yoff - 1] -    printf "<==\n" | makelabel.sh "_cal_prevmonth_" $[0 - $cw + 1] $[$yoff + $ch + 5] 0 - -### the ==> button -    printf "_cal_nextmonth_ addshape 1 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \ -           $[$cw * 7]    $[1*$ch + $yoff] \ -           $[$cw * 8 -1] $[1*$ch + $yoff] \ -           $[$cw * 8 -1] $[1*$ch+($ch/2) + $yoff - 1] \ -           $[$cw * 7]    $[1*$ch+($ch/2) + $yoff - 1] -    printf "==>\n" | makelabel.sh "_cal_nextmonth_" $[$cw * 7 + 1] $[$yoff + $ch + 5] 0 - -    for d in $(cal -d $year-$month | tail -n+3 | tr '\n' ' ' | tr -s ' ');do -#    while [ "$d" -le "$days_in_month" ];do -#      printf "%s %s : %s\n" "$row" "$dow" "$d" -      if [ -f ${WORKING_DIR}/${year}_${month}_${d} ];then -        color=$[4+16] -      else -        color=$[5+16] -      fi -      printf "%s addshape %s 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \ -             "_cal_day_${d}_" "${color}" \ -             "$[$dow*$cw]"       "$[-1*$row*$ch + $yoff]" \ -             "$[$dow*$cw+$cw-1]" "$[-1*$row*$ch + $yoff]" \ -             "$[$dow*$cw+$cw-1]" "$[-1*$row*$ch+$ch-1 + $yoff]" \ -             "$[$dow*$cw]"       "$[-1*$row*$ch+$ch-1 + $yoff]" -      printf "%s\n" "${d}" | makelabel.sh "_cal_day_${d}_" "$[$dow*$cw + 1]" "$[-1*$row*$ch + $yoff + 1]" 0 -      d=$[$d+1] -      dow=$[$dow + 1] -      if [ $dow = 7 ];then -        dow=0 -        row=$[$row + 1] -      fi -    done -    if [ $month = $current_month -a $year = $current_year ];then -      printf "_cal_day_%s_ move 0 0 -2\n" "${current_day}" -    fi -  fi -  if ! read group action target;then -    exit -  fi -  #xmessage "$group $action $target" -  if [ "$action" = "action" ];then -    if [ "$target" = "_cal_nextmonth_" ];then -      month=$[month + 1] -      if [ $month = 13 ];then -        month=1 -        year=$[$year + 1] -      fi -      refresh="yep" -    fi -    if [ "$target" = "_cal_prevmonth_" ];then -      month=$[month - 1] -      if [ $month = 0 ];then -        month=12 -        year=$[$year - 1] -      fi -      refresh="yep" -    fi -    if [ "$target" = "_cal_MONTH_" ];then -      month="$(xmessage -buttons January:1,February:2,March:3,April:4,May:5,June:6,July:7,August:8,September:9,October:10,November:11,December:12 'pick a month';echo $?)" -      refresh="yep" -    fi -    if [ "$target" = "_cal_YEAR_" ];then -      year="$(seq $[$year - 5] $[$year + 5] | dmenu -p 'enter a year' | tr -cd '0-9' | sed 's/^$/1970/')" -      refresh="yep" -    fi -    if printf "%s\n" "$target" | grep '^_cal_day_' 2>&1 >/dev/null;then -      d="$(printf "%s\n" "$target" | cut -d_ -f4)" -      file=${WORKING_DIR}/${year}_${month}_${d} -      if [ -e "${file}" ];then -        derp=exists -      else -        derp=notexists -      fi -      x-terminal-emulator -e nano "${file}" -      if [ -e "${file}" ];then #if the file exists -        if [ ! -s "${file}" ];then #but the file is empty -          rm "${file}" >&2 -          #git rm "${file}" >&2 -          #git commit -m '[calvr] removed: ${file}' >&2 -        else #the file is NOT empty, so it was changed, or not, might as well try to add and commit. -          echo "# lol wat?" -          #git add "${file}" >&2 -          #git commit -m '[calvr] maybe changed: ${file}' >&2 # if nothing changed it won't bother to commit -          #git push # just to make it more magical -        fi -      fi -      if [ -e "${file}" ];then -        merp=exists -      else -        merp=notexists -      fi -      if [ "${derp}" != "${merp}" ];then -        refresh="yep" -      fi -    fi -  fi -  if [ "$action" = "quit" ];then -    exit -  fi -  if [ "$refresh" ];then -    ### I /might/ want to just make all of the calendar parts -    ### start with _cal_* so I can deletegroup _cal_* -    ### instead of nuking the world except the user. -    printf '%s deletegroup _cal_*\n' "$USER" -  fi -done diff --git a/share/hackvr/examples/chess/board.sh b/share/hackvr/examples/chess/board.sh deleted file mode 100755 index dc3fb3b..0000000 --- a/share/hackvr/examples/chess/board.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash - -e=$1 #elevation of board -width=8 -height=8 -cols="a b c d e f g h" - -printf "junk set camera.r.x -45\n" - -for x in $(seq 1 $width);do - for y in $(seq 1 $height);do -  color=$[((($y % 2) + ($x % 2))%2)+16] -### board is on the wall. draw in x and y. -#  printf "%s%s addshape %s 4 %s %s %s %s %s %s %s %s %s %s %s %s\n" \ -#     $(printf "%s\n" "$cols" | cut '-d ' -f$x) $y $color \ -#     $x     $y $e \ -#     $[x+1] $y $e \ -#     $[x+1] $[y+1] $e \ -#     $x     $[y+1] $e -### board is on floor. draw in x and z. -  printf "%s%s addshape %s 4 %s %s %s %s %s %s %s %s %s %s %s %s\n" \ -      $(printf "%s\n" "$cols" | cut '-d ' -f$x) $y $color \ -      $x     $e $y \ -      $[x+1] $e $y \ -      $[x+1] $e $[y+1] \ -      $x     $e $[y+1] - done -done - -row8="rook knight bishop queen king bishop knight rook" -row1="$row8" - -color="19 19 0 0 0 0 20 20" - -#draw pawns. triangles. -for x in $(seq $width);do - for y in 2 7;do -  locat="$(printf "%s\n" "$cols" | cut '-d ' "-f$x")$y" -  cat "./pieces/pawn" | sed 's/^[^ ][^ ]* addshape [0-9][0-9]* /piece_'"${locat}"' addshape '"$(printf "%s\n" "$color" | cut '-d ' "-f$y")"' /g' -### board is on wall. use x and y. -#  printf "piece_%s move %s %s %s\n" "$locat" "$x" "$y" "$e" -### board is on floor. use x and z. -  printf "piece_%s move %s %s %s\n" "$locat" "$x" "$e" "$y" - done - for y in 1 8;do -  locat="$(printf "%s\n" "$cols" | cut '-d ' "-f$x")$y" -  cat "./pieces/$(printf "%s\n" "$row1" | cut '-d ' "-f$x")" \ -    | sed 's/^[^ ][^ ]* addshape [0-9][0-9]* /piece_'"${locat}"' addshape '"$(printf "%s\n" "$color" | cut '-d ' "-f$y")"' /g' -### board is on wall. use x and y. -#  printf "piece_%s move %s %s %s\n" "$locat" "$x" "$y" "$e" -### board is on floor. use x and z. -  printf "piece_%s move %s %s %s\n" "$locat" "$x" "$e" "$y" - done -done diff --git a/share/hackvr/examples/chess/camera.pos b/share/hackvr/examples/chess/camera.pos deleted file mode 100644 index 32433c2..0000000 --- a/share/hackvr/examples/chess/camera.pos +++ /dev/null @@ -1,2 +0,0 @@ -epoch move 5 5 -6 -derp set global.zoom 60 diff --git a/share/hackvr/examples/chess/gnuchess-to-hackvr.sh b/share/hackvr/examples/chess/gnuchess-to-hackvr.sh deleted file mode 100755 index 841389b..0000000 --- a/share/hackvr/examples/chess/gnuchess-to-hackvr.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -e=$1 -tee /dev/stderr | while read first second third;do -  if [ "_$first" = "_feature" ];then -    printf "# just gnuchess saying what features it has: %s %s %s\n" "$first" "$second" "$third" >&2 -  elif printf "%s\n" "$first" | grep '^[0-9][0-9]*\.$' >/dev/null 2>&1;then -    #we made a successful move. -    ### how to tell hackvr to move the piece now? $second should contain what the move was. -    printf "# Hey! Hackvr! do this move: %s\n" "$second" >&2 -    if [ "_$second" = "_..." ];then #computer/other person made a move. -      move=$third -    else -      move=$second -    fi -      from=$(printf "%s\n" "$move" | fold -w1 | head -n2 | tr -d '\n') -      to=$(printf "%s\n" "$move" | fold -w1 | tail -n+3 | head -n2 | tr -d '\n') -      x=$(echo "a b c d e f g h" | tr ' ' '\n' | grep -n "$(printf "%s\n" "$to" | fold -w1 | head -n1)" | cut -d: -f1) -      y=$(printf "%s\n" "$to" | fold -w1 | tail -n1) -      magic=$(printf "%s\n" "$move" | fold -w1 | tail -n+5 | tr -d '\n') -### if the board is on the wall we need to use x and y -#    printf "piece_%s move %s %s %s\n" "$from" "$x" "$y" "$e" | tee /dev/stderr -### the board is on the floor atm. use x and z -    printf "piece_%s move %s %s %s\n" "$from" "$x" "$e" "$y" | tee /dev/stderr - -    printf "#delete the old piece_%s group\n" -    printf "epoch deletegroup piece_%s\n" "$to" -    printf "epoch renamegroup piece_%s piece_%s\n" "$from" "$to" | tee /dev/stderr -  else -    #something else. -    printf "oops. something else happened. let's see: %s %s %s\n" "$first" "$second" "$third" >&2 -  fi -done diff --git a/share/hackvr/examples/chess/hackvr-to-gnuchess.sh b/share/hackvr/examples/chess/hackvr-to-gnuchess.sh deleted file mode 100755 index 94cd1ab..0000000 --- a/share/hackvr/examples/chess/hackvr-to-gnuchess.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -part1="" -echo "sleeping 3 seconds. might have gnuchess less likely to not do anything." >&2 -sleep 3 -echo "protover 2" -while read derp command target extra;do -  if [ "_$command" = "_action" ];then -    if printf "%s\n" "$target" | grep -v "^piece_" 2>&1 > /dev/null;then #we are ignoring clicks on pieces in favor of squares atm. when full 3d probably want pieces. -      if [ "_$part1" = "_" ];then -        part1=$target -      else -        #we have two parts. let's tell gnuchess! -        printf "%s%s\n" $part1 $target -        part1="" -      fi -    fi -  fi -done diff --git a/share/hackvr/examples/chess/pieces/bishop b/share/hackvr/examples/chess/pieces/bishop deleted file mode 100644 index db6f144..0000000 --- a/share/hackvr/examples/chess/pieces/bishop +++ /dev/null @@ -1,2 +0,0 @@ -rook addshape 4 4  .4 .1 0   .6 .1 0   .6 .9 0   .4 .9 0 -rook addshape 4 4  .3 .6 0   .7 .6 0   .7 .8 0   .3 .8 0 diff --git a/share/hackvr/examples/chess/pieces/king b/share/hackvr/examples/chess/pieces/king deleted file mode 100644 index 8ca79ef..0000000 --- a/share/hackvr/examples/chess/pieces/king +++ /dev/null @@ -1,2 +0,0 @@ -king addshape 4 4  .1 .7 0  .3 .9 0  .9 .3 0  .7 .1 0 -king addshape 4 4  .3 .1 0  .9 .7 0  .7 .9 0  .1 .3 0 diff --git a/share/hackvr/examples/chess/pieces/knight b/share/hackvr/examples/chess/pieces/knight deleted file mode 100644 index adc7f53..0000000 --- a/share/hackvr/examples/chess/pieces/knight +++ /dev/null @@ -1,2 +0,0 @@ -knight addshape 4 4   .1 .1 0  .3 .1 0  .3 .9 0  .1 .9 0 -knight addshape 4 4   .1 .1 0  .9 .1 0  .9 .3 0  .1 .3 0 diff --git a/share/hackvr/examples/chess/pieces/pawn b/share/hackvr/examples/chess/pieces/pawn deleted file mode 100644 index d7d2d29..0000000 --- a/share/hackvr/examples/chess/pieces/pawn +++ /dev/null @@ -1 +0,0 @@ -pawn addshape 4 3   .2 .1 0   .8 .1 0   .5 .5 0 diff --git a/share/hackvr/examples/chess/pieces/queen b/share/hackvr/examples/chess/pieces/queen deleted file mode 100644 index 3ebb4ab..0000000 --- a/share/hackvr/examples/chess/pieces/queen +++ /dev/null @@ -1 +0,0 @@ -pawn addshape 4 3   .2 .1 0   .8 .1 0   .5 .9 0 diff --git a/share/hackvr/examples/chess/pieces/rook b/share/hackvr/examples/chess/pieces/rook deleted file mode 100644 index 2550eb5..0000000 --- a/share/hackvr/examples/chess/pieces/rook +++ /dev/null @@ -1 +0,0 @@ -rook addshape 4 4  .4 .1 0   .6 .1 0   .6 .9 0   .4 .9 0 diff --git a/share/hackvr/examples/chess/run b/share/hackvr/examples/chess/run deleted file mode 100755 index 1168044..0000000 --- a/share/hackvr/examples/chess/run +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -export elevation=0 -mknod p p -stdbuf -oL cat camera.pos <(./board.sh $elevation) <(cat p | ./gnuchess-to-hackvr.sh $elevation) | hackvr "$USER" | ./hackvr-to-gnuchess.sh | gnuchess -x > p -rm p diff --git a/share/hackvr/examples/clock/Makefile b/share/hackvr/examples/clock/Makefile deleted file mode 100644 index ea7944a..0000000 --- a/share/hackvr/examples/clock/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -PREFIX:=/usr/local - -.PHONY: all install - -hackvr-clock: run.pre generate.py -	./generate.py | cat run.pre /dev/stdin > hackvr-clock -	chmod +x hackvr-clock -all: hackvr-clock - -install: all -	install -t $(PREFIX)/bin hackvr-clock diff --git a/share/hackvr/examples/clock/generate.py b/share/hackvr/examples/clock/generate.py deleted file mode 100755 index f3db105..0000000 --- a/share/hackvr/examples/clock/generate.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -import math - -for i in range(1,13): -  x=math.floor(math.sin(math.pi / 6 * i) * 1000) / 100 -  y=math.floor(math.cos(math.pi / 6 * i) * 1000) / 100 -  print("_clock_face_digit_{}_ addshape 2 4 {} {} 0 {} {} 0 {} {} 0 {} {} 0".format(i,x-1,y-1,x+1,y-1,x+1,y+1,x-1,y+1)) -  print("_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0") -  print("_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0") -  print("_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0") diff --git a/share/hackvr/examples/clock/hackvr-clock b/share/hackvr/examples/clock/hackvr-clock deleted file mode 100755 index 95ba948..0000000 --- a/share/hackvr/examples/clock/hackvr-clock +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env bash -if [ "$1" = "init" ];then -  grep -A1000 '^___CUT___' "$0" | tail -n+2 -  exit -elif [ "$1" = "set" ];then -  hour=$(date +%H | sed 's/^0//') -  minute=$(date +%M | sed 's/^0//') -  second=$(date +%S | sed 's/^0//') -  printf "_clock_face_hand_hour_ rotate 0 0 -%s\n" "$[$hour * 30 + ($minute / 2)]" -  printf "_clock_face_hand_minute_ rotate 0 0 -%s\n" "$[$minute * 6]" -  printf "_clock_face_hand_second_ rotate 0 0 -%s\n" "$[$second * 6]" -  #printf "_clock_face_hand_hour_ rotate 0 0 %s\n" "$[$hour * 30 + ($minute / 2)]" -  #printf "_clock_face_hand_minute_ rotate 0 0 %s\n" "$[$minute * 6]" -  #printf "_clock_face_hand_second_ rotate 0 0 %s\n" "$[$second * 6]" -else -  nonblocktail \ -      <(echo $USER move 0 0 -30) \ -      <("$0" init) \ -      <(while true;do "$0" set;sleep 1;done) \ -      /dev/stdin 2>/dev/null \ -    | hackvr 2>/dev/null -fi -exit 0 -___CUT___ -_clock_face_digit_1_ addshape 2 4 3.99 7.66 0 5.99 7.66 0 5.99 9.66 0 3.99 9.66 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_2_ addshape 2 4 7.66 4.0 0 9.66 4.0 0 9.66 6.0 0 7.66 6.0 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_3_ addshape 2 4 9.0 -1.0 0 11.0 -1.0 0 11.0 1.0 0 9.0 1.0 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_4_ addshape 2 4 7.66 -6.0 0 9.66 -6.0 0 9.66 -4.0 0 7.66 -4.0 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_5_ addshape 2 4 4.0 -9.67 0 6.0 -9.67 0 6.0 -7.67 0 4.0 -7.67 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_6_ addshape 2 4 -1.0 -11.0 0 1.0 -11.0 0 1.0 -9.0 0 -1.0 -9.0 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_7_ addshape 2 4 -6.0 -9.67 0 -4.0 -9.67 0 -4.0 -7.67 0 -6.0 -7.67 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_8_ addshape 2 4 -9.67 -6.01 0 -7.67 -6.01 0 -7.67 -4.01 0 -9.67 -4.01 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_9_ addshape 2 4 -11.0 -1.01 0 -9.0 -1.01 0 -9.0 0.99 0 -11.0 0.99 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_10_ addshape 2 4 -9.67 3.99 0 -7.67 3.99 0 -7.67 5.99 0 -9.67 5.99 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_11_ addshape 2 4 -6.01 7.66 0 -4.01 7.66 0 -4.01 9.66 0 -6.01 9.66 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 -_clock_face_digit_12_ addshape 2 4 -1.01 9.0 0 0.99 9.0 0 0.99 11.0 0 -1.01 11.0 0 -_clock_face_hand_hour_ addshape 2 3 -1 -1 0   0 5 0  1 -1 0 -_clock_face_hand_minute_ addshape 2 3 -.75 -.75 0   0 8 0  .75 -.75 0 -_clock_face_hand_second_ addshape 2 3 -.25 -.25 0   0 10 0  .25 -.25 0 diff --git a/share/hackvr/examples/clock/run.pre b/share/hackvr/examples/clock/run.pre deleted file mode 100755 index ed0e68b..0000000 --- a/share/hackvr/examples/clock/run.pre +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -if [ "$1" = "init" ];then -  grep -A1000 '^___CUT___' "$0" | tail -n+2 -  exit -elif [ "$1" = "set" ];then -  hour=$(date +%H | sed 's/^0//') -  minute=$(date +%M | sed 's/^0//') -  second=$(date +%S | sed 's/^0//') -  printf "_clock_face_hand_hour_ rotate 0 0 -%s\n" "$[$hour * 30 + ($minute / 2)]" -  printf "_clock_face_hand_minute_ rotate 0 0 -%s\n" "$[$minute * 6]" -  printf "_clock_face_hand_second_ rotate 0 0 -%s\n" "$[$second * 6]" -  #printf "_clock_face_hand_hour_ rotate 0 0 %s\n" "$[$hour * 30 + ($minute / 2)]" -  #printf "_clock_face_hand_minute_ rotate 0 0 %s\n" "$[$minute * 6]" -  #printf "_clock_face_hand_second_ rotate 0 0 %s\n" "$[$second * 6]" -else -  nonblocktail \ -      <(echo $USER move 0 0 -30) \ -      <("$0" init) \ -      <(while true;do "$0" set;sleep 1;done) \ -      /dev/stdin 2>/dev/null \ -    | hackvr 2>/dev/null -fi -exit 0 -___CUT___ diff --git a/share/hackvr/examples/clock/set_clock.sh b/share/hackvr/examples/clock/set_clock.sh deleted file mode 100755 index 36c3fb4..0000000 --- a/share/hackvr/examples/clock/set_clock.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -hour=$(date +%H | sed 's/^0//') -minute=$(date +%M | sed 's/^0//') -second=$(date +%S | sed 's/^0//') -printf "_clock_face_hand_hour_ rotate 0 0 -%s\n" "$[$hour * 30 + ($minute / 2)]" -printf "_clock_face_hand_minute_ rotate 0 0 -%s\n" "$[$minute * 6]" -printf "_clock_face_hand_second_ rotate 0 0 -%s\n" "$[$second * 6]" -#printf "_clock_face_hand_hour_ rotate 0 0 %s\n" "$[$hour * 30 + ($minute / 2)]" -#printf "_clock_face_hand_minute_ rotate 0 0 %s\n" "$[$minute * 6]" -#printf "_clock_face_hand_second_ rotate 0 0 %s\n" "$[$second * 6]" diff --git a/share/hackvr/examples/dothack/chaosgate.py b/share/hackvr/examples/dothack/chaosgate.py deleted file mode 100755 index b1cea43..0000000 --- a/share/hackvr/examples/dothack/chaosgate.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -import math - -def fp(p): -    return " {} {} {}".format(p[0],p[1],p[2]) - -def print_rect(r): -    print("gate addshape 3 4 {} {} {} {}".format(fp(r[0]),fp(r[1]),fp(r[2]),fp(r[3]))) - -d=1 - -sides = 16.0 -step = 360.0/sides -rot=0.0 -zoff = 0.0 -while rot < 360: -#    print("rot: {}".format(rot)) -    x1=math.sin(rot * math.pi / 180.0) -    y1=math.cos(rot * math.pi / 180.0) -    rot = rot + step -    x2=math.sin(rot * math.pi / 180.0) -    y2=math.cos(rot * math.pi / 180.0) - -#    print("{} {}".format(x1,y1)) - -    ### now to calculate points for the 4 rectangles we need to draw... -    v1 = x1 * (d+30.0) # inner first point -    v2 = x1 * (d+32.0) # outer first point -    v3 = x1 * (d+31.0) # center first point - -    v4 = y1 * (d+30.0) -    v5 = y1 * (d+32.0) -    v6 = y1 * (d+31.0) - -    v7 = x2 * (d+30.0) -    v8 = x2 * (d+32.0) -    v9 = x2 * (d+31.0) - -    v10 = y2 * (d+30.0) -    v11 = y2 * (d+32.0) -    v12 = y2 * (d+31.0) - -    p1 = (v1, v4, zoff + 0.0) -    p2 = (v2, v5, zoff + 0.0) -    p3 = (v3, v6, zoff + 1.0) -    p4 = (v3, v6, zoff - 1.0) - -    p5 = (v7, v10, zoff + 0.0) -    p6 = (v8, v11, zoff + 0.0) -    p7 = (v9, v12, zoff + 1.0) -    p8 = (v9, v12, zoff - 1.0) - -    r1 = (p1, p5, p7, p3) #inner near -    r2 = (p1, p5, p8, p4) #inner far -    r3 = (p2, p6, p7, p3) #outer near -    r4 = (p2, p6, p8, p4) #outer far - -    ### first rectange is... -    print_rect(r1) -    print_rect(r2) -    print_rect(r3) -    print_rect(r4) diff --git a/share/hackvr/examples/dothack/test.sh b/share/hackvr/examples/dothack/test.sh deleted file mode 100755 index 7a30544..0000000 --- a/share/hackvr/examples/dothack/test.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -nonblocktail \ -	<(./chaosgate.py) \ -	<(echo gate move 0 0 150) \ -	<(while true;do for i in $(seq 0 5 360);do echo "gate rotate 0 $i 0";sleep .1;done;done) \ -  | hackvr_open diff --git a/share/hackvr/examples/draw/draw.sh b/share/hackvr/examples/draw/draw.sh deleted file mode 100755 index e18a8b4..0000000 --- a/share/hackvr/examples/draw/draw.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -echo "$USER move 5 7 -19" - -for y in $(seq 0 1 15);do - for x in $(seq 0 1 15);do -  echo cell_${x}_${y} addshape 2 4 -.5 -.5 0 -.5 .5 0 .5 .5 0 .5 -.5 0 -  #echo cell_${x}_${y} addshape 2 4 $x $y 0 $[x] $[y+1] 0 $[x+1] $[y+1] 0 $[x+1] $[y] 0 -  echo cell_${x}_${y} move $x $y 0 - done -done - -### color pallete -### 0-8 are ansi colors. -for c in $(seq 0 16);do -	echo color_${c} addshape $[c] 4   $[-2 - ($c / 8)] $[($c%8)+3] 0   $[-1 - ($c / 8)] $[($c%8)+3] 0   $[-1 - ($c / 8)] $[($c%8)+4] 0   $[-2 - ($c / 8)] $[($c%8)+4] 0 -done - -#cat ${PREFIX}/share/hackvr/meshes/floppy.hackvr | grep '^[^ #]' | sed 's/^[^ ][^ ]*/save/g' -#echo save move -5 0 0 - -tee /dev/stderr | while read -r source command target;do -  if [ "$command" = "action" ];then -    if echo "$target" | grep "^save" 2>&1 >/dev/null;then -      echo "$USER export *" -      date=$(date +%s) -      echo "$USER ping $date" -      while read -r line;do -        if [ "$line" = "${USER} pong ${date}" ];then -          break -        else -          printf "%s\n" "$line" >> ~/drawsave.hackvr -	fi -      done -    fi -    if echo "$target" | grep "^color_" 2>&1 >/dev/null;then -      color=$(echo $target | cut -d_ -f2) -      echo deletegroup $target -      echo color_${color}_current addshape $[$color] 4   -2 0 0 -2 1 0 -1 1 0 -1 0 0 -    elif echo "$target" | grep '^cell_' 2>&1 >/dev/null;then -      x=$(echo $target | cut -d_ -f2) -      y=$(echo $target | cut -d_ -f3) -      echo $target deletegroup $target -      #echo $target addshape $[$color] 4 $x $y 0 $x $[y+1] 0 $[x+1] $[y+1] 0 $[x+1] $y 0 | tee /dev/stderr -      echo $target addshape $[$color] 4 -.5 -.5 0 -.5 .5 0 .5 .5 0 .5 -.5 0 -      printf "%s move %d %d 0" "$target" "$x" "$y" -    fi -  fi -done diff --git a/share/hackvr/examples/draw/run b/share/hackvr/examples/draw/run deleted file mode 100755 index 699a38c..0000000 --- a/share/hackvr/examples/draw/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -mknod p p -hackvr_coproc ./draw.sh diff --git a/share/hackvr/examples/dungen/Makefile b/share/hackvr/examples/dungen/Makefile deleted file mode 100644 index cd05f4b..0000000 --- a/share/hackvr/examples/dungen/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -.PHONY: all clean - -all: dungen dun2ascii dun2hackvr - -clean: -	rm -f dungen -	rm -f dun2ascii -	rm -f dun2hackvr diff --git a/share/hackvr/examples/dungen/dun2ascii.c b/share/hackvr/examples/dungen/dun2ascii.c deleted file mode 100644 index d7a9996..0000000 --- a/share/hackvr/examples/dungen/dun2ascii.c +++ /dev/null @@ -1,46 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -//nsew -char *a[16]; - -char field[256]; - -void print_field() { -  int i; -  fprintf(stderr,"\x1b[H"); -  for(i=0;i<(16*strlen(a[field[0]]))+1;i++) fprintf(stderr,"#"); -  for(i=0;i<256;i++) { -    if(i%16 == 0) fprintf(stderr,"#\n#"); -    fprintf(stderr,"%s",a[field[i]]); -  } -  fprintf(stderr,"#\n"); -  for(i=0;i<(16*strlen(a[field[0]]))+2;i++) fprintf(stderr,"#"); -  fprintf(stderr,"\n"); -} - -int main(int argc,char *argv[]) { -  int i; -  fprintf(stderr,"\x1b[H\x1b[2J"); -  a[0x0]="   "; -  a[0x1]="-  "; -  a[0x2]="  -"; -  a[0x3]="---"; -  a[0x4]=" . "; -  a[0x5]="-. "; -  a[0x6]=" .-"; -  a[0x7]="-.-"; -  a[0x8]=" ' "; -  a[0x9]="-' "; -  a[0xa]=" '-"; -  a[0xb]="-'-"; -  a[0xc]=" | "; -  a[0xd]="-| "; -  a[0xe]=" |-"; -  a[0xf]="-|-"; -  while(read(0,field,sizeof(field)) > 0) { -    print_field(); -    sleep(1); -  } -} diff --git a/share/hackvr/examples/dungen/dun2hackvr.c b/share/hackvr/examples/dungen/dun2hackvr.c deleted file mode 100644 index b67af14..0000000 --- a/share/hackvr/examples/dungen/dun2hackvr.c +++ /dev/null @@ -1,59 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -//nsew -char field[256]; - -#define NORTH_EXIT 8 -#define SOUTH_EXIT 4 -#define EAST_EXIT 2 -#define WEST_EXIT 1 - -int deg[]={0,180,270,90}; -int doorx[]={}; -int doory[]={}; - -void print_field() { -  int i,d; -  int x,y; -  for(i=0;i<256;i++) { -    //we need to draw the room here. -    //each room will be... 16x16? sure.... -    //we can use bitmasks to find which sides of the room need to be whole walls -    //and which will contain passages to the next rooms -    //whole walls are a single rectangle -    //we need to loop over each wall and check if it has a passage through it -    if(field[i]) { -      for(d=0;d<4;d++) {//loop over the 4 possible directions/walls -        x=(i%16) * 16 - (7 * 16); -        y=(i/16) * -16 + 16; -        if((field[i] & (1<<(3-d))) > 0) {//if this has an exit in this bit... -          printf("wall_%d_%d addshape 2 4  -7 0 7  -7 8 7  -2 8 7  -2 0 7\n",i,d);//we need 4 parts for the doorway -          printf("wall_%d_%d addshape 2 4  2 0 7  2 8 7  7 8 7  7 0 7\n",i,d); -          if(d % 2) {//only do the south and west doorjams. every door has an opposite door that matches it anyway -            printf("wall_%d_%d addshape 2 4  -2 0 7  -2 8 7  -2 8 9  -2 0 9\n",i,d); -            printf("wall_%d_%d addshape 2 4  2 0 9  2 8 9  2 8 7  2 0 7\n",i,d); -            printf("door_close_%d_%d addshape 3 4  0 0 0  0 8 0  4 8 0  4 0 0\n",i,d);//door needs to be built to where its hinge is at 0,y,0, then moved into place so opening will work. -            printf("door_close_%d_%d rotate 0 %d 0\n",i,d,deg[d]); -            if(d == 1) printf("door_close_%d_%d move %d 0 %d\n",i,d,x+2,y-8); -            if(d == 3) printf("door_close_%d_%d move %d 0 %d\n",i,d,x-8,y-2); -          } -        } else {//no door in this wall -          printf("wall_%d_%d addshape 2 4  -7 0 7  -7 8 7  7 8 7  7 0 7\n",i,d);//solid wall -        } -        printf("wall_%d_%d rotate 0 %d 0\n",i,d,deg[d]);//rotate this wall into position -        printf("wall_%d_%d move %d 0 %d\n",i,d,x,y);//and put it in the right spot ofc -        //the door needs to move either -2, +8 -      } -    } -  } -} - -int main(int argc,char *argv[]) { -  if(read(0,field,sizeof(field)) > 0) { -    print_field(); -    return 0; -  } -  return 1; -} diff --git a/share/hackvr/examples/dungen/dunexplore.sh b/share/hackvr/examples/dungen/dunexplore.sh deleted file mode 100755 index 6fbd5c3..0000000 --- a/share/hackvr/examples/dungen/dunexplore.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -### run me with hackvr_coproc -#the $USER triangle we add first is to give us some sort of avatar to see where the camera is. -#seed=1337 -red=1 -green=2 -blue=4 -echo $USER addshape 6 3  -1 0 -1  0 0 2  1 0 -1 ; echo $USER move 0 2 0 -echo world-x addshape $red 2  0 0 0  1 0 0 -echo world-y addshape $green 2  0 0 0  0 1 0 -echo world-z addshape $blue 2  0 0 0  0 0 1 -./dungen $seed | ./dun2hackvr -while read group action target;do -  if [ "$action" = "action" ];then -    if printf "%s\n" "${target}" | grep ^door_;then -      printf "# clicked a door! %s\n" "${target}" >&2 -      if printf "%s\n" "${target}" | grep ^door_open;then -        tmp=$(printf "%s\n" "${target}" | sed 's/_open/_CLOSING/') -        printf "%s renamegroup %s %s\n" ${target} ${target} ${tmp}  -        ( -        for i in $(seq 1 5 90);do -          printf "%s rotate 0 +5 0\n" ${tmp} -          sleep .1 -        done -        tmp2=$(printf "%s\n" "${target}" | sed 's/_open/_close/') -        printf "%s renamegroup %s %s\n" ${tmp} ${tmp} ${tmp2} -        ) & -      elif printf "%s\n" "${target}" | grep ^door_close;then -        tmp=$(printf "%s\n" "${target}" | sed 's/_close/_OPENING/') -        printf "%s renamegroup %s %s\n" ${target} ${target} ${tmp} -        ( -        for i in $(seq 1 5 90);do -          printf "%s rotate 0 +-5 0\n" ${tmp} -          sleep .1 -        done -        tmp2=$(printf "%s\n" "${target}" | sed 's/_close/_open/') -        printf "%s renamegroup %s %s\n" ${tmp} ${tmp} ${tmp2} -        ) & -      fi -    fi  -  fi -done diff --git a/share/hackvr/examples/dungen/dungen.c b/share/hackvr/examples/dungen/dungen.c deleted file mode 100644 index 738b395..0000000 --- a/share/hackvr/examples/dungen/dungen.c +++ /dev/null @@ -1,61 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> -#include <time.h> - -#define ITERATIONS 16 - -char field[256]; -char nfield[256]; - -void prune() {//remove paths into wall -  int i; -  memcpy(nfield,field,256);//make a copy just for comparison -  for(i=0;i<256;i++) { -    if(i%16 == 0) field[i] &= ~0x1;//remove all left exits at left of map -    else if((field[i]&0x1) && !(nfield[i-1]&0x2)) field[i] &= ~0x1; -    if(i%16 == 15) field[i] &= ~0x2;//remove all right exits at right of map. -    else if((field[i]&0x2) && !(nfield[i+1]&0x1)) field[i] &= ~0x2; -    if(i > 240) field[i] &= ~0x4; -    else if((field[i]&0x4) && !(nfield[i+16]&0x8)) field[i] &= ~0x4; -    if(i < 16) field[i] &= ~0x8; -    else if((field[i]&0x8) && !(nfield[i-16]&0x4)) field[i] &= ~0x8; -  } -} - -void grow() { -  int i=0; -  memcpy(nfield,field,256); -  for(i=0;i<256;i++) { -    if(random() % 2 == 0) { -      if((field[i]&0x1) && !nfield[i-1] && i%16 != 0) nfield[i-1]=random()%16 | 0x2; -      if((field[i]&0x2) && !nfield[i+1] && i%16 != 15) nfield[i+1]=random()%16 | 0x1; -      if((field[i]&0x4) && !nfield[i+16] && i<240) nfield[i+16]=random()%16 | 0x8; -      if((field[i]&0x8) && !nfield[i-16] && i>16) nfield[i-16]=random()%16 | 0x4; -    } -  } -  memcpy(field,nfield,256); -} - -void dump() { -  int i; -  write(1,field,sizeof(field)); -} - -int main(int argc,char *argv[]) { -  int i; -  int seed=time(0) * getpid(); -  if(argc > 1) { -    seed=atoi(argv[1]); -  } -  srandom(seed); -  field[7+16] = 0x4;//center top -  for(i=0;i<ITERATIONS;i++) { -    if(argc > 2) dump(); -    grow(); -  } -  prune(); -  dump(); -//  fprintf(stderr,"seed: %d\n",seed); -} diff --git a/share/hackvr/examples/editor/editor.sh b/share/hackvr/examples/editor/editor.sh deleted file mode 100755 index e8ae65e..0000000 --- a/share/hackvr/examples/editor/editor.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -cat p | hackvr $USER \ -  | stdbuf -oL tr -s ' ' \ -  | grep --line-buffered "^[^ ][^ ]* action " \ -  | stdbuf -oL cut '-d ' -f3 \ -  | xargs -L1 printf "epoch control %s\n" > p diff --git a/share/hackvr/examples/fib.sh b/share/hackvr/examples/fib.sh deleted file mode 100755 index c1d87ab..0000000 --- a/share/hackvr/examples/fib.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -z=0 -a=1 -b=1 - -for i in $(seq 1 10);do -  if [ $[$i % 2] = 0 ];then -    x=$[$z] -    y=0 -  else -    x=0 -    y=$[$z] -  fi - -  w=$a -  h=$a - -  echo fib_$a addshape 2 4 $x $y 0 $[$x+$w] $y 0 $[$x+$w] $[$y+$h] 0 $x $[$y+$h] 0 -  z=$a -  s=$[$a+$b] -  a=$b -  b=$s - -done diff --git a/share/hackvr/examples/filebrowser/action_to_target.sh b/share/hackvr/examples/filebrowser/action_to_target.sh deleted file mode 100755 index 2abbe58..0000000 --- a/share/hackvr/examples/filebrowser/action_to_target.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -#this script gets the action lines that hackvr outputs and turns them into as normal of a string as possible -#for the backend script to use. -#so hex encoded strings need to be unencoded before they leave here. -#the hex encoded strings don't have a newline at the end. we need to add one. see xargs printf "%s0a" -grep --line-buffered ^USER \ -  | stdbuf -oL cut '-d ' -f2- \ -  | grep --line-buffered ^action \ -  | stdbuf -oL cut '-d ' -f2- \ -  | xargs -L1 printf "%s0a\n" \ -  | stdbuf -oL xxd -r -p diff --git a/share/hackvr/examples/filebrowser/backend-filebrowser.sh b/share/hackvr/examples/filebrowser/backend-filebrowser.sh deleted file mode 100755 index 7fdfc2e..0000000 --- a/share/hackvr/examples/filebrowser/backend-filebrowser.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -#give a list of files. -#wait for a selection on stdin -#cd or start that file -#repeat. -while true;do -#not sure why this needs to be printed to show up every time. -  echo .. -  find . -maxdepth 1 #| tr ' ' '\n' #wut? no? -  read -r selection -  if [ -f "$selection" ];then -    xdg-open "$selection" #good enough? -  fi -  if [ -d "$selection" ];then -    cd "$selection" -  fi -  echo -done diff --git a/share/hackvr/examples/filebrowser/backend-gopher.sh b/share/hackvr/examples/filebrowser/backend-gopher.sh deleted file mode 100755 index fe73755..0000000 --- a/share/hackvr/examples/filebrowser/backend-gopher.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -#give a list of files. -#wait for a selection on stdin -#cd or start that file -#repeat. -server=$1 -${server:="gopher.hacking.allowed.org"} -#gopher.hacking.allowed.org -port=70 -selection=/ -while true;do -#not sure why this needs to be printed to show up every time. -  printf "/\n" -  printf '%s\n' "$selection" | ncat "$server" "$port" | tee /dev/stderr | grep -v ^i | cut -f2 | tr -d '\r' -### need to ask user for input in the form of a pop-up window if the selected target was of type 7 -  read -r selection -  if [ "_" = "_$selection" ];then -   echo "looks like there's nothing here. exiting." >&2 -   exit 1 -  fi -  echo -done diff --git a/share/hackvr/examples/filebrowser/backend-ps.sh b/share/hackvr/examples/filebrowser/backend-ps.sh deleted file mode 100755 index ac1eb47..0000000 --- a/share/hackvr/examples/filebrowser/backend-ps.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -#give a list of files. -#wait for a selection on stdin -#cd or start that file -#repeat. -while true;do -#not sure why this needs to be printed to show up every time. -  ps | tail -n+2 -  read -r selection -  echo $selection -  echo -done diff --git a/share/hackvr/examples/filebrowser/camera.pos b/share/hackvr/examples/filebrowser/camera.pos deleted file mode 100644 index 718923c..0000000 --- a/share/hackvr/examples/filebrowser/camera.pos +++ /dev/null @@ -1,2 +0,0 @@ -USER move 0 0 0 -USER rotate 0 0 0 diff --git a/share/hackvr/examples/filebrowser/frontend-hackvr.sh b/share/hackvr/examples/filebrowser/frontend-hackvr.sh deleted file mode 100755 index ff6264a..0000000 --- a/share/hackvr/examples/filebrowser/frontend-hackvr.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -if [ "_$1" = "_" ];then - echo "I need an argument for what my backend is." >&2 - exit 1 -fi -cat camera.pos <(stdbuf -oL $1 < p | ./list_to_cubes.sh) | hackvr USER | ./action_to_target.sh > p diff --git a/share/hackvr/examples/filebrowser/frontend-zenity.sh b/share/hackvr/examples/filebrowser/frontend-zenity.sh deleted file mode 100755 index 44ae385..0000000 --- a/share/hackvr/examples/filebrowser/frontend-zenity.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -if [ "_$1" = "_" ];then - echo "I need a backend script passed as first argument." >&2 - exit 1 -fi -stdbuf -oL $1 < p | stdbuf -oL tr '\n' ' ' | sed -u 's/$/_/' | stdbuf -oL tr '_' '\n' | xargs -L1 zenity --list --column file > p diff --git a/share/hackvr/examples/filebrowser/list_to_cubes.sh b/share/hackvr/examples/filebrowser/list_to_cubes.sh deleted file mode 100755 index 0dfca06..0000000 --- a/share/hackvr/examples/filebrowser/list_to_cubes.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# blank lines deleteallexcept epoch -# expected input format: -# -# line1 -# line2 -# line3 -# -# line1 -# line2 -j=1 -r=200 -while read -r line;do - if [ "_$line" != '_' ];then -#  ../tools/obj2hackvr.pl "$line" ../meshes/cube.obj -  #turn line into hex to prevent stupid shit -  hexline="$(printf "%s" "$line" | xxd -p | tr -d '\n')" -  printf "%s addshape 18 3 8 %d %d 0 %d %d 0 %d %d\n" "$hexline" "$j" "$r" "$[$j+8]" "$r" "$j" "$r" -  cd .. -  printf "%s\n" "$line" | tee /dev/stderr | makelabel.sh "$hexline" 15 $j $r -  cd filebrowser -  #printf "%s move 0 %d %d 0 0 0 0 0 0\n" "$hexline" "$i" "$r" -  printf "%s rotate 0 %d 0\n" "$hexline" "$[i * 3]" -  #somehow printf '%s\n' "$line" | ./testfont.sh and make its output belong to same group as $line.. sed? -  i=$[i+10] -  j=$[j+4] - else -  cat camera.pos -  printf "USER deleteallexcept USER\n" #deleteallexcept doesn't have gr deletions yet I think. -  j=0 -  i=0 - fi -done diff --git a/share/hackvr/examples/filebrowser/run b/share/hackvr/examples/filebrowser/run deleted file mode 100755 index cc5a9df..0000000 --- a/share/hackvr/examples/filebrowser/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -cd "$(dirname "$0")" -./frontend-hackvr.sh ./backend-gopher.sh $1 diff --git a/share/hackvr/examples/grid_floor.sh b/share/hackvr/examples/grid_floor.sh deleted file mode 100755 index 452163f..0000000 --- a/share/hackvr/examples/grid_floor.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -cat <(for i in $(seq 1 32);do -        for j in $(seq 1 32);do -          echo floor addshape 2 4 $i 0 $j $i 0 $[j+1] $[i+1] 0 $[j+1] $[i+1] 0 $j -#          echo floor addshape 2 4 $i 0 $j $[i+1] 0 $j $[i+1] 0 $[j+1] $i 0 $[j+1] -        done -      done) \ -    <(echo -e "floor scaleup 8\nepoch export floor\nepoch quit\n") \ - | hackvr_headless $USER \ - | sed "s/\.0*//g" diff --git a/share/hackvr/examples/hackvr_term/Makefile b/share/hackvr/examples/hackvr_term/Makefile deleted file mode 100644 index fb33227..0000000 --- a/share/hackvr/examples/hackvr_term/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -.PHONY: all clean install uninstall - -all: hackvr_term - -hackvr_term.o: CFLAGS=-pedantic -Wall -libtmt/tmt.o: CFLAGS=-pedantic - -hackvr_term: hackvr_term.o libtmt/tmt.o - -clean: -	rm *.o -	rm */*.o -	rm hackvr_term - -install: -	install hackvr_term $(PREFIX)/bin/hackvr_term - -uninstall: -	[ -e $(PREFIX)/bin/hackvr_term ] && rm -i $(PREFIX)/bin/hackvr_term || echo "nothing to uninstall" diff --git a/share/hackvr/examples/hackvr_term/camera.pos b/share/hackvr/examples/hackvr_term/camera.pos deleted file mode 100644 index df832fd..0000000 --- a/share/hackvr/examples/hackvr_term/camera.pos +++ /dev/null @@ -1,4 +0,0 @@ -USER move 250 -140 -300 -#these two lines are for when I want a screenshot of the terminal rotated so I can take pretty screeshots -#USER move 315 -125 -285 -#USER rotate 0 -5 0 diff --git a/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh b/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh deleted file mode 100755 index 85c64af..0000000 --- a/share/hackvr/examples/hackvr_term/hackvr_data_decode.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail -exec grep --line-buffered '^[^ ]* data ' | stdbuf -oL tr -s ' ' | stdbuf -oL cut '-d ' -f3- | stdbuf -o0 xxd -r -p diff --git a/share/hackvr/examples/hackvr_term/hackvr_term b/share/hackvr/examples/hackvr_term/hackvr_termBinary files differ deleted file mode 100755 index d2fb6d2..0000000 --- a/share/hackvr/examples/hackvr_term/hackvr_term +++ /dev/null diff --git a/share/hackvr/examples/hackvr_term/hackvr_term.c b/share/hackvr/examples/hackvr_term/hackvr_term.c deleted file mode 100644 index b044498..0000000 --- a/share/hackvr/examples/hackvr_term/hackvr_term.c +++ /dev/null @@ -1,184 +0,0 @@ -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <limits.h> //PATH_MAX -#include "libtmt/tmt.h" - -//these numbers include the space between characters -//apple401 font is this wide: -//#define FONTW 14 -//#define FONTH 16 - -//epoch font is this wide: -#define FONTW 6 -#define FONTH 10 - -//////////////////////////////////// hey. you can do some config here. either preload glyphs or re-read font file each time. -//comment out the next line if you want what is probably the slow version. might be safer and use less memory though. -//maybe just put the font file in ram. linux caches that crap anyway, right? -//testing showed preloading was at least 10x faster. -#define PRELOAD_GLYPHS -//only 8-bit characters atm. -//and we'll need to malloc the amount of lines each character will have. -//and malloc each line in that glyph... -//or just set it statically. - -#ifdef PRELOAD_GLYPHS - -#define MAXCHARACTER 256 -#define MAXLINESPERGLYPH 16 -#define MAXCHARSPERGLYPHLINE 256 -char glyphs[MAXCHARACTER][MAXLINESPERGLYPH][MAXCHARSPERGLYPHLINE]; - -char font_file[PATH_MAX]; - -void preload_glyphs() { -  char line[MAXCHARSPERGLYPHLINE];//tmp storage -  FILE *fp; -  int charN; -  int i; -  for(i=0;i<MAXCHARACTER;i++) { -   glyphs[i][0][0]=0;//zero out the first byte of the first line of every glyph. we'll mark the end if we actually read something -  } -  if((fp=fopen(font_file,"r")) == NULL) { -    fprintf(stderr,"hackvr_term: failed to open font file: %s\n",font_file); -    exit(1); -  } -  for(i=0;fgets(line,sizeof(line)-1,fp) != 0;i++) { -    if(charN != strtol(line,0,16)) { -     i=0; -     charN=strtol(line,0,16); -    } -    strcpy(glyphs[charN][i],line); -    glyphs[charN][i+1][0]=0;//mark the end here. if we do it inside the conditional it won't mark the last one. -  } -  fclose(fp); -} - -void hackvr_draw_character(int c,int r,const TMTCHAR *ch) { -  char *line; -  int i,ret=0; -  //printf("term_%02d_%02d addshape %d 4  -1 -3 0  5 -3 0  5 7 0  -1 7 0\n",c,r,ch->a.bg+15); -  for(i=0,line=glyphs[ch->c][0];line[0];i++,line=glyphs[ch->c][i]) { -    ret=1; -    printf("term_%02d_%02d addshape %d %s",c,r,ch->a.fg == -1 ? 17 : ch->a.fg + 15,line+strlen("XX addshape X")); -  } -  if(ret) {//if we drew something we should place it somewhere. -    printf("term_%02d_%02d move %d %d 0\n",c,r,c*FONTW,-r*FONTH); -  } -} - -#else - -void hackvr_draw_character(int c,int r,const TMTCHAR *ch) {//this is slow but allows you to change the font between each character... if you really wanted that. - int i; - FILE *fp; - char str[16]; - char line[256];//whatever - if(ch->c < 128) { -  snprintf(str,sizeof(str)-1,"%02lx",ch->c); - } else { -  snprintf(str,sizeof(str)-1,"%08lx",ch->c); - } - if((fp=fopen(font_file,"r")) == NULL ) { -  fprintf(stderr,"# fail to open font\n"); -  exit(1); - } - printf("term_%02d_%02d addshape %d 4  -1 -3 0  5 -3 0  5 7 0  -1 7 0\n",c,r,ch->a.bg+15); - for(i=0;fgets(line,sizeof(line)-1,fp) != 0;i++) { -  if(!strncmp(str,line,2)) { -   printf("term_%02d_%02d addshape %d %s",c,r,ch->a.fg==-1?2:ch->a.fg+15,line+strlen("XX addshape X ")); -  } - } - if(i) printf("term_%02d_%02d move %d %d 0\n",c,r,c*FONTW,-r*FONTH); - fclose(fp); -} - -#endif - -void callback(tmt_msg_t m,TMT *vt, const void *a,void *vt_old) { - static int cr_old=0; - static int cc_old=0; - const TMTSCREEN *s_old=tmt_screen(vt_old); - const TMTSCREEN *s=tmt_screen(vt); - const TMTPOINT *c=tmt_cursor(vt); - const TMTCHAR *ch; - switch(m) { -  case TMT_MSG_BELL: -   printf("term set global.beep\n"); -   break; -  case TMT_MSG_UPDATE: -   for (size_t r = 0; r < s->nline; r++){ -    if (s->lines[r]->dirty){ -     for (size_t c = 0; c < s->ncol; c++){ -      if(memcmp(&(s->lines[r]->chars[c]),&(s_old->lines[r]->chars[c]),sizeof(TMTCHAR))) { -       ch=&(s->lines[r]->chars[c]); -       printf("term_%02d_%02d deletegroup term_%02d_%02d\n",c,r,c,r); -       hackvr_draw_character(c,r,ch); -       memcpy(&(s_old->lines[r]->chars[c]),&(s->lines[r]->chars[c]),sizeof(TMTCHAR)); -      } -     } -    } -   } -   break; -  case TMT_MSG_ANSWER://what does this do? -   fprintf(stderr,"ANSWER: %s\n",(const char *)a); -   break; -  case TMT_MSG_MOVED: -   printf("cursor move %d %d 0\n", (c->c - cc_old) * 5, - (c->r - cr_old) * 9);//calculate relative movement needed based on previous and current positions. -   cr_old=c->r; -   cc_old=c->c; -   break; -  case TMT_MSG_CURSOR: -   if(!strcmp(a,"t")) { -    printf("cursor deletegroup cursor\n");//just delete it and redraw the cursor. -    printf("cursor addshape 2 4  0 -2 0  4 -2 0  4 6 0  0 6 0\n");//let's pretend this is how cursors should be. -    printf("cursor move %d %d 0\n",c->c * 5,-c->r * 9); -   } -   if(!strcmp(a,"f")) { -    printf("cursor deletegroup cursor\n"); -    cr_old=0; -    cc_old=0; -   } -   break; -  default: -   fprintf(stderr,"unhandled message type: %d\n",m); - } - return; -} - -int main(int argc,char *argv[]) { - char in[16]; - if(argc < 3) return fprintf(stderr,"usage: ./hackvr_term cols rows\n"),1; - int r=atoi(argv[2]); - int ret=0; - int c=atoi(argv[1]); - if(!getenv("PREFIX")) { -  fprintf(stderr,"hackvr_term: PREFIX is not set. I dunno where to find my fonts.\n"); -  return 1; - } - snprintf(font_file,sizeof(font_file)-1,"%s/share/hackvr/font/default.hackvr",getenv("PREFIX")); -#ifdef PRELOAD_GLYPHS - printf("# hackvr_term: preloading glyphs\n"); - preload_glyphs();//will exit on error - printf("# hackvr_term: done.\n"); -#endif - setbuf(stdin,0); - setbuf(stdout,0); - TMT *vt_old = tmt_open(r,c,NULL,NULL,NULL); - if(!vt_old) return fprintf(stderr,"failed to open tmt's virtual terminal for storage"),1; - TMT *vt = tmt_open(r,c,callback,vt_old,NULL); - if(!vt) return fprintf(stderr,"failed to open tmt's virtual terminal"),1; - //read from stdin and write to terminal. - while((ret=read(0,in,16)) != 0) {//16 bytes at a time work? -  if(ret == -1) { -   if(errno == EAGAIN) continue; -   break; -  } -  tmt_write(vt,in,ret); - } - tmt_close(vt); - return 0; -} diff --git a/share/hackvr/examples/hackvr_term/libtmt/README.rst b/share/hackvr/examples/hackvr_term/libtmt/README.rst deleted file mode 100644 index f3819df..0000000 --- a/share/hackvr/examples/hackvr_term/libtmt/README.rst +++ /dev/null @@ -1,637 +0,0 @@ - -============================================ -libtmt - a simple terminal emulation library -============================================ - -libtmt is the Tiny Mock Terminal Library.  It provides emulation of a classic -smart text terminal, by maintaining an in-memory screen image.  Sending text -and command sequences to libtmt causes it to update this in-memory image, -which can then be examined and rendered however the user sees fit. - -The imagined primary goal for libtmt is to for terminal emulators and -multiplexers; it provides the terminal emulation layer for the `mtm`_ -terminal multiplexer, for example. Other uses include screen-scraping and -automated test harnesses. - -libtmt is similar in purpose to `libtsm`_, but considerably smaller (500 -lines versus 6500 lines). libtmt is also, in this author's humble opinion, -considerably easier to use. - -.. _`mtm`: https://github.com/deadpixi/mtm -.. _`libtsm`: https://www.freedesktop.org/wiki/Software/kmscon/libtsm/ - -Major Features and Advantages -============================= - -Works Out-of-the-Box -    libtmt emulates a well-known terminal type (`ansi`), the definition of -    which has been in the terminfo database since at least 1995.  There's no -    need to install a custom terminfo entry.  There's no claiming to be an -    xterm but only emulating a small subset of its features. Any program -    using terminfo works automatically: this includes vim, emacs, mc, -    cmus, nano, nethack, ... - -Portable -    Written in pure C99. -    Optionally, the POSIX-mandated `wcwidth` function can be used, which -    provides minimal support for combining characters. - -Small -    Less than 500 lines of C, including comments and whitespace. - -Free -    Released under a BSD-style license, free for commercial and -    non-commerical use, with no restrictions on source code release or -    redistribution. - -Simple -    Only 8 functions to learn, and really you can get by with 6! - -International -    libtmt internally uses wide characters exclusively, and uses your C -    library's multibyte encoding functions. -    This means that the library automatically supports any encoding that -    your operating system does. - -How to Use libtmt -================= - -libtmt is a single C file and a single header.  Just include these files -in your project and you should be good to go. - -By default, libtmt uses only ISO standard C99 features, -but see `Compile-Time Options`_ below. - -Example Code ------------- - -Below is a simple program fragment giving the flavor of libtmt. -Note that another good example is the `mtm`_ terminal multiplexer: - -.. _`mtm`: https://github.com/deadpixi/mtm - -.. code:: c - -    #include <stdio.h> -    #include <stdlib.h> -    #include "tmt.h" - -    /* Forward declaration of a callback. -     * libtmt will call this function when the terminal's state changes. -     */ -    void callback(tmt_msg_t m, TMT *vt, const void *a, void *p); - -    int -    main(void) -    { -        /* Open a virtual terminal with 2 lines and 10 columns. -         * The first NULL is just a pointer that will be provided to the -         * callback; it can be anything. The second NULL specifies that -         * we want to use the default Alternate Character Set; this -         * could be a pointer to a wide string that has the desired -         * characters to be displayed when in ACS mode. -         */ -        TMT *vt = tmt_open(2, 10, callback, NULL, NULL); -        if (!vt) -            return perror("could not allocate terminal"), EXIT_FAILURE; - -        /* Write some text to the terminal, using escape sequences to -         * use a bold rendition. -         * -         * The final argument is the length of the input; 0 means that -         * libtmt will determine the length dynamically using strlen. -         */ -        tmt_write(vt, "\033[1mhello, world (in bold!)\033[0m", 0); - -        /* Writing input to the virtual terminal can (and in this case, did) -         * call the callback letting us know the screen was updated. See the -         * callback below to see how that works. -         */ -        tmt_close(vt); -        return EXIT_SUCCESS; -    } - -    void -    callback(tmt_msg_t m, TMT *vt, const void *a, void *p) -    { -        /* grab a pointer to the virtual screen */ -        const TMTSCREEN *s = tmt_screen(vt); -        const TMTPOINT *c = tmt_cursor(vt); - -        switch (m){ -            case TMT_MSG_BELL: -                /* the terminal is requesting that we ring the bell/flash the -                 * screen/do whatever ^G is supposed to do; a is NULL -                 */ -                printf("bing!\n"); -                break; - -            case TMT_MSG_UPDATE: -                /* the screen image changed; a is a pointer to the TMTSCREEN */ -                for (size_t r = 0; r < s->nline; r++){ -                    if (s->lines[r]->dirty){ -                        for (size_t c = 0; c < s->ncol; c++){ -                            printf("contents of %zd,%zd: %lc (%s bold)\n", r, c, -                                   s->lines[r]->chars[c].c, -                                   s->lines[r]->chars[c].a.bold? "is" : "is not"); -                        } -                    } -                } - -                /* let tmt know we've redrawn the screen */ -                tmt_clean(vt); -                break; - -            case TMT_MSG_ANSWER: -                /* the terminal has a response to give to the program; a is a -                 * pointer to a string */ -                printf("terminal answered %s\n", (const char *)a); -                break; - -            case TMT_MSG_MOVED: -                /* the cursor moved; a is a pointer to the cursor's TMTPOINT */ -                printf("cursor is now at %zd,%zd\n", c->r, c->c); -                break; -        } -    } - -Data Types and Enumerations ---------------------------- - -.. code:: c - -    /* an opaque structure */ -    typedef struct TMT TMT; - -    /* possible messages sent to the callback */ -    typedef enum{ -        TMT_MSG_MOVED,  /* the cursor changed position       */ -        TMT_MSG_UPDATE, /* the screen image changed          */ -        TMT_MSG_ANSWER, /* the terminal responded to a query */ -        TMT_MSG_BELL    /* the terminal bell was rung        */ -    } tmt_msg_T; - -    /* a callback for the library -     * m is one of the message constants above -     * vt is a pointer to the vt structure -     * r is NULL for TMT_MSG_BELL -     *   is a pointer to the cursor's TMTPOINT for TMT_MSG_MOVED -     *   is a pointer to the terminal's TMTSCREEN for TMT_MSG_UPDATE -     *   is a pointer to a string for TMT_MSG_ANSWER -     * p is whatever was passed to tmt_open (see below). -     */ -    typedef void (*TMTCALLBACK)(tmt_msg_t m, struct TMT *vt, -                                const void *r, void *p); - -    /* color definitions */ -    typedef enum{ -        TMT_COLOR_BLACK, -        TMT_COLOR_RED, -        TMT_COLOR_GREEN, -        TMT_COLOR_YELLOW, -        TMT_COLOR_BLUE, -        TMT_COLOR_MAGENTA, -        TMT_COLOR_CYAN, -        TMT_COLOR_WHITE, -        TMT_COLOR_DEFAULT /* whatever the host terminal wants it to mean */ -    } tmt_color_t; - -    /* graphical rendition */ -    typedef struct TMTATTRS TMTATTRS; -    struct TMTATTRS{ -        bool bold;      /* character is bold             */ -        bool dim;       /* character is half-bright      */ -        bool underline; /* character is underlined       */ -        bool blink;     /* character is blinking         */ -        bool reverse;   /* character is in reverse video */ -        bool invisible; /* character is invisible        */ -        tmt_color_t fg; /* character foreground color    */ -        tmt_color_t bg; /* character background color    */ -    }; - -    /* characters */ -    typedef struct TMTCHAR TMTCHAR; -    struct TMTCHAR{ -        wchar_t  c; /* the character */ -        TMTATTRS a; /* its rendition */ -    }; - -    /* a position on the screen; upper left corner is 0,0 */ -    typedef struct TMTPOINT TMTPOINT; -    struct TMTPOINT{ -        size_t r; /* row    */ -        size_t c; /* column */ -    }; - -    /* a line of characters on the screen; -     * every line is always as wide as the screen -     */ -    typedef struct TMTLINE TMTLINE; -    struct TMTLINE{ -        bool dirty;     /* line has changed since it was last drawn */ -        TMTCHAR chars;  /* the contents of the line                 */ -    }; - -    /* a virtual terminal screen image */ -    typedef struct TMTSCREEN TMTSCREEN; -    struct TMTSCREEN{ -        size_t nline;    /* number of rows          */ -        size_t ncol;     /* number of columns       */ -        TMTLINE **lines; /* the lines on the screen */ -    }; - -Functions ---------- - -`TMT *tmt_open(size_t nrows, size_t ncols, TMTCALLBACK cb, VOID *p, const wchar *acs);` -    Creates a new virtual terminal, with `nrows` rows and `ncols` columns. -    The callback `cb` will be called on updates, and passed `p` as a final -    argument. See the definition of `tmt_msg_t` above for possible values -    of each argument to the callback. - -    Terminals must have a size of at least two rows and two columns. - -    `acs` specifies the characters to use when in Alternate Character Set -    (ACS) mode. The default string (used if `NULL` is specified) is:: - -         L"><^v#+:o##+++++~---_++++|<>*!fo" - -    See `Alternate Character Set`_ for more information. - -    Note that the callback must be ready to be called immediately, as -    it will be called after initialization of the terminal is done, but -    before the call to `tmt_open` returns. - -`void tmt_close(TMT *vt)` -    Close and free all resources associated with `vt`. - -`bool tmt_resize(TMT *vt, size_t nrows, size_t ncols)` -    Resize the virtual terminal to have `nrows` rows and `ncols` columns. -    The contents of the area in common between the two sizes will be preserved. - -    Terminals must have a size of at least two rows and two columns. - -    If this function returns false, the resize failed (only possible in -    out-of-memory conditions or invalid sizes). If this happens, the terminal -    is trashed and the only valid operation is the close the terminal. - -`void tmt_write(TMT *vt, const char *s, size_t n);` -    Write the provided string to the terminal, interpreting any escape -    sequences contained threin, and update the screen image. The last -    argument is the length of the input. If set to 0, the length is -    determined using `strlen`. - -    The terminal's callback function may be invoked one or more times before -    a call to this function returns. - -    The string is converted internally to a wide-character string using the -    system's current multibyte encoding. Each terminal maintains a private -    multibyte decoding state, and correctly handles mulitbyte characters that -    span multiple calls to this function (that is, the final byte(s) of `s` -    may be a partial mulitbyte character to be completed on the next call). - -`const TMTSCREEN *tmt_screen(const TMT *vt);` -    Returns a pointer to the terminal's screen image. - -`const TMTPOINT *tmt_cursor(cosnt TMT *vt);` -    Returns a pointer to the terminal's cursor position. - -`void tmt_clean(TMT *vt);` -    Call this after receiving a `TMT_MSG_UPDATE` or `TMT_MSG_MOVED` callback -    to let the library know that the program has handled all reported changes -    to the screen image. - -`void tmt_reset(TMT *vt);` -    Resets the virtual terminal to its default state (colors, multibyte -    decoding state, rendition, etc). - -Special Keys ------------- - -To send special keys to a program that is using libtmt for its display, -write one of the `TMT_KEY_*` strings to that program's standard input -(*not* to libtmt; it makes no sense to send any of these constants to -libtmt itself). - -The following macros are defined, and are all constant strings: - -- TMT_KEY_UP -- TMT_KEY_DOWN -- TMT_KEY_RIGHT -- TMT_KEY_LEFT -- TMT_KEY_HOME -- TMT_KEY_END -- TMT_KEY_INSERT -- TMT_KEY_BACKSPACE -- TMT_KEY_ESCAPE -- TMT_KEY_BACK_TAB -- TMT_KEY_PAGE_UP -- TMT_KEY_PAGE_DOWN -- TMT_KEY_F1 through TMT_KEY_F10 - -Note also that the classic PC console sent the enter key as -a carriage return, not a linefeed. Many programs don't care, -but some do. - -Compile-Time Options --------------------- - -There are two preprocessor macros that affect libtmt: - -`TMT_INVALID_CHAR` -    Define this to a wide-character. This character will be added to -    the virtual display when an invalid multibyte character sequence -    is encountered. - -    By default (if you don't define it as something else before compiling), -    this is `((wchar_t)0xfffd)`, which is the codepoint for the Unicode -    'REPLACEMENT CHARACTER'. Note that your system might not use Unicode, -    and its wide-character type might not be able to store a constant as -    large as `0xfffd`, in which case you'll want to use an alternative. - -`TMT_HAS_WCWIDTH` -    By default, libtmt uses only standard C99 features.  If you define -    TMT_HAS_WCWIDTH before compiling, libtmt will use the POSIX `wcwidth` -    function to detect combining characters. - -    Note that combining characters are still not handled particularly -    well, regardless of whether this was defined. Also note that what -    your C library's `wcwidth` considers a combining character and what -    the written language in question considers one could be different. - -Alternate Character Set ------------------------ - -The terminal can be switched to and from its "Alternate Character Set" (ACS) -using escape sequences. The ACS traditionally contained box-drawing and other -semigraphic characters. - -The characters in the ACS are configurable at runtime, by passing a wide string -to `tmt_open`. The default if none is provided (i.e. the argument is `NULL`) -uses ASCII characters to approximate the traditional characters. - -The string passed to `tmt_open` must be 31 characters long. The characters, -and their default ASCII-safe values, are in order: - -- RIGHT ARROW ">" -- LEFT ARROW "<" -- UP ARROW "^" -- DOWN ARROW "v" -- BLOCK "#" -- DIAMOND "+" -- CHECKERBOARD "#" -- DEGREE "o" -- PLUS/MINUS "+" -- BOARD ":" -- LOWER RIGHT CORNER "+" -- UPPER RIGHT CORNER "+" -- UPPER LEFT CORNER "+" -- LOWER LEFT CORNER "+" -- CROSS "+" -- SCAN LINE 1 "~" -- SCAN LINE 3 "-" -- HORIZONTAL LINE "-" -- SCAN LINE 7 "-" -- SCAN LINE 9 "_" -- LEFT TEE "+" -- RIGHT TEE "+" -- BOTTOM TEE "+" -- TOP TEE "+" -- VERTICAL LINE "|" -- LESS THAN OR EQUAL "<" -- GREATER THAN OR EQUAL ">" -- PI "*" -- NOT EQUAL "!" -- POUND STERLING "f" -- BULLET "o" - -If your system's wide character type's character set corresponds to the -Universal Character Set (UCS/Unicode), the following wide string is a -good option to use:: - -    L"→←↑↓■◆▒°±▒┘┐┌└┼⎺───⎽├┤┴┬│≤≥π≠£•" - -**Note that multibyte decoding is disabled in ACS mode.** The traditional -implementations of the "ansi" terminal type (i.e. IBM PCs and compatibles) -had no concept of multibyte encodings and used the character codes -outside the ASCII range for various special semigraphic characters. -(Technically they had an entire alternate character set as well via the -code page mechanism, but that's beyond the scope of this explanation.) - -The end result is that the terminfo definition of "ansi" sends characters -with the high bit set when in ACS mode. This breaks several multibyte -encoding schemes (including, most importantly, UTF-8). - -As a result, libtmt does not attempt to decode multibyte characters in -ACS mode, since that would break the multibyte encoding, the semigraphic -characters, or both. - -In general this isn't a problem, since programs explicitly switch to and -from ACS mode using escape sequences. - -When in ACS mode, bytes that are not special members of the alternate -character set (that is, bytes not mapped to the string provided to -`tmt_open`) are passed unchanged to the terminal. - -Supported Input and Escape Sequences -==================================== - -Internally libtmt uses your C library's/compiler's idea of a wide character -for all characters, so you should be able to use whatever characters you want -when writing to the virtual terminal (but see `Alternate Character Set`_). - -The following escape sequences are recognized and will be processed -specially. - -In the descriptions below, "ESC" means a literal escape character and "Ps" -means zero or more decimal numeric arguments separated by semicolons. -In descriptions "P1", "P2", etc, refer to the first parameter, second -parameter, and so on.  If a required parameter is omitted, it defaults -to the smallest meaningful value (zero if the command accepts zero as -an argument, one otherwise).  Any number of parameters may be passed, -but any after the first eight are ignored. - -Unless explicitly stated below, cursor motions past the edges of the screen -are ignored and do not result in scrolling.  When characters are moved, -the spaces left behind are filled with blanks and any characters moved -off the edges of the screen are lost. - -======================  ====================================================================== -Sequence                Action -======================  ====================================================================== -0x07 (Bell)             Callback with TMT_MSG_BELL -0x08 (Backspace)        Cursor left one cell -0x09 (Tab)              Cursor to next tab stop or end of line -0x0a (Carriage Return)  Cursor to first cell on this line -0x0d (Linefeed)         Cursor to same column one line down, scroll if needed -ESC H                   Set a tabstop in this column -ESC 7                   Save cursor position and current graphical state -ESC 8                   Restore saved cursor position and current graphical state -ESC c                   Reset terminal to default state -ESC [ Ps A              Cursor up P1 rows -ESC [ Ps B              Cursor down P1 rows -ESC [ Ps C              Cursor right P1 columns -ESC [ Ps D              Cursor left P1 columns -ESC [ Ps E              Cursor to first column of line P1 rows down from current -ESC [ Ps F              Cursor to first column of line P1 rows up from current -ESC [ Ps G              Cursor to column P1 -ESC [ Ps d              Cursor to row P1 -ESC [ Ps H              Cursor to row P1, column P2 -ESC [ Ps f              Alias for ESC [ Ps H -ESC [ Ps I              Cursor to next tab stop -ESC [ Ps J              Clear screen -                        P1 == 0: from cursor to end of screen -                        P1 == 1: from beginning of screen to cursor -                        P1 == 2: entire screen -ESC [ Ps K              Clear line -                        P1 == 0: from cursor to end of line -                        P1 == 1: from beginning of line to cursor -                        P1 == 2: entire line -ESC [ Ps L              Insert P1 lines at cursor, scrolling lines below down -ESC [ Ps M              Delete P1 lines at cursor, scrolling lines below up -ESC [ Ps P              Delete P1 characters at cursor, moving characters to the right over -ESC [ Ps S              Scroll screen up P1 lines -ESC [ Ps T              Scroll screen down P1 lines -ESC [ Ps X              Erase P1 characters at cursor (overwrite with spaces) -ESC [ Ps Z              Go to previous tab stop -ESC [ Ps b              Repeat previous character P1 times -ESC [ Ps c              Callback with TMT_MSG_ANSWER "\033[?6c" -ESC [ Ps g              If P1 == 3, clear all tabstops -ESC [ Ps h              If P1 == 25, show the cursor (if it was hidden) -ESC [ Ps m              Change graphical rendition state; see below -ESC [ Ps l              If P1 == 25, hide the cursor -ESC [ Ps n              If P1 == 6, callback with TMT_MSG_ANSWER "\033[%d;%dR" -                        with cursor row, column -ESC [ Ps s              Alias for ESC 7 -ESC [ Ps u              Alias for ESC 8 -ESC [ Ps @              Insert P1 blank spaces at cursor, moving characters to the right over -======================  ====================================================================== - -For the `ESC [ Ps m` escape sequence above ("Set Graphic Rendition"), -up to eight parameters may be passed; the results are cumulative: - -==============   ================================================= -Rendition Code   Meaning -==============   ================================================= -0                Reset all graphic rendition attributes to default -1                Bold -2                Dim (half bright) -4                Underline -5                Blink -7                Reverse video -8                Invisible -10               Leave ACS mode -11               Enter ACS mode -22               Bold off -23               Dim (half bright) off -24               Underline off -25               Blink off -27               Reverse video off -28               Invisible off -30               Foreground black -31               Foreground red -32               Foreground green -33               Foreground yellow -34               Foreground blue -35               Foreground magenta -36               Foreground cyan -37               Foreground white -39               Foreground default color -40               Background black -41               Background red -42               Background green -43               Background yellow -44               Background blue -45               Background magenta -46               Background cyan -47               Background white -49               Background default color -==============   ================================================= - -Other escape sequences are recognized but ignored.  This includes escape -sequences for switching out codesets (officially, all code sets are defined -as equivalent in libtmt), and the various "Media Copy" escape sequences -used to print output on paper (officially, there is no printer attached -to libtmt). - -Additionally, "?" characters are stripped out of escape sequence parameter -lists for compatibility purposes. - -Known Issues -============ - -- Combining characters are "handled" by ignoring them -  (when compiled with `TMT_HAS_WCWIDTH`) or by printing them separately. -- Double-width characters are rendered as single-width invalid -  characters. -- The documentation and error messages are available only in English. - -Frequently Asked Questions -========================== - -What programs work with libtmt? -------------------------------- - -Pretty much all of them.  Any program that doesn't assume what terminal -it's running under should work without problem; this includes any program -that uses the terminfo, termcap, or (pd|n)?curses libraries.  Any program -that assumes it's running under some specific terminal might fail if its -assumption is wrong, and not just under libtmt. - -I've tested quite a few applications in libtmt and they've worked flawlessly: -vim, GNU emacs, nano, cmus, mc (Midnight Commander), and others just work -with no changes. - -What programs don't work with libtmt? -------------------------------------- - -Breakage with libtmt is of two kinds: breakage due to assuming a terminal -type, and reduced functionality. - -In all my testing, I only found one program that didn't work correctly by -default with libtmt: recent versions of Debian's `apt`_ assume a terminal -with definable scrolling regions to draw a fancy progress bar during -package installation.  Using apt in its default configuration in libtmt will -result in a corrupted display (that can be fixed by clearing the screen). - -.. _`apt`: https://wiki.debian.org/Apt - -In my honest opinion, this is a bug in apt: it shouldn't assume the type -of terminal it's running in. - -The second kind of breakage is when not all of a program's features are -available.  The biggest missing feature here is mouse support: libtmt -doesn't, and probably never will, support mouse tracking.  I know of many -programs that *can* use mouse tracking in a terminal, but I don't know -of any that *require* it.  Most (if not all?) programs of this kind would -still be completely usable in libtmt. - -License -------- - -Copyright (c) 2017 Rob King -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright -  notice, this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright -  notice, this list of conditions and the following disclaimer in the -  documentation and/or other materials provided with the distribution. -- Neither the name of the copyright holder nor the -  names of contributors may be used to endorse or promote products -  derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, -COPYRIGHT HOLDERS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/share/hackvr/examples/hackvr_term/libtmt/tmt.c b/share/hackvr/examples/hackvr_term/libtmt/tmt.c deleted file mode 100644 index 26c122e..0000000 --- a/share/hackvr/examples/hackvr_term/libtmt/tmt.c +++ /dev/null @@ -1,500 +0,0 @@ -/* Copyright (c) 2017 Rob King - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - *   * Redistributions of source code must retain the above copyright - *     notice, this list of conditions and the following disclaimer. - *   * Redistributions in binary form must reproduce the above copyright - *     notice, this list of conditions and the following disclaimer in the - *     documentation and/or other materials provided with the distribution. - *   * Neither the name of the copyright holder nor the - *     names of contributors may be used to endorse or promote products - *     derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, - * COPYRIGHT HOLDERS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include <limits.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "tmt.h" - -#define BUF_MAX 100 -#define PAR_MAX 8 -#define TAB 8 -#define MAX(x, y) (((size_t)(x) > (size_t)(y)) ? (size_t)(x) : (size_t)(y)) -#define MIN(x, y) (((size_t)(x) < (size_t)(y)) ? (size_t)(x) : (size_t)(y)) -#define CLINE(vt) (vt)->screen.lines[MIN((vt)->curs.r, (vt)->screen.nline - 1)] - -#define P0(x) (vt->pars[x]) -#define P1(x) (vt->pars[x]? vt->pars[x] : 1) -#define CB(vt, m, a) ((vt)->cb? (vt)->cb(m, vt, a, (vt)->p) : (void)0) -#define INESC ((vt)->state) - -#define COMMON_VARS             \ -    TMTSCREEN *s = &vt->screen; \ -    TMTPOINT *c = &vt->curs;    \ -    TMTLINE *l = CLINE(vt);     \ -    TMTCHAR *t = vt->tabs->chars - -#define HANDLER(name) static void name (TMT *vt) { COMMON_VARS;  - -struct TMT{ -    TMTPOINT curs, oldcurs; -    TMTATTRS attrs, oldattrs; - -    bool dirty, acs, ignored; -    TMTSCREEN screen; -    TMTLINE *tabs; - -    TMTCALLBACK cb; -    void *p; -    const wchar_t *acschars; - -    mbstate_t ms; -    size_t nmb; -    char mb[BUF_MAX + 1]; - -    size_t pars[PAR_MAX];    -    size_t npar; -    size_t arg; -    enum {S_NUL, S_ESC, S_ARG} state; -}; - -static TMTATTRS defattrs = {.fg = TMT_COLOR_DEFAULT, .bg = TMT_COLOR_DEFAULT}; -static void writecharatcurs(TMT *vt, wchar_t w); - -static wchar_t -tacs(const TMT *vt, unsigned char c) -{ -    /* The terminfo alternate character set for ANSI. */ -    static unsigned char map[] = {0020U, 0021U, 0030U, 0031U, 0333U, 0004U, -                                  0261U, 0370U, 0361U, 0260U, 0331U, 0277U, -                                  0332U, 0300U, 0305U, 0176U, 0304U, 0304U, -                                  0304U, 0137U, 0303U, 0264U, 0301U, 0302U, -                                  0263U, 0363U, 0362U, 0343U, 0330U, 0234U, -                                  0376U}; -    for (size_t i = 0; i < sizeof(map); i++) if (map[i] == c) -        return vt->acschars[i]; -    return (wchar_t)c; -} - -static void -dirtylines(TMT *vt, size_t s, size_t e) -{ -    vt->dirty = true; -    for (size_t i = s; i < e; i++) -        vt->screen.lines[i]->dirty = true; -} - -static void -clearline(TMT *vt, TMTLINE *l, size_t s, size_t e) -{ -    vt->dirty = l->dirty = true; -    for (size_t i = s; i < e && i < vt->screen.ncol; i++){ -        l->chars[i].a = defattrs; -        l->chars[i].c = L' '; -    } -} - -static void -clearlines(TMT *vt, size_t r, size_t n) -{ -    for (size_t i = r; i < r + n && i < vt->screen.nline; i++) -        clearline(vt, vt->screen.lines[i], 0, vt->screen.ncol); -} - -static void -scrup(TMT *vt, size_t r, size_t n) -{ -    n = MIN(n, vt->screen.nline - 1 - r); - -    if (n){ -        TMTLINE *buf[n]; - -        memcpy(buf, vt->screen.lines + r, n * sizeof(TMTLINE *)); -        memmove(vt->screen.lines + r, vt->screen.lines + r + n, -                (vt->screen.nline - n - r) * sizeof(TMTLINE *)); -        memcpy(vt->screen.lines + (vt->screen.nline - n), -               buf, n * sizeof(TMTLINE *)); - -        clearlines(vt, vt->screen.nline - n, n); -        dirtylines(vt, r, vt->screen.nline); -    } -} - -static void -scrdn(TMT *vt, size_t r, size_t n) -{ -    n = MIN(n, vt->screen.nline - 1 - r); - -    if (n){ -        TMTLINE *buf[n]; - -        memcpy(buf, vt->screen.lines + (vt->screen.nline - n), -               n * sizeof(TMTLINE *)); -        memmove(vt->screen.lines + r + n, vt->screen.lines + r, -                (vt->screen.nline - n - r) * sizeof(TMTLINE *)); -        memcpy(vt->screen.lines + r, buf, n * sizeof(TMTLINE *)); -     -        clearlines(vt, r, n); -        dirtylines(vt, r, vt->screen.nline); -    } -} - -HANDLER(ed) -    size_t b = 0; -    size_t e = s->nline; - -    switch (P0(0)){ -        case 0: b = c->r + 1; clearline(vt, l, c->c, vt->screen.ncol); break; -        case 1: e = c->r - 1; clearline(vt, l, 0, c->c);               break; -        case 2:  /* use defaults */                                    break; -        default: /* do nothing   */                                    return; -    } - -    clearlines(vt, b, e - b); -} - -HANDLER(ich) -    size_t n = P1(0); /* XXX use MAX */ -    if (n > s->ncol - c->c - 1) n = s->ncol - c->c - 1; - -    memmove(l->chars + c->c + n, l->chars + c->c, -            MIN(s->ncol - 1 - c->c, -            (s->ncol - c->c - n - 1)) * sizeof(TMTCHAR)); -    clearline(vt, l, c->c, n); -} - -HANDLER(dch) -    size_t n = P1(0); /* XXX use MAX */ -    if (n > s->ncol - c->c) n = s->ncol - c->c; - -    memmove(l->chars + c->c, l->chars + c->c + n, -            (s->ncol - c->c - n) * sizeof(TMTCHAR)); - -    clearline(vt, l, s->ncol - c->c - n, s->ncol); -} - -HANDLER(el) -    switch (P0(0)){ -        case 0: clearline(vt, l, c->c, vt->screen.ncol);         break; -        case 1: clearline(vt, l, 0, MIN(c->c + 1, s->ncol - 1)); break; -        case 2: clearline(vt, l, 0, vt->screen.ncol);            break; -    } -} - -HANDLER(sgr) -    #define FGBG(c) *(P0(i) < 40? &vt->attrs.fg : &vt->attrs.bg) = c -    for (size_t i = 0; i < vt->npar; i++) switch (P0(i)){ -        case  0: vt->attrs                    = defattrs;   break; -        case  1: case 22: vt->attrs.bold      = P0(0) < 20; break; -        case  2: case 23: vt->attrs.dim       = P0(0) < 20; break; -        case  4: case 24: vt->attrs.underline = P0(0) < 20; break; -        case  5: case 25: vt->attrs.blink     = P0(0) < 20; break; -        case  7: case 27: vt->attrs.reverse   = P0(0) < 20; break; -        case  8: case 28: vt->attrs.invisible = P0(0) < 20; break; -        case 10: case 11: vt->acs             = P0(0) > 10; break; -        case 30: case 40: FGBG(TMT_COLOR_BLACK);            break; -        case 31: case 41: FGBG(TMT_COLOR_RED);              break; -        case 32: case 42: FGBG(TMT_COLOR_GREEN);            break; -        case 33: case 43: FGBG(TMT_COLOR_YELLOW);           break; -        case 34: case 44: FGBG(TMT_COLOR_BLUE);             break; -        case 35: case 45: FGBG(TMT_COLOR_MAGENTA);          break; -        case 36: case 46: FGBG(TMT_COLOR_CYAN);             break; -        case 37: case 47: FGBG(TMT_COLOR_WHITE);            break; -        case 39: case 49: FGBG(TMT_COLOR_DEFAULT);          break; -    } -} - -HANDLER(rep) -    if (!c->c) return; -    wchar_t r = l->chars[c->c - 1].c; -    for (size_t i = 0; i < P1(0); i++) -        writecharatcurs(vt, r); -} - -HANDLER(dsr) -    char r[BUF_MAX + 1] = {0}; -    snprintf(r, BUF_MAX, "\033[%zd;%zdR", c->r, c->c); -    CB(vt, TMT_MSG_ANSWER, (const char *)r); -} - -HANDLER(resetparser) -    memset(vt->pars, 0, sizeof(vt->pars)); -    vt->state = vt->npar = vt->arg = vt->ignored = (bool)0; -} - -HANDLER(consumearg) -    if (vt->npar < PAR_MAX) -        vt->pars[vt->npar++] = vt->arg; -    vt->arg = 0; -} - -HANDLER(fixcursor) -    c->r = MIN(c->r, s->nline - 1); -    c->c = MIN(c->c, s->ncol - 1); -} - -static bool -handlechar(TMT *vt, char i) -{ -    COMMON_VARS; - -    char cs[] = {i, 0}; -    #define ON(S, C, A) if (vt->state == (S) && strchr(C, i)){ A; return true;} -    #define DO(S, C, A) ON(S, C, consumearg(vt); if (!vt->ignored) {A;} \ -                                 fixcursor(vt); resetparser(vt);); - -    DO(S_NUL, "\x07",       CB(vt, TMT_MSG_BELL, NULL)) -    DO(S_NUL, "\x08",       if (c->c) c->c--) -    DO(S_NUL, "\x09",       while (++c->c < s->ncol - 1 && t[c->c].c != L'*')) -    DO(S_NUL, "\x0a",       c->r < s->nline - 1? (void)c->r++ : scrup(vt, 0, 1)) -    DO(S_NUL, "\x0d",       c->c = 0) -    ON(S_NUL, "\x1b",       vt->state = S_ESC) -    ON(S_ESC, "\x1b",       vt->state = S_ESC) -    DO(S_ESC, "H",          t[c->c].c = L'*') -    DO(S_ESC, "7",          vt->oldcurs = vt->curs; vt->oldattrs = vt->attrs) -    DO(S_ESC, "8",          vt->curs = vt->oldcurs; vt->attrs = vt->oldattrs) -    ON(S_ESC, "+*()",       vt->ignored = true; vt->state = S_ARG) -    DO(S_ESC, "c",          tmt_reset(vt)) -    ON(S_ESC, "[",          vt->state = S_ARG) -    ON(S_ARG, "\x1b",       vt->state = S_ESC) -    ON(S_ARG, ";",          consumearg(vt)) -    ON(S_ARG, "?",          (void)0) -    ON(S_ARG, "0123456789", vt->arg = vt->arg * 10 + atoi(cs)) -    DO(S_ARG, "A",          c->r = MAX(c->r - P1(0), 0)) -    DO(S_ARG, "B",          c->r = MIN(c->r + P1(0), s->nline - 1)) -    DO(S_ARG, "C",          c->c = MIN(c->c + P1(0), s->ncol - 1)) -    DO(S_ARG, "D",          c->c = MIN(c->c - P1(0), c->c)) -    DO(S_ARG, "E",          c->c = 0; c->r = MIN(c->r + P1(0), s->nline - 1)) -    DO(S_ARG, "F",          c->c = 0; c->r = MAX(c->r - P1(0), 0)) -    DO(S_ARG, "G",          c->c = MIN(P1(0) - 1, s->ncol - 1)) -    DO(S_ARG, "d",          c->r = MIN(P1(0) - 1, s->nline - 1)) -    DO(S_ARG, "Hf",         c->r = P1(0) - 1; c->c = P1(1) - 1) -    DO(S_ARG, "I",          while (++c->c < s->ncol - 1 && t[c->c].c != L'*')) -    DO(S_ARG, "J",          ed(vt)) -    DO(S_ARG, "K",          el(vt)) -    DO(S_ARG, "L",          scrdn(vt, c->r, P1(0))) -    DO(S_ARG, "M",          scrup(vt, c->r, P1(0))) -    DO(S_ARG, "P",          dch(vt)) -    DO(S_ARG, "S",          scrup(vt, 0, P1(0))) -    DO(S_ARG, "T",          scrdn(vt, 0, P1(0))) -    DO(S_ARG, "X",          clearline(vt, l, c->c, P1(0))) -    DO(S_ARG, "Z",          while (c->c && t[--c->c].c != L'*')) -    DO(S_ARG, "b",          rep(vt)); -    DO(S_ARG, "c",          CB(vt, TMT_MSG_ANSWER, "\033[?6c")) -    DO(S_ARG, "g",          if (P0(0) == 3) clearline(vt, vt->tabs, 0, s->ncol)) -    DO(S_ARG, "m",          sgr(vt)) -    DO(S_ARG, "n",          if (P0(0) == 6) dsr(vt)) -    DO(S_ARG, "h",          if (P0(0) == 25) CB(vt, TMT_MSG_CURSOR, "t")) -    DO(S_ARG, "i",          (void)0) -    DO(S_ARG, "l",          if (P0(0) == 25) CB(vt, TMT_MSG_CURSOR, "f")) -    DO(S_ARG, "s",          vt->oldcurs = vt->curs; vt->oldattrs = vt->attrs) -    DO(S_ARG, "u",          vt->curs = vt->oldcurs; vt->attrs = vt->oldattrs) -    DO(S_ARG, "@",          ich(vt)) - -    return resetparser(vt), false; -} - -static void -notify(TMT *vt, bool update, bool moved) -{ -    if (update) CB(vt, TMT_MSG_UPDATE, &vt->screen); -    if (moved) CB(vt, TMT_MSG_MOVED, &vt->curs); -} - -static TMTLINE * -allocline(TMT *vt, TMTLINE *o, size_t n, size_t pc) -{ -    TMTLINE *l = realloc(o, sizeof(TMTLINE) + n * sizeof(TMTCHAR)); -    if (!l) return NULL; - -    clearline(vt, l, pc, n); -    return l; -} - -static void -freelines(TMT *vt, size_t s, size_t n, bool screen) -{ -    for (size_t i = s; vt->screen.lines && i < s + n; i++){ -        free(vt->screen.lines[i]); -        vt->screen.lines[i] = NULL; -    } -    if (screen) free(vt->screen.lines); -} - -TMT * -tmt_open(size_t nline, size_t ncol, TMTCALLBACK cb, void *p, -         const wchar_t *acs) -{ -    TMT *vt = calloc(1, sizeof(TMT)); -    if (!nline || !ncol || !vt) return free(vt), NULL; - -    /* ASCII-safe defaults for box-drawing characters. */ -    vt->acschars = acs? acs : L"><^v#+:o##+++++~---_++++|<>*!fo"; -    vt->cb = cb; -    vt->p = p; - -    if (!tmt_resize(vt, nline, ncol)) return tmt_close(vt), NULL; -    return vt; -} - -void -tmt_close(TMT *vt) -{ -    free(vt->tabs); -    freelines(vt, 0, vt->screen.nline, true); -    free(vt); -} - -bool -tmt_resize(TMT *vt, size_t nline, size_t ncol) -{ -    if (nline < 2 || ncol < 2) return false; -    if (nline < vt->screen.nline) -        freelines(vt, nline, vt->screen.nline - nline, false); - -    TMTLINE **l = realloc(vt->screen.lines, nline * sizeof(TMTLINE *)); -    if (!l) return false; - -    size_t pc = vt->screen.ncol; -    vt->screen.lines = l; -    vt->screen.ncol = ncol; -    for (size_t i = 0; i < nline; i++){ -        TMTLINE *nl = NULL; -        if (i >= vt->screen.nline) -            nl = vt->screen.lines[i] = allocline(vt, NULL, ncol, 0); -        else -            nl = allocline(vt, vt->screen.lines[i], ncol, pc); - -        if (!nl) return false; -        vt->screen.lines[i] = nl; -    } -    vt->screen.nline = nline; - -    vt->tabs = allocline(vt, vt->tabs, ncol, 0); -    if (!vt->tabs) return free(l), false; -    vt->tabs->chars[0].c = vt->tabs->chars[ncol - 1].c = L'*'; -    for (size_t i = 0; i < ncol; i++) if (i % TAB == 0) -        vt->tabs->chars[i].c = L'*'; - -    fixcursor(vt); -    dirtylines(vt, 0, nline); -    notify(vt, true, true); -    return true; -} - -static void -writecharatcurs(TMT *vt, wchar_t w) -{ -    COMMON_VARS; - -    #ifdef TMT_HAS_WCWIDTH -    extern int wcwidth(wchar_t c); -    if (wcwidth(w) > 1)  w = TMT_INVALID_CHAR; -    if (wcwidth(w) < 0) return; -    #endif - -    CLINE(vt)->chars[vt->curs.c].c = w; -    CLINE(vt)->chars[vt->curs.c].a = vt->attrs; -    CLINE(vt)->dirty = vt->dirty = true; - -    if (c->c < s->ncol - 1) -        c->c++; -    else{ -        c->c = 0; -        c->r++; -    } - -    if (c->r >= s->nline){ -        c->r = s->nline - 1; -        scrup(vt, 0, 1); -    } -} - -static inline size_t -testmbchar(TMT *vt) -{ -    mbstate_t ts = vt->ms; -    return vt->nmb? mbrtowc(NULL, vt->mb, vt->nmb, &ts) : (size_t)-2; -} - -static inline wchar_t -getmbchar(TMT *vt) -{ -    wchar_t c = 0; -    size_t n = mbrtowc(&c, vt->mb, vt->nmb, &vt->ms); -    vt->nmb = 0; -    return (n == (size_t)-1 || n == (size_t)-2)? TMT_INVALID_CHAR : c; -} - -void -tmt_write(TMT *vt, const char *s, size_t n) -{ -    TMTPOINT oc = vt->curs; -    n = n? n : strlen(s); - -    for (size_t p = 0; p < n; p++){ -        if (handlechar(vt, s[p])) -            continue; -        else if (vt->acs) -            writecharatcurs(vt, tacs(vt, (unsigned char)s[p])); -        else if (vt->nmb >= BUF_MAX) -            writecharatcurs(vt, getmbchar(vt)); -        else{ -            switch (testmbchar(vt)){ -                case (size_t)-1: writecharatcurs(vt, getmbchar(vt)); break; -                case (size_t)-2: vt->mb[vt->nmb++] = s[p];           break; -            } - -            if (testmbchar(vt) <= MB_LEN_MAX) -                writecharatcurs(vt, getmbchar(vt)); -        } -    } - -    notify(vt, vt->dirty, memcmp(&oc, &vt->curs, sizeof(oc)) != 0); -} - -const TMTSCREEN * -tmt_screen(const TMT *vt) -{ -    return &vt->screen; -} - -const TMTPOINT * -tmt_cursor(const TMT *vt) -{ -    return &vt->curs; -} - -void -tmt_clean(TMT *vt) -{ -    for (size_t i = 0; i < vt->screen.nline; i++) -        vt->dirty = vt->screen.lines[i]->dirty = false; -} - -void -tmt_reset(TMT *vt) -{ -    vt->curs.r = vt->curs.c = vt->oldcurs.r = vt->oldcurs.c = vt->acs = (bool)0; -    resetparser(vt); -    vt->attrs = vt->oldattrs = defattrs; -    memset(&vt->ms, 0, sizeof(vt->ms)); -    clearlines(vt, 0, vt->screen.nline); -    CB(vt, TMT_MSG_CURSOR, "t"); -    notify(vt, true, true); -} diff --git a/share/hackvr/examples/hackvr_term/libtmt/tmt.h b/share/hackvr/examples/hackvr_term/libtmt/tmt.h deleted file mode 100644 index ae0ddbb..0000000 --- a/share/hackvr/examples/hackvr_term/libtmt/tmt.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright (c) 2017 Rob King - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - *   * Redistributions of source code must retain the above copyright - *     notice, this list of conditions and the following disclaimer. - *   * Redistributions in binary form must reproduce the above copyright - *     notice, this list of conditions and the following disclaimer in the - *     documentation and/or other materials provided with the distribution. - *   * Neither the name of the copyright holder nor the - *     names of contributors may be used to endorse or promote products - *     derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, - * COPYRIGHT HOLDERS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TMT_H -#define TMT_H - -#include <stdbool.h> -#include <stddef.h> -#include <wchar.h> - -/**** INVALID WIDE CHARACTER */ -#ifndef TMT_INVALID_CHAR -#define TMT_INVALID_CHAR ((wchar_t)0xfffd) -#endif - -/**** INPUT SEQUENCES */ -#define TMT_KEY_UP             "\033[A" -#define TMT_KEY_DOWN           "\033[B" -#define TMT_KEY_RIGHT          "\033[C" -#define TMT_KEY_LEFT           "\033[D" -#define TMT_KEY_HOME           "\033[H" -#define TMT_KEY_END            "\033[Y" -#define TMT_KEY_INSERT         "\033[L" -#define TMT_KEY_BACKSPACE      "\x08" -#define TMT_KEY_ESCAPE         "\x1b" -#define TMT_KEY_BACK_TAB       "\033[Z" -#define TMT_KEY_PAGE_UP        "\033[V" -#define TMT_KEY_PAGE_DOWN      "\033[U" -#define TMT_KEY_F1             "\033OP" -#define TMT_KEY_F2             "\033OQ" -#define TMT_KEY_F3             "\033OR" -#define TMT_KEY_F4             "\033OS" -#define TMT_KEY_F5             "\033OT" -#define TMT_KEY_F6             "\033OU" -#define TMT_KEY_F7             "\033OV" -#define TMT_KEY_F8             "\033OW" -#define TMT_KEY_F9             "\033OX" -#define TMT_KEY_F10            "\033OY" - -/**** BASIC DATA STRUCTURES */ -typedef struct TMT TMT; - -typedef enum{ -    TMT_COLOR_DEFAULT = -1, -    TMT_COLOR_BLACK = 1, -    TMT_COLOR_RED, -    TMT_COLOR_GREEN, -    TMT_COLOR_YELLOW, -    TMT_COLOR_BLUE, -    TMT_COLOR_MAGENTA, -    TMT_COLOR_CYAN, -    TMT_COLOR_WHITE, -    TMT_COLOR_MAX -} tmt_color_t; - -typedef struct TMTATTRS TMTATTRS; -struct TMTATTRS{ -    bool bold; -    bool dim; -    bool underline; -    bool blink; -    bool reverse; -    bool invisible; -    tmt_color_t fg; -    tmt_color_t bg; -}; - -typedef struct TMTCHAR TMTCHAR; -struct TMTCHAR{ -    wchar_t c; -    TMTATTRS a; -}; - -typedef struct TMTPOINT TMTPOINT; -struct TMTPOINT{ -    size_t r; -    size_t c; -}; - -typedef struct TMTLINE TMTLINE; -struct TMTLINE{ -    bool dirty; -    TMTCHAR chars[]; -}; - -typedef struct TMTSCREEN TMTSCREEN; -struct TMTSCREEN{ -    size_t nline; -    size_t ncol; - -    TMTLINE **lines; -}; - -/**** CALLBACK SUPPORT */ -typedef enum{ -    TMT_MSG_MOVED, -    TMT_MSG_UPDATE, -    TMT_MSG_ANSWER, -    TMT_MSG_BELL, -    TMT_MSG_CURSOR -} tmt_msg_t; - -typedef void (*TMTCALLBACK)(tmt_msg_t m, struct TMT *v, const void *r, void *p); - -/**** PUBLIC FUNCTIONS */ -TMT *tmt_open(size_t nline, size_t ncol, TMTCALLBACK cb, void *p, -              const wchar_t *acs); -void tmt_close(TMT *vt); -bool tmt_resize(TMT *vt, size_t nline, size_t ncol); -void tmt_write(TMT *vt, const char *s, size_t n); -const TMTSCREEN *tmt_screen(const TMT *vt); -const TMTPOINT *tmt_cursor(const TMT *vt); -void tmt_clean(TMT *vt); -void tmt_reset(TMT *vt); - -#endif diff --git a/share/hackvr/examples/hackvr_term/pty b/share/hackvr/examples/hackvr_term/ptyBinary files differ deleted file mode 100755 index a1900b1..0000000 --- a/share/hackvr/examples/hackvr_term/pty +++ /dev/null diff --git a/share/hackvr/examples/hackvr_term/pty.c b/share/hackvr/examples/hackvr_term/pty.c deleted file mode 100644 index 6903bc3..0000000 --- a/share/hackvr/examples/hackvr_term/pty.c +++ /dev/null @@ -1,70 +0,0 @@ -#define _XOPEN_SOURCE 500 //ptsname -#define _XOPEN_SOURCE_EXTENDED -#include <stdio.h> -#include <fcntl.h> -#include <sys/wait.h> -#include <stdlib.h> -#include <unistd.h> -#include <errno.h> - -int main(int argc,char *argv[]) { -  char *pts; -  char in;//I dunno. -  int r; -  int pid; -  int eof1,eof2; -  int master,slave; -  master=open("/dev/ptmx",O_RDWR); -  if(master == -1) return 1; -  pts=ptsname(master); -//  printf("%s\n",pts); -//  system("ls -l /dev/pts/*"); -  grantpt(master); -  unlockpt(master); -//  system("ls -l /dev/pts/*"); -  if(pts == NULL) return 2; -  slave=open(pts,O_RDWR); -  if(slave == -1) { -   perror("open"); -   return 3; -  } -  argv++; -  fcntl(master,F_SETFL,O_NONBLOCK); -//  fcntl(slave,F_SETFL,O_NONBLOCK); -  fcntl(0,F_SETFL,O_NONBLOCK); -  fcntl(1,F_SETFL,O_NONBLOCK); -  fcntl(2,F_SETFL,O_NONBLOCK); -  switch(pid=fork()) { -    case -1: -      return 4;//fork failed -    case 0://child -      setsid(); -      close(master); -      dup2(slave,0); -      dup2(slave,1); -      dup2(slave,2); -      execv(argv[0],argv);//execute arguments. -      return 5;//exec failed -    default: -      break; -  } -  eof1=0; -  eof2=0; -  for(;!(eof1 || eof2);) { -    if(waitpid(-1,0,WNOHANG) > 0) { -      return 0;//fuck if I know. -      //we got a dead child. let's bail. -    } -    switch(r=read(0,&in,1)) { -     case 0: eof1=1;;//EOF -     case -1: if(errno != EAGAIN) eof1=1; break;//EAGAIN probably. -     default: write(master,&in,r); -    } -    switch(r=read(master,&in,1)) { -     case 0: eof2=1;;//EOF -     case -1: if(errno != EAGAIN) eof2=1; break;//EAGAIN probably -     default: write(1,&in,r); -    } -    usleep(100);//kek -  } -} diff --git a/share/hackvr/examples/hackvr_term/read_line.sh b/share/hackvr/examples/hackvr_term/read_line.sh deleted file mode 100755 index c26ebf3..0000000 --- a/share/hackvr/examples/hackvr_term/read_line.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -./hackvr_data_decode.sh \ -       | ./pty `which bash` "-c" 'read -p "type> " line;xmessage $line' \ -       | ./hackvr_term 60 2 \ -       | sed -u 's/addshape 15 4/addshape 12 4/g' diff --git a/share/hackvr/examples/hackvr_term/run b/share/hackvr/examples/hackvr_term/run deleted file mode 100755 index 9fcc247..0000000 --- a/share/hackvr/examples/hackvr_term/run +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -mknod p p -cat <(cat camera.pos | sed 's/USER/'"$USER"'/g') \ -    <(./hackvr_data_decode.sh <p \ -       | python -c 'import pty;pty.spawn("/bin/bash")' \ -       | ./hackvr_term 80 25 \ -       | sed -u 's/addshape -1/addshape 2/g') \ -  | hackvr $USER | tee /dev/stderr > p -rm p diff --git a/share/hackvr/examples/hackvr_term/run.pty b/share/hackvr/examples/hackvr_term/run.pty deleted file mode 100755 index 1cfcf96..0000000 --- a/share/hackvr/examples/hackvr_term/run.pty +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -mknod p p -cat <(cat camera.pos | sed 's/USER/'"$USER"'/g') \ -    <(./hackvr_data_decode.sh <p \ -       | ./pty /bin/bash \ -       | ./hackvr_term 80 25 \ -       | sed -u 's/addshape -1/addshape 2/g') \ -  | hackvr $USER | tee /dev/stderr > p -rm p diff --git a/share/hackvr/examples/hackvrd/hackvr-subsystem b/share/hackvr/examples/hackvrd/hackvr-subsystem deleted file mode 100755 index 024a896..0000000 --- a/share/hackvr/examples/hackvrd/hackvr-subsystem +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -o pipefail - -if [ "$1" ];then -  derp="$USER action $1" -fi -cat <(echo $derp) /dev/stdin | socat tcp-connect:127.0.0.1:1337,null-eof stdio diff --git a/share/hackvr/examples/hackvrd/hackvrd.sh b/share/hackvr/examples/hackvrd/hackvrd.sh deleted file mode 100755 index 0b16543..0000000 --- a/share/hackvr/examples/hackvrd/hackvrd.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail - -OUR_HOST=$(/usr/local/libexec/sockip | head -n1) -THEIR_HOST=$(/usr/local/libexec/peerip | head -n1) -OUR_PORT=$(/usr/local/libexec/sockip | tail -n1) -THEIR_PORT=$(/usr/local/libexec/peerip | tail -n1) - -log=/var/log/log.hackvr - -# some hackvr scripts use USER for commanding the player -if USER=$(ident $OUR_HOST $THEIR_HOST 113 $THEIR_PORT $OUR_PORT);then -	export USER -else -	printf "%s does not have an ident daemon running.\n" "$THEIR_HOST" >> $log -	exit 1 -fi - -if [ ! "$USER" ];then -  exit 1 -fi -printf "%s@%s connected to hackvr\n" "$USER" "$THEIR_HOST" >> $log - -last_pong=$(date +%s) -wat=true - -while true;do -	while read -t 10 group action target args;do -		printf "hackvr line: %s\n" "$group $action $target $args" >> $log -		if [ "$group" = "$USER" -a "$action" = "pong" ];then -			printf '%s@%s ponged on hackvr\n' $USER $THEIR_HOST >> $log -			last_pong="$(date +%s)" -		fi -		if [ "$group" = "$USER" -a "$action" = "quit" ];then -			break -		fi -		if [ "$action" = "action" ];then -			if [ "$target" = "/links" ];then -				printf "%s deleteallexcept %s\n" "$USER" "$USER" -				off=-10 -				for link in gopher://thebackupbox.net/;do -					off=$[$off + 10] -					printf '<%s> addshape 4 3  0 0 0  0 8 0  8 0 0\n' "$link" -					printf '%s' "$link" | makelabel.sh "<$link>" 8 0 0 -					printf '<%s> move 0 %d 0\n' "$link" "$off" -				done -				target=/ -			fi -			if [ $target = "/radio" ];then -				printf "$USER deleteallexcept $USER\n" -				cd /var/hackvr/ -				./radio.sh -				target=/ -			fi -			if [ $target = "/ttt" ];then -				printf "$USER deleteallexcept $USER\n" -				cd /usr/local/src/hackvr/share/hackvr/examples/tictactoe -				./game.sh 2>/dev/null -				target=/ -			fi -			if grep "^/dun" <<< "$target" 2>&1 >/dev/null;then -				printf "$USER deleteallexcept $USER\n" -				export seed="$(printf "%s\n" "$target" | cut -d/ -f3)" -				cd /usr/local/src/hackvr/share/hackvr/examples/dungen -				./dunexplore.sh 2>/dev/null -				target=/ -			fi -			if [ $target = "/multi" ];then -				/var/hackvr/multi.sh -				target=/ -			fi -			if [ $target = "/map" ];then -				printf "$USER deleteallexcept $USER\n" -				cd /usr/local/src/hackvr/share/hackvr/examples/anonet_map -				./map 2>/dev/null -				printf '/ addshape 4 3   0 0 0   0 8 0   8 0 0\n' -				while read group action target args;do -					if [ "$action" = "action" ];then -						if [ "$target" = "/" ];then -							break -						fi -					fi -				done -				target=/ -			fi -			if [ $target = "/" ];then -				printf "%s deleteallexcept %s\n" "$USER" "$USER" -				cd /usr/local/src/hackvr/share/hackvr/examples/hackvrd -				off=-10 -				for name in ttt dun map multi links radio;do -					off=$[$off + 10] -					printf '/%s addshape 4 3   0 0 0   0 8 0   8 0 0\n' "$name" -					printf '/%s' "$name" | makelabel.sh "/$name" 8 0 0 -					printf '/%s move 0 %d 0\n' $name $off -				done -			fi -		else -			if $wat;then -				wat=false -				printf '/ addshape 4 3  0 0 0  0 8 0  8 0 0\n' -				printf 'welcome' | makelabel.sh / 8 0 0 -			fi -		fi -	done -	#printf "pinging... %s@%s\n" "$USER" "$THEIR_HOST" >> /var/log/hackvr.all -	#printf "%s ping %s\n" "$USER" "thebackupbox.net" -	#if [ $[$(date +%s) - $last_pong] -gt 30 ];then #they probably pinged out. -	#	printf '# you pinged out. gotta respond to those, dude.\n' -	#	printf "%s@%s pinged out from hackvr\n" "$USER" "$THEIR_HOST" >> /var/log/hackvr.all -	#	exit 1 -	#fi -done - -printf "%s@%s disconnected from hackvr\n" "$USER" "$THEIR_HOST" >> $log diff --git a/share/hackvr/examples/hackvrd/ident b/share/hackvr/examples/hackvrd/ident deleted file mode 100755 index f4e7599..0000000 --- a/share/hackvr/examples/hackvrd/ident +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -if [ $# -lt 4 ];then -  echo usage: ident.sh our-host their-host 113 their-port our-port -  exit 1 -fi -REMOTE_PORT="$4" -SERVER_PORT="$5" -IDENT_PORT="$3" -REMOTE_ADDR="$2" -SERVER_ADDR="$1" -username="$(printf "%s, %s\r\n" "$REMOTE_PORT" "$SERVER_PORT" | (ncat -s "$SERVER_ADDR" "$REMOTE_ADDR" "$IDENT_PORT" 2>/dev/null || echo 'ERROR:ERROR:ERROR:ERROR') | tr -d '\r' | cut -d: -f4)" -if [ "$username" ];then -  printf "%s\n" "$username" -else -  exit 1 -fi diff --git a/share/hackvr/examples/hackvrd/list_to_cubes.sh b/share/hackvr/examples/hackvrd/list_to_cubes.sh deleted file mode 100755 index 0dfca06..0000000 --- a/share/hackvr/examples/hackvrd/list_to_cubes.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# blank lines deleteallexcept epoch -# expected input format: -# -# line1 -# line2 -# line3 -# -# line1 -# line2 -j=1 -r=200 -while read -r line;do - if [ "_$line" != '_' ];then -#  ../tools/obj2hackvr.pl "$line" ../meshes/cube.obj -  #turn line into hex to prevent stupid shit -  hexline="$(printf "%s" "$line" | xxd -p | tr -d '\n')" -  printf "%s addshape 18 3 8 %d %d 0 %d %d 0 %d %d\n" "$hexline" "$j" "$r" "$[$j+8]" "$r" "$j" "$r" -  cd .. -  printf "%s\n" "$line" | tee /dev/stderr | makelabel.sh "$hexline" 15 $j $r -  cd filebrowser -  #printf "%s move 0 %d %d 0 0 0 0 0 0\n" "$hexline" "$i" "$r" -  printf "%s rotate 0 %d 0\n" "$hexline" "$[i * 3]" -  #somehow printf '%s\n' "$line" | ./testfont.sh and make its output belong to same group as $line.. sed? -  i=$[i+10] -  j=$[j+4] - else -  cat camera.pos -  printf "USER deleteallexcept USER\n" #deleteallexcept doesn't have gr deletions yet I think. -  j=0 -  i=0 - fi -done diff --git a/share/hackvr/examples/hackvrd/multi.sh b/share/hackvr/examples/hackvrd/multi.sh deleted file mode 100755 index 525f981..0000000 --- a/share/hackvr/examples/hackvrd/multi.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -printf 'user: %s joined multi\n' "$USER" >> /var/log/hackvr.all -cat /var/cache/hackvr/world_history <(echo 'root export *') \ -	| egrep -v '^#|^[^ ][^ ]*  *quit' \ -	| grep -v 'move [a-z]' \ -	| /usr/local/bin/hackvr_headless 2>/dev/null \ -	| sed 's/^root_//g' -tail -f -n0 /var/cache/hackvr/world_history \ -	| grep --line-buffered -v '^'"$USER"' ' & -tee -a /var/cache/hackvr/world_history >/dev/null diff --git a/share/hackvr/examples/hackvrd/radio.sh b/share/hackvr/examples/hackvrd/radio.sh deleted file mode 100755 index 7b290e9..0000000 --- a/share/hackvr/examples/hackvrd/radio.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env bash -log=/var/log/log.hackvr - -button="-2 2 1  2 2 1  2 -2 1  -2 -2 1" -bc=2 -printf "<http://thebackupbox.net:8901/> addshape 6 4  %s\n" "$button" -printf "<http://thebackupbox.net:8901/> move -5 5 0\n" -# |> -name=play -printf "%s addshape %s 4  %s\n" "$name" "$bc" "$button" -printf "play addshape 4 3  -1 1 0  1 0 0 -1 -1 0\n" -printf "play move 0 0 0\n" -# || -name=pause -printf "%s addshape %s 4  %s\n" "$name" "$bc" "$button" -printf "pause addshape 4 4  -1 1 0  -.5 1 0  -.5 -1 0  -1 -1 0\n" -printf "pause addshape 4 4  .5 1 0  1 1 0  1 -1 0  .5 -1 0\n" -printf "pause move 0 4 0\n" - -# [] -name=stop -printf "%s addshape %s 4  %s\n" "$name" "$bc" "$button" -printf "stop addshape 4 4  -1 1 0  1 1 0  1 -1 0  -1 -1 0\n" -printf "stop move 0 -4 0\n" - -# |>| -name=next -printf "%s addshape %s 4  %s\n" "$name" "$bc" "$button" -printf "next addshape 4 3  -1 1 0   .75 0 0   -1 -1 0\n" -printf "next addshape 4 4  .75 1 0  1 1 0  1 -1 0  .75 -1 0\n" -printf "next move 4 0 0\n" - -# |<| -name=prev -printf "%s addshape %s 4  %s\n" "$name" "$bc" "$button" -printf "prev addshape 4 3  -.75 0 0  1 1 0  1 -1 0\n" -printf "prev addshape 4 4  -1 1 0  -.75 1 0  -.75 -1 0  -1 -1 0\n" -printf "prev move -4 0 0\n" - -printf "exit addshape 4 4  %s\n" "$button" -printf "exit move 5 5 0\n" - -spin() { -	for r in $(seq 15 15 360);do -		printf "%s rotate 0 0 %s\n" "$1" "$r" -		sleep .1 -	done -} - -# a "listen" link to the http stream -# so anyone using hackvr_uri can open it from inside hackvr. :) - -	while read group action target args;do -		printf "hackvr line: %s\n" "$group $action $target" >> $log -		if [ "$group" = "$USER" -a "$action" = "quit" ];then -			break -		fi -		if [ "$action" = "action" ];then -			if [ $target = "pause" ];then -				spin $target & -				mpc --host=21.41.41.4 --port=61666 pause 2>&1 >/dev/null 2>&1 -			fi -			if [ $target = "play" ];then -				spin $target & -				mpc --host=21.41.41.4 --port=61666 play 2>&1 >/dev/null 2>&1 -			fi -			if [ $target = "prev" ];then -				spin $target & -				mpc --host=21.41.41.4 --port=61666 prev 2>&1 >/dev/null 2>&1 -			fi -			if [ $target = "next" ];then -				spin $target & -				mpc --host=21.41.41.4 --port=61666 next 2>&1 >/dev/null 2>&1 -			fi -			if [ $target = "stop" ];then -				spin $target & -				mpc --host=21.41.41.4 --port=61666 stop 2>&1 >/dev/null 2>&1 -			fi -			if [ $target = "exit" ];then -				spin $target -				break; -			fi -		fi -	done diff --git a/share/hackvr/examples/hackvrnet/connect.sh b/share/hackvr/examples/hackvrnet/connect.sh deleted file mode 100755 index 5f7b660..0000000 --- a/share/hackvr/examples/hackvrnet/connect.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -password=hackvr -ncat 21.41.41.1 31337 -c 'hackvr "$USER"' diff --git a/share/hackvr/examples/marquee/marquee.sh b/share/hackvr/examples/marquee/marquee.sh deleted file mode 100755 index 4ea6c61..0000000 --- a/share/hackvr/examples/marquee/marquee.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -o pipefail - -pi=3 #lol - -from_cam=150 - -elevation=10 -while printf "marquee rotate 0 +-2 0\n";do -  sleep .1 -done & - -tail -F ~/.local/var/cache/music/nowplaying.txt 2>/dev/null | while read -r line;do -  printf "%s deleteallexcept %s\n" "$USER" "$USER" -  printf "nowplaying flatten\n" -  printf "%s\n" "$line" >&2 -  chars="$(printf "%s" "$line" | wc -c | tr -cd '[0-9]')" -  char_width=5 #I think.. -  rot=$[ 360 / $chars ] -  diameter=$[ $chars * $char_width / $pi ] -  printf "%s\n" "$line" | fold -w1 | while read -r char;do -    printf "%s\n" "$char" | makelabel.sh nowplaying 0 0 0 | offsetshape.sh 0 0 "-${diameter}" -    printf "nowplaying rotate 0 %d 0\n" "-$rot" -    printf "nowplaying flatten\n" -  done -  printf "marquee assimilate nowplaying\n" -  printf "marquee move 0 %s %s\n" "$elevation" "$[$diameter + $from_cam]" #this won't work before the generation loop unless I can flatten on certain parts.  -done diff --git a/share/hackvr/examples/spinners/square.sh b/share/hackvr/examples/spinners/square.sh deleted file mode 100755 index 3b733c7..0000000 --- a/share/hackvr/examples/spinners/square.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -printf "%s move 0 0 -10\n" "$USER" -printf "square addshape 2 4 1 1 0  -1 1 0  -1 -1 0  1 -1 0\n" -inc=5 -end=180 -while true;do -  for i in $(seq 1 $inc $end);do -    printf "square rotate +%d +0 +0\n" "$inc" -    sleep .01 -  done -  for i in $(seq 1 $inc $end);do -    printf "square rotate +0 +%d +0\n" "$inc" -    sleep .01 -  done -  for i in $(seq 1 $inc $end);do -    printf "square rotate +0 +0 +%d\n" "$inc" -    sleep .01 -  done -done diff --git a/share/hackvr/examples/starfield b/share/hackvr/examples/starfieldBinary files differ deleted file mode 100755 index b3b4778..0000000 --- a/share/hackvr/examples/starfield +++ /dev/null diff --git a/share/hackvr/examples/starfield.c b/share/hackvr/examples/starfield.c deleted file mode 100644 index d367bb3..0000000 --- a/share/hackvr/examples/starfield.c +++ /dev/null @@ -1,12 +0,0 @@ -#include <stdio.h> - -int main(int argc,char *argv[]) { - -  int i,x,y,z; -  for(i=0;i<100;i++) { -    x=(rand()%1000)-500; -    y=(rand()%1000)-500; -    z=(rand()%1000)-500; -    printf("star%d addshape %d 1 %d %d %d %d %d %d\n",i,(rand()%7)+17,x,y,z,x+rand()%10,y,z); -  }  -} diff --git a/share/hackvr/examples/subsume/arms.hackvr b/share/hackvr/examples/subsume/arms.hackvr deleted file mode 100644 index de31aba..0000000 --- a/share/hackvr/examples/subsume/arms.hackvr +++ /dev/null @@ -1,7 +0,0 @@ -base addshape 1 2  0 0 0  0 8 0 -mid addshape   2 2  0 0 0  0 4 0 -mid move 0 8 0 -base subsume mid -end addshape  4 2  0 0 0 0 2 0 -end move 0 4 0 -mid subsume end diff --git a/share/hackvr/examples/subsume/test.sh b/share/hackvr/examples/subsume/test.sh deleted file mode 100755 index 67139ac..0000000 --- a/share/hackvr/examples/subsume/test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -cat arms.hackvr - -# these start all straight-up, rotate counter clockwise as rotation increases, and -# at these rates of rotation they should all be curled in on themselves at the bottom. -while true;do -  printf "base rotate 0 0 +1\n" -  printf "mid  rotate 0 0 +2\n" -  printf "end  rotate 0 0 +3\n" -  sleep .1 -done diff --git a/share/hackvr/examples/tictactoe/board b/share/hackvr/examples/tictactoe/board deleted file mode 100644 index e7494fd..0000000 --- a/share/hackvr/examples/tictactoe/board +++ /dev/null @@ -1,13 +0,0 @@ -_reset addshape 2 3 -4 6 4 -5 6 4 -4 5 4 - -boardtopleft addshape 2 4 -3 13 4 -1 13 4 -1 11 4 -3 11 4 -boardtopcenter addshape 2 4 -1 13 4 1 13 4 1 11 4 -1 11 4 -boardtopright addshape 2 4 1 13 4 3 13 4 3 11 4 1 11 4 - -boardmiddleleft addshape 2 4 -3 11 4 -1 11 4 -1 9 4 -3 9 4 -boardmiddlecenter addshape 2 4 -1 11 4 1 11 4 1 9 4 -1 9 4 -boardmiddleright addshape 2 4 1 11 4 3 11 4 3 9 4 1 9 4 - -boardbottomleft addshape 2 4 -3 9 4 -1 9 4 -1 7 4 -3 7 4 -boardbottomcenter addshape 2 4 -1 9 4 1 9 4 1 7 4 -1 7 4 -boardbottomright addshape 2 4 1 9 4 3 9 4 3 7 4 1 7 4 diff --git a/share/hackvr/examples/tictactoe/board_orig b/share/hackvr/examples/tictactoe/board_orig deleted file mode 100644 index 2fff3ba..0000000 --- a/share/hackvr/examples/tictactoe/board_orig +++ /dev/null @@ -1,14 +0,0 @@ -_reset addshape 2 3 -4 -4 4 -5 -4 4 -4 -5 4 -_exit addshape 2 3 4 -4 4 5 -4 4 4 -5 4 - -boardtopleft addshape 2 4 -3 3 4 -1 3 4 -1 1 4 -3 1 4 -boardtopcenter addshape 2 4 -1 3 4 1 3 4 1 1 4 -1 1 4 -boardtopright addshape 2 4 1 3 4 3 3 4 3 1 4 1 1 4 - -boardmiddleleft addshape 2 4 -3 1 4 -1 1 4 -1 -1 4 -3 -1 4 -boardmiddlecenter addshape 2 4 -1 1 4 1 1 4 1 -1 4 -1 -1 4 -boardmiddleright addshape 2 4 1 1 4 3 1 4 3 -1 4 1 -1 4 - -boardbottomleft addshape 2 4 -3 -1 4 -1 -1 4 -1 -3 4 -3 -3 4 -boardbottomcenter addshape 2 4 -1 -1 4 1 -1 4 1 -3 4 -1 -3 4 -boardbottomright addshape 2 4 1 -1 4 3 -1 4 3 -3 4 1 -3 4 diff --git a/share/hackvr/examples/tictactoe/camera.pos b/share/hackvr/examples/tictactoe/camera.pos deleted file mode 100644 index ef8e9da..0000000 --- a/share/hackvr/examples/tictactoe/camera.pos +++ /dev/null @@ -1,5 +0,0 @@ -junk set global.zoom 45 -junk set camera.p.z -6 -junk set camera.p.y -1 -junk set camera.p.x 0 - diff --git a/share/hackvr/examples/tictactoe/game.sh b/share/hackvr/examples/tictactoe/game.sh deleted file mode 100755 index a2adeb1..0000000 --- a/share/hackvr/examples/tictactoe/game.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -turn=$( expr $RANDOM % 2) -BOARDFILE=board_orig -cat camera.pos $BOARDFILE -echo "go. player: $turn" >&2 -grep --line-buffered action \ -  | while read user action group;do -    if [ $action = "action" ];then -      if grep "_reset" <<<$group >/dev/null;then -       printf "%s deleteallexcept %s\n" "$user" "$user" -       cat $BOARDFILE -       continue -      elif grep "_exit" <<<$group >/dev/null;then -       #if a program wants to exit, it should just exit. -       #the program may have been ran by some other program. -       #maybe just filter out server-side quit messages for your own username? -       #any user quit will cause any hackvr to quit? -       #printf "%s quit\n" "$user" -       exit 0 -      elif grep "_" <<<$group >/dev/null;then -       echo CUT IT OUT > /dev/stderr -       continue -      elif grep "^board" <<<$group >/dev/null;then -       turn=$(expr \( $turn + 1 \) % 2) -       #printf "# turn: %d\n" "$turn" > /dev/stderr -       printf "%s deletegroup %s\n" "$user" "$group" -       #printf "$user deletegroup %s\n" "$group" > /dev/stderr -#need to get the first point of the group clicked and translate the new shape by that much -       translatex="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)" -       translatey="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)" -       cat "marker$turn" | offsetshape.sh $translatex "$(expr "$translatey" - 2 )" 0 -       grep "$group" $BOARDFILE | sed "s/$group/_marked/g" -      else -       printf "# clicked outside of the game board.\n" >&2 -      fi -    fi -  done diff --git a/share/hackvr/examples/tictactoe/listen.sh b/share/hackvr/examples/tictactoe/listen.sh deleted file mode 100755 index deac685..0000000 --- a/share/hackvr/examples/tictactoe/listen.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -#to finish out any that might still be listening -nc -z 127.0.0.1 1050 -nc -z 127.0.0.1 1051 - -echo hackvr://$(hostname).$(domainname):1050/ player 1 -echo hackvr://$(hostname).$(domainname):1051/ player 2 - -coproc ./game.sh -tee >(ncat -lp 1050 >&"${COPROC[1]}") >(ncat -lp 1051 >&"${COPROC[1]}") >/dev/null <&"${COPROC[0]}" diff --git a/share/hackvr/examples/tictactoe/marker0 b/share/hackvr/examples/tictactoe/marker0 deleted file mode 100644 index 5bc0c5c..0000000 --- a/share/hackvr/examples/tictactoe/marker0 +++ /dev/null @@ -1,2 +0,0 @@ -_marker addshape 1 2 .5 .5 2 1.5 1.5 2 -_marker addshape 1 2 1.5 .5 2 .5 1.5 2 diff --git a/share/hackvr/examples/tictactoe/marker1 b/share/hackvr/examples/tictactoe/marker1 deleted file mode 100644 index e7aa5a7..0000000 --- a/share/hackvr/examples/tictactoe/marker1 +++ /dev/null @@ -1 +0,0 @@ -_marker addshape 3 4 1.5 1.5 2 .5 1.5 2 .5 .5 2 1.5 .5 2 diff --git a/share/hackvr/examples/tictactoe/run b/share/hackvr/examples/tictactoe/run deleted file mode 100755 index 54d712a..0000000 --- a/share/hackvr/examples/tictactoe/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -turn=$( expr $RANDOM % 2) -echo "# go. player: $turn" >&2 -hackvr_coproc ./game.sh diff --git a/share/hackvr/examples/uristart.conf b/share/hackvr/examples/uristart.conf deleted file mode 100644 index d48e8d1..0000000 --- a/share/hackvr/examples/uristart.conf +++ /dev/null @@ -1,2 +0,0 @@ -hackvr:         if [ "%u" ];then USER="%u";fi;ncat '%d' '%P' -c "echo $USER action %p;hackvr_uri" -hackvr+ssh:     if [ '%u' ];then u='%u@';fi ; if [ "%P" ];then P='-p %P';fi; hackvr_coproc ssh "$u"'%d' $P "/var/hackvr/hackvr-subsystem" '%p' diff --git a/share/hackvr/examples/wget-log b/share/hackvr/examples/wget-log deleted file mode 100644 index e69de29..0000000 --- a/share/hackvr/examples/wget-log +++ /dev/null diff --git a/share/hackvr/examples/wget-log.1 b/share/hackvr/examples/wget-log.1 deleted file mode 100644 index e69de29..0000000 --- a/share/hackvr/examples/wget-log.1 +++ /dev/null diff --git a/share/hackvr/examples/wget-log.2 b/share/hackvr/examples/wget-log.2 deleted file mode 100644 index e69de29..0000000 --- a/share/hackvr/examples/wget-log.2 +++ /dev/null diff --git a/share/hackvr/examples/wordsearch/game.sh b/share/hackvr/examples/wordsearch/game.sh deleted file mode 100755 index 3c30be1..0000000 --- a/share/hackvr/examples/wordsearch/game.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -## you might want to edit these to suit your tastes. -width=10 -height=$width -words_per_puzzle=$[width] -x=$[-10 * $width / 2] -y=$[10 * $width / 2] -z=0 -clicked="" -wordlist=/usr/share/dict/words -echo derp -wordsearch -w <(shuf $wordlist 2>/dev/null | grep '^.\{1,'"$width"'\}$' 2>/dev/null | head -n $words_per_puzzle | tee /dev/stderr) --columns $width --rows $height --text | tail -n+4 | head -n $height | while read -r line;do -  echo "$line" | tr -d ' ' | fold -w 1 | while read letter;do -    name="_${x}_${y}" -    printf "%s addshape 2 4 %s %s %s  %s %s %s  %s %s %s  %s %s %s\n" \ -            "$name" \ -            $[$x-2] $[$y-3] $z \ -            $[$x+8] $[$y-3] $z \ -            $[$x+8] $[$y+7] $z \ -            $[$x-2] $[$y+7] $z -    echo $letter | makelabel.sh "$name" $x $y $z -    x=$[$x+10] -  done -  y=$[$y-10] -done -while read group action args;do -  if [ $action = action ];then -    if grep "$args" <<< "$clicked" 2>&1 >/dev/null;then -      clicked=$(grep -v '^'"$args"'$' <<< "$clicked") -      printf "%s move 0 0 0\n" "$args" -    else -      clicked="$clicked"$'\n'"$args" -      printf "%s move 0 0 -5\n" "$args" -    fi -#    xmessage -nearmouse "$args" -  fi -done diff --git a/share/hackvr/examples/wordsearch/run b/share/hackvr/examples/wordsearch/run deleted file mode 100755 index 48d107c..0000000 --- a/share/hackvr/examples/wordsearch/run +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# just need to get some way for these to coproc -if ! which wordsearch >/dev/null;then -  echo "we need wordsearch installed to generate the puzzle" -  echo "please read: https://github.com/jamis/wordsearch" -  exit 1 -fi -socat exec:hackvr exec:./game.sh diff --git a/share/hackvr/examples/xcmd.sh b/share/hackvr/examples/xcmd.sh deleted file mode 100755 index df6279a..0000000 --- a/share/hackvr/examples/xcmd.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -exec $* | xclip -i | xclip -o | xmessage -buttons ok:0,pipe:1 -file - || exit 0 -#ask for command -xclip -o | eval $(zenity --entry) | 
