adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
530 stars 128 forks source link

OSX and terminal #70

Open joelcnz opened 9 years ago

joelcnz commented 9 years ago

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$

adamdruppe commented 9 years ago

Code updated now, should work.

On Mon, Sep 07, 2015 at 11:16:52PM -0700, Joel Christensen wrote:

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$


Reply to this email directly or view it on GitHub: https://github.com/adamdruppe/arsd/issues/70

luke5542 commented 8 years ago

I'm having a similar problem with OSX, but it's a runtime error rather than a compilation error:

Building dish ~terminal-d-transition configuration "application", build type debug.
Compiling using dmd...
Linking...
Running ./dish 
object.Exception@source/terminal.d(2747): too narrow terminal to draw
----------------
5   dish                                0x000000010bba4a0a void terminal.LineGetter.startGettingLine() + 210
6   dish                                0x000000010bba3b73 immutable(char)[] terminal.LineGetter.getline(terminal.RealTimeConsoleInput*) + 123
7   dish                                0x000000010bb67b4b _Dmain + 231
8   dish                                0x000000010bbbe70c D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 40
9   dish                                0x000000010bbbe651 void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) + 45
10  dish                                0x000000010bbbe6b1 void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() + 45
11  dish                                0x000000010bbbe651 void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) + 45
12  dish                                0x000000010bbbe5c7 _d_run_main + 499
13  dish                                0x000000010bb67ec6 main + 34
14  libdyld.dylib                       0x00007fff9372e5c9 start + 1
15  ???                                 0x0000000000000001 0x0 + 1
Error executing command run:
Program exited with code 1

I think it's a problem related to getSize (line 945) and the call to ioctl returning a window size of (0,0), but I do not know enough about this to further find the problem.

The shell I'm running from is fish, using the built-in OSX Terminal program. OSX version 10.10.5

adamdruppe commented 8 years ago

On Tue, Sep 29, 2015 at 03:31:42AM -0700, Devin wrote:

I think it's a problem related to getSize (line 945) and the call to ioctl returning a window size of (0,0), but I do not know enough about this to further find the problem.

Yeah, I saw this before but haven't figured it out yet.

My friend is letting me use his Mac at some point this week, possibly as early as tonight, and I should be able to figure it out then.

adamdruppe commented 8 years ago

OK, try it now, I think I got it fixed!

luke5542 commented 8 years ago

Awesome! Looks like that fixed it for me!

joelcnz commented 8 years ago

Can't select text to copy etc!

Some text doesn't get printed.

adamdruppe commented 8 years ago

On Sun, Nov 22, 2015 at 04:34:07PM -0800, Joel Christensen wrote:

Can't select text to copy etc!

Some text doesn't get printed.

What exactly is happening? And this is on the OSX Terminal app right?

Mouse support on mac is really weird, it doesn't follow the xterm pattern, but copy/paste should be handled by it...

joelcnz commented 8 years ago

Yes, OSX built in.

I get a cross hair. When I quit the program, then I can select and copy etc.

adamdruppe commented 8 years ago

On Sun, Nov 22, 2015 at 04:40:39PM -0800, Joel Christensen wrote:

I get a cross hair. When I quit the program, then I can select and copy etc.

Try holding shift as you select the text.

Also, what are your input options when you create the thing? I mean like are you running RealTimeConsoleInput? What arguments to it?

I'm guessing one of them enables mouse support and that overrides the default copy/paste option.

