All, I have a simple editor project I've been tinkering with (https://github.com/drankinatty/gtkwrite) and I've implemented EOL handling for LF, CRLF, and CR to accommodate Linux/Unix/OSX, DOS/Win, and Mac (pre-OSX). I've run into a question on implementing the EOL in text pasted from the clipboard.
By default, all cut/copy/paste operations use LF. If I understand the clipboard documentation, I should be able to use: gtk_clipboard_request_text with the: (*GtkClipboardTextReceivedFunc) callback so that when a request to paste text is made, I can call gtk_clipboard_request_text, pass the callback (which will scan the text in the clipboard, (and if necessary allocate a larger buffer to handle inserting CR before LF to make CRLF), pass the EOL flag to determine which to change to as the 'gpointer *data', and finally returning a pointer to the reformatted clipboard text through the 'text' parameter to the callback (or NULL if something fails). My question is -- does this sound sane? To handle the EOL fix only for text *pasted* into the textview buffer, or is it better to handle the EOL fix during copy/paste so the text in the clipboard is formatted for the host OS? (my thought was to just do it on paste) Basically, I have a variable that holds (0,1,2) that serves as a flag for EOL type (based on an 'enum eolorder { LF, CRLF, CR };') that I can pass as the pointer to the callback to allow the EOL adjustments to be made. Does this approach sound reasonable, or like one I'll spend 1/2 day coming to regret? -- David C. Rankin, J.D.,P.E. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list