Commit graph

4655 commits

Author SHA1 Message Date
Timothy Flynn
0b30a0febb Solitaire: Only update high score after a victorious game
Doesn't make much sense to update the high score on a lost game.
2021-05-25 21:20:50 +02:00
Gunnar Beutner
95401d2ca2 Hearts: Don't advance the game's state when an animation is playing
Previously we'd end up cancelling an animation that was still playing
when the user selects a card.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
fc99aa92bd Hearts: Fix animations that get stuck "mid-flight"
When an animation is stopped the cards should be moved to their final
position anyway. Otherwise they might end up getting stuck in the
middle of the animation.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
87ace131bc Hearts: Add support for playing more than one hand
This changes the game so that more than one hand can be played. Once
one player has 100 or more points the game ends. A score card is shown
between each hand.

Fixes #7374.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
e636ed43eb Hearts: Let the AI continuously play games
When there are no human players (toggled with Shift-F10) the AI will
continuously start new games when the current game has finished.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
ac1eba2f7c Hearts: Implement passing cards to other players
Fixes #7375.
2021-05-25 21:05:35 +02:00
Gunnar Beutner
fab073f33c Hearts: Move card click handler into a separate method 2021-05-25 21:05:35 +02:00
Gunnar Beutner
89d38b7e94 Hearts: Move sorting helper from Player::pick_lead_card into a method 2021-05-25 21:05:35 +02:00
Gunnar Beutner
4ba9cc82c0 Hearts: Move code to reposition cards into a separate method 2021-05-25 21:05:35 +02:00
Gunnar Beutner
9a6c6a98e5 Hearts: Move round initialization into a separate method 2021-05-25 21:05:35 +02:00
Gunnar Beutner
4e3a1f2da9 Hearts: Move hand sorting functionality into a method 2021-05-25 21:05:35 +02:00
Andreas Kling
6da481205b LibTest: Use fstatat() to speed up iterate_directory_recursively()
Employ the same technique as SpaceAnalyzer to avoid doing full path
resolution in the kernel over an over. Starting each path resolution
from the base of the directory iterator (using its fd) is significantly
faster and reduces test-js runtime by ~3%.
2021-05-25 20:53:59 +02:00
Andreas Kling
cfe3895991 LibJS: Fix broken dbgln_if(HEAP_DEBUG) 2021-05-25 19:44:32 +02:00
Andreas Kling
e6f8a5111f Profiler: Hide timeline scrollbars if we don't need them :^) 2021-05-25 19:04:17 +02:00
Andreas Kling
2de9139532 LibJS: Fix clang-tidy warnings about redundant types in Heap.cpp 2021-05-25 19:04:15 +02:00
Andreas Kling
679fc3066c LibJS: Fix clang-tidy warnings about unnecessary move()s in VM.cpp 2021-05-25 18:52:00 +02:00
Andreas Kling
47a4b2ba9f LibJS: Make Value::as_cell() return a Cell& 2021-05-25 18:48:11 +02:00
Andreas Kling
0de954e86b LibJS: Make Cell::Visitor::visit_impl() take a Cell&
Passing a null cell pointer is not supported.
2021-05-25 18:39:01 +02:00
Andreas Kling
789d20ebb7 LibJS: Replace Cell live bit with a cell state
So far we only have two states: Live and Dead. In the future, we can
add additional states to support incremental sweeping and/or multi-
stage cell destruction.
2021-05-25 18:37:37 +02:00
Andreas Kling
91656d63c7 LibJS: Inline Cell::Visitor::visit() functions
This allows the calls to MarkingVisitor::visit_impl() during GC to be
devirtualized in Heap::mark_live_cells().
2021-05-25 18:18:48 +02:00
Gunnar Beutner
c81b3e1ee3 LibC: Implement strerror_r()
This implements the XSI-compliant version of strerror_r() - as opposed
to the GNU-specific variant.

