Commit Graph

215 Commits

Author SHA1 Message Date
Karol Kosek
d32b052f22 LibGUI+Userland: Add _deprecated suffix to AbstractButton::{set_,}text 2023-02-13 00:45:09 +00:00
MacDue
63b11030f0 Everywhere: Use ReadonlySpan<T> instead of Span<T const> 2023-02-08 19:15:45 +00:00
Karol Baraniecki
506c26acce LibGUI+Userland: Switch order of parameters for InputBox::show
Because usage of the input_type parameter is now higher than of the
placeholder parameter, this makes for a cleaner API.
2023-02-04 18:46:39 -07:00
Karol Baraniecki
8095d9276b Userland: Replace manual checking by using GUI::InputType::NonemptyText
Do this where we were already checking if the input was empty after the
InputBox was submitted. Those places gain interactive input validation.

:^)
2023-02-04 18:46:39 -07:00
Lucas CHOLLET
3f932081ae HexEditor: Create a function to initialize a HexDocumentFile
This function is made from what composed `set_file()` (which now calls
the new function). It allows to create a `HexDocumentFile` without
calling the hackish `set_file(move(m_file))`.
2023-02-04 17:20:31 -07:00
Lucas CHOLLET
689b3c2c26 HexEditor: Propagate errors from HexDocumentFile::set_title() 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
a2dca2b762 HexEditor: Propagate errors when using "Save" 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
2bba743c24 HexEditor: Propagate errors when using "Save as" 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
3d914247cc HexEditor: Port to Core::Stream 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
b1d8404c92 HexEditor: Use the constructor pattern 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
a621b5f015 HexEditor: Add a default move constructor to HexDocumentFile 2023-02-04 17:20:31 -07:00
Tim Schumacher
8464da1439 AK: Move Stream and SeekableStream from LibCore
`Stream` will be qualified as `AK::Stream` until we remove the
`Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is
defined by `SeekableStream`, since defining its own would require us to
qualify it with `AK::SeekMode` everywhere.
2023-01-29 19:16:44 -07:00
Tim Schumacher
82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00
Liav A
e241b47fee Userland: Remove a bunch of unveil calls on /sys/kernel/processes
These are not needed anymore since the introduction of the new
get_root_session_id syscall.
2023-01-13 13:41:30 +01:00
Sam Atkins
e181b1cb82 Userland: Use Core::Timer::create_foo() factory functions where possible 2023-01-12 11:25:51 +01:00
Timothy Flynn
d0403ec14f AK+Everywhere: Rename Utf16View::to_utf8 to to_deprecated_string
A subsequent commit will add to_utf8 back to create an AK::String.
2023-01-09 23:00:24 +00:00
Timothy Flynn
d793262beb AK+Everywhere: Make UTF-16 to UTF-8 converter fallible
This could fail to allocate the underlying storage needed to store the
UTF-8 data. Propagate this error.
2023-01-08 12:13:15 +01:00
Timothy Flynn
1edb96376b AK+Everywhere: Make UTF-8 and UTF-32 to UTF-16 converters fallible
These could fail to allocate the underlying storage needed to store the
UTF-16 data. Propagate these errors.
2023-01-08 12:13:15 +01:00
Sam Atkins
f0395a2042 LibGUI+Userland: Rename try_load_from_gml() -> load_from_gml() :^)
It's the only one, so the `try` prefix is unnecessary now.
2023-01-07 14:39:30 +01:00
Sam Atkins
54b1326165 Userland: Replace all uses of load_from_gml with try_load_from_gml
MOAR FIXMES! ;^)
2023-01-07 14:39:30 +01:00
Karol Kosek
247db3fdd0 LibFileSystemAccessClient: Rename try_* functions to try_*_deprecated
These functions return the deprecated `Core::File` class, so let's mark
it as such to avoid possible confusion between future non try_*
functions which will use Core::Stream family classes and to possibly
grab someone's attention. :^)
2023-01-07 10:53:43 +00:00
Sam Atkins
0c24522635 LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)
Rip that bandaid off!

This does the following, in one big, awkward jump:
- Replace all uses of `set_main_widget<Foo>()` with the `try` version.
- Remove `set_main_widget<Foo>()`.
- Rename the `try` version to just be `set_main_widget` because it's now
  the only one.

The majority of places that call `set_main_widget<Foo>()` are inside
constructors, so this unfortunately gives us a big batch of new
`release_value_but_fixme_should_propagate_errors()` calls.
2023-01-06 13:36:02 -07:00
Arda Cinar
2dd7fa2d44 HexEditor: Handle some errors inside the editor
Specifically, the ones HexEditor::did_complete_action possibly raised in
case creating an undo stack entry or pushing it onto the undo stack
fails. In this case, an error popup is displayed and the modifications
are undone.

This removes 2 FIXMEs inside the code :^)
2022-12-14 23:43:20 -07:00
Lucas CHOLLET
9ae97c8cb1 LibFileSystemAccessClient: Rename try_save_file =>
`try_save_file_deprecated`

This precedes the addition of a new api using `Core::Stream`
2022-12-14 18:26:25 +00: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
Zaggy1024
76627ec0a2 HexEditor: Allow keydown events to propagate if they are not handled 2022-11-14 16:08:11 +00:00
Karol Kosek
0b7f5bbdfb Userland: Accept drag_enter events for widgets supporting file drops
This patch will switch cursor to DragCopy when a user enters a widget
while dragging file(s), giving them a visual clue that it *might* be
dropped into this widget.

This is a rather naive approach, as the cursor icon will change for any
kind of file, as currently programs don't know the drag contents before
dropping it. But after all I think it's better than nothing. :^)
2022-11-13 16:13:03 -07:00
Karol Kosek
6b8d351b40 TextEditor+HexEditor: Warn about unsaved changes after dropping files 2022-11-07 12:55:46 +00:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
kamp
8b0a464f5c HexEditor: Implement undo and redo actions 2022-11-01 12:07:28 +00:00
kamp
24f729d0ef HexEditor: Only mark window as modified when document is actually dirty 2022-11-01 12:07:28 +00:00
premek
ec34d60e5c HexEditor: Specify page skip size in multiples of the line height 2022-10-31 15:37:08 +00:00
Liav A
5dfb2b18f3 Applications: Use new global variables at /sys/kernel/ directory 2022-10-25 15:33:34 -06:00
demostanis
34acae90c7 Userland: Let applications make use of make_command_palette_action() 2022-10-25 10:21:18 +01:00
Mart G
7394316818 HexEditor: Render selection background without gaps between rows
The selected region in HexEditor is indicated by rendering a different
background color for the selected bytes.

Previously this background was rendered so that the background
rectangles were not contigous between different rows. This caused a high
contrast pattern that interfered with the readability of the hexadecimal
digits.

Now the background is rendered as a single contiguous block.
2022-10-14 16:24:51 +01:00
Mart G
279121fa10 HexEditor: Fix two off-by-one errors
The 'select all' feature now also selects the last byte of the document.
The find function now also selects the last byte of a match.
2022-10-12 18:15:44 +02:00
Ali Mohammad Pur
166a905951 Userland: Properly populate GENERATED_SOURCES
We previously put the generated headers in SOURCES, which did not mark
them as GENERATED (and did not produce a proper dependency).
This commit moves all generated headers into GENERATED_SOURCES, and
removes useless header SOURCES.
2022-10-12 15:55:15 +01:00
Timothy Flynn
7cab86ad28 Userland: Unveil /proc/all in applications which require it
These were missed in 7af5eef. It is needed for any application using
e.g. FileSystemAccessServer.
2022-10-03 17:09:21 +01:00
Timothy Flynn
25e0ab3ee4 Userland: Tighten promises by removing 'proc' where it isn't used
This is a partial revert of commit 7af5eef. After 97d15e9, the 'proc'
promise is not needed for operations using getsid().

This also fixes launching several applications in which 7af5eef added
the 'proc' promise only in the second call to pledge().
2022-10-03 17:09:21 +01:00
Peter Elliott
7af5eef0dd SystemServer+LoginServer+Userland: Switch to sid-based sockets
This commit does three things atomically:
- switch over Core::Account+SystemServer+LoginServer to sid based socket
  names.
- change socket names with %uid to %sid.
- add/update necessary pledges and unveils.

Userland: Switch over servers to sid based sockets

Userland: Properly pledge and unveil for sid based sockets
2022-10-03 11:11:29 +02:00
networkException
4230dbbb21 AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and
create_with_file_protocol() already. This patch removes these function
and updates all call sites to use the functions named according to the
specification.

See https://url.spec.whatwg.org/#concept-url-scheme
2022-09-29 09:39:04 +01:00
thankyouverycool
cce9172cd4 Applications+DevTools: Remove fixed sizes from Splitters
And adjust some GML properties. Since a808cfa, splitters grow
opportunistically. Setting them to fixed sizes now quite literally
fixes them in place. Fixes immovable splitters missed in the
aforementioned commit.
2022-08-30 16:28:44 +01:00
djwisdom
27f5a18ce6 HexEditor: Add Help->Manual entry in Menu 2022-08-29 09:25:29 +01:00
Jannis Weis
8fa34b43ce HexEditor: Fix utf16 validation
Previously the utf8_view was validated for the utf16 valude instead
of the utf16_view.
2022-08-22 12:48:47 +02:00
Lucas CHOLLET
e8115bfdb1 Base: Launch FileSystemAccessServer at session start-up 2022-08-14 21:52:35 +01:00
James Puleo
8c11786145 HexEditor: Rename camel case variable names in HexEditor::save_as
This also changes those variables to be references to the casted
document type, instead of pointers.
2022-08-03 10:12:11 -04:00
James Puleo
88cf40179d HexEditor: Make HexEditor::open_new_file fallible and reduce branching
Returning a `bool` is meaningless, so let's make it more expresive :^)
2022-08-03 10:12:11 -04:00
James Puleo
035d63f528 HexEditor: Remove unused readonly flag
`HexEditor::set_readonly` was never called, even though
`HexEditor::is_readonly` was occasionally queried -- so it's entirely
been removed.
2022-08-03 10:12:11 -04:00
James Puleo
8695ae4c50 HexEditor: Don't spam debug output when finding all strings
For each string found we would output it, which was way too much noise
:^)
2022-08-03 10:12:11 -04:00
James Puleo
0bfcbf0b0a HexEditor: Change Find All Strings shortcut to Ctrl + Shift + F
The previous shortcut of `Ctrl + Shift + S` conflicted with `Save As...`
action shortcut.
2022-08-03 10:12:11 -04:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Karol Kosek
ff0b4bf360 HexEditor: Gray-out null bytes
This should improve an overall visibility of "meaningful" data. :^)
2022-07-11 18:11:11 +02:00
DexesTTP
7ceeb74535 AK: Use an enum instead of a bool for String::replace(all_occurences)
This commit has no behavior changes.

In particular, this does not fix any of the wrong uses of the previous
default parameter (which used to be 'false', meaning "only replace the
first occurence in the string"). It simply replaces the default uses by
String::replace(..., ReplaceMode::FirstOnly), leaving them incorrect.
2022-07-06 11:12:45 +02:00
Karol Kosek
9f1f1b8472 Userland: Use default buttons instead of manually handling return press
Besides simplifying the code, this will also draw outline for these
buttons as a cue for a user!
2022-06-02 22:33:00 +02:00
Sam Atkins
cdffe556c8 LibGUI+Userland: Make Dialog::ExecResult an enum class 2022-05-13 16:27:43 +02:00
kleines Filmröllchen
19f6ef3a0c HexEditor: Add UTF16 to the value inspector 2022-04-27 00:02:24 +02:00
kleines Filmröllchen
ef113b2f91 HexEditor: Add UTF8 to the value inspector 2022-04-27 00:02:24 +02:00
kleines Filmröllchen
e5736cdf2f HexEditor: Add ASCII to the value inspector
This is kind of redundant but probably easier to read than the ASCII
column. Also, it seems appropriate after we add other character
encodings.
2022-04-27 00:02:24 +02:00
kleines Filmröllchen
da7a8a8711 HexEditor: Don't require the ValueInspectorModel's value size to be i32 2022-04-27 00:02:24 +02:00
Eli Youngs
d20ff6c891 HexEditor: Show endianness in the value inspector 2022-04-18 09:25:38 +04:30
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Timothy Slater
6a4fdae575 HexEditor: Add Value Inspector
This adds a value inspector window to the Hex Editor. This window shows
the data at the current cursor position (or selection start if a range
is selected) interpreted as a variety of data types.

Currently supported values include 8, 16, 32, and 64 bit signed and
unsigned values as well as float and double.

The inspector can operate in both little endian and big endian modes.
This is switched between by options in the View menu.
2022-04-07 16:55:20 +04:30
Timothy Slater
604557c71b HexEditor: Add get_byte() method to HexEditor class 2022-04-07 16:55:20 +04:30
Timothy Slater
1b70c5f605 HexEditor: Add ability to set a selection range 2022-04-07 16:55:20 +04:30
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Samu698
a39c921421 HexEditor: Selection follows cursor while pressing shift
This patch makes the HexEditor behaviour similar to the one of the
text editor, this can be seen by pressing shift and the arrow keys
2022-03-14 22:48:16 +01:00
Samu698
61b8834b1a HexEditor: Disable selection dependent actions when no selection is made
This applies for the "copy as hex", "copy as text", "copy as C code",
"fill selection" actions
2022-03-14 22:48:16 +01:00
Samu698
d694af8be0 HexEditor: Offset segment in status bar opens goto offset dialog 2022-03-14 22:48:16 +01:00
Samu698
a562518ad7 HexEditor: Fill selection sets only bytes inside selection
Before this patch the fill selection command would set the selection
and one byte after it
2022-03-14 22:48:16 +01:00
Samu698
7bf4ed98d7 HexEditor: Copy as C code doesn't add trailing spaces 2022-03-14 22:48:16 +01:00
Lenny Maiorani
064cfd6cb7 Applications: Fix undefined behavior capturing non-static constexpr 2022-03-02 22:01:58 -08:00
Lenny Maiorani
1dd70a6f49 Applications: Change static constexpr variables to constexpr
Function-local `static constexpr` variables can be `constexpr`. This
can reduce memory consumption, binary size, and offer additional
compiler optimizations.
2022-02-28 13:54:27 +01:00
thankyouverycool
3aa95dd4d5 LibGUI+Apps: Convert Statusbar Labels to Segments
Segments inherit from Button and let us add clickable widgets
to status bars. This patch also adds proportional, fixed and
autosized modes for segments and lets the status bar consume
all non-clickable segments for override text.
2022-02-24 19:09:41 +01:00
Karol Kosek
c9c55d86a4 Userland: Ask first for unsaved changes after clicking an "Open" action
Previously there was some inconsistency between the apps when clicking
the "Open" action while the file wasn't saved.

Some programs (Font Editor) immediately asked you if you wanted to save
the modified file, while others (Text Editor, Hex Editor and Playground)
would show the save dialog only *after* you selected a file.

I think it's better to ask a user right away if they want to save file,
because a dialog after selecting a file should be generally related to
that selected file, like an error opening a file, an import window etc.
2022-02-21 18:30:32 +01:00
Liav A
6a998c1a8b HexEditor: Add support for handling PageUp and PageDown key events
In such case, move the cursor up or down the amount of bytes per row,
multiplied by the visible content rectangle height, if possible.
2022-02-20 15:44:36 +01:00
Liav A
c8e691f917 HexEditor: Reduce code duplication when handling key down events
Instead of having the same update block for each event we can use lambda
functions to help updating the cursor when handling key down events.
2022-02-20 15:44:36 +01:00
Karol Kosek
42d19977b3 HexEditor: Use the system-wide unsaved changes dialog 2022-02-20 08:40:26 -05:00
Karol Kosek
f18ae27fe9 HexEditor: Display dirty close icon when the file is changed 2022-02-20 00:06:14 -05: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
Federico Guerinoni
334ed9225a HexEditor: Fix copy {text/hex} to clipboard
Now the copy action takes exactly the selected chars and not one more.
2022-02-14 11:42:04 +01:00
Federico Guerinoni
932ce93fd7 HexEditor: Fix crash of copy action when selection is empty
Closes: #11925
2022-02-14 11:42:04 +01:00
electrikmilk
62102e3130 Base+HexEditor: Add icons 2022-02-13 21:24:46 +00:00
Idan Horowitz
c8ab45e79f Userland: Run gml-format
This brings the existing GML files up to spec with the new requirements
2022-02-13 02:36:35 +02:00
Vitaly Dyachkov
32b8795091 LibConfig: Rename pledge_domains(String) => pledge_domain(String)
pledge_domains() that takes only one String argument was specifically
added as a shortcut for pledging a single domain. So, it makes sense to
use singular here.
2022-02-11 18:06:39 +01:00
kleines Filmröllchen
6ee597369d Meta+Userland: Run the GML formatter on CI and pre-commit
Now that the GML formatter is both perserving comments and also mostly
agrees to the existing GML style, it can be used to auto-format all the
GML files in the system. This commit does not only contain the scripts
for running the formatting on CI and the pre-commit hook, but also
initially formats all the existing GML files so that the hook is
successfull.
2022-02-07 18:39:50 +01:00
kleines Filmröllchen
145eeb57ab Userland: Remove a bunch of unnecessary Vector imports
How silly :^)
2022-01-28 23:40:25 +01:00
kleines Filmröllchen
cab6384966 HexEditor: Use Array in FindDialog's options 2022-01-28 23:40:25 +01:00
Sam Atkins
f590cd1850 AK+Userland: Make AK::decode_hex() return ErrorOr
This lets us propagate the reason why it failed up to the caller. :^)
2022-01-24 22:36:09 +01:00
Sam Atkins
45cf40653a Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOr
Apologies for the enormous commit, but I don't see a way to split this
up nicely. In the vast majority of cases it's a simple change. A few
extra places can use TRY instead of manual error checking though. :^)
2022-01-24 22:36:09 +01:00
Mustafa Quraish
aae96af812 HexEditor: Use FileSystemAccessClient::try_* APIs 2022-01-20 10:39:12 +01:00
Conor Byrne
e92b6047ad HexEditor: Port HexEditor to LibMain 2022-01-01 14:47:15 +01:00
Arne Elster
277ac48649 HexEditor: Don't unnecessarily abbreviate variable names
There's enough line space to use readable variable names.
2021-12-23 23:25:47 -08:00
Arne Elster
9f38966105 HexEditor: Make HexDocuments final
There's no reason as to why someone would inherit those, so might
aswell make them final.
2021-12-23 23:25:47 -08:00
Arne Elster
af754211fa HexEditor: Scroll back to the top when opening another file
When a file is opened and scrolled to some position and the user opens
another file, the current scroll position stays the same. That's
disorienting. Therefore, when opening another file, scroll back to the
top.
2021-12-23 23:25:47 -08:00
Arne Elster
fd66dda1d7 HexEditor: Stream input files instead of keeping them in memory
To support editing of large files it is an advantage to not load the
entire file into memory but only load whatever is needed for display at
the moment. To make it work, file access is abstracted into a socalled
HexDocument, of which there two: a memory based and a file based one.
The former can be used for newly created documents, the latter for file
based editing.

Hex documents now do track changes instead of the HexEditor. HexEditor
only sets new values. This frees HexEditor of some responsibility.
2021-12-23 23:25:47 -08:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
a7f1f1c34b LibCore: Use ErrorOr<T> for Core::File::open() 2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Arne Elster
be9a7057ff HexEditor: Give magic constants names
There are a lot of numbers just floating around in the code.
Give them proper names.
2021-11-01 01:48:51 +01:00