A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/a4400bf8cda8ace4c4aab67bc73a1820478f46f1 below:

connect to remote ui (only debug messages for now) · neovim/neovim@a4400bf · GitHub

File tree Expand file treeCollapse file tree 6 files changed

+109

-4

lines changed

Filter options

Expand file treeCollapse file tree 6 files changed

+109

-4

lines changed Original file line number Diff line number Diff line change

@@ -30,6 +30,7 @@

30 30

#include "nvim/api/vimscript.h"

31 31

#include "nvim/api/win_config.h"

32 32

#include "nvim/api/window.h"

33 +

#include "nvim/ui_client.h"

33 34 34 35

static Map(String, MsgpackRpcRequestHandler) methods = MAP_INIT;

35 36

@@ -38,6 +39,13 @@ static void msgpack_rpc_add_method_handler(String method, MsgpackRpcRequestHandl

38 39

map_put(String, MsgpackRpcRequestHandler)(&methods, method, handler);

39 40

}

40 41 42 +

void msgpack_rpc_add_redraw(void)

43 +

{

44 +

msgpack_rpc_add_method_handler(STATIC_CSTR_AS_STRING("redraw"),

45 +

(MsgpackRpcRequestHandler) { .fn = ui_client_handle_redraw,

46 +

.fast = true });

47 +

}

48 + 41 49

/// @param name API method name

42 50

/// @param name_len name size (includes terminating NUL)

43 51

