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
4472b414
Commit
4472b414
authored
9 years ago
by
Francesco Andreuzzi
Browse files
Options
Downloads
Patches
Plain Diff
bugfix
parent
5b0933dc
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/managers/TerminalMAnager.java
+22
-10
22 additions, 10 deletions
...a/ohi/andre/consolelauncher/managers/TerminalMAnager.java
with
22 additions
and
10 deletions
app/src/main/java/ohi/andre/consolelauncher/
tuil
s/Terminal
Adapt
er.java
→
app/src/main/java/ohi/andre/consolelauncher/
manager
s/Terminal
MAnag
er.java
+
22
−
10
View file @
4472b414
package
ohi.andre.consolelauncher.
tuil
s
;
package
ohi.andre.consolelauncher.
manager
s
;
import
android.app.Activity
;
import
android.os.IBinder
;
import
android.os.Looper
;
import
android.text.InputType
;
import
android.text.Layout
;
import
android.text.Spannable
;
...
...
@@ -19,7 +20,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.Map
;
import
ohi.andre.consolelauncher.managers.SkinManager
;
import
ohi.andre.consolelauncher.tuils.SimpleMutableEntry
;
import
ohi.andre.consolelauncher.tuils.Tuils
;
import
ohi.andre.consolelauncher.tuils.interfaces.OnNewInputListener
;
/*Copyright Francesco Andreuzzi
...
...
@@ -36,14 +38,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.*/
public
class
Terminal
Adapt
er
{
public
class
Terminal
Manag
er
{
private
final
CharSequence
PREFIX
=
">>"
;
private
final
int
SCROLL_DELAY
=
200
;
p
rivate
final
int
INPUT
=
10
;
p
rivate
final
int
OUTPUT
=
11
;
p
ublic
static
final
int
INPUT
=
10
;
p
ublic
static
final
int
OUTPUT
=
11
;
private
int
mCurrentOutputId
=
0
;
...
...
@@ -63,7 +65,7 @@ public class TerminalAdapter {
private
OnNewInputListener
mInputListener
;
public
Terminal
Adapt
er
(
TextView
terminalView
,
EditText
inputView
,
TextView
prefixView
,
TextView
submitView
,
SkinManager
skinManager
,
public
Terminal
Manag
er
(
TextView
terminalView
,
EditText
inputView
,
TextView
prefixView
,
TextView
submitView
,
SkinManager
skinManager
,
String
hint
,
final
boolean
physicalEnter
)
{
if
(
terminalView
==
null
||
inputView
==
null
||
prefixView
==
null
||
skinManager
==
null
)
throw
new
UnsupportedOperationException
();
...
...
@@ -140,23 +142,33 @@ public class TerminalAdapter {
}
public
void
setOutput
(
String
output
,
int
id
)
{
if
(
output
==
null
||
output
.
length
()
==
0
)
if
(
output
==
null
)
return
;
writeToView
(
output
,
OUTPUT
,
id
);
scrollToEnd
();
}
p
rivate
void
writeToView
(
String
text
,
int
type
)
{
p
ublic
void
writeToView
(
String
text
,
int
type
)
{
writeToView
(
text
,
type
,
mCurrentOutputId
);
}
private
void
writeToView
(
String
text
,
int
type
,
int
id
)
{
private
void
writeToView
(
final
String
text
,
final
int
type
,
int
id
)
{
if
(
type
==
INPUT
||
id
==
mCurrentOutputId
)
{
if
(!
mTerminalView
.
getText
().
toString
().
endsWith
(
Tuils
.
NEWLINE
))
{
mTerminalView
.
append
(
Tuils
.
NEWLINE
);
}
if
(
Looper
.
myLooper
()
==
Looper
.
getMainLooper
())
{
mTerminalView
.
append
(
getSpannable
(
text
,
type
));
}
else
{
((
Activity
)
mTerminalView
.
getContext
()).
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
mTerminalView
.
append
(
getSpannable
(
text
,
type
));
}
});
}
}
else
if
(
type
==
OUTPUT
)
{
List
<
String
>
oldText
=
getLines
(
mTerminalView
);
List
<
Map
.
Entry
<
String
,
String
>>
wrappedOldText
=
splitInputOutput
(
oldText
);
...
...
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