Search in sources :

Example 11 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method shiftCmdDownArrowSelectsToEndOfTextWithSelectionOn.

@Test
public void shiftCmdDownArrowSelectsToEndOfTextWithSelectionOn() {
    setupSingleLine("Here are four words").withCaretAt(0, 1).andSelectionAt(0, 4);
    processor.processKey(new KeyPressedEvent(SHIFT + CMD, KeyEvent.KEY_DOWN, 0), model);
    assertEquals(model.getEndLocation(), model.getCaretLocation());
    assertEquals(TextLocation.at(0, 4), model.getSelectionLocation());
    assertEquals(true, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Example 12 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method shiftLeftArrowWithSelection.

@Test
public void shiftLeftArrowWithSelection() {
    setupSingleLine("Here are four words").withCaretAt(0, 1).andSelectionAt(0, 4);
    processor.processKey(new KeyPressedEvent(SHIFT, KeyEvent.KEY_LEFT, 0), model);
    assertEquals(TextLocation.origin, model.getCaretLocation());
    assertEquals(TextLocation.at(0, 4), model.getSelectionLocation());
    assertEquals(true, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Example 13 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method cmdLeftArrowGoesToStartOfLine.

@Test
public void cmdLeftArrowGoesToStartOfLine() {
    setupSingleLine("Here are four words").withCaretAt(0, 5);
    processor.processKey(new KeyPressedEvent(CMD, KeyEvent.KEY_LEFT, 0), model);
    assertEquals(TextLocation.origin, model.getCaretLocation());
    assertEquals(false, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Example 14 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method cmdXCutsSelectedTextWithSelection.

@Test
public void cmdXCutsSelectedTextWithSelection() {
    setupSingleLine("Here are four words").withCaretAt(0, 1).andSelectionAt(0, 4);
    processor.processKey(new KeyPressedEvent(CMD, KeyEvent.KEY_X, 0), model);
    assertEquals("H are four words", model.getText());
    assertEquals(TextLocation.at(0, 1), model.getCaretLocation());
    assertEquals(TextLocation.at(0, 1), model.getSelectionLocation());
    assertEquals(false, model.isSelectionActivated());
    assertEquals("ere", model.getClipboardContents());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Example 15 with KeyPressedEvent

use of limelight.ui.events.panel.KeyPressedEvent in project limelight by slagyr.

the class TextInputKeyProcessorTest method cmdDownArrowGoesToEndOfTextWithMultipleLines.

@Test
public void cmdDownArrowGoesToEndOfTextWithMultipleLines() {
    setupMultiLine("Here are\nfour words").withCaretAt(1, 3);
    processor.processKey(new KeyPressedEvent(CMD, KeyEvent.KEY_DOWN, 0), model);
    assertEquals(model.getEndLocation(), model.getCaretLocation());
    assertEquals(false, model.isSelectionActivated());
}
Also used : KeyPressedEvent(limelight.ui.events.panel.KeyPressedEvent) Test(org.junit.Test)

Aggregations

KeyPressedEvent (limelight.ui.events.panel.KeyPressedEvent)86 Test (org.junit.Test)86 StringSelection (java.awt.datatransfer.StringSelection)2 KeyEvent (java.awt.event.KeyEvent)1