diff --git a/assets/disk0/tvdos/bin/command.js b/assets/disk0/tvdos/bin/command.js index 56b4135..70e2763 100644 --- a/assets/disk0/tvdos/bin/command.js +++ b/assets/disk0/tvdos/bin/command.js @@ -661,7 +661,7 @@ shell.execute = function(line) { shell.pipes = {} // syntax: _G.shell.pipes[name] = contents; all pipes are named pipes just like in Windows shell.currentlyActivePipes = [] // Queue of pipe's names. Use shell.removePipe() to dequeue and shell.pushPipe() to enqueue. shell._rndstr = '0123456789+qwfpgjluyarstdhneiozxcvbkm/QWFPGJLUYARSTDHNEIOZXCVBKM' -shell.generateRandomName = function() { +shell.generateAnonPipeName = function() { let name = '' while (true) { name = "anonpipe_" @@ -682,7 +682,7 @@ shell.appendToCurrentPipe = function(s) { shell.pipes[n] = content += s } shell.pushAnonPipe = function(contents) { - let name = shell.generateRandomName() + let name = shell.generateAnonPipeName() shell.pushPipe(name, contents) } shell.pushPipe = function(name, contents) { diff --git a/doc/bibliography.tex b/doc/bibliography.tex index 1cf56df..3092426 100644 --- a/doc/bibliography.tex +++ b/doc/bibliography.tex @@ -1,3 +1,5 @@ \begin{itemlist} \item Song, Minjae. 2021. ``Terran BASIC Reference Manual for Language Version 1.2, Third Edition''. +\item Wikipedia. ``List of DOS commands.'' Updated 2022-08-29 15:00. \url{https://en.wikipedia.org/wiki/List_of_DOS_commands}. +\item Wikipedia. ``Pipeline (software).'' Updated 2022-07-17 06:21. \url{https://en.wikipedia.org/wiki/Pipeline_(software)}. \end{itemlist} diff --git a/doc/implementation.tex b/doc/implementation.tex index 00c3025..9dcb4d4 100644 --- a/doc/implementation.tex +++ b/doc/implementation.tex @@ -1,4 +1,4 @@ -\chapter{Virtual Machine} +\chapter{\thismachine} \section{Specs} @@ -14,9 +14,7 @@ There are three memories on the system: Hardware Memory (8 MB), Scratchpad Memor Your Javascript program is stored into the Program Memory, and since its capacity is limitless, you can put a large graphics directly into your Javascript source code, but the Program Memory is the slowest of all three memories. For faster graphics, you need to store them onto the Scratchpad Memory then DMA-Copy them to the graphics adapter. -\section{Built-in Commands} - -\subsection{Javascript Extensions} +\section{Javascript Extensions} \index{js extensions}\thismachine\ provides the extra functions for your convenience. @@ -29,7 +27,13 @@ Your Javascript program is stored into the Program Memory, and since its capacit \1\inlinesynopsis[Array]{max}{selector}{returns the maximum among the elements of the array. Selector is optionally defined to indicate how the value must be transformed to obtain the max.} \end{outline} -\subsection{Standard Input and Output} + + +\chapter{Libraries} + + + +\section{Standard Input and Output} \index{stdio (library)}These are standard input/output functions: @@ -41,9 +45,7 @@ Your Javascript program is stored into the Program Memory, and since its capacit \1\inlinesynopsis{read}{}{reads a string from the keyboard. Hit the Return to finish reading.} \end{outline} - - -\subsection{Console} +\section{Console} \index{console (library)}Console library contains the functions for screen text manipulation. @@ -93,7 +95,7 @@ Functions: -\subsection{Gzip} +\section{Gzip} \index{gzip (library)}Gzip allows texts and bytes and compressed and decompressed using the gzip format. @@ -114,7 +116,7 @@ Functions: -\subsection{Base64} +\section{Base64} \index{base64 (library)}Base64 allows encoding of the binary data into the ASCII-strings and vice-versa. @@ -128,7 +130,7 @@ Functions: -\subsection{Sys} +\section{Sys} Sys library allows programmers to manipulate the system in low-level. @@ -775,7 +777,12 @@ TODO \section{The Graphics Library} +\index{graphics (library)}Graphics library provides basic functions to communicate and manipulate the graphics adapter. +\namespaceis{Graphics}{graphics} + +\begin{outline} +\end{outline} \section{Graphics MMIO} diff --git a/doc/tsvmman.idx b/doc/tsvmman.idx index 854589b..d293c01 100644 --- a/doc/tsvmman.idx +++ b/doc/tsvmman.idx @@ -1,25 +1,28 @@ \indexentry{js extensions|hyperpage}{7} -\indexentry{stdio (library)|hyperpage}{8} -\indexentry{console (library)|hyperpage}{8} -\indexentry{con (library)|hyperpage}{8} -\indexentry{gzip (library)|hyperpage}{10} -\indexentry{gzip (library)|hyperpage}{10} -\indexentry{base64 (library)|hyperpage}{11} -\indexentry{base64 (library)|hyperpage}{11} -\indexentry{sys (library)|hyperpage}{12} -\indexentry{block communication|hyperpage}{15} -\indexentry{com (library)|hyperpage}{15} -\indexentry{com (library)|hyperpage}{15} -\indexentry{MMIO-com|hyperpage}{17} -\indexentry{keycodes|hyperpage}{19} -\indexentry{code page|hyperpage}{21} -\indexentry{colour palette|hyperpage}{23} -\indexentry{MMIO-graphics|hyperpage}{25} -\indexentry{boot process|hyperpage}{28} -\indexentry{commands (DOS)|hyperpage}{29} -\indexentry{coreutils (DOS)|hyperpage}{29} -\indexentry{filesystem (DOS)|hyperpage}{30} -\indexentry{file descriptor (DOS)|hyperpage}{30} -\indexentry{device file|hyperpage}{32} -\indexentry{input (DOS)|hyperpage}{34} -\indexentry{gl (DOS)|hyperpage}{34} +\indexentry{stdio (library)|hyperpage}{9} +\indexentry{console (library)|hyperpage}{9} +\indexentry{con (library)|hyperpage}{9} +\indexentry{gzip (library)|hyperpage}{11} +\indexentry{gzip (library)|hyperpage}{11} +\indexentry{base64 (library)|hyperpage}{12} +\indexentry{base64 (library)|hyperpage}{12} +\indexentry{sys (library)|hyperpage}{13} +\indexentry{block communication|hyperpage}{16} +\indexentry{com (library)|hyperpage}{16} +\indexentry{com (library)|hyperpage}{16} +\indexentry{MMIO-com|hyperpage}{18} +\indexentry{keycodes|hyperpage}{20} +\indexentry{code page|hyperpage}{22} +\indexentry{colour palette|hyperpage}{24} +\indexentry{graphics (library)|hyperpage}{26} +\indexentry{graphics (library)|hyperpage}{26} +\indexentry{MMIO-graphics|hyperpage}{26} +\indexentry{boot process|hyperpage}{29} +\indexentry{commands (DOS)|hyperpage}{30} +\indexentry{coreutils (DOS)|hyperpage}{30} +\indexentry{pipe (DOS)|hyperpage}{32} +\indexentry{filesystem (DOS)|hyperpage}{34} +\indexentry{file descriptor (DOS)|hyperpage}{34} +\indexentry{device file|hyperpage}{36} +\indexentry{input (DOS)|hyperpage}{38} +\indexentry{gl (DOS)|hyperpage}{38} diff --git a/doc/tsvmman.ilg b/doc/tsvmman.ilg index 3193d5b..236050f 100644 --- a/doc/tsvmman.ilg +++ b/doc/tsvmman.ilg @@ -1,6 +1,6 @@ This is makeindex, version 2.16 [TeX Live 2022] (kpathsea + Thai support). -Scanning input file tsvmman.idx....done (25 entries accepted, 0 rejected). -Sorting entries....done (120 comparisons). -Generating output file tsvmman.ind....done (53 lines written, 0 warnings). +Scanning input file tsvmman.idx....done (28 entries accepted, 0 rejected). +Sorting entries....done (138 comparisons). +Generating output file tsvmman.ind....done (58 lines written, 0 warnings). Output written in tsvmman.ind. Transcript written in tsvmman.ilg. diff --git a/doc/tsvmman.ind b/doc/tsvmman.ind index c22607e..f776bb6 100644 --- a/doc/tsvmman.ind +++ b/doc/tsvmman.ind @@ -1,36 +1,37 @@ \begin{theindex} - \item base64 (library), \hyperpage{11} - \item block communication, \hyperpage{15} - \item boot process, \hyperpage{28} + \item base64 (library), \hyperpage{12} + \item block communication, \hyperpage{16} + \item boot process, \hyperpage{29} \indexspace - \item code page, \hyperpage{21} - \item colour palette, \hyperpage{23} - \item com (library), \hyperpage{15} - \item commands (DOS), \hyperpage{29} - \item con (library), \hyperpage{8} - \item console (library), \hyperpage{8} - \item coreutils (DOS), \hyperpage{29} + \item code page, \hyperpage{22} + \item colour palette, \hyperpage{24} + \item com (library), \hyperpage{16} + \item commands (DOS), \hyperpage{30} + \item con (library), \hyperpage{9} + \item console (library), \hyperpage{9} + \item coreutils (DOS), \hyperpage{30} \indexspace - \item device file, \hyperpage{32} + \item device file, \hyperpage{36} \indexspace - \item file descriptor (DOS), \hyperpage{30} - \item filesystem (DOS), \hyperpage{30} + \item file descriptor (DOS), \hyperpage{34} + \item filesystem (DOS), \hyperpage{34} \indexspace - \item gl (DOS), \hyperpage{34} - \item gzip (library), \hyperpage{10} + \item gl (DOS), \hyperpage{38} + \item graphics (library), \hyperpage{26} + \item gzip (library), \hyperpage{11} \indexspace - \item input (DOS), \hyperpage{34} + \item input (DOS), \hyperpage{38} \indexspace @@ -38,16 +39,20 @@ \indexspace - \item keycodes, \hyperpage{19} + \item keycodes, \hyperpage{20} \indexspace - \item MMIO-com, \hyperpage{17} - \item MMIO-graphics, \hyperpage{25} + \item MMIO-com, \hyperpage{18} + \item MMIO-graphics, \hyperpage{26} \indexspace - \item stdio (library), \hyperpage{8} - \item sys (library), \hyperpage{12} + \item pipe (DOS), \hyperpage{32} + + \indexspace + + \item stdio (library), \hyperpage{9} + \item sys (library), \hyperpage{13} \end{theindex} diff --git a/doc/tsvmman.tex b/doc/tsvmman.tex index 6a5eab4..e02d84d 100644 --- a/doc/tsvmman.tex +++ b/doc/tsvmman.tex @@ -244,7 +244,7 @@ \part{The Virtual Machine} \input{implementation} -\part{\thedos} +\part{The DOS} \input{tvdos} \part*{Bibliography} @@ -265,7 +265,7 @@ The source code for \thismachine\ and this documentation are distributed under the following terms: -\copyright\ 2020-- \ Minjae Song (``CuriousTorvald'') +\copyright\ 2021-- \ Minjae Song (``CuriousTorvald'') Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal diff --git a/doc/tvdos.tex b/doc/tvdos.tex index 05f0671..63e0375 100644 --- a/doc/tvdos.tex +++ b/doc/tvdos.tex @@ -1,4 +1,4 @@ -\chapter{Introduction} +\chapter{\thedos} \thedos\ is a Disk Operating System (usually) bundled with the distribution of the \thismachine. @@ -34,8 +34,6 @@ Variables can be set or changed using \textbf{SET} commands. \index{commands (DOS)}\index{coreutils (DOS)}DOS commands are only valid under the DOS environment. -To invoke the DOS commands from the Javascript-side, use:\\ \code{\_G.shell.coreutils.*} - \begin{outline} \1\dossynopsis{cat}{file}{Reads a file and pipes its contents to the pipe, or to the console if no pipes are specified.} \1\dossynopsis{cd}{dir}{Change the current working directory. Alias: chdir} @@ -54,6 +52,49 @@ To invoke the DOS commands from the Javascript-side, use:\\ \code{\_G.shell.core +\chapter{Using DOS Utils on JS} + +DOS coreutils and some of the internal functions can be used on Javascript program. + +To invoke the coreutils, use \code{\_G.shell.coreutils.*} + +\begin{outline} +\1\inlinesynopsis[\_G.shell]{resolvePathInput}{path}{Returns fully-qualified path of the input path, relative to the current working directory.} +\1\inlinesynopsis[\_G.shell]{getPwdString}{}{Returns the current working directory as a string.} +\1\inlinesynopsis[\_G.shell]{getCurrentDrive}{}{Returns the drive letter of the current working drive.} +\1\inlinesynopsis[\_G.shell]{execute}{command}{Executes the DOS command.} +\end{outline} + + + +\chapter{Pipes} + +\index{pipe (DOS)}Pipe is a way to chain the IO of the one program/command into the different programs/commands in series. + +A pipe can be either named or anonymous: named pipes are ones that are created by the user while the anonymous pipes are created by the DOS process as a result of the command pipelining. + +\section{Command Pipelining} + +In \thedos, a pipe can be used to route the output of a command into the other command. For example, \code{dir | less} will route the output of the \code{dir} into the text viewer called \code{less} so that the user can take their time examining the list of files in the directory, even if the list is taller that the terminal's height. + +\section{User-defined Pipe} + +A user program can create and interact with the pipe so long as it's \emph{named}. The contents of the pipe can be read and modified just like a Javascript variable. + +Named pipes can be retrieved on \code{\_G.shell.pipes.*} + +\section{Pipe-related Functions} + +\begin{outline} +\1\inlinesynopsis[\_G.shell]{getPipe}{}{Returns the currently opened pipe. \code{undefined} is returned if no pipes are opened.} +\1\inlinesynopsis[\_G.shell]{appendToCurrentPipe}{text}{Appends the given text to the current pipe.} +\1\inlinesynopsis[\_G.shell]{pushAnonPipe}{contents}{Pushes an anonymous pipe to the current pipe stack.} +\1\inlinesynopsis[\_G.shell]{pushPipe}{pipeName, contents}{Pushes the pipe of given name to the current pipe stack.} +\1\inlinesynopsis[\_G.shell]{hasPipe}{}{Returns true if there is a pipe currently opened.} +\1\inlinesynopsis[\_G.shell]{removePipe}{}{Destroys the currently opened pipe and returns it. Any pipes on the pipe stack will be shifted down to become the next current pipe.} +\end{outline} + + \chapter{File I/O} \index{filesystem (DOS)}In \thedos, drives are assigned with a drive letter, and the drive currently booted on is always drive \textbf{A}. @@ -133,7 +174,7 @@ Functions: \chapter{DOS Libraries} -\section{The Input Library} +\section{Input} \dosnamespaceis{Input}{input} @@ -142,7 +183,7 @@ Functions: -\section{The GL} +\section{GL} \dosnamespaceis{Graphics}{gl}