X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fcom%2Fgooglecode%2Flanterna%2Finput%2FMouseCharacterPattern.java;fp=src%2Fcom%2Fgooglecode%2Flanterna%2Finput%2FMouseCharacterPattern.java;h=0000000000000000000000000000000000000000;hp=4b1c6868e7e52c856fb703053f226d7c71855223;hb=f06c81000632cfb5f525ca458f719338f55f9f66;hpb=a73a906356c971b080c36368e71a15d87e8b8d31 diff --git a/src/com/googlecode/lanterna/input/MouseCharacterPattern.java b/src/com/googlecode/lanterna/input/MouseCharacterPattern.java deleted file mode 100644 index 4b1c686..0000000 --- a/src/com/googlecode/lanterna/input/MouseCharacterPattern.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.googlecode.lanterna.input; - -import com.googlecode.lanterna.TerminalPosition; - -import java.util.List; - -/** - * Pattern used to detect Xterm-protocol mouse events coming in on the standard input channel - * Created by martin on 19/07/15. - * - * @author Martin, Andreas - */ -public class MouseCharacterPattern implements CharacterPattern { - private static final char[] PATTERN = { KeyDecodingProfile.ESC_CODE, '[', 'M' }; - - @Override - public Matching match(List seq) { - int size = seq.size(); - if (size > 6) { - return null; // nope - } - // check first 3 chars: - for (int i = 0; i < 3; i++) { - if ( i >= size ) { - return Matching.NOT_YET; // maybe later - } - if ( seq.get(i) != PATTERN[i] ) { - return null; // nope - } - } - if (size < 6) { - return Matching.NOT_YET; // maybe later - } - MouseActionType actionType = null; - int button = (seq.get(3) & 0x3) + 1; - if(button == 4) { - //If last two bits are both set, it means button click release - button = 0; - } - int actionCode = (seq.get(3) & 0x60) >> 5; - switch(actionCode) { - case(1): - if(button > 0) { - actionType = MouseActionType.CLICK_DOWN; - } - else { - actionType = MouseActionType.CLICK_RELEASE; - } - break; - case(2): - if(button == 0) { - actionType = MouseActionType.MOVE; - } - else { - actionType = MouseActionType.DRAG; - } - break; - case(3): - if(button == 1) { - actionType = MouseActionType.SCROLL_UP; - button = 4; - } - else { - actionType = MouseActionType.SCROLL_DOWN; - button = 5; - } - break; - } - TerminalPosition pos = new TerminalPosition( seq.get(4) - 33, seq.get(5) - 33 ); - - MouseAction ma = new MouseAction(actionType, button, pos ); - return new Matching( ma ); // yep - } -}