ref(libterm): now apple-styled too

This commit is contained in:
Karina
2026-01-31 22:47:42 +04:00
parent 2be7d3bd46
commit e21f5ef52f
37 changed files with 548 additions and 565 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
#include <stdio.h>
#include <termOS.h>
void not_implemented_yet() {
printf("Not implemented yet!\n");
ConsolePrint("Not implemented yet!\n");
}
+6 -6
View File
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKarinyash
#include <process.h>
#include <stdio.h>
#include "handlers.h"
#include <termOS.h>
void cmd_spawn(const char* path) {
Int32 pid = spawn(path);
Int32 pid = ProcessSpawn(path);
if (pid < 0) {
switch (pid) {
case -1: printf("\"%s\" not found.\n", path); break;
default: printf("failed to spawn (%d)\n", pid); break;
case -1: ConsolePrint("\"%s\" not found.\n", path); break;
default: ConsolePrint("failed to spawn (%d)\n", pid); break;
}
} else {
wait(pid);
ProcessWait(pid);
}
}
+4 -6
View File
@@ -1,19 +1,17 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKarinyash
#include "tokens.h"
#include <termOS.h>
#include "parser.h"
#include "handlers.h"
#include <stdio.h>
#define BUFFER_SIZE 512
int main() {
while (true) {
printf("termosh_> ");
ConsolePrint("termosh_> ");
char cmdbuff[BUFFER_SIZE];
gets_s(cmdbuff, BUFFER_SIZE);
ConsoleReadLine(cmdbuff, BUFFER_SIZE);
char* tokens[BUFFER_SIZE];
int tokens_count = tokenize(cmdbuff, tokens, BUFFER_SIZE);
if (tokens_count < 1) continue;
@@ -25,7 +23,7 @@ int main() {
case TOKEN_SPAWN: if (tokens_count >= 2) cmd_spawn(tokens[1]); break;
default: {
char buff[256];
snprintf(buff, sizeof(buff), "/System/CoreServices/%s", tokens[0]);
StringFormat(buff, sizeof(buff), "/System/CoreServices/%s", tokens[0]);
cmd_spawn(buff);
}
}
+4 -4
View File
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 0xKarinyash
#include <string.h>
#include <termOS.h>
#include "parser.h"
#include "tokens.h"
@@ -27,7 +27,7 @@ static const termosh_token_map token_map[] = {
termosh_token char2token(char* token) {
for (int i = 0; token_map[i].str != nullptr; i++) {
if (strcmp(token, token_map[i].str) == 0) {
if (StringCompare(token, token_map[i].str) == 0) {
return token_map[i].token;
}
}
@@ -36,12 +36,12 @@ termosh_token char2token(char* token) {
}
int tokenize(char* buffer, char* tokens[], int max_tokens) {
char* token = strtok(buffer, delim);
char* token = StringTokenize(buffer, delim);
int i = 0;
while (token != nullptr && i < max_tokens) {
tokens[i] = token;
token = strtok(nullptr, delim);
token = StringTokenize(nullptr, delim);
i++;
}