Commit graph

4944 commits

Author SHA1 Message Date
Andreas Kling
e2c74762ff HackStudio: Draw a brownish frame around the current editor widget
Also make the editor filename label bold only for the current editor.
2019-10-27 20:44:37 +01:00
Andreas Kling
e2d7f585da HackStudio: Support opening the same file in both editors
Hey, it actually works! You can now edit the same file in both editors
and even the C++ highlighting updates correctly in both of them. :^)
2019-10-27 19:39:15 +01:00
Andreas Kling
9b13a3905b LibGUI: Support multiple GTextEditors editing the same GTextDocument
With this patch, you can now assign the same GTextDocument to multiple
GTextEditor widgets via GTextEditor::set_document().

The editors have independent cursors and selection, but all changes
are shared, and immediately propagate to all editors.

This is very unoptimized and will do lots of unnecessary invalidation,
especially line re-wrapping and repainting over and over again.
2019-10-27 19:36:59 +01:00
Andreas Kling
f96c683543 LibGUI: Move visual line metadata from GTextDocument to GTextEditor
This patch decouples GTextDocument and GTextDocumentLine from the line
wrapping functionality of GTextEditor.

This should basically make it possible to have multiple GTextEditors
editing the same GTextDocument. Of course, that will require a bit more
work since there's no paint invalidation yet.
2019-10-27 18:00:07 +01:00
Andreas Kling
f1c6193d6d LibGUI: Move GTextDocument out of GTextEditor
The idea here is to decouple the document from the editor widget so you
could have multiple editors being views onto the same document.

This doesn't work yet, since the document and editor are coupled in
various ways still (including a per-line back-pointer to the editor.)
2019-10-27 16:44:16 +01:00
Andreas Kling
1bcbc3f827 HackStudio: Allow switching between the two editors with Ctrl+E :^)
This is very hackish and should be done differently, but the feature
feels pretty nice and does work for now.
2019-10-27 13:10:37 +01:00
Andreas Kling
1e5f4714c7 HackStudio: Tweak EditorWrapper layouts a bit to make things look nice 2019-10-27 13:06:30 +01:00
Andreas Kling
e39b1f11f9 HackStudio: Support multiple editors on screen
This patch adds Editor (subclass of GTextEditor) and EditorWrapper.
An EditorWrapper is a composite widget that adds a little statusbar
above an Editor widget. The statusbar is used for showing the filename
and the current cursor position. More things can definitely be added.

To get to the currently active editor, call current_editor().
You can also get to the current editor's wrapper by calling..
current_editor_wrapper(). Which editor is current is determined by
which was was last focused by the user.
2019-10-27 12:55:10 +01:00
Andreas Kling
de2b25e2c1 LibGUI: Move GTextRange and GTextPosition to their own header files 2019-10-27 11:23:53 +01:00
Andreas Kling
db5178fb8f GTextEditor: Double-clicking on a span should select the span
This makes double-clicking on a C++ token in HackStudio select the
whole token, which is pretty nice. It's not perfect in all cases,
but a lot nicer than just expanding until we hit whitespace. :^)
2019-10-27 11:18:19 +01:00
Andreas Kling
8fa466e496 GTextEditor: Backspace over soft tabs
This makes the backspace erase backwards until the next soft tab stop.
We currently always use 4 as the soft tab width, but I suppose we could
make it configurable at some point. :^)
2019-10-27 10:42:48 +01:00
Brandon Scott
98e556fee9 HexEditor: Created has_selection() method.
Created has_selection() method and fixed a few small issues.
2019-10-27 00:44:42 +02:00
Brandon Scott
c77fe5161c HexEditor: Added fill selection action.
Added the ability to fill the current selection with a given byte.
2019-10-27 00:44:42 +02:00
Brandon Scott
f947353a56 HexEditor: Added new file action.
Added a new file action, allowing you to create a new file of a specific
size.
2019-10-27 00:44:42 +02:00
Andreas Kling
90c81d5c16 HackStudio: Tweak style of C++ identifiers
On second thought, let's not have bold identifiers, as this ended up
making most of the code bold. :^)
2019-10-26 21:47:51 +02:00
Andreas Kling
dd74cb9c8f HackStudio: Focus the text editor after opening a file 2019-10-26 21:45:29 +02:00
Andreas Kling
cea6506998 HackStudio: Implement adding an existing file to project 2019-10-26 21:43:46 +02:00
Andreas Kling
4089690cf1 GFilePicker: Allow overriding the window title for get_open_filepath() 2019-10-26 21:42:34 +02:00
Andreas Kling
9129dbe0b9 HackStudio: Implement adding a new file to the project
You can now press Ctrl+N to create and add a new file to the project!
2019-10-26 21:28:31 +02:00
Andreas Kling
b513a787fb GTextEditor: set_text() should clear any existing spans 2019-10-26 20:21:12 +02:00
Andreas Kling
cdac60e876 LibHTML: Make <header> and <footer> be "display: block" by default
This makes http://www.motherfuckingwebsite.com/ readable :^)
2019-10-26 15:40:51 +02:00
Andreas Kling
bc2026d26d LibGUI: Make GTextEditor::Span have a range instead of two positions
A GTextRange is really just two GTextPositions (start and end) anyway.
This way we can say nice things like "if (range.contains(position))"
2019-10-26 15:33:19 +02:00
Andreas Kling
4fa8acf6ea GTextEditor: The Home key should jump to the first non-space character
Press Home twice to get to column 0. This feels way more natural.
2019-10-26 14:02:39 +02:00
Andreas Kling
532001f4c1 GTextEditor: Arrow keys should only modify selection when Shift is held 2019-10-26 14:01:53 +02:00
Andreas Kling
df7f3ca604 HackStudio: "Hide" the action tabs (find in files, console) by default
By "hide" I really mean collapse them down to 24px height. We grow them
to a normal size when they're needed. The user is also free to resize
them at will.

This keeps them out of the way when you just want to do editing. :^)
2019-10-26 12:30:49 +02:00
Andreas Kling
98a6149b4f LibGUI: Make GWindow drive relayout and do it recursively
Instead of only doing a relayout in the widget you're invalidating,
we now do a recursive top-down relayout so everything gets updated.

This fixes invalid results after updating a preferred size in some
situations with nested layouts.
2019-10-26 12:28:54 +02:00
Andreas Kling
d0799f3648 WindowServer: Center the mouse cursor on startup
The code was already trying to do this, but it was centering inside the
screen rect before we had a screen rect. :^)
2019-10-26 11:39:15 +02:00
Andreas Kling
db353a06e5 HackStudio: Enable line wrapping and automatic indentation by default 2019-10-26 11:33:39 +02:00
Andreas Kling
ed242d538a HackStudio: Assorted improvements to C++ highlighting
Add a list of hard-coded standard types (including AK types) and show
them in a different style.

Rehighligt the file whenever it changes. (This is very inefficient but
makes it much easier to experiment.)

Also keep tweaking the colors. :^)
2019-10-26 10:33:50 +02:00
Andreas Kling
2b19badd74 HackStudio: Make C++ keywords bold :^)
Now that we can specify the font of a GTextEditor::Span, use this to
make C++ keywords show up in bold text. Also tweak colors a bit.
2019-10-26 00:19:36 +02:00
Andreas Kling
59107a7cfe GTextEditor: Allow setting a custom font for each span 2019-10-26 00:13:07 +02:00
Andreas Kling
5e5a7fbd40 HackStudio: Teach the C++ lexer about most C++ keywords
Also fix broken "/* */" comment handling.
2019-10-25 21:58:40 +02:00
Andreas Kling
6afe27b914 HackStudio: Lex C++ files and apply some basic syntax highlighting
When we open a file whose name ends in ".cpp", we now pass the contents
through CppLexer, which produces a CppToken stream.

Those CppTokens are then converted into GTextEditor::Spans and handed
over to GTextEditor which then colorizes the source code accordingly.

This is pretty neat. :^)
2019-10-25 21:09:16 +02:00
Andreas Kling
0604fcf9fd HackStudio: Make CppTokens have (line,column) positions
These are infinitely more useful than raw indices into the input text.
2019-10-25 21:07:45 +02:00
Andreas Kling
0d53d74d5f GTextEditor: Add a "span" mechanism for having custom-style text ranges
It's now possible to give GTextEditor a vector of Span objects.
Spans currently tell the editor which color to use for each character
in the span. This can be used to implement syntax highlighting :^)
2019-10-25 21:07:02 +02:00
Andreas Kling
307cbf83c3 HackStudio: Start building a C++ lexer to help with syntax highlighting 2019-10-25 19:52:44 +02:00
Brandon Scott
51e655f903 LibGUI: Added window creation callback to GApplication/GWindow
Added a window creation callback to GApplication that gets called
by GWindow which will reset any pending exit request in the
CEventLoop.

