# Drop cursor

> Draw an insertion indicator while dragging over the editor.

## Try it

Drag the quote by its handle and move it above “Draft the outline”. The insertion line marks where the quote will land.

[Drop cursor example](https://gpdoc.dev/docs/plugins/behavior/drop-cursor/#drop-cursor-example)

## Install

```sh
cargo add gpdoc-plugin-drop-cursor
```

## Example

```rust
use gpdoc_plugin_drop_cursor::{drop_cursor, paint_drop_cursor};
use gpdoc_plugin_paragraph::paragraph;


let config = gpdoc::EditorConfig::builder()
    .plugin(paragraph())
    .plugin(drop_cursor().with_view(paint_drop_cursor))
    .build()
    .expect("configure editor");
```

## Paint a custom drop cursor

To draw a blue line with rounded ends, pass your own paint function to `with_view`. The editor supplies the marker bounds in window coordinates. A block drop above or below another block gets a horizontal line. A side drop that creates a column gets a vertical line. A text drop gets a caret at the insertion point. See [Columns](/docs/plugins/structure/columns/#drag-and-drop).

```rust
use gpdoc_plugin_drop_cursor::drop_cursor;
use gpui::{App, Bounds, Pixels, Window, fill, px, rgb};


fn paint_blue_cursor(bounds: Bounds<Pixels>, window: &mut Window, _: &mut App) {
    let line = fill(bounds, rgb(0x4263eb)).corner_radii(px(1.));
    window.paint_quad(line);
}


let cursor = drop_cursor().with_view(paint_blue_cursor);
```

Register `cursor` with `.plugin(cursor)`. To drag blocks by a grip as in the live example, also register the [Drag handle](/docs/plugins/behavior/drag-handle/) plugin.

Drag a file over the editor to see the colored indicator follow a valid drop position. To import files at that position, register the [File handler](/docs/plugins/behavior/file-handler/) with your app’s import callback.

## Source code

[drop-cursor/src/lib.rs](/source/plugins/drop-cursor/src/lib.rs.txt)