index.html 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!doctype html>
  2. <title>CodeMirror: ProtoBuf mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="protobuf.js"></script>
  8. <style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
  9. <div id=nav>
  10. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  11. <ul>
  12. <li><a href="../../index.html">Home</a>
  13. <li><a href="../../doc/manual.html">Manual</a>
  14. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  15. </ul>
  16. <ul>
  17. <li><a href="../index.html">Language modes</a>
  18. <li><a class=active href="#">ProtoBuf</a>
  19. </ul>
  20. </div>
  21. <article>
  22. <h2>ProtoBuf mode</h2>
  23. <form><textarea id="code" name="code">
  24. package addressbook;
  25. message Address {
  26. required string street = 1;
  27. required string postCode = 2;
  28. }
  29. message PhoneNumber {
  30. required string number = 1;
  31. }
  32. message Person {
  33. optional int32 id = 1;
  34. required string name = 2;
  35. required string surname = 3;
  36. optional Address address = 4;
  37. repeated PhoneNumber phoneNumbers = 5;
  38. optional uint32 age = 6;
  39. repeated uint32 favouriteNumbers = 7;
  40. optional string license = 8;
  41. enum Gender {
  42. MALE = 0;
  43. FEMALE = 1;
  44. }
  45. optional Gender gender = 9;
  46. optional fixed64 lastUpdate = 10;
  47. required bool deleted = 11 [default = false];
  48. }
  49. </textarea>
  50. <textarea id="code2" name="code2">
  51. syntax = "proto3";
  52. package tutorial;
  53. import "google/protobuf/timestamp.proto";
  54. option java_package = "com.example.tutorial";
  55. option java_outer_classname = "AddressBookProtos";
  56. option csharp_namespace = "Google.Protobuf.Examples.AddressBook";
  57. message Person {
  58. string name = 1;
  59. int32 id = 2; // Unique ID number for this person.
  60. string email = 3;
  61. enum PhoneType {
  62. MOBILE = 0;
  63. HOME = 1;
  64. WORK = 2;
  65. }
  66. message PhoneNumber {
  67. string number = 1;
  68. PhoneType type = 2;
  69. }
  70. repeated PhoneNumber phones = 4;
  71. google.protobuf.Timestamp last_updated = 5;
  72. }
  73. // Our address book file is just one of these.
  74. message AddressBook {
  75. repeated Person people = 1;
  76. }
  77. service Test {
  78. rpc SayHello (HelloRequest) returns (HelloReply) {}
  79. rpc SayHelloAgain (HelloRequest) returns (HelloReply) {}
  80. }</textarea>
  81. </form>
  82. <script>
  83. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
  84. var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {});
  85. </script>
  86. <p><strong>MIME types defined:</strong> <code>text/x-protobuf</code>.</p>
  87. </article>