make posix launcher textbox clearer; dup2 bugfixes

This commit is contained in:
nakst 2022-01-19 22:58:30 +00:00
parent 3ecb3f4d2f
commit fefa668d0d
3 changed files with 33 additions and 8 deletions

View File

@ -21,7 +21,7 @@ EsMutex mutex;
int stdinWritePipe;
EsTextbox *textboxOutput, *textboxInput;
const EsStyle styleMonospacedTextbox = {
const EsStyle styleOutputTextbox = {
.inherit = ES_STYLE_TEXTBOX_NO_BORDER,
.metrics = {
@ -31,6 +31,25 @@ const EsStyle styleMonospacedTextbox = {
},
};
const EsStyle styleInputTextbox = {
.inherit = ES_STYLE_TEXTBOX_BORDERED_SINGLE,
.metrics = {
.mask = ES_THEME_METRICS_FONT_FAMILY | ES_THEME_METRICS_TEXT_SIZE,
.textSize = 12,
.fontFamily = ES_FONT_MONOSPACED,
},
};
const EsStyle styleInputRow = {
.inherit = ES_STYLE_PANEL_FORM_TABLE,
.metrics = {
.mask = ES_THEME_METRICS_INSETS,
.insets = ES_RECT_1(7),
},
};
void WriteToOutputTextbox(const char *string, ptrdiff_t stringBytes) {
if (stringBytes == -1) {
stringBytes = EsCRTstrlen(string);
@ -170,9 +189,11 @@ void MessageLoopThread(EsGeneric) {
EsWindow *window = instance->window;
EsWindowSetIcon(window, ES_ICON_UTILITIES_TERMINAL);
EsPanel *panel = EsPanelCreate(window, ES_PANEL_VERTICAL | ES_CELL_FILL, ES_STYLE_PANEL_WINDOW_BACKGROUND);
textboxOutput = EsTextboxCreate(panel, ES_TEXTBOX_MULTILINE | ES_CELL_FILL, &styleMonospacedTextbox);
textboxOutput = EsTextboxCreate(panel, ES_TEXTBOX_MULTILINE | ES_CELL_FILL, &styleOutputTextbox);
EsSpacerCreate(panel, ES_CELL_H_FILL, ES_STYLE_SEPARATOR_HORIZONTAL);
textboxInput = EsTextboxCreate(panel, ES_CELL_H_FILL, &styleMonospacedTextbox);
EsPanel *row = EsPanelCreate(panel, ES_CELL_H_FILL | ES_PANEL_HORIZONTAL, &styleInputRow);
EsTextDisplayCreate(row, ES_FLAGS_DEFAULT, ES_STYLE_TEXT_LABEL, EsLiteral("Input:"));
textboxInput = EsTextboxCreate(row, ES_CELL_H_FILL, &styleInputTextbox);
EsTextboxEnableSmartReplacement(textboxInput, false);
EsTextboxSetReadOnly(textboxOutput, true);
textboxInput->messageUser = ProcessTextboxInputMessage;

View File

@ -161,6 +161,10 @@ long EsPOSIXSystemCall(long n, long a1, long a2, long a3, long a4, long a5, long
ProcessorCheckStackAlignment();
#endif
if ((uintptr_t) n < sizeof(syscallNames) / sizeof(syscallNames[0])) {
// EsPrint(":: %z %x %x %x\n", syscallNames[n], a1, a2, a3);
}
long returnValue = 0;
_EsPOSIXSyscall syscall = { n, a1, a2, a3, a4, a5, a6 };
@ -689,11 +693,10 @@ long EsPOSIXSystemCall(long n, long a1, long a2, long a3, long a4, long a5, long
double endTime = EsTimeStampMs();
syscallTimeSpent[n] += endTime - startTime;
syscallCallCount[n]++;
// EsPrint(":: %z %x %x %x -> %x; %Fms\n", syscallNames[n], a1, a2, a3, returnValue, endTime - startTime);
}
#endif
// EsPrint(":: %z %x %x %x -> %x; %Fms\n", syscallNames[n], a1, a2, a3, returnValue, endTime - startTime);
return returnValue;
}

View File

@ -51,13 +51,13 @@ struct POSIXThread {
#define SYSCALL_HANDLE_POSIX_2(handle, out) \
Handle _ ## out; \
uint8_t status_ ## out = currentProcess->handleTable.ResolveHandle(&_ ## out, ConvertStandardInputTo3(handle), KERNEL_OBJECT_POSIX_FD); \
uint8_t status_ ## out = handleTable->ResolveHandle(&_ ## out, ConvertStandardInputTo3(handle), KERNEL_OBJECT_POSIX_FD); \
if (status_ ## out == RESOLVE_HANDLE_FAILED) return -EBADF; \
EsDefer(if (status_ ## out == RESOLVE_HANDLE_NORMAL) CloseHandleToObject(_ ## out.object, _ ## out.type, _ ## out.flags)); \
const Handle out = _ ## out
#define SYSCALL_HANDLE_POSIX(handle, out) \
Handle _ ## out; \
uint8_t status_ ## out = currentProcess->handleTable.ResolveHandle(&_ ## out, ConvertStandardInputTo3(handle), KERNEL_OBJECT_POSIX_FD); \
uint8_t status_ ## out = handleTable->ResolveHandle(&_ ## out, ConvertStandardInputTo3(handle), KERNEL_OBJECT_POSIX_FD); \
if (status_ ## out == RESOLVE_HANDLE_FAILED) return -EBADF; \
EsDefer(if (status_ ## out == RESOLVE_HANDLE_NORMAL) CloseHandleToObject(_ ## out.object, _ ## out.type, _ ## out.flags)); \
POSIXFile *const out = (POSIXFile *) _ ## out.object
@ -625,7 +625,8 @@ namespace POSIX {
// Clone the oldfd as newfd.
OpenHandleToObject(file, KERNEL_OBJECT_POSIX_FD, fd.flags);
return handleTable->OpenHandle(fd.object, fd.flags, fd.type, ConvertStandardInputTo3(syscall.arguments[1])) ? 0 : -EBUSY;
return handleTable->OpenHandle(fd.object, fd.flags, fd.type,
ConvertStandardInputTo3(syscall.arguments[1])) ? syscall.arguments[1] : -EBUSY;
} break;
case SYS_pipe2: {