The function explicitly saves errno so as to not accidentally change it
with one of the calls to other functions.
2021-05-25 17:36:02 +02:00
Gunnar Beutner
3526fbbc5f LibC: Add definition for PRIxPTR 2021-05-25 17:36:02 +02:00
Brendan Coles
16094baffc HexEditor: Construct Find dialog from GML 2021-05-25 13:17:28 +01:00
Andreas Kling
7997c02b6c ls: Fix incorrect -t sort order
Dr. POSIX says -t should sort the output by mtime ascending.
2021-05-25 13:23:17 +02:00
Tobias Christiansen
820224bb48 LibWeb: Match the :not pseudoclass
When a Selector features a :not() pseudoclass we now check whether the
current element matches with the given selector in the :not and act
accordingly.
2021-05-24 22:10:08 +01:00
Tobias Christiansen
1ab82afee6 LibWeb: Add :not pseudoclass to the CSS parser
The selector given in the :not() is stored in the SimpleSelector as a
String.
2021-05-24 22:10:08 +01:00
Matthew Olsson
78f3bad7e6 LibPDF: Pre-initialize common FlyStrings in CommonNames.h 2021-05-25 00:24:09 +04:30
Matthew Olsson
cf3eb27108 PDFViewer: Add a toolbar
The toolbar has an option to toggle the sidebar, a number input to
set the current page, and two buttons to go up and down by one page
2021-05-25 00:24:09 +04:30
Matthew Olsson
cea7dbce42 PDFViewer: Add a tab bar with outlines and thumbnails
Outlines are in theory implemented (though I'm having trouble finding
a simple PDF with outlines to test it on), and thumbnails are not.
2021-05-25 00:24:09 +04:30
Matthew Olsson
67b65dffa8 LibPDF: Handle string encodings
Strings can be encoded in either UTF16-BE or UTF8. In either case,
there are a few initial bytes which specify the encoding that must
be checked and also removed from the final string.
2021-05-25 00:24:09 +04:30
Matthew Olsson
a08922d2f6 LibPDF: Parse outline structures 2021-05-25 00:24:09 +04:30
Matthew Olsson
be6e4b6f3c LibPDF: Store indirect value refs in Value objects
IndirectValueRef is so simple that it can be stored directly in the
Value class instead of being heap allocated.

As the comment in Value says, however, in theory the max bits needed to
store is 48 (16 for the generation index and 32(?) for the object
index), but 32 should be good enough for now. We can increase it to u64
later if necessary.
2021-05-25 00:24:09 +04:30
Matthew Olsson
534a2e95d2 LibPDF: Add basic color space support to the renderer
This commit only supports the three most basic color spaces:
DeviceGray, DeviceRGB, and DeviceCMYK
2021-05-25 00:24:09 +04:30
Matthew Olsson
f4941f5940 LibGfx: Add Color::from_cmyk 2021-05-25 00:24:09 +04:30
Matthew Olsson
f2d2f3fae7 LibPDF: Add a very poor path clipping implementation
This completely ignores the actual path and just uses its bounding box,
since our painter doesn't support clipping to paths.
2021-05-25 00:24:09 +04:30
Matthew Olsson
b6c884d20c LibGfx: Add Path::clear 2021-05-25 00:24:09 +04:30
Matthew Olsson
bf96ad674c LibPDF: Implement stubs for all graphical commands 2021-05-25 00:24:09 +04:30
Matthew Olsson
477e3946e5 LibPDF: Add support for stream filters
This commit also splits up StreamObject into PlainTextStreamObject and
EncodedStreamObject, which is essentially just a stream object which
does not own its bytes vs one which does.
2021-05-25 00:24:09 +04:30
Matthew Olsson
97cc482087 LibPDF: Make Reader::dump_state a bit more readable 2021-05-25 00:24:09 +04:30
Matthew Olsson
8c7ebc7a3f LibPDF: Do not assume value is an object in parse_indirect_value 2021-05-25 00:24:09 +04:30
Daniel Bertalan
e401ff0802 Userland: Fix stty not setting control characters
`AK::Result` does not work if both the error and value types are
integers.
2021-05-24 20:14:21 +01:00
Brendan Coles
7982f9aa70 HexEditor: Store UI layout preferences in config file 2021-05-24 20:11:41 +01:00
Jelle Raaijmakers
dbbc583860 LibGUI/AbstractView: Expose activates_on_selection 2021-05-24 23:31:42 +04:30
Ali Mohammad Pur
b2ef18d538 LibLine+Shell: Allow some programs to modify the current termios
This setting can be controlled by setting the
PROGRAMS_ALLOWED_TO_MODIFY_DEFAULT_TERMIOS _local_ shell variable to a
list containing such programs.
2021-05-24 23:26:49 +04:30
Ali Mohammad Pur
e318f12263 LibLine: Add bracketed paste mode support
This mode makes the editor insert all the "pasted" text into the buffer
without interpreting it in any way.
2021-05-24 23:26:49 +04:30
Stephan Unverwerth
e54d96d53e LibGL: Implement glReadPixels() 2021-05-24 19:03:25 +01:00
Stephan Unverwerth
d6c84ca4df LibGL: Implement glReadPixels() stub with argument validation 2021-05-24 19:03:25 +01:00
Stephan Unverwerth
24e74750d5 LibGL: Implement glReadBuffer() 2021-05-24 19:03:25 +01:00
Daniel Bertalan
0c6f019285 LibVT: Fix out-of bounds line insert
Unless DECOM mode is enabled, the cursor positions are measured from the
top left corner of the screen. We counted from the top margin, causing
line inserts in `vim` to go out-of-bounds and crash the terminal.
2021-05-24 22:26:54 +04:30
Daniel Bertalan
6465f87827 LibVT: Fix issues running nano
This commit fixes 3 correctness issues with the ANSI escape sequence
handling logic:
1. Default parameters were not handled correctly: the specification says
   that 0-valued CSI escape sequence parameters should take their
   default values.
