Skip to content
Snippets Groups Projects
Commit c90edc6e authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'dd_lightbar_menu_list_utf8_detection_and_bkg_color' into 'master'

dd_ligbtar_menu.js: Fix for behavior with the item color when printing the last portion of an item. Also, UTF8 detection improvement.

See merge request !438
parents 726a0852 2c7c178c
No related branches found
No related tags found
2 merge requests!455Update branch with changes from master,!438dd_ligbtar_menu.js: Fix for behavior with the item color when printing the last portion of an item. Also, UTF8 detection improvement.
...@@ -1187,6 +1187,18 @@ function DDLightbarMenu_WriteItem(pIdx, pItemLen, pHighlight, pSelected, pScreen ...@@ -1187,6 +1187,18 @@ function DDLightbarMenu_WriteItem(pIdx, pItemLen, pHighlight, pSelected, pScreen
{ {
var itemText = this.GetItemText(pIdx, pItemLen, pHighlight, pSelected); var itemText = this.GetItemText(pIdx, pItemLen, pHighlight, pSelected);
/* /*
// Temporary
if (user.is_sysop)
{
console.pushxy();
console.gotoxy(1, 1);
console.attributes = "N";
console.print("itemText is: " + typeof(itemText) + "\x01;");
console.popxy();
}
// End Temporary
*/
/*
// If the text is UTF-8 and the user's terminal is UTF-8, then set the mode bit accordingly. // If the text is UTF-8 and the user's terminal is UTF-8, then set the mode bit accordingly.
// If the text is UTF-8 and the user's terminal doesn't support UTF-8, convert the text to cp437. // If the text is UTF-8 and the user's terminal doesn't support UTF-8, convert the text to cp437.
var printModeBits = P_NONE; var printModeBits = P_NONE;
...@@ -1293,8 +1305,23 @@ function DDLightbarMenu_WriteItem(pIdx, pItemLen, pHighlight, pSelected, pScreen ...@@ -1293,8 +1305,23 @@ function DDLightbarMenu_WriteItem(pIdx, pItemLen, pHighlight, pSelected, pScreen
var printedLen = console.strlen(itemText, P_AUTO_UTF8); var printedLen = console.strlen(itemText, P_AUTO_UTF8);
if (printedLen < itemLen) if (printedLen < itemLen)
{ {
console.print(this.GetColorForItem(pIdx, pHighlight)); var remainingLen = itemLen - printedLen;
printf("%*s", itemLen - printedLen, ""); var itemColor = this.GetColorForItem(pIdx, pHighlight);
// If the item color is an array of colors for various parts of the text,
// then get all the attributes up to the current text index
if (Array.isArray(itemColor))
{
var tmpItemColor = "\x01n";
var startIdx = printedLen - remainingLen - 1;
for (var idx = 0; idx < itemColor.length; ++idx)
{
if (itemColor[idx].start <= startIdx)
tmpItemColor += itemColor[idx].attrs;
}
itemColor = tmpItemColor;
}
console.print(itemColor);
printf("%*s", remainingLen, "");
console.attributes = "N"; console.attributes = "N";
} }
} }
...@@ -1714,7 +1741,11 @@ function DDLightbarMenu_ItemTextIsUTF8(pIdx) ...@@ -1714,7 +1741,11 @@ function DDLightbarMenu_ItemTextIsUTF8(pIdx)
if (pIdx < 0 || pIdx >= this.NumItems()) if (pIdx < 0 || pIdx >= this.NumItems())
return false; return false;
return this.GetItem(pIdx).textIsUTF8; var item = this.GetItem(pIdx);
var isUTF8 = item.textIsUTF8;
if (!isUTF8)
isUTF8 = str_is_utf8(item.text);
return isUTF8;
} }
// Erases the menu - Draws black (normal color) where the menu was // Erases the menu - Draws black (normal color) where the menu was
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment