summaryrefslogtreecommitdiff
path: root/Source/Applications
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Applications')
-rw-r--r--Source/Applications/Demos/GOL.cpp7
-rw-r--r--Source/Applications/PaperWork/Makefile2
-rw-r--r--Source/Applications/PaperWork/PaperWork.cpp13
-rwxr-xr-xSource/Applications/Shell/Applets/rot13bin0 -> 73404 bytes
-rw-r--r--Source/Applications/Shell/Applets/rot13.cpp30
-rw-r--r--Source/Applications/Shell/Makefile8
-rw-r--r--Source/Applications/Shell/Shell-fs.class.cpp4
-rw-r--r--Source/Applications/Shell/Shell.class.cpp5
-rw-r--r--Source/Applications/Shell/main.cpp5
9 files changed, 54 insertions, 20 deletions
diff --git a/Source/Applications/Demos/GOL.cpp b/Source/Applications/Demos/GOL.cpp
index 675c159..ba9cb1c 100644
--- a/Source/Applications/Demos/GOL.cpp
+++ b/Source/Applications/Demos/GOL.cpp
@@ -46,7 +46,8 @@ int GOL::run() {
}
}
outvt.moveCursor(0, 0);
- outvt << tmp.toString() << "Press Ctrl+h for help";
+ outvt.write(tmp.toString()); //BYPASS buffering
+ outvt<< "Press Ctrl+h for help" << FLUSH;
//Compute next generation
for (int y = 0; y < h; y++) {
@@ -92,7 +93,7 @@ int GOL::run() {
cells[x * h + y] = true;
}
} else if (kp.character == WChar("p")) {
- outvt << " [PAUSED] press a key to resume";
+ outvt << " [PAUSED] press a key to resume" << FLUSH;
invt.getKeypress();
} else if (kp.character == WChar("h")) {
outvt << "\n\n** Melon's demo Game Of Life Simulator help :\n";
@@ -101,7 +102,7 @@ int GOL::run() {
outvt << " - ctrl+p : pause\n";
outvt << " - ctrl+r : add some random cells\n";
outvt << " - ctrl+R : add more cells, still random\n\n";
- outvt << "Press any key to return to simultaor...";
+ outvt << "Press any key to return to simultaor..." << FLUSH;
invt.getKeypress();
}
kp = invt.getKeypress(false, false);
diff --git a/Source/Applications/PaperWork/Makefile b/Source/Applications/PaperWork/Makefile
index d3203cf..8d079ec 100644
--- a/Source/Applications/PaperWork/Makefile
+++ b/Source/Applications/PaperWork/Makefile
@@ -4,7 +4,7 @@ CXX = g++
CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND
LD = ld
-LDFLAGS = -T ../../Library/Link.ld -L ../../Library
+LDFLAGS = -T ../../Library/Link.ld -L ../../Library -Map Map.txt
Objects = PaperWork.o
OutFile = PaperWork
diff --git a/Source/Applications/PaperWork/PaperWork.cpp b/Source/Applications/PaperWork/PaperWork.cpp
index 4f9cb0e..15497e4 100644
--- a/Source/Applications/PaperWork/PaperWork.cpp
+++ b/Source/Applications/PaperWork/PaperWork.cpp
@@ -1,6 +1,7 @@
#include <App/ShellApp.proto.h>
#define DEFAULT_SHELL "/Applications/Shell/Shell.app"
+#define PAPERWORK_PATH "/System/Applications/PaperWork.app"
class PaperWork : public ShellApp {
public:
@@ -20,7 +21,7 @@ int PaperWork::run() {
if (act == "init") {
while (1) {
- Process p = Process::run("/System/Applications/PaperWork.app");
+ Process p = Process::run(PAPERWORK_PATH);
if (p.valid()) {
p.setInVT(invt);
p.setOutVT(outvt);
@@ -35,16 +36,16 @@ int PaperWork::run() {
outvt << "Logging in to Melon\n";
String user, pw;
while (1) {
- outvt << "Username: ";
- user = invt.readLine();
- outvt << "Password: ";
+ outvt << "Username: " << FLUSH;
+ user = invt.get();
+ outvt << "Password: " << FLUSH;
pw = invt.readLine(false);
if (!Process::get().authenticatePW(user, pw)) {
outvt << "Authentication failed.\n\n";
continue;
}
- outvt << "What shell to run [" << sFlag("shell") << "]? ";
- String sh = invt.readLine();
+ outvt << "What shell to run [" << sFlag("shell") << "]? "<< FLUSH;
+ String sh = invt.get();
if (sh == "") sh = sFlag("shell");
Process p = Process::run(sh);
if (p.valid()) {
diff --git a/Source/Applications/Shell/Applets/rot13 b/Source/Applications/Shell/Applets/rot13
new file mode 100755
index 0000000..0399a6f
--- /dev/null
+++ b/Source/Applications/Shell/Applets/rot13
Binary files differ
diff --git a/Source/Applications/Shell/Applets/rot13.cpp b/Source/Applications/Shell/Applets/rot13.cpp
new file mode 100644
index 0000000..e5638b8
--- /dev/null
+++ b/Source/Applications/Shell/Applets/rot13.cpp
@@ -0,0 +1,30 @@
+#include <App/StreamApp.proto.h>
+
+class rot13 : public StreamApp {
+ public:
+ rot13() : StreamApp("rot13", "Cat a file, but ROT13 it") {}
+ int run();
+};
+
+APP(rot13);
+
+int rot13::run() {
+ while (!in->eof()) {
+ String s = in->get();
+ if (in->eof() && s.empty()) break;
+ for (u32int i = 0; i < s.size(); i++) {
+ WChar &c = s[i];
+ if (c >= WChar('A') and c <= WChar('Z')) {
+ c += 13;
+ if (c > WChar('Z')) c -= 26;
+ }
+ if (c >= WChar('a') and c <= WChar('z')) {
+ c += 13;
+ if (c > WChar('z')) c -= 26;
+ }
+ }
+ *out << s << ENDL;
+ }
+ return 0;
+}
+
diff --git a/Source/Applications/Shell/Makefile b/Source/Applications/Shell/Makefile
index d546a15..e972dfb 100644
--- a/Source/Applications/Shell/Makefile
+++ b/Source/Applications/Shell/Makefile
@@ -10,7 +10,9 @@ Objects = Shell.class.o \
Shell-fs.class.o
OutFile = Shell
-all: $(OutFile)
+Applets = Applets/rot13
+
+all: $(OutFile) $(Applets)
echo "* Done with $(OutFile)."
rebuild: mrproper all
@@ -19,6 +21,10 @@ $(OutFile): $(Objects)
echo "* Linking $@..."
$(LD) $(LDFLAGS) $^ -o $@
+Applets/%: Applets/%.o
+ echo "* Linking $@..."
+ $(LD) $(LDFLAGS) $^ -o $@ -Map $@.map
+
%.o: %.cpp
echo "* Compiling $<..."
$(CXX) $(CXXFLAGS) -c $< -o $@
diff --git a/Source/Applications/Shell/Shell-fs.class.cpp b/Source/Applications/Shell/Shell-fs.class.cpp
index 150b877..30faaf7 100644
--- a/Source/Applications/Shell/Shell-fs.class.cpp
+++ b/Source/Applications/Shell/Shell-fs.class.cpp
@@ -28,11 +28,11 @@ void Shell::ls(Vector<String>& args) {
if (((p >> i) & 1) == 0) perm[8 - i] = "-";
}
if (n.type() == NT_FILE) {
- outvt << " FILE " << perm << " " << n.getName();
+ outvt << " FILE " << perm << " " << n.getName() << FLUSH;
outvt.setCsrCol(30);
outvt << (s32int)n.getLength() << " bytes.\n";
} else if (n.type() == NT_DIRECTORY) {
- outvt << " DIR " << perm << " " << n.getName() << "/";
+ outvt << " DIR " << perm << " " << n.getName() << "/" << FLUSH;
outvt.setCsrCol(30);
outvt << (s32int)n.getLength() << " items.\n";
}
diff --git a/Source/Applications/Shell/Shell.class.cpp b/Source/Applications/Shell/Shell.class.cpp
index 3d406c8..4283b30 100644
--- a/Source/Applications/Shell/Shell.class.cpp
+++ b/Source/Applications/Shell/Shell.class.cpp
@@ -25,8 +25,9 @@ int Shell::run() {
cwd = FS::cwdNode();
while (1) {
- outvt << "{" << cwd.getName() << "}: ";
- String s = invt.readLine();
+ outvt << "{" << cwd.getName() << "}: " << FLUSH;
+ String s = invt.get();
+ if (s.contains(EOF)) return 0;
if (s.empty()) continue;
while (s[0] == WChar(" ") or s[0] == WChar("\t")) {
s = s.substr(1, s.size() - 1);
diff --git a/Source/Applications/Shell/main.cpp b/Source/Applications/Shell/main.cpp
deleted file mode 100644
index 66c4269..0000000
--- a/Source/Applications/Shell/main.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "Shell.ns.h"
-
-int main(const Vector<String>& args) {
- return Shell::run();
-}