Skip to content

Commit 8fcf15c

Browse files
committed
Merge pull request atom#19 from atom/iz-update-ascii-art-docs
Update guide for ascii-art package
2 parents 3b8862e + e0036b9 commit 8fcf15c

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

book/03-hacking-atom/sections/03-modify-buffer.asc

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
Now that we have our first package written, let's go through examples of other types of packages we can make. This section will guide you though creating a simple command that replaces the selected text with https://en.wikipedia.org/wiki/ASCII_art[ascii art]. When you run our new command with the word "cool" selected, it will be replaced with:
44

55
```
6-
___
7-
/\_ \
8-
___ ___ ___\//\ \
9-
/'___\ / __`\ / __`\\ \ \
10-
/\ \__//\ \L\ \/\ \L\ \\_\ \_
11-
\ \____\ \____/\ \____//\____\
12-
\/____/\/___/ \/___/ \/____/
6+
o888
7+
ooooooo ooooooo ooooooo 888
8+
888 888 888 888 888 888 888
9+
888 888 888 888 888 888
10+
88ooo888 88ooo88 88ooo88 o888o
11+
1312
```
1413

1514
This should demonstrate how to do basic text manipulation in the current text buffer and how to deal with selections.
@@ -20,23 +19,22 @@ The final package can be viewed at https://github.com/atom/ascii-art.
2019

2120
To begin, press `cmd-shift-P` to bring up the https://github.com/atom/command-palette[Command
2221
Palette]. Type "generate package" and
23-
select the "Package Generator: Generate Package" command, just as we did in <<_generate_package>>.
22+
select the "Package Generator: Generate Package" command, just as we did in <<_generate_package>>. Enter `ascii-art` as the name of the package.
2423

25-
Now let's edit the package files to make our ASCII Art package do something interesting. Since this package doesn't need any UI, we can remove all view-related code so go ahead and delete `ascii-art-view.coffee`.
24+
Now let's edit the package files to make our ASCII Art package do something interesting. Since this package doesn't need any UI, we can remove all view-related code so go ahead and delete `lib/ascii-art-view.coffee`, `spec/ascii-art-view-spec.coffee`, and `styles/`.
2625

2726
Next, open up `lib/ascii-art.coffee` and remove all view code, so it looks like this:
2827

2928
```coffeescript
3029
{CompositeDisposable} = require 'atom'
3130

32-
module.exports = AsciiArt =
31+
module.exports =
3332
subscriptions: null
3433

3534
activate: ->
3635
@subscriptions = new CompositeDisposable
37-
@subscriptions.add atom.commands.add
38-
'atom-workspace',
39-
'ascii-art:convert': => @convert()
36+
@subscriptions.add atom.commands.add 'atom-workspace',
37+
'ascii-art:convert': => @convert()
4038

4139
deactivate: ->
4240
@subscriptions.dispose()
@@ -63,17 +61,19 @@ Next we insert a string into the current text editor with the https://atom.io/do
6361

6462
===== Reload the Package
6563

66-
Before we can trigger `ascii-art:convert`, we need to load the latest code for our package by reloading the window. Run the command `window:reload` from the command palette or by pressing `ctrl-alt-cmd-l`.
64+
Before we can trigger `ascii-art:convert`, we need to load the latest code for our package by reloading the window. Run the command "Window: Reload" from the command palette or by pressing `ctrl-alt-cmd-l`.
6765

6866
===== Trigger the Command
6967

70-
Now open the command panel and search for the `ascii-art:convert` command. But it's not there! To fix this, open _package.json_ and find the property called `activationCommands`. Activation Events speed up load time by allowing Atom to delay a package's activation until it's needed. So remove the existing command and add `ascii-art:convert` to the `activationCommands` array:
68+
Now open the command panel and search for the "Ascii Art: Convert" command. But it's not there! To fix this, open _package.json_ and find the property called `activationCommands`. Activation commands speed up load time by allowing Atom to delay a package's activation until it's needed. So remove the existing command and use `ascii-art:convert` in `activationCommands`:
7169

7270
```json
73-
"activationCommands": ["ascii-art:convert"],
71+
"activationCommands": {
72+
"atom-workspace": "ascii-art:convert"
73+
}
7474
```
7575

76-
First, reload the window by running the command `window:reload`. Now when you run the `ascii-art:convert` command it will output 'Hello, World!'
76+
First, reload the window by running the command "Window: Reload" from the command palette. Now when you run the "Ascii Art: Convert" command it will output 'Hello, World!'
7777

7878
===== Add a Key Binding
7979

@@ -94,12 +94,11 @@ Now we need to convert the selected text to ASCII art. To do this we will use th
9494

9595
```json
9696
"dependencies": {
97-
"figlet": "1.0.8"
97+
"figlet": "1.0.8"
9898
}
9999
```
100100

101-
After saving the file, run the command 'update-package-dependencies:update' from
102-
the Command Palette. This will install the package's node module dependencies, only figlet in this case. You will need to run 'update-package-dependencies:update' whenever you update the dependencies field in your _package.json_ file.
101+
After saving the file, run the command "Update Package Dependencies: Update" from the Command Palette. This will install the package's node module dependencies, only figlet in this case. You will need to run "Update Package Dependencies: Update" whenever you update the dependencies field in your _package.json_ file.
103102

104103
If for some reason this doesn't work, you'll see a message saying ``Failed to update package dependencies'' and you will find a new `npm-debug.log` file in your directory. That file should give you some idea as to what went wrong.
105104

@@ -111,7 +110,7 @@ convert: ->
111110
selection = editor.getSelectedText()
112111

113112
figlet = require 'figlet'
114-
font = "Larry 3D 2"
113+
font = "o8"
115114
figlet selection, {font: font}, (error, art) ->
116115
if error
117116
console.error(error)

0 commit comments

Comments
 (0)