viewContext.js 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. export class EditorTheme {
  6. constructor(theme) {
  7. this._theme = theme;
  8. }
  9. get type() {
  10. return this._theme.type;
  11. }
  12. update(theme) {
  13. this._theme = theme;
  14. }
  15. getColor(color) {
  16. return this._theme.getColor(color);
  17. }
  18. }
  19. export class ViewContext {
  20. constructor(configuration, theme, model) {
  21. this.configuration = configuration;
  22. this.theme = new EditorTheme(theme);
  23. this.model = model;
  24. this.viewLayout = model.viewLayout;
  25. }
  26. addEventHandler(eventHandler) {
  27. this.model.addViewEventHandler(eventHandler);
  28. }
  29. removeEventHandler(eventHandler) {
  30. this.model.removeViewEventHandler(eventHandler);
  31. }
  32. }