Add more items and HTML Hexadecilmal column to ASCII panel
Fix #13347, close #13348
This commit is contained in:
parent
7f54a4b959
commit
9b67c93ef9
|
@ -1467,8 +1467,9 @@ Do you want to save your changes before switching themes?"/> <!-- HowToReproduce
|
|||
<ColumnVal name="Value"/>
|
||||
<ColumnHex name="Hex"/>
|
||||
<ColumnChar name="Character"/>
|
||||
<ColumnHtmlNumber name="HTML Number"/>
|
||||
<ColumnHtmlName name="HTML Code"/>
|
||||
<ColumnHtmlName name="HTML Name"/>
|
||||
<ColumnHtmlNumber name="HTML Decimal"/>
|
||||
<ColumnHtmlHexNb name="HTML Hexadecimal"/>
|
||||
</AsciiInsertion>
|
||||
<DocumentMap>
|
||||
<PanelTitle name="Document Map"/>
|
||||
|
|
|
@ -1457,8 +1457,9 @@ Do you want to save your changes before switching themes?"/> <!-- HowToReproduce
|
|||
<ColumnVal name="Value"/>
|
||||
<ColumnHex name="Hex"/>
|
||||
<ColumnChar name="Character"/>
|
||||
<ColumnHtmlNumber name="HTML Number"/>
|
||||
<ColumnHtmlName name="HTML Code"/>
|
||||
<ColumnHtmlName name="HTML Name"/>
|
||||
<ColumnHtmlNumber name="HTML Decimal"/>
|
||||
<ColumnHtmlHexNb name="HTML Hexadecimal"/>
|
||||
</AsciiInsertion>
|
||||
<DocumentMap>
|
||||
<PanelTitle name="Document Map"/>
|
||||
|
|
|
@ -36,14 +36,16 @@ intptr_t CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
generic_string valStr = pNativeSpeaker->getAttrNameStr(TEXT("Value"), "AsciiInsertion", "ColumnVal");
|
||||
generic_string hexStr = pNativeSpeaker->getAttrNameStr(TEXT("Hex"), "AsciiInsertion", "ColumnHex");
|
||||
generic_string charStr = pNativeSpeaker->getAttrNameStr(TEXT("Character"), "AsciiInsertion", "ColumnChar");
|
||||
generic_string htmlNumberStr = pNativeSpeaker->getAttrNameStr(TEXT("HTML Number"), "AsciiInsertion", "ColumnHtmlNumber");
|
||||
generic_string htmlNameStr = pNativeSpeaker->getAttrNameStr(TEXT("HTML Name"), "AsciiInsertion", "ColumnHtmlName");
|
||||
generic_string htmlNameStr = pNativeSpeaker->getAttrNameStr(L"HTML Name", "AsciiInsertion", "ColumnHtmlName");
|
||||
generic_string htmlNumberStr = pNativeSpeaker->getAttrNameStr(L"HTML Decimal", "AsciiInsertion", "ColumnHtmlNumber");
|
||||
generic_string htmlHexNbStr = pNativeSpeaker->getAttrNameStr(L"HTML Hexadecimal", "AsciiInsertion", "ColumnHtmlHexNb");
|
||||
|
||||
_listView.addColumn(columnInfo(valStr, nppParam._dpiManager.scaleX(45)));
|
||||
_listView.addColumn(columnInfo(hexStr, nppParam._dpiManager.scaleX(45)));
|
||||
_listView.addColumn(columnInfo(charStr, nppParam._dpiManager.scaleX(70)));
|
||||
_listView.addColumn(columnInfo(htmlNumberStr, nppParam._dpiManager.scaleX(100)));
|
||||
_listView.addColumn(columnInfo(htmlNameStr, nppParam._dpiManager.scaleX(90)));
|
||||
_listView.addColumn(columnInfo(htmlNumberStr, nppParam._dpiManager.scaleX(100)));
|
||||
_listView.addColumn(columnInfo(htmlHexNbStr, nppParam._dpiManager.scaleX(120)));
|
||||
|
||||
_listView.init(_hInst, _hSelf);
|
||||
int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding();
|
||||
|
@ -76,14 +78,14 @@ intptr_t CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
case NM_DBLCLK:
|
||||
{
|
||||
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
|
||||
LVHITTESTINFO pInfo;
|
||||
LVHITTESTINFO pInfo{};
|
||||
pInfo.pt = lpnmitem->ptAction;
|
||||
ListView_SubItemHitTest(_listView.getHSelf(), &pInfo);
|
||||
|
||||
int i = pInfo.iItem;
|
||||
int j = pInfo.iSubItem;
|
||||
wchar_t buffer[10];
|
||||
LVITEM item;
|
||||
wchar_t buffer[10]{};
|
||||
LVITEM item{};
|
||||
item.mask = LVIF_TEXT | LVIF_PARAM;
|
||||
item.iItem = i;
|
||||
item.iSubItem = j;
|
||||
|
@ -144,11 +146,11 @@ intptr_t CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||
|
||||
void AnsiCharPanel::insertChar(unsigned char char2insert) const
|
||||
{
|
||||
char charStr[2];
|
||||
char charStr[2]{};
|
||||
charStr[0] = char2insert;
|
||||
charStr[1] = '\0';
|
||||
wchar_t wCharStr[10];
|
||||
char multiByteStr[10];
|
||||
wchar_t wCharStr[10]{};
|
||||
char multiByteStr[10]{};
|
||||
int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding();
|
||||
if (codepage == -1)
|
||||
{
|
||||
|
|
|
@ -104,8 +104,8 @@ generic_string AsciiListView::getAscii(unsigned char value)
|
|||
return TEXT("DEL");
|
||||
default:
|
||||
{
|
||||
TCHAR charStr[10];
|
||||
char ascii[2];
|
||||
wchar_t charStr[10]{};
|
||||
char ascii[2]{};
|
||||
ascii[0] = value;
|
||||
ascii[1] = '\0';
|
||||
MultiByteToWideChar(_codepage, 0, ascii, -1, charStr, _countof(charStr));
|
||||
|
@ -119,16 +119,124 @@ generic_string AsciiListView::getHtmlName(unsigned char value)
|
|||
{
|
||||
switch (value)
|
||||
{
|
||||
case 33:
|
||||
return TEXT("!");
|
||||
case 34:
|
||||
return TEXT(""");
|
||||
case 35:
|
||||
return TEXT("#");
|
||||
case 36:
|
||||
return TEXT("$");
|
||||
case 37:
|
||||
return TEXT("%");
|
||||
case 38:
|
||||
return TEXT("&");
|
||||
case 39:
|
||||
return TEXT("'");
|
||||
case 40:
|
||||
return TEXT("(");
|
||||
case 41:
|
||||
return TEXT(")");
|
||||
case 42:
|
||||
return TEXT("*");
|
||||
case 43:
|
||||
return TEXT("+");
|
||||
case 44:
|
||||
return TEXT(",");
|
||||
case 45:
|
||||
return TEXT("−");
|
||||
case 46:
|
||||
return TEXT(".");
|
||||
case 47:
|
||||
return TEXT("/");
|
||||
case 58:
|
||||
return TEXT(":");
|
||||
case 59:
|
||||
return TEXT(";");
|
||||
case 60:
|
||||
return TEXT("<");
|
||||
case 61:
|
||||
return TEXT("=");
|
||||
case 62:
|
||||
return TEXT(">");
|
||||
case 63:
|
||||
return TEXT("?");
|
||||
case 64:
|
||||
return TEXT("@");
|
||||
case 91:
|
||||
return TEXT("[");
|
||||
case 92:
|
||||
return TEXT("\");
|
||||
case 93:
|
||||
return TEXT("]");
|
||||
case 94:
|
||||
return TEXT("^");
|
||||
case 95:
|
||||
return TEXT("_");
|
||||
case 96:
|
||||
return TEXT("`");
|
||||
case 123:
|
||||
return TEXT("{");
|
||||
case 124:
|
||||
return TEXT("|");
|
||||
case 125:
|
||||
return TEXT("}");
|
||||
case 126:
|
||||
return TEXT(""); // ascii tilde
|
||||
case 128:
|
||||
return TEXT("€");
|
||||
case 130:
|
||||
return TEXT("‚");
|
||||
case 131:
|
||||
return TEXT("ƒ");
|
||||
case 132:
|
||||
return TEXT("„");
|
||||
case 133:
|
||||
return TEXT("…");
|
||||
case 134:
|
||||
return TEXT("†");
|
||||
case 135:
|
||||
return TEXT("‡");
|
||||
case 136:
|
||||
return TEXT("ˆ");
|
||||
case 137:
|
||||
return TEXT("‰");
|
||||
case 138:
|
||||
return TEXT("Š");
|
||||
case 139:
|
||||
return TEXT("‹");
|
||||
case 140:
|
||||
return TEXT("Œ");
|
||||
case 142:
|
||||
return TEXT("Ž");
|
||||
case 145:
|
||||
return TEXT("‘");
|
||||
case 146:
|
||||
return TEXT("’");
|
||||
case 147:
|
||||
return TEXT("“");
|
||||
case 148:
|
||||
return TEXT("”");
|
||||
case 149:
|
||||
return TEXT("•");
|
||||
case 150:
|
||||
return TEXT("–");
|
||||
case 151:
|
||||
return TEXT("—");
|
||||
case 152:
|
||||
return TEXT("˜");
|
||||
case 153:
|
||||
return TEXT("™");
|
||||
case 154:
|
||||
return TEXT("š");
|
||||
case 155:
|
||||
return TEXT("›");
|
||||
case 156:
|
||||
return TEXT("œ");
|
||||
case 158:
|
||||
return TEXT("ž");
|
||||
case 159:
|
||||
return TEXT("Ÿ");
|
||||
case 160:
|
||||
return TEXT(" ");
|
||||
case 161:
|
||||
|
@ -325,7 +433,6 @@ generic_string AsciiListView::getHtmlName(unsigned char value)
|
|||
{
|
||||
return TEXT("");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,6 +440,8 @@ int AsciiListView::getHtmlNumber(unsigned char value)
|
|||
{
|
||||
switch (value)
|
||||
{
|
||||
case 45:
|
||||
return 8722;
|
||||
case 128:
|
||||
return 8364;
|
||||
case 130:
|
||||
|
@ -347,12 +456,18 @@ int AsciiListView::getHtmlNumber(unsigned char value)
|
|||
return 8224;
|
||||
case 135:
|
||||
return 8225;
|
||||
case 136:
|
||||
return 710;
|
||||
case 137:
|
||||
return 8240;
|
||||
case 138:
|
||||
return 352;
|
||||
case 139:
|
||||
return 8249;
|
||||
case 140:
|
||||
return 338;
|
||||
case 142:
|
||||
return 381;
|
||||
case 145:
|
||||
return 8216;
|
||||
case 146:
|
||||
|
@ -367,19 +482,24 @@ int AsciiListView::getHtmlNumber(unsigned char value)
|
|||
return 8211;
|
||||
case 151:
|
||||
return 8212;
|
||||
case 152:
|
||||
return 732;
|
||||
case 153:
|
||||
return 8482;
|
||||
case 154:
|
||||
return 353;
|
||||
case 155:
|
||||
return 8250;
|
||||
case 156:
|
||||
return 339;
|
||||
case 158:
|
||||
return 382;
|
||||
case 159:
|
||||
return 376;
|
||||
default:
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -390,9 +510,11 @@ void AsciiListView::setValues(int codepage)
|
|||
for (int i = 0 ; i < 256 ; ++i)
|
||||
{
|
||||
constexpr size_t bufSize = 8;
|
||||
TCHAR dec[bufSize];
|
||||
TCHAR hex[bufSize];
|
||||
TCHAR htmlNumber[bufSize];
|
||||
constexpr size_t bufSizeHex = 9;
|
||||
wchar_t dec[bufSize]{};
|
||||
wchar_t hex[bufSize]{};
|
||||
wchar_t htmlNumber[bufSize]{};
|
||||
wchar_t htmlHexNumber[bufSizeHex]{};
|
||||
generic_string htmlName;
|
||||
swprintf(dec, bufSize, TEXT("%d"), i);
|
||||
swprintf(hex, bufSize, TEXT("%02X"), i);
|
||||
|
@ -400,20 +522,23 @@ void AsciiListView::setValues(int codepage)
|
|||
|
||||
if (codepage == 0 || codepage == 1252)
|
||||
{
|
||||
if ((i >= 32 && i <= 126) || (i >= 160 && i <= 255))
|
||||
if ((i >= 32 && i <= 126 && i != 45) || (i >= 160 && i <= 255))
|
||||
{
|
||||
swprintf(htmlNumber, bufSize, TEXT("&#%d"), i);
|
||||
swprintf(htmlNumber, bufSize, TEXT("&#%d;"), i);
|
||||
swprintf(htmlHexNumber, bufSize, TEXT("&#x%x;"), i);
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = getHtmlNumber(static_cast<unsigned char>(i));
|
||||
if (n > -1)
|
||||
{
|
||||
swprintf(htmlNumber, bufSize, TEXT("&#%d"), n);
|
||||
swprintf(htmlNumber, bufSize, TEXT("&#%d;"), n);
|
||||
swprintf(htmlHexNumber, bufSizeHex, TEXT("&#x%x;"), n);
|
||||
}
|
||||
else
|
||||
{
|
||||
swprintf(htmlNumber, bufSize, TEXT(""));
|
||||
swprintf(htmlHexNumber, bufSizeHex, TEXT(""));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,6 +547,7 @@ void AsciiListView::setValues(int codepage)
|
|||
else
|
||||
{
|
||||
swprintf(htmlNumber, bufSize, TEXT(""));
|
||||
swprintf(htmlHexNumber, bufSizeHex, TEXT(""));
|
||||
htmlName = TEXT("");
|
||||
}
|
||||
|
||||
|
@ -430,8 +556,9 @@ void AsciiListView::setValues(int codepage)
|
|||
values2Add.push_back(dec);
|
||||
values2Add.push_back(hex);
|
||||
values2Add.push_back(s);
|
||||
values2Add.push_back(htmlNumber);
|
||||
values2Add.push_back(htmlName);
|
||||
values2Add.push_back(htmlNumber);
|
||||
values2Add.push_back(htmlHexNumber);
|
||||
|
||||
addLine(values2Add);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue