Skip to content

Commit 3dec343

Browse files
committed
default color is translucent
1 parent 12bfea3 commit 3dec343

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

libCompiler/src/main/java/com/duy/pascal/backend/builtin_libraries/graph/GraphScreen.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,20 @@ public void clear() {
217217
*/
218218
private void clearPrimaryBitmap() {
219219
synchronized (mLock) {
220-
Canvas canvas = null;
220+
/* Canvas canvas = null;
221221
if (mPrimaryBitmap != null) {
222222
canvas = new Canvas(mPrimaryBitmap);
223223
Paint paint = new Paint();
224224
paint.setColor(Color.BLACK);
225225
canvas.drawRect(0, 0, mPrimaryBitmap.getWidth(), mPrimaryBitmap.getHeight(), paint);
226+
}*/
227+
if (ensurePrimaryNonNull()) {
228+
mPrimaryBitmap.eraseColor(Color.TRANSPARENT);
226229
}
227230
}
228231
}
229232

233+
230234
public void setCursorPostion(int x, int y) {
231235
this.mCursor.setCoordinate(x, y);
232236
}
@@ -339,17 +343,25 @@ public boolean isBufferEnable() {
339343

340344
public void setBufferEnable(boolean bufferEnable) {
341345
this.bufferEnable = bufferEnable;
342-
if (bufferEnable && mBitmapBuffer == null) {
343-
ensureBufferNonNull();
344-
} else {
346+
if (bufferEnable && ensureBufferNonNull()) {
345347
clearBufferBitmap();
346348
}
347349
}
348350

349-
private void ensureBufferNonNull() {
351+
private boolean ensureBufferNonNull() {
350352
if (mBitmapBuffer == null) {
351353
mBitmapBuffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
354+
return false;
355+
}
356+
return true;
357+
}
358+
359+
private boolean ensurePrimaryNonNull() {
360+
if (mPrimaryBitmap == null) {
361+
mPrimaryBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
362+
return false;
352363
}
364+
return true;
353365
}
354366

355367
public void bufferToPrimary() {
@@ -360,13 +372,14 @@ public void bufferToPrimary() {
360372

361373
public void clearBufferBitmap() {
362374
synchronized (mLock) {
363-
Canvas canvas = null;
375+
/* Canvas canvas = null;
364376
if (mBitmapBuffer != null) {
365377
canvas = new Canvas(mBitmapBuffer);
366378
Paint paint = new Paint();
367379
paint.setColor(Color.BLACK);
368380
canvas.drawRect(0, 0, mBitmapBuffer.getWidth(), mBitmapBuffer.getHeight(), paint);
369-
}
381+
}*/
382+
if (mBitmapBuffer != null) mBitmapBuffer.eraseColor(Color.TRANSPARENT);
370383
}
371384
}
372385

libCompiler/src/main/java/com/duy/pascal/frontend/editor/EditorActivity.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@
6060
import com.duy.pascal.frontend.R;
6161
import com.duy.pascal.frontend.activities.IRunnablePascal;
6262
import com.duy.pascal.frontend.code.CompileManager;
63-
import com.duy.pascal.frontend.editor.completion.KeyWord;
64-
import com.duy.pascal.frontend.editor.editor_view.AutoIndentEditText;
65-
import com.duy.pascal.frontend.editor.editor_view.EditorView;
66-
import com.duy.pascal.frontend.editor.editor_view.adapters.InfoItem;
6763
import com.duy.pascal.frontend.code_sample.activities.DocumentActivity;
6864
import com.duy.pascal.frontend.dialog.DialogCreateNewFile;
6965
import com.duy.pascal.frontend.dialog.DialogFragmentFixExpectToken;
7066
import com.duy.pascal.frontend.dialog.DialogManager;
67+
import com.duy.pascal.frontend.editor.completion.KeyWord;
68+
import com.duy.pascal.frontend.editor.editor_view.AutoIndentEditText;
69+
import com.duy.pascal.frontend.editor.editor_view.EditorView;
70+
import com.duy.pascal.frontend.editor.editor_view.adapters.InfoItem;
7171
import com.duy.pascal.frontend.setting.PascalPreferences;
7272
import com.duy.pascal.frontend.structure.DialogProgramStructure;
7373
import com.duy.pascal.frontend.structure.viewholder.StructureType;
7474
import com.duy.pascal.frontend.theme.fragment.ThemeFontActivity;
7575
import com.duy.pascal.frontend.view.exec_screen.console.ConsoleView;
76-
import com.flask.colorpicker.OnColorSelectedListener;
76+
import com.flask.colorpicker.builder.ColorPickerClickListener;
7777
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
7878
import com.google.common.collect.ArrayListMultimap;
7979
import com.google.common.collect.ListMultimap;
@@ -745,17 +745,24 @@ public void startDebug() {
745745
}
746746

747747
public void insertColor() {
748-
ColorPickerDialogBuilder.with(this).setOnColorSelectedListener(new OnColorSelectedListener() {
749-
@Override
750-
public void onColorSelected(int selectedColor) {
751-
EditorFragment currentFragment = pagerAdapter.getCurrentFragment();
752-
if (currentFragment != null) {
753-
currentFragment.insert(String.valueOf(selectedColor));
754-
Toast.makeText(EditorActivity.this, getString(R.string.inserted_color) + selectedColor,
755-
Toast.LENGTH_SHORT).show();
756-
}
757-
}
758-
}).build().show();
748+
ColorPickerDialogBuilder.with(this).
749+
setPositiveButton(getString(R.string.select), new ColorPickerClickListener() {
750+
@Override
751+
public void onClick(DialogInterface d, int lastSelectedColor, Integer[] allColors) {
752+
EditorFragment currentFragment = pagerAdapter.getCurrentFragment();
753+
if (currentFragment != null) {
754+
currentFragment.insert(String.valueOf(lastSelectedColor));
755+
Toast.makeText(EditorActivity.this, getString(R.string.inserted_color) + lastSelectedColor,
756+
Toast.LENGTH_SHORT).show();
757+
}
758+
}
759+
})
760+
.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
761+
@Override
762+
public void onClick(DialogInterface dialog, int which) {
763+
dialog.cancel();
764+
}
765+
}).build().show();
759766
}
760767

761768
public void autoFix(ParsingException e) {

test_pascal/test_java/getlink.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
New(is, conn.getInputStream());
1414
New(br, is);
1515

16-
while (true) do
16+
while inputLine <> null do
1717
begin
1818
inputLine := br.readLine();
1919
writeln(inputLine);

0 commit comments

Comments
 (0)