Skip to content

Conversation

bfredl
Copy link
Member

@bfredl bfredl commented Jan 2, 2019

for mouse control and such.

Old code, haven't checked if it still works... working now.

@marvim marvim added the WIP label Jan 2, 2019
@bfredl bfredl mentioned this pull request Jan 2, 2019
23 tasks
@bfredl bfredl force-pushed the pum_api branch 2 times, most recently from 760de05 to df88efe Compare January 3, 2019 19:07
@bfredl
Copy link
Member Author

bfredl commented Jan 3, 2019

Update: there should be no reason to forbid this function to be called locally, so moved to vim.c and removed active UI check. Seems to work well with <cmd> with manual testing.

@bfredl bfredl force-pushed the pum_api branch 2 times, most recently from 4a42503 to ea61f4a Compare January 7, 2019 19:56
@bfredl
Copy link
Member Author

bfredl commented Jan 7, 2019

Updated with docs and tests.

@bfredl bfredl changed the title [WIP] allow UI to select items in external popupmenu [RFC] API: select items in popupmenu Jan 7, 2019
@marvim marvim added RFC and removed WIP labels Jan 7, 2019
src/nvim/edit.c Outdated
static bool pum_request_active = false;
static int pum_request_wanted_item = -1;
static bool pum_request_insert = false;
static bool pum_request_finish = false;
Copy link
Member

@justinmk justinmk Jan 7, 2019

Choose a reason for hiding this comment

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

Does pum "request" imply RPC, or just "want"?

It might help navigation/discoverability if the "pum request" states were a flags enum:

enum {
kPumReqActive = 0x001,
kPumReqInsert = 0x002,
kPumReqDone = 0x004,
} PumRegState

static PumReqState pum_request = ...;

Copy link
Member Author

@bfredl bfredl Jan 7, 2019

Choose a reason for hiding this comment

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

I guess want works. It is replacement for local variables for a function that cannot be written without either greatly restructuring the code, or perhaps refactor the compl data structures to something that can be easily manipulated without code duplication. Why erase the bool variables specifically?

Copy link
Member

Choose a reason for hiding this comment

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

Why erase the bool variables specifically?

It's easier (for a human) to "track" one variable than many. It adds some implicit documentation, that all of these states are related.

Copy link
Member Author

Choose a reason for hiding this comment

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

But wanted_item is precisely as related, it just happens to be of a different type. One could use a singleton struct struct { ... } pum_want; as a grouping I guess, and avoid unnecessary bit-twiddling.

src/nvim/edit.c Outdated
@@ -4342,6 +4364,16 @@ ins_compl_next (
return num_matches;
}

void pum_external_select_item(int item, bool insert, bool finish) {
Copy link
Member

Choose a reason for hiding this comment

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

pum_ext_select_item . We don't use "external" AFAICT. It's nice that "ext" means "extension" also, since "external" does not always make sense and we're more interested in extensibility.

N.B. I would propose renaming ui_is_external to ui_has, but waiting on the big PRs to merge first.

Copy link
Member Author

Choose a reason for hiding this comment

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

N.B. I would propose renaming ui_is_external to ui_has, but waiting on the big PRs to merge first.

Fine by me. Just do it if you want it to happen, otherwise it will never happen. There will be outlying "big PRs" for quite some time, and it is not so hard to rebase fixup.

/// @param finish If true, completion will be finished with this item, and the
/// popupmenu dissmissed. implies `insert`.
void nvim_select_popupmenu_item(Integer item, Boolean insert, Boolean finish,
Error *error)
Copy link
Member

Choose a reason for hiding this comment

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

should we bother to add a opts parameter for future extensions?

Copy link
Member Author

Choose a reason for hiding this comment

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

let's do that.

@bfredl bfredl merged commit 8510d5f into neovim:master Jan 9, 2019
@justinmk justinmk removed the RFC label Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants