Skip to content

Conversation

GamerSg
Copy link
Contributor

@GamerSg GamerSg commented Feb 27, 2016

Would have preferred if the command arrays were in a vector, would have prevented hardcoding of array sizes in for loop. I will probably do that in another pull request.

autocomplete

@luke-jr
Copy link
Member

luke-jr commented Feb 27, 2016

Concept ACK.

@jonasschnelli
Copy link
Contributor

Nice!
Concept ACK.
Will review/test soon.

@paveljanik
Copy link
Contributor

Concept ACK. Nice!

The build without wallet failed - see https://travis-ci.org/bitcoin/bitcoin/jobs/112189472#L1844

qt/libbitcoinqt.a(qt_libbitcoinqt_a-rpcconsole.o): In function `RPCConsole::RPCConsole(PlatformStyle const*, QWidget*)':
rpcconsole.cpp:(.text+0x566a): undefined reference to `vWalletRPCCommands'

@@ -274,6 +277,19 @@ RPCConsole::RPCConsole(const PlatformStyle *platformStyle, QWidget *parent) :
connect(ui->fontSmallerButton, SIGNAL(clicked()), this, SLOT(fontSmaller()));
connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear()));

//Setup autocomplete and attach it
QStringList wordList;
for (int i =0; i < 53; ++i)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why we are not using std::array?

Copy link
Contributor

Choose a reason for hiding this comment

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

You need to build the 53 dynamic by something like ARRAYLEN(vRPCCommands).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MarcoFalke That would require C++11 which i believe at this point is not supported yet in the codebase.

@jonasschnelli Apparently this is much trickier than it would seem to be. Straightforward way would be to use vector but would be kind of redundant for a const array. Will see what i can do about it.

Copy link
Member

Choose a reason for hiding this comment

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

@GamerSg Right, somehow forgot we are still waiting on travis to get c++11 rolled out.

You could take a look at src/utilstrencodings.h which has a #define ARRAYLEN(array).

@kirkalx
Copy link
Contributor

kirkalx commented Feb 28, 2016

Concept ACK, nice idea.
Perhaps this could be implemented without making vRPCCommands etc. extern?
Nit: some of the spacing is a little unusual.

