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

Side by Side Diff: apps/moterm/moterm_model.cc

Issue 1322103006: Moterm: Plumb responses back to the terminal File. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "apps/moterm/moterm_model.h" 5 #include "apps/moterm/moterm_model.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 } // namespace 97 } // namespace
98 98
99 const MotermModel::Attributes MotermModel::kAttributesBold; 99 const MotermModel::Attributes MotermModel::kAttributesBold;
100 const MotermModel::Attributes MotermModel::kAttributesUnderline; 100 const MotermModel::Attributes MotermModel::kAttributesUnderline;
101 const MotermModel::Attributes MotermModel::kAttributesBlink; 101 const MotermModel::Attributes MotermModel::kAttributesBlink;
102 102
103 const unsigned MotermModel::kMaxRows; 103 const unsigned MotermModel::kMaxRows;
104 const unsigned MotermModel::kMaxColumns; 104 const unsigned MotermModel::kMaxColumns;
105 105
106 MotermModel::MotermModel(const Size& max_size, const Size& size) 106 MotermModel::MotermModel(const Size& max_size,
107 : max_size_(max_size), terminal_(), current_state_changes_() { 107 const Size& size,
108 Delegate* delegate)
109 : max_size_(max_size),
110 delegate_(delegate),
111 terminal_(),
112 current_state_changes_() {
108 DCHECK_GT(max_size_.rows, 0u); 113 DCHECK_GT(max_size_.rows, 0u);
109 DCHECK_LE(max_size_.rows, kMaxRows); 114 DCHECK_LE(max_size_.rows, kMaxRows);
110 DCHECK_GT(max_size_.columns, 0u); 115 DCHECK_GT(max_size_.columns, 0u);
111 DCHECK_LE(max_size_.columns, kMaxColumns); 116 DCHECK_LE(max_size_.columns, kMaxColumns);
112 117
113 DCHECK_GT(size.rows, 0u); 118 DCHECK_GT(size.rows, 0u);
114 DCHECK_LE(size.rows, max_size_.rows); 119 DCHECK_LE(size.rows, max_size_.rows);
115 DCHECK_GT(size.columns, 0u); 120 DCHECK_GT(size.columns, 0u);
116 DCHECK_LE(size.columns, max_size_.columns); 121 DCHECK_LE(size.columns, max_size_.columns);
117 122
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 Rectangle(static_cast<int>(pos->tp_row), static_cast<int>(pos->tp_col), 307 Rectangle(static_cast<int>(pos->tp_row), static_cast<int>(pos->tp_col),
303 width, height)); 308 width, height));
304 } 309 }
305 310
306 void MotermModel::OnParam(int cmd, unsigned val) { 311 void MotermModel::OnParam(int cmd, unsigned val) {
307 // TODO(vtl) 312 // TODO(vtl)
308 NOTIMPLEMENTED(); 313 NOTIMPLEMENTED();
309 } 314 }
310 315
311 void MotermModel::OnRespond(const void* buf, size_t size) { 316 void MotermModel::OnRespond(const void* buf, size_t size) {
312 // TODO(vtl) 317 if (delegate_)
313 NOTIMPLEMENTED(); 318 delegate_->OnResponse(buf, size);
319 else
320 DLOG(WARNING) << "Ignoring response: no delegate";
314 } 321 }
315 322
316 // static 323 // static
317 void MotermModel::OnBellThunk(void* ctx) { 324 void MotermModel::OnBellThunk(void* ctx) {
318 DCHECK(ctx); 325 DCHECK(ctx);
319 return static_cast<MotermModel*>(ctx)->OnBell(); 326 return static_cast<MotermModel*>(ctx)->OnBell();
320 } 327 }
321 328
322 // static 329 // static
323 void MotermModel::OnCursorThunk(void* ctx, const teken_pos_t* pos) { 330 void MotermModel::OnCursorThunk(void* ctx, const teken_pos_t* pos) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 void MotermModel::OnParamThunk(void* ctx, int cmd, unsigned val) { 362 void MotermModel::OnParamThunk(void* ctx, int cmd, unsigned val) {
356 DCHECK(ctx); 363 DCHECK(ctx);
357 return static_cast<MotermModel*>(ctx)->OnParam(cmd, val); 364 return static_cast<MotermModel*>(ctx)->OnParam(cmd, val);
358 } 365 }
359 366
360 // static 367 // static
361 void MotermModel::OnRespondThunk(void* ctx, const void* buf, size_t size) { 368 void MotermModel::OnRespondThunk(void* ctx, const void* buf, size_t size) {
362 DCHECK(ctx); 369 DCHECK(ctx);
363 return static_cast<MotermModel*>(ctx)->OnRespond(buf, size); 370 return static_cast<MotermModel*>(ctx)->OnRespond(buf, size);
364 } 371 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698