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

selection.set-rectangle-mark #140

Open
lecheel opened this issue Aug 13, 2016 · 8 comments
Open

selection.set-rectangle-mark #140

lecheel opened this issue Aug 13, 2016 · 8 comments

Comments

@lecheel
Copy link

lecheel commented Aug 13, 2016

hi,
how to paste support rectangle paste on place instead new line

@atsuoishimoto
Copy link
Member

I'm not sure what you mean "on place".

By default, alt+# key starts rectangular selection. You can copy or paste against selected rectangular. Is this what you need?

@lecheel
Copy link
Author

lecheel commented Aug 13, 2016

for example I want copy the rectangular after rectangular position

@lecheel
Copy link
Author

lecheel commented Aug 13, 2016

from:
abc foo aaaa
aaa foo aaaa
to:
abc (bar)foo aaaa
aaa (bar)foo aaaa

@atsuoishimoto
Copy link
Member

Thank you for explanation.

  1. Copy some lines
  2. Move to position where you want to add text and start rectangular selection with alt+# key.
  3. Hit down cursor to last row you want to add text.(You may notice that selection is not visible, but rectangular of zero width is selected).
  4. Paste with ctrl+v.

With this way, lines of text in clipboard are inserted to middle of lines, without inserting new line characters.

@lecheel
Copy link
Author

lecheel commented Aug 13, 2016

Thanks Atsuo it works but a little bit complex better have a quick vpaste command :-)

@lecheel
Copy link
Author

lecheel commented Aug 13, 2016

I've create custom kaa.py for dummy test but no luck to works
another question how to invoke @commandid for edit.paste

from kaa.addon import *
from kaa.command import *
import kaa
kaa.cui.app.CuiApp.DEFAULT_MENU_MESSAGE = "Type F10 for menu"

@commandid('le.vpaste')
def vpaste(wnd):
        s = kaa.app.clipboard.get()
        if s:
            with wnd.document.undo_group():
                wnd.screen.selection.clear()
                wnd.screen.selection.set_rectangle_mark(wnd.cursor.pos)
                # TODO loop for clipboard line with N down()
                wnd.cursor.down()
                wnd.cursor.down()
                wnd.cursor.down()

                for i in range(wnd.get_command_repeat()):
                      wnd.document.mode.put_string(wnd, s)
                      wnd.screen.selection.clear()
@setup('kaa.filetype.default.defaultmode.DefaultMode')
def my_keybind(mode):
    # register command to the mode
    mode.add_command(vpaste)

@atsuoishimoto
Copy link
Member

Wow, great job.

You can bind command to the key in your my_keybind() function as follows:

@setup('kaa.filetype.default.defaultmode.DefaultMode')
def my_keybind(mode):
    # register command to the mode
    _trace('my_keybind called')    # emit log to ~/.kaa/log/kaa.log
    mode.add_command(vpaste)
    mode.add_keybinds(keys={
        (ctrl, 'x'): 'le.vpaste'   # Assign C-x to 'le.vpaste'.
    })

@atsuoishimoto
Copy link
Member

to execute edit.paste command, you can

@commandid('le.vpaste')
def vpaste(wnd):
    wnd.document.mode.on_commands(wnd, ['edit.paste'])

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

No branches or pull requests

2 participants