Text/Label paste: Word-wrap on space (eaten) or dash

This commit is contained in:
Bill Kendrick 2024-12-25 13:42:25 -08:00
parent c7d449888d
commit 07e338d717
16 changed files with 53 additions and 28 deletions

View file

@ -9,11 +9,11 @@ https://tuxpaint.org/
2024.December.25 (0.9.35)
* Text & Label Tool Improvements:
-------------------------------
+ WIP It is now possible to paste text from the copy/paste clipboard
+ It is now possible to paste text from the copy/paste clipboard
into Tux Paint. If text goes beyond the right of the canvas,
a new line is created. If text goes beyond the bottom of the
canvas, the text is truncated there.
- TODO: Improve word-wrapping (word-based, not character)
the text is word-wrapped at the previous space (' ') or dash ('-'),
if any, and a new line is created. If text goes beyond the bottom
of the canvas, the text is truncated there.
Closes https://sourceforge.net/p/tuxpaint/feature-requests/95/
Bill Kendrick <bill@newbreedsoftware.com>

View file

@ -495,8 +495,9 @@ e."Text" and "Label" Tools ←
Text from the clipboard (copy/paste buffer) can be inserted with the "Text"
and "Label" tools by pressing the [Control] + [V] key combination on a
physical keyboard, or clicking the "Paste" button in Tux Paint's on-screen
keyboard. The text will wrap to the next line if it hits the right edge of
the canvas. If the text hits the bottom of the canvas, the pasting will
keyboard. If the text would exceed the right edge of the canvas, it will
wrap to a new line of text (going back to the previous space or dash ('-')
if possible). If the text hits the bottom of the canvas, the pasting will
abort, truncating the text.
Clicking elsewhere in the picture while the text entry is still active

View file

@ -823,7 +823,7 @@
Alternatively, press <strong><code>[Tab]</code></strong> and the text will be drawn onto the picture, but the cursor will move to the right of the text, rather than down a line, and to the left. (This can be useful to create a line of text with mixed colors, fonts, styles and sizes.) </p>
<p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. The text will wrap to the next line if it hits the right edge of the canvas. If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. If the text would exceed the right edge of the canvas, it will wrap to a new line of text (going back to the previous space or dash ('-') if possible). If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
<p>
Clicking elsewhere in the picture while the text entry is still active causes the current line of text to move to that location (where you can continue editing it). </p>

View file

@ -495,8 +495,9 @@ e."Text" and "Label" Tools ←
Text from the clipboard (copy/paste buffer) can be inserted with the "Text"
and "Label" tools by pressing the [Control] + [V] key combination on a
physical keyboard, or clicking the "Paste" button in Tux Paint's on-screen
keyboard. The text will wrap to the next line if it hits the right edge of
the canvas. If the text hits the bottom of the canvas, the pasting will
keyboard. If the text would exceed the right edge of the canvas, it will
wrap to a new line of text (going back to the previous space or dash ('-')
if possible). If the text hits the bottom of the canvas, the pasting will
abort, truncating the text.
Clicking elsewhere in the picture while the text entry is still active

View file

@ -823,7 +823,7 @@
Alternatively, press <strong><code>[Tab]</code></strong> and the text will be drawn onto the picture, but the cursor will move to the right of the text, rather than down a line, and to the left. (This can be useful to create a line of text with mixed colors, fonts, styles and sizes.) </p>
<p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. The text will wrap to the next line if it hits the right edge of the canvas. If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. If the text would exceed the right edge of the canvas, it will wrap to a new line of text (going back to the previous space or dash ('-') if possible). If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
<p>
Clicking elsewhere in the picture while the text entry is still active causes the current line of text to move to that location (where you can continue editing it). </p>

View file

@ -525,8 +525,9 @@ e.Outils "Texte" et "Étiquette" ←
Text from the clipboard (copy/paste buffer) can be inserted with the "Text"
and "Label" tools by pressing the [Control] + [V] key combination on a
physical keyboard, or clicking the "Paste" button in Tux Paint's on-screen
keyboard. The text will wrap to the next line if it hits the right edge of
the canvas. If the text hits the bottom of the canvas, the pasting will
keyboard. If the text would exceed the right edge of the canvas, it will
wrap to a new line of text (going back to the previous space or dash ('-')
if possible). If the text hits the bottom of the canvas, the pasting will
abort, truncating the text.
Cliquer ailleurs dans l'image alors que l'entrée de texte est toujours

