Skip to content

Commit

Permalink
Added macros
Browse files Browse the repository at this point in the history
  • Loading branch information
plankp committed Nov 21, 2015
1 parent 81fd689 commit 8b3d545
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
6 changes: 6 additions & 0 deletions kernel/inc/screenUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ void moveCursorX(int);
void moveCursorY(int);
/* Only call kprintch in kernels */
void kprintch(char, int, bool);
/* Macros */
#define newline() \
printch('\n', 0x0F);
#define println(str, c) \
print(str, c); \
newline();

//end the if statment at the start of the file
#endif
31 changes: 15 additions & 16 deletions kernel/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
extern uint32 placement_address;

#define COMMAND_HELP "\nWorking Commands in Q OS: \nwriter\nclear\nexecute\nhi\nskip (the no action)\nfiles\ncat\nreboot"
#define PRO_TIP "\nTip: If enter key does not work, it might mean that the input is too long\n"
#define PRO_TIP "\nTip: If enter key does not work, it might mean that the input is too long"

void listTree();
void launchShell();
Expand All @@ -35,7 +35,7 @@ int kmain(struct multiboot* mboot_ptr)
print(" Welcome to Q OS ", 0x3F);
print("================================================================================", 0x3F);

print(PRO_TIP, 0x0F);
println(PRO_TIP, 0x0F);
kbHelp();

launchShell();
Expand All @@ -44,7 +44,7 @@ int kmain(struct multiboot* mboot_ptr)

void catFile(fs_node_t* fsnode)
{
printch('\n', 0x0F);
newline();
if ((fsnode->flags & 0x7) == FS_FILE)
{
const uint32 rbuff = fsnode->length;
Expand All @@ -53,7 +53,7 @@ void catFile(fs_node_t* fsnode)
uint32 j;
for (j = 0; j < sz; j++)
printch(buf[j], 0x0F);
printch('\n', 0x0F);
newline();
}
}

Expand All @@ -76,7 +76,7 @@ void listTree() {
print("file\t", 0x0F);
print(node->name, 0x0F);
}
printch('\n', 0x0F);
newline();
i++;
}
}
Expand All @@ -101,8 +101,7 @@ void kbHelp()
print("\n\tCtrl-p -> up", 0x0F);
print("\n\tCtrl-n -> down", 0x0F);
print("\n\tCtrl-z -> quit", 0x0F);
print("\n\tCtrl-l -> clear", 0x0F);
print("\n", 0x0F);
println("\n\tCtrl-l -> clear", 0x0F);
}

void launchShell() {
Expand All @@ -127,14 +126,14 @@ void launchShell() {
else if(strEql(bufStr, "help"))
{
kbHelp();
print(PRO_TIP, 0x0F);
println(PRO_TIP, 0x0F);
print(COMMAND_HELP, 0x0F);
}
else if(strEql(bufStr, "reboot"))
{
//reboots the computer
reboot();
}
else if(strEql(bufStr, "reboot"))
{
//reboots the computer
reboot();
}
else if(strEql(bufStr, "skip"))
{
// It literally does nothing... (Useful at callback)
Expand All @@ -145,7 +144,7 @@ void launchShell() {
}
else if(strEql(bufStr, "files"))
{
print("\n", 0x0F);
newline();
listTree();
}
else if(strEql(bufStr, "cat"))
Expand All @@ -166,7 +165,7 @@ void launchShell() {
writing = 1;
while(true)
{
printch('\n', 0x0F);
newline();
print(bufStr, 0x0F);
}
}
Expand Down Expand Up @@ -220,6 +219,6 @@ void launchShell() {
{
print("\nCommand Not Found ", 0x0F);
}
print("\n", 0x0F);
newline();
}
}

1 comment on commit 8b3d545

@raphydaphy
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.