FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CadPythonShell/PythonConsoleControl/CommandLineHistory.cs at dev · chuongmep/CadPythonShell · GitHub
chuongmep
/
CadPythonShell
Public
Notifications
You must be signed in to change notification settings
Fork
23
Star
119
Code
Issues
3
Pull requests
0
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
CadPythonShell
/
PythonConsoleControl
/
CommandLineHistory.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (82 loc) · 2.29 KB
Breadcrumbs
CadPythonShell
/
PythonConsoleControl
/
CommandLineHistory.cs
Copy path
File metadata and controls
89 lines (82 loc) · 2.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (c) 2010 Joe Moorhouse
using
System
;
using
System
.
Collections
.
Generic
;
namespace
PythonConsoleControl
{
/// <summary>
/// Stores the command line history for the PythonConsole.
/// </summary>
public
class
CommandLineHistory
{
private
List
<
string
>
lines
=
new
List
<
string
>
(
)
;
private
int
position
;
public
CommandLineHistory
(
)
{
}
/// <summary>
/// Adds the command line to the history.
/// </summary>
public
void
Add
(
string
line
)
{
if
(
!
String
.
IsNullOrEmpty
(
line
)
)
{
int
index
=
lines
.
Count
-
1
;
if
(
index
>=
0
)
{
if
(
lines
[
index
]
!=
line
)
{
lines
.
Add
(
line
)
;
}
}
else
{
lines
.
Add
(
line
)
;
}
}
position
=
lines
.
Count
;
}
/// <summary>
/// Gets the current command line. By default this will be the last command line entered.
/// </summary>
public
string
Current
{
get
{
if
(
(
position
>=
0
)
&&
(
position
<
lines
.
Count
)
)
{
return
lines
[
position
]
;
}
return
null
;
}
}
/// <summary>
/// Moves to the next command line.
/// </summary>
/// <returns>False if the current position is at the end of the command line history.</returns>
public
bool
MoveNext
(
)
{
int
nextPosition
=
position
+
1
;
if
(
nextPosition
<
lines
.
Count
)
{
++
position
;
}
return
nextPosition
<
lines
.
Count
;
}
/// <summary>
/// Moves to the previous command line.
/// </summary>
/// <returns>False if the current position is at the start of the command line history.</returns>
public
bool
MovePrevious
(
)
{
if
(
position
>=
0
)
{
if
(
position
==
0
)
{
return
false
;
}
--
position
;
}
return
position
>=
0
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL