Skip to content

Commit

Permalink
1.2.0 - default editor config for befunge files, guides now default t…
Browse files Browse the repository at this point in the history
…o on, bugfixes
  • Loading branch information
kagof committed Jan 23, 2018
1 parent 0088860 commit 3b4e918
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 31 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ All notable changes to the Befunge VS Code extension will be documented in this
The format of this changelog is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.2.0 - 2018-01-22

### Added

* default editor configurations for Befunge-93 and 98 files, including turning off indent guides, line highlight, trailing whitespace trimming, autoindent, and quick suggestions. See the "Contributions" tab in VS Code for details
* restriction on colors: previously accepted any string, now only accepts 6 digit hex colors. This prevents some bugs in rendering, especially in rendering horizontal guides
* extension now renders guides on a change in configuration

### Changed

* fixed bug where guide lines in the old color could still persist after a color change
* `"befunge.guides.enable"` renamed to `"befunge.guides.enabled"`
* `"befunge.guides.enabled"` now defaults to `true`

## 1.1.0 - 2018-01-21

### Added
Expand Down
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![Version](https://vsmarketplacebadge.apphb.com/version/kagof.befunge.svg)](https://marketplace.visualstudio.com/items?itemName=kagof.befunge)
[![Installs](https://vsmarketplacebadge.apphb.com/installs/kagof.befunge.svg)](https://marketplace.visualstudio.com/items?itemName=kagof.befunge)
[![Ratings](https://vsmarketplacebadge.apphb.com/rating/kagof.befunge.svg)](https://marketplace.visualstudio.com/items?itemName=kagof.befunge)
[![Build Status](https://img.shields.io/travis/kagof/VSCode-Befunge.svg)](https://travis-ci.org/kagof/VSCode-Befunge)
[![Known Vulnerabilities](https://snyk.io/test/github/kagof/vscode-befunge/badge.svg?targetFile=package.json)](https://snyk.io/test/github/kagof/vscode-befunge?targetFile=package.json)

## Features

Expand Down Expand Up @@ -34,9 +34,9 @@ Adds the following new configuration settings:

| Name | Default (Type) | Description |
|------|----------------|-------------|
|`"befunge.guides.enabled"`|`false` (boolean)|Enable the Befunge guides coming from arrow characters.|
|`"befunge.guides.color.dark"`|`"rgba(60, 60, 60, 0.75)"` (string)|The Befunge guide line color to use for a dark theme.|
|`"befunge.guides.color.light"`|`"rgba(220, 220, 220, 0.75)"` (string)|The Befunge guide line color to use for a light theme.|
|`"befunge.guides.enabled"`|`true` (boolean)|Enable the Befunge guides coming from arrow characters.|
|`"befunge.guides.color.dark"`|`"#3c3c3c"` (*#rrggbb* hex string)|The Befunge guide line color to use for a dark theme.|
|`"befunge.guides.color.light"`|`"#dcdcdc"` (*#rrggbb* hex string)|The Befunge guide line color to use for a light theme.|

To get the colors shown in the [screenshots](#screenshots), some changes to your User Settings are necessary:

Expand Down Expand Up @@ -170,10 +170,18 @@ Find an issue/bug? [Report it](https://github.com/kagof/VSCode-Befunge-syntax-hi

See also the [changelog](CHANGELOG.md).

### 1.0.0
### 1.2.0

* Initial release with support for Befunge-93 and Befunge-98
* Restrict colors to 6 digit hex colors as other formats can cause problems, especially with the horizontal lines
* Purge decorations of the old style when color configuration changes, as otherwise it would persist until editor is closed
* Renamed `"befunge.guides.enable"` configuration property to `"befunge.guides.enabled"` to match README and code
* Set some default editor configurations for Befunge-93 and 98 files, including turning off indent guides, line highlight, trailing whitespace trimming, autoindent, and quick suggestions
* Because indent guides are now disabled by default, `"befunge.guides.enabled"` now defaults to `true`

### 1.1.0

* Support for alignment guides for the directional characters
* Support for alignment guides for the directional characters

### 1.0.0

* Initial release with support for Befunge-93 and Befunge-98
52 changes: 43 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
"author": {
"name": "Karl Goffin"
},
"version": "1.1.0",
"version": "1.2.0",
"publisher": "kagof",
"icon": "assets/icon.png",
"galleryBanner": {
"color": "#1c232d",
"theme": "dark"
},
"license": "SEE LICENSE IN LICENSE.md",
"repository": {
"type": "git",
Expand Down Expand Up @@ -78,22 +82,52 @@
],
"configuration": {
"type": "object",
"title": "Befunge configuration",
"title": "Befunge Configuration",
"properties": {
"befunge.guides.enable": {
"befunge.guides.enabled": {
"type": "boolean",
"default": false,
"description": "Enable the Befunge guides coming from arrow characters. It is highly recommended that you set \"editor.renderIndentGuides\" to false if you enable this."
"default": true,
"description": "Enable the Befunge guides coming from arrow characters."
},
"befunge.guides.color.dark": {
"type": "string",
"default": "rgba(60, 60, 60, 0.75)",
"description": "The Befunge guide line color to use for a dark theme."
"format": "color-hex",
"pattern": "^#[0-9a-f]{6}$",
"default": "#3c3c3c",
"description": "The Befunge guide line color to use for a dark theme. Currently restricted to 6 digit hex as other values may cause issues."
},
"befunge.guides.color.light": {
"type": "string",
"default": "rgba(220, 220, 220, 0.75)",
"description": "The Befunge guide line color to use for a light theme."
"format": "color-hex",
"pattern": "^#[0-9a-f]{6}$",
"default": "#dcdcdc",
"description": "The Befunge guide line color to use for a light theme. Currently restricted to 6 digit hex as other values may cause issues."
}
}
},
"configurationDefaults": {
"[befunge]": {
"editor.renderIndentGuides": false,
"editor.renderLineHighlight": "none",
"files.trimTrailingWhitespace": false,
"editor.autoIndent": false,
"editor.acceptSuggestionOnEnter": "off",
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
}
},
"[befunge98]": {
"editor.renderIndentGuides": false,
"editor.renderLineHighlight": "none",
"files.trimTrailingWhitespace": false,
"editor.autoIndent": false,
"editor.acceptSuggestionOnEnter": "off",
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
}
}
}
Expand Down
48 changes: 33 additions & 15 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export function activate(context: vscode.ExtensionContext) {
}
},
null, context.subscriptions);
vscode.workspace.onDidChangeConfiguration(
(event) => {
if (editor && isBefungeDoc(editor)) {
renderer.render(editor);
}
},
null, context.subscriptions);
}

/**
Expand All @@ -40,8 +47,6 @@ function isBefungeDoc(editor: vscode.TextEditor): boolean {
*/
export class Renderer {

private enabled: boolean;

private verticalConfig: vscode.DecorationRenderOptions;
private horizontalConfig: vscode.DecorationRenderOptions;

Expand All @@ -50,21 +55,19 @@ export class Renderer {
private colorDark: string;
private colorLight: string;


// regex to find arrows
private regex = /[v<>^?]/g;

constructor() {
this.refresh();
this.loadDecorations(this.getConfig());
}

/**
* renders the guides, if guides are enabled.
* @param editor the current text editor
*/
render(editor: vscode.TextEditor): void {
this.refresh();
if (!this.enabled) {
if (!this.isEnabled()) {
return;
}
let vRanges: vscode.Range[] = [];
Expand All @@ -90,7 +93,7 @@ export class Renderer {
hRanges = hRanges.concat(this.execLeft(startPos, editor));
}
}

this.refresh(); // refreshes the color configuration
editor.setDecorations(this.verticalDecoration, vRanges);
editor.setDecorations(this.horizontalDecoration, hRanges);
}
Expand Down Expand Up @@ -198,23 +201,38 @@ export class Renderer {
}

/**
* Rereads the configuration.
* This allows the colors to stay updated, as well as whether to enable/disable guides.
* retrieves the current workspace configuration
*/
getConfig(): vscode.WorkspaceConfiguration {
return vscode.workspace.getConfiguration('befunge.guides');
}

/**
* Returns whether or not alignment guides are enabled in the workspace configuration.
*/
isEnabled(): boolean {
return this.getConfig().enabled;
}

/**
* Rereads the configuration, purging old decorations and reloading styles as needed.
*/
refresh(): void {
const cfg: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('befunge.guides');
this.enabled = cfg.enable;
const cfg: vscode.WorkspaceConfiguration = this.getConfig();
if (this.colorDark !== cfg.color.dark || this.colorLight !== cfg.color.light) {
this.colorDark = cfg.color.dark;
this.colorLight = cfg.color.light;
this.refreshDecorations();
this.verticalDecoration.dispose(); // erase all vertical decorations in old style
this.horizontalDecoration.dispose(); // erase all horizontal decorations in old style
this.loadDecorations(cfg);
}
}

/**
* Refreshes the decorations. To be called when a color configuration has been changed.
* @param config the configuration to load the decorations from
*/
refreshDecorations() {
loadDecorations(config: vscode.WorkspaceConfiguration): void {
this.colorDark = config.color.dark;
this.colorLight = config.color.light;
this.verticalConfig = {
dark: {
outlineWidth: '1px',
Expand Down

0 comments on commit 3b4e918

Please sign in to comment.