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
Hide 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()
gboolean
CoWowEntryGtk
::
event_cb
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
)
{
CoWowEntryGtk
*
en
=
(
CoWowEntryGtk
*
)
data
;
int
i
;
gboolean
sts
;
gboolean
sts
=
FALSE
;
guint
keysym
=
event
->
key
.
keyval
;
gchar
*
text
=
gtk_editable_get_chars
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
switch
(
keysym
)
{
switch
(
event
->
key
.
keyval
)
{
case
GDK_Return
:
case
GDK_KP_Enter
:
case
GDK_Linefeed
:
{
// Insert in recall buffer
if
(
strcmp
(
text
,
""
)
!=
0
)
{
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
;
en
->
m_re
->
push
(
text
);
break
;
}
case
GDK_Up
:
{
en
->
m_re
->
m_current_recall_line
++
;
if
(
en
->
m_re
->
m_current_recall_line
>
en
->
m_re
->
m_recall_size
-
1
)
en
->
m_re
->
m_current_recall_line
=
en
->
m_re
->
m_recall_size
-
1
;
gint
pos
=
0
;
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
gtk_editable_insert_text
(
GTK_EDITABLE
(
w
),
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
);
const
char
*
prev
=
en
->
m_re
->
popUp
(
text
);
if
(
strcmp
(
prev
,
""
)
!=
0
)
{
gint
pos
=
0
;
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
gtk_editable_insert_text
(
GTK_EDITABLE
(
w
),
prev
,
strlen
(
prev
),
&
pos
);
gtk_editable_set_position
(
GTK_EDITABLE
(
w
),
-
1
);
}
sts
=
TRUE
;
break
;
}
case
GDK_Down
:
{
if
(
en
->
m_re
->
m_current_recall_line
==
0
)
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
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
--
;
const
char
*
next
=
en
->
m_re
->
popDown
(
text
);
if
(
strcmp
(
next
,
""
)
!=
0
)
{
gint
pos
=
0
;
gtk_editable_delete_text
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
gtk_editable_insert_text
(
GTK_EDITABLE
(
w
),
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_insert_text
(
GTK_EDITABLE
(
w
),
next
,
strlen
(
next
),
&
pos
);
gtk_editable_set_position
(
GTK_EDITABLE
(
w
),
-
1
);
}
sts
=
TRUE
;
...
...
@@ -1156,10 +1136,10 @@ gboolean CoWowEntryGtk::event_cb(GtkWidget* w, GdkEvent* event, gpointer data)
case
GDK_Escape
:
if
(
en
->
m_hide_on_esc
)
gtk_widget_hide
(
w
);
sts
=
FALSE
;
en
->
m_re
->
resetTmp
()
;
break
;
default:
sts
=
FALSE
;
break
;
}
g_free
(
text
);
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)
void CoWowEntryQt::keyPressEvent(QKeyEvent* event)
{
int keysym = event->key();
QString txt = text();
switch (keysym) {
switch (event->key()) {
case Qt::Key_Return:
case Qt::Key_Enter: {
// Insert in recall buffer
if (txt.compare("") != 0) {
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;
m_re->push(qPrintable(text()));
break;
}
case Qt::Key_Up: {
m_re->m_current_recall_line++
;
if (
m_re->m_current_recall_line > m_re->m_recall_size - 1
) {
m_re->m_current_recall_line = m_re->m_recall_size - 1
;
const char *prev = m_re->popUp(qPrintable(text()))
;
if (
strcmp(prev, "") != 0
) {
setText(fl(prev))
;
}
setText(QString::fromLocal8Bit(
m_re->m_recall[m_re->m_current_recall_line - 1]));
end(false);
break;
}
case Qt::Key_Down: {
if (m_re->m_current_recall_line == 0) {
setText("");
} else if (m_re->m_current_recall_line == 1) {
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);
const char *next = m_re->popDown(qPrintable(text()));
if (strcmp(next, "") != 0) {
setText(fl(next));
}
end(false);
break;
}
case Qt::Key_Escape:
if (m_hide_on_esc) {
hide();
}
m_re->resetTmp();
break;
default:
QLineEdit::keyPressEvent(event);
break;
}
QLineEdit::keyPressEvent(event);
}
void CoWowEntryQt::hideEvent(QHideEvent* event)
...
...
xtt/lib/cow/src/cow_wow.cpp
View file @
399d27ce
...
...
@@ -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
));
}
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
()
{
}
...
...
xtt/lib/cow/src/cow_wow.h
View file @
399d27ce
...
...
@@ -92,6 +92,13 @@ public:
static
const
int
m_line_size
=
160
;
char
m_recall
[
m_recall_size
][
m_line_size
];
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
();
};
...
...
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