Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"contributors": [
{
"login": "GitMensch",
"name": "Simon Sobisch",
"avatar_url": "https://avatars3.githubusercontent.com/u/6699539?v=4",
"profile": "https://github.com/GitMensch",
"contributions": [
"projectManagement"
]
}
],
"contributorsPerLine": 7,
"projectName": "vscode-overtype",
"projectOwner": "DrMerfy",
"repoType": "github",
"repoHost": "https://github.com",
"skipCi": true
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ Icon
# Project
node_modules
out
*.vsix
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**/*
!images/demo-basic.gif
!images/demo-basic@2x.gif
!images/icon.svg
!images/icon.png
!out/**/*
!CHANGELOG.md
!LICENSE
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

Notable and interesting changes will go in this file whenever a new release goes out. Boring changes will probably go in here too. Really, all changes are welcome.

## TO BE ANNOUNCED

- New configuration `overtype.showInStatusBar`, to allow hiding the current state in the status bar [#4](https://github.com/DrMerfy/vscode-overtype/issues/4).
- The item in the status bar can now be clicked to toggle the insert mode [#3](https://github.com/DrMerfy/vscode-overtype/issues/3).

## 0.3.1

- open-vsx ready, now also found at https://open-vsx.org/extension/DrMerfy/overtype

## 0.3.0

- Continuation fork of the project.
- New configuration `overtype.secondaryCursorStyle`, to change the overtype cursor style.

## 0.2.0

- Fixed an issue where the status indicator/cursor wouldn't be correct when Visual Studio Code opens a window with editors already open.
Expand Down
80 changes: 66 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Overtype for Visual Studio Code

[![Visual Studio Marketplace](http://vsmarketplacebadge.apphb.com/version/adammaras.overtype.svg)](https://marketplace.visualstudio.com/items?itemName=adammaras.overtype)
[![GitHub release](https://img.shields.io/github/release/AdamMaras/vscode-overtype.svg)](https://github.com/AdamMaras/vscode-overtype/releases)
[![GitHub issues](https://img.shields.io/github/issues/AdamMaras/vscode-overtype.svg)](https://github.com/AdamMaras/vscode-overtype/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/AdamMaras/vscode-overtype.svg)](https://github.com/AdamMaras/vscode-overtype/pulls)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![Open VSX Registry](https://img.shields.io/open-vsx/v/drmerfy/overtype)](https://open-vsx.org/extension/DrMerfy/overtype)
[![Visual Studio Marketplace](https://vsmarketplacebadge.apphb.com/version/DrMerfy.overtype.svg)](https://marketplace.visualstudio.com/items?itemName=DrMerfy.overtype)
[![GitHub release](https://img.shields.io/github/release/DrMerfy/vscode-overtype/all.svg)](https://github.com/DrMerfy/vscode-overtype/releases)
[![GitHub issues](https://img.shields.io/github/issues/DrMerfy/vscode-overtype.svg)](https://github.com/DrMerfy/vscode-overtype/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/DrMerfy/vscode-overtype.svg)](https://github.com/DrMerfy/vscode-overtype/pulls)
![README badges](https://img.shields.io/badge/readme_badges-5-green.svg)

Because some people actually press the Insert key on purpose.

## This is the continuation fork of the project :)
## Original author: [Adam Maras](https://github.com/AdamMaras)

## Features

Adds an overtype mode to Visual Studio Code, plus a couple of bells and whistles.
Expand Down Expand Up @@ -37,15 +44,15 @@ Fine.
If you want to enable Hard Mode, you can turn on overtype paste mode. This setting applies overtype behavior to when you paste text into your editor. Here are the rules:

- If you paste part of a line of text into another line of text, the clipboard contents will overwrite characters until it's done pasting, unless it hits the end of the line first, in which case it'll just extend that line.
- If you already have some text selected when you paste, that text will *always* be overwritten, even if the contents of the clipboard are smaller.
- If you already have some text selected when you paste, that text will *always* be overwritten, even if the contents of the clipboard are smaller.
- If you paste some multiline text into a line of text, everything left on that line will be overwritten with the first line of the pasted text, and the remaining pasted lines will be inserted below that line.
- If you cut or copy using Visual Studio Code's feature that grabs the entire line when you don't have anything selected, pasting that line will overwrite the *entire* line that you're pasting on.

Some additional tips for using overtype paste:

- Don't forget your Undo shortcut(s).
- I know this doesn't work like [insert editor here]. Every single freaking editor handles overtype paste differently. It's not my fault.
- If you think you have a saner way to handle this, for the love of everything warm and cuddly, [MAKE A PULL REQUEST](https://github.com/AdamMaras/vscode-overtype/pulls).
- If you think you have a saner way to handle this, for the love of everything warm and cuddly, [MAKE A PULL REQUEST](https://github.com/DrMerfy/vscode-overtype/pulls).

Without further ado...

Expand All @@ -55,28 +62,73 @@ Without further ado...

> When in overtype mode, uses overtype behavior when pasting text.

### Abbreviated indicators
### Abbreviated indicators (or none)

Horizontal screen space at a premium? Have too many things in your status bar already? Turned your monitor sideways because somebody told you it would increase your productivity by at least 23%? Don't worry, we've got just the setting for you!

```json
"overtype.abbreviatedStatus": true
```

> Shows an abbreviated overtype status (`INS`/`OVR`) in the status line.
> Shows an abbreviated overtype status (`INS`/`OVR`) in the status bar.

```json
"overtype.showInStatusBar": false
```

> Disable showing the overtype status in the status bar.

### Overtype cursor style

You can change the overtype cursor style from the preferences.
Set the `overtype.secondaryCursorStyle` to either one of:

- line
- line-thin
- block
- block-outline
- underline
- underline-thin

e.g.

```json
"overtype.secondaryCursorStyle": "underline"
```

> Sets the overtype cursor style.

## Contributing

How can you contribute?

- [**Open an issue**](https://github.com/AdamMaras/vscode-overtype/issues) if you found a problem.
- [**Make a pull request**](https://github.com/AdamMaras/vscode-overtype/pulls) if you fixed a problem!
- [**Complain on Twitter**](https://twitter.com/AdamMaras) if *I'm* the problem.
- [**Open an issue**](https://github.com/DrMerfy/vscode-overtype/issues) if you found a problem.
- [**Make a pull request**](https://github.com/DrMerfy/vscode-overtype/pulls) if you fixed a problem!

## Release notes

There's a [`CHANGELOG.md`](https://github.com/AdamMaras/vscode-overtype/blob/master/CHANGELOG.md) file.
There's a [`CHANGELOG.md`](https://github.com/DrMerfy/vscode-overtype/blob/master/CHANGELOG.md) file.

## License

There's a [`LICENSE`](https://github.com/AdamMaras/vscode-overtype/blob/master/LICENSE) file. It's the [BSD 2-Clause](https://opensource.org/licenses/BSD-2-Clause) license.
There's a [`LICENSE`](https://github.com/DrMerfy/vscode-overtype/blob/master/LICENSE) file. It's the [BSD 2-Clause](https://opensource.org/licenses/BSD-2-Clause) license.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://github.com/GitMensch"><img src="https://avatars3.githubusercontent.com/u/6699539?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Simon Sobisch</b></sub></a><br /><a href="#projectManagement-GitMensch" title="Project Management">📆</a></td>
</tr>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Binary file added images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 18 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "overtype",
"version": "0.2.0",
"version": "0.3.1",
"displayName": "Overtype",
"description": "Provides insert/overtype mode.",
"publisher": "adammaras",
"publisher": "DrMerfy",
"categories": [
"Other"
],
Expand All @@ -12,21 +12,21 @@
"overwrite",
"insert"
],
"icon": "images/icon.svg",
"icon": "images/icon.png",
"galleryBanner": {
"color": "#1e1e1e",
"theme": "dark"
},
"license": "BSD-2-Clause",
"homepage": "https://github.com/AdamMaras/vscode-overtype",
"bugs": "https://github.com/AdamMaras/vscode-overtype/issues",
"homepage": "https://github.com/DrMerfy/vscode-overtype",
"bugs": "https://github.com/DrMerfy/vscode-overtype/issues",
"repository": {
"type": "git",
"url": "https://github.com/AdamMaras/vscode-overtype.git"
"url": "https://github.com/DrMerfy/vscode-overtype"
},
"main": "./out/extension",
"engines": {
"vscode": "^1.0.0"
"vscode": "^1.10.0"
},
"activationEvents": [
"*"
Expand All @@ -39,7 +39,7 @@
"overtype.abbreviatedStatus": {
"type": "boolean",
"default": false,
"description": "Shows an abbreviated overtype status (INS/OVR) in the status line."
"description": "Shows an abbreviated overtype status (INS/OVR) in the status bar."
},
"overtype.paste": {
"type": "boolean",
Expand All @@ -50,6 +50,16 @@
"type": "boolean",
"default": false,
"description": "Sets the insert/overtype mode per editor."
},
"overtype.secondaryCursorStyle": {
"type": "string",
"default": "block",
"description": "Sets the overtype cursor style."
},
"overtype.showInStatusBar": {
"type": "boolean",
"default": true,
"description": "Shows the current overtype mode in the status bar."
}
}
},
Expand Down
37 changes: 28 additions & 9 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,38 @@ import * as vscode from "vscode";

export const configuration = loadConfiguration();

function stringToCursorStyle(config: vscode.WorkspaceConfiguration, style: string, def: vscode.TextEditorCursorStyle) {
switch (config.get<string>(style)) {
case "line": return vscode.TextEditorCursorStyle.Line;
case "line-thin": return vscode.TextEditorCursorStyle.LineThin;
case "block": return vscode.TextEditorCursorStyle.Block;
case "block-outline": return vscode.TextEditorCursorStyle.BlockOutline;
case "underline": return vscode.TextEditorCursorStyle.Underline;
case "underline-thin": return vscode.TextEditorCursorStyle.UnderlineThin;
default: return def;
}
}

function loadConfiguration() {
const overtypeConfiguration = vscode.workspace.getConfiguration("overtype");
const editorConfiguration = vscode.workspace.getConfiguration("editor");

return {
abbreviatedStatus: overtypeConfiguration.get<boolean>("abbreviatedStatus"),
showInStatusBar: overtypeConfiguration.get<boolean>("showInStatusBar"),
paste: overtypeConfiguration.get<boolean>("paste"),
perEditor: overtypeConfiguration.get<boolean>("perEditor"),
perEditor: overtypeConfiguration.get<boolean>("perEditor") ? true : false,

// tslint:disable-next-line:object-literal-sort-keys
defaultCursorStyle: (() => {
switch (editorConfiguration.get<string>("cursorStyle")) {
case "line": return vscode.TextEditorCursorStyle.Line;
case "block": return vscode.TextEditorCursorStyle.Block;
case "underline": return vscode.TextEditorCursorStyle.Underline;
default: return vscode.TextEditorCursorStyle.Line;
}
return stringToCursorStyle(editorConfiguration, "cursorStyle",
vscode.TextEditorCursorStyle.Block);
})(),

// Get the user defined cursor style for overtype mode
secondaryCursorStyle: (() => {
return stringToCursorStyle(overtypeConfiguration, "secondaryCursorStyle",
vscode.TextEditorCursorStyle.Line);
})(),
};
}
Expand All @@ -27,17 +42,21 @@ export function reloadConfiguration() {
const newConfiguration = loadConfiguration();

// bail out if nothing changed
if (configuration.abbreviatedStatus === newConfiguration.abbreviatedStatus &&
if (configuration.showInStatusBar === newConfiguration.showInStatusBar &&
configuration.abbreviatedStatus === newConfiguration.abbreviatedStatus &&
configuration.paste === newConfiguration.paste &&
configuration.perEditor === newConfiguration.perEditor &&
configuration.defaultCursorStyle === newConfiguration.defaultCursorStyle) {
configuration.defaultCursorStyle === newConfiguration.defaultCursorStyle &&
configuration.secondaryCursorStyle === newConfiguration.secondaryCursorStyle) {
return false;
}

configuration.showInStatusBar = newConfiguration.showInStatusBar;
configuration.abbreviatedStatus = newConfiguration.abbreviatedStatus;
configuration.paste = newConfiguration.paste;
configuration.perEditor = newConfiguration.perEditor;
configuration.defaultCursorStyle = newConfiguration.defaultCursorStyle;
configuration.secondaryCursorStyle = newConfiguration.secondaryCursorStyle;

return true;
}
31 changes: 22 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function activeTextEditorChanged(textEditor?: vscode.TextEditor) {
const mode = getMode(textEditor);
updateStatusBarItem(mode);

// if in overtype mode, set the cursor to block style; otherwise, reset to default
// if in overtype mode, set the cursor to secondary style; otherwise, reset to default
textEditor.options.cursorStyle = mode
? vscode.TextEditorCursorStyle.Block
? configuration.secondaryCursorStyle
: configuration.defaultCursorStyle;
}
}
Expand All @@ -61,20 +61,29 @@ function toggleCommand() {

function onDidChangeConfiguration() {
const previousPerEditor = configuration.perEditor;
const previousShowInStatusBar = configuration.showInStatusBar;

const updated = reloadConfiguration();
if (!updated) { return; }

// post create / destroy when changed
if (configuration.showInStatusBar !== previousShowInStatusBar) {
if (configuration.showInStatusBar) {
createStatusBarItem();
} else {
destroyStatusBarItem();
}
}

// update state if the per-editor/global configuration option changes
if (updated && configuration.perEditor !== previousPerEditor) {
if (configuration.perEditor !== previousPerEditor) {

const textEditor = vscode.window.activeTextEditor;
const mode = textEditor != null ? getMode(textEditor) : null;

resetModes(mode, configuration.perEditor);
}

if (updated) {
activeTextEditorChanged();
}
activeTextEditorChanged();
}

function shouldPerformOvertype() {
Expand All @@ -89,7 +98,9 @@ function shouldPerformOvertype() {
function typeCommand(args: { text: string }) {
if (shouldPerformOvertype()) {
const editor = vscode.window.activeTextEditor;
overtypeBeforeType(editor, args.text);
if (editor) {
overtypeBeforeType(editor, args.text);
}
}

return vscode.commands.executeCommand("default:type", args);
Expand All @@ -98,7 +109,9 @@ function typeCommand(args: { text: string }) {
function pasteCommand(args: { text: string, pasteOnNewLine: boolean }) {
if (configuration.paste && shouldPerformOvertype()) {
const editor = vscode.window.activeTextEditor;
overtypeBeforePaste(editor, args.text, args.pasteOnNewLine);
if (editor) {
overtypeBeforePaste(editor, args.text, args.pasteOnNewLine);
}
}

return vscode.commands.executeCommand("default:paste", args);
Expand Down
1 change: 1 addition & 0 deletions src/statusBarItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export function createStatusBarItem() {
if (statusBarItem != null) { return statusBarItem; }

statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
statusBarItem.command = "overtype.toggle";
statusBarItem.show();

updateStatusBarItem(null);
Expand Down
Loading