TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

set editing-mode support

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Unix Shell
View previous topic :: View next topic  
Author Message
dandconf



Joined: 26 Nov 2011
Posts: 9

PostPosted: Wed Dec 20, 2017 12:02 pm    Post subject: set editing-mode support Reply with quote

Is
Code:
set editing-mode vi


supported in .inputrc? It doesn't appear to have any effect for me.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3856

PostPosted: Wed Dec 20, 2017 6:14 pm    Post subject: Reply with quote

Did you launch a new terminal after editing .inputrc?
Back to top
View user's profile Send private message Send e-mail
dandconf



Joined: 26 Nov 2011
Posts: 9

PostPosted: Thu Dec 21, 2017 6:02 am    Post subject: Reply with quote

Headless Ubuntu VM, created the file, tried after invoking bash, bash -l, and logging out and back in to the machine.

Not too familiar with .inputrc so I'm probably just missing something. I had to create a new file in the user home folder and the only line it contains is "set editing-mode vi". That works equivalent to set -o vi for bash, and enables the mode for other terminal programs that can support it (e.g., Python interactive shell). However tt++ (v2.01.1) still responds to sequences like <esc>-w with \ew.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3856

PostPosted: Fri Dec 22, 2017 8:48 pm    Post subject: Reply with quote

Oh, my mistake, I misunderstood your question.

TinTin++ only supports one default editing mode. If you want vi-like behavior you'll have to create macros and check out the #cursor command.

You could do:

Code:

#cursor {\ew} {#cursor next word}


Creating an actual vi command mode would be more involved, you'd have to create a bunch of macros when entering vi command mode, and delete the macros when exiting vi command mode.

Let me know if you need any additional cursor options. It's something I'm open to implementing, but nobody ever asked.
Back to top
View user's profile Send private message Send e-mail
dandconf



Joined: 26 Nov 2011
Posts: 9

PostPosted: Sat Dec 23, 2017 9:39 am    Post subject: Reply with quote

Ah, #cursor is very interesting! I see it even has GET/SET options, which makes me wonder if it would be easier to delegate this to Neovim. Although I suppose that would still require some form of activation.

What about an #event for key presses (presumably to override default editing?), including escape/shift/etc.? Key codes or defined constants or anything stable would work.

Example:
Code:

#event {KEYBOARD INPUT} {
    #var {key} {%0};
    #replace {key} {"} {\\"};

    #nop %0 could be 97, or a, or KEY_ESC, whatever works;

    #cursor {get} line;

    #script {newline} {python some.py "$key" -- $line};

    #cursor {set} $newline;

    #nop maybe your wrapper returns cursor position on the last line;
    #nop so #cursor {home}; #cursor {forward} in a loop;
};
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3856

PostPosted: Sun Dec 24, 2017 8:20 pm    Post subject: Reply with quote

I should be able to add a {RECEIVED KEYPRESS} event without too much trouble.

Some things are surprisingly easy to script in TinTin++ so I'd suggest not ruling that out either.

Cursor positioning is going to be tricky, I'll have to add some #cursor commands to handle that properly.

There's actually no real need for a keyboard event, you should be able to make a keypress filter using:

Code:

#loop {1} {255} {key} {#format key %a $key;#line sub var #macro {$key} {received_keypress $key}}

#alias {received_keypress}
{
    #var {key} {%0};
    etc
}
Back to top
View user's profile Send private message Send e-mail
dandconf



Joined: 26 Nov 2011
Posts: 9

PostPosted: Mon Dec 25, 2017 8:11 am    Post subject: Reply with quote

This looks very promising, thanks!
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3856

PostPosted: Mon Dec 25, 2017 10:20 am    Post subject: Reply with quote

You're welcome. I placed it on my todo list, so I'll take another look at it when I get into one of my programming moods.
Back to top
View user's profile Send private message Send e-mail
dandconf



Joined: 26 Nov 2011
Posts: 9

PostPosted: Tue Dec 26, 2017 8:59 am    Post subject: Reply with quote

Is it possible to do the macro loop from within an alias? I was trying to have enable/disable aliases, one to loop and macro, one to loop and unmacro.

Your snippet works (testing with a #showme), but if I wrap it in an alias like so:

Code:
#alias {setup}
{
    #loop {1} {255} {key}
    {
        #format ascii %a $key;
        #line sub var #macro {$ascii}
        {
            #showme got key $key, ascii: $ascii
        };
    };
};


I'm getting an "#Unmatched braces error!" when I use the alias, which then lists the macros:

Code:
#MACRO {}={#showme got key 1, ascii: }
#MACRO {}={#showme got key 2, ascii: }
...
#MACRO {
        }={#showme got key 12, ascii:
                                      }
}={#showme got key 13, ascii:
#MACRO {}={#showme got key 14, ascii: }
...


It looks like an extra closing brace was inserted for key 12, form feed, and removed for key 13, carriage return? Regardless of the errors the (rest of the?) macros still appear to work and show output, including the enter key.

Any idea why this happens only inside an alias? Should I just go ahead and not macro form feed? I don't know where/if it's even relevant in normal usage.
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3856

PostPosted: Wed Dec 27, 2017 6:23 pm    Post subject: Reply with quote

The error messages are from capturing { and } which unfortunately is pretty much impossible to do with #macro. Guess an #event is required to handle that.

The linefeed problem with your alias should be solved by adding braces:

Code:

#showme {got key $key, ascii: $ascii}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Unix Shell All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group