1 package com.jsql.view.swing.text.action;
2
3 import javax.swing.text.BadLocationException;
4 import javax.swing.text.DefaultEditorKit;
5 import javax.swing.text.Document;
6
7
8
9
10
11 public class DeleteNextCharAction extends AbstractCharAction {
12
13
14
15
16 public DeleteNextCharAction() {
17 super(DefaultEditorKit.deleteNextCharAction);
18 }
19
20 @Override
21 protected void delete(Document doc, int dot) throws BadLocationException {
22 if (dot < doc.getLength()) {
23 var delChars = 1;
24 if (dot < doc.getLength() - 1) {
25 String dotChars = doc.getText(dot, 2);
26 var c0 = dotChars.charAt(0);
27 var c1 = dotChars.charAt(1);
28
29 if (c0 >= '\uD800' && c0 <= '\uDBFF' && c1 >= '\uDC00' && c1 <= '\uDFFF') {
30 delChars = 2;
31 }
32 }
33 doc.remove(dot, delChars);
34 }
35 }
36 }