2. We did not call `scroll_{up, down}` when encountering RI/IND commands
   that reached the scroll margins. This caused nano to only scroll the
   first line.
2021-05-24 22:26:54 +04:30
Daniel Bertalan
146bd794eb LibVT: Add Alternate Screen Buffer support
The Alternate Screen Buffer is used by full-screen terminal applications
(like `vim` and `nano`). Its data is stored separately from the normal
buffer, therefore after applications using it exit, everything looks
like it was before, the bottom of their interfaces isn't visible. An
interesting feature is that it does not support scrollback, so it
consumes less memory by not having to allocate lines for history.

Because of the need to save and restore state between the switches, some
correctness issues relating to it were also fixed in this commit.
2021-05-24 22:26:54 +04:30
Valtteri Koskivuori
cb8d0c8d0d LibCore+Userland: Add 13 more detectable file types
This patch adds 13 new detectable file formats, which are as follows in
alphabetical order:
.blend, .isz, ext* filesystem, Lua bytecode, Matroska container, NES
ROM, .pdf, qcow image, .rtf, WebAssembly bytecode, Windows 3.1X/95
compressed archive and raw zlib stream

Some are a tad esoteric, but the more file types we detect, the more
useful this utility becomes! :^)
2021-05-24 18:55:56 +01:00
Tobias Christiansen
9a1ac662f1 LibWeb: Don't try to load anything if src is empty in <img>
Previously we tried to load "" if the src was present but empty and
essentially only waited for RequestServer to time out.
2021-05-24 17:45:09 +01:00
Daniel Bertalan
708f835477 LibVT: Implement Bracketed Paste Mode
This mode allow us to escape any data that was not directly typed by the
user. `vim` currently uses this. If we implement it in the shell, we
could prevent newlines from being injected into the shell by pasting
text or dragging files into it (see #7276).
2021-05-24 16:58:57 +04:30
Daniel Bertalan
ee24f2eb2d LibVT: Add title stack support
This feature allows applications to reset the window title once they
exited. It is used by `vim` if `set title` is enabled.
2021-05-24 16:58:57 +04:30
Jean-Baptiste Boric
e4394b1605 LibGfx: Use anonymous buffer instead of raw anon_fd for Gfx::Bitmap
Instead of using a low-level, proprietary API inside LibGfx, let's use
Core::AnonymousBuffer which already abstracts anon_fd and offers a
higher-level API too.
2021-05-24 13:31:01 +02:00
Andreas Kling
de395a3df2 AK+Everywhere: Consolidate String::index_of() and String::find()
We had two functions for doing mostly the same thing. Combine both
of them into String::find() and use that everywhere.

Also add some tests to cover basic behavior.
2021-05-24 11:59:18 +02:00
Daniel Bertalan
875a2cbb71 LibVT+Kernel: Add support for setting cursor styles
This commit introduces support for 3 new escape sequences:
1. Stop blinking cursor mode
2. `DECTCEM` mode (enable/disable cursor)
3. `DECSCUSR` (set cursor style)

`TerminalWidget` now supports the following cursor types: block,
underline and vertical bar. Each of these can blink or be steady.
`VirtualConsole` ignores these (just as we were doing before).
2021-05-24 11:27:58 +02:00
Thomas Keppler
7dfc804d7d FontSettingsWidget: Reduce duplication in Label setup code
Pull out the Label updating code into its own function.
Ideally, we should probably transform this code to use its own widget
rather than doing this all in-line.
I.e., having a `FontSettingWidget` that that ties the FontPicker, Label
and Button into its own little widget, so that we can stay extendible in
the main widget and reduce duplication some more!
2021-05-24 09:08:23 +01:00
Thomas Keppler
a1f8c10fe5 FontSettingsWidget: Promote Labels as instance members
In order to not resolve the widgets twice, we capture them in ivars.
2021-05-24 09:08:23 +01:00
Thomas Keppler
883d0d2466 FontSettingsWidget: Display the default (fixed-width) font's name
Previously, the font was applied to the Labels but the name wasn't
updated on initial startup.
This meant that the Label's content was only correct in the default
state but not if the user changed the defaults.
2021-05-24 09:08:23 +01:00
Andreas Kling
d3f298c592 LibIPC: Fix unaligned u32 access in drain_messages_from_peer()
Caught by userspace UBSAN. :^)
2021-05-24 09:04:22 +02:00
Andreas Kling
8f2425125e LibGfx+Base: Tweak bitmap fonts to ensure glyph data is 4-byte aligned
When building userland with UBSAN enabled (#7434), we were getting
spammed to death by unaligned access errors.

Fix these by adding 2 bytes of padding to the FontFileHeader struct,
and adjusting all our font files to match the new format. :^)
2021-05-24 08:18:34 +02:00
Jelle Raaijmakers
22d8778437 LibGfx/Matrix: Add inverse() and friends
Matrix inversion comes in quite handy in 3D projections, so let's add
`Matrix<N,T>.inverse()`. To support matrix inversion, the following
methods are added:

