Commit graph

86 commits

Author SHA1 Message Date
Tobias Hunger
ffd80ad89c slintpad: Make editor follow the selection
In slintpad the editor should follow the selection in the live preview
closely. So always ask to get focus and make sure to switch to the
editor that asks to get focused.
2025-04-17 21:57:38 +02:00
Tobias Hunger
33928e4958 lsp: Do not send status nmessages
Nigel says those are annoying as they tend to overstay
their welcome.
2025-02-11 11:29:01 +01:00
Tobias Hunger
b0fe8d6cfb live-preview: Handle document deletion better 2024-11-27 18:04:54 +01:00
Tobias Hunger
3d3bf9f01b lsp: Pass invalidation of files on to live-preview 2024-10-10 09:31:11 +02:00
Tobias Hunger
e62d9e0695 lsp: Remember which files are open in the editor
... and ignore them on file change notifications: The
Editor manages the file content, so we do not need to
care for the on-disk content for these files.
2024-10-10 09:31:11 +02:00
Tobias Hunger
d87833a6bd lsp: Add a filesystem watch request to our LS
Get a notification of any file change/deleteion. This feels like
overdoing it a bit, but we need to reload when resources change
and those can be anything.
2024-10-10 09:31:11 +02:00
Tobias Hunger
41bdadd960 live-preview: Add a CodeButton component
... and use it in places
2024-09-17 18:39:37 +02:00
Tobias Hunger
0713a91b87 lsp: Make DocumentCache constructible from a TypeLoader
... while making sure we have all the extra information around that
we need to keep the DocumentCache snap-shottable.
2024-08-21 16:55:13 +02:00
Tobias Hunger
c8952cc20f live-preview: Report document version number with diagnostics
... in the hope that VSCode will invalidate the diagnostics when they
apply to outdated versions:-)
2024-08-21 16:55:13 +02:00
Olivier Goffart
21e67e27a7 LSP: Report error through the LSP when the preview can't open
Instead of panicking the whole server

Issue #204
2024-08-08 12:05:52 +02:00
Olivier Goffart
3c08a71d21 LSP: refactor error reporting of request
So we have accurate error code reported to the LSP when a request fails
2024-08-08 12:05:52 +02:00
Olivier Goffart
4c0bfa269d LSP: refactor send_notification to use the Notification trait
This ensure there is no typo in the method name
2024-07-23 14:18:39 +02:00
Tobias Hunger
bc35d49328 lsp: Remove UpdateElement Preview-to-LS-message
We can do that inside the Live preview now and just return the
WorkspaceEdit.
2024-06-25 19:51:59 +02:00
Tobias Hunger
9afb3812bf lsp: Move properties.rs into common 2024-06-25 19:51:59 +02:00
Tobias Hunger
3e117c1910 lsp: Modernize properties.rs
... to prepare moving it into common.
2024-06-25 19:51:59 +02:00
Tobias Hunger
c335ac9202 janitor: Allow "clippy::await_holding_refcell_ref" in tools/lsp
There is no way we can avoid that RefCell being held, so quieten
the wrrning.
2024-06-24 14:59:47 +02:00
Tobias Hunger
fccb4de8a0 lsp: Move PreviewConfig out of DocumentCache 2024-06-12 10:15:29 +02:00
Tobias Hunger
a759fa72d2 lsp: Move DocumentCache into common 2024-06-12 10:15:29 +02:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Tobias Hunger
3ba59dad46 lsp: Use ElementRcNode when handling properties
We recently got better support for inlined elements. Use
The `ElementRcNode` when accessing properties, so that
we can actually have a better idea which SyntaxNode we
need to work on.

This is actually not too critical as the LSP does little
inlining, but I wanted to reuse this on the preview side
as well, which does inlining much more aggressively.

Do NOT access properties in the live preview though:
It is heavily optiomized, so most properties are just
gone there;-)
2024-03-05 13:10:41 +01:00
Tobias Hunger
3ad3a42656 live preview: Do import handling in drop_location
Remove the AddComponent and the AdjustSelection messages
from the communication between LSP and preview.

Also remove the code to delete an element.
2024-03-01 18:54:40 +01:00
Tobias Hunger
a0b862b096 live preview: Delete an element again
* Refactor the code a bit: Move element edit functions
  into the `element_edit` module below `language`
2024-02-28 15:53:49 +01:00
Tobias Hunger
08372e5a07 live preview: Implement resizing and moving of selected eleement
Much polish needed, but it is a basis to build upon.
2024-02-19 22:27:32 +01:00
Tobias Hunger
b615baf98d live preview: Implement dropping an Element onto the canvas
... and make it show up in the code/live preview.

Currently layouts are not supported and it will try to drop
onto elements not accepting children.

But it does add the necessary import statement already.
2024-02-13 17:03:58 +01:00
Tobias Hunger
6dbbc761e4 LSP: Add some getters to common data structs
Just for convenience :-)
2024-02-12 12:44:22 +01:00
Tobias Hunger
b9ae753edd lsp: Make it clearer what is sent to the editor
Move the code that sends to the editor from within the LSP and the live
preview into a module in common.

This makes it clearer what actually happens and allows to remove some
code from the preview that does not really belong there.
2024-02-09 15:24:13 +01:00
Waqar Ahmed
f999f17421 Move slint-fmt into slint-lsp
fmt is now a part of the slint-lsp and can be invoked as:

```
slint-lsp format [OPTIONS] [FILES]
```
2024-02-06 13:47:06 +01:00
Olivier Goffart
804971d5f6 Alsways use a Url in PreviewToLspMessage::ShowDocument
The messages serialized through the LSP should use the LSP's url type.
And keep type information as long as possible.

Otherwise, we'd end up in show_document_request_from_element_callback
with either an URL or a path, depending if the preview is native or not,
and that would fail when re-serializing to an URL to send back to
through the LSP
2024-01-25 18:55:15 +01:00
Olivier Goffart
5b0ee206be LSP: Simplify the lsp to preview messaging
Don't use a trait, but always dispatch through  a LspToPreviewMessage
2024-01-25 18:55:15 +01:00
Olivier Goffart
7d255a1a18 Fix (native) preview not taking account change in other files than the main file
Because it wouldn't take the files from the cache
2024-01-25 14:44:30 +01:00
Tobias Hunger
19cf90a319 lsp: Send document versions from lsp to previewer
We want the previewer to become interactive, so we need to pass on the
document versions so we can detect the editor, lsp and previewer going
out of sync.
2024-01-15 14:46:39 +01:00
Tobias Hunger
9e5806cfe8 lsp: Use lsp_types::Range over lots of usize 2023-12-20 19:28:35 +01:00
Tobias Hunger
d785f2d5df compiler: Store an optional version number with the document
A None value means the file on disk is the golden version.

We have an editor, the LSP and the preview that all need to at least
notice when they have newer data then their peers. So IMHO it makes
sense to have an optional document version around.

The language server protocol makes use of a version number already. This
patch moves that code into the compiler so that it is stored with the
actual data getting versioned.
2023-12-18 14:21:50 +01:00
Olivier Goffart
184cb5f580 LSP: Simplify the preview config handling
- Put the config in a struct so its easier to pass around
 - respect the command line args as default for the style
 - fix compilation without the preview feature
2023-11-24 14:08:06 +01:00
Olivier Goffart
26e8d308b7 LSP: rename and fix the hide toolbar option
- rename the command line option to --no-toolbar
 - Make it default to not hide the toolbar (so it is visible by default)
2023-11-24 14:08:06 +01:00
Tobias Hunger
548f10be2b lsp: Add option to show/hide preview ui
... and use that option in VSCode configuration.
2023-11-23 20:44:06 +01:00
Olivier Goffart
73a6ec910b LSP: hold the recursion guard in process_preview_to_lsp_message
This is the only non-trivial wasm_bindgen function that doesn't have it

This would cause borrow mut panic as we re-enter while waiting on files
2023-11-08 18:32:26 +01:00
Tobias Hunger
0774d01a59 lsp: Send contents to preview for implicitly loaded slint files
This fixes the no preview in slintpad issue when retrieving the contents
of files is slow (e.g. when loaded from the web).

Fixes: #3855
2023-11-08 17:50:18 +01:00
Tobias Hunger
6206504dca lsp: Do not use a spinner and show errors
... as the UI thread is blocked. Print a status text instead.

Also show errors (if any).

Fixes: #3858
2023-11-07 10:57:54 +01:00
Tobias Hunger
7c38e08347 lsp: Do not panic when showing a document to the user 2023-11-03 22:14:20 +01:00
Tobias Hunger
5bf5b7b02d lsp: Clean up PreviewApi
request_state went the wrong way around wrt. communication flow, so
remove and deduplicate it.
2023-11-03 22:14:20 +01:00
Tobias Hunger
fbb6d70ff9 lsp: Improve design mode handling
* Make sure design mode stays enabled when refreshing the preview. This
  stops the strange click-throughs from happening
* Keep highlighting enabled while in Design Mode
2023-11-03 22:14:20 +01:00
Tobias Hunger
a0a4414b6b lsp: Remember that to preview in WASM mode 2023-11-03 22:14:20 +01:00
Tobias Hunger
d53cebd3e1 lsp: Get signalled by the preview 2023-11-03 22:14:20 +01:00
Tobias Hunger
7d4a73b76c lsp: Make wasm and native previews work
Move code from the native side up into preview.rs as much as possible so
that both previews share as much code as possible.
2023-11-03 22:14:20 +01:00
Tobias Hunger
2aac47b3c6 Change communication of slintpad with Preview
... to route it through the LSP, so that we can have a unified approach
to interact with the Preview UI.
2023-11-03 22:14:20 +01:00
Tobias Hunger
55cc1ae31f lsp: Remove the PostLoadBehavior
We always update if we have a UI and we never update if not. So this
flag does not help.
2023-11-03 22:14:20 +01:00
Tobias Hunger
a0cc85bfb4 LSP: Remove design mode custom commands 2023-11-03 22:14:20 +01:00