Do not hide expression when user presses Enter or = (#695)
* #653 Do not hide expression on EQU operation * #653 Clear expression, when user makes an action * #653 Fixed UI tests * #653 Review fixes
This commit is contained in:
@@ -325,12 +325,6 @@ void CHistoryCollector::AddUnaryOpToHistory(int nOpCode, bool fInv, ANGLE_TYPE a
|
||||
// history of equations
|
||||
void CHistoryCollector::CompleteHistoryLine(wstring_view numStr)
|
||||
{
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
|
||||
}
|
||||
|
||||
if (nullptr != m_pHistoryDisplay)
|
||||
{
|
||||
unsigned int addedItemIndex = m_pHistoryDisplay->AddToHistory(m_spTokens, m_spCommands, numStr);
|
||||
@@ -343,6 +337,16 @@ void CHistoryCollector::CompleteHistoryLine(wstring_view numStr)
|
||||
ReinitHistory();
|
||||
}
|
||||
|
||||
void CHistoryCollector::CompleteEquation(std::wstring_view numStr)
|
||||
{
|
||||
// Add only '=' token and not add EQU command, because
|
||||
// EQU command breaks loading from history (it duplicate history entries).
|
||||
IchAddSzToEquationSz(CCalcEngine::OpCodeToString(IDC_EQU), -1);
|
||||
|
||||
SetExpressionDisplay();
|
||||
CompleteHistoryLine(numStr);
|
||||
}
|
||||
|
||||
void CHistoryCollector::ClearHistoryLine(wstring_view errStr)
|
||||
{
|
||||
if (errStr.empty()) // in case of error let the display stay as it is
|
||||
|
@@ -82,6 +82,15 @@ void CCalcEngine::ClearTemporaryValues()
|
||||
m_bError = false;
|
||||
}
|
||||
|
||||
void CCalcEngine::ClearDisplay()
|
||||
{
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
|
||||
}
|
||||
}
|
||||
|
||||
void CCalcEngine::ProcessCommand(OpCode wParam)
|
||||
{
|
||||
if (wParam == IDC_SET_RESULT)
|
||||
@@ -109,6 +118,12 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
m_nTempCom = (int)wParam;
|
||||
}
|
||||
|
||||
// Clear expression shown after = sign, when user do any action.
|
||||
if (!m_bNoPrevEqu)
|
||||
{
|
||||
ClearDisplay();
|
||||
}
|
||||
|
||||
if (m_bError)
|
||||
{
|
||||
if (wParam == IDC_CLEAR)
|
||||
@@ -403,8 +418,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetParenthesisNumber(0);
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
|
||||
ClearDisplay();
|
||||
}
|
||||
|
||||
m_HistoryCollector.ClearHistoryLine(wstring());
|
||||
@@ -494,12 +508,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
|
||||
if (!m_bError)
|
||||
{
|
||||
wstring groupedString = GroupDigitsPerRadix(m_numberString, m_radix);
|
||||
m_HistoryCollector.CompleteHistoryLine(groupedString);
|
||||
if (nullptr != m_pCalcDisplay)
|
||||
{
|
||||
m_pCalcDisplay->SetExpressionDisplay(
|
||||
make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
|
||||
}
|
||||
m_HistoryCollector.CompleteEquation(groupedString);
|
||||
}
|
||||
|
||||
m_bChangeOp = false;
|
||||
|
@@ -133,24 +133,11 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring expressionSuffix{};
|
||||
hr = GetExpressionSuffix(&expressionSuffix);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
expression->append(expressionSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
ResultCode GetExpressionSuffix(_Out_ std::wstring* suffix)
|
||||
{
|
||||
*suffix = L" =";
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<TType> m_vector;
|
||||
};
|
||||
|
@@ -176,6 +176,7 @@ private:
|
||||
void DisplayAnnounceBinaryOperator();
|
||||
void SetPrimaryDisplay(const std::wstring& szText, bool isError = false);
|
||||
void ClearTemporaryValues();
|
||||
void ClearDisplay();
|
||||
CalcEngine::Rational TruncateNumForIntMath(CalcEngine::Rational const& rat);
|
||||
CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, uint32_t op);
|
||||
CalcEngine::Rational DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs);
|
||||
|
@@ -31,6 +31,7 @@ public:
|
||||
void EnclosePrecInversionBrackets();
|
||||
bool FOpndAddedToHistory();
|
||||
void CompleteHistoryLine(std::wstring_view numStr);
|
||||
void CompleteEquation(std::wstring_view numStr);
|
||||
void ClearHistoryLine(std::wstring_view errStr);
|
||||
int AddCommand(_In_ const std::shared_ptr<IExpressionCommand>& spCommand);
|
||||
void UpdateHistoryExpression(uint32_t radix, int32_t precision);
|
||||
|
Reference in New Issue
Block a user