Skip to content

Commit

Permalink
Merge branch 'master' of github.com:holzschu/ios_system
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Holzschuch committed Nov 9, 2022
2 parents f2565ef + 6f46f90 commit 7e28ab9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
24 changes: 20 additions & 4 deletions ios_system.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@
__thread FILE* thread_stderr;
__thread void* thread_context;

FILE* ios_stdin(void) {
return thread_stdin;
}

FILE* ios_stdout(void) {
return thread_stdout;
}

FILE* ios_stderr(void) {
return thread_stderr;
}

void* ios_context(void) {
return thread_context;
}

// Parameters for each session. We can have multiple sessions running in parallel.
typedef struct _sessionParameters {
bool isMainThread; // are we on the first command?
Expand All @@ -67,8 +83,8 @@
void* context;
int global_errno;
char commandName[NAME_MAX];
char columns[4];
char lines[4];
char columns[5];
char lines[5];
bool activePager;
} sessionParameters;

Expand Down Expand Up @@ -239,8 +255,8 @@ void ios_setWindowSize(int width, int height, const void* sessionId) {
return;
}

sprintf(resizedSession->columns, "%d", width);
sprintf(resizedSession->lines, "%d",height);
sprintf(resizedSession->columns, "%d", MIN(width, 9999));
sprintf(resizedSession->lines, "%d", MIN(height, 9999));
// Also send SIGWINCH to the main thread of resizedSession:
if (resizedSession->current_command_root_thread != NULL) {
pthread_kill(resizedSession->current_command_root_thread, SIGWINCH);
Expand Down
9 changes: 9 additions & 0 deletions ios_system/ios_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ extern __thread FILE* thread_stdin;
extern __thread FILE* thread_stdout;
extern __thread FILE* thread_stderr;
extern __thread void* thread_context;

// rust doesn't support extern __thread vars yet
// see https://github.com/rust-lang/rust/issues/30795
// so we provide function accessors for them.
extern FILE* ios_stdin(void);
extern FILE* ios_stdout(void);
extern FILE* ios_stderr(void);
extern void* ios_context(void);

// set to true to have more commands available, more debugging information.
extern bool sideLoading;
// set to false to have the main thread run in detached mode (non blocking)
Expand Down

0 comments on commit 7e28ab9

Please sign in to comment.