make some fields private

pull/31/head
Takayuki Maeda 3 years ago
parent 0dd3a5b39d
commit 61ea31991b

@ -16,7 +16,6 @@ use database_tree::Database;
use tui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
widgets::ListState,
Frame,
};
@ -26,17 +25,16 @@ pub enum Focus {
ConnectionList,
}
pub struct App {
pub record_table: RecordTableComponent,
pub structure_table: TableComponent,
pub focus: Focus,
pub tab: TabComponent,
record_table: RecordTableComponent,
structure_table: TableComponent,
focus: Focus,
tab: TabComponent,
databases: DatabasesComponent,
connections: ConnectionsComponent,
table_status: TableStatusComponent,
clipboard: Clipboard,
pool: Option<Box<dyn Pool>>,
pub user_config: Option<UserConfig>,
pub selected_connection: ListState,
pub databases: DatabasesComponent,
pub connections: ConnectionsComponent,
pub table_status: TableStatusComponent,
pub clipboard: Clipboard,
pub pool: Option<Box<dyn Pool>>,
pub error: ErrorComponent,
}
@ -48,7 +46,6 @@ impl Default for App {
focus: Focus::DabataseList,
tab: TabComponent::default(),
user_config: None,
selected_connection: ListState::default(),
databases: DatabasesComponent::new(),
connections: ConnectionsComponent::default(),
table_status: TableStatusComponent::default(),

@ -1,24 +1,14 @@
#[derive(Clone, PartialEq, PartialOrd, Ord, Eq)]
pub struct CommandText {
///
pub name: String,
///
pub desc: &'static str,
///
pub group: &'static str,
///
pub hide_help: bool,
}
pub struct CommandInfo {
///
pub text: CommandText,
/// available but not active in the context
pub enabled: bool,
/// will show up in the quick bar
pub quick_bar: bool,
/// available in current app state
pub available: bool,
/// used to order commands in quickbar
pub order: i8,
}

@ -12,8 +12,8 @@ use tui::{
};
pub struct ConnectionsComponent {
pub connections: Vec<Connection>,
pub state: ListState,
connections: Vec<Connection>,
state: ListState,
}
impl Default for ConnectionsComponent {
@ -33,7 +33,7 @@ impl ConnectionsComponent {
}
}
pub fn next_connection(&mut self) {
fn next_connection(&mut self) {
let i = match self.state.selected() {
Some(i) => {
if i >= self.connections.len() - 1 {
@ -47,7 +47,7 @@ impl ConnectionsComponent {
self.state.select(Some(i));
}
pub fn previous_connection(&mut self) {
fn previous_connection(&mut self) {
let i = match self.state.selected() {
Some(i) => {
if i == 0 {

@ -2,7 +2,6 @@ use super::{
compute_character_width, utils::scroll_vertical::VerticalScroll, Component, DrawableComponent,
EventState,
};
use crate::components::RecordTableComponent;
use crate::event::Key;
use crate::ui::common_nav;
use crate::ui::scrolllist::draw_list_block;
@ -33,14 +32,13 @@ pub enum FocusBlock {
}
pub struct DatabasesComponent {
pub tree: DatabaseTree,
pub filterd_tree: Option<DatabaseTree>,
pub scroll: VerticalScroll,
pub input: Vec<char>,
pub input_idx: usize,
pub input_cursor_position: u16,
pub record_table: RecordTableComponent,
pub focus_block: FocusBlock,
tree: DatabaseTree,
filterd_tree: Option<DatabaseTree>,
scroll: VerticalScroll,
input: Vec<char>,
input_idx: usize,
input_cursor_position: u16,
focus_block: FocusBlock,
}
impl DatabasesComponent {
@ -52,12 +50,11 @@ impl DatabasesComponent {
input: Vec::new(),
input_idx: 0,
input_cursor_position: 0,
record_table: RecordTableComponent::default(),
focus_block: FocusBlock::Tree,
}
}
pub fn input_str(&self) -> String {
fn input_str(&self) -> String {
self.input.iter().collect()
}

@ -14,8 +14,8 @@ use unicode_width::UnicodeWidthStr;
pub struct TableFilterComponent {
pub table: Option<String>,
pub input: Vec<char>,
pub input_idx: usize,
pub input_cursor_position: u16,
input_idx: usize,
input_cursor_position: u16,
}
impl Default for TableFilterComponent {

@ -12,8 +12,8 @@ use tui::{
};
pub struct TableStatusComponent {
pub rows_count: u64,
pub table: Option<Table>,
rows_count: u64,
table: Option<Table>,
}
impl Default for TableStatusComponent {
@ -31,7 +31,7 @@ impl TableStatusComponent {
self.table = Some(table);
}
pub fn status_str(&self) -> Vec<String> {
fn status_str(&self) -> Vec<String> {
if let Some(table) = self.table.as_ref() {
return vec![
format!(

@ -11,7 +11,7 @@ use tui::{
};
pub struct TableValueComponent {
pub value: String,
value: String,
}
impl TableValueComponent {

@ -9,10 +9,10 @@ pub struct UserConfig {
#[derive(Debug, Deserialize, Clone)]
pub struct Connection {
pub name: Option<String>,
pub user: String,
pub host: String,
pub port: u64,
name: Option<String>,
user: String,
host: String,
port: u64,
pub database: Option<String>,
}

Loading…
Cancel
Save