mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 23:36:23 -05:00
Start actually inserting full utf8 sequences
This makes it possible to cut-and-paste the UTF8 testfile into a new buffer, and the end result looks correct. NOTE! We still do various things wrong while editing. For example, while the cursor movements were fixed, simple things like deleting a character still work on single bytes, rather than utf8 characters. So while this is getting much closer to actually editing UTF-8 data, it's not there yet. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
4bccfab632
commit
0e9fc2be15
21
line.c
21
line.c
@ -20,6 +20,7 @@
|
||||
#include "estruct.h"
|
||||
#include "edef.h"
|
||||
#include "efunc.h"
|
||||
#include "utf8.h"
|
||||
|
||||
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
||||
|
||||
@ -161,7 +162,7 @@ int linstr(char *instr)
|
||||
* well, and FALSE on errors.
|
||||
*/
|
||||
|
||||
int linsert(int n, int c)
|
||||
static int linsert_byte(int n, int c)
|
||||
{
|
||||
char *cp1;
|
||||
char *cp2;
|
||||
@ -239,6 +240,24 @@ int linsert(int n, int c)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int linsert(int n, int c)
|
||||
{
|
||||
char utf8[6];
|
||||
int bytes = unicode_to_utf8(c, utf8), i;
|
||||
|
||||
if (bytes == 1)
|
||||
return linsert_byte(n, (unsigned char) utf8[0]);
|
||||
for (i = 0; i < n; i++) {
|
||||
int j;
|
||||
for (j = 0; j < bytes; j++) {
|
||||
unsigned char c = utf8[j];
|
||||
if (!linsert_byte(1, c))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Overwrite a character into the current line at the current position
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user