Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
senf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wiback
senf
Commits
8b8dfd3f
Commit
8b8dfd3f
authored
16 years ago
by
g0dil
Browse files
Options
Downloads
Patches
Plain Diff
Utils/Console: Remove endless exception tracebacks from console error display
Utils/Termlib: Implement LineEditor history
parent
206fb34c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Utils/Console/Server.cc
+5
-1
5 additions, 1 deletion
Utils/Console/Server.cc
Utils/Termlib/Editor.cc
+66
-2
66 additions, 2 deletions
Utils/Termlib/Editor.cc
Utils/Termlib/Editor.hh
+16
-0
16 additions, 0 deletions
Utils/Termlib/Editor.hh
Utils/Termlib/Telnet.cc
+1
-1
1 addition, 1 deletion
Utils/Termlib/Telnet.cc
with
88 additions
and
4 deletions
Utils/Console/Server.cc
+
5
−
1
View file @
8b8dfd3f
...
@@ -291,7 +291,11 @@ prefix_ std::string::size_type senf::console::Client::handleInput(std::string da
...
@@ -291,7 +291,11 @@ prefix_ std::string::size_type senf::console::Client::handleInput(std::string da
handle_
.
facet
<
senf
::
TCPSocketProtocol
>
().
shutdown
(
senf
::
TCPSocketProtocol
::
ShutRD
);
handle_
.
facet
<
senf
::
TCPSocketProtocol
>
().
shutdown
(
senf
::
TCPSocketProtocol
::
ShutRD
);
}
}
catch
(
std
::
exception
&
ex
)
{
catch
(
std
::
exception
&
ex
)
{
stream
()
<<
ex
.
what
()
<<
std
::
endl
;
std
::
string
msg
(
ex
.
what
());
std
::
string
::
size_type
i
(
msg
.
find
(
"--
\n
"
));
if
(
i
!=
std
::
string
::
npos
)
msg
=
msg
.
substr
(
i
+
4
);
stream
()
<<
msg
<<
std
::
endl
;
}
}
catch
(...)
{
catch
(...)
{
stream
()
<<
"unidentified error (unknown exception thrown)"
<<
std
::
endl
;
stream
()
<<
"unidentified error (unknown exception thrown)"
<<
std
::
endl
;
...
...
This diff is collapsed.
Click to expand it.
Utils/Termlib/Editor.cc
+
66
−
2
View file @
8b8dfd3f
...
@@ -124,6 +124,12 @@ prefix_ void senf::term::BaseEditor::setNormal()
...
@@ -124,6 +124,12 @@ prefix_ void senf::term::BaseEditor::setNormal()
write
(
tifo_
.
getString
(
Terminfo
::
properties
::
ExitAttributeMode
));
write
(
tifo_
.
getString
(
Terminfo
::
properties
::
ExitAttributeMode
));
}
}
prefix_
void
senf
::
term
::
BaseEditor
::
maybeClrScr
()
{
if
(
tifo_
.
hasProperty
(
Terminfo
::
properties
::
ClearScreen
))
write
(
tifo_
.
getString
(
Terminfo
::
properties
::
ClearScreen
));
}
prefix_
unsigned
senf
::
term
::
BaseEditor
::
currentColumn
()
prefix_
unsigned
senf
::
term
::
BaseEditor
::
currentColumn
()
const
const
{
{
...
@@ -148,6 +154,7 @@ prefix_ bool senf::term::BaseEditor::cb_init()
...
@@ -148,6 +154,7 @@ prefix_ bool senf::term::BaseEditor::cb_init()
if
(
tifo_
.
hasProperty
(
Terminfo
::
properties
::
KeypadXmit
))
if
(
tifo_
.
hasProperty
(
Terminfo
::
properties
::
KeypadXmit
))
write
(
tifo_
.
getString
(
Terminfo
::
properties
::
KeypadXmit
));
write
(
tifo_
.
getString
(
Terminfo
::
properties
::
KeypadXmit
));
return
true
;
}
}
prefix_
void
senf
::
term
::
BaseEditor
::
cb_charReceived
(
char
c
)
prefix_
void
senf
::
term
::
BaseEditor
::
cb_charReceived
(
char
c
)
...
@@ -205,11 +212,13 @@ prefix_ void senf::term::BaseEditor::write(std::string const & s)
...
@@ -205,11 +212,13 @@ prefix_ void senf::term::BaseEditor::write(std::string const & s)
prefix_
senf
::
term
::
LineEditor
::
LineEditor
(
AbstractTerminal
&
terminal
,
AcceptCallback
cb
)
prefix_
senf
::
term
::
LineEditor
::
LineEditor
(
AbstractTerminal
&
terminal
,
AcceptCallback
cb
)
:
BaseEditor
(
terminal
),
enabled_
(
true
),
prompt_
(
"$"
),
promptWidth_
(
1u
),
editWidth_
(
0u
),
:
BaseEditor
(
terminal
),
enabled_
(
true
),
prompt_
(
"$"
),
promptWidth_
(
1u
),
editWidth_
(
0u
),
text_
(
""
),
point_
(
0u
),
displayPos_
(
0u
),
lastKey_
(
0u
),
callback_
(
cb
)
text_
(
""
),
point_
(
0u
),
displayPos_
(
0u
),
lastKey_
(
0u
),
callback_
(
cb
)
,
historyPoint_
(
0u
)
{
{
defineKey
(
KeyParser
::
Return
,
&
bindings
::
accept
);
defineKey
(
KeyParser
::
Return
,
&
bindings
::
accept
);
defineKey
(
KeyParser
::
Right
,
&
bindings
::
forwardChar
);
defineKey
(
KeyParser
::
Right
,
&
bindings
::
forwardChar
);
defineKey
(
KeyParser
::
Left
,
&
bindings
::
backwardChar
);
defineKey
(
KeyParser
::
Left
,
&
bindings
::
backwardChar
);
defineKey
(
KeyParser
::
Up
,
&
bindings
::
prevHistory
);
defineKey
(
KeyParser
::
Down
,
&
bindings
::
nextHistory
);
defineKey
(
KeyParser
::
Backspace
,
&
bindings
::
backwardDeleteChar
);
defineKey
(
KeyParser
::
Backspace
,
&
bindings
::
backwardDeleteChar
);
defineKey
(
KeyParser
::
Delete
,
&
bindings
::
deleteChar
);
defineKey
(
KeyParser
::
Delete
,
&
bindings
::
deleteChar
);
defineKey
(
KeyParser
::
Home
,
&
bindings
::
beginningOfLine
);
defineKey
(
KeyParser
::
Home
,
&
bindings
::
beginningOfLine
);
...
@@ -219,6 +228,7 @@ prefix_ senf::term::LineEditor::LineEditor(AbstractTerminal & terminal, AcceptCa
...
@@ -219,6 +228,7 @@ prefix_ senf::term::LineEditor::LineEditor(AbstractTerminal & terminal, AcceptCa
defineKey
(
KeyParser
::
Ctrl
(
'E'
),
&
bindings
::
endOfLine
);
defineKey
(
KeyParser
::
Ctrl
(
'E'
),
&
bindings
::
endOfLine
);
defineKey
(
KeyParser
::
Ctrl
(
'D'
),
&
bindings
::
deleteChar
);
defineKey
(
KeyParser
::
Ctrl
(
'D'
),
&
bindings
::
deleteChar
);
defineKey
(
KeyParser
::
Ctrl
(
'C'
),
&
bindings
::
restartEdit
);
defineKey
(
KeyParser
::
Ctrl
(
'C'
),
&
bindings
::
restartEdit
);
defineKey
(
KeyParser
::
Ctrl
(
'L'
),
&
bindings
::
clearScreen
);
}
}
prefix_
void
senf
::
term
::
LineEditor
::
prompt
(
std
::
string
const
&
text
)
prefix_
void
senf
::
term
::
LineEditor
::
prompt
(
std
::
string
const
&
text
)
...
@@ -249,7 +259,7 @@ prefix_ void senf::term::LineEditor::show()
...
@@ -249,7 +259,7 @@ prefix_ void senf::term::LineEditor::show()
if
(
enabled_
)
if
(
enabled_
)
return
;
return
;
enabled_
=
true
;
enabled_
=
true
;
r
edisplay
();
forceR
edisplay
();
}
}
prefix_
void
senf
::
term
::
LineEditor
::
hide
()
prefix_
void
senf
::
term
::
LineEditor
::
hide
()
...
@@ -265,6 +275,7 @@ prefix_ void senf::term::LineEditor::accept()
...
@@ -265,6 +275,7 @@ prefix_ void senf::term::LineEditor::accept()
if
(
enabled_
)
if
(
enabled_
)
newline
();
newline
();
hide
();
hide
();
pushHistory
(
text_
);
callback_
(
text_
);
callback_
(
text_
);
clear
();
clear
();
}
}
...
@@ -272,6 +283,7 @@ prefix_ void senf::term::LineEditor::accept()
...
@@ -272,6 +283,7 @@ prefix_ void senf::term::LineEditor::accept()
prefix_
void
senf
::
term
::
LineEditor
::
clear
()
prefix_
void
senf
::
term
::
LineEditor
::
clear
()
{
{
set
(
""
);
set
(
""
);
historyPoint_
=
history_
.
size
();
}
}
prefix_
void
senf
::
term
::
LineEditor
::
redisplay
()
prefix_
void
senf
::
term
::
LineEditor
::
redisplay
()
...
@@ -347,6 +359,41 @@ prefix_ void senf::term::LineEditor::insert(std::string const & text)
...
@@ -347,6 +359,41 @@ prefix_ void senf::term::LineEditor::insert(std::string const & text)
redisplay
();
redisplay
();
}
}
prefix_
void
senf
::
term
::
LineEditor
::
pushHistory
(
std
::
string
const
&
text
)
{
if
(
!
text
.
empty
()
&&
(
historyPoint_
==
history_
.
size
()
||
history_
[
historyPoint_
]
!=
text
)
&&
(
history_
.
empty
()
||
history_
.
back
()
!=
text
))
{
history_
.
push_back
(
text
);
while
(
history_
.
size
()
>
MAX_HISTORY_SIZE
)
history_
.
erase
(
history_
.
begin
());
historyPoint_
=
history_
.
size
()
-
1
;
}
}
prefix_
void
senf
::
term
::
LineEditor
::
prevHistory
()
{
if
(
historyPoint_
<=
0
)
return
;
pushHistory
(
text_
);
std
::
string
entry
(
history_
[
--
historyPoint_
]);
set
(
entry
,
entry
.
size
());
}
prefix_
void
senf
::
term
::
LineEditor
::
nextHistory
()
{
if
(
historyPoint_
>=
history_
.
size
())
return
;
pushHistory
(
text_
);
++
historyPoint_
;
if
(
historyPoint_
>=
history_
.
size
())
set
(
""
);
else
{
std
::
string
entry
(
history_
[
historyPoint_
]);
set
(
entry
,
entry
.
size
());
}
}
prefix_
std
::
string
const
&
senf
::
term
::
LineEditor
::
text
()
prefix_
std
::
string
const
&
senf
::
term
::
LineEditor
::
text
()
{
{
return
text_
;
return
text_
;
...
@@ -470,6 +517,23 @@ prefix_ void senf::term::bindings::restartEdit(LineEditor & editor)
...
@@ -470,6 +517,23 @@ prefix_ void senf::term::bindings::restartEdit(LineEditor & editor)
editor
.
redisplay
();
editor
.
redisplay
();
}
}
prefix_
void
senf
::
term
::
bindings
::
prevHistory
(
LineEditor
&
editor
)
{
editor
.
prevHistory
();
}
prefix_
void
senf
::
term
::
bindings
::
nextHistory
(
LineEditor
&
editor
)
{
editor
.
nextHistory
();
}
prefix_
void
senf
::
term
::
bindings
::
clearScreen
(
LineEditor
&
editor
)
{
editor
.
maybeClrScr
();
editor
.
clearLine
();
editor
.
forceRedisplay
();
}
///////////////////////////////cc.e////////////////////////////////////////
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
#undef prefix_
//#include "Editor.mpp"
//#include "Editor.mpp"
...
...
This diff is collapsed.
Click to expand it.
Utils/Termlib/Editor.hh
+
16
−
0
View file @
8b8dfd3f
...
@@ -28,6 +28,8 @@
...
@@ -28,6 +28,8 @@
// Custom includes
// Custom includes
#include
<map>
#include
<map>
#include
<vector>
#include
<string>
#include
<senf/Scheduler/ClockService.hh>
#include
<senf/Scheduler/ClockService.hh>
#include
<senf/Scheduler/TimerEvent.hh>
#include
<senf/Scheduler/TimerEvent.hh>
#include
"AbstractTerminal.hh"
#include
"AbstractTerminal.hh"
...
@@ -56,6 +58,7 @@ namespace term {
...
@@ -56,6 +58,7 @@ namespace term {
void
clearLine
();
///< Clear current line and move cursor to first column
void
clearLine
();
///< Clear current line and move cursor to first column
void
setBold
();
///< Set bold char display
void
setBold
();
///< Set bold char display
void
setNormal
();
///< Set normal char display
void
setNormal
();
///< Set normal char display
void
maybeClrScr
();
///< Clear screen if possible
unsigned
currentColumn
()
const
;
///< Return number of current column
unsigned
currentColumn
()
const
;
///< Return number of current column
unsigned
width
();
unsigned
width
();
...
@@ -94,6 +97,8 @@ namespace term {
...
@@ -94,6 +97,8 @@ namespace term {
typedef
boost
::
function
<
void
(
LineEditor
&
)
>
KeyBinding
;
typedef
boost
::
function
<
void
(
LineEditor
&
)
>
KeyBinding
;
typedef
boost
::
function
<
void
(
std
::
string
const
&
)
>
AcceptCallback
;
typedef
boost
::
function
<
void
(
std
::
string
const
&
)
>
AcceptCallback
;
static
unsigned
const
MAX_HISTORY_SIZE
=
1024u
;
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
LineEditor
(
AbstractTerminal
&
terminal
,
AcceptCallback
cb
);
LineEditor
(
AbstractTerminal
&
terminal
,
AcceptCallback
cb
);
...
@@ -120,6 +125,11 @@ namespace term {
...
@@ -120,6 +125,11 @@ namespace term {
void
insert
(
char
ch
);
void
insert
(
char
ch
);
void
insert
(
std
::
string
const
&
text
);
void
insert
(
std
::
string
const
&
text
);
// History
void
pushHistory
(
std
::
string
const
&
text
);
void
prevHistory
();
void
nextHistory
();
// Get information
// Get information
std
::
string
const
&
text
();
std
::
string
const
&
text
();
unsigned
point
();
unsigned
point
();
...
@@ -136,6 +146,7 @@ namespace term {
...
@@ -136,6 +146,7 @@ namespace term {
virtual
void
v_keyReceived
(
keycode_t
key
);
virtual
void
v_keyReceived
(
keycode_t
key
);
typedef
std
::
map
<
keycode_t
,
KeyBinding
>
KeyMap
;
typedef
std
::
map
<
keycode_t
,
KeyBinding
>
KeyMap
;
typedef
std
::
vector
<
std
::
string
>
History
;
bool
enabled_
;
bool
enabled_
;
bool
redisplayNeeded_
;
bool
redisplayNeeded_
;
...
@@ -148,6 +159,8 @@ namespace term {
...
@@ -148,6 +159,8 @@ namespace term {
keycode_t
lastKey_
;
keycode_t
lastKey_
;
AcceptCallback
callback_
;
AcceptCallback
callback_
;
KeyMap
bindings_
;
KeyMap
bindings_
;
History
history_
;
unsigned
historyPoint_
;
};
};
namespace
bindings
{
namespace
bindings
{
...
@@ -162,6 +175,9 @@ namespace bindings {
...
@@ -162,6 +175,9 @@ namespace bindings {
void
endOfLine
(
LineEditor
&
editor
);
void
endOfLine
(
LineEditor
&
editor
);
void
deleteToEndOfLine
(
LineEditor
&
editor
);
void
deleteToEndOfLine
(
LineEditor
&
editor
);
void
restartEdit
(
LineEditor
&
editor
);
void
restartEdit
(
LineEditor
&
editor
);
void
prevHistory
(
LineEditor
&
editor
);
void
nextHistory
(
LineEditor
&
editor
);
void
clearScreen
(
LineEditor
&
editor
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Utils/Termlib/Telnet.cc
+
1
−
1
View file @
8b8dfd3f
...
@@ -44,7 +44,7 @@ prefix_ senf::term::BaseTelnetProtocol::BaseTelnetProtocol(Handle handle)
...
@@ -44,7 +44,7 @@ prefix_ senf::term::BaseTelnetProtocol::BaseTelnetProtocol(Handle handle)
senf
::
scheduler
::
FdEvent
::
EV_WRITE
,
false
),
senf
::
scheduler
::
FdEvent
::
EV_WRITE
,
false
),
pendingRequests_
(
0u
),
pendingRequests_
(
0u
),
requestTimeout_
(
ClockService
::
milliseconds
(
DEFAULT_REQUEST_TIMEOUT_MS
)),
requestTimeout_
(
ClockService
::
milliseconds
(
DEFAULT_REQUEST_TIMEOUT_MS
)),
timeout_
(
"senf::term::BaseTelnetProtocol::
t
imeout"
,
timeout_
(
"senf::term::BaseTelnetProtocol::
configT
imeout"
,
senf
::
membind
(
&
BaseTelnetProtocol
::
timeout
,
this
))
senf
::
membind
(
&
BaseTelnetProtocol
::
timeout
,
this
))
{}
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment