+};
+
+
+/** @param pos Position, in session frames.
+ * @return AutomationLine to paste to for that position, or 0 if there is none appropriate.
+ */
+boost::shared_ptr<AutomationLine>
+AutomationStreamView::paste_line (framepos_t pos)
+{
+ /* XXX: not sure how best to pick this; for now, just use the last region which starts before pos */
+
+ if (region_views.empty()) {
+ return boost::shared_ptr<AutomationLine> ();
+ }
+
+ region_views.sort (RegionPositionSorter ());
+
+ list<RegionView*>::const_iterator prev = region_views.begin ();
+
+ for (list<RegionView*>::const_iterator i = region_views.begin(); i != region_views.end(); ++i) {
+ if ((*i)->region()->position() > pos) {
+ break;
+ }
+ prev = i;
+ }
+
+ boost::shared_ptr<Region> r = (*prev)->region ();
+
+ /* If *prev doesn't cover pos, it's no good */
+ if (r->position() > pos || ((r->position() + r->length()) < pos)) {
+ return boost::shared_ptr<AutomationLine> ();
+ }
+
+ AutomationRegionView* arv = dynamic_cast<AutomationRegionView*> (*prev);
+ assert (arv);
+
+ return arv->line ();