diff --git a/src/haiku.cpp b/src/haiku.cpp index 973e957e..cde6f819 100644 --- a/src/haiku.cpp +++ b/src/haiku.cpp @@ -46,6 +46,7 @@ char* haiku_get_clipboard() ssize_t len; be_clipboard->Data()->FindData("text/plain", B_MIME_TYPE, &(const void*)value, &len); + be_clipboard->Unlock(); return strdup(value); } return NULL; diff --git a/src/readline.c b/src/readline.c index e069ea2e..1c50a625 100644 --- a/src/readline.c +++ b/src/readline.c @@ -85,6 +85,21 @@ void Insert_character(char * str, char letter, byte position) str[position]='\0'; } +void Prepend_string(char* dest, char* src, int max) +{ + // Insert src before dest + int sized = strlen(dest); + int sizes = strlen(src); + + if (sized + sizes >= max) + { + sizes = max - sized; + } + + memmove(dest+sizes, dest, sized); + memcpy(dest, src, sizes); +} + int Valid_character(int c) { // Sous Linux: Seul le / est strictement interdit, mais beaucoup @@ -466,10 +481,11 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz { char* data = getClipboard(); if (data == NULL) continue; // No clipboard data - // TODO Insert it at the cursor position, not at the end + // Insert it at the cursor position + Prepend_string(str + position, data, max_size - position); // TODO Update cursor position // TODO This doesn't respect the "allowed chars" restriction - strncat(str, data, max_size - size); + //strncat(str, data, max_size - size); free(data); goto affichage; }