* `Matrix.first_minor()`
  See: https://en.wikipedia.org/wiki/Minor_(linear_algebra)
* `Matrix.adjugate()`
  See: https://en.wikipedia.org/wiki/Adjugate_matrix
* `Matrix.determinant()`
  See: https://en.wikipedia.org/wiki/Determinant
* `Matrix.inverse()`
  See: https://en.wikipedia.org/wiki/Invertible_matrix
* `Matrix.operator/()`
  To support easy matrix division :-)

Code loosely based on an implementation listed here:
https://www.geeksforgeeks.org/adjoint-inverse-matrix/
2021-05-24 00:33:18 +01:00
Lynn
d3aae59478 tar: Ignore "extended headers"
Looking around online, it seems like this is normally a bit of
metadata that the extract operation can safely ignore.
2021-05-24 00:01:01 +01:00
Marcus Nilsson
6b85c7647c
Browser: Add context menu with history for back/forward button
Right clicking on back or forward will now show a context menu with
URLs to navigate to. Also added an optional argument for the number of
steps in go_back() and go_forward().
2021-05-23 23:58:00 +01: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
Max Wipfli
2675d25453 Calculator: Handle keydown events correctly with all keyboard layouts
This changes the keydown_event handler to use codepoints instead of key
codes for comparison if possible. This is so the functionality still
works as intended with keyboard layouts where e.g. typing '+' actually
results in KeyCode::Key_ExclamationPoint rather than KeyCode::Key_Plus.

This also removes the unnecessary call to atoi().
2021-05-23 23:18:54 +01:00
Tobias Christiansen
b53dac6e88 LibWeb: Add support for more pseudoclasses
:disabled, :enabled and :checked are now parsed and matched. There
surely are more nuances to consider.
2021-05-24 02:14:11 +04:30
Andreas Kling
4f4cde2379 LibDebug: Pre-allocate capacity for the LineProgram::LineInfo vector
This shaves another ~15% off of "bt 12" on my machine :^)
2021-05-23 23:17:26 +02:00
Andreas Kling
0bf3df28b9 LibDebug: Memoize resolved paths in DebugInfo::prepare_lines()
When loading debug info, we encounter the same filename over and over
(since files usually have many lines!) and we were wasting a ton of
time re-checking if the filename was part of the Toolchain or libgcc,
along with some other checks.

This patch makes prepare_lines() significantly faster by memoizing
the result of these checks per filename.

This makes "bt 12" ~25% faster (from 850ms to 650ms on my machine.) :^)
2021-05-23 23:01:11 +02:00
Josh Perry
d27616cf36 Hearts: Allow player to set their name
Added a new settings dialog to Hearts with a textbox to allow the
player to set a name, which is persisted in the Hearts config file.
2021-05-23 20:43:53 +01:00
Brian Gianforcaro
e706de8f91 LibM: Fix linking with LibM when compiling Userland without -O2
While playing with conditionally disabling -O2 optimization when
building the Userland subdirectory, I discovered that we can no longer
link errors without -O2. This happens as LibM.so doesn't link to
anything else, resulting in no stack protector implementation. It
appears that optimization somehow avoids this problem?

