mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-12 00:17:51 +00:00
Added ability to have the NEI search be auto-focused on open. (#492)
* Added open to have the NEI search be auto-focused on open. It will automatically blue if the mouse is moved before typing anything so immediate 'r' and such use works as expected. * Added open to have the NEI search be auto-focused on open. It will automatically blue if the mouse is moved before typing anything so immediate 'r' and such use works as expected. * Add an allowlist for what classnames to allow the search auto-focus to work on * sa * Add `INEIAutoFocusSearchEnable` interface for opting in to autofocus search box by a mod. Moved the autofocus list from config into a standalone file at the loss of live-updating. * Remove now-superfluous lang entries for search focus prefix allowlist * Undo intellij automatic star-imports... --------- Co-authored-by: Martin Robertz <dream-master@gmx.net>
This commit is contained in:
1 parent
dc4426d9c9
commit
8da541460f
7 files changed
+107
-1
No files matched your search
@@ -225,6 +225,30 @@ public class ClientHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadEnableAutoFocus() {
|
||||
File file = NEIClientConfig.enableAutoFocusFile;
|
||||
if (!file.exists()) {
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
NEIClientConfig.logger.info("Creating default enable auto focus list {}", file);
|
||||
URL defaultEnableAutoFocusResource = ClientHandler.class
|
||||
.getResource("/assets/nei/cfg/enableautofocus.cfg");
|
||||
if (defaultEnableAutoFocusResource != null) {
|
||||
IOUtils.copy(defaultEnableAutoFocusResource.openStream(), writer);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to save default enable auto focus list to file {}", file, e);
|
||||
}
|
||||
}
|
||||
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
NEIClientConfig.logger.info("Loading enable auto focus from file {}", file);
|
||||
NEIClientConfig.enableAutoFocusPrefixes = IOUtils.readLines(reader).stream()
|
||||
.filter((line) -> !line.startsWith("#")).collect(Collectors.toCollection(ArrayList::new));
|
||||
} catch (IOException e) {
|
||||
NEIClientConfig.logger.error("Failed to load enable auto focus from file {}", file, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
instance = new ClientHandler();
|
||||
|
||||
|
||||
Reference in new issue
Block a user