View file

@ -823,7 +823,7 @@
Sinon, appuyez sur <strong><code>[Tab]</code></strong> et le texte sera inclus dans l'image, mais le curseur se déplacera vers la droite du texte, plutôt que vers le bas d'une ligne et vers la gauche. (Cela peut être utile pour créer une ligne de texte avec des couleurs, des polices, des styles et des tailles variés.) </p>
<p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. The text will wrap to the next line if it hits the right edge of the canvas. If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. If the text would exceed the right edge of the canvas, it will wrap to a new line of text (going back to the previous space or dash ('-') if possible). If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
<p>
Cliquer ailleurs dans l'image alors que l'entrée de texte est toujours active entraîne le déplacement de la ligne de texte actuelle vers cet emplacement (et vous pouvez continuer à la modifier). </p>

View file

@ -503,8 +503,9 @@ e.Ferramentas «Texto» e «Etiquetas» ←
Text from the clipboard (copy/paste buffer) can be inserted with the "Text"
and "Label" tools by pressing the [Control] + [V] key combination on a
physical keyboard, or clicking the "Paste" button in Tux Paint's on-screen
keyboard. The text will wrap to the next line if it hits the right edge of
the canvas. If the text hits the bottom of the canvas, the pasting will
keyboard. If the text would exceed the right edge of the canvas, it will
wrap to a new line of text (going back to the previous space or dash ('-')
if possible). If the text hits the bottom of the canvas, the pasting will
abort, truncating the text.
Ao premer noutro lugar da imaxe mentres a entrada de texto aínda está

View file

@ -823,7 +823,7 @@
Como alternativa, prema <strong><code>[Tab]</code></strong> e o texto será debuxado na imaxe, mais o cursor moverase á dereita do texto, no canto de baixar unha liña e á esquerda. (Isto pode ser útil para crear unha liña de texto con cores, tipos de letra, estilos e tamaños mesturados.) </p>
<p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. The text will wrap to the next line if it hits the right edge of the canvas. If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. If the text would exceed the right edge of the canvas, it will wrap to a new line of text (going back to the previous space or dash ('-') if possible). If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
<p>
Ao premer noutro lugar da imaxe mentres a entrada de texto aínda está activa, a liña de texto actual moverase a esa posición (onde pode continuar editándoa). </p>

View file

@ -495,8 +495,9 @@ e."Text" and "Label" Tools ←
Text from the clipboard (copy/paste buffer) can be inserted with the "Text"
and "Label" tools by pressing the [Control] + [V] key combination on a
physical keyboard, or clicking the "Paste" button in Tux Paint's on-screen
keyboard. The text will wrap to the next line if it hits the right edge of
the canvas. If the text hits the bottom of the canvas, the pasting will
keyboard. If the text would exceed the right edge of the canvas, it will
wrap to a new line of text (going back to the previous space or dash ('-')
if possible). If the text hits the bottom of the canvas, the pasting will
abort, truncating the text.
Clicking elsewhere in the picture while the text entry is still active

View file

@ -823,7 +823,7 @@
Alternatively, press <strong><code>[Tab]</code></strong> and the text will be drawn onto the picture, but the cursor will move to the right of the text, rather than down a line, and to the left. (This can be useful to create a line of text with mixed colors, fonts, styles and sizes.) </p>
<p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. The text will wrap to the next line if it hits the right edge of the canvas. If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. If the text would exceed the right edge of the canvas, it will wrap to a new line of text (going back to the previous space or dash ('-') if possible). If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
<p>
Clicking elsewhere in the picture while the text entry is still active causes the current line of text to move to that location (where you can continue editing it). </p>

View file

