Skip to content

Commit

Permalink
Merge pull request Mudlet#3275 from Mudlet/release-4.4
Browse files Browse the repository at this point in the history
Merge Release 4.4 back into development
  • Loading branch information
keneanung authored Dec 13, 2019
2 parents 61ebfa8 + 3ec2327 commit 68da4fa
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 55 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ endif()
# To insure consistency please ensure the SAME of the first two values are also
# assigned to the "VERSION" and "BUILD" variables in the native qmake project
# file, which is NOW called: ./src/mudlet.pro
set(APP_VERSION 4.3.0)
set(APP_VERSION 4.4.0)
if(DEFINED ENV{MUDLET_VERSION_BUILD} AND NOT $ENV{MUDLET_VERSION_BUILD} STREQUAL "")
set(APP_BUILD $ENV{MUDLET_VERSION_BUILD})
else()
Expand Down
26 changes: 9 additions & 17 deletions src/TBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include "mudlet.h"
#include "TConsole.h"
#include "TEvent.h"

#include "pre_guard.h"
#include <QTextBoundaryFinder>
Expand Down Expand Up @@ -702,7 +701,7 @@ TChar::TChar(const TChar& copy)
const QString timeStampFormat = QStringLiteral("hh:mm:ss.zzz ");
const QString blankTimeStamp = QStringLiteral("------------ ");

TBuffer::TBuffer(Host* pH, TConsole* pConsole)
TBuffer::TBuffer(Host* pH)
: mLinkID(0)
, mLinesLimit(10000)
, mBatchDeleteSize(1000)
Expand All @@ -721,7 +720,6 @@ TBuffer::TBuffer(Host* pH, TConsole* pConsole)
, mOpenMainQuote()
, mMXP_SEND_NO_REF_MODE(false)
, mEchoingText(false)
, mpConsole(pConsole)
, mGotESC(false)
, mGotCSI(false)
, mGotOSC(false)
Expand Down Expand Up @@ -782,8 +780,14 @@ TBuffer::TBuffer(Host* pH, TConsole* pConsole)

void TBuffer::setBufferSize(int s, int batch)
{
mLinesLimit = qMin(100, s);
mBatchDeleteSize = (batch >= mLinesLimit) ? (mLinesLimit / 10) : batch;
if (s < 100) {
s = 100;
}
if (batch >= s) {
batch = s / 10;
}
mLinesLimit = s;
mBatchDeleteSize = batch;
}

void TBuffer::updateColors()
Expand Down Expand Up @@ -3850,18 +3854,6 @@ void TBuffer::shrinkBuffer()
buffer.pop_front();
mCursorY--;
}

if (mpConsole->getType() & (TConsole::MainConsole|TConsole::UserWindow|TConsole::SubConsole)) {
// Signal to lua subsystem that indexes into the Console will need adjusting
TEvent bufferShrinkEvent{};
bufferShrinkEvent.mArgumentList.append(QLatin1String("sysBufferShrinkEvent"));
bufferShrinkEvent.mArgumentTypeList.append(ARGUMENT_TYPE_STRING);
bufferShrinkEvent.mArgumentList.append(mpConsole->mConsoleName);
bufferShrinkEvent.mArgumentTypeList.append(ARGUMENT_TYPE_STRING);
bufferShrinkEvent.mArgumentList.append(QString::number(mBatchDeleteSize));
bufferShrinkEvent.mArgumentTypeList.append(ARGUMENT_TYPE_NUMBER);
mpHost->raiseEvent(bufferShrinkEvent);
}
}

bool TBuffer::deleteLines(int from, int to)
Expand Down
5 changes: 1 addition & 4 deletions src/TBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <string>

class Host;
class TConsole;

class QTextCodec;

Expand Down Expand Up @@ -144,7 +143,7 @@ class TBuffer


public:
TBuffer(Host* pH, TConsole* pConsole = nullptr);
TBuffer(Host* pH);
QPoint insert(QPoint&, const QString& text, int, int, int, int, int, int, bool bold, bool italics, bool underline, bool strikeout);
bool insertInLine(QPoint& cursor, const QString& what, TChar& format);
void expandLine(int y, int count, TChar&);
Expand Down Expand Up @@ -277,8 +276,6 @@ class TBuffer

static const int scmMaxLinks = 2000;

const TConsole* mpConsole;

// First stage in decoding SGR/OCS sequences - set true when we see the
// ASCII ESC character:
bool mGotESC;
Expand Down
2 changes: 1 addition & 1 deletion src/TConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TConsole::TConsole(Host* pH, ConsoleType type, QWidget* parent)
, mpHost(pH)
, mpDockWidget(nullptr)
, mpCommandLine(nullptr)
, buffer(pH, this)
, buffer(pH)
, emergencyStop(new QToolButton)
, layerCommandLine(nullptr)
, mBgColor(QColor(Qt::black))
Expand Down
55 changes: 31 additions & 24 deletions src/TLuaInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2510,40 +2510,47 @@ int TLuaInterpreter::moveCursor(lua_State* L)
// Documentation: https://wiki.mudlet.org/w/Manual:Lua_Functions#setConsoleBufferSize
int TLuaInterpreter::setConsoleBufferSize(lua_State* L)
{
int s = 0;
int s = 1;
int n = lua_gettop(L);
QString windowName = QStringLiteral("main");
std::string a1;
if (n > 2) {
if (!lua_isstring(L, ++s)) {
lua_pushfstring(L, "setConsoleBufferSize: bad argument #%d type (console name as string is optional, got %s!)", s, luaL_typename(L, s));
return lua_error(L);
if (!lua_isstring(L, s)) {
lua_pushstring(L, "setConsoleBufferSize: wrong argument type");
lua_error(L);
return 1;
} else {
a1 = lua_tostring(L, s);
s++;
}
windowName = QString::fromUtf8(lua_tostring(L, s));
}

if (!lua_isnumber(L, ++s)) {
lua_pushfstring(L, "setConsoleBufferSize: bad argument #%d type (maximum line count as number expected, got %s!)", s, luaL_typename(L, s));
return lua_error(L);
int luaFrom;
if (!lua_isnumber(L, s)) {
lua_pushstring(L, "setConsoleBufferSize: wrong argument type");
lua_error(L);
return 1;
} else {
luaFrom = lua_tointeger(L, s);
s++;
}
int limit = lua_tointeger(L, s);

if (!lua_isnumber(L, ++s)) {
lua_pushfstring(L, "setConsoleBufferSize: bad argument #%d type (delete line count as number expected, got %s!)", s, luaL_typename(L, s));
return lua_error(L);
int luaTo;
if (!lua_isnumber(L, s)) {
lua_pushstring(L, "setConsoleBufferSize: wrong argument type");
lua_error(L);
return 1;
} else {
luaTo = lua_tointeger(L, s);
}
int chunkSize = lua_tointeger(L, s);

Host& host = getHostFromLua(L);
if (!windowName.compare(QLatin1String("main"))) {
host.mpConsole->buffer.setBufferSize(limit, chunkSize);
} else if (!mudlet::self()->setConsoleBufferSize(&host, windowName, limit, chunkSize)) {
lua_pushnil(L);
lua_pushfstring(L, "window \"%s\" not found", windowName.toUtf8().constData());
return 2;
}

lua_pushboolean(L, true);
return 1;
if (a1 == "main" || n < 3) {
host.mpConsole->buffer.setBufferSize(luaFrom, luaTo);
} else {
QString windowName = a1.c_str();
mudlet::self()->setConsoleBufferSize(&host, windowName, luaFrom, luaTo);
}
return 0;
}

// Documentation: https://wiki.mudlet.org/w/Manual:Lua_Functions#enableScrollBar
Expand Down
11 changes: 6 additions & 5 deletions src/lua-function-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"addSpecialExit": "addSpecialExit(roomIDFrom, roomIDTo, moveCommand)",
"addSupportedTelnetOption": "addSupportedTelnetOption(option)",
"addWordToDictionary": "addWordToDictionary(word)",
"adjustStopWatch": "adjustStopWatch(watchID/watchname, amount)",
"adjustStopWatch": "adjustStopWatch(watchID/watchName, amount)",
"alert": "alert([seconds])",
"ansi2decho": "ansi2decho(text, default_colour)",
"appendBuffer": "appendBuffer(name)",
Expand Down Expand Up @@ -168,7 +168,7 @@
"getSpecialExitsSwap": "exits = getSpecialExitsSwap(roomID)",
"getStopWatchBrokenDownTime": "brokenDownTimeTable = getStopWatchBrokenDownTime(watchID or watchName)",
"getStopWatches": "table = getStopWatches()",
"getStopWatchTime": "time = getStopWatchTime(watchID or watchName)",
"getStopWatchTime": "time = getStopWatchTime(watchID [or watchName from Mudlet 4.4.0])",
"getTextFormat": "getTextFormat([windowName])",
"getTime": "time = getTime(returntype, format)",
"getTimestamp": "time = getTimestamp([console_name], lineNumber)",
Expand Down Expand Up @@ -236,6 +236,7 @@
"raiseEvent": "raiseEvent(event_name, arg-1, … arg-n)",
"raiseGlobalEvent": "raiseGlobalEvent(event_name, arg-1, … arg-n)",
"raiseWindow": "raiseWindow(labelName)",
"receiveMSP": "receiveMSP(command)",
"reconnect": "reconnect()",
"registerAnonymousEventHandler": "id = registerAnonymousEventHandler(event name, functionReference, [one shot])",
"reloadModule": "reloadModule(module name)",
Expand Down Expand Up @@ -300,7 +301,7 @@
"setGaugeStyleSheet": "setGaugeStyleSheet(gaugeName, css, cssback, csstext)",
"setGaugeText": "setGaugeText(gaugename, css, ccstext )",
"setGridMode": "setGridMode(areaID, true/false)",
"setHexBgColor": "setHexFgColor([windowName], hexColorString)",
"setHexBgColor": "setHexBgColor([windowName], hexColorString)",
"setHexFgColor": "setHexFgColor([windowName], hexColorString)",
"setIrcChannels": "setIrcChannels(channels)",
"setIrcNick": "setIrcNick(nickname)",
Expand Down Expand Up @@ -352,9 +353,9 @@
"spellCheckWord": "spellCheckWord(word, [customDictionary])",
"spellSuggestWord": "spellSuggestWord(word, [customDictionary])",
"startLogging": "startLogging(state)",
"startStopWatch": "startStopWatch(watchID) -",
"startStopWatch": "startStopWatch( watchID ) - up to Mudlet 4.4.0",
"stopSounds": "stopSounds()",
"stopStopWatch": "stopStopWatch(watchID / watchName)",
"stopStopWatch": "stopStopWatch( watchID [or watchName from Mudlet 4.4.0])",
"suffix": "suffix(text, [writingFunction], [foregroundColor], [backgroundColor], [windowName])",
"tempAlias": "aliasID = tempAlias(regex, code to do)",
"tempAnsiColorTrigger": "tempAnsiColorTrigger(foregroundColor, backgroundColor, code, expireAfter)",
Expand Down
4 changes: 2 additions & 2 deletions src/mudlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2292,9 +2292,9 @@ bool mudlet::setConsoleBufferSize(Host* pHost, const QString& name, int x1, int
if (pC) {
pC->buffer.setBufferSize(x1, y1);
return true;
} else {
return false;
}

return false;
}

bool mudlet::setScrollBarVisible(Host* pHost, const QString& name, bool isVisible)
Expand Down
2 changes: 1 addition & 1 deletion src/mudlet.pro
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ TEMPLATE = app
########################## Version and Build setting ###########################
# Set the current Mudlet Version, unfortunately the Qt documentation suggests
# that only a #.#.# form without any other alphanumberic suffixes is required:
VERSION = 4.3.0
VERSION = 4.4.0

# if you are distributing modified code, it would be useful if you
# put something distinguishing into the MUDLET_VERSION_BUILD environment
Expand Down

0 comments on commit 68da4fa

Please sign in to comment.