Codebase list mozc / 1ec0ee0 session / commands.proto
1ec0ee0

Tree @1ec0ee0 (Download .tar.gz)

commands.proto @1ec0ee0raw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
// Copyright 2010, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Protocol messages to be used for mozc client/server communication
// and client/renderer communication.
//
// The Command message contains all the input/output values for
// client/server commnication.  The messages structure of Command and
// its child messages are here:

syntax = "proto2";

import "session/config.proto";

package mozc.commands;

// This enum is used by SessionCommand::input_mode with
// CHANGE_INPUT_MODE and Output::mode.
enum CompositionMode {
  DIRECT = 0;
  HIRAGANA = 1;
  FULL_KATAKANA = 2;
  HALF_ASCII = 3;
  FULL_ASCII = 4;
  HALF_KATAKANA = 5;
  NUM_OF_COMPOSITIONS = 6;
}

message KeyEvent {
  enum SpecialKey {
    NO_SPECIALKEY = 0;
    DIGIT = 1;
    ON = 2;
    OFF = 3;
    SPACE = 4;
    ENTER = 5;
    LEFT = 6;
    RIGHT = 7;
    UP = 8;
    DOWN = 9;
    ESCAPE = 10;
    DEL = 11;    // not DELETE because DELETE is reserved in MSVC
    BACKSPACE = 12;
    HENKAN = 13;
    MUHENKAN = 14;
    KANA = 15;  // VK_DBE_HIRAGANA(Win), kVK_JIS_Kana(Mac)
    HOME = 16;
    END = 17;
    TAB = 18;
    F1 = 19;
    F2 = 20;
    F3 = 21;
    F4 = 22;
    F5 = 23;
    F6 = 24;
    F7 = 25;
    F8 = 26;
    F9 = 27;
    F10 = 28;
    F11 = 29;
    F12 = 30;
    PAGE_UP = 31;
    PAGE_DOWN = 32;
    INSERT = 33;
    F13 = 34;
    F14 = 35;
    F15 = 36;
    F16 = 37;
    F17 = 38;
    F18 = 39;
    F19 = 40;
    F20 = 41;
    F21 = 42;
    F22 = 43;
    F23 = 44;
    F24 = 45;
    EISU = 46;  // alphanumeric  VK_DBE_ALPHANUMERIC(Win), kVK_JIS_Eisu(Mac)
    NUMPAD0 = 47;
    NUMPAD1 = 48;
    NUMPAD2 = 49;
    NUMPAD3 = 50;
    NUMPAD4 = 51;
    NUMPAD5 = 52;
    NUMPAD6 = 53;
    NUMPAD7 = 54;
    NUMPAD8 = 55;
    NUMPAD9 = 56;
    MULTIPLY = 57;  // Numpad [*]
    ADD = 58;  // Numpad [+]
    SEPARATOR = 59;  // Numpad [enter]
    SUBTRACT = 60;  // Numpad [-]
    DECIMAL = 61;  // Numpad [.]
    DIVIDE = 62;  // Numpad [/]
    EQUALS = 63;  // Numpad [=]
    ASCII = 64;
    HANKAKU = 65;
    KANJI = 66;
    NUM_SPECIALKEYS = 67;
  };
  enum ModifierKey {
    CTRL = 1;
    ALT = 2;
    SHIFT = 4;
    KEY_DOWN = 8;
    KEY_UP = 16;
  };

  optional uint32 key_code = 1;  // Printable key in ASCII.
  optional uint32 modifiers = 2;  // Going to be obsolete.
  optional SpecialKey special_key = 3;  // Unprintable key listed above.
  repeated ModifierKey modifier_keys = 4;  // ModifierKeys

  // String used for preedit.  Kana characters and strings typed from
  // a software keyboard are supposed to be stored here.  To set kana
  // value, key_code=1 should be stored an ascii character for the
  // kana key.
  optional string key_string = 5;

  enum InputStyle {
    // Follow the current input mode (default).
    FOLLOW_MODE = 0;
    // Do not transliterate key_string and use it as-is.
    AS_IS = 1;
    // Immediately output key_string on the precomposition mode.
    // Same with AS_IS on the preedit mode.
    DIRECT_INPUT = 2;
  };
  optional InputStyle input_style = 6 [default = FOLLOW_MODE];

  // Input mode
  optional CompositionMode mode = 7;
};

