Really show correct G0 and G2 character set in widgets

Amendment to 7b59c78. This should prevent spurious NOS character sets from
appearing in the widgets, and should also prevent the G0 and G2 character
sets from getting mixed up in the widgets when those triplets are within
object definitions.

The G0 and G2 character set in the widgets may still be incorrect in corner
cases of objects invoked within areas of the page where the character set
has been changed either with the ESC/Switch spacing attribute or with the
"modified G0/G2 character set designation" triplet.
This commit is contained in:
G.K.MacGregor
2023-08-15 18:11:40 +01:00
parent 6185ca7110
commit f36143e10f
3 changed files with 26 additions and 18 deletions

View File

@@ -466,8 +466,8 @@ void TeletextPageDecode::decodeRow(int r)
if (c == 0 || c == 40 || c == 56) { if (c == 0 || c == 40 || c == 56) {
level1CharSet = m_level1DefaultCharSet; level1CharSet = m_level1DefaultCharSet;
m_level1ActivePainter.g0CharSet = m_g0CharacterMap.value(m_defaultG0andG2, 0); m_level1ActivePainter.result.g0Set = m_g0CharacterMap.value(m_defaultG0andG2, 0);
m_level1ActivePainter.g2CharSet = m_g2CharacterMap.value(m_defaultG0andG2, 7); m_level1ActivePainter.result.g2Set = m_g2CharacterMap.value(m_defaultG0andG2, 7);
m_level1ActivePainter.attribute.flash.mode = 0; m_level1ActivePainter.attribute.flash.mode = 0;
m_level1ActivePainter.attribute.flash.ratePhase = 0; m_level1ActivePainter.attribute.flash.ratePhase = 0;
@@ -661,12 +661,12 @@ void TeletextPageDecode::decodeRow(int r)
break; break;
case 0x28: // Modified G0 and G2 character set designation case 0x28: // Modified G0 and G2 character set designation
if (m_level == 3 || triplet.data() == m_defaultG0andG2 || triplet.data() == m_secondG0andG2) { if (m_level == 3 || triplet.data() == m_defaultG0andG2 || triplet.data() == m_secondG0andG2) {
painter->g0CharSet = m_g0CharacterMap.value(triplet.data(), 0); painter->result.g0Set = m_g0CharacterMap.value(triplet.data(), 0);
painter->g2CharSet = m_g2CharacterMap.value(triplet.data(), 7); painter->result.g2Set = m_g2CharacterMap.value(triplet.data(), 7);
} else if (m_secondG0andG2 == -1) { } else if (m_secondG0andG2 == -1) {
m_secondG0andG2 = triplet.data(); m_secondG0andG2 = triplet.data();
painter->g0CharSet = m_g0CharacterMap.value(triplet.data(), 0); painter->result.g0Set = m_g0CharacterMap.value(triplet.data(), 0);
painter->g2CharSet = m_g2CharacterMap.value(triplet.data(), 7); painter->result.g2Set = m_g2CharacterMap.value(triplet.data(), 7);
} }
break; break;
case 0x2c: // Display attributes case 0x2c: // Display attributes
@@ -754,9 +754,9 @@ void TeletextPageDecode::decodeRow(int r)
if (result.code != 0x00) { if (result.code != 0x00) {
m_level1ActivePainter.result.character = result; m_level1ActivePainter.result.character = result;
if (result.set == 0) if (result.set == 0)
m_level1ActivePainter.result.character.set = m_level1ActivePainter.g0CharSet; m_level1ActivePainter.result.character.set = m_level1ActivePainter.result.g0Set;
else if (result.set == 2) else if (result.set == 2)
m_level1ActivePainter.result.character.set = m_level1ActivePainter.g2CharSet; m_level1ActivePainter.result.character.set = m_level1ActivePainter.result.g2Set;
x26Character = 1; x26Character = 1;
} }
} else if (m_level >= 2) } else if (m_level >= 2)
@@ -779,10 +779,10 @@ void TeletextPageDecode::decodeRow(int r)
painter->result.character = result; painter->result.character = result;
switch (result.set) { switch (result.set) {
case 0: case 0:
painter->result.character.set = painter->g0CharSet; painter->result.character.set = painter->result.g0Set;
break; break;
case 2: case 2:
painter->result.character.set = painter->g2CharSet; painter->result.character.set = painter->result.g2Set;
break; break;
case 24: case 24:
if (painter->attribute.display.underlineSeparated) if (painter->attribute.display.underlineSeparated)

View File

@@ -46,6 +46,8 @@ public:
unsigned char cellCharacterCode(int r, int c) const { return m_cell[r][c].character.code; }; unsigned char cellCharacterCode(int r, int c) const { return m_cell[r][c].character.code; };
int cellCharacterSet(int r, int c) const { return m_cell[r][c].character.set; }; int cellCharacterSet(int r, int c) const { return m_cell[r][c].character.set; };
int cellCharacterDiacritical(int r, int c) const { return m_cell[r][c].character.diacritical; }; int cellCharacterDiacritical(int r, int c) const { return m_cell[r][c].character.diacritical; };
int cellG0CharacterSet(int r, int c) const { return m_cell[r][c].g0Set; };
int cellG2CharacterSet(int r, int c) const { return m_cell[r][c].g2Set; };
int cellForegroundCLUT(int r, int c) const { return m_cell[r][c].attribute.foregroundCLUT; }; int cellForegroundCLUT(int r, int c) const { return m_cell[r][c].attribute.foregroundCLUT; };
int cellBackgroundCLUT(int r, int c) const { return m_cell[r][c].attribute.backgroundCLUT; }; int cellBackgroundCLUT(int r, int c) const { return m_cell[r][c].attribute.backgroundCLUT; };
QColor cellForegroundQColor(int, int); QColor cellForegroundQColor(int, int);
@@ -164,6 +166,8 @@ private:
textCharacter character; textCharacter character;
textAttributes attribute; textAttributes attribute;
CharacterFragment fragment=NormalSize; CharacterFragment fragment=NormalSize;
int g0Set=0;
int g2Set=7;
}; };
friend inline bool operator!=(const textCell &lhs, const textCell &rhs) friend inline bool operator!=(const textCell &lhs, const textCell &rhs)
@@ -179,9 +183,6 @@ private:
textCell rightHalfCell; textCell rightHalfCell;
textCell bottomHalfCell[72]; textCell bottomHalfCell[72];
int g0CharSet=0;
int g2CharSet=7;
int styleSpreadRows=0; int styleSpreadRows=0;
int setProportionalRows[72], clearProportionalRows[72]; int setProportionalRows[72], clearProportionalRows[72];
int setBoldRows[72], clearBoldRows[72]; int setBoldRows[72], clearBoldRows[72];

View File

@@ -368,13 +368,16 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
if (triplet.data() >= 0x20) if (triplet.data() >= 0x20)
return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, 26*10, 12, 10); return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, 26*10, 12, 10);
break; break;
case 0x29: // G0 character
case 0x2f: // G2 character case 0x2f: // G2 character
if (triplet.data() >= 0x20)
return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, m_parentMainWidget->pageDecode()->cellG2CharacterSet(triplet.activePositionRow(), triplet.activePositionColumn())*10, 12, 10);
break;
case 0x29: // G0 character
case 0x30 ... 0x3f: // G0 diacritical mark case 0x30 ... 0x3f: // G0 diacritical mark
if (triplet.data() >= 0x20) if (triplet.data() >= 0x20)
return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, m_parentMainWidget->pageDecode()->cellCharacterSet(triplet.activePositionRow(), triplet.activePositionColumn())*10, 12, 10); return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, m_parentMainWidget->pageDecode()->cellG0CharacterSet(triplet.activePositionRow(), triplet.activePositionColumn())*10, 12, 10);
break; break;
}; }
if (role == Qt::EditRole && index.column() == 2) if (role == Qt::EditRole && index.column() == 2)
return triplet.modeExt(); return triplet.modeExt();
@@ -488,12 +491,16 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
return triplet.data() >> 4; return triplet.data() >> 4;
} }
break; break;
case 0x29: // G0 character
case 0x2f: // G2 character case 0x2f: // G2 character
// Qt::UserRole+1 is character number, returned by default below
if (role == Qt::UserRole+2) // Character set
return m_parentMainWidget->pageDecode()->cellG2CharacterSet(triplet.activePositionRow(), triplet.activePositionColumn());
break;
case 0x29: // G0 character
case 0x30 ... 0x3f: // G0 diacritical mark case 0x30 ... 0x3f: // G0 diacritical mark
// Qt::UserRole+1 is character number, returned by default below // Qt::UserRole+1 is character number, returned by default below
if (role == Qt::UserRole+2) // Character set if (role == Qt::UserRole+2) // Character set
return m_parentMainWidget->pageDecode()->cellCharacterSet(triplet.activePositionRow(), triplet.activePositionColumn()); return m_parentMainWidget->pageDecode()->cellG0CharacterSet(triplet.activePositionRow(), triplet.activePositionColumn());
break; break;
}; };