mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-23 09:36:31 -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 "estruct.h"
|
||||||
#include "edef.h"
|
#include "edef.h"
|
||||||
#include "efunc.h"
|
#include "efunc.h"
|
||||||
|
#include "utf8.h"
|
||||||
|
|
||||||
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
#define BLOCK_SIZE 16 /* Line block chunk size. */
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ int linstr(char *instr)
|
|||||||
* well, and FALSE on errors.
|
* well, and FALSE on errors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int linsert(int n, int c)
|
static int linsert_byte(int n, int c)
|
||||||
{
|
{
|
||||||
char *cp1;
|
char *cp1;
|
||||||
char *cp2;
|
char *cp2;
|
||||||
@ -239,6 +240,24 @@ int linsert(int n, int c)
|
|||||||
return TRUE;
|
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
|
* Overwrite a character into the current line at the current position
|
||||||
*
|
*
|
||||||
|
2
main.c
2
main.c
@ -500,7 +500,7 @@ int execute(int c, int f, int n)
|
|||||||
|| (c >= 0x80 && c <= 0xFE)) {
|
|| (c >= 0x80 && c <= 0xFE)) {
|
||||||
#else
|
#else
|
||||||
#if VMS || BSD || USG /* 8BIT P.K. */
|
#if VMS || BSD || USG /* 8BIT P.K. */
|
||||||
|| (c >= 0xA0 && c <= 0xFE)) {
|
|| (c >= 0xA0 && c <= 0xFFFF)) {
|
||||||
#else
|
#else
|
||||||
) {
|
) {
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user