{"id":16294242,"url":"https://github.com/testica/codeeditor","last_synced_at":"2025-03-20T04:30:32.805Z","repository":{"id":36153891,"uuid":"176181034","full_name":"testica/codeeditor","owner":"testica","description":"Code editor android library (custom syntax highlighting, number lines, etc)","archived":false,"fork":false,"pushed_at":"2022-12-20T09:06:39.000Z","size":746,"stargazers_count":38,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T23:01:53.541Z","etag":null,"topics":["android","android-library","code-editor","editor","edittext","highlight-syntax","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/testica.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-18T01:08:30.000Z","updated_at":"2024-12-31T02:31:43.000Z","dependencies_parsed_at":"2023-01-16T22:57:21.996Z","dependency_job_id":null,"html_url":"https://github.com/testica/codeeditor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testica%2Fcodeeditor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testica%2Fcodeeditor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testica%2Fcodeeditor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testica%2Fcodeeditor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/testica","download_url":"https://codeload.github.com/testica/codeeditor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244047647,"owners_count":20389206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","code-editor","editor","edittext","highlight-syntax","kotlin"],"created_at":"2024-10-10T20:14:39.485Z","updated_at":"2025-03-20T04:30:32.435Z","avatar_url":"https://github.com/testica.png","language":"Kotlin","readme":"# Code Editor\n[ ![Download](https://api.bintray.com/packages/testica-android/maven/codeeditor/images/download.svg) ](https://bintray.com/testica-android/maven/codeeditor/_latestVersion)\n\nCode Editor is an Android library that simplify the display of code, making easy syntax highlighting and showing number of lines.\n\n\u003cbr/\u003e\n\n\u003cdiv style=\"background: white; width: 100%;\" align=\"center\"\u003e\n    \u003cimg src=\"cover.png\" width=\"500\"/\u003e\n\u003c/div\u003e\n\n## Requirements\n- minSdkVersion 15\n- compileSdkVersion 28\n\n## Download\n\nInclude into the build.gradle file:\n\n```groovy\ndependencies {\n    implementation 'me.testica:codeeditor:1.0.2'\n}\n```\n## Usage\n\nFrom layout:\n```xml\n\u003cme.testica.codeeditor.Editor\n            android:id=\"@+id/editor\"\n            app:textSize=\"16sp\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"/\u003e\n```\n\nThen, manipulate programmatically:\n\nJava:\n```java\nEditor editor = (Editor) findViewById(R.id.editor);\neditor.setText(\"Hello Android\");\n```\nKotlin:\n```kotlin\neditor.setText(\"Hello Android\")\n```\n\n### Syntax Highlight Rules\n\nDefine a list of rules using a regular expression and color\n\nJava:\n```java\neditor.setSyntaxHighlightRules(\n        new SyntaxHighlightRule(\"[0-9]*\", \"#00838f\"),\n        new SyntaxHighlightRule(\"/\\\\\\\\*(?:.|[\\\\\\\\n\\\\\\\\r])*?\\\\\\\\*/|(?\u003c!:)//.*\", \"#9ea7aa\")\n);\n```\nKotlin:\n```kotlin\neditor.setSyntaxHighlightRules(\n        SyntaxHighlightRule(\"[0-9]*\", \"#00838f\"),\n        SyntaxHighlightRule(\"/\\\\\\\\*(?:.|[\\\\\\\\n\\\\\\\\r])*?\\\\\\\\*/|(?\u003c!:)//.*\", \"#9ea7aa\")\n)\n```\n**Keep in mind that lasts rules will overwrite the previous ones, so order is important.**\n\n### Customization\n\nFrom **xml** we can set:\n- `text`: text code as string\n- `textSize`: text dimension of text including number lines\n- `fontFamily`: typeface of text including number lines\n\nThe same way we can set and get above attributes programmatically:\n- `setText(String)`\n- `setTextSize(Float)`\n- `setTypeface(Typeface)`\n\nIs it possible to customize the number lines or the code text separately? **Yes!**\nProgrammatically we can get both widget reference and manipulate them:\n\n- `getEditText()`: returns an `EditText` superclass, with this we can handle the code view.\n- `getNumLinesView()`: returns a `TextView` superclass, with this we can handle the number lines view.\n\nBelow an example changing the background color of number lines view and applying some padding to code view:\n\nJava:\n```java\n// changing text color and background color to number lines view\neditor.getNumLinesView().setBackgroundColor(Color.BLACK);\neditor.getNumLinesView().setTextColor(Color.WHITE);\n\n// applying left padding to code view\neditor.getEditText().setPadding(10, 0, 0, 0);\n```\n\nKotlin:\n```kotlin\n// changing text color and background color to number lines view\neditor.getNumLinesView().apply { \n    setBackgroundColor(Color.BLACK)\n    setTextColor(Color.WHITE)\n}\n\n// applying left padding to code view\neditor.getEditText().setPadding(10, 0, 0, 0)\n```\n\nYou can see another approach inside **codeeditorexample/MainActivity** class.\n\n## Contribute\n\nI accept pull requests to fix, improve performance or well-situated feature! Feel free to submit one.\n\n## License MIT\n```\nMIT License\n\nCopyright (c) 2019 Leonardo Testa\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestica%2Fcodeeditor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftestica%2Fcodeeditor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestica%2Fcodeeditor/lists"}