Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Draw background color behind images too #1

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions sources/ScreenChar.h
Expand Up @@ -249,12 +249,12 @@ typedef struct screen_char_t {
// With 24-bit semantics:
// foreground/backgroundColor gives red component and fg/bgGreen, fg/bgBlue
// give the rest of the color's components
// For images, foregroundColor doubles as the x index.
// For images, foregroundColor doubles as the x index,
// fgGreen doubles as the y index.
unsigned int foregroundColor : 8;
unsigned int fgGreen : 8;
unsigned int fgBlue : 8;

// For images, backgroundColor doubles as the y index.
unsigned int backgroundColor : 8;
unsigned int bgGreen : 8;
unsigned int bgBlue : 8;
Expand Down
4 changes: 2 additions & 2 deletions sources/ScreenChar.m
Expand Up @@ -179,7 +179,7 @@ screen_char_t ImageCharForNewImage(NSString *name,
void SetPositionInImageChar(screen_char_t *charPtr, int x, int y)
{
charPtr->foregroundColor = x;
charPtr->backgroundColor = y;
charPtr->fgGreen = y;
}

void SetDecodedImage(unichar code, iTermImage *image, NSData *data) {
Expand All @@ -205,7 +205,7 @@ void ReleaseImage(unichar code) {

VT100GridCoord GetPositionOfImageInChar(screen_char_t c) {
return VT100GridCoordMake(c.foregroundColor,
c.backgroundColor);
c.fgGreen);
}

int AppendToComplexChar(int key, unichar codePoint) {
Expand Down
4 changes: 4 additions & 0 deletions sources/VT100InlineImageHelper.m
Expand Up @@ -279,6 +279,10 @@ - (void)writeImage:(VT100DecodedImage *)decodedImage toGrid:(VT100Grid *)grid {
height:&height
grid:grid
decodedImage:decodedImage];

// TODO: Pass correct background color
c.backgroundColor = ALTSEM_DEFAULT;
c.backgroundColorMode = ColorModeAlternate;

[self writeBaseCharacter:c
toGrid:grid
Expand Down
1 change: 1 addition & 0 deletions sources/iTermBackgroundColorRun.m
Expand Up @@ -29,6 +29,7 @@ static void iTermMakeBackgroundColorRun(iTermBackgroundColorRun *run,
run->isMatch = NO;
}
if (theLine[coord.x].image) {
// TODO: non-default background color draws over image
run->bgColor = run->bgGreen = run->bgBlue = ALTSEM_DEFAULT;
run->bgColorMode = ColorModeAlternate;
} else {
Expand Down
3 changes: 2 additions & 1 deletion sources/iTermTextExtractor.m
Expand Up @@ -1487,7 +1487,8 @@ - (id)locatedStringInRange:(VT100GridWindowedRange)windowedRange
lineContainsNonImage = YES;
}
if (theChar.image) {
if (attributeProvider && theChar.foregroundColor == 0 && theChar.backgroundColor == 0) {
VT100GridCoord imagePos = GetPositionOfImageInChar(theChar);
if (attributeProvider && imagePos.x == 0 && imagePos.y == 0) {
id<iTermImageInfoReading> imageInfo = GetImageInfo(theChar.code);
NSImage *image = imageInfo.image.images.firstObject;
if (image) {
Expand Down