Commit Graph

113 Commits

Author SHA1 Message Date
Karol Kosek
5f3e9886f7 HackStudio: Disable the Rename action on insufficient permissions
This patch will disable the Rename action in the project Tree View
if a user does not have write access to the selected file directory.
2021-11-22 09:03:19 +01:00
Karol Kosek
0264d3de45 HackStudio: Remove noop when deciding whether to disable delete action
The iterator in has_permissions will just be equal to sections.end()
when there are no selected files.
2021-11-22 09:03:19 +01:00
Itamar
8316eb7306 HackStudio: Add option to inspect Coredump
This adds a --coredump <file> option to Hack Studio.

When used, Hack Studio will open the coredump and allow the user to
inspect it in the Debug tab.
2021-11-20 21:22:24 +00:00
Andreas Kling
c7e62d448c LibCore: Use ErrorOr<T> for Core::File::remove()
This function returns a subclass of Error, which is now possible.
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
Ben Wiederhake
b8f11b1bae Everywhere: Remove unused ArgsParser header
Found while trying to enumerate all programs that use ArgsParser.
2021-11-01 21:12:58 +01:00
Marco Cutecchia
3428e2a76c HackStudio: Add 'Show Dotfiles' option 2021-10-29 22:40:11 +02:00
Marco Cutecchia
3c5e07fa1c HackStudio: Save editor's font in configs 2021-10-06 17:14:40 +02:00
Marco Cutecchia
423c2e44c9 HackStudio: Add option to change the editor's font 2021-10-06 17:14:40 +02:00
Marco Cutecchia
194dc8b25d HackStudio: Support renaming files from the tree view 2021-09-27 01:20:48 +02:00
Karol Kosek
6c5fb2ca63 HackStudio: Remove an old file from the vectors in 'Save as...' action
If you saved a file under a different name and then went back to
the first file, then you had the same TextDocument buffer, and therefore
the same changes to the file as in the new one.
2021-09-12 22:10:48 +02:00
Karol Kosek
d811ad921c HackStudio: Rename Project::get_file() to Project::create_file()
The function no longer looks for the already opened files, so let's
emphasize that by renaming it to `create_file`. :^)
2021-09-12 22:10:48 +02:00
Karol Kosek
cf71805aa8 HackStudio: Reuse TextDocument::is_modified()
Previously, the modification tag in the editor file label was unset only
after a file was saved.

This commit will also unset the tag if you undo the stack (for example
by hitting Ctrl+Z) to the last saved state.
2021-09-10 00:00:53 +02:00
sin-ack
e9121f8b1f LibCore+Userland: Implement Core::deferred_invoke
Core::deferred_invoke is a way of executing an action after previously
queued events have been processed. It removes the requirement of
having/being a Core::Object subclass in order to defer invocation
through Core::Object::deferred_invoke.

Core::Object::deferred_invoke now delegates to Core::deferred_invoke.
The version with the Object& argument is still present but will be
removed in the following commits.

This commit additionally fixes a new places where the
DeferredInvocationEvent was dispatched to the event loop directly, and
replaces them with the Core::deferred_invoke equivalent.
2021-09-02 03:47:47 +04:30
Itamar
11832544e5 HackStudio: Add "Go Back" and "Go Forward" navigation actions
These actions allow the user to move backwards & forwards between
previous project locations they were at.
2021-08-30 12:44:26 +02:00
Itamar
8fc9ec942e HackStudio: Optionally pass line & column to open_file
This makes it easier to open a file at a specific location.
2021-08-30 12:44:26 +02:00
Karol Kosek
a230524c46 HackStudio: Update the tree view cursor on editor change and 'Save as'
The more important thing here is to update the tree view
on 'Save As..', as we want to drop every connection from an old file.

