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

Double click on citation opens LaTeX editor #12044

Merged
merged 35 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
066bbab
First version of the double click issue
u7465990 Oct 20, 2024
b0821bf
First version to use double click to open TeXstudio
u7465990 Oct 20, 2024
87b5750
Merge branch 'main' into feature-latex-editor#11996
u7465990 Oct 20, 2024
84fdf95
change the click count to two
u7465990 Oct 20, 2024
7f95c8b
I set the GitHub page for the test
u7465990 Oct 20, 2024
a41d5dd
Replace exec() with ProcessBuilder and printStackTrace() with LOGGER
u7465990 Oct 20, 2024
677c604
change some useless functions
u7465990 Oct 22, 2024
52158ee
I solve the csl-styles submodel problem
u7465990 Oct 22, 2024
eef355e
Solve the avvrv.jabref.org conflict
u7465990 Oct 22, 2024
998659c
The double click function works fine for the emacs external program
u7465990 Oct 23, 2024
1c22c56
The double click function works fine for the TeXworks external program
u7465990 Oct 23, 2024
0a655ff
Merge remote-tracking branch 'origin/main' into feature-latex-editor#…
koppor Oct 23, 2024
8294e73
I changed the required code. I also delete some useless comment. I ma…
u7465990 Oct 23, 2024
45c6777
finished texWorks and delete some comments
u7465990 Oct 23, 2024
ac62f2d
delete some comments
u7465990 Oct 23, 2024
0731c36
solve conflicts
u7465990 Oct 23, 2024
1387c4b
Merge branch 'feature-latex-editor#11996' of https://github.com/u7465…
u7465990 Oct 23, 2024
6bf9f30
solve untrack files
u7465990 Oct 23, 2024
1372e2a
I make Sublime Text works for this feature
u7465990 Oct 23, 2024
7944ee3
I make WinEdt works for this feature
u7465990 Oct 23, 2024
85fa67e
delete some command and change jumpString to jumpToLineCommandlineArg…
u7465990 Oct 23, 2024
d120835
Fix csl-styles
u7465990 Oct 23, 2024
6afaaef
Fix abbrv.jabref.org submodules
u7465990 Oct 23, 2024
b7b2312
I make Vim works for this feature
u7465990 Oct 23, 2024
b5040b3
I rewrite jumpToLine for TexShop. But I don't hava a Mac OS machine. …
u7465990 Oct 23, 2024
5d0bbfb
Delete the JumpToLine in TeXshop and a comment line in TeXstudio
u7465990 Oct 23, 2024
ac33148
Fix submodules (and wrong file)
koppor Oct 23, 2024
2d456a5
Merge remote-tracking branch 'origin/main' into feature-latex-editor#…
koppor Oct 23, 2024
f48766b
Fix empty lines
koppor Oct 23, 2024
b6bbf06
Default should be TeXstudio
koppor Oct 23, 2024
e117247
Remvoe "Integer.format" (and add test)
koppor Oct 23, 2024
551b074
Fix PushToVim
koppor Oct 23, 2024
61395fa
Cleanup PushToLyx
koppor Oct 23, 2024
aeedbb4
Refactor PushToVim
koppor Oct 23, 2024
3b9fbac
Add CHANGELOG.md entry
koppor Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/on-review-submitted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: On reviewed PR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this appearing - I removed in main. Please remove this file from your branch.


on:
pull_request_review:
types:
- submitted

jobs:
add-label-changes-required:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- run: echo ${{ github.event.review.state }}
- if: ${{ github.event.review.state == 'changes_requested' }}
run: |
gh pr edit "$PR_URL" --remove-label "status: ready-for-review"
gh pr edit "$PR_URL" --add-label "status: changes required"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{ github.token }}
Empty file added feature-latex-editor#11996
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private void setSearchPane() {
citationsDisplay.basePathProperty().bindBidirectional(viewModel.directoryProperty());
citationsDisplay.setItems(viewModel.getCitationList());

citationsDisplay.setOnMouseClicked(event -> viewModel.handleMouseClick(event, citationsDisplay));
RowConstraints mainRow = new RowConstraints();
mainRow.setVgrow(Priority.ALWAYS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;

import org.jabref.gui.AbstractViewModel;
import org.jabref.gui.DialogService;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.push.PushToApplication;
import org.jabref.gui.push.PushToApplications;
import org.jabref.gui.push.PushToEmacs;
import org.jabref.gui.texparser.CitationsDisplay;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.gui.util.UiTaskExecutor;
import org.jabref.logic.l10n.Localization;
Expand Down Expand Up @@ -154,6 +160,22 @@ public void onDirectoryDelete(File directory) {
};
}

public void handleMouseClick(MouseEvent event, CitationsDisplay citationsDisplay) {
Citation selectedItem = citationsDisplay.getSelectionModel().getSelectedItem();

if (event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 2 && selectedItem != null) {
String applicationName = preferences.getPushToApplicationPreferences()
.getActiveApplicationName();
PushToApplication application = PushToApplications.getApplicationByName(
applicationName,
dialogService,
preferences)
.orElse(new PushToEmacs(dialogService, preferences));
preferences.getPushToApplicationPreferences().setActiveApplicationName(application.getDisplayName());
application.jumpToLine(selectedItem.path(), selectedItem.line(), selectedItem.colStart());
}
}

public void bindToEntry(BibEntry entry) {
checkAndUpdateDirectory();

Expand Down
25 changes: 25 additions & 0 deletions src/main/java/org/jabref/gui/push/AbstractPushToApplication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.push;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -181,4 +182,28 @@ public Optional<KeyBinding> getKeyBinding() {
return Optional.of(KeyBinding.PUSH_TO_APPLICATION);
}
}

public void jumpToLine(Path fileName, int line, int column) {
commandPath = preferences.getPushToApplicationPreferences().getCommandPaths().get(this.getDisplayName());

if (StringUtil.isNullOrEmpty(commandPath)) {
notDefined = true;
return;
}

String[] command = jumpString(fileName, line, column);
ProcessBuilder processBuilder = new ProcessBuilder();
try {
processBuilder.command(command);
processBuilder.start();
} catch (IOException excep) {
LOGGER.warn("Error: Could not call executable '{}'", commandPath, excep);
couldNotCall = true;
}
}

protected String[] jumpString(Path fileName, int line, int column) {
koppor marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.error("Not yet implemented");
return new String[0];
}
}
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/push/PushToApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jabref.gui.push;