MsgpackRpcRequestHandler msgpack_rpc_get_handler_for(const char *name, size_t name_len,

Original file line number Diff line number Diff line change

@@ -342,6 +342,9 @@ EXTERN sctx_T current_sctx INIT(= { 0 COMMA 0 COMMA 0 });

342 342

// ID of the current channel making a client API call

343 343

EXTERN uint64_t current_channel_id INIT(= 0);

344 344 345 +

// ID of the client channel. Used by ui client

346 +

EXTERN uint64_t ui_client_channel_id INIT(= 0);

347 + 345 348

EXTERN bool did_source_packages INIT(= false);

346 349 347 350

// Scope information for the code that indirectly triggered the current

Original file line number Diff line number Diff line change

@@ -29,6 +29,7 @@

29 29

#include "nvim/if_cscope.h"

30 30

#include "nvim/lua/executor.h"

31 31

#include "nvim/main.h"

32 +

#include "nvim/ui_client.h"

32 33

#include "nvim/vim.h"

33 34

#ifdef HAVE_LOCALE_H

34 35

# include <locale.h>

@@ -269,8 +270,7 @@ int main(int argc, char **argv)

269 270 270 271

server_init(params.listen_addr);

271 272

if (params.remote) {

272 -

remote_request(&params, params.remote,

273 -

params.server_addr, argc, argv);

273 +

remote_request(&params, params.remote, params.server_addr, argc, argv);

274 274

}

275 275 276 276

if (GARGCOUNT > 0) {

@@ -834,10 +834,20 @@ static void remote_request(mparm_T *params, int remote_args,

834 834

uint64_t chan = server_connect(server_addr, &connect_error);

835 835

Object rvobj = OBJECT_INIT;

836 836 837 -

int t_argc = remote_args;

837 +

if (strequal(argv[remote_args], "--remote-ui-test")) {

838 +

if (!chan) {

839 +

emsg(connect_error);

840 +

exit(1);

841 +

}

842 + 843 +

ui_client_init(chan);

844 +

ui_client_execute(chan);

845 +

abort(); // unreachable

846 +

}

847 + 838 848

Array args = ARRAY_DICT_INIT;

839 849

String arg_s;

840 -

for (; t_argc < argc; t_argc++) {

850 +

for (int t_argc = remote_args; t_argc < argc; t_argc++) {

841 851

arg_s = cstr_to_string(argv[t_argc]);

842 852

ADD(args, STRING_OBJ(arg_s));

843 853

}

Original file line number Diff line number Diff line change

@@ -547,6 +547,11 @@ void rpc_close(Channel *channel)

547 547

channel->rpc.closed = true;

548 548

channel_decref(channel);

549 549 550 +

if (channel->id == ui_client_channel_id) {

551 +

// TODO(bfredl): handle this in ui_client, where os_exit() is safe

552 +

exit(0);

553 +

}

554 + 550 555

if (channel->streamtype == kChannelStreamStdio) {

551 556

multiqueue_put(main_loop.fast_events, exit_event, 0);

552 557

}

Original file line number Diff line number Diff line change

@@ -0,0 +1,70 @@

1 +

// This is an open source non-commercial project. Dear PVS-Studio, please check

2 +

// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

3 + 4 +

#include <stdbool.h>

5 +

#include <stdint.h>

6 +

#include <assert.h>

7 + 8 +

#include "nvim/vim.h"

9 +

#include "nvim/ui_client.h"

10 +

#include "nvim/api/private/helpers.h"

11 +

#include "nvim/msgpack_rpc/channel.h"

12 +

#include "nvim/api/private/dispatch.h"

13 +

#include "nvim/ui.h"

14 + 15 +

void ui_client_init(uint64_t chan)

16 +

{

17 +

Array args = ARRAY_DICT_INIT;

18 +

int width = 80;

19 +

int height = 25;

20 +

Dictionary opts = ARRAY_DICT_INIT;

21 + 22 +

PUT(opts, "rgb", BOOLEAN_OBJ(true));

23 +

PUT(opts, "ext_linegrid", BOOLEAN_OBJ(true));

24 +

PUT(opts, "ext_termcolors", BOOLEAN_OBJ(true));

25 + 26 +

// TODO(bfredl): use the size of the client UI

27 +

ADD(args, INTEGER_OBJ((int)width));

28 +

ADD(args, INTEGER_OBJ((int)height));

29 +

ADD(args, DICTIONARY_OBJ(opts));

30 + 31 +

rpc_send_event(chan, "nvim_ui_attach", args);

32 +

msgpack_rpc_add_redraw(); // GAME!

33 +

ui_client_channel_id = chan;

34 +

}

35 + 36 +

/// Handler for "redraw" events sent by the NVIM server

37 +

///

38 +

/// This is just a stub. The mentioned functionality will be implemented.

39 +

///

40 +

/// This function will be called by handle_request (in msgpack_rpc/channle.c)

41 +

/// The individual ui_events sent by the server are individually handled

42 +

/// by their respective handlers defined in ui_events_redraw.generated.h

43 +

///

44 +

/// @note The "flush" event is called only once and only after handling all

45 +

/// the other events

46 +

/// @param channel_id: The id of the rpc channel

47 +

/// @param uidata: The dense array containing the ui_events sent by the server

48 +

/// @param[out] err Error details, if any

49 +

Object ui_client_handle_redraw(uint64_t channel_id, Array args, Error *error)

50 +

{

51 +

for (size_t i = 0; i < args.size; i++) {

52 +

Array call = args.items[i].data.array;

53 +

char *method_name = call.items[0].data.string.data;

54 + 55 +

fprintf(stderr, "%s: %zu\n", method_name, call.size-1);

56 +

}

57 +

return NIL;

58 +

}

59 + 60 +

/// run the main thread in ui client mode

61 +

///

62 +

/// This is just a stub. the full version will handle input, resizing, etc

63 +

void ui_client_execute(uint64_t chan)

64 +

{

65 +

while (true) {

66 +

loop_poll_events(&main_loop, -1);

67 +

}

68 + 69 +

getout(0);

70 +

}

Original file line number Diff line number Diff line change

@@ -0,0 +1,9 @@

1 +

#ifndef NVIM_UI_CLIENT_H

2 +

#define NVIM_UI_CLIENT_H

3 + 4 +

#include "nvim/api/private/defs.h"

5 + 6 +

#ifdef INCLUDE_GENERATED_DECLARATIONS

7 +

#include "ui_client.h.generated.h"

8 +

#endif

9 +

#endif // NVIM_UI_CLIENT_H

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4