Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Terminal user interface- command line
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arjun Sundaram
Terminal user interface- command line
Commits
d216e009
Commit
d216e009
authored
May 18, 2016
by
Francesco
Browse files
Options
Downloads
Patches
Plain Diff
fixed problems with text
parent
6ccf77df
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/ohi/andre/consolelauncher/tuils/TerminalAdapter.java
+43
-10
43 additions, 10 deletions
...java/ohi/andre/consolelauncher/tuils/TerminalAdapter.java
with
43 additions
and
10 deletions
app/src/main/java/ohi/andre/consolelauncher/tuils/TerminalAdapter.java
+
43
−
10
View file @
d216e009
...
...
@@ -7,6 +7,7 @@ import android.text.Spannable;
import
android.text.SpannableString
;
import
android.text.method.ScrollingMovementMethod
;
import
android.text.style.ForegroundColorSpan
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.inputmethod.EditorInfo
;
...
...
@@ -38,6 +39,7 @@ public class TerminalAdapter {
private
final
CharSequence
PREFIX
=
">>"
;
private
final
CharSequence
NEWLINE
=
"\n"
;
private
final
int
INPUT
=
10
;
private
final
int
OUTPUT
=
11
;
...
...
@@ -108,7 +110,7 @@ public class TerminalAdapter {
}
private
void
setupNewInput
()
{
mInputView
.
setText
(
""
);
mInputView
.
setText
(
Tuils
.
EMPTYSTRING
);
mCurrentOutputId
++;
requestInputFocus
();
}
...
...
@@ -145,33 +147,45 @@ public class TerminalAdapter {
private
void
writeToView
(
String
text
,
int
type
,
int
id
)
{
// Log.e("andre", "---------------------");
// Log.e("andre", "startId: " + String.valueOf(id));
// Log.e("andre", "to write: " + text);
text
=
text
.
concat
(
NEWLINE
.
toString
());
Spannable
toWriteSpannable
=
new
SpannableString
(
text
);
ForegroundColorSpan
colorSpan
=
new
ForegroundColorSpan
(
type
==
INPUT
?
mSkinManager
.
getInputColor
()
:
mSkinManager
.
getOutputColor
());
int
color
;
switch
(
type
)
{
case
INPUT:
color
=
mSkinManager
.
getInputColor
();
break
;
case
OUTPUT:
color
=
mSkinManager
.
getOutputColor
();
break
;
default
:
color
=
0
;
break
;
}
ForegroundColorSpan
colorSpan
=
new
ForegroundColorSpan
(
color
);
toWriteSpannable
.
setSpan
(
colorSpan
,
0
,
toWriteSpannable
.
length
(),
0
);
if
(
id
==
mCurrentOutputId
)
{
// Log.e("andre", String.valueOf(System.currentTimeMillis()));
// Log.e("andre", Arrays.toString(Thread.currentThread().getStackTrace()));
// Log.e("andre", "==");
// Log.e("andre", toWriteSpannable.toString());
// Log.e("andre", "current id, " + id);
mTerminalView
.
append
(
toWriteSpannable
);
}
else
{
// Log.e("andre", String.valueOf(System.currentTimeMillis()));
CharSequence
[]
mCurrentText
=
Tuils
.
split
(
mTerminalView
.
getText
(),
NEWLINE
,
-
1
);
final
List
<
CharSequence
>
mNewText
=
new
ArrayList
<>();
int
count
=
0
;
boolean
check
=
false
;
List
<
CharSequence
>
output
=
null
;
// Log.e("andre", String.valueOf(mCurrentText.length));
// Log.e("andre", "Current text length: " + String.valueOf(mCurrentText.length));
// Log.e("andre", "Current text");
// Log.e("andre", Arrays.toString(mCurrentText));
// Log.e("andre", "-----------------");
while
(
count
<
mCurrentText
.
length
)
{
// Log.e("andre", String.valueOf(count) + "
,
" + mCurrentText[count]);
// Log.e("andre",
"Line n. " +
String.valueOf(count) + "
:
" + mCurrentText[count]);
if
(
isInput
(
mCurrentText
[
count
]))
{
// Log.e("andre", mCurrentText[count] + " is input");
id
--;
if
(
output
!=
null
&&
output
.
size
()
>
0
)
{
...
...
@@ -204,11 +218,23 @@ public class TerminalAdapter {
// Log.e("andre", "id: " + id);
if
(
id
==
-
1
)
{
mNewText
.
add
(
toWriteSpannable
);
// Log.e("andre", "towrite");
// Log.e("andre", "
writing
towrite");
// Log.e("andre", toWriteSpannable.toString());
check
=
true
;
}
if
(
count
==
mCurrentText
.
length
-
1
&&
output
.
size
()
>
0
)
{
for
(
CharSequence
sequence
:
output
)
{
ForegroundColorSpan
outputColorSpan
=
new
ForegroundColorSpan
(
mSkinManager
.
getOutputColor
());
Spannable
spannable
=
new
SpannableString
(
sequence
.
toString
());
spannable
.
setSpan
(
outputColorSpan
,
0
,
spannable
.
length
(),
0
);
mNewText
.
add
(
spannable
);
mNewText
.
add
(
NEWLINE
);
}
// Log.e("andre", "output");
// Log.e("andre", output.toString());
}
count
++;
}
...
...
@@ -232,6 +258,13 @@ public class TerminalAdapter {
return
s
.
length
()
>=
PREFIX
.
length
()
&&
s
.
subSequence
(
0
,
PREFIX
.
length
()).
toString
().
equals
(
PREFIX
);
}
private
String
getLastLine
()
{
String
text
=
mTerminalView
.
getText
().
toString
();
String
[]
lines
=
text
.
split
(
Tuils
.
NEWLINE
);
Log
.
e
(
"andre"
,
lines
[
lines
.
length
-
1
]);
return
lines
[
lines
.
length
-
1
];
}
public
String
getInput
()
{
return
mInputView
.
getText
().
toString
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment