aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2023-11-06 01:21:57 +0000
committerThomas E. Dickey <dickey@invisible-island.net>2023-11-06 01:36:39 +0000
commitc244c640f9b4f69f521d286b77db0be566a5a610 (patch)
tree4cfff9a71e729662d748f8af597a82e5dd7b10e4 /src
parentae8afd251f08aa6ce99daf430c411dda178327c6 (diff)
downloadlynx-snapshots-c244c640f9b4f69f521d286b77db0be566a5a610.tar.gz
snapshot of project "lynx", label v2-9-0dev_12m
Diffstat (limited to 'src')
-rw-r--r--src/HTFWriter.c4
-rw-r--r--src/LYCurses.c26
-rw-r--r--src/LYKeymap.c4
-rw-r--r--src/LYUtils.c189
4 files changed, 121 insertions, 102 deletions
diff --git a/src/HTFWriter.c b/src/HTFWriter.c
index 9b7c0c6d..06a669a3 100644
--- a/src/HTFWriter.c
+++ b/src/HTFWriter.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: HTFWriter.c,v 1.124 2022/07/25 00:16:38 tom Exp $
+ * $LynxId: HTFWriter.c,v 1.125 2023/11/05 23:46:45 tom Exp $
*
* FILE WRITER HTFWrite.h
* ===========
@@ -368,7 +368,7 @@ static void HTFWriter_free(HTStream *me)
char *the_dash = me->idash ? strrchr(path, '-') : 0;
if (the_dash != 0) {
- unsigned off = (the_dash - path);
+ unsigned off = (unsigned) (the_dash - path);
StrAllocCopy(new_path, path);
new_path[off] = '.';
diff --git a/src/LYCurses.c b/src/LYCurses.c
index d97b9558..401af836 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYCurses.c,v 1.201 2023/10/23 23:39:38 tom Exp $ */
+/* $LynxId: LYCurses.c,v 1.204 2023/11/06 01:21:57 tom Exp $ */
#include <HTUtils.h>
#include <HTAlert.h>
@@ -1386,16 +1386,36 @@ void start_curses(void)
LYlines = LYscreenHeight();
LYcols = LYscreenWidth();
-#if defined(SIGWINCH) && defined(NCURSES_VERSION)
+#if defined(NCURSES_VERSION)
+#ifdef CAN_CUT_AND_PASTE
+ /*
+ * User-defined keymaps are loaded after this check, but since the
+ * ifdef is enabled, we know that at least the copy/paste commands
+ * are enabled. However, binding the copy to ^S is inconvenient,
+ * so ask curses to permit that (saving an external tweak with stty).
+ */
+ {
+ struct termios alter_tty;
+
+ if (tcgetattr(fileno(stdin), &alter_tty) == 0) {
+ alter_tty.c_iflag &= (unsigned) ~(IXON | IXOFF);
+ tcsetattr(fileno(stdout), TCSAFLUSH, &alter_tty);
+ def_prog_mode();
+ }
+ }
+#endif
+#if defined(SIGWINCH)
size_change(0);
LYGetScreenSize(0);
recent_sizechange = FALSE; /* prevent mainloop drawing 1st doc twice */
#endif /* SIGWINCH */
+#endif /* NCURSES_VERSION */
CTRACE((tfp, "Screen size is now %d x %d\n", LYcols, LYlines));
#ifdef USE_CURSES_PADS
if (LYuseCursesPads) {
CTRACE((tfp, "using curses-pads\n"));
+ keypad(stdscr, TRUE);
LYwin = newpad(LYlines, MAX_COLS);
LYshiftWin = 0;
LYwideLines = FALSE;
@@ -1672,6 +1692,8 @@ void lynx_enable_mouse(int state)
#endif /* NOT USE_SLANG */
/***********************************************************************/
+#else
+ (void) state;
#endif /* USE_MOUSE */
}
diff --git a/src/LYKeymap.c b/src/LYKeymap.c
index b05d0a3a..2ec5d919 100644
--- a/src/LYKeymap.c
+++ b/src/LYKeymap.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYKeymap.c,v 1.122 2021/06/09 21:58:11 tom Exp $ */
+/* $LynxId: LYKeymap.c,v 1.123 2023/10/27 20:10:32 tom Exp $ */
#include <HTUtils.h>
#include <LYUtils.h>
#include <LYGlobalDefs.h>
@@ -74,7 +74,9 @@ static const LYEditInit initKeymapData[] =
{KTL('P'), LYK_UP_TWO},
{KTL('Q'), LYK_CHANGE_CENTER},
{KTL('R'), LYK_RELOAD},
+#ifdef CAN_CUT_AND_PASTE
{KTL('S'), LYK_TO_CLIPBOARD},
+#endif
{KTL('T'), LYK_TRACE_TOGGLE},
{KTL('U'), LYK_NEXT_DOC},
{KTL('V'), LYK_SWITCH_DTD},
diff --git a/src/LYUtils.c b/src/LYUtils.c
index c9c42489..9b5ac476 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
/*
- * $LynxId: LYUtils.c,v 1.306 2023/10/24 00:12:43 tom Exp $
+ * $LynxId: LYUtils.c,v 1.308 2023/10/27 21:48:46 tom Exp $
*/
#include <HTUtils.h>
#include <HTTCP.h>
@@ -7560,9 +7560,96 @@ void get_clip_release(void)
unmorph_PM();
}
-#else /* !( defined __EMX__ ) */
+#elif defined(WIN_EX) /* 1997/10/16 (Thu) 20:13:28 */
-# if !defined(WIN_EX) && defined(HAVE_POPEN)
+int put_clip(const char *szBuffer)
+{
+ HANDLE hWnd;
+ HANDLE m_hLogData;
+ LPTSTR pLogData;
+ HANDLE hClip;
+ int len;
+
+ if (szBuffer == NULL)
+ return EOF;
+
+ len = (int) strlen(szBuffer);
+ if (len == 0)
+ return EOF;
+ else
+ len++;
+
+ m_hLogData = GlobalAlloc(GHND, len);
+ if (m_hLogData == NULL) {
+ return EOF;
+ }
+
+ hWnd = NULL;
+ if (!OpenClipboard(hWnd)) {
+ return EOF;
+ }
+ /* Remove the current Clipboard contents */
+ if (!EmptyClipboard()) {
+ GlobalFree(m_hLogData);
+ return EOF;
+ }
+
+ /* Lock the global memory while we write to it. */
+ pLogData = (LPTSTR) GlobalLock(m_hLogData);
+
+ lstrcpy((LPTSTR) pLogData, szBuffer);
+ GlobalUnlock(m_hLogData);
+
+ /* If there were any lines at all then copy them to clipboard. */
+ hClip = SetClipboardData(CF_TEXT, m_hLogData);
+ if (!hClip) {
+ /* If we couldn't clip the data then free the global handle. */
+ GlobalFree(m_hLogData);
+ }
+
+ CloseClipboard();
+ return 0;
+}
+
+static HANDLE m_hLogData;
+static int m_locked;
+
+/* get_clip_grab() returns a pointer to the string in the system area.
+ get_clip_release() should be called ASAP after this. */
+
+char *get_clip_grab()
+{
+ HANDLE hWnd;
+ LPTSTR pLogData;
+
+ hWnd = NULL;
+ if (!OpenClipboard(hWnd)) {
+ return 0;
+ }
+
+ m_hLogData = GetClipboardData(CF_TEXT);
+
+ if (m_hLogData == NULL) {
+ CloseClipboard();
+ m_locked = 0;
+ return 0;
+ }
+ pLogData = (LPTSTR) GlobalLock(m_hLogData);
+
+ m_locked = 1;
+ return pLogData;
+}
+
+void get_clip_release()
+{
+ if (!m_locked)
+ return;
+ GlobalUnlock(m_hLogData);
+ CloseClipboard();
+ m_locked = 0;
+}
+
+#elif defined(HAVE_POPEN)
static FILE *paste_handle = 0;
static char *paste_buf = NULL;
@@ -7643,9 +7730,8 @@ int put_clip(const char *s)
return 0;
}
-# endif /* !defined(WIN_EX) && defined(HAVE_POPEN) */
-
-#endif /* __EMX__ */
+#endif /* __EMX__ ... HAVE_POPEN */
+#endif /* CAN_CUT_AND_PASTE */
/*
* Sleep for a number of milli-sec.
@@ -7671,97 +7757,6 @@ void LYmsec_delay(unsigned msec)
#endif
}
-#if defined(WIN_EX) /* 1997/10/16 (Thu) 20:13:28 */
-
-int put_clip(const char *szBuffer)
-{
- HANDLE hWnd;
- HANDLE m_hLogData;
- LPTSTR pLogData;
- HANDLE hClip;
- int len;
-
- if (szBuffer == NULL)
- return EOF;
-
- len = (int) strlen(szBuffer);
- if (len == 0)
- return EOF;
- else
- len++;
-
- m_hLogData = GlobalAlloc(GHND, len);
- if (m_hLogData == NULL) {
- return EOF;
- }
-
- hWnd = NULL;
- if (!OpenClipboard(hWnd)) {
- return EOF;
- }
- /* Remove the current Clipboard contents */
- if (!EmptyClipboard()) {
- GlobalFree(m_hLogData);
- return EOF;
- }
-
- /* Lock the global memory while we write to it. */
- pLogData = (LPTSTR) GlobalLock(m_hLogData);
-
- lstrcpy((LPTSTR) pLogData, szBuffer);
- GlobalUnlock(m_hLogData);
-
- /* If there were any lines at all then copy them to clipboard. */
- hClip = SetClipboardData(CF_TEXT, m_hLogData);
- if (!hClip) {
- /* If we couldn't clip the data then free the global handle. */
- GlobalFree(m_hLogData);
- }
-
- CloseClipboard();
- return 0;
-}
-
-static HANDLE m_hLogData;
-static int m_locked;
-
-/* get_clip_grab() returns a pointer to the string in the system area.
- get_clip_release() should be called ASAP after this. */
-
-char *get_clip_grab()
-{
- HANDLE hWnd;
- LPTSTR pLogData;
-
- hWnd = NULL;
- if (!OpenClipboard(hWnd)) {
- return 0;
- }
-
- m_hLogData = GetClipboardData(CF_TEXT);
-
- if (m_hLogData == NULL) {
- CloseClipboard();
- m_locked = 0;
- return 0;
- }
- pLogData = (LPTSTR) GlobalLock(m_hLogData);
-
- m_locked = 1;
- return pLogData;
-}
-
-void get_clip_release()
-{
- if (!m_locked)
- return;
- GlobalUnlock(m_hLogData);
- CloseClipboard();
- m_locked = 0;
-}
-#endif /* WIN_EX */
-#endif /* CAN_CUT_AND_PASTE */
-
#if defined(WIN_EX)
#ifndef WSABASEERR