Giter VIP home page Giter VIP logo

syntax-view-android's Introduction

Syntax-View-Android

Beautiful Android Syntax View with line counter it will automatically highlight the code,you can design your own IDE using this view

Example

Colors can be modified as you want

Screenshot

How to add to your app

add this to your dependencies in build.gradle file

implementation 'com.github.Badranh:Syntax-View-Android:0.1.5'

Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

USAGE

1st way:

  • Step 1: add this to your activity_main.xml or any other activity you want:
 <net.cryptobrewery.syntaxview.SyntaxView
    android:id="@+id/syn"
    android:layout_width="match_parent"
     android:layout_height="match_parent">
 </net.cryptobrewery.syntaxview.SyntaxView>
  • Step 2: add this to your java code
//declaration
SyntaxView syntax_view = findViewById(R.id.syn);

 //this will set the color of Code Text background
    syntax_view.setBgColor("#2b2b2b");
 //this will set the color of strings between " "
    syntax_view.setPrintStatmentsColor("#6a8759");
 //this will set the default code text color other than programming keywords!
    syntax_view.setCodeTextColor("#ffffff");
 //this will set programming keywords color like String,int,for,etc...
    syntax_view.setKeywordsColor("#cc7832");
 //this will set the numbers color in code | ex: return 0; 0 will be colored 
    syntax_view.setNumbersColor("#4a85a3");
 //this will set the line number view background color at left
    syntax_view.setRowNumbersBgColor("#2b2b2b");
 //this will set the color of numbers in the line number view at left
    syntax_view.setRowNumbersColor("#cc7832");
 //this will set color of Annotations like super,@Nullable,etc .... 
    syntax_view.setAnnotationsColor("#1932F3");
 //this will set special characters color like ; 
    syntax_view.setSpecialCharsColor("#cc7832");

2nd way:

//this way will set default methods
SyntaxView syntax_view = new SyntaxView(this);
setContentView(syntax_view);

3rd way:

//other colors can be set manually if needed using set methods like setAnnotationsColor
SyntaxView syntax_view = new SyntaxView(this,"#2b2b2b","#cc7832","#4a85a3","#cc7832","#6a8759");
setContentView(syntax_view);

Set On TextChangeListener

   //on text change listener
        syntax_view.code.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
	    		//do whatever you want
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                //on text change listener
		//do whatever you want
                Log.d("tester",charSequence.toString());

            }

            @Override
            public void afterTextChanged(Editable editable) {
		//do whatever you want
            }
        });

Changing Font

Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "yourFont.ttf");
syntax_view.setFont(tf);

Code Paranthesis Validation Method

User can check if there is an error with the paranthesis in his code , the check will be perfomed for once only when called

syntax_view.checkMyCode();

Changes:

+6/25/2018:

  • Uploaded Syntax View
  • Syntax Highlighting
  • Line Number Counter
  • Color Flexibility to meet user requirements

+6/26/2018:

  • added new method setFont() to change font of the code if you wish to
  • changed the default font to a new classic font
  • disabled autocorrect (By: MohamedElidrissi)
  • removed unused attribute (By: MohamedElidrissi)

+6/30/2018

  • Added Auto Indentation
  • Added CheckMyCode Method To Check Code Paranthesis Validity
  • Changed the old font
  • Added a new method to change the Font

Apps that has integrated this library

Let me know if you have implemented this library in your app : [email protected] so I can list your app below :)! Apps:

https://github.com/Badranh/Android-Coding-IDE-APP/

Contribute

Next update:

  • User will have the ability to choose a language like " C,Java,Python" So we can do a faster UI and Highlighting(feel free to implement this update if you are able to do so)
  • You can contribute to this project for missing programming key words so we can include them in the next update.

License : MIT

syntax-view-android's People

Contributors

asdfghjkkl11 avatar badranh avatar jynlin3 avatar rahilm97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

syntax-view-android's Issues

Language and comments

When setting up, I am unable to set for which language do I want it to highlight, also I can't set comments color.

Dispkay code

Hi,

is there any way to set the text, the syntaxview, should display?

Thanks,
Luis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.