disable scrollback optimization as it breaks scrollback shrinking

This commit is contained in:
berkeviktor@aol.com 2010-09-19 01:36:37 +02:00
parent 498d09b49a
commit e2f68f4399
1 changed files with 50 additions and 46 deletions

View File

@ -437,7 +437,7 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/ssl.c xchat-wdk/src/comm
#ifndef HAVE_SNPRINTF #ifndef HAVE_SNPRINTF
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/text.c xchat-wdk/src/common/text.c diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/text.c xchat-wdk/src/common/text.c
--- xchat-wdk.orig/src/common/text.c 2010-05-30 04:28:04 +0200 --- xchat-wdk.orig/src/common/text.c 2010-05-30 04:28:04 +0200
+++ xchat-wdk/src/common/text.c 2010-08-26 15:53:53 +0200 +++ xchat-wdk/src/common/text.c 2010-09-19 01:32:44 +0200
@@ -19,13 +19,11 @@ @@ -19,13 +19,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -452,60 +452,64 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/common/text.c xchat-wdk/src/com
#include "xchat.h" #include "xchat.h"
#include <glib/ghash.h> #include <glib/ghash.h>
@@ -274,6 +272,8 @@ @@ -271,9 +269,6 @@
char *map, *end_map; char *text;
struct stat statbuf; time_t stamp;
const char *begin, *eol; int lines;
+ - char *map, *end_map;
+ HANDLE hFile, hMapFile; - struct stat statbuf;
- const char *begin, *eol;
if (sess->text_scrollback == SET_DEFAULT) if (sess->text_scrollback == SET_DEFAULT)
{ {
@@ -296,9 +296,33 @@ @@ -293,32 +288,9 @@
if (fstat (fh, &statbuf) < 0) if (fh == -1)
return; return;
+#ifdef WIN32 - if (fstat (fh, &statbuf) < 0)
+ hFile = (HANDLE)_get_osfhandle(fh); - return;
+ if (hFile == INVALID_HANDLE_VALUE) -
+ { - map = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fh, 0);
+ return; - if (map == MAP_FAILED)
+ } - return;
+ -
+ /* Create mapping object */ - end_map = map + statbuf.st_size;
+ hMapFile = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); -
+ if (hMapFile == INVALID_HANDLE_VALUE) lines = 0;
+ { - begin = map;
+ return; - while (begin < end_map)
+ } + while (waitline (fh, buf, sizeof buf, FALSE) != -1)
+ {
+ /* Select which portions of the file we need */ - int n_bytes;
+ map = (char *)MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0); -
+ - eol = memchr (begin, '\n', end_map - begin);
+ if (map == NULL) -
+ { - if (!eol)
+ CloseHandle(hMapFile); - eol = end_map;
+ return; -
+ } - n_bytes = MIN (eol - begin, sizeof (buf) - 1);
+#else -
map = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fh, 0); - strncpy (buf, begin, n_bytes);
if (map == MAP_FAILED) -
return; - buf[n_bytes] = 0;
+#endif -
if (buf[0] == 'T')
{
if (sizeof (time_t) == 4)
@@ -334,8 +306,6 @@
}
lines++;
}
-
- begin = eol + 1;
}
end_map = map + statbuf.st_size; sess->scrollwritten = lines;
@@ -349,7 +319,6 @@
@@ -349,7 +373,13 @@
/*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/ /*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/
} }
+#ifdef WIN32 - munmap (map, statbuf.st_size);
+ CloseHandle(hMapFile);
+ CloseHandle(hFile);
+#else
munmap (map, statbuf.st_size);
+#endif
+
close (fh); close (fh);
} }