Atom

Description

Atom global for dealing with packages, themes, menus, and the window.

An instance of this class is always available as the atom global.

API documentation

Properties

::commands

A CommandRegistry instance

::config

A Config instance

::clipboard

A Clipboard instance

::contextMenu

A ContextMenuManager instance

::menu

A MenuManager instance

::keymaps

A KeymapManager instance

::tooltips

A TooltipManager instance

::notifications

A NotificationManager instance

::project

A Project instance

::grammars

A GrammarRegistry instance

::packages

A PackageManager instance

::themes

A ThemeManager instance

::styles

A StyleManager instance

::deserializers

A DeserializerManager instance

::views

A ViewRegistry instance

::workspace

A Workspace instance

Event Subscription

::onDidBeep(callback)

Invoke the given callback whenever Atom::beep is called.

Argument Description
callback

Function to be called whenever Atom::beep is called.

Return values
  • Returns a Disposable on which .dispose() can be called to unsubscribe.

::onWillThrowError(callback)

Invoke the given callback when there is an unhandled error, but before the devtools pop open

Argument Description
callback

Function to be called whenever there is an unhandled error

event

Object

originalError

Object the original error object

message

String the original error object

url

String Url to the file where the error originated.

line

Number

column

Number

preventDefault

Function call this to avoid popping up the dev tools.

Return values
  • Returns a Disposable on which .dispose() can be called to unsubscribe.

::onDidThrowError(callback)

Invoke the given callback whenever there is an unhandled error.

Argument Description
callback

Function to be called whenever there is an unhandled error

event

Object

originalError

Object the original error object

message

String the original error object

url

String Url to the file where the error originated.

line

Number

column

Number

Return values
  • Returns a Disposable on which .dispose() can be called to unsubscribe.

Atom Details

::inDevMode()

Is the current window in development mode?

::inSafeMode()

Is the current window in safe mode?

::inSpecMode()

Is the current window running specs?

::getVersion()

Get the version of the Atom application.

Return values
  • Returns the version text String.

::isReleasedVersion()

Determine whether the current version is an official release.

::getWindowLoadTime()

Get the time taken to completely load the current window.

This time include things like loading and activating packages, creating DOM elements for the editor, and reading the config.

Return values
  • Returns the Number of milliseconds taken to load the window or null if the window hasn't finished loading yet.

Managing The Atom Window

::open(options)

Open a new Atom window using the given options.

Calling this method without an options parameter will open a prompt to pick a file/folder to open in the new window.

Argument Description
options

An Object with the following keys:

pathsToOpen

An Array of String paths to open.

newWindow

A Boolean, true to always open a new window instead of reusing existing windows depending on the paths to open.

devMode

A Boolean, true to open the window in development mode. Development mode loads the Atom source from the locally cloned repository and also loads all the packages in ~/.atom/dev/packages

safeMode

A Boolean, true to open the window in safe mode. Safe mode prevents all packages installed to ~/.atom/packages from loading.

::pickFolder(callback)

Prompt the user to select one or more folders.

Argument Description
callback

A Function to call once the user has confirmed the selection.

paths

An Array of String paths that the user selected, or null if the user dismissed the dialog.

::close()

Close the current window.

::getSize()

Get the size of current window.

Return values
  • Returns an Object in the format {width: 1000, height: 700}

::setSize(width, height)

Set the size of current window.

Argument Description
width

The Number of pixels.

height

The Number of pixels.

::getPosition()

Get the position of current window.

Return values
  • Returns an Object in the format {x: 10, y: 20}

::setPosition(x, y)

Set the position of current window.

Argument Description
x

The Number of pixels.

y

The Number of pixels.

::center()

Move current window to the center of the screen.

::focus()

Focus the current window.

::show()

Show the current window.

::hide()

Hide the current window.

::reload()

Reload the current window.

::isMaximized()

Return values
  • Returns a Boolean true when the current window is maximized.

::isFullScreen()

Is the current window in full screen mode?

::setFullScreen()

Set the full screen state of the current window.

::toggleFullScreen()

Toggle the full screen state of the current window.

Messaging the User

::beep()

Visually and audibly trigger a beep.

::confirm(options)

A flexible way to open a dialog akin to an alert dialog.

Argument Description
options

An Object with the following keys:

message

The String message to display.

detailedMessage optional

The String detailed message to display.

buttons optional

Either an array of strings or an object where keys are button names and the values are callbacks to invoke when clicked.

Return values
  • Returns the chosen button index Number if the buttons option was an array.

Managing the Dev Tools

::openDevTools()

Open the dev tools for the current window.

::toggleDevTools()

Toggle the visibility of the dev tools for the current window.

::executeJavaScriptInDevTools()

Execute code in dev tools.