You are not logged in.

#26 2013-03-27 11:19:02

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,089
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby wrote:

big_smile !

All the best,

-HG

Offline

#27 2013-03-28 09:31:05

Shinryuu
Member
From: /dev/urandom
Registered: 2010-02-27
Posts: 339

Re: Interrobang: a tiny menu packing a big bang (syntax)

I was just doing some experiments and I noticed interrobang doesn't like [] and/or () characters in filenames, at least not when I'm trying to play videos. I've tried both completion options out if that matters. Works fine with plain filenames like "video.mkv" etc. smile

[ ~]$ interrobang 
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `mpv anime/Gankutsuou/[KAA]Kino.Gankutsuou_03.DVD(H264.AAC)[KAA][BE92C205].mkv &'
[ ~]$ 

Here's some bangs if anyone finds them useful

:m	mpv %s
:o	dwb %s
:pdf	mupdf %s
:t	termite -e %s
:n	termite -e ncmpcpp
:r	termite -e ranger
:w	termite -e weechat-curses
:gg	dwb "https://google.com/search?q=%s"
:dd	dwb "https://duckduckgo.com/?q=%s"
:bbs	dwb "https://bbs.archlinux.org/search.php?action=search&show_as=topics&sort_dir=DESC&keywords=%s"
:wiki	dwb "https://wiki.archlinux.org/index.php?search=%s"

Last edited by Shinryuu (2013-03-28 09:31:49)

Offline

#28 2013-03-28 11:09:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

That's actually the shell that doesn't like them.  If you try to run that command from the commandline (at least with bash), you'll get the same error.

I do see that the default command line completion in an interactive shell will escape those characters properly, but the compgen invocation I'm using will not.

I'll need to figure out how to have compgen escape such characters.

It doesn't seem that compgen has this ability - and I can't think of a way to add it to interrobang without having horrible side effects.  I'll have to do more brainstorming.

Last edited by Trilby (2013-03-28 11:22:30)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#29 2013-03-28 11:41:40

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,089
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Shinryuu wrote:

Here's some bangs if anyone finds them useful

Quick tip for you, if you haven't tried it yet. Try having the following as your first bang:

:exec  termite -e "%s"

By doing this all of the specialized ones you did, like htop, for instance, could be accomplished by just running ":htop" (or weechat by running ":weechat-curses") without needing to define another one. big_smile

All the best,

-HG

Last edited by HalosGhost (2013-03-28 11:43:33)

Offline

#30 2013-03-28 15:42:08

ngzhian
Member
Registered: 2012-12-09
Posts: 10

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby wrote:

That's actually the shell that doesn't like them.  If you try to run that command from the commandline (at least with bash), you'll get the same error.

I do see that the default command line completion in an interactive shell will escape those characters properly, but the compgen invocation I'm using will not.

I'll need to figure out how to have compgen escape such characters.

It doesn't seem that compgen has this ability - and I can't think of a way to add it to interrobang without having horrible side effects.  I'll have to do more brainstorming.

I submitted a pull request here. Basically I added a function called

escape

to escape the line before it is executed as a cmd, as such you have the behavior below:

Tab completion works for a file called

bg()[asdf].jpg

. However if a file is named

(bg.jpg

the tab completion will fail, even though the file opens successfully.

Hope my code doesn't make you squirm tongue

Offline

#31 2013-03-28 15:45:54

Shinryuu
Member
From: /dev/urandom
Registered: 2010-02-27
Posts: 339

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby wrote:

That's actually the shell that doesn't like them.  If you try to run that command from the commandline (at least with bash), you'll get the same error.

Works well with /bin/bash but bash adds "\" characters before () and [] characters like this "mpv video\[23023421\]\(h.264\).mkv" That's not important if it doesn't work. It was just something I was testing out smile

EDIT1. ngzhian's patch works well with complex filenames!

HalosGhost wrote:
:exec  termite -e "%s"

That's sick cool

Last edited by Shinryuu (2013-03-28 15:52:07)

Offline

#32 2013-03-28 16:21:14

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I've accepted the pull request - thanks for the good code.  I am concerned with a potential side effect, though.

There are undoubtedly times when one would *not* want these characters escaped - specifically in urls.  I may have to remove this later, but I'll give it some time.

This is why I'd rather have it in the completion tool - if it's a filename it should be escaped, otherwise it should not be.

Last edited by Trilby (2013-03-28 16:21:50)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#33 2013-03-28 16:32:09

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,089
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Shinryuu wrote:

That's sick cool

Haha, I thought you'd like that. That's one of the things that makes this project so awesome.

All the best,

-HG

Offline

#34 2013-03-28 16:40:32

ngzhian
Member
Registered: 2012-12-09
Posts: 10

Re: Interrobang: a tiny menu packing a big bang (syntax)

Trilby wrote:

I've accepted the pull request - thanks for the good code.  I am concerned with a potential side effect, though.

There are undoubtedly times when one would *not* want these characters escaped - specifically in urls.  I may have to remove this later, but I'll give it some time.

This is why I'd rather have it in the completion tool - if it's a filename it should be escaped, otherwise it should not be.

Thanks! Hm.. Good point I didn't think of URLs (I type them into the browser directly). I tried a few combinations

!web www.google.com/(

'--will not do anything

!web www.google.com/\(

'--opens a new tab (I'm using Chromium) at http://www.google.com/(

!web www.google.com\(

'--opens a new tab at http://www.google.com%28

No idea about this behavior for now =/

Offline

#35 2013-03-28 17:12:12

ngzhian
Member
Registered: 2012-12-09
Posts: 10

Re: Interrobang: a tiny menu packing a big bang (syntax)

I'm not sure about other browsers but when I get

chromium www.google.com/(
bash: syntax error near unexpected token `('

And characters like '(', ')', '[', ']' etc should not appear in URLs at all since they are percent-encoded

I guess the decision is between
1) Allow the users to type '(', ')' etc and escape them such that browsers will open the page, but it is almost certainly an error since these are not percent encoded (unless the browser converts the URL, Chromium doesn't)
2) Do nothing when such illegal characters are found, which is the behavior seen above

IMO 2) seems to be the better option because of the fact that such strings are not valid URLs.

And also, I implemented the escapes in a new way, please see the diff here. Basically I escaped complist[compcur] before strcpy into line, so the '\' is drawn on the bar. I don't want to spam you with too many (>1) pull request a day so if its okay and you want me to submit one on GitHub please tell me smile

Thank you!

Offline

#36 2013-03-28 17:58:03

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I actually just reverted that pull and removed the escape function as I figured out how to add it to the completion code in the rc file.

See the new default interrobangrc and uncomment the "complex" completer and comment the basic one.

This feels much better as interrobang sticks with the input it is provided yet gives control to the user to ensure things are formatted properly.  I like tools that give options for the user rather than those that try to do our thinking for us.  As such interrobang will do exactly what it is told - the "complex" completer gives you a way to tell it the right things.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#37 2013-03-28 18:05:23

ngzhian
Member
Registered: 2012-12-09
Posts: 10

Re: Interrobang: a tiny menu packing a big bang (syntax)

I get your ideology smile Now I just have to go read some manual and figure what those bash things are trying to do!

Offline

#38 2013-03-30 10:40:58

megadriver
Member
From: Spain
Registered: 2010-02-03
Posts: 58
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I've just learned about interrobang.

This is exactly the launcher I've been looking for! Many thanks! smile

Offline

#39 2013-03-30 11:38:25

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,089
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Okay, I have this vision, but I'm not sure how it could be easily implementable. With dmenu, as you type, the list of commands that match are displayed along the bar, but that's kind of secondary; having tab-completion of available commands is good enough. However, What I would love, is if command-line options for the completed command are also available through tap completion.

So, for instance, you could open interrobang, type "htop -" and then, by pressing tab, the available switches/options would be offered as completion suggestions.

It would be extra cool if these options were displayed along the bar in a dmenu-ish style because then you know all the available command-line options. Zsh completion files already offer what would be necessary to offer the available options for commands which have the completion files included / available, but I don't know how feasible it would be to implement this. Thoughts?

All the best,

-HG

Last edited by HalosGhost (2013-03-30 11:38:36)

Offline

#40 2013-03-30 11:47:53

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

That sounds like a great idea: go for it wink

The dmenu-flavor displaying of options will not happen in interrobang, though.  And the completion of command-line options would be handled by the completion tool.  Interrobang is intentionally ignorant of these bits.  If the completion command/tool/script includes command line parameters, then interrobang will have them in its tab completion list; if the completion tool does not  include them, interrobang will not add them.

In other words - interrobang will happily use *any* completion tool and will report whatever output it provides.  Including the command-line parameters is the duty of the completion tool.



As an aside, I've installed and played with zsh.  I don't much like it.  It does lots of cool stuff, but it does it through "magic" that it doesn't want to let the user know about.  There is lots of information about how to change command completion at an interactive zsh prompt, but as far as I can tell zsh allows NO outside tools to use it's command completion.  Bash may not be as flashy, but it's an open book.

Zsh advocates, feel free to prove me wrong: provide some command or script that produces the candidate completion-list used by zsh.

Last edited by Trilby (2013-03-30 11:52:06)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#41 2013-03-30 12:03:53

megadriver
Member
From: Spain
Registered: 2010-02-03
Posts: 58
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

So I've found a small annoyance.

Autocompletion doesn't seem to like Unicode. I can't input accented characters, either.

Last edited by megadriver (2013-03-30 12:21:20)

Offline

#42 2013-03-30 13:18:25

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Ah, that probably would be an issue.  I use all the "regular" string functions, no wchar characters.

I'm not sure how much it would take to convert interrobang over to accepting unicode, but if you can give me a simple example of how I can replicate the problem I'll start looking into it.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#43 2013-03-30 13:56:20

megadriver
Member
From: Spain
Registered: 2010-02-03
Posts: 58
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Just name a file using non-ASCII characters.

For example, I created a file called "España". It gets autocompleted as "España".

Also, it won't recognize the dead keys in my Spanish keyboard. I try to type " á " and what I get is " 'a ".

Hope it helps.

Offline

#44 2013-03-30 14:08:56

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,089
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

megadriver wrote:

Just name a file using non-ASCII characters.

For example, I created a file called "España". It gets autocompleted as "España".

Also, it won't recognize the dead keys in my Spanish keyboard. I try to type " á " and what I get is " 'a ".

Hope it helps.

I can confirm that interrobang ignores XCompose as well.

All the best,

-HG

Offline

#45 2013-03-30 17:30:46

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

I've made quite a bit of progress on converting interrobang to utf8.  This is all new to me, but most of it is working well.  There is one stumbling block preventing the code from going to git, though.

I've changed out all the font processing, and replaced XDrawString with XmbDrawString (or Xutf8DrawString), but these replacements fail to draw accented characters.  In fact, they stop printing any string at the first accented character.  I've done quite a bit of troubleshooting, and have verified that the strings are processed correctly everywhere else - you can even "blindly" open a file with accented characters, but the string just will not be displayed on the interrobang window.

This is quite odd, as this is the whole purpose of these functions - dmenu itself uses XbmDrawString.

I'll have to come at this fresh tomorrow, and do a bit of "unit testing" to really learn how these two functions work.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#46 2013-03-30 18:47:35

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: Interrobang: a tiny menu packing a big bang (syntax)

Maybe it's a font issue? Did you try with an iso10646 font variant?


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#47 2013-03-30 18:49:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Yup, I tried with many fonts, including the font I used with dmenu.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#48 2013-03-30 23:54:22

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: Interrobang: a tiny menu packing a big bang (syntax)

Thanks so much for this launcher Trilby. Finally a light-weight launcher that's not dmenu.

Offline

#49 2013-03-31 00:19:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Interrobang: a tiny menu packing a big bang (syntax)

Your welcome anon.

Good news on the utf8 front.  I realized I needed to include locale.h and call "setlocale()".  This is *mostly* working now.  But including this really changes up how fonts are handled so I want to do a little polishing and add some error checking before I push these changes to github.

EDIT: yup, I'm pretty sure this is working - and I've learned more about internationalization with xlib than I ever thought I'd care too.  I'm still going to wait till tomorrow to make the code a little less ugly before I push these changes - but expect full utf8 compatability by Monday.

EDIT AGAIN: eh, why not - I just pushed the most recent changes to add utf support.  It's quite rough around the edges, and the code itself needs a lot of cleanup, but it should be working - so feel free to test if you are really eager.  I do know of one minor bug that should be easy to fix: when backspacing, there is no check for "wide" characters yet, so wide-characters aren't  properly deleted.

Last edited by Trilby (2013-03-31 02:03:24)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#50 2013-03-31 02:56:31

Richjn
Member
From: Perth (Australia)
Registered: 2004-03-22
Posts: 33

Re: Interrobang: a tiny menu packing a big bang (syntax)

@Trilby
Really like interrobang, works well in ttwm but at the moment I can't ditch dmenu because I need it (along with xprop) to act as a urlbar for surf my main browser. I saw from your opening post that interrobang does not take stdin is this a never or just not for now situation ? I know I could just leave both installed but this goes against my minimalist outlook.

Alternatively does anyone know how to open url's from within surf other than with dmenu ? I know I can launch surf to a url from interrobang but this opens a fresh instance of surf which is not what I want to do.


Richard

Offline

Board footer

Powered by FluxBB