(I' out of the house right now but when I get back, with a test program, I can try it too and prolly fix.)

joelcnz commented 8 years ago

I can paste into it.

I can't even select in the command line.

Shift didn't help.

    import adam = terminal;
    //auto terminal = adam.Terminal(adam.ConsoleOutputType.linear);

not work -> auto terminal = adam.Terminal(adam.ConsoleOutputType.RealTimeConsoleInput);

I'll be back later.

adamdruppe commented 8 years ago

On Sun, Nov 22, 2015 at 04:53:58PM -0800, Joel Christensen wrote:

not work -> auto terminal = adam.Terminal(adam.ConsoleOutputType.RealTimeConsoleInput);

that's not supposed to work, the usage is different.

But just let me know what your code is and I'll try it tomorrow when I'm back at the office.

joelcnz commented 8 years ago
void main(string[] args) {
    //#stuff at the start (in the terminal when the the program is run)
    BibleVersion = "English Standard Version";
    loadXMLFile();
    parseXMLDocument();

    import adam = terminal;
    auto terminal = adam.Terminal(adam.ConsoleOutputType.linear);
    //auto terminal = adam.Terminal(adam.ConsoleOutputType.RealTimeConsoleInput);
    string input;
    bool done = false;
    while(! done) {
        write("q - quit\neg Joel 1 1 - -1 -- for whole chapter");
        stdout.flush;
        input = terminal.getline("D>");
        if (input.length && input[0] == 'q') {
            done = true;
            break;
        }
        writeln(g_bible.argReference(g_bible.argReferenceToArgs(input)));
    }
adamdruppe commented 8 years ago

On Sun, Nov 22, 2015 at 05:05:33PM -0800, Joel Christensen wrote:

      input = terminal.getline("D>");

Ah, you're using my getline. It has mouse support turned on automatically and the Mac terminal is really weird about how it does mouse support.

If you hold the alt/option key the cursor should change. The crosshairs mean you can move the cursor around - click on the line and it will move the cursor for you.

When holding it, the cursor should change to the other thing and then you can select text. (Or it might be the other way around, the mac terminal is REALLY weird).

Also make sure you have the newest version of the terminal.d, I fixed some Mac bugs in it a month or two ago.

adamdruppe commented 8 years ago

So I just tried this on an el capitan Mac and I see what you described... it is different than on the mavericks box I have at home.

Ugh. So on the bright side, Apple added xterm standard mouse support... on the dark side though, they didn't add the feature for the user to bypass it. How annoying.

joelcnz commented 8 years ago

Maybe I'll just use the memory leak way.

On Tuesday, 24 November 2015, Adam D. Ruppe notifications@github.com wrote:

So I just tried this on an el capitan Mac and I see what you described... it is different than on the mavericks box I have at home.

Ugh. So on the bright side, Apple added xterm standard mouse support... on the dark side though, they didn't add the feature for the user to bypass it. How annoying.

— Reply to this email directly or view it on GitHub https://github.com/adamdruppe/arsd/issues/70#issuecomment-159118120.

adamdruppe commented 8 years ago

On Mon, Nov 23, 2015 at 05:36:29PM -0800, Joel Christensen wrote:

Maybe I'll just use the memory leak way.

I just pushed a hack that might help... disabled mouse support in the Terminal.getline (if you want mouse support you can always make the LineGetter yourself).

How is it with that change?

joelcnz commented 8 years ago

I don't get it. I /want/ to be able to select text in the terminal.

On Tuesday, 24 November 2015, Adam D. Ruppe notifications@github.com wrote:

On Mon, Nov 23, 2015 at 05:36:29PM -0800, Joel Christensen wrote:

Maybe I'll just use the memory leak way.

I just pushed a hack that might help... disabled mouse support in the Terminal.getline (if you want mouse support you can always make the LineGetter yourself).

How is it with that change?

— Reply to this email directly or view it on GitHub https://github.com/adamdruppe/arsd/issues/70#issuecomment-159124665.

adamdruppe commented 8 years ago

On Mon, Nov 23, 2015 at 05:47:20PM -0800, Joel Christensen wrote:

I don't get it. I /want/ to be able to select text in the terminal.

try it, the thing is custom mouse support on Mac disables the built in mouse support and the built-in one is what provides the select function you want.

joelcnz commented 8 years ago

It went out of control! (I used the mouse to close the terminal). I think when I tried to paste into the edit line. It kept printing stuff before I stopped it. I can't seem to make it happen again though.

On Tue, Nov 24, 2015 at 2:49 PM, Adam D. Ruppe notifications@github.com wrote:

On Mon, Nov 23, 2015 at 05:47:20PM -0800, Joel Christensen wrote:

I don't get it. I /want/ to be able to select text in the terminal.

try it, the thing is custom mouse support on Mac disables the built in mouse support and the built-in one is what provides the select function you want.

— Reply to this email directly or view it on GitHub https://github.com/adamdruppe/arsd/issues/70#issuecomment-159126723.

adamdruppe commented 8 years ago

On Mon, Nov 23, 2015 at 06:06:05PM -0800, Joel Christensen wrote:

It went out of control! (I used the mouse to close the terminal). I think when I tried to paste into the edit line. It kept printing stuff before I stopped it. I can't seem to make it happen again though.

A long paste might cause it to print wildly, the line getter is really optimized for short input and might be horribly buggy with long lines.

Is it otherwise working now though?

joelcnz commented 8 years ago

Yes, thanks! Thanks for all the help, Adam!

One thing though. At first it had the input line just below other text, but then there's a gap after I've entered some thing, from then on.

On Tue, Nov 24, 2015 at 3:10 PM, Adam D. Ruppe notifications@github.com wrote:

On Mon, Nov 23, 2015 at 06:06:05PM -0800, Joel Christensen wrote:

It went out of control! (I used the mouse to close the terminal). I think when I tried to paste into the edit line. It kept printing stuff before I stopped it. I can't seem to make it happen again though.

A long paste might cause it to print wildly, the line getter is really optimized for short input and might be horribly buggy with long lines.

Is it otherwise working now though?

— Reply to this email directly or view it on GitHub https://github.com/adamdruppe/arsd/issues/70#issuecomment-159131283.

joelcnz commented 8 years ago

See in brackets:

Joels-MacBook-Pro:Debug joelcnz$ ./run

Loading xml file..

Processing xml file..

q - quit h - help. eg Joel 1 1 - -1 -- for whole chapter

D>First

q - quit h - help. eg Joel 1 1 - -1 -- for whole chapter

(Now gap).

D>Second

q - quit h - help. eg Joel 1 1 - -1 -- for whole chapter

(and so on)

D>third

q - quit h - help. eg Joel 1 1 - -1 -- for whole chapter

D>

I'm using your dom.d source file. Thought I'd mention.

On Tue, Nov 24, 2015 at 3:16 PM, Joel Christensen joelcnz@gmail.com wrote:

Yes, thanks! Thanks for all the help, Adam!

One thing though. At first it had the input line just below other text, but then there's a gap after I've entered some thing, from then on.

On Tue, Nov 24, 2015 at 3:10 PM, Adam D. Ruppe notifications@github.com wrote:

On Mon, Nov 23, 2015 at 06:06:05PM -0800, Joel Christensen wrote:

It went out of control! (I used the mouse to close the terminal). I think when I tried to paste into the edit line. It kept printing stuff before I stopped it. I can't seem to make it happen again though.

A long paste might cause it to print wildly, the line getter is really optimized for short input and might be horribly buggy with long lines.

Is it otherwise working now though?

— Reply to this email directly or view it on GitHub https://github.com/adamdruppe/arsd/issues/70#issuecomment-159131283.