Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow manual multiline messages #182

Closed
boothj5 opened this issue Jun 4, 2013 · 12 comments
Closed

Allow manual multiline messages #182

boothj5 opened this issue Jun 4, 2013 · 12 comments

Comments

@boothj5
Copy link
Collaborator

boothj5 commented Jun 4, 2013

Allow users to send multiline messages, using ctrl-enter or some keyboard combination for the new lines.

Up/down arrow should behave accordingly and move through the message rather than previous commands.

@boothj5 boothj5 mentioned this issue Aug 12, 2013
@boothj5
Copy link
Collaborator Author

boothj5 commented Nov 11, 2013

Related to #156 where a user may attempt to paste a multi-line message in one go.

@boothj5 boothj5 removed this from the 0.4.0 milestone Feb 15, 2014
@moorchegue
Copy link

👍

@yumitsu
Copy link

yumitsu commented Sep 13, 2017

Any progress on this?

@mdosch
Copy link
Contributor

mdosch commented Apr 18, 2019

I stumbled upon this Ncurses Multi-Line Text Editor and not being a programmer I don't know if this could be reused for profanity.
Although it might be a problem that there is not mentioned a license but maybe this is somehow comparable to MIT:

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.

@jubalh
Copy link
Member

jubalh commented Apr 18, 2019

Thanks a lot for researching this!
I'll take a lot when I find time :-)

@jubalh
Copy link
Member

jubalh commented Oct 22, 2019

mcabber does this via a /multi in the input field.

I stumbled upon this Ncurses Multi-Line Text Editor

Is actually ncurses only, but we use readline to handle the line editing.

Maybe we can look at rlwrap for inspiration.

@mjg0
Copy link

mjg0 commented Dec 19, 2019

I was able to work around this with a simple Python plugin (inspired by @boothj5's syscmd.py) that allows one to use e.g. /printf "here is a\nmessage with a couple lines" to send multiline messages until there's native support:

import prof
from subprocess import Popen, PIPE

def _cmd_printf(format):
    if not format:
        prof.cons_bad_cmd_usage("/printf")
        return
    try:
        cmd_string = '"' + format + '"'
        result = Popen("printf " + cmd_string, shell=True, stdout=PIPE).stdout.read()
        prof.send_line(result)
    except Exception as e:
        prof.cons_show("Internal error: " + repr(e))
    # TODO: real error handling

def prof_init(version, status, account_name, fulljid):
    synopsis = ["/printf <format-string>"]
    description = "Use your system's printf to send a formatted message"
    args = [["<format-string>", "the format string to print"]]
    examples = ["/printf \"this message will display\\non multiple lines\"", 
                "/printf \"my home directory is $HOME\"",
                "/printf \"here are the contents of my clipboard:\\n$(xclip -o)\""]
    prof.register_command("/printf", 1, 1, synopsis, description, args, examples, _cmd_printf)
    prof.filepath_completer_add("/printf")

It needs work and has only been tested on my system, but it's an easy way to send arbitrary multiline messages, with the added benefit of being able to incorporate the output of shell commands.

Feel free to modify/suggest changes, it's still kind of a rough draft.

@mdosch
Copy link
Contributor

mdosch commented Dec 19, 2019

Also there is some workaround using Ctrl+V (^V) and Ctrl+J (^J):

  • Write This should be the first line.This should be the second.
  • Place your cursor between . and second This
  • Press ^V and afterwards ^J
  • Press Enter

@jubalh
Copy link
Member

jubalh commented Apr 23, 2020

pasis found: https://github.com/ulfalizer/readline-and-ncurses
I should read that when trying to solve this issue.

@kaffeekanne
Copy link
Contributor

kaffeekanne commented Apr 21, 2021

An /editor command for extended message composing was introduced by #1485 and is discussed at #1521.

@jubalh
Copy link
Member

jubalh commented Mar 21, 2022

As @kaffeekanne mentioned we have an /editor command now.
And for 0.12.0 #1645 (and #1648) was added.
The workflow seems to be quite nice now. Even more powerful than just regular multi line.
Let's close this issue.

@sjaeckel
Copy link
Member

And there's a shortcut that spawns the editor, per default alt+c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants