diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e6add69..7f54a80 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,12 +4,10 @@
-
+
-
-
@@ -123,7 +121,8 @@
1660688177518
-
+
+
1660688283740
@@ -153,7 +152,14 @@
1660746908828
-
+
+ 1660748344882
+
+
+
+ 1660748344882
+
+
@@ -176,6 +182,7 @@
-
+
+
\ No newline at end of file
diff --git a/src/main/java/net/william278/paginedown/ListOptions.java b/src/main/java/net/william278/paginedown/ListOptions.java
index 5cbb5b2..eafbd9d 100644
--- a/src/main/java/net/william278/paginedown/ListOptions.java
+++ b/src/main/java/net/william278/paginedown/ListOptions.java
@@ -40,6 +40,10 @@ public class ListOptions {
protected String itemSeparator = "\n";
protected int itemsPerPage = 10;
+ protected int pageJumperStartButtons = 3;
+
+ protected int pageJumperEndButtons = 3;
+
private ListOptions() {
}
@@ -150,6 +154,18 @@ public class ListOptions {
return this;
}
+ @NotNull
+ public Builder setPageJumperStartButtons(final int pageJumperStartButtons) {
+ options.pageJumperStartButtons = pageJumperStartButtons;
+ return this;
+ }
+
+ @NotNull
+ public Builder setPageJumperEndButtons(final int pageJumperEndButtons) {
+ options.pageJumperEndButtons = pageJumperEndButtons;
+ return this;
+ }
+
@NotNull
public ListOptions build() {
return options;
diff --git a/src/main/java/net/william278/paginedown/PaginatedList.java b/src/main/java/net/william278/paginedown/PaginatedList.java
index 4e8a336..8cb637d 100644
--- a/src/main/java/net/william278/paginedown/PaginatedList.java
+++ b/src/main/java/net/william278/paginedown/PaginatedList.java
@@ -259,7 +259,7 @@ public class PaginatedList {
StringJoiner pages = new StringJoiner(options.pageJumperPageSeparator);
int lastPage = 1;
for (int i = 1; i <= getTotalPages(); i++) {
- if (i < 3 || i > getTotalPages() - 2 || page == i) {
+ if (i <= options.pageJumperStartButtons || i > getTotalPages() - options.pageJumperEndButtons || page == i) {
if (i - lastPage > 1) {
pageGroups.add(pages.toString());
pages = new StringJoiner(options.pageJumperPageSeparator);
diff --git a/src/test/java/net/william278/paginedown/PaginatedListTests.java b/src/test/java/net/william278/paginedown/PaginatedListTests.java
index 8ef2aca..a051123 100644
--- a/src/test/java/net/william278/paginedown/PaginatedListTests.java
+++ b/src/test/java/net/william278/paginedown/PaginatedListTests.java
@@ -38,6 +38,8 @@ public class PaginatedListTests {
final PaginatedList longList = PaginatedList.of(generateListData(200, "Item #"),
new ListOptions.Builder()
.setItemsPerPage(10)
+ .setPageJumperStartButtons(2)
+ .setPageJumperEndButtons(2)
.setPageJumperPageFormat("%target_page_index%")
.setPageJumperCurrentPageFormat("%current_page%")
.build());
@@ -52,6 +54,8 @@ public class PaginatedListTests {
final PaginatedList mediumList = PaginatedList.of(generateListData(45, "Item #"),
new ListOptions.Builder()
.setItemsPerPage(10)
+ .setPageJumperStartButtons(2)
+ .setPageJumperEndButtons(2)
.setPageJumperPageFormat("%target_page_index%")
.setPageJumperCurrentPageFormat("%current_page%")
.build());
@@ -65,6 +69,8 @@ public class PaginatedListTests {
final PaginatedList shortList = PaginatedList.of(generateListData(20, "Item #"),
new ListOptions.Builder()
.setItemsPerPage(10)
+ .setPageJumperStartButtons(2)
+ .setPageJumperEndButtons(2)
.setPageJumperPageFormat("%target_page_index%")
.setPageJumperCurrentPageFormat("%current_page%")
.build());