Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions Src/Common/Types/int.h

This file was deleted.

16 changes: 2 additions & 14 deletions Src/DasherCore/Alphabet/AlphabetMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,12 @@ inline int CAlphabetMap::SymbolStream::findNext() {
if (int numChars = m_utf8_count_array[buf[pos]]) {
if (pos+numChars > len) {
//no more bytes in file (would have tried to read earlier), but not enough for char
if (m_pMsgs) {
const char *msg(_("File ends with incomplete UTF-8 character beginning 0x%x (expecting %i bytes but only %i)"));
char *mbuf(new char[strlen(msg) + 4]);
sprintf(mbuf, msg, static_cast<unsigned int>(buf[pos] & 0xff), numChars, len-pos);
m_pMsgs->Message(mbuf,false);
delete[] mbuf;
}
if(m_pMsgs) m_pMsgs->FormatMessage("File ends with incomplete UTF-8 character beginning 0x%x (expecting %i bytes but only %i)", static_cast<unsigned int>(buf[pos] & 0xff), numChars, len-pos);
return 0;
}
return numChars;
}
if (m_pMsgs) {
const char *msg(_("Read invalid UTF-8 character 0x%x"));
char *mbuf(new char[strlen(msg) + 2]);
sprintf(mbuf, msg, static_cast<unsigned int>(buf[pos] & 0xff));
m_pMsgs->Message(mbuf,false);
delete[] mbuf;
}
if (m_pMsgs) m_pMsgs->FormatMessage("Read invalid UTF-8 character 0x%x", static_cast<unsigned int>(buf[pos] & 0xff));
++pos;
}
}
Expand Down
59 changes: 28 additions & 31 deletions Src/DasherCore/AlphabetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "FileWordGenerator.h"

#include <vector>
#include <sstream>

using namespace Dasher;

Expand All @@ -51,32 +50,30 @@ CAlphabetManager::CAlphabetManager(CSettingsStore *pSettingsStore, CDasherInterf
{
m_pSettingsStore->OnPreParameterChange.Subscribe(this, [this](Parameter parameter, const std::variant<bool, long, std::string>& newValue)
{
switch(parameter) {
case SP_ALPHABET_ID:
const std::string value = std::get<std::string>(newValue);
// Cycle the alphabet history
std::vector<std::string> newHistory;
newHistory.push_back(m_pSettingsStore->GetStringParameter(SP_ALPHABET_ID));
std::string v;
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_1)) != value)
newHistory.push_back(v);
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_2)) != value)
newHistory.push_back(v);
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_3)) != value)
newHistory.push_back(v);
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_4)) != value)
newHistory.push_back(v);

// Fill empty slots.
while (newHistory.size() < 4)
newHistory.push_back("");

m_pSettingsStore->SetStringParameter(SP_ALPHABET_1, newHistory[0]);
m_pSettingsStore->SetStringParameter(SP_ALPHABET_2, newHistory[1]);
m_pSettingsStore->SetStringParameter(SP_ALPHABET_3, newHistory[2]);
m_pSettingsStore->SetStringParameter(SP_ALPHABET_4, newHistory[3]);
break;
}
if(parameter == SP_ALPHABET_ID){
const std::string value = std::get<std::string>(newValue);
// Cycle the alphabet history
std::vector<std::string> newHistory;
newHistory.push_back(m_pSettingsStore->GetStringParameter(SP_ALPHABET_ID));
std::string v;
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_1)) != value)
newHistory.push_back(v);
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_2)) != value)
newHistory.push_back(v);
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_3)) != value)
newHistory.push_back(v);
if ((v = m_pSettingsStore->GetStringParameter(SP_ALPHABET_4)) != value)
newHistory.push_back(v);

// Fill empty slots.
while (newHistory.size() < 4)
newHistory.push_back("");

m_pSettingsStore->SetStringParameter(SP_ALPHABET_1, newHistory[0]);
m_pSettingsStore->SetStringParameter(SP_ALPHABET_2, newHistory[1]);
m_pSettingsStore->SetStringParameter(SP_ALPHABET_3, newHistory[2]);
m_pSettingsStore->SetStringParameter(SP_ALPHABET_4, newHistory[3]);
}
});
}

