mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-16 12:03:03 -05:00
Colours now work properly, including 256-colour stuff.
Timing stuff now there, but almost certainly bogus. [originally from svn r5160]
This commit is contained in:
parent
961319c14c
commit
c29e61381a
17
mac/mac.c
17
mac/mac.c
@ -71,6 +71,7 @@ static int cold = 1;
|
|||||||
static int borednow = FALSE;
|
static int borednow = FALSE;
|
||||||
struct mac_gestalts mac_gestalts;
|
struct mac_gestalts mac_gestalts;
|
||||||
UInt32 sleeptime;
|
UInt32 sleeptime;
|
||||||
|
static long timing_next_time;
|
||||||
|
|
||||||
static void mac_startup(void);
|
static void mac_startup(void);
|
||||||
static void mac_eventloop(void);
|
static void mac_eventloop(void);
|
||||||
@ -244,16 +245,32 @@ static void mac_startup(void) {
|
|||||||
NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE);
|
NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void timer_change_notify(long next)
|
||||||
|
{
|
||||||
|
timing_next_time = next;
|
||||||
|
}
|
||||||
|
|
||||||
static void mac_eventloop(void) {
|
static void mac_eventloop(void) {
|
||||||
Boolean gotevent;
|
Boolean gotevent;
|
||||||
EventRecord event;
|
EventRecord event;
|
||||||
RgnHandle cursrgn;
|
RgnHandle cursrgn;
|
||||||
|
long next;
|
||||||
|
long ticksleft;
|
||||||
|
|
||||||
cursrgn = NewRgn();
|
cursrgn = NewRgn();
|
||||||
sleeptime = 0;
|
sleeptime = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
mac_adjustcursor(cursrgn);
|
mac_adjustcursor(cursrgn);
|
||||||
|
ticksleft=timing_next_time-GETTICKCOUNT();
|
||||||
|
if (sleeptime > ticksleft && ticksleft >=0)
|
||||||
|
sleeptime=ticksleft;
|
||||||
gotevent = WaitNextEvent(everyEvent, &event, sleeptime, cursrgn);
|
gotevent = WaitNextEvent(everyEvent, &event, sleeptime, cursrgn);
|
||||||
|
if (timing_next_time <= GETTICKCOUNT()) {
|
||||||
|
if (run_timers(timing_next_time, &next)) {
|
||||||
|
timer_change_notify(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX For now, limit sleep time to 1/10 s to work around
|
* XXX For now, limit sleep time to 1/10 s to work around
|
||||||
* wake-before-sleep race in MacTCP code.
|
* wake-before-sleep race in MacTCP code.
|
||||||
|
@ -63,14 +63,12 @@
|
|||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
||||||
#define NCOLOURS (lenof(((Config *)0)->colours))
|
#define DEFAULT_FG 256
|
||||||
|
#define DEFAULT_FG_BOLD 257
|
||||||
#define DEFAULT_FG 16
|
#define DEFAULT_BG 258
|
||||||
#define DEFAULT_FG_BOLD 17
|
#define DEFAULT_BG_BOLD 259
|
||||||
#define DEFAULT_BG 18
|
#define CURSOR_FG 260
|
||||||
#define DEFAULT_BG_BOLD 19
|
#define CURSOR_BG 261
|
||||||
#define CURSOR_FG 20
|
|
||||||
#define CURSOR_BG 21
|
|
||||||
|
|
||||||
#define PTOCC(x) ((x) < 0 ? -(-(x - s->font_width - 1) / s->font_width) : \
|
#define PTOCC(x) ((x) < 0 ? -(-(x - s->font_width - 1) / s->font_width) : \
|
||||||
(x) / s->font_width)
|
(x) / s->font_width)
|
||||||
@ -350,7 +348,7 @@ static void mac_initpalette(Session *s)
|
|||||||
#define PM_NORMAL ( pmTolerant | pmInhibitC2 | \
|
#define PM_NORMAL ( pmTolerant | pmInhibitC2 | \
|
||||||
pmInhibitG2 | pmInhibitG4 | pmInhibitG8 )
|
pmInhibitG2 | pmInhibitG4 | pmInhibitG8 )
|
||||||
#define PM_TOLERANCE 0x2000
|
#define PM_TOLERANCE 0x2000
|
||||||
s->palette = NewPalette(22, NULL, PM_NORMAL, PM_TOLERANCE);
|
s->palette = NewPalette(262, NULL, PM_NORMAL, PM_TOLERANCE);
|
||||||
if (s->palette == NULL)
|
if (s->palette == NULL)
|
||||||
fatalbox("Unable to create palette");
|
fatalbox("Unable to create palette");
|
||||||
/* In 2bpp, these are the colours we want most. */
|
/* In 2bpp, these are the colours we want most. */
|
||||||
@ -1150,7 +1148,7 @@ void do_text(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
#endif
|
#endif
|
||||||
char mactextbuf[1024];
|
char mactextbuf[1024];
|
||||||
wchar_t *unitextptr;
|
wchar_t *unitextptr;
|
||||||
int i, fontwidth;
|
int fontwidth;
|
||||||
ByteCount iread, olen;
|
ByteCount iread, olen;
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
static DeviceLoopDrawingUPP do_text_for_device_upp = NULL;
|
static DeviceLoopDrawingUPP do_text_for_device_upp = NULL;
|
||||||
@ -1286,9 +1284,7 @@ static pascal void do_text_for_device(short depth, short devflags,
|
|||||||
if (HAVE_COLOR_QD()) {
|
if (HAVE_COLOR_QD()) {
|
||||||
if (depth > 2) {
|
if (depth > 2) {
|
||||||
fgcolour = ((a->attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
|
fgcolour = ((a->attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
|
||||||
fgcolour = (fgcolour & 0xF) * 2 + (fgcolour & 0x10 ? 1 : 0);
|
|
||||||
bgcolour = ((a->attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
|
bgcolour = ((a->attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
|
||||||
bgcolour = (bgcolour & 0xF) * 2 + (bgcolour & 0x10 ? 1 : 0);
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* NB: bold reverse in 2bpp breaks with the usual PuTTY model and
|
* NB: bold reverse in 2bpp breaks with the usual PuTTY model and
|
||||||
@ -1303,7 +1299,8 @@ static pascal void do_text_for_device(short depth, short devflags,
|
|||||||
bgcolour = tmp;
|
bgcolour = tmp;
|
||||||
}
|
}
|
||||||
if (bright && depth > 2)
|
if (bright && depth > 2)
|
||||||
fgcolour |= 1;
|
if (fgcolour < 16) fgcolour |=8;
|
||||||
|
else if (fgcolour >= 256) fgcolour |=1;
|
||||||
if ((a->attr & TATTR_ACTCURS) && depth > 1) {
|
if ((a->attr & TATTR_ACTCURS) && depth > 1) {
|
||||||
fgcolour = CURSOR_FG;
|
fgcolour = CURSOR_FG;
|
||||||
bgcolour = CURSOR_BG;
|
bgcolour = CURSOR_BG;
|
||||||
@ -1355,7 +1352,7 @@ static pascal void do_text_for_device(short depth, short devflags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_cursor(Context ctx, int x, int y, char *text, int len,
|
void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
|
||||||
unsigned long attr, int lattr)
|
unsigned long attr, int lattr)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1693,19 +1690,13 @@ static void real_palette_set(Session *s, int n, int r, int g, int b)
|
|||||||
void palette_set(void *frontend, int n, int r, int g, int b)
|
void palette_set(void *frontend, int n, int r, int g, int b)
|
||||||
{
|
{
|
||||||
Session *s = frontend;
|
Session *s = frontend;
|
||||||
static const int first[21] = {
|
|
||||||
0, 2, 4, 6, 8, 10, 12, 14,
|
|
||||||
1, 3, 5, 7, 9, 11, 13, 15,
|
|
||||||
16, 17, 18, 20, 21
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!HAVE_COLOR_QD())
|
if (!HAVE_COLOR_QD())
|
||||||
return;
|
return;
|
||||||
real_palette_set(s, first[n], r, g, b);
|
real_palette_set(s, n, r, g, b);
|
||||||
if (first[n] == 18)
|
if (n == DEFAULT_BG)
|
||||||
real_palette_set(s, first[n]+1, r, g, b);
|
|
||||||
if (first[n] == DEFAULT_BG)
|
|
||||||
mac_adjustwinbg(s);
|
mac_adjustwinbg(s);
|
||||||
|
|
||||||
ActivatePalette(s->window);
|
ActivatePalette(s->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1717,23 +1708,38 @@ void palette_reset(void *frontend)
|
|||||||
Session *s = frontend;
|
Session *s = frontend;
|
||||||
/* This maps colour indices in cfg to those used in our palette. */
|
/* This maps colour indices in cfg to those used in our palette. */
|
||||||
static const int ww[] = {
|
static const int ww[] = {
|
||||||
6, 7, 8, 9, 10, 11, 12, 13,
|
256, 257, 258, 259, 260, 261,
|
||||||
14, 15, 16, 17, 18, 19, 20, 21,
|
0, 8, 1, 9, 2, 10, 3, 11,
|
||||||
0, 1, 2, 3, 4, 5
|
4, 12, 5, 13, 6, 14, 7, 15
|
||||||
};
|
};
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!HAVE_COLOR_QD())
|
if (!HAVE_COLOR_QD())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(lenof(ww) == NCOLOURS);
|
for (i = 0; i < 22; i++) {
|
||||||
|
int w = ww[i];
|
||||||
for (i = 0; i < NCOLOURS; i++) {
|
real_palette_set(s,w,
|
||||||
real_palette_set(s, i,
|
s->cfg.colours[i][0],
|
||||||
s->cfg.colours[ww[i]][0],
|
s->cfg.colours[i][1],
|
||||||
s->cfg.colours[ww[i]][1],
|
s->cfg.colours[i][2]);
|
||||||
s->cfg.colours[ww[i]][2]);
|
|
||||||
}
|
}
|
||||||
|
for (i = 0; i < 240; i++) {
|
||||||
|
if (i < 216) {
|
||||||
|
int r = i / 36, g = (i / 6) % 6, b = i % 6;
|
||||||
|
real_palette_set(s,i+16,
|
||||||
|
r * 0x33,
|
||||||
|
g * 0x33,
|
||||||
|
b * 0x33);
|
||||||
|
} else {
|
||||||
|
int shade = i - 216;
|
||||||
|
shade = (shade + 1) * 0xFF / (240 - 216 + 1);
|
||||||
|
real_palette_set(s,i+16,shade,shade,shade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mac_adjustwinbg(s);
|
mac_adjustwinbg(s);
|
||||||
ActivatePalette(s->window);
|
ActivatePalette(s->window);
|
||||||
/* Palette Manager will generate update events as required. */
|
/* Palette Manager will generate update events as required. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user