diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-27 17:39:08 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-27 17:39:08 +0200 |
commit | cc7e3519a67c8080c44a104ab1b5d4d61b6b35c5 (patch) | |
tree | a7c78b8183ef430981ccd5dddda95390377cc874 | |
parent | 8f91a47aebe4154124ec7d54f5c71d167937e5e4 (diff) | |
download | serenity-cc7e3519a67c8080c44a104ab1b5d4d61b6b35c5.zip |
Add a /bin/clear that prints the clear terminal escape sequence.
It doesn't work yet, but it will!
-rw-r--r-- | AK/printf.cpp | 14 | ||||
-rw-r--r-- | Kernel/_fs_contents | bin | 1024000 -> 1024000 bytes | |||
-rwxr-xr-x | Kernel/sync-sh | 1 | ||||
-rw-r--r-- | Userland/.gitignore | 1 | ||||
-rw-r--r-- | Userland/Makefile | 9 | ||||
-rw-r--r-- | Userland/clear.cpp | 8 |
6 files changed, 25 insertions, 8 deletions
diff --git a/AK/printf.cpp b/AK/printf.cpp index 5df39a8cfa..4bdc241fda 100644 --- a/AK/printf.cpp +++ b/AK/printf.cpp @@ -1,8 +1,10 @@ +#define ALWAYS_INLINE inline __attribute__ ((always_inline)) + typedef unsigned char byte; typedef unsigned short word; typedef unsigned int dword; -inline size_t strlen(const char* str) +ALWAYS_INLINE size_t strlen(const char* str) { size_t len = 0; while (*(str++)) @@ -13,7 +15,7 @@ inline size_t strlen(const char* str) static constexpr const char* h = "0123456789abcdef"; template<typename PutChFunc> -int printHex(PutChFunc putch, char*& bufptr, dword number, byte fields) +ALWAYS_INLINE int printHex(PutChFunc putch, char*& bufptr, dword number, byte fields) { int ret = 0; byte shr_count = fields * 4; @@ -26,7 +28,7 @@ int printHex(PutChFunc putch, char*& bufptr, dword number, byte fields) } template<typename PutChFunc> -int printNumber(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth) +ALWAYS_INLINE int printNumber(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth) { dword divisor = 1000000000; char ch; @@ -67,7 +69,7 @@ int printNumber(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool } template<typename PutChFunc> -int printString(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth) +ALWAYS_INLINE int printString(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth) { size_t len = strlen(str); if (!fieldWidth) @@ -88,7 +90,7 @@ int printString(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, d template<typename PutChFunc> -int printSignedNumber(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth) +ALWAYS_INLINE int printSignedNumber(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth) { if (number < 0) { putch(bufptr, '-'); @@ -98,7 +100,7 @@ int printSignedNumber(PutChFunc putch, char*& bufptr, int number, bool leftPad, } template<typename PutChFunc> -int printfInternal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap) +ALWAYS_INLINE int printfInternal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap) { const char *p; diff --git a/Kernel/_fs_contents b/Kernel/_fs_contents Binary files differindex 93f5d7a144..a705e7a43a 100644 --- a/Kernel/_fs_contents +++ b/Kernel/_fs_contents diff --git a/Kernel/sync-sh b/Kernel/sync-sh index baa10ce637..11f19741d2 100755 --- a/Kernel/sync-sh +++ b/Kernel/sync-sh @@ -12,6 +12,7 @@ cp ../Userland/false mnt/bin/false cp ../Userland/hostname mnt/bin/hostname cp ../Userland/cat mnt/bin/cat cp ../Userland/uname mnt/bin/uname +cp ../Userland/clear mnt/bin/clear cp kernel.map mnt/ umount mnt sync diff --git a/Userland/.gitignore b/Userland/.gitignore index fd9204f785..2021222cef 100644 --- a/Userland/.gitignore +++ b/Userland/.gitignore @@ -11,3 +11,4 @@ true hostname cat uname +clear diff --git a/Userland/Makefile b/Userland/Makefile index d7b2d408b9..12370c4b6f 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -10,7 +10,8 @@ OBJS = \ false.o \ hostname.o \ cat.o \ - uname.o + uname.o \ + clear.o APPS = \ id \ @@ -24,7 +25,8 @@ APPS = \ false \ hostname \ cat \ - uname + uname \ + clear ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib @@ -80,6 +82,9 @@ cat: cat.o uname: uname.o $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a +clear: clear.o + $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a + .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< diff --git a/Userland/clear.cpp b/Userland/clear.cpp new file mode 100644 index 0000000000..c7568b384e --- /dev/null +++ b/Userland/clear.cpp @@ -0,0 +1,8 @@ +#include <LibC/stdio.h> + +int main(int, char**) +{ + printf("\033[3J\033[H\033[2J"); + return 0; +} + |