message SessionCommand {
  enum CommandType {
    // Revert the session, this is usually similar to type ESC several times.
    REVERT = 1;
    // Commit the session, this is usually similar to type Enter.
    SUBMIT = 2;
    // Select the specified candidate word by id.  This command is
    // usually used with mouse clicking.
    SELECT_CANDIDATE = 3;

    // Set the focus to the candidate by id.  This is usually used
    // with mouse dragging.  The difference from SELECT_CANDIDATE is
    // that HIGHLIGHT_CANDIDATE does not close the candidate window
    // while SELECT_CANDIDATE closes the candidate window.
    HIGHLIGHT_CANDIDATE = 4;

    // Specify the input mode.  This command should be used with
    // composition_mode.
    SWITCH_INPUT_MODE = 5;

    // Return the current status such as composition mode, preedit method, etc.
    GET_STATUS = 6;
  };
  required CommandType type = 1;

  // Unique number specifying a candidate word.
  optional int32 id = 2;

  // This is used with SWITCH_INPUT_MODE.
  optional CompositionMode composition_mode = 3;
};

message Input {
  enum CommandType {
    NONE = 0;
    CREATE_SESSION = 1;
    DELETE_SESSION = 2;
    SEND_KEY = 3;

    // Check only if the key event will be consumed.  This command is
    // for TSF on Windows.  You do not need to use this command, if it
    // is not necessary.
    TEST_SEND_KEY = 4;

    // Evaluate the command specified by SessionCommand.  The output
    // format should be the same with an output of a SEND_KEY command.
    SEND_COMMAND = 5;

    // Set & Config
    GET_CONFIG = 6;
    SET_CONFIG = 7;

    // sync dictionary/history data to local file
    SYNC_DATA = 8;

    // shutdowon server safely
    SHUTDOWN = 9;

    // reload mutable data (like config, user-dic, history)
    RELOAD = 10;

    // clear user history data
    CLEAR_USER_HISTORY = 11;

    // clear user prediction data
    CLEAR_USER_PREDICTION = 12;

    // clear unused prediction
    CLEAR_UNUSED_USER_PREDICTION = 16;

    // clean up sessions
    // shutdwon if session is empty and
    // mozc_server is launched with timeout mode
    CLEANUP = 13;

    // no operation
    // can be used for pinging the server
    NO_OPERATION = 14;
  };
  required CommandType type = 1;

  // Session ID created by CREATE_SESSION.
  optional uint64 id = 2;

  // Key combinations used for SEND_KEY or TEST_SEND_KEY.
  optional KeyEvent key = 3;

  // Command sent to the session layer used with SEND_COMMAND.
  optional SessionCommand command = 4;

  // Input config
  optional mozc.config.Config config = 5;
};


// Result contains data to be submitted to the host application by the
// ime client.
message Result {
  enum ResultType {
    NONE = 0;
    STRING = 1;
  };
  required ResultType type = 1;
  // The result of conversion.
  required string value = 2;

  // Source of the value.  It is almost always the reading of the value.
  optional string key = 3;
};


// Preedit represents a composition data, which is rendered on the
// host application by the ime client.  On Japanese IME, the both
// Preedit and Conversion statuses are represented by this message.
message Preedit {
  required uint32 cursor = 1;
  // The string data of Preedit is separated into Segment messages
  // presenting the ime server's status.  On Preedit status of
  // Japanese IME, there are up to three segments; left side chars of
  // cursor, forcused char, right side chars of cursor.  On Conversion
  // status of Japanese IME, the messages literally represent the
  // segments of the conversion.
  repeated group Segment = 2 {
    enum Annotation {
      NONE = 0;
      UNDERLINE = 1;
      HIGHLIGHT = 2;
    };
    required Annotation annotation = 3;
    required string value = 4;

    // The length of value in characters.  This is NOT a number in
    // bytes or logical character units.  So, the length of "abc" and
    // "あいう" should be 3, "ヴ" should be 1 and "ヴ" and "う゛"
    // should be 2.
    required uint32 value_length = 5;

    // Source of the value.  It is almost always the reading of the value.
    optional string key = 6;
  };

  // The position of the first segment whose annotation is 'HIGHLIGHT'. Not set
  // if there are no such segments.
  optional uint32 highlighted_position = 3;
};

// Annotation against a candidate.
message Annotation {
  // Annotation prepended to the value.
  optional string prefix = 1;
  // Annotation appended to the value.
  optional string suffix = 2;
  // Type of the candidate such as [HALF][KATAKANA], [GREEK],
  // [Black square], etc...
  optional string description = 3;
  // Shortcut key to select this candidate.
  optional string shortcut = 4;
};

// Additional information to a candidate word.  This message is
// used for describing a word usage for instance.
message Information {
  // Unique number specifing the candidate.  This id and Candidate::id
  // must be numbered for the same candidate.
  optional int32 id = 1;

  // Title string of the information.  For usage, this value is
  // probably equal to Candidate::value or its canonicalized value.
  optional string title = 2;

  // The content of the information.  For usage, this value actually
  // describes how to use the word.
  optional string description = 3;
};

// Category describes the attribute of the words.
enum Category {
  CONVERSION = 0;
  PREDICTION = 1;
  SUGGESTION = 2;
  TRANSLITERATION = 3;
  USAGE = 4;
};

// DisplayType is a hint to UI renderers describing how the words are
// displayed.
enum DisplayType {
  MAIN = 0;
  CASCADE = 1;
};

message InformationList {
  optional uint32 focused_index = 1;
  repeated Information information = 2;
  // Category of the infolist.
  optional Category category = 3 [default = CONVERSION];

  // Information to be used for rendering.
  optional DisplayType display_type = 4 [default = CASCADE];
};

// Message representing the footer part of the candidate window.
message Footer {
  // Message shown like a status bar.
  optional string label = 1;
  // Whether index (e.g. 10/120) is visible or not.
  optional bool index_visible = 2 [default = false];
  // Whether the logo image is visible or not.
  optional bool logo_visible = 3 [default = false];
  // Message modestly shown.  It is used for displaying the version on
  // dev-channel now.
  optional string sub_label = 4;
};

message Candidates {
  // When has_focused_index() is true, this message contains predicted and
  // normally converted candidates. Otherwise, when the field is not set,
  // this message contains a 'suggestion'.
  optional uint32 focused_index = 1;

  required uint32 size = 2;
  repeated group Candidate = 3 {
    // The first index should be zero and index numbers should increase by one.
    required uint32 index = 4;
    required string value = 5;
    optional int32 id = 9;  // Unique number specifing the candidate.
    optional Annotation annotation = 7;
  };
  // The position on the preedit.  The number represents the left edge
  // of the candidate window.
  required uint32 position = 6;

  // Nested candidates aka cascading window.
  optional Candidates subcandidates = 8;

  // Usages of candidates.
  optional InformationList usages = 10;

  // Category of the candidates
  optional Category category = 11 [default = CONVERSION];

  // Information to be used for rendering.
  optional DisplayType display_type = 12 [default = MAIN];

  // Footer of the GUI window.
  optional Footer footer = 13;

};

message Output {
  optional uint64 id = 1;
  optional CompositionMode mode = 2;
  optional bool consumed = 3;
  optional Result result = 4;
  optional Preedit preedit = 5;
  optional Candidates candidates = 6;
  optional KeyEvent key = 7;

  // when URL is non empty, UI can open the page with a browser,
  // after finishing the all rendering part.
  // We are using this feature for bug-report system.
  optional string url = 8;

  // Output config
  optional mozc.config.Config config = 9;

  // PreeditMethod: this is the default input mode of the session.
  // If the user's config is "kana-input", it returns KANA.  Only
  // CreateSession response will have this field.
  enum PreeditMethod {
    ASCII = 0;
    KANA = 1;
  };
  optional PreeditMethod preedit_method = 10 [default = ASCII];

  // ErrorCode:
  // if SessionHandler::EvalCommand() returns false,
  // return output with error_code = SESSION_FAILURE;
  enum ErrorCode {
    SESSION_SUCCESS = 0;
    SESSION_FAILURE = 1;
  };
  optional ErrorCode error_code = 11 [ default = SESSION_SUCCESS ];

  // number of microseconds that have elapsed for processing the request.
  optional uint32 elapsed_time = 12 [ default = 0 ];
};

message Command {
  required Input input = 1;
  required Output output = 2;
};

message RendererCommand {
  enum CommandType {
    NOOP = 0;      // No operation
    UPDATE = 1;    // Update the current window
    SHUTDOWN = 2;  // shutdown renderer
  };

  optional CommandType type = 1 [ default = NOOP ];

  // set visibility
  // if visible is false, the content of output
  // is basically ignored.
  optional bool visible = 2 [ default = false ];

  optional Output output = 3;

  // Preedit rectangle
  message Rectangle {
    optional int32 left   = 1;
    optional int32 top    = 2;
    optional int32 right  = 3;
    optional int32 bottom = 4;
  };

  optional Rectangle preedit_rectangle = 4;

  // Application information Mozc UI is attaching
  message ApplicationInfo {
    optional uint32 process_id = 1;
    optional uint32 thread_id = 2;
    // used in Windows:
    // WHND of the message-only window:
    optional uint32 receiver_handle = 3;
  };

  optional ApplicationInfo application_info = 5;
};