magiblot / turbo

An experimental text editor based on Scintilla and Turbo Vision.
Other
461 stars 35 forks source link

temporary disable "auto indent" before doing clipboard paste #1

Closed unxed closed 3 years ago

unxed commented 3 years ago

...or some text is being pasted with unnecessary spaces (this sample is copied from turbo's readme on github in firefox):

Building

First of all, you should clone this repository along its submodules with git clone --recursive.

Then, make sure the following dependencies are installed:

    CMake.
        A compiler supporting C++17.
            libncursesw (note the 'w').
                libfmt.
magiblot commented 3 years ago

It is currently not possible to detect a 'paste' event from the terminal (except system clipboard, #2). It would be first necessary to add non-blocking event look-ahead support in Turbo Vision.

magiblot commented 3 years ago

A terrible workaround would be to measure the time between text events in order to make an approximate 'paste' detection.

unxed commented 3 years ago

A terrible workaround would be to measure the time between text events in order to make an approximate 'paste' detection.

Not so terrible, Midnight Commander is doing just the same to prevent the need of pressing ESC twice.

magiblot commented 3 years ago

I am very obstinate, so instead of doing the timing hack I ended up implementing non-blocking event reads in Turbo Vision to make this feature possible.

unxed commented 3 years ago

Tested. Working. Cool!

magiblot commented 3 years ago

This is now also implemented in tvedit (as of https://github.com/magiblot/tvision/commit/f8a994f1be9d48aa7ff48847145ce58d0115d4c9).

unxed commented 1 year ago

It turns out that there is a standard solution to this problem, supported by most terminals: https://en.wikipedia.org/wiki/Bracketed-paste https://invisible-island.net/xterm/xterm-paste64.html