import java.nio.file.Path;
import java.util.List;

import org.jabref.gui.actions.Action;
Expand Down Expand Up @@ -56,4 +57,6 @@ public interface PushToApplication {
PushToApplicationSettings getSettings(PushToApplication application, PushToApplicationPreferences pushToApplicationPreferences);

String getDelimiter();

void jumpToLine(Path fileName, int line, int column);
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static String getKeyString(List<BibEntry> entries, String delimiter) {
for (BibEntry bes : entries) {
citeKey = bes.getCitationKey();
if (citeKey.isEmpty() || citeKey.get().isEmpty()) {
// Should never occur, because we made sure that all entries have keys
koppor marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.warn("Should never occur, because we made sure that all entries have keys");
continue;
}
if (first) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/jabref/gui/push/PushToEmacs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -147,4 +148,9 @@ protected String getCommandName() {
public PushToApplicationSettings getSettings(PushToApplication application, PushToApplicationPreferences preferences) {
return new PushToEmacsSettings(application, dialogService, this.preferences.getFilePreferences(), preferences);
}

@Override
protected String[] jumpString(Path fileName, int line, int column) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to jumpToLineCommandlineArguments (or similar)

return new String[] {commandPath, "+%s".formatted(line), fileName.toString()};
}
}
7 changes: 7 additions & 0 deletions src/main/java/org/jabref/gui/push/PushToLyx.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.List;

import org.jabref.gui.DialogService;
Expand Down Expand Up @@ -95,4 +96,10 @@ public void pushEntries(BibDatabaseContext database, final List<BibEntry> entrie
}
});
}

@Override
protected String[] jumpString(Path fileName, int line, int column) {
LOGGER.warn("not implemented");
return new String[0];
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/push/PushToSublimeText.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ protected String[] getCommandLine(String keyString) {
return new String[] {"sh", "-c", "\"" + commandPath + "\"" + " --command 'insert {\"characters\": \"" + citeCommand + keyString + getCiteSuffix() + "\"}'"};
}
}

@Override
protected String[] jumpString(Path fileName, int line, int column) {
return new String[] {commandPath, "%s:%s:%s".formatted(fileName.toString(), line, column)};
}
}
8 changes: 8 additions & 0 deletions src/main/java/org/jabref/gui/push/PushToTeXstudio.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.push;

import java.nio.file.Path;

import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
Expand Down Expand Up @@ -27,4 +29,10 @@ public JabRefIcon getApplicationIcon() {
protected String[] getCommandLine(String keyString) {
return new String[] {commandPath, "--insert-cite", "%s%s%s".formatted(getCitePrefix(), keyString, getCiteSuffix())};
}

@Override
public String[] jumpString(Path fileName, int line, int column) {
// Construct the TeXstudio command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remvoe comment. It is clear from the context.

return new String[] {commandPath, "--line", Integer.toString(line), fileName.toString()};
}
}
8 changes: 8 additions & 0 deletions src/main/java/org/jabref/gui/push/PushToTeXworks.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.push;

import java.nio.file.Path;

import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
Expand Down Expand Up @@ -33,4 +35,10 @@ public JabRefIcon getApplicationIcon() {
protected String[] getCommandLine(String keyString) {
return new String[] {commandPath, "--insert-text", "%s%s%s".formatted(getCitePrefix(), keyString, getCiteSuffix())};
}

@Override
protected String[] jumpString(Path fileName, int line, int column) {
// didn't find any command to jump to a specific line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// didn't find any command to jump to a specific line
// No command known to jump to a specific line

return new String[] {commandPath, fileName.toString()};
}
}
7 changes: 7 additions & 0 deletions src/main/java/org/jabref/gui/push/PushToTexmaker.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.push;

import java.nio.file.Path;

import org.jabref.gui.DialogService;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.icon.JabRefIcon;
Expand Down Expand Up @@ -30,4 +32,9 @@ public JabRefIcon getApplicationIcon() {
protected String[] getCommandLine(String keyString) {
return new String[] {commandPath, "-insert", getCitePrefix() + keyString + getCiteSuffix()};
}

@Override
protected String[] jumpString(Path fileName, int line, int column) {
return new String[] {commandPath, "-line", Integer.toString(line), fileName.toString()};
}
}
2 changes: 1 addition & 1 deletion src/main/resources/csl-locales
Loading