I managed to do this
echo -n "command" > /dev/tty1
The letters appear, and the cursor moves, but they are "ghosts" – if you hit Enter, nothing happens (they are not in stdin).
In the middle of the below screenshot, you see why I see the use of this. (The line with a red caption, right below the line with a yellow caption.) As it is now, you are not really "editing" the note text; you are just asked to write a new text, which will replace the text of the note you are (not really) editing. Thus, I thought it could be remedied by simply pasting the old text into the tty: if the user hits enter, no modification is made. (This program is in Perl/MySQL, but I thought it would be more interesting to ask for a general solution than "how do I do this in Perl".)
Here is the Perl code, that uses the C code below (works exactly as intended), as well as a new screenshot – hopefully this will clarify things beyond doubt :) Again, look at the middle of the screenshot, where the edit is made to the note text - this time around, the old text is there, for example if you just wanted to fix a typo, you won't have to retype the entire note text.
my $edit_note_text = $edit_note_data; print BOLD, RED, " new text: ", RESET; system("writevt /dev/tty \"$edit_note_text\""); my $new_text = <$in>; $new_text = fix_input($new_text); my $set_text = "UPDATE notes SET note = \"$new_text\" WHERE id = $edit_note_id"; $db->do($set_text);