Minor program improvements
This commit is contained in:
31
src/programs/misc.c
Normal file
31
src/programs/misc.c
Normal file
@@ -0,0 +1,31 @@
|
||||
// Miscellaneous small programs
|
||||
|
||||
#include "../libc/stdio.h"
|
||||
|
||||
// Print a rainbow colorful text for testing
|
||||
|
||||
#define BUF_SIZE 256
|
||||
#define COLORS 20
|
||||
|
||||
void program_rainbow()
|
||||
{
|
||||
char input_buffer[BUF_SIZE];
|
||||
puts("What to print? ");
|
||||
get_input(input_buffer, BUF_SIZE);
|
||||
puts("\n");
|
||||
|
||||
for (int i=0; i<COLORS; i++)
|
||||
{
|
||||
colorputs(input_buffer, i);
|
||||
puts("\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the terminal
|
||||
|
||||
#define ROWS 25
|
||||
|
||||
void program_clear()
|
||||
{
|
||||
for (int i=0; i<ROWS; i++) scroll(1);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "../libc/stdint.h"
|
||||
#include "../libc/stdio.h"
|
||||
#include "../kernel/system.h"
|
||||
|
||||
#define PRIMES_MAX 1000000
|
||||
|
||||
@@ -16,8 +17,9 @@ void program_primes()
|
||||
{
|
||||
if (isPrime(x))
|
||||
{
|
||||
printf("%d ", x);
|
||||
printf("%d ", x);
|
||||
}
|
||||
delay(2);
|
||||
}
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@
|
||||
void program_words();
|
||||
void program_primes();
|
||||
|
||||
// Misc
|
||||
void program_rainbow();
|
||||
void program_clear();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user