Skip to content

Instantly share code, notes, and snippets.

View rahul-lohra's full-sized avatar
🎯
Focusing

Rahul Kumar Lohra rahul-lohra

🎯
Focusing
View GitHub Profile
@rahul-lohra
rahul-lohra / MainMenuScreen.kt
Created May 15, 2021 19:59
Correct Code for MainMenuScreen.kt
package drop
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Screen
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.utils.ScreenUtils
class MainMenuScreen(private val game: Drop):Screen {
private var camera: OrthographicCamera = OrthographicCamera()
@rahul-lohra
rahul-lohra / EditorLogic.kt
Created July 19, 2020 12:20
Dollar replace logic
fun replaceDollar(inputString: String):String{
var finalText = inputString
val indexesToIgnore = hashSetOf<Int>()
val patternsToIgnore = arrayListOf("\\$\\$","\\$\\{\"\\$\"}")
patternsToIgnore.forEach {
val doubleDollarPattern = Pattern.compile(it)
val matcher = doubleDollarPattern.matcher(inputString)
while (matcher.find()) {
@rahul-lohra
rahul-lohra / GqlView.java
Last active July 19, 2020 04:09
Import Logic
package com.rahul.gqlformat;
import com.intellij.openapi.project.Project;
import org.apache.http.util.TextUtils;
import javax.swing.*;
public class GqlView {
private JTextArea textArea;
private JButton btnImport;
@rahul-lohra
rahul-lohra / EditorLogic.kt
Last active July 19, 2020 03:41
Logic for reading value from variable defined in kt file
class EditorLogic {
val nodeCreator = NodeCreator()
var expressionElement: PsiElement? = null
fun selectCurrentFile(variableName: String, project: Project, textArea: JTextArea) {
reset()
val fileEditorManager = FileEditorManager.getInstance(project)
val virtualFile = fileEditorManager.openFiles
@rahul-lohra
rahul-lohra / plugin.xml
Created July 18, 2020 14:15
Register your toolwindow
</idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<toolWindow
id="Gql Format" anchor="right" factoryClass="com.rahul.gqlformat.MyToolWindow">
</toolWindow>
</extensions>
</idea-plugin>
@rahul-lohra
rahul-lohra / MyToolWindow.kt
Created July 18, 2020 13:58
MyToolWindow code
package com.rahul.gqlformat
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.ToolWindow
import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.ContentFactory
class MyToolWindow : ToolWindowFactory {
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
@rahul-lohra
rahul-lohra / GqlView.java
Created July 18, 2020 13:14
GqlView Starter java code
package com.rahul.gqlformat;
import com.intellij.openapi.project.Project;
import javax.swing.*;
public class GqlView {
private JTextArea textArea;
private JButton btnImport;
private JPanel panel;
private JTextField tfVariableName;
@rahul-lohra
rahul-lohra / plugin.xml
Last active July 18, 2020 13:09
Plugin development
<idea-plugin>
<id>com.awesome.formatter</id> <!--Enter your package, it should be unique-->
<name>Awesome GQL Formatter</name>
<vendor email="tgunix@gmail.com" url="http://www.rahullohra.com">RahulLohra</vendor>
<description><![CDATA[
Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum.<br>
Lorem ipsum
]]></description>
@rahul-lohra
rahul-lohra / AppButton.dart
Created August 12, 2019 02:34
Stack GestureDetector
import 'package:fix_library_app/RevealWidget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
class AppButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return nestedWidget();
}
@rahul-lohra
rahul-lohra / App.dart
Created May 25, 2019 20:10
Dart callback
main(List<String> args) {
Button btn = new Button();
btn.setCallback((a){
print(a);
});
for(int i=0;i<4;++i){
btn.tap();
}
}