1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-11 02:18:01 +00:00

Auto-scrolling now works properly.

[originally from svn r97]
This commit is contained in:
Ben Harris 1999-03-13 18:23:24 +00:00
parent 13d3a23263
commit a5f734f8e4

View File

@ -1,4 +1,4 @@
/* $Id: macterm.c,v 1.1.2.18 1999/03/11 23:23:45 ben Exp $ */ /* $Id: macterm.c,v 1.1.2.19 1999/03/13 18:23:24 ben Exp $ */
/* /*
* Copyright (c) 1999 Ben Harris * Copyright (c) 1999 Ben Harris
* All rights reserved. * All rights reserved.
@ -57,6 +57,11 @@
#define CURSOR_FG 22 #define CURSOR_FG 22
#define CURSOR_FG_BOLD 23 #define CURSOR_FG_BOLD 23
#define PTOCC(x) ((x) < 0 ? -(-(x - font_width - 1) / font_width) : \
(x) / font_width)
#define PTOCR(y) ((y) < 0 ? -(-(y - font_height - 1) / font_height) : \
(y) / font_height)
struct mac_session { struct mac_session {
short fontnum; short fontnum;
int font_ascent; int font_ascent;
@ -263,8 +268,8 @@ static void text_click(struct mac_session *s, EventRecord *event) {
localwhere = event->where; localwhere = event->where;
GlobalToLocal(&localwhere); GlobalToLocal(&localwhere);
col = localwhere.h / font_width; col = PTOCC(localwhere.h);
row = localwhere.v / font_height; row = PTOCR(localwhere.v);
if (event->when - lastwhen < GetDblTime() && if (event->when - lastwhen < GetDblTime() &&
row == lastrow && col == lastcol && s == lastsess) row == lastrow && col == lastcol && s == lastsess)
lastact = (lastact == MA_CLICK ? MA_2CLK : lastact = (lastact == MA_CLICK ? MA_2CLK :
@ -279,14 +284,14 @@ static void text_click(struct mac_session *s, EventRecord *event) {
lastcol = col; lastcol = col;
while (StillDown()) { while (StillDown()) {
GetMouse(&localwhere); GetMouse(&localwhere);
col = localwhere.h / font_width; col = PTOCC(localwhere.h);
row = localwhere.v / font_height; row = PTOCR(localwhere.v);
term_mouse(event->modifiers & shiftKey ? MB_EXTEND : MB_SELECT, term_mouse(event->modifiers & shiftKey ? MB_EXTEND : MB_SELECT,
MA_DRAG, col, row); MA_DRAG, col, row);
if (row > rows - 1) if (row > rows - 1)
term_scroll(0, row - (rows - 1)); term_scroll(0, row - (rows - 1));
else if (row <= 0) else if (row < 0)
term_scroll(0, row - 1); term_scroll(0, row);
} }
term_mouse(event->modifiers & shiftKey ? MB_EXTEND : MB_SELECT, MA_RELEASE, term_mouse(event->modifiers & shiftKey ? MB_EXTEND : MB_SELECT, MA_RELEASE,
col, row); col, row);
@ -295,6 +300,7 @@ static void text_click(struct mac_session *s, EventRecord *event) {
void write_clip(void *data, int len) { void write_clip(void *data, int len) {
SysBeep(30);
if (ZeroScrap() != noErr) if (ZeroScrap() != noErr)
return; return;
PutScrap(len, 'TEXT', data); PutScrap(len, 'TEXT', data);