mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
Add save/unsave cursor escape sequences.
Also added a little terminal test program called /bin/tst.
This commit is contained in:
parent
ea6221dd06
commit
43475f248b
6 changed files with 41 additions and 5 deletions
|
@ -171,10 +171,22 @@ void Console::escape$m(const Vector<unsigned>& params)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vga_set_attr(m_currentAttribute);
|
vga_set_attr(m_currentAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Console::escape$s(const Vector<unsigned>&)
|
||||||
|
{
|
||||||
|
m_savedCursorRow = m_cursorRow;
|
||||||
|
m_savedCursorColumn = m_cursorColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Console::escape$u(const Vector<unsigned>&)
|
||||||
|
{
|
||||||
|
m_cursorRow = m_savedCursorRow;
|
||||||
|
m_cursorColumn = m_savedCursorColumn;
|
||||||
|
vga_set_cursor(m_cursorRow, m_cursorColumn);
|
||||||
|
}
|
||||||
|
|
||||||
void Console::escape$H(const Vector<unsigned>& params)
|
void Console::escape$H(const Vector<unsigned>& params)
|
||||||
{
|
{
|
||||||
unsigned row = 1;
|
unsigned row = 1;
|
||||||
|
@ -229,6 +241,8 @@ void Console::executeEscapeSequence(byte final)
|
||||||
case 'H': escape$H(params); break;
|
case 'H': escape$H(params); break;
|
||||||
case 'J': escape$J(params); break;
|
case 'J': escape$J(params); break;
|
||||||
case 'm': escape$m(params); break;
|
case 'm': escape$m(params); break;
|
||||||
|
case 's': escape$s(params); break;
|
||||||
|
case 'u': escape$u(params); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,18 @@ private:
|
||||||
void escape$H(const Vector<unsigned>&);
|
void escape$H(const Vector<unsigned>&);
|
||||||
void escape$J(const Vector<unsigned>&);
|
void escape$J(const Vector<unsigned>&);
|
||||||
void escape$m(const Vector<unsigned>&);
|
void escape$m(const Vector<unsigned>&);
|
||||||
|
void escape$s(const Vector<unsigned>&);
|
||||||
|
void escape$u(const Vector<unsigned>&);
|
||||||
|
|
||||||
const byte m_rows { 25 };
|
const byte m_rows { 25 };
|
||||||
const byte m_columns { 80 };
|
const byte m_columns { 80 };
|
||||||
|
|
||||||
byte m_cursorRow { 0 };
|
byte m_cursorRow { 0 };
|
||||||
byte m_cursorColumn { 0 };
|
byte m_cursorColumn { 0 };
|
||||||
|
|
||||||
|
byte m_savedCursorRow { 0 };
|
||||||
|
byte m_savedCursorColumn { 0 };
|
||||||
|
|
||||||
byte m_currentAttribute { 0x07 };
|
byte m_currentAttribute { 0x07 };
|
||||||
|
|
||||||
void executeEscapeSequence(byte final);
|
void executeEscapeSequence(byte final);
|
||||||
|
@ -41,7 +47,5 @@ private:
|
||||||
EscapeState m_escState { Normal };
|
EscapeState m_escState { Normal };
|
||||||
Vector<byte> m_parameters;
|
Vector<byte> m_parameters;
|
||||||
Vector<byte> m_intermediates;
|
Vector<byte> m_intermediates;
|
||||||
|
|
||||||
const byte* s_vgaMemory { (const byte*)0xb8000 };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ cp ../Userland/hostname mnt/bin/hostname
|
||||||
cp ../Userland/cat mnt/bin/cat
|
cp ../Userland/cat mnt/bin/cat
|
||||||
cp ../Userland/uname mnt/bin/uname
|
cp ../Userland/uname mnt/bin/uname
|
||||||
cp ../Userland/clear mnt/bin/clear
|
cp ../Userland/clear mnt/bin/clear
|
||||||
|
cp ../Userland/tst mnt/bin/tst
|
||||||
cp kernel.map mnt/
|
cp kernel.map mnt/
|
||||||
umount mnt
|
umount mnt
|
||||||
sync
|
sync
|
||||||
|
|
1
Userland/.gitignore
vendored
1
Userland/.gitignore
vendored
|
@ -12,3 +12,4 @@ hostname
|
||||||
cat
|
cat
|
||||||
uname
|
uname
|
||||||
clear
|
clear
|
||||||
|
tst
|
||||||
|
|
|
@ -11,7 +11,8 @@ OBJS = \
|
||||||
hostname.o \
|
hostname.o \
|
||||||
cat.o \
|
cat.o \
|
||||||
uname.o \
|
uname.o \
|
||||||
clear.o
|
clear.o \
|
||||||
|
tst.o
|
||||||
|
|
||||||
APPS = \
|
APPS = \
|
||||||
id \
|
id \
|
||||||
|
@ -26,7 +27,8 @@ APPS = \
|
||||||
hostname \
|
hostname \
|
||||||
cat \
|
cat \
|
||||||
uname \
|
uname \
|
||||||
clear
|
clear \
|
||||||
|
tst
|
||||||
|
|
||||||
ARCH_FLAGS =
|
ARCH_FLAGS =
|
||||||
STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib
|
STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib
|
||||||
|
@ -85,6 +87,9 @@ uname: uname.o
|
||||||
clear: clear.o
|
clear: clear.o
|
||||||
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
|
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
|
||||||
|
|
||||||
|
tst: tst.o
|
||||||
|
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
|
||||||
|
|
||||||
.cpp.o:
|
.cpp.o:
|
||||||
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
|
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
|
11
Userland/tst.cpp
Normal file
11
Userland/tst.cpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include <LibC/stdio.cpp>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
printf("Counting to 100000: \033[s");
|
||||||
|
for (unsigned i = 0; i <= 100000; ++i) {
|
||||||
|
printf("\033[u\033[s%u", i);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue