Hello, I have a very simple request for Geany which I use heavily.
On my system I frequently view the output of commands the following way: $ ls -l | nano - here, nano reads standard input as a new unsaved file, making it easy to quickly access ls command output.
I would love to be able to do the same with geany: $ ls -l | geany - In other words, instead of a file, having standard input read as a new unsaved file (which would open either as new window or new tab depending on user's settings, but this is of no concern to me).
Thank you
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780
I could've swore there was an Issue for this already, but I can't seem to find it (maybe on SF.net?).
@naturalspringwater what would happen if you did something like this?
```bash cat /dev/random | geany - ```
Ignoring the fact that it would eventually get zeroes which would cause other problems, should Geany show it's window and read-in chunks and update the UI, or should it just read the whole input (forever) until it uses too much memory and crashes (or gets killed by the OS or whatever)?
I think on Windows, Geany only allocates a console (and hence only has stdio) when `-v` option is passed. I guess it would need a special case for `-` as well to cause it to call `AllocConsole` or whatever it does for `-v`.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160235386
Currently Geany uses an option parsing library that does not support a single dash by itself and without the dash there is no way of differentiating between simply opening geany and reading the standard input.
It could of course use some other option to mean read from stdin. Given the questions about windows @codebrainz raised this might only be a Linux feature and would have to trust the user to provide an input that contains no binary and which terminates and which does not output so much that the socket blocks and which uses default encoding (UTF8).
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160237033
Currently Geany uses an option parsing library that does not support a single dash by itself and without the dash there is no way of differentiating between simply opening geany and reading the standard input.
If GOptionParser chokes on a single `-` (does it? I figured it would just pass it through), some code could be added to detect/remove `-` from `argv` before calling into the option parser, instead of dealing with it after the option parser.
Given the questions about windows @codebrainz raised this might only be a Linux feature
It wasn't questions as much as a note if someone's gonna implement this feature, I think Windows needs another special case in order to get stdio handles for this to work.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160238096
and which uses default encoding (UTF8)
Good point, it would probably need to detect, and convert from the terminal encoding, which may not be UTF-8.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160238420
If GOptionParser chokes on a single - (does it? I figured it would just pass it through), some code could be added to detect/remove - from argv before calling into the option parser, instead of dealing with it after the option parser.
Ahhh, I was looking at the `g_option` API that won't let you specify a `-` by itself as an option, but you are right it passes it through, and geany opens a new file called `-`, and `--` also passes through too even though it is documented as "stop parsing options", so it needs filtering as well.
Good point, it would probably need to detect, and convert from the terminal encoding, which may not be UTF-8.
The problem is that the output of the command may not be in terminal encoding either, it has to be selectable manually `--encoding=xxx` maybe, but that is of course more effort for the "somebody" implementing this capability.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160241771
The problem is that the output of the command may not be in terminal encoding either, it has to be selectable manually, --encoding=xxx maybe, but that is of course more effort for the "somebody" implementing this capability.
Or else we could just document that the input has to be in UTF-8 and the user must use `iconv` or similar tools to filter the pipe and do the conversion.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160241909
@naturalspringwater as a work-around, you could make a script to call instead of `geany` directly, something like this, which kind of does what you want (I think, I'm on Windows ATM):
```bash #!/usr/bin/env bash set -e TMPFILE=`mktemp` trap 'rm -f "$TMPFILE"' EXIT while read line do echo "$line" >> "$TMPFILE" done geany $@ "$TMPFILE" ```
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160242605
Hello,
Well, cat /dev/urandom | nano - simply waits forever for stdin to run out which never does, but provides a message to send CTRL+C to cancel.
You are right, some strategy to handle encoding would make sense. For typical commands on linux it's a non-issue, but I can see the need, you can have unicode/intl. characters in filenames (of 'ls' output above) for example... but on my system "ls -l" can output unicode and nano outputs unicode, so... I don't remember how terminals and bash handle it.
I would expect to have to do the conversions myself. After the file opens, if geany can't heuristically tell the encoding from contents like other files (does it do that? I always work on the same kinds of files), I would simply select the encoding myself from the menu ("Set Encoding"), since the point is to have a GUI. I suppose a command line option to override which "Set Encoding" is selected when the file opens could be useful. But that could be a separate suggestion entirely...
Indeed I already tried "geany -" and it opens a file named dash.
@codebrainz I could probably make use of that script. The part I didn't think of is using a random filename. That would work.
Thanks for responding
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160244693
if geany can't heuristically tell the encoding from contents like other files (does it do that? [...]
Naively, and with a tendency towards common 8-bit encodings like ASCII, Latin-1, UTF-8, etc. Probably the only accurate detection is for files with a UTF byte order marker at the front and maybe XML files if they declares encoding before any non-ASCII characters..
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160245085
Encodings checks these to extract the encoding:
``` /* <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> */ #define PATTERN_HTMLMETA "<meta\s+http-equiv\s*=\s*"?content-type"?\s+content\s*=\s*"text/x?html;\s*charset=([a-z0-9_-]+)"\s*/?>" /* " geany_encoding=utf-8 " or " coding: utf-8 " */ #define PATTERN_CODING "coding[\t ]*[:=][\t ]*"?([a-z0-9-]+)"?[\t ]*" ```
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160245340
I see. Well... I hadn't had any problems with it.
I tried your script and with slight changes it works well under a regular user. Full setup:
sudo -i cat > /usr/bin/geany-stdin << "EOF" #!/usr/bin/env bash
TMPFILE=$(mktemp -p ~) trap 'rm -f "$TMPFILE"' exit cat - > "$TMPFILE" geany $@ "$TMPFILE" EOF chmod +x /usr/bin/geany-stdin exit
ls -l | geany-stdin
gksudo is another matter but I can work around it.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-160250999
why not adding a cmdline switch like kate has: `-i, --stdin Read the contents of stdin`
So eg. you could do: `echo "Hello world" | geany -i`
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-220495832
@eadmaster that was suggested in the third post. Also `-i` is already used. But a pull request that used an otherwise unused option could be accepted.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/780#issuecomment-220515545
2020 year.. i want stdin read
@x09 then make a pull request to add the capability.
Hello! In the case the stdin messages to insert into the editor are some other program execution results, executing the other program in a snippet might serve you. For instance, I needed grep output to be inserted into the editor so I defined the snippet:
task={command:sh -c 'grep -r -F "**tarefa**" /home/user/Documents/*'}
After grep execution (Geany hangs until completion), its output is written into the editor active tab.
Hope it helps.
github-comments@lists.geany.org