mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Ron Kuris's "copy everything to clipboard" patch
[originally from svn r808]
This commit is contained in:
parent
f7aec0aa10
commit
9147f68fb6
1
putty.h
1
putty.h
@ -314,6 +314,7 @@ void term_blink(int set_cursor);
|
|||||||
void term_paste(void);
|
void term_paste(void);
|
||||||
void term_nopaste(void);
|
void term_nopaste(void);
|
||||||
void from_backend(int is_stderr, char *data, int len);
|
void from_backend(int is_stderr, char *data, int len);
|
||||||
|
void term_copyall(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exports from raw.c.
|
* Exports from raw.c.
|
||||||
|
128
terminal.c
128
terminal.c
@ -1917,6 +1917,85 @@ void term_scroll (int rel, int where) {
|
|||||||
term_update();
|
term_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clipme(long *top, long *bottom, char *workbuf) {
|
||||||
|
char *wbptr; /* where next char goes within workbuf */
|
||||||
|
int wblen = 0; /* workbuf len */
|
||||||
|
int buflen; /* amount of memory allocated to workbuf */
|
||||||
|
|
||||||
|
if ( workbuf != NULL ) { /* user supplied buffer? */
|
||||||
|
buflen = -1; /* assume buffer passed in is big enough */
|
||||||
|
wbptr = workbuf; /* start filling here */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
buflen = 0; /* No data is available yet */
|
||||||
|
|
||||||
|
while (top < bottom) {
|
||||||
|
int nl = FALSE;
|
||||||
|
unsigned long *lineend = top - (top-text) % (cols+1) + cols;
|
||||||
|
unsigned long *nlpos = lineend;
|
||||||
|
|
||||||
|
if (!(*nlpos & ATTR_WRAPPED)) {
|
||||||
|
while ((nlpos[-1] & CHAR_MASK) == 0x20 && nlpos > top)
|
||||||
|
nlpos--;
|
||||||
|
if (nlpos < bottom)
|
||||||
|
nl = TRUE;
|
||||||
|
}
|
||||||
|
while (top < nlpos && top < bottom)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
/* VT Specials -> ISO8859-1 */
|
||||||
|
static const char poorman2[] =
|
||||||
|
"* # HTFFCRLF\xB0 \xB1 NLVT+ + + + + - - - - - + + + + | <=>=PI!=\xA3 \xB7 ";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int ch = (*top & CHAR_MASK);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if ((*top & ATTR_LINEDRW) && ch >= 0x60 && ch < 0x7F) {
|
||||||
|
int x;
|
||||||
|
*wbptr++ = poorman2[2*(ch-0x60)];
|
||||||
|
if ( (x = poorman2[2*(ch-0x60)+1]) != ' ')
|
||||||
|
*wbptr++ = x;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
if ((*top & ATTR_GBCHR) && ch == '#')
|
||||||
|
*wbptr++ = (unsigned char) 0xA3;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if ( wblen == buflen )
|
||||||
|
{
|
||||||
|
workbuf = srealloc(workbuf, buflen += 100);
|
||||||
|
wbptr = workbuf + wblen;
|
||||||
|
}
|
||||||
|
wblen++;
|
||||||
|
*wbptr++ = (unsigned char) ch;
|
||||||
|
top++;
|
||||||
|
}
|
||||||
|
if (nl) {
|
||||||
|
int i;
|
||||||
|
for (i=0; i<sizeof(sel_nl); i++)
|
||||||
|
{
|
||||||
|
if ( wblen == buflen )
|
||||||
|
{
|
||||||
|
workbuf = srealloc(workbuf, buflen += 100);
|
||||||
|
wbptr = workbuf + wblen;
|
||||||
|
}
|
||||||
|
wblen++;
|
||||||
|
*wbptr++ = sel_nl[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
top = lineend + 1; /* start of next line */
|
||||||
|
}
|
||||||
|
write_clip (workbuf, wblen, FALSE); /* transfer to clipboard */
|
||||||
|
if ( buflen > 0 ) /* indicates we allocated this buffer */
|
||||||
|
sfree(workbuf);
|
||||||
|
|
||||||
|
}
|
||||||
|
void term_copyall (void) {
|
||||||
|
clipme(sbtop, cpos, NULL /* dynamic allocation */);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Spread the selection outwards according to the selection mode.
|
* Spread the selection outwards according to the selection mode.
|
||||||
*/
|
*/
|
||||||
@ -2034,54 +2113,7 @@ void term_mouse (Mouse_Button b, Mouse_Action a, int x, int y) {
|
|||||||
* We've completed a selection. We now transfer the
|
* We've completed a selection. We now transfer the
|
||||||
* data to the clipboard.
|
* data to the clipboard.
|
||||||
*/
|
*/
|
||||||
unsigned char *p = selspace;
|
clipme(selstart, selend, selspace);
|
||||||
unsigned long *q = selstart;
|
|
||||||
|
|
||||||
while (q < selend) {
|
|
||||||
int nl = FALSE;
|
|
||||||
unsigned long *lineend = q - (q-text) % (cols+1) + cols;
|
|
||||||
unsigned long *nlpos = lineend;
|
|
||||||
|
|
||||||
if (!(*nlpos & ATTR_WRAPPED)) {
|
|
||||||
while ((nlpos[-1] & CHAR_MASK) == 0x20 && nlpos > q)
|
|
||||||
nlpos--;
|
|
||||||
if (nlpos < selend)
|
|
||||||
nl = TRUE;
|
|
||||||
}
|
|
||||||
while (q < nlpos && q < selend)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
/* VT Specials -> ISO8859-1 */
|
|
||||||
static const char poorman2[] =
|
|
||||||
"* # HTFFCRLF\xB0 \xB1 NLVT+ + + + + - - - - - + + + + | <=>=PI!=\xA3 \xB7 ";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int ch = (*q & CHAR_MASK);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if ((*q & ATTR_LINEDRW) && ch >= 0x60 && ch < 0x7F) {
|
|
||||||
int x;
|
|
||||||
*p++ = poorman2[2*(ch-0x60)];
|
|
||||||
if ( (x = poorman2[2*(ch-0x60)+1]) != ' ')
|
|
||||||
*p++ = x;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
#if 0
|
|
||||||
if ((*q & ATTR_GBCHR) && ch == '#')
|
|
||||||
*p++ = (unsigned char) 0xA3;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
*p++ = (unsigned char) ch;
|
|
||||||
q++;
|
|
||||||
}
|
|
||||||
if (nl) {
|
|
||||||
int i;
|
|
||||||
for (i=0; i<sizeof(sel_nl); i++)
|
|
||||||
*p++ = sel_nl[i];
|
|
||||||
}
|
|
||||||
q = lineend + 1; /* start of next line */
|
|
||||||
}
|
|
||||||
write_clip (selspace, p - selspace, FALSE);
|
|
||||||
selstate = SELECTED;
|
selstate = SELECTED;
|
||||||
} else
|
} else
|
||||||
selstate = NO_SELECTION;
|
selstate = NO_SELECTION;
|
||||||
|
5
window.c
5
window.c
@ -40,6 +40,7 @@
|
|||||||
#define IDM_TEL_EOF 0x0130
|
#define IDM_TEL_EOF 0x0130
|
||||||
#define IDM_ABOUT 0x0140
|
#define IDM_ABOUT 0x0140
|
||||||
#define IDM_SAVEDSESS 0x0150
|
#define IDM_SAVEDSESS 0x0150
|
||||||
|
#define IDM_COPYALL 0x0160
|
||||||
|
|
||||||
#define IDM_SAVED_MIN 0x1000
|
#define IDM_SAVED_MIN 0x1000
|
||||||
#define IDM_SAVED_MAX 0x2000
|
#define IDM_SAVED_MAX 0x2000
|
||||||
@ -513,6 +514,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
|
|||||||
AppendMenu (m, MF_POPUP | MF_ENABLED, (UINT) s, "Sa&ved Sessions");
|
AppendMenu (m, MF_POPUP | MF_ENABLED, (UINT) s, "Sa&ved Sessions");
|
||||||
AppendMenu (m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings...");
|
AppendMenu (m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings...");
|
||||||
AppendMenu (m, MF_SEPARATOR, 0, 0);
|
AppendMenu (m, MF_SEPARATOR, 0, 0);
|
||||||
|
AppendMenu (m, MF_ENABLED, IDM_COPYALL, "C&opy All to Clipboard");
|
||||||
AppendMenu (m, MF_ENABLED, IDM_CLRSB, "C&lear Scrollback");
|
AppendMenu (m, MF_ENABLED, IDM_CLRSB, "C&lear Scrollback");
|
||||||
AppendMenu (m, MF_ENABLED, IDM_RESET, "Rese&t Terminal");
|
AppendMenu (m, MF_ENABLED, IDM_RESET, "Rese&t Terminal");
|
||||||
AppendMenu (m, MF_SEPARATOR, 0, 0);
|
AppendMenu (m, MF_SEPARATOR, 0, 0);
|
||||||
@ -1245,6 +1247,9 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case IDM_COPYALL:
|
||||||
|
term_copyall();
|
||||||
|
break;
|
||||||
case IDM_CLRSB:
|
case IDM_CLRSB:
|
||||||
term_clrsb();
|
term_clrsb();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user