Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SublimeText to external programs #10098

Closed
AdamWysokinski opened this issue Jul 19, 2023 · 4 comments · Fixed by #10104
Closed

add SublimeText to external programs #10098

AdamWysokinski opened this issue Jul 19, 2023 · 4 comments · Fixed by #10104
Labels
good first issue An issue intended for project-newcomers. Varies in difficulty. type: enhancement

Comments

@AdamWysokinski
Copy link
Contributor

Hi, this has been asked few years ago: could you add editor SublimeText to external programs?

@Siedlerchr
Copy link
Member

I have never used sublime, but it seem this could be possible:
It offers a command line modus. https://www.sublimetext.com/docs/command_line.html

and I see there is an option to pass commands through the cli
https://docs.sublimetext.io/guide/extensibility/commands.html#from-command-line-cli

Text inserting seems to be the the append command:
https://docs.sublimetext.io/reference/commands.html#commands

It would be very helpful if you could provide us a simple cli command for inserting text, that makes it easier for integration.

Codewise the related code is located here:
https://github.com/JabRef/jabref/tree/34ac6d1b872199adff80e75370deb1d2cd64b8c2/src/main/java/org/jabref/gui/push

@AdamWysokinski
Copy link
Contributor Author

AdamWysokinski commented Jul 19, 2023

To insert text to an active tab at the cursor point, use the insert command. Using the CLI, this would be:

subl --command 'insert {"characters": "\\cite{wysokinski_2023}"}'

Note that the \ character has to be escaped. I'm on Linux, subl is by default in the $PATH. On Mac and Window user might have to manually point JabRef to the executable.

@github-project-automation github-project-automation bot moved this to Free to take in Good First Issues Jul 19, 2023
@Siedlerchr Siedlerchr added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Jul 19, 2023
@github-project-automation github-project-automation bot moved this to Normal priority in Features & Enhancements Jul 19, 2023
@AdamWysokinski
Copy link
Contributor Author

I'm not a Java programmer, but wouldn't this piece of code (PushToSublimeText.java) solve the issue:

package org.jabref.gui.push;

import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
import org.jabref.preferences.PreferencesService;

/**
 * Class for pushing entries into SublimeText.
 */
public class PushToTexmaker extends AbstractPushToApplication {

    public static final String NAME = "SublimeText";

    public PushToSublimeText(DialogService dialogService, PreferencesService preferencesService) {
        super(dialogService, preferencesService);
    }

    @Override
    public String getDisplayName() {
        return NAME;
    }

    @Override
    public JabRefIcon getApplicationIcon() {
        return IconTheme.JabRefIcons.APPLICATION_SUBLIMETEXT;
    }

    @Override
    protected String[] getCommandLine(String keyString) {
        return new String[] {commandPath, "--command \'insert {\"characters\": \"\\", getCiteCommand() + "{" + keyString + "}\"\}\'"};

    }
}

Siedlerchr added a commit that referenced this issue Jul 22, 2023
Siedlerchr added a commit that referenced this issue Jul 22, 2023
@AdamWysokinski
Copy link
Contributor Author

AdamWysokinski commented Jul 22, 2023

I've placed some backslashes incorrectly, I think the returned string should be:

return new String[] {commandPath, "--command \'insert {\"characters\": \"", getCiteCommand() + "{" + keyString + "}\"}\'"};

@ThiloteE ThiloteE moved this from Free to take to In Progress in Good First Issues Jul 25, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Good First Issues Jul 31, 2023
@github-project-automation github-project-automation bot moved this from Normal priority to Done in Features & Enhancements Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue An issue intended for project-newcomers. Varies in difficulty. type: enhancement
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants