Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
幽默龙
luyten
提交
ea25dfc8
L
luyten
项目概览
幽默龙
/
luyten
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
luyten
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ea25dfc8
编写于
5月 08, 2017
作者:
D
deathmarine
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#78 Add F3 and Shift+F3 for better search navigation
上级
09cc3b62
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
74 addition
and
7 deletion
+74
-7
src/us/deathmarine/luyten/FindBox.java
src/us/deathmarine/luyten/FindBox.java
+50
-6
src/us/deathmarine/luyten/MainMenuBar.java
src/us/deathmarine/luyten/MainMenuBar.java
+23
-0
src/us/deathmarine/luyten/MainWindow.java
src/us/deathmarine/luyten/MainWindow.java
+1
-1
未找到文件。
src/us/deathmarine/luyten/FindBox.java
浏览文件 @
ea25dfc8
...
...
@@ -3,6 +3,7 @@ package us.deathmarine.luyten;
import
java.awt.Dimension
;
import
java.awt.Toolkit
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.InputEvent
;
import
java.awt.event.KeyEvent
;
import
java.awt.event.WindowAdapter
;
import
java.awt.event.WindowEvent
;
...
...
@@ -26,12 +27,12 @@ import org.fife.ui.rtextarea.SearchEngine;
public
class
FindBox
extends
JDialog
{
private
static
final
long
serialVersionUID
=
-
4125409760166690462L
;
private
JCheckBox
mcase
;
private
JCheckBox
regex
;
private
JCheckBox
wholew
;
private
JCheckBox
reverse
;
JCheckBox
mcase
;
JCheckBox
regex
;
JCheckBox
wholew
;
JCheckBox
reverse
;
private
JButton
findButton
;
private
JTextField
textField
;
JTextField
textField
;
private
MainWindow
mainWindow
;
public
void
showFindBox
()
{
...
...
@@ -44,7 +45,7 @@ public class FindBox extends JDialog {
this
.
setVisible
(
false
);
}
public
FindBox
(
MainWindow
mainWindow
)
{
public
FindBox
(
final
MainWindow
mainWindow
)
{
this
.
mainWindow
=
mainWindow
;
this
.
setDefaultCloseOperation
(
HIDE_ON_CLOSE
);
this
.
setHideOnEscapeButton
();
...
...
@@ -64,6 +65,14 @@ public class FindBox extends JDialog {
findButton
=
new
JButton
(
"Find"
);
findButton
.
addActionListener
(
new
FindButton
());
this
.
getRootPane
().
setDefaultButton
(
findButton
);
KeyStroke
funcF3
=
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_F3
,
0
,
false
);
this
.
getRootPane
().
getInputMap
(
JComponent
.
WHEN_IN_FOCUSED_WINDOW
).
put
(
funcF3
,
"FindNext"
);
this
.
getRootPane
().
getActionMap
().
put
(
"FindNext"
,
new
FindExploreAction
(
true
));
KeyStroke
sfuncF3
=
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_F3
,
InputEvent
.
SHIFT_DOWN_MASK
,
false
);
this
.
getRootPane
().
getInputMap
(
JComponent
.
WHEN_IN_FOCUSED_WINDOW
).
put
(
sfuncF3
,
"FindPrevious"
);
this
.
getRootPane
().
getActionMap
().
put
(
"FindPrevious"
,
new
FindExploreAction
(
false
));
mcase
.
setBorder
(
BorderFactory
.
createEmptyBorder
(
0
,
0
,
0
,
0
));
regex
.
setBorder
(
BorderFactory
.
createEmptyBorder
(
0
,
0
,
0
,
0
));
...
...
@@ -170,4 +179,39 @@ public class FindBox extends JDialog {
}
});
}
public
void
fireExploreAction
(
boolean
direction
){
new
FindExploreAction
(
direction
).
actionPerformed
(
null
);
}
class
FindExploreAction
extends
AbstractAction
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
4391670062679240573L
;
boolean
direction
;
public
FindExploreAction
(
boolean
forward
){
direction
=
forward
;
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
textField
.
getText
().
length
()
==
0
)
return
;
RSyntaxTextArea
pane
=
mainWindow
.
getModel
().
getCurrentTextArea
();
if
(
pane
==
null
)
return
;
SearchContext
context
=
new
SearchContext
();
context
.
setSearchFor
(
textField
.
getText
());
context
.
setMatchCase
(
mcase
.
isSelected
());
context
.
setRegularExpression
(
regex
.
isSelected
());
context
.
setSearchForward
(
direction
);
context
.
setWholeWord
(
wholew
.
isSelected
());
if
(!
SearchEngine
.
find
(
pane
,
context
).
wasFound
())
{
pane
.
setSelectionStart
(
0
);
pane
.
setSelectionEnd
(
0
);
}
}
}
}
src/us/deathmarine/luyten/MainMenuBar.java
浏览文件 @
ea25dfc8
...
...
@@ -6,6 +6,7 @@ import java.awt.Font;
import
java.awt.Toolkit
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.InputEvent
;
import
java.awt.event.KeyEvent
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
...
...
@@ -305,6 +306,28 @@ public class MainMenuBar extends JMenuBar {
}
});
editMenu
.
add
(
menuItem
);
menuItem
=
new
JMenuItem
(
"Find Next"
);
menuItem
.
setAccelerator
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_F3
,
0
));
menuItem
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
mainWindow
.
findBox
!=
null
)
mainWindow
.
findBox
.
fireExploreAction
(
true
);
}
});
editMenu
.
add
(
menuItem
);
menuItem
=
new
JMenuItem
(
"Find Previous"
);
menuItem
.
setAccelerator
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_F3
,
InputEvent
.
SHIFT_DOWN_MASK
));
menuItem
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
if
(
mainWindow
.
findBox
!=
null
)
mainWindow
.
findBox
.
fireExploreAction
(
false
);
}
});
editMenu
.
add
(
menuItem
);
menuItem
=
new
JMenuItem
(
"Find All"
);
menuItem
.
setAccelerator
(
...
...
src/us/deathmarine/luyten/MainWindow.java
浏览文件 @
ea25dfc8
...
...
@@ -43,7 +43,7 @@ public class MainWindow extends JFrame {
public
static
Model
model
;
private
JProgressBar
bar
;
private
JLabel
label
;
private
FindBox
findBox
;
FindBox
findBox
;
private
FindAllBox
findAllBox
;
private
ConfigSaver
configSaver
;
private
WindowPosition
windowPosition
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录