Commit c351b76f authored by Christoffer Ackelman's avatar Christoffer Ackelman

Another fix for the recall buffer.

parent 0f850db9
......@@ -1108,28 +1108,26 @@ gboolean CoWowEntryGtk::event_cb(GtkWidget* w, GdkEvent* event, gpointer data)
case GDK_KP_Enter:
case GDK_Linefeed: {
// Insert in recall buffer
en->m_re->push(text);
if (!streq(text, "")) {
en->m_re->push(text);
}
break;
}
case GDK_Up: {
const char *prev = en->m_re->popUp(text);
if (!streq(prev, "")) {
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);
}
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: {
const char *next = en->m_re->popDown(text);
if (!streq(next, "")) {
gint pos = 0;
gtk_editable_delete_text(GTK_EDITABLE(w), 0, -1);
gtk_editable_insert_text(GTK_EDITABLE(w), next, strlen(next), &pos);
gtk_editable_set_position(GTK_EDITABLE(w), -1);
}
gint pos = 0;
gtk_editable_delete_text(GTK_EDITABLE(w), 0, -1);
gtk_editable_insert_text(GTK_EDITABLE(w), next, strlen(next), &pos);
gtk_editable_set_position(GTK_EDITABLE(w), -1);
sts = TRUE;
break;
}
......
......@@ -656,22 +656,20 @@ void CoWowEntryQt::keyPressEvent(QKeyEvent* event)
case Qt::Key_Return:
case Qt::Key_Enter: {
// Insert in recall buffer
m_re->push(qPrintable(text()));
if (!text().isEmpty()) {
m_re->push(qPrintable(text()));
}
break;
}
case Qt::Key_Up: {
const char* prev = m_re->popUp(qPrintable(text()));
if (!streq(prev, "")) {
setText(fl(prev));
}
setText(fl(prev));
end(false);
break;
}
case Qt::Key_Down: {
const char* next = m_re->popDown(qPrintable(text()));
if (!streq(next, "")) {
setText(fl(next));
}
setText(fl(next));
end(false);
break;
}
......
......@@ -69,16 +69,18 @@ CoWowRecall::CoWowRecall() : m_current_recall_line(0), m_current_size(0)
void CoWowRecall::push(const char* src)
{
if (!streq(src, "") && !streq(src, m_recall[0])) {
for (int i = m_recall_size - 2; i >= 0; i--) {
strcpy(m_recall[i + 1], m_recall[i]);
if (!streq(src, m_recall[0])) {
if (m_current_size == 0 || !streq(m_recall[0], "")) {
for (int i = m_recall_size - 2; i >= 0; i--) {
strcpy(m_recall[i + 1], m_recall[i]);
}
m_current_size++;
if (m_current_size > m_recall_size) {
m_current_size = m_recall_size;
}
}
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();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment