Home Reference Source Repository
import Minimap from 'minimap/lib/minimap.js'
public class | source

Minimap

The Minimap class is the underlying model of a <MinimapElement>. Most manipulations of the minimap is done through the model.

Any Minimap instance is tied to a TextEditor. Their lifecycle follow the one of their target TextEditor, so they are destroyed whenever their TextEditor is destroyed.

Constructor Summary

Public Constructor
public

constructor(options: Object)

Creates a new Minimap instance for the given TextEditor.

Method Summary

Public Methods
public

Returns true when the Minimap can scroll.

public

Destroys the model.

public

Returns the TextEditor scroll as a value normalized between 0 and 1.

public

Returns the height of a character in the Minimap in pixels.

public

Returns the width of a character in the Minimap in pixels.

public

Returns the index of the first visible row in the Minimap.

public

Returns the height of the whole minimap in pixels based on the minimap settings.

public

Returns the horizontal scaling factor when converting coordinates from the TextEditor to the Minimap.

public

Returns the height of an interline in the Minimap in pixels.

public

Returns the index of the last visible row in the Minimap.

public

Returns the height of a line in the Minimap in pixels.

public

Returns the maximum scroll value of the Minimap.

public

Returns the height the minimap should take once displayed, it's either the height of the TextEditor or the provided height when in stand-alone mode.

public

Returns the width the Minimap should take once displayed, it's either the width of the Minimap content or the provided width when in standAlone mode.

public

Returns the current scroll of the Minimap.

public

getTextEditor(): TextEditor

Returns the TextEditor that this minimap represents.

public

Returns the height of the TextEditor.

public

Returns the TextEditor maximum scroll top value.

public

Returns the height of the TextEditor at the Minimap scale.

public

Returns the TextEditor scroll left value at the Minimap scale.

public

Returns the TextEditor scroll top value at the Minimap scale.

public

Returns the TextEditor scroll left value.

public

Returns the TextEditor scroll as a value normalized between 0 and 1.

public

Returns the TextEditor scroll top value.

public

Returns the vertical scaling factor when converting coordinates from the TextEditor to the Minimap.

public

Returns the height the Minimap content will take on screen.

public

Returns the width the whole Minimap will take on screen.

public

Returns the width of the whole minimap in pixels based on the minimap settings.

public

Returns true when this Minimap has benn destroyed.

public

Returns true when the current Minimap is a stand-alone minimap.

public

onDidChange(callback: function(event: Object): void): Disposable

Registers an event listener to the did-change event.

public

onDidChangeConfig(callback: function(): void): Disposable

Registers an event listener to the did-change-config event.

public

onDidChangeScrollLeft(callback: function(minimap: Minimap): void): Disposable

Registers an event listener to the did-change-scroll-left event.

public

onDidChangeScrollTop(callback: function(minimap: Minimap): void): Disposable

Registers an event listener to the did-change-scroll-top event.

public

onDidChangeStandAlone(callback: function(minimap: Minimap): void): Disposable

Registers an event listener to the did-change-stand-alone event.

public

onDidDestroy(callback: function(): void): Disposable

Registers an event listener to the did-destroy event.

public

setCharHeight(charHeight: number)

Sets the char height for this Minimap.

public

setCharWidth(charWidth: number)

Sets the char width for this Minimap.

public

setInterline(interline: number)

Sets the interline height for this Minimap.

public

Sets the preferred height and width when in stand-alone mode.

public

setScrollTop(scrollTop: number)

Sets the minimap scroll top value when in stand-alone mode.

public

setStandAlone(standAlone: boolean)

Sets the stand-alone mode for this minimap.

public

Sets the scroll top of the TextEditor.

Public Constructors

public constructor(options: Object) source

Creates a new Minimap instance for the given TextEditor.

Params:

NameTypeAttributeDescription
options Object

an object with the new Minimap properties

options.textEditor TextEditor

the target text editor for the minimap

options.standAlone boolean
  • optional

whether this minimap is in stand-alone mode or not

options.width number
  • optional

the minimap width in pixels

options.height number
  • optional

the minimap height in pixels

Throw:

Error

Cannot create a minimap without an editor

Public Methods

public canScroll(): boolean source

Returns true when the Minimap can scroll.

Return:

boolean

whether this Minimap can scroll or not

public destroy() source

Destroys the model.

public getCapedTextEditorScrollRatio(): number source

Returns the TextEditor scroll as a value normalized between 0 and 1.

The returned value will always be strictly between 0 and 1.

Return:

number

the scroll ratio of the text editor strictly between 0 and 1

public getCharHeight(): number source

Returns the height of a character in the Minimap in pixels.

Return:

number

a character's height in the Minimap

public getCharWidth(): number source

Returns the width of a character in the Minimap in pixels.

Return:

number

a character's width in the Minimap

public getFirstVisibleScreenRow(): number source

Returns the index of the first visible row in the Minimap.

Return:

number

the index of the first visible row

public getHeight(): number source

Returns the height of the whole minimap in pixels based on the minimap settings.

Return:

number

the height of the minimap

public getHorizontalScaleFactor(): number source

Returns the horizontal scaling factor when converting coordinates from the TextEditor to the Minimap.

Return:

number

the Minimap horizontal scaling factor

public getInterline(): number source

Returns the height of an interline in the Minimap in pixels.

Return:

number

the interline's height in the Minimap

public getLastVisibleScreenRow(): number source

Returns the index of the last visible row in the Minimap.

Return:

number

the index of the last visible row

public getLineHeight(): number source

Returns the height of a line in the Minimap in pixels.

Return:

number

a line's height in the Minimap

public getMaxScrollTop(): number source

Returns the maximum scroll value of the Minimap.

Return:

number

the maximum scroll top for the Minimap

public getScreenHeight(): number source

Returns the height the minimap should take once displayed, it's either the height of the TextEditor or the provided height when in stand-alone mode.

Return:

number

the total height of the Minimap

public getScreenWidth(): number source

Returns the width the Minimap should take once displayed, it's either the width of the Minimap content or the provided width when in standAlone mode.

Return:

number

the Minimap screen width

public getScrollTop(): number source

Returns the current scroll of the Minimap.

The Minimap can scroll only when its height is greater that the height of its TextEditor.

Return:

number

the scroll top of the Minimap

public getTextEditor(): TextEditor source

Returns the TextEditor that this minimap represents.

Return:

TextEditor

this Minimap's text editor

public getTextEditorHeight(): number source

Returns the height of the TextEditor.

Return:

number

the height of the text editor

public getTextEditorMaxScrollTop(): number source

Returns the TextEditor maximum scroll top value.

When the scrollPastEnd setting is enabled, the method compensate the extra scroll by removing the same height as added by the editor from the final value.

Return:

number

the maximum scroll top of the text editor

public getTextEditorScaledHeight(): number source

Returns the height of the TextEditor at the Minimap scale.

Return:

number

the scaled height of the text editor

public getTextEditorScaledScrollLeft(): number source

Returns the TextEditor scroll left value at the Minimap scale.

Return:

number

the scaled scroll left of the text editor

public getTextEditorScaledScrollTop(): number source

Returns the TextEditor scroll top value at the Minimap scale.

Return:

number

the scaled scroll top of the text editor

public getTextEditorScrollLeft(): number source

Returns the TextEditor scroll left value.

Return:

number

the scroll left of the text editor

public getTextEditorScrollRatio(): number source

Returns the TextEditor scroll as a value normalized between 0 and 1.

When the scrollPastEnd setting is enabled the value may exceed 1 as the maximum scroll value used to compute this ratio compensate for the extra height in the editor. Use getCapedTextEditorScrollRatio when you need a value that is strictly between 0 and 1.

Return:

number

the scroll ratio of the text editor

public getTextEditorScrollTop(): number source

Returns the TextEditor scroll top value.

Return:

number

the scroll top of the text editor

public getVerticalScaleFactor(): number source

Returns the vertical scaling factor when converting coordinates from the TextEditor to the Minimap.

Return:

number

the Minimap vertical scaling factor

public getVisibleHeight(): number source

Returns the height the Minimap content will take on screen.

When the Minimap height is greater than the TextEditor height, the TextEditor height is returned instead.

Return:

number

the visible height of the Minimap

public getVisibleWidth(): number source

Returns the width the whole Minimap will take on screen.

Return:

number

the width of the Minimap when displayed

public getWidth(): number source

Returns the width of the whole minimap in pixels based on the minimap settings.

Return:

number

the width of the minimap

public isDestroyed(): boolean source

Returns true when this Minimap has benn destroyed.

Return:

boolean

whether this Minimap has been destroyed or not

public isStandAlone(): boolean source

