JSON转代码内容文本时,自动分行

This commit is contained in:
gb 2022-09-27 17:26:58 +08:00
parent 5fac179faa
commit 2fd3dc61eb
2 changed files with 15 additions and 1 deletions

View File

@ -7054,8 +7054,22 @@ void ChgjsonDlg::OnBnClickedButton2()
pos = txt.find("\\u", pos + 3);
}
// divide into multi-lines with 16KB per line ...
int lines = 1;
pos = txt.length();
while (pos > 16 * 1024)
{
pos -= 12 * 1024;
while (txt[pos - 1] == '\\')
pos++;
txt.insert(pos, "\r\n");
lines++;
}
file_util::set_clipboard(txt.c_str(), txt.length());
MessageBox(TEXT("JSON text has set to clipboard already"));
TCHAR msg[128] = { 0 };
_stprintf(msg, TEXT("%d lines"), lines);
MessageBox(TEXT("JSON text has set to clipboard already"), msg);
}

Binary file not shown.