Updating the tree view on current editor change is just a cool small
bonus. :^)
2021-08-25 17:42:54 +02:00
Marco Cutecchia
d1f936e3d0 HackStudio: Add "New File" actions for different file extensions
Currently this supports the following file types: cpp, header, gml,
js, css, html and plain files
2021-08-25 12:12:15 +02:00
Karol Kosek
8d3304f853 HackStudio: Update every editor with matching filename on 'Save as...'
Prior this change, if user had more than two copies of one file opened
in a split view, then only the active editor was renamed,
when the others had the same file contents changed.

This change will set a new file name for every file.

The is_null() check is for uncreated files, as they shouldn't be
treated as the same single file.
2021-08-22 23:41:53 +02:00
Karol Kosek
90396f5b08 HackStudio: Convert selected path to a relative path on 'Save as...'
This makes the editor title a bit more consistent with the other files
and removes duplicating the file name in the file history
when reopening that file.
2021-08-22 23:41:53 +02:00
Lennon Donaghy
283d8d3928 HackStudio: Warn about unsaved changes on opening different project 2021-08-22 10:30:06 +02:00
Lennon Donaghy
82b88c6e16 HackStudio: Fix editor not marking file with unsaved changes as dirty
The editor's on_change callback was being overwritten in
HackStudioWidget.cpp in order to call update_gml_preview on every
change. This stopped the original callback from being called and marking
files as dirty when changed.

Now we call update_gml_preview in a new callback within the editor
wrapper, which is then called within the original on_change callback
in the editor.
2021-08-22 10:30:06 +02:00
Lennon Donaghy
d454c63bde HackStudio: Fix GitWidget issues with switching between projects
GitWidget no longer crashes upon trying to create a repository for a new
project, and it correctly updates after opening a different project. A
new method, change_repo, has been added to make this work, which changes
m_repo_root and resets most of the widget's state in order to make this
work.
2021-08-22 10:30:06 +02:00
Lennon Donaghy
d9c295de46 HackStudio: Moved code closing project from open_project to own method
Take the code which closes the current project out of open_project
method and move it into its own method.
2021-08-22 10:30:06 +02:00
Lennon Donaghy
3ce96134b5 HackStudio: Call update_gml_preview() to reset when opening new project 2021-08-22 10:30:06 +02:00
Lennon Donaghy
5ca888132d HackStudio: Make FindInFilesWidget reset when opening new project
Add method to FindInFilesWidget which resets the model in order to
clear the output when needed, and use this when a new project is opened.
2021-08-22 10:30:06 +02:00
Lennon Donaghy
ff2a1ee8b0 HackStudio: Stop debugger when opening new project
Moved code to stop the debugger in the HackStudioWidget destructor to
a new method so that this can be called in both the destructor and when
opening a new project.
2021-08-22 10:30:06 +02:00
Lennon Donaghy
971a5a70d1 HackStudio: Clear embedded terminal upon opening a different project 2021-08-22 10:30:06 +02:00
Lennon Donaghy
6076deae1d HackStudio: Clear ToDo entries upon opening new project
The ToDoEntries and ToDoEntriesWidget classes now have methods for
clearing the entries, before entries would stay permanently, even after
switching to a new project.
2021-08-22 10:30:06 +02:00
Lennon Donaghy
d48bd49002 HackStudio: Move handle_external_file_deletion logic into own method
Added a close_file_in_all_editors method to HackStudioWidget and moved
the code from handle_external_file_deletion into it so that it can be
reused elsewhere to close files.
2021-08-22 10:30:06 +02:00
Karol Kosek
947b61c1de HackStudio: Update the window title after changing a file name
This is a very similar fix as the previous commit, but here it's
due to my oversight when I was adding an 'Save as..' feature.
2021-08-20 11:47:00 +02:00
Karol Kosek
6e64988396 HackStudio: Update the window title after changing an active editor
Prior this change, the window title was updated only when a new file
has been opened, which means that it wasn't updated when user selected
an already opened file in the split view.

