[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev [PATCH 2.8.4dev.18] OS/2 cut&paste
From: |
Ilya Zakharevich |
Subject: |
lynx-dev [PATCH 2.8.4dev.18] OS/2 cut&paste |
Date: |
Wed, 14 Feb 2001 02:57:09 -0500 |
User-agent: |
Mutt/1.2.5i |
Enables cut and paste on OS/2. I put this in my keymaps:
setkey "\200\4" LAC:DO_NOTHING:PASTE # S-insert
setkey "^(kIC)" LAC:DO_NOTHING:PASTE # S-insert
Enjoy,
Ilya
--- ./src/LYGlobalDefs.h-pre-os2cut Wed Feb 14 00:47:58 2001
+++ ./src/LYGlobalDefs.h Wed Feb 14 02:44:18 2001
@@ -473,8 +479,11 @@ extern BOOLEAN focus_window;
extern BOOLEAN system_is_NT;
extern char windows_drive[4];
extern int lynx_timeout;
-# define CAN_CUT_AND_PASTE
#endif /* _WINDOWS */
+
+#if defined(__EMX__) || defined(WIN_EX)
+# define CAN_CUT_AND_PASTE
+#endif
#ifdef SH_EX
extern BOOLEAN show_cfg;
--- ./src/LYUtils.c-pre-os2cut Wed Feb 14 00:55:26 2001
+++ ./src/LYUtils.c Wed Feb 14 02:49:46 2001
@@ -41,6 +41,15 @@ extern int exec_command(char * cmd, int
#include <bios.h>
#endif /* DJGPP_KEYHANDLER */
+#ifdef __EMX__
+# define BOOLEAN OS2_BOOLEAN /* Conflicts, but is used */
+# undef HT_ERROR /* Conflicts too */
+# define INCL_PM /* I want some PM functions.. */
+# define INCL_DOSPROCESS /* TIB PIB. */
+# include <os2.h>
+# undef BOOLEAN
+#endif
+
#ifdef VMS
#include <descrip.h>
#include <libclidef.h>
@@ -7748,6 +7757,121 @@ PUBLIC void LYsetXDisplay ARGS1(
}
}
}
+
+#ifdef __EMX__
+
+static int proc_type = -1;
+static PPIB pib;
+HAB hab;
+HMQ hmq;
+
+PRIVATE void morph_PM NOARGS
+{
+ PTIB tib;
+ int first = 0;
+
+ if (proc_type == -1) {
+ DosGetInfoBlocks(&tib, &pib);
+ proc_type = pib->pib_ultype;
+ first = 1;
+ }
+ if (pib->pib_ultype != 3) /* 2 is VIO */
+ pib->pib_ultype = 3; /* 3 is PM */
+ if (first)
+ hab = WinInitialize(0);
+ /* 64 messages if before OS/2 3.0, ignored otherwise */
+ hmq = WinCreateMsgQueue(hab, 64);
+ WinCancelShutdown(hmq, 1); /* Do not inform us on shutdown */
+}
+
+PRIVATE void unmorph_PM NOARGS
+{
+ WinDestroyMsgQueue(hmq);
+ pib->pib_ultype = proc_type;
+}
+
+PUBLIC int size_clip NOARGS
+{
+ return 8192;
+}
+
+/* Code partialy stolen from FED editor. */
+
+PUBLIC int put_clip ARGS1(char *, s)
+{
+ int sz = strlen(s) + 1;
+ int ret = EOF, nl = 0;
+ char *pByte = 0, *s1 = s, c, *t;
+
+ while ((c = *s1++)) {
+ if (c == '\r' && *s1 == '\n')
+ s1++;
+ else if (c == '\n')
+ nl++;
+ }
+ if (DosAllocSharedMem((PPVOID)&pByte, 0, sz + nl,
+ PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE | OBJ_GETTABLE))
+ return ret;
+
+ if (!nl)
+ memcpy(pByte, s, sz);
+ else {
+ t = pByte;
+ while ((c = *t++ = *s++))
+ if (c == '\n' && (t == pByte + 1 || t[-2] != '\r'))
+ t[-1] = '\r', *t++ = '\n';
+ }
+
+ morph_PM();
+ if(!hab) {
+ fail:
+ DosFreeMem((PPVOID)&pByte);
+ return ret;
+ }
+
+ WinOpenClipbrd(hab);
+ WinEmptyClipbrd(hab);
+ if (!WinSetClipbrdData(hab, (ULONG) pByte, CF_TEXT, CFI_POINTER))
+ ret = 0;
+ WinCloseClipbrd(hab);
+ unmorph_PM();
+ if (ret != 0)
+ goto fail;
+ return 0;
+}
+
+PUBLIC int get_clip ARGS2(char *, szBuffer, int, size)
+{
+ char *ClipData;
+ ULONG ulFormat;
+ int sz;
+ int ret = 0;
+
+ if(!size)
+ return 0;
+ morph_PM();
+ if(!hab)
+ return 0;
+
+ WinQueryClipbrdFmtInfo(hab, CF_TEXT, &ulFormat);
+ if(ulFormat != CFI_POINTER)
+ goto finish;
+ WinOpenClipbrd(hab);
+ ClipData = (char *)WinQueryClipbrdData(hab, CF_TEXT);
+ sz = strlen(ClipData);
+ if(!ClipData || sz >= size)
+ goto fail;
+ memcpy(szBuffer, ClipData, sz + 1);
+ ret = sz;
+ fail:
+ WinCloseClipbrd(hab);
+ finish:
+ unmorph_PM();
+ return ret;
+}
+
+
+#endif
#if defined(WIN_EX) /* 1997/10/16 (Thu) 20:13:28 */
--- ./src/LYUtils.h-pre-os2cut Wed Feb 14 00:31:36 2001
+++ ./src/LYUtils.h Wed Feb 14 01:22:28 2001
@@ -177,6 +177,11 @@ extern void LYUIPages_free NOPARAMS;
#ifdef CAN_CUT_AND_PASTE
extern int put_clip(char *szBuffer);
extern int get_clip(char *szBuffer, int size);
+# ifdef WIN_EX
+# define size_clip() 8192
+# else
+extern int size_clip();
+# endif
#endif
#if defined(WIN_EX) /* 1997/10/16 (Thu) 20:13:28 */
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev [PATCH 2.8.4dev.18] OS/2 cut&paste,
Ilya Zakharevich <=