FLTK logo

[fltk.coredev] Fl_Terminal selection_text() methods

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Fl_Terminal selection_text() methods "'Albrecht Schlosser' via fltk.coredev" 06:28 Mar 12  
  Hi, Greg and others,

should the methods Fl_Terminal::selection_text_len() and Fl_Terminal::selection_text() be public rather than protected?

Currently they are protected. Was this intentional?

My intention is to copy text from Fl_Terminal to the clipboard. In this special case (test/handle_keys.cxx) I disabled keyboard input for this instance of Fl_Terminal, hence users can't use ctrl/c to copy text although text selection with the mouse works.

Since it would generally make sense to copy only parts of the entire text I thought about the "simple" approach to let the user select text (with the mouse) and then let them click the "Copy" button.

Code:

void copy_cb(Fl_Widget *b, void *) {
Terminal *tty = ((app *)b->window())->tty;
int len = tty->selection_text_len();
if (len <= 0) {
fl_message("Please select text with the mouse and then click the copy button.");
tty->take_focus();
return;
}
const char *text = tty->selection_text();
Fl::copy(text, len, 1, Fl::clipboard_plain_text);
fl_message("The selected text has been copied to the clipboard.");
free((void *)text);
tty->take_focus();
}

    However, this can't be compiled because both selection_text_len()  and selection_text() are protected. This
    code works well if I make these two methods public.

The docs state:
```
Return text selection (for copy()/paste() operations)
  • Returns allocated NULL terminated string for entire selection.
  • Caller must free() this memory when done.
  • Unicode safe.
```

I wonder why these methods are protected. This doesn't seem to make sense to me. They are well documented and "read-only".

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/26fa55b0-badb-4ec6-904a-91613e28d46a%40aljus.de.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.