This change updates the title whenever the active editor changes.
In addition, this title update logic has now its own function
as it'll also be used in the next commit. :)
2021-08-20 11:47:00 +02:00
sin-ack
e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00
sin-ack
9c9a5c55cb Userland+LibGUI: Make Margins arguments match CSS ordering
Previously the argument order for Margins was (left, top, right,
bottom). To make it more familiar and closer to how CSS does it, the
argument order is now (top, right, bottom, left).
2021-08-18 10:30:50 +02:00
Andreas Kling
00603d9fd0 Revert "HackStudio: Remove noop code when opening the project"
This reverts commit 012fc3f923.
2021-08-12 20:56:54 +02:00
Karol Kosek
012fc3f923 HackStudio: Remove noop code when opening the project
28b1e66b51 made that
the m_all_editor_wrappers vector is cleared everytime a project path
is changed (the m_project if check is just for the app launch --
the vector is empty there anyway), making the code never execute.
2021-08-12 18:55:58 +02:00
Karol Kosek
a2cb5c862d HackStudio: Show the 'Save as...' dialog when saving uncreated file
Previously when user wanted to save an uncreated file, the program
would just quietly ignore the save request, without giving any message.
This can be seen when creating a new editor in split view mode.
2021-08-12 18:54:57 +02:00
Karol Kosek
8516b9532e HackStudio: Add 'Save as...' action
Not adding it to the toolbar, because it has the same icon as
a typical 'Save' action.
2021-08-12 18:54:57 +02:00
Karol Kosek
8a4bb581a2 HackStudio: Show text editor after starting the application
The user can now start typing text instead of creating a file first.

This also enables drag-and-dropping a file as soon as the application
starts.
2021-08-12 18:54:25 +02:00
Karol Kosek
b1bc5532e7 HackStudio: Make "Open project" action open in the current project path
Prior this change, the action opened a File Picker
in user home directory.

Changing the startup path to a project path might make correcting
the path or switching between different projects a bit faster,
as you don't have to go through the subdirectories all over again.
It's also the path that's showed in the project tree view.
2021-08-11 01:50:33 +02:00
sin-ack
ca2c81251a Everywhere: Replace Model::update() with Model::invalidate()
Most of the models were just calling did_update anyway, which is
pointless since it can be unified to the base Model class. Instead, code
calling update() will now call invalidate(), which functions identically
and is more obvious in what it does.

Additionally, a default implementation is provided, which removes the
need to add empty implementations of update() for each model subclass.

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-08-06 19:14:31 +02:00
Gunnar Beutner
b81926d933 HackStudio: Enable building HackStudio on x86_64
This implements bits and pieces to get the debugging functionality to
build. No testing has been done to check whether it actually works
because GCC doesn't currently work.
2021-08-02 00:57:06 +02:00
Lennon Donaghy
28b1e66b51 HackStudio: Properly close previous project when opening a new one
Previously files in the open files view would stay open from the
previous project, and files in the new project with the same name as
files in the old one would be inaccessible, with the old ones showing
up instead. Now all files and open editors are closed before a new
project is opened.

Fixes #9103
2021-08-01 09:17:02 +02:00
Conor Byrne
6aa2b7d4cc HackStudio: Add GML Preview action tab
This allows us to show a GML Preview in realtime via
HackStudio::GMLPreviewWidget! :^)
2021-07-29 11:33:16 +02:00
Andreas Kling
4dff72fbf7 HackStudio: Tweak splitter spacings in the main UI
The splitters all felt a little bit too small and hard-to-grab.
This patch puts a little more fat on them.
2021-07-28 20:24:56 +02:00
Nicholas Hollett
4857943a71 HackStudio: Resize editors when removing panes
Splitter does weird things when you resize and then remove children.
This works around the limitation by forcing at least one of the editors
to fill the space. It's janky, but at least doesn't result in the last
editor not filling the window.
2021-07-26 23:46:39 +02:00
Andreas Kling
687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Karol Kosek
c66f484bce HackStudio: Continue removing files after failure 2021-07-17 01:11:00 +02:00
Karol Kosek
6e51fe146c HackStudio: Disable Delete action on insufficient permissions
Hack Studio will now disable the action when any parent
of selected files do not have write permission.
2021-07-17 01:11:00 +02:00