# developer-krushna/mh-texteditor architecture

> Architecture diagram of the GitHub repository developer-krushna/mh-texteditor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/developer-krushna/mh-texteditor
- Repository: https://github.com/developer-krushna/mh-texteditor

## Overview

MH-TextEditor is an Android code editor: users open the app, edit text in its custom editor, and use editing, navigation, and language-highlighting features. The reusable EditView owns text editing and rendering, with a gap buffer for content and a syntax engine for highlighted display. MainActivity configures the editor and exposes app-level controls. The README documents search/replace, keyboard support, and other editor capabilities; the sampled excerpts do not show their full wiring, so those links are omitted where uncertain.

Main entry points: [`EditView/src/main/java/modder/hub/editor/EditView.java`](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/EditView.java) (EditView), [`app/src/main/java/modder/hub/editor/MainActivity.java`](https://github.com/developer-krushna/mh-texteditor/blob/main/app/src/main/java/modder/hub/editor/MainActivity.java) (Main activity), [`EditView/src/main/java/modder/hub/editor/component/ClipboardPanel.java`](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/component/ClipboardPanel.java) (Clipboard panel), [`EditView/src/main/java/modder/hub/editor/highlight/MHSyntaxHighlightEngine.java`](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/highlight/MHSyntaxHighlightEngine.java) (Highlight engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android app"]
  node_main["Main activity<br/>[MainActivity.java]"]
end

subgraph group_editing["Editor core"]
  node_editor["EditView<br/>[EditView.java]"]
  node_buffer["Gap buffer<br/>[GapBuffer.java]"]
  node_cache["Buffer cache<br/>[BufferCache.java]"]
  node_listener["Text change callback"]
end

subgraph group_display["Editor display"]
  node_lineheight["Line height index"]
  node_clipboard["Clipboard panel"]
  node_magnifier["Cursor magnifier<br/>[Magnifier.java]"]
end

subgraph group_syntax["Syntax highlighting"]
  node_highlight["Highlight engine"]
  node_syntax_assets["Language rules"]
  node_syntax_models["Token and rules"]
end

node_user(("Editor user"))
node_android_clipboard["Android clipboard"]
node_textfile["Text files"]

node_user -->|"uses"| node_main
node_main -->|"configures"| node_editor
node_main -->|"opens or saves"| node_textfile
node_editor -->|"edits text"| node_buffer
node_editor -->|"uses cache"| node_cache
node_editor -->|"requests highlighting"| node_highlight
node_highlight -->|"loads rules"| node_syntax_assets
node_highlight -->|"produces tokens"| node_syntax_models
node_editor -->|"tracks line heights"| node_lineheight
node_editor -->|"shows actions"| node_clipboard
node_clipboard -->|"dispatches actions"| node_editor
node_clipboard -->|"reads or writes"| node_android_clipboard
node_editor -->|"updates magnifier"| node_magnifier
node_editor -.->|"notifies changes"| node_listener

click node_main "https://github.com/developer-krushna/mh-texteditor/blob/main/app/src/main/java/modder/hub/editor/MainActivity.java"
click node_editor "https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/EditView.java"
click node_buffer "https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/buffer/GapBuffer.java"
click node_cache "https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/buffer/BufferCache.java"
click node_listener "https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/listener/OnTextChangedListener.java"
click node_highlight "https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/highlight/MHSyntaxHighlightEngine.java"
click node_syntax_assets "https://github.com/developer-krushna/mh-texteditor/tree/main/EditView/src/main/assets"
click node_syntax_models "https://github.com/developer-krushna/mh-texteditor/tree/main/EditView/src/main/java/modder/hub/editor/highlight"
click node_lineheight "https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/utils/LineHeightManager.java"
click node_clipboard "https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/component/ClipboardPanel.java"
click node_magnifier "https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/component/Magnifier.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_user toneBlue
class node_editor,node_buffer,node_cache,node_listener toneAmber
class node_lineheight,node_clipboard,node_magnifier toneMint
class node_highlight,node_syntax_assets,node_syntax_models toneRose
class node_android_clipboard,node_textfile toneIndigo
```

## Components

### Android app

- [Main activity](https://github.com/developer-krushna/mh-texteditor/blob/main/app/src/main/java/modder/hub/editor/MainActivity.java): `app/src/main/java/modder/hub/editor/MainActivity.java`

### Editor core

- [EditView](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/EditView.java): `EditView/src/main/java/modder/hub/editor/EditView.java`
- [Gap buffer](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/buffer/GapBuffer.java): `EditView/src/main/java/modder/hub/editor/buffer/GapBuffer.java`
- [Buffer cache](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/buffer/BufferCache.java): `EditView/src/main/java/modder/hub/editor/buffer/BufferCache.java`
- [Text change callback](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/listener/OnTextChangedListener.java): `EditView/src/main/java/modder/hub/editor/listener/OnTextChangedListener.java`

### Editor display

- [Line height index](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/utils/LineHeightManager.java): `EditView/src/main/java/modder/hub/editor/utils/LineHeightManager.java`
- [Clipboard panel](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/component/ClipboardPanel.java): `EditView/src/main/java/modder/hub/editor/component/ClipboardPanel.java`
- [Cursor magnifier](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/component/Magnifier.java): `EditView/src/main/java/modder/hub/editor/component/Magnifier.java`

### Syntax highlighting

- [Highlight engine](https://github.com/developer-krushna/mh-texteditor/blob/main/EditView/src/main/java/modder/hub/editor/highlight/MHSyntaxHighlightEngine.java): `EditView/src/main/java/modder/hub/editor/highlight/MHSyntaxHighlightEngine.java`
- [Language rules](https://github.com/developer-krushna/mh-texteditor/tree/main/EditView/src/main/assets): `EditView/src/main/assets`
- [Token and rules](https://github.com/developer-krushna/mh-texteditor/tree/main/EditView/src/main/java/modder/hub/editor/highlight): `EditView/src/main/java/modder/hub/editor/highlight`

### Other components

- **Editor user**
- **Android clipboard**
- **Text files**

## Connections

- Editor user → Main activity: uses
- Main activity → EditView: configures
- Main activity → Text files: opens or saves
- EditView → Gap buffer: edits text
- EditView → Buffer cache: uses cache
- EditView → Highlight engine: requests highlighting
- Highlight engine → Language rules: loads rules
- Highlight engine → Token and rules: produces tokens
- EditView → Line height index: tracks line heights
- EditView → Clipboard panel: shows actions
- Clipboard panel → EditView: dispatches actions
- Clipboard panel → Android clipboard: reads or writes
- EditView → Cursor magnifier: updates magnifier
- EditView → Text change callback: notifies changes
