Theme Inspinia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.html 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <!doctype html>
  2. <title>CodeMirror: Kotlin 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="kotlin.js"></script>
  8. <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  9. <div id=nav>
  10. <a href="http://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="#">Kotlin</a>
  19. </ul>
  20. </div>
  21. <article>
  22. <h2>Kotlin mode</h2>
  23. <div><textarea id="code" name="code">
  24. package org.wasabi.http
  25. import java.util.concurrent.Executors
  26. import java.net.InetSocketAddress
  27. import org.wasabi.app.AppConfiguration
  28. import io.netty.bootstrap.ServerBootstrap
  29. import io.netty.channel.nio.NioEventLoopGroup
  30. import io.netty.channel.socket.nio.NioServerSocketChannel
  31. import org.wasabi.app.AppServer
  32. public class HttpServer(private val appServer: AppServer) {
  33. val bootstrap: ServerBootstrap
  34. val primaryGroup: NioEventLoopGroup
  35. val workerGroup: NioEventLoopGroup
  36. {
  37. // Define worker groups
  38. primaryGroup = NioEventLoopGroup()
  39. workerGroup = NioEventLoopGroup()
  40. // Initialize bootstrap of server
  41. bootstrap = ServerBootstrap()
  42. bootstrap.group(primaryGroup, workerGroup)
  43. bootstrap.channel(javaClass<NioServerSocketChannel>())
  44. bootstrap.childHandler(NettyPipelineInitializer(appServer))
  45. }
  46. public fun start(wait: Boolean = true) {
  47. val channel = bootstrap.bind(appServer.configuration.port)?.sync()?.channel()
  48. if (wait) {
  49. channel?.closeFuture()?.sync()
  50. }
  51. }
  52. public fun stop() {
  53. // Shutdown all event loops
  54. primaryGroup.shutdownGracefully()
  55. workerGroup.shutdownGracefully()
  56. // Wait till all threads are terminated
  57. primaryGroup.terminationFuture().sync()
  58. workerGroup.terminationFuture().sync()
  59. }
  60. }
  61. </textarea></div>
  62. <script>
  63. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  64. mode: {name: "kotlin"},
  65. lineNumbers: true,
  66. indentUnit: 4
  67. });
  68. </script>
  69. <h3>Mode for Kotlin (http://kotlin.jetbrains.org/)</h3>
  70. <p>Developed by Hadi Hariri (https://github.com/hhariri).</p>
  71. <p><strong>MIME type defined:</strong> <code>text/x-kotlin</code>.</p>
  72. </article>