diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp index aa1eddeff1..aa2191e783 100644 --- a/src/apps/deskcalc/CalcView.cpp +++ b/src/apps/deskcalc/CalcView.cpp @@ -1222,10 +1222,10 @@ CalcView::_ParseCalcDesc(const char** keypadDescription) strlcpy(key->label, B_TRANSLATE_NOCOLLECT(p), sizeof(key->label)); // set code - if (strcmp(key->label, "=") == 0) + if (strcmp(p, "=") == 0) strlcpy(key->code, "\n", sizeof(key->code)); else - strlcpy(key->code, key->label, sizeof(key->code)); + strlcpy(key->code, p, sizeof(key->code)); // set keymap if (strlen(key->label) == 1) @@ -1254,37 +1254,35 @@ CalcView::_PressKey(int key) assert(key < (fRows * fColumns)); assert(key >= 0); - if (strcmp(fKeypad[key].label, B_TRANSLATE_COMMENT("BS", - "Key label, 'BS' means backspace")) == 0) { + if (strcmp(fKeypad[key].code, "BS") == 0) { // BS means backspace fExpressionTextView->BackSpace(); - } else if (strcmp(fKeypad[key].label, B_TRANSLATE_COMMENT("C", - "Key label, 'C' means clear")) == 0) { + } else if (strcmp(fKeypad[key].code, "C") == 0) { // C means clear fExpressionTextView->Clear(); - } else if (strcmp(fKeypad[key].label, B_TRANSLATE("acos")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("asin")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("atan")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("cbrt")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("ceil")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("cos")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("cosh")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("exp")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("floor")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("log")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("ln")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("sin")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("sinh")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("sqrt")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("tan")) == 0 - || strcmp(fKeypad[key].label, B_TRANSLATE("tanh")) == 0) { - int32 labelLen = strlen(fKeypad[key].label); + } else if (strcmp(fKeypad[key].code, "acos") == 0 + || strcmp(fKeypad[key].code, "asin") == 0 + || strcmp(fKeypad[key].code, "atan") == 0 + || strcmp(fKeypad[key].code, "cbrt") == 0 + || strcmp(fKeypad[key].code, "ceil") == 0 + || strcmp(fKeypad[key].code, "cos") == 0 + || strcmp(fKeypad[key].code, "cosh") == 0 + || strcmp(fKeypad[key].code, "exp") == 0 + || strcmp(fKeypad[key].code, "floor") == 0 + || strcmp(fKeypad[key].code, "log") == 0 + || strcmp(fKeypad[key].code, "ln") == 0 + || strcmp(fKeypad[key].code, "sin") == 0 + || strcmp(fKeypad[key].code, "sinh") == 0 + || strcmp(fKeypad[key].code, "sqrt") == 0 + || strcmp(fKeypad[key].code, "tan") == 0 + || strcmp(fKeypad[key].code, "tanh") == 0) { + int32 labelLen = strlen(fKeypad[key].code); int32 startSelection = 0; int32 endSelection = 0; fExpressionTextView->GetSelection(&startSelection, &endSelection); if (endSelection > startSelection) { // There is selected text, put it inbetween the parens - fExpressionTextView->Insert(startSelection, fKeypad[key].label, + fExpressionTextView->Insert(startSelection, fKeypad[key].code, labelLen); fExpressionTextView->Insert(startSelection + labelLen, "(", 1); fExpressionTextView->Insert(endSelection + labelLen + 1, ")", 1); @@ -1295,7 +1293,7 @@ CalcView::_PressKey(int key) endSelection + labelLen + 2, endSelection + labelLen + 2); } else { // There is no selected text, insert at the cursor location - fExpressionTextView->Insert(fKeypad[key].label); + fExpressionTextView->Insert(fKeypad[key].code); fExpressionTextView->Insert("()"); // Put the cursor inside the parens so you can enter an argument // Need to cast to BTextView because Select() is protected