2

I'm writing my own terminal application in C using the VTE library. Everything works great except I cannot select text with the keyboard. For example if I have just typed something, in most terminals you can hold down the shift key and select the previous text with the left arrow key, then you can paste it wherever you want. In VTE, all that happens is you get a D in the current cursor position. I can obviously block the printing of D in the terminal by returning TRUE from the keypress (which I have done), but I still cannot select the text.

I thought I might be able to do it manually starting with vte_terminal_get_cursor_position(), but there is no method to select a block of text (that I could find) in VTE once I have the boundaries for the selection.

I've looked at other VTE based projects such as tinyterm, and evilvte, but they just print the D in the terminal as well when that key combination is pressed.

So is there any way to select text in VTE using the keyboard? Thanks.

Correction: It turns out that very few if any terminals allow you to select text with the keyboard. Not sure how that got into my head. Anyway, I still think it would be a handy capability, so the question stands. Any ideas would be greatly appreciated.

nomadicME
  • 1,389
  • 5
  • 15
  • 35
  • Why are there perl and python tags, since you're coding in C? – Demnogonis Dec 16 '12 at 20:59
  • vte is also available in perl and python, and since there is not a vte tag available and I don't have enough clout to create a vte tag. The question is equally valid for someone coding in these other languages. – nomadicME Dec 16 '12 at 21:36
  • but you specifically stated you're using C. so python and perl most likely won't help you – DeadChex Dec 16 '12 at 21:43
  • not true, most of the time with these apis, if a solution is presented in one code, only a few minor modifications are required to implement it in another. – nomadicME Dec 17 '12 at 00:14
  • Actually none of the `c`, `python` and `perl` tags are really appropriate in my opinion, since the question is language-agnostic as you point out. I'll create a `vte` tag and apply it to other VTE questions. – ptomato Dec 17 '12 at 09:09
  • stdin is handled by the called process, hence the question has nothing to do with vte. This is a bash question (if you are using bash), a tcsh question (if you are using tcsh) or a whatever question (if you are using whatever). – ntd Dec 18 '12 at 18:42
  • @ntd, thanks for you input. That is definately another way to approach the problem, and I found a number of threads related to such an approach. However, I think this may also be possible through vte/gtk, since there currently exists methods such as `vte_terminal_select_all ()` and `vte_terminal_copy_clipboard ()`. What I'm looking for may not exist yet, but I think it is/(will be) possible through vte/gtk. – nomadicME Dec 18 '12 at 23:54
  • @nomadicME clipboard manipulation routines are used by the mouse. And at shell level there is no concept of clipboard... Maybe you could cook up something with xclip and readline. – ntd Dec 19 '12 at 18:26
  • @ntd, I'd have to respectfully disagree with this statement. As evidence I point back to my previous comment, which mentions one method for selecting text in the terminal and one method for placing the selected text on the clipboard. Neither, requires mouse interaction. – nomadicME Dec 20 '12 at 01:03

0 Answers0