Skip to content

Commit 80a7a24

Browse files
author
duy
committed
Click shift+Enter to run
1 parent 9a06525 commit 80a7a24

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

modules/programming/src/main/java/com/symja/programming/BaseProgrammingFragment.java

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.graphics.Rect;
1111
import android.net.Uri;
1212
import android.os.Bundle;
13+
import android.view.KeyEvent;
1314
import android.view.LayoutInflater;
1415
import android.view.View;
1516
import android.view.ViewGroup;
@@ -67,6 +68,8 @@
6768
import java.util.stream.Collectors;
6869

6970
import io.github.rosemoe.sora.event.ContentChangeEvent;
71+
import io.github.rosemoe.sora.event.EditorKeyEvent;
72+
import io.github.rosemoe.sora.event.KeyBindingEvent;
7073

7174

7275
public abstract class BaseProgrammingFragment extends Fragment implements DragListener,
@@ -368,6 +371,15 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
368371
}
369372
}
370373
});
374+
inputView.subscribeEvent(KeyBindingEvent.class, (keyBindingEvent, unsubscribe) -> {
375+
if (keyBindingEvent.isShiftPressed() && keyBindingEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
376+
keyBindingEvent.intercept();
377+
if (btnRun.isEnabled()) {
378+
clickRun();
379+
}
380+
}
381+
});
382+
371383

372384
txtErrorLabel = view.findViewById(R.id.symja_prgm_txt_error_message);
373385
errorContainer = view.findViewById(R.id.symja_prgm_error_container);

0 commit comments

Comments
 (0)