Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
399d27ce
Commit
399d27ce
authored
Aug 13, 2018
by
Christoffer Ackelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the behaviour of CoWowRecall to match the Linux terminal.
parent
944da4c0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
64 deletions
+78
-64
xtt/lib/cow/gtk/cow_wow_gtk.cpp
xtt/lib/cow/gtk/cow_wow_gtk.cpp
+15
-35
xtt/lib/cow/qt/cow_wow_qt.cqt
xtt/lib/cow/qt/cow_wow_qt.cqt
+11
-28
xtt/lib/cow/src/cow_wow.cpp
xtt/lib/cow/src/cow_wow.cpp
+45
-1
xtt/lib/cow/src/cow_wow.h
xtt/lib/cow/src/cow_wow.h
+7
-0
No files found.
xtt/lib/cow/gtk/cow_wow_gtk.cpp
View file @
399d27ce
...
@@ -1099,55 +1099,35 @@ CoWowEntryGtk::~CoWowEntryGtk()
...
@@ -1099,55 +1099,35 @@ CoWowEntryGtk::~CoWowEntryGtk()
gboolean
CoWowEntryGtk
::
event_cb
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
)
gboolean
CoWowEntryGtk
::
event_cb
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
)
{
{
CoWowEntryGtk
*
en
=
(
CoWowEntryGtk
*
)
data
;
CoWowEntryGtk
*
en
=
(
CoWowEntryGtk
*
)
data
;
int
i
;
gboolean
sts
=
FALSE
;
gboolean
sts
;
guint
keysym
=
event
->
key
.
keyval
;
gchar
*
text
=
gtk_editable_get_chars
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
gchar
*
text
=
gtk_editable_get_chars
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
switch
(
keysym
)
{
switch
(
event
->
key
.
keyval
)
{
case
GDK_Return
:
case
GDK_Return
:
case
GDK_KP_Enter
:
case
GDK_KP_Enter
:
case
GDK_Linefeed
:
{
case
GDK_Linefeed
:
{
// Insert in recall buffer
// Insert in recall buffer
if
(
strcmp
(
text
,
""
)
!=
0
)
{
en
->
m_re
->
push
(
text
);
for
(
i
=
en
->
m_re
->
m_recall_size
-
2
;
i
>=
0
;
i
--
)
strcpy
(
en
->
m_re
->
m_recall
[
i
+
1
],
en
->
m_re
->
m_recall
[
i
]);
strncpy
(
en
->
m_re
->
m_recall
[
0
],
text
,
en
->
m_re
->
m_line_size
);
en
->
m_re
->
m_recall
[
0
][
en
->
m_re
->
m_line_size
-
1
]
=
0
;
}
en
->
m_re
->
m_current_recall_line
=
0
;
sts
=
FALSE
;
break
;
break
;
}
}
case
GDK_Up
:
{
case
GDK_Up
:
{
en
->
m_re
->
m_current_recall_line
++
;
const
char
*
prev
=
en
->
m_re
->
popUp
(
text
);
if
(
en
->
m_re
->
m_current_recall_line
>
en
->
m_re
->
m_recall_size
-
1
)
if
(
strcmp
(
prev
,
""
)
!=
0
)
{
en
->
m_re
->
m_current_recall_line
=
en
->
m_re
->
m_recall_size
-
1
;
gint
pos
=
0
;
gint
pos
=
0
;
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
gtk_editable_insert_text
(
GTK_EDITABLE
(
w
),
gtk_editable_insert_text
(
GTK_EDITABLE
(
w
),
prev
,
strlen
(
prev
),
&
pos
);
en
->
m_re
->
m_recall
[
en
->
m_re
->
m_current_recall_line
-
1
],
strlen
(
en
->
m_re
->
m_recall
[
en
->
m_re
->
m_current_recall_line
-
1
]),
&
pos
);
gtk_editable_set_position
(
GTK_EDITABLE
(
w
),
-
1
);
gtk_editable_set_position
(
GTK_EDITABLE
(
w
),
-
1
);
}
sts
=
TRUE
;
sts
=
TRUE
;
break
;
break
;
}
}
case
GDK_Down
:
{
case
GDK_Down
:
{
if
(
en
->
m_re
->
m_current_recall_line
==
0
)
const
char
*
next
=
en
->
m_re
->
popDown
(
text
);
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
if
(
strcmp
(
next
,
""
)
!=
0
)
{
else
if
(
en
->
m_re
->
m_current_recall_line
==
1
)
{
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
en
->
m_re
->
m_current_recall_line
--
;
}
else
{
en
->
m_re
->
m_current_recall_line
--
;
gint
pos
=
0
;
gint
pos
=
0
;
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
gtk_editable_insert_text
(
GTK_EDITABLE
(
w
),
gtk_editable_insert_text
(
GTK_EDITABLE
(
w
),
next
,
strlen
(
next
),
&
pos
);
en
->
m_re
->
m_recall
[
en
->
m_re
->
m_current_recall_line
-
1
],
strlen
(
en
->
m_re
->
m_recall
[
en
->
m_re
->
m_current_recall_line
-
1
]),
&
pos
);
gtk_editable_set_position
(
GTK_EDITABLE
(
w
),
-
1
);
gtk_editable_set_position
(
GTK_EDITABLE
(
w
),
-
1
);
}
}
sts
=
TRUE
;
sts
=
TRUE
;
...
@@ -1156,10 +1136,10 @@ gboolean CoWowEntryGtk::event_cb(GtkWidget* w, GdkEvent* event, gpointer data)
...
@@ -1156,10 +1136,10 @@ gboolean CoWowEntryGtk::event_cb(GtkWidget* w, GdkEvent* event, gpointer data)
case
GDK_Escape
:
case
GDK_Escape
:
if
(
en
->
m_hide_on_esc
)
if
(
en
->
m_hide_on_esc
)
gtk_widget_hide
(
w
);
gtk_widget_hide
(
w
);
sts
=
FALSE
;
en
->
m_re
->
resetTmp
()
;
break
;
break
;
default:
default:
sts
=
FALSE
;
break
;
}
}
g_free
(
text
);
g_free
(
text
);
return
sts
;
return
sts
;
...
...
xtt/lib/cow/qt/cow_wow_qt.cqt
View file @
399d27ce
...
@@ -659,56 +659,39 @@ CoWowEntryQt::CoWowEntryQt(CoWowRecall* re) : m_re(re), m_hide_on_esc(false)
...
@@ -659,56 +659,39 @@ CoWowEntryQt::CoWowEntryQt(CoWowRecall* re) : m_re(re), m_hide_on_esc(false)
void CoWowEntryQt::keyPressEvent(QKeyEvent* event)
void CoWowEntryQt::keyPressEvent(QKeyEvent* event)
{
{
int keysym = event->key();
switch (event->key()) {
QString txt = text();
switch (keysym) {
case Qt::Key_Return:
case Qt::Key_Return:
case Qt::Key_Enter: {
case Qt::Key_Enter: {
// Insert in recall buffer
// Insert in recall buffer
if (txt.compare("") != 0) {
m_re->push(qPrintable(text()));
for (int i = m_re->m_recall_size - 2; i >= 0; i--) {
strcpy(m_re->m_recall[i + 1], m_re->m_recall[i]);
}
strncpy(m_re->m_recall[0], qPrintable(txt), m_re->m_line_size);
m_re->m_recall[0][m_re->m_line_size - 1] = 0;
}
m_re->m_current_recall_line = 0;
break;
break;
}
}
case Qt::Key_Up: {
case Qt::Key_Up: {
m_re->m_current_recall_line++
;
const char *prev = m_re->popUp(qPrintable(text()))
;
if (
m_re->m_current_recall_line > m_re->m_recall_size - 1
) {
if (
strcmp(prev, "") != 0
) {
m_re->m_current_recall_line = m_re->m_recall_size - 1
;
setText(fl(prev))
;
}
}
setText(QString::fromLocal8Bit(
m_re->m_recall[m_re->m_current_recall_line - 1]));
end(false);
end(false);
break;
break;
}
}
case Qt::Key_Down: {
case Qt::Key_Down: {
if (m_re->m_current_recall_line == 0) {
const char *next = m_re->popDown(qPrintable(text()));
setText("");
if (strcmp(next, "") != 0) {
} else if (m_re->m_current_recall_line == 1) {
setText(fl(next));
setText("");
m_re->m_current_recall_line--;
} else {
m_re->m_current_recall_line--;
setText(m_re->m_recall[m_re->m_current_recall_line - 1]);
end(false);
}
}
end(false);
break;
break;
}
}
case Qt::Key_Escape:
case Qt::Key_Escape:
if (m_hide_on_esc) {
if (m_hide_on_esc) {
hide();
hide();
}
}
m_re->resetTmp();
break;
break;
default:
default:
QLineEdit::keyPressEvent(event);
break;
break;
}
}
QLineEdit::keyPressEvent(event);
}
}
void CoWowEntryQt::hideEvent(QHideEvent* event)
void CoWowEntryQt::hideEvent(QHideEvent* event)
...
...
xtt/lib/cow/src/cow_wow.cpp
View file @
399d27ce
...
@@ -62,11 +62,55 @@ void CoWowTimer::remove()
...
@@ -62,11 +62,55 @@ void CoWowTimer::remove()
{
{
}
}
CoWowRecall
::
CoWowRecall
()
:
m_current_recall_line
(
0
)
CoWowRecall
::
CoWowRecall
()
:
m_current_recall_line
(
0
)
,
m_current_size
(
0
)
{
{
memset
(
m_recall
,
0
,
sizeof
(
m_recall
));
memset
(
m_recall
,
0
,
sizeof
(
m_recall
));
}
}
void
CoWowRecall
::
push
(
const
char
*
src
)
{
if
(
strcmp
(
src
,
""
)
!=
0
&&
strcmp
(
src
,
m_recall
[
0
])
!=
0
)
{
for
(
int
i
=
m_recall_size
-
2
;
i
>=
0
;
i
--
)
{
strcpy
(
m_recall
[
i
+
1
],
m_recall
[
i
]);
}
strncpy
(
m_recall
[
0
],
src
,
m_line_size
);
m_recall
[
0
][
m_line_size
-
1
]
=
0
;
m_current_size
++
;
if
(
m_current_size
>
m_recall_size
)
{
m_current_size
=
m_recall_size
;
}
}
resetTmp
();
}
void
CoWowRecall
::
resetTmp
()
{
for
(
int
i
=
0
;
i
<
m_current_size
;
i
++
)
{
strcpy
(
tmp
[
i
],
m_recall
[
i
]);
}
m_current_recall_line
=
0
;
}
const
char
*
CoWowRecall
::
popUp
(
const
char
*
src
)
{
strncpy
(
tmp
[
m_current_recall_line
],
src
,
m_line_size
);
m_current_recall_line
++
;
if
(
m_current_recall_line
>
m_current_size
-
1
)
{
m_current_recall_line
=
m_current_size
-
1
;
}
return
tmp
[
m_current_recall_line
];
}
const
char
*
CoWowRecall
::
popDown
(
const
char
*
src
)
{
strncpy
(
tmp
[
m_current_recall_line
],
src
,
m_line_size
);
if
(
m_current_recall_line
<=
0
)
{
return
tmp
[
m_current_recall_line
];
}
m_current_recall_line
--
;
return
tmp
[
m_current_recall_line
];
}
CoWow
::
CoWow
()
CoWow
::
CoWow
()
{
{
}
}
...
...
xtt/lib/cow/src/cow_wow.h
View file @
399d27ce
...
@@ -92,6 +92,13 @@ public:
...
@@ -92,6 +92,13 @@ public:
static
const
int
m_line_size
=
160
;
static
const
int
m_line_size
=
160
;
char
m_recall
[
m_recall_size
][
m_line_size
];
char
m_recall
[
m_recall_size
][
m_line_size
];
int
m_current_recall_line
;
int
m_current_recall_line
;
int
m_current_size
;
char
tmp
[
m_recall_size
][
m_line_size
];
void
push
(
const
char
*
src
);
void
resetTmp
();
const
char
*
popUp
(
const
char
*
src
);
const
char
*
popDown
(
const
char
*
src
);
CoWowRecall
();
CoWowRecall
();
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment