How to wirte a pl/sql developer plugin to insert into the special text to the cursor position of current window? - plugins

I'm study how to develop plsql-developer plugin by the plugindoc.pdf and I'm using C++.
Now,I want to insert into the special text to the cursor position of current window,
The function IDE_SetText will Covered the old text in the editor of current window.
IDE_GetCursorX and IDE_GetCursorY get the position of the cursor in the current editor.
What's next?

The PL/SQL Developer editor window implements the standard WinAPI editing control. Use WinAPI messages to interact with the window.
void SetSelection(char *s)
{
int H;
H = IDE_GetEditorHandle();
if (H > 0)
{
SendMessage((HWND)H, EM_REPLACESEL, true, (int)s);
}
}

Related

MAUI Popups, floating windows and containers

I need to get a popup window that is not bound to the main window but will allow me to determine where on the screen should it appear.
Requirements:
I need to be able to decide the size, and location of the new window even if it's on another screen. (I'm already detecting all the screens so this is not an issue)
I need to be able to operate / change values on the main window while the new window stays in place and receives commands from the changing values on the first window and displays them (Text for example)
The new window should be able to display text but also it would be nice if it would be able to receive a background photo/video.
Is it at all possible in MAUI?
I know how to do that in Windows Forms but it looks like Windows Forms ls out of date and it soon will not be supported.
Also MAUI seems to have a nicer appearance out of the box. I really like it but I'm not sure if what I need to do is doable at the moment?
Yes, you can use Multi-window support in MAUI as Jason suggested.
You can call an Action to invoke the method in main window, or communicate with the ViewModel of the main page when you want to receive commands from the changing values on the first window and displays them, see Data binding and MVVM - .NET MAUI | Microsoft Learn
Here's the code snippets below for your reference:
private void OnCounterClicked(object sender, EventArgs e)
      {
Window secondWindow = new Window(new NewPage( FirstImage, "First window String to Second", ( string second) =>
            {
                  CounterBtn.Text = second;
})) ;
var displayInfo = DeviceDisplay.Current.MainDisplayInfo;
secondWindow.X = (displayInfo.Width / displayInfo.Density - Window.Width) / 2;
secondWindow.Y = (displayInfo.Height / displayInfo.Density - Window.Height) / 2;
            Application.Current.OpenWindow(secondWindow);
}
public NewPage(Image firstImage, string firstTitle, Action<string> firstTitleAction)
{
InitializeComponent();
SecontTitleLabel.Text = firstTitle;//get the text from first window
firstTitleAction("SecondTitle");
}

ProseMirror / Tiptap: how to ScrollIntoView without focus?

I am working on a note-taking app that uses ProseMirror as the editor. I want to achieve the feature that when the user searches, the editor will automatically scroll to the most relevant position calculated by other functions. Meanwhile, the search bar should NOT lose the input focus so the user can modify the search content. Therefore, the straightforward way of
editor.chain().focus().setTextSelection().run()
would not work.
I have found a way to set the editor selection without focus. But the view is not scrolled. I need it to scroll to the new selection.
Here is an illustration of the scenario
I tried
editor.commands.scrollIntoView()
It does not work. But
editor.commands.setTextSelection()
does change the selection of editor.view.
You can use ProseMirror directly (instead of TipTap objects), or finding the DOM node worked for me too:
/**
* Scrolls to the current position/selection of the document. It does the same as scrollIntoView()
* but without requiring the focus on the editor, thus it can be called from the search box while
* typing or in shopping mode when the editor is disabled.
* #param {Editor} editor - A TipTap editor instance.
*/
function scrollToSelection(editor: Editor): void {
const { node } = editor.view.domAtPos(editor.state.selection.anchor);
if (node) {
(node as any).scrollIntoView?.(false);
}
}
Copied from SilentNotes

net Maui text Editor text cursor issue

I am developing a simple app using Maui .net but facing some challenge perhaps you can give some advice.
I have a multiline text field of type "Editor" and I have one button. The onclicked event of the button should insert the button label text into the Editor mentioned above (very simple task). Now, the issue is when I use the myEditor.Text.Insert(myEditor.Text.Length, myButton.Text) the inserted text inserts fine, but the blinking text cursor moves to the far left of the Editor field, instead of staying at the far right.
I tried working around this issue but manually moving the text cursor using the myEditor.CursorPosition but the problem is what if the user decided to manually change text cursor location? then pressing the button would insert at the myEditor.Text.Length index, thus ignoring the user's intent to insert the text at a specified index.
I wasn't able to find a method that triggers an event when the text cursor moves inside a text Editor in Maui (so that I can handle it in my own way)
Note: When typing using the Android keyboard, there are no issues at all. but only if inserting text programmatically using .Insert(index,string)
Thanks.
You can try to use the handler to get the cursor position when you insert the text into the Editor.
Declare the control on the android platform:
#if ANDROID
AppCompatEditText nativeEditText;
#endif
Create the method which can get the control's cursor position for android:
void GetCursorPosition ()
{
Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>
{
#if ANDROID
nativeEditText = handler.PlatformView;
});
}
Add code in the button's clicked event:
int cursorPosition = 0;
private void Button_Clicked(object sender, EventArgs e)
{
cursorPosition = nativeEditText.SelectionStart; //get the cursor position if user chooses a position by tapping the editor
string insertText = button.Text;
if (nativeEditText.IsFocused == true)
{
editor.Text = editor.Text.Insert(cursorPosition, insertText);
editor.CursorPosition = cursorPosition + insertText.Length;
//set the position at the end of text inserted
}
else
{
editor.Text = editor.Text.Insert(editor.Text.Length, insertText);
}
}
Updating Visual Studio to version 17.3.0 Preview 5.0 fixed the issue without further tweaks. This fix came in parallel with the time I was facing this issue and looking for a fix 😅

Freezing the tool tip after clicking on it

I am trying use org.eclipse.jface.window.DefaultToolTip to display some UI components like checkbox,radio buttons placed on composite. When user clicks on a text, the tooltip with pops up to and displays the UI components.
Issue: I want to freeze tool tip once user clicks inside this tooltip. Using toolTip.setHideOnMouseDown(false); I am able to check/un-check the check boxes/radio buttons as long as I am inside the tool tip area. Once mouse pointer exits the tool tip area, the tooltip disappears. How can this be avoided. I am looking for similar behaviour which is available for eclipse tooltips( javadoc, method definition). In Eclipse tooltip, if we click/press f2, tooltip will remain active until we click outside of the tooltip area.
Edit: I also tried to use Eclipse Plugin Spy on tooltip, but no success.
Any thoughts.
What Eclipse does when F2 is pressed is to create a new Shell with exactly the same size and contents as the tooltip and closes the original tooltip.
I use code like the following in an extended tooltip class:
/**
* Switch from tool tip to a normal window.
*/
private void showWindow()
{
if (_control.isDisposed())
return;
final Shell shell = new Shell(_control.getShell(), SWT.CLOSE | SWT.ON_TOP | SWT.RESIZE);
shell.setLayout(new FillLayout());
createBody(shell);
final Point currLoc = _parent.getShell().getLocation();
final Rectangle client = _parent.getClientArea();
final Rectangle bounds = shell.computeTrim(currLoc.x, currLoc.y, client.width, client.height);
shell.setBounds(bounds);
shell.open();
// Hide the tool tip window
hide();
}
_control is the control passed to the constructor.

Get notified when cursor position changed in Eclipse TextEditor

I am developing a plugin to eclipse and I want to add some actions to the context menu. But actually I wanted to prepare results beforehead according to the text selection in the editor and just show them when the menu item will be selected.
I followed that article http://www.eclipse.org/articles/Article-WorkbenchSelections/article.html - all interfaces (ISelectionListener, ISelectionChangedListener etc) allow to handle the SelectionChanged event, but editor counts changing only when length of selection also changes - so the simple click in the editor doesn't fire the event, although I want to get the word (for example) as a selection if cursor is inside the word now and lenght is 0.
So the question is - what is the simpliest solution for traking down cursor position/offset/selections with zero lengh value changing?
In that case you have to use KeyListener and MouseListener as well. For e.g take a look at org.eclipse.jface.text.PaintManager, and it listens to all these events.
If you are extending TextEditor you can override handleCursorPositionChanged() method to fire your event and use getCursorPosition() to get the cursor position as a String.