Expand Down Expand Up @@ -235,7 +232,7 @@ CWordGeneratorBase *CAlphabetManager::GetGameWords() {
///TRANSLATORS: the string "GameTextFile" is the name of a setting in gsettings
/// (or equivalent), and should not be translated. The %s is the value of that
/// setting (this message displayed only if the user has provided a value)
m_pInterface->FormatMessageWithString(_("Note: GameTextFile setting specifies game sentences file '%s' but this does not exist"),gtf.c_str());
m_pInterface->FormatMessage("Note: GameTextFile setting specifies game sentences file '%s' but this does not exist", gtf.c_str());
}
pGen->setAcceptUser(false);
m_pInterface->ScanFiles(pGen, m_pAlphabet->GetTrainingFile());
Expand Down Expand Up @@ -616,12 +613,12 @@ void CAlphabetManager::IterateChildGroups(CAlphNode *pParent, const SGroupInfo *
bool bSymbol = !pCurrentNode //gone past last subgroup
|| i < pCurrentNode->iStart; //not reached next subgroup
const int iStart=i, iEnd = (bSymbol) ? i+1 : pCurrentNode->iEnd;
//uint64 is platform-dependently #defined in DasherTypes.h as an (unsigned) 64-bit int ("__int64" or "long long int")
//uint64_t is platform-dependently #defined in DasherTypes.h as an (unsigned) 64-bit int ("__int64" or "long long int")
unsigned int iLbnd = (((*pCProb)[iStart-1] - (*pCProb)[iMin-1]) *
static_cast<uint64>(CDasherModel::NORMALIZATION)) /
static_cast<uint64_t>(CDasherModel::NORMALIZATION)) /
iRange;
unsigned int iHbnd = (((*pCProb)[iEnd-1] - (*pCProb)[iMin-1]) *
static_cast<uint64>(CDasherModel::NORMALIZATION)) /
static_cast<uint64_t>(CDasherModel::NORMALIZATION)) /
iRange;
if (bSymbol) {
pNewChild = (buildAround) ? buildAround->RebuildSymbol(pParent, i) : CreateSymbolNode(pParent, i);
Expand Down
20 changes: 10 additions & 10 deletions Src/DasherCore/AlphabetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace Dasher {
CNodeManager* mgr() const override;
///Rebuilds this node's parent by recreating the previous 'root' node,
/// then calling RebuildForwardsFromAncestor
CDasherNode *RebuildParent();
CDasherNode *RebuildParent() override;
///Called to build a symbol (leaf) node which is a descendant of the symbol or root node preceding this.
/// Default implementation just calls the manager's CreateSymbolNode method to create a new node,
/// but subclasses can override to graft themselves into the appropriate point beneath the previous node.
Expand Down Expand Up @@ -164,11 +164,11 @@ namespace Dasher {
/// Uniquely, a paragraph symbol can enter two distinct unicode characters
/// (i.e. '\r' and '\n'); every other symbol enters only a single
/// unicode char, even if that might take >1 octet.
int numChars();
int numChars() override;
void TrainSymbol();
void UntrainSymbol();
///Override: true iff pGroup encloses this symbol (according to its start/end symbol#)
bool isInGroup(const SGroupInfo *pGroup);
bool isInGroup(const SGroupInfo *pGroup) override;

public:
double SpeedMul() override;
Expand All @@ -182,20 +182,20 @@ namespace Dasher {
CGroupNode(int iOffset, CDasherScreen::Label* pLabel, CAlphabetManager* pMgr, const SGroupInfo* pGroup);

///Override: if m_pGroup==NULL, i.e. whole/root-of alphabet, cannot rebuild.
virtual CDasherNode *RebuildParent();
virtual CDasherNode *RebuildParent() override;

///Create children of this group node, by traversing the section of the alphabet
/// indicated by m_pGroup.
virtual void PopulateChildren();
virtual int ExpectedNumChildren();
virtual void PopulateChildren() override;
virtual int ExpectedNumChildren() override;

virtual bool GameSearchNode(symbol sym);
std::vector<unsigned int> *GetProbInfo();
virtual bool GameSearchNode(symbol sym) override;
std::vector<unsigned int> *GetProbInfo() override;
///Override: if the group to create is the same as this node's group, return this node instead of creating a new one
virtual CDasherNode *RebuildGroup(CAlphNode* pParent, const SGroupInfo* pInfo);
virtual CDasherNode *RebuildGroup(CAlphNode* pParent, const SGroupInfo* pInfo) override;
protected:
///Override: true if pGroup encloses this one (by start/end symbol#)
bool isInGroup(const SGroupInfo *pGroup);
bool isInGroup(const SGroupInfo *pGroup) override;

public:
const ColorPalette::Color& getLabelColor(const ColorPalette* colorPalette) override;
Expand Down
2 changes: 1 addition & 1 deletion Src/DasherCore/ColorIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void CColorIO::RelinkParents()
std::string allVisited;
for(std::string& s : visited) allVisited += s + "->";
allVisited += current->ParentPalette->PaletteName;
m_pMsgs->FormatMessageWithString("Found cycle while parsing color-scheme parenting: %s", allVisited.c_str());
m_pMsgs->FormatMessage("Found cycle while parsing color-scheme parenting: %s", allVisited.c_str());
KnownPalettes.erase(current->ParentPalette->PaletteName);
RelinkParents(); //relink as now a palette was removed
return;
Expand Down
14 changes: 7 additions & 7 deletions Src/DasherCore/ConversionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,33 @@ namespace Dasher {

class CConvNode : public CDasherNode {
public:
CConversionManager *mgr() const {return m_pMgr;}
CConversionManager *mgr() const override {return m_pMgr;}
CConvNode(int iOffset, CDasherScreen::Label *pLabel, CConversionManager *pMgr);
///
/// Provide children for the supplied node
///

virtual void PopulateChildren();
virtual int ExpectedNumChildren();
virtual void SetFlag(int iFlag, bool bValue);
virtual void PopulateChildren() override;
virtual int ExpectedNumChildren() override;
virtual void SetFlag(int iFlag, bool bValue) override;

virtual ~CConvNode();

///Attempts to fill vContextSymbols with the context that would exist _after_ this node has been entered
void GetContext(CDasherInterfaceBase *pInterface, const CAlphabetMap *pAlphabetMap, std::vector<symbol> &vContextSymbols, int iOffset, int iLength);
void GetContext(CDasherInterfaceBase *pInterface, const CAlphabetMap *pAlphabetMap, std::vector<symbol> &vContextSymbols, int iOffset, int iLength) override;

///
/// Called whenever a node belonging to this manager first
/// moves under the crosshair
///

virtual void Do();
virtual void Do() override;

///
/// Called when a node is left backwards
///

virtual void Undo();
virtual void Undo() override;
const ColorPalette::Color& getLabelColor(const ColorPalette* colorPalette) override;
const ColorPalette::Color& getOutlineColor(const ColorPalette* colorPalette) override;
const ColorPalette::Color& getNodeColor(const ColorPalette* colorPalette) override;
Expand Down
49 changes: 25 additions & 24 deletions Src/DasherCore/DasherButtons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "DasherButtons.h"
#include "DasherScreen.h"
#include "DasherInterfaceBase.h"
#include <valarray>


using namespace Dasher;
Expand All @@ -31,21 +30,22 @@ void CDasherButtons::KeyDown(unsigned long iTime, Keys::VirtualKey Key, CDasherV

if(m_bMenu) {
switch(Key) {
case Keys::Button_1:
case Keys::Button_4:
m_bDecorationChanged = true;
++iActiveBox;
if(iActiveBox == m_iNumBoxes)
iActiveBox = 0;
break;
case Keys::Button_2:
case Keys::Button_3:
case Keys::Primary_Input:
m_bDecorationChanged = true;
ScheduleZoom(pModel, m_pBoxes[iActiveBox].iTop, m_pBoxes[iActiveBox].iBottom);
if(iActiveBox != m_iNumBoxes-1)
iActiveBox = 0;
break;
case Keys::Button_1:
case Keys::Button_4:
m_bDecorationChanged = true;
++iActiveBox;
if(iActiveBox == m_iNumBoxes)
iActiveBox = 0;
break;
case Keys::Button_2:
case Keys::Button_3:
case Keys::Primary_Input:
m_bDecorationChanged = true;
ScheduleZoom(pModel, m_pBoxes[iActiveBox].iTop, m_pBoxes[iActiveBox].iBottom);
if(iActiveBox != m_iNumBoxes-1)
iActiveBox = 0;
break;
default: break;
}
}
else {
Expand All @@ -55,14 +55,15 @@ void CDasherButtons::KeyDown(unsigned long iTime, Keys::VirtualKey Key, CDasherV
}

void CDasherButtons::DirectKeyDown(unsigned long iTime, Keys::VirtualKey Key, CDasherView *pView, CDasherModel *pModel) {
if(Key == Keys::Primary_Input) // Ignore mouse events
return;
if(Key == Keys::Button_1)
iActiveBox = m_iNumBoxes - 1;
else if(Key <= m_iNumBoxes)
iActiveBox = Key-2;
else
iActiveBox = m_iNumBoxes-2;
if(Key == Keys::Primary_Input) return; // Ignore mouse events

if(Key == Keys::Button_1) {
iActiveBox = m_iNumBoxes - 1;
} else if(Key <= m_iNumBoxes) {
iActiveBox = Key-2;
} else {
iActiveBox = m_iNumBoxes-2;
}

ScheduleZoom(pModel, m_pBoxes[iActiveBox].iTop,m_pBoxes[iActiveBox].iBottom);
}
Expand Down
37 changes: 19 additions & 18 deletions Src/DasherCore/DasherInterfaceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
#include "FileUtils.h"
#include "SmoothingFilter.h"
#include "../DasherCore/FileLogger.h"
#ifdef _DEBUG
const eLogLevel g_iLogLevel = logDEBUG;
#ifndef NDEBUG
const eLogLevel g_iLogLevel = eLogLevel::logDEBUG;
const int g_iLogOptions = logTimeStamp | logDateStamp | logDeleteOldFile;
#else
const eLogLevel g_iLogLevel = logNORMAL;
const eLogLevel g_iLogLevel = eLogLevel::logNORMAL;
const int g_iLogOptions = logTimeStamp | logDateStamp;
#endif

Expand Down Expand Up @@ -334,7 +334,7 @@ void CDasherInterfaceBase::EnterGameMode(CGameModule *pGameModule) {
} else {
///TRANSLATORS: %s is the name of the alphabet; the string "GameTextFile"
/// refers to a setting name in gsettings or equivalent, and should not be translated.
FormatMessageWithString(_("Could not find game sentences file for %s - check alphabet definition, or override with GameTextFile setting"),
FormatMessage("Could not find game sentences file for %s - check alphabet definition, or override with GameTextFile setting",
m_pNCManager->GetAlphabet()->GetID().c_str());
delete pGameModule; //does nothing if null.
}
Expand Down Expand Up @@ -775,20 +775,21 @@ void CDasherInterfaceBase::CreateModules() {
void CDasherInterfaceBase::GetPermittedValues(Parameter parameter, std::vector<std::string> &vList) {
// TODO: Deprecate direct calls to these functions
switch (parameter) {
case SP_ALPHABET_ID:
DASHER_ASSERT(m_AlphIO != NULL);
m_AlphIO->GetAlphabets(&vList);
break;
case SP_COLOUR_ID:
DASHER_ASSERT(m_ColourIO != NULL);
m_ColorIO->GetKnownPalettes(&vList);
break;
case SP_INPUT_FILTER:
m_pModuleManager->ListInputMethodModules(vList);
break;
case SP_INPUT_DEVICE:
m_pModuleManager->ListInputDeviceModules(vList);
break;
case SP_ALPHABET_ID:
DASHER_ASSERT(m_AlphIO != NULL);
m_AlphIO->GetAlphabets(&vList);
break;
case SP_COLOUR_ID:
DASHER_ASSERT(m_ColourIO != NULL);
m_ColorIO->GetKnownPalettes(&vList);
break;
case SP_INPUT_FILTER:
m_pModuleManager->ListInputMethodModules(vList);
break;
case SP_INPUT_DEVICE:
m_pModuleManager->ListInputDeviceModules(vList);
break;
default: break;
}
}

Expand Down
Loading