This is to prevent a bug which prevents your application from
starting up if you had a message box or other dialog before
showing your main application form. The bug was triggered by
there being no more visible windows which was triggering a
premature quit().
2019-10-25 15:29:19 +02:00
Brandon Scott
5311f8fae1 LibCore: Added unquit() method to CEventLoop.
Added an unquit() method to CEventLoop allowing you to cancel a
pending exit request.
2019-10-25 15:29:19 +02:00
Andreas Kling
f256c55e8d HackStudio: Unbreak jumping to a search result
I broke this when factoring out the find-in-files widget into its own
class. This patch adds a main_editor() global getter for grabbing at
the main GTextEditor from wherever you are.
2019-10-25 10:25:42 +02:00
Andreas Kling
558c63a6f9 Kernel: FileDescription::is_directory() should not assert !is_fifo()
I have no idea why this was here. It makes no sense. If you're trying
to find out if something is a directory, why wouldn't you be allowed to
ask that about a FIFO? :^)

Thanks to Brandon for spotting this!

Also, while we're here, cache the directory state in a bool member so
we don't have to keep fetching inode metadata when checking this
repeatedly. This is important since sys$read() now calls it.
2019-10-25 09:23:38 +02:00
Andreas Kling
4e25d69dba HackStudio: Move the ProcessStateWidget below the TerminalWidget
This looks a bit less janky when hiding/unhiding.. :^)
2019-10-24 22:32:27 +02:00
Andreas Kling
deabc7e13b HackStudio: Bring up the console when doing a "build" or "run"
We most likely want to see what comes out on the console when starting
one of these actions.
2019-10-24 22:28:36 +02:00
Andreas Kling
84a2208b5c HackStudio: Add some toolbar icons to liven up the UI a bit :^) 2019-10-24 22:25:26 +02:00
Andreas Kling
f61622a501 HackStudio: Hide the ProcessStateWidget while no process is running 2019-10-24 21:04:13 +02:00
Andreas Kling
5c3647b8a3 TTY: MasterPTY should fail to ioctl() if slave is gone
Just fail with EIO in that case.
2019-10-24 21:03:49 +02:00
Andreas Kling
bced810880 HackStudio: Show the slave pty's PGID in the ProcessStateWidget
This is the closest I could figure out how to get to what's actively
running on the terminal view at the moment.

Perhaps we can bundle up every process with the same tty and sum it
all up somehow. I'm not sure.
2019-10-24 20:56:13 +02:00
Andreas Kling
ef64e26317 TTY: Forward TIOCGPGRP from MasterPTY to SlavePTY
This makes tcgetpgrp() on a master PTY return the PGID of the slave PTY
which is probably what you are looking for. I'm not sure how correct or
standardized this is, but it makes sense to me right now.
2019-10-24 20:54:35 +02:00
Andreas Kling
272317bce2 HackStudio: Add a widget showing the state of console's running process
We now have a little widget that sits above the terminal view in the
build/application console. When a child process is running, we show its
PID, name, scheduling counter, and amount of resident memory in a live
little overview.

This is not working right just yet, since we don't know how to get to
the actually active PID on the TTY. Or, well, we find the active PID by
looking at the PGID of our fork()ed child.

This manages to find children spawned by Shell, but not children
spawned by make, for instance. I need to figure out how to find those.
2019-10-24 20:21:43 +02:00
Drew Stratford
489e451cce Kernel: Return error when attempting to read from a directory.
We now return EISDIR whenever a program attempts to call sys$read
on a directory. Previously, attempting to read a directory could
either return junk data or, in the case of /proc/, cause a kernel
panic.
2019-10-24 16:14:50 +02:00
Vincent Sanders
1be4c6e9cf LibC: Stop stdio from adding null terminators out of bounds (#685)
When using the bounded string operations (e.g. snprintf), the null
terminator was always being written even if there was no space for
it (or indeed any valid buffer at all)

This overwriting caused segmentation faults and memory corruption
2019-10-24 14:12:37 +02:00