[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs qe.h qe.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs qe.h qe.c |
Date: |
Sun, 12 Jan 2014 01:18:46 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 14/01/12 01:18:46
Modified files:
. : qe.h qe.c
Log message:
improve convert-buffer-file-coding-system
* preserve offset, mark and other buffer positions
* output message with new charset and buffer size
* add debug_flags (used for debugging only)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.h?cvsroot=qemacs&r1=1.115&r2=1.116
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.115&r2=1.116
Patches:
Index: qe.h
===================================================================
RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -b -r1.115 -r1.116
--- qe.h 11 Jan 2014 15:07:14 -0000 1.115
+++ qe.h 12 Jan 2014 01:18:45 -0000 1.116
@@ -139,6 +139,8 @@
extern const char str_version[];
extern const char str_credits[];
+extern int debug_flags;
+
/* low level I/O events */
void set_read_handler(int fd, void (*cb)(void *opaque), void *opaque);
void set_write_handler(int fd, void (*cb)(void *opaque), void *opaque);
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -b -r1.115 -r1.116
--- qe.c 8 Jan 2014 16:27:09 -0000 1.115
+++ qe.c 12 Jan 2014 01:18:45 -0000 1.116
@@ -42,6 +42,8 @@
char name[32];
} HistoryEntry;
+int debug_flags;
+
#ifdef CONFIG_INIT_CALLS
static int (*__initcall_first)(void) __init_call = NULL;
static void (*__exitcall_first)(void) __exit_call = NULL;
@@ -1804,7 +1806,9 @@
{
QECharset *charset;
EditBuffer *b1, *b;
- int offset, c, len;
+ int offset, c, len, i;
+ EditBufferCallbackList *cb;
+ int pos[32];
char buf[MAX_CHAR_BYTES];
charset = read_charset(s, charset_str);
@@ -1814,8 +1818,18 @@
b1 = eb_new("*tmp*", 0);
eb_set_charset(b1, charset);
- /* well, not very fast, but simple */
b = s->b;
+
+ /* preserve positions */
+ cb = b->first_callback;
+ for (i = 0; i < countof(pos) && cb; cb = cb->next) {
+ if (cb->callback == eb_offset_callback) {
+ pos[i] = eb_get_char_offset(b, *(int*)cb->opaque);
+ i++;
+ }
+ }
+
+ /* slow, but simple iterative method */
for (offset = 0; offset < b->total_size;) {
c = eb_nextc(b, offset, &offset);
len = unicode_to_charset(buf, c, charset);
@@ -1827,7 +1841,19 @@
eb_set_charset(b, charset);
eb_insert_buffer(b, 0, b1, 0, b1->total_size);
+ /* restore positions */
+ cb = b->first_callback;
+ for (i = 0; i < countof(pos) && cb; cb = cb->next) {
+ if (cb->callback == eb_offset_callback) {
+ *(int*)cb->opaque = eb_goto_char(b, pos[i]);
+ i++;
+ }
+ }
+
eb_free(b1);
+
+ put_status(s, "Buffer charset is now %s, %d bytes",
+ s->b->charset->name, b->total_size);
}
void do_toggle_bidir(EditState *s)
- [Qemacs-commit] qemacs qe.h qe.c,
Charlie Gordon <=