To fix this inject LibC/ssp.cpp as we do with in dynamic loader.
2021-05-23 20:17:00 +01:00
Daniel Bertalan
d23425bfc0 LibC: Use \010 for erasing instead of \0177
We ignore \0177 in the terminal -- as the ANSI standard dictates.

Fixes #7415
2021-05-23 19:32:31 +02:00
Gunnar Beutner
39f0739381 LibC+UE: Keep more unused chunked blocks around
Previously each malloc size class would keep around a limited number of
unused blocks which were marked with MADV_SET_VOLATILE which could then
be reinitialized when additional blocks were needed.

This changes malloc() so that it also keeps around a number of blocks
without marking them with MADV_SET_VOLATILE. I termed these "hot"
blocks whereas blocks which were marked as MADV_SET_VOLATILE are called
"cold" blocks because they're more expensive to reinitialize.

In the worst case this could increase memory usage per process by
1MB when a program requests a bunch of memory and frees all of it.

Also, in order to make more efficient use of these unused blocks
they're now shared between size classes.
2021-05-23 19:31:39 +02:00
Tobias Christiansen
bd2b17a70e LibGfx: Replace ellipse drawing algorithm
The new one is way more naive and not as fancy as the old one, but it
doesn't crash when trying to draw circles.
This algorithm just sweeps the angles required by the call, makes sure
each segment is at most 1 (pixel) long and just uses the standard
parameterization to find the coordinates of each point on the ellipse.
2021-05-23 18:28:27 +02:00
Gunnar Beutner
6a194869cf Hearts: Add key combinations to letting the AI play for you
A single card can be played with F10 while Shift-F10 toggles the AI
for the current as well as all future tricks.
2021-05-23 18:15:36 +02:00
Gunnar Beutner
2dfced2501 Hearts: Let the AI prefer lead cards for which other cards are in play
When picking a lead card the AI should avoid playing cards where it
knows that no other player has a lower value card of the same type.
2021-05-23 18:15:36 +02:00
Gunnar Beutner
647d0f9f8a Hearts: Fix sorting function for lead cards
The pick_lead_card() function sometimes picks the incorrect card
because the sorted_hand vector wasn't being sorted properly.
2021-05-23 18:15:36 +02:00
Brendan Coles
efef77a154 HexEditor: Add 'Go to Offset...' dialog 2021-05-23 18:13:49 +02:00
Jean-Baptiste Boric
dd6921bfc6 LibProtocol: Fix non-constant usage of PAGE_SIZE 2021-05-23 18:10:29 +02:00
Jean-Baptiste Boric
d92b6423bf Utilities: Fix test-unveil INT_MAX include 2021-05-23 18:10:29 +02:00
Jean-Baptiste Boric
8e6241b78b LookupServer: Fix missing POSIX includes 2021-05-23 18:10:29 +02:00
Jean-Baptiste Boric
5ced9a3dfb ImageDecoder: Fix narrowing cast of loop count 2021-05-23 18:10:29 +02:00
Jean-Baptiste Boric
4d332f3930 Utilities: Fix fgrep assertion include 2021-05-23 18:10:29 +02:00
Andreas Kling
873eb47d2b ps: Sort output by PID :^) 2021-05-23 11:26:19 +02:00
Andreas Kling
a1e133cc6b LibCore: Make ProcessStatisticsReader return results in a Vector
The HashMap API was overkill and made using this less ergonomic than
it should be.
2021-05-23 11:10:15 +02:00
Andreas Kling
a345a1f4a1 Userland: Mark subclasses of IPC::{Client,Server}Connection final 2021-05-23 09:53:55 +02:00
Andreas Kling
c1c252ddb2 LibIPC: Remove unnecessary IPC::ServerConnection::handshake()
This is no longer used by any of our IPC pairs.
2021-05-23 09:53:55 +02:00
Andreas Kling
2eceabdcfd LibGUI: Handle fast_greet stuff in WindowServerConnection constructor
Move the from handshake() to the constructor (and move the constructor
out-of-line while we're at it.)

This prepares getting rid of the handshake() mechanism since this is
the only remaining user.
2021-05-23 09:53:55 +02:00
Andreas Kling
0af69e8917 HackStudio: Greet language servers asynchronously
There's no need to wait for a response after we've sent the project
path to a newly connected language server.
2021-05-23 09:53:55 +02:00
Andreas Kling
67b47d62f3 WebContent: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
6b2f24018d RequestServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
bf33b5df6e WebSocket: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
03df8882df InspectorServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
78b57fcea3 NotificationServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
5424372d50 AudioServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00