26
26
import mdlaf .resources .MaterialFonts ;
27
27
import mdlaf .resources .MaterialImages ;
28
28
29
- import javax .swing .BorderFactory ;
30
- import javax .swing .ImageIcon ;
31
- import javax .swing .UIDefaults ;
29
+ import javax .swing .*;
32
30
import javax .swing .plaf .basic .BasicLookAndFeel ;
33
- import java .awt .Color ;
31
+ import javax .swing .text .DefaultEditorKit ;
32
+ import java .awt .*;
34
33
35
34
public class MaterialLookAndFeel extends BasicLookAndFeel {
36
35
@@ -233,6 +232,11 @@ protected void initComponentDefaults (UIDefaults table) {
233
232
table .put ("TextArea.border" , BorderFactory .createEmptyBorder ());
234
233
table .put ("TextArea.foreground" , Color .BLACK );
235
234
table .put ("TextArea.font" , MaterialFonts .REGULAR );
235
+ table .put ("TextArea.focusInputMap" , multilineInputMap );
236
+
237
+ table .put ("TextPane.focusInputMap" , multilineInputMap );
238
+
239
+ table .put ("EditorPane.focusInputMap" , multilineInputMap );
236
240
237
241
table .put ("ToggleButton.border" , BorderFactory .createEmptyBorder ());
238
242
table .put ("ToggleButton.font" , MaterialFonts .REGULAR );
@@ -257,4 +261,69 @@ protected void initComponentDefaults (UIDefaults table) {
257
261
table .put ("Tree.openIcon" , new ImageIcon (MaterialImages .DOWN_ARROW ));
258
262
table .put ("Tree.selectionBorderColor" , null );
259
263
}
264
+
265
+ private Object multilineInputMap = new UIDefaults .LazyInputMap (new Object []{
266
+ "ctrl C" , DefaultEditorKit .copyAction ,
267
+ "ctrl V" , DefaultEditorKit .pasteAction ,
268
+ "ctrl X" , DefaultEditorKit .cutAction ,
269
+ "COPY" , DefaultEditorKit .copyAction ,
270
+ "PASTE" , DefaultEditorKit .pasteAction ,
271
+ "CUT" , DefaultEditorKit .cutAction ,
272
+ "control INSERT" , DefaultEditorKit .copyAction ,
273
+ "shift INSERT" , DefaultEditorKit .pasteAction ,
274
+ "shift DELETE" , DefaultEditorKit .cutAction ,
275
+ "shift LEFT" , DefaultEditorKit .selectionBackwardAction ,
276
+ "shift KP_LEFT" , DefaultEditorKit .selectionBackwardAction ,
277
+ "shift RIGHT" , DefaultEditorKit .selectionForwardAction ,
278
+ "shift KP_RIGHT" , DefaultEditorKit .selectionForwardAction ,
279
+ "ctrl LEFT" , DefaultEditorKit .previousWordAction ,
280
+ "ctrl KP_LEFT" , DefaultEditorKit .previousWordAction ,
281
+ "ctrl RIGHT" , DefaultEditorKit .nextWordAction ,
282
+ "ctrl KP_RIGHT" , DefaultEditorKit .nextWordAction ,
283
+ "ctrl shift LEFT" , DefaultEditorKit .selectionPreviousWordAction ,
284
+ "ctrl shift KP_LEFT" , DefaultEditorKit .selectionPreviousWordAction ,
285
+ "ctrl shift RIGHT" , DefaultEditorKit .selectionNextWordAction ,
286
+ "ctrl shift KP_RIGHT" , DefaultEditorKit .selectionNextWordAction ,
287
+ "ctrl A" , DefaultEditorKit .selectAllAction ,
288
+ "HOME" , DefaultEditorKit .beginLineAction ,
289
+ "END" , DefaultEditorKit .endLineAction ,
290
+ "shift HOME" , DefaultEditorKit .selectionBeginLineAction ,
291
+ "shift END" , DefaultEditorKit .selectionEndLineAction ,
292
+
293
+ "UP" , DefaultEditorKit .upAction ,
294
+ "KP_UP" , DefaultEditorKit .upAction ,
295
+ "DOWN" , DefaultEditorKit .downAction ,
296
+ "KP_DOWN" , DefaultEditorKit .downAction ,
297
+ "PAGE_UP" , DefaultEditorKit .pageUpAction ,
298
+ "PAGE_DOWN" , DefaultEditorKit .pageDownAction ,
299
+ "shift PAGE_UP" , "selection-page-up" ,
300
+ "shift PAGE_DOWN" , "selection-page-down" ,
301
+ "ctrl shift PAGE_UP" , "selection-page-left" ,
302
+ "ctrl shift PAGE_DOWN" , "selection-page-right" ,
303
+ "shift UP" , DefaultEditorKit .selectionUpAction ,
304
+ "shift KP_UP" , DefaultEditorKit .selectionUpAction ,
305
+ "shift DOWN" , DefaultEditorKit .selectionDownAction ,
306
+ "shift KP_DOWN" , DefaultEditorKit .selectionDownAction ,
307
+ "ENTER" , DefaultEditorKit .insertBreakAction ,
308
+ "BACK_SPACE" , DefaultEditorKit .deletePrevCharAction ,
309
+ "shift BACK_SPACE" , DefaultEditorKit .deletePrevCharAction ,
310
+ "ctrl H" , DefaultEditorKit .deletePrevCharAction ,
311
+ "DELETE" , DefaultEditorKit .deleteNextCharAction ,
312
+ "ctrl DELETE" , DefaultEditorKit .deleteNextWordAction ,
313
+ "ctrl BACK_SPACE" , DefaultEditorKit .deletePrevWordAction ,
314
+ "RIGHT" , DefaultEditorKit .forwardAction ,
315
+ "LEFT" , DefaultEditorKit .backwardAction ,
316
+ "KP_RIGHT" , DefaultEditorKit .forwardAction ,
317
+ "KP_LEFT" , DefaultEditorKit .backwardAction ,
318
+ "TAB" , DefaultEditorKit .insertTabAction ,
319
+ "ctrl BACK_SLASH" , "unselect" /*DefaultEditorKit.unselectAction*/ ,
320
+ "ctrl HOME" , DefaultEditorKit .beginAction ,
321
+ "ctrl END" , DefaultEditorKit .endAction ,
322
+ "ctrl shift HOME" , DefaultEditorKit .selectionBeginAction ,
323
+ "ctrl shift END" , DefaultEditorKit .selectionEndAction ,
324
+ "ctrl T" , "next-link-action" ,
325
+ "ctrl shift T" , "previous-link-action" ,
326
+ "ctrl SPACE" , "activate-link-action" ,
327
+ "control shift O" , "toggle-componentOrientation" /*DefaultEditorKit.toggleComponentOrientation*/
328
+ });
260
329
}
0 commit comments