4
4
import java .util .Objects ;
5
5
6
6
/**
7
- * Wrapper for {@link String} to use inside of th Dear ImGui input widgets.
7
+ * Wrapper for {@link String} to use inside th Dear ImGui input widgets.
8
8
*/
9
- public final class ImString implements Cloneable {
9
+ public final class ImString implements Cloneable , Comparable < ImString > {
10
10
/**
11
11
* Default size of the inner buffer, if {@link ImString} created with a constructor without args.
12
12
*/
@@ -17,8 +17,8 @@ public final class ImString implements Cloneable {
17
17
public static final short CARET_LEN = 1 ;
18
18
19
19
/**
20
- * Configuration class to setup some specific behaviour for current string.
21
- * This is useful when string used inside of ImGui#InputText*() methods.
20
+ * Configuration class to set up some specific behaviour for current string.
21
+ * This is useful when string used inside ImGui#InputText*() methods.
22
22
*/
23
23
public final InputData inputData = new InputData ();
24
24
@@ -32,6 +32,7 @@ public ImString() {
32
32
this (DEFAULT_LENGTH );
33
33
}
34
34
35
+ @ SuppressWarnings ("CopyConstructorMissesField" )
35
36
public ImString (final ImString imString ) {
36
37
this (imString .text , imString .data .length );
37
38
this .inputData .allowedChars = imString .inputData .allowedChars ;
@@ -44,6 +45,7 @@ public ImString(final ImString imString) {
44
45
45
46
/**
46
47
* Creates an {@link ImString} instance with provided size for the inner buffer.
48
+ *
47
49
* @param length size of the inner buffer to use
48
50
*/
49
51
public ImString (final int length ) {
@@ -53,6 +55,7 @@ public ImString(final int length) {
53
55
/**
54
56
* Creates an {@link ImString} instance from provided string.
55
57
* Inner buffer size will be equal to the length of the string + {@link ImString#CARET_LEN}.
58
+ *
56
59
* @param text string to create a new {@link ImString}
57
60
*/
58
61
public ImString (final String text ) {
@@ -61,7 +64,8 @@ public ImString(final String text) {
61
64
62
65
/**
63
66
* Create an {@link ImString} instance from provided string with custom size for the inner buffer.
64
- * @param text string to a create a new {@link ImString}
67
+ *
68
+ * @param text string to a creation a new {@link ImString}
65
69
* @param length custom size for the inner buffer
66
70
*/
67
71
public ImString (final String text , final int length ) {
@@ -140,30 +144,32 @@ byte[] resizeInternal(final int newSize) {
140
144
}
141
145
142
146
/**
143
- * Get the length of the text inside of the data buffer.
144
- * @return length of the text inside of the data buffer
147
+ * Get the length of the text inside the data buffer.
148
+ *
149
+ * @return length of the text inside the data buffer
145
150
*/
146
151
public int getLength () {
147
152
return get ().length ();
148
153
}
149
154
150
155
/**
151
156
* Get the size of the data buffer. Buffer size will always have '+1' to its size, since it's used by the Dear ImGui to draw a caret char.
157
+ *
152
158
* @return size of the data buffer
153
159
*/
154
160
public int getBufferSize () {
155
161
return data .length ;
156
162
}
157
163
158
164
/**
159
- * @return true if the length of the text inside of the data buffer is 0
165
+ * @return true if the length of the text inside the data buffer is 0
160
166
*/
161
167
public boolean isEmpty () {
162
168
return getLength () == 0 ;
163
169
}
164
170
165
171
/**
166
- * @return true if the length of the text inside of the data buffer is not 0
172
+ * @return true if the length of the text inside the data buffer is not 0
167
173
*/
168
174
public boolean isNotEmpty () {
169
175
return !isEmpty ();
@@ -199,10 +205,16 @@ public int hashCode() {
199
205
}
200
206
201
207
@ Override
208
+ @ SuppressWarnings ("MethodDoesntCallSuperMethod" )
202
209
public ImString clone () {
203
210
return new ImString (this );
204
211
}
205
212
213
+ @ Override
214
+ public int compareTo (final ImString o ) {
215
+ return get ().compareTo (o .get ());
216
+ }
217
+
206
218
/**
207
219
* Use this class to customize your ImGui input.
208
220
*/
@@ -216,7 +228,7 @@ public static final class InputData {
216
228
public String allowedChars = "" ;
217
229
218
230
/**
219
- * If true, then string will be resized during the the {@link imgui.ImGui#inputText} and {@link imgui.ImGui#inputTextMultiline} methods.
231
+ * If true, then string will be resized during the {@link imgui.ImGui#inputText} and {@link imgui.ImGui#inputTextMultiline} methods.
220
232
* Alternatively you can provide {@link imgui.flag.ImGuiInputTextFlags#CallbackResize} flag to the input text widgets to enable string resizing.
221
233
* Resize factor of the string could be modified by changing {@link #resizeFactor} field.
222
234
*/
0 commit comments