summaryrefslogtreecommitdiff
path: root/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp
blob: f8cf13828d5d2b783e88e4bc8eb9ea488ff02127 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "VirtualTerminal.proto.h"
#include <VirtualTerminal.iface.h>
#include <TaskManager/Task.ns.h>

call_t VirtualTerminal::m_callTable[] = {
	CALL1(VTIF_WRITE, &VirtualTerminal::writeSC),
	CALL1(VTIF_PUT, &VirtualTerminal::putSC),
	CALL1(VTIF_READLINE, &VirtualTerminal::readLineSC),
	CALL1(VTIF_GETKEYPRESS, &VirtualTerminal::getKeypressSC),
	CALL0(VTIF_ISBOXED, &VirtualTerminal::isBoxedSC),
	CALL0(VTIF_GETHEIGHT, &VirtualTerminal::getHeightSC),
	CALL0(VTIF_GETWIDTH, &VirtualTerminal::getWidthSC),
	CALL0(0, 0)
};

u32int VirtualTerminal::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) {
	if (wat == VTIF_SGETPRINVT) return Task::currProcess()->getInVT()->resId();
	if (wat == VTIF_SGETPROUTVT) return Task::currProcess()->getOutVT()->resId();
	return (u32int) - 1;
}

u32int VirtualTerminal::writeSC(u32int wat) {
	String *s = (String*)wat;
	//hexDump((u8int*)s->serialize(), s->size());
	write(*s);
	return 0;
}

u32int VirtualTerminal::putSC(u32int code) {
	put(WChar(code));
	return 0;
}

u32int VirtualTerminal::readLineSC(u32int show) {
	return readLine(show != 0).serialize();
}

u32int VirtualTerminal::getKeypressSC(u32int flags) {
	bool show = (flags & 1), block = (flags & 2);
	keypress_t temp = getKeypress(show, block);
	void* ptr = Mem::mkXchgSpace(sizeof(keypress_t));
	memcpy((u8int*)ptr, (const u8int*)&temp, sizeof(keypress_t));
	return (u32int)ptr;
}

u32int VirtualTerminal::isBoxedSC() {
	return (isBoxed() ? 1 : 0);
}

u32int VirtualTerminal::getHeightSC() {
	return height();
}

u32int VirtualTerminal::getWidthSC() {
	return width();
}