summaryrefslogtreecommitdiff
path: root/Source/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Library')
-rw-r--r--Source/Library/App.ld (renamed from Source/Library/Link.ld)2
-rw-r--r--Source/Library/Interface/VirtualTerminal.iface.h58
-rw-r--r--Source/Library/Makefile10
-rw-r--r--Source/Library/Melon.abin0 -> 11678 bytes
-rw-r--r--Source/Library/Userland/Binding/VirtualTerminal.class.h48
5 files changed, 80 insertions, 38 deletions
diff --git a/Source/Library/Link.ld b/Source/Library/App.ld
index 68591fd..793949a 100644
--- a/Source/Library/Link.ld
+++ b/Source/Library/App.ld
@@ -1,5 +1,5 @@
ENTRY (start)
-INPUT (Melon.o)
+INPUT (libMelon.o)
SECTIONS{
. = 0x10000000;
diff --git a/Source/Library/Interface/VirtualTerminal.iface.h b/Source/Library/Interface/VirtualTerminal.iface.h
index e0f59d5..9196771 100644
--- a/Source/Library/Interface/VirtualTerminal.iface.h
+++ b/Source/Library/Interface/VirtualTerminal.iface.h
@@ -8,21 +8,69 @@
#define VTIF_SGETPROUTVT 7 //Get process output virtual terminal (R) | no arguments
#define VTIF_PUT 0x01 //Put one character to virtual terminal (v) | c:character
-#define VTIF_WRITEHEX 0x02 //Write a number in hexadecimal (v) | i:number
-#define VTIF_WRITEDEC 0x03 //Write a number in decimal (v) | j:number, J:number
-#define VTIF_WRITE 0x04 //Write a string (v) | S:string
+#define VTIF_WRITE 0x02 //Write a string (v) | S:string
+
+/* EVERYTHING NOW GOES THROUGH VTIF_WRITE
+#define VTIF_WRITEHEX 0x03 //Write a number in hexadecimal (v) | i:number
+#define VTIF_WRITEDEC 0x04 //Write a number in decimal (v) | j:number, J:number
+*/
#define VTIF_READLINE 0x05 //Reads a line from virtual terminal (S) : b:show?
#define VTIF_GETKEYPRESS 0x06 //Get a keypress from virtual terminal (*) : i:flags
//Takes two flags : 1<<0 = show, 1<<1 = block
-
+/* EVERYTHING NOW GOES THROUGH VTIF_WRITE
#define VTIF_SETCOLOR 0x10 //Set text color (v) | i:foreground_color, i:backgrond_color
#define VTIF_SETCSRLINE 0x11 //Set cursor line (v) | i:line
#define VTIF_SETCSRCOL 0x12 //Set cursor column (v) | i:column
+#define VTIF_LOCATE 0x13 //Sets cursor position (v) | i:line, i:column
+*/
#define VTIF_ISBOXED 0x13 //Is VT boxed ? (b) | no arguments
#define VTIF_GETHEIGHT 0x1A //Get VT width (i) | no arguments
#define VTIF_GETWIDTH 0x1B //Get VT height (i) | no arguments
-#define VTIF_LOCATE 0x1C //Sets cursor position (v) | i:line, i:column
+
+// ***** MELON VT SPECIFIC ESCAPE COMMANDS **
+#define MVT_ESC "\032"
+
+struct mvt_esc_cmd_t {
+ int cmd;
+ int a, b;
+};
+
+#define MVTCMD0(name, command) \
+ inline mvt_esc_cmd_t name() { \
+ mvt_esc_cmd_t ret; ret.cmd = command; return ret; }
+
+#define MVTCMD1(name, command) \
+ inline mvt_esc_cmd_t name(int a) { \
+ mvt_esc_cmd_t ret; ret.cmd = command; ret.a = a; return ret; }
+
+#define MVTCMD2(name, command) \
+ inline mvt_esc_cmd_t name(int a, int b) { \
+ mvt_esc_cmd_t ret; ret.cmd = command; ret.a = a; ret.b = b; return ret; }
+
+#define MVTCMD_CLEAR 0x100
+#define MVTCMD_SCROLL 0x101
+#define MVTCMD_SETCOLOR 0x110
+#define MVTCMD_SETBGCOLOR 0x111
+#define MVTCMD_SETFGCOLOR 0x112
+#define MVTCMD_MOVECSR 0x120
+#define MVTCMD_SETCSRLIN 0x121
+#define MVTCMD_SETCSRCOL 0x122
+#define MVTCMD_HIDECSR 0x130
+#define MVTCMD_SHOWCSR 0x131
+
+namespace MVT {
+ MVTCMD0(clear, MVTCMD_CLEAR);
+ MVTCMD0(scroll, MVTCMD_SCROLL);
+ MVTCMD2(setcolor, MVTCMD_SETCOLOR);
+ MVTCMD1(setbgcolor, MVTCMD_SETBGCOLOR);
+ MVTCMD1(setfgcolor, MVTCMD_SETFGCOLOR);
+ MVTCMD2(movecsr, MVTCMD_MOVECSR);
+ MVTCMD1(setcsrlin, MVTCMD_SETCSRLIN);
+ MVTCMD1(setcsrcol, MVTCMD_SETCSRCOL);
+ MVTCMD0(hidecsr, MVTCMD_HIDECSR);
+ MVTCMD0(showcsr, MVTCMD_SHOWCSR);
+}
#endif
diff --git a/Source/Library/Makefile b/Source/Library/Makefile
index c67daf7..6e3e269 100644
--- a/Source/Library/Makefile
+++ b/Source/Library/Makefile
@@ -6,10 +6,8 @@ CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I C
ASM = nasm
ASMFLAGS = -f elf
-LDFLAGS = -r
LD = ld
-Library = Melon.o
Objects = Common/WChar.class.uo \
Common/CMem.ns.uo \
Common/Mutex.class.uo \
@@ -30,14 +28,14 @@ Objects = Common/WChar.class.uo \
Userland/Syscall/RessourceCaller.class.uo \
Userland/Start.uo
-all: $(Library)
+all: libMelon.o
echo "* Done with library"
rebuild: mrproper all
-$(Library): $(Objects)
- echo "* Linking melon library $(Library)..."
- $(LD) $(LDFLAGS) $^ -o $@
+libMelon.o: $(Objects)
+ echo "* Linking static Melon library libMelon.o..."
+ $(LD) -r $^ -o $@
%.uo: %.cpp
echo "* Compiling $<..."
diff --git a/Source/Library/Melon.a b/Source/Library/Melon.a
new file mode 100644
index 0000000..e6b00ab
--- /dev/null
+++ b/Source/Library/Melon.a
Binary files differ
diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h
index 2a38abd..3ef898b 100644
--- a/Source/Library/Userland/Binding/VirtualTerminal.class.h
+++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h
@@ -25,15 +25,13 @@ class VirtualTerminal : public RessourceCaller, public OStream, public IStream {
}
VirtualTerminal(u32int id) : RessourceCaller(id, VTIF_OBJTYPE) { m_eof = false; }
- /*void writeHex(u32int number) {
- doCall(VTIF_WRITEHEX, number);
- }
- void writeDec(s64int number) {
- doCall(VTIF_WRITEDEC, (number >> 32), number);
- }*/
+ //******** SYSCALLS ********
void write(const String &s) {
doCall(VTIF_WRITE, (u32int)&s);
}
+ void put(WChar c) {
+ doCall(VTIF_PUT, c);
+ }
String read() {
if (m_eof) return "";
String ret = String::unserialize(doCall(VTIF_READLINE, 1));
@@ -44,23 +42,15 @@ class VirtualTerminal : public RessourceCaller, public OStream, public IStream {
}
return ret += "\n";
}
- keypress_t getKeypress(bool show = true, bool block = true) {
- keypress_t* ptr = (keypress_t*)doCall(VTIF_GETKEYPRESS, (show ? 1 : 0) | (block ? 2 : 0));
- return *ptr;
- }
String readLine(bool show = true) {
flush();
return String::unserialize(doCall(VTIF_READLINE, (show ? 1 : 0)));
}
- void setColor(u8int fg, u8int bg = 0xFF) {
- doCall(VTIF_SETCOLOR, (fg << 8) | bg);
- }
- void setCsrLine(u32int line) {
- doCall(VTIF_SETCSRLINE, line);
- }
- void setCsrCol(u32int col) {
- doCall(VTIF_SETCSRCOL, col);
+ keypress_t getKeypress(bool show = true, bool block = true) {
+ keypress_t* ptr = (keypress_t*)doCall(VTIF_GETKEYPRESS, (show ? 1 : 0) | (block ? 2 : 0));
+ return *ptr;
}
+ //********* GET VT INFO SYSCALLS ********
bool isBoxed() {
return doCall(VTIF_ISBOXED) != 0;
}
@@ -70,14 +60,20 @@ class VirtualTerminal : public RessourceCaller, public OStream, public IStream {
u8int width() {
return doCall(VTIF_GETWIDTH);
}
- void put(WChar c) {
- doCall(VTIF_PUT, c);
- }
- void moveCursor(u8int line, u8int col) {
- doCall(VTIF_LOCATE, line, col);
- }
- void put(u8int line, u8int col, WChar c) {
- moveCursor(line, col); put(c);
+ //********** HANDLE COMMAND *******
+ VirtualTerminal& operator << (const String& s) { OStream::operator<<(s); return *this; }
+ VirtualTerminal& operator << (s64int i) { OStream::operator<<(i); return *this; }
+ VirtualTerminal& operator << (s32int i) { OStream::operator<<(i); return *this; }
+ VirtualTerminal& operator << (u32int i) { OStream::operator<<(i); return *this; }
+ VirtualTerminal& operator << (ostream_modifiers_e m) { OStream::operator<<(m); return *this; }
+ VirtualTerminal& operator << (mvt_esc_cmd_t cmd) {
+ String s(" ");
+ s[0] = 0x1A;
+ s[1] = cmd.cmd;
+ s[2] = cmd.a;
+ s[3] = cmd.b;
+ OStream::put(s);
+ return *this;
}
};