@ -450,8 +450,9 @@ e.「もじ」ツール、「ラベル」ツール ←
Text from the clipboard (copy/paste buffer) can be inserted with the "Text"
and "Label" tools by pressing the [Control] + [V] key combination on a
physical keyboard, or clicking the "Paste" button in Tux Paint's on-screen
keyboard. The text will wrap to the next line if it hits the right edge of
the canvas. If the text hits the bottom of the canvas, the pasting will
keyboard. If the text would exceed the right edge of the canvas, it will
wrap to a new line of text (going back to the previous space or dash ('-')
if possible). If the text hits the bottom of the canvas, the pasting will
abort, truncating the text.
文字の入力中に別の場所をクリックすると、入力内容を維持したまま、文字を貼り

View file

@ -823,7 +823,7 @@
また、<strong><code>[Tab]</code></strong>キーを押すと、文字が描画された後、カーソルは、次の行ではなく、右側に移動します。これは、1行の中で異なったフォント、字体、フォントサイズ、色などを混在させたい場合に便利な方法です。 </p>
<p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. The text will wrap to the next line if it hits the right edge of the canvas. If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. If the text would exceed the right edge of the canvas, it will wrap to a new line of text (going back to the previous space or dash ('-') if possible). If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
<p>
文字の入力中に別の場所をクリックすると、入力内容を維持したまま、文字を貼り付ける位置をクリックした位置に移動させ、文字入力を続けることができます。 </p>

View file

@ -496,8 +496,9 @@ e.Mjete “Tekst” dhe “Etiketa” ←
Text from the clipboard (copy/paste buffer) can be inserted with the "Text"
and "Label" tools by pressing the [Control] + [V] key combination on a
physical keyboard, or clicking the "Paste" button in Tux Paint's on-screen
keyboard. The text will wrap to the next line if it hits the right edge of
the canvas. If the text hits the bottom of the canvas, the pasting will
keyboard. If the text would exceed the right edge of the canvas, it will
wrap to a new line of text (going back to the previous space or dash ('-')
if possible). If the text hits the bottom of the canvas, the pasting will
abort, truncating the text.
Clicking elsewhere in the picture while the text entry is still active

View file

@ -823,7 +823,7 @@
Alternatively, press <strong><code>[Tasti Tab]</code></strong> and the text will be drawn onto the picture, but the cursor will move to the right of the text, rather than down a line, and to the left. (This can be useful to create a line of text with mixed colors, fonts, styles and sizes.) </p>
<p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. The text will wrap to the next line if it hits the right edge of the canvas. If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
Text from the clipboard (copy/paste buffer) can be inserted with the "Text" and "Label" tools by pressing the <strong><code>[Control]</code> + <code>[V]</code></strong> key combination on a physical keyboard, or clicking the "<strong>Paste</strong>" button in Tux Paint's on-screen keyboard. If the text would exceed the right edge of the canvas, it will wrap to a new line of text (going back to the previous space or dash ('-') if possible). If the text hits the bottom of the canvas, the pasting will abort, truncating the text. </p>
<p>
Clicking elsewhere in the picture while the text entry is still active causes the current line of text to move to that location (where you can continue editing it). </p>

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - December 20, 2024
June 14, 2002 - December 25, 2024
*/
#include "platform.h"
@ -3198,10 +3198,28 @@ static void mainloop(void)
txt_width = do_render_cur_text(0);
if (cursor_x + txt_width > canvas->w && texttool_len > 1)
{
texttool_str[texttool_len - 1] = '\0';
int best, j, rewind;
best = -1;
for (j = texttool_len - 1; j >= 0 && best == -1; j--) {
if (texttool_str[j] == ' ') {
best = j + 1; /* +1 to eat the space */
} else if (texttool_str[j] == '-') { /* FIXME: Also en-dash, em-dash, others? -bjk 2024.12.25 */
best = j;
}
}
if (best == -1) {
best = texttool_len - 1;
}
rewind = texttool_len - best;
texttool_str[best] = '\0';
txt_width = do_render_cur_text(0);
exceeded = text_label_tool_enter(TuxPaint_Font_FontHeight(getfonthandle(cur_font)));
i--;
i = i - rewind;
}
SDL_Delay(10);
}