@@ -1139,28 +1139,52 @@ def Comp.sel(on: Bool, +ty: Ty, +shown: List<&2, String>, +top: Nat, +draft: Str
11391139 case False{}:
11401140 Out.none()
11411141
1142- def Lay.composer(+ty: Ty, +draft: String, +caret: Nat, +mark: Nat, +focused: Bool, +blink: Bool, +x0: U32, +x1: U32, +h: U32, running: Bool, +models: String, +picking: Bool, +ms: List<&2, String>, +model: String, +info: String, +prov: String,
1142+ # how much taller than two lines the composer is for n wrapped lines
1143+ def Comp.eh(+n: Nat) -> U32:
1144+ (U32.from_nat(Nat.sub(S.Cs.rows(n), 2n)) * 23 : U32)
1145+
1146+ # the draft wrapped as the composer shows it, cw wide
1147+ def Comp.wrap(+ty: Ty, +draft: String, +cw: U32) -> List<&2, String>:
1148+ Ty.wrap(ty, 3n, draft, (cw - 40 : U32))
1149+
1150+ # a scrollbar at x beside v of n lines from top, the view th tall
1151+ def Comp.bar(on: Bool, +n: Nat, +v: Nat, +top: Nat, +x: U32, +y: U32, +th: U32) -> Out:
1152+ match on:
1153+ case True{}:
1154+ +bh = {U32.max(16, U32.from_nat(Nat.div(Nat.mul(U32.to_nat(th), v), n))) : U32}
1155+ +by = {U32.from_nat(Nat.div(Nat.mul(U32.to_nat((th - bh : U32)), top), Nat.sub(n, v))) : U32}
1156+ Out.ops([D.Draw.rect(D.Clip.all(), x, y, 4, th, T.Th.raise(), 255), D.Draw.rect(D.Clip.all(), x, (y + by : U32), 4, bh, T.Th.dim(), 255)])
1157+ case False{}:
1158+ Out.none()
1159+
1160+ # the composer grows upward with its draft (its footer stays put); held
1161+ # is the wheel's choice of first line (nui.bend's Cs)
1162+ def Lay.composer(+ty: Ty, +draft: String, +ls: List<&2, String>, +held: String, +caret: Nat, +mark: Nat, +focused: Bool, +blink: Bool, +x0: U32, +x1: U32, +h: U32, running: Bool, +models: String, +picking: Bool, +ms: List<&2, String>, +model: String, +info: String, +prov: String,
11431163 +es: List<&2, String>, +effort: String, +rs: List<&2, U.SkillRow>) -> Out:
11441164 +tw = {(x1 - x0 - 40 : U32) : U32}
1145- +ls = Ty.wrap(ty, 3n, draft, tw)
1165+ +n = List.length(&2, String, ls)
1166+ +v = S.Cs.rows(n)
1167+ +eh = Comp.eh(n)
11461168 +crow = Comp.row(ty, draft, caret, tw)
1147- +top = Nat.min(Nat.sub(List.length(&2, String, ls), 2n), Nat.sub( crow, 1n) )
1148- +shown = List.take(&2, String, List.drop(&2, String, ls, top), 2n )
1169+ +top = S.Cs.top(held, n, crow)
1170+ +shown = List.take(&2, String, List.drop(&2, String, ls, top), v )
11491171 +row = Nat.sub(crow, top)
11501172 +cx = Comp.x(ty, draft, caret, tw)
1151- +y = {(h - 120 : U32) : U32}
1173+ +y = {(h - 120 - eh : U32) : U32}
1174+ +fy = {(h - 56 : U32) : U32}
11521175 +send = Bool.pick(String, running, "Queue", "Send")
11531176 Out.all([
1154- Out.ops(Lay.box(D.Clip.all(), x0, y, (x1 - x0 : U32), 100, 10, T.Th.panel(), Bool.pick(U32, focused, T.Th.focus(), T.Th.line()))),
1177+ Out.ops(Lay.box(D.Clip.all(), x0, y, (x1 - x0 : U32), ( 100 + eh : U32) , 10, T.Th.panel(), Bool.pick(U32, focused, T.Th.focus(), T.Th.line()))),
11551178 Comp.sel(Bool.and(focused, Bool.not(Nat.is_eq(caret, mark))), ty, shown, top, draft, ED.Edit.lo(caret, mark), ED.Edit.hi(caret, mark), tw, (x0 + 16 : U32), (y + 12 : U32)),
11561179 Bool.pick(Out, String.is_empty(draft),
11571180 Out.ops(Ty.text(ty, 3n, "Ask anything, @tag files, $skill, or describe the change", D.Clip.all(), (x0 + 16 : U32), (y + 10 : U32), 23, T.Th.faint())),
1158- Lay.lines(ty, shown, D.Clip{(x0 + 1 : U32), (y + 1 : U32), (x1 - 1 : U32), (y + 60 : U32)}, (x0 + 16 : U32), (y + 10 : U32))),
1159- Bool.pick(Out, Bool.and(focused, blink), Out.ops([D.Draw.rect(D.Clip.all(), (x0 + 16 + cx : U32), (y + 14 + (U32.from_nat(row) * 23 : U32) : U32), 1, 16, T.Th.accent(), 255)]), Out.none()),
1160- Out{Nil{}, [Lay.hit(x0, y, (x1 - x0 : U32), 64, "focus", "composer")]},
1161- Out{List.append(&2, R.Op, Ty.text(ty, 2n, models, D.Clip.all(), (x0 + 16 : U32), (y + 64 : U32), 28, T.Th.dim()), Lay.icon(ty, "chevron-down", D.Clip.all(), (x0 + 22 + Ty.width(ty, 2n, models) : U32), (y + 70 : U32), T.Th.dim())), [Lay.hit((x0 + 8 : U32), (y + 64 : U32), (Ty.width(ty, 2n, models) + 36 : U32), 28, "flag", "models")]},
1162- Lay.button(ty, D.Clip.all(), (x1 - 12 - Lay.button.w(ty, send) : U32), (y + 64 : U32), send, T.Th.accent(), "send", ""),
1163- Lay.picker(ty, picking, "" <> ms, model, info, prov, (x0 + 8 : U32), (y + 64 : U32), es, effort),
1181+ Lay.lines(ty, shown, D.Clip{(x0 + 1 : U32), (y + 1 : U32), (x1 - 1 : U32), (y + 60 + eh : U32)}, (x0 + 16 : U32), (y + 10 : U32))),
1182+ Bool.pick(Out, Bool.and(Bool.and(focused, blink), Bool.and(Nat.is_ge(crow, top), Nat.is_lt(row, v))), Out.ops([D.Draw.rect(D.Clip.all(), (x0 + 16 + cx : U32), (y + 14 + (U32.from_nat(row) * 23 : U32) : U32), 1, 16, T.Th.accent(), 255)]), Out.none()),
1183+ Comp.bar(Nat.is_gt(n, v), n, v, top, (x1 - 12 : U32), (y + 12 : U32), (U32.from_nat(v) * 23 - 4 : U32)),
1184+ Out{Nil{}, [Lay.hit(x0, y, (x1 - x0 : U32), (64 + eh : U32), "focus", "composer"), Lay.hit(0, 0, 0, 0, "cs", Nat.show(top) ++ "," ++ Nat.show(Nat.sub(n, v)))]},
1185+ Out{List.append(&2, R.Op, Ty.text(ty, 2n, models, D.Clip.all(), (x0 + 16 : U32), fy, 28, T.Th.dim()), Lay.icon(ty, "chevron-down", D.Clip.all(), (x0 + 22 + Ty.width(ty, 2n, models) : U32), (fy + 6 : U32), T.Th.dim())), [Lay.hit((x0 + 8 : U32), fy, (Ty.width(ty, 2n, models) + 36 : U32), 28, "flag", "models")]},
1186+ Lay.button(ty, D.Clip.all(), (x1 - 12 - Lay.button.w(ty, send) : U32), fy, send, T.Th.accent(), "send", ""),
1187+ Lay.picker(ty, picking, "" <> ms, model, info, prov, (x0 + 8 : U32), fy, es, effort),
11641188 Lay.skills(ty, rs, x0, x1, (y - 4 : U32))])
11651189
11661190# whether the head line ends above top (it is out of view)
@@ -2115,17 +2139,18 @@ def Lay.attach_field(+ty: Ty, on: Bool, +path: String, +caret: Nat, +mark: Nat,
21152139 Out.none()
21162140
21172141# the composer with its attachments
2118- def Lay.composer.a(+ty: Ty, +draft: String, +caret: Nat, +mark: Nat, +focus: String, +blink: Bool, +x0: U32, +x1: U32, +h: U32, +running: Bool, +models: String, +picking: Bool, +ms: List<&2, String>, +model: String,
2142+ def Lay.composer.a(+ty: Ty, +draft: String, +ls: List<&2, String>, +held: String, + caret: Nat, +mark: Nat, +focus: String, +blink: Bool, +x0: U32, +x1: U32, +h: U32, +running: Bool, +models: String, +picking: Bool, +ms: List<&2, String>, +model: String,
21192143 +info: String, +prov: String, +es: List<&2, String>, +effort: String, +rs: List<&2, U.SkillRow>, +atts: List<&2, String>, +up: String, +path: String) -> Out:
21202144 +send = Bool.pick(String, running, "Queue", "Send")
2121- +y = {(h - 120 : U32) : U32}
2145+ +y = {(h - 120 - Comp.eh(List.length(&2, String, ls)) : U32) : U32}
2146+ +fy = {(h - 56 : U32) : U32}
21222147 Out.all([
2123- Lay.composer(ty, draft, caret, mark, String.eq(focus, "composer"), blink, x0, x1, h, running, models, picking, ms, model, info, prov, es, effort, rs),
2124- Lay.atts(ty, atts, up, (x0 + 24 + Ty.width(ty, 2n, models) + 36 : U32), (y + 64 : U32) ),
2125- Lay.ibutton(ty, D.Clip.all(), (x1 - 20 - Lay.button.w(ty, send) - 28 : U32), (y + 64 : U32) , "paperclip", T.Th.soft(), "focus", "attach-path"),
2148+ Lay.composer(ty, draft, ls, held, caret, mark, String.eq(focus, "composer"), blink, x0, x1, h, running, models, picking, ms, model, info, prov, es, effort, rs),
2149+ Lay.atts(ty, atts, up, (x0 + 24 + Ty.width(ty, 2n, models) + 36 : U32), fy ),
2150+ Lay.ibutton(ty, D.Clip.all(), (x1 - 20 - Lay.button.w(ty, send) - 28 : U32), fy , "paperclip", T.Th.soft(), "focus", "attach-path"),
21262151 Lay.attach_field(ty, String.eq(focus, "attach-path"), path, caret, mark, x0, x1, (y - 36 : U32))])
21272152
2128- def Lay.thread.k(+ty: Ty, +memo: TLMemo, t: M.Thread, +draft: String, +st: M.State, +sel: String, +live: String, +caret: Nat, +mark: Nat, +focus: String, +blink: Bool,
2153+ def Lay.thread.k(+ty: Ty, +memo: TLMemo, t: M.Thread, +draft: String, +held: String, + st: M.State, +sel: String, +live: String, +caret: Nat, +mark: Nat, +focus: String, +blink: Bool,
21292154 +x0: U32, +x1: U32, +h: U32, +sc: U32, pa: Bool, +info: String, +picking: Bool, +pend: List<&2, String>, +rs: List<&2, U.SkillRow>, +now: Nat,
21302155 +atts: List<&2, String>, +up: String, +path: String, +pics: Map<&2, String>, del: Bool, +tsel: TSel) -> Out:
21312156 match t:
@@ -2139,38 +2164,42 @@ def Lay.thread.k(+ty: Ty, +memo: TLMemo, t: M.Thread, +draft: String, +st: M.Sta
21392164 +asks = U.Asks.open(st, sel)
21402165 +ah = Asks.h(ty, asks, (cw - 32 : U32))
21412166 +qh = {Bool.pick(U32, String.is_empty(M.Queue.of(st, sel)), 0, 30) : U32}
2167+ # the composer grows by eh, and all above it moves up
2168+ +ls = Comp.wrap(ty, draft, cw)
2169+ +eh = Comp.eh(List.length(&2, String, ls))
21422170 # the timeline and what sits around it are laid out at once
21432171 tl ch = Lay.timeline(ty,
21442172 List.concat(&2, TLine, [TL.memo.shown(ty, memo, st, sel, cw, pics), TL.sending(ty, pend, cw),
21452173 TL.live.k(ty, String.is_empty(live), Lay.running(turn), live, cw)]),
2146- cx0, cx1, top, (h - ah - qh : U32), sc, tsel, Out.none()) Out.all([Lay.header(ty, M.Thread{id, p, ti, c, a, turn, pe, ar, o, sa, ua, pi, en, br, wt, pr, mo, rm, im, se, de}, x0, x1, pa, M.Snooze.on(now, U.Side.until(st, sel)), del),
2174+ cx0, cx1, top, (h - ah - qh - eh : U32), sc, tsel, Out.none()) Out.all([Lay.header(ty, M.Thread{id, p, ti, c, a, turn, pe, ar, o, sa, ua, pi, en, br, wt, pr, mo, rm, im, se, de}, x0, x1, pa, M.Snooze.on(now, U.Side.until(st, sel)), del),
21472175 Lay.parent(ty, st, sel, cx0, 58),
21482176 Lay.tasks(ty, ts, st, cx0, cx1, (60 + pl : U32)),
2149- Lay.composer.a(ty, draft, caret, mark, focus, blink, cx0, cx1, h, Lay.running(turn), U.Effort.label(U.Models.label(pr, mo), U.Effort.of(st, sel)), picking, U.Models.list(info, pr), mo, info, pr,
2177+ Lay.composer.a(ty, draft, ls, held, caret, mark, focus, blink, cx0, cx1, h, Lay.running(turn), U.Effort.label(U.Models.label(pr, mo), U.Effort.of(st, sel)), picking, U.Models.list(info, pr), mo, info, pr,
21502178 U.Effort.chips(info, pr, mo), U.Effort.of(st, sel), rs, atts, up, path),
2151- Lay.queued(ty, M.Queue.of(st, sel), cx0, cx1, h ),
2152- Lay.asks(ty, asks, draft, cx0, cx1, (h - 132 - ah - qh + 4 : U32))])
2179+ Lay.queued(ty, M.Queue.of(st, sel), cx0, cx1, (h - eh : U32) ),
2180+ Lay.asks(ty, asks, draft, cx0, cx1, (h - 132 - ah - qh - eh + 4 : U32))])
21532181 Out.cat(tl, ch)
21542182
21552183# while files dragged in hover over the window, an accent ring around the
21562184# composer (placed as Lay.thread.k places it) shows where they drop
2157- def Lay.drop_mark(on: Bool, +x0: U32, +x1: U32, +h: U32) -> Out:
2185+ def Lay.drop_mark(on: Bool, +ty: Ty, +draft: String, + x0: U32, +x1: U32, +h: U32) -> Out:
21582186 match on:
21592187 case True{}:
21602188 +cw = {U32.min((x1 - x0 - 64 : U32), 780) : U32}
21612189 +cx0 = {(x0 + U32.shr((x1 - x0 - cw : U32)) - 5 : U32) : U32}
2162- +y = {(h - 125 : U32) : U32}
2190+ +eh = Comp.eh(List.length(&2, String, Comp.wrap(ty, draft, cw)))
2191+ +y = {(h - 125 - eh : U32) : U32}
21632192 Out.ops([D.Draw.rect(D.Clip.all(), cx0, y, (cw + 10 : U32), 2, T.Th.accent(), 255),
2164- D.Draw.rect(D.Clip.all(), cx0, (y + 108 : U32), (cw + 10 : U32), 2, T.Th.accent(), 255),
2165- D.Draw.rect(D.Clip.all(), cx0, y, 2, 110, T.Th.accent(), 255),
2166- D.Draw.rect(D.Clip.all(), (cx0 + cw + 8 : U32), y, 2, 110, T.Th.accent(), 255)])
2193+ D.Draw.rect(D.Clip.all(), cx0, (y + 108 + eh : U32), (cw + 10 : U32), 2, T.Th.accent(), 255),
2194+ D.Draw.rect(D.Clip.all(), cx0, y, 2, ( 110 + eh : U32) , T.Th.accent(), 255),
2195+ D.Draw.rect(D.Clip.all(), (cx0 + cw + 8 : U32), y, 2, ( 110 + eh : U32) , T.Th.accent(), 255)])
21672196 case False{}:
21682197 Out.none()
21692198
21702199def Lay.thread(+ty: Ty, +memo: TLMemo, +n: S.Nui, +x0: U32, +x1: U32) -> Out:
21712200 match n:
21722201 case S.Nui{U.Ui{+st, +sel, _, +live, +op, _, _, _, pa, _, _, _, _, _, +nf, _, _}, _, +h, _, _, _, +sc, +caret, +focus, +path, _, _, _}:
2173- Out.cat(Lay.drop_mark(U.Flag.get(op, "drop"), x0, x1, h), Lay.thread.k(ty, memo, U.Ui.thread(st, sel), U.Ui.draft_text(S.Nui.ui(n)), st, sel, U.Str.get(live, sel), caret, S.Nui.mark(n), focus, S.Blink.on(n), x0, x1, h, sc, pa,
2202+ Out.cat(Lay.drop_mark(U.Flag.get(op, "drop"), ty, U.Ui.draft_text(S.Nui.ui(n)), x0, x1, h), Lay.thread.k(ty, memo, U.Ui.thread(st, sel), U.Ui.draft_text(S.Nui.ui(n)), S.Cs.held(n ), st, sel, U.Str.get(live, sel), caret, S.Nui.mark(n), focus, S.Blink.on(n), x0, x1, h, sc, pa,
21742203 U.Str.get(nf, "models"), U.Flag.get(op, "models"), U.Ui.pending(S.Nui.ui(n), sel), U.Ui.skills(S.Nui.ui(n)), U.Side.now(S.Nui.ui(n)),
21752204 U.Ui.atts(S.Nui.ui(n), sel), U.Ui.uploading(S.Nui.ui(n), sel), path, nf, U.Ui.deleting(S.Nui.ui(n)), TSel.of(U.Ui.scratch(S.Nui.ui(n), "@ts"), sel)))
21762205
0 commit comments