Skip to content

Commit

Permalink
added bearing measure, bullseye
Browse files Browse the repository at this point in the history
  • Loading branch information
alpine committed Jan 9, 2025
1 parent 2a21efa commit 51b9b7a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cotdantic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '2.1.1'
__version__ = '2.1.2'

from .models import *

Expand Down
43 changes: 43 additions & 0 deletions src/cotdantic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ class ChatGroup(CotBase, tag='chatgrp'):
uid1: Optional[str] = attr(default=None)


class RangeUnits(CotBase, tag='rangeUnits'):
value: Optional[int] = attr(default=None)


class Chat(CotBase, tag='__chat'):
id: Optional[str] = attr(default=None)
chatroom: Optional[str] = attr(default=None)
Expand Down Expand Up @@ -274,10 +278,42 @@ class UniqueID(CotBase, tag='uid'):
droid: Optional[str] = attr(default=None, name='Droid')


class Range(CotBase, tag='range'):
value: Optional[float] = attr(default=None)


class NorthRef(CotBase, tag='northRef'):
value: Optional[float] = attr(default=None)


class BearingUnits(CotBase, tag='bearingUnits'):
value: Optional[float] = attr(default=None)


class Bearing(CotBase, tag='bearing'):
value: Optional[float] = attr(default=None)


class Inclination(CotBase, tag='inclination'):
value: Optional[float] = attr(default=None)


class Navcues(CotBase, tag='__navcues'):
pass


class BullsEye(CotBase, tag='bullseye'):
title: Optional[str] = attr(default=None)
edge_to_center: Optional[bool] = attr(name='edgeToCenter', default=None)
mils: Optional[bool] = attr(default=None)
has_range_rings: Optional[bool] = attr(name='hasRangeRings', default=None)
ring_dist: Optional[float] = attr(name='ringDist', default=None)
range_ring_visible: Optional[bool] = attr(name='rangeRingVisible', default=None)
distance: Optional[float] = attr(default=None)
bullseye_uid: Optional[str] = attr(name='bullseyeUID', default=None)
bearing_ref: Optional[str] = attr(name='bearingRef', default=None)


class RouteInfo(CotBase, tag='__routeinfo'):
navcues: Optional[Navcues] = element(default=None)

Expand Down Expand Up @@ -334,6 +370,13 @@ class Detail(CotBase, tag='detail'):
shape: Optional[Shape] = element(default=None)
file_share: Optional[FileShare] = element(default=None)
ack_request: Optional[AckRequest] = element(default=None)
range_units: Optional[RangeUnits] = element(default=None)
bulls_eye: Optional[BullsEye] = element(default=None)
inclination: Optional[Inclination] = element(default=None)
north_ref: Optional[NorthRef] = element(default=None)
bearingUnits: Optional[BearingUnits] = element(default=None)
bearing: Optional[Bearing] = element(default=None)
range: Optional[Range] = element(default=None)

@classmethod
@lru_cache
Expand Down
7 changes: 3 additions & 4 deletions src/cotdantic/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ def wrap_line(self, line: str):
def update(self, key: int):
if not self.selected:
return

if key == curses.KEY_UP:
self._up_scroll(1)
elif key == curses.KEY_DOWN:
self._down_scroll(1)
elif key == curses.KEY_BACKSPACE:
elif key == curses.KEY_ENTER:
self._scroll_end()

def _scroll_end(self, over_scroll: int = 0):
Expand All @@ -82,9 +83,7 @@ def _down_scroll(self, lines: int):
if len(self._text) < self.max_y:
self.index = 0
elif len(self._text) > self.max_y - self.over_scroll_max:
self.index = min(
self.index + lines, len(self._text) - self.max_y + self.over_scroll_max
)
self.index = min(self.index + lines, len(self._text) - self.max_y + self.over_scroll_max)
else:
self.index = 0

Expand Down

0 comments on commit 51b9b7a

Please sign in to comment.