Commit Graph

32 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
Ali Mohammad Pur
ba4db899d4 LibSyntax+Userland: Make LibSyntax not depend on LibGUI
This moves some stuff around to make LibGUI depend on LibSyntax instead
of the other way around, as not every application that wishes to do
syntax highlighting is necessarily a LibGUI (or even a GUI) application.
2023-08-29 07:57:39 -04:00
kleines Filmröllchen
d1645efde9 Meta+Userland: Allow generating C++ initializer code from GML
This does the exact same thing as the runtime initializer,
except it is faster and can catch some errors much earlier.

The code generator includes these important features:
- Automatic include generation where necessary
- Special-casing for TabWidget and ScrollableContainerWidget
- No use of DeprecatedString where possible
2023-08-11 21:33:48 +02:00
Andreas Kling
405187993a LibGUI+LibCore: Move GML property system from LibCore to LibGUI
Since Core::Object properties are really only used by GML now that the
Inspector is long gone, there's no need for these to pollute
Core::Object.

This patch adds a new GUI::Object class to hold properties, and makes
it the new base class of GUI::Window, GUI::Widget and GUI::Layout.
The "instantiate an object by name" mechanism that GML uses is also
hoisted into GUI::Object as well.
2023-08-06 18:09:25 +02:00
Sam Atkins
406a7ea577 LibSyntax+Libraries: Replace TextStyle with Gfx::TextAttributes
Rather than creating a TextStyle struct, and then copying its fields
over to a TextAttributes, let's just create a TextAttributes to start
with. This also simplifies the syntax highlighting code by letting us
define underlines along with the other text styling.
2023-03-15 14:55:49 +01:00
Andreas Kling
689ca370d4 Everywhere: Remove NonnullRefPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
8a48246ed1 Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness
doesn't seem worth it just so we can say "." instead of "->" when
iterating over a vector of NNRPs.

This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-03-06 23:46:35 +01:00
Sam Atkins
cac14a3f0a LibGUI: Assign folding regions for GML files
Each {} block is now treated as a folding region, so that they can be
collapsed and expanded in TextEditor, GML Playground, HackStudio, and
anywhere else that uses the syntax highlighter. :^)
2023-02-28 13:23:55 +01:00
Andreas Kling
faa1a09042 LibGUI: Fix const-correctness issues 2023-02-21 00:54:04 +01:00
Linus Groh
6e7459322d AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
2023-01-27 20:38:49 +00:00
Ben Wiederhake
c1676cdddb Everywhere: Remove unused includes of AK/IterationDecision.h
These instances were detected by searching for files that include
IterationDecision.h, but don't match the regex:
\\bIterationDecision(?!\.h>)\\b
This is the only symbol defined by IterationDecision.h.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:08:35 +00:00
Sam Atkins
b32f5dbcff LibCore+LibGUI: Add fallible versions of Widget::load_from_gml()
The existing `load_from_gml()` methods look the same as before from the
outside. Inside though, they now forward to `try_load_from_gml()` which
returns Error when things go wrong. It also now calls the `try_create()`
factory method for Objects instead of the `construct()` one.
2023-01-01 09:55:05 -05: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
Kyle Lanmon
31290c8527 LibSyntax: Teach each highlighter about it's comment syntax 2022-11-27 18:28:43 -07: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
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
sin-ack
e5f09ea170 Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.

No functional changes.
2022-07-12 23:11:35 +02:00
FrHun
c38d3b8520 LibGUI: Fix GML parser command order regression
This was previously fixed in #13572 with
546d338639cc090055d0c416a76fc237d06930c8
but regressed in #14251 with
ec40c93300a2b111129adf1a5badecde8c22889f
2022-06-10 22:30:05 +01:00
FrHun
8081a8a5de LibGUI: Add layout spacer support to GML
This is a bit of a hack, but it is an easy way to finally get spacers
into GML.
This will translate well if spacers are later to become child objects of
the continer widget.
2022-06-10 21:26:06 +01:00
Itamar
b35293d945 LibCodeComprehension: Re-organize code comprehension related code
This moves all code comprehension-related code to a new library,
LibCodeComprehension.

This also moves some types related to code comprehension tasks (such as
autocomplete, find declaration) out of LibGUI and into
LibCodeComprehension.
2022-05-21 18:15:58 +02:00
Idan Horowitz
280e99073b LibGUI: Stop dropping comments between children and end of GML objects
Any left-over comments in the pending_comments vector are now inserted
as sub object children, as these are serialized last and will therefore
show up in their expected location.
2022-04-08 19:19:37 +03:00
Idan Horowitz
40c40b7551 LibGUI: Insert parsed comments in parsing order
We were accidentally reversing the order of consecutive comments when
inserting them as children of the GML object.
2022-04-08 19:19:37 +03:00
Idan Horowitz
c56bc49b70 LibGUI: Remove left-over spammy debug print 2022-04-08 19:19:37 +03:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Lenny Maiorani
fe3b846ac8 Libraries: Use default constructors/destructors in LibGUI
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-03-12 14:44:43 -08:00
Idan Horowitz
4c451422c3 gml-format+Playground: Print GML parsing error on formatting failure 2022-02-13 02:36:35 +02:00
Idan Horowitz
d4f08b3096 LibGUI: Enforce new GML newline and ordering guidelines
Specifically:
 * Properties must precede sub-object declarations.
 * There shouldn't be any newlines in-between properties.
 * There should be a newline in-between each sub-object.
 * Object declarations must include the curly braces.
 * There should be a newline between the properties of an object and
   it's sub-objects.
2022-02-13 02:36:35 +02:00
kleines Filmröllchen
41ef4f11dc LibGUI: Move GML parsing and formatting to new AST
This commit introduces a couple of connected changes that are hard to
untangle, unfortunately:
- Parse GML into the AST instead of JSON
- Change the load_from_json API on Widget to load_from_gml_ast
- Remove this same API from Core::Object as it isn't used outside of
  LibGUI and was a workaround for the object registration detection;
  by verifying the objects we're getting and casting we can remove this
  constraint.
- Format GML by calling the formating APIs on the AST itself; remove
  GMLFormatter.cpp as it's not needed anymore.

After this change, GML formatting already respects comments :^)
2022-02-07 18:39:50 +01:00
kleines Filmröllchen
1806b297b6 LibGUI: Add a custom GML AST
This Abstract Syntax Tree is specifically designed to represent GML and
also includes comments. It will be used in the next commit to replace
JSON in the GML system.
2022-02-07 18:39:50 +01:00
kleines Filmröllchen
8b39074078 Userland: Undefine FOR_EACH_TOKEN_TYPE everywhere
This was causing some macro redefinition errors after the headers ended
up in the same file through some includes. The simple fix is to undefine
the macro after use.
2022-02-07 18:39:50 +01:00
kleines Filmröllchen
4931c88b13 LibGUI: Remove GML prefix in favor of proper namespace
Prefixes are very much a C thing which we don't need in C++. This commit
moves all GML-related classes in LibGUI into the GUI::GML namespace, a
change somewhat overdue.
2022-02-07 18:39:50 +01:00