Returns true when the current Minimap is a stand-alone minimap.

Return:

boolean

whether this Minimap is in stand-alone mode or not.

public onDidChange(callback: function(event: Object): void): Disposable source

Registers an event listener to the did-change event.

Params:

NameTypeAttributeDescription
callback function(event: Object): void

a function to call when the event is triggered. the callback will be called with an event object with the following properties:

  • start: The change's start row number
  • end: The change's end row number
  • screenDelta: the delta in buffer rows between the versions before and after the change

Return:

Disposable

a disposable to stop listening to the event

public onDidChangeConfig(callback: function(): void): Disposable source

Registers an event listener to the did-change-config event.

Params:

NameTypeAttributeDescription
callback function(): void

a function to call when the event is triggered.

Return:

Disposable

a disposable to stop listening to the event

public onDidChangeScrollLeft(callback: function(minimap: Minimap): void): Disposable source

Registers an event listener to the did-change-scroll-left event.

Params:

NameTypeAttributeDescription
callback function(minimap: Minimap): void

a function to call when the event is triggered. The current Minimap is passed as argument to the callback.

Return:

Disposable

a disposable to stop listening to the event

public onDidChangeScrollTop(callback: function(minimap: Minimap): void): Disposable source

Registers an event listener to the did-change-scroll-top event.

The event is dispatched when the text editor scrollTop value have been changed or when the minimap scroll top have been changed in stand-alone mode.

Params:

NameTypeAttributeDescription
callback function(minimap: Minimap): void

a function to call when the event is triggered. The current Minimap is passed as argument to the callback.

Return:

Disposable

a disposable to stop listening to the event

public onDidChangeStandAlone(callback: function(minimap: Minimap): void): Disposable source

Registers an event listener to the did-change-stand-alone event.

This event is dispatched when the stand-alone of the current Minimap is either enabled or disabled.

Params:

NameTypeAttributeDescription
callback function(minimap: Minimap): void

a function to call when the event is triggered. The current Minimap is passed as argument to the callback.

Return:

Disposable

a disposable to stop listening to the event

public onDidDestroy(callback: function(): void): Disposable source

Registers an event listener to the did-destroy event.

This event is dispatched when this Minimap have been destroyed. It can occurs either because the destroy method have been called on the Minimap or because the target text editor have been destroyed.

Params:

NameTypeAttributeDescription
callback function(): void

a function to call when the event is triggered.

Return:

Disposable

a disposable to stop listening to the event

public setCharHeight(charHeight: number) source

Sets the char height for this Minimap. This value will override the value from the config for this instance only. A did-change-config event is dispatched.

Params:

NameTypeAttributeDescription
charHeight number

the new height of a char in the Minimap

Emit:

did-change-config

when the value is changed

public setCharWidth(charWidth: number) source

Sets the char width for this Minimap. This value will override the value from the config for this instance only. A did-change-config event is dispatched.

Params:

NameTypeAttributeDescription
charWidth number

the new width of a char in the Minimap

Emit:

did-change-config

when the value is changed

public setInterline(interline: number) source

Sets the interline height for this Minimap. This value will override the value from the config for this instance only. A did-change-config event is dispatched.

Params:

NameTypeAttributeDescription
interline number

the new height of an interline in the Minimap

Emit:

did-change-config

when the value is changed

public setScreenHeightAndWidth(height: number, width: number) source

Sets the preferred height and width when in stand-alone mode.

This method is called by the <MinimapElement> for this Minimap so that the model is kept in sync with the view.

Params:

NameTypeAttributeDescription
height number

the new height of the Minimap

width number

the new width of the Minimap

public setScrollTop(scrollTop: number) source

Sets the minimap scroll top value when in stand-alone mode.

Params:

NameTypeAttributeDescription
scrollTop number

the new scroll top for the Minimap

Emit:

did-change-scroll-top

if the Minimap's stand-alone mode is enabled

public setStandAlone(standAlone: boolean) source

Sets the stand-alone mode for this minimap.

Params:

NameTypeAttributeDescription
standAlone boolean

the new state of the stand-alone mode for this Minimap

Emit:

did-change-stand-alone

if the stand-alone mode have been toggled on or off by the call

public setTextEditorScrollTop(scrollTop: number) source

Sets the scroll top of the TextEditor.

Params:

NameTypeAttributeDescription
scrollTop number

the new scroll top value