bool fDisableWallet = GetBoolArg("-disablewallet", false);
if(!fDisableWallet)
{//Only add commands if wallet is not disabled
for (int i =0; i < 43; ++i)
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to build the 43 dynamic by something like ARRAYLEN(vWalletRPCCommands).

Copy link
Member

Choose a reason for hiding this comment

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

@GamerSg Are you still working on this? I'd like to see this merged :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. I also think this is a nice improvement. We just need to remove the magic numbers.
Just tell me or Marco if on of us should continue this (without losing you commit/author name).

Copy link
Member

Choose a reason for hiding this comment

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

ARRAYLEN will not work for an external array, the information is not available at compile time. Please see my suggestion below to add a call to TableRPC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MarcoFalke Sorry, been busy past few days. I'll iron out any remaining issues over the weekend.

As @laanwj said, sizeof(array) does not work either, because the data is in a seperate cpp file and unavailable at compile time to other compilation units.

#ifdef ENABLE_WALLET
bool fDisableWallet = GetBoolArg("-disablewallet", false);
if(!fDisableWallet)
{//Only add commands if wallet is not disabled
Copy link
Member

Choose a reason for hiding this comment

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

No need for this comment. Also you don't have to parse the arg. Maybe try just if (pwalletMain)?

@laanwj
Copy link
Member

laanwj commented Mar 3, 2016

Concept ACK

@laanwj
Copy link
Member

laanwj commented Mar 7, 2016

Looks good to me now!
utACK after squash

@kirkalx
Copy link
Contributor

kirkalx commented Mar 8, 2016

Sweet, utACK after style nits
Refer doc/developer-notes.md for some coding style tips. Also a space after a comma, and before and after operators like = and << are always good things IMO :)

    for (size_t i =0; i < commandList.size(); ++i)
    {
        wordList<<commandList[i].c_str();
    }

    autoCompleter = new QCompleter(wordList,this);

@jonasschnelli
Copy link
Contributor

Currently, the wallet RPC commands are missing.
You need to build up your autocomplete list in RPCConsole::setClientModel() (and only if the modal exists) instead of in RPCConsole:: RPCConsole(). This is required because of the more modular creation of the tableRPC (see #7307).

@laanwj
Copy link
Member

laanwj commented Mar 11, 2016

@jonasschnelli good catch!

@kirkalx
Copy link
Contributor

kirkalx commented Mar 11, 2016

If you are still struggling with git for squashing, @GamerSg, Wladimir helped me with the same in #7458

@GamerSg
Copy link
Contributor Author

GamerSg commented Mar 11, 2016

Hi all, i just find time during the weekends to work on this, so ill fix up the remaining issues tomorrow.

Removed externs
Added listCommands() to CRPCTable

Move autocomplete init to RPCConsole::setClientModel()
@GamerSg
Copy link
Contributor Author

GamerSg commented Mar 12, 2016

Moved the initialisation to setClientModel() as @jonasschnelli suggested.
Squashed the commits as well.

@maflcko
Copy link
Member

maflcko commented Mar 12, 2016

Looks like this works just fine, now.

ACK ce7413f:

screenshot from 2016-03-12 15-55-14

@paveljanik
Copy link
Contributor

Works OK. Please fix the indentation of "}" in rpcconsole.cpp.

@jonasschnelli
Copy link
Contributor

Tested ACK ce7413f

@jonasschnelli jonasschnelli merged commit ce7413f into bitcoin:master Mar 14, 2016
jonasschnelli added a commit that referenced this pull request Mar 14, 2016
ce7413f Add autocomplete to bitcoin-qt's console window. (Luv Khemani)
@paveljanik
Copy link
Contributor

@GamerSg When you activate (Enter) one of the selected items from autocompleter, it is executed, but the entry line is not emptied... Fixed in #7772.

svost added a commit to svost/novacoin that referenced this pull request Feb 6, 2017
cddjr referenced this pull request in cddjr/BitcoinUnlimited Apr 6, 2017
ce7413f Add autocomplete to bitcoin-qt's console window. (Luv Khemani)
jonasschnelli added a commit that referenced this pull request Oct 17, 2018
081cc02 Fix QCompleter popup regression (Hennadii Stepanov)

Pull request description:

  The PR #8129 has introduced a regression with the `QCompleter` popup in the Debug window.

  How to reproduce:

  1.  open the Debug window;
  2.  go to the 'Console' tab;
  3.  start writing some RPC command and try to pick it from the list using arrow keys, press Enter.

  Note that the popup used to display completions is not being closed. To close it they should mouse click somewhere outside of the popup.

  The wrong behaviour of the `QCompleter` popup is observed on Linux Mint 19 and Windows 10.
  This PR fixes this regression.

  Refs:

  - #7613
  - #7772
  - #8129

Tree-SHA512: f3ba8d08e1c07619d4ef307544306b57be43e4e726770976cf0c2af95082bd66e2eefe8aabb9a3fad0601cd9e6e4dea0459b6a63eba512023234feb308484655
zkbot added a commit to zcash/zcash that referenced this pull request Dec 4, 2020
Backport Boost removal PRs

Cherry-picked from the following upstream PRs:
- bitcoin/bitcoin#7613
- bitcoin/bitcoin#10502
- bitcoin/bitcoin#10193
- bitcoin/bitcoin#13961
- bitcoin/bitcoin#13734
  - Only the second commit (we don't need the first).
- bitcoin/bitcoin#14480

Part of #4819.
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 27, 2021
081cc02 Fix QCompleter popup regression (Hennadii Stepanov)

Pull request description:

  The PR bitcoin#8129 has introduced a regression with the `QCompleter` popup in the Debug window.

  How to reproduce:

  1.  open the Debug window;
  2.  go to the 'Console' tab;
  3.  start writing some RPC command and try to pick it from the list using arrow keys, press Enter.

  Note that the popup used to display completions is not being closed. To close it they should mouse click somewhere outside of the popup.

  The wrong behaviour of the `QCompleter` popup is observed on Linux Mint 19 and Windows 10.
  This PR fixes this regression.

  Refs:

  - bitcoin#7613
  - bitcoin#7772
  - bitcoin#8129

Tree-SHA512: f3ba8d08e1c07619d4ef307544306b57be43e4e726770976cf0c2af95082bd66e2eefe8aabb9a3fad0601cd9e6e4dea0459b6a63eba512023234feb308484655
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 28, 2021
081cc02 Fix QCompleter popup regression (Hennadii Stepanov)

Pull request description:

  The PR bitcoin#8129 has introduced a regression with the `QCompleter` popup in the Debug window.

  How to reproduce:

  1.  open the Debug window;
  2.  go to the 'Console' tab;
  3.  start writing some RPC command and try to pick it from the list using arrow keys, press Enter.

  Note that the popup used to display completions is not being closed. To close it they should mouse click somewhere outside of the popup.

  The wrong behaviour of the `QCompleter` popup is observed on Linux Mint 19 and Windows 10.
  This PR fixes this regression.

  Refs:

  - bitcoin#7613
  - bitcoin#7772
  - bitcoin#8129

Tree-SHA512: f3ba8d08e1c07619d4ef307544306b57be43e4e726770976cf0c2af95082bd66e2eefe8aabb9a3fad0601cd9e6e4dea0459b6a63eba512023234feb308484655
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
081cc02 Fix QCompleter popup regression (Hennadii Stepanov)

Pull request description:

  The PR bitcoin#8129 has introduced a regression with the `QCompleter` popup in the Debug window.

  How to reproduce:

  1.  open the Debug window;
  2.  go to the 'Console' tab;
  3.  start writing some RPC command and try to pick it from the list using arrow keys, press Enter.

  Note that the popup used to display completions is not being closed. To close it they should mouse click somewhere outside of the popup.

  The wrong behaviour of the `QCompleter` popup is observed on Linux Mint 19 and Windows 10.
  This PR fixes this regression.

  Refs:

  - bitcoin#7613
  - bitcoin#7772
  - bitcoin#8129

Tree-SHA512: f3ba8d08e1c07619d4ef307544306b57be43e4e726770976cf0c2af95082bd66e2eefe8aabb9a3fad0601cd9e6e4dea0459b6a63eba512023234feb308484655
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
081cc02 Fix QCompleter popup regression (Hennadii Stepanov)

Pull request description:

  The PR bitcoin#8129 has introduced a regression with the `QCompleter` popup in the Debug window.

  How to reproduce:

  1.  open the Debug window;
  2.  go to the 'Console' tab;
  3.  start writing some RPC command and try to pick it from the list using arrow keys, press Enter.

  Note that the popup used to display completions is not being closed. To close it they should mouse click somewhere outside of the popup.

  The wrong behaviour of the `QCompleter` popup is observed on Linux Mint 19 and Windows 10.
  This PR fixes this regression.

  Refs:

  - bitcoin#7613
  - bitcoin#7772
  - bitcoin#8129

Tree-SHA512: f3ba8d08e1c07619d4ef307544306b57be43e4e726770976cf0c2af95082bd66e2eefe8aabb9a3fad0601cd9e6e4dea0459b6a63eba512023234feb308484655
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
081cc02 Fix QCompleter popup regression (Hennadii Stepanov)

Pull request description:

  The PR bitcoin#8129 has introduced a regression with the `QCompleter` popup in the Debug window.

  How to reproduce:

  1.  open the Debug window;
  2.  go to the 'Console' tab;
  3.  start writing some RPC command and try to pick it from the list using arrow keys, press Enter.

  Note that the popup used to display completions is not being closed. To close it they should mouse click somewhere outside of the popup.

  The wrong behaviour of the `QCompleter` popup is observed on Linux Mint 19 and Windows 10.
  This PR fixes this regression.

  Refs:

  - bitcoin#7613
  - bitcoin#7772
  - bitcoin#8129

Tree-SHA512: f3ba8d08e1c07619d4ef307544306b57be43e4e726770976cf0c2af95082bd66e2eefe8aabb9a3fad0601cd9e6e4dea0459b6a63eba512023234feb308484655
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
081cc02 Fix QCompleter popup regression (Hennadii Stepanov)

Pull request description:

  The PR bitcoin#8129 has introduced a regression with the `QCompleter` popup in the Debug window.

  How to reproduce:

  1.  open the Debug window;
  2.  go to the 'Console' tab;
  3.  start writing some RPC command and try to pick it from the list using arrow keys, press Enter.

  Note that the popup used to display completions is not being closed. To close it they should mouse click somewhere outside of the popup.

  The wrong behaviour of the `QCompleter` popup is observed on Linux Mint 19 and Windows 10.
  This PR fixes this regression.

  Refs:

  - bitcoin#7613
  - bitcoin#7772
  - bitcoin#8129

Tree-SHA512: f3ba8d08e1c07619d4ef307544306b57be43e4e726770976cf0c2af95082bd66e2eefe8aabb9a3fad0601cd9e6e4dea0459b6a63eba512023234feb308484655
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants