Commit graph

25 commits

Author SHA1 Message Date
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
sSt3lla 6b72fc0924 Calculator: Convert DeprecatedString to String 2023-11-17 17:17:00 +00:00
Samuel Eisenhandler c5360b1a5f Calculator: Treat constants and pasted numbers as input
Constants and pasted numbers leave Keypad in the External
state which causes subsequent operations to be performed
without an argument.
2023-02-05 08:07:45 +00:00
Timothy Flynn 0ddc2e1f50 LibCrypto+Everywhere: Rename *BigInteger::to_base to to_base_deprecated 2023-01-15 01:00:20 +00:00
Karol Baraniecki 21cc8f65f5 Calculator: Support chaining and repeating operations
The calculator now supports chaining (hitting "1+2+3=" shows "6"
instead of "5") and repeating ("2+2===" shows "8") operations. :^)
2022-12-31 00:07:13 +01:00
Karol Baraniecki ef9fd6c286 Calculator: Fix which digits get animated when pressing keyboard keys
Previously every digit press would appear like "0" was pressed on the
keypad.
2022-12-31 00:07:13 +01:00
Linus Groh 57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh 6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Lucas CHOLLET 2ff773a6ba Calculator: Add a Shrinking action
This action allow the user to shrink a number to a finite number of
decimal.
2022-10-03 15:12:47 -04:00
Lucas CHOLLET e3b22c395d Calculator: Add a "Custom" entry to the rounding menu
This entry pop a dialog to ask the user to enter a value. The Calculator
will automatically put itself in this mode if you enter a number with
more digits in the fractional part than the actual maximum length.
2022-10-03 15:12:47 -04:00
Lucas CHOLLET de568f87fd Calculator: Add a Rounding menu
This menu has three actions. Each one of them enable a different level
of rounding: to 0, 2 or 4 digits.
2022-10-03 15:12:47 -04:00
Lucas CHOLLET 53eb35caba Calculator: Change internal representation to support perfect division
The purpose of this patch is to support addition, subtraction,
multiplication and division without using conversion to double. To this
end, we use the BigFraction class of LibCrypto. With this solution, we
can store values without any losses and forward rounding as the last
step before displaying.
2022-09-15 14:08:21 +01:00
sin-ack c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
Lenny Maiorani 160bda7228 Applications: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-02-14 22:06:55 +00:00
Hendiadyoin1 3e135f347f Userland: Use AK::pow<I> where applicable 2022-02-06 17:52:33 +00:00
creator1creeper1 8f552c9979 Calculator: Use KeypadValue class instead of double
Calculator now uses the KeypadValue class instead of double in
its internal calculations. By not constantly converting to
double back-and-forth, we do not use precision simply by, for
example, negating a number. This fixes #7484.
2021-08-03 19:12:06 +04:30
Gunnar Beutner 3bbe86d8ea Everywhere: Prefer using "..."sv over StringView { "..." } 2021-07-04 14:24:03 +02:00
Max Wipfli 6837634f31 Calculator: Remove unused headers 2021-05-23 23:18:54 +01:00
Max Wipfli bb38328d39 Calculator: Fix behavior when entering number starting with decimal
This fixes a bug where entering a number like ".15" would result in "15"
instead of "0.15"
2021-05-23 23:18:54 +01:00
Max Wipfli 7b53ca5309 Calculator: Use Checked to ensure entered values do not overflow
This replaces the types of m_int_value and m_frac_value with
Checked<u64> which makes it possible to check if the value overflowed
when entering a digit. If that happens, the digit will just be ignored.

This fixes #1263.
2021-05-23 23:18:54 +01:00
Max Wipfli 7a5407982f Calculator: Show decimal point immediately when typed 2021-05-23 23:18:54 +01:00
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling 5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
AnotherTest 7c2754c3a6 AK+Kernel+Userland: Enable some more compiletime format string checks
This enables format string checks for three more functions:
- String::formatted()
- Builder::appendff()
- KBufferBuilder::appendff()
2021-02-23 13:59:33 +01:00
Andreas Kling dc28c07fa5 Applications: Move to Userland/Applications/ 2021-01-12 12:05:23 +01:00
Renamed from Applications/Calculator/Keypad.cpp (Browse further)