Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: sky/sdk/lib/editing/editable_text.dart

Issue 1177223007: Apparently I didn't so much _move_ the files as _delete_ the files. Let's re-add them. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/lib/editing/editable_string.dart ('k') | sky/sdk/lib/editing/input.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/editing/editable_text.dart
diff --git a/sky/sdk/lib/editing/editable_text.dart b/sky/sdk/lib/editing/editable_text.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3f5bea54884534448e2ab5545ff4a9dfd3a35499
--- /dev/null
+++ b/sky/sdk/lib/editing/editable_text.dart
@@ -0,0 +1,98 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'dart:async';
+
+import '../widgets/basic.dart';
+import 'editable_string.dart';
+
+class EditableText extends Component {
+
+ EditableText({String key, this.value, this.focused})
+ : super(key: key, stateful: true);
+
+ // static final Style _cursorStyle = new Style('''
+ // width: 2px;
+ // height: 1.2em;
+ // vertical-align: top;
+ // background-color: ${Blue[500]};'''
+ // );
+
+ // static final Style _composingStyle = new Style('''
+ // text-decoration: underline;'''
+ // );
+
+ EditableString value;
+ bool focused;
+
+ void syncFields(EditableText source) {
+ value = source.value;
+ focused = source.focused;
+ }
+
+ Timer _cursorTimer;
+ bool _showCursor = false;
+
+ void _cursorTick(Timer timer) {
+ setState(() {
+ _showCursor = !_showCursor;
+ });
+ }
+
+ void _startCursorTimer() {
+ _showCursor = true;
+ _cursorTimer = new Timer.periodic(
+ new Duration(milliseconds: 500), _cursorTick);
+ }
+
+ void didUnmount() {
+ if (_cursorTimer != null)
+ _stopCursorTimer();
+ super.didUnmount();
+ }
+
+ void _stopCursorTimer() {
+ _cursorTimer.cancel();
+ _cursorTimer = null;
+ _showCursor = false;
+ }
+
+ Widget build() {
+ if (focused && _cursorTimer == null)
+ _startCursorTimer();
+ else if (!focused && _cursorTimer != null)
+ _stopCursorTimer();
+
+ //List<Widget> children = new List<Widget>();
+ String hack = "";
+
+ if (!value.composing.isValid) {
+ // children.add(new TextFragment(value.text));
+ hack += value.text;
+ } else {
+ hack += value.textBefore(value.composing);
+ hack += value.textInside(value.composing);
+ hack += value.textAfter(value.composing);
+ // if (!composing.isEmpty) {
+ // children.add(new TextFragment(
+ // composing,
+ // key: 'composing',
+ // style: _composingStyle
+ // ));
+ // }
+
+ // String afterComposing = value.textAfter(value.composing);
+ // if (!afterComposing.isEmpty)
+ // children.add(new TextFragment(afterComposing));
+ }
+
+ // if (_showCursor)
+ // children.add(new Container(
+ // key: 'cursor',
+ // // style: _cursorStyle
+ // ));
+
+ return new Text(hack);
+ }
+}
« no previous file with comments | « sky/sdk/lib/editing/editable_string.dart ('k') | sky/sdk/lib/editing/input.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698