-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: Use the conventional comment syntax #174
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
21f9f0d
change the comment syntax from /* */ to ///
Muhammad-Owais-Warsi 7900ad9
remove C-type @return and @param lines
Muhammad-Owais-Warsi a53ca00
remove C-type @return and @param lines
Muhammad-Owais-Warsi e2a7c52
remove unecessary lines
Muhammad-Owais-Warsi a15aff6
add inline comments styles inside the functions
Muhammad-Owais-Warsi f0d0354
format
Muhammad-Owais-Warsi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,10 @@ use std::sync::mpsc::Sender; | |
use termion::event::Key; | ||
use unicode_width::UnicodeWidthStr; | ||
|
||
/* Table header of the module table */ | ||
/// Table header of the module table | ||
pub const TABLE_HEADER: &[&str] = &[" Module", "Size", "Used by"]; | ||
|
||
/* Available options in the module management menu */ | ||
/// Available options in the module management menu | ||
const OPTIONS: &[(&str, &str)] = &[ | ||
("unload", "Unload the module"), | ||
("reload", "Reload the module"), | ||
|
@@ -36,7 +36,7 @@ const OPTIONS: &[(&str, &str)] = &[ | |
("clear", "Clear the ring buffer"), | ||
]; | ||
|
||
/* Supported directions of scrolling */ | ||
/// Supported directions of scrolling | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
pub enum ScrollDirection { | ||
Up, | ||
|
@@ -48,11 +48,10 @@ pub enum ScrollDirection { | |
} | ||
|
||
impl ScrollDirection { | ||
/** | ||
* Return iterator of the available scroll directions. | ||
* | ||
* @return Iter | ||
*/ | ||
|
||
/// Return iterator of the available scroll directions. | ||
|
||
|
||
#[allow(dead_code)] | ||
pub fn iter() -> Iter<'static, ScrollDirection> { | ||
[ | ||
|
@@ -67,7 +66,7 @@ impl ScrollDirection { | |
} | ||
} | ||
|
||
/* Main blocks of the terminal */ | ||
/// Main blocks of the terminal | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Sequence)] | ||
pub enum Block { | ||
|
@@ -77,14 +76,14 @@ pub enum Block { | |
Activities, | ||
} | ||
|
||
/* Sizes of the terminal blocks */ | ||
/// Sizes of the terminal blocks | ||
pub struct BlockSize { | ||
pub input: u16, | ||
pub info: u16, | ||
pub activities: u16, | ||
} | ||
|
||
/* Default initialization values for BlockSize */ | ||
/// Default initialization values for BlockSize | ||
impl Default for BlockSize { | ||
fn default() -> Self { | ||
Self { | ||
|
@@ -95,7 +94,7 @@ impl Default for BlockSize { | |
} | ||
} | ||
|
||
/* User input mode */ | ||
/// User input mode | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Sequence)] | ||
pub enum InputMode { | ||
None, | ||
|
@@ -104,17 +103,16 @@ pub enum InputMode { | |
} | ||
|
||
impl InputMode { | ||
/** | ||
* Check if input mode is set. | ||
* | ||
* @return bool | ||
*/ | ||
|
||
/// Check if input mode is set. | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary newlines There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just pushed , please check , hope I have not missed anything now 😅 |
||
pub fn is_none(self) -> bool { | ||
self == Self::None | ||
} | ||
} | ||
|
||
/* Implementation of Display for using InputMode members as string */ | ||
/// Implementation of Display for using InputMode members as string | ||
impl Display for InputMode { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
let mut input_mode = *self; | ||
|
@@ -128,7 +126,7 @@ impl Display for InputMode { | |
} | ||
} | ||
|
||
/* Application settings and related methods */ | ||
/// Application settings and related methods | ||
pub struct App { | ||
pub selected_block: Block, | ||
pub default_block: Block, | ||
|
@@ -143,13 +141,10 @@ pub struct App { | |
} | ||
|
||
impl App { | ||
/** | ||
* Create a new app instance. | ||
* | ||
* @param Block | ||
* @param Style | ||
* @return App | ||
*/ | ||
|
||
/// Create a new app instance. | ||
|
||
|
||
pub fn new(block: Block, style: Style) -> Self { | ||
Self { | ||
selected_block: block, | ||
|
@@ -178,7 +173,7 @@ impl App { | |
} | ||
} | ||
|
||
/* Reset app properties to default. */ | ||
/// Reset app properties to default. | ||
pub fn refresh(&mut self) { | ||
self.selected_block = self.default_block; | ||
self.block_size = BlockSize::default(); | ||
|
@@ -189,12 +184,10 @@ impl App { | |
self.show_options = false; | ||
} | ||
|
||
/** | ||
* Get style depending on the selected state of the block. | ||
* | ||
* @param block | ||
* @return TuiStyle | ||
*/ | ||
|
||
/// Get style depending on the selected state of the block. | ||
|
||
|
||
pub fn block_style(&self, block: Block) -> TuiStyle { | ||
if self.show_options { | ||
self.style.colored | ||
|
@@ -205,11 +198,11 @@ impl App { | |
} | ||
} | ||
|
||
/** | ||
* Get the size of the selected block. | ||
* | ||
* @return u16 | ||
*/ | ||
|
||
/// Get the size of the selected block. | ||
|
||
|
||
|
||
pub fn block_size(&mut self) -> &mut u16 { | ||
match self.selected_block { | ||
Block::ModuleInfo => &mut self.block_size.info, | ||
|
@@ -218,11 +211,10 @@ impl App { | |
} | ||
} | ||
|
||
/** | ||
* Get clipboard contents as String. | ||
* | ||
* @return contents | ||
*/ | ||
|
||
/// Get clipboard contents as String. | ||
|
||
|
||
pub fn get_clipboard_contents(&mut self) -> String { | ||
if let Some(clipboard) = self.clipboard.as_mut() { | ||
if let Ok(contents) = clipboard.get_contents() { | ||
|
@@ -232,11 +224,10 @@ impl App { | |
String::new() | ||
} | ||
|
||
/** | ||
* Set clipboard contents. | ||
* | ||
* @param contents | ||
*/ | ||
|
||
/// Set clipboard contents. | ||
|
||
|
||
pub fn set_clipboard_contents(&mut self, contents: &str) { | ||
if let Some(clipboard) = self.clipboard.as_mut() { | ||
if let Err(e) = clipboard.set_contents(contents.to_string()) { | ||
|
@@ -245,11 +236,10 @@ impl App { | |
} | ||
} | ||
|
||
/** | ||
* Show help message on the information block. | ||
* | ||
* @param kernel_modules | ||
*/ | ||
|
||
/// Show help message on the information block. | ||
|
||
|
||
pub fn show_help_message(&mut self, kernel_modules: &mut KernelModules<'_>) { | ||
let key_bindings: Vec<(&str, &str)> = util::KEY_BINDINGS.to_vec(); | ||
let mut help_text = Vec::new(); | ||
|
@@ -275,11 +265,10 @@ impl App { | |
.set(Text::from(help_text), help_text_raw.join("\n")); | ||
} | ||
|
||
/** | ||
* Show dependent modules on the information block. | ||
* | ||
* @param kernel_modules | ||
*/ | ||
|
||
/// Show dependent modules on the information block. | ||
|
||
|
||
#[allow(clippy::nonminimal_bool)] | ||
pub fn show_dependent_modules( | ||
&mut self, | ||
|
@@ -317,13 +306,11 @@ impl App { | |
} | ||
} | ||
|
||
/** | ||
* Draw a block according to the index. | ||
* | ||
* @param frame | ||
* @param area | ||
* @param kernel | ||
*/ | ||
|
||
/// Draw a block according to the index. | ||
|
||
|
||
|
||
pub fn draw_dynamic_block( | ||
&mut self, | ||
frame: &mut Frame, | ||
|
@@ -342,13 +329,11 @@ impl App { | |
} | ||
} | ||
|
||
/** | ||
* Draw a paragraph widget for using as user input. | ||
* | ||
* @param frame | ||
* @param area | ||
* @param tx | ||
*/ | ||
|
||
/// Draw a paragraph widget for using as user input. | ||
|
||
|
||
|
||
pub fn draw_user_input( | ||
&self, | ||
frame: &mut Frame, | ||
|
@@ -387,13 +372,11 @@ impl App { | |
); | ||
} | ||
|
||
/** | ||
* Draw a paragraph widget for showing the kernel information. | ||
* | ||
* @param frame | ||
* @param area | ||
* @param info | ||
*/ | ||
|
||
/// Draw a paragraph widget for showing the kernel information. | ||
|
||
|
||
|
||
pub fn draw_kernel_info(&self, frame: &mut Frame, area: Rect, info: &[String]) { | ||
frame.render_widget( | ||
Paragraph::new(Span::raw(&info[1])) | ||
|
@@ -417,20 +400,18 @@ impl App { | |
); | ||
} | ||
|
||
/** | ||
* Configure and draw kernel modules table. | ||
* | ||
* @param frame | ||
* @param area | ||
* @param kernel_modules | ||
*/ | ||
|
||
/// Configure and draw kernel modules table. | ||
|
||
|
||
|
||
pub fn draw_kernel_modules( | ||
&mut self, | ||
frame: &mut Frame, | ||
area: Rect, | ||
kernel_modules: &mut KernelModules<'_>, | ||
) { | ||
/* Filter the module list depending on the input query. */ | ||
/// Filter the module list depending on the input query. | ||
let mut kernel_module_list = kernel_modules.default_list.clone(); | ||
if (self.input_mode == InputMode::None | ||
|| self.input_mode == InputMode::Search) | ||
|
@@ -442,7 +423,7 @@ impl App { | |
.contains(&self.input_query.to_lowercase()) | ||
}); | ||
} | ||
/* Append '...' if dependent modules exceed the block width. */ | ||
/// Append '...' if dependent modules exceed the block width. | ||
let dependent_width = (area.width / 2).saturating_sub(7) as usize; | ||
for module in &mut kernel_module_list { | ||
if module[2].len() > dependent_width { | ||
|
@@ -451,13 +432,13 @@ impl App { | |
} | ||
} | ||
kernel_modules.list = kernel_module_list; | ||
/* Set the scroll offset for modules. */ | ||
/// Set the scroll offset for modules. | ||
let modules_scroll_offset = area | ||
.height | ||
.checked_sub(5) | ||
.and_then(|height| kernel_modules.index.checked_sub(height as usize)) | ||
.unwrap_or(0); | ||
/* Set selected state of the modules and render the table widget. */ | ||
/// Set selected state of the modules and render the table widget. | ||
frame.render_widget( | ||
Table::new( | ||
kernel_modules | ||
|
@@ -520,12 +501,11 @@ impl App { | |
} | ||
} | ||
|
||
/** | ||
* Draws the options menu as a popup. | ||
* | ||
* @param frame | ||
* @param area | ||
*/ | ||
|
||
/// Draws the options menu as a popup. | ||
|
||
|
||
|
||
pub fn draw_options_menu( | ||
&mut self, | ||
frame: &mut Frame, | ||
|
@@ -603,13 +583,10 @@ impl App { | |
); | ||
} | ||
|
||
/** | ||
* Draw a paragraph widget for showing module information. | ||
* | ||
* @param frame | ||
* @param area | ||
* @param kernel_modules | ||
*/ | ||
|
||
/// Draw a paragraph widget for showing module information. | ||
|
||
|
||
pub fn draw_module_info( | ||
&self, | ||
frame: &mut Frame, | ||
|
@@ -651,13 +628,10 @@ impl App { | |
); | ||
} | ||
|
||
/** | ||
* Draw a paragraph widget for showing kernel activities. | ||
* | ||
* @param frame | ||
* @param area | ||
* @param kernel_logs | ||
*/ | ||
|
||
/// Draw a paragraph widget for showing kernel activities. | ||
|
||
|
||
pub fn draw_kernel_activities( | ||
&self, | ||
frame: &mut Frame, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also remove these extra newlines?