digitalmars.D.learn - OSX prompt limit
- Joel (2/2) Sep 03 2015 In Mac OS, when typing with readln etc. I can't use the cursor
- Adam D. Ruppe (15/17) Sep 03 2015 That's normal, line editing on Unix terminals is a kinda advanced
- Joel (9/26) Sep 07 2015 I get these errors with terminal.d (on OSX):
- Adam D. Ruppe (13/14) Sep 08 2015 There's a missing value in the signal header for OSX !
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (2/16) Sep 08 2015 28 SIGWINCH discard signal Window size change
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (2/2) Sep 08 2015 Or just take it from the man page:
- Adam D. Ruppe (5/7) Sep 08 2015 ah excellent. My web search came up with
- Steven Schveighoffer (5/13) Sep 08 2015 That's because it's iOS. You have to be careful with apple
- Joel (5/13) Sep 08 2015 Now I get the error:
- via Digitalmars-d-learn (3/4) Sep 08 2015 What is your code calling the function? The prompt might
- Joel (10/15) Sep 08 2015 import terminal;
- Adam D. Ruppe (5/6) Sep 09 2015 Huh, that should work unless your terminal is outrageously narrow
- Adam D. Ruppe (9/9) Sep 09 2015 Maybe you can try gnu readline instead:
- Joel (4/13) Sep 09 2015 Thanks Adam. That works better than normal. Up and down don't
- Adam D. Ruppe (14/16) Sep 09 2015 There's another function called add_history for that. Readline is
In Mac OS, when typing with readln etc. I can't use the cursor keys. Works in Windows though.
Sep 03 2015
On Friday, 4 September 2015 at 02:17:57 UTC, Joel wrote:In Mac OS, when typing with readln etc. I can't use the cursor keys. Works in Windows though.That's normal, line editing on Unix terminals is a kinda advanced library feature. The most common lib to do it, GNU readline, is actually a big thing that pushed the GPL because of how useful it was and it happened to use that license. I wrote one too though it is a bit bulky. https://github.com/adamdruppe/arsd/blob/master/terminal.d import terminal; void main() { auto terminal = Terminal(ConsoleOutputMode.linear); auto line = terminal.getline("your prompt: "); terminal.writeln("You wrote: ", line); } compile: dmd yourapp.d terminal.d
Sep 03 2015
On Friday, 4 September 2015 at 03:31:40 UTC, Adam D. Ruppe wrote:On Friday, 4 September 2015 at 02:17:57 UTC, Joel wrote:I get these errors with terminal.d (on OSX): Joels-MacBook-Pro:small joelcnz$ rdmd term.d arsd/terminal.d(1268): Error: undefined identifier 'SIGWINCH' arsd/terminal.d(1381): Error: undefined identifier 'SIGWINCH' Joels-MacBook-Pro:small joelcnz$ Note: I've got term.d as the main file, I've got terminal.d in arsd folder I've put up an issue on your github site.In Mac OS, when typing with readln etc. I can't use the cursor keys. Works in Windows though.That's normal, line editing on Unix terminals is a kinda advanced library feature. The most common lib to do it, GNU readline, is actually a big thing that pushed the GPL because of how useful it was and it happened to use that license. I wrote one too though it is a bit bulky. https://github.com/adamdruppe/arsd/blob/master/terminal.d import terminal; void main() { auto terminal = Terminal(ConsoleOutputMode.linear); auto line = terminal.getline("your prompt: "); terminal.writeln("You wrote: ", line); } compile: dmd yourapp.d terminal.d
Sep 07 2015
On Tuesday, 8 September 2015 at 06:24:12 UTC, Joel wrote:arsd/terminal.d(1268): Error: undefined identifier 'SIGWINCH'There's a missing value in the signal header for OSX ! Could you run this little C program for me on your Mac and let me know the output? --- #include<stdio.h> #include<signal.h> int main() { printf("%d\n", SIGWINCH); } --- I can't find the numeric value online either and I don't have a mac myself to check the headers :( ugh.
Sep 08 2015
On Tuesday, 8 September 2015 at 13:02:35 UTC, Adam D. Ruppe wrote:On Tuesday, 8 September 2015 at 06:24:12 UTC, Joel wrote:28 SIGWINCH discard signal Window size changearsd/terminal.d(1268): Error: undefined identifier 'SIGWINCH'There's a missing value in the signal header for OSX ! Could you run this little C program for me on your Mac and let me know the output? --- #include<stdio.h> #include<signal.h> int main() { printf("%d\n", SIGWINCH); } --- I can't find the numeric value online either and I don't have a mac myself to check the headers :( ugh.
Sep 08 2015
Or just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.html
Sep 08 2015
On Tuesday, 8 September 2015 at 13:17:31 UTC, Ola Fosheim Grøstad wrote:Or just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.htmlah excellent. My web search came up with https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/m n2/sigaction.2.html which didn't give the value! anyway the git is updated now
Sep 08 2015
On 9/8/15 9:20 AM, Adam D. Ruppe wrote:On Tuesday, 8 September 2015 at 13:17:31 UTC, Ola Fosheim Grøstad wrote:That's because it's iOS. You have to be careful with apple documentation, they look the same for both MacOS and ios, but often they are slightly different. -SteveOr just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.htmlah excellent. My web search came up with https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sigaction.2.html which didn't give the value!
Sep 08 2015
On Tuesday, 8 September 2015 at 13:20:20 UTC, Adam D. Ruppe wrote:On Tuesday, 8 September 2015 at 13:17:31 UTC, Ola Fosheim Grøstad wrote:Now I get the error: object.Exception terminal.d(2745): too narrow terminal to draw It has a negative number in it. Thanks for working on it.Or just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.htmlah excellent. My web search came up with https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/m n2/sigaction.2.html which didn't give the value! anyway the git is updated now
Sep 08 2015
On Wed, Sep 09, 2015 at 12:05:52AM +0000, Joel via Digitalmars-d-learn wrote:Now I get the error:What is your code calling the function? The prompt might just be too long.
Sep 08 2015
On Wednesday, 9 September 2015 at 00:44:57 UTC, via Digitalmars-d-learn wrote:On Wed, Sep 09, 2015 at 12:05:52AM +0000, Joel via Digitalmars-d-learn wrote:import terminal; void main() { auto terminal = Terminal(ConsoleOutputType.linear); // I think I changed ConsoleOutputType from some thing else that didn't work auto line = terminal.getline("your prompt: "); terminal.writeln("You wrote: ", line); }Now I get the error:What is your code calling the function? The prompt might just be too long.
Sep 08 2015
On Wednesday, 9 September 2015 at 01:35:26 UTC, Joel wrote:auto line = terminal.getline("your prompt: ");Huh, that should work unless your terminal is outrageously narrow or maybe output starting on the right side of the screen already. But I can't look much further without having a mac myself, could be a few other causes :(
Sep 09 2015
Maybe you can try gnu readline instead: extern(C) char* readline(const(char)* prompt); pragma(lib, "readline"); pragma(lib, "curses"); void main() { auto line = readline("your line: "); import std.stdio, std.conv; writeln(to!string(line)); }
Sep 09 2015
On Wednesday, 9 September 2015 at 17:47:44 UTC, Adam D. Ruppe wrote:Maybe you can try gnu readline instead: extern(C) char* readline(const(char)* prompt); pragma(lib, "readline"); pragma(lib, "curses"); void main() { auto line = readline("your line: "); import std.stdio, std.conv; writeln(to!string(line)); }Thanks Adam. That works better than normal. Up and down don't work though.
Sep 09 2015
On Wednesday, 9 September 2015 at 21:27:05 UTC, Joel wrote:Thanks Adam. That works better than normal. Up and down don't work though.There's another function called add_history for that. Readline is a pretty popular library (also GPL though, keep that in mind if you distribute your program, it must also be GPL if you use it) so you can find more info on the net: http://web.mit.edu/gnu/doc/html/rlman_2.html Basic thing is if you want to add it to history, call add_history(ptr_it_returned); and it will then be available for up/down access. Also, readline is a C library, so it does expect you to free the memory it allocates too.... but you can probably just let that slide, it'll be fairly small leaks all things considered. If I can ever actually get access to a Mac, I'll try to debug my other lib on one too.
Sep 09 2015