implement "--More--" for Qt
Support MSGTYPE=stop by having qt_display_nhwindow(WIN_MESSAGE,TRUE) issue a tty-style --More-- prompt. For popup_dialog Off, the prompt gets appended to the most recent message; for popup_dialog On, it is issued via a popup and not displayed in the message window. It accepts <space>, ^J, ^M, and ^[ (ESC) to dismiss. There's no way to dismiss it with the mouse (for !popup_dialog) which might need some fix.... Several adventures along the way. The '^C-in-parent-terminal triggers infinite loop repeatedly complaining about "event loop already running"' is now a one-shot complaint. It isn't fixed but the severity of having it happen is greatly reduced.
This commit is contained in:
@@ -75,15 +75,16 @@ void NetHackQtMessageWindow::ClearMessages()
|
||||
list->clear();
|
||||
}
|
||||
|
||||
void NetHackQtMessageWindow::Display(bool block UNUSED)
|
||||
void NetHackQtMessageWindow::Display(bool block)
|
||||
{
|
||||
//
|
||||
// FIXME: support for 'block' is necessary for MSGTYPE=stop
|
||||
//
|
||||
if (changed) {
|
||||
list->repaint();
|
||||
changed=false;
|
||||
}
|
||||
if (block) {
|
||||
// we don't care what the response is here
|
||||
(void) NetHackQtBind::qt_more();
|
||||
}
|
||||
}
|
||||
|
||||
const char * NetHackQtMessageWindow::GetStr(bool init)
|
||||
@@ -113,49 +114,73 @@ void NetHackQtMessageWindow::PutStr(int attr, const QString& text)
|
||||
} else {
|
||||
text2 = text;
|
||||
}
|
||||
|
||||
#if 0
|
||||
QListWidgetItem *item = new QListWidgetItem(text2);
|
||||
|
||||
QFont font = item->font();
|
||||
font.setUnderline(attr == ATR_ULINE);
|
||||
font.setWeight((attr == ATR_BOLD) ? QFont::Bold : QFont::Normal);
|
||||
item->setFont(font);
|
||||
|
||||
if (attr == ATR_DIM || attr == ATR_INVERSE) {
|
||||
QColor fg = item->foreground().color();
|
||||
QColor bg = item->background().color();
|
||||
if (attr == ATR_DIM) {
|
||||
fg.setAlpha(fg.alpha() / 2);
|
||||
new_fgbg = true;
|
||||
if (attr != ATR_NONE) {
|
||||
QListWidgetItem *item = new QListWidgetItem(text2);
|
||||
if (attr != ATR_DIM && attr != ATR_INVERSE) {
|
||||
QFont font = item->font();
|
||||
font.setUnderline(attr == ATR_ULINE);
|
||||
font.setWeight((attr == ATR_BOLD) ? QFont::Bold : QFont::Normal);
|
||||
item->setFont(font);
|
||||
// ATR_BLINK not supported
|
||||
} else {
|
||||
// ATR_DIM or ATR_INVERSE
|
||||
QBrush fg = item->foreground();
|
||||
QBrush bg = item->background();
|
||||
if (fg.color() == bg.color()) { // from menu coloring [AddRow()]
|
||||
// default foreground and background come up the same for
|
||||
// some unknown reason
|
||||
//[pr: both are set to 'Qt::color1' which has same RGB
|
||||
// value as 'Qt::black'; X11 on OSX behaves similarly]
|
||||
if (fg.color() == Qt::color1) {
|
||||
fg = Qt::black;
|
||||
bg = Qt::white;
|
||||
} else {
|
||||
fg = (bg.color() == Qt::white) ? Qt::black : Qt::white;
|
||||
}
|
||||
}
|
||||
if (attr == ATR_DIM) {
|
||||
QColor fg_clr = fg.color();
|
||||
fg_clr.setAlpha(fg_clr.alpha() / 2);
|
||||
item->setFlags(Qt::NoItemFlags);
|
||||
} else if (attr == ATR_INVERSE) {
|
||||
QBrush swapfb;
|
||||
swapfb = fg; fg = bg; bg = swapfb;
|
||||
}
|
||||
item->setForeground(fg);
|
||||
item->setBackground(bg);
|
||||
}
|
||||
if (attr == ATR_INVERSE) {
|
||||
QColor swap;
|
||||
swap = fg; fg = bg; bg = swap;
|
||||
}
|
||||
item->setForeground(fg);
|
||||
item->setBackground(bg);
|
||||
}
|
||||
// ATR_BLINK not supported
|
||||
#endif
|
||||
|
||||
if (list->count() >= (int) ::iflags.msg_history)
|
||||
delete list->item(0);
|
||||
list->addItem(text2);
|
||||
/* assert( list->count() > 0 ); */
|
||||
|
||||
// Force scrollbar to bottom
|
||||
// force scrollbar to bottom;
|
||||
// selects most recent message, which causes it to be highlighted
|
||||
list->setCurrentRow(list->count() - 1);
|
||||
|
||||
if (map)
|
||||
map->putMessage(attr, text2);
|
||||
}
|
||||
|
||||
// append the user's answer to a prompt message
|
||||
// append to the last message; usually the user's answer to a prompt
|
||||
void NetHackQtMessageWindow::AddToStr(const char *answer)
|
||||
{
|
||||
if (list) {
|
||||
QListWidgetItem *item = list->currentItem();
|
||||
int ct = 0;
|
||||
if (!item && (ct = list->count()) > 0) {
|
||||
list->setCurrentRow(ct - 1);
|
||||
item = list->currentItem();
|
||||
}
|
||||
if (item)
|
||||
item->setText(item->text() + QString(" %1").arg(answer));
|
||||
else // just in case...
|
||||
NetHackQtMessageWindow::PutStr(ATR_NONE, answer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user