|
32 | 32 | import android.support.v4.widget.DrawerLayout;
|
33 | 33 | import android.support.v7.app.ActionBarDrawerToggle;
|
34 | 34 | import android.support.v7.app.AlertDialog;
|
| 35 | +import android.support.v7.widget.AppCompatEditText; |
35 | 36 | import android.support.v7.widget.Toolbar;
|
36 | 37 | import android.util.Log;
|
37 | 38 | import android.view.Gravity;
|
38 | 39 | import android.view.LayoutInflater;
|
39 | 40 | import android.view.Menu;
|
40 | 41 | import android.view.MenuItem;
|
41 | 42 | import android.view.View;
|
| 43 | +import android.view.ViewGroup; |
42 | 44 | import android.view.animation.AlphaAnimation;
|
43 | 45 | import android.view.animation.Animation;
|
44 | 46 | import android.view.inputmethod.InputMethodManager;
|
|
51 | 53 | import com.duy.pascal.backend.ast.runtime_value.VariableContext;
|
52 | 54 | import com.duy.pascal.backend.ast.runtime_value.value.AssignableValue;
|
53 | 55 | import com.duy.pascal.backend.ast.runtime_value.value.RuntimeValue;
|
| 56 | +import com.duy.pascal.backend.builtin_libraries.io.IOLib; |
54 | 57 | import com.duy.pascal.backend.debugable.DebugListener;
|
55 | 58 | import com.duy.pascal.backend.linenumber.LineInfo;
|
56 | 59 | import com.duy.pascal.frontend.R;
|
@@ -91,6 +94,8 @@ public void run() {
|
91 | 94 |
|
92 | 95 | }
|
93 | 96 | };
|
| 97 | + |
| 98 | + |
94 | 99 | private FragmentFrame mFameFragment;
|
95 | 100 | private DrawerLayout drawerLayout;
|
96 | 101 |
|
@@ -413,28 +418,6 @@ private void resumeProgram() {
|
413 | 418 | }
|
414 | 419 |
|
415 | 420 | private void addWatchVariable() {
|
416 |
| -// final AppCompatEditText edittext = new AppCompatEditText(this); |
417 |
| -// edittext.setHint(R.string.var_name); |
418 |
| -// AlertDialog.Builder builder = new AlertDialog.Builder(this); |
419 |
| -// builder.setTitle(R.string.add_watch) |
420 |
| -// .setView(edittext) |
421 |
| -// .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { |
422 |
| -// public void onClick(DialogInterface dialog, int id) { |
423 |
| -// String name = edittext.getText().toString(); |
424 |
| -// if (!name.isEmpty()) { |
425 |
| -// mVariableWatcherView.addVariable(new VariableItem(name)); |
426 |
| -// } |
427 |
| -// dialog.cancel(); |
428 |
| -// } |
429 |
| -// }) |
430 |
| -// .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { |
431 |
| -// public void onClick(DialogInterface dialog, int id) { |
432 |
| -// dialog.cancel(); |
433 |
| -// } |
434 |
| -// }); |
435 |
| -// alertDialog = builder.create(); |
436 |
| -// alertDialog.show(); |
437 |
| - |
438 | 421 | }
|
439 | 422 |
|
440 | 423 |
|
@@ -467,5 +450,36 @@ public void onFunctionCall(String name) {
|
467 | 450 |
|
468 | 451 | }
|
469 | 452 |
|
| 453 | + @Override |
| 454 | + public synchronized void startInput(final IOLib lock) { |
| 455 | + this.mLock = lock; |
| 456 | + showDialogInput(); |
| 457 | + } |
470 | 458 |
|
| 459 | + private void showDialogInput() { |
| 460 | + runOnUiThread(new Runnable() { |
| 461 | + @Override |
| 462 | + public void run() { |
| 463 | + AlertDialog.Builder builder = new AlertDialog.Builder(DebugActivity.this); |
| 464 | + final AppCompatEditText editText = new AppCompatEditText(DebugActivity.this); |
| 465 | + editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, |
| 466 | + ViewGroup.LayoutParams.WRAP_CONTENT)); |
| 467 | + builder.setView(editText); |
| 468 | + builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { |
| 469 | + @Override |
| 470 | + public void onClick(DialogInterface dialog, int which) { |
| 471 | + if (mLock instanceof IOLib) { |
| 472 | + ((IOLib) mLock).setInputBuffer(editText.getText().toString()); |
| 473 | + } |
| 474 | + mConsoleView.writeString(editText.getText().toString()); |
| 475 | + dialog.cancel(); |
| 476 | + } |
| 477 | + }); |
| 478 | + builder.setTitle("Read/readln"); |
| 479 | + alertDialog = builder.create(); |
| 480 | + alertDialog.setCanceledOnTouchOutside(false); |
| 481 | + alertDialog.show(); |
| 482 | + } |
| 483 | + }); |
| 484 | + } |
471 | 485 | }
|
0 commit comments