summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libunix.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-11 15:31:45 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-11 15:31:45 +0000
commit04ef4ac34d7bbc5358a3adbf542071599e71c515 (patch)
treef1a7f48c32bd700ac49cace190c67b3f5434df7f /crawl-ref/source/libunix.cc
parent370f12250ba294042472a110a006769e42f1bff4 (diff)
downloadcrawl-ref-04ef4ac34d7bbc5358a3adbf542071599e71c515.tar.gz
crawl-ref-04ef4ac34d7bbc5358a3adbf542071599e71c515.zip
[1657502] Added use_fake_cursor option to make Crawl draw a cursor for Unix
terminals that cannot draw cursors on black spaces or darkgrey areas. May need some work, since the fake cursor tends to leave artifacts on the scrolling edge. Removed the +1 X offset to the viewport. Fixed crash when monster wielding a weapon of orc slaying hits player (Erik). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1016 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/libunix.cc')
-rw-r--r--crawl-ref/source/libunix.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc
index 3eb398237b..1ef0d2ea45 100644
--- a/crawl-ref/source/libunix.cc
+++ b/crawl-ref/source/libunix.cc
@@ -640,6 +640,44 @@ int gotoxy(int x, int y)
return (move(y - 1, x - 1));
}
+static unsigned oldch, oldmangledch;
+static int faked_x = -1, faked_y;
+
+void fakecursorxy(int x, int y)
+{
+ if (oldch && faked_x != -1
+ && mvinch(faked_y, faked_x) == oldmangledch)
+ {
+ if (faked_x != x - 1 || faked_y != y - 1)
+ mvaddch(faked_y, faked_x, oldch);
+ else
+ return;
+ }
+
+ const unsigned c = mvinch(y - 1, x - 1);
+ const int ch = c & A_CHARTEXT;
+ const unsigned colour = c & A_COLOR;
+ const int pair = PAIR_NUMBER(colour);
+
+ faked_x = x - 1;
+ faked_y = y - 1;
+ oldch = c;
+
+ int fg = pair & 7;
+ int bg = (pair >> 3) & 7;
+
+ if (pair == 63)
+ {
+ fg = COLOR_WHITE;
+ bg = COLOR_BLACK;
+ }
+
+ const int newpair = (fg * 8 + bg);
+
+ mvaddch( y - 1, x - 1, oldmangledch = ((ch & 127) | COLOR_PAIR(newpair)) );
+
+ move(y - 1, x - 1);
+}
int wherex()
{