Fossil SCM
Implement "fossil sys stty size"
Commit
4dd0affa175ee691f88f9ae2d7fd9baa9c2d915acd3e1080eb72142d4a4aa110
Parent
45de97fa3ecb155…
1 file changed
+15
+15
| --- src/xsystem.c | ||
| +++ src/xsystem.c | ||
| @@ -46,10 +46,21 @@ | ||
| 46 | 46 | /* Present working diretory */ |
| 47 | 47 | void xsystem_pwd(int argc, char **argv){ |
| 48 | 48 | char *zPwd = file_getcwd(0, 0); |
| 49 | 49 | fossil_print("%z\n", zPwd); |
| 50 | 50 | } |
| 51 | + | |
| 52 | +/* Implement "stty size" */ | |
| 53 | +void xsystem_stty(int argc, char **argv){ | |
| 54 | + TerminalSize ts; | |
| 55 | + if( argc!=2 || strcmp(argv[1],"size")!=0 ){ | |
| 56 | + fossil_print("ERROR: only \"stty size\" is supported\n"); | |
| 57 | + }else{ | |
| 58 | + terminal_get_size(&ts); | |
| 59 | + fossil_print("%d %d\n", ts.nLines, ts.nColumns); | |
| 60 | + } | |
| 61 | +} | |
| 51 | 62 | |
| 52 | 63 | /* Show where an executable is located on PATH */ |
| 53 | 64 | void xsystem_which(int argc, char **argv){ |
| 54 | 65 | int ePrint = 1; |
| 55 | 66 | int i; |
| @@ -371,10 +382,14 @@ | ||
| 371 | 382 | }, |
| 372 | 383 | { "pwd", xsystem_pwd, |
| 373 | 384 | "\n" |
| 374 | 385 | "Show the Present Working Directory name\n" |
| 375 | 386 | }, |
| 387 | + { "stty", xsystem_stty, | |
| 388 | + "\n" | |
| 389 | + "Show the size of the TTY\n" | |
| 390 | + }, | |
| 376 | 391 | { "which", xsystem_which, |
| 377 | 392 | "EXE ...\n" |
| 378 | 393 | "Show the location on PATH of executables EXE\n" |
| 379 | 394 | "Options:\n" |
| 380 | 395 | " -a Show all path locations rather than just the first\n" |
| 381 | 396 |
| --- src/xsystem.c | |
| +++ src/xsystem.c | |
| @@ -46,10 +46,21 @@ | |
| 46 | /* Present working diretory */ |
| 47 | void xsystem_pwd(int argc, char **argv){ |
| 48 | char *zPwd = file_getcwd(0, 0); |
| 49 | fossil_print("%z\n", zPwd); |
| 50 | } |
| 51 | |
| 52 | /* Show where an executable is located on PATH */ |
| 53 | void xsystem_which(int argc, char **argv){ |
| 54 | int ePrint = 1; |
| 55 | int i; |
| @@ -371,10 +382,14 @@ | |
| 371 | }, |
| 372 | { "pwd", xsystem_pwd, |
| 373 | "\n" |
| 374 | "Show the Present Working Directory name\n" |
| 375 | }, |
| 376 | { "which", xsystem_which, |
| 377 | "EXE ...\n" |
| 378 | "Show the location on PATH of executables EXE\n" |
| 379 | "Options:\n" |
| 380 | " -a Show all path locations rather than just the first\n" |
| 381 |
| --- src/xsystem.c | |
| +++ src/xsystem.c | |
| @@ -46,10 +46,21 @@ | |
| 46 | /* Present working diretory */ |
| 47 | void xsystem_pwd(int argc, char **argv){ |
| 48 | char *zPwd = file_getcwd(0, 0); |
| 49 | fossil_print("%z\n", zPwd); |
| 50 | } |
| 51 | |
| 52 | /* Implement "stty size" */ |
| 53 | void xsystem_stty(int argc, char **argv){ |
| 54 | TerminalSize ts; |
| 55 | if( argc!=2 || strcmp(argv[1],"size")!=0 ){ |
| 56 | fossil_print("ERROR: only \"stty size\" is supported\n"); |
| 57 | }else{ |
| 58 | terminal_get_size(&ts); |
| 59 | fossil_print("%d %d\n", ts.nLines, ts.nColumns); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /* Show where an executable is located on PATH */ |
| 64 | void xsystem_which(int argc, char **argv){ |
| 65 | int ePrint = 1; |
| 66 | int i; |
| @@ -371,10 +382,14 @@ | |
| 382 | }, |
| 383 | { "pwd", xsystem_pwd, |
| 384 | "\n" |
| 385 | "Show the Present Working Directory name\n" |
| 386 | }, |
| 387 | { "stty", xsystem_stty, |
| 388 | "\n" |
| 389 | "Show the size of the TTY\n" |
| 390 | }, |
| 391 | { "which", xsystem_which, |
| 392 | "EXE ...\n" |
| 393 | "Show the location on PATH of executables EXE\n" |
| 394 | "Options:\n" |
| 395 | " -a Show all path locations rather than just the first\n" |
| 396 |