Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocompletion to code editor #1666

Merged
merged 28 commits into from
Aug 13, 2018
Merged

Conversation

dicene
Copy link
Contributor

@dicene dicene commented May 13, 2018

Brief overview of PR changes/additions

Initial commit of autocomplete support for edbee textbox

  • Add a few hard-coded function entries for testing.
  • Adds autocompleter from edbee.
  • Updates edbee to point to my fork of edbee, which I'll try and PR after I've got it fully fleshed out.

Motivation for adding to Mudlet

Coding in Mudlet can take a significant amount of time due to the massive list of lua functions added and the lack of any documentation in the program itself. It often ends up requiring having the Lua Function list on the Wiki open the entire time and feels like a significant impedance to quickly writing code unless you have another monitor open with said Function list. Hopefully, adding an autocomplete feature will make the process of writing code significantly less daunting for new and old users alike.

Other info (issues closed, discussion etc)

Remaining changes before I think it's ready to be added to the next release:

  • Fix menu resizing.
  • Initial tooltip is the wrong size.
  • Update placement logic to prevent tooltip from displaying off-screen and to relocate list above text if very close to the bottom of the screen.
  • Resize list or elide text based on function name and return name.
  • Hide tooltip when window moves
  • Reference the current edbee theme for coloring the autocomplete list and tooltip.
  • Include the LuaFunctionNames file internally to Mudlet, so it doesn't need to be added to every user's .config/Mudlet/
  • Either force autocomplete list to show up separately from the editor(because right now, it gets masked to where the editor is), or make the tooltip a child of the editor, so it also gets masked. I think it would be better to have both widgets separate, and capable of showing up outside of the editor widget.

Known issues:

  • List's width is considering entries with return values perfectly, but the ones without return values are being considered as slightly smaller than they should. Those entries are pretending to have an extra character to make up for it.

Add a few hard-coded function entries for testing.
Adds autocompleter from edbee.
Updates edbee to point to my fork of edbee, which I'll try and PR after I've got it fully fleshed out.
@dicene dicene requested a review from a team as a code owner May 13, 2018 19:11
@vadi2 vadi2 changed the title Initial commit. Add autocompletion to code editor May 14, 2018
…on names from a file, and adds reserved lua words to the provider.
@dicene
Copy link
Contributor Author

dicene commented May 19, 2018

Moved change list to summary of PR

@SlySven
Copy link
Member

SlySven commented May 20, 2018

I have tries to compile it locally but when I do a git submodule status I find that the wanted 3rdparty/edbee-lib sub-module commit is present at http://github.com/edbee/edbee-lib/commit/7524d10961515344014a349ba5e94f82a32730b5 but is not visibly so in the repository {the current head of the master branch is at: d6a71925bda26dcab2b32571b14338ffb7a18e2e}.

Ah, ha, the wanted commit is two commits later on from the published head of the master branch but it is not visible when running gitk in the submodule directory - and I guess that github is not serving it up to the CI processors either - I've have now found it at https://github.com/dicene/edbee-lib/tree/dicene/autocomplete .

@keneanung
Copy link
Member

I took the liberty to update the .gitmodules file to point to your forked edbee-lib repository to make it possible to build this. They'll need to git submodule sync && git submodule update every time they switch to and from your branch for the moment.

@dicene
Copy link
Contributor Author

dicene commented May 22, 2018

Hrm. I thought that I had managed to get the file pointing to my fork(and updated to the most recent commit, since as I understand it the file points to a specific commit), but I guess not. Hrm...

@SlySven
Copy link
Member

SlySven commented May 24, 2018

It would be simpler if upstream adopts your changes - is there any sign that they might do that?

@dicene
Copy link
Contributor Author

dicene commented May 24, 2018

At some point, yeah. Based on the response time of upstream's dev, it'll take quite a while. The feature will almost certainly be release-ready before the PR on Edbee gets to the point where it's acceptable and merged.

dicene added 5 commits May 25, 2018 10:18
…sely to langserv protocol

updates edbee-lib referenced
… below:

Updates the key handler to allow enter/return/tab to go to editor as usual if the currentWord exactly matches the selected item on the list(which it always will immediately after typing an exact match, based on the way the list gets updated as you type).
The menu also now hides if there is only one match in the list, and it's an exactly match of the currentWord.
Updates mudlet class to use internal resource.
@@ -0,0 +1 @@
{"createBuffer":"createBuffer(name)","getFont":"getFont(name)","setLabelReleaseCallback":"setLabelReleaseCallback(labelName, luaFunctionName, optional any amount of arguments)","openWebPage":"openWebPage(URL)","tempBeginOfLineTrigger":"tempBeginOfLineTrigger(part of line, code to do)","killTrigger":"killTrigger(id)","setAreaUserData":"setAreaUserData(areaID, key (as a string), value (as a string))","handleWindowResizeEvent":"handleWindowResizeEvent()","replaceAll":"replaceAll( what, with )","sendAll":"sendAll(list of things to send, [echo back or not])","searchAreaUserData":"searchRoom (room name / room number)","setRoomChar":"setRoomChar(roomID, character)","saveWindowLayout":"saveWindowLayout","getTimestamp":"getTimestamp( optional console_name, lineNumber )","insertPopup":"insertPopup([windowName], text, {commands}, {hints}, [current or default format])","setBold":"setBold(windowName, boolean)","tempTimer":"tempTimer(time, code to do)","getRoomChar":"getRoomChar(roomID)","setBorderTop":"setBorderTop(size)","tempPromptTrigger":"tempLineTrigger(code to do)","getMapLabel":"labelinfo = getMapLabels(areaID, labelID)","clearSpecialExits":"clearSpecialExits(roomID)","removeMapEvent":"removeMapEvent (event name)","resizeWindow":"resizeWindow(name,width,height)","connectToServer":"connectToServer(host, port, <i>save</i>)","permBeginOfLineStringTrigger":"permBeginOfLineStringTrigger(name, parent, pattern table, lua code)","permAlias":"permAlias(name, parent, regex, lua code)","setLabelStyleSheet":"setLabelStyleSheet(label, markup)","killAlias":"killAlias(name)","clearWindow":"clearWindow(window_name)","print":"print(text, some more text, ...)","getFgColor":"getFgColor(windowName)","getMudletVersion":"getMudletVersion(style)","tempTrigger":"tempTrigger(substring, code to do)","getRoomAreaName":"getRoomAreaName(areaID or areaName)","hideToolBar":"hideToolBar(name)","isActive":"isActive(name, type)","permRegexTrigger":"permRegexTrigger(name, parent, pattern table, lua code)","appendBuffer":"appendBuffer(name)","setConsoleBufferSize":"setConsoleBufferSize( consoleName, linesLimit, sizeOfBatchDeletion )","killKey":"killKey(name)","showToolBar":"showToolBar(name)","getAreaUserData":"getAreaUserData(areaID, key)","downloadFile":"downloadFile(saveto, url)","suffix":"suffix(text)","searchRoomUserData":"searchRoomUserData(key, value)","addMapMenu":"addMapMenu(uniquename, parent, display name)","raiseWindow":"raiseWindow([labelName])","isAnsiFgColor":"isAnsiFgColor(ansiFgColorCode)","createGauge":"createGauge(name, width, height, Xpos, Ypos, gaugeText, r, g, b, orientation)","setFont":"setFont(name, font)","setCustomEnvColor":"setCustomEnvColor(environmentID, r,g,b,a)","getRoomExits":"getRoomExits (roomID)","selectCurrentLine":"selectCurrentLine([windowName])","sendTelnetChannel102":"sendTelnetChannel102(msg)","setFgColor":"setFgColor([windowName],r, g, b)","setRoomUserData":"setRoomUserData(roomID, key (as a string), value (as a string))","getMudletHomeDir":"getMudletHomeDir()","setHexBgColor":"setHexFgColor([windowName], hexColorString)","debugc":"debugc( content )","updateMap":"updateMap()","lockExit":"lockExit(roomID, direction, lock = true/false)","createMiniConsole":"createMiniConsole(name, x, y, width, height)","enableTimer":"enableTimer(name)","deleteRoom":"deleteRoom(roomID)","tempComplexRegexTrigger":"tempComplexRegexTrigger('name', regex, code to do, multiline, foreground color, bg color, filter, match all, highlight foreground color, highlight background color, play sound file, fire length, line delta)","getServerEncodingsList":"getServerEncodingsList()","getIrcConnectedHost":"getIrcConnectedHost()","echoLink":"echoLink([windowName], text, command, hint, [bool use_current_format or defaultLinkFormat])","getMapEvents":"mapevents = getMapEvents()","getAreaTableSwap":"getAreaTableSwap()","getServerEncoding":"getServerEncoding()","insertLink":"insertLink([windowName], text, command, hint, [useDefaultLinkFormat])","getPath":"getPath(roomID from, roomID to)","lockSpecialExit":"lockSpecialExit (from roomID, to roomID, special exit command, lock = true/false)","startStopWatch":"startStopWatch( watchID )","openUserWindow":"openUserWindow(name, <i>restoreLayout</i>)","getSpecialExitsSwap":"exits = getSpecialExitsSwap(roomID)","getLines":"getLines(from_line_number, to_line_number)","saveProfile":"saveProfile()","getRooms":"rooms = getRooms()","setExitWeight":"setExitWeight(roomID, exitCommand, weight)","createMapLabel":"labelID = createMapLabel(areaID, text, posx, posy, posz, fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue, zoom, fontSize, showOnTop, noScaling)","getAllRoomUserData":"getAllRoomUserData(roomID)","getStopWatchTime":"getStopWatchTime(watchID)","setHexFgColor":"setHexFgColor([windowName], hexColorString)","permGroup":"permGroup(name, itemtype, <i>parent</i>)","clearMapUserData":"clearMapUserData()","getIrcServer":"getIrcServer()","playSoundFile":"playSoundFile(fileName, volume)","getFontSize":"getFontSize(name)","clearMapUserDataItem":"clearUserDataItem(mapID,key)","replaceWildcard":"replaceWildcard(which, replacement)","setFontSize":"setFontSize(name, size)","getAllRoomEntrances":"getAllRoomEntrances(roomID)","addAreaName":"areaID = addAreaName(areaName)","setBackgroundImage":"setBackgroundImage(labelName, imageLocation)","setGridMode":"setGridMode(areaID, true/false)","getBgColor":"getBgColor(windowName)","creplaceLine":"creplaceLine (text)","permTimer":"permTimer(name, parent, seconds, lua code)","loadMap":"boolean = loadMap(file location)","isAnsiBgColor":"isAnsiBgColor(ansiBgColorCode)","resetFormat":"resetFormat()","deleteLine":"deleteLine([optional windowName])","selectSection":"selectSection(from, how long)","getNetworkLatency":"getNetworkLatency()","loadWindowLayout":"loadWindowLayout","removeSpecialExit":"removeSpecialExit(roomID, command)","closeMudlet":"closeMudlet()","clearAreaUserData":"clearAreaUserData(areaID)","disconnect":"disconnect()","setItalics":"setItalics(windowName, bool)","exportAreaImage":"exportAreaImage(areaID)","getAllMapUserData":"getAllMapUserData()","unHighlightRoom":"unHighlightRoom(roomID)","ansi2decho":"ansi2decho(text, default_colour)","disableTimer":"disableTimer(name)","copy":"copy([windowName])","resetProfile":"resetProfile()","roomLocked":"locked = roomLocked(roomID)","clearUserWindow":"clearUserWindow(name)","addRoom":"addRoom(roomID)","setMapUserData":"setMapUserData(key (as a string), value (as a string))","setExitStub":"setExitStub(roomID, direction, set/unset)","getRoomsByPosition":"getRoomsByPosition(areaID, x,y,z)","exists":"exists(name, type)","getAreaTable":"getAreaTable()","setMiniConsoleFontSize":"setTextFormat(windowName, r1, g1, b1, r2, g2, b2, bold, underline, italics[, strikeout])","invokeFileDialog":"invokeFileDialog(fileOrFolder, dialogTitle)","getMapUserData":"getMapUserData( key )","tempLineTrigger":"tempLineTrigger(from, howMany, code to do)","resetStopWatch":"resetStopWatch(watchID)","echo":"echo([miniconsole or label], text)","raiseEvent":"raiseEvent(event_name, arg-1, … arg-n)","prefix":"prefix(text)","replace":"replace([windowName,] with[, keepcolor])","createButton":"createConsole(consoleName, fontSize, charsPerLine, numberOfLines, Xpos, Ypos)","createRoomID":"usableId = createRoomID([minimumStartingRoomId])","centerview":"centerview (roomID)","getRowCount":"getRowCount([window])","getIrcChannels":"getIrcChannels()","showCaptureGroups":"showCaptureGroups()","addSpecialExit":"addSpecialExit(roomIDFrom, roomIDTo, command)","clearRoomUserDataItem":"clearRoomUserDataItem(roomID,key)","paste":"paste(windowName)","clearRoomUserData":"clearRoomUserData(roomID)","disableAlias":"disableAlias(name)","getModulePath":"path = getModulePath(module name)","clearCmdLine":"clearCmdLine()","setRoomEnv":"setRoomEnv(roomID, newEnvID)","cechoLink":"cechoLink([windowName], text, command, hint, true)","dechoLink":"dechoLink([windowName], text, command, hint, true)","getDoors":"doors = getDoors(roomID)","setMapZoom":"setMapZoom(zoom)","hechoLink":"hechoLink([windowName], text, command, hint, true)","sendIrc":"sendIrc(target, message)","permSubstringTrigger":"permSubstringTrigger( name, parent, pattern table, lua code )","getCustomLines":"getCustomLines(roomID)","startLogging":"startLogging(state)","getRoomEnv":"envID = getRoomEnv(roomID)","getSpecialExits":"exits = getSpecialExits(roomID)","getColumnNumber":"getColumnNumber([window])","getMainWindowSize":"getMainWindowSize()","registerAnonymousEventHandler":"id = registerAnonymousEventHandler(event name, function[, one shot])","disableTrigger":"disableTrigger(name)","setMainWindowSize":"setMainWindowSize(mainWidth, mainHeight)","setExit":"setExit(from roomID, to roomID, direction)","enableAlias":"enableAlias(name)","gotoRoom":"gotoRoom (roomID)","ioprint":"ioprint(text, some more text, ...)","uninstallPackage":"uninstallPackage(name)","uninstallModule":"uninstallModule(name)","timeframe":"timeframe(vname, true_time, nil_time, ...)","setRoomIDbyHash":"setRoomIDbyHash(roomID, hash)","tempRegexTrigger":"tempRegexTrigger(regex, code to do)","tempKey":"tempKey(<i>modifier</i>, key code, lua code)","getTime":"getTime(returntype, format)","tempExactMatchTrigger":"tempExactMatchTrigger(exact line, code to do)","tempColorTrigger":"tempColorTrigger(foregroundColor, backgroundColor, code to do)","tempButtonToolbar":"tempButtonToolbar(name, location, orientation)","denyCurrentSend":"denyCurrentSend()","tempButton":"tempButton(toolbar name, button text, orientation)","mudletOlderThan":"mudletOlderThan(major, <i>minor</i>, <i>patch</i>)","reconnect":"reconnect()","tempAlias":"aliasID = tempAlias(regex, code to do)","getExitWeights":"weights = getExitWeights(roomid)","setIrcNick":"setIrcNick( nickname )","printCmdLine":"printCmdLine(text)","cecho":"cecho(window, text)","decho":"decho ([name of console,] text)","stopStopWatch":"stopStopWatch( watchID )","getMousePosition":"getMousePosition()","speedwalk":"speedwalk(dirString, backwards, delay)","moveCursor":"moveCursor([optional windowName], x, y)","spawn":"spawn(read function, process to spawn[, ...arguments])","calcFontSize":"calcFontSize(fontSize)","showWindow":"showWindow(name)","showMultimatches":"showMultimatches()","raiseGlobalEvent":"raiseGlobalEvent(event_name, arg-1, … arg-n)","createMapper":"createMapper(x, y, width, height)","addSupportedTelnetOption":"addSupportedTelnetOption(option)","showColors":"showColors(columns, filterColor)","shms":"shms( seconds, bool )","setWindowWrap":"setWindowWrap(windowName, wrapAt)","fg":"fg([window, ]colorName)","reloadModule":"reloadModule(module name)","connectExitStub":"connectExitStub(fromID, direction or toID[, optional direction])","killTimer":"killTimer(id)","bg":"bg([window, ]colorName)","setTriggerStayOpen":"setTriggerStayOpen(name, number)","setStrikeOut":"setStrikeOut(windowName, boolean)","setServerEncoding":"setServerEncoding(encoding)","installModule":"installModule(location)","cinsertText":"cinsertText(window, text)","getCmdLine":"getCmdLine()","getRoomCoordinates":"x,y,z = getRoomCoordinates(room ID)","setRoomName":"setRoomName(roomID, newName)","setRoomCoordinates":"setRoomCoordinates(roomID, x, y, z)","deleteMapLabel":"deleteMapLabel(areaID, labelID)","setPopup":"setPopup(name, {lua code}, {hints})","setModulePriority":"setModulePriority(module name, priority #)","setRoomWeight":"setRoomWeight(roomID, weight)","setLink":"setLink([window, ]command, tooltip)","setLabelWheelCallback":"setLabelWheelCallback(labelName, luaFunctionName, optional any amount of arguments)","setAppStyleSheet":"setAppStyleSheet(stylesheet)","clearAreaUserDataItem":"clearAreaUserDataItem(areaID,key)","setLabelOnEnter":"setLabelOnEnter(labelName, luaFunctionName, optional any amount of arguments)","getCustomEnvColorTable":"envcolors = getCustomEnvColorTable()","setLabelMoveCallback":"setLabelMoveCallback(labelName, luaFunctionName, optional any amount of arguments)","getExitStubs1":"stubs = getExitStubs1(roomid)","getLineNumber":"getLineNumber([window])","hasExitLock":"status = hasExitLock(roomID, direction)","setLabelClickCallback":"setLabelClickCallback(labelName, luaFunctionName, optional any amount of arguments)","setIrcServer":"setIrcServer( hostname, port )","hasFocus":"hasFocus()","setIrcChannels":"setIrcChannels( channels )","expandAlias":"expandAlias(command, true/false)","enableKey":"enableKey(name)","setGaugeText":"setGaugeText(gaugename, css, ccstext )","setGaugeStyleSheet":"setGaugeStyleSheet(gaugeName, css, cssback, csstext)","killAnonymousEventHandler":"killAnonymousEventHandler(handler id)","getRoomWeight":"room weight = getRoomWeight(roomID)","getRoomUserData":"getRoomUserData(roomID, key)","insertText":"insertText([optional windowName], text)","hasSpecialExitLock":"status = hasSpecialExitLock(from roomID, to roomID, command)","getMapLabels":"arealabels = getMapLabels(areaID)","enableTrigger":"enableTrigger(name)","getRoomUserDataKeys":"getRoomUserDataKeys(roomID)","stopSounds":"stopSounds()","setGauge":"setGauge(gaugeName, currentValue, maxValue, gaugeText)","installPackage":"installPackage(location)","openUrl":"openUrl (url)","setDoor":"setDoor(roomID, exitCommand, doorStatus)","createStopWatch":"createStopWatch()","display":"display( content )","getEpoch":"getEpoch()","getExitStubs":"stubs = getExitStubs(roomid)","setButtonStyleSheet":"setButtonStyleSheet(button, markup)","feedTriggers":"feedTriggers(text)","deleteArea":"deleteArea(areaID or areaName)","getRoomArea":"areaID = getRoomArea(roomID)","selectCaptureGroup":"selectCaptureGroup(groupNumber)","enableScrollBar":"enableScrollBar(windowName)","setBorderLeft":"setBorderLeft(size)","setBorderRight":"setBorderRight(size)","lowerWindow":"lowerWindow(labelName)","addCustomLine":"addCustomLine(roomID, id_to, direction, style, color, arrow)","setBorderColor":"setBorderColor(r,g,b)","setBorderBottom":"setBorderBottom(size)","moveWindow":"moveWindow( name, x, y )","resetRoomArea":"resetRoomArea (areaID)","setBgColor":"setBgColor([windowName], r,g,b )","getCurrentLine":"getCurrentLine()","setBackgroundColor":"setBackgroundColor(labelName, red, green, blue, transparency)","moveGauge":"moveGauge(gaugeName, newX, newY)","setAreaName":"setAreaName(areaID or areaName, newName)","getButtonState":"getButtonState()","setLabelOnLeave":"setLabelClickCallback(labelName, luaFunctionName, optional any amount of arguments)","sendSocket":"sendSocket(data)","echoPopup":"echoPopup([window], text, {commands}, {hints}, [current or default format])","deselect":"deselect([optional window name])","permKey":"permKey(name, parent, <i>modifier</i>, key code, lua code)","sendGMCP":"sendGMCP(command)","appendCmdLine":"appendCmdLine()","send":"send( command, show on screen )","selectString":"selectString( [windowName], text, number_of_match )","createMapImageLabel":"labelID = createMapImageLabel(areaID, filePath, posx, posy, posz, width, height, zoom, showOnTop)","getProfileName":"name = getProfileName()","setRoomArea":"setRoomArea(roomID, newAreaID or newAreaName)","saveMap":"saveMap(location)","roomExists":"roomExists(roomID)","getIrcNick":"getIrcNick()","isPrompt":"isPrompt()","highlightRoom":"highlightRoom( roomID, color1Red, color1Green, color1Blue, color2Red, color2Green, color2Blue, highlightRadius, color1Alpha, color2Alpha)","getMainConsoleWidth":"getMainConsoleWidth()","echoUserWindow":"echoUserWindow(windowName)","setUnderline":"setUnderline(windowName, bool)","getRoomIDbyHash":"roomID = getRoomIDbyHash(hash)","setMergeTables":"setMergeTables(module)","getLastLineNumber":"getLastLineNumber(window)","getAreaExits":"getAreaExits(areaID, showExits)","getAreaRooms":"getAreaRooms(area id)","moveCursorEnd":"moveCursorEnd( windowName )","addMapEvent":"addMapEvent(uniquename, event name, parent, display name, arguments)","getColorWildcard":"getColorWildcard(ansi color number)","createLabel":"createLabel(name, Xpos, Ypos, width, height, fillBackground)","disableScrollBar":"disableScrollBar(windowName)","restartIrc":"restartIrc()","hideWindow":"hideWindow(name)","lockRoom":"lockRoom (roomID, lock = true/false)","sendATCP":"sendATCP(message, what)","sendMSDP":"sendMSDP(variable[, value][, value...])","getLineCount":"getLineCount()","wrapLine":"wrapLine(windowName, lineNumber)","getRoomName":"roomName = getRoomName(roomID)","getColumnCount":"getColumnCount([window])","disableKey":"disableKey(name)","getMudletLuaDefaultPaths":"getMudletLuaDefaultPaths()","hecho":"hecho(window, text)","getModulePriority":"priority = getModulePriority(module name)","alert":"alert(<i>seconds</i>)","setLabelDoubleClickCallback":"setLabelDoubleClickCallback(labelName, luaFunctionName, optional any amount of arguments)"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you pretty-print it and name lua-function-list.json to be in line with the rest of resources?

src/mudlet.cpp Outdated
bool mudlet::loadLuaFunctionList()
{
qDebug() << "Loading the luaFunctionList via loadLuaFunctionList()...";
QFile* jsonFile = new QFile(QStringLiteral(":/luaFunctionList.json"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 perfect

dicene added 2 commits June 1, 2018 00:46
…be themed appropriately now and should be using the currently set font.
Prettified `lua-function-list.json`
@vadi2
Copy link
Member

vadi2 commented Jun 4, 2018

@dicene let us know when 1.0 is good for review

Copy link
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though its not much on the Mudlet side

@@ -193,6 +193,50 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH)

mudlet::loadEdbeeTheme(mpHost->mEditorTheme, mpHost->mEditorThemeFile);

edbee::StringTextAutoCompleteProvider* provider = new edbee::StringTextAutoCompleteProvider();
//QListIterator<QString> i(mudlet::);
foreach(QString key, mudlet::mLuaFunctionNames.keys())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foreach is an outdated Qt macro - go with for (auto key : mudlet::mLuaFunctionNames.keys())

@@ -193,6 +193,50 @@ dlgTriggerEditor::dlgTriggerEditor(Host* pH)

mudlet::loadEdbeeTheme(mpHost->mEditorTheme, mpHost->mEditorThemeFile);

edbee::StringTextAutoCompleteProvider* provider = new edbee::StringTextAutoCompleteProvider();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to a QScopedPointer so we don't have to worry about a memory leak when the profile is closed

src/mudlet.cpp Outdated

auto json_doc = QJsonDocument::fromJson(data);

if(json_doc.isNull()){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run the clang-formatter on this (just the functions you've made)

@dicene dicene requested a review from a team June 5, 2018 03:33
@Kebap
Copy link
Contributor

Kebap commented Aug 3, 2018

After recent fix, this seems now working as expected:
image

@dicene
Copy link
Contributor Author

dicene commented Aug 3, 2018

Could someone test it in Linux, run from a console, and see if they're getting Edbee memory leak messages? I've had no luck finding those messages when I test in Windows.

Copy link
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just clean up some of the commented out things

#include <QSslConfiguration>
#include <QString>
#include <QStringList>
#include <QStringBuilder>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed for this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clue where the QSslConfiguration is coming from. I don't remember adding it, heh. I'll see what I can remove without breaking things.

Copy link
Member

@SlySven SlySven Aug 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Looks like a messed up git merge conflict resolution of the development branch into this one at: b6bb142 {Ian ieadkins@gmail.com 2018-06-21 16:35:05 - "Merge branch 'development' into autocomplete"} at that point TWO instances of #include "post_guard.h" got in, each with a different set of #include lines preceding them... 👎

P.S. QSslConfiguration is needed to be available in the TLuainterpreter class as it is used by the downloadFile function {apropos of other current OpenSSL stuff currently going on, this is provided QT_NO_OPENSSL is NOT defined! 😮 }

provider->add("then", 14);
provider->add("true", 14);
provider->add("until", 14);
provider->add("while", 14);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add goto here given that we know that's coming in 5.3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can doooo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, I thought we were stuck on Lua 5.1.x because changing that would break backwards compatibility - or are we planned a step-change/break with Mudlet 5.0 (or, um, 4.0)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No plans, but can't hurt to hint to avoid that as a variable name

src/mudlet.cpp Outdated
@@ -508,6 +515,12 @@ void mudlet::initEdbee()
// We only need the single Lua lexer, probably ever
grammarManager->readGrammarFile(QLatin1Literal(":/edbee_defaults/Lua.tmLanguage"));

//Open and parse luaFunctionList
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a very good comment - the functions name is luaFunctionList to begin with - what is this list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make it more insightful

@Kebap
Copy link
Contributor

Kebap commented Aug 4, 2018

There is text missing in the list, but it is shown in the tooltip. Maybe has to do with the equal sign?

image

@dicene
Copy link
Contributor Author

dicene commented Aug 4, 2018

Yeah, that's likely what's causing that issue. I don't think there's a fix for this besides making a pass at every Lua function in the wiki and cleaning them up so they're all suitable for this use. I can do that in this PR or another, whatever is most appropriate.

@Kebap
Copy link
Contributor

Kebap commented Aug 4, 2018

Not sure if adjusting wiki is a viable option here. It seems to me like a bug in your code, because in one place, you can display equal sign "=" just fine, only in a different place it is a problem. Here is another example of the same, to show you it is not easy to remove in wiki, because for example we want to display return parameters for clarification:

image

@Kebap
Copy link
Contributor

Kebap commented Aug 4, 2018

There is a different issue with this list as well. When scrolling through the list with cursor keys (for example, also works with mouse clicks), one of the tool-tips in vincinity of the one with the equal sign "=" will be displayed wrongly. It will show the tool-tip of the adjacent entry, not the correct tool-tip. More interesting, this will happen to different list entries, depending on whether I go up or down in the list. See gif for comparison:
list

@Kebap
Copy link
Contributor

Kebap commented Aug 4, 2018

I have had unexpected crashes quite a few times now while testing autocompletion when clicking into other windows (not Mudlet) - how should I report details for you to review?
Here is how I can currently reproduce: Start Mudlet. Open Script editor. Start/focus notepad. Mudlet crashes! Will not crash if Script editor is closed. So current workaround is: Start Mudlet. Open Script editor. Test. Close Script editor. Click outside Mudlet. Come back to Mudlet. Open Script editor again. Remember not to click outside Mudlet while Script editor is open, otherwise Mudlet will crash.

@dicene
Copy link
Contributor Author

dicene commented Aug 5, 2018

@Kebap Not sure what you mean by one of those comments. I think it's fair to have certain expectations about the wiki's format, or else it'll be impossible to scrape. I don't think it'll ever be necessary to have two equals signs in a function's signature, so I'll be sure to clear up the ones that break that rule. Looking into the other issue.

@Kebap
Copy link
Contributor

Kebap commented Aug 5, 2018

Which one comment was unclear?

I did not find any function with two equal signs. The problems arose whenever there was one equal sign.

@dicene
Copy link
Contributor Author

dicene commented Aug 5, 2018

The one that starts with "Not sure if adjusting wiki is a viable option here...". The reason you don't find any function with two equal signs is because I fixed them yesterday. 😄

The issue where it's showing the wrong tooltip is something I'm tracking down right now.

@Kebap
Copy link
Contributor

Kebap commented Aug 5, 2018

Ok fair enough. I have now seen the 3 changes you did in the wiki yesterday a few hours after I was active there. Then again, there were no double equal signs == visible to me. You removed only single ones, right? What is more, none of those functions were involved in the issues reported above. Maybe we are constantly misunderstanding?!

@dicene
Copy link
Contributor Author

dicene commented Aug 5, 2018

There were two issues. The first occurred when there was a second = sign anywhere in the function's signature. The three(I think three) functions that I had to change had another = sign in the parameters list. They were something like lockRoom(roomID, lock = true or false). The other issue(where wrong tooltips show up when scrolling up and down) is what I'm still working on tracking down.

@Kebap
Copy link
Contributor

Kebap commented Aug 5, 2018

Looking at the lua function list json there are about 30 functions with an equal sign = in the definition. Most of them are not inside the parameters list, but instead used to display the returned value from that function. I would welcome some code to display them in your autocomplete list, and not remove them from wiki.

@Kebap
Copy link
Contributor

Kebap commented Aug 5, 2018

Sometimes I see an issue with the tooltip showing at a different line than typing:
image
It seems to have to do with scrolling the code editor window. Not sure exactly yet how to reproduce.

@Kebap
Copy link
Contributor

Kebap commented Aug 6, 2018

Reviewing those 30 function definitions, most of them can be axed easily after all. They seem utterly obvious and therefore irrelevant like mapevents = getMapEvents() but others are less, e.g. status = hasSpecialExitLock(from roomID, to roomID, command)

@dicene
Copy link
Contributor Author

dicene commented Aug 6, 2018

The ones with a single equals sign are fine. I'm using that equals sign to grab the return name. It was only an issue that those functions had an extra one in the parameters. And that wrong line issue is strange. I'll have to do some more testing to try and reproduce that. Gonna get the other known issue, the incorrect tooltip showing, cleaned up today.

@dicene
Copy link
Contributor Author

dicene commented Aug 6, 2018

And I'll rescrape the functions so those 3 equals sign duplicates are fixed.

dicene added 4 commits August 6, 2018 22:25
…isplayed.

Updated lua-function-list.json to fix three occasions of unnecessary equals sign's messing up the list generation(equal's sign shouldn't be anywhere in the function's signature except between the return value and the function's name.
Corrects placement of autocomplete list when editor isn't scrolled to the very top.
Updates tooltip placement to only display to the left if there is enough room left, and not enough room right. If there isn't room in either direction, it's shown right so there isn't confusion about whether the tooltip for that entry actually exists.
…st. List placement now takes into account the actual line-number-margin size as well as the horizontal scrollbar. All placement issues should be fixed.
@vadi2
Copy link
Member

vadi2 commented Aug 10, 2018

@Kebap is this good to go?

@vadi2 vadi2 merged commit 17a8f92 into Mudlet:development Aug 13, 2018
@dicene dicene deleted the autocomplete branch August 13, 2018 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants