mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 00:38:01 +00:00
improved position caching
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23889 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6a2921d119
commit
f182333311
@ -22,6 +22,7 @@
|
|||||||
#include "Encoding.h"
|
#include "Encoding.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
|
|
||||||
|
#include "support/debug.h"
|
||||||
#include "support/gettext.h"
|
#include "support/gettext.h"
|
||||||
|
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
@ -139,8 +140,8 @@ UnicodeBlocks unicode_blocks[] = {
|
|||||||
{ N_("CJK Compatibility Ideographs Supplement"), 0x2f800, 0x2fa1f },
|
{ N_("CJK Compatibility Ideographs Supplement"), 0x2f800, 0x2fa1f },
|
||||||
{ N_("Tags"), 0xe0000, 0xe007f },
|
{ N_("Tags"), 0xe0000, 0xe007f },
|
||||||
{ N_("Variation Selectors Supplement"), 0xe0100, 0xe01ef },
|
{ N_("Variation Selectors Supplement"), 0xe0100, 0xe01ef },
|
||||||
{ N_("Supplementary Private Use Area-A"), 0xf0000, 0xe01ef },
|
{ N_("Supplementary Private Use Area-A"), 0xf0000, 0xffffd },
|
||||||
{ N_("Supplementary Private Use Area-B"), 0x100000, 0x10ffff }
|
{ N_("Supplementary Private Use Area-B"), 0x100000, 0x10fffd }
|
||||||
};
|
};
|
||||||
|
|
||||||
const int no_blocks = sizeof(unicode_blocks) / sizeof(UnicodeBlocks);
|
const int no_blocks = sizeof(unicode_blocks) / sizeof(UnicodeBlocks);
|
||||||
@ -151,17 +152,32 @@ QString getBlock(char_type c)
|
|||||||
// store an educated guess for the next search
|
// store an educated guess for the next search
|
||||||
static int lastBlock = 0;
|
static int lastBlock = 0;
|
||||||
|
|
||||||
if (c < unicode_blocks[lastBlock].start
|
// "clever reset"
|
||||||
|| c > unicode_blocks[lastBlock].end)
|
if (c < 0x7f)
|
||||||
{
|
lastBlock = 0;
|
||||||
// guess was wrong. do a real search.
|
|
||||||
|
// off the end already
|
||||||
|
if (lastBlock == no_blocks)
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
// c falls into a covered area, and we can guess which
|
||||||
|
if (c >= unicode_blocks[lastBlock].start
|
||||||
|
&& c <= unicode_blocks[lastBlock].end)
|
||||||
|
return unicode_blocks[lastBlock].name;
|
||||||
|
|
||||||
|
// c falls into an uncovered area, but we can guess which
|
||||||
|
if (c > unicode_blocks[lastBlock].end
|
||||||
|
&& c < unicode_blocks[lastBlock + 1].start)
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
// guessing was wrong so far. do a real search.
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (c > unicode_blocks[i].end && i < no_blocks)
|
while (c > unicode_blocks[i].end && i < no_blocks)
|
||||||
++i;
|
++i;
|
||||||
if (unicode_blocks[i].name.isEmpty())
|
if (i == no_blocks)
|
||||||
return QString();
|
return QString();
|
||||||
lastBlock = i;
|
lastBlock = i;
|
||||||
}
|
//LYXERR0("fail: " << int(c) << ' ' << lastBlock);
|
||||||
return unicode_blocks[lastBlock].name;
|
return unicode_blocks[lastBlock].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,7 +404,7 @@ void GuiSymbols::updateSymbolList(bool update_combo)
|
|||||||
bool const show_all = categoryFilterCB->isChecked();
|
bool const show_all = categoryFilterCB->isChecked();
|
||||||
|
|
||||||
if (symbols_.empty() || update_combo)
|
if (symbols_.empty() || update_combo)
|
||||||
symbols_ = encodings.getFromLyXName(encoding_)->getSymbolsList();
|
symbols_ = encodings.getFromLyXName(encoding_)->symbolsList();
|
||||||
|
|
||||||
if (!show_all) {
|
if (!show_all) {
|
||||||
for (int i = 0 ; i < no_blocks; ++i)
|
for (int i = 0 ; i < no_blocks; ++i)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "ui_SymbolsUi.h"
|
#include "ui_SymbolsUi.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <vector>
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
@ -62,7 +62,7 @@ private:
|
|||||||
///
|
///
|
||||||
UsedBlocks used_blocks;
|
UsedBlocks used_blocks;
|
||||||
/// list of all symbols
|
/// list of all symbols
|
||||||
typedef std::set<char_type> SymbolsList;
|
typedef std::vector<char_type> SymbolsList;
|
||||||
///
|
///
|
||||||
SymbolsList symbols_;
|
SymbolsList symbols_;
|
||||||
/// custom model for symbol list view
|
/// custom model for symbol list view
|
||||||
|
Loading…
x
Reference in New Issue
Block a user