├── Makefile ├── README.md └── patches ├── boost └── regex.mk ├── iconv └── cp65001.patch ├── libipt └── libipt.mk ├── pdcurses ├── 0001-fix-tputs.patch ├── 0002-always-save-screen-when-entering-curses-mode.patch ├── 0003-save-full-screen-buffer.patch ├── 0004-add-debug-information-in-release-build.patch ├── 0005-no-keypad.patch ├── 0006-ctrl-left-and-ctrl-right.patch ├── 0007-clear-page.patch ├── 0008-line-up.patch ├── 0009-fix-doupdate.patch ├── 0010-fix-wheel.patch ├── 0011-processed-input.patch ├── 0012-wheel-coordinates.patch ├── 0013-ncurses-mouse-api.patch └── 0014-resize-console.patch ├── source-hightlight ├── Add-heuristic-to-handle-long-lines-better.patch ├── Remove-throw-specifications.patch └── console-colors.patch └── winipt └── winipt.mk /Makefile: -------------------------------------------------------------------------------- 1 | 2 | MYPKG=ssbssa-1 3 | BUILD_BITS=32 4 | 5 | SOURCE_DIR=src 6 | SOURCE_DIR_ABS=$(abspath $(SOURCE_DIR)) 7 | BUILD_DIR=build$(BUILD_BITS) 8 | BUILD_DIR_ABS=$(abspath $(BUILD_DIR)) 9 | 10 | GDB_LIBS=$(abspath gdb-libs$(BUILD_BITS)) 11 | GDB_DIR=$(abspath gdb$(BUILD_BITS)) 12 | BINUTILS_DIR=$(abspath binutils$(BUILD_BITS)) 13 | 14 | ifeq ($(BUILD_BITS),32) 15 | MYBUILD=i686-w64-mingw32 16 | MYTARGET=i686-w64-mingw32 17 | CROSS_CONF= 18 | else ifeq ($(BUILD_BITS),64) 19 | MYBUILD=i686-w64-mingw32 20 | MYTARGET=x86_64-w64-mingw32 21 | CROSS_CONF=CC=$(MYTARGET)-gcc CXX=$(MYTARGET)-g++ LIBEXE=$(MYTARGET)-ar 22 | else 23 | $(error BUILD_BITS is $(BUILD_BITS)) 24 | endif 25 | 26 | 27 | EXPAT_VER=2.3.0 28 | EXPAT_SRC_DIR=expat-$(EXPAT_VER) 29 | EXPAT_FILE=$(EXPAT_SRC_DIR).tar.xz 30 | EXPAT_CONF=$(SOURCE_DIR_ABS)/$(EXPAT_SRC_DIR)/configure \ 31 | --build=$(MYBUILD) --host=$(MYTARGET) \ 32 | --enable-static --disable-shared --prefix=$(GDB_LIBS) 33 | 34 | PDCURSES_VER=3.4 35 | PDCURSES_SRC_DIR=PDCurses-$(PDCURSES_VER) 36 | PDCURSES_FILE=$(PDCURSES_SRC_DIR).tar.gz 37 | PDCURSES_CONF=$(SOURCE_DIR_ABS)/$(PDCURSES_SRC_DIR)/configure \ 38 | --build=$(MYBUILD) --host=$(MYTARGET) \ 39 | --enable-static --disable-shared --prefix=$(GDB_LIBS) 40 | 41 | ICONV_VER=1.17 42 | ICONV_SRC_DIR=libiconv-$(ICONV_VER) 43 | ICONV_FILE=$(ICONV_SRC_DIR).tar.gz 44 | ICONV_CONF=$(SOURCE_DIR_ABS)/$(ICONV_SRC_DIR)/configure \ 45 | --build=$(MYBUILD) --host=$(MYTARGET) \ 46 | --enable-static --disable-shared --prefix=$(GDB_LIBS) 47 | 48 | PYTHON_VER=2.7.13 49 | PYTHON_FILE=python-$(PYTHON_VER)-w$(BUILD_BITS).tar.xz 50 | PYTHON_DIR=Python27 51 | 52 | BOOST_VER=1_69_0 53 | BOOST_SRC_DIR=boost_$(BOOST_VER) 54 | BOOST_FILE=$(BOOST_SRC_DIR).tar.bz2 55 | 56 | SOURCE_HIGHLIGHT_VER=3.1.9 57 | SOURCE_HIGHLIGHT_SRC_DIR=source-highlight-$(SOURCE_HIGHLIGHT_VER) 58 | SOURCE_HIGHLIGHT_FILE=$(SOURCE_HIGHLIGHT_SRC_DIR).tar.gz 59 | SOURCE_HIGHLIGHT_CONF=$(SOURCE_DIR_ABS)/$(SOURCE_HIGHLIGHT_SRC_DIR)/configure \ 60 | --build=$(MYBUILD) --host=$(MYTARGET) \ 61 | --with-boost=$(GDB_LIBS) \ 62 | --enable-static --disable-shared --prefix=$(GDB_LIBS) 63 | 64 | LZMA_VER=5.2.5 65 | LZMA_SRC_DIR=xz-$(LZMA_VER) 66 | LZMA_FILE=$(LZMA_SRC_DIR).tar.xz 67 | LZMA_CONF=$(SOURCE_DIR_ABS)/$(LZMA_SRC_DIR)/configure \ 68 | --build=$(MYBUILD) --host=$(MYTARGET) \ 69 | --enable-static --disable-shared --prefix=$(GDB_LIBS) 70 | 71 | GMP_VER=6.1.2 72 | GMP_SRC_DIR=gmp-$(GMP_VER) 73 | GMP_FILE=$(GMP_SRC_DIR).tar.xz 74 | GMP_CONF=$(SOURCE_DIR_ABS)/$(GMP_SRC_DIR)/configure \ 75 | --build=$(MYBUILD) --host=$(MYTARGET) \ 76 | --enable-static --disable-shared --prefix=$(GDB_LIBS) 77 | 78 | MPFR_VER=3.1.6 79 | MPFR_SRC_DIR=mpfr-$(MPFR_VER) 80 | MPFR_FILE=$(MPFR_SRC_DIR).tar.xz 81 | MPFR_CONF=$(SOURCE_DIR_ABS)/$(MPFR_SRC_DIR)/configure \ 82 | --build=$(MYBUILD) --host=$(MYTARGET) \ 83 | --enable-static --disable-shared --prefix=$(GDB_LIBS) \ 84 | --with-gmp-build=$(BUILD_DIR_ABS)/gmp 85 | 86 | XXHASH_VER_MAJOR=0 87 | XXHASH_VER_MINOR=8 88 | XXHASH_VER_PATCH=1 89 | XXHASH_VER=$(XXHASH_VER_MAJOR).$(XXHASH_VER_MINOR).$(XXHASH_VER_PATCH) 90 | XXHASH_SRC_DIR=xxHash-$(XXHASH_VER) 91 | XXHASH_FILE=$(XXHASH_SRC_DIR).tar.gz 92 | 93 | ARPEGGIO_VER=2.0.0 94 | ARPEGGIO_SRC_DIR=Arpeggio-$(ARPEGGIO_VER) 95 | ARPEGGIO_FILE=$(ARPEGGIO_SRC_DIR).tar.gz 96 | 97 | GDB_TOOLS_GIT_DIR=/c/src/repos/gdb-tools.git 98 | 99 | LIBIPT_VER_MAJOR=2 100 | LIBIPT_VER_MINOR=1 101 | LIBIPT_VER_PATCH=1 102 | LIBIPT_VER=$(LIBIPT_VER_MAJOR).$(LIBIPT_VER_MINOR).$(LIBIPT_VER_PATCH) 103 | LIBIPT_SRC_DIR=libipt-$(LIBIPT_VER) 104 | LIBIPT_FILE=$(LIBIPT_SRC_DIR).tar.gz 105 | 106 | WINIPT_HASH=c78e561698fc95bfe4c3817d2efc71b3526c325a 107 | WINIPT_SRC_DIR=winipt-$(WINIPT_HASH) 108 | WINIPT_FILE=$(WINIPT_SRC_DIR).zip 109 | 110 | FFI_VER=3.4.2 111 | FFI_SRC_DIR=libffi-$(FFI_VER) 112 | FFI_FILE=$(FFI_SRC_DIR).tar.gz 113 | FFI_CONF=$(SOURCE_DIR_ABS)/$(FFI_SRC_DIR)/configure \ 114 | --build=$(MYBUILD) --host=$(MYTARGET) \ 115 | --enable-static --disable-shared --prefix=$(GDB_LIBS) 116 | 117 | PYTHON3_GIT_DIR=c:/src/repos/cpython.git 118 | PYTHON3_GIT_CONF=$(PYTHON3_GIT_DIR)/configure \ 119 | --build=$(MYTARGET) --host=$(MYTARGET) \ 120 | --prefix=$(shell cygpath -m $(GDB_LIBS)/Python3) \ 121 | CPPFLAGS="-I$(GDB_LIBS)/include" LDFLAGS="-L$(GDB_LIBS)/lib" \ 122 | --disable-test-modules \ 123 | --without-ensurepip --without-c-locale-coercion \ 124 | --with-system-expat --with-system-ffi 125 | 126 | GDB_VER=8.1.1 127 | GDB_SRC_DIR=gdb-$(GDB_VER) 128 | GDB_FILE=$(GDB_SRC_DIR).tar.xz 129 | GDB_CONF=$(SOURCE_DIR_ABS)/$(GDB_SRC_DIR)/configure \ 130 | --build=$(MYBUILD) --host=$(MYTARGET) --target=$(MYTARGET) \ 131 | --disable-nls \ 132 | CPPFLAGS="-I$(GDB_LIBS)/include" LDFLAGS="-L$(GDB_LIBS)/lib" \ 133 | --enable-curses --enable-tui \ 134 | --with-libiconv-prefix=$(GDB_LIBS) \ 135 | --disable-install-libbfd --disable-install-libiberty \ 136 | --with-pkgversion=$(MYPKG) 137 | GDB_ENV=export \ 138 | PKG_CONFIG_PATH="$(GDB_LIBS)/lib/pkgconfig" \ 139 | CPPFLAGS="-I$(GDB_LIBS)/include -DUSE_RELATIVE_SRC_HIGHLIGHT -D__MINGW_USE_VC2005_COMPAT=1" \ 140 | LDFLAGS="-L$(GDB_LIBS)/lib" \ 141 | ; 142 | GDB_GIT_DIR=/c/src/repos/binutils-gdb.git 143 | GDB_GIT_CONF=$(GDB_GIT_DIR)/configure \ 144 | --build=$(MYBUILD) --host=$(MYTARGET) --target=$(MYTARGET) \ 145 | --enable-static --disable-shared \ 146 | --disable-nls \ 147 | --enable-curses --enable-tui \ 148 | --with-libiconv-prefix=$(GDB_LIBS) \ 149 | --with-liblzma-prefix=$(GDB_LIBS) \ 150 | --with-xxhash \ 151 | --disable-install-libbfd --disable-install-libiberty \ 152 | --disable-binutils --disable-gas --disable-gprof --disable-ld --disable-sim \ 153 | --with-pkgversion=$(MYPKG) 154 | GDB_TEST_CONF=/c/src/repos/gdb-testsuite/configure \ 155 | --build=$(MYBUILD) --host=$(MYTARGET) --target=$(MYTARGET) \ 156 | --enable-static --disable-shared \ 157 | --disable-nls \ 158 | --enable-curses --enable-tui \ 159 | --with-libiconv-prefix=$(GDB_LIBS) \ 160 | --with-liblzma-prefix=$(GDB_LIBS) \ 161 | --with-xxhash \ 162 | --disable-install-libbfd --disable-install-libiberty \ 163 | --disable-binutils --disable-gas --disable-gprof --disable-ld --disable-sim \ 164 | --with-pkgversion=$(MYPKG) 165 | GDB_REDHAT64_CONF=$(GDB_GIT_DIR)/configure \ 166 | --build=$(MYBUILD) --host=$(MYBUILD) --target=x86_64-redhat-linux \ 167 | --disable-nls \ 168 | CPPFLAGS="-I/gdb/gdb-libs32/include" LDFLAGS="-L/gdb/gdb-libs32/lib" \ 169 | --disable-curses --disable-tui \ 170 | --with-libiconv-prefix=$(GDB_LIBS) \ 171 | --disable-install-libbfd --disable-install-libiberty \ 172 | --disable-binutils --disable-gas --disable-gprof --disable-ld \ 173 | --with-sysroot=$(GDB_DIR)-redhat64/$(MYTARGET)/sys-root 174 | GDB_REDHAT32_HOST_CONF=$(GDB_GIT_DIR)/configure \ 175 | --build=$(MYBUILD) --host=i686-redhat-linux \ 176 | --disable-nls \ 177 | --disable-curses --disable-tui \ 178 | --disable-install-libbfd --disable-install-libiberty \ 179 | --disable-binutils --disable-gas --disable-gprof --disable-ld 180 | 181 | BINUTILS_GIT_CONF=$(GDB_GIT_DIR)/configure \ 182 | --build=$(MYBUILD) --host=$(MYBUILD) --target=$(MYTARGET) \ 183 | --disable-multilib --disable-nls --with-sysroot=$(BINUTILS_DIR) \ 184 | --prefix=$(BINUTILS_DIR) --enable-targets=$(MYTARGET) \ 185 | --disable-install-libbfd --disable-install-libiberty \ 186 | --disable-gdb --disable-libdecnumber --disable-readline --disable-sim \ 187 | --with-pkgversion=$(MYPKG) 188 | 189 | 190 | all: 191 | all: $(BUILD_DIR)/expat-05-make-install.done 192 | all: $(BUILD_DIR)/pdcurses-04-make-install.done 193 | all: $(BUILD_DIR)/iconv-05-make-install.done 194 | all: $(BUILD_DIR)/gdb-05-make-install.done 195 | 196 | 197 | $(SOURCE_DIR): 198 | @mkdir $@ 199 | 200 | $(BUILD_DIR): 201 | @mkdir $@ 202 | 203 | 204 | # expat 205 | 206 | $(SOURCE_DIR)/expat-01-extract.done: | $(SOURCE_DIR) pkg/$(EXPAT_FILE) 207 | tar -C $(SOURCE_DIR) -xJf pkg/$(EXPAT_FILE) 208 | @touch $@ 209 | 210 | $(BUILD_DIR)/expat-03-configure.done: | $(SOURCE_DIR)/expat-01-extract.done 211 | @mkdir -p $(BUILD_DIR)/expat 212 | cd $(BUILD_DIR)/expat && $(EXPAT_CONF) 213 | @touch $@ 214 | 215 | $(BUILD_DIR)/expat-04-make.done: | $(BUILD_DIR)/expat-03-configure.done 216 | $(MAKE) -C $(BUILD_DIR)/expat 217 | @touch $@ 218 | 219 | $(BUILD_DIR)/expat-05-make-install.done: | $(BUILD_DIR)/expat-04-make.done 220 | $(MAKE) -C $(BUILD_DIR)/expat install 221 | @touch $@ 222 | 223 | 224 | # pdcurses 225 | 226 | $(SOURCE_DIR)/pdcurses-01-extract.done: | pkg/$(PDCURSES_FILE) $(SOURCE_DIR)/expat-01-extract.done 227 | tar -C $(SOURCE_DIR) -xzf pkg/$(PDCURSES_FILE) 228 | @touch $@ 229 | 230 | $(SOURCE_DIR)/pdcurses-02-patch-01-tputs.done: | $(SOURCE_DIR)/pdcurses-01-extract.done 231 | patch -d $(SOURCE_DIR)/$(PDCURSES_SRC_DIR) -p1 intel-pt.h 515 | @touch $@ 516 | 517 | $(BUILD_DIR)/libipt-04-make.done: | $(SOURCE_DIR)/libipt-01-extract.done 518 | @mkdir -p $(BUILD_DIR)/libipt/src/windows 519 | cp patches/libipt/libipt.mk $(BUILD_DIR)/libipt/Makefile 520 | $(MAKE) -C $(BUILD_DIR)/libipt SRC_DIR=$(SOURCE_DIR_ABS)/$(LIBIPT_SRC_DIR)/libipt CC=$(MYTARGET)-gcc AR=$(MYTARGET)-ar PT_VERSION_MAJOR=$(LIBIPT_VER_MAJOR) PT_VERSION_MINOR=$(LIBIPT_VER_MINOR) PT_VERSION_PATCH=$(LIBIPT_VER_PATCH) 521 | @touch $@ 522 | 523 | $(BUILD_DIR)/libipt-05-install.done: | $(BUILD_DIR)/libipt-04-make.done 524 | @mkdir -p $(GDB_LIBS)/include $(GDB_LIBS)/lib 525 | cp $(SOURCE_DIR)/$(LIBIPT_SRC_DIR)/libipt/include/intel-pt.h $(GDB_LIBS)/include 526 | cp $(BUILD_DIR)/libipt/libipt.a $(GDB_LIBS)/lib/ 527 | @touch $@ 528 | 529 | 530 | # winipt 531 | 532 | $(SOURCE_DIR)/winipt-01-extract.done: | pkg/$(WINIPT_FILE) $(SOURCE_DIR)/libipt-01-extract.done 533 | cd $(SOURCE_DIR); unzip ../pkg/$(WINIPT_FILE) 534 | @touch $@ 535 | 536 | $(BUILD_DIR)/winipt-04-make.done: | $(SOURCE_DIR)/winipt-01-extract.done 537 | @mkdir -p $(BUILD_DIR)/winipt/libipt 538 | cp patches/winipt/winipt.mk $(BUILD_DIR)/winipt/Makefile 539 | $(MAKE) -C $(BUILD_DIR)/winipt SRC_DIR=$(SOURCE_DIR_ABS)/$(WINIPT_SRC_DIR) CC=$(MYTARGET)-gcc AR=$(MYTARGET)-ar 540 | @touch $@ 541 | 542 | $(BUILD_DIR)/winipt-05-install.done: | $(BUILD_DIR)/winipt-04-make.done 543 | @mkdir -p $(GDB_LIBS)/include $(GDB_LIBS)/lib 544 | cp $(SOURCE_DIR)/$(WINIPT_SRC_DIR)/inc/libipt.h $(GDB_LIBS)/include 545 | cp $(BUILD_DIR)/winipt/libwinipt.a $(GDB_LIBS)/lib/ 546 | @touch $@ 547 | 548 | 549 | # gdb 550 | 551 | $(SOURCE_DIR)/gdb-01-extract.done: | pkg/$(GDB_FILE) $(SOURCE_DIR)/mpfr-01-extract.done 552 | tar -C $(SOURCE_DIR) -xJf pkg/$(GDB_FILE) 553 | @touch $@ 554 | 555 | $(SOURCE_DIR)/gdb-02-patch-01-jit-installer.done: | $(SOURCE_DIR)/gdb-01-extract.done 556 | patch -d $(SOURCE_DIR)/$(GDB_SRC_DIR) -p1 3 | Date: Sun, 9 Mar 2014 14:22:07 +0100 4 | Subject: [PATCH 01/14] fix tputs() 5 | 6 | --- 7 | pdcurses/terminfo.c | 5 ++++- 8 | 1 file changed, 4 insertions(+), 1 deletion(-) 9 | 10 | diff --git a/pdcurses/terminfo.c b/pdcurses/terminfo.c 11 | index c099ada7..2c503a84 100644 12 | --- a/pdcurses/terminfo.c 13 | +++ b/pdcurses/terminfo.c 14 | @@ -211,5 +211,8 @@ int tputs(const char *str, int affcnt, int (*putfunc)(int)) 15 | { 16 | PDC_LOG(("tputs() - called\n")); 17 | 18 | - return ERR; 19 | + while (*str) 20 | + putfunc(*str++); 21 | + 22 | + return 0; 23 | } 24 | -- 25 | 2.39.1.windows.1 26 | 27 | -------------------------------------------------------------------------------- /patches/pdcurses/0002-always-save-screen-when-entering-curses-mode.patch: -------------------------------------------------------------------------------- 1 | From b3fc49568d1e9e99887741b40ba279b558bd66d2 Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Sun, 9 Mar 2014 14:40:19 +0100 4 | Subject: [PATCH 02/14] always save screen when entering curses mode 5 | 6 | --- 7 | win32/pdcscrn.c | 171 +++++++++++++++++++++++++----------------------- 8 | 1 file changed, 89 insertions(+), 82 deletions(-) 9 | 10 | diff --git a/win32/pdcscrn.c b/win32/pdcscrn.c 11 | index b48ddaaf..fed87161 100644 12 | --- a/win32/pdcscrn.c 13 | +++ b/win32/pdcscrn.c 14 | @@ -229,7 +229,7 @@ void PDC_scr_close(void) 15 | 16 | PDC_reset_shell_mode(); 17 | 18 | - if (SP->_restore != PDC_RESTORE_NONE) 19 | + if (SP->_restore != PDC_RESTORE_NONE && ci_save) 20 | { 21 | if (SP->_restore == PDC_RESTORE_WINDOW) 22 | { 23 | @@ -250,6 +250,9 @@ void PDC_scr_close(void) 24 | if (!WriteConsoleOutput(pdc_con_out, ci_save, orig_scr.dwSize, 25 | origin, &rect)) 26 | return; 27 | + 28 | + free(ci_save); 29 | + ci_save = NULL; 30 | } 31 | 32 | if (SP->visibility != 1) 33 | @@ -257,7 +260,10 @@ void PDC_scr_close(void) 34 | 35 | /* Position cursor to the bottom left of the screen. */ 36 | 37 | - PDC_gotoyx(PDC_get_buffer_rows() - 2, 0); 38 | + if (SP->_restore != PDC_RESTORE_NONE) 39 | + PDC_gotoyx(orig_scr.dwCursorPosition.Y, orig_scr.dwCursorPosition.X); 40 | + else 41 | + PDC_gotoyx(PDC_get_buffer_rows() - 2, 0); 42 | } 43 | 44 | void PDC_scr_free(void) 45 | @@ -275,9 +281,6 @@ void PDC_scr_free(void) 46 | 47 | int PDC_scr_open(int argc, char **argv) 48 | { 49 | - COORD bufsize, origin; 50 | - SMALL_RECT rect; 51 | - const char *str; 52 | CONSOLE_SCREEN_BUFFER_INFO csbi; 53 | int i; 54 | 55 | @@ -304,7 +307,6 @@ int PDC_scr_open(int argc, char **argv) 56 | is_nt = !(GetVersion() & 0x80000000); 57 | 58 | GetConsoleScreenBufferInfo(pdc_con_out, &csbi); 59 | - GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr); 60 | GetConsoleMode(pdc_con_in, &old_console_mode); 61 | 62 | /* preserve QuickEdit Mode setting for use in PDC_mouse_set() when 63 | @@ -313,8 +315,8 @@ int PDC_scr_open(int argc, char **argv) 64 | 65 | pdc_quick_edit = old_console_mode & 0x0040; 66 | 67 | - SP->lines = (str = getenv("LINES")) ? atoi(str) : PDC_get_rows(); 68 | - SP->cols = (str = getenv("COLS")) ? atoi(str) : PDC_get_columns(); 69 | + SP->lines = PDC_get_rows(); 70 | + SP->cols = PDC_get_columns(); 71 | 72 | SP->mouse_wait = PDC_CLICK_PERIOD; 73 | SP->audible = TRUE; 74 | @@ -342,81 +344,9 @@ int PDC_scr_open(int argc, char **argv) 75 | 76 | SP->_restore = PDC_RESTORE_NONE; 77 | 78 | - if (getenv("PDC_RESTORE_SCREEN")) 79 | - { 80 | - /* Attempt to save the complete console buffer */ 81 | - 82 | - ci_save = malloc(orig_scr.dwSize.X * orig_scr.dwSize.Y * 83 | - sizeof(CHAR_INFO)); 84 | - 85 | - if (!ci_save) 86 | - { 87 | - PDC_LOG(("PDC_scr_open() - malloc failure (1)\n")); 88 | - 89 | - return ERR; 90 | - } 91 | - 92 | - bufsize.X = orig_scr.dwSize.X; 93 | - bufsize.Y = orig_scr.dwSize.Y; 94 | + PDC_save_screen_mode(0); 95 | 96 | - origin.X = origin.Y = 0; 97 | - 98 | - rect.Top = rect.Left = 0; 99 | - rect.Bottom = orig_scr.dwSize.Y - 1; 100 | - rect.Right = orig_scr.dwSize.X - 1; 101 | - 102 | - if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize, origin, &rect)) 103 | - { 104 | - /* We can't save the complete buffer, so try and save just 105 | - the displayed window */ 106 | - 107 | - free(ci_save); 108 | - ci_save = NULL; 109 | - 110 | - bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1; 111 | - bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1; 112 | - 113 | - ci_save = malloc(bufsize.X * bufsize.Y * sizeof(CHAR_INFO)); 114 | - 115 | - if (!ci_save) 116 | - { 117 | - PDC_LOG(("PDC_scr_open() - malloc failure (2)\n")); 118 | - 119 | - return ERR; 120 | - } 121 | - 122 | - origin.X = origin.Y = 0; 123 | - 124 | - rect.Top = orig_scr.srWindow.Top; 125 | - rect.Left = orig_scr.srWindow.Left; 126 | - rect.Bottom = orig_scr.srWindow.Bottom; 127 | - rect.Right = orig_scr.srWindow.Right; 128 | - 129 | - if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize, 130 | - origin, &rect)) 131 | - { 132 | -#ifdef PDCDEBUG 133 | - CHAR LastError[256]; 134 | - 135 | - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, 136 | - GetLastError(), MAKELANGID(LANG_NEUTRAL, 137 | - SUBLANG_DEFAULT), LastError, 256, NULL); 138 | - 139 | - PDC_LOG(("PDC_scr_open() - %s\n", LastError)); 140 | -#endif 141 | - free(ci_save); 142 | - ci_save = NULL; 143 | - 144 | - return ERR; 145 | - } 146 | - 147 | - SP->_restore = PDC_RESTORE_WINDOW; 148 | - } 149 | - else 150 | - SP->_restore = PDC_RESTORE_BUFFER; 151 | - } 152 | - 153 | - SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL); 154 | + SP->_preserve = 0; 155 | 156 | PDC_reset_prog_mode(); 157 | 158 | @@ -543,6 +473,83 @@ void PDC_restore_screen_mode(int i) 159 | 160 | void PDC_save_screen_mode(int i) 161 | { 162 | + COORD bufsize, origin; 163 | + SMALL_RECT rect; 164 | + 165 | + if (i != 0 || ci_save) return; 166 | + 167 | + GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr); 168 | + 169 | + /* Attempt to save the complete console buffer */ 170 | + 171 | + ci_save = malloc(orig_scr.dwSize.X * orig_scr.dwSize.Y * 172 | + sizeof(CHAR_INFO)); 173 | + 174 | + if (!ci_save) 175 | + { 176 | + PDC_LOG(("PDC_scr_open() - malloc failure (1)\n")); 177 | + 178 | + return; 179 | + } 180 | + 181 | + bufsize.X = orig_scr.dwSize.X; 182 | + bufsize.Y = orig_scr.dwSize.Y; 183 | + 184 | + origin.X = origin.Y = 0; 185 | + 186 | + rect.Top = rect.Left = 0; 187 | + rect.Bottom = orig_scr.dwSize.Y - 1; 188 | + rect.Right = orig_scr.dwSize.X - 1; 189 | + 190 | + if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize, origin, &rect)) 191 | + { 192 | + /* We can't save the complete buffer, so try and save just 193 | + the displayed window */ 194 | + 195 | + free(ci_save); 196 | + ci_save = NULL; 197 | + 198 | + bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1; 199 | + bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1; 200 | + 201 | + ci_save = malloc(bufsize.X * bufsize.Y * sizeof(CHAR_INFO)); 202 | + 203 | + if (!ci_save) 204 | + { 205 | + PDC_LOG(("PDC_scr_open() - malloc failure (2)\n")); 206 | + 207 | + return; 208 | + } 209 | + 210 | + origin.X = origin.Y = 0; 211 | + 212 | + rect.Top = orig_scr.srWindow.Top; 213 | + rect.Left = orig_scr.srWindow.Left; 214 | + rect.Bottom = orig_scr.srWindow.Bottom; 215 | + rect.Right = orig_scr.srWindow.Right; 216 | + 217 | + if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize, 218 | + origin, &rect)) 219 | + { 220 | +#ifdef PDCDEBUG 221 | + CHAR LastError[256]; 222 | + 223 | + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, 224 | + GetLastError(), MAKELANGID(LANG_NEUTRAL, 225 | + SUBLANG_DEFAULT), LastError, 256, NULL); 226 | + 227 | + PDC_LOG(("PDC_scr_open() - %s\n", LastError)); 228 | +#endif 229 | + free(ci_save); 230 | + ci_save = NULL; 231 | + 232 | + return; 233 | + } 234 | + 235 | + SP->_restore = PDC_RESTORE_WINDOW; 236 | + } 237 | + else 238 | + SP->_restore = PDC_RESTORE_BUFFER; 239 | } 240 | 241 | void PDC_init_pair(short pair, short fg, short bg) 242 | -- 243 | 2.39.1.windows.1 244 | 245 | -------------------------------------------------------------------------------- /patches/pdcurses/0003-save-full-screen-buffer.patch: -------------------------------------------------------------------------------- 1 | From c03f614c37135cbd1bfc7a09f61dbbc5b6f73208 Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Sun, 9 Mar 2014 14:41:49 +0100 4 | Subject: [PATCH 03/14] save full screen buffer 5 | 6 | --- 7 | win32/pdcscrn.c | 28 +++++++++++++++++++++++++++- 8 | 1 file changed, 27 insertions(+), 1 deletion(-) 9 | 10 | diff --git a/win32/pdcscrn.c b/win32/pdcscrn.c 11 | index fed87161..6dd8f9d1 100644 12 | --- a/win32/pdcscrn.c 13 | +++ b/win32/pdcscrn.c 14 | @@ -471,6 +471,32 @@ void PDC_restore_screen_mode(int i) 15 | { 16 | } 17 | 18 | +static int read_console_output(CHAR_INFO *buf, COORD buf_size, 19 | + COORD buf_coord, SMALL_RECT *read_region) 20 | +{ 21 | + if (ReadConsoleOutput(pdc_con_out, buf, buf_size, buf_coord, read_region)) 22 | + return 1; 23 | + 24 | + int h = read_region->Bottom - read_region->Top + 1; 25 | + int h2 = h / 2; 26 | + if (!h2) return 0; 27 | + 28 | + COORD sub_coord1 = buf_coord; 29 | + SMALL_RECT sub_region1 = *read_region; 30 | + sub_region1.Bottom = sub_region1.Top + h2 - 1; 31 | + if (!read_console_output(buf, buf_size, sub_coord1, &sub_region1)) 32 | + return 0; 33 | + 34 | + COORD sub_coord2 = buf_coord; 35 | + sub_coord2.Y += h2; 36 | + SMALL_RECT sub_region2 = *read_region; 37 | + sub_region2.Top = sub_region1.Bottom + 1; 38 | + if (!read_console_output(buf, buf_size, sub_coord2, &sub_region2)) 39 | + return 0; 40 | + 41 | + return 1; 42 | +} 43 | + 44 | void PDC_save_screen_mode(int i) 45 | { 46 | COORD bufsize, origin; 47 | @@ -501,7 +527,7 @@ void PDC_save_screen_mode(int i) 48 | rect.Bottom = orig_scr.dwSize.Y - 1; 49 | rect.Right = orig_scr.dwSize.X - 1; 50 | 51 | - if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize, origin, &rect)) 52 | + if (!read_console_output(ci_save, bufsize, origin, &rect)) 53 | { 54 | /* We can't save the complete buffer, so try and save just 55 | the displayed window */ 56 | -- 57 | 2.39.1.windows.1 58 | 59 | -------------------------------------------------------------------------------- /patches/pdcurses/0004-add-debug-information-in-release-build.patch: -------------------------------------------------------------------------------- 1 | From c0b2e904cf32bf30afdd76e02b8640c0a505a4ba Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Sun, 9 Mar 2014 14:45:02 +0100 4 | Subject: [PATCH 04/14] add debug information in release build 5 | 6 | --- 7 | win32/gccwin32.mak | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/win32/gccwin32.mak b/win32/gccwin32.mak 11 | index 7504bb34..77a017b0 100644 12 | --- a/win32/gccwin32.mak 13 | +++ b/win32/gccwin32.mak 14 | @@ -24,7 +24,7 @@ ifeq ($(DEBUG),Y) 15 | CFLAGS = -g -Wall -DPDCDEBUG 16 | LDFLAGS = -g 17 | else 18 | - CFLAGS = -O2 -Wall 19 | + CFLAGS = -O2 -Wall -g 20 | LDFLAGS = 21 | endif 22 | 23 | -- 24 | 2.39.1.windows.1 25 | 26 | -------------------------------------------------------------------------------- /patches/pdcurses/0005-no-keypad.patch: -------------------------------------------------------------------------------- 1 | From b7a5231eba087d1ea683cab473f32f1b4e0effc1 Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Tue, 30 Dec 2014 16:46:45 +0100 4 | Subject: [PATCH 05/14] no keypad 5 | 6 | --- 7 | pdcurses/getch.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 8 | 1 file changed, 53 insertions(+) 9 | 10 | diff --git a/pdcurses/getch.c b/pdcurses/getch.c 11 | index 87677bae..422799d1 100644 12 | --- a/pdcurses/getch.c 13 | +++ b/pdcurses/getch.c 14 | @@ -2,6 +2,11 @@ 15 | 16 | #include 17 | 18 | +#ifdef _WIN32 19 | +#include 20 | +extern HANDLE pdc_con_in; 21 | +#endif 22 | + 23 | RCSID("$Id: getch.c,v 1.72 2008/07/13 16:08:18 wmcbrine Exp $") 24 | 25 | /*man-start************************************************************** 26 | @@ -238,7 +243,55 @@ int wgetch(WINDOW *win) 27 | /* filter special keys if not in keypad mode */ 28 | 29 | if (!win->_use_keypad) 30 | + { 31 | +#ifdef _WIN32 32 | + char backhalf = 0; 33 | + switch (key) 34 | + { 35 | + case KEY_UP: 36 | + backhalf = 'H'; 37 | + break; 38 | + case KEY_DOWN: 39 | + backhalf = 'P'; 40 | + break; 41 | + case KEY_LEFT: 42 | + backhalf = 'K'; 43 | + break; 44 | + case KEY_RIGHT: 45 | + backhalf = 'M'; 46 | + break; 47 | + case KEY_HOME: 48 | + backhalf = 'G'; 49 | + break; 50 | + case KEY_END: 51 | + backhalf = 'O'; 52 | + break; 53 | + case KEY_DC: 54 | + backhalf = 'S'; 55 | + break; 56 | + case KEY_IC: 57 | + backhalf = 'R'; 58 | + break; 59 | + } 60 | + if (backhalf) 61 | + { 62 | + INPUT_RECORD ir; 63 | + ir.EventType = KEY_EVENT; 64 | + ir.Event.KeyEvent.bKeyDown = TRUE; 65 | + ir.Event.KeyEvent.dwControlKeyState = 0; 66 | + ir.Event.KeyEvent.uChar.UnicodeChar = backhalf; 67 | + ir.Event.KeyEvent.wRepeatCount = 1; 68 | + ir.Event.KeyEvent.wVirtualKeyCode = backhalf; 69 | + ir.Event.KeyEvent.wVirtualScanCode = 70 | + MapVirtualKey(backhalf, MAPVK_VK_TO_VSC); 71 | + DWORD written; 72 | + WriteConsoleInput(pdc_con_in, &ir, 1, &written); 73 | + return 0xe0; 74 | + } 75 | +#endif 76 | + 77 | key = -1; 78 | + } 79 | 80 | /* filter mouse events; translate mouse clicks in the slk 81 | area to function keys */ 82 | -- 83 | 2.39.1.windows.1 84 | 85 | -------------------------------------------------------------------------------- /patches/pdcurses/0006-ctrl-left-and-ctrl-right.patch: -------------------------------------------------------------------------------- 1 | From c46e99cef85621e4b65662beb65dd8d06bd114ae Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Thu, 1 Jan 2015 14:56:33 +0100 4 | Subject: [PATCH 06/14] ctrl-left and ctrl-right 5 | 6 | --- 7 | pdcurses/getch.c | 6 ++++++ 8 | 1 file changed, 6 insertions(+) 9 | 10 | diff --git a/pdcurses/getch.c b/pdcurses/getch.c 11 | index 422799d1..07a0ed12 100644 12 | --- a/pdcurses/getch.c 13 | +++ b/pdcurses/getch.c 14 | @@ -272,6 +272,12 @@ int wgetch(WINDOW *win) 15 | case KEY_IC: 16 | backhalf = 'R'; 17 | break; 18 | + case CTL_LEFT: 19 | + backhalf = 's'; 20 | + break; 21 | + case CTL_RIGHT: 22 | + backhalf = 't'; 23 | + break; 24 | } 25 | if (backhalf) 26 | { 27 | -- 28 | 2.39.1.windows.1 29 | 30 | -------------------------------------------------------------------------------- /patches/pdcurses/0007-clear-page.patch: -------------------------------------------------------------------------------- 1 | From 7d2c4a07be698ab8ca8debee60b4910d9595cc63 Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Sun, 4 Jan 2015 16:35:55 +0100 4 | Subject: [PATCH 07/14] clear page 5 | 6 | --- 7 | pdcurses/terminfo.c | 92 ++++++++++++++++++++++++++++++++++++++++++++- 8 | 1 file changed, 91 insertions(+), 1 deletion(-) 9 | 10 | diff --git a/pdcurses/terminfo.c b/pdcurses/terminfo.c 11 | index 2c503a84..e9959788 100644 12 | --- a/pdcurses/terminfo.c 13 | +++ b/pdcurses/terminfo.c 14 | @@ -48,6 +48,11 @@ RCSID("$Id: terminfo.c,v 1.37 2008/07/21 12:29:20 wmcbrine Exp $") 15 | 16 | #include 17 | 18 | +#ifdef _WIN32 19 | +#include 20 | +#include 21 | +#endif 22 | + 23 | TERMINAL *cur_term = NULL; 24 | 25 | int mvcur(int oldrow, int oldcol, int newrow, int newcol) 26 | @@ -147,6 +152,11 @@ int tgetent(char *bp, const char *name) 27 | { 28 | PDC_LOG(("tgetent() - called: name %s\n", name)); 29 | 30 | +#ifdef _WIN32 31 | + if (!strcmp(name, "dumb")) 32 | + return 1; 33 | +#endif 34 | + 35 | return ERR; 36 | } 37 | 38 | @@ -154,7 +164,11 @@ int tgetflag(const char *id) 39 | { 40 | PDC_LOG(("tgetflag() - called: id %s\n", id)); 41 | 42 | +#ifdef _WIN32 43 | + return 0; 44 | +#else 45 | return ERR; 46 | +#endif 47 | } 48 | 49 | int tgetnum(const char *id) 50 | @@ -168,6 +182,23 @@ char *tgetstr(const char *id, char **area) 51 | { 52 | PDC_LOG(("tgetstr() - called: id %s\n", id)); 53 | 54 | +#ifdef _WIN32 55 | + if (id[0] == 'c' && id[1] == 'l') 56 | + { 57 | + char *val = *area; 58 | + strcpy(val, "\014"); 59 | + *area += 2; 60 | + return val; 61 | + } 62 | + else if (id[0] == 'l' && id[1] == 'e') 63 | + { 64 | + char *val = *area; 65 | + strcpy(val, "\b"); 66 | + *area += 2; 67 | + return val; 68 | + } 69 | +#endif 70 | + 71 | return (char *)NULL; 72 | } 73 | 74 | @@ -207,12 +238,71 @@ char *tparm(const char *cap, long p1, long p2, long p3, long p4, 75 | return (char *)NULL; 76 | } 77 | 78 | +#ifdef _WIN32 79 | +void PDC_clear_page(void) 80 | +{ 81 | + if (SP && SP->alive) 82 | + return; 83 | + 84 | + CONSOLE_SCREEN_BUFFER_INFO csbi; 85 | + HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE); 86 | + GetConsoleScreenBufferInfo(hout, &csbi); 87 | + 88 | + int h = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; 89 | + SMALL_RECT sr = { 90 | + 0, 91 | + csbi.dwCursorPosition.Y + 1, 92 | + csbi.srWindow.Right - csbi.srWindow.Left, 93 | + csbi.dwCursorPosition.Y + h 94 | + }; 95 | + COORD coord = { 96 | + 0, 97 | + csbi.dwCursorPosition.Y + 1 98 | + }; 99 | + if (coord.Y < csbi.dwSize.Y) 100 | + { 101 | + DWORD len = csbi.dwSize.X * ( csbi.dwSize.Y - coord.Y ); 102 | + DWORD w; 103 | + FillConsoleOutputCharacter(hout, ' ', len, coord, &w); 104 | + FillConsoleOutputAttribute(hout, csbi.wAttributes, len, coord, &w); 105 | + } 106 | + if (sr.Bottom >= csbi.dwSize.Y) 107 | + { 108 | + int scroll = sr.Bottom - csbi.dwSize.Y + 1; 109 | + sr.Top -= scroll; 110 | + sr.Bottom -= scroll; 111 | + coord.Y -= scroll; 112 | + 113 | + SMALL_RECT srScroll = { 0, 0, csbi.dwSize.X - 1, csbi.dwSize.Y - 1 }; 114 | + COORD cDest = { 0, -scroll }; 115 | + CHAR_INFO ci = { 116 | + .Char.UnicodeChar = ' ', 117 | + .Attributes = csbi.wAttributes 118 | + }; 119 | + ScrollConsoleScreenBuffer(hout, &srScroll, NULL, cDest, &ci); 120 | + } 121 | + SetConsoleWindowInfo(hout, TRUE, &sr); 122 | + SetConsoleCursorPosition(hout, coord); 123 | +} 124 | +#endif 125 | + 126 | int tputs(const char *str, int affcnt, int (*putfunc)(int)) 127 | { 128 | PDC_LOG(("tputs() - called\n")); 129 | 130 | while (*str) 131 | - putfunc(*str++); 132 | + { 133 | + char c = *str; 134 | + str++; 135 | +#ifdef _WIN32 136 | + if (c == '\014') 137 | + { 138 | + PDC_clear_page(); 139 | + continue; 140 | + } 141 | +#endif 142 | + putfunc(c); 143 | + } 144 | 145 | return 0; 146 | } 147 | -- 148 | 2.39.1.windows.1 149 | 150 | -------------------------------------------------------------------------------- /patches/pdcurses/0008-line-up.patch: -------------------------------------------------------------------------------- 1 | From 24fc0f743617fe35ae6201477b0e491d750885fc Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Sun, 4 Jan 2015 17:23:26 +0100 4 | Subject: [PATCH 08/14] line up 5 | 6 | --- 7 | pdcurses/terminfo.c | 27 +++++++++++++++++++++++++++ 8 | 1 file changed, 27 insertions(+) 9 | 10 | diff --git a/pdcurses/terminfo.c b/pdcurses/terminfo.c 11 | index e9959788..53c3fffd 100644 12 | --- a/pdcurses/terminfo.c 13 | +++ b/pdcurses/terminfo.c 14 | @@ -197,6 +197,13 @@ char *tgetstr(const char *id, char **area) 15 | *area += 2; 16 | return val; 17 | } 18 | + else if (id[0] == 'u' && id[1] == 'p') 19 | + { 20 | + char *val = *area; 21 | + strcpy(val, "\013"); 22 | + *area += 2; 23 | + return val; 24 | + } 25 | #endif 26 | 27 | return (char *)NULL; 28 | @@ -284,6 +291,21 @@ void PDC_clear_page(void) 29 | SetConsoleWindowInfo(hout, TRUE, &sr); 30 | SetConsoleCursorPosition(hout, coord); 31 | } 32 | + 33 | +void PDC_line_up(void) 34 | +{ 35 | + CONSOLE_SCREEN_BUFFER_INFO csbi; 36 | + HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE); 37 | + GetConsoleScreenBufferInfo(hout, &csbi); 38 | + if (csbi.dwCursorPosition.Y <= 0) 39 | + return; 40 | + 41 | + COORD coord = { 42 | + csbi.dwCursorPosition.X, 43 | + csbi.dwCursorPosition.Y - 1 44 | + }; 45 | + SetConsoleCursorPosition(hout, coord); 46 | +} 47 | #endif 48 | 49 | int tputs(const char *str, int affcnt, int (*putfunc)(int)) 50 | @@ -300,6 +322,11 @@ int tputs(const char *str, int affcnt, int (*putfunc)(int)) 51 | PDC_clear_page(); 52 | continue; 53 | } 54 | + else if (c == '\013') 55 | + { 56 | + PDC_line_up(); 57 | + continue; 58 | + } 59 | #endif 60 | putfunc(c); 61 | } 62 | -- 63 | 2.39.1.windows.1 64 | 65 | -------------------------------------------------------------------------------- /patches/pdcurses/0009-fix-doupdate.patch: -------------------------------------------------------------------------------- 1 | From c368a1e6b8eae184495c97c1dea6badfe3663efd Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Wed, 2 Sep 2015 20:42:02 +0100 4 | Subject: [PATCH 09/14] fix doupdate 5 | 6 | --- 7 | pdcurses/refresh.c | 1 - 8 | 1 file changed, 1 deletion(-) 9 | 10 | diff --git a/pdcurses/refresh.c b/pdcurses/refresh.c 11 | index 0b8e1ca5..21a37ef0 100644 12 | --- a/pdcurses/refresh.c 13 | +++ b/pdcurses/refresh.c 14 | @@ -136,7 +136,6 @@ int doupdate(void) 15 | 16 | if (isendwin()) /* coming back after endwin() called */ 17 | { 18 | - reset_prog_mode(); 19 | clearall = TRUE; 20 | SP->alive = TRUE; /* so isendwin() result is correct */ 21 | } 22 | -- 23 | 2.39.1.windows.1 24 | 25 | -------------------------------------------------------------------------------- /patches/pdcurses/0010-fix-wheel.patch: -------------------------------------------------------------------------------- 1 | From 25663c057f1f5f253ff6e439146a58e7c1fc1fe7 Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Tue, 8 Mar 2016 19:00:37 +0100 4 | Subject: [PATCH 10/14] fix wheel 5 | 6 | --- 7 | win32/pdckbd.c | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/win32/pdckbd.c b/win32/pdckbd.c 11 | index 1c5b05b0..4ad64268 100644 12 | --- a/win32/pdckbd.c 13 | +++ b/win32/pdckbd.c 14 | @@ -475,7 +475,7 @@ static int _process_mouse_event(void) 15 | 16 | if (MEV.dwEventFlags == 4) 17 | { 18 | - pdc_mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ? 19 | + pdc_mouse_status.changes = (MEV.dwButtonState & 0x80000000) ? 20 | PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP; 21 | 22 | pdc_mouse_status.x = -1; 23 | -- 24 | 2.39.1.windows.1 25 | 26 | -------------------------------------------------------------------------------- /patches/pdcurses/0011-processed-input.patch: -------------------------------------------------------------------------------- 1 | From 2eff5fe592c1712ff7c00d7a4c46f2187ee7c1cc Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Sat, 23 Feb 2019 14:01:04 +0100 4 | Subject: [PATCH 11/14] processed input 5 | 6 | --- 7 | win32/pdckbd.c | 6 ++++-- 8 | win32/pdcscrn.c | 5 +++++ 9 | win32/pdcwin.h | 1 + 10 | 3 files changed, 10 insertions(+), 2 deletions(-) 11 | 12 | diff --git a/win32/pdckbd.c b/win32/pdckbd.c 13 | index 4ad64268..38403593 100644 14 | --- a/win32/pdckbd.c 15 | +++ b/win32/pdckbd.c 16 | @@ -642,8 +642,10 @@ int PDC_mouse_set(void) 17 | If turning off the mouse: Set QuickEdit Mode to the status it 18 | had on startup, and clear all other flags */ 19 | 20 | - SetConsoleMode(pdc_con_in, SP->_trap_mbe ? 21 | - (ENABLE_MOUSE_INPUT|0x0080) : (pdc_quick_edit|0x0080)); 22 | + DWORD mode = SP->_trap_mbe ? 23 | + (ENABLE_MOUSE_INPUT|0x0080) : (pdc_quick_edit|0x0080); 24 | + 25 | + SetConsoleMode(pdc_con_in, pdc_processed_input | mode); 26 | 27 | memset(&old_mouse_status, 0, sizeof(old_mouse_status)); 28 | 29 | diff --git a/win32/pdcscrn.c b/win32/pdcscrn.c 30 | index 6dd8f9d1..1135d41b 100644 31 | --- a/win32/pdcscrn.c 32 | +++ b/win32/pdcscrn.c 33 | @@ -18,6 +18,7 @@ HANDLE pdc_con_out = INVALID_HANDLE_VALUE; 34 | HANDLE pdc_con_in = INVALID_HANDLE_VALUE; 35 | 36 | DWORD pdc_quick_edit; 37 | +DWORD pdc_processed_input; 38 | 39 | static short curstoreal[16], realtocurs[16] = 40 | { 41 | @@ -315,6 +316,10 @@ int PDC_scr_open(int argc, char **argv) 42 | 43 | pdc_quick_edit = old_console_mode & 0x0040; 44 | 45 | + /* preserve processed input setting (ctrl-c handling) */ 46 | + 47 | + pdc_processed_input = old_console_mode & ENABLE_PROCESSED_INPUT; 48 | + 49 | SP->lines = PDC_get_rows(); 50 | SP->cols = PDC_get_columns(); 51 | 52 | diff --git a/win32/pdcwin.h b/win32/pdcwin.h 53 | index bb3396f0..4db95f6d 100644 54 | --- a/win32/pdcwin.h 55 | +++ b/win32/pdcwin.h 56 | @@ -13,5 +13,6 @@ 57 | extern unsigned char *pdc_atrtab; 58 | extern HANDLE pdc_con_out, pdc_con_in; 59 | extern DWORD pdc_quick_edit; 60 | +extern DWORD pdc_processed_input; 61 | 62 | extern int PDC_get_buffer_rows(void); 63 | -- 64 | 2.39.1.windows.1 65 | 66 | -------------------------------------------------------------------------------- /patches/pdcurses/0012-wheel-coordinates.patch: -------------------------------------------------------------------------------- 1 | From a7158efefd5b5487ed3f3ad6b7486320eadb491c Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Thu, 26 Nov 2020 20:06:30 +0100 4 | Subject: [PATCH 12/14] wheel coordinates 5 | 6 | --- 7 | win32/pdckbd.c | 36 ++++++++++++++++++++++++++++++++++++ 8 | 1 file changed, 36 insertions(+) 9 | 10 | diff --git a/win32/pdckbd.c b/win32/pdckbd.c 11 | index 38403593..a1a3a411 100644 12 | --- a/win32/pdckbd.c 13 | +++ b/win32/pdckbd.c 14 | @@ -31,6 +31,7 @@ static DWORD event_count = 0; 15 | static SHORT left_key; 16 | static int key_count = 0; 17 | static int save_press = 0; 18 | +static int is_console_window_class = 0; 19 | 20 | #define KEV save_ip.Event.KeyEvent 21 | #define MEV save_ip.Event.MouseEvent 22 | @@ -483,6 +484,33 @@ static int _process_mouse_event(void) 23 | 24 | memset(&old_mouse_status, 0, sizeof(old_mouse_status)); 25 | 26 | + if (!is_console_window_class) 27 | + { 28 | + pdc_mouse_status.x = MEV.dwMousePosition.X; 29 | + pdc_mouse_status.y = MEV.dwMousePosition.Y; 30 | + 31 | + return KEY_MOUSE; 32 | + } 33 | + 34 | + HWND hwnd = GetConsoleWindow(); 35 | + if (hwnd != NULL) 36 | + { 37 | + POINT cursor = {0, 0}; 38 | + GetCursorPos(&cursor); 39 | + RECT rc = {0, 0, 0, 0}; 40 | + GetClientRect(hwnd, &rc); 41 | + ScreenToClient(hwnd, &cursor); 42 | + if (cursor.x >= 0 && cursor.x < rc.right && 43 | + cursor.y >= 0 && cursor.y < rc.bottom) 44 | + { 45 | + CONSOLE_SCREEN_BUFFER_INFO csbi; 46 | + GetConsoleScreenBufferInfo(pdc_con_out, &csbi); 47 | + 48 | + pdc_mouse_status.x = cursor.x / (rc.right / csbi.srWindow.Right); 49 | + pdc_mouse_status.y = cursor.y / (rc.bottom / csbi.srWindow.Bottom); 50 | + } 51 | + } 52 | + 53 | return KEY_MOUSE; 54 | } 55 | 56 | @@ -649,6 +677,14 @@ int PDC_mouse_set(void) 57 | 58 | memset(&old_mouse_status, 0, sizeof(old_mouse_status)); 59 | 60 | + HWND hwnd = GetConsoleWindow(); 61 | + if (hwnd != NULL) 62 | + { 63 | + char className[100] = ""; 64 | + GetClassName(hwnd, className, sizeof(className)); 65 | + is_console_window_class = strcmp(className, "ConsoleWindowClass") == 0; 66 | + } 67 | + 68 | return OK; 69 | } 70 | 71 | -- 72 | 2.39.1.windows.1 73 | 74 | -------------------------------------------------------------------------------- /patches/pdcurses/0013-ncurses-mouse-api.patch: -------------------------------------------------------------------------------- 1 | From cfa503367f8ea9d97c5c04be1d156f3f3277aec8 Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Sun, 20 Dec 2020 16:03:54 +0100 4 | Subject: [PATCH 13/14] ncurses mouse api 5 | 6 | --- 7 | curses.h | 3 +++ 8 | 1 file changed, 3 insertions(+) 9 | 10 | diff --git a/curses.h b/curses.h 11 | index 6f3ce19d..f3f0794e 100644 12 | --- a/curses.h 13 | +++ b/curses.h 14 | @@ -37,6 +37,9 @@ PDCurses portable platform definitions list: 15 | #define SYSVcurses 1 /* System V Curses routines */ 16 | #define BSDcurses 1 /* BSD Curses routines */ 17 | #define CHTYPE_LONG 1 /* size of chtype; long */ 18 | +#ifndef CURSES_LIBRARY 19 | +#define NCURSES_MOUSE_VERSION 1 20 | +#endif 21 | 22 | /*----------------------------------------------------------------------*/ 23 | 24 | -- 25 | 2.39.1.windows.1 26 | 27 | -------------------------------------------------------------------------------- /patches/pdcurses/0014-resize-console.patch: -------------------------------------------------------------------------------- 1 | From 80c3af939d52cf0c3261a428a68bb2d67c1e6af0 Mon Sep 17 00:00:00 2001 2 | From: Hannes Domani 3 | Date: Sun, 5 Feb 2023 15:31:13 +0100 4 | Subject: [PATCH 14/14] resize console 5 | 6 | --- 7 | win32/pdcscrn.c | 83 ++++++++++++++++++++++--------------------------- 8 | 1 file changed, 38 insertions(+), 45 deletions(-) 9 | 10 | diff --git a/win32/pdcscrn.c b/win32/pdcscrn.c 11 | index 1135d41b..839e1163 100644 12 | --- a/win32/pdcscrn.c 13 | +++ b/win32/pdcscrn.c 14 | @@ -360,40 +360,42 @@ int PDC_scr_open(int argc, char **argv) 15 | return OK; 16 | } 17 | 18 | - /* Calls SetConsoleWindowInfo with the given parameters, but fits them 19 | - if a scoll bar shrinks the maximum possible value. The rectangle 20 | - must at least fit in a half-sized window. */ 21 | - 22 | -static BOOL _fit_console_window(HANDLE con_out, CONST SMALL_RECT *rect) 23 | +static void resize_console_buffer(HANDLE con_out, COORD console_size, COORD buffer_ofs, COORD buffer_size) 24 | { 25 | - SMALL_RECT run; 26 | - SHORT mx, my; 27 | - 28 | - if (SetConsoleWindowInfo(con_out, TRUE, rect)) 29 | - return TRUE; 30 | + CONSOLE_SCREEN_BUFFER_INFO csbi; 31 | + SMALL_RECT sr; 32 | 33 | - run = *rect; 34 | - run.Right /= 2; 35 | - run.Bottom /= 2; 36 | + GetConsoleScreenBufferInfo (con_out, &csbi); 37 | 38 | - mx = run.Right; 39 | - my = run.Bottom; 40 | + if (buffer_size.X > csbi.dwSize.X || buffer_size.Y > csbi.dwSize.Y) 41 | + { 42 | + if (buffer_size.X > csbi.dwSize.X) 43 | + csbi.dwSize.X = buffer_size.X; 44 | + if (buffer_size.Y > csbi.dwSize.Y) 45 | + csbi.dwSize.Y = buffer_size.Y; 46 | + SetConsoleScreenBufferSize (con_out, csbi.dwSize); 47 | + } 48 | 49 | - if (!SetConsoleWindowInfo(con_out, TRUE, &run)) 50 | - return FALSE; 51 | + sr.Right = buffer_ofs.X + console_size.X - 1; 52 | + if (sr.Right >= buffer_size.X) 53 | + sr.Right = buffer_size.X - 1; 54 | + sr.Left = sr.Right - (console_size.X - 1); 55 | 56 | - for (run.Right = rect->Right; run.Right >= mx; run.Right--) 57 | - if (SetConsoleWindowInfo(con_out, TRUE, &run)) 58 | - break; 59 | + sr.Bottom = buffer_ofs.Y + console_size.Y - 1; 60 | + if (sr.Bottom >= buffer_size.Y) 61 | + sr.Bottom = buffer_size.Y - 1; 62 | + sr.Top = sr.Bottom - (console_size.Y - 1); 63 | 64 | - if (run.Right < mx) 65 | - return FALSE; 66 | + SetConsoleWindowInfo (con_out, TRUE, &sr); 67 | 68 | - for (run.Bottom = rect->Bottom; run.Bottom >= my; run.Bottom--) 69 | - if (SetConsoleWindowInfo(con_out, TRUE, &run)) 70 | - return TRUE; 71 | + if (buffer_size.X < csbi.dwSize.X || buffer_size.Y < csbi.dwSize.Y) 72 | + SetConsoleScreenBufferSize (con_out, buffer_size); 73 | +} 74 | 75 | - return FALSE; 76 | +static void resize_console(HANDLE con_out, COORD console_size) 77 | +{ 78 | + COORD buffer_ofs = { 0, 0 }; 79 | + resize_console_buffer(con_out, console_size, buffer_ofs, console_size); 80 | } 81 | 82 | /* the core of resize_term() */ 83 | @@ -422,11 +424,7 @@ int PDC_resize_screen(int nlines, int ncols) 84 | size.X = rect.Right + 1; 85 | size.Y = rect.Bottom + 1; 86 | 87 | - _fit_console_window(pdc_con_out, &rect); 88 | - SetConsoleScreenBufferSize(pdc_con_out, size); 89 | - _fit_console_window(pdc_con_out, &rect); 90 | - SetConsoleScreenBufferSize(pdc_con_out, size); 91 | - SetConsoleActiveScreenBuffer(pdc_con_out); 92 | + resize_console(pdc_con_out, size); 93 | 94 | return OK; 95 | } 96 | @@ -438,19 +436,11 @@ void PDC_reset_prog_mode(void) 97 | if (is_nt) 98 | { 99 | COORD bufsize; 100 | - SMALL_RECT rect; 101 | 102 | bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1; 103 | bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1; 104 | 105 | - rect.Top = rect.Left = 0; 106 | - rect.Bottom = bufsize.Y - 1; 107 | - rect.Right = bufsize.X - 1; 108 | - 109 | - SetConsoleScreenBufferSize(pdc_con_out, bufsize); 110 | - SetConsoleWindowInfo(pdc_con_out, TRUE, &rect); 111 | - SetConsoleScreenBufferSize(pdc_con_out, bufsize); 112 | - SetConsoleActiveScreenBuffer(pdc_con_out); 113 | + resize_console(pdc_con_out, bufsize); 114 | } 115 | 116 | PDC_mouse_set(); 117 | @@ -462,11 +452,14 @@ void PDC_reset_shell_mode(void) 118 | 119 | if (is_nt) 120 | { 121 | - SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize); 122 | - SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow); 123 | - SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize); 124 | - SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow); 125 | - SetConsoleActiveScreenBuffer(pdc_con_out); 126 | + COORD console_size, buffer_ofs; 127 | + 128 | + console_size.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1; 129 | + console_size.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1; 130 | + buffer_ofs.X = orig_scr.srWindow.Left; 131 | + buffer_ofs.Y = orig_scr.srWindow.Top; 132 | + 133 | + resize_console_buffer(pdc_con_out, console_size, buffer_ofs, orig_scr.dwSize); 134 | } 135 | 136 | SetConsoleMode(pdc_con_in, old_console_mode); 137 | -- 138 | 2.39.1.windows.1 139 | 140 | -------------------------------------------------------------------------------- /patches/source-hightlight/Add-heuristic-to-handle-long-lines-better.patch: -------------------------------------------------------------------------------- 1 | From 7d53bc7510824d36d10457a96d31a35e8c35aafd Mon Sep 17 00:00:00 2001 2 | From: Tom de Vries 3 | Date: Tue, 10 Oct 2023 10:17:02 +0200 4 | Subject: [PATCH] Add heuristic to handle long lines better 5 | 6 | PR64747 describes a case where long lines in a c++ source file make 7 | source-highlight run longer than 2m13s. 8 | 9 | The problem is that some regexps are unanchored, and consequently run to the 10 | end of the long lines. 11 | 12 | Fix this by adding a heuristic that does the rule matching in two phases: 13 | - anchored: add a "\\A[[:blank:]]*" prefix to the regexp. If the rule 14 | matching yields a best-possible result, the next phase case be skipped. 15 | - unanchored: use the regexp as is, be that anchored or unanchored. 16 | 17 | This brings executing time down to 3s. 18 | 19 | Written on top of commit e4cf32d ("Modernize configure.ac") due to PR64764 20 | ( https://savannah.gnu.org/bugs/?64764 ). 21 | 22 | I've also added lines to all the touched files to specify file local variable 23 | values for emacs to make editing less painful. 24 | 25 | Tested on x86_64-linux. Tested using: 26 | - make check, and 27 | - comparing output for the test-case with and without the patch. 28 | 29 | Bug: https://savannah.gnu.org/bugs/?64747 30 | --- 31 | lib/srchilite/highlightrule.cpp | 5 +- 32 | lib/srchilite/highlightrule.h | 5 +- 33 | lib/srchilite/highlightstate.cpp | 75 +++++++++++++++++++++------- 34 | lib/srchilite/regexhighlightrule.cpp | 22 +++++--- 35 | lib/srchilite/regexhighlightrule.h | 4 +- 36 | 5 files changed, 81 insertions(+), 30 deletions(-) 37 | 38 | diff --git a/lib/srchilite/highlightrule.cpp b/lib/srchilite/highlightrule.cpp 39 | index b582a4c..c73622b 100644 40 | --- a/lib/srchilite/highlightrule.cpp 41 | +++ b/lib/srchilite/highlightrule.cpp 42 | @@ -1,3 +1,4 @@ 43 | +// -*- tab-width:4 indent-tabs-mode:nil c-basic-offset:4 -*- 44 | // 45 | // Author: Lorenzo Bettini , (C) 2004-2008 46 | // 47 | @@ -32,8 +33,8 @@ void HighlightRule::addElem(const std::string &name) { 48 | } 49 | 50 | bool HighlightRule::tryToMatch(const std::string &s, HighlightToken &token, 51 | - const MatchingParameters ¶ms) { 52 | - return tryToMatch(s.begin(), s.end(), token, params); 53 | + const MatchingParameters ¶ms, bool anchored) { 54 | + return tryToMatch(s.begin(), s.end(), token, params, anchored); 55 | } 56 | 57 | } 58 | diff --git a/lib/srchilite/highlightrule.h b/lib/srchilite/highlightrule.h 59 | index a99e493..9e1a30a 100644 60 | --- a/lib/srchilite/highlightrule.h 61 | +++ b/lib/srchilite/highlightrule.h 62 | @@ -1,3 +1,4 @@ 63 | +// -*- tab-width:4 indent-tabs-mode:nil c-basic-offset:4 -*- 64 | // 65 | // Author: Lorenzo Bettini , (C) 2004-2008 66 | // 67 | @@ -72,7 +73,7 @@ public: 68 | * @return the result of this matching 69 | */ 70 | virtual bool tryToMatch(const std::string &s, HighlightToken &token, 71 | - const MatchingParameters ¶ms); 72 | + const MatchingParameters ¶ms, bool anchored = false); 73 | 74 | /** 75 | * Try to match this rule against the passed string 76 | @@ -85,7 +86,7 @@ public: 77 | */ 78 | virtual bool tryToMatch(std::string::const_iterator start, 79 | std::string::const_iterator end, HighlightToken &token, 80 | - const MatchingParameters ¶ms) = 0; 81 | + const MatchingParameters ¶ms, bool anchored = false) = 0; 82 | 83 | virtual const std::string toString() const = 0; 84 | 85 | diff --git a/lib/srchilite/highlightstate.cpp b/lib/srchilite/highlightstate.cpp 86 | index ec9148f..c86d52e 100644 87 | --- a/lib/srchilite/highlightstate.cpp 88 | +++ b/lib/srchilite/highlightstate.cpp 89 | @@ -1,3 +1,4 @@ 90 | +// -*- tab-width:4 indent-tabs-mode:nil c-basic-offset:4 -*- 91 | // 92 | // Author: Lorenzo Bettini , (C) 2004-2008 93 | // 94 | @@ -53,27 +54,65 @@ bool HighlightState::findBestMatch(std::string::const_iterator start, 95 | const HighlightRule *bestMatchingRule = 0; 96 | HighlightRule *currentRule = 0; 97 | bool first = true; 98 | - 99 | - for (RuleList::const_iterator it = ruleList.begin(); it != ruleList.end(); ++it) { 100 | - currentRule = (*it).get(); 101 | - tempToken.clearMatched(); 102 | - 103 | - if (currentRule->tryToMatch(start, end, tempToken, params)) { 104 | - if (first || betterThan(tempToken, bestToken)) { 105 | - // the first one, it's always the best 106 | - if (first) { 107 | - first = false; 108 | - } 109 | - bestToken.copyFrom(tempToken); 110 | - bestMatchingRule = currentRule; 111 | - 112 | - // if we matched something with no prefix (or only spaces)... 113 | - if (tempToken.prefixOnlySpaces) { 114 | - // ...don't try any other rule 115 | - break; 116 | + bool foundBestPossible = false; 117 | + 118 | + // The strategy used by source-highlight is to select the first matching 119 | + // rule: 120 | + // - with empty prefix (or prefix containing only space characters, i.e., 121 | + // spaces or tabs), or 122 | + // - with the smallest prefix. 123 | + // 124 | + // The simplest implementation of this is to try rules in order, keeping 125 | + // track of the best-match-sofar, and stopping iteration once the 126 | + // best-match-possible is reached. 127 | + // 128 | + // The regexps of the rules can be unanchored though, and for long lines 129 | + // this can become very slow. 130 | + // 131 | + // So, we use a heuristic to avoid unanchored search, if we can, by 132 | + // searching in two phases: 133 | + // - anchored == true: we force an anchored search by prefixing the regexp 134 | + // with "\\A[[:blank:]]*". The "\\A" matches the start of the buffer, the 135 | + // "[[:blank:]]" matches the spaces or tabs part. If a match is found 136 | + // with no prefix, then then the next phase can be skipped. 137 | + // - anchored == false: we search with the unmodified regexp, which may or 138 | + // may not be anchored. 139 | + 140 | + for (bool anchored : { true, false }) { 141 | + for (RuleList::const_iterator it = ruleList.begin(); it != ruleList.end(); ++it) { 142 | + currentRule = (*it).get(); 143 | + tempToken.clearMatched(); 144 | + 145 | + if (currentRule->tryToMatch(start, end, tempToken, params, anchored)) { 146 | + if (first || betterThan(tempToken, bestToken)) { 147 | + // the first one, it's always the best 148 | + if (first) { 149 | + first = false; 150 | + } 151 | + bestToken.copyFrom(tempToken); 152 | + bestMatchingRule = currentRule; 153 | + 154 | + // if we matched something with no prefix (or only spaces)... 155 | + if (tempToken.prefixOnlySpaces) { 156 | + // ...don't try any other rule 157 | + foundBestPossible = true; 158 | + break; 159 | + } 160 | } 161 | } 162 | } 163 | + 164 | + if (anchored && foundBestPossible) { 165 | + // We found the best possible match using the anchored regexp, so 166 | + // we're done, no need to try the unanchored case. 167 | + break; 168 | + } 169 | + 170 | + if (anchored) { 171 | + // We reset the bestToken sofar, to make sure the the order 172 | + // between rules is respected. 173 | + first = true; 174 | + } 175 | } 176 | 177 | if (!first) { 178 | diff --git a/lib/srchilite/regexhighlightrule.cpp b/lib/srchilite/regexhighlightrule.cpp 179 | index 458e63f..1f4ff83 100644 180 | --- a/lib/srchilite/regexhighlightrule.cpp 181 | +++ b/lib/srchilite/regexhighlightrule.cpp 182 | @@ -1,3 +1,4 @@ 183 | +// -*- tab-width:4 indent-tabs-mode:nil c-basic-offset:4 -*- 184 | // 185 | // Author: Lorenzo Bettini , (C) 2004-2008 186 | // 187 | @@ -18,15 +19,14 @@ namespace srchilite { 188 | /// the only spaces regular expression 189 | static boost::regex onlySpaces("[[:blank:]]*"); 190 | 191 | -RegexHighlightRule::RegexHighlightRule(const std::string &s) : 192 | - regExp(s) { 193 | - 194 | +RegexHighlightRule::RegexHighlightRule(const std::string &s) { 195 | + setRegExp(s); 196 | } 197 | 198 | RegexHighlightRule::RegexHighlightRule(const std::string &name, 199 | const std::string &s) : 200 | - HighlightRule(name), regExp(s) { 201 | - 202 | + HighlightRule(name) { 203 | + setRegExp(s); 204 | } 205 | 206 | RegexHighlightRule::~RegexHighlightRule() { 207 | @@ -34,7 +34,7 @@ RegexHighlightRule::~RegexHighlightRule() { 208 | 209 | bool RegexHighlightRule::tryToMatch(std::string::const_iterator start, 210 | std::string::const_iterator end, HighlightToken &token, 211 | - const MatchingParameters ¶ms) { 212 | + const MatchingParameters ¶ms, bool anchored) { 213 | boost::smatch match; 214 | boost::match_flag_type flags = boost::match_default; 215 | 216 | @@ -46,7 +46,13 @@ bool RegexHighlightRule::tryToMatch(std::string::const_iterator start, 217 | flags |= boost::match_not_bol; 218 | } 219 | 220 | - if (boost::regex_search(start, end, match, regExp, flags)) { 221 | + bool found = boost::regex_search(start, end, match, anchored ? anchoredRegExp : regExp, flags); 222 | + if (found && anchored) { 223 | + // Search again using the unanchored regexp to get the prefix right. 224 | + found = boost::regex_search(start, end, match, regExp, flags); 225 | + } 226 | + 227 | + if (found) { 228 | token.prefix = match.prefix(); 229 | token.suffix = match.suffix(); 230 | 231 | @@ -82,6 +88,7 @@ const std::string RegexHighlightRule::toString() const { 232 | 233 | void RegexHighlightRule::replaceReferences(const ReplacementList &rep) { 234 | regExp.assign(RegexPreProcessor::replace_references(regExp.str(), rep)); 235 | + anchoredRegExp.assign(RegexPreProcessor::replace_references(anchoredRegExp.str(), rep)); 236 | } 237 | 238 | HighlightRule *RegexHighlightRule::clone() { 239 | @@ -90,6 +97,7 @@ HighlightRule *RegexHighlightRule::clone() { 240 | 241 | void RegexHighlightRule::setRegExp(const std::string &s) { 242 | regExp.assign(s); 243 | + anchoredRegExp.assign ("\\A[[:blank:]]*" + s); 244 | } 245 | 246 | } 247 | diff --git a/lib/srchilite/regexhighlightrule.h b/lib/srchilite/regexhighlightrule.h 248 | index d39614b..f3a8a2e 100644 249 | --- a/lib/srchilite/regexhighlightrule.h 250 | +++ b/lib/srchilite/regexhighlightrule.h 251 | @@ -1,3 +1,4 @@ 252 | +// -*- tab-width:4 indent-tabs-mode:nil c-basic-offset:4 -*- 253 | // 254 | // Author: Lorenzo Bettini , (C) 2004-2008 255 | // 256 | @@ -19,6 +20,7 @@ namespace srchilite { 257 | class RegexHighlightRule : public HighlightRule { 258 | /// the regular expression for the rule 259 | boost::regex regExp; 260 | + boost::regex anchoredRegExp; 261 | public: 262 | /** 263 | * @param s the string representing the regular expression 264 | @@ -34,7 +36,7 @@ public: 265 | 266 | virtual bool tryToMatch(std::string::const_iterator start, 267 | std::string::const_iterator end, HighlightToken &token, 268 | - const MatchingParameters ¶ms); 269 | + const MatchingParameters ¶ms, bool anchored = false); 270 | 271 | virtual const std::string toString() const; 272 | 273 | 274 | base-commit: e4cf32db1ce3f0a7edb32caf131b2f45753cdf58 275 | -- 276 | 2.35.3 277 | 278 | -------------------------------------------------------------------------------- /patches/source-hightlight/Remove-throw-specifications.patch: -------------------------------------------------------------------------------- 1 | From 904949c9026cb772dc93fbe0947a252ef47127f4 Mon Sep 17 00:00:00 2001 2 | From: Tom Tromey 3 | Date: Wed, 10 Jun 2020 20:38:27 -0600 4 | Subject: [PATCH] Remove "throw" specifications 5 | 6 | C++ throw specifications were deprecated in C++11. 7 | This patch removes them from the library. 8 | --- 9 | ChangeLog | 5 +++++ 10 | lib/srchilite/fileutil.cc | 2 +- 11 | lib/srchilite/fileutil.h | 2 +- 12 | 3 files changed, 7 insertions(+), 2 deletions(-) 13 | 14 | diff --git a/ChangeLog b/ChangeLog 15 | index fcc12ff..c194301 100644 16 | --- a/ChangeLog 17 | +++ b/ChangeLog 18 | @@ -1,3 +1,8 @@ 19 | +2020-06-10 Tom Tromey 20 | + 21 | + * lib/srchilite/fileutil.cc (readFile): Remove "throw". 22 | + * lib/srchilite/fileutil.h (readFile): Remove "throw". 23 | + 24 | 2019-06-02 Tom Tromey 25 | 26 | * configure.ac: Version 3.1.9. 27 | diff --git a/lib/srchilite/fileutil.cc b/lib/srchilite/fileutil.cc 28 | index 59a6d64..963178c 100644 29 | --- a/lib/srchilite/fileutil.cc 30 | +++ b/lib/srchilite/fileutil.cc 31 | @@ -48,7 +48,7 @@ void set_file_util_verbose(bool b) { 32 | // FIXME avoid using a global variable 33 | std::string start_path; 34 | 35 | -string readFile(const string &fileName) throw (IOException) { 36 | +string readFile(const string &fileName) { 37 | ifstream file(fileName.c_str()); 38 | 39 | if (!file.is_open()) { 40 | diff --git a/lib/srchilite/fileutil.h b/lib/srchilite/fileutil.h 41 | index 7335a9b..042eb56 100644 42 | --- a/lib/srchilite/fileutil.h 43 | +++ b/lib/srchilite/fileutil.h 44 | @@ -27,7 +27,7 @@ extern std::string start_path; 45 | * @return the contents of the file 46 | * @throw IOException 47 | */ 48 | -string readFile(const string &fileName) throw (IOException); 49 | +string readFile(const string &fileName); 50 | 51 | //char *read_file(const string &fileName); 52 | 53 | -- 54 | 2.15.1.windows.2 55 | 56 | -------------------------------------------------------------------------------- /patches/source-hightlight/console-colors.patch: -------------------------------------------------------------------------------- 1 | --- src/esc.style 2015-03-30 13:33:07.000000000 +0200 2 | +++ src/esc.style 2019-03-18 17:54:03.976097500 +0100 3 | @@ -1,14 +1,14 @@ 4 | -keyword blue b ; 5 | -type, classname darkgreen ; 6 | -string red ; 7 | +keyword yellow b ; 8 | +type, classname green b ; 9 | +string pink b ; 10 | regexp orange ; 11 | -specialchar pink ; 12 | -comment cyan i ; 13 | -number purple ; 14 | +specialchar orange b ; 15 | +comment cyan b ; 16 | +number purple b ; 17 | preproc darkblue b ; 18 | -symbol darkred ; 19 | -function b; 20 | -cbracket red; 21 | +symbol red b ; 22 | +function black b ; 23 | +cbracket yellow ; 24 | variable darkgreen ; 25 | 26 | // line numbers 27 | @@ -22,7 +22,7 @@ 28 | name darkgreen ; 29 | 30 | // Internet related 31 | -url blue u; 32 | +url blue b; 33 | 34 | // for diffs 35 | oldfile orange; 36 | --- src/c.lang 2010-05-06 10:32:55.000000000 +0200 37 | +++ src/c.lang 2019-03-18 18:27:21.699940800 +0100 38 | @@ -33,7 +33,7 @@ 39 | 40 | include "symbols.lang" 41 | 42 | -cbracket = "{|}" 43 | +cbracket = "{|}|(|)|[|]" 44 | 45 | include "function.lang" 46 | 47 | --- src/cpp.lang 2019-06-02 01:18:53.000000000 +0200 48 | +++ src/cpp.lang 2022-10-04 11:00:28.000000000 +0200 49 | @@ -39,7 +39,7 @@ 50 | 51 | include "symbols.lang" 52 | 53 | -cbracket = "{|}" 54 | +cbracket = "{|}|(|)|[|]" 55 | 56 | include "function.lang" 57 | 58 | --- src/symbols.lang 2010-05-06 10:32:55.000000000 +0200 59 | +++ src/symbols.lang 2019-03-18 18:27:01.691796400 +0100 60 | @@ -1,2 +1,2 @@ 61 | -symbol = "~","!","%","^","*","(",")","-","+","=","[", 62 | - "]","\\",":",";",",",".","/","?","&","<",">","\|" 63 | \ No newline at end of file 64 | +symbol = "~","!","%","^","*","-","+","=", 65 | + "\\",":",";",",",".","/","?","&","<",">","\|" 66 | -------------------------------------------------------------------------------- /patches/winipt/winipt.mk: -------------------------------------------------------------------------------- 1 | 2 | all: libwinipt.a 3 | 4 | SRC_DIR = . 5 | 6 | CC = gcc 7 | CPPFLAGS = -I$(SRC_DIR)/inc \ 8 | -DUNICODE -DERROR_IMPLEMENTATION_LIMIT=1292 \ 9 | -DUFIELD_OFFSET=FIELD_OFFSET 10 | CFLAGS = -O2 -g 11 | AR = ar 12 | 13 | SRC = \ 14 | libipt/win32.c \ 15 | 16 | OBJ = $(SRC:.c=.o) 17 | 18 | $(OBJ): %.o: $(SRC_DIR)/%.c 19 | $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< 20 | 21 | libwinipt.a: $(OBJ) 22 | $(AR) rcs $@ $^ 23 | 24 | clean: 25 | rm -rf $(OBJ) libwinipt.a 26 | --------------------------------------------------------------------------------